|
@@ -20,6 +20,7 @@ use Composer\DependencyResolver\Operation;
|
|
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
|
|
use Composer\Repository\PlatformRepository;
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
+use Symfony\Component\Console\Input\InputOption;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
/**
|
|
@@ -32,6 +33,10 @@ class DebugPackagesCommand extends Command
|
|
|
$this
|
|
|
->setName('debug:packages')
|
|
|
->setDescription('Lists all existing packages and their version')
|
|
|
+ ->setDefinition(array(
|
|
|
+ new InputOption('local', null, InputOption::VALUE_NONE, 'list locally installed packages only'),
|
|
|
+ new InputOption('platform', null, InputOption::VALUE_NONE, 'list platform packages only'),
|
|
|
+ ))
|
|
|
->setHelp(<<<EOT
|
|
|
<info>php composer.phar debug:packages</info>
|
|
|
|
|
@@ -45,18 +50,40 @@ EOT
|
|
|
$composer = $this->getComposer();
|
|
|
|
|
|
// create local repo, this contains all packages that are installed in the local project
|
|
|
- $localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
|
|
+ $localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
|
|
// create installed repo, this contains all local packages + platform packages (php & extensions)
|
|
|
- $installedRepo = new PlatformRepository($localRepo);
|
|
|
+ $installedRepo = new PlatformRepository($localRepo);
|
|
|
+
|
|
|
+ if ($input->getOption('local')) {
|
|
|
+ foreach ($localRepo->getPackages() as $package) {
|
|
|
+ $output->writeln('<info>local:</info> ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getVersion() . ')</comment>');
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($input->getOption('platform')) {
|
|
|
+ $repos = array_diff($installedRepo->getPackages(), $localRepo->getPackages());
|
|
|
+ foreach ($repos as $package) {
|
|
|
+ $output->writeln('<info>plattform:</info> ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getVersion() . ')</comment>');
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
foreach ($installedRepo->getPackages() as $package) {
|
|
|
- $output->writeln('installed: '.$package->getPrettyName().' '.$package->getPrettyVersion().' ('.$package->getName().' '.$package->getVersion().')');
|
|
|
+ if ($localRepo->hasPackage($package)) {
|
|
|
+ $output->writeln('<info>installed:</info> ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getVersion() . ')</comment>');
|
|
|
+ } else {
|
|
|
+ $output->writeln('<info>platform:</info> ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getName() . ' ' . $package->getVersion() . ')</comment>');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
foreach ($composer->getRepositoryManager()->getRepositories() as $repository) {
|
|
|
foreach ($repository->getPackages() as $package) {
|
|
|
- $output->writeln('available: '.$package->getPrettyName().' '.$package->getPrettyVersion().' ('.$package->getName().' '.$package->getVersion().')');
|
|
|
+ $output->writeln('<comment>available:</comment> ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getName() . ' ' . $package->getVersion() . ')</comment>');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+}
|