Simplify composer output to take less lines
parent
d5d710421c
commit
4d082f77b8
|
@ -28,14 +28,14 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function download(PackageInterface $package, $path)
|
||||
public function download(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
$temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
|
||||
$retries = 3;
|
||||
while ($retries--) {
|
||||
$fileName = parent::download($package, $path);
|
||||
$fileName = parent::download($package, $path, $output);
|
||||
|
||||
$this->io->writeError(' Extracting archive', true, IOInterface::VERBOSE);
|
||||
$this->io->writeError(' Extracting archive', false, IOInterface::VERBOSE);
|
||||
|
||||
try {
|
||||
$this->filesystem->ensureDirectoryExists($temporaryDir);
|
||||
|
@ -76,6 +76,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
|
||||
// retry downloading if we have an invalid zip file
|
||||
if ($retries && $e instanceof \UnexpectedValueException && class_exists('ZipArchive') && $e->getCode() === \ZipArchive::ER_NOZIP) {
|
||||
$this->io->writeError('');
|
||||
if ($this->io->isDebug()) {
|
||||
$this->io->writeError(' Invalid zip file ('.$e->getMessage().'), retrying...');
|
||||
} else {
|
||||
|
@ -91,8 +92,10 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
break;
|
||||
}
|
||||
|
||||
if ($output) {
|
||||
$this->io->writeError('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -77,13 +77,15 @@ class FileDownloader implements DownloaderInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function download(PackageInterface $package, $path)
|
||||
public function download(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
if (!$package->getDistUrl()) {
|
||||
throw new \InvalidArgumentException('The given package is missing url information');
|
||||
}
|
||||
|
||||
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||
if ($output) {
|
||||
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)", false);
|
||||
}
|
||||
|
||||
$urls = $package->getDistUrls();
|
||||
while ($url = array_shift($urls)) {
|
||||
|
@ -95,7 +97,7 @@ class FileDownloader implements DownloaderInterface
|
|||
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
|
||||
} elseif (count($urls)) {
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
|
||||
$this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')', false);
|
||||
}
|
||||
|
||||
if (!count($urls)) {
|
||||
|
@ -104,8 +106,10 @@ class FileDownloader implements DownloaderInterface
|
|||
}
|
||||
}
|
||||
|
||||
if ($output) {
|
||||
$this->io->writeError('');
|
||||
}
|
||||
}
|
||||
|
||||
protected function doDownload(PackageInterface $package, $path, $url)
|
||||
{
|
||||
|
@ -129,7 +133,7 @@ class FileDownloader implements DownloaderInterface
|
|||
// download if we don't have it in cache or the cache is invalidated
|
||||
if (!$this->cache || ($checksum && $checksum !== $this->cache->sha1($cacheKey)) || !$this->cache->copyTo($cacheKey, $fileName)) {
|
||||
if (!$this->outputProgress) {
|
||||
$this->io->writeError(' Downloading');
|
||||
$this->io->writeError(' Downloading', false);
|
||||
}
|
||||
|
||||
// try to download 3 times then fail hard
|
||||
|
@ -143,6 +147,7 @@ class FileDownloader implements DownloaderInterface
|
|||
if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
|
||||
throw $e;
|
||||
}
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(' Download failed, retrying...', true, IOInterface::VERBOSE);
|
||||
usleep(500000);
|
||||
}
|
||||
|
@ -153,7 +158,7 @@ class FileDownloader implements DownloaderInterface
|
|||
$this->cache->copyFrom($cacheKey, $fileName);
|
||||
}
|
||||
} else {
|
||||
$this->io->writeError(' Loading from cache');
|
||||
$this->io->writeError(' Loading from cache', false);
|
||||
}
|
||||
|
||||
if (!file_exists($fileName)) {
|
||||
|
@ -197,16 +202,26 @@ class FileDownloader implements DownloaderInterface
|
|||
*/
|
||||
public function update(PackageInterface $initial, PackageInterface $target, $path)
|
||||
{
|
||||
$this->remove($initial, $path);
|
||||
$this->download($target, $path);
|
||||
$name = $target->getName();
|
||||
$from = $initial->getPrettyVersion();
|
||||
$to = $target->getPrettyVersion();
|
||||
|
||||
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)", false);
|
||||
|
||||
$this->remove($initial, $path, false);
|
||||
$this->download($target, $path, false);
|
||||
|
||||
$this->io->writeError('');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove(PackageInterface $package, $path)
|
||||
public function remove(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
if ($output) {
|
||||
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||
}
|
||||
if (!$this->filesystem->removeDirectory($path)) {
|
||||
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
$gitVersion = $this->gitUtil->getVersion();
|
||||
$msg = " Cloning ".$ref;
|
||||
if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=')) {
|
||||
$this->io->writeError('', true, IOInterface::DEBUG);
|
||||
$this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
|
||||
try {
|
||||
$this->gitUtil->syncMirror($url, $cachePath);
|
||||
|
|
|
@ -35,7 +35,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function download(PackageInterface $package, $path)
|
||||
public function download(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
$url = $package->getDistUrl();
|
||||
$realUrl = realpath($url);
|
||||
|
@ -75,18 +75,21 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
$fileSystem = new Filesystem();
|
||||
$this->filesystem->removeDirectory($path);
|
||||
|
||||
if ($output) {
|
||||
$this->io->writeError(sprintf(
|
||||
' - Installing <info>%s</info> (<comment>%s</comment>)',
|
||||
$package->getName(),
|
||||
$package->getFullPrettyVersion()
|
||||
));
|
||||
), false);
|
||||
}
|
||||
|
||||
$isFallback = false;
|
||||
if (self::STRATEGY_SYMLINK == $currentStrategy) {
|
||||
try {
|
||||
if (Platform::isWindows()) {
|
||||
// Implement symlinks as NTFS junctions on Windows
|
||||
$this->filesystem->junction($realUrl, $path);
|
||||
$this->io->writeError(sprintf(' Junctioned from %s', $url));
|
||||
$this->io->writeError(sprintf(' Junctioned from %s', $url), false);
|
||||
} else {
|
||||
$absolutePath = $path;
|
||||
if (!$this->filesystem->isAbsolutePath($absolutePath)) {
|
||||
|
@ -95,12 +98,14 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
$shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
|
||||
$path = rtrim($path, "/");
|
||||
$fileSystem->symlink($shortestPath, $path);
|
||||
$this->io->writeError(sprintf(' Symlinked from %s', $url));
|
||||
$this->io->writeError(sprintf(' Symlinked from %s', $url), false);
|
||||
}
|
||||
} catch (IOException $e) {
|
||||
if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
|
||||
$currentStrategy = self::STRATEGY_MIRROR;
|
||||
$isFallback = true;
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
|
||||
}
|
||||
|
@ -110,7 +115,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
// Fallback if symlink failed or if symlink is not allowed for the package
|
||||
if (self::STRATEGY_MIRROR == $currentStrategy) {
|
||||
$fileSystem->mirror($realUrl, $path);
|
||||
$this->io->writeError(sprintf(' Mirrored from %s', $url));
|
||||
$this->io->writeError(sprintf('%s Mirrored from %s', $isFallback ? ' ' : '', $url), false);
|
||||
}
|
||||
|
||||
$this->io->writeError('');
|
||||
|
@ -119,7 +124,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove(PackageInterface $package, $path)
|
||||
public function remove(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
/**
|
||||
* For junctions don't blindly rely on Filesystem::removeDirectory as it may be overzealous. If a process
|
||||
|
@ -127,9 +132,11 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
* is disastrous within a junction. So in that case we have no other real choice but to fail hard.
|
||||
*/
|
||||
if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
|
||||
if ($output) {
|
||||
$this->io->writeError(" - Removing junction for <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||
}
|
||||
if (!$this->filesystem->removeJunction($path)) {
|
||||
$this->io->writeError("<warn>Could not remove junction at " . $path . " - is another process locking it?</warn>");
|
||||
$this->io->writeError(" <warn>Could not remove junction at " . $path . " - is another process locking it?</warn>");
|
||||
throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||
}
|
||||
|
||||
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)", false);
|
||||
$this->filesystem->emptyDirectory($path);
|
||||
|
||||
$urls = $package->getSourceUrls();
|
||||
|
@ -104,8 +104,6 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->io->writeError('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +130,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
$to = $target->getFullPrettyVersion();
|
||||
}
|
||||
|
||||
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
|
||||
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)", false);
|
||||
|
||||
$this->cleanChanges($initial, $path, true);
|
||||
$urls = $target->getSourceUrls();
|
||||
|
@ -189,8 +187,6 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
if (!$urls && $exception) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$this->io->writeError('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@ class ZipDownloader extends ArchiveDownloader
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function download(PackageInterface $package, $path)
|
||||
public function download(PackageInterface $package, $path, $output = true)
|
||||
{
|
||||
if (null === self::$hasSystemUnzip) {
|
||||
$finder = new ExecutableFinder;
|
||||
|
@ -56,7 +56,7 @@ class ZipDownloader extends ArchiveDownloader
|
|||
throw new \RuntimeException($error);
|
||||
}
|
||||
|
||||
return parent::download($package, $path);
|
||||
return parent::download($package, $path, $output);
|
||||
}
|
||||
|
||||
protected function extract($file, $path)
|
||||
|
|
|
@ -575,10 +575,8 @@ class Installer
|
|||
// output non-alias ops when not executing operations (i.e. dry run), output alias ops in debug verbosity
|
||||
if (!$this->executeOperations && false === strpos($operation->getJobType(), 'Alias')) {
|
||||
$this->io->writeError(' - ' . $operation);
|
||||
$this->io->writeError('');
|
||||
} elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
|
||||
$this->io->writeError(' - ' . $operation);
|
||||
$this->io->writeError('');
|
||||
}
|
||||
|
||||
$this->installationManager->execute($localRepo, $operation);
|
||||
|
|
|
@ -325,6 +325,7 @@ class RemoteFilesystem
|
|||
if (isset($e) && !$this->retry) {
|
||||
if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
|
||||
$this->degradedMode = true;
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(array(
|
||||
'<error>'.$e->getMessage().'</error>',
|
||||
'<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
|
||||
|
@ -366,7 +367,7 @@ class RemoteFilesystem
|
|||
if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
|
||||
if (!$this->retry) {
|
||||
if ($this->progress && !$this->retry && !$isRedirect) {
|
||||
$this->io->overwriteError(" Downloading: <error>Failed</error>");
|
||||
$this->io->overwriteError(" Downloading: <error>Failed</error>", false);
|
||||
}
|
||||
|
||||
$e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
|
||||
|
@ -379,7 +380,7 @@ class RemoteFilesystem
|
|||
}
|
||||
|
||||
if ($this->progress && !$this->retry && !$isRedirect) {
|
||||
$this->io->overwriteError(" Downloading: ".($result === false ? '<error>Failed</error>' : '<comment>100%</comment>'));
|
||||
$this->io->overwriteError(" Downloading: ".($result === false ? '<error>Failed</error>' : '<comment>100%</comment>'), false);
|
||||
}
|
||||
|
||||
// decode gzip
|
||||
|
@ -405,6 +406,7 @@ class RemoteFilesystem
|
|||
|
||||
$this->degradedMode = true;
|
||||
$this->io->writeError(array(
|
||||
'',
|
||||
'<error>Failed to decode response: '.$e->getMessage().'</error>',
|
||||
'<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
|
||||
));
|
||||
|
@ -461,6 +463,7 @@ class RemoteFilesystem
|
|||
$this->retry = true;
|
||||
}
|
||||
} else {
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(sprintf(
|
||||
'<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
|
||||
PHP_VERSION
|
||||
|
@ -490,6 +493,7 @@ class RemoteFilesystem
|
|||
|
||||
if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
|
||||
$this->degradedMode = true;
|
||||
$this->io->writeError('');
|
||||
$this->io->writeError(array(
|
||||
'<error>'.$e->getMessage().'</error>',
|
||||
'<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
|
||||
|
@ -638,7 +642,8 @@ class RemoteFilesystem
|
|||
throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus);
|
||||
}
|
||||
|
||||
$this->io->overwriteError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
|
||||
$this->io->overwriteError('');
|
||||
$this->io->writeError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
|
||||
$username = $this->io->ask(' Username: ');
|
||||
$password = $this->io->askAndHideAnswer(' Password: ');
|
||||
$this->io->setAuthentication($this->originUrl, $username, $password);
|
||||
|
@ -681,6 +686,7 @@ class RemoteFilesystem
|
|||
// Handle subjectAltName on lesser PHP's.
|
||||
$certMap = $this->peerCertificateMap[$urlAuthority];
|
||||
|
||||
$this->io->writeError('', true, IOInterface::DEBUG);
|
||||
$this->io->writeError(sprintf(
|
||||
'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
|
||||
$certMap['cn'],
|
||||
|
@ -766,6 +772,7 @@ class RemoteFilesystem
|
|||
if (!empty($targetUrl)) {
|
||||
$this->redirects++;
|
||||
|
||||
$this->io->writeError('', true, IOInterface::DEBUG);
|
||||
$this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, $targetUrl), true, IOInterface::DEBUG);
|
||||
|
||||
$additionalOptions['redirects'] = $this->redirects;
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
create-project seld/jsonlint %testDir% 1.0.0 --prefer-source -n
|
||||
--EXPECT-ERROR--
|
||||
Installing seld/jsonlint (1.0.0)
|
||||
- Installing seld/jsonlint (1.0.0)
|
||||
Cloning 3b4bc2a96ff5d3fe6866bfe9dd0c845246705791
|
||||
|
||||
- Installing seld/jsonlint (1.0.0) Cloning 3b4bc2a96ff5d3fe6866bfe9dd0c845246705791
|
||||
Created project in %testDir%
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies (including require-dev)
|
||||
|
|
Loading…
Reference in New Issue