diff --git a/README.md b/README.md index d309a7c..8c9270a 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,15 @@ Now, you can create or clone a [Composer](https://getcomposer.org/) package into and run: ```bash -composer install --plug-and-play +composer plug-and-play:install # or -composer update --plug-and-play +composer plug-and-play:update # or -composer dump-autoload --plug-and-play +composer plug-and-play:dump ``` ### Directories and files diff --git a/composer.json b/composer.json index e9a4303..f233687 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "composer-plugin-api": "^2.0" }, "require-dev": { - "composer/composer": "<=2.1.5", + "composer/composer": "^2.0", "phpunit/phpunit": "^9.4" }, "autoload": { diff --git a/src/Commands/CommandNaming.php b/src/Commands/CommandNaming.php index f8892f7..b93eef8 100644 --- a/src/Commands/CommandNaming.php +++ b/src/Commands/CommandNaming.php @@ -10,15 +10,12 @@ trait CommandNaming * Define name, aliases and add plug and play option. * * @param string $command - * @param array $aliases * * @return void */ - public function naming(string $command, array $aliases = []) + public function naming(string $command) { $this->setName($command); - $this->setAliases($aliases); - $this->addOption('plug-and-play', null, InputOption::VALUE_NONE, 'Run using plug and play plugin.'); $this->addOption('plug-and-play-pretend', null, InputOption::VALUE_NONE, 'Run pretending to use plug and play plugin.'); } } diff --git a/src/Commands/ComposerCreator.php b/src/Commands/ComposerCreator.php index 42ff782..fd1669b 100644 --- a/src/Commands/ComposerCreator.php +++ b/src/Commands/ComposerCreator.php @@ -69,9 +69,8 @@ public function getComposer($required = true, $disablePlugins = null) protected function execute(InputInterface $input, OutputInterface $output) { $isTheCommand = $input->getFirstArgument() === $this->getName(); - $hasOption = $input->getOption('plug-and-play'); - if ($isTheCommand || $hasOption) { + if ($isTheCommand) { $this->usePlugAndPlay = true; $output->writeln('You are using Composer Plug and Play Plugin.'); } diff --git a/src/Commands/DumpAutoloadCommand.php b/src/Commands/DumpAutoloadCommand.php index 57a6e66..65384d6 100644 --- a/src/Commands/DumpAutoloadCommand.php +++ b/src/Commands/DumpAutoloadCommand.php @@ -12,6 +12,6 @@ protected function configure() { parent::configure(); - $this->naming('plug-and-play:dump', ['dumpautoload', 'dump-autoload']); + $this->naming('plug-and-play:dump'); } } diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 69bbba9..0e305d8 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -12,6 +12,6 @@ protected function configure() { parent::configure(); - $this->naming('plug-and-play:install', ['i', 'install']); + $this->naming('plug-and-play:install'); } } diff --git a/src/Commands/UpdateCommand.php b/src/Commands/UpdateCommand.php index 5cbdbb9..0adc785 100644 --- a/src/Commands/UpdateCommand.php +++ b/src/Commands/UpdateCommand.php @@ -12,6 +12,6 @@ protected function configure() { parent::configure(); - $this->naming('plug-and-play:update', ['u', 'update']); + $this->naming('plug-and-play:update'); } } diff --git a/tests/Unit/ComposerCommandsTest.php b/tests/Unit/ComposerCommandsTest.php index c49f21e..eaaccbe 100644 --- a/tests/Unit/ComposerCommandsTest.php +++ b/tests/Unit/ComposerCommandsTest.php @@ -61,70 +61,4 @@ public function testListCommand() $this->assertStringContainsString('plug-and-play:install', $content); $this->assertStringContainsString('plug-and-play:update', $content); } - - public function testInstallCommand() - { - $application = new Application(); - $input = new StringInput("install --plug-and-play --plug-and-play-pretend -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch()); - } - - public function testUpdateCommand() - { - $application = new Application(); - $input = new StringInput("update --plug-and-play --plug-and-play-pretend -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch()); - } - - public function testDumpautoloadCommand() - { - $application = new Application(); - $input = new StringInput("dumpautoload --plug-and-play --plug-and-play-pretend -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch()); - } - - public function testIfOptionIsPresentInInstallCommand() - { - $application = new Application(); - $input = new StringInput("install --help -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('--plug-and-play', $output->fetch()); - } - - public function testIfOptionIsPresentInUpdateCommand() - { - $application = new Application(); - $input = new StringInput("update --help -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('--plug-and-play', $output->fetch()); - } - - public function testIfOptionIsPresentInDumpautoloadCommand() - { - $application = new Application(); - $input = new StringInput("dumpautoload --help -d {$this->directory}"); - $output = new BufferedOutput(); - - $application->doRun($input, $output); - - $this->assertStringContainsString('--plug-and-play', $output->fetch()); - } }