Skip to content

Commit

Permalink
[FEATURE] Add postClone option to the clone command
Browse files Browse the repository at this point in the history
The postClone option can either be an array or a string. The given commands are executed with the shell after the clone is finished.
The the local FLOW_CONTEXT is added to the command so `./flow ...` can be used without specifying the context.
  • Loading branch information
mficzel committed Mar 1, 2016
1 parent 9a3f59a commit cfda533
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Classes/Sitegeist/MagicWand/Command/AbstractCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,23 @@ protected function executeLocalShellCommand($command, $arguments = [], $options
* @param array $arguments
* @param array $options
*/
protected function executeLocalFlowCommand($command, $arguments = [], $options = [])
protected function executeLocalShellCommandWithFlowContext($command, $arguments = [], $options = [])
{
$flowCommand = 'FLOW_CONTEXT=' . $this->bootstrap->getContext() . ' ./flow ' . $command;
$flowCommand = 'FLOW_CONTEXT=' . $this->bootstrap->getContext() . ' ' . $command;
return $this->executeLocalShellCommand($flowCommand, $arguments, $options);
}

/**
* @param string $commands
* @param array $arguments
* @param array $options
*/
protected function executeLocalFlowCommand($command, $arguments = [], $options = [])
{
$flowCommand = './flow ' . $command;
return $this->executeLocalShellCommandWithFlowContext($flowCommand, $arguments, $options);
}

/**
* @param $line
*/
Expand Down
18 changes: 18 additions & 0 deletions Classes/Sitegeist/MagicWand/Command/CloneCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function presetCommand($presetName, $yes = false, $keepDb = false)
$this->clonePresets[$presetName]['port'],
$this->clonePresets[$presetName]['path'],
$this->clonePresets[$presetName]['context'],
($this->clonePresets[$presetName]['postClone'] ? $this->clonePresets[$presetName]['postClone'] : NULL),
$yes,
$keepDb
);
Expand All @@ -84,6 +85,7 @@ public function presetCommand($presetName, $yes = false, $keepDb = false)
* @param string $port ssh port
* @param string $path path on the remote server
* @param string $context flow_context on the remote server
* @param mixded $postClone command or array of commands to be executed after cloning

This comment has been minimized.

Copy link
@ComiR

ComiR Apr 26, 2016

typo! ;)

* @param boolean $yes confirm execution without further input
* @param boolean $keepDb skip dropping of database during sync
*/
Expand All @@ -93,6 +95,7 @@ public function remoteHostCommand(
$port,
$path,
$context = 'Production',
$postClone = NULL,
$yes = false,
$keepDb = false
) {
Expand Down Expand Up @@ -240,6 +243,21 @@ public function remoteHostCommand(
$this->outputHeadLine('Publish Resources');
$this->executeLocalFlowCommand('resource:publish');

##############
# Post Clone #
##############

if ($postClone) {
$this->outputHeadLine('Execute post_clone commands');
if (is_array($postClone)) {
foreach($postClone as $postCloneCommand) {
$this->executeLocalShellCommandWithFlowContext($postCloneCommand);
}
} else {
$this->executeLocalShellCommandWithFlowContext($postClone);
}
}

#################
# Final Message #
#################
Expand Down

0 comments on commit cfda533

Please sign in to comment.