コード例 #1
0
 /**
  * Handles the "self-update" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $updateStrategy = new GithubStrategy();
     $updateStrategy->setPackageName('puli/cli');
     $updateStrategy->setStability($this->getStability($args));
     $updateStrategy->setPharName('puli.phar');
     $updateStrategy->setCurrentLocalVersion(PuliApplicationConfig::VERSION);
     $updater = new Updater();
     $updater->setStrategyObject($updateStrategy);
     if ($updater->update()) {
         $io->writeLine(sprintf('Updated from version %s to version %s.', $updater->getOldVersion(), $updater->getNewVersion()));
     } else {
         $io->writeLine(sprintf('Version %s is the latest version. No update required.', $updater->getOldVersion()));
     }
     return 0;
 }
コード例 #2
0
 /**
  * Handles the "self-update" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $updateStrategy = new GithubStrategy();
     $updateStrategy->setPackageName('puli/cli');
     $updateStrategy->setStability($this->getStability($args));
     $updateStrategy->setPharName('puli.phar');
     $updateStrategy->setCurrentLocalVersion(PuliApplicationConfig::VERSION);
     // false: disable signed releases, otherwise the updater will look for
     // a *.pubkey file for the PHAR
     $updater = new Updater(null, false);
     $updater->setStrategyObject($updateStrategy);
     if ($updater->update()) {
         $io->writeLine(sprintf('Updated from version %s to version %s.', $updater->getOldVersion(), $updater->getNewVersion()));
         return 0;
     }
     $io->writeLine(sprintf('Version %s is the latest version. No update required.', $updater->getOldVersion()));
     return 0;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $application = $this->getApplication();
     $pharName = 'drupal.phar';
     $updateStrategy = new GithubStrategy();
     $updateStrategy->setPackageName('drupal/console');
     $updateStrategy->setStability(GithubStrategy::STABLE);
     $updateStrategy->setPharName($pharName);
     $updateStrategy->setCurrentLocalVersion($application::VERSION);
     $updater = new Updater(null, false);
     $updater->setStrategyObject($updateStrategy);
     if ($updater->update()) {
         $output->success(sprintf($this->trans('commands.self-update.messages.success'), $updater->getOldVersion(), $pharName));
     } else {
         $output->warning(sprintf($this->trans('commands.self-update.messages.current-version'), $updater->getOldVersion()));
     }
     $this->getApplication()->setDispatcher(null);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updateStrategy = new GithubStrategy();
     $updateStrategy->setPackageName('drupal/console');
     $updateStrategy->setStability(GithubStrategy::STABLE);
     $updateStrategy->setPharName('console.phar');
     $updateStrategy->setCurrentLocalVersion(Application::VERSION);
     $updater = new Updater(null, false);
     $updater->setStrategyObject($updateStrategy);
     if ($updater->update()) {
         $output->writeln(sprintf($this->trans('commands.self-update.messages.success'), $updater->getOldVersion(), $updater->getNewVersion()));
     } else {
         $output->writeln(sprintf($this->trans('commands.self-update.messages.current-version'), $updater->getOldVersion()));
     }
     // Recommended by Commerce Guys CLI
     // https://github.com/platformsh/platformsh-cli/blob/7a122d3f3226d5e6ed0a0b74803158c51b31ad5e/src/Command/Self/SelfUpdateCommand.php#L72-L77
     // Errors appear if new classes are instantiated after this stage
     // (namely, Symfony's ConsoleTerminateEvent). This suggests PHP
     // can't read files properly from the overwritten Phar, or perhaps it's
     // because the autoloader's name has changed. We avoid the problem by
     // terminating now.
     exit;
 }
コード例 #5
0
ファイル: Application.php プロジェクト: nochso/phormat
 private function selfUpdate()
 {
     $phar = \Phar::running(false);
     if ($phar === '') {
         $this->stdio->errln('<<red>>Self-updating only works when running the PHAR version of phormat.<<reset>>');
         exit(Status::UNAVAILABLE);
     }
     $updater = new Updater($phar, false);
     $strategy = new GithubStrategy();
     $strategy->setPackageName('nochso/phormat');
     $strategy->setPharName('phormat.phar');
     $strategy->setCurrentLocalVersion($this->version->getVersion());
     $updater->setStrategyObject($strategy);
     try {
         if ($updater->update()) {
             $this->stdio->success(sprintf('Successfully updated phormat from <<yellow>>%s<<reset>> to <<yellow>>%s<<reset>>.', $updater->getOldVersion(), $updater->getNewVersion()));
             exit(Status::SUCCESS);
         }
         $this->stdio->neutral('There is no update available.');
         exit(Status::SUCCESS);
     } catch (\Exception $e) {
         $this->stdio->error(sprintf("Self-update failed:\n%s<<reset>>", $e->getMessage()));
     }
 }