From 06bb3c91797b10474bf4ef403f5f9e855c5e7cae Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 4 Jan 2022 17:11:28 +0100 Subject: [PATCH] Add links to repo to show/outdated commands package lists, fixes #9367 --- src/Composer/Command/ShowCommand.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index f1f52f90b..112f057d9 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -326,6 +326,7 @@ EOT } // list packages + /** @var array> $packages */ $packages = array(); $packageFilterRegex = null; if (null !== $packageFilter) { @@ -437,6 +438,14 @@ EOT } $packageViewData['name'] = $package->getPrettyName(); + if ($format !== 'json' || true !== $input->getOption('name-only')) { + $packageViewData['homepage'] = $package->getHomepage(); + if (isset($package->getSupport()['source'])) { + $packageViewData['source'] = $package->getSupport()['source']; + } elseif (null !== $package->getSourceUrl()) { + $packageViewData['source'] = $package->getSourceUrl(); + } + } $nameLength = max($nameLength, strlen($package->getPrettyName())); if ($writeVersion) { $packageViewData['version'] = $package->getFullPrettyVersion(); @@ -528,7 +537,12 @@ EOT } foreach ($packages as $package) { - $io->write($indent . str_pad($package['name'], $nameLength, ' '), false); + $link = $package['source'] ?? $package['homepage'] ?? ''; + if ($link) { + $io->write($indent . '', '', $link).'>'.$package['name'].''. str_repeat(' ', $nameLength - strlen($package['name'])), false); + } else { + $io->write($indent . str_pad($package['name'], $nameLength, ' '), false); + } if (isset($package['version']) && $writeVersion) { $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false); }