Merge remote-tracking branch 'alcohol/write-errors-to-stderr'
Conflicts: src/Composer/Command/LicensesCommand.phppull/3778/head
commit
e0ce559838
|
@ -92,7 +92,7 @@ class ClassMapGenerator
|
||||||
if (!isset($map[$class])) {
|
if (!isset($map[$class])) {
|
||||||
$map[$class] = $filePath;
|
$map[$class] = $filePath;
|
||||||
} elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
|
} elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
|
||||||
$io->write(
|
$io->writeError(
|
||||||
'<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
|
'<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
|
||||||
' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
|
' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
|
||||||
);
|
);
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Cache
|
||||||
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
||||||
if ($this->enabled && file_exists($this->root . $file)) {
|
if ($this->enabled && file_exists($this->root . $file)) {
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Reading '.$this->root . $file.' from cache');
|
$this->io->writeError('Reading '.$this->root . $file.' from cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_get_contents($this->root . $file);
|
return file_get_contents($this->root . $file);
|
||||||
|
@ -80,7 +80,7 @@ class Cache
|
||||||
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
$file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
|
||||||
|
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Writing '.$this->root . $file.' into cache');
|
$this->io->writeError('Writing '.$this->root . $file.' into cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -98,7 +98,7 @@ class Cache
|
||||||
@disk_free_space($this->root . dirname($file))
|
@disk_free_space($this->root . dirname($file))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->io->write($message);
|
$this->io->writeError($message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ class Cache
|
||||||
$this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
|
$this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
|
||||||
|
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Writing '.$this->root . $file.' into cache');
|
$this->io->writeError('Writing '.$this->root . $file.' into cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy($source, $this->root . $file);
|
return copy($source, $this->root . $file);
|
||||||
|
@ -139,7 +139,7 @@ class Cache
|
||||||
touch($this->root . $file);
|
touch($this->root . $file);
|
||||||
|
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Reading '.$this->root . $file.' from cache');
|
$this->io->writeError('Reading '.$this->root . $file.' from cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy($this->root . $file, $target);
|
return copy($this->root . $file, $target);
|
||||||
|
|
|
@ -34,7 +34,7 @@ EOT
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$output->writeln(<<<EOT
|
$this->getIO()->write(<<<EOT
|
||||||
<info>Composer - Package Management for PHP</info>
|
<info>Composer - Package Management for PHP</info>
|
||||||
<comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
|
<comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
|
||||||
See http://getcomposer.org/ for more information.</comment>
|
See http://getcomposer.org/ for more information.</comment>
|
||||||
|
|
|
@ -97,7 +97,7 @@ EOT
|
||||||
$package = $this->getComposer()->getPackage();
|
$package = $this->getComposer()->getPackage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->write('<info>Creating the archive.</info>');
|
$io->writeError('<info>Creating the archive.</info>');
|
||||||
$archiveManager->archive($package, $format, $dest);
|
$archiveManager->archive($package, $format, $dest);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -105,14 +105,14 @@ EOT
|
||||||
|
|
||||||
protected function selectPackage(IOInterface $io, $packageName, $version = null)
|
protected function selectPackage(IOInterface $io, $packageName, $version = null)
|
||||||
{
|
{
|
||||||
$io->write('<info>Searching for the specified package.</info>');
|
$io->writeError('<info>Searching for the specified package.</info>');
|
||||||
|
|
||||||
if ($composer = $this->getComposer(false)) {
|
if ($composer = $this->getComposer(false)) {
|
||||||
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
||||||
$repos = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
|
$repos = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
|
||||||
} else {
|
} else {
|
||||||
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
||||||
$io->write('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
|
$io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
|
||||||
$repos = new CompositeRepository($defaultRepos);
|
$repos = new CompositeRepository($defaultRepos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +125,14 @@ EOT
|
||||||
|
|
||||||
if (count($packages) > 1) {
|
if (count($packages) > 1) {
|
||||||
$package = reset($packages);
|
$package = reset($packages);
|
||||||
$io->write('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
|
$io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
|
||||||
$io->write('Alternatives were '.implode(', ', array_map(function ($p) { return $p->getPrettyString(); }, $packages)).'.');
|
$io->writeError('Alternatives were '.implode(', ', array_map(function ($p) { return $p->getPrettyString(); }, $packages)).'.');
|
||||||
$io->write('<comment>Please use a more specific constraint to pick a different package.</comment>');
|
$io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
|
||||||
} elseif ($packages) {
|
} elseif ($packages) {
|
||||||
$package = reset($packages);
|
$package = reset($packages);
|
||||||
$io->write('<info>Found an exact match '.$package->getPrettyString().'.</info>');
|
$io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
|
||||||
} else {
|
} else {
|
||||||
$io->write('<error>Could not find a package matching '.$packageName.'.</error>');
|
$io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,21 +51,21 @@ EOT
|
||||||
foreach ($cachePaths as $key => $cachePath) {
|
foreach ($cachePaths as $key => $cachePath) {
|
||||||
$cachePath = realpath($cachePath);
|
$cachePath = realpath($cachePath);
|
||||||
if (!$cachePath) {
|
if (!$cachePath) {
|
||||||
$io->write("<info>Cache directory does not exist ($key): $cachePath</info>");
|
$io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cache = new Cache($io, $cachePath);
|
$cache = new Cache($io, $cachePath);
|
||||||
if (!$cache->isEnabled()) {
|
if (!$cache->isEnabled()) {
|
||||||
$io->write("<info>Cache is not enabled ($key): $cachePath</info>");
|
$io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->write("<info>Clearing cache ($key): $cachePath</info>");
|
$io->writeError("<info>Clearing cache ($key): $cachePath</info>");
|
||||||
$cache->gc(0, 0);
|
$cache->gc(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->write('<info>All caches cleared.</info>');
|
$io->writeError('<info>All caches cleared.</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,15 +33,25 @@ class ConfigCommand extends Command
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Composer\Json\JsonFile
|
* @var JsonFile
|
||||||
*/
|
*/
|
||||||
protected $configFile;
|
protected $configFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Composer\Config\JsonConfigSource
|
* @var JsonConfigSource
|
||||||
*/
|
*/
|
||||||
protected $configSource;
|
protected $configSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var JsonFile
|
||||||
|
*/
|
||||||
|
protected $authConfigFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var JsonConfigSource
|
||||||
|
*/
|
||||||
|
protected $authConfigSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +257,7 @@ EOT
|
||||||
$value = json_encode($value);
|
$value = json_encode($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln($value);
|
$this->getIO()->write($value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -474,9 +484,9 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($rawVal) && $rawVal != $value) {
|
if (is_string($rawVal) && $rawVal != $value) {
|
||||||
$output->writeln('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
|
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
|
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ EOT
|
||||||
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist);
|
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist);
|
||||||
|
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} 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;
|
$hasVcs = false;
|
||||||
|
@ -288,10 +288,10 @@ EOT
|
||||||
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
|
$directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
|
$io->writeError('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
|
||||||
|
|
||||||
if ($disablePlugins) {
|
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'))) {
|
if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) {
|
||||||
|
@ -311,7 +311,7 @@ EOT
|
||||||
|
|
||||||
$installedFromVcs = 'source' === $package->getInstallationSource();
|
$installedFromVcs = 'source' === $package->getInstallationSource();
|
||||||
|
|
||||||
$io->write('<info>Created project in ' . $directory . '</info>');
|
$io->writeError('<info>Created project in ' . $directory . '</info>');
|
||||||
chdir($directory);
|
chdir($directory);
|
||||||
|
|
||||||
putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion());
|
putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion());
|
||||||
|
|
|
@ -96,9 +96,9 @@ EOT
|
||||||
|
|
||||||
if ($messages) {
|
if ($messages) {
|
||||||
sort($messages);
|
sort($messages);
|
||||||
$output->writeln($messages);
|
$this->getIO()->write($messages);
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<info>There is no installed package depending on "'.$needle.'".</info>');
|
$this->getIO()->writeError('<info>There is no installed package depending on "'.$needle.'".</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ EOT
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
||||||
$output->write('Checking composer.json: ');
|
$this->getIO()->write('Checking composer.json: ', false);
|
||||||
$this->outputResult($output, $this->checkComposerSchema());
|
$this->outputResult($this->checkComposerSchema());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($composer) {
|
if ($composer) {
|
||||||
|
@ -72,37 +72,37 @@ EOT
|
||||||
$this->rfs = new RemoteFilesystem($this->getIO(), $config);
|
$this->rfs = new RemoteFilesystem($this->getIO(), $config);
|
||||||
$this->process = new ProcessExecutor($this->getIO());
|
$this->process = new ProcessExecutor($this->getIO());
|
||||||
|
|
||||||
$output->write('Checking platform settings: ');
|
$this->getIO()->write('Checking platform settings: ', false);
|
||||||
$this->outputResult($output, $this->checkPlatform());
|
$this->outputResult($this->checkPlatform());
|
||||||
|
|
||||||
$output->write('Checking git settings: ');
|
$this->getIO()->write('Checking git settings: ', false);
|
||||||
$this->outputResult($output, $this->checkGit());
|
$this->outputResult($this->checkGit());
|
||||||
|
|
||||||
$output->write('Checking http connectivity: ');
|
$this->getIO()->write('Checking http connectivity: ', false);
|
||||||
$this->outputResult($output, $this->checkHttp());
|
$this->outputResult($this->checkHttp());
|
||||||
|
|
||||||
$opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
|
$opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
|
||||||
if (!empty($opts['http']['proxy'])) {
|
if (!empty($opts['http']['proxy'])) {
|
||||||
$output->write('Checking HTTP proxy: ');
|
$this->getIO()->write('Checking HTTP proxy: ', false);
|
||||||
$this->outputResult($output, $this->checkHttpProxy());
|
$this->outputResult($this->checkHttpProxy());
|
||||||
$output->write('Checking HTTP proxy support for request_fulluri: ');
|
$this->getIO()->write('Checking HTTP proxy support for request_fulluri: ', false);
|
||||||
$this->outputResult($output, $this->checkHttpProxyFullUriRequestParam());
|
$this->outputResult($this->checkHttpProxyFullUriRequestParam());
|
||||||
$output->write('Checking HTTPS proxy support for request_fulluri: ');
|
$this->getIO()->write('Checking HTTPS proxy support for request_fulluri: ', false);
|
||||||
$this->outputResult($output, $this->checkHttpsProxyFullUriRequestParam());
|
$this->outputResult($this->checkHttpsProxyFullUriRequestParam());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oauth = $config->get('github-oauth')) {
|
if ($oauth = $config->get('github-oauth')) {
|
||||||
foreach ($oauth as $domain => $token) {
|
foreach ($oauth as $domain => $token) {
|
||||||
$output->write('Checking '.$domain.' oauth access: ');
|
$this->getIO()->write('Checking '.$domain.' oauth access: ', false);
|
||||||
$this->outputResult($output, $this->checkGithubOauth($domain, $token));
|
$this->outputResult($this->checkGithubOauth($domain, $token));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$output->write('Checking github.com rate limit: ');
|
$this->getIO()->write('Checking github.com rate limit: ', false);
|
||||||
$rate = $this->getGithubRateLimit('github.com');
|
$rate = $this->getGithubRateLimit('github.com');
|
||||||
|
|
||||||
if (10 > $rate['remaining']) {
|
if (10 > $rate['remaining']) {
|
||||||
$output->writeln('<warning>WARNING</warning>');
|
$this->getIO()->write('<warning>WARNING</warning>');
|
||||||
$output->writeln(sprintf(
|
$this->getIO()->write(sprintf(
|
||||||
'<comment>Github has a rate limit on their API. '
|
'<comment>Github has a rate limit on their API. '
|
||||||
. 'You currently have <options=bold>%u</options=bold> '
|
. 'You currently have <options=bold>%u</options=bold> '
|
||||||
. 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
|
. 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
|
||||||
|
@ -112,15 +112,15 @@ EOT
|
||||||
$rate['limit']
|
$rate['limit']
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<info>OK</info>');
|
$this->getIO()->write('<info>OK</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->write('Checking disk free space: ');
|
$this->getIO()->write('Checking disk free space: ', false);
|
||||||
$this->outputResult($output, $this->checkDiskSpace($config));
|
$this->outputResult($this->checkDiskSpace($config));
|
||||||
|
|
||||||
$output->write('Checking composer version: ');
|
$this->getIO()->write('Checking composer version: ', false);
|
||||||
$this->outputResult($output, $this->checkVersion());
|
$this->outputResult($this->checkVersion());
|
||||||
|
|
||||||
return $this->failures;
|
return $this->failures;
|
||||||
}
|
}
|
||||||
|
@ -308,17 +308,17 @@ EOT
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function outputResult(OutputInterface $output, $result)
|
private function outputResult($result)
|
||||||
{
|
{
|
||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
$output->writeln('<info>OK</info>');
|
$this->getIO()->write('<info>OK</info>');
|
||||||
} else {
|
} else {
|
||||||
$this->failures++;
|
$this->failures++;
|
||||||
$output->writeln('<error>FAIL</error>');
|
$this->getIO()->write('<error>FAIL</error>');
|
||||||
if ($result instanceof \Exception) {
|
if ($result instanceof \Exception) {
|
||||||
$output->writeln('['.get_class($result).'] '.$result->getMessage());
|
$this->getIO()->write('['.get_class($result).'] '.$result->getMessage());
|
||||||
} elseif ($result) {
|
} elseif ($result) {
|
||||||
$output->writeln(trim($result));
|
$this->getIO()->write(trim($result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@ EOT
|
||||||
$optimize = $input->getOption('optimize') || $config->get('optimize-autoloader') || $config->get('classmap-authoritative');
|
$optimize = $input->getOption('optimize') || $config->get('optimize-autoloader') || $config->get('classmap-authoritative');
|
||||||
|
|
||||||
if ($optimize) {
|
if ($optimize) {
|
||||||
$output->writeln('<info>Generating optimized autoload files</info>');
|
$this->getIO()->writeError('<info>Generating optimized autoload files</info>');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<info>Generating autoload files</info>');
|
$this->getIO()->writeError('<info>Generating autoload files</info>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$generator = $composer->getAutoloadGenerator();
|
$generator = $composer->getAutoloadGenerator();
|
||||||
|
|
|
@ -72,7 +72,7 @@ EOT
|
||||||
// change to global dir
|
// change to global dir
|
||||||
$config = Factory::createConfig();
|
$config = Factory::createConfig();
|
||||||
chdir($config->get('home'));
|
chdir($config->get('home'));
|
||||||
$output->writeln('<info>Changed current directory to '.$config->get('home').'</info>');
|
$this->getIO()->writeError('<info>Changed current directory to '.$config->get('home').'</info>');
|
||||||
|
|
||||||
// create new input without "global" command prefix
|
// create new input without "global" command prefix
|
||||||
$input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
|
$input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
|
||||||
|
|
|
@ -71,7 +71,7 @@ EOT
|
||||||
|
|
||||||
if (!$package instanceof CompletePackageInterface) {
|
if (!$package instanceof CompletePackageInterface) {
|
||||||
$return = 1;
|
$return = 1;
|
||||||
$output->writeln('<warning>Package '.$packageName.' not found</warning>');
|
$this->getIO()->writeError('<warning>Package '.$packageName.' not found</warning>');
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -84,13 +84,13 @@ EOT
|
||||||
|
|
||||||
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
||||||
$return = 1;
|
$return = 1;
|
||||||
$output->writeln('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
|
$this->getIO()->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('show')) {
|
if ($input->getOption('show')) {
|
||||||
$output->writeln(sprintf('<info>%s</info>', $url));
|
$this->getIO()->write(sprintf('<info>%s</info>', $url));
|
||||||
} else {
|
} else {
|
||||||
$this->openBrowser($url);
|
$this->openBrowser($url);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ EOT
|
||||||
} elseif (0 === $osx) {
|
} elseif (0 === $osx) {
|
||||||
passthru('open ' . $url);
|
passthru('open ' . $url);
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->write('no suitable browser opening command found, open yourself: ' . $url);
|
$this->getIO()->writeError('no suitable browser opening command found, open yourself: ' . $url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,13 +117,13 @@ EOT
|
||||||
$json = $file->encode($options);
|
$json = $file->encode($options);
|
||||||
|
|
||||||
if ($input->isInteractive()) {
|
if ($input->isInteractive()) {
|
||||||
$output->writeln(array(
|
$this->getIO()->writeError(array(
|
||||||
'',
|
'',
|
||||||
$json,
|
$json,
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
|
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
|
||||||
$output->writeln('<error>Command aborted</error>');
|
$this->getIO()->writeError('<error>Command aborted</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,14 @@ EOT
|
||||||
|
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
$formatter = $this->getHelperSet()->get('formatter');
|
$formatter = $this->getHelperSet()->get('formatter');
|
||||||
$output->writeln(array(
|
$this->getIO()->writeError(array(
|
||||||
'',
|
'',
|
||||||
$formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
|
$formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
|
|
||||||
// namespace
|
// namespace
|
||||||
$output->writeln(array(
|
$this->getIO()->writeError(array(
|
||||||
'',
|
'',
|
||||||
'This command will guide you through creating your composer.json config.',
|
'This command will guide you through creating your composer.json config.',
|
||||||
'',
|
'',
|
||||||
|
@ -266,7 +266,7 @@ EOT
|
||||||
);
|
);
|
||||||
$input->setOption('license', $license);
|
$input->setOption('license', $license);
|
||||||
|
|
||||||
$output->writeln(array(
|
$this->getIO()->writeError(array(
|
||||||
'',
|
'',
|
||||||
'Define your dependencies.',
|
'Define your dependencies.',
|
||||||
''
|
''
|
||||||
|
@ -316,7 +316,7 @@ EOT
|
||||||
$version = $this->findBestVersionForPackage($input, $requirement['name']);
|
$version = $this->findBestVersionForPackage($input, $requirement['name']);
|
||||||
$requirement['version'] = $version;
|
$requirement['version'] = $version;
|
||||||
|
|
||||||
$output->writeln(sprintf(
|
$this->getIO()->writeError(sprintf(
|
||||||
'Using version <info>%s</info> for <info>%s</info>',
|
'Using version <info>%s</info> for <info>%s</info>',
|
||||||
$requirement['version'],
|
$requirement['version'],
|
||||||
$requirement['name']
|
$requirement['name']
|
||||||
|
@ -345,14 +345,14 @@ EOT
|
||||||
|
|
||||||
// no match, prompt which to pick
|
// no match, prompt which to pick
|
||||||
if (!$exactMatch) {
|
if (!$exactMatch) {
|
||||||
$output->writeln(array(
|
$this->getIO()->writeError(array(
|
||||||
'',
|
'',
|
||||||
sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
|
sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
|
|
||||||
$output->writeln($choices);
|
$this->getIO()->writeError($choices);
|
||||||
$output->writeln('');
|
$this->getIO()->writeError('');
|
||||||
|
|
||||||
$validator = function ($selection) use ($matches) {
|
$validator = function ($selection) use ($matches) {
|
||||||
if ('' === $selection) {
|
if ('' === $selection) {
|
||||||
|
@ -392,7 +392,7 @@ EOT
|
||||||
if (false === $constraint) {
|
if (false === $constraint) {
|
||||||
$constraint = $this->findBestVersionForPackage($input, $package);
|
$constraint = $this->findBestVersionForPackage($input, $package);
|
||||||
|
|
||||||
$output->writeln(sprintf(
|
$this->getIO()->writeError(sprintf(
|
||||||
'Using version <info>%s</info> for <info>%s</info>',
|
'Using version <info>%s</info> for <info>%s</info>',
|
||||||
$constraint,
|
$constraint,
|
||||||
$package
|
$package
|
||||||
|
|
|
@ -65,18 +65,18 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
if ($args = $input->getArgument('packages')) {
|
if ($args = $input->getArgument('packages')) {
|
||||||
$output->writeln('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
|
$this->getIO()->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('dev')) {
|
if ($input->getOption('dev')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
$this->getIO()->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||||
|
|
|
@ -69,11 +69,11 @@ EOT
|
||||||
|
|
||||||
switch ($format = $input->getOption('format')) {
|
switch ($format = $input->getOption('format')) {
|
||||||
case 'text':
|
case 'text':
|
||||||
$output->writeln('Name: <comment>'.$root->getPrettyName().'</comment>');
|
$this->getIO()->write('Name: <comment>'.$root->getPrettyName().'</comment>');
|
||||||
$output->writeln('Version: <comment>'.$versionParser->formatVersion($root).'</comment>');
|
$this->getIO()->write('Version: <comment>'.$versionParser->formatVersion($root).'</comment>');
|
||||||
$output->writeln('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
|
$this->getIO()->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
|
||||||
$output->writeln('Dependencies:');
|
$this->getIO()->write('Dependencies:');
|
||||||
$output->writeln('');
|
$this->getIO()->write('');
|
||||||
|
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
$table->setStyle('compact');
|
$table->setStyle('compact');
|
||||||
|
@ -98,7 +98,7 @@ EOT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln(JsonFile::encode(array(
|
$this->getIO()->write(JsonFile::encode(array(
|
||||||
'name' => $root->getPrettyName(),
|
'name' => $root->getPrettyName(),
|
||||||
'version' => $versionParser->formatVersion($root),
|
'version' => $versionParser->formatVersion($root),
|
||||||
'license' => $root->getLicense(),
|
'license' => $root->getLicense(),
|
||||||
|
|
|
@ -73,7 +73,7 @@ EOT
|
||||||
if (isset($composer[$type][$package])) {
|
if (isset($composer[$type][$package])) {
|
||||||
$json->removeLink($type, $package);
|
$json->removeLink($type, $package);
|
||||||
} elseif (isset($composer[$altType][$package])) {
|
} elseif (isset($composer[$altType][$package])) {
|
||||||
$output->writeln('<warning>'.$package.' could not be found in '.$type.' but it is present in '.$altType.'</warning>');
|
$this->getIO()->writeError('<warning>'.$package.' could not be found in '.$type.' but it is present in '.$altType.'</warning>');
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
if ($this->getIO()->isInteractive()) {
|
if ($this->getIO()->isInteractive()) {
|
||||||
if ($dialog->askConfirmation($output, $dialog->getQuestion('Do you want to remove it from '.$altType, 'yes', '?'), true)) {
|
if ($dialog->askConfirmation($output, $dialog->getQuestion('Do you want to remove it from '.$altType, 'yes', '?'), true)) {
|
||||||
|
@ -81,7 +81,7 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
|
$this->getIO()->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ EOT
|
||||||
|
|
||||||
$status = $install->run();
|
$status = $install->run();
|
||||||
if ($status !== 0) {
|
if ($status !== 0) {
|
||||||
$output->writeln("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
|
$this->getIO()->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
|
||||||
file_put_contents($jsonFile->getPath(), $composerBackup);
|
file_put_contents($jsonFile->getPath(), $composerBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,17 +67,17 @@ EOT
|
||||||
|
|
||||||
$newlyCreated = !file_exists($file);
|
$newlyCreated = !file_exists($file);
|
||||||
if (!file_exists($file) && !file_put_contents($file, "{\n}\n")) {
|
if (!file_exists($file) && !file_put_contents($file, "{\n}\n")) {
|
||||||
$output->writeln('<error>'.$file.' could not be created.</error>');
|
$this->getIO()->writeError('<error>'.$file.' could not be created.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
$output->writeln('<error>'.$file.' is not readable.</error>');
|
$this->getIO()->writeError('<error>'.$file.' is not readable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_writable($file)) {
|
if (!is_writable($file)) {
|
||||||
$output->writeln('<error>'.$file.' is not writable.</error>');
|
$this->getIO()->writeError('<error>'.$file.' is not writable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ EOT
|
||||||
$json->write($composerDefinition);
|
$json->write($composerDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('<info>'.$file.' has been '.($newlyCreated ? 'created' : 'updated').'</info>');
|
$this->getIO()->writeError('<info>'.$file.' has been '.($newlyCreated ? 'created' : 'updated').'</info>');
|
||||||
|
|
||||||
if ($input->getOption('no-update')) {
|
if ($input->getOption('no-update')) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -154,10 +154,10 @@ EOT
|
||||||
$status = $install->run();
|
$status = $install->run();
|
||||||
if ($status !== 0) {
|
if ($status !== 0) {
|
||||||
if ($newlyCreated) {
|
if ($newlyCreated) {
|
||||||
$output->writeln("\n".'<error>Installation failed, deleting '.$file.'.</error>');
|
$this->getIO()->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>');
|
||||||
unlink($json->getPath());
|
unlink($json->getPath());
|
||||||
} else {
|
} else {
|
||||||
$output->writeln("\n".'<error>Installation failed, reverting '.$file.' to its original content.</error>');
|
$this->getIO()->writeError("\n".'<error>Installation failed, reverting '.$file.' to its original content.</error>');
|
||||||
file_put_contents($json->getPath(), $composerBackup);
|
file_put_contents($json->getPath(), $composerBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
if ($input->getOption('list')) {
|
if ($input->getOption('list')) {
|
||||||
return $this->listScripts($input, $output);
|
return $this->listScripts();
|
||||||
} elseif (!$input->getArgument('script')) {
|
} elseif (!$input->getArgument('script')) {
|
||||||
throw new \RunTimeException('Missing required argument "script"');
|
throw new \RunTimeException('Missing required argument "script"');
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ EOT
|
||||||
return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
|
return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function listScripts(InputInterface $input, OutputInterface $output)
|
protected function listScripts()
|
||||||
{
|
{
|
||||||
$scripts = $this->getComposer()->getPackage()->getScripts();
|
$scripts = $this->getComposer()->getPackage()->getScripts();
|
||||||
|
|
||||||
|
@ -103,9 +103,9 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('<info>scripts:</info>');
|
$this->getIO()->writeError('<info>scripts:</info>');
|
||||||
foreach ($scripts as $name => $script) {
|
foreach ($scripts as $name => $script) {
|
||||||
$output->writeln(' ' . $name);
|
$this->getIO()->write(' ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -62,7 +62,7 @@ EOT
|
||||||
$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
|
$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
|
||||||
} else {
|
} else {
|
||||||
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
||||||
$output->writeln('No composer.json found in the current directory, showing packages from ' . implode(', ', array_keys($defaultRepos)));
|
$this->getIO()->writeError('No composer.json found in the current directory, showing packages from ' . implode(', ', array_keys($defaultRepos)));
|
||||||
$installedRepo = $platformRepo;
|
$installedRepo = $platformRepo;
|
||||||
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
|
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ EOT
|
||||||
$results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags);
|
$results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags);
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$output->writeln($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
|
$this->getIO()->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,13 +84,13 @@ EOT
|
||||||
$updateVersion = $input->getArgument('version') ?: $latestVersion;
|
$updateVersion = $input->getArgument('version') ?: $latestVersion;
|
||||||
|
|
||||||
if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
|
if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
|
||||||
$output->writeln('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
|
$this->getIO()->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Composer::VERSION === $updateVersion) {
|
if (Composer::VERSION === $updateVersion) {
|
||||||
$output->writeln('<info>You are already using composer version '.$updateVersion.'.</info>');
|
$this->getIO()->writeError('<info>You are already using composer version '.$updateVersion.'.</info>');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +104,11 @@ EOT
|
||||||
self::OLD_INSTALL_EXT
|
self::OLD_INSTALL_EXT
|
||||||
);
|
);
|
||||||
|
|
||||||
$output->writeln(sprintf("Updating to version <info>%s</info>.", $updateVersion));
|
$this->getIO()->writeError(sprintf("Updating to version <info>%s</info>.", $updateVersion));
|
||||||
$remoteFilename = $baseUrl . (preg_match('{^[0-9a-f]{40}$}', $updateVersion) ? '/composer.phar' : "/download/{$updateVersion}/composer.phar");
|
$remoteFilename = $baseUrl . (preg_match('{^[0-9a-f]{40}$}', $updateVersion) ? '/composer.phar' : "/download/{$updateVersion}/composer.phar");
|
||||||
$remoteFilesystem->copy(self::HOMEPAGE, $remoteFilename, $tempFilename, !$input->getOption('no-progress'));
|
$remoteFilesystem->copy(self::HOMEPAGE, $remoteFilename, $tempFilename, !$input->getOption('no-progress'));
|
||||||
if (!file_exists($tempFilename)) {
|
if (!file_exists($tempFilename)) {
|
||||||
$output->writeln('<error>The download of the new composer version failed for an unexpected reason</error>');
|
$this->getIO()->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -120,22 +120,22 @@ EOT
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
$file = (string) $file;
|
$file = (string) $file;
|
||||||
$output->writeln('<info>Removing: '.$file.'</info>');
|
$this->getIO()->writeError('<info>Removing: '.$file.'</info>');
|
||||||
$fs->remove($file);
|
$fs->remove($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
|
if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
|
||||||
$output->writeln('<error>The file is corrupted ('.$err->getMessage().').</error>');
|
$this->getIO()->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>');
|
||||||
$output->writeln('<error>Please re-run the self-update command to try again.</error>');
|
$this->getIO()->writeError('<error>Please re-run the self-update command to try again.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($backupFile)) {
|
if (file_exists($backupFile)) {
|
||||||
$output->writeln('Use <info>composer self-update --rollback</info> to return to version '.Composer::VERSION);
|
$this->getIO()->writeError('Use <info>composer self-update --rollback</info> to return to version '.Composer::VERSION);
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
|
$this->getIO()->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +160,9 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldFile = $rollbackDir . "/{$rollbackVersion}" . self::OLD_INSTALL_EXT;
|
$oldFile = $rollbackDir . "/{$rollbackVersion}" . self::OLD_INSTALL_EXT;
|
||||||
$output->writeln(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
|
$this->getIO()->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
|
||||||
if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
|
if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
|
||||||
$output->writeln('<error>The backup file was corrupted ('.$err->getMessage().') and has been removed.</error>');
|
$this->getIO()->writeError('<error>The backup file was corrupted ('.$err->getMessage().') and has been removed.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ EOT
|
||||||
} else {
|
} else {
|
||||||
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
||||||
$repos = new CompositeRepository($defaultRepos);
|
$repos = new CompositeRepository($defaultRepos);
|
||||||
$output->writeln('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
||||||
}
|
}
|
||||||
} elseif ($composer) {
|
} elseif ($composer) {
|
||||||
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
||||||
|
@ -92,7 +92,7 @@ EOT
|
||||||
$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
|
$repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
|
||||||
} else {
|
} else {
|
||||||
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
||||||
$output->writeln('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
||||||
$installedRepo = $platformRepo;
|
$installedRepo = $platformRepo;
|
||||||
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
|
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ EOT
|
||||||
$this->printLinks($input, $output, $package, 'requires');
|
$this->printLinks($input, $output, $package, 'requires');
|
||||||
$this->printLinks($input, $output, $package, 'devRequires', 'requires (dev)');
|
$this->printLinks($input, $output, $package, 'devRequires', 'requires (dev)');
|
||||||
if ($package->getSuggests()) {
|
if ($package->getSuggests()) {
|
||||||
$output->writeln("\n<info>suggests</info>");
|
$this->getIO()->write("\n<info>suggests</info>");
|
||||||
foreach ($package->getSuggests() as $suggested => $reason) {
|
foreach ($package->getSuggests() as $suggested => $reason) {
|
||||||
$output->writeln($suggested . ' <comment>' . $reason . '</comment>');
|
$this->getIO()->write($suggested . ' <comment>' . $reason . '</comment>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->printLinks($input, $output, $package, 'provides');
|
$this->printLinks($input, $output, $package, 'provides');
|
||||||
|
@ -172,7 +172,7 @@ EOT
|
||||||
foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) {
|
foreach (array('<info>platform</info>:' => true, '<comment>available</comment>:' => false, '<info>installed</info>:' => true) as $type => $showVersion) {
|
||||||
if (isset($packages[$type])) {
|
if (isset($packages[$type])) {
|
||||||
if ($tree) {
|
if ($tree) {
|
||||||
$output->writeln($type);
|
$this->getIO()->write($type);
|
||||||
}
|
}
|
||||||
ksort($packages[$type]);
|
ksort($packages[$type]);
|
||||||
|
|
||||||
|
@ -222,10 +222,10 @@ EOT
|
||||||
} else {
|
} else {
|
||||||
$output->write($indent . $package);
|
$output->write($indent . $package);
|
||||||
}
|
}
|
||||||
$output->writeln('');
|
$this->getIO()->write('');
|
||||||
}
|
}
|
||||||
if ($tree) {
|
if ($tree) {
|
||||||
$output->writeln('');
|
$this->getIO()->write('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,53 +285,53 @@ EOT
|
||||||
*/
|
*/
|
||||||
protected function printMeta(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
|
protected function printMeta(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
|
||||||
{
|
{
|
||||||
$output->writeln('<info>name</info> : ' . $package->getPrettyName());
|
$this->getIO()->write('<info>name</info> : ' . $package->getPrettyName());
|
||||||
$output->writeln('<info>descrip.</info> : ' . $package->getDescription());
|
$this->getIO()->write('<info>descrip.</info> : ' . $package->getDescription());
|
||||||
$output->writeln('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
|
$this->getIO()->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
|
||||||
$this->printVersions($input, $output, $package, $versions, $installedRepo, $repos);
|
$this->printVersions($input, $output, $package, $versions, $installedRepo, $repos);
|
||||||
$output->writeln('<info>type</info> : ' . $package->getType());
|
$this->getIO()->write('<info>type</info> : ' . $package->getType());
|
||||||
$output->writeln('<info>license</info> : ' . implode(', ', $package->getLicense()));
|
$this->getIO()->write('<info>license</info> : ' . implode(', ', $package->getLicense()));
|
||||||
$output->writeln('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
|
$this->getIO()->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
|
||||||
$output->writeln('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
|
$this->getIO()->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
|
||||||
$output->writeln('<info>names</info> : ' . implode(', ', $package->getNames()));
|
$this->getIO()->write('<info>names</info> : ' . implode(', ', $package->getNames()));
|
||||||
|
|
||||||
if ($package->isAbandoned()) {
|
if ($package->isAbandoned()) {
|
||||||
$replacement = ($package->getReplacementPackage() !== null)
|
$replacement = ($package->getReplacementPackage() !== null)
|
||||||
? ' The author suggests using the ' . $package->getReplacementPackage(). ' package instead.'
|
? ' The author suggests using the ' . $package->getReplacementPackage(). ' package instead.'
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
$output->writeln(
|
$this->getIO()->writeError(
|
||||||
sprintf('<error>Attention: This package is abandoned and no longer maintained.%s</error>', $replacement)
|
sprintf('<error>Attention: This package is abandoned and no longer maintained.%s</error>', $replacement)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getSupport()) {
|
if ($package->getSupport()) {
|
||||||
$output->writeln("\n<info>support</info>");
|
$this->getIO()->write("\n<info>support</info>");
|
||||||
foreach ($package->getSupport() as $type => $value) {
|
foreach ($package->getSupport() as $type => $value) {
|
||||||
$output->writeln('<comment>' . $type . '</comment> : '.$value);
|
$this->getIO()->write('<comment>' . $type . '</comment> : '.$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getAutoload()) {
|
if ($package->getAutoload()) {
|
||||||
$output->writeln("\n<info>autoload</info>");
|
$this->getIO()->write("\n<info>autoload</info>");
|
||||||
foreach ($package->getAutoload() as $type => $autoloads) {
|
foreach ($package->getAutoload() as $type => $autoloads) {
|
||||||
$output->writeln('<comment>' . $type . '</comment>');
|
$this->getIO()->write('<comment>' . $type . '</comment>');
|
||||||
|
|
||||||
if ($type === 'psr-0') {
|
if ($type === 'psr-0') {
|
||||||
foreach ($autoloads as $name => $path) {
|
foreach ($autoloads as $name => $path) {
|
||||||
$output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
$this->getIO()->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
||||||
}
|
}
|
||||||
} elseif ($type === 'psr-4') {
|
} elseif ($type === 'psr-4') {
|
||||||
foreach ($autoloads as $name => $path) {
|
foreach ($autoloads as $name => $path) {
|
||||||
$output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
$this->getIO()->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
||||||
}
|
}
|
||||||
} elseif ($type === 'classmap') {
|
} elseif ($type === 'classmap') {
|
||||||
$output->writeln(implode(', ', $autoloads));
|
$this->getIO()->write(implode(', ', $autoloads));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($package->getIncludePaths()) {
|
if ($package->getIncludePaths()) {
|
||||||
$output->writeln('<comment>include-path</comment>');
|
$this->getIO()->write('<comment>include-path</comment>');
|
||||||
$output->writeln(implode(', ', $package->getIncludePaths()));
|
$this->getIO()->write(implode(', ', $package->getIncludePaths()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ EOT
|
||||||
|
|
||||||
$versions = implode(', ', $versions);
|
$versions = implode(', ', $versions);
|
||||||
|
|
||||||
$output->writeln('<info>versions</info> : ' . $versions);
|
$this->getIO()->write('<info>versions</info> : ' . $versions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -371,10 +371,10 @@ EOT
|
||||||
{
|
{
|
||||||
$title = $title ?: $linkType;
|
$title = $title ?: $linkType;
|
||||||
if ($links = $package->{'get'.ucfirst($linkType)}()) {
|
if ($links = $package->{'get'.ucfirst($linkType)}()) {
|
||||||
$output->writeln("\n<info>" . $title . "</info>");
|
$this->getIO()->write("\n<info>" . $title . "</info>");
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$output->writeln($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
|
$this->getIO()->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ EOT
|
||||||
|
|
||||||
// output errors/warnings
|
// output errors/warnings
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
$output->writeln('<info>No local changes</info>');
|
$this->getIO()->writeError('<info>No local changes</info>');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<error>You have changes in the following dependencies:</error>');
|
$this->getIO()->writeError('<error>You have changes in the following dependencies:</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($errors as $path => $changes) {
|
foreach ($errors as $path => $changes) {
|
||||||
|
@ -86,15 +86,15 @@ EOT
|
||||||
$indentedChanges = implode("\n", array_map(function ($line) {
|
$indentedChanges = implode("\n", array_map(function ($line) {
|
||||||
return ' ' . ltrim($line);
|
return ' ' . ltrim($line);
|
||||||
}, explode("\n", $changes)));
|
}, explode("\n", $changes)));
|
||||||
$output->writeln('<info>'.$path.'</info>:');
|
$this->getIO()->write('<info>'.$path.'</info>:');
|
||||||
$output->writeln($indentedChanges);
|
$this->getIO()->write($indentedChanges);
|
||||||
} else {
|
} else {
|
||||||
$output->writeln($path);
|
$this->getIO()->write($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($errors && !$input->getOption('verbose')) {
|
if ($errors && !$input->getOption('verbose')) {
|
||||||
$output->writeln('Use --verbose (-v) to see modified files');
|
$this->getIO()->writeError('Use --verbose (-v) to see modified files');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch post-status-command
|
// Dispatch post-status-command
|
||||||
|
|
|
@ -75,12 +75,12 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('dev')) {
|
if ($input->getOption('dev')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
$this->getIO()->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||||
|
|
|
@ -57,12 +57,12 @@ EOT
|
||||||
$file = $input->getArgument('file');
|
$file = $input->getArgument('file');
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
$output->writeln('<error>' . $file . ' not found.</error>');
|
$this->getIO()->writeError('<error>' . $file . ' not found.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
$output->writeln('<error>' . $file . ' is not readable.</error>');
|
$this->getIO()->writeError('<error>' . $file . ' is not readable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,16 @@ EOT
|
||||||
|
|
||||||
// output errors/warnings
|
// output errors/warnings
|
||||||
if (!$errors && !$publishErrors && !$warnings) {
|
if (!$errors && !$publishErrors && !$warnings) {
|
||||||
$output->writeln('<info>' . $file . ' is valid</info>');
|
$this->getIO()->write('<info>' . $file . ' is valid</info>');
|
||||||
} elseif (!$errors && !$publishErrors) {
|
} elseif (!$errors && !$publishErrors) {
|
||||||
$output->writeln('<info>' . $file . ' is valid, but with a few warnings</info>');
|
$this->getIO()->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
|
||||||
$output->writeln('<warning>See http://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
$this->getIO()->writeError('<warning>See http://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
||||||
} elseif (!$errors) {
|
} elseif (!$errors) {
|
||||||
$output->writeln('<info>' . $file . ' is valid for simple usage with composer but has</info>');
|
$this->getIO()->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
|
||||||
$output->writeln('<info>strict errors that make it unable to be published as a package:</info>');
|
$this->getIO()->writeError('<info>strict errors that make it unable to be published as a package:</info>');
|
||||||
$output->writeln('<warning>See http://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
$this->getIO()->writeError('<warning>See http://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
||||||
} else {
|
} else {
|
||||||
$output->writeln('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
|
$this->getIO()->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = array(
|
$messages = array(
|
||||||
|
@ -92,7 +92,7 @@ EOT
|
||||||
|
|
||||||
foreach ($messages as $style => $msgs) {
|
foreach ($messages as $style => $msgs) {
|
||||||
foreach ($msgs as $msg) {
|
foreach ($msgs as $msg) {
|
||||||
$output->writeln('<' . $style . '>' . $msg . '</' . $style . '>');
|
$this->getIO()->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Composer\Console;
|
||||||
use Symfony\Component\Console\Application as BaseApplication;
|
use Symfony\Component\Console\Application as BaseApplication;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||||
|
@ -91,7 +92,7 @@ class Application extends BaseApplication
|
||||||
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
|
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5.3.2', '<')) {
|
if (version_compare(PHP_VERSION, '5.3.2', '<')) {
|
||||||
$output->writeln('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
|
$this->getIO()->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('COMPOSER_DEV_WARNING_TIME')) {
|
if (defined('COMPOSER_DEV_WARNING_TIME')) {
|
||||||
|
@ -104,7 +105,7 @@ class Application extends BaseApplication
|
||||||
}
|
}
|
||||||
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
|
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
|
||||||
if (time() > COMPOSER_DEV_WARNING_TIME) {
|
if (time() > COMPOSER_DEV_WARNING_TIME) {
|
||||||
$output->writeln(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
|
$this->getIO()->writeError(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +118,8 @@ class Application extends BaseApplication
|
||||||
if ($newWorkDir = $this->getNewWorkingDir($input)) {
|
if ($newWorkDir = $this->getNewWorkingDir($input)) {
|
||||||
$oldWorkingDir = getcwd();
|
$oldWorkingDir = getcwd();
|
||||||
chdir($newWorkDir);
|
chdir($newWorkDir);
|
||||||
if ($output->getVerbosity() >= 4) {
|
if ($this->getIO()->isDebug() >= 4) {
|
||||||
$output->writeln('Changed CWD to ' . getcwd());
|
$this->getIO()->writeError('Changed CWD to ' . getcwd());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ class Application extends BaseApplication
|
||||||
foreach ($composer['scripts'] as $script => $dummy) {
|
foreach ($composer['scripts'] as $script => $dummy) {
|
||||||
if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
|
if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
|
||||||
if ($this->has($script)) {
|
if ($this->has($script)) {
|
||||||
$output->writeln('<warning>A script named '.$script.' would override a native Composer function and has been skipped</warning>');
|
$this->getIO()->writeError('<warning>A script named '.$script.' would override a native Composer function and has been skipped</warning>');
|
||||||
} else {
|
} else {
|
||||||
$this->add(new Command\ScriptAliasCommand($script));
|
$this->add(new Command\ScriptAliasCommand($script));
|
||||||
}
|
}
|
||||||
|
@ -150,7 +151,7 @@ class Application extends BaseApplication
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($startTime)) {
|
if (isset($startTime)) {
|
||||||
$output->writeln('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MB), time: '.round(microtime(true) - $startTime, 2).'s');
|
$this->getIO->writeError('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MB), time: '.round(microtime(true) - $startTime, 2).'s');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -186,23 +187,27 @@ class Application extends BaseApplication
|
||||||
|| (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
|
|| (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
|
||||||
|| (($df = @disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
|
|| (($df = @disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
|
||||||
) {
|
) {
|
||||||
$output->writeln('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
|
$this->getIO()->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
|
||||||
$output->writeln('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
|
$this->getIO()->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
|
||||||
$output->writeln('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');
|
$this->getIO()->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
|
if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
|
||||||
$output->writeln('<error>The following exception is caused by a lack of memory and not having swap configured</error>');
|
$this->getIO()->writeError('<error>The following exception is caused by a lack of memory and not having swap configured</error>');
|
||||||
$output->writeln('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>');
|
$this->getIO()->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::renderException($exception, $output);
|
if ($output instanceof ConsoleOutputInterface) {
|
||||||
|
parent::renderException($exception, $output->getErrorOutput());
|
||||||
|
} else {
|
||||||
|
parent::renderException($exception, $output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,7 +223,7 @@ class Application extends BaseApplication
|
||||||
$this->composer = Factory::create($this->io, null, $disablePlugins);
|
$this->composer = Factory::create($this->io, null, $disablePlugins);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
if ($required) {
|
if ($required) {
|
||||||
$this->io->write($e->getMessage());
|
$this->io->writeError($e->getMessage());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} catch (JsonValidationException $e) {
|
} catch (JsonValidationException $e) {
|
||||||
|
@ -323,7 +328,6 @@ class Application extends BaseApplication
|
||||||
protected function getDefaultHelperSet()
|
protected function getDefaultHelperSet()
|
||||||
{
|
{
|
||||||
$helperSet = parent::getDefaultHelperSet();
|
$helperSet = parent::getDefaultHelperSet();
|
||||||
|
|
||||||
$helperSet->set(new DialogHelper());
|
$helperSet->set(new DialogHelper());
|
||||||
|
|
||||||
return $helperSet;
|
return $helperSet;
|
||||||
|
|
|
@ -35,7 +35,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
$fileName = parent::download($package, $path);
|
$fileName = parent::download($package, $path);
|
||||||
|
|
||||||
if ($this->io->isVerbose()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->write(' Extracting archive');
|
$this->io->writeError(' Extracting archive');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -77,7 +77,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
|
|
||||||
// retry downloading if we have an invalid zip file
|
// retry downloading if we have an invalid zip file
|
||||||
if ($retries && $e instanceof \UnexpectedValueException && class_exists('ZipArchive') && $e->getCode() === \ZipArchive::ER_NOZIP) {
|
if ($retries && $e instanceof \UnexpectedValueException && class_exists('ZipArchive') && $e->getCode() === \ZipArchive::ER_NOZIP) {
|
||||||
$this->io->write(' Invalid zip file, retrying...');
|
$this->io->writeError(' Invalid zip file, retrying...');
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -192,7 +192,7 @@ class DownloadManager
|
||||||
|
|
||||||
foreach ($sources as $i => $source) {
|
foreach ($sources as $i => $source) {
|
||||||
if (isset($e)) {
|
if (isset($e)) {
|
||||||
$this->io->write(' <warning>Now trying to download from ' . $source . '</warning>');
|
$this->io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
|
||||||
}
|
}
|
||||||
$package->setInstallationSource($source);
|
$package->setInstallationSource($source);
|
||||||
try {
|
try {
|
||||||
|
@ -206,7 +206,7 @@ class DownloadManager
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(
|
$this->io->writeError(
|
||||||
' <warning>Failed to download '.
|
' <warning>Failed to download '.
|
||||||
$package->getPrettyName().
|
$package->getPrettyName().
|
||||||
' from ' . $source . ': '.
|
' from ' . $source . ': '.
|
||||||
|
|
|
@ -81,7 +81,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
throw new \InvalidArgumentException('The given package is missing url information');
|
throw new \InvalidArgumentException('The given package is missing url information');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
||||||
|
|
||||||
$urls = $package->getDistUrls();
|
$urls = $package->getDistUrls();
|
||||||
while ($url = array_shift($urls)) {
|
while ($url = array_shift($urls)) {
|
||||||
|
@ -89,11 +89,11 @@ class FileDownloader implements DownloaderInterface
|
||||||
return $this->doDownload($package, $path, $url);
|
return $this->doDownload($package, $path, $url);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
$this->io->write('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
|
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
|
||||||
} elseif (count($urls)) {
|
} elseif (count($urls)) {
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
$this->io->write(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
|
$this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($urls)) {
|
if (!count($urls)) {
|
||||||
|
@ -102,7 +102,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doDownload(PackageInterface $package, $path, $url)
|
protected function doDownload(PackageInterface $package, $path, $url)
|
||||||
|
@ -127,7 +127,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
// download if we don't have it in cache or the cache is invalidated
|
// 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->cache || ($checksum && $checksum !== $this->cache->sha1($cacheKey)) || !$this->cache->copyTo($cacheKey, $fileName)) {
|
||||||
if (!$this->outputProgress) {
|
if (!$this->outputProgress) {
|
||||||
$this->io->write(' Downloading');
|
$this->io->writeError(' Downloading');
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to download 3 times then fail hard
|
// try to download 3 times then fail hard
|
||||||
|
@ -142,7 +142,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
if ($this->io->isVerbose()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->write(' Download failed, retrying...');
|
$this->io->writeError(' Download failed, retrying...');
|
||||||
}
|
}
|
||||||
usleep(500000);
|
usleep(500000);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
$this->cache->copyFrom($cacheKey, $fileName);
|
$this->cache->copyFrom($cacheKey, $fileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->io->write(' Loading from cache');
|
$this->io->writeError(' Loading from cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($fileName)) {
|
if (!file_exists($fileName)) {
|
||||||
|
@ -205,7 +205,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path)
|
public function remove(PackageInterface $package, $path)
|
||||||
{
|
{
|
||||||
$this->io->write(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
||||||
if (!$this->filesystem->removeDirectory($path)) {
|
if (!$this->filesystem->removeDirectory($path)) {
|
||||||
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class GitDownloader extends VcsDownloader
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
$flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : '';
|
$flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : '';
|
||||||
$command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer';
|
$command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer';
|
||||||
$this->io->write(" Cloning ".$ref);
|
$this->io->writeError(" Cloning ".$ref);
|
||||||
|
|
||||||
$commandCallable = function ($url) use ($ref, $path, $command) {
|
$commandCallable = function ($url) use ($ref, $path, $command) {
|
||||||
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
|
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
|
||||||
|
@ -78,7 +78,7 @@ class GitDownloader extends VcsDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
$ref = $target->getSourceReference();
|
$ref = $target->getSourceReference();
|
||||||
$this->io->write(" Checking out ".$ref);
|
$this->io->writeError(" Checking out ".$ref);
|
||||||
$command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
|
$command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
|
||||||
|
|
||||||
$commandCallable = function ($url) use ($command) {
|
$commandCallable = function ($url) use ($command) {
|
||||||
|
@ -143,10 +143,10 @@ class GitDownloader extends VcsDownloader
|
||||||
$changes = array_map(function ($elem) {
|
$changes = array_map(function ($elem) {
|
||||||
return ' '.$elem;
|
return ' '.$elem;
|
||||||
}, preg_split('{\s*\r?\n\s*}', $changes));
|
}, preg_split('{\s*\r?\n\s*}', $changes));
|
||||||
$this->io->write(' <error>The package has modified files:</error>');
|
$this->io->writeError(' <error>The package has modified files:</error>');
|
||||||
$this->io->write(array_slice($changes, 0, 10));
|
$this->io->writeError(array_slice($changes, 0, 10));
|
||||||
if (count($changes) > 10) {
|
if (count($changes) > 10) {
|
||||||
$this->io->write(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
|
$this->io->writeError(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -167,21 +167,21 @@ class GitDownloader extends VcsDownloader
|
||||||
throw new \RuntimeException('Update aborted');
|
throw new \RuntimeException('Update aborted');
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
$this->io->write($changes);
|
$this->io->writeError($changes);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
help:
|
help:
|
||||||
$this->io->write(array(
|
$this->io->writeError(array(
|
||||||
' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
|
' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
|
||||||
' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
|
' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
|
||||||
' v - view modified files',
|
' v - view modified files',
|
||||||
));
|
));
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$this->io->write(' s - stash changes and try to reapply them after the update');
|
$this->io->writeError(' s - stash changes and try to reapply them after the update');
|
||||||
}
|
}
|
||||||
$this->io->write(' ? - print help');
|
$this->io->writeError(' ? - print help');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class GitDownloader extends VcsDownloader
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
if ($this->hasStashedChanges) {
|
if ($this->hasStashedChanges) {
|
||||||
$this->hasStashedChanges = false;
|
$this->hasStashedChanges = false;
|
||||||
$this->io->write(' <info>Re-applying stashed changes</info>');
|
$this->io->writeError(' <info>Re-applying stashed changes</info>');
|
||||||
if (0 !== $this->process->execute('git stash pop', $output, $path)) {
|
if (0 !== $this->process->execute('git stash pop', $output, $path)) {
|
||||||
throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
|
throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ class GitDownloader extends VcsDownloader
|
||||||
|
|
||||||
// reference was not found (prints "fatal: reference is not a tree: $ref")
|
// reference was not found (prints "fatal: reference is not a tree: $ref")
|
||||||
if (false !== strpos($this->process->getErrorOutput(), $reference)) {
|
if (false !== strpos($this->process->getErrorOutput(), $reference)) {
|
||||||
$this->io->write(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
|
$this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('Failed to execute ' . GitUtil::sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput());
|
throw new \RuntimeException('Failed to execute ' . GitUtil::sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput());
|
||||||
|
|
|
@ -27,7 +27,7 @@ class HgDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
$url = ProcessExecutor::escape($url);
|
$url = ProcessExecutor::escape($url);
|
||||||
$ref = ProcessExecutor::escape($package->getSourceReference());
|
$ref = ProcessExecutor::escape($package->getSourceReference());
|
||||||
$this->io->write(" Cloning ".$package->getSourceReference());
|
$this->io->writeError(" Cloning ".$package->getSourceReference());
|
||||||
$command = sprintf('hg clone %s %s', $url, ProcessExecutor::escape($path));
|
$command = sprintf('hg clone %s %s', $url, ProcessExecutor::escape($path));
|
||||||
if (0 !== $this->process->execute($command, $ignoredOutput)) {
|
if (0 !== $this->process->execute($command, $ignoredOutput)) {
|
||||||
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
||||||
|
@ -45,7 +45,7 @@ class HgDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
$url = ProcessExecutor::escape($url);
|
$url = ProcessExecutor::escape($url);
|
||||||
$ref = ProcessExecutor::escape($target->getSourceReference());
|
$ref = ProcessExecutor::escape($target->getSourceReference());
|
||||||
$this->io->write(" Updating to ".$target->getSourceReference());
|
$this->io->writeError(" Updating to ".$target->getSourceReference());
|
||||||
|
|
||||||
if (!is_dir($path.'/.hg')) {
|
if (!is_dir($path.'/.hg')) {
|
||||||
throw new \RuntimeException('The .hg directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information');
|
throw new \RuntimeException('The .hg directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information');
|
||||||
|
|
|
@ -31,7 +31,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
$label = $this->getLabelFromSourceReference($ref);
|
$label = $this->getLabelFromSourceReference($ref);
|
||||||
|
|
||||||
$this->io->write(' Cloning ' . $ref);
|
$this->io->writeError(' Cloning ' . $ref);
|
||||||
$this->initPerforce($package, $path, $url);
|
$this->initPerforce($package, $path, $url);
|
||||||
$this->perforce->setStream($ref);
|
$this->perforce->setStream($ref);
|
||||||
$this->perforce->p4Login($this->io);
|
$this->perforce->p4Login($this->io);
|
||||||
|
@ -85,7 +85,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges(PackageInterface $package, $path)
|
public function getLocalChanges(PackageInterface $package, $path)
|
||||||
{
|
{
|
||||||
$this->io->write('Perforce driver does not check for local changes before overriding', true);
|
$this->io->writeError('Perforce driver does not check for local changes before overriding', true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
SvnUtil::cleanEnv();
|
SvnUtil::cleanEnv();
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
|
|
||||||
$this->io->write(" Checking out ".$package->getSourceReference());
|
$this->io->writeError(" Checking out ".$package->getSourceReference());
|
||||||
$this->execute($url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
|
$this->execute($url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class SvnDownloader extends VcsDownloader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(" Checking out " . $ref);
|
$this->io->writeError(" Checking out " . $ref);
|
||||||
$this->execute($url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
|
$this->execute($url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,10 +114,10 @@ class SvnDownloader extends VcsDownloader
|
||||||
$changes = array_map(function ($elem) {
|
$changes = array_map(function ($elem) {
|
||||||
return ' '.$elem;
|
return ' '.$elem;
|
||||||
}, preg_split('{\s*\r?\n\s*}', $changes));
|
}, preg_split('{\s*\r?\n\s*}', $changes));
|
||||||
$this->io->write(' <error>The package has modified files:</error>');
|
$this->io->writeError(' <error>The package has modified files:</error>');
|
||||||
$this->io->write(array_slice($changes, 0, 10));
|
$this->io->writeError(array_slice($changes, 0, 10));
|
||||||
if (count($changes) > 10) {
|
if (count($changes) > 10) {
|
||||||
$this->io->write(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
|
$this->io->writeError(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>');
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -130,12 +130,12 @@ class SvnDownloader extends VcsDownloader
|
||||||
throw new \RuntimeException('Update aborted');
|
throw new \RuntimeException('Update aborted');
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
$this->io->write($changes);
|
$this->io->writeError($changes);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
$this->io->write(array(
|
$this->io->writeError(array(
|
||||||
' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
|
' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
|
||||||
' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
|
' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
|
||||||
' v - view modified files',
|
' v - view modified files',
|
||||||
|
|
|
@ -54,7 +54,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
|
||||||
$this->filesystem->emptyDirectory($path);
|
$this->filesystem->emptyDirectory($path);
|
||||||
|
|
||||||
$urls = $package->getSourceUrls();
|
$urls = $package->getSourceUrls();
|
||||||
|
@ -67,9 +67,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
break;
|
break;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Failed: ['.get_class($e).'] '.$e->getMessage());
|
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
|
||||||
} elseif (count($urls)) {
|
} elseif (count($urls)) {
|
||||||
$this->io->write(' Failed, trying the next URL');
|
$this->io->writeError(' Failed, trying the next URL');
|
||||||
}
|
}
|
||||||
if (!count($urls)) {
|
if (!count($urls)) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -77,7 +77,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
$to = VersionParser::formatVersion($target);
|
$to = VersionParser::formatVersion($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
|
$this->io->writeError(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
|
||||||
|
|
||||||
$this->cleanChanges($initial, $path, true);
|
$this->cleanChanges($initial, $path, true);
|
||||||
$urls = $target->getSourceUrls();
|
$urls = $target->getSourceUrls();
|
||||||
|
@ -117,9 +117,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
break;
|
break;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write('Failed: ['.get_class($e).'] '.$e->getMessage());
|
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
|
||||||
} elseif (count($urls)) {
|
} elseif (count($urls)) {
|
||||||
$this->io->write(' Failed, trying the next URL');
|
$this->io->writeError(' Failed, trying the next URL');
|
||||||
} else {
|
} else {
|
||||||
// in case of failed update, try to reapply the changes before aborting
|
// in case of failed update, try to reapply the changes before aborting
|
||||||
$this->reapplyChanges($path);
|
$this->reapplyChanges($path);
|
||||||
|
@ -146,12 +146,12 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
return ' ' . $line;
|
return ' ' . $line;
|
||||||
}, explode("\n", $logs)));
|
}, explode("\n", $logs)));
|
||||||
|
|
||||||
$this->io->write(' '.$message);
|
$this->io->writeError(' '.$message);
|
||||||
$this->io->write($logs);
|
$this->io->writeError($logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +159,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
||||||
*/
|
*/
|
||||||
public function remove(PackageInterface $package, $path)
|
public function remove(PackageInterface $package, $path)
|
||||||
{
|
{
|
||||||
$this->io->write(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
|
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
|
||||||
$this->cleanChanges($package, $path, false);
|
$this->cleanChanges($package, $path, false);
|
||||||
if (!$this->filesystem->removeDirectory($path)) {
|
if (!$this->filesystem->removeDirectory($path)) {
|
||||||
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
|
||||||
|
|
|
@ -154,11 +154,11 @@ class EventDispatcher
|
||||||
$methodName = substr($callable, strpos($callable, '::') + 2);
|
$methodName = substr($callable, strpos($callable, '::') + 2);
|
||||||
|
|
||||||
if (!class_exists($className)) {
|
if (!class_exists($className)) {
|
||||||
$this->io->write('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>');
|
$this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!is_callable($callable)) {
|
if (!is_callable($callable)) {
|
||||||
$this->io->write('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>');
|
$this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +166,13 @@ class EventDispatcher
|
||||||
$return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
|
$return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$message = "Script %s handling the %s event terminated with an exception";
|
$message = "Script %s handling the %s event terminated with an exception";
|
||||||
$this->io->write('<error>'.sprintf($message, $callable, $event->getName()).'</error>');
|
$this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>');
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$args = implode(' ', array_map(array('Composer\Util\ProcessExecutor','escape'), $event->getArguments()));
|
$args = implode(' ', array_map(array('Composer\Util\ProcessExecutor','escape'), $event->getArguments()));
|
||||||
if (0 !== ($exitCode = $this->process->execute($callable . ($args === '' ? '' : ' '.$args)))) {
|
if (0 !== ($exitCode = $this->process->execute($callable . ($args === '' ? '' : ' '.$args)))) {
|
||||||
$this->io->write(sprintf('<error>Script %s handling the %s event returned with an error</error>', $callable, $event->getName()));
|
$this->io->writeError(sprintf('<error>Script %s handling the %s event returned with an error</error>', $callable, $event->getName()));
|
||||||
|
|
||||||
throw new \RuntimeException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
|
throw new \RuntimeException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ class Factory
|
||||||
$file = new JsonFile($home.'/config.json');
|
$file = new JsonFile($home.'/config.json');
|
||||||
if ($file->exists()) {
|
if ($file->exists()) {
|
||||||
if ($io && $io->isDebug()) {
|
if ($io && $io->isDebug()) {
|
||||||
$io->write('Loading config file ' . $file->getPath());
|
$io->writeError('Loading config file ' . $file->getPath());
|
||||||
}
|
}
|
||||||
$config->merge($file->read());
|
$config->merge($file->read());
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class Factory
|
||||||
$file = new JsonFile($config->get('home').'/auth.json');
|
$file = new JsonFile($config->get('home').'/auth.json');
|
||||||
if ($file->exists()) {
|
if ($file->exists()) {
|
||||||
if ($io && $io->isDebug()) {
|
if ($io && $io->isDebug()) {
|
||||||
$io->write('Loading config file ' . $file->getPath());
|
$io->writeError('Loading config file ' . $file->getPath());
|
||||||
}
|
}
|
||||||
$config->merge(array('config' => $file->read()));
|
$config->merge(array('config' => $file->read()));
|
||||||
}
|
}
|
||||||
|
@ -227,12 +227,12 @@ class Factory
|
||||||
$config->merge($localConfig);
|
$config->merge($localConfig);
|
||||||
if (isset($composerFile)) {
|
if (isset($composerFile)) {
|
||||||
if ($io && $io->isDebug()) {
|
if ($io && $io->isDebug()) {
|
||||||
$io->write('Loading config file ' . $composerFile);
|
$io->writeError('Loading config file ' . $composerFile);
|
||||||
}
|
}
|
||||||
$localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
|
$localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
|
||||||
if ($localAuthFile->exists()) {
|
if ($localAuthFile->exists()) {
|
||||||
if ($io && $io->isDebug()) {
|
if ($io && $io->isDebug()) {
|
||||||
$io->write('Loading config file ' . $localAuthFile->getPath());
|
$io->writeError('Loading config file ' . $localAuthFile->getPath());
|
||||||
}
|
}
|
||||||
$config->merge(array('config' => $localAuthFile->read()));
|
$config->merge(array('config' => $localAuthFile->read()));
|
||||||
$config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
|
$config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
|
||||||
|
@ -362,7 +362,7 @@ class Factory
|
||||||
$composer = self::createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), false);
|
$composer = self::createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), false);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($io->isDebug()) {
|
if ($io->isDebug()) {
|
||||||
$io->write('Failed to initialize global composer: '.$e->getMessage());
|
$io->writeError('Failed to initialize global composer: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,19 @@ use Symfony\Component\Console\Helper\HelperSet;
|
||||||
class BufferIO extends ConsoleIO
|
class BufferIO extends ConsoleIO
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param int $verbosity
|
* @param int $verbosity
|
||||||
* @param OutputFormatterInterface $formatter
|
* @param OutputFormatterInterface $formatter
|
||||||
*/
|
*/
|
||||||
public function __construct($input = '', $verbosity = null, OutputFormatterInterface $formatter = null)
|
public function __construct(
|
||||||
{
|
$input = '',
|
||||||
|
$verbosity = StreamOutput::VERBOSITY_NORMAL,
|
||||||
|
OutputFormatterInterface $formatter = null
|
||||||
|
) {
|
||||||
$input = new StringInput($input);
|
$input = new StringInput($input);
|
||||||
$input->setInteractive(false);
|
$input->setInteractive(false);
|
||||||
|
|
||||||
$output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity === null ? StreamOutput::VERBOSITY_NORMAL : $verbosity, !empty($formatter), $formatter);
|
$output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, !empty($formatter), $formatter);
|
||||||
|
|
||||||
parent::__construct($input, $output, new HelperSet(array()));
|
parent::__construct($input, $output, new HelperSet(array()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\IO;
|
namespace Composer\IO;
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Helper\HelperSet;
|
use Symfony\Component\Console\Helper\HelperSet;
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
@ -29,6 +30,7 @@ class ConsoleIO extends BaseIO
|
||||||
protected $output;
|
protected $output;
|
||||||
protected $helperSet;
|
protected $helperSet;
|
||||||
protected $lastMessage;
|
protected $lastMessage;
|
||||||
|
protected $lastMessageErr;
|
||||||
private $startTime;
|
private $startTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,6 +96,24 @@ class ConsoleIO extends BaseIO
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function write($messages, $newline = true)
|
public function write($messages, $newline = true)
|
||||||
|
{
|
||||||
|
$this->doWrite($messages, $newline, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeError($messages, $newline = true)
|
||||||
|
{
|
||||||
|
$this->doWrite($messages, $newline, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $messages
|
||||||
|
* @param boolean $newline
|
||||||
|
* @param boolean $stderr
|
||||||
|
*/
|
||||||
|
private function doWrite($messages, $newline, $stderr)
|
||||||
{
|
{
|
||||||
if (null !== $this->startTime) {
|
if (null !== $this->startTime) {
|
||||||
$memoryUsage = memory_get_usage() / 1024 / 1024;
|
$memoryUsage = memory_get_usage() / 1024 / 1024;
|
||||||
|
@ -102,6 +122,13 @@ class ConsoleIO extends BaseIO
|
||||||
return sprintf('[%.1fMB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
|
return sprintf('[%.1fMB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
|
||||||
}, (array) $messages);
|
}, (array) $messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
|
||||||
|
$this->output->getErrorOutput()->write($messages, $newline);
|
||||||
|
$this->lastMessageErr = join($newline ? "\n" : '', (array) $messages);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->output->write($messages, $newline);
|
$this->output->write($messages, $newline);
|
||||||
$this->lastMessage = join($newline ? "\n" : '', (array) $messages);
|
$this->lastMessage = join($newline ? "\n" : '', (array) $messages);
|
||||||
}
|
}
|
||||||
|
@ -111,12 +138,38 @@ class ConsoleIO extends BaseIO
|
||||||
*/
|
*/
|
||||||
public function overwrite($messages, $newline = true, $size = null)
|
public function overwrite($messages, $newline = true, $size = null)
|
||||||
{
|
{
|
||||||
if (!$this->output->isDecorated()) {
|
$this->doOverwrite($messages, $newline, $size, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function overwriteError($messages, $newline = true, $size = null)
|
||||||
|
{
|
||||||
|
$this->doOverwrite($messages, $newline, $size, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $messages
|
||||||
|
* @param boolean $newline
|
||||||
|
* @param integer $size
|
||||||
|
* @param boolean $stderr
|
||||||
|
*/
|
||||||
|
private function doOverwrite($messages, $newline, $size, $stderr)
|
||||||
|
{
|
||||||
|
if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
|
||||||
|
$output = $this->output->getErrorOutput();
|
||||||
|
} else {
|
||||||
|
$output = $this->output;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$output->isDecorated()) {
|
||||||
if (!$messages) {
|
if (!$messages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->write($messages, count($messages) === 1 || $newline);
|
$this->doWrite($messages, count($messages) === 1 || $newline, $stderr);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// messages can be an array, let's convert it to string anyway
|
// messages can be an array, let's convert it to string anyway
|
||||||
|
@ -125,24 +178,24 @@ class ConsoleIO extends BaseIO
|
||||||
// since overwrite is supposed to overwrite last message...
|
// since overwrite is supposed to overwrite last message...
|
||||||
if (!isset($size)) {
|
if (!isset($size)) {
|
||||||
// removing possible formatting of lastMessage with strip_tags
|
// removing possible formatting of lastMessage with strip_tags
|
||||||
$size = strlen(strip_tags($this->lastMessage));
|
$size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
|
||||||
}
|
}
|
||||||
// ...let's fill its length with backspaces
|
// ...let's fill its length with backspaces
|
||||||
$this->write(str_repeat("\x08", $size), false);
|
$this->doWrite(str_repeat("\x08", $size), false, $stderr);
|
||||||
|
|
||||||
// write the new message
|
// write the new message
|
||||||
$this->write($messages, false);
|
$this->doWrite($messages, false, $stderr);
|
||||||
|
|
||||||
$fill = $size - strlen(strip_tags($messages));
|
$fill = $size - strlen(strip_tags($messages));
|
||||||
if ($fill > 0) {
|
if ($fill > 0) {
|
||||||
// whitespace whatever has left
|
// whitespace whatever has left
|
||||||
$this->write(str_repeat(' ', $fill), false);
|
$this->doWrite(str_repeat(' ', $fill), false, $stderr);
|
||||||
// move the cursor back
|
// move the cursor back
|
||||||
$this->write(str_repeat("\x08", $fill), false);
|
$this->doWrite(str_repeat("\x08", $fill), false, $stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newline) {
|
if ($newline) {
|
||||||
$this->write('');
|
$this->doWrite('', true, $stderr);
|
||||||
}
|
}
|
||||||
$this->lastMessage = $messages;
|
$this->lastMessage = $messages;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +205,16 @@ class ConsoleIO extends BaseIO
|
||||||
*/
|
*/
|
||||||
public function ask($question, $default = null)
|
public function ask($question, $default = null)
|
||||||
{
|
{
|
||||||
return $this->helperSet->get('dialog')->ask($this->output, $question, $default);
|
$output = $this->output;
|
||||||
|
|
||||||
|
if ($output instanceof ConsoleOutputInterface) {
|
||||||
|
$output = $output->getErrorOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var \Symfony\Component\Console\Helper\DialogHelper $dialog */
|
||||||
|
$dialog = $this->helperSet->get('dialog');
|
||||||
|
|
||||||
|
return $dialog->ask($output, $question, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +222,16 @@ class ConsoleIO extends BaseIO
|
||||||
*/
|
*/
|
||||||
public function askConfirmation($question, $default = true)
|
public function askConfirmation($question, $default = true)
|
||||||
{
|
{
|
||||||
return $this->helperSet->get('dialog')->askConfirmation($this->output, $question, $default);
|
$output = $this->output;
|
||||||
|
|
||||||
|
if ($output instanceof ConsoleOutputInterface) {
|
||||||
|
$output = $output->getErrorOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var \Symfony\Component\Console\Helper\DialogHelper $dialog */
|
||||||
|
$dialog = $this->helperSet->get('dialog');
|
||||||
|
|
||||||
|
return $dialog->askConfirmation($output, $question, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +239,16 @@ class ConsoleIO extends BaseIO
|
||||||
*/
|
*/
|
||||||
public function askAndValidate($question, $validator, $attempts = false, $default = null)
|
public function askAndValidate($question, $validator, $attempts = false, $default = null)
|
||||||
{
|
{
|
||||||
return $this->helperSet->get('dialog')->askAndValidate($this->output, $question, $validator, $attempts, $default);
|
$output = $this->output;
|
||||||
|
|
||||||
|
if ($output instanceof ConsoleOutputInterface) {
|
||||||
|
$output = $output->getErrorOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var \Symfony\Component\Console\Helper\DialogHelper $dialog */
|
||||||
|
$dialog = $this->helperSet->get('dialog');
|
||||||
|
|
||||||
|
return $dialog->askAndValidate($output, $question, $validator, $attempts, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,9 +262,9 @@ class ConsoleIO extends BaseIO
|
||||||
|
|
||||||
// use bash if it's present
|
// use bash if it's present
|
||||||
if ($finder->find('bash') && $finder->find('stty')) {
|
if ($finder->find('bash') && $finder->find('stty')) {
|
||||||
$this->write($question, false);
|
$this->writeError($question, false);
|
||||||
$value = rtrim(shell_exec('bash -c "stty -echo; read -n0 discard; read -r mypassword; stty echo; echo $mypassword"'));
|
$value = rtrim(shell_exec('bash -c "stty -echo; read -n0 discard; read -r mypassword; stty echo; echo $mypassword"'));
|
||||||
$this->write('');
|
$this->writeError('');
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -208,9 +288,9 @@ class ConsoleIO extends BaseIO
|
||||||
$exe = $tmpExe;
|
$exe = $tmpExe;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->write($question, false);
|
$this->writeError($question, false);
|
||||||
$value = rtrim(shell_exec($exe));
|
$value = rtrim(shell_exec($exe));
|
||||||
$this->write('');
|
$this->writeError('');
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
if (isset($tmpExe)) {
|
if (isset($tmpExe)) {
|
||||||
|
@ -230,11 +310,11 @@ class ConsoleIO extends BaseIO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($shell)) {
|
if (isset($shell)) {
|
||||||
$this->write($question, false);
|
$this->writeError($question, false);
|
||||||
$readCmd = ($shell === 'csh') ? 'set mypassword = $<' : 'read -r mypassword';
|
$readCmd = ($shell === 'csh') ? 'set mypassword = $<' : 'read -r mypassword';
|
||||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||||
$value = rtrim(shell_exec($command));
|
$value = rtrim(shell_exec($command));
|
||||||
$this->write('');
|
$this->writeError('');
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,14 @@ interface IOInterface
|
||||||
*/
|
*/
|
||||||
public function write($messages, $newline = true);
|
public function write($messages, $newline = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a message to the error output.
|
||||||
|
*
|
||||||
|
* @param string|array $messages The message as an array of lines or a single string
|
||||||
|
* @param bool $newline Whether to add a newline or not
|
||||||
|
*/
|
||||||
|
public function writeError($messages, $newline = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwrites a previous message to the output.
|
* Overwrites a previous message to the output.
|
||||||
*
|
*
|
||||||
|
@ -73,6 +81,15 @@ interface IOInterface
|
||||||
*/
|
*/
|
||||||
public function overwrite($messages, $newline = true, $size = null);
|
public function overwrite($messages, $newline = true, $size = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrites a previous message to the error output.
|
||||||
|
*
|
||||||
|
* @param string|array $messages The message as an array of lines or a single string
|
||||||
|
* @param bool $newline Whether to add a newline or not
|
||||||
|
* @param integer $size The size of line
|
||||||
|
*/
|
||||||
|
public function overwriteError($messages, $newline = true, $size = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks a question to the user.
|
* Asks a question to the user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,6 +66,13 @@ class NullIO extends BaseIO
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function writeError($messages, $newline = true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +80,13 @@ class NullIO extends BaseIO
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function overwriteError($messages, $newline = true, $size = 80)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -177,7 +177,7 @@ class Installer
|
||||||
// purge old require-dev packages to avoid conflicts with the new way of handling dev requirements
|
// purge old require-dev packages to avoid conflicts with the new way of handling dev requirements
|
||||||
$devRepo = new InstalledFilesystemRepository(new JsonFile($this->config->get('vendor-dir').'/composer/installed_dev.json'));
|
$devRepo = new InstalledFilesystemRepository(new JsonFile($this->config->get('vendor-dir').'/composer/installed_dev.json'));
|
||||||
if ($devRepo->getPackages()) {
|
if ($devRepo->getPackages()) {
|
||||||
$this->io->write('<warning>BC Notice: Removing old dev packages to migrate to the new require-dev handling.</warning>');
|
$this->io->writeError('<warning>BC Notice: Removing old dev packages to migrate to the new require-dev handling.</warning>');
|
||||||
foreach ($devRepo->getPackages() as $package) {
|
foreach ($devRepo->getPackages() as $package) {
|
||||||
if ($this->installationManager->isPackageInstalled($devRepo, $package)) {
|
if ($this->installationManager->isPackageInstalled($devRepo, $package)) {
|
||||||
$this->installationManager->uninstall($devRepo, new UninstallOperation($package));
|
$this->installationManager->uninstall($devRepo, new UninstallOperation($package));
|
||||||
|
@ -243,7 +243,7 @@ class Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
|
$this->io->writeError($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ class Installer
|
||||||
? 'Use ' . $package->getReplacementPackage() . ' instead'
|
? 'Use ' . $package->getReplacementPackage() . ' instead'
|
||||||
: 'No replacement was suggested';
|
: 'No replacement was suggested';
|
||||||
|
|
||||||
$this->io->write(
|
$this->io->writeError(
|
||||||
sprintf(
|
sprintf(
|
||||||
"<error>Package %s is abandoned, you should avoid using it. %s.</error>",
|
"<error>Package %s is abandoned, you should avoid using it. %s.</error>",
|
||||||
$package->getPrettyName(),
|
$package->getPrettyName(),
|
||||||
|
@ -314,16 +314,16 @@ class Installer
|
||||||
$this->preferLowest
|
$this->preferLowest
|
||||||
);
|
);
|
||||||
if ($updatedLock) {
|
if ($updatedLock) {
|
||||||
$this->io->write('<info>Writing lock file</info>');
|
$this->io->writeError('<info>Writing lock file</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->dumpAutoloader) {
|
if ($this->dumpAutoloader) {
|
||||||
// write autoloader
|
// write autoloader
|
||||||
if ($this->optimizeAutoloader) {
|
if ($this->optimizeAutoloader) {
|
||||||
$this->io->write('<info>Generating optimized autoload files</info>');
|
$this->io->writeError('<info>Generating optimized autoload files</info>');
|
||||||
} else {
|
} else {
|
||||||
$this->io->write('<info>Generating autoload files</info>');
|
$this->io->writeError('<info>Generating autoload files</info>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->autoloadGenerator->setDevMode($this->devMode);
|
$this->autoloadGenerator->setDevMode($this->devMode);
|
||||||
|
@ -374,7 +374,7 @@ class Installer
|
||||||
$this->package->getDevRequires()
|
$this->package->getDevRequires()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->io->write('<info>Loading composer repositories with package information</info>');
|
$this->io->writeError('<info>Loading composer repositories with package information</info>');
|
||||||
|
|
||||||
// creating repository pool
|
// creating repository pool
|
||||||
$policy = $this->createPolicy();
|
$policy = $this->createPolicy();
|
||||||
|
@ -409,7 +409,7 @@ class Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->update) {
|
if ($this->update) {
|
||||||
$this->io->write('<info>Updating dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
|
$this->io->writeError('<info>Updating dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
|
||||||
|
|
||||||
$request->updateAll();
|
$request->updateAll();
|
||||||
|
|
||||||
|
@ -460,10 +460,10 @@ class Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($installFromLock) {
|
} elseif ($installFromLock) {
|
||||||
$this->io->write('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').' from lock file</info>');
|
$this->io->writeError('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').' from lock file</info>');
|
||||||
|
|
||||||
if (!$this->locker->isFresh()) {
|
if (!$this->locker->isFresh()) {
|
||||||
$this->io->write('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>');
|
$this->io->writeError('<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lockedRepository->getPackages() as $package) {
|
foreach ($lockedRepository->getPackages() as $package) {
|
||||||
|
@ -480,7 +480,7 @@ class Installer
|
||||||
$request->install($link->getTarget(), $link->getConstraint());
|
$request->install($link->getTarget(), $link->getConstraint());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->io->write('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
|
$this->io->writeError('<info>Installing dependencies'.($withDevReqs ? ' (including require-dev)' : '').'</info>');
|
||||||
|
|
||||||
if ($withDevReqs) {
|
if ($withDevReqs) {
|
||||||
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
|
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
|
||||||
|
@ -503,8 +503,8 @@ class Installer
|
||||||
$operations = $solver->solve($request, $this->ignorePlatformReqs);
|
$operations = $solver->solve($request, $this->ignorePlatformReqs);
|
||||||
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);
|
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);
|
||||||
} catch (SolverProblemsException $e) {
|
} catch (SolverProblemsException $e) {
|
||||||
$this->io->write('<error>Your requirements could not be resolved to an installable set of packages.</error>');
|
$this->io->writeError('<error>Your requirements could not be resolved to an installable set of packages.</error>');
|
||||||
$this->io->write($e->getMessage());
|
$this->io->writeError($e->getMessage());
|
||||||
|
|
||||||
return max(1, $e->getCode());
|
return max(1, $e->getCode());
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ class Installer
|
||||||
|
|
||||||
// execute operations
|
// execute operations
|
||||||
if (!$operations) {
|
if (!$operations) {
|
||||||
$this->io->write('Nothing to install or update');
|
$this->io->writeError('Nothing to install or update');
|
||||||
}
|
}
|
||||||
|
|
||||||
$operations = $this->movePluginsToFront($operations);
|
$operations = $this->movePluginsToFront($operations);
|
||||||
|
@ -553,8 +553,8 @@ class Installer
|
||||||
&& $operation->getTargetPackage()->getSourceReference() === $operation->getInitialPackage()->getSourceReference()
|
&& $operation->getTargetPackage()->getSourceReference() === $operation->getInitialPackage()->getSourceReference()
|
||||||
) {
|
) {
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write(' - Skipping update of '. $operation->getTargetPackage()->getPrettyName().' to the same reference-locked version');
|
$this->io->writeError(' - Skipping update of '. $operation->getTargetPackage()->getPrettyName().' to the same reference-locked version');
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -568,11 +568,11 @@ class Installer
|
||||||
|
|
||||||
// output non-alias ops in dry run, output alias ops in debug verbosity
|
// output non-alias ops in dry run, output alias ops in debug verbosity
|
||||||
if ($this->dryRun && false === strpos($operation->getJobType(), 'Alias')) {
|
if ($this->dryRun && false === strpos($operation->getJobType(), 'Alias')) {
|
||||||
$this->io->write(' - ' . $operation);
|
$this->io->writeError(' - ' . $operation);
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
} elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
|
} elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
|
||||||
$this->io->write(' - ' . $operation);
|
$this->io->writeError(' - ' . $operation);
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->installationManager->execute($localRepo, $operation);
|
$this->installationManager->execute($localRepo, $operation);
|
||||||
|
@ -583,12 +583,12 @@ class Installer
|
||||||
if ($reason instanceof Rule) {
|
if ($reason instanceof Rule) {
|
||||||
switch ($reason->getReason()) {
|
switch ($reason->getReason()) {
|
||||||
case Rule::RULE_JOB_INSTALL:
|
case Rule::RULE_JOB_INSTALL:
|
||||||
$this->io->write(' REASON: Required by root: '.$reason->getPrettyString($pool));
|
$this->io->writeError(' REASON: Required by root: '.$reason->getPrettyString($pool));
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
break;
|
break;
|
||||||
case Rule::RULE_PACKAGE_REQUIRES:
|
case Rule::RULE_PACKAGE_REQUIRES:
|
||||||
$this->io->write(' REASON: '.$reason->getPrettyString($pool));
|
$this->io->writeError(' REASON: '.$reason->getPrettyString($pool));
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1001,7 +1001,7 @@ class Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($depPackages) == 0 && !$nameMatchesRequiredPackage && !in_array($packageName, array('nothing', 'lock'))) {
|
if (count($depPackages) == 0 && !$nameMatchesRequiredPackage && !in_array($packageName, array('nothing', 'lock'))) {
|
||||||
$this->io->write('<warning>Package "' . $packageName . '" listed for update is not installed. Ignoring.</warning>');
|
$this->io->writeError('<warning>Package "' . $packageName . '" listed for update is not installed. Ignoring.</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($depPackages as $depPackage) {
|
foreach ($depPackages as $depPackage) {
|
||||||
|
|
|
@ -197,7 +197,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
foreach ($binaries as $bin) {
|
foreach ($binaries as $bin) {
|
||||||
$binPath = $this->getInstallPath($package).'/'.$bin;
|
$binPath = $this->getInstallPath($package).'/'.$bin;
|
||||||
if (!file_exists($binPath)) {
|
if (!file_exists($binPath)) {
|
||||||
$this->io->write(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
|
$this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
// is a fresh install of the vendor.
|
// is a fresh install of the vendor.
|
||||||
@chmod($link, 0777 & ~umask());
|
@chmod($link, 0777 & ~umask());
|
||||||
}
|
}
|
||||||
$this->io->write(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
$this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
@ -226,7 +226,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
@chmod($link, 0777 & ~umask());
|
@chmod($link, 0777 & ~umask());
|
||||||
$link .= '.bat';
|
$link .= '.bat';
|
||||||
if (file_exists($link)) {
|
if (file_exists($link)) {
|
||||||
$this->io->write(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
|
$this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!file_exists($link)) {
|
if (!file_exists($link)) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ class PearInstaller extends LibraryInstaller
|
||||||
$pearExtractor->extractTo($this->getInstallPath($package), array('php' => '/', 'script' => '/bin', 'data' => '/data'), $vars);
|
$pearExtractor->extractTo($this->getInstallPath($package), array('php' => '/', 'script' => '/bin', 'data' => '/data'), $vars);
|
||||||
|
|
||||||
if ($this->io->isVerbose()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->write(' Cleaning up');
|
$this->io->writeError(' Cleaning up');
|
||||||
}
|
}
|
||||||
$this->filesystem->unlink($packageArchive);
|
$this->filesystem->unlink($packageArchive);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class PluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$requiresComposer->matches(new VersionConstraint('==', $this->versionParser->normalize(PluginInterface::PLUGIN_API_VERSION)))) {
|
if (!$requiresComposer->matches(new VersionConstraint('==', $this->versionParser->normalize(PluginInterface::PLUGIN_API_VERSION)))) {
|
||||||
$this->io->write("<warning>The plugin ".$package->getName()." requires a version of composer-plugin-api that does not match your composer installation. You may need to run composer update with the '--no-plugins' option.</warning>");
|
$this->io->writeError("<warning>The plugin ".$package->getName()." requires a version of composer-plugin-api that does not match your composer installation. You may need to run composer update with the '--no-plugins' option.</warning>");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerPackage($package);
|
$this->registerPackage($package);
|
||||||
|
|
|
@ -60,14 +60,14 @@ class ArtifactRepository extends ArrayRepository
|
||||||
$package = $this->getComposerInformation($file);
|
$package = $this->getComposerInformation($file);
|
||||||
if (!$package) {
|
if (!$package) {
|
||||||
if ($io->isVerbose()) {
|
if ($io->isVerbose()) {
|
||||||
$io->write("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package");
|
$io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($io->isVerbose()) {
|
if ($io->isVerbose()) {
|
||||||
$template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
|
$template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
|
||||||
$io->write(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()));
|
$io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addPackage($package);
|
$this->addPackage($package);
|
||||||
|
|
|
@ -434,7 +434,7 @@ class ComposerRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['warning'])) {
|
if (!empty($data['warning'])) {
|
||||||
$this->io->write('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
|
$this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['providers-lazy-url'])) {
|
if (!empty($data['providers-lazy-url'])) {
|
||||||
|
@ -613,8 +613,8 @@ class ComposerRepository extends ArrayRepository
|
||||||
|
|
||||||
if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
|
if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
|
||||||
if (!$this->degradedMode) {
|
if (!$this->degradedMode) {
|
||||||
$this->io->write('<warning>'.$e->getMessage().'</warning>');
|
$this->io->writeError('<warning>'.$e->getMessage().'</warning>');
|
||||||
$this->io->write('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
|
$this->io->writeError('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
|
||||||
}
|
}
|
||||||
$this->degradedMode = true;
|
$this->degradedMode = true;
|
||||||
$data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
|
$data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
|
||||||
|
|
|
@ -66,13 +66,13 @@ class PearRepository extends ArrayRepository
|
||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
|
||||||
$this->io->write('Initializing PEAR repository '.$this->url);
|
$this->io->writeError('Initializing PEAR repository '.$this->url);
|
||||||
|
|
||||||
$reader = new ChannelReader($this->rfs);
|
$reader = new ChannelReader($this->rfs);
|
||||||
try {
|
try {
|
||||||
$channelInfo = $reader->read($this->url);
|
$channelInfo = $reader->read($this->url);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->io->write('<warning>PEAR repository from '.$this->url.' could not be loaded. '.$e->getMessage().'</warning>');
|
$this->io->writeError('<warning>PEAR repository from '.$this->url.' could not be loaded. '.$e->getMessage().'</warning>');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class PearRepository extends ArrayRepository
|
||||||
$normalizedVersion = $versionParser->normalize($version);
|
$normalizedVersion = $versionParser->normalize($version);
|
||||||
} catch (\UnexpectedValueException $e) {
|
} catch (\UnexpectedValueException $e) {
|
||||||
if ($this->io->isVerbose()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->write('Could not load '.$packageDefinition->getPackageName().' '.$version.': '.$e->getMessage());
|
$this->io->writeError('Could not load '.$packageDefinition->getPackageName().' '.$version.': '.$e->getMessage());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
||||||
|
|
||||||
if (!extension_loaded('openssl')) {
|
if (!extension_loaded('openssl')) {
|
||||||
if ($io->isVerbose()) {
|
if ($io->isVerbose()) {
|
||||||
$io->write('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
$io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -66,7 +66,7 @@ class GitDriver extends VcsDriver
|
||||||
};
|
};
|
||||||
$gitUtil->runCommand($commandCallable, $this->url, $this->repoDir);
|
$gitUtil->runCommand($commandCallable, $this->url, $this->repoDir);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->io->write('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$e->getMessage().')</error>');
|
$this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$e->getMessage().')</error>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// clean up directory and do a fresh clone into it
|
// clean up directory and do a fresh clone into it
|
||||||
|
|
|
@ -266,7 +266,7 @@ class GitHubDriver extends VcsDriver
|
||||||
|
|
||||||
if (!extension_loaded('openssl')) {
|
if (!extension_loaded('openssl')) {
|
||||||
if ($io->isVerbose()) {
|
if ($io->isVerbose()) {
|
||||||
$io->write('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
$io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -333,7 +333,7 @@ class GitHubDriver extends VcsDriver
|
||||||
|
|
||||||
if (!$this->io->hasAuthentication($this->originUrl)) {
|
if (!$this->io->hasAuthentication($this->originUrl)) {
|
||||||
if (!$this->io->isInteractive()) {
|
if (!$this->io->isInteractive()) {
|
||||||
$this->io->write('<error>GitHub API limit exhausted. Failed to get metadata for the '.$this->url.' repository, try running in interactive mode so that you can enter your GitHub credentials to increase the API limit</error>');
|
$this->io->writeError('<error>GitHub API limit exhausted. Failed to get metadata for the '.$this->url.' repository, try running in interactive mode so that you can enter your GitHub credentials to increase the API limit</error>');
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ class GitHubDriver extends VcsDriver
|
||||||
|
|
||||||
if ($rateLimited) {
|
if ($rateLimited) {
|
||||||
$rateLimit = $this->getRateLimit($e->getHeaders());
|
$rateLimit = $this->getRateLimit($e->getHeaders());
|
||||||
$this->io->write(sprintf(
|
$this->io->writeError(sprintf(
|
||||||
'<error>GitHub API limit (%d calls/hr) is exhausted. You are already authorized so you have to wait until %s before doing more requests</error>',
|
'<error>GitHub API limit (%d calls/hr) is exhausted. You are already authorized so you have to wait until %s before doing more requests</error>',
|
||||||
$rateLimit['limit'],
|
$rateLimit['limit'],
|
||||||
$rateLimit['reset']
|
$rateLimit['reset']
|
||||||
|
@ -435,7 +435,7 @@ class GitHubDriver extends VcsDriver
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
$this->gitDriver = null;
|
$this->gitDriver = null;
|
||||||
|
|
||||||
$this->io->write('<error>Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your GitHub credentials</error>');
|
$this->io->writeError('<error>Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your GitHub credentials</error>');
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ class HgBitbucketDriver extends VcsDriver
|
||||||
|
|
||||||
if (!extension_loaded('openssl')) {
|
if (!extension_loaded('openssl')) {
|
||||||
if ($io->isVerbose()) {
|
if ($io->isVerbose()) {
|
||||||
$io->write('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
$io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,7 +50,7 @@ class HgDriver extends VcsDriver
|
||||||
// update the repo if it is a valid hg repository
|
// update the repo if it is a valid hg repository
|
||||||
if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
|
if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
|
||||||
if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
|
if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
|
||||||
$this->io->write('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
|
$this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// clean up directory and do a fresh clone into it
|
// clean up directory and do a fresh clone into it
|
||||||
|
|
|
@ -127,16 +127,16 @@ class VcsRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
|
$this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($driver->getTags() as $tag => $identifier) {
|
foreach ($driver->getTags() as $tag => $identifier) {
|
||||||
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
|
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write($msg);
|
$this->io->writeError($msg);
|
||||||
} else {
|
} else {
|
||||||
$this->io->overwrite($msg, false);
|
$this->io->overwriteError($msg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip the release- prefix from tags if present
|
// strip the release- prefix from tags if present
|
||||||
|
@ -144,7 +144,7 @@ class VcsRepository extends ArrayRepository
|
||||||
|
|
||||||
if (!$parsedTag = $this->validateTag($tag)) {
|
if (!$parsedTag = $this->validateTag($tag)) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ class VcsRepository extends ArrayRepository
|
||||||
try {
|
try {
|
||||||
if (!$data = $driver->getComposerInformation($identifier)) {
|
if (!$data = $driver->getComposerInformation($identifier)) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped tag '.$tag.', no composer file</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -173,39 +173,39 @@ class VcsRepository extends ArrayRepository
|
||||||
// broken package, version doesn't match tag
|
// broken package, version doesn't match tag
|
||||||
if ($data['version_normalized'] !== $parsedTag) {
|
if ($data['version_normalized'] !== $parsedTag) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')');
|
$this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
|
$this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$verbose) {
|
if (!$verbose) {
|
||||||
$this->io->overwrite('', false);
|
$this->io->overwriteError('', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($driver->getBranches() as $branch => $identifier) {
|
foreach ($driver->getBranches() as $branch => $identifier) {
|
||||||
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
|
$msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write($msg);
|
$this->io->writeError($msg);
|
||||||
} else {
|
} else {
|
||||||
$this->io->overwrite($msg, false);
|
$this->io->overwriteError($msg, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$parsedBranch = $this->validateBranch($branch)) {
|
if (!$parsedBranch = $this->validateBranch($branch)) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped branch '.$branch.', invalid name</warning>');
|
$this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ class VcsRepository extends ArrayRepository
|
||||||
try {
|
try {
|
||||||
if (!$data = $driver->getComposerInformation($identifier)) {
|
if (!$data = $driver->getComposerInformation($identifier)) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped branch '.$branch.', no composer file</warning>');
|
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class VcsRepository extends ArrayRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('Importing branch '.$branch.' ('.$data['version'].')');
|
$this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
|
||||||
}
|
}
|
||||||
|
|
||||||
$packageData = $this->preProcess($driver, $data, $identifier);
|
$packageData = $this->preProcess($driver, $data, $identifier);
|
||||||
|
@ -241,23 +241,23 @@ class VcsRepository extends ArrayRepository
|
||||||
$this->addPackage($package);
|
$this->addPackage($package);
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$this->io->write('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
|
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (!$verbose) {
|
if (!$verbose) {
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
}
|
}
|
||||||
$this->branchErrorOccurred = true;
|
$this->branchErrorOccurred = true;
|
||||||
$this->io->write('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
|
$this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
|
||||||
$this->io->write('');
|
$this->io->writeError('');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$driver->cleanup();
|
$driver->cleanup();
|
||||||
|
|
||||||
if (!$verbose) {
|
if (!$verbose) {
|
||||||
$this->io->overwrite('', false);
|
$this->io->overwriteError('', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getPackages()) {
|
if (!$this->getPackages()) {
|
||||||
|
|
|
@ -122,7 +122,7 @@ class Git
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(' Authentication required (<info>'.parse_url($url, PHP_URL_HOST).'</info>):');
|
$this->io->writeError(' Authentication required (<info>'.parse_url($url, PHP_URL_HOST).'</info>):');
|
||||||
$auth = array(
|
$auth = array(
|
||||||
'username' => $this->io->ask(' Username: ', $defaultUsername),
|
'username' => $this->io->ask(' Username: ', $defaultUsername),
|
||||||
'password' => $this->io->askAndHideAnswer(' Password: '),
|
'password' => $this->io->askAndHideAnswer(' Password: '),
|
||||||
|
|
|
@ -77,11 +77,11 @@ class GitHub
|
||||||
public function authorizeOAuthInteractively($originUrl, $message = null)
|
public function authorizeOAuthInteractively($originUrl, $message = null)
|
||||||
{
|
{
|
||||||
if ($message) {
|
if ($message) {
|
||||||
$this->io->write($message);
|
$this->io->writeError($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
|
$this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
|
||||||
$this->io->write('To revoke access to this token you can visit https://github.com/settings/applications');
|
$this->io->writeError('To revoke access to this token you can visit https://github.com/settings/applications');
|
||||||
|
|
||||||
$otp = null;
|
$otp = null;
|
||||||
$attemptCounter = 0;
|
$attemptCounter = 0;
|
||||||
|
@ -105,13 +105,13 @@ class GitHub
|
||||||
}
|
}
|
||||||
|
|
||||||
if (401 === $e->getCode()) {
|
if (401 === $e->getCode()) {
|
||||||
$this->io->write('Bad credentials.');
|
$this->io->writeError('Bad credentials.');
|
||||||
} else {
|
} else {
|
||||||
$this->io->write('Maximum number of login attempts exceeded. Please try again later.');
|
$this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write('You can also manually create a personal token at https://github.com/settings/applications');
|
$this->io->writeError('You can also manually create a personal token at https://github.com/settings/applications');
|
||||||
$this->io->write('Add it using "composer config github-oauth.github.com <token>"');
|
$this->io->writeError('Add it using "composer config github-oauth.github.com <token>"');
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ class GitHub
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->io->write('Token successfully created');
|
$this->io->writeError('Token successfully created');
|
||||||
|
|
||||||
return JsonFile::parseJson($json);
|
return JsonFile::parseJson($json);
|
||||||
}
|
}
|
||||||
|
@ -184,14 +184,14 @@ class GitHub
|
||||||
list($required, $method) = array_map('trim', explode(';', substr(strstr($headers[$key], ':'), 1)));
|
list($required, $method) = array_map('trim', explode(';', substr(strstr($headers[$key], ':'), 1)));
|
||||||
|
|
||||||
if ('required' === $required) {
|
if ('required' === $required) {
|
||||||
$this->io->write('Two-factor Authentication');
|
$this->io->writeError('Two-factor Authentication');
|
||||||
|
|
||||||
if ('app' === $method) {
|
if ('app' === $method) {
|
||||||
$this->io->write('Open the two-factor authentication app on your device to view your authentication code and verify your identity.');
|
$this->io->writeError('Open the two-factor authentication app on your device to view your authentication code and verify your identity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('sms' === $method) {
|
if ('sms' === $method) {
|
||||||
$this->io->write('You have been sent an SMS message with an authentication code to verify your identity.');
|
$this->io->writeError('You have been sent an SMS message with an authentication code to verify your identity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->io->ask('Authentication Code: ');
|
return $this->io->ask('Authentication Code: ');
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ProcessExecutor
|
||||||
{
|
{
|
||||||
if ($this->io && $this->io->isDebug()) {
|
if ($this->io && $this->io->isDebug()) {
|
||||||
$safeCommand = preg_replace('{(://[^:/\s]+:)[^@\s/]+}i', '$1****', $command);
|
$safeCommand = preg_replace('{(://[^:/\s]+:)[^@\s/]+}i', '$1****', $command);
|
||||||
$this->io->write('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
|
$this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that null translate to the proper directory in case the dir is a symlink
|
// make sure that null translate to the proper directory in case the dir is a symlink
|
||||||
|
|
|
@ -146,7 +146,7 @@ class RemoteFilesystem
|
||||||
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
||||||
|
|
||||||
if ($this->io->isDebug()) {
|
if ($this->io->isDebug()) {
|
||||||
$this->io->write((substr($fileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . $fileUrl);
|
$this->io->writeError((substr($fileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . $fileUrl);
|
||||||
}
|
}
|
||||||
if (isset($options['github-token'])) {
|
if (isset($options['github-token'])) {
|
||||||
$fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token'];
|
$fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token'];
|
||||||
|
@ -158,7 +158,7 @@ class RemoteFilesystem
|
||||||
$ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
|
$ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
|
||||||
|
|
||||||
if ($this->progress) {
|
if ($this->progress) {
|
||||||
$this->io->write(" Downloading: <comment>connection...</comment>", false);
|
$this->io->writeError(" Downloading: <comment>connection...</comment>", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errorMessage = '';
|
$errorMessage = '';
|
||||||
|
@ -228,7 +228,7 @@ class RemoteFilesystem
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->progress && !$this->retry) {
|
if ($this->progress && !$this->retry) {
|
||||||
$this->io->overwrite(" Downloading: <comment>100%</comment>");
|
$this->io->overwriteError(" Downloading: <comment>100%</comment>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle copy command if download was successful
|
// handle copy command if download was successful
|
||||||
|
@ -329,7 +329,7 @@ class RemoteFilesystem
|
||||||
|
|
||||||
if ((0 === $progression % 5) && $progression !== $this->lastProgress) {
|
if ((0 === $progression % 5) && $progression !== $this->lastProgress) {
|
||||||
$this->lastProgress = $progression;
|
$this->lastProgress = $progression;
|
||||||
$this->io->overwrite(" Downloading: <comment>$progression%</comment>", false);
|
$this->io->overwriteError(" Downloading: <comment>$progression%</comment>", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -371,7 +371,7 @@ class RemoteFilesystem
|
||||||
throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus);
|
throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->overwrite(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
|
$this->io->overwriteError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
|
||||||
$username = $this->io->ask(' Username: ');
|
$username = $this->io->ask(' Username: ');
|
||||||
$password = $this->io->askAndHideAnswer(' Password: ');
|
$password = $this->io->askAndHideAnswer(' Password: ');
|
||||||
$this->io->setAuthentication($this->originUrl, $username, $password);
|
$this->io->setAuthentication($this->originUrl, $username, $password);
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Svn
|
||||||
}
|
}
|
||||||
$output .= $buffer;
|
$output .= $buffer;
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$io->write($buffer, false);
|
$io->writeError($buffer, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$status = $this->process->execute($svnCommand, $handler, $cwd);
|
$status = $this->process->execute($svnCommand, $handler, $cwd);
|
||||||
|
@ -169,7 +169,7 @@ class Svn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->write("The Subversion server ({$this->url}) requested credentials:");
|
$this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
|
||||||
|
|
||||||
$this->hasAuth = true;
|
$this->hasAuth = true;
|
||||||
$this->credentials['username'] = $this->io->ask("Username: ");
|
$this->credentials['username'] = $this->io->ask("Username: ");
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ApplicationTest extends TestCase
|
||||||
->will($this->returnValue('list'));
|
->will($this->returnValue('list'));
|
||||||
|
|
||||||
$outputMock->expects($this->once())
|
$outputMock->expects($this->once())
|
||||||
->method("writeln")
|
->method("write")
|
||||||
->with($this->equalTo(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF'])));
|
->with($this->equalTo(sprintf('<warning>Warning: This development build of composer is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF'])));
|
||||||
|
|
||||||
if (!defined('COMPOSER_DEV_WARNING_TIME')) {
|
if (!defined('COMPOSER_DEV_WARNING_TIME')) {
|
||||||
|
|
|
@ -128,7 +128,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
->method('write')
|
->method('writeError')
|
||||||
->will($this->returnCallback(function ($text) use (&$msg) {
|
->will($this->returnCallback(function ($text) use (&$msg) {
|
||||||
$msg = $text;
|
$msg = $text;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -120,7 +120,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$ref = 'SOURCE_REF@123';
|
$ref = 'SOURCE_REF@123';
|
||||||
$label = 123;
|
$label = 123;
|
||||||
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
|
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
|
||||||
$this->io->expects($this->once())->method('write')->with($this->stringContains('Cloning '.$ref));
|
$this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
|
||||||
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
|
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
|
||||||
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
|
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
|
||||||
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
|
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
|
||||||
|
@ -143,7 +143,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$ref = 'SOURCE_REF';
|
$ref = 'SOURCE_REF';
|
||||||
$label = null;
|
$label = null;
|
||||||
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
|
$this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
|
||||||
$this->io->expects($this->once())->method('write')->with($this->stringContains('Cloning '.$ref));
|
$this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning '.$ref));
|
||||||
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
|
$perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
|
||||||
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
|
$perforce = $this->getMockBuilder('Composer\Util\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
|
||||||
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
|
$perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
|
||||||
|
|
|
@ -33,7 +33,7 @@ class EventDispatcherTest extends TestCase
|
||||||
), $io);
|
), $io);
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
->method('write')
|
->method('writeError')
|
||||||
->with('<error>Script Composer\Test\EventDispatcher\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception</error>');
|
->with('<error>Script Composer\Test\EventDispatcher\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception</error>');
|
||||||
|
|
||||||
$dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
|
$dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
|
||||||
|
@ -189,7 +189,7 @@ class EventDispatcherTest extends TestCase
|
||||||
->will($this->returnValue($listener));
|
->will($this->returnValue($listener));
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
->method('write')
|
->method('writeError')
|
||||||
->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with an error</error>'));
|
->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with an error</error>'));
|
||||||
|
|
||||||
$this->setExpectedException('RuntimeException');
|
$this->setExpectedException('RuntimeException');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--RUN--
|
--RUN--
|
||||||
create-project seld/jsonlint %testDir% 1.0.0 --prefer-source -n
|
create-project seld/jsonlint %testDir% 1.0.0 --prefer-source -n
|
||||||
--EXPECT--
|
--EXPECT-ERROR--
|
||||||
Installing seld/jsonlint (1.0.0)
|
Installing seld/jsonlint (1.0.0)
|
||||||
- Installing seld/jsonlint (1.0.0)
|
- Installing seld/jsonlint (1.0.0)
|
||||||
Cloning 3b4bc2a96ff5d3fe6866bfe9dd0c845246705791
|
Cloning 3b4bc2a96ff5d3fe6866bfe9dd0c845246705791
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
--RUN--
|
--RUN--
|
||||||
create-project --repository-url=packages.json -v seld/jsonlint %testDir% dev-master
|
create-project --repository-url=packages.json -v seld/jsonlint %testDir% dev-master
|
||||||
--EXPECT-REGEX--
|
--EXPECT-ERROR-REGEX--
|
||||||
{^Installing seld/jsonlint \(dev-master [a-f0-9]{40}\)}
|
{^Installing seld/jsonlint \(dev-master [a-f0-9]{40}\)}
|
||||||
|
|
|
@ -49,6 +49,22 @@ class ConsoleIOTest extends TestCase
|
||||||
$consoleIO->write('some information about something', false);
|
$consoleIO->write('some information about something', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWriteError()
|
||||||
|
{
|
||||||
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
|
$outputMock = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface');
|
||||||
|
$outputMock->expects($this->once())
|
||||||
|
->method('getErrorOutput')
|
||||||
|
->willReturn($outputMock);
|
||||||
|
$outputMock->expects($this->once())
|
||||||
|
->method('write')
|
||||||
|
->with($this->equalTo('some information about something'), $this->equalTo(false));
|
||||||
|
$helperMock = $this->getMock('Symfony\Component\Console\Helper\HelperSet');
|
||||||
|
|
||||||
|
$consoleIO = new ConsoleIO($inputMock, $outputMock, $helperMock);
|
||||||
|
$consoleIO->writeError('some information about something', false);
|
||||||
|
}
|
||||||
|
|
||||||
public function testWriteWithMultipleLineStringWhenDebugging()
|
public function testWriteWithMultipleLineStringWhenDebugging()
|
||||||
{
|
{
|
||||||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
|
|
|
@ -149,11 +149,15 @@ class InstallerTest extends TestCase
|
||||||
|
|
||||||
$output = null;
|
$output = null;
|
||||||
$io = $this->getMock('Composer\IO\IOInterface');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
|
$callback = function ($text, $newline) use (&$output) {
|
||||||
|
$output .= $text . ($newline ? "\n" : "");
|
||||||
|
};
|
||||||
$io->expects($this->any())
|
$io->expects($this->any())
|
||||||
->method('write')
|
->method('write')
|
||||||
->will($this->returnCallback(function ($text, $newline) use (&$output) {
|
->will($this->returnCallback($callback));
|
||||||
$output .= $text . ($newline ? "\n" : "");
|
$io->expects($this->any())
|
||||||
}));
|
->method('writeError')
|
||||||
|
->will($this->returnCallback($callback));
|
||||||
|
|
||||||
$composer = FactoryMock::create($io, $composerConfig);
|
$composer = FactoryMock::create($io, $composerConfig);
|
||||||
|
|
||||||
|
@ -195,10 +199,7 @@ class InstallerTest extends TestCase
|
||||||
$composer->setAutoloadGenerator($autoloadGenerator);
|
$composer->setAutoloadGenerator($autoloadGenerator);
|
||||||
$composer->setEventDispatcher($eventDispatcher);
|
$composer->setEventDispatcher($eventDispatcher);
|
||||||
|
|
||||||
$installer = Installer::create(
|
$installer = Installer::create($io, $composer);
|
||||||
$io,
|
|
||||||
$composer
|
|
||||||
);
|
|
||||||
|
|
||||||
$application = new Application;
|
$application = new Application;
|
||||||
$application->get('install')->setCode(function ($input, $output) use ($installer) {
|
$application->get('install')->setCode(function ($input, $output) use ($installer) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ class GitHubTest extends \PHPUnit_Framework_TestCase
|
||||||
$io = $this->getIOMock();
|
$io = $this->getIOMock();
|
||||||
$io
|
$io
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
->method('write')
|
->method('writeError')
|
||||||
->with($this->message)
|
->with($this->message)
|
||||||
;
|
;
|
||||||
$io
|
$io
|
||||||
|
|
|
@ -119,7 +119,7 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
|
||||||
$io = $this->getMock('Composer\IO\IOInterface');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
$io
|
$io
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('overwrite')
|
->method('overwriteError')
|
||||||
;
|
;
|
||||||
|
|
||||||
$fs = new RemoteFilesystem($io);
|
$fs = new RemoteFilesystem($io);
|
||||||
|
|
Loading…
Reference in New Issue