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
15657
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);
    }
959552
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);
        }
    }
427555
public Optional<Deployment> create(long applicationId, Deployment deployment)
    {
        return HTTP.POST(String.format("/v2/applications/%d/deployments.json", applicationId), deployment, DEPLOYMENT);
    }
524393
protected function buildCommands(
        Deployment $deployment,
        Application $application,
        $options = []
    ) {
        $commands = [];
        $command = '';
        $commandProvider = $this->commandProviderService->getDetectedCommandProvider($deployment, $application);
        switch ($commandProvider) {
            case CommandProviderService::COMMAND_PROVIDER_COREAPI:
                $command = $this->buildCoreapiCommand($deployment, $application, $options);
                break;
            case CommandProviderService::COMMAND_PROVIDER_TYPO3_CONSOLE:
                $command = $this->buildTypo3ConsoleCommand($options);
                break;
            default:
                // Do nothing
        }

        if ($command === '') {
            throw new CommandProviderException('The used Provider (' . $commandProvider . ') has no implementation for this task.', 1494672441);
        }

        $commands[] = 'cd ' . escapeshellarg($deployment->getApplicationReleasePath($application));
        if (!empty($options['context'])) {
            $commands[] = 'export TYPO3_CONTEXT=' . escapeshellarg($options['context']);
        }
        $commands[] = $command;

        return $commands;
    }
190649
public static function deploy($options = array()) {
		$result = array(
			'success' => false,
			'error' => array()
		);
		$options['mode'] = $options['mode'] ?? 'production';
		do {
			$temp = rtrim(getcwd(), '/');
			$deployed_dir = $temp . '/../../deployed';
			$code_dir = $temp . '/../../application';
			// for development we handle deployment differently, just symlink to the code
			$data = \System\Dependencies::processDepsAll(['mode' => 'test']);
			if ($options['mode'] == 'development') {
				\Helper\File::delete($deployed_dir);
				symlink($code_dir, $deployed_dir);
				// process components
				if (!empty($data['data']['components'])) {
					// create directories
					\Helper\File::mkdir($code_dir . '/application/Components');
					\Helper\File::mkdir($code_dir . '/application/../public_html/components');
					foreach ($data['data']['components'] as $k => $v) {
						\Helper\File::delete($code_dir . '/application/Components/' . $k . '/');
						\Helper\File::delete($code_dir . '/application/../public_html/components/' . $k . '/');
						\Helper\File::mkdir($code_dir . '/application/Components/' . $k . '/');
						\Helper\File::mkdir($code_dir . '/application/../public_html/components/' . $k . '/');
						foreach (['application', 'public_html'] as $v2) {
							$files = \Helper\File::iterate($v . $v2, ['recursive' => true]);
							foreach ($files as $v3) {
								$temp1 = explode('/' . $v2 . '/', $v3);
								if ($v2 == 'application') {
									\Helper\File::copy($code_dir . '/' . $v2 . '/' . $v3, $code_dir . '/application/Components/' . $k . '/' . $temp1[1]);
								} else {
									\Helper\File::copy($code_dir . '/' . $v2 . '/' . $v3, $code_dir . '/application/../public_html/components/' . $k . '/' . $temp1[1]);
								}
							}
						}
					}
				}
				$result['success'] = true;
				break;
			}
			// determine and create directories
			$all_deps_dir = $temp . '/../../deployments';
			$time = time();
			$dep_id = 'build.' . $time . '.' . rand(100, 999);
			$dep_dir = $all_deps_dir . '/' . $dep_id;
			$media_dir = $dep_dir . '/public_html/numbers';
			if (\Helper\File::mkdir($dep_dir, 0777) === false) {
				$result['error'][] = ' - unable to create new deployment directory ' . $dep_dir;
				break;
			}
			// copying code repository
			if (!\Helper\File::copy($code_dir, $dep_dir, ['skip_directories' => ['.numbers', '.git'], 'skip_files' => ['Makefile', 'Make.cmd', '.gitignore']])) {
				$result['error'][] = ' - unable to copy code!';
				break;
			}
			// copy components
			\Helper\File::mkdir($dep_dir . '/application/Components');
			\Helper\File::mkdir($dep_dir . '/application/../public_html/components');
			foreach ($data['data']['components'] as $k => $v) {
				\Helper\File::mkdir($code_dir . '/application/Components/' . $k . '/');
				\Helper\File::mkdir($code_dir . '/application/../public_html/components/' . $k . '/');
				foreach (['application', 'public_html'] as $v2) {
					$files = \Helper\File::iterate($v . $v2, ['recursive' => true]);
					foreach ($files as $v3) {
						$temp1 = explode('/' . $v2 . '/', $v3);
						if ($v2 == 'application') {
							\Helper\File::copy($code_dir . '/' . $v2 . '/' . $v3, $dep_dir . '/application/Components/' . $k . '/' . $temp1[1]);
						} else {
							\Helper\File::copy($code_dir . '/' . $v2 . '/' . $v3, $dep_dir . '/application/../public_html/components/' . $k . '/' . $temp1[1]);
						}
					}
				}
			}
			// js, css, scss, files here
			$files_to_copy = [];
			$process_extensions = ['js', 'css'];
			if (\Application::get('dep.submodule.numbers.frontend.media.scss')) {
				$process_extensions[] = 'scss';
			}
			$iterator = new \RecursiveIteratorIterator(
				new \RecursiveDirectoryIterator($dep_dir)
			);
			foreach ($iterator as $filename => $cur) {
				$extension = $cur->getExtension();
				if (in_array($extension, $process_extensions)) {
					$parent_dir_name = basename(dirname($filename));
					if (strpos($filename, '/controller/') !== false) {
						$key = str_replace($dep_dir, '', $filename);
						$files_to_copy[$extension][$key] = $filename;
					}
				}
			}
			// create media directory
			$media_dir_full = $media_dir . '/media_generated';
			if (!empty($files_to_copy['js']) || !empty($files_to_copy['css']) || !empty($files_to_copy['scss'])) {
				\Helper\File::mkdir($media_dir_full, 0777);
			}
			// coping javescript files
			if (!empty($files_to_copy['js'])) {
				foreach ($files_to_copy['js'] as $k => $v) {
					$newname = ltrim(str_replace('/', '_', $k), '_');
					\Helper\File::copy($v, "$media_dir_full/$newname");
				}
			}
			// coping css files
			if (!empty($files_to_copy['css'])) {
				foreach ($files_to_copy['css'] as $k => $v) {
					$newname = ltrim(str_replace('/', '_', $k), '_');
					\Helper\File::copy($v, "$media_dir_full/$newname");
				}
			}
			// coping scss files
			if (!empty($files_to_copy['scss'])) {
				foreach ($files_to_copy['scss'] as $k => $v) {
					$newname = ltrim(str_replace('/', '_', $k), '_');
					// processing scss files
					$temp = \Numbers\Frontend\Media\SCSS\Base::serve($v);
					if ($temp['success']) {
						file_put_contents("{$media_dir_full}/{$newname}.css", $temp['data']);
					}
				}
			}
			// we need to load media from dependencies
			$result = \System\Dependencies::processDepsAll(['mode' => 'test']);
			// copying js, css & scss files
			$media_dir_submodule = $dep_dir . '/public_html';
			if (!empty($result['data']['media'])) {
				\Helper\File::mkdir($media_dir_submodule . '/numbers/media_submodules', 0777);
				foreach ($result['data']['media'] as $k => $v) {
					if (!in_array($k, ['js', 'css', 'scss', 'other'])) {
						continue;
					}
					foreach ($v as $k2 => $v2) {
						if (!isset($v2['origin']) || !isset($v2['destination'])) {
							continue;
						}
						// js and css we just copy
						$copy_from = $dep_dir . '/libraries/vendor' . $v2['origin'];
						$copy_to = $media_dir_submodule . $v2['destination'];
						if ($k == 'js' || $k == 'css' || $k == 'other') {
							\Helper\File::copy($copy_from, $copy_to);
						} else if ($k == 'scss' && Application::get('dep.submodule.numbers.frontend.media.scss')) {
							// todo
							// we need to process scss
							$temp = numbers_frontend_media_scss_base::serve($copy_from);
							if ($temp['success']) {
								file_put_contents($copy_to, $temp['data']);
							}
						}
					}
				}
			}
			// setting permissions
			\Helper\File::chmod($dep_dir, 0777);
			// now we need to create a symlink
			if (file_exists($deployed_dir)) {
				\Helper\File::delete($deployed_dir);
			}
			symlink($dep_dir, $deployed_dir);
			// cleanup older deployments,older than 5 days
			$iterator = new \DirectoryIterator($all_deps_dir);
			foreach ($iterator as $filedir => $fileinfo) {
				if ($fileinfo->isDir()) {
					$filename = $fileinfo->getFilename();
					// sanity check
					if ($filename == $dep_id) continue;
					if (strpos($filename, 'build.') === 0) {
						if ($time - $fileinfo->getMTime() > 259200) {
							$temp = $fileinfo->getPathname();
							\Helper\File::delete($temp);
						}
					}
				}
			}
			$result['success'] = true;
		} while(0);
		return $result;
	}
402213
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;
    }
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);
    }
799042
public static function run($version, $deployFile)
    {
        // Init Deployer
        $console = new Application('Deployer', $version);
        $input = new ArgvInput();
        $output = new ConsoleOutput();
        $deployer = new self($console);

        // Pretty-print uncaught exceptions in symfony-console
        set_exception_handler(function ($e) use ($input, $output, $deployer) {
            $io = new SymfonyStyle($input, $output);
            $io->block($e->getMessage(), get_class($e), 'fg=white;bg=red', ' ', true);
            $io->block($e->getTraceAsString());

            $deployer->logger->log('['. get_class($e) .'] '. $e->getMessage());
            $deployer->logger->log($e->getTraceAsString());
            exit(1);
        });

        // Require deploy.php file
        if (is_readable($deployFile)) {
            // Prevent variable leak into deploy.php file
            call_user_func(function () use ($deployFile) {
                require $deployFile;
            });
        }

        // Run Deployer
        $deployer->init();
        $console->run($input, $output);
    }
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);
    }
279038
private function executeAction($id, array $options)
    {
        $action = $this->adapter->post(sprintf('%s/floating_ips/%s/actions', $this->endpoint, $id), $options);

        $action = json_decode($action);

        return new ActionEntity($action->action);
    }
47195
public function afterSave($event, $entity, $options)
    {
        $fields = $this->getFieldList();
        $storedToSave = [];
        foreach ($fields as $field => $data) {
            if ($this->_ifUploaded($entity, $field)) {
                if ($this->_uploadFile($entity, $field)) {
                    if (!key_exists($field, $this->_savedFields)) {
                        $this->_savedFields[$field] = true;
                        $storedToSave[] = $this->_setUploadColumns($entity, $field);
                    }
                }
            }
        }
        foreach ($storedToSave as $toSave) {
            $event->subject()->save($toSave);
        }
        $this->_savedFields = [];
    }
1006757
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
            $gitRootPath = $deployment->getWorkspacePath($application);
        } else {
            $gitRootPath = $deployment->getApplicationReleasePath($application);
        }

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

        if (!empty($options['nodeName'])) {
            $node = $deployment->getNode($options['nodeName']);
            if ($node === null) {
                throw new InvalidConfigurationException(
                    sprintf('Node "%s" not found', $options['nodeName']),
                    1413298085
                );
            }
        }

        $commands = [
            'cd '.escapeshellarg($gitRootPath),
            'if [ -d \'.git\' ] && hash git 2>/dev/null; then '.
//				'git clean ' . $quietFlag . ' -d -ff && ' .
            'git checkout -- .; '.
            'fi;',
        ];

        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
900253
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $options = $this->configureOptions($options);

        if (empty($options['symlinks'])) {
            return;
        }

        $baseDirectory = $options['genericSymlinksBaseDir'] ?: $deployment->getApplicationReleasePath($application);

        $commands = [
            'cd ' . $baseDirectory,
        ];

        foreach ($options['symlinks'] as $linkPath => $sourcePath) {
            $commands[] = sprintf('ln -s %s %s', $sourcePath, $linkPath);
        }

        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
1059029
public function processNode(Parser $parser, $variable, $data, array $options)
    {
        $this->processAction($parser, $variable, $data, $options);

        return null;
    }
192354
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);
    }
1085654
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $unLockDeployment = new UnlockDeploymentTask();
        $unLockDeployment->setShellCommandService(new ShellCommandService());
        $unLockDeployment->execute($node, $application, $deployment, $options);
    }
1229502
public function execute(ResourceNode $resourceNode, string $actionName, array $options = [], array $content = null, array $files = null): Response
    {
        $resourceAction = $this->get($resourceNode, $actionName);
        $resource = $this->resourceManager->getResourceFromNode($resourceNode);

        /** @var ResourceActionEvent $event */
        $event = $this->dispatcher->dispatch(
            static::eventName($actionName, $resourceAction->getResourceType()),
            ResourceActionEvent::class,
            [$resource, $options, $content, $files, $resourceNode]
        );

        return $event->getResponse();
    }