Skip to content
Snippets Groups Projects
Commit f74d4daa authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3408483 by phenaproxima, Wim Leers: Support cweagans/composer-patches 2.x

parent a79ff6a4
No related branches found
No related tags found
1 merge request!991Allow cweagans/composer-patches 2.x
Pipeline #75914 canceled
......@@ -4,6 +4,7 @@ declare(strict_types = 1);
namespace Drupal\package_manager\Validator;
use Composer\Semver\Semver;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
......@@ -155,15 +156,26 @@ final class ComposerPatchesValidator implements EventSubscriberInterface {
*/
private function computePatcherStatus(string $working_dir): array {
$list = $this->composerInspector->getInstalledPackagesList($working_dir);
$is_installed = isset($list[static::PLUGIN_NAME]);
$installed_version = $list[static::PLUGIN_NAME]?->version;
$info = $this->composerInspector->getRootPackageInfo($working_dir);
$is_root_requirement = array_key_exists(static::PLUGIN_NAME, $info['requires'] ?? []) || array_key_exists(static::PLUGIN_NAME, $info['devRequires'] ?? []);
$extra = Json::decode($this->composerInspector->getConfig('extra', $working_dir));
$exit_on_failure = $extra['composer-exit-on-patch-failure'] ?? FALSE;
// The 2.x version of the plugin always exits with an error if a patch can't
// be applied.
if ($installed_version && Semver::satisfies($installed_version, '^2')) {
$exit_on_failure = TRUE;
}
else {
$extra = Json::decode($this->composerInspector->getConfig('extra', $working_dir));
$exit_on_failure = $extra['composer-exit-on-patch-failure'] ?? FALSE;
}
return [$is_installed, $is_root_requirement, $exit_on_failure];
return [
is_string($installed_version),
$is_root_requirement,
$exit_on_failure,
];
}
/**
......
......@@ -64,7 +64,7 @@ final class ComposerPluginsValidator implements EventSubscriberInterface {
private const SUPPORTED_PLUGINS_THAT_DO_MODIFY = [
// cSpell:disable
// @see \Drupal\package_manager\Validator\ComposerPatchesValidator
'cweagans/composer-patches' => '^1.7.3',
'cweagans/composer-patches' => '^1.7.3 || ^2',
// @see \Drupal\package_manager\PathExcluder\VendorHardeningExcluder
'drupal/core-vendor-hardening' => '*',
'php-http/discovery' => '*',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment