/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new ConsoleIO($input, $output); if ($this->isInstalledAsPhar() === false) { $io->error('Self-update is available only for PHAR version'); return 1; } $manifest = $this->getManifestFile(); $remoteVersion = $manifest['version']; $localVersion = $this->getApplication()->getVersion(); if ($localVersion === $remoteVersion) { $io->success('Spress is already up to date'); return; } $remoteFilename = $manifest['url']; $localFilename = $_SERVER['argv'][0]; $tempFilename = basename($localFilename, '.phar') . '-tmp.phar'; $io->newLine(); $io->write('Downloading Spress...'); $io->newLine(); $this->downloadRemoteFilename($remoteFilename); try { copy($remoteFilename, $tempFilename); chmod($tempFilename, 0777 & ~umask()); $phar = new \Phar($tempFilename); unset($phar); if (@rename($tempFilename, $localFilename) !== true) { $io->error(sprintf('Cannot rename "%s" to "%s" probably because permission denied.', $tempFilename, $localFilename)); return 1; } $io->success(sprintf('Spress updated from %s to %s.', $localVersion, $remoteVersion)); if (isset($manifest['changelog_url']) === true) { $io->write(sprintf('<comment>Go to <info>%s</info> for more details.</comment>', $manifest['changelog_url'])); } } catch (\Exception $e) { if ($e instanceof \UnexpectedValueException === false && $e instanceof \PharException === false) { throw $e; } unlink($tempFilename); $io->error([sprintf('The download is corrupt (%s).', $e->getMessage()), 'Please re-run the self-update command to try again.']); return 1; } }
/** * Write the result of rebuilding a site. * * @param Yosymfony\Spress\IO\ConsoleIO $io * @param array $newResources * @param array $updatedResources * @param array $deletedResources */ protected function rebuildingSiteMessage(ConsoleIO $io, array $newResources, array $updatedResources, array $deletedResources) { $io->write(sprintf('<comment>Rebuilding site... (%s new, %s updated and %s deleted resources)</comment>', count($newResources), count($updatedResources), count($deletedResources))); $io->newLine(); }
public function testNewLine() { $this->command->setCode(function (InputInterface $input, OutputInterface $output) use(&$isDecorated) { $io = new ConsoleIO($input, $output); $io->newLine(); }); $this->tester->execute([], ['interactive' => false, 'decorated' => false]); $this->assertEquals("\n", $this->tester->getDisplay(true)); }