diff --git a/src/InlineRecipeCommand.php b/src/InlineRecipeCommand.php new file mode 100644 index 0000000..45d2618 --- /dev/null +++ b/src/InlineRecipeCommand.php @@ -0,0 +1,30 @@ +setName('inline'); + $this->setDescription('Invoke this command to inline a recipe into your root composer.json'); + $this->addArgument( + 'recipe', + InputArgument::REQUIRED, + 'Recipe name to inline. Must be of type ' + . RecipePlugin::RECIPE + . ' and be included in the root as a direct dependency' + ); + $this->addUsage('composer inline silverstripe/recipe-blogging'); + } + + public function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); // TODO: Change the autogenerated stub + } +} diff --git a/src/RecipeCommandProvider.php b/src/RecipeCommandProvider.php new file mode 100644 index 0000000..0b21354 --- /dev/null +++ b/src/RecipeCommandProvider.php @@ -0,0 +1,21 @@ +getType() !== RecipePlugin::RECIPE) { + return; + } + // Copy project files to root $destinationPath = getcwd(); $name = $package->getName(); diff --git a/src/RecipePlugin.php b/src/RecipePlugin.php index a29aad9..6256876 100644 --- a/src/RecipePlugin.php +++ b/src/RecipePlugin.php @@ -10,16 +10,26 @@ use Composer\EventDispatcher\EventSubscriberInterface; use Composer\Installer\PackageEvent; use Composer\IO\IOInterface; use Composer\Package\PackageInterface; +use Composer\Plugin\Capable; use Composer\Plugin\PluginInterface; +use Composer\Plugin\Capability\CommandProvider; /** * Register the RecipeInstaller * * Credit to http://stackoverflow.com/questions/27194348/get-package-install-path-from-composer-script-composer-api */ -class RecipePlugin implements PluginInterface, EventSubscriberInterface +class RecipePlugin implements PluginInterface, EventSubscriberInterface, Capable { - public function activate(Composer $composer, IOInterface $io) { } + + /** + * Recipe type + */ + const RECIPE = 'silverstripe-recipe'; + + public function activate(Composer $composer, IOInterface $io) + { + } public static function getSubscribedEvents() { @@ -33,7 +43,8 @@ class RecipePlugin implements PluginInterface, EventSubscriberInterface * * @param PackageEvent $event */ - public function installPackage(PackageEvent $event) { + public function installPackage(PackageEvent $event) + { $package = $this->getOperationPackage($event); if ($package) { $installer = new RecipeInstaller($event->getIO(), $event->getComposer()); @@ -58,4 +69,11 @@ class RecipePlugin implements PluginInterface, EventSubscriberInterface } return null; } + + public function getCapabilities() + { + return [ + CommandProvider::class => RecipeCommandProvider::class + ]; + } }