From a0e63cd66a05ff721f92f5175a22c58f018c24cb Mon Sep 17 00:00:00 2001 From: Greg Anderson Date: Wed, 30 Sep 2020 12:41:08 -0700 Subject: [PATCH] Composer 2 support. --- composer.json | 6 +++--- src/QuicksilverComposerInstallerPlugin.php | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 2ff3311..88dd2ae 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ "class": "rvtraveller\\QuicksilverComposerInstaller\\QuicksilverComposerInstallerPlugin" }, "require": { - "composer-plugin-api": "~1.0", - "composer/installers": "~1.0" + "composer-plugin-api": "^1.0 || ^2.0", + "composer/installers": "^1.9" }, "require-dev": { - "composer/composer": "~1.0@dev" + "composer/composer": "1.0.* || 2.0.*@dev" } } diff --git a/src/QuicksilverComposerInstallerPlugin.php b/src/QuicksilverComposerInstallerPlugin.php index 0e8e27e..556c2b8 100644 --- a/src/QuicksilverComposerInstallerPlugin.php +++ b/src/QuicksilverComposerInstallerPlugin.php @@ -8,13 +8,24 @@ class QuicksilverComposerInstallerPlugin implements PluginInterface { + private $installer; + public function activate(Composer $composer, IOInterface $io) { // Strange autoloading problem on CircleCI if (!class_exists(QuickSilverComposerInstaller::class)) { include_once __DIR__ . '/QuicksilverComposerInstaller.php'; } - $installer = new QuickSilverComposerInstaller($io, $composer); - $composer->getInstallationManager()->addInstaller($installer); + $this->installer = new QuickSilverComposerInstaller($io, $composer); + $composer->getInstallationManager()->addInstaller($this->installer); + } + + public function deactivate(Composer $composer, IOInterface $io) + { + $composer->getInstallationManager()->removeInstaller($this->installer); + } + + public function uninstall(Composer $composer, IOInterface $io) + { } }