mirror of
https://github.com/composer/composer
synced 2025-05-09 08:32:56 +00:00
Take only displayed packages into account to determine column width
The ShowCommand was taking all packages into account when determining the max lengths used to display the width of each column. This was causing unnecessary hiding of columns in case of using a longer name or a longer version in a different package. This was especially visible when using the outdated command, as it applies filtering by default.
This commit is contained in:
parent
72476b62d4
commit
ce521e5697
1 changed files with 17 additions and 19 deletions
|
@ -329,23 +329,17 @@ EOT
|
|||
ksort($packages[$type]);
|
||||
|
||||
$nameLength = $versionLength = $latestLength = 0;
|
||||
foreach ($packages[$type] as $package) {
|
||||
if (is_object($package)) {
|
||||
$nameLength = max($nameLength, strlen($package->getPrettyName()));
|
||||
if ($showVersion) {
|
||||
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
|
||||
if ($showLatest) {
|
||||
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
|
||||
if ($latestPackage === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$latestPackages[$package->getPrettyName()] = $latestPackage;
|
||||
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
|
||||
if ($showLatest && $showVersion) {
|
||||
foreach ($packages[$type] as $package) {
|
||||
if (is_object($package)) {
|
||||
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
|
||||
if ($latestPackage === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$latestPackages[$package->getPrettyName()] = $latestPackage;
|
||||
}
|
||||
} else {
|
||||
$nameLength = max($nameLength, strlen($package));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,11 +351,6 @@ EOT
|
|||
$hasOutdatedPackages = false;
|
||||
|
||||
$viewData[$type] = array();
|
||||
$viewMetaData[$type] = array(
|
||||
'nameLength' => $nameLength,
|
||||
'versionLength' => $versionLength,
|
||||
'latestLength' => $latestLength,
|
||||
);
|
||||
foreach ($packages[$type] as $package) {
|
||||
$packageViewData = array();
|
||||
if (is_object($package)) {
|
||||
|
@ -376,12 +365,15 @@ EOT
|
|||
}
|
||||
|
||||
$packageViewData['name'] = $package->getPrettyName();
|
||||
$nameLength = max($nameLength, strlen($package->getPrettyName()));
|
||||
if ($writeVersion) {
|
||||
$packageViewData['version'] = $package->getFullPrettyVersion();
|
||||
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
|
||||
}
|
||||
if ($writeLatest && $latestPackage) {
|
||||
$packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
|
||||
$packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
|
||||
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
|
||||
}
|
||||
if ($writeDescription) {
|
||||
$packageViewData['description'] = $package->getDescription();
|
||||
|
@ -403,9 +395,15 @@ EOT
|
|||
}
|
||||
} else {
|
||||
$packageViewData['name'] = $package;
|
||||
$nameLength = max($nameLength, strlen($package));
|
||||
}
|
||||
$viewData[$type][] = $packageViewData;
|
||||
}
|
||||
$viewMetaData[$type] = array(
|
||||
'nameLength' => $nameLength,
|
||||
'versionLength' => $versionLength,
|
||||
'latestLength' => $latestLength,
|
||||
);
|
||||
if ($input->getOption('strict') && $hasOutdatedPackages) {
|
||||
$exitCode = 1;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue