mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
Merge remote-tracking branch 'origin/master' into tls-config
This commit is contained in:
commit
5d015defb8
309 changed files with 14391 additions and 8355 deletions
|
@ -102,19 +102,19 @@ EOT
|
|||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$config = Factory::createConfig();
|
||||
$io = $this->getIO();
|
||||
|
||||
$preferSource = false;
|
||||
$preferDist = false;
|
||||
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist);
|
||||
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist, true);
|
||||
|
||||
if ($input->getOption('no-custom-installers')) {
|
||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||
$input->setOption('no-plugins', true);
|
||||
}
|
||||
|
||||
return $this->installProject(
|
||||
$this->getIO(),
|
||||
$io,
|
||||
$config,
|
||||
$input,
|
||||
$input->getArgument('package'),
|
||||
$input->getArgument('directory'),
|
||||
$input->getArgument('version'),
|
||||
|
@ -128,12 +128,11 @@ EOT
|
|||
$input->getOption('keep-vcs'),
|
||||
$input->getOption('no-progress'),
|
||||
$input->getOption('no-install'),
|
||||
$input->getOption('ignore-platform-reqs'),
|
||||
$input
|
||||
$input->getOption('ignore-platform-reqs')
|
||||
);
|
||||
}
|
||||
|
||||
public function installProject(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, InputInterface $input)
|
||||
public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disablePlugins = false, $noScripts = false, $keepVcs = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false)
|
||||
{
|
||||
$oldCwd = getcwd();
|
||||
|
||||
|
@ -147,11 +146,13 @@ EOT
|
|||
}
|
||||
|
||||
$composer = Factory::create($io, null, $disablePlugins);
|
||||
$composer->getDownloadManager()->setOutputProgress(!$noProgress);
|
||||
|
||||
$fs = new Filesystem();
|
||||
|
||||
if ($noScripts === false) {
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
|
||||
}
|
||||
|
||||
$rootPackageConfig = $composer->getConfig();
|
||||
|
@ -198,7 +199,7 @@ EOT
|
|||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$io->write('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
|
||||
$io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
|
||||
}
|
||||
|
||||
$hasVcs = false;
|
||||
|
@ -219,7 +220,7 @@ EOT
|
|||
|
||||
if ($noScripts === false) {
|
||||
// dispatch event
|
||||
$composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
|
||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
|
||||
}
|
||||
|
||||
chdir($oldCwd);
|
||||
|
@ -277,9 +278,12 @@ EOT
|
|||
$pool = new Pool($stability);
|
||||
$pool->addRepository($sourceRepo);
|
||||
|
||||
// using those 3 constants to build a version without the 'extra' bit that can contain garbage
|
||||
$phpVersion = PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION;
|
||||
|
||||
// find the latest version if there are multiple
|
||||
$versionSelector = new VersionSelector($pool);
|
||||
$package = $versionSelector->findBestCandidate($name, $packageVersion);
|
||||
$package = $versionSelector->findBestCandidate($name, $packageVersion, $phpVersion, $stability);
|
||||
|
||||
if (!$package) {
|
||||
throw new \InvalidArgumentException("Could not find package $name" . ($packageVersion ? " with version $packageVersion." : " with stability $stability."));
|
||||
|
@ -290,10 +294,20 @@ EOT
|
|||
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
|
||||
}
|
||||
|
||||
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
|
||||
// handler Ctrl+C for unix-like systems
|
||||
if (function_exists('pcntl_signal')) {
|
||||
declare (ticks = 100);
|
||||
pcntl_signal(SIGINT, function () use ($directory) {
|
||||
$fs = new Filesystem();
|
||||
$fs->removeDirectory($directory);
|
||||
exit(130);
|
||||
});
|
||||
}
|
||||
|
||||
$io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
|
||||
|
||||
if ($disablePlugins) {
|
||||
$io->write('<info>Plugins have been disabled.</info>');
|
||||
$io->writeError('<info>Plugins have been disabled.</info>');
|
||||
}
|
||||
|
||||
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
|
||||
|
@ -309,14 +323,15 @@ EOT
|
|||
$im = $this->createInstallationManager();
|
||||
$im->addInstaller($projectInstaller);
|
||||
$im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
|
||||
$im->notifyInstalls();
|
||||
$im->notifyInstalls($io);
|
||||
|
||||
$installedFromVcs = 'source' === $package->getInstallationSource();
|
||||
|
||||
$io->write('<info>Created project in ' . $directory . '</info>');
|
||||
$io->writeError('<info>Created project in ' . $directory . '</info>');
|
||||
chdir($directory);
|
||||
|
||||
putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion());
|
||||
$_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
|
||||
putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
|
||||
|
||||
return $installedFromVcs;
|
||||
}
|
||||
|
@ -337,18 +352,19 @@ EOT
|
|||
* Updated preferSource or preferDist based on the preferredInstall config option
|
||||
* @param Config $config
|
||||
* @param InputInterface $input
|
||||
* @param boolean $preferSource
|
||||
* @param boolean $preferDist
|
||||
* @param bool $preferSource
|
||||
* @param bool $preferDist
|
||||
*/
|
||||
protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist)
|
||||
protected function updatePreferredOptions(Config $config, InputInterface $input, &$preferSource, &$preferDist, $keepVcsRequiresPreferSource = false)
|
||||
{
|
||||
$preferSource = false;
|
||||
$preferDist = false;
|
||||
|
||||
switch ($config->get('preferred-install')) {
|
||||
case 'source':
|
||||
$preferSource = true;
|
||||
$preferDist = false;
|
||||
break;
|
||||
case 'dist':
|
||||
$preferSource = false;
|
||||
$preferDist = true;
|
||||
break;
|
||||
case 'auto':
|
||||
|
@ -357,8 +373,8 @@ EOT
|
|||
break;
|
||||
}
|
||||
|
||||
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
|
||||
$preferSource = $input->getOption('prefer-source');
|
||||
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->getOption('keep-vcs'))) {
|
||||
$preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->getOption('keep-vcs'));
|
||||
$preferDist = $input->getOption('prefer-dist');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue