Skip to content

Commit

Permalink
Making requirement for composer.lock update after BLT update more cle…
Browse files Browse the repository at this point in the history
…ar. (#741)

* Making requirement for composer.lock update after BLT update more clear.

* Changing deploy key to prod in modules array.

* Making composer install verbose.

* Fixing repo root in updater.

* Fixing args

* Adding missing file.
  • Loading branch information
grasmash authored Dec 5, 2016
1 parent 10b70d3 commit f671c33
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ install:
- composer validate --no-check-all --ansi
# Remove acquia packages from cache before running `composer install`.
- rm -rf vendor/acquia
- composer install
- composer install -v
- export PATH=$TRAVIS_BUILD_DIR/vendor/bin:$PATH
# Install proper version of node for front end tasks.
- nvm install 4.4.1
Expand Down
7 changes: 4 additions & 3 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ protected function executeBltUpdate($version) {

// Rsyncs, updates composer.json, project.yml, executes scripted updates for version delta.
$this->executeCommand('blt update');
$this->io->write('<comment>This may have modified your composer.json and require a subsequent `composer update`</comment>');

// @todo check if require or require-dev changed. If so, run `composer update`.
// @todo if require and require-dev did not change, but something else in composer.json changed, execute `composer update --lock`.
$output = $this->executeCommand('composer validate --no-check-all');
if (strstr($output, 'The lock file is not up to date')) {
$this->io->write('<error>Your composer.json dependencies were modified, you MUST run "composer update" to update your composer.lock file. This is not an error.</error>');
}
}
else {
$this->io->write('<comment>Skipping update of BLT templated files</comment>');
Expand Down
3 changes: 1 addition & 2 deletions src/Console/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$ending_version = $input->getArgument('ending_version');
$repo_root = $input->getArgument('repo_root');

$updater = new Updater();
$updater->setRepoRoot($repo_root);
$updater = new Updater('Acquia\Blt\Update\Updates', $repo_root);
$updates = $updater->getUpdates($starting_version, $ending_version);
if ($updates) {
$output->writeln("<comment>The following BLT updates are outstanding:</comment>");
Expand Down
22 changes: 21 additions & 1 deletion src/Update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;
use vierbergenlars\SemVer\version;

/**
Expand Down Expand Up @@ -40,15 +41,19 @@ class Updater {
*
* @param string $update_class
* The name of the class containing the update methods to be executed.
* @param string $repo_root
* The root directory for this project.
*/
public function __construct($update_class = 'Acquia\Blt\Update\Updates') {
public function __construct($update_class, $repo_root) {
$this->output = new ConsoleOutput();
$this->output->setFormatter(new OutputFormatter(TRUE));
AnnotationRegistry::registerFile(__DIR__ . '/../Annotations/Update.php');
$this->annotationsReader = new IndexedReader(new AnnotationReader());
$this->updateClassName = $update_class;
$this->fs = new Filesystem();
$this->setRepoRoot($repo_root);
$this->composerJsonFilepath = $this->repoRoot . '/composer.json';
$this->projectYmlFilepath = $this->repoRoot . '/blt/project.yml';
}

/**
Expand Down Expand Up @@ -322,6 +327,21 @@ public function writeComposerJson($contents) {
file_put_contents($this->composerJsonFilepath, json_encode($contents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}

/**
* @return mixed
*/
public function getProjectConfig() {
$project_yml = Yaml::parse(file_get_contents($this->projectYmlFilepath));

return $project_yml;
}

/**
* @param $contents
*/
public function writeProjectConfig($contents) {
file_put_contents($this->projectYmlFilepath, Yaml::dump($contents, 3, 2));
}

/**
* Moves a file from one location to another, relative to repo root.
Expand Down
8 changes: 8 additions & 0 deletions src/Update/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public function update_860() {

$this->updater->removeComposerRepository('https://github.com/mortenson/composer-patches');
$this->updater->removeComposerScript('post-create-project-cmd');

// Change 'deploy' module key to 'prod'.
// @see https://github.com/acquia/blt/pull/700.
$project_config = $this->updater->getProjectConfig();
if (!empty($project_config['modules']['deploy'])) {
$project_config['modules']['prod'] = $project_config['modules']['deploy'];
unset($project_config['modules']['deploy']);
}
}

}
22 changes: 11 additions & 11 deletions template/blt/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ import: ~

# An array of modules to be enabled or uninstalled automatically in local, ci, and deploy contexts.
modules:
local:
enable:
- dblog
- devel
- field_ui
- seckit
- views_ui
uninstall:
- acsf
- acquia_connector
- shield
ci:
enable: []
uninstall:
Expand All @@ -93,14 +104,3 @@ modules:
- devel
- field_ui
- views_ui
local:
enable:
- dblog
- devel
- field_ui
- seckit
- views_ui
uninstall:
- acsf
- acquia_connector
- shield

0 comments on commit f671c33

Please sign in to comment.