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