Tweak validate command output to be slightly more readable, less colorful

main
Jordi Boggiano 3 years ago
parent 2eaf81c813
commit 90d72ca686
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -168,36 +168,62 @@ EOT
if ($errors) { if ($errors) {
$io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>'); $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
} elseif ($publishErrors) { } elseif ($publishErrors) {
$io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>'); $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
$io->writeError('<info>strict errors that make it unable to be published as a package:</info>'); $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
$doPrintSchemaUrl = $printSchemaUrl; $doPrintSchemaUrl = $printSchemaUrl;
} elseif ($warnings) { } elseif ($warnings) {
$io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>'); $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
$doPrintSchemaUrl = $printSchemaUrl; $doPrintSchemaUrl = $printSchemaUrl;
} elseif ($lockErrors) {
$io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
} else { } else {
$io->write('<info>' . $name . ' is valid</info>'); $io->write('<info>' . $name . ' is valid</info>');
// if ($lockErrors) then they will be displayed below
} }
if ($doPrintSchemaUrl) { if ($doPrintSchemaUrl) {
$io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>'); $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
} }
if ($errors) {
$errors = array_map(function ($err) {
return '- ' . $err;
}, $errors);
array_unshift($errors, '# General errors');
}
if ($warnings) {
$warnings = array_map(function ($err) {
return '- ' . $err;
}, $warnings);
array_unshift($warnings, '# General warnings');
}
// Avoid setting the exit code to 1 in case --strict and --no-check-publish/--no-check-lock are combined // Avoid setting the exit code to 1 in case --strict and --no-check-publish/--no-check-lock are combined
$extraWarnings = array(); $extraWarnings = array();
// If checking publish errors, display them as errors, otherwise just show them as warnings // If checking publish errors, display them as errors, otherwise just show them as warnings
if ($checkPublish) { if ($publishErrors) {
$errors = array_merge($errors, $publishErrors); $publishErrors = array_map(function ($err) {
} else { return '- ' . $err;
$extraWarnings = array_merge($extraWarnings, $publishErrors); }, $publishErrors);
if ($checkPublish) {
array_unshift($publishErrors, '# Publish errors');
$errors = array_merge($errors, $publishErrors);
} else {
array_unshift($publishErrors, '# Publish warnings');
$extraWarnings = array_merge($extraWarnings, $publishErrors);
}
} }
// If checking lock errors, display them as errors, otherwise just show them as warnings // If checking lock errors, display them as errors, otherwise just show them as warnings
if ($checkLock) { if ($lockErrors) {
$errors = array_merge($errors, $lockErrors); if ($checkLock) {
} else { array_unshift($lockErrors, '# Lock file errors');
$extraWarnings = array_merge($extraWarnings, $lockErrors); $errors = array_merge($errors, $lockErrors);
} else {
array_unshift($lockErrors, '# Lock file warnings');
$extraWarnings = array_merge($extraWarnings, $lockErrors);
}
} }
$messages = array( $messages = array(
@ -207,7 +233,11 @@ EOT
foreach ($messages as $style => $msgs) { foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) { foreach ($msgs as $msg) {
$io->writeError('<' . $style . '>' . $msg . '</' . $style . '>'); if (strpos($msg, '#') === 0) {
$io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
} else {
$io->writeError($msg);
}
} }
} }
} }

Loading…
Cancel
Save