1
0
Fork 0

Add support for outdated command info without ANSI colors, fixes #6070

pull/6097/head^2
Jordi Boggiano 2017-01-22 19:59:50 +01:00
parent cf2838131f
commit d6ffe1fd1d
2 changed files with 10 additions and 4 deletions

View File

@ -39,13 +39,13 @@ class OutdatedCommand extends ShowCommand
->setHelp(<<<EOT ->setHelp(<<<EOT
The outdated command is just a proxy for `composer show -l` The outdated command is just a proxy for `composer show -l`
The color coding for dependency versions is as such: The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
- <info>green</info>: Dependency is in the latest version and is up to date. - <info>green</info> (=): Dependency is in the latest version and is up to date.
- <comment>yellow</comment>: Dependency has a new version available that includes backwards - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
compatibility breaks according to semver, so upgrade when you can but it compatibility breaks according to semver, so upgrade when you can but it
may involve work. may involve work.
- <highlight>red</highlight>: Dependency has a new version that is semver-compatible and you should upgrade it. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
EOT EOT

View File

@ -317,6 +317,9 @@ EOT
$writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width); $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width);
$writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width); $writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width);
$writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width); $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width);
if ($writeLatest && !$io->isDecorated()) {
$latestLength += 2;
}
$hasOutdatedPackages = false; $hasOutdatedPackages = false;
foreach ($packages[$type] as $package) { foreach ($packages[$type] as $package) {
if (is_object($package)) { if (is_object($package)) {
@ -339,6 +342,9 @@ EOT
if ($writeLatest && $latestPackackage) { if ($writeLatest && $latestPackackage) {
$latestVersion = $latestPackackage->getFullPrettyVersion(); $latestVersion = $latestPackackage->getFullPrettyVersion();
$style = $this->getVersionStyle($latestPackackage, $package); $style = $this->getVersionStyle($latestPackackage, $package);
if (!$io->isDecorated()) {
$latestVersion = str_replace(array('info', 'highlight', 'comment'), array('=', '!', '~'), $style) . ' ' . $latestVersion;
}
$io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false); $io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false);
} }