From 5eb954eae00f78caa9b54ebbe87316c5babf64b7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 9 Jun 2022 11:45:32 +0200 Subject: [PATCH] Add --major-only flag to outdated/show commands to restrict the list to packages with major updates available, fixes #10439 (#10827) --- doc/03-cli.md | 12 +++++++++--- src/Composer/Command/OutdatedCommand.php | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 495cc59e0e0e..bda06ddfcca9 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -497,7 +497,7 @@ php composer.phar show monolog/monolog 1.0.2 ### Options -* **--all :** List all packages available in all your repositories. +* **--all:** List all packages available in all your repositories. * **--installed (-i):** List the packages that are installed (this is enabled by default, and deprecated). * **--locked:** List the locked packages from composer.lock. * **--platform (-p):** List only platform packages (php & extensions). @@ -508,8 +508,11 @@ php composer.phar show monolog/monolog 1.0.2 * **--tree (-t):** List your dependencies as a tree. If you pass a package name it will show the dependency tree for that package. * **--latest (-l):** List all installed packages including their latest version. * **--outdated (-o):** Implies --latest, but this lists *only* packages that have a newer version available. +* **--ignore:** Ignore specified package(s). Use it with the --outdated option if you don't want to be informed about new versions of some packages * **--no-dev:** Filters dev dependencies from the package list. -* **--minor-only (-m):** Use with --latest. Only shows packages that have minor SemVer-compatible updates. +* **--major-only (-M):** Use with --latest or --outdated. Only shows packages that have major SemVer-compatible updates. +* **--minor-only (-m):** Use with --latest or --outdated. Only shows packages that have minor SemVer-compatible updates. +* **--patch-only (-p):** Use with --latest or --outdated. Only shows packages that have patch-level SemVer-compatible updates. * **--direct (-D):** Restricts the list of packages to your direct dependencies. * **--strict:** Return a non-zero exit code when there are outdated packages. * **--format (-f):** Lets you pick between text (default) or json output format. @@ -536,10 +539,13 @@ The color coding is as such: ### Options -* **--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 --latest`). * **--direct (-D):** Restricts the list of packages to your direct dependencies. * **--strict:** Returns non-zero exit code if any package is outdated. +* **--ignore:** Ignore specified package(s). Use it if you don't want to be informed about new versions of some packages +* **--major-only (-M):** Only shows packages that have major SemVer-compatible updates. * **--minor-only (-m):** Only shows packages that have minor SemVer-compatible updates. +* **--patch-only (-p):** Only shows packages that have patch-level SemVer-compatible updates. * **--format (-f):** Lets you pick between text (default) or json output format. * **--no-dev:** Do not show outdated dev dependencies. * **--locked:** Shows updates for packages from the lock file, regardless of what is currently in vendor dir. diff --git a/src/Composer/Command/OutdatedCommand.php b/src/Composer/Command/OutdatedCommand.php index ffa9ba3af731..5d3a05b164d5 100644 --- a/src/Composer/Command/OutdatedCommand.php +++ b/src/Composer/Command/OutdatedCommand.php @@ -40,10 +40,11 @@ protected function configure(): void new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'), new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'), new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'), - new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'), - new InputOption('patch-only', 'p', InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates. Use with the --outdated option.'), + new InputOption('major-only', 'M', InputOption::VALUE_NONE, 'Show only packages that have major SemVer-compatible updates.'), + new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates.'), + new InputOption('patch-only', 'p', InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates.'), new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']), - new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Use it with the --outdated option if you don\'t want to be informed about new versions of some packages.', null, $this->suggestInstalledPackage()), + new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Use it if you don\'t want to be informed about new versions of some packages.', null, $this->suggestInstalledPackage()), new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'), new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'), @@ -84,6 +85,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('strict')) { $args['--strict'] = true; } + if ($input->getOption('major-only')) { + $args['--major-only'] = true; + } if ($input->getOption('minor-only')) { $args['--minor-only'] = true; }