1
0
Fork 0

Only show direct dependencies suggestions by default, add --all flag to see all in suggest command, fixes #8660

pull/8684/head
Jordi Boggiano 2020-03-10 15:09:28 +01:00
parent 2445ef5e1f
commit 94e6cfc521
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 8 additions and 0 deletions

View File

@ -416,6 +416,8 @@ If you only want a list of suggested package names, use `--list`.
* **--by-package:** Groups output by suggesting package (default).
* **--by-suggestion:** Groups output by suggested package.
* **--all:** Show suggestions from all dependencies, including transitive ones (by
default only direct dependencies' suggestions are shown).
* **--list:** Show only list of suggested package names.
* **--no-dev:** Excludes suggestions from `require-dev` packages.

View File

@ -31,6 +31,7 @@ class SuggestsCommand extends BaseCommand
->setDefinition(array(
new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
@ -70,6 +71,11 @@ EOT
$reporter = new SuggestedPackagesReporter($this->getIO());
$filter = $input->getArgument('packages');
if (empty($filter) && !$input->getOption('all')) {
$filter = array_map(function ($link) {
return $link->getTarget();
}, array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()));
}
foreach ($installedRepo->getPackages() as $package) {
if (!empty($filter) && !in_array($package->getName(), $filter)) {
continue;