Add --no-dev option to check-platform-reqs command
parent
df2f2dc113
commit
c279c7ca96
|
@ -17,6 +17,7 @@ use Composer\Package\PackageInterface;
|
|||
use Composer\Semver\Constraint\Constraint;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
|
||||
|
@ -26,6 +27,9 @@ 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.'),
|
||||
))
|
||||
->setHelp(
|
||||
<<<EOT
|
||||
Checks that your PHP and extensions versions match the platform requirements of the installed packages.
|
||||
|
@ -40,22 +44,22 @@ EOT
|
|||
{
|
||||
$composer = $this->getComposer();
|
||||
|
||||
$repos = $composer->getRepositoryManager()->getLocalRepository();
|
||||
|
||||
$allPackages = array_merge(array($composer->getPackage()), $repos->getPackages());
|
||||
$requires = $composer->getPackage()->getDevRequires();
|
||||
$requires = $composer->getPackage()->getRequires();
|
||||
if (!$input->getOption('no-dev')) {
|
||||
$requires += $composer->getPackage()->getDevRequires();
|
||||
}
|
||||
foreach ($requires as $require => $link) {
|
||||
$requires[$require] = array($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var PackageInterface $package
|
||||
*/
|
||||
foreach ($allPackages as $package) {
|
||||
$locker = $composer->getLocker()
|
||||
->getLockedRepository(!$input->getOption('no-dev'));
|
||||
foreach ($locker->getPackages() as $package) {
|
||||
foreach ($package->getRequires() as $require => $link) {
|
||||
$requires[$require][] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($requires);
|
||||
|
||||
$platformRepo = new PlatformRepository(array(), array());
|
||||
|
@ -74,7 +78,7 @@ EOT
|
|||
$exitCode = 0;
|
||||
|
||||
/**
|
||||
* @var Link $require
|
||||
* @var Link[] $links
|
||||
*/
|
||||
foreach ($requires as $require => $links) {
|
||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $require)) {
|
||||
|
|
Loading…
Reference in New Issue