Add --no-progress support and a few more fixes
parent
9c78eda7db
commit
085fe4e7e5
|
@ -23,6 +23,7 @@ use Composer\Plugin\CommandEvent;
|
||||||
use Composer\Plugin\PluginEvents;
|
use Composer\Plugin\PluginEvents;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
use Composer\Util\Loop;
|
use Composer\Util\Loop;
|
||||||
|
use Composer\Util\ProcessExecutor;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
@ -112,9 +113,10 @@ EOT
|
||||||
$archiveManager = $composer->getArchiveManager();
|
$archiveManager = $composer->getArchiveManager();
|
||||||
} else {
|
} else {
|
||||||
$factory = new Factory;
|
$factory = new Factory;
|
||||||
|
$process = new ProcessExecutor();
|
||||||
$httpDownloader = $factory->createHttpDownloader($io, $config);
|
$httpDownloader = $factory->createHttpDownloader($io, $config);
|
||||||
$downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader);
|
$downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
|
||||||
$archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader));
|
$archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($packageName) {
|
if ($packageName) {
|
||||||
|
|
|
@ -201,6 +201,8 @@ EOT
|
||||||
|
|
||||||
// install dependencies of the created project
|
// install dependencies of the created project
|
||||||
if ($noInstall === false) {
|
if ($noInstall === false) {
|
||||||
|
$composer->getInstallationManager()->setOutputProgress(!$noProgress);
|
||||||
|
|
||||||
$installer = Installer::create($io, $composer);
|
$installer = Installer::create($io, $composer);
|
||||||
$installer->setPreferSource($preferSource)
|
$installer->setPreferSource($preferSource)
|
||||||
->setPreferDist($preferDist)
|
->setPreferDist($preferDist)
|
||||||
|
@ -212,6 +214,10 @@ EOT
|
||||||
->setClassMapAuthoritative($config->get('classmap-authoritative'))
|
->setClassMapAuthoritative($config->get('classmap-authoritative'))
|
||||||
->setApcuAutoloader($config->get('apcu-autoloader'));
|
->setApcuAutoloader($config->get('apcu-autoloader'));
|
||||||
|
|
||||||
|
if (!$composer->getLocker()->isLocked()) {
|
||||||
|
$installer->setUpdate(true);
|
||||||
|
}
|
||||||
|
|
||||||
if ($disablePlugins) {
|
if ($disablePlugins) {
|
||||||
$installer->disablePlugins();
|
$installer->disablePlugins();
|
||||||
}
|
}
|
||||||
|
@ -405,7 +411,8 @@ EOT
|
||||||
->setPreferDist($preferDist);
|
->setPreferDist($preferDist);
|
||||||
|
|
||||||
$projectInstaller = new ProjectInstaller($directory, $dm, $fs);
|
$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->addInstaller($projectInstaller);
|
||||||
$im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
|
$im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
|
||||||
$im->notifyInstalls($io);
|
$im->notifyInstalls($io);
|
||||||
|
|
|
@ -106,6 +106,8 @@ EOT
|
||||||
|
|
||||||
$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
|
$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
|
||||||
|
|
||||||
|
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
|
|
||||||
$install
|
$install
|
||||||
->setDryRun($input->getOption('dry-run'))
|
->setDryRun($input->getOption('dry-run'))
|
||||||
->setVerbose($input->getOption('verbose'))
|
->setVerbose($input->getOption('verbose'))
|
||||||
|
|
|
@ -220,6 +220,8 @@ EOT
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
||||||
|
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
|
|
||||||
$install = Installer::create($io, $composer);
|
$install = Installer::create($io, $composer);
|
||||||
|
|
||||||
$updateDevMode = !$input->getOption('update-no-dev');
|
$updateDevMode = !$input->getOption('update-no-dev');
|
||||||
|
|
|
@ -286,6 +286,8 @@ EOT
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
||||||
|
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
|
|
||||||
$install = Installer::create($io, $composer);
|
$install = Installer::create($io, $composer);
|
||||||
|
|
||||||
$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
|
$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);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
||||||
|
$composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
|
|
||||||
$install = Installer::create($io, $composer);
|
$install = Installer::create($io, $composer);
|
||||||
|
|
||||||
$config = $composer->getConfig();
|
$config = $composer->getConfig();
|
||||||
|
|
|
@ -685,7 +685,7 @@ class Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->executeOperations) {
|
if ($this->executeOperations) {
|
||||||
$this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode);
|
$this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
|
||||||
} else {
|
} else {
|
||||||
foreach ($localRepoTransaction->getOperations() as $operation) {
|
foreach ($localRepoTransaction->getOperations() as $operation) {
|
||||||
// output op, but alias op only in debug verbosity
|
// output op, but alias op only in debug verbosity
|
||||||
|
|
|
@ -50,6 +50,8 @@ class InstallationManager
|
||||||
private $io;
|
private $io;
|
||||||
/** @var EventDispatcher */
|
/** @var EventDispatcher */
|
||||||
private $eventDispatcher;
|
private $eventDispatcher;
|
||||||
|
/** @var bool */
|
||||||
|
private $outputProgress;
|
||||||
|
|
||||||
public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
|
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 RepositoryInterface $repo repository in which to add/remove/update packages
|
||||||
* @param OperationInterface[] $operations operations to execute
|
* @param OperationInterface[] $operations operations to execute
|
||||||
* @param bool $devMode whether the install is being run in dev mode
|
* @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)
|
public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
|
||||||
{
|
{
|
||||||
|
@ -269,7 +271,14 @@ class InstallationManager
|
||||||
|
|
||||||
// execute all downloads first
|
// execute all downloads first
|
||||||
if (!empty($promises)) {
|
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
|
// 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
|
// execute all prepare => installs/updates/removes => cleanup steps
|
||||||
if (!empty($promises)) {
|
if (!empty($promises)) {
|
||||||
$progress = null;
|
$progress = null;
|
||||||
if ($io instanceof ConsoleIO && !$io->isDebug() && count($promises) > 1) {
|
if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
|
||||||
$progress = $io->getProgressBar();
|
$progress = $this->io->getProgressBar();
|
||||||
}
|
}
|
||||||
$this->loop->wait($promises, $progress);
|
$this->loop->wait($promises, $progress);
|
||||||
if ($progress) {
|
if ($progress) {
|
||||||
|
@ -485,6 +494,11 @@ class InstallationManager
|
||||||
return $installer->getInstallPath($package);
|
return $installer->getInstallPath($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setOutputProgress($outputProgress)
|
||||||
|
{
|
||||||
|
$this->outputProgress = $outputProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public function notifyInstalls(IOInterface $io)
|
public function notifyInstalls(IOInterface $io)
|
||||||
{
|
{
|
||||||
foreach ($this->notifiablePackages as $repoUrl => $packages) {
|
foreach ($this->notifiablePackages as $repoUrl => $packages) {
|
||||||
|
|
Loading…
Reference in New Issue