public function execute(Context $context) { if ($this->io) { $this->io->write(sprintf('Wring remote info file')); } $version = $context->getVersion(); $versionFile = FilePath::join($this->transporter->getPath(), $context->getStrategy()->getUploadPath($context->getVersion()), $this->remoteInfoFile); $this->transporter->putContent($version->getUID(), $versionFile); }
protected function getCommand($target, $version, $command) { $basepath = $path = $this->transporter->getPath(); if (isset($this->options['path']) && $this->options['path']) { $path = FilePath::join($basepath, $this->options['path']); } $command = sprintf('cd %s && %s', $path, $command); return $command; }
protected function getRemoteVersion(Context $context) { if ($context->isFullDeploy()) { return; } $versionFile = FilePath::join($this->transporter->getPath(), $context->getStrategy()->getCurrentReleasePath(), $this->remoteInfoFile); $content = $this->transporter->get($versionFile); list($name, $build) = explode(':', trim($content)); $context->setRemoteVersion(new Version($name, $build)); }
/** * Retrieve the status for each target * * @param null|string $target when given only get the status for a single target * @return array */ public function status($target = null) { $config = $this->getConfig()->getConfig(); $targets = null !== $target ? array($target) : array_keys($config['targets']); $repository = $this->getRepository(); $remoteInfoFile = $this->container->getParameter('conveyor.remoteinfofile'); $retval = array(); foreach ($targets as $target) { $this->assertTargetExists($target, $config); } foreach ($targets as $target) { $transporter = $this->getTransporter($target); $strategy = $this->getStrategy($transporter); $context = new Context(); $context->setTarget($target)->setStrategy($strategy); try { $versionFile = FilePath::join($transporter->getPath(), $strategy->getCurrentReleasePath(), $remoteInfoFile); $isDeployed = $transporter->exists($versionFile); if ($isDeployed) { $manager = new StageManager($context, $this->container->get('dispatcher')); $manager->addStage('get.remote.version', new Stage\RetrieveRemoteVersionInfoStage($transporter, $repository, new NullIO(), $remoteInfoFile, array('getRemoteVersion'))); $manager->execute(); // @todo don't compare to master branch, compare to the remote version's ancestor $localVersion = $repository->getVersion(sprintf('dev-%s', $repository->getMasterBranch())); $remoteVersion = $context->getRemoteVersion(); $compare = $repository->versionCompare($localVersion, $remoteVersion); $changelog = array(); if (1 === $compare) { $changelog = $repository->changelog($remoteVersion, $localVersion); } elseif (-1 === $compare) { $changelog = $repository->changelog($localVersion, $remoteVersion); } $retval[$target] = array('remoteVersion' => $context->getRemoteVersion(), 'localVersion' => $localVersion, 'changelog' => $changelog, 'compare' => $compare); } else { $retval[$target] = false; } } catch (\Exception $e) { $retval[$target] = array('error' => $e); } } return $retval; }
protected function validateRemoteVersionFile(Context $context) { if ($context->isFullDeploy()) { return; } $versionFile = FilePath::join($this->transporter->getPath(), $context->getStrategy()->getCurrentReleasePath(), $this->remoteInfoFile); if (false == $this->transporter->exists($versionFile)) { if ($context->isForce()) { $answer = true; } else { $answer = $this->io->askConfirmation(sprintf('Remote version information not found. Would you like to do a full deploy? (Y/n): '), 'Y'); } if ($answer) { $context->setFullDeploy(true); } else { return false; } } return true; }
/** * Check in the remote if a current release exists * * @param Context $context * * @return bool */ protected function currentReleaseExists(Context $context) { return $this->transporter->exists(FilePath::join($this->transporter->getPath(), $context->getStrategy()->getCurrentReleasePath())); }
/** * * @param FileCollection $sharedFiles * @param Context $context */ protected function putDeferedSharedFiles($sharedFiles, Context $context) { $basepath = $this->transporter->getPath(); $sharedPath = $basepath . '/shared'; foreach ($sharedFiles as $file) { $src = FilePath::join($context->getBuilddir(), $file); $sharedFilepath = $sharedPath . '/' . $file; if (false === file_exists($src)) { // @todo we might wanna ask the user if he likes to continue or abort if ($this->io) { $this->io->write(sprintf('<error>Warning</error> <comment>%s</comment> not found', $src)); } continue; } $this->transporter->put($src, $sharedFilepath); } }
protected function getDestinationPath(StrategyInterface $strategy, Version $version) { return FilePath::join($this->transporter->getPath(), $strategy->getUploadPath($version)); }