From fcf8ab0a3f962417a61e3d94f75963f62083dd7d Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 25 Apr 2017 14:36:04 -0400 Subject: [PATCH 1/2] Refactoring release command OUT of BLT app. --- RELEASE.md | 4 ++-- .../Commands/BltReleaseCommand.php => RoboFile.php | 13 +++++-------- bin/blt-robo-run.php | 4 +--- src/Robo/Blt.php | 5 ++++- 4 files changed, 12 insertions(+), 14 deletions(-) rename src/Robo/Commands/BltReleaseCommand.php => RoboFile.php (96%) diff --git a/RELEASE.md b/RELEASE.md index b4d9871e2..dbefa1468 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -42,7 +42,7 @@ In order to use these testing instructions: Then, generate your release notes via: - ./bin/blt-robo blt:release-notes [tag] [token] + ./vendor/bin/robo release-notes [tag] [token] This will update CHANGELOG.md and create a commit locally. @@ -50,7 +50,7 @@ This will update CHANGELOG.md and create a commit locally. To both generate release notes and also create a new release on GitHub, execute: - ./bin/blt-robo blt:release [tag] [token] --update-changelog + ./vendor/bin/robo release --update-changelog [tag] [token] This is a potentially destructive command. It will: diff --git a/src/Robo/Commands/BltReleaseCommand.php b/RoboFile.php similarity index 96% rename from src/Robo/Commands/BltReleaseCommand.php rename to RoboFile.php index a5dfe87a6..572d14b43 100644 --- a/src/Robo/Commands/BltReleaseCommand.php +++ b/RoboFile.php @@ -1,22 +1,19 @@ checkCommandsExist([ 'github_changelog_generator', @@ -253,7 +250,7 @@ protected function generateReleaseNotes($tag, $github_token) { * @return bool * TRUE if the command exists, otherwise FALSE. */ - public function checkCommandsExist(array $commands) { + protected function checkCommandsExist(array $commands) { foreach ($commands as $command) { if (!$this->getInspector()->commandExists($command)) { $this->yell("Unable to find '$command' command!"); diff --git a/bin/blt-robo-run.php b/bin/blt-robo-run.php index 03f642680..fe6c15882 100644 --- a/bin/blt-robo-run.php +++ b/bin/blt-robo-run.php @@ -43,15 +43,13 @@ $config = new DefaultConfig(); $loader = new YamlConfigLoader(); $processor = new YamlConfigProcessor(); -$processor->add($config->export(), 'default'); +$processor->add($config->export()); $processor->extend($loader->load($config->get('blt.root') . '/phing/build.yml')); $processor->extend($loader->load($config->get('repo.root') . '/blt/project.yml')); $processor->extend($loader->load($config->get('repo.root') . '/blt/project.local.yml')); $config->import($processor->export()); $config->populateHelperConfig(); -// @todo realpath() repo.root, docroot, composer.bin, etc. - $blt = new Blt($config, $input, $output); $status_code = (int) $blt->run($input, $output); exit($status_code); diff --git a/src/Robo/Blt.php b/src/Robo/Blt.php index 2657404e1..f14e1eb87 100644 --- a/src/Robo/Blt.php +++ b/src/Robo/Blt.php @@ -124,7 +124,10 @@ private function getCommands( array $options = ['path' => NULL, 'namespace' => NULL] ) { $discovery = new CommandFileDiscovery(); - $discovery->setSearchPattern('*Command.php')->setSearchLocations([]); + $discovery + ->setSearchPattern('*Command.php') + ->setSearchLocations([]) + ->addExclude('Internal'); return $discovery->discover($options['path'], $options['namespace']); } From e4997b3183a527ac365bfff0a427e407257ca60e Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Tue, 25 Apr 2017 15:10:01 -0400 Subject: [PATCH 2/2] Adding requirements check back. --- RoboFile.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/RoboFile.php b/RoboFile.php index 572d14b43..e22cbc966 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -252,7 +252,7 @@ protected function generateReleaseNotes($tag, $github_token) { */ protected function checkCommandsExist(array $commands) { foreach ($commands as $command) { - if (!$this->getInspector()->commandExists($command)) { + if (!$this->commandExists($command)) { $this->yell("Unable to find '$command' command!"); return FALSE; } @@ -261,4 +261,18 @@ protected function checkCommandsExist(array $commands) { return TRUE; } + /** + * Checks if a given command exists on the system. + * + * @param string $command + * The command binary only. E.g., "drush" or "php". + * + * @return bool + * TRUE if the command exists, otherwise FALSE. + */ + protected function commandExists($command) { + exec("command -v $command >/dev/null 2>&1", $output, $exit_code); + return $exit_code == 0; + } + }