Example #1
0
 public function execute(Context $context)
 {
     $this->io->write(sprintf('Comparing <info>%s</info> (<comment>%s</comment>) with <info>%s</info> (<comment>%s</comment>)', $context->getVersion()->getName(), $context->getVersion()->getBuild(), $context->getRemoteVersion()->getName(), $context->getRemoteVersion()->getBuild()));
     $result = $this->repository->diff($context->getRemoteVersion(), $context->getVersion());
     if ($result) {
         foreach ($result as $fileinfo) {
             switch ($fileinfo->getStatus()) {
                 case Status::ADDED:
                     $symbol = '+';
                     $color = 'info';
                     break;
                 case Status::MODIFIED:
                     $symbol = '*';
                     $color = 'comment';
                     break;
                 case Status::DELETED:
                     $symbol = '-';
                     $color = 'error';
                     break;
             }
             $this->io->write(sprintf(' <%s>%-2s %s</%s>', $color, $symbol, $fileinfo->getPathname(), $color));
         }
     } else {
         $this->io->write('No changes between versions');
     }
 }
 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);
 }
Example #3
0
 protected function executeTaskrunner(Context $context)
 {
     $this->io->write('');
     if (true === $context->isSimulate()) {
         $this->io->write(sprintf('Simulating tasks before deploy'));
     } else {
         $this->io->write(sprintf('Running tasks before deploy'));
     }
     $this->io->increaseIndention(1);
     if (true === $context->isSimulate()) {
         $this->taskRunner->simulate($context->getTarget(), $context->getVersion());
     } else {
         $this->taskRunner->execute($context->getTarget(), $context->getVersion());
     }
     $this->io->decreaseIndention(1);
 }
 public function execute(Context $context)
 {
     // this was filled by the builder
     $filesModified = $context->getFilesModified();
     $filesDeleted = $context->getFilesDeleted();
     if (false === $context->isFullDeploy()) {
         $diff = $this->repository->diff($context->getRemoteVersion(), $context->getVersion());
         $subselectionModified = new FileCollection($context->getBuilddir());
         foreach ($diff as $fileinfo) {
             if (Status::ADDED === $fileinfo->getStatus()) {
                 $subselectionModified[] = $fileinfo->getPathname();
             } elseif (Status::MODIFIED === $fileinfo->getStatus()) {
                 $subselectionModified[] = $fileinfo->getPathname();
             } elseif (Status::DELETED === $fileinfo->getStatus()) {
                 $filesDeleted->add($fileinfo->getPathname(), true);
             } else {
                 // @todo handle other cases if they actually exist
             }
         }
         foreach ($this->derivedFiles as $derivable) {
             $source = $derivable['source'];
             $derived = $derivable['derived'];
             if ($subselectionModified->has($source)) {
                 $subselectionModified->add($derived);
             }
         }
         // only keep files that are changed
         $filesModified->intersect($subselectionModified);
         //            if (0 === count($filesAdded) && count($subselectionAdded) > 0) {
         //                // hmm.. so files have changed but nothing to deploy
         //                // it looks like we forgot to specify some derived files
         //                // @todo inform the user about this?
         //            }
         // @todo we could also check here if all files are accounted for (maybe
         //       some files were deleted and not told to us by setting it in
         //       the `removes` config?) in other words: file_exists on all files?
     } else {
         foreach ($this->derivedFiles as $derivable) {
             $source = $derivable['source'];
             $derived = $derivable['derived'];
             if ($filesModified->has($source)) {
                 $filesModified->add($derived);
             }
         }
     }
     // never upload the conveyor configuration!
     $filesModified->remove('conveyor.yml');
     // validate result, throw exception when we have nothing to deploy
     if (0 === count($filesModified) && 0 === count($filesDeleted)) {
         throw new EmptyChangesetException();
     }
     $context->setFilesModified($filesModified);
     $context->setFilesDeleted($filesDeleted);
 }
Example #5
0
 protected function removeFiles(array $files, Context $context)
 {
     $total = count($files);
     foreach ($files as $t => $file) {
         $src = FilePath::join($context->getBuilddir(), $file);
         $dest = FilePath::join($this->getDestinationPath($context->getStrategy(), $context->getVersion()), $file);
         $this->transporter->remove($dest, true);
         if ($this->io && true === $this->showProgress) {
             $this->io->overwrite(sprintf('Progress: <comment>%d%%</comment>', ($t + 1) * 100 / $total), false);
         }
     }
 }
Example #6
0
 public function execute(Context $context)
 {
     if (true !== $this->validateBuildDir($context->isForce())) {
         return false;
     }
     $this->io->write('');
     $this->io->write(sprintf('Building <info>%s</info> (<comment>%s</comment>) to <info>%s</info>', $context->getVersion()->getName(), $context->getTarget(), $context->getBuilddir()));
     $this->io->increaseIndention(1);
     $this->builder->setContext($context);
     $this->builder->build($context->getTarget(), $context->getVersion());
     $this->io->decreaseIndention(1);
     return true;
 }
 protected function compareRemoteVersionBuild(Context $context)
 {
     if ($context->isFullDeploy()) {
         return true;
     }
     if ($context->getVersion()->equals($context->getRemoteVersion())) {
         $this->io->write('Remote version is already up-to-date.', true);
         return false;
     } elseif (1 === $this->repository->versionCompare($context->getRemoteVersion(), $context->getVersion())) {
         if ($context->isForce()) {
             $answer = true;
         } else {
             $answer = $this->io->askConfirmation(sprintf('Remote version (%s) is newer than the selected version (%s). ' . 'Would you like to continue as full deploy? (Y/n): ', $context->getRemoteVersion()->getBuild(), $context->getVersion()->getBuild()), 'Y');
         }
         if ($answer) {
             $context->setFullDeploy(true);
         } else {
             return false;
         }
     }
     return true;
 }
Example #8
0
 /**
  * Execute a single task
  *
  * @param Context $context
  *
  * @return void
  */
 protected function executeTaskrunner(Context $context)
 {
     $this->io->write('');
     $this->io->increaseIndention(1);
     $this->taskRunner->execute($context->getTarget(), $context->getVersion());
     $this->io->decreaseIndention(1);
 }
Example #9
0
 /**
  * Copies the latest version server-side to the uploaddir,
  * in case this is a incremental deploy.
  *
  * @param \Webcreate\Conveyor\Context $context
  */
 protected function prepareUploadPath($context)
 {
     $basepath = $this->transporter->getPath();
     $uploadPath = $basepath . '/' . $this->getUploadPath($context->getVersion());
     $currentReleasePath = $basepath . '/' . $this->getCurrentReleasePath() . '/';
     if (false === $context->isFullDeploy()) {
         // add some white space to the output
         $this->io->write('');
         $this->transporter->copy($currentReleasePath, $uploadPath);
     }
 }