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
500182
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
            );
        }
    }
1083186
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);
                    }
                }
            }
        }
    }
636487
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $releasePath = $deployment->getApplicationReleasePath($application);
        $this->shell->execute('rm -Rf ' . $releasePath, $node, $deployment, true);
    }
607268
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;
        }
    }
234966
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $replacePaths = [];
        $replacePaths['{workspacePath}'] = escapeshellarg($deployment->getWorkspacePath($application));

        if (!isset($options['command'])) {
            throw new InvalidConfigurationException('Missing "command" option for LocalShellTask', 1311168045);
        }
        $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);

        $localhost = new Node('localhost');
        $localhost->onLocalhost();

        $this->shell->executeOrSimulate($command, $localhost, $deployment, $ignoreErrors, $logOutput);
    }
485293
public function process(NodeType $nodeType, array &$configuration, array $options)
    {
        $pluginViewDefinitions = $this->pluginService->getPluginViewDefinitionsByPluginNodeType($nodeType);
        if ($pluginViewDefinitions === []) {
            return;
        }
        $configuration['ui']['inspector']['groups']['pluginViews'] = [
            'position' => '9999',
            'label' => 'Plugin Views'
        ];
        $configuration['properties']['views'] = [
            'type' => 'string',
            'ui' => [
                'inspector' => [
                    'group' => 'pluginViews',
                    'position' => '20',
                    'editor' => 'Neos.Neos/Inspector/Editors/PluginViewsEditor'
                ]
            ]
        ];
    }
167983
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);
    }
701932
public function handle(NodeInterface $node, array $data)
    {
        if ($node->getNodeType()->hasConfiguration('options.template')) {
            $templateConfiguration = $node->getNodeType()->getConfiguration('options.template');
        } else {
            return;
        }

        $propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();

        $subPropertyMappingConfiguration = $propertyMappingConfiguration;
        for ($i = 0; $i < 10; $i++) {
            $subPropertyMappingConfiguration = $subPropertyMappingConfiguration
                ->forProperty('childNodes.*')
                ->allowAllProperties();
        }

        /** @var Template $template */
        $template = $this->propertyMapper->convert($templateConfiguration, Template::class,
            $propertyMappingConfiguration);

        $context = [
            'data' => $data,
            'triggeringNode' => $node,
        ];
        $template->apply($node, $context);
        return;
    }
1309216
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;
    }
1248917
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $localPackagePath = $deployment->getWorkspacePath($application);
        $releasePath = $deployment->getApplicationReleasePath($application);

        $remotePath = Files::concatenatePaths([$application->getDeploymentPath(), 'cache/transfer']);
        // make sure there is a remote .cache folder
        $command = 'mkdir -p ' . $remotePath;
        $this->shell->executeOrSimulate($command, $node, $deployment);

        $username = $node->hasOption('username') ? $node->getOption('username') . '@' : '';
        $hostname = $node->getHostname();
        $noPubkeyAuthentication = $node->hasOption('password') ? ' -o PubkeyAuthentication=no' : '';
        $port = $node->hasOption('port') ? ' -p ' . escapeshellarg($node->getOption('port')) : '';
        $key = $node->hasOption('privateKeyFile') ? ' -i ' . escapeshellarg($node->getOption('privateKeyFile')) : '';
        $quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q';
        $rshFlag = ($node->isLocalhost() ? '' : '--rsh="ssh' . $noPubkeyAuthentication . $port . $key . '" ');

        $rsyncExcludes = isset($options['rsyncExcludes']) ? $options['rsyncExcludes'] : ['.git'];
        $excludeFlags = $this->getExcludeFlags($rsyncExcludes);

        $rsyncFlags = (isset($options['rsyncFlags']) ? $options['rsyncFlags'] : '--recursive --times --perms --links --delete --delete-excluded') . $excludeFlags;

        $destinationArgument = ($node->isLocalhost() ? $remotePath : "{$username}{$hostname}:{$remotePath}");

        $command = "rsync {$quietFlag} --compress {$rshFlag} {$rsyncFlags} " . escapeshellarg($localPackagePath . '/.') . ' ' . escapeshellarg($destinationArgument);

        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);
            }
            $command = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $command);
        }

        $localhost = new Node('localhost');
        $localhost->onLocalhost();
        $this->shell->executeOrSimulate($command, $localhost, $deployment);

        if (isset($passwordSshLoginScriptPathAndFilename) && Phar::running() !== '') {
            unlink($passwordSshLoginScriptPathAndFilename);
        }

        $command = strtr("cp -RPp $remotePath/. $releasePath", "\t\n", '  ');
        // TODO Copy revision file (if it exists) for application to deployment path with release identifier

        $this->shell->executeOrSimulate($command, $node, $deployment);
    }
392365
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $commands = [
            'if [ -d '.escapeshellarg($deployment->getApplicationReleasePath($application)).' ]; then '.
            'cd '.escapeshellarg($deployment->getApplicationReleasePath($application)).'; '.
            'if [ -d \'.git\' ] && hash git 2>/dev/null; then '.
            'CHANGES=$( git status --porcelain ); '.
            'if [ "$CHANGES" ]; then '.
            'echo \'Detected changes in the target directory. Deployments are just possible to clean targets!\' 1>&2; '.
            'echo $CHANGES 1>&2; '.
            'exit 1; '.
            'fi; '.
            'fi; '.
            'fi;',
        ];

        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
960682
public function execute($options = [])
    {
        if (! is_array($options) && ! $options instanceof Option) throw new \InvalidArgumentException('invalid option');
        if (! $this->do) throw new \Samurai\Samurai\Exception\LogicException('preset task something do.');

        $option = $this->getOption($this->do);
        if (is_array($options)) {
            $option->importFromArray($options);
        } else {
            $option->import($options);
        }
        $option->validate();
        $this->{$this->do . 'Task'}($option);
    }
240219
public function run(array $options): void
    {
        // run once
        $this->___checkRun(new AppException("You cannot call App::run() anymore, it's already ".
                "called in skeleton/pub/index.php once"));

        // apply user options (@see skeleton/pub/index.php)
        if (isset($options['env'])) $this->env = $options['env'];
        if (isset($options['root'])) $this->root = $options['root'];
        if (isset($options['config'])) $this->applyConfig($options['config']);

        // check env
        if (empty($this->env)) {
            throw new AppException('Application env is not defined');
        }

        // security & performans checks
        $halt = $this->haltCheck();
        if ($halt != null) {
            $this->halt($halt[1], $halt[0]);
        }

        $this->applyDefaults();

        $this->request = new Request($this);
        $this->response = new Response($this);

        // @override
        set_global('app', $this);

        // create service
        $service = ServiceFactory::create($this);
        if ($service == null) {
            throw new AppException('Could not create service');
        }

        $this->startOutputBuffer();

        // here!!
        $this->events->fire('service.beforeRun');
        $output = $service->run();
        $this->events->fire('service.afterRun');

        $this->endOutputBuffer($output);
    }
178996
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $this->executeOrSimulate($node, $application, $deployment, $options);
    }
386376
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);
    }
617116
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (empty($options['branch']) || !empty($options['tag'])) {
            return;
        }

        $quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q';

        $commands = [];
        $commands[] = 'cd '.escapeshellarg($deployment->getApplicationReleasePath($application));
        $commands[] = 'if [ -d \'.git\' ] && hash git 2>/dev/null; then '.
            'git branch -f '.escapeshellarg($options['branch']).' deploy && '.
            'git checkout '.$quietFlag.' '.escapeshellarg($options['branch']).' && '.
            'git branch -D deploy; '.
            'fi;';

        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
1334005
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);
    }