Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring release command OUT of BLT app. #1434

Merged
merged 2 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ 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.

## Create a release

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:

Expand Down
29 changes: 20 additions & 9 deletions src/Robo/Commands/BltReleaseCommand.php → RoboFile.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<?php

namespace Acquia\Blt\Robo\Commands;

use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Common\StringManipulator;
use GuzzleHttp\Client;
use Robo\Tasks;

/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class BltReleaseCommand extends BltTasks {

class RoboFile extends Tasks {
/**
* Generates release notes and cuts a new tag on GitHub.
*
* @command blt:release
* @command release
*
* @param string $tag
* The tag name. E.g, 8.6.10.
Expand Down Expand Up @@ -160,7 +157,7 @@ protected function createGitHubRelease(
* @return int
* The CLI status code.
*/
public function bltReleaseNotes($tag, $github_token) {
public function releaseNotes($tag, $github_token) {

$requirements_met = $this->checkCommandsExist([
'github_changelog_generator',
Expand Down Expand Up @@ -253,9 +250,9 @@ 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)) {
if (!$this->commandExists($command)) {
$this->yell("Unable to find '$command' command!");
return FALSE;
}
Expand All @@ -264,4 +261,18 @@ public 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;
}

}
4 changes: 1 addition & 3 deletions bin/blt-robo-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 4 additions & 1 deletion src/Robo/Blt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

Expand Down