Skip to content

Commit

Permalink
[!!!][TASK] Make commands compatible with Flow 4.0
Browse files Browse the repository at this point in the history
Flow 4.0 has now the Neos namespace and needs
a different fully qualified name for the commands.

This change is breaking as the default Flow version
is now set to 4.0 and configurations might need to
be adapted.

Resolves: TYPO3#49
  • Loading branch information
Sebastian Helzle authored and Sebobo committed Jan 31, 2017
1 parent 583c5fa commit df98de6
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 26 deletions.
39 changes: 34 additions & 5 deletions src/Application/Neos/Flow.php
Expand Up @@ -25,7 +25,7 @@ class Flow extends BaseApplication
* The Neos Flow major and minor version of this application
* @var string
*/
protected $version = '3.0';
protected $version = '4.0';

/**
* Constructor
Expand Down Expand Up @@ -150,9 +150,8 @@ public function getBuildEssentialsDirectoryName()
{
if ($this->getVersion() <= '1.1') {
return 'Common';
} else {
return 'BuildEssentials';
}
return 'BuildEssentials';
}

/**
Expand All @@ -166,8 +165,38 @@ public function getFlowScriptName()
{
if ($this->getVersion() <= '1.1') {
return 'flow3';
} else {
return 'flow';
}
return 'flow';
}

/**
*
*
* @return string
*/
public function getCommandPackageKey()
{
if ($this->getVersion() < '2.0') {
return 'typo3.flow3';
}
if ($this->getVersion() < '4.0') {
return 'typo3.flow';
}
return 'neos.flow';
}

/**
* Returns a executable flow command including the context
*
* @param string $targetPath the path where the command should be executed
* @param string $command the actual command for example `cache:flush`
* @param array $arguments list of arguments which will be appended to the command
* @return string
*/
public function buildCommand($targetPath, $command, array $arguments = [])
{
return 'cd ' . $targetPath . ' && FLOW_CONTEXT=' . $this->getContext() .
' ./' . $this->getFlowScriptName() . ' ' . $this->getCommandPackageKey() . ':' . $command . ' '
. join(' ', array_map('escapeshellarg', $arguments));
}
}
4 changes: 2 additions & 2 deletions src/Task/Neos/Flow/FlushCacheListTask.php
Expand Up @@ -21,7 +21,7 @@
* You can configure the list of cache identifiers in the task option ```flushCacheList```, like::
*
* $workflow->setTaskOptions('TYPO3\\Surf\\Task\\Neos\\Flow\\FlushCacheListTask', [
* 'flushCacheList' => 'TYPO3_TypoScript_Content, Flow_Session_MetaData, Flow_Session_Storage'
* 'flushCacheList' => 'Neos_Fusion_Content, Flow_Session_MetaData, Flow_Session_Storage'
* ])
*
*/
Expand Down Expand Up @@ -57,7 +57,7 @@ public function execute(Node $node, Application $application, Deployment $deploy
$targetPath = $deployment->getApplicationReleasePath($application);
foreach ($caches as $cache) {
$deployment->getLogger()->debug(sprintf('Flush cache with identifier "%s"', $cache));
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . sprintf('typo3.flow:cache:flushone --identifier %s',
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . sprintf('flow:cache:flushone --identifier %s',
$cache), $node, $deployment);
}
} else {
Expand Down
7 changes: 1 addition & 6 deletions src/Task/Neos/Flow/MigrateTask.php
Expand Up @@ -39,13 +39,8 @@ public function execute(Node $node, Application $application, Deployment $deploy
throw new InvalidConfigurationException(sprintf('Flow application needed for MigrateTask, got "%s"', get_class($application)), 1358863288);
}

$commandPackageKey = 'typo3.flow';
if ($application->getVersion() < '2.0') {
$commandPackageKey = 'typo3.flow3';
}

$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . $commandPackageKey . ':doctrine:migrate', $node, $deployment);
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'doctrine:migrate'), $node, $deployment);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Neos/Flow/PublishResourcesTask.php
Expand Up @@ -39,7 +39,7 @@ public function execute(Node $node, Application $application, Deployment $deploy

if ($application->getVersion() >= '3.0') {
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . 'typo3.flow:resource:publish', $node, $deployment);
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'resource:publish'), $node, $deployment);
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/Task/Neos/Flow/SetFilePermissionsTask.php
Expand Up @@ -35,21 +35,20 @@ class SetFilePermissionsTask extends Task implements ShellCommandServiceAwareInt
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
if (!$application instanceof Flow) {
throw new InvalidConfigurationException(sprintf('Flow application needed for SetFilePermissionsTask, got "%s"', get_class($application)), 1358863436);
throw new InvalidConfigurationException(sprintf('Flow application needed for SetFilePermissionsTask, got "%s"',
get_class($application)), 1358863436);
}

$targetPath = $deployment->getApplicationReleasePath($application);

$arguments = isset($options['shellUsername']) ? $options['shellUsername'] : (isset($options['username']) ? $options['username'] : 'root');
$arguments .= ' ' . (isset($options['webserverUsername']) ? $options['webserverUsername'] : 'www-data');
$arguments .= ' ' . (isset($options['webserverGroupname']) ? $options['webserverGroupname'] : 'www-data');
$arguments = [
isset($options['shellUsername']) ? $options['shellUsername'] : (isset($options['username']) ? $options['username'] : 'root'),
isset($options['webserverUsername']) ? $options['webserverUsername'] : 'www-data',
isset($options['webserverGroupname']) ? $options['webserverGroupname'] : 'www-data'
];

$commandPackageKey = 'typo3.flow';
if ($application->getVersion() < '2.0') {
$commandPackageKey = 'typo3.flow3';
}

$this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . $commandPackageKey . ':core:setfilepermissions ' . $arguments, $node, $deployment);
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'core:setfilepermissions',
[$arguments]), $node, $deployment);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Task/Neos/Neos/ImportSiteTask.php
Expand Up @@ -43,8 +43,11 @@ public function execute(Node $node, Application $application, Deployment $deploy
}

$targetPath = $deployment->getApplicationReleasePath($application);
$sitePackageKey = $options['sitePackageKey'];
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && FLOW_CONTEXT=' . $application->getContext() . ' ./flow typo3.neos:site:import --package-key ' . $sitePackageKey, $node, $deployment);
$arguments = [
'--package-key',
$options['sitePackageKey']
];
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'site:import', $arguments), $node, $deployment);
}

/**
Expand Down

0 comments on commit df98de6

Please sign in to comment.