1111
1212namespace CaptainHook \Plugin \Composer ;
1313
14+ use CaptainHook \App \Composer \Cmd ;
1415use Composer \Composer ;
1516use Composer \EventDispatcher \EventSubscriberInterface ;
1617use Composer \IO \IOInterface ;
2324 *
2425 * @package CaptainHook\Plugin
2526 * @author Andrea Heigl <andreas@heigl.org>
26- * @link https://github.com/captainhookphp/captainhook
27+ * @link https://github.com/captainhookphp/plugin-composer
2728 */
2829class ComposerPlugin implements PluginInterface, EventSubscriberInterface
2930{
3031 /**
31- * @var Installer
32- */
33- private $ installer ;
34-
35- /**
36- * Activate the plugin by setting up the installer
32+ * Activate the plugin
3733 *
3834 * @param \Composer\Composer $composer
3935 * @param \Composer\IO\IOInterface $io
4036 * @return void
4137 */
4238 public function activate (Composer $ composer , IOInterface $ io ) : void
4339 {
44- $ this -> installer = new Installer ( $ io , $ composer -> getPackage ());
40+ // nothing to do here
4541 }
4642
4743 /**
@@ -61,6 +57,7 @@ public static function getSubscribedEvents() : array
6157 *
6258 * @param \Composer\Script\Event $event
6359 * @return void
60+ * @throws \Exception
6461 */
6562 public function installHooks (Event $ event ) : void
6663 {
@@ -71,13 +68,21 @@ public function installHooks(Event $event) : void
7168 require $ vendorDir . '/autoload.php ' ;
7269 }
7370
74- // if it's still not available end the plugin execution
7571 if (!$ this ->isCaptainHookInstalled ()) {
76- $ event ->getIO ()->write (' <info>CaptainHook not properly installed try to run composer update</info> ' );
72+ // if CaptainHook is still not available end the plugin execution
73+ // normally this only happens if CaptainHook gets uninstalled
74+ $ event ->getIO ()->write (
75+ ' <info>CaptainHook not properly installed try to run composer update</info> ' . PHP_EOL .
76+ PHP_EOL .
77+ 'If you are uninstalling CaptainHook, we are sad seeing you go, ' .
78+ 'but we would appreciate your feedback on your experience. ' . PHP_EOL .
79+ 'Just go to https://github.com/CaptainHookPhp/captainhook/issues to leave your feedback ' . PHP_EOL .
80+ PHP_EOL .
81+ '<comment>WARNING: Don \'t forget to deactivate the hooks in your .git/hooks directory.</comment> '
82+ );
7783 return ;
7884 }
79- // otherwise run the installer
80- ($ this ->installer )();
85+ Cmd::setup ($ event );
8186 }
8287
8388 /**
0 commit comments