Show suggestions from root package in suggest, and lists them in count only on first install of a project, fixes #8805
parent
6529fabb24
commit
9b8694bc0b
|
@ -71,7 +71,9 @@ EOT
|
||||||
$reporter = new SuggestedPackagesReporter($this->getIO());
|
$reporter = new SuggestedPackagesReporter($this->getIO());
|
||||||
|
|
||||||
$filter = $input->getArgument('packages');
|
$filter = $input->getArgument('packages');
|
||||||
foreach ($installedRepo->getPackages() as $package) {
|
$packages = $installedRepo->getPackages();
|
||||||
|
$packages[] = $composer->getPackage();
|
||||||
|
foreach ($packages as $package) {
|
||||||
if (!empty($filter) && !in_array($package->getName(), $filter)) {
|
if (!empty($filter) && !in_array($package->getName(), $filter)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,6 +203,8 @@ class Installer
|
||||||
throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
|
throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
|
||||||
|
|
||||||
// Force update if there is no lock file present
|
// Force update if there is no lock file present
|
||||||
if (!$this->update && !$this->locker->isLocked()) {
|
if (!$this->update && !$this->locker->isLocked()) {
|
||||||
$this->io->writeError('<warning>No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.</warning>');
|
$this->io->writeError('<warning>No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.</warning>');
|
||||||
|
@ -264,6 +266,9 @@ class Installer
|
||||||
$this->createPlatformRepo(false),
|
$this->createPlatformRepo(false),
|
||||||
new RootPackageRepository(clone $this->package),
|
new RootPackageRepository(clone $this->package),
|
||||||
));
|
));
|
||||||
|
if ($isFreshInstall) {
|
||||||
|
$this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
|
||||||
|
}
|
||||||
$this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
|
$this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class SuggestedPackagesReporter
|
||||||
*
|
*
|
||||||
* @param int $mode One of the MODE_* constants from this class
|
* @param int $mode One of the MODE_* constants from this class
|
||||||
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
||||||
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package will be shown
|
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
|
||||||
* @return SuggestedPackagesReporter
|
* @return SuggestedPackagesReporter
|
||||||
*/
|
*/
|
||||||
public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
||||||
|
@ -168,7 +168,7 @@ class SuggestedPackagesReporter
|
||||||
* Output number of new suggested packages and a hint to use suggest command.
|
* Output number of new suggested packages and a hint to use suggest command.
|
||||||
*
|
*
|
||||||
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
||||||
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package will be shown
|
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
|
||||||
* @return SuggestedPackagesReporter
|
* @return SuggestedPackagesReporter
|
||||||
*/
|
*/
|
||||||
public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
||||||
|
@ -183,7 +183,7 @@ class SuggestedPackagesReporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
* @param InstalledRepository $installedRepo If passed in, suggested packages which are installed already will be skipped
|
||||||
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package will be shown
|
* @param PackageInterface $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
|
||||||
|
@ -204,6 +204,7 @@ class SuggestedPackagesReporter
|
||||||
$sourceFilter = array_map(function ($link) {
|
$sourceFilter = array_map(function ($link) {
|
||||||
return $link->getTarget();
|
return $link->getTarget();
|
||||||
}, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
|
}, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
|
||||||
|
$sourceFilter[] = $onlyDependentsOf->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$suggestions = array();
|
$suggestions = array();
|
||||||
|
|
Loading…
Reference in New Issue