commit
7267b2ed90
|
@ -464,6 +464,7 @@ EOT
|
||||||
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
|
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
|
||||||
{
|
{
|
||||||
$origK = $k;
|
$origK = $k;
|
||||||
|
$io = $this->getIO();
|
||||||
foreach ($contents as $key => $value) {
|
foreach ($contents as $key => $value) {
|
||||||
if ($k === null && !in_array($key, array('config', 'repositories'))) {
|
if ($k === null && !in_array($key, array('config', 'repositories'))) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -498,9 +499,9 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($rawVal) && $rawVal != $value) {
|
if (is_string($rawVal) && $rawVal != $value) {
|
||||||
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
|
$io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
|
$io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,16 +100,17 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$config = Factory::createConfig();
|
$config = Factory::createConfig();
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist, true);
|
$this->updatePreferredOptions($config, $input, $preferSource, $preferDist, true);
|
||||||
|
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->installProject(
|
return $this->installProject(
|
||||||
$this->getIO(),
|
$io,
|
||||||
$config,
|
$config,
|
||||||
$input->getArgument('package'),
|
$input->getArgument('package'),
|
||||||
$input->getArgument('directory'),
|
$input->getArgument('directory'),
|
||||||
|
|
|
@ -81,6 +81,7 @@ EOT
|
||||||
|
|
||||||
$messages = array();
|
$messages = array();
|
||||||
$outputPackages = array();
|
$outputPackages = array();
|
||||||
|
$io = $this->getIO();
|
||||||
foreach ($repo->getPackages() as $package) {
|
foreach ($repo->getPackages() as $package) {
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
||||||
|
@ -96,9 +97,9 @@ EOT
|
||||||
|
|
||||||
if ($messages) {
|
if ($messages) {
|
||||||
sort($messages);
|
sort($messages);
|
||||||
$this->getIO()->write($messages);
|
$io->write($messages);
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError('<info>There is no installed package depending on "'.$needle.'".</info>');
|
$io->writeError('<info>There is no installed package depending on "'.$needle.'".</info>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,12 +57,13 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$composer = $this->getComposer(false);
|
$composer = $this->getComposer(false);
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
if ($composer) {
|
if ($composer) {
|
||||||
$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);
|
||||||
|
|
||||||
$this->getIO()->write('Checking composer.json: ', false);
|
$io->write('Checking composer.json: ', false);
|
||||||
$this->outputResult($this->checkComposerSchema());
|
$this->outputResult($this->checkComposerSchema());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,44 +73,44 @@ EOT
|
||||||
$config = Factory::createConfig();
|
$config = Factory::createConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->rfs = new RemoteFilesystem($this->getIO(), $config);
|
$this->rfs = new RemoteFilesystem($io, $config);
|
||||||
$this->process = new ProcessExecutor($this->getIO());
|
$this->process = new ProcessExecutor($io);
|
||||||
|
|
||||||
$this->getIO()->write('Checking platform settings: ', false);
|
$io->write('Checking platform settings: ', false);
|
||||||
$this->outputResult($this->checkPlatform());
|
$this->outputResult($this->checkPlatform());
|
||||||
|
|
||||||
$this->getIO()->write('Checking git settings: ', false);
|
$io->write('Checking git settings: ', false);
|
||||||
$this->outputResult($this->checkGit());
|
$this->outputResult($this->checkGit());
|
||||||
|
|
||||||
$this->getIO()->write('Checking http connectivity to packagist: ', false);
|
$io->write('Checking http connectivity to packagist: ', false);
|
||||||
$this->outputResult($this->checkHttp('http'));
|
$this->outputResult($this->checkHttp('http'));
|
||||||
|
|
||||||
$this->getIO()->write('Checking https connectivity to packagist: ', false);
|
$io->write('Checking https connectivity to packagist: ', false);
|
||||||
$this->outputResult($this->checkHttp('https'));
|
$this->outputResult($this->checkHttp('https'));
|
||||||
|
|
||||||
$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'])) {
|
||||||
$this->getIO()->write('Checking HTTP proxy: ', false);
|
$io->write('Checking HTTP proxy: ', false);
|
||||||
$this->outputResult($this->checkHttpProxy());
|
$this->outputResult($this->checkHttpProxy());
|
||||||
$this->getIO()->write('Checking HTTP proxy support for request_fulluri: ', false);
|
$io->write('Checking HTTP proxy support for request_fulluri: ', false);
|
||||||
$this->outputResult($this->checkHttpProxyFullUriRequestParam());
|
$this->outputResult($this->checkHttpProxyFullUriRequestParam());
|
||||||
$this->getIO()->write('Checking HTTPS proxy support for request_fulluri: ', false);
|
$io->write('Checking HTTPS proxy support for request_fulluri: ', false);
|
||||||
$this->outputResult($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) {
|
||||||
$this->getIO()->write('Checking '.$domain.' oauth access: ', false);
|
$io->write('Checking '.$domain.' oauth access: ', false);
|
||||||
$this->outputResult($this->checkGithubOauth($domain, $token));
|
$this->outputResult($this->checkGithubOauth($domain, $token));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->write('Checking github.com rate limit: ', false);
|
$io->write('Checking github.com rate limit: ', false);
|
||||||
try {
|
try {
|
||||||
$rate = $this->getGithubRateLimit('github.com');
|
$rate = $this->getGithubRateLimit('github.com');
|
||||||
$this->outputResult(true);
|
$this->outputResult(true);
|
||||||
if (10 > $rate['remaining']) {
|
if (10 > $rate['remaining']) {
|
||||||
$this->getIO()->write('<warning>WARNING</warning>');
|
$io->write('<warning>WARNING</warning>');
|
||||||
$this->getIO()->write(sprintf(
|
$io->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
|
||||||
|
@ -128,10 +129,10 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->write('Checking disk free space: ', false);
|
$io->write('Checking disk free space: ', false);
|
||||||
$this->outputResult($this->checkDiskSpace($config));
|
$this->outputResult($this->checkDiskSpace($config));
|
||||||
|
|
||||||
$this->getIO()->write('Checking composer version: ', false);
|
$io->write('Checking composer version: ', false);
|
||||||
$this->outputResult($this->checkVersion());
|
$this->outputResult($this->checkVersion());
|
||||||
|
|
||||||
return $this->failures;
|
return $this->failures;
|
||||||
|
@ -322,15 +323,16 @@ EOT
|
||||||
*/
|
*/
|
||||||
private function outputResult($result)
|
private function outputResult($result)
|
||||||
{
|
{
|
||||||
|
$io = $this->getIO();
|
||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
$this->getIO()->write('<info>OK</info>');
|
$io->write('<info>OK</info>');
|
||||||
} else {
|
} else {
|
||||||
$this->failures++;
|
$this->failures++;
|
||||||
$this->getIO()->write('<error>FAIL</error>');
|
$io->write('<error>FAIL</error>');
|
||||||
if ($result instanceof \Exception) {
|
if ($result instanceof \Exception) {
|
||||||
$this->getIO()->write('['.get_class($result).'] '.$result->getMessage());
|
$io->write('['.get_class($result).'] '.$result->getMessage());
|
||||||
} elseif ($result) {
|
} elseif ($result) {
|
||||||
$this->getIO()->write(trim($result));
|
$io->write(trim($result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$repos = $this->initializeRepos();
|
$repos = $this->initializeRepos();
|
||||||
|
$io = $this->getIO();
|
||||||
$return = 0;
|
$return = 0;
|
||||||
|
|
||||||
foreach ($input->getArgument('packages') as $packageName) {
|
foreach ($input->getArgument('packages') as $packageName) {
|
||||||
|
@ -74,12 +75,12 @@ EOT
|
||||||
|
|
||||||
if (!$packageExists) {
|
if (!$packageExists) {
|
||||||
$return = 1;
|
$return = 1;
|
||||||
$this->getIO()->writeError('<warning>Package '.$packageName.' not found</warning>');
|
$io->writeError('<warning>Package '.$packageName.' not found</warning>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$handled) {
|
if (!$handled) {
|
||||||
$return = 1;
|
$return = 1;
|
||||||
$this->getIO()->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
|
$io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,11 +106,12 @@ EOT
|
||||||
|
|
||||||
$file = new JsonFile('composer.json');
|
$file = new JsonFile('composer.json');
|
||||||
$json = $file->encode($options);
|
$json = $file->encode($options);
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
if ($input->isInteractive()) {
|
if ($input->isInteractive()) {
|
||||||
$this->getIO()->writeError(array('', $json, ''));
|
$io->writeError(array('', $json, ''));
|
||||||
if (!$this->getIO()->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ', true)) {
|
if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ', true)) {
|
||||||
$this->getIO()->writeError('<error>Command aborted</error>');
|
$io->writeError('<error>Command aborted</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +129,7 @@ EOT
|
||||||
if (!$this->hasVendorIgnore($ignoreFile)) {
|
if (!$this->hasVendorIgnore($ignoreFile)) {
|
||||||
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
|
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
|
||||||
|
|
||||||
if ($this->getIO()->askConfirmation($question, true)) {
|
if ($io->askConfirmation($question, true)) {
|
||||||
$this->addVendorIgnore($ignoreFile);
|
$this->addVendorIgnore($ignoreFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,17 +142,17 @@ EOT
|
||||||
protected function interact(InputInterface $input, OutputInterface $output)
|
protected function interact(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$git = $this->getGitConfig();
|
$git = $this->getGitConfig();
|
||||||
|
$io = $this->getIO();
|
||||||
$formatter = $this->getHelperSet()->get('formatter');
|
$formatter = $this->getHelperSet()->get('formatter');
|
||||||
|
|
||||||
$this->getIO()->writeError(array(
|
$io->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
|
||||||
$this->getIO()->writeError(array(
|
$io->writeError(array(
|
||||||
'',
|
'',
|
||||||
'This command will guide you through creating your composer.json config.',
|
'This command will guide you through creating your composer.json config.',
|
||||||
'',
|
'',
|
||||||
|
@ -181,7 +182,7 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $this->getIO()->askAndValidate(
|
$name = $io->askAndValidate(
|
||||||
'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
|
'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
|
||||||
function ($value) use ($name) {
|
function ($value) use ($name) {
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
|
@ -202,7 +203,7 @@ EOT
|
||||||
$input->setOption('name', $name);
|
$input->setOption('name', $name);
|
||||||
|
|
||||||
$description = $input->getOption('description') ?: false;
|
$description = $input->getOption('description') ?: false;
|
||||||
$description = $this->getIO()->ask(
|
$description = $io->ask(
|
||||||
'Description [<comment>'.$description.'</comment>]: ',
|
'Description [<comment>'.$description.'</comment>]: ',
|
||||||
$description
|
$description
|
||||||
);
|
);
|
||||||
|
@ -215,7 +216,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$author = $this->getIO()->askAndValidate(
|
$author = $io->askAndValidate(
|
||||||
'Author [<comment>'.$author.'</comment>]: ',
|
'Author [<comment>'.$author.'</comment>]: ',
|
||||||
function ($value) use ($self, $author) {
|
function ($value) use ($self, $author) {
|
||||||
$value = $value ?: $author;
|
$value = $value ?: $author;
|
||||||
|
@ -229,7 +230,7 @@ EOT
|
||||||
$input->setOption('author', $author);
|
$input->setOption('author', $author);
|
||||||
|
|
||||||
$minimumStability = $input->getOption('stability') ?: null;
|
$minimumStability = $input->getOption('stability') ?: null;
|
||||||
$minimumStability = $this->getIO()->askAndValidate(
|
$minimumStability = $io->askAndValidate(
|
||||||
'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
|
'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
|
||||||
function ($value) use ($self, $minimumStability) {
|
function ($value) use ($self, $minimumStability) {
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
|
@ -251,31 +252,31 @@ EOT
|
||||||
$input->setOption('stability', $minimumStability);
|
$input->setOption('stability', $minimumStability);
|
||||||
|
|
||||||
$type = $input->getOption('type') ?: false;
|
$type = $input->getOption('type') ?: false;
|
||||||
$type = $this->getIO()->ask(
|
$type = $io->ask(
|
||||||
'Package Type [<comment>'.$type.'</comment>]: ',
|
'Package Type [<comment>'.$type.'</comment>]: ',
|
||||||
$type
|
$type
|
||||||
);
|
);
|
||||||
$input->setOption('type', $type);
|
$input->setOption('type', $type);
|
||||||
|
|
||||||
$license = $input->getOption('license') ?: false;
|
$license = $input->getOption('license') ?: false;
|
||||||
$license = $this->getIO()->ask(
|
$license = $io->ask(
|
||||||
'License [<comment>'.$license.'</comment>]: ',
|
'License [<comment>'.$license.'</comment>]: ',
|
||||||
$license
|
$license
|
||||||
);
|
);
|
||||||
$input->setOption('license', $license);
|
$input->setOption('license', $license);
|
||||||
|
|
||||||
$this->getIO()->writeError(array('', 'Define your dependencies.', ''));
|
$io->writeError(array('', 'Define your dependencies.', ''));
|
||||||
|
|
||||||
$question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
|
$question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
|
||||||
$requirements = array();
|
$requirements = array();
|
||||||
if ($this->getIO()->askConfirmation($question, true)) {
|
if ($io->askConfirmation($question, true)) {
|
||||||
$requirements = $this->determineRequirements($input, $output, $input->getOption('require'));
|
$requirements = $this->determineRequirements($input, $output, $input->getOption('require'));
|
||||||
}
|
}
|
||||||
$input->setOption('require', $requirements);
|
$input->setOption('require', $requirements);
|
||||||
|
|
||||||
$question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
|
$question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
|
||||||
$devRequirements = array();
|
$devRequirements = array();
|
||||||
if ($this->getIO()->askConfirmation($question, true)) {
|
if ($io->askConfirmation($question, true)) {
|
||||||
$devRequirements = $this->determineRequirements($input, $output, $input->getOption('require-dev'));
|
$devRequirements = $this->determineRequirements($input, $output, $input->getOption('require-dev'));
|
||||||
}
|
}
|
||||||
$input->setOption('require-dev', $devRequirements);
|
$input->setOption('require-dev', $devRequirements);
|
||||||
|
@ -325,6 +326,7 @@ EOT
|
||||||
if ($requires) {
|
if ($requires) {
|
||||||
$requires = $this->normalizeRequirements($requires);
|
$requires = $this->normalizeRequirements($requires);
|
||||||
$result = array();
|
$result = array();
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
foreach ($requires as $requirement) {
|
foreach ($requires as $requirement) {
|
||||||
if (!isset($requirement['version'])) {
|
if (!isset($requirement['version'])) {
|
||||||
|
@ -332,7 +334,7 @@ EOT
|
||||||
$version = $this->findBestVersionForPackage($input, $requirement['name']);
|
$version = $this->findBestVersionForPackage($input, $requirement['name']);
|
||||||
$requirement['version'] = $version;
|
$requirement['version'] = $version;
|
||||||
|
|
||||||
$this->getIO()->writeError(sprintf(
|
$io->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']
|
||||||
|
@ -346,7 +348,8 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$versionParser = new VersionParser();
|
$versionParser = new VersionParser();
|
||||||
while (null !== $package = $this->getIO()->ask('Search for a package: ')) {
|
$io = $this->getIO();
|
||||||
|
while (null !== $package = $io->ask('Search for a package: ')) {
|
||||||
$matches = $this->findPackages($package);
|
$matches = $this->findPackages($package);
|
||||||
|
|
||||||
if (count($matches)) {
|
if (count($matches)) {
|
||||||
|
@ -362,14 +365,14 @@ EOT
|
||||||
|
|
||||||
// no match, prompt which to pick
|
// no match, prompt which to pick
|
||||||
if (!$exactMatch) {
|
if (!$exactMatch) {
|
||||||
$this->getIO()->writeError(array(
|
$io->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),
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->getIO()->writeError($choices);
|
$io->writeError($choices);
|
||||||
$this->getIO()->writeError('');
|
$io->writeError('');
|
||||||
|
|
||||||
$validator = function ($selection) use ($matches, $versionParser) {
|
$validator = function ($selection) use ($matches, $versionParser) {
|
||||||
if ('' === $selection) {
|
if ('' === $selection) {
|
||||||
|
@ -399,7 +402,7 @@ EOT
|
||||||
throw new \Exception('Not a valid selection');
|
throw new \Exception('Not a valid selection');
|
||||||
};
|
};
|
||||||
|
|
||||||
$package = $this->getIO()->askAndValidate(
|
$package = $io->askAndValidate(
|
||||||
'Enter package # to add, or the complete package name if it is not listed: ',
|
'Enter package # to add, or the complete package name if it is not listed: ',
|
||||||
$validator,
|
$validator,
|
||||||
3,
|
3,
|
||||||
|
@ -415,7 +418,7 @@ EOT
|
||||||
return $input ?: false;
|
return $input ?: false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$constraint = $this->getIO()->askAndValidate(
|
$constraint = $io->askAndValidate(
|
||||||
'Enter the version constraint to require (or leave blank to use the latest version): ',
|
'Enter the version constraint to require (or leave blank to use the latest version): ',
|
||||||
$validator,
|
$validator,
|
||||||
3,
|
3,
|
||||||
|
@ -425,7 +428,7 @@ EOT
|
||||||
if (false === $constraint) {
|
if (false === $constraint) {
|
||||||
$constraint = $this->findBestVersionForPackage($input, $package);
|
$constraint = $this->findBestVersionForPackage($input, $package);
|
||||||
|
|
||||||
$this->getIO()->writeError(sprintf(
|
$io->writeError(sprintf(
|
||||||
'Using version <info>%s</info> for <info>%s</info>',
|
'Using version <info>%s</info> for <info>%s</info>',
|
||||||
$constraint,
|
$constraint,
|
||||||
$package
|
$package
|
||||||
|
|
|
@ -64,24 +64,24 @@ EOT
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = $this->getIO();
|
||||||
if ($args = $input->getArgument('packages')) {
|
if ($args = $input->getArgument('packages')) {
|
||||||
$this->getIO()->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
|
$io->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')) {
|
||||||
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('dev')) {
|
if ($input->getOption('dev')) {
|
||||||
$this->getIO()->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
$io->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'));
|
||||||
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
$io = $this->getIO();
|
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
|
@ -62,14 +62,15 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($packages);
|
ksort($packages);
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
switch ($format = $input->getOption('format')) {
|
switch ($format = $input->getOption('format')) {
|
||||||
case 'text':
|
case 'text':
|
||||||
$this->getIO()->write('Name: <comment>'.$root->getPrettyName().'</comment>');
|
$io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
|
||||||
$this->getIO()->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
|
$io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
|
||||||
$this->getIO()->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
|
$io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
|
||||||
$this->getIO()->write('Dependencies:');
|
$io->write('Dependencies:');
|
||||||
$this->getIO()->write('');
|
$io->write('');
|
||||||
|
|
||||||
$table = new Table($output);
|
$table = new Table($output);
|
||||||
$table->setStyle('compact');
|
$table->setStyle('compact');
|
||||||
|
@ -94,7 +95,7 @@ EOT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->write(JsonFile::encode(array(
|
$io->write(JsonFile::encode(array(
|
||||||
'name' => $root->getPrettyName(),
|
'name' => $root->getPrettyName(),
|
||||||
'version' => $root->getFullPrettyVersion(),
|
'version' => $root->getFullPrettyVersion(),
|
||||||
'license' => $root->getLicense(),
|
'license' => $root->getLicense(),
|
||||||
|
|
|
@ -68,19 +68,20 @@ EOT
|
||||||
|
|
||||||
$type = $input->getOption('dev') ? 'require-dev' : 'require';
|
$type = $input->getOption('dev') ? 'require-dev' : 'require';
|
||||||
$altType = !$input->getOption('dev') ? 'require-dev' : 'require';
|
$altType = !$input->getOption('dev') ? 'require-dev' : 'require';
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
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])) {
|
||||||
$this->getIO()->writeError('<warning>'.$package.' could not be found in '.$type.' but it is present in '.$altType.'</warning>');
|
$io->writeError('<warning>'.$package.' could not be found in '.$type.' but it is present in '.$altType.'</warning>');
|
||||||
if ($this->getIO()->isInteractive()) {
|
if ($io->isInteractive()) {
|
||||||
if ($this->getIO()->askConfirmation('Do you want to remove it from '.$altType.' [<comment>yes</comment>]? ', true)) {
|
if ($io->askConfirmation('Do you want to remove it from '.$altType.' [<comment>yes</comment>]? ', true)) {
|
||||||
$json->removeLink($altType, $package);
|
$json->removeLink($altType, $package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
|
$io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +92,6 @@ EOT
|
||||||
// Update packages
|
// Update packages
|
||||||
$composer = $this->getComposer();
|
$composer = $this->getComposer();
|
||||||
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
$io = $this->getIO();
|
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
@ -110,7 +110,7 @@ EOT
|
||||||
|
|
||||||
$status = $install->run();
|
$status = $install->run();
|
||||||
if ($status !== 0) {
|
if ($status !== 0) {
|
||||||
$this->getIO()->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
|
$io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
|
||||||
file_put_contents($jsonFile->getPath(), $composerBackup);
|
file_put_contents($jsonFile->getPath(), $composerBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,20 +64,21 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$file = Factory::getComposerFile();
|
$file = Factory::getComposerFile();
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
$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")) {
|
||||||
$this->getIO()->writeError('<error>'.$file.' could not be created.</error>');
|
$io->writeError('<error>'.$file.' could not be created.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
$this->getIO()->writeError('<error>'.$file.' is not readable.</error>');
|
$io->writeError('<error>'.$file.' is not readable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_writable($file)) {
|
if (!is_writable($file)) {
|
||||||
$this->getIO()->writeError('<error>'.$file.' is not writable.</error>');
|
$io->writeError('<error>'.$file.' is not writable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,7 @@ EOT
|
||||||
$json->write($composerDefinition);
|
$json->write($composerDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->writeError('<info>'.$file.' has been '.($newlyCreated ? 'created' : 'updated').'</info>');
|
$io->writeError('<info>'.$file.' has been '.($newlyCreated ? 'created' : 'updated').'</info>');
|
||||||
|
|
||||||
if ($input->getOption('no-update')) {
|
if ($input->getOption('no-update')) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -137,7 +138,6 @@ EOT
|
||||||
$this->resetComposer();
|
$this->resetComposer();
|
||||||
$composer = $this->getComposer();
|
$composer = $this->getComposer();
|
||||||
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
$io = $this->getIO();
|
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
@ -158,10 +158,10 @@ EOT
|
||||||
$status = $install->run();
|
$status = $install->run();
|
||||||
if ($status !== 0) {
|
if ($status !== 0) {
|
||||||
if ($newlyCreated) {
|
if ($newlyCreated) {
|
||||||
$this->getIO()->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>');
|
$io->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>');
|
||||||
unlink($json->getPath());
|
unlink($json->getPath());
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError("\n".'<error>Installation failed, reverting '.$file.' to its original content.</error>');
|
$io->writeError("\n".'<error>Installation failed, reverting '.$file.' to its original content.</error>');
|
||||||
file_put_contents($json->getPath(), $composerBackup);
|
file_put_contents($json->getPath(), $composerBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,10 @@ EOT
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->writeError('<info>scripts:</info>');
|
$io = $this->getIO();
|
||||||
|
$io->writeError('<info>scripts:</info>');
|
||||||
foreach ($scripts as $name => $script) {
|
foreach ($scripts as $name => $script) {
|
||||||
$this->getIO()->write(' ' . $name);
|
$io->write(' ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -56,13 +56,14 @@ EOT
|
||||||
{
|
{
|
||||||
// init repos
|
// init repos
|
||||||
$platformRepo = new PlatformRepository;
|
$platformRepo = new PlatformRepository;
|
||||||
|
$io = $this->getIO();
|
||||||
if ($composer = $this->getComposer(false)) {
|
if ($composer = $this->getComposer(false)) {
|
||||||
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
$localRepo = $composer->getRepositoryManager()->getLocalRepository();
|
||||||
$installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
|
$installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
|
||||||
$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($io);
|
||||||
$this->getIO()->writeError('No composer.json found in the current directory, showing packages from ' . implode(', ', array_keys($defaultRepos)));
|
$io->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 +79,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) {
|
||||||
$this->getIO()->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
|
$io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ EOT
|
||||||
{
|
{
|
||||||
$baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . self::HOMEPAGE;
|
$baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . self::HOMEPAGE;
|
||||||
$config = Factory::createConfig();
|
$config = Factory::createConfig();
|
||||||
$remoteFilesystem = new RemoteFilesystem($this->getIO(), $config);
|
$io = $this->getIO();
|
||||||
|
$remoteFilesystem = new RemoteFilesystem($io, $config);
|
||||||
$cacheDir = $config->get('cache-dir');
|
$cacheDir = $config->get('cache-dir');
|
||||||
$rollbackDir = $config->get('home');
|
$rollbackDir = $config->get('home');
|
||||||
$localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
|
$localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
|
||||||
|
@ -84,13 +85,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) {
|
||||||
$this->getIO()->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
|
$io->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) {
|
||||||
$this->getIO()->writeError('<info>You are already using composer version '.$updateVersion.'.</info>');
|
$io->writeError('<info>You are already using composer version '.$updateVersion.'.</info>');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +105,11 @@ EOT
|
||||||
self::OLD_INSTALL_EXT
|
self::OLD_INSTALL_EXT
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->getIO()->writeError(sprintf("Updating to version <info>%s</info>.", $updateVersion));
|
$io->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)) {
|
||||||
$this->getIO()->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
|
$io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -120,22 +121,22 @@ EOT
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
$file = (string) $file;
|
$file = (string) $file;
|
||||||
$this->getIO()->writeError('<info>Removing: '.$file.'</info>');
|
$io->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)) {
|
||||||
$this->getIO()->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>');
|
$io->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>');
|
||||||
$this->getIO()->writeError('<error>Please re-run the self-update command to try again.</error>');
|
$io->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)) {
|
||||||
$this->getIO()->writeError('Use <info>composer self-update --rollback</info> to return to version '.Composer::VERSION);
|
$io->writeError('Use <info>composer self-update --rollback</info> to return to version '.Composer::VERSION);
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
|
$io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +161,10 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldFile = $rollbackDir . "/{$rollbackVersion}" . self::OLD_INSTALL_EXT;
|
$oldFile = $rollbackDir . "/{$rollbackVersion}" . self::OLD_INSTALL_EXT;
|
||||||
$this->getIO()->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
|
$io = $this->getIO();
|
||||||
|
$io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
|
||||||
if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
|
if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
|
||||||
$this->getIO()->writeError('<error>The backup file was corrupted ('.$err->getMessage().') and has been removed.</error>');
|
$io->writeError('<error>The backup file was corrupted ('.$err->getMessage().') and has been removed.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ EOT
|
||||||
$platformRepo = new PlatformRepository;
|
$platformRepo = new PlatformRepository;
|
||||||
|
|
||||||
$composer = $this->getComposer(false);
|
$composer = $this->getComposer(false);
|
||||||
|
$io = $this->getIO();
|
||||||
if ($input->getOption('self')) {
|
if ($input->getOption('self')) {
|
||||||
$package = $this->getComposer()->getPackage();
|
$package = $this->getComposer()->getPackage();
|
||||||
$repos = $installedRepo = new ArrayRepository(array($package));
|
$repos = $installedRepo = new ArrayRepository(array($package));
|
||||||
|
@ -83,17 +84,17 @@ EOT
|
||||||
if ($composer) {
|
if ($composer) {
|
||||||
$repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
|
$repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
|
||||||
} else {
|
} else {
|
||||||
$defaultRepos = Factory::createDefaultRepositories($this->getIO());
|
$defaultRepos = Factory::createDefaultRepositories($io);
|
||||||
$repos = new CompositeRepository($defaultRepos);
|
$repos = new CompositeRepository($defaultRepos);
|
||||||
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
$io->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();
|
||||||
$installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
|
$installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
|
||||||
$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($io);
|
||||||
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
|
$io->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));
|
||||||
}
|
}
|
||||||
|
@ -120,9 +121,9 @@ EOT
|
||||||
$this->printLinks($package, 'requires');
|
$this->printLinks($package, 'requires');
|
||||||
$this->printLinks($package, 'devRequires', 'requires (dev)');
|
$this->printLinks($package, 'devRequires', 'requires (dev)');
|
||||||
if ($package->getSuggests()) {
|
if ($package->getSuggests()) {
|
||||||
$this->getIO()->write("\n<info>suggests</info>");
|
$io->write("\n<info>suggests</info>");
|
||||||
foreach ($package->getSuggests() as $suggested => $reason) {
|
foreach ($package->getSuggests() as $suggested => $reason) {
|
||||||
$this->getIO()->write($suggested . ' <comment>' . $reason . '</comment>');
|
$io->write($suggested . ' <comment>' . $reason . '</comment>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->printLinks($package, 'provides');
|
$this->printLinks($package, 'provides');
|
||||||
|
@ -173,7 +174,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) {
|
||||||
$this->getIO()->write($type);
|
$io->write($type);
|
||||||
}
|
}
|
||||||
ksort($packages[$type]);
|
ksort($packages[$type]);
|
||||||
|
|
||||||
|
@ -197,7 +198,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('path') && null === $composer) {
|
if ($input->getOption('path') && null === $composer) {
|
||||||
$this->getIO()->writeError('No composer.json found in the current directory, disabling "path" option');
|
$io->writeError('No composer.json found in the current directory, disabling "path" option');
|
||||||
$input->setOption('path', false);
|
$input->setOption('path', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,10 +229,10 @@ EOT
|
||||||
} else {
|
} else {
|
||||||
$output->write($indent . $package);
|
$output->write($indent . $package);
|
||||||
}
|
}
|
||||||
$this->getIO()->write('');
|
$io->write('');
|
||||||
}
|
}
|
||||||
if ($tree) {
|
if ($tree) {
|
||||||
$this->getIO()->write('');
|
$io->write('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,53 +292,54 @@ EOT
|
||||||
*/
|
*/
|
||||||
protected function printMeta(CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo)
|
protected function printMeta(CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo)
|
||||||
{
|
{
|
||||||
$this->getIO()->write('<info>name</info> : ' . $package->getPrettyName());
|
$io = $this->getIO();
|
||||||
$this->getIO()->write('<info>descrip.</info> : ' . $package->getDescription());
|
$io->write('<info>name</info> : ' . $package->getPrettyName());
|
||||||
$this->getIO()->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
|
$io->write('<info>descrip.</info> : ' . $package->getDescription());
|
||||||
|
$io->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
|
||||||
$this->printVersions($package, $versions, $installedRepo);
|
$this->printVersions($package, $versions, $installedRepo);
|
||||||
$this->getIO()->write('<info>type</info> : ' . $package->getType());
|
$io->write('<info>type</info> : ' . $package->getType());
|
||||||
$this->printLicenses($package);
|
$this->printLicenses($package);
|
||||||
$this->getIO()->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
|
$io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
|
||||||
$this->getIO()->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
|
$io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
|
||||||
$this->getIO()->write('<info>names</info> : ' . implode(', ', $package->getNames()));
|
$io->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;
|
||||||
|
|
||||||
$this->getIO()->writeError(
|
$io->writeError(
|
||||||
sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
|
sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getSupport()) {
|
if ($package->getSupport()) {
|
||||||
$this->getIO()->write("\n<info>support</info>");
|
$io->write("\n<info>support</info>");
|
||||||
foreach ($package->getSupport() as $type => $value) {
|
foreach ($package->getSupport() as $type => $value) {
|
||||||
$this->getIO()->write('<comment>' . $type . '</comment> : '.$value);
|
$io->write('<comment>' . $type . '</comment> : '.$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package->getAutoload()) {
|
if ($package->getAutoload()) {
|
||||||
$this->getIO()->write("\n<info>autoload</info>");
|
$io->write("\n<info>autoload</info>");
|
||||||
foreach ($package->getAutoload() as $type => $autoloads) {
|
foreach ($package->getAutoload() as $type => $autoloads) {
|
||||||
$this->getIO()->write('<comment>' . $type . '</comment>');
|
$io->write('<comment>' . $type . '</comment>');
|
||||||
|
|
||||||
if ($type === 'psr-0') {
|
if ($type === 'psr-0') {
|
||||||
foreach ($autoloads as $name => $path) {
|
foreach ($autoloads as $name => $path) {
|
||||||
$this->getIO()->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
$io->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) {
|
||||||
$this->getIO()->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
$io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
|
||||||
}
|
}
|
||||||
} elseif ($type === 'classmap') {
|
} elseif ($type === 'classmap') {
|
||||||
$this->getIO()->write(implode(', ', $autoloads));
|
$io->write(implode(', ', $autoloads));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($package->getIncludePaths()) {
|
if ($package->getIncludePaths()) {
|
||||||
$this->getIO()->write('<comment>include-path</comment>');
|
$io->write('<comment>include-path</comment>');
|
||||||
$this->getIO()->write(implode(', ', $package->getIncludePaths()));
|
$io->write(implode(', ', $package->getIncludePaths()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,11 +376,12 @@ EOT
|
||||||
protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
|
protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
|
||||||
{
|
{
|
||||||
$title = $title ?: $linkType;
|
$title = $title ?: $linkType;
|
||||||
|
$io = $this->getIO();
|
||||||
if ($links = $package->{'get'.ucfirst($linkType)}()) {
|
if ($links = $package->{'get'.ucfirst($linkType)}()) {
|
||||||
$this->getIO()->write("\n<info>" . $title . "</info>");
|
$io->write("\n<info>" . $title . "</info>");
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$this->getIO()->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
|
$io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,6 +396,7 @@ EOT
|
||||||
$spdxLicenses = new SpdxLicenses();
|
$spdxLicenses = new SpdxLicenses();
|
||||||
|
|
||||||
$licenses = $package->getLicense();
|
$licenses = $package->getLicense();
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
foreach ($licenses as $licenseId) {
|
foreach ($licenses as $licenseId) {
|
||||||
$license = $spdxLicenses->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url
|
$license = $spdxLicenses->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url
|
||||||
|
@ -408,7 +412,7 @@ EOT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getIO()->write('<info>license</info> : ' . $out);
|
$io->write('<info>license</info> : ' . $out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ EOT
|
||||||
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
|
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
// list packages
|
// list packages
|
||||||
foreach ($installedRepo->getPackages() as $package) {
|
foreach ($installedRepo->getPackages() as $package) {
|
||||||
|
@ -80,9 +81,9 @@ EOT
|
||||||
|
|
||||||
// output errors/warnings
|
// output errors/warnings
|
||||||
if (!$errors) {
|
if (!$errors) {
|
||||||
$this->getIO()->writeError('<info>No local changes</info>');
|
$io->writeError('<info>No local changes</info>');
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError('<error>You have changes in the following dependencies:</error>');
|
$io->writeError('<error>You have changes in the following dependencies:</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($errors as $path => $changes) {
|
foreach ($errors as $path => $changes) {
|
||||||
|
@ -90,15 +91,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)));
|
||||||
$this->getIO()->write('<info>'.$path.'</info>:');
|
$io->write('<info>'.$path.'</info>:');
|
||||||
$this->getIO()->write($indentedChanges);
|
$io->write($indentedChanges);
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->write($path);
|
$io->write($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($errors && !$input->getOption('verbose')) {
|
if ($errors && !$input->getOption('verbose')) {
|
||||||
$this->getIO()->writeError('Use --verbose (-v) to see modified files');
|
$io->writeError('Use --verbose (-v) to see modified files');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch post-status-command
|
// Dispatch post-status-command
|
||||||
|
|
|
@ -74,18 +74,18 @@ EOT
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = $this->getIO();
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->getOption('dev')) {
|
if ($input->getOption('dev')) {
|
||||||
$this->getIO()->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
|
$io->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'));
|
||||||
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
$io = $this->getIO();
|
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
||||||
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
|
||||||
|
|
|
@ -58,19 +58,20 @@ EOT
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$file = $input->getArgument('file');
|
$file = $input->getArgument('file');
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
$this->getIO()->writeError('<error>' . $file . ' not found.</error>');
|
$io->writeError('<error>' . $file . ' not found.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
$this->getIO()->writeError('<error>' . $file . ' is not readable.</error>');
|
$io->writeError('<error>' . $file . ' is not readable.</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$validator = new ConfigValidator($this->getIO());
|
$validator = new ConfigValidator($io);
|
||||||
$checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
|
$checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
|
||||||
$checkPublish = !$input->getOption('no-check-publish');
|
$checkPublish = !$input->getOption('no-check-publish');
|
||||||
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
|
list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
|
||||||
|
@ -78,7 +79,7 @@ EOT
|
||||||
$checkLock = !$input->getOption('no-check-lock');
|
$checkLock = !$input->getOption('no-check-lock');
|
||||||
|
|
||||||
$lockErrors = array();
|
$lockErrors = array();
|
||||||
$composer = Factory::create($this->getIO(), $file);
|
$composer = Factory::create($io, $file);
|
||||||
$locker = $composer->getLocker();
|
$locker = $composer->getLocker();
|
||||||
if ($locker->isLocked() && !$locker->isFresh()) {
|
if ($locker->isLocked() && !$locker->isFresh()) {
|
||||||
$lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json.';
|
$lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json.';
|
||||||
|
@ -86,16 +87,16 @@ EOT
|
||||||
|
|
||||||
// output errors/warnings
|
// output errors/warnings
|
||||||
if (!$errors && !$publishErrors && !$warnings) {
|
if (!$errors && !$publishErrors && !$warnings) {
|
||||||
$this->getIO()->write('<info>' . $file . ' is valid</info>');
|
$io->write('<info>' . $file . ' is valid</info>');
|
||||||
} elseif (!$errors && !$publishErrors) {
|
} elseif (!$errors && !$publishErrors) {
|
||||||
$this->getIO()->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
|
$io->writeError('<info>' . $file . ' is valid, but with a few warnings</info>');
|
||||||
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
$io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
||||||
} elseif (!$errors) {
|
} elseif (!$errors) {
|
||||||
$this->getIO()->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
|
$io->writeError('<info>' . $file . ' is valid for simple usage with composer but has</info>');
|
||||||
$this->getIO()->writeError('<info>strict errors that make it unable to be published as a package:</info>');
|
$io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
|
||||||
$this->getIO()->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
$io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
|
||||||
} else {
|
} else {
|
||||||
$this->getIO()->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
|
$io->writeError('<error>' . $file . ' is invalid, the following errors/warnings were found:</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = array(
|
$messages = array(
|
||||||
|
@ -119,7 +120,7 @@ EOT
|
||||||
|
|
||||||
foreach ($messages as $style => $msgs) {
|
foreach ($messages as $style => $msgs) {
|
||||||
foreach ($msgs as $msg) {
|
foreach ($msgs as $msg) {
|
||||||
$this->getIO()->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
|
$io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,10 @@ class Application extends BaseApplication
|
||||||
{
|
{
|
||||||
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
|
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
|
||||||
ErrorHandler::register($this->io);
|
ErrorHandler::register($this->io);
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50302) {
|
if (PHP_VERSION_ID < 50302) {
|
||||||
$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>');
|
$io->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) {
|
||||||
$this->getIO()->writeError(sprintf('<warning>Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
|
$io->writeError(sprintf('<warning>Warning: This development build of composer is over 60 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 ($this->getIO()->isDebug() >= 4) {
|
if ($io->isDebug() >= 4) {
|
||||||
$this->getIO()->writeError('Changed CWD to ' . getcwd());
|
$io->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)) {
|
||||||
$this->getIO()->writeError('<warning>A script named '.$script.' would override a native Composer function and has been skipped</warning>');
|
$io->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)) {
|
||||||
$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');
|
$io->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;
|
||||||
|
@ -176,6 +177,8 @@ class Application extends BaseApplication
|
||||||
*/
|
*/
|
||||||
public function renderException($exception, $output)
|
public function renderException($exception, $output)
|
||||||
{
|
{
|
||||||
|
$io = $this->getIO();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$composer = $this->getComposer(false, true);
|
$composer = $this->getComposer(false, true);
|
||||||
if ($composer) {
|
if ($composer) {
|
||||||
|
@ -186,20 +189,20 @@ 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)
|
||||||
) {
|
) {
|
||||||
$this->getIO()->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
|
$io->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')) {
|
||||||
$this->getIO()->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
|
$io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
|
||||||
$this->getIO()->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');
|
$io->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')) {
|
||||||
$this->getIO()->writeError('<error>The following exception is caused by a lack of memory and not having swap configured</error>');
|
$io->writeError('<error>The following exception is caused by a lack of memory and not having swap configured</error>');
|
||||||
$this->getIO()->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>');
|
$io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output instanceof ConsoleOutputInterface) {
|
if ($output instanceof ConsoleOutputInterface) {
|
||||||
|
|
Loading…
Reference in New Issue