1
0
Fork 0

Add hint in create-project when it fails due to a missing allow-plugins in project, refs #10928

pull/10985/head
Jordi Boggiano 2022-07-13 14:38:54 +02:00
parent 0e59fbb46e
commit 336a0d20c6
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 30 additions and 4 deletions

View File

@ -26,6 +26,7 @@ use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\Package\Version\VersionSelector;
use Composer\Package\AliasPackage;
use Composer\Pcre\Preg;
use Composer\Plugin\PluginBlockedException;
use Composer\Repository\RepositoryFactory;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
@ -268,10 +269,16 @@ EOT
$installer->disablePlugins();
}
try {
$status = $installer->run();
if (0 !== $status) {
return $status;
}
} catch (PluginBlockedException $e) {
$io->writeError('<error>Hint: To allow running the config command recommended below before dependencies are installed, run create-project with --no-install.</error>');
$io->writeError('<error>You can then cd into '.getcwd().', configure allow-plugins, and finally run a composer install to complete the process.</error>');
throw $e;
}
}
$hasVcs = $installedFromVcs;

View File

@ -0,0 +1,19 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Plugin;
use UnexpectedValueException;
class PluginBlockedException extends UnexpectedValueException
{
}

View File

@ -765,7 +765,7 @@ class PluginManager
}
}
throw new \UnexpectedValueException(
throw new PluginBlockedException(
$package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.'.PHP_EOL.
'You can run "composer '.($isGlobalPlugin ? 'global ' : '').'config --no-plugins allow-plugins.'.$package.' [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false)'.PHP_EOL.
'See https://getcomposer.org/allow-plugins'