diff --git a/src/Command/SebSept/HelloCommand.php b/src/Command/SebSept/HelloCommand.php
index 69a698a..0cef833 100644
--- a/src/Command/SebSept/HelloCommand.php
+++ b/src/Command/SebSept/HelloCommand.php
@@ -34,7 +34,12 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
- $this->getIO()->write('This command show some helps for usage of this package.');
+ var_dump($this->getIO()->isInteractive());
+ $this->getIO()->write('This command show some helps for usage of this package.'); // not displayed
+ $this->getIO()->askConfirmation('oi K');
+ $this->getIO()->write('ee');
+ $this->getIO()->error('implement me');
+// throw new \Exception('implement me');
return 0;
}
diff --git a/src/Composer/PsDevToolsCommandProvider.php b/src/Composer/PsDevToolsCommandProvider.php
index 02e7da0..97ee147 100644
--- a/src/Composer/PsDevToolsCommandProvider.php
+++ b/src/Composer/PsDevToolsCommandProvider.php
@@ -32,7 +32,7 @@ final class PsDevToolsCommandProvider implements CommandProvider
public function getCommands(): array
{
return [
-// new HelloCommand(),
+ new HelloCommand(),
new PrestashopDevToolsPhpStan(),
new PrestashopDevToolsCsFixer(),
new IndexPhpFiller(),
diff --git a/src/Composer/PsDevToolsPlugin.php b/src/Composer/PsDevToolsPlugin.php
index ca3b132..64968d6 100644
--- a/src/Composer/PsDevToolsPlugin.php
+++ b/src/Composer/PsDevToolsPlugin.php
@@ -27,17 +27,20 @@
use Composer\IO\IOInterface;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;
+use Composer\Script\Event;
+use Symfony\Component\Process\Process;
final class PsDevToolsPlugin implements PluginInterface, Capable, EventSubscriberInterface
{
+ /** @var bool */
+ private $isFirstRun = false;
+
public function activate(Composer $composer, IOInterface $io): void
{
- $io->debug('Mon plugin est actif');
}
public function deactivate(Composer $composer, IOInterface $io): void
{
- $io->debug('Mon plugin est inactif');
}
public function uninstall(Composer $composer, IOInterface $io): void
@@ -58,17 +61,39 @@ public function getCapabilities(): array
}
/**
- * @return array
+ * @return array>>
*/
public static function getSubscribedEvents(): array
{
return [
- 'post-package-install' => 'hello',
+ 'post-package-install' => 'preparefirstRun',
+ 'post-update-cmd' => 'firstRun', // just to be the last output.
];
}
- public function hello(PackageEvent $event): void
+ public function firstRun(Event $event): void
{
+ if (!$this->isFirstRun) {
+ return;
+ }
+
+ $event->getIO()->info(__CLASS__ . ' first run ...');
+
+ $i = new Process('composer psdt:hello'); // @phpstan-ignore-line
+ $i->enableOutput()
+ ->setTty(true)
+ ->start();
+ $i->wait();
+
+ $this->isFirstRun = false;
+ }
+
+ public function preparefirstRun(PackageEvent $event): void
+ {
+ if (!$event->getIO()->isInteractive()) {
+ return;
+ }
+
// this happen on post-package-install so it should be an InstallOperation
// however, for safety it's checked.
if (!$event->getOperation() instanceof InstallOperation) {
@@ -82,9 +107,6 @@ public function hello(PackageEvent $event): void
return;
}
- $event->getIO()->write('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
- $event->getIO()->write('~~ Congratulation !PsDevTool is now installed>. ~~');
- $event->getIO()->write('~~ run composer list psdt to get started. ~~');
- $event->getIO()->write('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
+ $this->isFirstRun = true;
}
}