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

OPENEUROPA-1161: Add --config-dir option do drupal:site-install command #77

Merged
merged 2 commits into from
Sep 4, 2018
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
1 change: 1 addition & 0 deletions config/commands/drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ command:
database-user: ${drupal.database.user}
database-password: ${drupal.database.password}
sites-subdir: ${drupal.site.sites_subdir}
config-dir: ${drupal.site.config_dir}
drush-setup:
options:
config-dir: ${drupal.root}/drush
1 change: 1 addition & 0 deletions config/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ drupal:
update: "false"
locale: "en"
sites_subdir: "default"
config_dir: ~

# Administrator account information.
account:
Expand Down
6 changes: 6 additions & 0 deletions src/Commands/DrupalCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function validateSiteInstall(CommandData $commandData)
* @option database-user Database username.
* @option database-password Database password.
* @option sites-subdir Sites sub-directory.
* @option config-dir Config export directory.
*
* @aliases drupal:si,dsi
*
Expand All @@ -124,6 +125,7 @@ public function siteInstall(array $options = [
'database-port' => InputOption::VALUE_REQUIRED,
'database-name' => InputOption::VALUE_REQUIRED,
'sites-subdir' => InputOption::VALUE_REQUIRED,
'config-dir' => InputOption::VALUE_REQUIRED,
])
{
if ($options['database-type']) {
Expand All @@ -149,6 +151,10 @@ public function siteInstall(array $options = [
->sitesSubdir($options['sites-subdir'])
->siteProfile($options['site-profile']);

if (!empty($options['config-dir'])) {
$task->setConfigDir($options['config-dir']);
}

return $this->collectionBuilder()->addTaskList([
$this->sitePreInstall(),
$task->siteInstall(),
Expand Down
25 changes: 21 additions & 4 deletions src/Tasks/Drush/Drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Drush extends Exec
protected $databasePassword = '';
protected $databaseName = '';
protected $sitesSubdir = '';
protected $configDir = '';

/**
* Build Drush site install command.
Expand All @@ -47,7 +48,7 @@ public function siteInstall()
];
$dbUrl = http_build_url($dbArray, $dbArray);

return $this->option('-y')
$this->option('-y')
->rawArg("--root=$(pwd)/".$this->root)
->options([
'site-name' => $this->siteName,
Expand All @@ -58,9 +59,13 @@ public function siteInstall()
'account-pass' => $this->accountPassword,
'sites-subdir' => $this->sitesSubdir,
'db-url' => $dbUrl,
], '=')
->arg('site-install')
->arg($this->siteProfile);
], '=');

if (!empty($this->configDir)) {
$this->option('config-dir', $this->configDir, '=');
}

return $this->arg('site-install')->arg($this->siteProfile);
}

/**
Expand Down Expand Up @@ -254,4 +259,16 @@ public function sitesSubdir($sitesSubdir)

return $this;
}

/**
* @param string $configDir
*
* @return Drush
*/
public function setConfigDir($configDir)
{
$this->configDir = $configDir;

return $this;
}
}
24 changes: 24 additions & 0 deletions tests/fixtures/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@
contains:
- "./bin/drush -y --root=$(pwd)/overridden"

- command: 'drupal:site-install --site-name="Test site" --config-dir="../config-dir"'
configuration:
drupal:
database:
name: "drupal"
user: "root"
password: "root"
composer: ''
contains:
- "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Test site' [email protected] --locale=en [email protected] --account-name=admin --account-pass=admin --sites-subdir=default --db-url='mysql://root:[email protected]:3306/drupal' --config-dir=../config-dir site-install standard"

- command: 'drupal:site-install --site-name="Test site"'
configuration:
drupal:
site:
config_dir: "../config/sync"
database:
name: "drupal"
user: "root"
password: "root"
composer: ''
contains:
- "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Test site' [email protected] --locale=en [email protected] --account-name=admin --account-pass=admin --sites-subdir=default --db-url='mysql://root:[email protected]:3306/drupal' --config-dir=../config/sync site-install standard"

- command: 'changelog:generate'
configuration:
github:
Expand Down