Added minor-only option to only show packages with minor updates
parent
3d920f8dbb
commit
4b0e40d482
|
@ -71,6 +71,7 @@ class ShowCommand extends BaseCommand
|
||||||
new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
|
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('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('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'),
|
new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
|
||||||
))
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
|
@ -314,6 +315,11 @@ EOT
|
||||||
if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
|
if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
|
||||||
$latestPackackage = $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()) {
|
if ($input->getOption('outdated') && $latestPackackage && $latestPackackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackackage->isAbandoned()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -390,11 +396,7 @@ EOT
|
||||||
return 'info';
|
return 'info';
|
||||||
}
|
}
|
||||||
|
|
||||||
$constraint = $package->getVersion();
|
if ($this->isImmediateSemverCompliantUpgradeNeeded($package, $latestPackage)) {
|
||||||
if (0 !== strpos($constraint, 'dev-')) {
|
|
||||||
$constraint = '^'.$constraint;
|
|
||||||
}
|
|
||||||
if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
|
|
||||||
// print red as it needs an immediate semver-compliant upgrade
|
// print red as it needs an immediate semver-compliant upgrade
|
||||||
return 'highlight';
|
return 'highlight';
|
||||||
}
|
}
|
||||||
|
@ -403,6 +405,16 @@ EOT
|
||||||
return 'comment';
|
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
|
* finds a package by name and version if provided
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue