diff --git a/CHANGELOG.md b/CHANGELOG.md index 551ae83..45882ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.4] - 2020-10-20 + +### Changed +- Revert part of previous release and disable incompatible pw-module installer using event listener in plugin. + ## [1.0.3] - 2020-10-20 ### Fixed diff --git a/composer.json b/composer.json index 0d5183c..63ed62a 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,8 @@ "hari/pw-module": "^1.0.0" }, "autoload": { - "psr-0": { - "PW\\Composer\\": "src/" - }, "psr-4": { - "wireframe\\": "src/" + "wireframe\\ComposerInstaller\\": "src/ComposerInstaller/" } }, "extra": { diff --git a/src/ComposerInstaller/Plugin.php b/src/ComposerInstaller/Plugin.php index 35347ad..0a66701 100644 --- a/src/ComposerInstaller/Plugin.php +++ b/src/ComposerInstaller/Plugin.php @@ -3,8 +3,11 @@ namespace wireframe\ComposerInstaller; use Composer\Composer; +use Composer\EventDispatcher\EventSubscriberInterface; use Composer\IO\IOInterface; use Composer\Plugin\PluginInterface; +use Composer\Installer\PackageEvent; +use Composer\Installer\PackageEvents; /** * The Plugin class @@ -14,7 +17,7 @@ * @author Teppo Koivula * @license Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/ */ -class Plugin implements PluginInterface +class Plugin implements PluginInterface, EventSubscriberInterface { /** * Register custom installers for ProcessWire modules and site profiles. @@ -28,4 +31,38 @@ public function activate(Composer $composer, IOInterface $io) $installationManager->addInstaller(new ModuleInstaller($io, $composer)); $installationManager->addInstaller(new SiteProfileInstaller($io, $composer)); } + + /** + * Register pre package install event listener + * + * @return array + */ + public static function getSubscribedEvents() + { + return [ + PackageEvents::PRE_PACKAGE_INSTALL => [ + array('prePackageInstall', 0) + ], + ]; + } + + /** + * Pre package install event listener + * + * wireframe-framework/processwire-composer-installer and hari/pw-module are not fully compatible, + * which means that when wireframe-framework/processwire-composer-installer is enabled, we need to + * disable the hari/pw-module SystemInstaller composer-installer. + * + * @param PackageEvent $event + */ + public static function prePackageInstall(PackageEvent $event) + { + $package = $event->getOperation()->getPackage(); + if ($package->getType() !== 'pw-module') return; + $installationManager = $event->getComposer()->getInstallationManager(); + $moduleInstaller = $installationManager->getInstaller('pw-module'); + if (strpos(get_class($moduleInstaller), 'PW\Composer\SystemInstaller') === 0) { + $installationManager->removeInstaller($moduleInstaller); + } + } } diff --git a/src/PW/Composer/SystemInstaller.php b/src/PW/Composer/SystemInstaller.php deleted file mode 100644 index 3c21034..0000000 --- a/src/PW/Composer/SystemInstaller.php +++ /dev/null @@ -1,12 +0,0 @@ -