1
0
Fork 0

Provide release-date/release-age and latest-release-date in composer outdated -A -f json (#12053)

pull/12063/head
Sam L 2024-07-26 10:21:02 -04:00 committed by GitHub
parent d53cf81429
commit d3d378184b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 6 deletions

View File

@ -670,6 +670,11 @@ parameters:
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in &&, array given on the right side\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in &&, array\\<Composer\\\\Package\\\\BasePackage\\|int\\> given on the right side\\.$#"
count: 1
@ -680,11 +685,6 @@ parameters:
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in &&, array\\<string, array\\<int, array\\<string, bool\\|string\\|null\\>\\>\\> given on the right side\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Only booleans are allowed in &&, string given on the left side\\.$#"
count: 1
@ -760,6 +760,11 @@ parameters:
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Parameter \\#1 \\$array \\(array\\<'available'\\|'installed'\\|'locked'\\|'platform', list\\<non\\-empty\\-array\\<literal\\-string&non\\-falsy\\-string, mixed\\>\\>\\>\\) to function array_filter contains falsy values only, the result will always be an empty array\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Parameter \\#1 \\$arrayTree of method Composer\\\\Command\\\\ShowCommand\\:\\:displayPackageTree\\(\\) expects array\\<int, array\\<string, array\\|string\\>\\>, array\\<int, array\\<string, array\\<int, array\\<string, array\\|string\\>\\>\\|string\\|null\\>\\> given\\.$#"
count: 2

View File

@ -43,6 +43,7 @@ use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Semver;
use Composer\Spdx\SpdxLicenses;
use Composer\Util\PackageInfo;
use DateTimeInterface;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
@ -493,7 +494,7 @@ EOT
$writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
$writeLatest = $writeVersion && $showLatest;
$writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
$writeReleaseDate = $writeLatest && $input->getOption('sort-by-age');
$writeReleaseDate = $writeLatest && ($input->getOption('sort-by-age') || $format === 'json');
$hasOutdatedPackages = false;
@ -550,8 +551,10 @@ EOT
$packageViewData['release-age'] = 'from '.$packageViewData['release-age'];
}
$releaseDateLength = max($releaseDateLength, strlen($packageViewData['release-age']));
$packageViewData['release-date'] = $package->getReleaseDate()->format(DateTimeInterface::ATOM);
} else {
$packageViewData['release-age'] = '';
$packageViewData['release-date'] = '';
}
}
if ($writeLatest && $latestPackage) {
@ -561,6 +564,12 @@ EOT
}
$packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
$latestLength = max($latestLength, strlen($packageViewData['latest']));
if ($latestPackage->getReleaseDate() !== null) {
$packageViewData['latest-release-date'] = $latestPackage->getReleaseDate()->format(DateTimeInterface::ATOM);
} else {
$packageViewData['latest-release-date'] = '';
}
} elseif ($writeLatest) {
$packageViewData['latest'] = '[none matched]';
$packageViewData['latest-status'] = 'up-to-date';