Ejemplo n.º 1
0
    /**
     * Executes a composer install in the configured directory.
     *
     * @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
     */
    public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        if (empty($options['gruntRootPath'])) {
            throw new \TYPO3\Surf\Exception\InvalidConfigurationException('gruntRootPath option not specified for grunt build task.', 1432127041);
        }
        if (isset($options['nodeName'])) {
            $node = $deployment->getNode($options['nodeName']);
            if ($node === null) {
                throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1432127050);
            }
        }
        if (isset($options['forceLocalMode']) && $options['forceLocalMode']) {
            $node = $deployment->getNode('localhost');
        }
        $gruntRootPath = $this->replacePathPlaceholders($options['gruntRootPath'], $application, $deployment);
        $gruntRootPath = escapeshellarg($gruntRootPath);
        $exitCodeIfRootDoesNotExist = !empty($options['skipMissingDirectory']) ? 0 : 1;
        $command = '

			if [ ! -d ' . $gruntRootPath . ' ]; then
				echo "Grunt root path ' . $gruntRootPath . ' does not exist."
				exit ' . $exitCodeIfRootDoesNotExist . ';
			fi

			# Break on errors
			set -e

			cd ' . $gruntRootPath . '
			if [ -f package.json ]; then npm install; fi
			if [ -f bower.json ]; then bower install; fi
			if [ -f Gruntfile.js ]; then grunt; fi
		';
        $this->shell->executeOrSimulate($command, $node, $deployment);
    }
Ejemplo n.º 2
0
 /**
  * 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
  * @return void
  * @throws \TYPO3\Surf\Exception\InvalidConfigurationException
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (!isset($options['repositoryUrl'])) {
         throw new \TYPO3\Surf\Exception\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);
 }
 /**
  * @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
  * @return void
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if ($application->getOption('transferMethod') == 'rsync') {
         $path = $deployment->getWorkspacePath($application);
         $node = $deployment->getNode('localhost');
         $command = 'beard patch';
     } else {
         $patch = $deployment->getApplicationReleasePath($application);
         $command = $application->getOption('phpPath') . ' beard.phar patch';
     }
     $command = sprintf('cd %s && %s', escapeshellarg($path), $command);
     $this->shell->executeOrSimulate($command, $node, $deployment);
 }
Ejemplo n.º 4
0
 /**
  * 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
  * @return string
  */
 protected function determineWorkingDirectoryAndTargetNode(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (!isset($this->workingDirectory) || !isset($this->targetNode)) {
         if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
             $targetPath = $deployment->getWorkspacePath($application);
             $node = $deployment->getNode('localhost');
         } else {
             $targetPath = $deployment->getApplicationReleasePath($application);
         }
         $applicationRootDirectory = isset($options['applicationRootDirectory']) ? $options['applicationRootDirectory'] : '';
         $this->workingDirectory = $targetPath . '/' . $applicationRootDirectory;
         $this->targetNode = $node;
     }
 }
Ejemplo n.º 5
0
 /**
  * Executes this task
  *
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws InvalidConfigurationException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     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 = array('cd ' . escapeshellarg($gitRootPath), 'if [ -d \'.git\' ] && hash git 2>/dev/null; then ' . 'git checkout -- .; ' . 'fi;');
     $this->shell->executeOrSimulate($commands, $node, $deployment);
 }
Ejemplo n.º 6
0
 /**
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
         $composerRootPath = $deployment->getWorkspacePath($application);
     } else {
         $composerRootPath = $deployment->getApplicationReleasePath($application);
     }
     if (isset($options['nodeName'])) {
         $node = $deployment->getNode($options['nodeName']);
         if ($node === null) {
             throw new \TYPO3\Surf\Exception\InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1369759412);
         }
     }
     if ($this->composerManifestExists($composerRootPath, $node, $deployment)) {
         $command = $this->buildComposerInstallCommand($composerRootPath, $options);
         $this->shell->executeOrSimulate($command, $node, $deployment);
     }
 }
Ejemplo n.º 7
0
 /**
  * Executes this task
  *
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) {
         $rootPath = $deployment->getWorkspacePath($application);
     } else {
         $rootPath = $deployment->getApplicationReleasePath($application);
     }
     if (isset($options['relativeRootPath'])) {
         $rootPath .= $options['relativeRootPath'];
     }
     if (!empty($options['nodeName'])) {
         $node = $deployment->getNode($options['nodeName']);
         if ($node === NULL) {
             throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1414781227);
         }
     }
     $commands = array();
     $commands[] = 'cd ' . escapeshellarg($rootPath);
     $commands[] = 'if [ "`which npm`" != "" ] && [ -f "package.json" ]; then ' . 'npm install --loglevel error; ' . 'fi';
     $this->shell->executeOrSimulate($commands, $node, $deployment);
 }
Ejemplo n.º 8
0
 /**
  * Executes this task
  *
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws InvalidConfigurationException
  * @throws TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) {
         $rootPath = $deployment->getWorkspacePath($application);
     } else {
         $rootPath = $deployment->getApplicationReleasePath($application);
     }
     if (isset($options['relativeRootPath'])) {
         $rootPath .= $options['relativeRootPath'];
     }
     if (!empty($options['nodeName'])) {
         $node = $deployment->getNode($options['nodeName']);
         if ($node === NULL) {
             throw new InvalidConfigurationException(sprintf('Node "%s" not found', $options['nodeName']), 1414781227);
         }
     }
     $commands = array();
     $commands[] = 'cd ' . escapeshellarg($rootPath);
     $commands[] = 'if hash gulp 2>/dev/null && [ -f gulpfile.js ]; then ' . 'gulp build; ' . 'fi;';
     $this->shell->executeOrSimulate($commands, $node, $deployment);
 }
Ejemplo n.º 9
0
 /**
  * Executes this task
  *
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws InvalidConfigurationException
  * @throws TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (!empty($options['disableDeploymentTag'])) {
         return;
     }
     if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === TRUE) {
         $gitRootPath = $deployment->getWorkspacePath($application);
     } else {
         $gitRootPath = $deployment->getApplicationReleasePath($application);
     }
     $tagPrefix = isset($options['deploymentTagPrefix']) ? $options['deploymentTagPrefix'] : 'server-';
     $tagName = preg_replace('/[^a-zA-Z0-9-_\\.]*/', '', $tagPrefix . $node->getName());
     $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']), 1408441582);
         }
     }
     $commands = array('cd ' . escapeshellarg($gitRootPath), 'git tag --force -- ' . escapeshellarg($tagName), 'git push origin --force ' . $quietFlag . ' -- ' . escapeshellarg($tagName));
     $this->shell->executeOrSimulate($commands, $node, $deployment);
 }
Ejemplo n.º 10
0
 /**
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws InvalidConfigurationException
  * @throws TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     // Get nodes
     if (empty($options['sourceNode']) || !is_array($options['sourceNode'])) {
         throw new InvalidConfigurationException('No sourceNode given in options.', 1409078366);
     }
     $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
     $localNode = $deployment->getNode('localhost');
     $targetNode = $node;
     // Get shared paths
     $sourceSharedPath = $this->getSharedPathFromNode($sourceNode, $deployment, $options['sourceNodeOptions'], $application);
     $localSharedPath = $deployment->getWorkspacePath($application) . '_shared/';
     $targetSharedPath = $this->getSharedPathFromNode($node, $deployment, $options, $application);
     // maybe we should change this behaviour ...
     if ($targetNode->isLocalhost() === TRUE || $sourceNode->isLocalhost() === TRUE) {
         // sync direct
         $this->sync($sourceNode, $sourceSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
     } else {
         // cached
         $this->sync($sourceNode, $sourceSharedPath, $localNode, $localSharedPath, $deployment, $options);
         $this->sync($localNode, $localSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
     }
 }