Show package descriptions in show/search commands, merge similar packages in show, fixes #366
parent
33c926c303
commit
5dba49af54
|
@ -19,6 +19,7 @@ use Composer\Repository\CompositeRepository;
|
|||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Repository\ComposerRepository;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
|
||||
/**
|
||||
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||
|
@ -56,10 +57,14 @@ EOT
|
|||
$repos = new CompositeRepository(array($installedRepo, new ComposerRepository(array('url' => 'http://packagist.org'))));
|
||||
}
|
||||
|
||||
$tokens = array_map('strtolower', $input->getArgument('tokens'));
|
||||
$tokens = $input->getArgument('tokens');
|
||||
$packages = array();
|
||||
|
||||
foreach ($repos->getPackages() as $package) {
|
||||
if ($package instanceof AliasPackage || isset($packages[$package->getName()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($tokens as $token) {
|
||||
if (!$this->matchPackage($package, $token)) {
|
||||
continue;
|
||||
|
@ -73,15 +78,16 @@ EOT
|
|||
$name = $package->getPrettyName();
|
||||
}
|
||||
|
||||
$version = $installedRepo->hasPackage($package) ? '<info>'.$package->getPrettyVersion().'</info>' : $package->getPrettyVersion();
|
||||
|
||||
$packages[$name][$package->getPrettyVersion()] = $version;
|
||||
$packages[$package->getName()] = array(
|
||||
'name' => $name,
|
||||
'description' => strtok($package->getDescription(), "\r\n")
|
||||
);
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($packages as $name => $versions) {
|
||||
$output->writeln($name .' <comment>:</comment> '. join(', ', $versions));
|
||||
foreach ($packages as $details) {
|
||||
$output->writeln($details['name'] .' <comment>:</comment> '. $details['description']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,15 +83,32 @@ EOT
|
|||
}
|
||||
|
||||
// list packages
|
||||
$packages = array();
|
||||
foreach ($repos->getPackages() as $package) {
|
||||
if ($platformRepo->hasPackage($package)) {
|
||||
$type = '<info>platform: </info> ';
|
||||
$type = '<info>platform</info>:';
|
||||
} elseif ($installedRepo->hasPackage($package)) {
|
||||
$type = '<info>installed:</info> ';
|
||||
$type = '<info>installed</info>:';
|
||||
} else {
|
||||
$type = '<comment>available:</comment> ';
|
||||
$type = '<comment>available</comment>:';
|
||||
}
|
||||
if (isset($packages[$type][$package->getName()])
|
||||
&& version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '>=')
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$packages[$type][$package->getName()] = $package;
|
||||
}
|
||||
|
||||
foreach (array('<info>platform</info>:', '<comment>available</comment>:', '<info>installed</info>:') as $type) {
|
||||
if (isset($packages[$type])) {
|
||||
$output->writeln($type);
|
||||
ksort($packages[$type]);
|
||||
foreach ($packages[$type] as $package) {
|
||||
$output->writeln(' '.$package->getPrettyName() .' <comment>:</comment> '. strtok($package->getDescription(), "\r\n"));
|
||||
}
|
||||
$output->writeln('');
|
||||
}
|
||||
$output->writeln($type . ' ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . '<comment> (' . $package->getVersion() . ')</comment>');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,14 +36,15 @@ class PlatformRepository extends ArrayRepository
|
|||
}
|
||||
|
||||
$php = new MemoryPackage('php', $version, $prettyVersion);
|
||||
$php->setDescription('The PHP interpreter');
|
||||
parent::addPackage($php);
|
||||
|
||||
foreach (get_loaded_extensions() as $ext) {
|
||||
if (in_array($ext, array('standard', 'Core'))) {
|
||||
foreach (get_loaded_extensions() as $name) {
|
||||
if (in_array($name, array('standard', 'Core'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reflExt = new \ReflectionExtension($ext);
|
||||
$reflExt = new \ReflectionExtension($name);
|
||||
try {
|
||||
$prettyVersion = $reflExt->getVersion();
|
||||
$version = $versionParser->normalize($prettyVersion);
|
||||
|
@ -52,7 +53,8 @@ class PlatformRepository extends ArrayRepository
|
|||
$version = $versionParser->normalize($prettyVersion);
|
||||
}
|
||||
|
||||
$ext = new MemoryPackage('ext-'.strtolower($ext), $version, $prettyVersion);
|
||||
$ext = new MemoryPackage('ext-'.$name, $version, $prettyVersion);
|
||||
$ext->setDescription('The '.$name.' PHP extension');
|
||||
parent::addPackage($ext);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue