From 8ccd0b800b333d97fc2a8fa78f184b16987a1a80 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Tue, 21 Apr 2020 17:31:46 -0700 Subject: [PATCH 1/2] Fixes #16: Support Composer 2. --- composer.json | 2 +- src/Plugin.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 415f844..e73c394 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "composer-plugin-api": "^1.1" + "composer-plugin-api": "^1.1 || ^2.0" }, "require-dev": { "composer/composer": "^1.6", diff --git a/src/Plugin.php b/src/Plugin.php index 51e474c..8867bfa 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -54,6 +54,14 @@ public function activate(Composer $composer, IOInterface $io) $composer->setRepositoryManager($manager); } + public function deactivate(Composer $composer, IOInterface $io) + { + } + + public function uninstall(Composer $composer, IOInterface $io) + { + } + /** * Negotiates default require constraint and package for given drupal/core. * From b9d5b646539cea5865f1b79ed05ec69ab31f87a1 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Tue, 6 Oct 2020 15:29:41 +0200 Subject: [PATCH 2/2] Return early for Composer 2 --- src/Plugin.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Plugin.php b/src/Plugin.php index 8867bfa..e60ea80 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -16,6 +16,13 @@ class Plugin implements PluginInterface public function activate(Composer $composer, IOInterface $io) { + if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '<=')) { + if ($io->isVerbose()) { + $io->write(sprintf('zaporylie/composer-drupal-optimizations is disabled for Composer 2')); + } + // Return early. + return; + } // Set default version constraints based on the composer requirements. $extra = $composer->getPackage()->getExtra(); $packages = $composer->getPackage()->getRequires();