1
0
Fork 0

Added minor-only option to only show packages with minor updates

pull/5552/head
Frank van den Brink 2016-07-26 09:39:56 +02:00
parent 3d920f8dbb
commit 4b0e40d482
No known key found for this signature in database
GPG Key ID: F6CBCF6CB657D94D
1 changed files with 17 additions and 5 deletions

View File

@ -71,6 +71,7 @@ class ShowCommand extends BaseCommand
new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages which have minor updates. Use in combination with --outdated'),
new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
))
->setHelp(<<<EOT
@ -314,6 +315,11 @@ EOT
if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
$latestPackackage = $latestPackages[$package->getPrettyName()];
}
if ($input->getOption('outdated') && $input->getOption('minor-only') && $latestPackackage && (!$this->isImmediateSemverCompliantUpgradeNeeded($package, $latestPackackage) || $latestPackackage->isAbandoned())) {
continue;
}
if ($input->getOption('outdated') && $latestPackackage && $latestPackackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackackage->isAbandoned()) {
continue;
}
@ -390,11 +396,7 @@ EOT
return 'info';
}
$constraint = $package->getVersion();
if (0 !== strpos($constraint, 'dev-')) {
$constraint = '^'.$constraint;
}
if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
if ($this->isImmediateSemverCompliantUpgradeNeeded($package, $latestPackage)) {
// print red as it needs an immediate semver-compliant upgrade
return 'highlight';
}
@ -403,6 +405,16 @@ EOT
return 'comment';
}
protected function isImmediateSemverCompliantUpgradeNeeded(PackageInterface $package, PackageInterface $latestPackage)
{
$constraint = $package->getVersion();
if (0 !== strpos($constraint, 'dev-')) {
$constraint = '^'.$constraint;
}
return $latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint);
}
/**
* finds a package by name and version if provided
*