1
0
Fork 0

Fix check-platform-reqs --no-dev to not require lock anymore

pull/9433/head
Jordi Boggiano 2020-11-06 20:39:27 +01:00
parent 2a8cc06ba2
commit f31564ef5b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 14 additions and 10 deletions

View File

@ -29,7 +29,7 @@ class CheckPlatformReqsCommand extends BaseCommand
$this->setName('check-platform-reqs')
->setDescription('Check that platform requirements are satisfied.')
->setDefinition(array(
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements, implies --lock.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
))
->setHelp(
@ -49,21 +49,22 @@ EOT
$composer = $this->getComposer();
$requires = array();
if ($input->getOption('no-dev') || $input->getOption('lock')) {
$removePackages = array();
if ($input->getOption('lock')) {
$this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
} else {
$this->getIO()->writeError('<warning>The --no-dev option implies --lock, checking platform requirements from lock file instead of vendor dir</warning>');
}
$installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
} else {
$installedRepo = $composer->getRepositoryManager()->getLocalRepository();
// fallback to lockfile if installed repo is empty
if (!$installedRepo->getPackages()) {
$this->getIO()->writeError('<warning>No vendor dir present, checking platform requirements from the lock file</warning>');
$installedRepo = $composer->getLocker()->getLockedRepository(true);
$this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
$installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
} else {
$this->getIO()->writeError('<info>Checking platform requirements for packages in the vendor dir</info>');
if ($input->getOption('no-dev')) {
$removePackages = $installedRepo->getDevPackageNames();
}
$this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
}
}
if (!$input->getOption('no-dev')) {
@ -76,6 +77,9 @@ EOT
$installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
foreach ($installedRepo->getPackages() as $package) {
if (in_array($package->getName(), $removePackages, true)) {
continue;
}
foreach ($package->getRequires() as $require => $link) {
$requires[$require][] = $link;
}