Skip to content

Commit

Permalink
DX-2267: Restore local.blt.yml generation (#4239)
Browse files Browse the repository at this point in the history
* DX-2267: Restore local.blt.yml generation

* Refactor method

* Dev tweaks
  • Loading branch information
danepowell authored Sep 4, 2020
1 parent 41373ee commit 6210afd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For major releases, coordinate with ORCA prior to starting this process to ensur

## Review issue labels

Review the issues and pull requests that will make up the release and ensure they are labelled correctly so that the changelog and release notes will be generated with the correct categories (new features, bug fixes, etc...).
Review the issues and pull requests that will make up the release and ensure they are labelled correctly so that the changelog and release notes will be generated with the correct categories (new features, bug fixes, etc...). [Github releases](https://github.com/acquia/blt/releases) have a link to display all commits since a given release.

## Test via Canary

Expand Down
2 changes: 1 addition & 1 deletion src/Robo/Commands/Source/LinkPackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LinkPackageCommand extends BltTasks {
*/
public function linkComposer(array $options = [
'name' => 'acquia/blt',
'path' => '../../packages/blt',
'path' => '../../src/blt',
'version-constraint' => '*',
]) {
$path_parts = explode('/', $options['path']);
Expand Down
39 changes: 39 additions & 0 deletions src/Robo/Commands/Source/SettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ public function initialize() {
* @command source:build:settings
*
* @aliases blt:init:settings bis settings setup:settings
* @throws \Acquia\Blt\Robo\Exceptions\BltException
*/
public function generateSiteConfigFiles() {
$this->generateLocalConfigFile();

// Generate hash file in salt.txt.
$this->hashSalt();

Expand Down Expand Up @@ -348,4 +351,40 @@ public function createDeployId($options = ['id' => InputOption::VALUE_REQUIRED])
}
}

/**
* Generates local.blt.yml from example.local.blt.yml.
*
* @throws \Acquia\Blt\Robo\Exceptions\BltException
*/
private function generateLocalConfigFile() {
$localConfigFile = $this->getConfigValue('blt.config-files.local');
$exampleLocalConfigFile = $this->getConfigValue('blt.config-files.example-local');
$localConfigFilepath = $this->getInspector()
->getFs()
->makePathRelative($localConfigFile, $this->getConfigValue('repo.root'));
$exampleLocalConfigFilepath = $this->getInspector()
->getFs()
->makePathRelative($exampleLocalConfigFile, $this->getConfigValue('repo.root'));

if (file_exists($localConfigFile)) {
// Don't overwrite an existing local.blt.yml.
return;
}

if (!file_exists($exampleLocalConfigFile)) {
$this->say("Could not find $exampleLocalConfigFilepath. Create and commit this file if you'd like to automatically generate $localConfigFilepath based on this template.");
return;
}

$result = $this->taskFilesystemStack()
->copy($exampleLocalConfigFile, $localConfigFile)
->stopOnFail()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();

if (!$result->wasSuccessful()) {
throw new BltException("Unable to create $localConfigFilepath.");
}
}

}

0 comments on commit 6210afd

Please sign in to comment.