repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
TYPO3/Surf | src/Domain/Model/Application.php | Application.setReleasesDirectory | public function setReleasesDirectory($releasesDirectory)
{
if (preg_match('/(^|\/)\.\.(\/|$)/', $releasesDirectory)) {
throw new InvalidConfigurationException(
sprintf('"../" is not allowed in the releases directory "%s"', $releasesDirectory),
1380870750
);
}
$this->releasesDirectory = trim($releasesDirectory, '/');
return $this;
} | php | public function setReleasesDirectory($releasesDirectory)
{
if (preg_match('/(^|\/)\.\.(\/|$)/', $releasesDirectory)) {
throw new InvalidConfigurationException(
sprintf('"../" is not allowed in the releases directory "%s"', $releasesDirectory),
1380870750
);
}
$this->releasesDirectory = trim($releasesDirectory, '/');
return $this;
} | [
"public",
"function",
"setReleasesDirectory",
"(",
"$",
"releasesDirectory",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/(^|\\/)\\.\\.(\\/|$)/'",
",",
"$",
"releasesDirectory",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"sprintf",
"(",
"'\".... | Sets the releases directory
@param string $releasesDirectory
@return \TYPO3\Surf\Domain\Model\Application The current instance for chaining | [
"Sets",
"the",
"releases",
"directory"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Application.php#L242-L252 |
TYPO3/Surf | src/Domain/Model/Application.php | Application.getOptions | public function getOptions()
{
return array_merge($this->options, [
'deploymentPath' => $this->getDeploymentPath(),
'releasesPath' => $this->getReleasesPath(),
'sharedPath' => $this->getSharedPath()
]);
} | php | public function getOptions()
{
return array_merge($this->options, [
'deploymentPath' => $this->getDeploymentPath(),
'releasesPath' => $this->getReleasesPath(),
'sharedPath' => $this->getSharedPath()
]);
} | [
"public",
"function",
"getOptions",
"(",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"[",
"'deploymentPath'",
"=>",
"$",
"this",
"->",
"getDeploymentPath",
"(",
")",
",",
"'releasesPath'",
"=>",
"$",
"this",
"->",
"getReleasesP... | Get all options defined on this application instance
The options will include the deploymentPath and sharedPath for
unified option handling.
@return array An array of options indexed by option key | [
"Get",
"all",
"options",
"defined",
"on",
"this",
"application",
"instance"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Application.php#L272-L279 |
TYPO3/Surf | src/Domain/Model/Application.php | Application.getOption | public function getOption($key)
{
switch ($key) {
case 'deploymentPath':
return $this->getDeploymentPath();
case 'releasesPath':
return $this->getReleasesPath();
case 'sharedPath':
return $this->getSharedPath();
default:
return $this->options[$key];
}
} | php | public function getOption($key)
{
switch ($key) {
case 'deploymentPath':
return $this->getDeploymentPath();
case 'releasesPath':
return $this->getReleasesPath();
case 'sharedPath':
return $this->getSharedPath();
default:
return $this->options[$key];
}
} | [
"public",
"function",
"getOption",
"(",
"$",
"key",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'deploymentPath'",
":",
"return",
"$",
"this",
"->",
"getDeploymentPath",
"(",
")",
";",
"case",
"'releasesPath'",
":",
"return",
"$",
"this",
"->... | Get an option defined on this application instance
@param string $key
@return mixed | [
"Get",
"an",
"option",
"defined",
"on",
"this",
"application",
"instance"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Application.php#L287-L299 |
TYPO3/Surf | src/Task/TYPO3/CMS/ActivatePackagesTask.php | ActivatePackagesTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
try {
$scriptFileName = $this->getConsoleScriptFileName($node, $application, $deployment, $options);
} catch (InvalidConfigurationException $e) {
$deployment->getLogger()->warning('TYPO3 Console script (' . $options['scriptFileName'] . ') was not found! Make sure it is available in your project, you set the "scriptFileName" option correctly or remove this task (' . __CLASS__ . ') in your deployment configuration!');
return;
}
$deployment->getLogger()->warning('This task has been deprecated and will be removed in Surf 2.1. Please use SetUpExtensionsTask instead.');
$activePackages = isset($options['activePackages']) ? $options['activePackages'] : [];
foreach ($activePackages as $packageKey) {
$this->executeCliCommand(
[$scriptFileName, 'extension:activate', $packageKey],
$node,
$application,
$deployment,
$options
);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
try {
$scriptFileName = $this->getConsoleScriptFileName($node, $application, $deployment, $options);
} catch (InvalidConfigurationException $e) {
$deployment->getLogger()->warning('TYPO3 Console script (' . $options['scriptFileName'] . ') was not found! Make sure it is available in your project, you set the "scriptFileName" option correctly or remove this task (' . __CLASS__ . ') in your deployment configuration!');
return;
}
$deployment->getLogger()->warning('This task has been deprecated and will be removed in Surf 2.1. Please use SetUpExtensionsTask instead.');
$activePackages = isset($options['activePackages']) ? $options['activePackages'] : [];
foreach ($activePackages as $packageKey) {
$this->executeCliCommand(
[$scriptFileName, 'extension:activate', $packageKey],
$node,
$application,
$deployment,
$options
);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensureApplicationIsTypo3Cms",
"(",
"$",
"app... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/ActivatePackagesTask.php#L44-L64 |
TYPO3/Surf | src/Task/TYPO3/CMS/SymlinkDataTask.php | SymlinkDataTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$targetReleasePath = $deployment->getApplicationReleasePath($application);
$webDirectory = $options['webDirectory'];
$relativeDataPath = $relativeDataPathFromWeb = '../../shared/Data';
if ($webDirectory !== '') {
$relativeDataPathFromWeb = str_repeat('../', substr_count(trim($webDirectory, '/'), '/') + 1) . $relativeDataPath;
}
$absoluteWebDirectory = rtrim("$targetReleasePath/$webDirectory", '/');
$commands[] = 'cd ' . escapeshellarg($targetReleasePath);
foreach ($options['symlinkDataFolders'] as $directory) {
$commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($relativeDataPath . '/' . $directory));
$commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg($relativeDataPathFromWeb . '/' . $directory), escapeshellarg($absoluteWebDirectory . '/' . $directory));
}
foreach ($options['directories'] as $directory) {
$directory = trim($directory, '\\/');
$targetDirectory = Files::concatenatePaths([$relativeDataPath, $directory]);
$commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($targetDirectory));
$commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg(str_repeat('../', substr_count(trim($directory, '/'), '/')) . $targetDirectory), escapeshellarg($directory));
}
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$targetReleasePath = $deployment->getApplicationReleasePath($application);
$webDirectory = $options['webDirectory'];
$relativeDataPath = $relativeDataPathFromWeb = '../../shared/Data';
if ($webDirectory !== '') {
$relativeDataPathFromWeb = str_repeat('../', substr_count(trim($webDirectory, '/'), '/') + 1) . $relativeDataPath;
}
$absoluteWebDirectory = rtrim("$targetReleasePath/$webDirectory", '/');
$commands[] = 'cd ' . escapeshellarg($targetReleasePath);
foreach ($options['symlinkDataFolders'] as $directory) {
$commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($relativeDataPath . '/' . $directory));
$commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg($relativeDataPathFromWeb . '/' . $directory), escapeshellarg($absoluteWebDirectory . '/' . $directory));
}
foreach ($options['directories'] as $directory) {
$directory = trim($directory, '\\/');
$targetDirectory = Files::concatenatePaths([$relativeDataPath, $directory]);
$commands[] = sprintf('{ [ -d %1$s ] || mkdir -p %1$s; }', escapeshellarg($targetDirectory));
$commands[] = sprintf('ln -sf %1$s %2$s', escapeshellarg(str_repeat('../', substr_count(trim($directory, '/'), '/')) . $targetDirectory), escapeshellarg($directory));
}
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"(... | Executes this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/SymlinkDataTask.php#L38-L63 |
TYPO3/Surf | src/Domain/Model/Task.php | Task.rollback | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->configureOptions($options);
} | php | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->configureOptions($options);
} | [
"public",
"function",
"rollback",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"configureOptions",
"(",
"$",
"options",
"... | Rollback this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Rollback",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Task.php#L46-L49 |
TYPO3/Surf | src/Domain/Model/Task.php | Task.configureOptions | protected function configureOptions(array $options = [])
{
try {
$resolver = new OptionsResolver();
// We set all global options as defined options, otherwise we would get a lot of exceptions
$resolver->setDefined(array_keys($options));
$this->resolveOptions($resolver);
return $resolver->resolve($options);
} catch (MissingOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (InvalidOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (NoConfigurationException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (NoSuchOptionException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (OptionDefinitionException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (UndefinedOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (ExceptionInterface $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
}
} | php | protected function configureOptions(array $options = [])
{
try {
$resolver = new OptionsResolver();
// We set all global options as defined options, otherwise we would get a lot of exceptions
$resolver->setDefined(array_keys($options));
$this->resolveOptions($resolver);
return $resolver->resolve($options);
} catch (MissingOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (InvalidOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (NoConfigurationException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (NoSuchOptionException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (OptionDefinitionException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (UndefinedOptionsException $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
} catch (ExceptionInterface $e) {
throw new InvalidConfigurationException($e->getMessage(), $e->getCode());
}
} | [
"protected",
"function",
"configureOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"// We set all global options as defined options, otherwise we would get a lot of exceptions",
... | @param array $options
@return array
@throws \Exception | [
"@param",
"array",
"$options"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Task.php#L70-L93 |
TYPO3/Surf | src/Task/Neos/Flow/SymlinkDataTask.php | SymlinkDataTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$releaseIdentifier = $deployment->getReleaseIdentifier();
$releasesPath = $application->getReleasesPath();
$commands = [
"mkdir -p $releasesPath/$releaseIdentifier/Data",
"cd $releasesPath/$releaseIdentifier",
'ln -sf ../../../shared/Data/Logs ./Data/Logs',
'ln -sf ../../../shared/Data/Persistent ./Data/Persistent'
];
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$releaseIdentifier = $deployment->getReleaseIdentifier();
$releasesPath = $application->getReleasesPath();
$commands = [
"mkdir -p $releasesPath/$releaseIdentifier/Data",
"cd $releasesPath/$releaseIdentifier",
'ln -sf ../../../shared/Data/Logs ./Data/Logs',
'ln -sf ../../../shared/Data/Persistent ./Data/Persistent'
];
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"releaseIdentifier",
"=",
"$",
"deployment",
"->",
"getRele... | Executes this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/SymlinkDataTask.php#L35-L46 |
TYPO3/Surf | src/Task/Release/ReleaseTask.php | ReleaseTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$host = $options['releaseHost'];
$login = $options['releaseHostLogin'];
$changeLogUri = $options['changeLogUri'];
$sitePath = $options['releaseHostSitePath'];
$version = $options['version'];
$productName = $options['productName'];
$this->shell->executeOrSimulate(sprintf('ssh %s%s "cd \"%s\" ; ./flow release:release --product-name \"%s\" --version \"%s\" --change-log-uri \"%s\""', ($login ? $login . '@' : ''), $host, $sitePath, $productName, $version, ($changeLogUri ? $changeLogUri : '')), $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$host = $options['releaseHost'];
$login = $options['releaseHostLogin'];
$changeLogUri = $options['changeLogUri'];
$sitePath = $options['releaseHostSitePath'];
$version = $options['version'];
$productName = $options['productName'];
$this->shell->executeOrSimulate(sprintf('ssh %s%s "cd \"%s\" ; ./flow release:release --product-name \"%s\" --version \"%s\" --change-log-uri \"%s\""', ($login ? $login . '@' : ''), $host, $sitePath, $productName, $version, ($changeLogUri ? $changeLogUri : '')), $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"(... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Release/ReleaseTask.php#L29-L41 |
TYPO3/Surf | src/Task/TYPO3/CMS/CompareDatabaseTask.php | CompareDatabaseTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
$cliArguments = $this->getSuitableCliArguments($node, $application, $deployment, $options);
if (empty($cliArguments)) {
$deployment->getLogger()->warning('Neither Extension "typo3_console" nor "coreapi" was not found! Make sure one is available in your project, or remove this task (' . __CLASS__ . ') in your deployment configuration!');
return;
}
$this->executeCliCommand(
$cliArguments,
$node,
$application,
$deployment,
$options
);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
$cliArguments = $this->getSuitableCliArguments($node, $application, $deployment, $options);
if (empty($cliArguments)) {
$deployment->getLogger()->warning('Neither Extension "typo3_console" nor "coreapi" was not found! Make sure one is available in your project, or remove this task (' . __CLASS__ . ') in your deployment configuration!');
return;
}
$this->executeCliCommand(
$cliArguments,
$node,
$application,
$deployment,
$options
);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensureApplicationIsTypo3Cms",
"(",
"$",
"app... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/CompareDatabaseTask.php#L43-L58 |
TYPO3/Surf | src/Task/Neos/Flow/CreateDirectoriesTask.php | CreateDirectoriesTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = [
'directories' => [
'shared/Data/Logs',
'shared/Data/Persistent',
'shared/Configuration'
],
'baseDirectory' => $application->getDeploymentPath()
];
parent::execute($node, $application, $deployment, $options);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = [
'directories' => [
'shared/Data/Logs',
'shared/Data/Persistent',
'shared/Configuration'
],
'baseDirectory' => $application->getDeploymentPath()
];
parent::execute($node, $application, $deployment, $options);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"'directories'",
"=>",
"[",
"'shared... | Execute this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/CreateDirectoriesTask.php#L30-L41 |
TYPO3/Surf | src/Command/ShowCommand.php | ShowCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentNames = $this->factory->getDeploymentNames($configurationPath);
$output->writeln(sprintf(PHP_EOL . '<u>Deployments in "%s":</u>' . PHP_EOL, $this->factory->getDeploymentsBasePath($configurationPath)));
foreach ($deploymentNames as $deploymentName) {
$line = sprintf(' <info>%s</info>', $deploymentName);
$output->writeln($line);
}
$output->writeln('');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentNames = $this->factory->getDeploymentNames($configurationPath);
$output->writeln(sprintf(PHP_EOL . '<u>Deployments in "%s":</u>' . PHP_EOL, $this->factory->getDeploymentsBasePath($configurationPath)));
foreach ($deploymentNames as $deploymentName) {
$line = sprintf(' <info>%s</info>', $deploymentName);
$output->writeln($line);
}
$output->writeln('');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"configurationPath",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'configurationPath'",
")",
";",
"$",
"deploymentNames",
"=",
"$",
"t... | Execute
@param InputInterface $input
@param OutputInterface $output | [
"Execute"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/ShowCommand.php#L46-L57 |
TYPO3/Surf | src/Command/DescribeCommand.php | DescribeCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$deployment = $this->factory->getDeployment($deploymentName, $configurationPath);
$workflow = $deployment->getWorkflow();
if (! $deployment instanceof FailedDeployment) {
$output->writeln('<success>Deployment ' . $deployment->getName() . '</success>');
$output->writeln('');
$output->writeln('Workflow: <success>' . $workflow->getName() . '</success>');
if ($workflow instanceof SimpleWorkflow) {
$value = $workflow->isEnableRollback() ? 'true' : 'false';
$output->writeln(' <comment>Rollback enabled:</comment> <info>' . $value . '</info>');
}
$output->writeln('');
$this->printNodes($deployment->getNodes());
$this->printApplications($deployment->getApplications(), $deployment->getWorkflow());
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$deployment = $this->factory->getDeployment($deploymentName, $configurationPath);
$workflow = $deployment->getWorkflow();
if (! $deployment instanceof FailedDeployment) {
$output->writeln('<success>Deployment ' . $deployment->getName() . '</success>');
$output->writeln('');
$output->writeln('Workflow: <success>' . $workflow->getName() . '</success>');
if ($workflow instanceof SimpleWorkflow) {
$value = $workflow->isEnableRollback() ? 'true' : 'false';
$output->writeln(' <comment>Rollback enabled:</comment> <info>' . $value . '</info>');
}
$output->writeln('');
$this->printNodes($deployment->getNodes());
$this->printApplications($deployment->getApplications(), $deployment->getWorkflow());
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"$",
"output",
";",
"$",
"configurationPath",
... | Prints configuration for the
@param InputInterface $input
@param OutputInterface $output | [
"Prints",
"configuration",
"for",
"the"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/DescribeCommand.php#L67-L92 |
TYPO3/Surf | src/Command/DescribeCommand.php | DescribeCommand.printApplications | protected function printApplications(array $applications, Workflow $workflow)
{
$this->output->writeln(PHP_EOL . 'Applications:' . PHP_EOL);
foreach ($applications as $application) {
$this->output->writeln(' <success>' . $application->getName() . ':</success>');
$this->output->writeln(' <comment>Deployment path</comment>: <success>' . $application->getDeploymentPath() . '</success>');
$this->output->writeln(' <comment>Options</comment>: ');
foreach ($application->getOptions() as $key => $value) {
if (is_array($value)) {
$this->output->writeln(' ' . $key . ' =>');
foreach ($value as $itemKey => $itemValue) {
$itemOutput = is_string($itemKey) ? sprintf('%s => %s', $itemKey, $itemValue) : $itemValue;
$this->output->writeln(sprintf(' <success>%s</success>', $itemOutput));
}
} else {
$printableValue = is_scalar($value) ? $value : gettype($value);
$this->output->writeln(' ' . $key . ' => <success>' . $printableValue . '</success>');
}
}
$this->output->writeln(' <comment>Nodes</comment>: <success>' . implode(
', ',
$application->getNodes()
) . '</success>');
if ($workflow instanceof SimpleWorkflow) {
$this->output->writeln(' <comment>Detailed workflow</comment>: ');
$this->printStages($application, $workflow->getStages(), $workflow->getTasks());
}
}
} | php | protected function printApplications(array $applications, Workflow $workflow)
{
$this->output->writeln(PHP_EOL . 'Applications:' . PHP_EOL);
foreach ($applications as $application) {
$this->output->writeln(' <success>' . $application->getName() . ':</success>');
$this->output->writeln(' <comment>Deployment path</comment>: <success>' . $application->getDeploymentPath() . '</success>');
$this->output->writeln(' <comment>Options</comment>: ');
foreach ($application->getOptions() as $key => $value) {
if (is_array($value)) {
$this->output->writeln(' ' . $key . ' =>');
foreach ($value as $itemKey => $itemValue) {
$itemOutput = is_string($itemKey) ? sprintf('%s => %s', $itemKey, $itemValue) : $itemValue;
$this->output->writeln(sprintf(' <success>%s</success>', $itemOutput));
}
} else {
$printableValue = is_scalar($value) ? $value : gettype($value);
$this->output->writeln(' ' . $key . ' => <success>' . $printableValue . '</success>');
}
}
$this->output->writeln(' <comment>Nodes</comment>: <success>' . implode(
', ',
$application->getNodes()
) . '</success>');
if ($workflow instanceof SimpleWorkflow) {
$this->output->writeln(' <comment>Detailed workflow</comment>: ');
$this->printStages($application, $workflow->getStages(), $workflow->getTasks());
}
}
} | [
"protected",
"function",
"printApplications",
"(",
"array",
"$",
"applications",
",",
"Workflow",
"$",
"workflow",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"PHP_EOL",
".",
"'Applications:'",
".",
"PHP_EOL",
")",
";",
"foreach",
"(",
"$",
... | Prints configuration for each defined application
@param array $applications
@param Workflow $workflow | [
"Prints",
"configuration",
"for",
"each",
"defined",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/DescribeCommand.php#L111-L140 |
TYPO3/Surf | src/Command/DescribeCommand.php | DescribeCommand.printStages | protected function printStages(Application $application, array $stages, array $tasks)
{
foreach ($stages as $stage) {
$this->output->writeln(' <comment>' . $stage . ':</comment>');
foreach (['before', 'tasks', 'after'] as $stageStep) {
$output = '';
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all applications' : 'for application ' . $applicationName;
if (isset($tasks['stage'][$applicationName][$stage][$stageStep])) {
foreach ($tasks['stage'][$applicationName][$stage][$stageStep] as $task) {
$this->printBeforeAfterTasks($tasks, $applicationName, $task, 'before', $output);
$output .= ' <success>' . $task . '</success> <info>(' . $label . ')</info>' . PHP_EOL;
$this->printBeforeAfterTasks($tasks, $applicationName, $task, 'after', $output);
}
}
}
if (strlen($output) > 0) {
$this->output->writeln(' <info>' . $stageStep . ':</info>');
}
$this->output->write($output);
}
}
} | php | protected function printStages(Application $application, array $stages, array $tasks)
{
foreach ($stages as $stage) {
$this->output->writeln(' <comment>' . $stage . ':</comment>');
foreach (['before', 'tasks', 'after'] as $stageStep) {
$output = '';
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all applications' : 'for application ' . $applicationName;
if (isset($tasks['stage'][$applicationName][$stage][$stageStep])) {
foreach ($tasks['stage'][$applicationName][$stage][$stageStep] as $task) {
$this->printBeforeAfterTasks($tasks, $applicationName, $task, 'before', $output);
$output .= ' <success>' . $task . '</success> <info>(' . $label . ')</info>' . PHP_EOL;
$this->printBeforeAfterTasks($tasks, $applicationName, $task, 'after', $output);
}
}
}
if (strlen($output) > 0) {
$this->output->writeln(' <info>' . $stageStep . ':</info>');
}
$this->output->write($output);
}
}
} | [
"protected",
"function",
"printStages",
"(",
"Application",
"$",
"application",
",",
"array",
"$",
"stages",
",",
"array",
"$",
"tasks",
")",
"{",
"foreach",
"(",
"$",
"stages",
"as",
"$",
"stage",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
... | Prints stages and contained tasks for given application
@param Application $application
@param array $stages
@param array $tasks | [
"Prints",
"stages",
"and",
"contained",
"tasks",
"for",
"given",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/DescribeCommand.php#L149-L172 |
TYPO3/Surf | src/Command/DescribeCommand.php | DescribeCommand.printBeforeAfterTasks | private function printBeforeAfterTasks(array $tasks, $applicationName, $task, $step, &$output)
{
$label = $applicationName === '_' ? 'for all applications' : 'for application ' . $applicationName;
if (isset($tasks[$step][$applicationName][$task])) {
// 'Task "' . $beforeTask . '" before "' . $task
foreach ($tasks[$step][$applicationName][$task] as $beforeAfterTask) {
$output .= ' <success>Task ' . $beforeAfterTask . ' ' . $step . ' ' . $task . '</success> <info>(' . $label . ')</info>' . PHP_EOL;
}
}
} | php | private function printBeforeAfterTasks(array $tasks, $applicationName, $task, $step, &$output)
{
$label = $applicationName === '_' ? 'for all applications' : 'for application ' . $applicationName;
if (isset($tasks[$step][$applicationName][$task])) {
// 'Task "' . $beforeTask . '" before "' . $task
foreach ($tasks[$step][$applicationName][$task] as $beforeAfterTask) {
$output .= ' <success>Task ' . $beforeAfterTask . ' ' . $step . ' ' . $task . '</success> <info>(' . $label . ')</info>' . PHP_EOL;
}
}
} | [
"private",
"function",
"printBeforeAfterTasks",
"(",
"array",
"$",
"tasks",
",",
"$",
"applicationName",
",",
"$",
"task",
",",
"$",
"step",
",",
"&",
"$",
"output",
")",
"{",
"$",
"label",
"=",
"$",
"applicationName",
"===",
"'_'",
"?",
"'for all applicat... | Print all tasks before or after a task
@param array $tasks
@param string $applicationName
@param string $task
@param string $step
@param string $output | [
"Print",
"all",
"tasks",
"before",
"or",
"after",
"a",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/DescribeCommand.php#L183-L192 |
TYPO3/Surf | src/Task/TYPO3/CMS/RunCommandTask.php | RunCommandTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
$options = $this->configureOptions($options);
$arguments = array_merge([$this->getConsoleScriptFileName($node, $application, $deployment, $options), $options['command']], $options['arguments']);
$this->executeCliCommand(
$arguments,
$node,
$application,
$deployment,
$options
);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->ensureApplicationIsTypo3Cms($application);
$options = $this->configureOptions($options);
$arguments = array_merge([$this->getConsoleScriptFileName($node, $application, $deployment, $options), $options['command']], $options['arguments']);
$this->executeCliCommand(
$arguments,
$node,
$application,
$deployment,
$options
);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"ensureApplicationIsTypo3Cms",
"(",
"$",
"app... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param CMS|\TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/RunCommandTask.php#L36-L51 |
TYPO3/Surf | src/Task/Neos/Flow/CopyConfigurationTask.php | CopyConfigurationTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$configurationFileExtension = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'yaml';
$targetReleasePath = $deployment->getApplicationReleasePath($application);
$configurationPath = $deployment->getDeploymentConfigurationPath();
if (!is_dir($configurationPath)) {
return;
}
$commands = [];
$configurationFiles = Files::readDirectoryRecursively($configurationPath, $configurationFileExtension);
foreach ($configurationFiles as $configuration) {
$targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration));
$escapedSourcePath = escapeshellarg($configuration);
$escapedTargetPath = escapeshellarg(Files::concatenatePaths([$targetReleasePath, 'Configuration', $targetConfigurationPath]) . '/');
if ($node->isLocalhost()) {
$commands[] = 'mkdir -p ' . $escapedTargetPath;
$commands[] = 'cp ' . $escapedSourcePath . ' ' . $escapedTargetPath;
} else {
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$sshPort = isset($options['port']) ? '-p ' . escapeshellarg($options['port']) . ' ' : '';
$scpPort = isset($options['port']) ? '-P ' . escapeshellarg($options['port']) . ' ' : '';
$sshOptions = '';
$expect = '';
if ($node->hasOption('password')) {
$sshOptions .= '-o PubkeyAuthentication=no ';
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(dirname(__DIR__)))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
if (Phar::running() !== '') {
$passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
}
$expect = sprintf('expect %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')));
}
$createDirectoryCommand = '"mkdir -p ' . $escapedTargetPath . '"';
$commands[] = ltrim("{$expect} ssh {$sshOptions}{$sshPort}{$username}{$hostname} {$createDirectoryCommand}");
$commands[] = ltrim("{$expect} scp {$sshOptions}{$scpPort}{$escapedSourcePath} {$username}{$hostname}:\"{$escapedTargetPath}\"");
}
}
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$configurationFileExtension = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'yaml';
$targetReleasePath = $deployment->getApplicationReleasePath($application);
$configurationPath = $deployment->getDeploymentConfigurationPath();
if (!is_dir($configurationPath)) {
return;
}
$commands = [];
$configurationFiles = Files::readDirectoryRecursively($configurationPath, $configurationFileExtension);
foreach ($configurationFiles as $configuration) {
$targetConfigurationPath = dirname(str_replace($configurationPath, '', $configuration));
$escapedSourcePath = escapeshellarg($configuration);
$escapedTargetPath = escapeshellarg(Files::concatenatePaths([$targetReleasePath, 'Configuration', $targetConfigurationPath]) . '/');
if ($node->isLocalhost()) {
$commands[] = 'mkdir -p ' . $escapedTargetPath;
$commands[] = 'cp ' . $escapedSourcePath . ' ' . $escapedTargetPath;
} else {
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$sshPort = isset($options['port']) ? '-p ' . escapeshellarg($options['port']) . ' ' : '';
$scpPort = isset($options['port']) ? '-P ' . escapeshellarg($options['port']) . ' ' : '';
$sshOptions = '';
$expect = '';
if ($node->hasOption('password')) {
$sshOptions .= '-o PubkeyAuthentication=no ';
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(dirname(__DIR__)))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
if (Phar::running() !== '') {
$passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
}
$expect = sprintf('expect %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')));
}
$createDirectoryCommand = '"mkdir -p ' . $escapedTargetPath . '"';
$commands[] = ltrim("{$expect} ssh {$sshOptions}{$sshPort}{$username}{$hostname} {$createDirectoryCommand}");
$commands[] = ltrim("{$expect} scp {$sshOptions}{$scpPort}{$escapedSourcePath} {$username}{$hostname}:\"{$escapedTargetPath}\"");
}
}
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"configurationFileExtension",
"=",
"isset",
"(",
"$",
"opti... | Executes this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options
@throws TaskExecutionException
@throws InvalidConfigurationException | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/CopyConfigurationTask.php#L50-L95 |
TYPO3/Surf | src/Task/Release/AddDownloadTask.php | AddDownloadTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->checkOptionsForValidity($options);
$host = $options['releaseHost'];
$login = $options['releaseHostLogin'];
$sitePath = $options['releaseHostSitePath'];
$version = $options['version'];
$label = $options['label'];
$uriPattern = $options['downloadUriPattern'];
$productName = $options['productName'];
$files = $options['files'];
$downloads = [];
foreach ($files as $file) {
$downloads[] = sprintf('"%s,%s,%s"', basename($file), sha1($file), sprintf($uriPattern, basename($file)));
}
$this->shell->executeOrSimulate(sprintf('ssh %s%s "cd \"%s\" ; ./flow release:adddownload --product-name \"%s\" --version \"%s\" --label \"%s\" %s"', ($login ? $login . '@' : ''), $host, $sitePath, $productName, $version, $label, implode(' ', $downloads)), $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->checkOptionsForValidity($options);
$host = $options['releaseHost'];
$login = $options['releaseHostLogin'];
$sitePath = $options['releaseHostSitePath'];
$version = $options['version'];
$label = $options['label'];
$uriPattern = $options['downloadUriPattern'];
$productName = $options['productName'];
$files = $options['files'];
$downloads = [];
foreach ($files as $file) {
$downloads[] = sprintf('"%s,%s,%s"', basename($file), sha1($file), sprintf($uriPattern, basename($file)));
}
$this->shell->executeOrSimulate(sprintf('ssh %s%s "cd \"%s\" ; ./flow release:adddownload --product-name \"%s\" --version \"%s\" --label \"%s\" %s"', ($login ? $login . '@' : ''), $host, $sitePath, $productName, $version, $label, implode(' ', $downloads)), $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"checkOptionsForValidity",
"(",
"$",
"options... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Release/AddDownloadTask.php#L34-L51 |
TYPO3/Surf | src/Task/Git/PushTask.php | PushTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['remote'])) {
throw new InvalidConfigurationException('Missing "remote" option for PushTask', 1314186541);
}
if (!isset($options['refspec'])) {
throw new InvalidConfigurationException('Missing "refspec" option for PushTask', 1314186553);
}
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git push -f %s %s', $options['remote'], $options['refspec']), $node, $deployment);
if (isset($options['recurseIntoSubmodules']) && $options['recurseIntoSubmodules'] === true) {
$this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git submodule foreach \'git push -f %s %s\'', $options['remote'], $options['refspec']), $node, $deployment);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['remote'])) {
throw new InvalidConfigurationException('Missing "remote" option for PushTask', 1314186541);
}
if (!isset($options['refspec'])) {
throw new InvalidConfigurationException('Missing "refspec" option for PushTask', 1314186553);
}
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git push -f %s %s', $options['remote'], $options['refspec']), $node, $deployment);
if (isset($options['recurseIntoSubmodules']) && $options['recurseIntoSubmodules'] === true) {
$this->shell->executeOrSimulate(sprintf('cd ' . $targetPath . '; git submodule foreach \'git push -f %s %s\'', $options['remote'], $options['refspec']), $node, $deployment);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'remote'... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Git/PushTask.php#L50-L66 |
TYPO3/Surf | src/Command/SimulateCommand.php | SimulateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$deployment = $this->factory->getDeployment($deploymentName, $configurationPath, true, true, $input->getOption('force'));
$deployment->simulate();
return $deployment->getStatus();
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$deployment = $this->factory->getDeployment($deploymentName, $configurationPath, true, true, $input->getOption('force'));
$deployment->simulate();
return $deployment->getStatus();
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"configurationPath",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'configurationPath'",
")",
";",
"$",
"deploymentName",
"=",
"$",
"in... | Execute
@param InputInterface $input
@param OutputInterface $output
@return int | [
"Execute"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/SimulateCommand.php#L61-L69 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.initialize | public function initialize()
{
if ($this->initialized) {
throw new SurfException('Already initialized', 1335976472);
}
if ($this->workflow === null) {
$this->workflow = new SimpleWorkflow();
}
foreach ($this->applications as $application) {
$application->registerTasks($this->workflow, $this);
}
foreach ($this->initCallbacks as $callback) {
$callback();
}
$this->initialized = true;
} | php | public function initialize()
{
if ($this->initialized) {
throw new SurfException('Already initialized', 1335976472);
}
if ($this->workflow === null) {
$this->workflow = new SimpleWorkflow();
}
foreach ($this->applications as $application) {
$application->registerTasks($this->workflow, $this);
}
foreach ($this->initCallbacks as $callback) {
$callback();
}
$this->initialized = true;
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"SurfException",
"(",
"'Already initialized'",
",",
"1335976472",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"workflow",
"===",
"n... | Initialize the deployment
Must be called before calling deploy() on a deployment.
A time-based release identifier will be created on initialization. It also executes
callbacks given to the deployment with onInitialize(...).
@throws SurfException | [
"Initialize",
"the",
"deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L143-L160 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.deploy | public function deploy()
{
$this->logger->notice('Deploying ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->workflow->run($this);
} | php | public function deploy()
{
$this->logger->notice('Deploying ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->workflow->run($this);
} | [
"public",
"function",
"deploy",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"notice",
"(",
"'Deploying '",
".",
"$",
"this",
"->",
"name",
".",
"' ('",
".",
"$",
"this",
"->",
"releaseIdentifier",
".",
"')'",
")",
";",
"$",
"this",
"->",
"workf... | Run this deployment
@throws SurfException | [
"Run",
"this",
"deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L181-L185 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.simulate | public function simulate()
{
$this->setDryRun(true);
$this->logger->notice('Simulating ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->workflow->run($this);
} | php | public function simulate()
{
$this->setDryRun(true);
$this->logger->notice('Simulating ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->workflow->run($this);
} | [
"public",
"function",
"simulate",
"(",
")",
"{",
"$",
"this",
"->",
"setDryRun",
"(",
"true",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"notice",
"(",
"'Simulating '",
".",
"$",
"this",
"->",
"name",
".",
"' ('",
".",
"$",
"this",
"->",
"releaseId... | Simulate this deployment without executing tasks
It will set dryRun = TRUE which can be inspected by any task. | [
"Simulate",
"this",
"deployment",
"without",
"executing",
"tasks"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L192-L197 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.getNodes | public function getNodes()
{
$nodes = [];
foreach ($this->applications as $application) {
foreach ($application->getNodes() as $node) {
$nodes[$node->getName()] = $node;
}
}
return $nodes;
} | php | public function getNodes()
{
$nodes = [];
foreach ($this->applications as $application) {
foreach ($application->getNodes() as $node) {
$nodes[$node->getName()] = $node;
}
}
return $nodes;
} | [
"public",
"function",
"getNodes",
"(",
")",
"{",
"$",
"nodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"applications",
"as",
"$",
"application",
")",
"{",
"foreach",
"(",
"$",
"application",
"->",
"getNodes",
"(",
")",
"as",
"$",
"node... | Get all nodes of this deployment
@return Node[] The deployment nodes with all application nodes | [
"Get",
"all",
"nodes",
"of",
"this",
"deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L238-L248 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.getNode | public function getNode($name)
{
if ($name === 'localhost') {
$node = new Node('localhost');
$node->onLocalhost();
return $node;
}
$nodes = $this->getNodes();
return isset($nodes[$name]) ? $nodes[$name] : null;
} | php | public function getNode($name)
{
if ($name === 'localhost') {
$node = new Node('localhost');
$node->onLocalhost();
return $node;
}
$nodes = $this->getNodes();
return isset($nodes[$name]) ? $nodes[$name] : null;
} | [
"public",
"function",
"getNode",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'localhost'",
")",
"{",
"$",
"node",
"=",
"new",
"Node",
"(",
"'localhost'",
")",
";",
"$",
"node",
"->",
"onLocalhost",
"(",
")",
";",
"return",
"$",
"nod... | Get a node by name
In the special case "localhost" an ad-hoc Node with hostname "localhost" is returned.
@return \TYPO3\Surf\Domain\Model\Node The Node or NULL if no Node with the given name was found | [
"Get",
"a",
"node",
"by",
"name"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L257-L267 |
TYPO3/Surf | src/Domain/Model/Deployment.php | Deployment.rollback | public function rollback($dryRun = false)
{
$this->logger->notice('Rollback deployment ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->setWorkflow(new RollbackWorkflow());
$this->initialize();
if ($dryRun) {
$this->setDryRun(true);
}
$this->workflow->run($this);
} | php | public function rollback($dryRun = false)
{
$this->logger->notice('Rollback deployment ' . $this->name . ' (' . $this->releaseIdentifier . ')');
$this->setWorkflow(new RollbackWorkflow());
$this->initialize();
if ($dryRun) {
$this->setDryRun(true);
}
$this->workflow->run($this);
} | [
"public",
"function",
"rollback",
"(",
"$",
"dryRun",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"notice",
"(",
"'Rollback deployment '",
".",
"$",
"this",
"->",
"name",
".",
"' ('",
".",
"$",
"this",
"->",
"releaseIdentifier",
".",
"')'"... | Rollback a deployment
@param bool $dryRun
@throws SurfException
@throws SurfException\InvalidConfigurationException | [
"Rollback",
"a",
"deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Deployment.php#L541-L551 |
TYPO3/Surf | src/Integration/Factory.php | Factory.createOutput | public function createOutput()
{
if ($this->output === null) {
$this->output = new ConsoleOutput();
$this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, ['bold']));
$this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white'));
$this->output->getFormatter()->setStyle('u', new OutputFormatterStyle(null, null, ['underscore']));
$this->output->getFormatter()->setStyle('em', new OutputFormatterStyle(null, null, ['reverse']));
$this->output->getFormatter()->setStyle('strike', new OutputFormatterStyle(null, null, ['conceal']));
$this->output->getFormatter()->setStyle('success', new OutputFormatterStyle('green'));
$this->output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
$this->output->getFormatter()->setStyle('notice', new OutputFormatterStyle('yellow'));
$this->output->getFormatter()->setStyle('info', new OutputFormatterStyle('white', null, ['bold']));
$this->output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white'));
}
return $this->output;
} | php | public function createOutput()
{
if ($this->output === null) {
$this->output = new ConsoleOutput();
$this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, ['bold']));
$this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white'));
$this->output->getFormatter()->setStyle('u', new OutputFormatterStyle(null, null, ['underscore']));
$this->output->getFormatter()->setStyle('em', new OutputFormatterStyle(null, null, ['reverse']));
$this->output->getFormatter()->setStyle('strike', new OutputFormatterStyle(null, null, ['conceal']));
$this->output->getFormatter()->setStyle('success', new OutputFormatterStyle('green'));
$this->output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
$this->output->getFormatter()->setStyle('notice', new OutputFormatterStyle('yellow'));
$this->output->getFormatter()->setStyle('info', new OutputFormatterStyle('white', null, ['bold']));
$this->output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white'));
}
return $this->output;
} | [
"public",
"function",
"createOutput",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"output",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"new",
"ConsoleOutput",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")"... | Create the output
@return ConsoleOutput | [
"Create",
"the",
"output"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L72-L89 |
TYPO3/Surf | src/Integration/Factory.php | Factory.getDeployment | public function getDeployment($deploymentName, $configurationPath = null, $simulateDeployment = true, $initialize = true, $forceDeployment = false)
{
$deployment = $this->createDeployment($deploymentName, $configurationPath);
if ($deployment->getLogger() === null) {
$logger = $this->createLogger();
if (! $simulateDeployment) {
$logFilePath = Files::concatenatePaths([$this->getWorkspacesBasePath($configurationPath), 'logs', $deployment->getName() . '.log']);
$logger->pushHandler(new StreamHandler($logFilePath));
}
$deployment->setLogger($logger);
}
$deployment->setForceRun($forceDeployment);
if ($initialize) {
$deployment->initialize();
}
$deployment->setDryRun($simulateDeployment);
return $deployment;
} | php | public function getDeployment($deploymentName, $configurationPath = null, $simulateDeployment = true, $initialize = true, $forceDeployment = false)
{
$deployment = $this->createDeployment($deploymentName, $configurationPath);
if ($deployment->getLogger() === null) {
$logger = $this->createLogger();
if (! $simulateDeployment) {
$logFilePath = Files::concatenatePaths([$this->getWorkspacesBasePath($configurationPath), 'logs', $deployment->getName() . '.log']);
$logger->pushHandler(new StreamHandler($logFilePath));
}
$deployment->setLogger($logger);
}
$deployment->setForceRun($forceDeployment);
if ($initialize) {
$deployment->initialize();
}
$deployment->setDryRun($simulateDeployment);
return $deployment;
} | [
"public",
"function",
"getDeployment",
"(",
"$",
"deploymentName",
",",
"$",
"configurationPath",
"=",
"null",
",",
"$",
"simulateDeployment",
"=",
"true",
",",
"$",
"initialize",
"=",
"true",
",",
"$",
"forceDeployment",
"=",
"false",
")",
"{",
"$",
"deploy... | Get the deployment object
@param string $deploymentName
@param string $configurationPath
@param bool $simulateDeployment
@param bool $initialize
@param bool $forceDeployment
@return Deployment
@throws InvalidConfigurationException
@throws \TYPO3\Surf\Exception | [
"Get",
"the",
"deployment",
"object"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L104-L125 |
TYPO3/Surf | src/Integration/Factory.php | Factory.getDeploymentNames | public function getDeploymentNames($path = null)
{
$path = $this->getDeploymentsBasePath($path);
$files = glob(Files::concatenatePaths([$path, '*.php']));
return array_map(function ($file) use ($path) {
return substr($file, strlen($path) + 1, -4);
}, $files);
} | php | public function getDeploymentNames($path = null)
{
$path = $this->getDeploymentsBasePath($path);
$files = glob(Files::concatenatePaths([$path, '*.php']));
return array_map(function ($file) use ($path) {
return substr($file, strlen($path) + 1, -4);
}, $files);
} | [
"public",
"function",
"getDeploymentNames",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getDeploymentsBasePath",
"(",
"$",
"path",
")",
";",
"$",
"files",
"=",
"glob",
"(",
"Files",
"::",
"concatenatePaths",
"(",
"[",
... | Get available deployment names
Will look up all .php files in the directory ./.surf/ or the given path if specified.
@param string $path
@return array | [
"Get",
"available",
"deployment",
"names"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L136-L144 |
TYPO3/Surf | src/Integration/Factory.php | Factory.getDeploymentsBasePath | public function getDeploymentsBasePath($path = null)
{
$localDeploymentDescription = @realpath('./.surf');
if (! $path && is_dir($localDeploymentDescription)) {
$path = $localDeploymentDescription;
}
$path = $path ?: Files::concatenatePaths([$this->getHomeDir(), 'deployments']);
$this->ensureDirectoryExists($path);
return $path;
} | php | public function getDeploymentsBasePath($path = null)
{
$localDeploymentDescription = @realpath('./.surf');
if (! $path && is_dir($localDeploymentDescription)) {
$path = $localDeploymentDescription;
}
$path = $path ?: Files::concatenatePaths([$this->getHomeDir(), 'deployments']);
$this->ensureDirectoryExists($path);
return $path;
} | [
"public",
"function",
"getDeploymentsBasePath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"localDeploymentDescription",
"=",
"@",
"realpath",
"(",
"'./.surf'",
")",
";",
"if",
"(",
"!",
"$",
"path",
"&&",
"is_dir",
"(",
"$",
"localDeploymentDescription",
... | Get the root path of the surf deployment declarations
This defaults to ./.surf if a NULL path is given.
@param string $path An absolute path (optional)
@return string The configuration root path without a trailing slash.
@throws \RuntimeException
@throws InvalidConfigurationException | [
"Get",
"the",
"root",
"path",
"of",
"the",
"surf",
"deployment",
"declarations"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L157-L167 |
TYPO3/Surf | src/Integration/Factory.php | Factory.getWorkspacesBasePath | public function getWorkspacesBasePath($path = null)
{
$workspacesBasePath = getenv('SURF_WORKSPACE');
if (! $workspacesBasePath) {
$path = $path ?: $this->getHomeDir();
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if ($workspacesBasePath = getenv('LOCALAPPDATA')) {
$workspacesBasePath = Files::concatenatePaths([$workspacesBasePath, 'Surf']);
} else {
$workspacesBasePath = Files::concatenatePaths([$path, 'workspace']);
}
} else {
$workspacesBasePath = Files::concatenatePaths([$path, 'workspace']);
}
}
$this->ensureDirectoryExists($workspacesBasePath);
return $workspacesBasePath;
} | php | public function getWorkspacesBasePath($path = null)
{
$workspacesBasePath = getenv('SURF_WORKSPACE');
if (! $workspacesBasePath) {
$path = $path ?: $this->getHomeDir();
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if ($workspacesBasePath = getenv('LOCALAPPDATA')) {
$workspacesBasePath = Files::concatenatePaths([$workspacesBasePath, 'Surf']);
} else {
$workspacesBasePath = Files::concatenatePaths([$path, 'workspace']);
}
} else {
$workspacesBasePath = Files::concatenatePaths([$path, 'workspace']);
}
}
$this->ensureDirectoryExists($workspacesBasePath);
return $workspacesBasePath;
} | [
"public",
"function",
"getWorkspacesBasePath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"workspacesBasePath",
"=",
"getenv",
"(",
"'SURF_WORKSPACE'",
")",
";",
"if",
"(",
"!",
"$",
"workspacesBasePath",
")",
"{",
"$",
"path",
"=",
"$",
"path",
"?",
... | Get the base path to local workspaces
@param string $path An absolute path (optional)
@return string The workspaces base path without a trailing slash.
@throws \RuntimeException
@throws InvalidConfigurationException | [
"Get",
"the",
"base",
"path",
"to",
"local",
"workspaces"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L178-L196 |
TYPO3/Surf | src/Integration/Factory.php | Factory.createDeployment | protected function createDeployment($deploymentName, $path = null)
{
$deploymentConfigurationPath = $this->getDeploymentsBasePath($path);
$workspacesBasePath = $this->getWorkspacesBasePath();
if (empty($deploymentName)) {
$deploymentNames = $this->getDeploymentNames($path);
if (count($deploymentNames) !== 1) {
throw new InvalidConfigurationException('No deployment name given!', 1451865016);
}
$deploymentName = array_pop($deploymentNames);
}
$deploymentPathAndFilename = Files::concatenatePaths([$deploymentConfigurationPath, $deploymentName . '.php']);
if (file_exists($deploymentPathAndFilename)) {
$deployment = new Deployment($deploymentName);
$deployment->setDeploymentBasePath($deploymentConfigurationPath);
$deployment->setWorkspacesBasePath($workspacesBasePath);
$tempPath = Files::concatenatePaths([$workspacesBasePath, $deploymentName]);
$this->ensureDirectoryExists($tempPath);
$deployment->setTemporaryPath($tempPath);
require($deploymentPathAndFilename);
} else {
$this->createLogger()->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename));
$deployment = new FailedDeployment();
}
return $deployment;
} | php | protected function createDeployment($deploymentName, $path = null)
{
$deploymentConfigurationPath = $this->getDeploymentsBasePath($path);
$workspacesBasePath = $this->getWorkspacesBasePath();
if (empty($deploymentName)) {
$deploymentNames = $this->getDeploymentNames($path);
if (count($deploymentNames) !== 1) {
throw new InvalidConfigurationException('No deployment name given!', 1451865016);
}
$deploymentName = array_pop($deploymentNames);
}
$deploymentPathAndFilename = Files::concatenatePaths([$deploymentConfigurationPath, $deploymentName . '.php']);
if (file_exists($deploymentPathAndFilename)) {
$deployment = new Deployment($deploymentName);
$deployment->setDeploymentBasePath($deploymentConfigurationPath);
$deployment->setWorkspacesBasePath($workspacesBasePath);
$tempPath = Files::concatenatePaths([$workspacesBasePath, $deploymentName]);
$this->ensureDirectoryExists($tempPath);
$deployment->setTemporaryPath($tempPath);
require($deploymentPathAndFilename);
} else {
$this->createLogger()->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename));
$deployment = new FailedDeployment();
}
return $deployment;
} | [
"protected",
"function",
"createDeployment",
"(",
"$",
"deploymentName",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"deploymentConfigurationPath",
"=",
"$",
"this",
"->",
"getDeploymentsBasePath",
"(",
"$",
"path",
")",
";",
"$",
"workspacesBasePath",
"=",
... | Get a deployment object by deployment name
Looks up the deployment in directory ./.surf/[deploymentName].php
The script has access to a deployment object as "$deployment". This could change
in the future.
@param string $deploymentName
@param string $path
@return Deployment
@throws \RuntimeException
@throws InvalidConfigurationException | [
"Get",
"a",
"deployment",
"object",
"by",
"deployment",
"name"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L213-L241 |
TYPO3/Surf | src/Integration/Factory.php | Factory.getHomeDir | protected function getHomeDir()
{
$home = getenv('SURF_HOME');
if (! $home) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (! getenv('APPDATA')) {
throw new \RuntimeException('The APPDATA or SURF_HOME environment variable must be set for composer to run correctly');
}
$home = Files::concatenatePaths([getenv('APPDATA'), 'Surf']);
} else {
if (! getenv('HOME')) {
throw new \RuntimeException('The HOME or SURF_HOME environment variable must be set for composer to run correctly');
}
$home = Files::concatenatePaths([getenv('HOME'), '.surf']);
}
}
$this->ensureDirectoryExists($home);
return $home;
} | php | protected function getHomeDir()
{
$home = getenv('SURF_HOME');
if (! $home) {
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if (! getenv('APPDATA')) {
throw new \RuntimeException('The APPDATA or SURF_HOME environment variable must be set for composer to run correctly');
}
$home = Files::concatenatePaths([getenv('APPDATA'), 'Surf']);
} else {
if (! getenv('HOME')) {
throw new \RuntimeException('The HOME or SURF_HOME environment variable must be set for composer to run correctly');
}
$home = Files::concatenatePaths([getenv('HOME'), '.surf']);
}
}
$this->ensureDirectoryExists($home);
return $home;
} | [
"protected",
"function",
"getHomeDir",
"(",
")",
"{",
"$",
"home",
"=",
"getenv",
"(",
"'SURF_HOME'",
")",
";",
"if",
"(",
"!",
"$",
"home",
")",
"{",
"if",
"(",
"defined",
"(",
"'PHP_WINDOWS_VERSION_MAJOR'",
")",
")",
"{",
"if",
"(",
"!",
"getenv",
... | Get the home directory
@return string
@throws \RuntimeException
@throws InvalidConfigurationException | [
"Get",
"the",
"home",
"directory"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L250-L269 |
TYPO3/Surf | src/Integration/Factory.php | Factory.createLogger | protected function createLogger()
{
if ($this->logger === null) {
$consoleHandler = new ConsoleHandler($this->createOutput());
$this->logger = new Logger('TYPO3 Surf', [$consoleHandler]);
}
return $this->logger;
} | php | protected function createLogger()
{
if ($this->logger === null) {
$consoleHandler = new ConsoleHandler($this->createOutput());
$this->logger = new Logger('TYPO3 Surf', [$consoleHandler]);
}
return $this->logger;
} | [
"protected",
"function",
"createLogger",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
"===",
"null",
")",
"{",
"$",
"consoleHandler",
"=",
"new",
"ConsoleHandler",
"(",
"$",
"this",
"->",
"createOutput",
"(",
")",
")",
";",
"$",
"this",
"->",... | Create a logger instance
@return Logger | [
"Create",
"a",
"logger",
"instance"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L276-L284 |
TYPO3/Surf | src/Integration/Factory.php | Factory.ensureDirectoryExists | protected function ensureDirectoryExists($dir)
{
if (! file_exists($dir) && ! @mkdir($dir, 0777, true) && ! is_dir($dir)) {
throw new InvalidConfigurationException(sprintf('Directory "%s" cannot be created!', $dir), 1451862775);
}
} | php | protected function ensureDirectoryExists($dir)
{
if (! file_exists($dir) && ! @mkdir($dir, 0777, true) && ! is_dir($dir)) {
throw new InvalidConfigurationException(sprintf('Directory "%s" cannot be created!', $dir), 1451862775);
}
} | [
"protected",
"function",
"ensureDirectoryExists",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
"&&",
"!",
"@",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
"&&",
"!",
"is_dir",
"(",
"$",
"dir",
")",
... | Check that the directory exists
@param string $dir
@throws InvalidConfigurationException | [
"Check",
"that",
"the",
"directory",
"exists"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Integration/Factory.php#L293-L298 |
TYPO3/Surf | src/Application/BaseApplication.php | BaseApplication.registerTasks | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
$this->setOption(GenericCreateDirectoriesTask::class . '[directories]', $this->getDirectories());
$this->setOption(CreateSymlinksTask::class . '[symlinks]', $this->getSymlinks());
if ($this->hasOption('packageMethod')) {
$this->registerTasksForPackageMethod($workflow, $this->getOption('packageMethod'));
}
if ($this->hasOption('transferMethod')) {
$this->registerTasksForTransferMethod($workflow, $this->getOption('transferMethod'));
}
$workflow->afterStage('transfer', CreateSymlinksTask::class, $this);
if ($this->hasOption('updateMethod')) {
$this->registerTasksForUpdateMethod($workflow, $this->getOption('updateMethod'));
}
// TODO Define tasks for local shell task and local git checkout
$workflow
->addTask(CreateDirectoriesTask::class, 'initialize', $this)
->afterTask(CreateDirectoriesTask::class, GenericCreateDirectoriesTask::class, $this)
->addTask(SymlinkReleaseTask::class, 'switch', $this)
->addTask(CleanupReleasesTask::class, 'cleanup', $this);
if ($this->hasOption('lockDeployment') && $this->getOption('lockDeployment') === true) {
$workflow->addTask(LockDeploymentTask::class, 'lock', $this);
$workflow->addTask(UnlockDeploymentTask::class, 'unlock', $this);
}
if ($deployment->getForceRun()) {
$workflow->beforeTask(LockDeploymentTask::class, UnlockDeploymentTask::class, $this);
}
} | php | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
$this->setOption(GenericCreateDirectoriesTask::class . '[directories]', $this->getDirectories());
$this->setOption(CreateSymlinksTask::class . '[symlinks]', $this->getSymlinks());
if ($this->hasOption('packageMethod')) {
$this->registerTasksForPackageMethod($workflow, $this->getOption('packageMethod'));
}
if ($this->hasOption('transferMethod')) {
$this->registerTasksForTransferMethod($workflow, $this->getOption('transferMethod'));
}
$workflow->afterStage('transfer', CreateSymlinksTask::class, $this);
if ($this->hasOption('updateMethod')) {
$this->registerTasksForUpdateMethod($workflow, $this->getOption('updateMethod'));
}
// TODO Define tasks for local shell task and local git checkout
$workflow
->addTask(CreateDirectoriesTask::class, 'initialize', $this)
->afterTask(CreateDirectoriesTask::class, GenericCreateDirectoriesTask::class, $this)
->addTask(SymlinkReleaseTask::class, 'switch', $this)
->addTask(CleanupReleasesTask::class, 'cleanup', $this);
if ($this->hasOption('lockDeployment') && $this->getOption('lockDeployment') === true) {
$workflow->addTask(LockDeploymentTask::class, 'lock', $this);
$workflow->addTask(UnlockDeploymentTask::class, 'unlock', $this);
}
if ($deployment->getForceRun()) {
$workflow->beforeTask(LockDeploymentTask::class, UnlockDeploymentTask::class, $this);
}
} | [
"public",
"function",
"registerTasks",
"(",
"Workflow",
"$",
"workflow",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"GenericCreateDirectoriesTask",
"::",
"class",
".",
"'[directories]'",
",",
"$",
"this",
"->",
"getDirec... | Register tasks for the base application
The base application performs the following tasks:
Initialize stage:
- Create directories for release structure
Update stage:
- Perform Git checkout (and pass on sha1 / tag or branch option from application to the task)
Switch stage:
- Symlink the current and previous release
Cleanup stage:
- Clean up old releases
@param \TYPO3\Surf\Domain\Model\Workflow $workflow
@param \TYPO3\Surf\Domain\Model\Deployment $deployment | [
"Register",
"tasks",
"for",
"the",
"base",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/BaseApplication.php#L94-L129 |
TYPO3/Surf | src/Application/BaseApplication.php | BaseApplication.addSymlinks | public function addSymlinks(array $symlinks)
{
foreach ($symlinks as $linkPath => $sourcePath) {
$this->addSymlink($linkPath, $sourcePath);
}
return $this;
} | php | public function addSymlinks(array $symlinks)
{
foreach ($symlinks as $linkPath => $sourcePath) {
$this->addSymlink($linkPath, $sourcePath);
}
return $this;
} | [
"public",
"function",
"addSymlinks",
"(",
"array",
"$",
"symlinks",
")",
"{",
"foreach",
"(",
"$",
"symlinks",
"as",
"$",
"linkPath",
"=>",
"$",
"sourcePath",
")",
"{",
"$",
"this",
"->",
"addSymlink",
"(",
"$",
"linkPath",
",",
"$",
"sourcePath",
")",
... | Register an array of additional symlinks to be created for the application
@param array $symlinks
@return \TYPO3\Surf\Application\BaseApplication
@see setSymlinks() | [
"Register",
"an",
"array",
"of",
"additional",
"symlinks",
"to",
"be",
"created",
"for",
"the",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/BaseApplication.php#L179-L186 |
TYPO3/Surf | src/Command/ReleaseCommand.php | ReleaseCommand.executeProcess | public function executeProcess($command)
{
$process = new Process($command);
$process->setTimeout(null);
$output = $this->output;
$callback = function ($type, $data) use ($output) {
$output->writeln(trim($data));
};
$exitCode = $process->run($callback);
return [$exitCode, trim($process->getOutput())];
} | php | public function executeProcess($command)
{
$process = new Process($command);
$process->setTimeout(null);
$output = $this->output;
$callback = function ($type, $data) use ($output) {
$output->writeln(trim($data));
};
$exitCode = $process->run($callback);
return [$exitCode, trim($process->getOutput())];
} | [
"public",
"function",
"executeProcess",
"(",
"$",
"command",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"command",
")",
";",
"$",
"process",
"->",
"setTimeout",
"(",
"null",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"output",
"... | Open a process with symfony/process and process each line by logging and
collecting its output.
@param string $command
@return array The exit code of the command and the returned output | [
"Open",
"a",
"process",
"with",
"symfony",
"/",
"process",
"and",
"process",
"each",
"line",
"by",
"logging",
"and",
"collecting",
"its",
"output",
"."
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/ReleaseCommand.php#L61-L71 |
TYPO3/Surf | src/Task/Neos/Flow/FlushCacheListTask.php | FlushCacheListTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, FlowApplication::class, sprintf('Flow application needed for MigrateTask, got "%s"', get_class($application)));
Assert::greaterThanEq($application->getVersion(), '2.3', sprintf('FlushCacheListTask is available since Flow Framework 2.3, your application version is "%s"', $application->getVersion()));
$options = $this->configureOptions($options);
$targetPath = $deployment->getApplicationReleasePath($application);
foreach ($options['flushCacheList'] as $cache) {
$deployment->getLogger()->debug(sprintf('Flush cache with identifier "%s"', $cache));
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . sprintf(
'flow:cache:flushone --identifier %s',
$cache
), $node, $deployment);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, FlowApplication::class, sprintf('Flow application needed for MigrateTask, got "%s"', get_class($application)));
Assert::greaterThanEq($application->getVersion(), '2.3', sprintf('FlushCacheListTask is available since Flow Framework 2.3, your application version is "%s"', $application->getVersion()));
$options = $this->configureOptions($options);
$targetPath = $deployment->getApplicationReleasePath($application);
foreach ($options['flushCacheList'] as $cache) {
$deployment->getLogger()->debug(sprintf('Flush cache with identifier "%s"', $cache));
$this->shell->executeOrSimulate('cd ' . $targetPath . ' && ' . 'FLOW_CONTEXT=' . $application->getContext() . ' ./' . $application->getFlowScriptName() . ' ' . sprintf(
'flow:cache:flushone --identifier %s',
$cache
), $node, $deployment);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"Assert",
"::",
"isInstanceOf",
"(",
"$",
"application",
",",
... | Execute this task
@param Node $node
@param Application|FlowApplication $application
@param Deployment $deployment
@param array $options
@throws InvalidArgumentException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/FlushCacheListTask.php#L56-L72 |
TYPO3/Surf | src/Task/GitCheckoutTask.php | GitCheckoutTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['repositoryUrl'])) {
throw new InvalidConfigurationException(sprintf('Missing "repositoryUrl" option for application "%s"', $application->getName()), 1335974764);
}
$releasePath = $deployment->getApplicationReleasePath($application);
$checkoutPath = Files::concatenatePaths([$application->getDeploymentPath(), 'cache/transfer']);
if (!isset($options['hardClean'])) {
$options['hardClean'] = true;
}
$sha1 = $this->executeOrSimulateGitCloneOrUpdate($checkoutPath, $node, $deployment, $options);
$command = strtr("
cp -RPp $checkoutPath/. $releasePath
&& (echo $sha1 > $releasePath" . 'REVISION)
', "\t\n", ' ');
$this->shell->executeOrSimulate($command, $node, $deployment);
$this->executeOrSimulatePostGitCheckoutCommands($releasePath, $sha1, $node, $deployment, $options);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['repositoryUrl'])) {
throw new InvalidConfigurationException(sprintf('Missing "repositoryUrl" option for application "%s"', $application->getName()), 1335974764);
}
$releasePath = $deployment->getApplicationReleasePath($application);
$checkoutPath = Files::concatenatePaths([$application->getDeploymentPath(), 'cache/transfer']);
if (!isset($options['hardClean'])) {
$options['hardClean'] = true;
}
$sha1 = $this->executeOrSimulateGitCloneOrUpdate($checkoutPath, $node, $deployment, $options);
$command = strtr("
cp -RPp $checkoutPath/. $releasePath
&& (echo $sha1 > $releasePath" . 'REVISION)
', "\t\n", ' ');
$this->shell->executeOrSimulate($command, $node, $deployment);
$this->executeOrSimulatePostGitCheckoutCommands($releasePath, $sha1, $node, $deployment, $options);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'reposit... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException
@throws \TYPO3\Surf\Exception\TaskExecutionException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/GitCheckoutTask.php#L41-L64 |
TYPO3/Surf | src/Application/Neos/FlowDistribution.php | FlowDistribution.registerTasks | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
parent::registerTasks($workflow, $deployment);
$this->checkIfMandatoryOptionsExist();
$this->buildConfiguration();
$this->defineTasks($workflow, $deployment);
if ($this->getOption('enableTests') !== false) {
$workflow
->addTask([
UnitTestTask::class,
FunctionalTestTask::class
], 'test', $this);
}
$workflow->addTask([
'TYPO3\\Surf\\DefinedTask\\CreateZipDistributionTask',
'TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask',
'TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask',
], 'cleanup', $this);
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->addTask(SourceforgeUploadTask::class, 'cleanup', $this);
}
if ($this->hasOption('releaseHost')) {
$workflow->addTask(PrepareReleaseTask::class, 'initialize', $this);
$workflow->addTask(ReleaseTask::class, 'cleanup', $this);
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->addTask(AddDownloadTask::class, 'cleanup', $this);
}
if ($this->hasOption('createTags') && $this->getOption('createTags') === true) {
$workflow->addTask(TagTask::class, 'cleanup', $this);
if ($this->hasOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') && $this->getOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') === true) {
$workflow->afterTask(TagTask::class, 'TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask', $this);
}
}
$workflow->removeTask(MigrateTask::class);
} | php | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
parent::registerTasks($workflow, $deployment);
$this->checkIfMandatoryOptionsExist();
$this->buildConfiguration();
$this->defineTasks($workflow, $deployment);
if ($this->getOption('enableTests') !== false) {
$workflow
->addTask([
UnitTestTask::class,
FunctionalTestTask::class
], 'test', $this);
}
$workflow->addTask([
'TYPO3\\Surf\\DefinedTask\\CreateZipDistributionTask',
'TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask',
'TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask',
], 'cleanup', $this);
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->addTask(SourceforgeUploadTask::class, 'cleanup', $this);
}
if ($this->hasOption('releaseHost')) {
$workflow->addTask(PrepareReleaseTask::class, 'initialize', $this);
$workflow->addTask(ReleaseTask::class, 'cleanup', $this);
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->addTask(AddDownloadTask::class, 'cleanup', $this);
}
if ($this->hasOption('createTags') && $this->getOption('createTags') === true) {
$workflow->addTask(TagTask::class, 'cleanup', $this);
if ($this->hasOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') && $this->getOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') === true) {
$workflow->afterTask(TagTask::class, 'TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask', $this);
}
}
$workflow->removeTask(MigrateTask::class);
} | [
"public",
"function",
"registerTasks",
"(",
"Workflow",
"$",
"workflow",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"parent",
"::",
"registerTasks",
"(",
"$",
"workflow",
",",
"$",
"deployment",
")",
";",
"$",
"this",
"->",
"checkIfMandatoryOptionsExist",
... | Register tasks for this application
@param Workflow $workflow
@param Deployment $deployment | [
"Register",
"tasks",
"for",
"this",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/FlowDistribution.php#L50-L90 |
TYPO3/Surf | src/Application/Neos/FlowDistribution.php | FlowDistribution.checkIfMandatoryOptionsExist | protected function checkIfMandatoryOptionsExist()
{
if (!$this->hasOption('version')) {
throw new InvalidConfigurationException('"version" option needs to be defined. Example: 1.0.0-beta2', 1314187396);
}
if (!$this->hasOption('projectName')) {
throw new InvalidConfigurationException('"projectName" option needs to be defined. Example: Neos Flow', 1314187397);
}
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
if (!$this->hasOption('sourceforgeProjectName')) {
throw new InvalidConfigurationException('"sourceforgeProjectName" option needs to be specified', 1314187402);
}
if (!$this->hasOption('sourceforgePackageName')) {
throw new InvalidConfigurationException('"sourceforgePackageName" option needs to be specified', 1314187406);
}
if (!$this->hasOption('sourceforgeUserName')) {
throw new InvalidConfigurationException('"sourceforgeUserName" option needs to be specified', 1314187407);
}
}
if ($this->hasOption('releaseHost')) {
if (!$this->hasOption('releaseHostSitePath')) {
throw new InvalidConfigurationException('"releaseHostSitePath" option needs to be specified', 1321545975);
}
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
if (!$this->hasOption('releaseDownloadLabel')) {
throw new InvalidConfigurationException('"releaseDownloadLabel" option needs to be specified', 1321545965);
}
if (!$this->hasOption('releaseDownloadUriPattern')) {
throw new InvalidConfigurationException('"releaseDownloadUriPattern" option needs to be specified', 1321545985);
}
}
} | php | protected function checkIfMandatoryOptionsExist()
{
if (!$this->hasOption('version')) {
throw new InvalidConfigurationException('"version" option needs to be defined. Example: 1.0.0-beta2', 1314187396);
}
if (!$this->hasOption('projectName')) {
throw new InvalidConfigurationException('"projectName" option needs to be defined. Example: Neos Flow', 1314187397);
}
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
if (!$this->hasOption('sourceforgeProjectName')) {
throw new InvalidConfigurationException('"sourceforgeProjectName" option needs to be specified', 1314187402);
}
if (!$this->hasOption('sourceforgePackageName')) {
throw new InvalidConfigurationException('"sourceforgePackageName" option needs to be specified', 1314187406);
}
if (!$this->hasOption('sourceforgeUserName')) {
throw new InvalidConfigurationException('"sourceforgeUserName" option needs to be specified', 1314187407);
}
}
if ($this->hasOption('releaseHost')) {
if (!$this->hasOption('releaseHostSitePath')) {
throw new InvalidConfigurationException('"releaseHostSitePath" option needs to be specified', 1321545975);
}
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
if (!$this->hasOption('releaseDownloadLabel')) {
throw new InvalidConfigurationException('"releaseDownloadLabel" option needs to be specified', 1321545965);
}
if (!$this->hasOption('releaseDownloadUriPattern')) {
throw new InvalidConfigurationException('"releaseDownloadUriPattern" option needs to be specified', 1321545985);
}
}
} | [
"protected",
"function",
"checkIfMandatoryOptionsExist",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"'version'",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"'\"version\" option needs to be defined. Example: 1.0.0-beta2'",... | Check if all necessary options to run are set
@throws InvalidConfigurationException | [
"Check",
"if",
"all",
"necessary",
"options",
"to",
"run",
"are",
"set"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/FlowDistribution.php#L97-L131 |
TYPO3/Surf | src/Application/Neos/FlowDistribution.php | FlowDistribution.buildConfiguration | protected function buildConfiguration()
{
$versionAndProjectName = sprintf('%s-%s', str_replace(' ', '_', $this->getOption('projectName')), $this->getOption('version'));
$this->configuration['versionAndProjectName'] = $versionAndProjectName;
$this->configuration['zipFile'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.zip';
$this->configuration['tarGzFile'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.tar.gz';
$this->configuration['tarBz2File'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.tar.bz2';
} | php | protected function buildConfiguration()
{
$versionAndProjectName = sprintf('%s-%s', str_replace(' ', '_', $this->getOption('projectName')), $this->getOption('version'));
$this->configuration['versionAndProjectName'] = $versionAndProjectName;
$this->configuration['zipFile'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.zip';
$this->configuration['tarGzFile'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.tar.gz';
$this->configuration['tarBz2File'] = $this->getDeploymentPath() . '/buildArtifacts/' . $versionAndProjectName . '.tar.bz2';
} | [
"protected",
"function",
"buildConfiguration",
"(",
")",
"{",
"$",
"versionAndProjectName",
"=",
"sprintf",
"(",
"'%s-%s'",
",",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"$",
"this",
"->",
"getOption",
"(",
"'projectName'",
")",
")",
",",
"$",
"this",
"... | Build configuration which we need later into $this->configuration | [
"Build",
"configuration",
"which",
"we",
"need",
"later",
"into",
"$this",
"-",
">",
"configuration"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/FlowDistribution.php#L136-L144 |
TYPO3/Surf | src/Application/Neos/FlowDistribution.php | FlowDistribution.defineTasks | protected function defineTasks(Workflow $workflow, Deployment $deployment)
{
$excludePatterns = [
'.git*',
'Data/*',
'Web/_Resources/*',
'Build/Reports',
'./Cache',
'Configuration/PackageStates.php'
];
$baseArchiveConfiguration = [
'sourceDirectory' => $deployment->getApplicationReleasePath($this),
'baseDirectory' => $this->configuration['versionAndProjectName'],
'exclude' => $excludePatterns
];
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateZipDistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['zipFile']
]));
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['tarGzFile'],
]));
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['tarBz2File'],
]));
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->defineTask(SourceforgeUploadTask::class, SourceforgeUploadTask::class, [
'sourceforgeProjectName' => $this->getOption('sourceforgeProjectName'),
'sourceforgePackageName' => $this->getOption('sourceforgePackageName'),
'sourceforgeUserName' => $this->getOption('sourceforgeUserName'),
'version' => $this->getOption('version'),
'files' => [
$this->configuration['zipFile'],
$this->configuration['tarGzFile'],
$this->configuration['tarBz2File'],
]
]);
}
if ($this->hasOption('releaseHost')) {
$workflow->defineTask(PrepareReleaseTask::class, PrepareReleaseTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
]);
$workflow->defineTask(ReleaseTask::class, ReleaseTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
'changeLogUri' => $this->hasOption('changeLogUri') ? $this->getOption('changeLogUri') : null,
]);
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->defineTask(AddDownloadTask::class, AddDownloadTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
'label' => $this->getOption('releaseDownloadLabel'),
'downloadUriPattern' => $this->getOption('releaseDownloadUriPattern'),
'files' => [
$this->configuration['zipFile'],
$this->configuration['tarGzFile'],
$this->configuration['tarBz2File'],
]
]);
}
$workflow->defineTask(TagTask::class, TagTask::class, [
'tagName' => $this->configuration['versionAndProjectName'],
'description' => 'Tag distribution with tag ' . $this->configuration['versionAndProjectName'],
'recurseIntoSubmodules' => $this->getOption('tagRecurseIntoSubmodules')
]);
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask', PushTask::class, [
'remote' => 'origin',
'refspec' => $this->configuration['versionAndProjectName'] . ':refs/tags/' . $this->configuration['versionAndProjectName'],
'recurseIntoSubmodules' => $this->getOption('tagRecurseIntoSubmodules')
]);
} | php | protected function defineTasks(Workflow $workflow, Deployment $deployment)
{
$excludePatterns = [
'.git*',
'Data/*',
'Web/_Resources/*',
'Build/Reports',
'./Cache',
'Configuration/PackageStates.php'
];
$baseArchiveConfiguration = [
'sourceDirectory' => $deployment->getApplicationReleasePath($this),
'baseDirectory' => $this->configuration['versionAndProjectName'],
'exclude' => $excludePatterns
];
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateZipDistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['zipFile']
]));
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['tarGzFile'],
]));
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask', CreateArchiveTask::class, array_merge($baseArchiveConfiguration, [
'targetFile' => $this->configuration['tarBz2File'],
]));
if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->defineTask(SourceforgeUploadTask::class, SourceforgeUploadTask::class, [
'sourceforgeProjectName' => $this->getOption('sourceforgeProjectName'),
'sourceforgePackageName' => $this->getOption('sourceforgePackageName'),
'sourceforgeUserName' => $this->getOption('sourceforgeUserName'),
'version' => $this->getOption('version'),
'files' => [
$this->configuration['zipFile'],
$this->configuration['tarGzFile'],
$this->configuration['tarBz2File'],
]
]);
}
if ($this->hasOption('releaseHost')) {
$workflow->defineTask(PrepareReleaseTask::class, PrepareReleaseTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
]);
$workflow->defineTask(ReleaseTask::class, ReleaseTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
'changeLogUri' => $this->hasOption('changeLogUri') ? $this->getOption('changeLogUri') : null,
]);
}
if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
$workflow->defineTask(AddDownloadTask::class, AddDownloadTask::class, [
'releaseHost' => $this->getOption('releaseHost'),
'releaseHostSitePath' => $this->getOption('releaseHostSitePath'),
'releaseHostLogin' => $this->hasOption('releaseHostLogin') ? $this->getOption('releaseHostLogin') : null,
'productName' => $this->getOption('projectName'),
'version' => $this->getOption('version'),
'label' => $this->getOption('releaseDownloadLabel'),
'downloadUriPattern' => $this->getOption('releaseDownloadUriPattern'),
'files' => [
$this->configuration['zipFile'],
$this->configuration['tarGzFile'],
$this->configuration['tarBz2File'],
]
]);
}
$workflow->defineTask(TagTask::class, TagTask::class, [
'tagName' => $this->configuration['versionAndProjectName'],
'description' => 'Tag distribution with tag ' . $this->configuration['versionAndProjectName'],
'recurseIntoSubmodules' => $this->getOption('tagRecurseIntoSubmodules')
]);
$workflow->defineTask('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask', PushTask::class, [
'remote' => 'origin',
'refspec' => $this->configuration['versionAndProjectName'] . ':refs/tags/' . $this->configuration['versionAndProjectName'],
'recurseIntoSubmodules' => $this->getOption('tagRecurseIntoSubmodules')
]);
} | [
"protected",
"function",
"defineTasks",
"(",
"Workflow",
"$",
"workflow",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"$",
"excludePatterns",
"=",
"[",
"'.git*'",
",",
"'Data/*'",
",",
"'Web/_Resources/*'",
",",
"'Build/Reports'",
",",
"'./Cache'",
",",
"'Co... | Configure tasks
@param Workflow $workflow
@param Deployment $deployment | [
"Configure",
"tasks"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/FlowDistribution.php#L152-L241 |
TYPO3/Surf | src/Task/SourceforgeUploadTask.php | SourceforgeUploadTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$deployment->getLogger()->warning(DeprecationMessageFactory::createGenericDeprecationWarningForTask(__CLASS__));
$options = $this->configureOptions($options);
$projectName = $options['sourceforgeProjectName'];
$sourceforgeLogin = $options['sourceforgeUserName'] . ',' . $options['sourceforgeProjectName'];
$projectDirectory = str_replace(' ', '\ ', sprintf('/home/frs/project/%s/%s/%s/%s/%s', substr($projectName, 0, 1), substr($projectName, 0, 2), $projectName, $options['sourceforgePackageName'], $options['version']));
$targetHostAndDirectory = escapeshellarg($sourceforgeLogin . '@frs.sourceforge.net:' . $projectDirectory);
$this->shell->executeOrSimulate('rsync -e ssh ' . implode(' ', $options['files']) . ' ' . $targetHostAndDirectory, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$deployment->getLogger()->warning(DeprecationMessageFactory::createGenericDeprecationWarningForTask(__CLASS__));
$options = $this->configureOptions($options);
$projectName = $options['sourceforgeProjectName'];
$sourceforgeLogin = $options['sourceforgeUserName'] . ',' . $options['sourceforgeProjectName'];
$projectDirectory = str_replace(' ', '\ ', sprintf('/home/frs/project/%s/%s/%s/%s/%s', substr($projectName, 0, 1), substr($projectName, 0, 2), $projectName, $options['sourceforgePackageName'], $options['version']));
$targetHostAndDirectory = escapeshellarg($sourceforgeLogin . '@frs.sourceforge.net:' . $projectDirectory);
$this->shell->executeOrSimulate('rsync -e ssh ' . implode(' ', $options['files']) . ' ' . $targetHostAndDirectory, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"deployment",
"->",
"getLogger",
"(",
")",
"->",
"warning... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/SourceforgeUploadTask.php#L60-L72 |
TYPO3/Surf | src/Task/CleanupReleasesTask.php | CleanupReleasesTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (! isset($options['keepReleases'])) {
$deployment->getLogger()->debug(($deployment->isDryRun() ? 'Would keep' : 'Keeping') . ' all releases for "' . $application->getName() . '"');
return;
}
$keepReleases = $options['keepReleases'];
$releasesPath = $application->getReleasesPath();
$currentReleaseIdentifier = $deployment->getReleaseIdentifier();
$previousReleaseIdentifier = \TYPO3\Surf\findPreviousReleaseIdentifier($deployment, $node, $application, $this->shell);
$allReleases = \TYPO3\Surf\findAllReleases($deployment, $node, $application, $this->shell);
$removableReleases = array_map('trim', array_filter($allReleases, function ($release) use ($currentReleaseIdentifier, $previousReleaseIdentifier) {
return $release !== '.' && $release !== $currentReleaseIdentifier && $release !== $previousReleaseIdentifier && $release !== 'current' && $release !== 'previous';
}));
sort($removableReleases);
$removeReleases = array_slice($removableReleases, 0, count($removableReleases) - $keepReleases);
$removeCommand = '';
foreach ($removeReleases as $removeRelease) {
$removeCommand .= "rm -rf {$releasesPath}/{$removeRelease};rm -f {$releasesPath}/{$removeRelease}REVISION;";
}
if (count($removeReleases) > 0) {
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' releases ' . implode(', ', $removeReleases));
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
} else {
$deployment->getLogger()->info('No releases to remove');
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (! isset($options['keepReleases'])) {
$deployment->getLogger()->debug(($deployment->isDryRun() ? 'Would keep' : 'Keeping') . ' all releases for "' . $application->getName() . '"');
return;
}
$keepReleases = $options['keepReleases'];
$releasesPath = $application->getReleasesPath();
$currentReleaseIdentifier = $deployment->getReleaseIdentifier();
$previousReleaseIdentifier = \TYPO3\Surf\findPreviousReleaseIdentifier($deployment, $node, $application, $this->shell);
$allReleases = \TYPO3\Surf\findAllReleases($deployment, $node, $application, $this->shell);
$removableReleases = array_map('trim', array_filter($allReleases, function ($release) use ($currentReleaseIdentifier, $previousReleaseIdentifier) {
return $release !== '.' && $release !== $currentReleaseIdentifier && $release !== $previousReleaseIdentifier && $release !== 'current' && $release !== 'previous';
}));
sort($removableReleases);
$removeReleases = array_slice($removableReleases, 0, count($removableReleases) - $keepReleases);
$removeCommand = '';
foreach ($removeReleases as $removeRelease) {
$removeCommand .= "rm -rf {$releasesPath}/{$removeRelease};rm -f {$releasesPath}/{$removeRelease}REVISION;";
}
if (count($removeReleases) > 0) {
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' releases ' . implode(', ', $removeReleases));
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
} else {
$deployment->getLogger()->info('No releases to remove');
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'keepRel... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/CleanupReleasesTask.php#L50-L82 |
TYPO3/Surf | src/Task/ShellTask.php | ShellTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['command'])) {
throw new InvalidConfigurationException('Missing "command" option for ShellTask', 1311168045);
}
$replacePaths = [
'{deploymentPath}' => escapeshellarg($application->getDeploymentPath()),
'{sharedPath}' => escapeshellarg($application->getSharedPath()),
'{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)),
'{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'),
'{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous')
];
$command = $options['command'];
$command = str_replace(array_keys($replacePaths), $replacePaths, $command);
$ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true;
$logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false);
$this->shell->executeOrSimulate($command, $node, $deployment, $ignoreErrors, $logOutput);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['command'])) {
throw new InvalidConfigurationException('Missing "command" option for ShellTask', 1311168045);
}
$replacePaths = [
'{deploymentPath}' => escapeshellarg($application->getDeploymentPath()),
'{sharedPath}' => escapeshellarg($application->getSharedPath()),
'{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)),
'{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'),
'{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous')
];
$command = $options['command'];
$command = str_replace(array_keys($replacePaths), $replacePaths, $command);
$ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true;
$logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false);
$this->shell->executeOrSimulate($command, $node, $deployment, $ignoreErrors, $logOutput);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'command... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/ShellTask.php#L50-L71 |
TYPO3/Surf | src/Task/ShellTask.php | ShellTask.rollback | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['rollbackCommand'])) {
return;
}
$replacePaths = [
'{deploymentPath}' => $application->getDeploymentPath(),
'{sharedPath}' => $application->getSharedPath(),
'{releasePath}' => $deployment->getApplicationReleasePath($application),
'{currentPath}' => $application->getReleasesPath() . '/current',
'{previousPath}' => $application->getReleasesPath() . '/previous'
];
$command = $options['rollbackCommand'];
$command = str_replace(array_keys($replacePaths), $replacePaths, $command);
$this->shell->execute($command, $node, $deployment, true);
} | php | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['rollbackCommand'])) {
return;
}
$replacePaths = [
'{deploymentPath}' => $application->getDeploymentPath(),
'{sharedPath}' => $application->getSharedPath(),
'{releasePath}' => $deployment->getApplicationReleasePath($application),
'{currentPath}' => $application->getReleasesPath() . '/current',
'{previousPath}' => $application->getReleasesPath() . '/previous'
];
$command = $options['rollbackCommand'];
$command = str_replace(array_keys($replacePaths), $replacePaths, $command);
$this->shell->execute($command, $node, $deployment, true);
} | [
"public",
"function",
"rollback",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'rollba... | Rollback this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Rollback",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/ShellTask.php#L94-L112 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.execute | public function execute($command, Node $node, Deployment $deployment, $ignoreErrors = false, $logOutput = true)
{
if ($node->isLocalhost()) {
list($exitCode, $returnedOutput) = $this->executeLocalCommand($command, $deployment, $logOutput);
} else {
list($exitCode, $returnedOutput) = $this->executeRemoteCommand($command, $node, $deployment, $logOutput);
}
if ($ignoreErrors !== true && $exitCode !== 0) {
$deployment->getLogger()->warning(rtrim($returnedOutput));
throw new TaskExecutionException('Command returned non-zero return code: ' . $exitCode, 1311007746);
}
return $exitCode === 0 ? $returnedOutput : false;
} | php | public function execute($command, Node $node, Deployment $deployment, $ignoreErrors = false, $logOutput = true)
{
if ($node->isLocalhost()) {
list($exitCode, $returnedOutput) = $this->executeLocalCommand($command, $deployment, $logOutput);
} else {
list($exitCode, $returnedOutput) = $this->executeRemoteCommand($command, $node, $deployment, $logOutput);
}
if ($ignoreErrors !== true && $exitCode !== 0) {
$deployment->getLogger()->warning(rtrim($returnedOutput));
throw new TaskExecutionException('Command returned non-zero return code: ' . $exitCode, 1311007746);
}
return $exitCode === 0 ? $returnedOutput : false;
} | [
"public",
"function",
"execute",
"(",
"$",
"command",
",",
"Node",
"$",
"node",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"ignoreErrors",
"=",
"false",
",",
"$",
"logOutput",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"isLocalhost",
"("... | Execute a shell command (locally or remote depending on the node hostname)
@param array|string $command The shell command to execute, either string or array of commands
@param Node $node Node to execute command against
@param Deployment $deployment
@param bool $ignoreErrors If this command should ignore exit codes unequal zero
@param bool $logOutput TRUE if the output of the command should be logged
@return mixed The output of the shell command or false if the command returned a non-zero exit code and $ignoreErrors was enabled.
@throws TaskExecutionException | [
"Execute",
"a",
"shell",
"command",
"(",
"locally",
"or",
"remote",
"depending",
"on",
"the",
"node",
"hostname",
")"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L33-L45 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.simulate | public function simulate($command, Node $node, Deployment $deployment)
{
if ($node->isLocalhost()) {
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('... (localhost): "' . $command . '"');
} else {
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('... $' . $node->getName() . ': "' . $command . '"');
}
return true;
} | php | public function simulate($command, Node $node, Deployment $deployment)
{
if ($node->isLocalhost()) {
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('... (localhost): "' . $command . '"');
} else {
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('... $' . $node->getName() . ': "' . $command . '"');
}
return true;
} | [
"public",
"function",
"simulate",
"(",
"$",
"command",
",",
"Node",
"$",
"node",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"isLocalhost",
"(",
")",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"prepareCommand",
... | Simulate a command by just outputting what would be executed
@param array|string $command
@param Node|null $node
@param Deployment $deployment
@return bool
@throws TaskExecutionException | [
"Simulate",
"a",
"command",
"by",
"just",
"outputting",
"what",
"would",
"be",
"executed"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L56-L66 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.executeOrSimulate | public function executeOrSimulate($command, Node $node, Deployment $deployment, $ignoreErrors = false, $logOutput = true)
{
if (!$deployment->isDryRun()) {
return $this->execute($command, $node, $deployment, $ignoreErrors, $logOutput);
}
return $this->simulate($command, $node, $deployment);
} | php | public function executeOrSimulate($command, Node $node, Deployment $deployment, $ignoreErrors = false, $logOutput = true)
{
if (!$deployment->isDryRun()) {
return $this->execute($command, $node, $deployment, $ignoreErrors, $logOutput);
}
return $this->simulate($command, $node, $deployment);
} | [
"public",
"function",
"executeOrSimulate",
"(",
"$",
"command",
",",
"Node",
"$",
"node",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"ignoreErrors",
"=",
"false",
",",
"$",
"logOutput",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"deployment",
"->",... | Execute or simulate a command (if the deployment is in dry run mode)
@param array|string $command
@param Node $node
@param Deployment $deployment
@param bool $ignoreErrors
@param bool $logOutput true if the output of the command should be logged
@return mixed false if command failed or command output as string
@throws TaskExecutionException | [
"Execute",
"or",
"simulate",
"a",
"command",
"(",
"if",
"the",
"deployment",
"is",
"in",
"dry",
"run",
"mode",
")"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L79-L85 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.executeLocalCommand | protected function executeLocalCommand($command, Deployment $deployment, $logOutput = true)
{
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('(localhost): "' . $command . '"');
return $this->executeProcess($deployment, $command, $logOutput, '> ');
} | php | protected function executeLocalCommand($command, Deployment $deployment, $logOutput = true)
{
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('(localhost): "' . $command . '"');
return $this->executeProcess($deployment, $command, $logOutput, '> ');
} | [
"protected",
"function",
"executeLocalCommand",
"(",
"$",
"command",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"logOutput",
"=",
"true",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"prepareCommand",
"(",
"$",
"command",
")",
";",
"$",
"deployme... | Execute a shell command locally
@param array|string $command
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param bool $logOutput TRUE if the output of the command should be logged
@return array
@throws TaskExecutionException | [
"Execute",
"a",
"shell",
"command",
"locally"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L96-L102 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.executeRemoteCommand | protected function executeRemoteCommand($command, Node $node, Deployment $deployment, $logOutput = true)
{
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('$' . $node->getName() . ': "' . $command . '"');
if ($node->hasOption('remoteCommandExecutionHandler')) {
$remoteCommandExecutionHandler = $node->getOption('remoteCommandExecutionHandler');
/** @var $remoteCommandExecutionHandler callable */
return $remoteCommandExecutionHandler($this, $command, $node, $deployment, $logOutput);
}
$username = $node->hasOption('username') ? $node->getOption('username') : null;
if (!empty($username)) {
$username = $username . '@';
}
$hostname = $node->getHostname();
// TODO Get SSH options from node or deployment
$sshOptions = ['-A'];
if ($node->hasOption('port')) {
$sshOptions[] = '-p ' . escapeshellarg($node->getOption('port'));
}
if ($node->hasOption('password')) {
$sshOptions[] = '-o PubkeyAuthentication=no';
}
if ($node->hasOption('privateKeyFile')) {
$sshOptions[] = '-i ' . escapeshellarg($node->getOption('privateKeyFile'));
}
$sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);
if ($node->hasOption('password')) {
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(__DIR__))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
if (\Phar::running() !== '') {
$passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
}
$sshCommand = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $sshCommand);
}
$success = $this->executeProcess($deployment, $sshCommand, $logOutput, ' > ');
if (isset($passwordSshLoginScriptPathAndFilename) && \Phar::running() !== '') {
unlink($passwordSshLoginScriptPathAndFilename);
}
return $success;
} | php | protected function executeRemoteCommand($command, Node $node, Deployment $deployment, $logOutput = true)
{
$command = $this->prepareCommand($command);
$deployment->getLogger()->debug('$' . $node->getName() . ': "' . $command . '"');
if ($node->hasOption('remoteCommandExecutionHandler')) {
$remoteCommandExecutionHandler = $node->getOption('remoteCommandExecutionHandler');
/** @var $remoteCommandExecutionHandler callable */
return $remoteCommandExecutionHandler($this, $command, $node, $deployment, $logOutput);
}
$username = $node->hasOption('username') ? $node->getOption('username') : null;
if (!empty($username)) {
$username = $username . '@';
}
$hostname = $node->getHostname();
// TODO Get SSH options from node or deployment
$sshOptions = ['-A'];
if ($node->hasOption('port')) {
$sshOptions[] = '-p ' . escapeshellarg($node->getOption('port'));
}
if ($node->hasOption('password')) {
$sshOptions[] = '-o PubkeyAuthentication=no';
}
if ($node->hasOption('privateKeyFile')) {
$sshOptions[] = '-i ' . escapeshellarg($node->getOption('privateKeyFile'));
}
$sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);
if ($node->hasOption('password')) {
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(__DIR__))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
if (\Phar::running() !== '') {
$passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
$passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
}
$sshCommand = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $sshCommand);
}
$success = $this->executeProcess($deployment, $sshCommand, $logOutput, ' > ');
if (isset($passwordSshLoginScriptPathAndFilename) && \Phar::running() !== '') {
unlink($passwordSshLoginScriptPathAndFilename);
}
return $success;
} | [
"protected",
"function",
"executeRemoteCommand",
"(",
"$",
"command",
",",
"Node",
"$",
"node",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"logOutput",
"=",
"true",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"prepareCommand",
"(",
"$",
"command... | Execute a shell command via SSH
@param array|string $command
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param bool $logOutput TRUE if the output of the command should be logged
@return array
@throws TaskExecutionException | [
"Execute",
"a",
"shell",
"command",
"via",
"SSH"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L114-L159 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.executeProcess | public function executeProcess($deployment, $command, $logOutput, $logPrefix)
{
$process = new Process($command);
$process->setTimeout(null);
$callback = null;
if ($logOutput) {
$callback = function ($type, $data) use ($deployment, $logPrefix) {
if ($type === Process::OUT) {
$deployment->getLogger()->debug($logPrefix . trim($data));
} elseif ($type === Process::ERR) {
$deployment->getLogger()->error($logPrefix . trim($data));
}
};
}
$exitCode = $process->run($callback);
return [$exitCode, trim($process->getOutput())];
} | php | public function executeProcess($deployment, $command, $logOutput, $logPrefix)
{
$process = new Process($command);
$process->setTimeout(null);
$callback = null;
if ($logOutput) {
$callback = function ($type, $data) use ($deployment, $logPrefix) {
if ($type === Process::OUT) {
$deployment->getLogger()->debug($logPrefix . trim($data));
} elseif ($type === Process::ERR) {
$deployment->getLogger()->error($logPrefix . trim($data));
}
};
}
$exitCode = $process->run($callback);
return [$exitCode, trim($process->getOutput())];
} | [
"public",
"function",
"executeProcess",
"(",
"$",
"deployment",
",",
"$",
"command",
",",
"$",
"logOutput",
",",
"$",
"logPrefix",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"command",
")",
";",
"$",
"process",
"->",
"setTimeout",
"(",
... | Open a process with symfony/process and process each line by logging and
collecting its output.
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param string $command
@param bool $logOutput
@param string $logPrefix
@return array The exit code of the command and the returned output | [
"Open",
"a",
"process",
"with",
"symfony",
"/",
"process",
"and",
"process",
"each",
"line",
"by",
"logging",
"and",
"collecting",
"its",
"output",
"."
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L171-L187 |
TYPO3/Surf | src/Domain/Service/ShellCommandService.php | ShellCommandService.prepareCommand | protected function prepareCommand($command)
{
if (is_string($command)) {
return trim($command);
}
if (is_array($command)) {
return implode(' && ', $command);
}
throw new TaskExecutionException('Command must be string or array, ' . gettype($command) . ' given.', 1312454906);
} | php | protected function prepareCommand($command)
{
if (is_string($command)) {
return trim($command);
}
if (is_array($command)) {
return implode(' && ', $command);
}
throw new TaskExecutionException('Command must be string or array, ' . gettype($command) . ' given.', 1312454906);
} | [
"protected",
"function",
"prepareCommand",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"command",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"command",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"command",
")",
")",
"{",
"... | Prepare a command
@param array|string $command
@return string
@throws TaskExecutionException | [
"Prepare",
"a",
"command"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/ShellCommandService.php#L196-L205 |
TYPO3/Surf | src/Task/Generic/CreateDirectoriesTask.php | CreateDirectoriesTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
try {
$options = $this->configureOptions($options);
} catch (ExceptionInterface $e) {
return;
}
if (empty($options['directories'])) {
return;
}
$baseDirectory = $options['baseDirectory'] ?: $deployment->getApplicationReleasePath($application);
$commands = array_map(function ($directory) {
return sprintf('mkdir -p %s', $directory);
}, $options['directories']);
array_unshift($commands, sprintf('cd %s', $baseDirectory));
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
try {
$options = $this->configureOptions($options);
} catch (ExceptionInterface $e) {
return;
}
if (empty($options['directories'])) {
return;
}
$baseDirectory = $options['baseDirectory'] ?: $deployment->getApplicationReleasePath($application);
$commands = array_map(function ($directory) {
return sprintf('mkdir -p %s', $directory);
}, $options['directories']);
array_unshift($commands, sprintf('cd %s', $baseDirectory));
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configu... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Generic/CreateDirectoriesTask.php#L53-L74 |
TYPO3/Surf | src/Task/Generic/CreateDirectoriesTask.php | CreateDirectoriesTask.resolveOptions | protected function resolveOptions(OptionsResolver $resolver)
{
$resolver->setRequired('directories');
$resolver->setDefault('baseDirectory', null);
$resolver->setAllowedTypes('directories', 'array');
} | php | protected function resolveOptions(OptionsResolver $resolver)
{
$resolver->setRequired('directories');
$resolver->setDefault('baseDirectory', null);
$resolver->setAllowedTypes('directories', 'array');
} | [
"protected",
"function",
"resolveOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setRequired",
"(",
"'directories'",
")",
";",
"$",
"resolver",
"->",
"setDefault",
"(",
"'baseDirectory'",
",",
"null",
")",
";",
"$",
"resolv... | @param OptionsResolver $resolver
@throws \Exception | [
"@param",
"OptionsResolver",
"$resolver"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Generic/CreateDirectoriesTask.php#L94-L99 |
TYPO3/Surf | src/Task/Package/GitTask.php | GitTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['repositoryUrl'])) {
throw new InvalidConfigurationException(sprintf('Missing "repositoryUrl" option for application "%s"', $application->getName()), 1374074052);
}
$localCheckoutPath = $deployment->getWorkspacePath($application);
$node = $deployment->getNode('localhost');
$sha1 = $this->executeOrSimulateGitCloneOrUpdate($localCheckoutPath, $node, $deployment, $options);
$this->executeOrSimulatePostGitCheckoutCommands($localCheckoutPath, $sha1, $node, $deployment, $options);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['repositoryUrl'])) {
throw new InvalidConfigurationException(sprintf('Missing "repositoryUrl" option for application "%s"', $application->getName()), 1374074052);
}
$localCheckoutPath = $deployment->getWorkspacePath($application);
$node = $deployment->getNode('localhost');
$sha1 = $this->executeOrSimulateGitCloneOrUpdate($localCheckoutPath, $node, $deployment, $options);
$this->executeOrSimulatePostGitCheckoutCommands($localCheckoutPath, $sha1, $node, $deployment, $options);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'reposit... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException
@throws \TYPO3\Surf\Exception\TaskExecutionException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Package/GitTask.php#L59-L72 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.removeTask | public function removeTask($removeTask, Application $application = null)
{
$removeApplicationName = $application instanceof Application ? $application->getName() : null;
$applicationRemovalGuardClause = function ($applicationName) use ($removeApplicationName) {
return null !== $removeApplicationName && $applicationName !== $removeApplicationName;
};
if (isset($this->tasks['stage'])) {
foreach ($this->tasks['stage'] as $applicationName => $steps) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($steps as $step => $tasksByStageStep) {
foreach ($tasksByStageStep as $stageName => $tasks) {
$this->tasks['stage'][$applicationName][$step][$stageName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
}
if (isset($this->tasks['before'])) {
foreach ($this->tasks['before'] as $applicationName => $tasksByTask) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($tasksByTask as $taskName => $tasks) {
$this->tasks['before'][$applicationName][$taskName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
if (isset($this->tasks['after'])) {
foreach ($this->tasks['after'] as $applicationName => $tasksByTask) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($tasksByTask as $taskName => $tasks) {
$this->tasks['after'][$applicationName][$taskName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
return $this;
} | php | public function removeTask($removeTask, Application $application = null)
{
$removeApplicationName = $application instanceof Application ? $application->getName() : null;
$applicationRemovalGuardClause = function ($applicationName) use ($removeApplicationName) {
return null !== $removeApplicationName && $applicationName !== $removeApplicationName;
};
if (isset($this->tasks['stage'])) {
foreach ($this->tasks['stage'] as $applicationName => $steps) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($steps as $step => $tasksByStageStep) {
foreach ($tasksByStageStep as $stageName => $tasks) {
$this->tasks['stage'][$applicationName][$step][$stageName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
}
if (isset($this->tasks['before'])) {
foreach ($this->tasks['before'] as $applicationName => $tasksByTask) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($tasksByTask as $taskName => $tasks) {
$this->tasks['before'][$applicationName][$taskName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
if (isset($this->tasks['after'])) {
foreach ($this->tasks['after'] as $applicationName => $tasksByTask) {
if ($applicationRemovalGuardClause($applicationName)) {
continue;
}
foreach ($tasksByTask as $taskName => $tasks) {
$this->tasks['after'][$applicationName][$taskName] = array_filter($tasks, function ($task) use ($removeTask) {
return $task !== $removeTask;
});
}
}
}
return $this;
} | [
"public",
"function",
"removeTask",
"(",
"$",
"removeTask",
",",
"Application",
"$",
"application",
"=",
"null",
")",
"{",
"$",
"removeApplicationName",
"=",
"$",
"application",
"instanceof",
"Application",
"?",
"$",
"application",
"->",
"getName",
"(",
")",
"... | Remove the given task from all stages and applications
@param string $removeTask
@param \TYPO3\Surf\Domain\Model\Application $application if given, task is only removed from application
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Remove",
"the",
"given",
"task",
"from",
"all",
"stages",
"and",
"applications"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L66-L114 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.addTaskToStage | protected function addTaskToStage($tasks, $stage, Application $application = null, $step = 'tasks')
{
if (!is_array($tasks)) {
$tasks = [$tasks];
}
$applicationName = $application !== null ? $application->getName() : '_';
if (!isset($this->tasks['stage'][$applicationName][$stage][$step])) {
$this->tasks['stage'][$applicationName][$stage][$step] = [];
}
$this->tasks['stage'][$applicationName][$stage][$step] = array_merge($this->tasks['stage'][$applicationName][$stage][$step], $tasks);
} | php | protected function addTaskToStage($tasks, $stage, Application $application = null, $step = 'tasks')
{
if (!is_array($tasks)) {
$tasks = [$tasks];
}
$applicationName = $application !== null ? $application->getName() : '_';
if (!isset($this->tasks['stage'][$applicationName][$stage][$step])) {
$this->tasks['stage'][$applicationName][$stage][$step] = [];
}
$this->tasks['stage'][$applicationName][$stage][$step] = array_merge($this->tasks['stage'][$applicationName][$stage][$step], $tasks);
} | [
"protected",
"function",
"addTaskToStage",
"(",
"$",
"tasks",
",",
"$",
"stage",
",",
"Application",
"$",
"application",
"=",
"null",
",",
"$",
"step",
"=",
"'tasks'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tasks",
")",
")",
"{",
"$",
"task... | Add the given tasks to a step in a stage and optionally a specific application
The tasks will be executed for the given stage. If an application is given,
the tasks will be executed only for the stage and application.
@param array|string $tasks
@param string $stage The name of the stage when this task shall be executed
@param \TYPO3\Surf\Domain\Model\Application $application If given the task will be specific for this application
@param string $step A stage has three steps "before", "tasks" and "after" | [
"Add",
"the",
"given",
"tasks",
"to",
"a",
"step",
"in",
"a",
"stage",
"and",
"optionally",
"a",
"specific",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L137-L150 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.addTask | public function addTask($tasks, $stage, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application);
return $this;
} | php | public function addTask($tasks, $stage, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application);
return $this;
} | [
"public",
"function",
"addTask",
"(",
"$",
"tasks",
",",
"$",
"stage",
",",
"Application",
"$",
"application",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addTaskToStage",
"(",
"$",
"tasks",
",",
"$",
"stage",
",",
"$",
"application",
")",
";",
"return"... | Add the given tasks for a stage and optionally a specific application
The tasks will be executed for the given stage. If an application is given,
the tasks will be executed only for the stage and application.
@param array|string $tasks
@param string $stage The name of the stage when this task shall be executed
@param \TYPO3\Surf\Domain\Model\Application $application If given the task will be specific for this application
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Add",
"the",
"given",
"tasks",
"for",
"a",
"stage",
"and",
"optionally",
"a",
"specific",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L164-L169 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.afterTask | public function afterTask($task, $tasks, Application $application = null)
{
if (!is_array($tasks)) {
$tasks = [$tasks];
}
$applicationName = $application !== null ? $application->getName() : '_';
if (!isset($this->tasks['after'][$applicationName][$task])) {
$this->tasks['after'][$applicationName][$task] = [];
}
$this->tasks['after'][$applicationName][$task] = array_merge($this->tasks['after'][$applicationName][$task], $tasks);
return $this;
} | php | public function afterTask($task, $tasks, Application $application = null)
{
if (!is_array($tasks)) {
$tasks = [$tasks];
}
$applicationName = $application !== null ? $application->getName() : '_';
if (!isset($this->tasks['after'][$applicationName][$task])) {
$this->tasks['after'][$applicationName][$task] = [];
}
$this->tasks['after'][$applicationName][$task] = array_merge($this->tasks['after'][$applicationName][$task], $tasks);
return $this;
} | [
"public",
"function",
"afterTask",
"(",
"$",
"task",
",",
"$",
"tasks",
",",
"Application",
"$",
"application",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tasks",
")",
")",
"{",
"$",
"tasks",
"=",
"[",
"$",
"tasks",
"]",
";",
"... | Add tasks that shall be executed after the given task
The execution will not depend on a stage but on an optional application.
@param string $task
@param array|string $tasks
@param \TYPO3\Surf\Domain\Model\Application $application
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Add",
"tasks",
"that",
"shall",
"be",
"executed",
"after",
"the",
"given",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L182-L196 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.defineTask | public function defineTask($taskName, $baseTask, $options)
{
$this->tasks['defined'][$taskName] = [
'task' => $baseTask,
'options' => $options
];
return $this;
} | php | public function defineTask($taskName, $baseTask, $options)
{
$this->tasks['defined'][$taskName] = [
'task' => $baseTask,
'options' => $options
];
return $this;
} | [
"public",
"function",
"defineTask",
"(",
"$",
"taskName",
",",
"$",
"baseTask",
",",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"tasks",
"[",
"'defined'",
"]",
"[",
"$",
"taskName",
"]",
"=",
"[",
"'task'",
"=>",
"$",
"baseTask",
",",
"'options'",
... | Define a new task based on an existing task by setting options
@param string $taskName
@param string $baseTask
@param array $options
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Define",
"a",
"new",
"task",
"based",
"on",
"an",
"existing",
"task",
"by",
"setting",
"options"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L234-L241 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.beforeStage | public function beforeStage($stage, $tasks, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application, 'before');
return $this;
} | php | public function beforeStage($stage, $tasks, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application, 'before');
return $this;
} | [
"public",
"function",
"beforeStage",
"(",
"$",
"stage",
",",
"$",
"tasks",
",",
"Application",
"$",
"application",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addTaskToStage",
"(",
"$",
"tasks",
",",
"$",
"stage",
",",
"$",
"application",
",",
"'before'",... | Add tasks that shall be executed before the given stage
@param string $stage
@param array|string $tasks
@param \TYPO3\Surf\Domain\Model\Application $application
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Add",
"tasks",
"that",
"shall",
"be",
"executed",
"before",
"the",
"given",
"stage"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L252-L257 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.afterStage | public function afterStage($stage, $tasks, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application, 'after');
return $this;
} | php | public function afterStage($stage, $tasks, Application $application = null)
{
$this->addTaskToStage($tasks, $stage, $application, 'after');
return $this;
} | [
"public",
"function",
"afterStage",
"(",
"$",
"stage",
",",
"$",
"tasks",
",",
"Application",
"$",
"application",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addTaskToStage",
"(",
"$",
"tasks",
",",
"$",
"stage",
",",
"$",
"application",
",",
"'after'",
... | Add tasks that shall be executed after the given stage
@param string $stage
@param array|string $tasks
@param \TYPO3\Surf\Domain\Model\Application $application
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Add",
"tasks",
"that",
"shall",
"be",
"executed",
"after",
"the",
"given",
"stage"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L268-L273 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.setTaskOptions | public function setTaskOptions($taskName, $options)
{
$baseTask = $taskName;
if (isset($this->tasks['defined'][$taskName]) && is_array($this->tasks['defined'][$taskName])) {
$definedTask = $this->tasks['defined'][$taskName];
$baseTask = $definedTask['task'];
if (is_array($definedTask['options'])) {
$options = array_merge_recursive($definedTask['options'], $options);
}
}
$this->defineTask($taskName, $baseTask, $options);
return $this;
} | php | public function setTaskOptions($taskName, $options)
{
$baseTask = $taskName;
if (isset($this->tasks['defined'][$taskName]) && is_array($this->tasks['defined'][$taskName])) {
$definedTask = $this->tasks['defined'][$taskName];
$baseTask = $definedTask['task'];
if (is_array($definedTask['options'])) {
$options = array_merge_recursive($definedTask['options'], $options);
}
}
$this->defineTask($taskName, $baseTask, $options);
return $this;
} | [
"public",
"function",
"setTaskOptions",
"(",
"$",
"taskName",
",",
"$",
"options",
")",
"{",
"$",
"baseTask",
"=",
"$",
"taskName",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tasks",
"[",
"'defined'",
"]",
"[",
"$",
"taskName",
"]",
")",
"&&",... | Override options for given task
@param string $taskName
@param array $options
@return \TYPO3\Surf\Domain\Model\Workflow | [
"Override",
"options",
"for",
"given",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L283-L296 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.executeStage | protected function executeStage($stage, Node $node, Application $application, Deployment $deployment)
{
foreach (['before', 'tasks', 'after'] as $stageStep) {
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
if (isset($this->tasks['stage'][$applicationName][$stage][$stageStep])) {
$deployment->getLogger()->debug('Executing stage "' . $stage . '" (step "' . $stageStep . '") on "' . $node->getName() . '" ' . $label);
foreach ($this->tasks['stage'][$applicationName][$stage][$stageStep] as $task) {
$this->executeTask($task, $node, $application, $deployment, $stage);
}
}
}
}
} | php | protected function executeStage($stage, Node $node, Application $application, Deployment $deployment)
{
foreach (['before', 'tasks', 'after'] as $stageStep) {
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
if (isset($this->tasks['stage'][$applicationName][$stage][$stageStep])) {
$deployment->getLogger()->debug('Executing stage "' . $stage . '" (step "' . $stageStep . '") on "' . $node->getName() . '" ' . $label);
foreach ($this->tasks['stage'][$applicationName][$stage][$stageStep] as $task) {
$this->executeTask($task, $node, $application, $deployment, $stage);
}
}
}
}
} | [
"protected",
"function",
"executeStage",
"(",
"$",
"stage",
",",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"foreach",
"(",
"[",
"'before'",
",",
"'tasks'",
",",
"'after'",
"]",
"as",
"$",
... | Execute a stage for a node and application
@param string $stage
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@throws DeploymentLockedException | [
"Execute",
"a",
"stage",
"for",
"a",
"node",
"and",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L317-L331 |
TYPO3/Surf | src/Domain/Model/Workflow.php | Workflow.executeTask | protected function executeTask($task, Node $node, Application $application, Deployment $deployment, $stage, array &$callstack = [])
{
foreach (['_', $application->getName()] as $applicationName) {
if (isset($this->tasks['before'][$applicationName][$task])) {
foreach ($this->tasks['before'][$applicationName][$task] as $beforeTask) {
$deployment->getLogger()->debug('Task "' . $beforeTask . '" before "' . $task);
$this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
}
}
}
if (isset($callstack[$task])) {
throw new TaskExecutionException('Cycle for task "' . $task . '" detected, aborting.', 1335976544);
}
if (isset($this->tasks['defined'][$task])) {
$this->taskManager->execute($this->tasks['defined'][$task]['task'], $node, $application, $deployment, $stage, $this->tasks['defined'][$task]['options'], $task);
} else {
$this->taskManager->execute($task, $node, $application, $deployment, $stage);
}
$callstack[$task] = true;
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
if (isset($this->tasks['after'][$applicationName][$task])) {
foreach ($this->tasks['after'][$applicationName][$task] as $beforeTask) {
$deployment->getLogger()->debug('Task "' . $beforeTask . '" after "' . $task . '" ' . $label);
$this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
}
}
}
} | php | protected function executeTask($task, Node $node, Application $application, Deployment $deployment, $stage, array &$callstack = [])
{
foreach (['_', $application->getName()] as $applicationName) {
if (isset($this->tasks['before'][$applicationName][$task])) {
foreach ($this->tasks['before'][$applicationName][$task] as $beforeTask) {
$deployment->getLogger()->debug('Task "' . $beforeTask . '" before "' . $task);
$this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
}
}
}
if (isset($callstack[$task])) {
throw new TaskExecutionException('Cycle for task "' . $task . '" detected, aborting.', 1335976544);
}
if (isset($this->tasks['defined'][$task])) {
$this->taskManager->execute($this->tasks['defined'][$task]['task'], $node, $application, $deployment, $stage, $this->tasks['defined'][$task]['options'], $task);
} else {
$this->taskManager->execute($task, $node, $application, $deployment, $stage);
}
$callstack[$task] = true;
foreach (['_', $application->getName()] as $applicationName) {
$label = $applicationName === '_' ? 'for all' : 'for application ' . $applicationName;
if (isset($this->tasks['after'][$applicationName][$task])) {
foreach ($this->tasks['after'][$applicationName][$task] as $beforeTask) {
$deployment->getLogger()->debug('Task "' . $beforeTask . '" after "' . $task . '" ' . $label);
$this->executeTask($beforeTask, $node, $application, $deployment, $stage, $callstack);
}
}
}
} | [
"protected",
"function",
"executeTask",
"(",
"$",
"task",
",",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"stage",
",",
"array",
"&",
"$",
"callstack",
"=",
"[",
"]",
")",
"{",
"foreach",
... | Execute a task and consider configured before / after "hooks"
Will also execute tasks that are registered to run before or after this task.
@param string $task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param string $stage
@param array $callstack
@throws TaskExecutionException
@throws DeploymentLockedException | [
"Execute",
"a",
"task",
"and",
"consider",
"configured",
"before",
"/",
"after",
"hooks"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/Workflow.php#L347-L375 |
TYPO3/Surf | src/Task/LockDeploymentTask.php | LockDeploymentTask.rollback | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$unLockDeployment = new UnlockDeploymentTask();
$unLockDeployment->setShellCommandService(new ShellCommandService());
$unLockDeployment->execute($node, $application, $deployment, $options);
} | php | public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$unLockDeployment = new UnlockDeploymentTask();
$unLockDeployment->setShellCommandService(new ShellCommandService());
$unLockDeployment->execute($node, $application, $deployment, $options);
} | [
"public",
"function",
"rollback",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"unLockDeployment",
"=",
"new",
"UnlockDeploymentTask",
"(",... | Removes lock file on failed deployment
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Removes",
"lock",
"file",
"on",
"failed",
"deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/LockDeploymentTask.php#L66-L71 |
TYPO3/Surf | src/Domain/Service/TaskManager.php | TaskManager.execute | public function execute($taskName, Node $node, Application $application, Deployment $deployment, $stage, array $options = [], $definedTaskName = '')
{
$definedTaskName = $definedTaskName ?: $taskName;
$deployment->getLogger()->info($node->getName() . ' (' . $application->getName() . ') ' . $definedTaskName);
$task = $this->createTaskInstance($taskName);
$globalOptions = $this->overrideOptions($definedTaskName, $deployment, $node, $application, $options);
$this->taskHistory[] = [
'task' => $task,
'node' => $node,
'application' => $application,
'deployment' => $deployment,
'stage' => $stage,
'options' => $globalOptions
];
if (!$deployment->isDryRun()) {
$task->execute($node, $application, $deployment, $globalOptions);
} else {
$task->simulate($node, $application, $deployment, $globalOptions);
}
} | php | public function execute($taskName, Node $node, Application $application, Deployment $deployment, $stage, array $options = [], $definedTaskName = '')
{
$definedTaskName = $definedTaskName ?: $taskName;
$deployment->getLogger()->info($node->getName() . ' (' . $application->getName() . ') ' . $definedTaskName);
$task = $this->createTaskInstance($taskName);
$globalOptions = $this->overrideOptions($definedTaskName, $deployment, $node, $application, $options);
$this->taskHistory[] = [
'task' => $task,
'node' => $node,
'application' => $application,
'deployment' => $deployment,
'stage' => $stage,
'options' => $globalOptions
];
if (!$deployment->isDryRun()) {
$task->execute($node, $application, $deployment, $globalOptions);
} else {
$task->simulate($node, $application, $deployment, $globalOptions);
}
} | [
"public",
"function",
"execute",
"(",
"$",
"taskName",
",",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"$",
"stage",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"definedTaskName",
"=... | Execute a task
@param string $taskName
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param string $stage
@param array $options Local task options
@param string $definedTaskName
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"a",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/TaskManager.php#L39-L62 |
TYPO3/Surf | src/Domain/Service/TaskManager.php | TaskManager.rollback | public function rollback()
{
foreach (array_reverse($this->taskHistory) as $historicTask) {
$historicTask['deployment']->getLogger()->info('Rolling back ' . get_class($historicTask['task']));
if (!$historicTask['deployment']->isDryRun()) {
$historicTask['task']->rollback($historicTask['node'], $historicTask['application'], $historicTask['deployment'], $historicTask['options']);
}
}
$this->reset();
} | php | public function rollback()
{
foreach (array_reverse($this->taskHistory) as $historicTask) {
$historicTask['deployment']->getLogger()->info('Rolling back ' . get_class($historicTask['task']));
if (!$historicTask['deployment']->isDryRun()) {
$historicTask['task']->rollback($historicTask['node'], $historicTask['application'], $historicTask['deployment'], $historicTask['options']);
}
}
$this->reset();
} | [
"public",
"function",
"rollback",
"(",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"taskHistory",
")",
"as",
"$",
"historicTask",
")",
"{",
"$",
"historicTask",
"[",
"'deployment'",
"]",
"->",
"getLogger",
"(",
")",
"->",
"info",
"... | Rollback all tasks stored in the task history in reverse order | [
"Rollback",
"all",
"tasks",
"stored",
"in",
"the",
"task",
"history",
"in",
"reverse",
"order"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/TaskManager.php#L67-L76 |
TYPO3/Surf | src/Domain/Service/TaskManager.php | TaskManager.overrideOptions | protected function overrideOptions($taskName, Deployment $deployment, Node $node, Application $application, array $taskOptions)
{
$globalOptions = array_merge(
$deployment->getOptions(),
$node->getOptions(),
$application->getOptions()
);
$globalTaskOptions = [];
foreach ($globalOptions as $optionKey => $optionValue) {
if (strlen($optionKey) > strlen($taskName) && strpos($optionKey, $taskName) === 0 && $optionKey[strlen($taskName)] === '[') {
$globalTaskOptions[substr($optionKey, strlen($taskName) + 1, -1)] = $optionValue;
}
}
return array_merge(
$globalOptions,
$globalTaskOptions,
$taskOptions
);
} | php | protected function overrideOptions($taskName, Deployment $deployment, Node $node, Application $application, array $taskOptions)
{
$globalOptions = array_merge(
$deployment->getOptions(),
$node->getOptions(),
$application->getOptions()
);
$globalTaskOptions = [];
foreach ($globalOptions as $optionKey => $optionValue) {
if (strlen($optionKey) > strlen($taskName) && strpos($optionKey, $taskName) === 0 && $optionKey[strlen($taskName)] === '[') {
$globalTaskOptions[substr($optionKey, strlen($taskName) + 1, -1)] = $optionValue;
}
}
return array_merge(
$globalOptions,
$globalTaskOptions,
$taskOptions
);
} | [
"protected",
"function",
"overrideOptions",
"(",
"$",
"taskName",
",",
"Deployment",
"$",
"deployment",
",",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"array",
"$",
"taskOptions",
")",
"{",
"$",
"globalOptions",
"=",
"array_merge",
"(",... | Override options for a task
The order of the options is:
Deployment, Node, Application, Task
A task option will always override more global options from the
Deployment, Node or Application.
Global options for a task should be prefixed with the task name to prevent naming
issues between different tasks. For example passing a special option to the
GitCheckoutTask could be expressed like GitCheckoutTask::class . '[sha1]' => '1234...'.
@param string $taskName
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param array $taskOptions
@return array | [
"Override",
"options",
"for",
"a",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/TaskManager.php#L107-L126 |
TYPO3/Surf | src/Domain/Service/TaskManager.php | TaskManager.createTaskInstance | protected function createTaskInstance($taskName)
{
$taskClassName = $this->mapTaskNameToTaskClass($taskName);
$task = new $taskClassName();
if ($task instanceof ShellCommandServiceAwareInterface) {
$task->setShellCommandService(new ShellCommandService());
}
return $task;
} | php | protected function createTaskInstance($taskName)
{
$taskClassName = $this->mapTaskNameToTaskClass($taskName);
$task = new $taskClassName();
if ($task instanceof ShellCommandServiceAwareInterface) {
$task->setShellCommandService(new ShellCommandService());
}
return $task;
} | [
"protected",
"function",
"createTaskInstance",
"(",
"$",
"taskName",
")",
"{",
"$",
"taskClassName",
"=",
"$",
"this",
"->",
"mapTaskNameToTaskClass",
"(",
"$",
"taskName",
")",
";",
"$",
"task",
"=",
"new",
"$",
"taskClassName",
"(",
")",
";",
"if",
"(",
... | Create a task instance from the given task name
@param string $taskName
@return \TYPO3\Surf\Domain\Model\Task
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Create",
"a",
"task",
"instance",
"from",
"the",
"given",
"task",
"name"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Service/TaskManager.php#L135-L143 |
TYPO3/Surf | src/Task/TYPO3/CMS/CopyConfigurationTask.php | CopyConfigurationTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$deployment->getLogger()->warning(DeprecationMessageFactory::createGenericDeprecationWarningForTask(__CLASS__));
$options['configurationFileExtension'] = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'php';
parent::execute($node, $application, $deployment, $options);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$deployment->getLogger()->warning(DeprecationMessageFactory::createGenericDeprecationWarningForTask(__CLASS__));
$options['configurationFileExtension'] = isset($options['configurationFileExtension']) ? $options['configurationFileExtension'] : 'php';
parent::execute($node, $application, $deployment, $options);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"deployment",
"->",
"getLogger",
"(",
")",
"->",
"warning... | Executes this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\TaskExecutionException
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/CopyConfigurationTask.php#L43-L48 |
TYPO3/Surf | src/Task/Neos/Flow/PublishResourcesTask.php | PublishResourcesTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for PublishResourcesTask, got "%s"', get_class($application)));
if ($application->getVersion() >= '3.0') {
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'resource:publish'), $node, $deployment);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for PublishResourcesTask, got "%s"', get_class($application)));
if ($application->getVersion() >= '3.0') {
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'resource:publish'), $node, $deployment);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"Assert",
"::",
"isInstanceOf",
"(",
"$",
"application",
",",
... | Execute this task
@param Node $node
@param Application|Flow $application
@param Deployment $deployment
@param array $options
@throws InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/PublishResourcesTask.php#L39-L47 |
TYPO3/Surf | src/Command/MigrateCommand.php | MigrateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$basePath = $this->factory->getDeploymentsBasePath($configurationPath);
$deploymentFileName = $basePath . '/' . $deploymentName . '.php';
$legacyMap = require __DIR__ . '/../../Migrations/Code/LegacyClassMap.php';
$fileContent = file_get_contents($deploymentFileName);
foreach ($legacyMap as $identifier => $className) {
if ($fileContent !== str_ireplace($identifier, str_replace('\\', '\\\\', $className), $fileContent)) {
$output->writeln(sprintf('<warning>Legacy deployment task name or task option "%s" found!</warning>', $identifier));
$fileContent = str_ireplace($identifier, str_replace('\\', '\\\\', $className), $fileContent);
}
}
file_put_contents($deploymentFileName, $fileContent);
$output->writeln('<info>Migrated deployment definition "' . $deploymentName . '"</info>');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$configurationPath = $input->getOption('configurationPath');
$deploymentName = $input->getArgument('deploymentName');
$basePath = $this->factory->getDeploymentsBasePath($configurationPath);
$deploymentFileName = $basePath . '/' . $deploymentName . '.php';
$legacyMap = require __DIR__ . '/../../Migrations/Code/LegacyClassMap.php';
$fileContent = file_get_contents($deploymentFileName);
foreach ($legacyMap as $identifier => $className) {
if ($fileContent !== str_ireplace($identifier, str_replace('\\', '\\\\', $className), $fileContent)) {
$output->writeln(sprintf('<warning>Legacy deployment task name or task option "%s" found!</warning>', $identifier));
$fileContent = str_ireplace($identifier, str_replace('\\', '\\\\', $className), $fileContent);
}
}
file_put_contents($deploymentFileName, $fileContent);
$output->writeln('<info>Migrated deployment definition "' . $deploymentName . '"</info>');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"configurationPath",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'configurationPath'",
")",
";",
"$",
"deploymentName",
"=",
"$",
"in... | Execute
@param InputInterface $input
@param OutputInterface $output
@return int | [
"Execute"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/MigrateCommand.php#L53-L71 |
TYPO3/Surf | src/Task/CreateArchiveTask.php | CreateArchiveTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->checkOptionsForValidity($options);
$this->shell->execute('rm -f ' . $options['targetFile'] . '; mkdir -p ' . dirname($options['targetFile']), $node, $deployment);
$sourcePath = $deployment->getApplicationReleasePath($application);
$tarOptions = sprintf(' --transform="s,^%s,%s," ', ltrim($sourcePath, '/'), $options['baseDirectory']);
if (isset($options['exclude']) && is_array($options['exclude'])) {
foreach ($options['exclude'] as $excludePattern) {
$tarOptions .= sprintf(' --exclude="%s" ', $excludePattern);
}
}
if (substr($options['targetFile'], -7) === '.tar.gz') {
$tarOptions .= sprintf(' -czf %s %s', $options['targetFile'], $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
} elseif (substr($options['targetFile'], -8) === '.tar.bz2') {
$tarOptions .= sprintf(' -cjf %s %s', $options['targetFile'], $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
} elseif (substr($options['targetFile'], -4) === '.zip') {
$temporaryDirectory = sys_get_temp_dir() . '/' . uniqid('f3_deploy');
$this->shell->execute(sprintf('mkdir -p %s', $temporaryDirectory), $node, $deployment);
$tarOptions .= sprintf(' -cf %s/out.tar %s', $temporaryDirectory, $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
$this->shell->execute(sprintf('cd %s; tar -xf out.tar; rm out.tar; zip --quiet -9 -r out %s', $temporaryDirectory, $options['baseDirectory']), $node, $deployment);
$this->shell->execute(sprintf('mv %s/out.zip %s; rm -Rf %s', $temporaryDirectory, $options['targetFile'], $temporaryDirectory), $node, $deployment);
} else {
throw new TaskExecutionException('Unknown target file format', 1314248387);
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$this->checkOptionsForValidity($options);
$this->shell->execute('rm -f ' . $options['targetFile'] . '; mkdir -p ' . dirname($options['targetFile']), $node, $deployment);
$sourcePath = $deployment->getApplicationReleasePath($application);
$tarOptions = sprintf(' --transform="s,^%s,%s," ', ltrim($sourcePath, '/'), $options['baseDirectory']);
if (isset($options['exclude']) && is_array($options['exclude'])) {
foreach ($options['exclude'] as $excludePattern) {
$tarOptions .= sprintf(' --exclude="%s" ', $excludePattern);
}
}
if (substr($options['targetFile'], -7) === '.tar.gz') {
$tarOptions .= sprintf(' -czf %s %s', $options['targetFile'], $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
} elseif (substr($options['targetFile'], -8) === '.tar.bz2') {
$tarOptions .= sprintf(' -cjf %s %s', $options['targetFile'], $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
} elseif (substr($options['targetFile'], -4) === '.zip') {
$temporaryDirectory = sys_get_temp_dir() . '/' . uniqid('f3_deploy');
$this->shell->execute(sprintf('mkdir -p %s', $temporaryDirectory), $node, $deployment);
$tarOptions .= sprintf(' -cf %s/out.tar %s', $temporaryDirectory, $sourcePath);
$this->shell->execute(sprintf('tar %s || gnutar %s', $tarOptions, $tarOptions), $node, $deployment);
$this->shell->execute(sprintf('cd %s; tar -xf out.tar; rm out.tar; zip --quiet -9 -r out %s', $temporaryDirectory, $options['baseDirectory']), $node, $deployment);
$this->shell->execute(sprintf('mv %s/out.zip %s; rm -Rf %s', $temporaryDirectory, $options['targetFile'], $temporaryDirectory), $node, $deployment);
} else {
throw new TaskExecutionException('Unknown target file format', 1314248387);
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"checkOptionsForValidity",
"(",
"$",
"options... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\TaskExecutionException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/CreateArchiveTask.php#L60-L90 |
TYPO3/Surf | src/Domain/Model/SimpleWorkflow.php | SimpleWorkflow.run | public function run(Deployment $deployment)
{
parent::run($deployment);
$applications = $deployment->getApplications();
if (count($applications) === 0) {
throw InvalidConfigurationException::createNoApplicationConfigured();
}
$nodes = $deployment->getNodes();
if (count($nodes) === 0) {
throw InvalidConfigurationException::createNoNodesConfigured();
}
foreach ($this->stages as $stage) {
$deployment->getLogger()->notice('Stage ' . $stage);
foreach ($nodes as $node) {
$deployment->getLogger()->debug('Node ' . $node->getName());
foreach ($applications as $application) {
if (! $application->hasNode($node)) {
continue;
}
$deployment->getLogger()->debug('Application ' . $application->getName());
try {
$this->executeStage($stage, $node, $application, $deployment);
} catch (DeploymentLockedException $exception) {
$deployment->setStatus(Deployment::STATUS_CANCELLED);
$deployment->getLogger()->info($exception->getMessage());
if ($this->enableRollback) {
$this->taskManager->rollback();
}
return;
} catch (Exception $exception) {
$deployment->setStatus(Deployment::STATUS_FAILED);
if ($this->enableRollback) {
if (array_search($stage, $this->stages, false) <= array_search('switch', $this->stages, false)) {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" rolling back.');
$this->taskManager->rollback();
} else {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but after switch stage, no rollback necessary.');
$this->taskManager->reset();
}
} else {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but rollback disabled. Stopping.');
}
return;
}
}
}
}
if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) {
$deployment->setStatus(Deployment::STATUS_SUCCESS);
}
} | php | public function run(Deployment $deployment)
{
parent::run($deployment);
$applications = $deployment->getApplications();
if (count($applications) === 0) {
throw InvalidConfigurationException::createNoApplicationConfigured();
}
$nodes = $deployment->getNodes();
if (count($nodes) === 0) {
throw InvalidConfigurationException::createNoNodesConfigured();
}
foreach ($this->stages as $stage) {
$deployment->getLogger()->notice('Stage ' . $stage);
foreach ($nodes as $node) {
$deployment->getLogger()->debug('Node ' . $node->getName());
foreach ($applications as $application) {
if (! $application->hasNode($node)) {
continue;
}
$deployment->getLogger()->debug('Application ' . $application->getName());
try {
$this->executeStage($stage, $node, $application, $deployment);
} catch (DeploymentLockedException $exception) {
$deployment->setStatus(Deployment::STATUS_CANCELLED);
$deployment->getLogger()->info($exception->getMessage());
if ($this->enableRollback) {
$this->taskManager->rollback();
}
return;
} catch (Exception $exception) {
$deployment->setStatus(Deployment::STATUS_FAILED);
if ($this->enableRollback) {
if (array_search($stage, $this->stages, false) <= array_search('switch', $this->stages, false)) {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" rolling back.');
$this->taskManager->rollback();
} else {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but after switch stage, no rollback necessary.');
$this->taskManager->reset();
}
} else {
$deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but rollback disabled. Stopping.');
}
return;
}
}
}
}
if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) {
$deployment->setStatus(Deployment::STATUS_SUCCESS);
}
} | [
"public",
"function",
"run",
"(",
"Deployment",
"$",
"deployment",
")",
"{",
"parent",
"::",
"run",
"(",
"$",
"deployment",
")",
";",
"$",
"applications",
"=",
"$",
"deployment",
"->",
"getApplications",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ap... | Sequentially execute the stages for each node, so first all nodes will go through the initialize stage and
then the next stage will be executed until the final stage is reached and the workflow is finished.
A rollback will be done for all nodes as long as the stage switch was not completed.
@param Deployment $deployment
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Sequentially",
"execute",
"the",
"stages",
"for",
"each",
"node",
"so",
"first",
"all",
"nodes",
"will",
"go",
"through",
"the",
"initialize",
"stage",
"and",
"then",
"the",
"next",
"stage",
"will",
"be",
"executed",
"until",
"the",
"final",
"stage",
"is",
... | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/SimpleWorkflow.php#L67-L124 |
TYPO3/Surf | src/Application/Neos/Neos.php | Neos.getCommandPackageKey | public function getCommandPackageKey($command = '')
{
if ($this->getVersion() < '4.0') {
return $this->isNeosCommand($command) ? 'typo3.neos' : 'typo3.flow';
}
return $this->isNeosCommand($command) ? 'neos.neos' : 'neos.flow';
} | php | public function getCommandPackageKey($command = '')
{
if ($this->getVersion() < '4.0') {
return $this->isNeosCommand($command) ? 'typo3.neos' : 'typo3.flow';
}
return $this->isNeosCommand($command) ? 'neos.neos' : 'neos.flow';
} | [
"public",
"function",
"getCommandPackageKey",
"(",
"$",
"command",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getVersion",
"(",
")",
"<",
"'4.0'",
")",
"{",
"return",
"$",
"this",
"->",
"isNeosCommand",
"(",
"$",
"command",
")",
"?",
"'typo3.n... | Get the package key to prefix the command
@param string $command
@return string | [
"Get",
"the",
"package",
"key",
"to",
"prefix",
"the",
"command"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/Neos/Neos.php#L75-L81 |
TYPO3/Surf | src/Task/Php/WebOpcacheResetCreateScriptTask.php | WebOpcacheResetCreateScriptTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$workspacePath = $deployment->getWorkspacePath($application);
$webDirectory = $application->hasOption('webDirectory') ? $application->getOption('webDirectory') : 'Web';
$scriptBasePath = $options['scriptBasePath'] ?: Files::concatenatePaths([$workspacePath, $webDirectory]);
if ($options['scriptIdentifier'] === null) {
// Store the script identifier as an application option
$scriptIdentifier = bin2hex($this->randomBytesGenerator->generate(32));
$application->setOption(WebOpcacheResetExecuteTask::class . '[scriptIdentifier]', $scriptIdentifier);
} else {
$scriptIdentifier = $options['scriptIdentifier'];
}
$localhost = new Node('localhost');
$localhost->onLocalhost();
$commands = [
'cd ' . escapeshellarg($scriptBasePath),
'rm -f surf-opcache-reset-*',
];
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
if (! $deployment->isDryRun()) {
$scriptFilename = sprintf('%s/surf-opcache-reset-%s.php', $scriptBasePath, $scriptIdentifier);
$result = $this->filesystem->put($scriptFilename, '<?php
if (function_exists("opcache_reset")) {
opcache_reset();
}
@unlink(__FILE__);
echo "success";
');
if ($result === false) {
throw TaskExecutionException::webOpcacheResetCreateScriptTaskCouldNotWritFile($scriptFilename);
}
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$workspacePath = $deployment->getWorkspacePath($application);
$webDirectory = $application->hasOption('webDirectory') ? $application->getOption('webDirectory') : 'Web';
$scriptBasePath = $options['scriptBasePath'] ?: Files::concatenatePaths([$workspacePath, $webDirectory]);
if ($options['scriptIdentifier'] === null) {
// Store the script identifier as an application option
$scriptIdentifier = bin2hex($this->randomBytesGenerator->generate(32));
$application->setOption(WebOpcacheResetExecuteTask::class . '[scriptIdentifier]', $scriptIdentifier);
} else {
$scriptIdentifier = $options['scriptIdentifier'];
}
$localhost = new Node('localhost');
$localhost->onLocalhost();
$commands = [
'cd ' . escapeshellarg($scriptBasePath),
'rm -f surf-opcache-reset-*',
];
$this->shell->executeOrSimulate($commands, $localhost, $deployment);
if (! $deployment->isDryRun()) {
$scriptFilename = sprintf('%s/surf-opcache-reset-%s.php', $scriptBasePath, $scriptIdentifier);
$result = $this->filesystem->put($scriptFilename, '<?php
if (function_exists("opcache_reset")) {
opcache_reset();
}
@unlink(__FILE__);
echo "success";
');
if ($result === false) {
throw TaskExecutionException::webOpcacheResetCreateScriptTaskCouldNotWritFile($scriptFilename);
}
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"(... | Execute this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options Supported options: "scriptBasePath" and "scriptIdentifier"
@throws TaskExecutionException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Php/WebOpcacheResetCreateScriptTask.php#L90-L131 |
TYPO3/Surf | src/Task/Neos/Flow/RunCommandTask.php | RunCommandTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for RunCommandTask, got "%s"', get_class($application)));
$options = $this->configureOptions($options);
$targetPath = $deployment->getApplicationReleasePath($application);
$command = sprintf('cd %s && FLOW_CONTEXT=%s ./%s %s', $targetPath, $application->getContext(), $application->getFlowScriptName(), $options['command']);
$this->shell->executeOrSimulate($command, $node, $deployment, $options['ignoreErrors'], $options['logOutput']);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for RunCommandTask, got "%s"', get_class($application)));
$options = $this->configureOptions($options);
$targetPath = $deployment->getApplicationReleasePath($application);
$command = sprintf('cd %s && FLOW_CONTEXT=%s ./%s %s', $targetPath, $application->getContext(), $application->getFlowScriptName(), $options['command']);
$this->shell->executeOrSimulate($command, $node, $deployment, $options['ignoreErrors'], $options['logOutput']);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"Assert",
"::",
"isInstanceOf",
"(",
"$",
"application",
",",
... | Execute this task
@param Node $node
@param Application|Flow $application
@param Deployment $deployment
@param array $options
@throws InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/RunCommandTask.php#L58-L69 |
TYPO3/Surf | src/Task/Generic/RollbackTask.php | RollbackTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$allReleases = \TYPO3\Surf\findAllReleases($deployment, $node, $application, $this->shell);
$releasesPath = $application->getReleasesPath();
$releases = array_map('trim', array_filter($allReleases, function ($release) {
return $release !== '.' && $release !== 'current' && $release !== 'previous';
}));
sort($releases, SORT_NUMERIC | SORT_DESC);
$numberOfReleases = count($releases);
if ($numberOfReleases > 1) {
$previousReleaseIdentifier = \TYPO3\Surf\findPreviousReleaseIdentifier($deployment, $node, $application, $this->shell);
$currentReleaseIdentifier = \TYPO3\Surf\findCurrentReleaseIdentifier($deployment, $node, $application, $this->shell);
// Symlink to old release.
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would symlink current to' : 'Symlink current to') . ' release ' . $previousReleaseIdentifier);
$symlinkCommand = sprintf('cd %1$s && ln -sfn ./%2$s current', $releasesPath, $previousReleaseIdentifier);
$deployment->getLogger()->info($symlinkCommand);
$this->shell->executeOrSimulate($symlinkCommand, $node, $deployment);
// Remove current release
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' old current release ' . $currentReleaseIdentifier);
$removeCommand = sprintf('rm -rf %1$s/%2$s; rm -rf %1$s/%2$sREVISION;', $releasesPath, $currentReleaseIdentifier);
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
if ($numberOfReleases > 2) {
list($penultimateRelease) = array_slice($releases, -3, 1);
// Symlink previous to penultimate release
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would symlink previous to' : 'Symlink previous to') . ' release ' . $penultimateRelease);
$symlinkCommand = sprintf('cd %1$s && ln -sfn ./%2$s previous', $releasesPath, $penultimateRelease);
$deployment->getLogger()->info($symlinkCommand);
$this->shell->executeOrSimulate($symlinkCommand, $node, $deployment);
} else {
// Remove previous symlink
$removeCommand = sprintf('rm -rf %1$s/previous', $application->getReleasesPath());
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' previous symlink: ' . $removeCommand);
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
}
} else {
$deployment->getLogger()->notice('No more releases you can revert to.');
}
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$allReleases = \TYPO3\Surf\findAllReleases($deployment, $node, $application, $this->shell);
$releasesPath = $application->getReleasesPath();
$releases = array_map('trim', array_filter($allReleases, function ($release) {
return $release !== '.' && $release !== 'current' && $release !== 'previous';
}));
sort($releases, SORT_NUMERIC | SORT_DESC);
$numberOfReleases = count($releases);
if ($numberOfReleases > 1) {
$previousReleaseIdentifier = \TYPO3\Surf\findPreviousReleaseIdentifier($deployment, $node, $application, $this->shell);
$currentReleaseIdentifier = \TYPO3\Surf\findCurrentReleaseIdentifier($deployment, $node, $application, $this->shell);
// Symlink to old release.
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would symlink current to' : 'Symlink current to') . ' release ' . $previousReleaseIdentifier);
$symlinkCommand = sprintf('cd %1$s && ln -sfn ./%2$s current', $releasesPath, $previousReleaseIdentifier);
$deployment->getLogger()->info($symlinkCommand);
$this->shell->executeOrSimulate($symlinkCommand, $node, $deployment);
// Remove current release
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' old current release ' . $currentReleaseIdentifier);
$removeCommand = sprintf('rm -rf %1$s/%2$s; rm -rf %1$s/%2$sREVISION;', $releasesPath, $currentReleaseIdentifier);
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
if ($numberOfReleases > 2) {
list($penultimateRelease) = array_slice($releases, -3, 1);
// Symlink previous to penultimate release
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would symlink previous to' : 'Symlink previous to') . ' release ' . $penultimateRelease);
$symlinkCommand = sprintf('cd %1$s && ln -sfn ./%2$s previous', $releasesPath, $penultimateRelease);
$deployment->getLogger()->info($symlinkCommand);
$this->shell->executeOrSimulate($symlinkCommand, $node, $deployment);
} else {
// Remove previous symlink
$removeCommand = sprintf('rm -rf %1$s/previous', $application->getReleasesPath());
$deployment->getLogger()->info(($deployment->isDryRun() ? 'Would remove' : 'Removing') . ' previous symlink: ' . $removeCommand);
$this->shell->executeOrSimulate($removeCommand, $node, $deployment);
}
} else {
$deployment->getLogger()->notice('No more releases you can revert to.');
}
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"allReleases",
"=",
"\\",
"TYPO3",
"\\",
"Surf",
"\\",
... | @param Node $node
@param Application $application
@param Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\TaskExecutionException | [
"@param",
"Node",
"$node",
"@param",
"Application",
"$application",
"@param",
"Deployment",
"$deployment",
"@param",
"array",
"$options"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Generic/RollbackTask.php#L30-L74 |
TYPO3/Surf | src/Task/VarnishBanTask.php | VarnishBanTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$this->shell->executeOrSimulate($options['varnishadm'] . ' -S ' . $options['secretFile'] . ' -T 127.0.0.1:6082 ban.url ' . escapeshellarg($options['banUrl']), $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$this->shell->executeOrSimulate($options['varnishadm'] . ' -S ' . $options['secretFile'] . ' -T 127.0.0.1:6082 ban.url ' . escapeshellarg($options['banUrl']), $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"(... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/VarnishBanTask.php#L49-L53 |
TYPO3/Surf | src/Task/VarnishBanTask.php | VarnishBanTask.simulate | public function simulate(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$this->shell->executeOrSimulate($options['varnishadm'] . ' -S ' . $options['secretFile'] . ' -T 127.0.0.1:6082 status', $node, $deployment);
} | php | public function simulate(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$this->shell->executeOrSimulate($options['varnishadm'] . ' -S ' . $options['secretFile'] . ' -T 127.0.0.1:6082 status', $node, $deployment);
} | [
"public",
"function",
"simulate",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"... | Simulate this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Simulate",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/VarnishBanTask.php#L63-L67 |
TYPO3/Surf | src/Command/SelfUpdateCommand.php | SelfUpdateCommand.configure | protected function configure()
{
$this->setName('self-update')
->addOption(
'stability',
null,
InputOption::VALUE_OPTIONAL,
'GitHub stability value (' . GithubStrategy::STABLE . ', ' . GithubStrategy::UNSTABLE . ', ' . GithubStrategy::ANY . ')'
)->addOption(
'check',
null,
InputOption::VALUE_NONE,
'Check for new version'
)->addOption(
'rollback',
null,
InputOption::VALUE_NONE,
'Rolls back to previous version'
)->setDescription(sprintf('Update %s to most recent stable build', $this->getLocalPharName()));
} | php | protected function configure()
{
$this->setName('self-update')
->addOption(
'stability',
null,
InputOption::VALUE_OPTIONAL,
'GitHub stability value (' . GithubStrategy::STABLE . ', ' . GithubStrategy::UNSTABLE . ', ' . GithubStrategy::ANY . ')'
)->addOption(
'check',
null,
InputOption::VALUE_NONE,
'Check for new version'
)->addOption(
'rollback',
null,
InputOption::VALUE_NONE,
'Rolls back to previous version'
)->setDescription(sprintf('Update %s to most recent stable build', $this->getLocalPharName()));
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"'self-update'",
")",
"->",
"addOption",
"(",
"'stability'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'GitHub stability value ('",
".",
"GithubStrategy",
... | Configure | [
"Configure"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/SelfUpdateCommand.php#L38-L57 |
TYPO3/Surf | src/Command/SelfUpdateCommand.php | SelfUpdateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
/** @var GithubStrategy $strategy */
$strategy = $updater->getStrategy();
$strategy->setPackageName('TYPO3/Surf');
$strategy->setPharName('surf.phar');
$io = new SymfonyStyle($input, $output);
$stability = $input->getOption('stability');
if (empty($stability)) {
$stability = GithubStrategy::STABLE;
}
/** @var GithubStrategy $strategy */
$strategy = $updater->getStrategy();
$strategy->setCurrentLocalVersion($this->getApplication()->getVersion());
$strategy->setStability($stability);
if ($input->getOption('check')) {
$result = $updater->hasUpdate();
if ($result) {
$output->writeln(sprintf(
'The %s build available remotely is: %s',
$strategy->getStability() === GithubStrategy::ANY ? 'latest' : 'current ' . $strategy->getStability(),
$updater->getNewVersion()
));
} elseif (false === $updater->getNewVersion()) {
$output->writeln('There are no new builds available.');
} else {
$output->writeln(sprintf('You have the current %s build installed.', $strategy->getStability()));
}
} elseif ($input->getOption('rollback')) {
$result = $updater->rollback();
$result ? $output->writeln('Success!') : $output->writeln('Failure!');
} else {
$result = $updater->update();
if ($result) {
$io->success(
sprintf(
'Your %s has been updated from "%s" to "%s".',
$this->getLocalPharName(),
$updater->getOldVersion(),
$updater->getNewVersion()
)
);
} else {
$io->success(sprintf('Your %s is already up to date.', $this->getLocalPharName()));
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
/** @var GithubStrategy $strategy */
$strategy = $updater->getStrategy();
$strategy->setPackageName('TYPO3/Surf');
$strategy->setPharName('surf.phar');
$io = new SymfonyStyle($input, $output);
$stability = $input->getOption('stability');
if (empty($stability)) {
$stability = GithubStrategy::STABLE;
}
/** @var GithubStrategy $strategy */
$strategy = $updater->getStrategy();
$strategy->setCurrentLocalVersion($this->getApplication()->getVersion());
$strategy->setStability($stability);
if ($input->getOption('check')) {
$result = $updater->hasUpdate();
if ($result) {
$output->writeln(sprintf(
'The %s build available remotely is: %s',
$strategy->getStability() === GithubStrategy::ANY ? 'latest' : 'current ' . $strategy->getStability(),
$updater->getNewVersion()
));
} elseif (false === $updater->getNewVersion()) {
$output->writeln('There are no new builds available.');
} else {
$output->writeln(sprintf('You have the current %s build installed.', $strategy->getStability()));
}
} elseif ($input->getOption('rollback')) {
$result = $updater->rollback();
$result ? $output->writeln('Success!') : $output->writeln('Failure!');
} else {
$result = $updater->update();
if ($result) {
$io->success(
sprintf(
'Your %s has been updated from "%s" to "%s".',
$this->getLocalPharName(),
$updater->getOldVersion(),
$updater->getNewVersion()
)
);
} else {
$io->success(sprintf('Your %s is already up to date.', $this->getLocalPharName()));
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"updater",
"=",
"new",
"Updater",
"(",
"null",
",",
"false",
",",
"Updater",
"::",
"STRATEGY_GITHUB",
")",
";",
"/** @var GithubStrat... | Execute
@param InputInterface $input
@param OutputInterface $output | [
"Execute"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Command/SelfUpdateCommand.php#L65-L116 |
TYPO3/Surf | src/Application/TYPO3/CMS.php | CMS.registerTasks | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
parent::registerTasks($workflow, $deployment);
if ($deployment->hasOption('initialDeployment') && $deployment->getOption('initialDeployment') === true) {
$workflow->addTask(DumpDatabaseTask::class, 'initialize', $this);
$workflow->addTask(RsyncFoldersTask::class, 'initialize', $this);
}
$workflow
->afterStage('transfer', CreatePackageStatesTask::class, $this)
->afterStage(
'update',
[
SymlinkDataTask::class,
CopyConfigurationTask::class
],
$this
)
->afterStage('switch', FlushCachesTask::class, $this)
->addTask(SetUpExtensionsTask::class, 'migrate', $this);
} | php | public function registerTasks(Workflow $workflow, Deployment $deployment)
{
parent::registerTasks($workflow, $deployment);
if ($deployment->hasOption('initialDeployment') && $deployment->getOption('initialDeployment') === true) {
$workflow->addTask(DumpDatabaseTask::class, 'initialize', $this);
$workflow->addTask(RsyncFoldersTask::class, 'initialize', $this);
}
$workflow
->afterStage('transfer', CreatePackageStatesTask::class, $this)
->afterStage(
'update',
[
SymlinkDataTask::class,
CopyConfigurationTask::class
],
$this
)
->afterStage('switch', FlushCachesTask::class, $this)
->addTask(SetUpExtensionsTask::class, 'migrate', $this);
} | [
"public",
"function",
"registerTasks",
"(",
"Workflow",
"$",
"workflow",
",",
"Deployment",
"$",
"deployment",
")",
"{",
"parent",
"::",
"registerTasks",
"(",
"$",
"workflow",
",",
"$",
"deployment",
")",
";",
"if",
"(",
"$",
"deployment",
"->",
"hasOption",... | Register tasks for this application
@param Workflow $workflow
@param Deployment $deployment | [
"Register",
"tasks",
"for",
"this",
"application"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Application/TYPO3/CMS.php#L78-L98 |
TYPO3/Surf | src/Domain/Filesystem/Filesystem.php | Filesystem.get | public function get($filename, $includePath = false, $streamContext = null)
{
return file_get_contents($filename, $includePath, $streamContext);
} | php | public function get($filename, $includePath = false, $streamContext = null)
{
return file_get_contents($filename, $includePath, $streamContext);
} | [
"public",
"function",
"get",
"(",
"$",
"filename",
",",
"$",
"includePath",
"=",
"false",
",",
"$",
"streamContext",
"=",
"null",
")",
"{",
"return",
"file_get_contents",
"(",
"$",
"filename",
",",
"$",
"includePath",
",",
"$",
"streamContext",
")",
";",
... | @param string $filename
@param bool $includePath
@param resource|null $streamContext
@return false|string | [
"@param",
"string",
"$filename",
"@param",
"bool",
"$includePath",
"@param",
"resource|null",
"$streamContext"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Filesystem/Filesystem.php#L33-L36 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.executeCliCommand | protected function executeCliCommand(array $cliArguments, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$phpBinaryPathAndFilename = isset($options['phpBinaryPathAndFilename']) ? $options['phpBinaryPathAndFilename'] : 'php';
$commandPrefix = '';
if (isset($options['context'])) {
$commandPrefix = 'TYPO3_CONTEXT=' . escapeshellarg($options['context']) . ' ';
}
$commandPrefix .= $phpBinaryPathAndFilename . ' ';
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
return $this->shell->executeOrSimulate([
'cd ' . escapeshellarg($this->workingDirectory),
$commandPrefix . implode(' ', array_map('escapeshellarg', $cliArguments))
], $this->targetNode, $deployment);
} | php | protected function executeCliCommand(array $cliArguments, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$phpBinaryPathAndFilename = isset($options['phpBinaryPathAndFilename']) ? $options['phpBinaryPathAndFilename'] : 'php';
$commandPrefix = '';
if (isset($options['context'])) {
$commandPrefix = 'TYPO3_CONTEXT=' . escapeshellarg($options['context']) . ' ';
}
$commandPrefix .= $phpBinaryPathAndFilename . ' ';
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
return $this->shell->executeOrSimulate([
'cd ' . escapeshellarg($this->workingDirectory),
$commandPrefix . implode(' ', array_map('escapeshellarg', $cliArguments))
], $this->targetNode, $deployment);
} | [
"protected",
"function",
"executeCliCommand",
"(",
"array",
"$",
"cliArguments",
",",
"Node",
"$",
"node",
",",
"CMS",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"de... | Execute this task
@param array $cliArguments
@param \TYPO3\Surf\Domain\Model\Node $node
@param CMS $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@return bool|mixed | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L53-L69 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.determineWorkingDirectoryAndTargetNode | protected function determineWorkingDirectoryAndTargetNode(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($this->workingDirectory, $this->targetNode)) {
if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
$this->workingDirectory = $deployment->getWorkspacePath($application);
$node = $deployment->getNode('localhost');
} else {
$this->workingDirectory = $deployment->getApplicationReleasePath($application);
}
$this->targetNode = $node;
}
} | php | protected function determineWorkingDirectoryAndTargetNode(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($this->workingDirectory, $this->targetNode)) {
if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
$this->workingDirectory = $deployment->getWorkspacePath($application);
$node = $deployment->getNode('localhost');
} else {
$this->workingDirectory = $deployment->getApplicationReleasePath($application);
}
$this->targetNode = $node;
}
} | [
"protected",
"function",
"determineWorkingDirectoryAndTargetNode",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$... | Determines the path to the working directory and the target node by given options
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Determines",
"the",
"path",
"to",
"the",
"working",
"directory",
"and",
"the",
"target",
"node",
"by",
"given",
"options"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L92-L103 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.packageExists | protected function packageExists($packageKey, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$webDirectory = isset($options['webDirectory']) ? trim($options['webDirectory'], '\\/') : '';
return $this->directoryExists($webDirectory . '/typo3conf/ext/' . $packageKey, $node, $application, $deployment, $options);
} | php | protected function packageExists($packageKey, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$webDirectory = isset($options['webDirectory']) ? trim($options['webDirectory'], '\\/') : '';
return $this->directoryExists($webDirectory . '/typo3conf/ext/' . $packageKey, $node, $application, $deployment, $options);
} | [
"protected",
"function",
"packageExists",
"(",
"$",
"packageKey",
",",
"Node",
"$",
"node",
",",
"CMS",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"webDirectory",
"=",
"isset",
"(... | Checks if a package exists in the packages directory
@param string $packageKey
@param Node $node
@param CMS $application
@param Deployment $deployment
@param array $options
@return bool | [
"Checks",
"if",
"a",
"package",
"exists",
"in",
"the",
"packages",
"directory"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L152-L156 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.directoryExists | protected function directoryExists($directory, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$directory = Files::concatenatePaths([$this->workingDirectory, $directory]);
return $this->shell->executeOrSimulate('test -d ' . escapeshellarg($directory), $this->targetNode, $deployment, true) === false ? false : true;
} | php | protected function directoryExists($directory, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$directory = Files::concatenatePaths([$this->workingDirectory, $directory]);
return $this->shell->executeOrSimulate('test -d ' . escapeshellarg($directory), $this->targetNode, $deployment, true) === false ? false : true;
} | [
"protected",
"function",
"directoryExists",
"(",
"$",
"directory",
",",
"Node",
"$",
"node",
",",
"CMS",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"determineWorkingDi... | Checks if a given directory exists.
@param string $directory
@param Node $node
@param CMS $application
@param Deployment $deployment
@param array $options
@return bool | [
"Checks",
"if",
"a",
"given",
"directory",
"exists",
"."
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L168-L173 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.fileExists | protected function fileExists($pathAndFileName, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$pathAndFileName = $this->workingDirectory . '/' . $pathAndFileName;
return $this->shell->executeOrSimulate('test -f ' . escapeshellarg($pathAndFileName), $this->targetNode, $deployment, true) === false ? false : true;
} | php | protected function fileExists($pathAndFileName, Node $node, CMS $application, Deployment $deployment, array $options = [])
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$pathAndFileName = $this->workingDirectory . '/' . $pathAndFileName;
return $this->shell->executeOrSimulate('test -f ' . escapeshellarg($pathAndFileName), $this->targetNode, $deployment, true) === false ? false : true;
} | [
"protected",
"function",
"fileExists",
"(",
"$",
"pathAndFileName",
",",
"Node",
"$",
"node",
",",
"CMS",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"determineWorkingD... | Checks if a given file exists.
@param string $pathAndFileName
@param Node $node
@param CMS $application
@param Deployment $deployment
@param array $options
@return bool | [
"Checks",
"if",
"a",
"given",
"file",
"exists",
"."
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L185-L190 |
TYPO3/Surf | src/Task/TYPO3/CMS/AbstractCliTask.php | AbstractCliTask.getCliDispatchScriptFileName | protected function getCliDispatchScriptFileName(array $options = [])
{
$webDirectory = isset($options['webDirectory']) ? trim($options['webDirectory'], '\\/') : '';
return $webDirectory !== '' ? sprintf('%s/typo3/cli_dispatch.phpsh', $webDirectory) : 'typo3/cli_dispatch.phpsh';
} | php | protected function getCliDispatchScriptFileName(array $options = [])
{
$webDirectory = isset($options['webDirectory']) ? trim($options['webDirectory'], '\\/') : '';
return $webDirectory !== '' ? sprintf('%s/typo3/cli_dispatch.phpsh', $webDirectory) : 'typo3/cli_dispatch.phpsh';
} | [
"protected",
"function",
"getCliDispatchScriptFileName",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"webDirectory",
"=",
"isset",
"(",
"$",
"options",
"[",
"'webDirectory'",
"]",
")",
"?",
"trim",
"(",
"$",
"options",
"[",
"'webDirectory'",
... | @param array $options
@return string | [
"@param",
"array",
"$options"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/TYPO3/CMS/AbstractCliTask.php#L211-L215 |
TYPO3/Surf | src/Domain/Model/RollbackWorkflow.php | RollbackWorkflow.run | public function run(Deployment $deployment)
{
parent::run($deployment);
$applications = $deployment->getApplications();
if (count($applications) === 0) {
throw InvalidConfigurationException::createNoApplicationConfigured();
}
$nodes = $deployment->getNodes();
if (count($nodes) === 0) {
throw InvalidConfigurationException::createNoNodesConfigured();
}
$this->configureRollbackTasks($deployment);
foreach ($this->stages as $stage) {
$deployment->getLogger()->notice('Stage ' . $stage);
foreach ($nodes as $node) {
$deployment->getLogger()->debug('Node ' . $node->getName());
foreach ($applications as $application) {
if (! $application->hasNode($node)) {
continue;
}
$deployment->getLogger()->debug('Application ' . $application->getName());
try {
$this->executeStage($stage, $node, $application, $deployment);
} catch (Exception $exception) {
return;
}
}
}
}
if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) {
$deployment->setStatus(Deployment::STATUS_SUCCESS);
}
} | php | public function run(Deployment $deployment)
{
parent::run($deployment);
$applications = $deployment->getApplications();
if (count($applications) === 0) {
throw InvalidConfigurationException::createNoApplicationConfigured();
}
$nodes = $deployment->getNodes();
if (count($nodes) === 0) {
throw InvalidConfigurationException::createNoNodesConfigured();
}
$this->configureRollbackTasks($deployment);
foreach ($this->stages as $stage) {
$deployment->getLogger()->notice('Stage ' . $stage);
foreach ($nodes as $node) {
$deployment->getLogger()->debug('Node ' . $node->getName());
foreach ($applications as $application) {
if (! $application->hasNode($node)) {
continue;
}
$deployment->getLogger()->debug('Application ' . $application->getName());
try {
$this->executeStage($stage, $node, $application, $deployment);
} catch (Exception $exception) {
return;
}
}
}
}
if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) {
$deployment->setStatus(Deployment::STATUS_SUCCESS);
}
} | [
"public",
"function",
"run",
"(",
"Deployment",
"$",
"deployment",
")",
"{",
"parent",
"::",
"run",
"(",
"$",
"deployment",
")",
";",
"$",
"applications",
"=",
"$",
"deployment",
"->",
"getApplications",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ap... | @param Deployment $deployment
@throws \TYPO3\Surf\Exception | [
"@param",
"Deployment",
"$deployment"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Domain/Model/RollbackWorkflow.php#L33-L71 |
TYPO3/Surf | src/Task/SymlinkReleaseTask.php | SymlinkReleaseTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$releaseIdentifier = $deployment->getReleaseIdentifier();
$releasesPath = $application->getReleasesPath();
$this->shell->executeOrSimulate('cd ' . $releasesPath . ' && rm -f ./previous && if [ -e ./current ]; then mv ./current ./previous; fi && ln -s ./' . $releaseIdentifier . ' ./current && rm -f ./next', $node, $deployment);
$deployment->getLogger()->notice('<success>Node "' . $node->getName() . '" ' . ($deployment->isDryRun() ? 'would be' : 'is') . ' live!</success>');
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$releaseIdentifier = $deployment->getReleaseIdentifier();
$releasesPath = $application->getReleasesPath();
$this->shell->executeOrSimulate('cd ' . $releasesPath . ' && rm -f ./previous && if [ -e ./current ]; then mv ./current ./previous; fi && ln -s ./' . $releaseIdentifier . ' ./current && rm -f ./next', $node, $deployment);
$deployment->getLogger()->notice('<success>Node "' . $node->getName() . '" ' . ($deployment->isDryRun() ? 'would be' : 'is') . ' live!</success>');
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"releaseIdentifier",
"=",
"$",
"deployment",
"->",
"getRele... | Executes this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/SymlinkReleaseTask.php#L35-L41 |
TYPO3/Surf | src/Task/DumpDatabaseTask.php | DumpDatabaseTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$dumpCommand = new Process([
'mysqldump',
'-h',
$options['sourceHost'],
'-u',
$options['sourceUser'],
'-p' . $options['sourcePassword'],
$options['sourceDatabase']
]);
$mysqlCommand = new Process([
'mysql',
'-h',
$options['targetHost'],
'-u',
$options['targetUser'],
'-p' . $options['targetPassword'],
$options['targetDatabase']
]);
$sshCommand = ['ssh'];
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$sshCommand[] = $username . $hostname;
if ($node->hasOption('port')) {
$sshCommand[] = '-P';
$sshCommand[] = $node->getOption('port');
}
$sshCommand[] = $mysqlCommand->getCommandLine();
$sshCommand = new Process($sshCommand);
$command = $dumpCommand->getCommandLine()
. ' | '
. $sshCommand->getCommandLine();
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($command, $localhost, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$options = $this->configureOptions($options);
$dumpCommand = new Process([
'mysqldump',
'-h',
$options['sourceHost'],
'-u',
$options['sourceUser'],
'-p' . $options['sourcePassword'],
$options['sourceDatabase']
]);
$mysqlCommand = new Process([
'mysql',
'-h',
$options['targetHost'],
'-u',
$options['targetUser'],
'-p' . $options['targetPassword'],
$options['targetDatabase']
]);
$sshCommand = ['ssh'];
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$sshCommand[] = $username . $hostname;
if ($node->hasOption('port')) {
$sshCommand[] = '-P';
$sshCommand[] = $node->getOption('port');
}
$sshCommand[] = $mysqlCommand->getCommandLine();
$sshCommand = new Process($sshCommand);
$command = $dumpCommand->getCommandLine()
. ' | '
. $sshCommand->getCommandLine();
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($command, $localhost, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"configureOptions",
"(... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/DumpDatabaseTask.php#L61-L105 |
TYPO3/Surf | src/Task/Neos/Flow/SymlinkConfigurationTask.php | SymlinkConfigurationTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$targetReleasePath = $deployment->getApplicationReleasePath($application);
if ($application instanceof Flow) {
$context = $application->getContext();
} else {
$context = 'Production';
}
$commands = [
"cd {$targetReleasePath}/Configuration",
"if [ -d {$context} ]; then rm -Rf {$context}; fi",
"mkdir -p ../../../shared/Configuration/{$context}"
];
if (strpos($context, '/') !== false) {
$baseContext = dirname($context);
$commands[] = "mkdir -p {$baseContext}";
$commands[] = "ln -snf ../../../../shared/Configuration/{$context} {$context}";
} else {
$commands[] = "ln -snf ../../../shared/Configuration/{$context} {$context}";
}
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$targetReleasePath = $deployment->getApplicationReleasePath($application);
if ($application instanceof Flow) {
$context = $application->getContext();
} else {
$context = 'Production';
}
$commands = [
"cd {$targetReleasePath}/Configuration",
"if [ -d {$context} ]; then rm -Rf {$context}; fi",
"mkdir -p ../../../shared/Configuration/{$context}"
];
if (strpos($context, '/') !== false) {
$baseContext = dirname($context);
$commands[] = "mkdir -p {$baseContext}";
$commands[] = "ln -snf ../../../../shared/Configuration/{$context} {$context}";
} else {
$commands[] = "ln -snf ../../../shared/Configuration/{$context} {$context}";
}
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"targetReleasePath",
"=",
"$",
"deployment",
"->",
"getAppl... | Executes this task
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options | [
"Executes",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/Neos/Flow/SymlinkConfigurationTask.php#L41-L66 |
TYPO3/Surf | src/Task/RsyncFoldersTask.php | RsyncFoldersTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['folders'])) {
return;
}
$folders = $options['folders'];
if (!is_array($folders)) {
$folders = [$folders];
}
$replacePaths = [
'{deploymentPath}' => escapeshellarg($application->getDeploymentPath()),
'{sharedPath}' => escapeshellarg($application->getSharedPath()),
'{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)),
'{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'),
'{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous')
];
$commands = [];
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$port = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : '';
foreach ($folders as $folderPair) {
if (!is_array($folderPair) || count($folderPair) !== 2) {
throw new InvalidConfigurationException('Each rsync folder definition must be an array of exactly two folders', 1405599056);
}
$sourceFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[0]), '/') . '/';
$targetFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[1]), '/') . '/';
$commands[] = "rsync -avz --delete -e ssh {$sourceFolder} {$username}{$hostname}:{$targetFolder}";
}
$ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true;
$logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false);
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($commands, $localhost, $deployment, $ignoreErrors, $logOutput);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (!isset($options['folders'])) {
return;
}
$folders = $options['folders'];
if (!is_array($folders)) {
$folders = [$folders];
}
$replacePaths = [
'{deploymentPath}' => escapeshellarg($application->getDeploymentPath()),
'{sharedPath}' => escapeshellarg($application->getSharedPath()),
'{releasePath}' => escapeshellarg($deployment->getApplicationReleasePath($application)),
'{currentPath}' => escapeshellarg($application->getReleasesPath() . '/current'),
'{previousPath}' => escapeshellarg($application->getReleasesPath() . '/previous')
];
$commands = [];
$username = isset($options['username']) ? $options['username'] . '@' : '';
$hostname = $node->getHostname();
$port = $node->hasOption('port') ? '-P ' . escapeshellarg($node->getOption('port')) : '';
foreach ($folders as $folderPair) {
if (!is_array($folderPair) || count($folderPair) !== 2) {
throw new InvalidConfigurationException('Each rsync folder definition must be an array of exactly two folders', 1405599056);
}
$sourceFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[0]), '/') . '/';
$targetFolder = rtrim(str_replace(array_keys($replacePaths), $replacePaths, $folderPair[1]), '/') . '/';
$commands[] = "rsync -avz --delete -e ssh {$sourceFolder} {$username}{$hostname}:{$targetFolder}";
}
$ignoreErrors = isset($options['ignoreErrors']) && $options['ignoreErrors'] === true;
$logOutput = !(isset($options['logOutput']) && $options['logOutput'] === false);
$localhost = new Node('localhost');
$localhost->onLocalhost();
$this->shell->executeOrSimulate($commands, $localhost, $deployment, $ignoreErrors, $logOutput);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'folders... | Execute this task
@param \TYPO3\Surf\Domain\Model\Node $node
@param \TYPO3\Surf\Domain\Model\Application $application
@param \TYPO3\Surf\Domain\Model\Deployment $deployment
@param array $options
@throws \TYPO3\Surf\Exception\InvalidConfigurationException | [
"Execute",
"this",
"task"
] | train | https://github.com/TYPO3/Surf/blob/0292b88a0cd21dd96174f3306deb98952a0c03a7/src/Task/RsyncFoldersTask.php#L54-L93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.