11
11
12
12
namespace CaptainHook \Plugin \Composer ;
13
13
14
+ use CaptainHook \App \Composer \Cmd ;
14
15
use Composer \Composer ;
15
16
use Composer \EventDispatcher \EventSubscriberInterface ;
16
17
use Composer \IO \IOInterface ;
23
24
*
24
25
* @package CaptainHook\Plugin
25
26
* @author Andrea Heigl <[email protected] >
26
- * @link https://github.com/captainhookphp/captainhook
27
+ * @link https://github.com/captainhookphp/plugin-composer
27
28
*/
28
29
class ComposerPlugin implements PluginInterface, EventSubscriberInterface
29
30
{
30
31
/**
31
- * @var Installer
32
- */
33
- private $ installer ;
34
-
35
- /**
36
- * Activate the plugin by setting up the installer
32
+ * Activate the plugin
37
33
*
38
34
* @param \Composer\Composer $composer
39
35
* @param \Composer\IO\IOInterface $io
40
36
* @return void
41
37
*/
42
38
public function activate (Composer $ composer , IOInterface $ io ) : void
43
39
{
44
- $ this -> installer = new Installer ( $ io , $ composer -> getPackage ());
40
+ // nothing to do here
45
41
}
46
42
47
43
/**
@@ -61,6 +57,7 @@ public static function getSubscribedEvents() : array
61
57
*
62
58
* @param \Composer\Script\Event $event
63
59
* @return void
60
+ * @throws \Exception
64
61
*/
65
62
public function installHooks (Event $ event ) : void
66
63
{
@@ -71,13 +68,21 @@ public function installHooks(Event $event) : void
71
68
require $ vendorDir . '/autoload.php ' ;
72
69
}
73
70
74
- // if it's still not available end the plugin execution
75
71
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
+ );
77
83
return ;
78
84
}
79
- // otherwise run the installer
80
- ($ this ->installer )();
85
+ Cmd::setup ($ event );
81
86
}
82
87
83
88
/**
0 commit comments