Add --no-progress support and a few more fixes

main
Jordi Boggiano 4 years ago
parent 9c78eda7db
commit 085fe4e7e5
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -23,6 +23,7 @@ use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Util\Filesystem;
use Composer\Util\Loop;
use Composer\Util\ProcessExecutor;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@ -112,9 +113,10 @@ EOT
$archiveManager = $composer->getArchiveManager();
} else {
$factory = new Factory;
$process = new ProcessExecutor();
$httpDownloader = $factory->createHttpDownloader($io, $config);
$downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader);
$archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader));
$downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
$archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
}
if ($packageName) {

@ -201,6 +201,8 @@ EOT
// install dependencies of the created project
if ($noInstall === false) {
$composer->getInstallationManager()->setOutputProgress(!$noProgress);
$installer = Installer::create($io, $composer);
$installer->setPreferSource($preferSource)
->setPreferDist($preferDist)
@ -212,6 +214,10 @@ EOT
->setClassMapAuthoritative($config->get('classmap-authoritative'))
->setApcuAutoloader($config->get('apcu-autoloader'));
if (!$composer->getLocker()->isLocked()) {
$installer->setUpdate(true);
}
if ($disablePlugins) {
$installer->disablePlugins();
}
@ -405,7 +411,8 @@ EOT
->setPreferDist($preferDist);
$projectInstaller = new ProjectInstaller($directory, $dm, $fs);
$im = $factory->createInstallationManager(new Loop($httpDownloader), $io);
$im = $factory->createInstallationManager(new Loop($httpDownloader, $process), $io);
$im->setOutputProgress(!$noProgress);
$im->addInstaller($projectInstaller);
$im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
$im->notifyInstalls($io);

@ -106,6 +106,8 @@ EOT
$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))

@ -220,6 +220,8 @@ EOT
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
$install = Installer::create($io, $composer);
$updateDevMode = !$input->getOption('update-no-dev');

@ -286,6 +286,8 @@ EOT
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
$install = Installer::create($io, $composer);
$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);

@ -180,6 +180,8 @@ EOT
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
$install = Installer::create($io, $composer);
$config = $composer->getConfig();

@ -685,7 +685,7 @@ class Installer
}
if ($this->executeOperations) {
$this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode);
$this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
} else {
foreach ($localRepoTransaction->getOperations() as $operation) {
// output op, but alias op only in debug verbosity

@ -50,6 +50,8 @@ class InstallationManager
private $io;
/** @var EventDispatcher */
private $eventDispatcher;
/** @var bool */
private $outputProgress;
public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
{
@ -174,7 +176,7 @@ class InstallationManager
* @param RepositoryInterface $repo repository in which to add/remove/update packages
* @param OperationInterface[] $operations operations to execute
* @param bool $devMode whether the install is being run in dev mode
* @param bool $operation whether to dispatch script events
* @param bool $runScripts whether to dispatch script events
*/
public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
{
@ -269,7 +271,14 @@ class InstallationManager
// execute all downloads first
if (!empty($promises)) {
$this->loop->wait($promises);
$progress = null;
if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
$progress = $this->io->getProgressBar();
}
$this->loop->wait($promises, $progress);
if ($progress) {
$progress->clear();
}
}
// execute operations in batches to make sure every plugin is installed in the
@ -377,8 +386,8 @@ class InstallationManager
// execute all prepare => installs/updates/removes => cleanup steps
if (!empty($promises)) {
$progress = null;
if ($io instanceof ConsoleIO && !$io->isDebug() && count($promises) > 1) {
$progress = $io->getProgressBar();
if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
$progress = $this->io->getProgressBar();
}
$this->loop->wait($promises, $progress);
if ($progress) {
@ -485,6 +494,11 @@ class InstallationManager
return $installer->getInstallPath($package);
}
public function setOutputProgress($outputProgress)
{
$this->outputProgress = $outputProgress;
}
public function notifyInstalls(IOInterface $io)
{
foreach ($this->notifiablePackages as $repoUrl => $packages) {

Loading…
Cancel
Save