Merge pull request #5552 from fvdb/add-minor-only-option
Added minor-only option to show command to only show packages with minor updatespull/5639/head
commit
f3af3ede40
|
@ -333,6 +333,7 @@ php composer.phar show monolog/monolog 1.0.2
|
||||||
* **--name-only (-N):** List package names only.
|
* **--name-only (-N):** List package names only.
|
||||||
* **--path (-P):** List package paths.
|
* **--path (-P):** List package paths.
|
||||||
* **--outdated (-o):** Implies --latest, but this lists *only* packages that have a newer version available.
|
* **--outdated (-o):** Implies --latest, but this lists *only* packages that have a newer version available.
|
||||||
|
* **--minor-only (-m):** Use with --latest. Only shows packages that have minor SemVer-compatible updates.
|
||||||
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
|
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
|
||||||
|
|
||||||
## outdated
|
## outdated
|
||||||
|
@ -352,6 +353,7 @@ The color coding is as such:
|
||||||
|
|
||||||
* **--all (-a):** Show all packages, not just outdated (alias for `composer show -l`).
|
* **--all (-a):** Show all packages, not just outdated (alias for `composer show -l`).
|
||||||
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
|
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
|
||||||
|
* **--minor-only (-m):** Only shows packages that have minor SemVer-compatible updates.
|
||||||
|
|
||||||
## browse / home
|
## browse / home
|
||||||
|
|
||||||
|
|
|
@ -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 that have minor SemVer-compatible updates. Use with the --outdated option.'),
|
||||||
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
|
||||||
|
@ -259,6 +260,7 @@ EOT
|
||||||
|
|
||||||
$showAllTypes = $input->getOption('all');
|
$showAllTypes = $input->getOption('all');
|
||||||
$showLatest = $input->getOption('latest');
|
$showLatest = $input->getOption('latest');
|
||||||
|
$showMinorOnly = $input->getOption('minor-only');
|
||||||
$indent = $showAllTypes ? ' ' : '';
|
$indent = $showAllTypes ? ' ' : '';
|
||||||
$latestPackages = array();
|
$latestPackages = array();
|
||||||
foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) {
|
foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) {
|
||||||
|
@ -276,7 +278,7 @@ EOT
|
||||||
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
|
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
|
||||||
if ($showLatest) {
|
if ($showLatest) {
|
||||||
|
|
||||||
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion);
|
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
|
||||||
if ($latestPackage === false) {
|
if ($latestPackage === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -711,10 +713,11 @@ EOT
|
||||||
* @param PackageInterface $package
|
* @param PackageInterface $package
|
||||||
* @param Composer $composer
|
* @param Composer $composer
|
||||||
* @param string $phpVersion
|
* @param string $phpVersion
|
||||||
|
* @param bool $minorOnly
|
||||||
*
|
*
|
||||||
* @return PackageInterface|null
|
* @return PackageInterface|null
|
||||||
*/
|
*/
|
||||||
private function findLatestPackage(PackageInterface $package, Composer $composer, $phpVersion)
|
private function findLatestPackage(PackageInterface $package, Composer $composer, $phpVersion, $minorOnly = false)
|
||||||
{
|
{
|
||||||
// find the latest version allowed in this pool
|
// find the latest version allowed in this pool
|
||||||
$name = $package->getName();
|
$name = $package->getName();
|
||||||
|
@ -735,6 +738,10 @@ EOT
|
||||||
$targetVersion = $package->getVersion();
|
$targetVersion = $package->getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($targetVersion === null && $minorOnly) {
|
||||||
|
$targetVersion = '^' . $package->getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
return $versionSelector->findBestCandidate($name, $targetVersion, $phpVersion, $bestStability);
|
return $versionSelector->findBestCandidate($name, $targetVersion, $phpVersion, $bestStability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue