Skip to content

Commit

Permalink
Merge pull request #37 from universityofadelaide/add-config-plus
Browse files Browse the repository at this point in the history
Adds configImportPlus and configExportPlus commands.
  • Loading branch information
acbramley authored Jul 16, 2018
2 parents 9a4804b + 114d2bb commit 894b0a0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
53 changes: 53 additions & 0 deletions RoboFileBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,34 @@ abstract class RoboFileBase extends \Robo\Tasks {
*/
protected $phpcsRuleset = 'vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml';

/**
* The path to the config dir.
*
* @var string
*/
protected $configDir = '/code/config-export';

/**
* The path to the config install dir.
*
* @var string
*/
protected $configInstallDir = '/code/config-install';

/**
* The path to the config delete list.
*
* @var string
*/
protected $configDeleteList = '/code/drush/config-delete.yml';

/**
* The path to the config delete list.
*
* @var string
*/
protected $configIgnoreList = '/code/drush/config-ignore.yml';

/**
* Initialize config variables and apply overrides.
*/
Expand Down Expand Up @@ -373,6 +401,7 @@ public function configExportNew() {
* The folder within the application root.
*/
protected function configExport($destination = NULL) {
$this->yell('This command is deprecated, you should use config:export-plus instead', 40, 'red');
if ($destination) {
$this->_exec("$this->drush_cmd -y cex --destination=" . $destination);
$this->_exec("sed -i '/^uuid:.*$/d; /^_core:$/, /^.*default_config_hash:.*$/d' $this->application_root/$destination/*.yml");
Expand All @@ -389,6 +418,7 @@ protected function configExport($destination = NULL) {
* Diff output as an array of strings.
*/
public function configChanges($opts = ['show|s' => FALSE]) {
$this->yell('This command is deprecated, you should use config:export-plus and config:import-plus instead', 40, 'red');
$output_style = '-qbr';
$config_old_path = $this->application_root . '/' . $this->config_old_directory;
$config_new_path = $this->application_root . '/' . $this->config_new_directory;
Expand Down Expand Up @@ -416,6 +446,7 @@ public function configChanges($opts = ['show|s' => FALSE]) {
* If the sync is to update an entity instead of a profile, supple a path.
*/
public function configSync($path = NULL) {
$this->yell('This command is deprecated, you should use config:export-plus and config:import-plus instead', 40, 'red');
$config_sync_already_run = FALSE;
$output_path = $this->application_root . '/profiles/' . $this->getDrupalProfile() . '/config/install';
$config_new_path = $this->application_root . '/' . $this->config_new_directory;
Expand Down Expand Up @@ -469,6 +500,28 @@ public function configSync($path = NULL) {
$tasks->run();
}

/**
* Imports configuration using advanced drush commands.
*
* Commands provided by previousnext/drush_cmi_tools.
*
* @see https://github.com/previousnext/drush_cmi_tools
*/
public function configImportPlus() {
$this->_exec("$this->drush_cmd cimy -y --source=$this->configDir --install=$this->configInstallDir --delete-list=$this->configDeleteList");
}

/**
* Exports configuration using advanced drush commands.
*
* Commands provided by previousnext/drush_cmi_tools.
*
* @see https://github.com/previousnext/drush_cmi_tools
*/
public function configExportPlus() {
$this->_exec("$this->drush_cmd cexy -y --destination=$this->configDir --ignore-list=$this->configIgnoreList");
}

/**
* Turns on twig debug mode, autoreload on and caching off.
*/
Expand Down
1 change: 1 addition & 0 deletions drush/config-delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
delete: {}
1 change: 1 addition & 0 deletions drush/config-ignore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore: {}
16 changes: 10 additions & 6 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function updateShepherdScaffoldFiles()
'docker-compose.yml',
'dsh_proxy.conf',
'RoboFile.php',
'drush/config-ignore.yml',
'drush/config-delete.yml',
]
);
}
Expand All @@ -94,16 +96,18 @@ public function createDirectories()
{
$root = $this->getDrupalRootPath();
$dirs = [
'modules',
'profiles',
'themes',
$root . '/modules',
$root . '/profiles',
$root . '/themes',
'config-install',
'config-export',
];

// Required for unit testing.
foreach ($dirs as $dir) {
if (!$this->filesystem->exists($root . '/'. $dir)) {
$this->filesystem->mkdir($root . '/'. $dir);
$this->filesystem->touch($root . '/'. $dir . '/.gitkeep');
if (!$this->filesystem->exists($dir)) {
$this->filesystem->mkdir($dir);
$this->filesystem->touch($dir . '/.gitkeep');
}
}
}
Expand Down

0 comments on commit 894b0a0

Please sign in to comment.