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