From 2d36324e993f3149042452c42dc39ffc0d2ed2a0 Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Tue, 24 Jan 2017 19:45:16 +0100 Subject: [PATCH] streamline install progress messages --- src/Composer/Downloader/FileDownloader.php | 9 +++++++-- src/Composer/Downloader/FossilDownloader.php | 2 +- src/Composer/Downloader/GitDownloader.php | 4 ++-- src/Composer/Downloader/HgDownloader.php | 2 +- src/Composer/Downloader/PathDownloader.php | 8 ++++---- src/Composer/Downloader/PerforceDownloader.php | 2 +- src/Composer/Downloader/VcsDownloader.php | 4 ++-- src/Composer/Util/RemoteFilesystem.php | 8 ++++---- .../Test/Fixtures/functional/create-project-command.test | 2 +- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 8c8c13bc0..5e508e690 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -132,8 +132,9 @@ 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)) { + $this->io->writeError(': ', false); if (!$this->outputProgress) { - $this->io->writeError(' Downloading', false); + $this->io->writeError('Downloading', false); } // try to download 3 times then fail hard @@ -153,12 +154,16 @@ class FileDownloader implements DownloaderInterface } } + if (!$this->outputProgress) { + $this->io->writeError(' (100%)', false); + } + if ($this->cache) { $this->lastCacheWrites[$package->getName()] = $cacheKey; $this->cache->copyFrom($cacheKey, $fileName); } } else { - $this->io->writeError(' Loading from cache', false); + $this->io->writeError(' from cache', false); } if (!file_exists($fileName)) { diff --git a/src/Composer/Downloader/FossilDownloader.php b/src/Composer/Downloader/FossilDownloader.php index 72b09ce8c..63839df65 100644 --- a/src/Composer/Downloader/FossilDownloader.php +++ b/src/Composer/Downloader/FossilDownloader.php @@ -31,7 +31,7 @@ class FossilDownloader extends VcsDownloader $url = ProcessExecutor::escape($url); $ref = ProcessExecutor::escape($package->getSourceReference()); $repoFile = $path . '.fossil'; - $this->io->writeError(" Cloning ".$package->getSourceReference()); + $this->io->writeError("Cloning ".$package->getSourceReference()); $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile)); if (0 !== $this->process->execute($command, $ignoredOutput)) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 748016f92..2c76fd717 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -49,7 +49,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface // --dissociate option is only available since git 2.3.0-rc0 $gitVersion = $this->gitUtil->getVersion(); - $msg = " Cloning ".$this->getShortHash($ref); + $msg = "Cloning ".$this->getShortHash($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); @@ -57,7 +57,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface $this->gitUtil->syncMirror($url, $cachePath); if (is_dir($cachePath)) { $cacheOptions = sprintf('--dissociate --reference %s ', ProcessExecutor::escape($cachePath)); - $msg = " Cloning ".$this->getShortHash($ref).' from cache'; + $msg = "Cloning ".$this->getShortHash($ref).' from cache'; } } catch (\RuntimeException $e) {} } diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index a69d654ae..a7a42e62c 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -30,7 +30,7 @@ class HgDownloader extends VcsDownloader $url = ProcessExecutor::escape($url); $ref = ProcessExecutor::escape($package->getSourceReference()); - $this->io->writeError(" Cloning ".$package->getSourceReference()); + $this->io->writeError("Cloning ".$package->getSourceReference()); $command = sprintf('hg clone %s %s', $url, ProcessExecutor::escape($path)); if (0 !== $this->process->execute($command, $ignoredOutput)) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index cde32f4a6..6c090a171 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -77,7 +77,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter if ($output) { $this->io->writeError(sprintf( - ' - Installing %s (%s)', + ' - Installing %s (%s): ', $package->getName(), $package->getFullPrettyVersion() ), false); @@ -88,8 +88,8 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter try { if (Platform::isWindows()) { // Implement symlinks as NTFS junctions on Windows + $this->io->writeError(sprintf('Junctioning from %s', $url), false); $this->filesystem->junction($realUrl, $path); - $this->io->writeError(sprintf(' Junctioned from %s', $url), false); } else { $absolutePath = $path; if (!$this->filesystem->isAbsolutePath($absolutePath)) { @@ -97,8 +97,8 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter } $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl); $path = rtrim($path, "/"); + $this->io->writeError(sprintf('Symlinking from %s', $url), false); $fileSystem->symlink($shortestPath, $path); - $this->io->writeError(sprintf(' Symlinked from %s', $url), false); } } catch (IOException $e) { if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) { @@ -114,8 +114,8 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter // Fallback if symlink failed or if symlink is not allowed for the package if (self::STRATEGY_MIRROR == $currentStrategy) { + $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false); $fileSystem->mirror($realUrl, $path); - $this->io->writeError(sprintf('%s Mirrored from %s', $isFallback ? ' ' : '', $url), false); } $this->io->writeError(''); diff --git a/src/Composer/Downloader/PerforceDownloader.php b/src/Composer/Downloader/PerforceDownloader.php index ff1cc10c6..09980e8e9 100644 --- a/src/Composer/Downloader/PerforceDownloader.php +++ b/src/Composer/Downloader/PerforceDownloader.php @@ -32,7 +32,7 @@ class PerforceDownloader extends VcsDownloader $ref = $package->getSourceReference(); $label = $this->getLabelFromSourceReference($ref); - $this->io->writeError(' Cloning ' . $ref); + $this->io->writeError('Cloning ' . $ref); $this->initPerforce($package, $path, $url); $this->perforce->setStream($ref); $this->perforce->p4Login(); diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index f779bead1..cdc63e5ec 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -60,7 +60,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information'); } - $this->io->writeError(" - Installing " . $package->getName() . " (" . $package->getFullPrettyVersion() . ")", false); + $this->io->writeError(" - Installing " . $package->getName() . " (" . $package->getFullPrettyVersion() . "): ", false); $this->filesystem->emptyDirectory($path); $urls = $package->getSourceUrls(); @@ -130,7 +130,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa $to = $target->getFullPrettyVersion(); } - $this->io->writeError(" - Updating " . $name . " (" . $from . " => " . $to . ")", false); + $this->io->writeError(" - Updating " . $name . " (" . $from . " => " . $to . "): ", false); $this->cleanChanges($initial, $path, true); $urls = $target->getSourceUrls(); diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 5b137686d..c989315b0 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -276,7 +276,7 @@ class RemoteFilesystem } if ($this->progress && !$isRedirect) { - $this->io->writeError(" Downloading: Connecting...", false); + $this->io->writeError("Downloading (connecting...)", false); } $errorMessage = ''; @@ -367,7 +367,7 @@ class RemoteFilesystem if ($statusCode && $statusCode >= 400 && $statusCode <= 599) { if (!$this->retry) { if ($this->progress && !$this->retry && !$isRedirect) { - $this->io->overwriteError(" Downloading: Failed", false); + $this->io->overwriteError("Downloading (failed)", false); } $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode); @@ -380,7 +380,7 @@ class RemoteFilesystem } if ($this->progress && !$this->retry && !$isRedirect) { - $this->io->overwriteError(" Downloading: ".($result === false ? 'Failed' : '100%'), false); + $this->io->overwriteError("Downloading (".($result === false ? 'failed' : '100%)'), false); } // decode gzip @@ -567,7 +567,7 @@ class RemoteFilesystem if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) { $this->lastProgress = $progression; - $this->io->overwriteError(" Downloading: $progression%", false); + $this->io->overwriteError("Downloading ($progression%)", false); } } break; diff --git a/tests/Composer/Test/Fixtures/functional/create-project-command.test b/tests/Composer/Test/Fixtures/functional/create-project-command.test index 1f2f36f1e..35c343355 100644 --- a/tests/Composer/Test/Fixtures/functional/create-project-command.test +++ b/tests/Composer/Test/Fixtures/functional/create-project-command.test @@ -2,7 +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 3b4bc2a96f + - Installing seld/jsonlint (1.0.0): Cloning 3b4bc2a96f Created project in %testDir% Loading composer repositories with package information Updating dependencies (including require-dev)