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); }
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); } } }
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; }
/** * Creates shared files and folders */ protected function prepareSharedFilesAndFolders(Context $context) { $basepath = $this->transporter->getPath(); $sharedPath = $basepath . '/shared'; $shared = (array) $this->options['shared']; // add some white space to the output if (count($shared) > 0) { $this->io->write(''); } foreach ($shared as $fileOrFolder) { $sharedFilepath = $sharedPath . '/' . $fileOrFolder; $localFilepath = $context->getBuilddir() . '/' . $fileOrFolder; if (false === $this->transporter->exists($sharedFilepath)) { // Hmm, the shared entity doesn't exist // is it a directory? if (is_dir($localFilepath) || '/' === substr($sharedFilepath, -1)) { $this->transporter->mkdir($sharedFilepath); } else { $parentDir = dirname($sharedFilepath); if (false === $this->transporter->exists($parentDir) && $parentDir != $sharedPath) { $this->transporter->mkdir($parentDir); } $this->transporter->putContent('', $sharedFilepath); // make a dummy file } } } }