protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (PHP_VERSION_ID < 50600) {
         $message = 'Self updating is not available in PHP versions under 5.6.' . "\n";
         $message .= 'The latest version can be found at ' . self::PHAR_URL;
         $output->writeln(sprintf('<error>%s</error>', $message));
         return 1;
     } elseif (Application::VERSION === '@' . 'package_version' . '@') {
         $output->writeln('<error>Self updating has been disabled in source version.</error>');
         return 1;
     }
     $exitCode = 0;
     $updater = new Updater();
     $updater->getStrategy()->setPharUrl(self::PHAR_URL);
     $updater->getStrategy()->setVersionUrl(self::PHAR_VERSION_URL);
     try {
         if ($input->getOption('rollback')) {
             $result = $updater->rollback();
         } else {
             $result = $updater->update();
         }
         if ($result) {
             $new = $updater->getNewVersion();
             $old = $updater->getOldVersion();
             $output->writeln(sprintf('Updated from %s to %s', $old, $new));
         } else {
             $exitCode = 1;
         }
     } catch (Exception $e) {
         $exitCode = 1;
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
     return $exitCode;
 }
예제 #2
0
 /**
  * Configure updater to use unstable builds.
  *
  * @param Updater $updater
  */
 private function stable(Updater $updater)
 {
     $updater->setStrategy(Updater::STRATEGY_GITHUB);
     $updater->getStrategy()->setPackageName('nanbando/core');
     $updater->getStrategy()->setPharName('nanbando.phar');
     $updater->getStrategy()->setCurrentLocalVersion('@git_version@');
     $updater->getStrategy()->setStability(GithubStrategy::STABLE);
 }
예제 #3
0
 /**
  * @return Updater
  */
 private function createUpdater()
 {
     $config = $this->container->get('config');
     $pharUrl = $config['update']['pharUrl'];
     $versionUrl = $config['update']['vesionUrl'];
     $verifyKey = (bool) $config['update']['verifyPublicKey'];
     $updater = new Updater(null, $verifyKey);
     $updater->getStrategy()->setPharUrl($pharUrl);
     $updater->getStrategy()->setVersionUrl($versionUrl);
     return $updater;
 }
예제 #4
0
 /**
  * @param mixed $version
  */
 public function __construct($version)
 {
     $this->version = $version;
     $this->updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     /* @var $strategy \Humbug\SelfUpdate\Strategy\GithubStrategy */
     $strategy = $this->updater->getStrategy();
     $strategy->setPackageName('narno/phpoole');
     $strategy->setPharName('phpoole.phar');
     $strategy->setCurrentLocalVersion($this->version);
     $strategy->setStability('any');
 }
예제 #5
0
 /**
  * Execute Command.
  *
  * @param InputInterface  $consoleInput
  * @param OutputInterface $consoleOutput
  *
  * @return int|null|void
  */
 public function execute(InputInterface $consoleInput, OutputInterface $consoleOutput)
 {
     $updater = new Updater();
     $updater->setStrategy(Updater::STRATEGY_GITHUB);
     $updater->getStrategy()->setPackageName('kriskbx/wyn');
     $updater->getStrategy()->setPharName('wyn.phar');
     $updater->getStrategy()->setCurrentLocalVersion($GLOBALS['wynVersion']);
     try {
         $result = $updater->rollback();
         $result ? exit('Success!') : exit('Failure!');
     } catch (\Exception $e) {
         exit('Well, something happened! Either an oopsie or something involving hackers.');
     }
 }
예제 #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater();
     $updater->setStrategy(Updater::STRATEGY_GITHUB);
     $updater->getStrategy()->setPackageName('relamptk/git-deployer');
     $updater->getStrategy()->setPharName('git-deployer.phar');
     $updater->getStrategy()->setCurrentLocalVersion($this->getApplication()->getVersion());
     $result = $updater->update();
     if ($result) {
         $new = $updater->getNewVersion();
         $output->writeln('<info>Git-Deployer</info> updated to version ' . $new . '.');
     } else {
         $output->writeln('<info>Git-Deployer</info> is already on the latest version!');
     }
 }
예제 #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     $updater->getStrategy()->setPackageName('friendsofphp/pickle');
     $updater->getStrategy()->setPharName(self::PHAR_NAME);
     $updater->getStrategy()->setCurrentLocalVersion($this->getApplication()->getVersion());
     if ($input->getOption('unstable')) {
         $updater->getStrategy()->setStability('unstable');
     }
     if ($updater->update() === false) {
         $output->writeln('<info>Already up-to-date.</info>');
     } else {
         $output->writeln('<info>' . $updater->getLocalPharFileBasename() . ' has been updated!</info>');
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = new ConsoleLogger($output);
     $updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     /** @var GithubStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPackageName('icehawk/component-template-generator');
     $strategy->setPharName('icehawk-ctg.phar');
     $strategy->setCurrentLocalVersion('@package_version@');
     $stability = $input->getOption('stability');
     $strategy->setStability($stability);
     if ($updater->hasUpdate()) {
         $newVersion = $updater->getNewVersion();
         $logger->info(sprintf('The current stable version available is: %s', $newVersion));
         $logger->info('Updating...');
         if ($updater->update()) {
             $logger->info(sprintf('Successful! You now have version %s installed', $newVersion));
         }
     } elseif (false === $updater->getNewVersion()) {
         $logger->alert('There is no stable version available.');
     } else {
         $logger->info('@package_version@ is the latest stable version.');
     }
     return 0;
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = new ConsoleLogger($output);
     $updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     /** @var GithubStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPackageName(PharTool::PACKAGE_NAME);
     $strategy->setPharName(PharTool::PHAR_NAME);
     $strategy->setCurrentLocalVersion('@package_version@');
     $stability = $input->getOption('stability');
     $strategy->setStability($stability);
     try {
         if ($updater->hasUpdate()) {
             $newVersion = $updater->getNewVersion();
             $logger->info(sprintf('The current stable version available is: %s', $newVersion));
             $logger->info('Updating...');
             if ($updater->update()) {
                 $logger->info(sprintf('Successful! You now have version %s installed', $newVersion));
             }
         } elseif (false === $updater->getNewVersion()) {
             $logger->alert('There is no stable version available.');
         } else {
             $logger->info('@package_version@ is the latest stable version.');
         }
         return 0;
     } catch (HttpRequestException $e) {
         $logger->alert('Error fetching current version from remote repository.');
         return 1;
     }
 }
예제 #10
0
 /**
  * Execute
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater(null, false);
     $updater->setStrategy(Updater::STRATEGY_GITHUB);
     $strategy = $updater->getStrategy();
     /* @var GithubStrategy $strategy */
     $strategy->setPackageName('TYPO3/Surf');
     $strategy->setPharName('surf.phar');
     $strategy->setCurrentLocalVersion($this->getApplication()->getVersion());
     $stability = $input->getOption('stability');
     if (empty($stability)) {
         // Unstable by default. Should be removed once we have a 2.0.0 final
         $stability = GithubStrategy::UNSTABLE;
     }
     $strategy->setStability($stability);
     if ($input->getOption('check')) {
         $result = $updater->hasUpdate();
         if ($result) {
             $output->writeln(sprintf('The %s build available remotely is: %s', $strategy->getStability() === GithubStrategy::ANY ? 'latest' : 'current ' . $strategy->getStability(), $updater->getNewVersion()));
         } elseif (false === $updater->getNewVersion()) {
             $output->writeln('There are no new builds available.');
         } else {
             $output->writeln(sprintf('You have the current %s build installed.', $strategy->getStability()));
         }
     } elseif ($input->getOption('rollback')) {
         $result = $updater->rollback();
         $result ? $output->writeln('Success!') : $output->writeln('Failure!');
     } else {
         $result = $updater->update();
         $result ? $output->writeln('Updated.') : $output->writeln('No update needed!');
     }
 }
예제 #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater();
     $updater->getStrategy()->setPharUrl('https://gilbitron.github.io/Handle/handle.phar');
     $updater->getStrategy()->setVersionUrl('https://gilbitron.github.io/Handle/handle.phar.version');
     try {
         $result = $updater->rollback();
         if (!$result) {
             $output->writeln('<error>There was an error rolling back the update</error>');
             return;
         }
         $output->writeln('<info>Rollback successful</info>');
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
 /**
  * @runInSeparateProcess
  */
 public function testUpdatePhar()
 {
     if (!extension_loaded('openssl')) {
         $this->markTestSkipped('This test requires the openssl extension to run.');
     }
     $this->createTestPharAndKey();
     $this->assertEquals('old', $this->getPharOutput($this->tmp . '/old.phar'));
     $updater = new Updater($this->tmp . '/old.phar');
     $updater->setStrategyObject(new GithubTestStrategy());
     $updater->getStrategy()->setPharName('new.phar');
     $updater->getStrategy()->setPackageName('');
     // not used in this test
     $updater->getStrategy()->setCurrentLocalVersion('1.0.0');
     $this->assertTrue($updater->update());
     $this->assertEquals('new', $this->getPharOutput($this->tmp . '/old.phar'));
 }
예제 #13
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater();
     $updater->getStrategy()->setPharUrl('https://gilbitron.github.io/Handle/handle.phar');
     $updater->getStrategy()->setVersionUrl('https://gilbitron.github.io/Handle/handle.phar.version');
     try {
         $result = $updater->update();
         if (!$result) {
             $output->writeln('<info>No update available</info>');
             return;
         }
         $new = $updater->getNewVersion();
         $old = $updater->getOldVersion();
         $output->writeln(sprintf('<info>Updated from %s to %s</info>', $old, $new));
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
예제 #14
0
 /**
  * Run the command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater(null, false);
     $updater->setStrategyObject(new CurlGithubStrategy());
     $updater->getStrategy()->setPackageName('inetprocess/sugarcli');
     $updater->getStrategy()->setPharName('sugarcli.phar');
     $updater->getStrategy()->setCurrentLocalVersion($this->getApplication()->getVersion());
     if ($input->getOption('rollback')) {
         $updater->rollback();
     } else {
         $result = $updater->update();
         if ($result) {
             $output->writeln('Successfuly updated');
         } else {
             $output->writeln('Already up to date');
         }
     }
 }
예제 #15
0
 /**
  * Execute the self-update command
  *
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $updater = new Updater(null, false);
     $updater->setStrategy(Updater::STRATEGY_GITHUB);
     $updater->getStrategy()->setPackageName('studioforty9/modrepo');
     $updater->getStrategy()->setPharName('modrepo.phar');
     $updater->getStrategy()->setCurrentLocalVersion($this->getApplication()->getVersion());
     $updater->getStrategy()->setStability('stable');
     try {
         $result = $updater->update();
         if ($result) {
             $output->writeln('<fg=green>Modrepo has been updated.</fg=green>');
             $output->writeln(sprintf('<fg=green>Current version is:</fg=green> <options=bold>%s</options=bold>.', $updater->getNewVersion()));
             $output->writeln(sprintf('<fg=green>Previous version was:</fg=green> <options=bold>%s</options=bold>.', $updater->getOldVersion()));
         } else {
             $output->writeln('<fg=green>Modrepo is currently up to date.</fg=green>');
             $output->writeln(sprintf('<fg=green>Current version is:</fg=green> <options=bold>%s</options=bold>.', $updater->getOldVersion()));
         }
     } catch (\Exception $e) {
         $output->writeln(sprintf('Error: <fg=yellow>%s</fg=yellow>', $e->getMessage()));
     }
     $output->write(PHP_EOL);
 }
 /**
  * @param Route $route
  * @param Console $console
  * @return int
  */
 public function __invoke(Route $route, Console $console)
 {
     if (version_compare(\PHP_VERSION, '5.6', 'lt')) {
         $console->writeLine(sprintf('self-update requires PHP >=5.6 (version %s was used); aborting', \PHP_VERSION), Color::RED);
         exit(1);
     }
     $updater = new Updater();
     $updater->getStrategy()->setPharUrl(self::URL_PHAR);
     $updater->getStrategy()->setVersionUrl(self::URL_VERSION);
     try {
         $result = $updater->update();
         if (!$result) {
             $console->writeLine('No updated needed!', Color::GREEN);
             return 0;
         }
         $new = $updater->getNewVersion();
         $old = $updater->getOldVersion();
         $console->writeLine(sprintf('Updated from %s to %s', $old, $new), Color::GREEN);
         return 0;
     } catch (Exception $e) {
         $console->writeLine('[ERROR] Could not update', Color::RED);
         return 1;
     }
 }
예제 #17
0
 function exec()
 {
     try {
         $updater = new Updater();
         //$updater->setStrategy(Updater::STRATEGY_GITHUB); //use packagist.org
         //$updater->getStrategy()->setStability('any');
         //$updater->getStrategy()->setPackageName('redcatphp/artist');
         //$updater->getStrategy()->setPharName('artist.phar');
         //$updater->getStrategy()->setCurrentLocalVersion('@package_version@');
         $updater->getStrategy()->setPharUrl('https://raw.githubusercontent.com/redcatphp/artist/master/artist.phar');
         $updater->getStrategy()->setVersionUrl('https://raw.githubusercontent.com/redcatphp/artist/master/artist.version');
         $result = $updater->update();
         if (!$result) {
             $this->output->writeln('allready up to date');
             return;
         }
         $new = $updater->getNewVersion();
         $old = $updater->getOldVersion();
         printf('Updated from %s to %s', $old, $new);
     } catch (FilesystemException $e) {
         echo "you must run this command as sudo (root)\n";
         throw $e;
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = new ConsoleLogger($output);
     $updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     /** @var GithubStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPackageName('icehawk/component-template-generator');
     $strategy->setPharName('icehawk-ctg.phar');
     $strategy->setCurrentLocalVersion('@package_version@');
     if ($updater->rollback()) {
         $logger->info('Roll back successful!');
     } else {
         $logger->alert('Roll back failed.');
     }
     return 0;
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $input->validate();
     $logger = new ConsoleLogger($output);
     $updater = new Updater(null, false, Updater::STRATEGY_GITHUB);
     /** @var GithubStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPackageName(PharTool::PACKAGE_NAME);
     $strategy->setPharName(PharTool::PHAR_NAME);
     $strategy->setCurrentLocalVersion('@package_version@');
     if ($updater->rollback()) {
         $logger->info('Roll back successful!');
     } else {
         $logger->alert('Roll back failed.');
     }
     return 0;
 }
예제 #20
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $updater = new Updater();
     $strategy = $updater->getStrategy();
     if ($strategy instanceof ShaStrategy) {
         $strategy->setPharUrl('http://lucascherifi.github.io/gitaski/gitaski.phar');
         $strategy->setVersionUrl('http://lucascherifi.github.io/gitaski/gitaski.phar.version');
     }
     $result = $updater->update();
     if (!$result) {
         $io = new SymfonyStyle($input, $output);
         $io->success('No update needed.');
         return;
     }
     $new = $updater->getNewVersion();
     $old = $updater->getOldVersion();
     $io->success(sprintf('Updated from %s to %s', $old, $new));
     return;
 }
예제 #21
0
 /**
  * executes the command
  *
  * @return int
  */
 protected function handle()
 {
     $updater = new Updater(null, false);
     /** @var \Humbug\SelfUpdate\Strategy\ShaStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPharUrl(self::UPDATE_PHAR_URL);
     $strategy->setVersionUrl(self::UPDATE_VERSION_URL);
     try {
         $result = $updater->update();
         if (!$result) {
             // No update needed!
             return 0;
         }
         $new = $updater->getNewVersion();
         $old = $updater->getOldVersion();
         $this->info(sprintf('Updated from %s to %s', $old, $new));
         return 0;
     } catch (\Exception $e) {
         // Report an error!
         $this->error($e->getMessage());
         return 1;
     }
 }
예제 #22
0
 protected function printVersion(Updater $updater)
 {
     $stability = 'stable';
     if ($updater->getStrategy() instanceof ShaStrategy) {
         $stability = 'development';
     } elseif ($updater->getStrategy() instanceof GithubStrategy && $updater->getStrategy()->getStability() == GithubStrategy::UNSTABLE) {
         $stability = 'pre-release';
     }
     try {
         if ($updater->hasUpdate()) {
             $this->output->writeln(sprintf('The current %s build available remotely is: <options=bold>%s</options=bold>', $stability, $updater->getNewVersion()));
         } elseif (false == $updater->getNewVersion()) {
             $this->output->writeln(sprintf('There are no %s builds available.', $stability));
         } else {
             $this->output->writeln(sprintf('You have the current %s build installed.', $stability));
         }
     } catch (\Exception $e) {
         $this->output->writeln(sprintf('Error: <fg=yellow>%s</fg=yellow>', $e->getMessage()));
     }
 }
예제 #23
0
 protected function printVersion(Updater $updater)
 {
     $stability = 'stable';
     $strategyInterface = $updater->getStrategy();
     if ($strategyInterface instanceof ShaStrategy) {
         $stability = 'development';
     } elseif ($strategyInterface instanceof GithubStrategy && $strategyInterface->getStability() == GithubStrategy::UNSTABLE) {
         $stability = 'pre-release';
     }
     try {
         if ($updater->hasUpdate()) {
             $this->io->text("The current {$stability} build available remotely is: " . $updater->getNewVersion());
         } elseif (false == $updater->getNewVersion()) {
             $this->io->text("There are no {$stability} builds available.");
         } else {
             $this->io->text("You have the current {$stability} build installed.");
         }
     } catch (\Exception $e) {
         $this->io->error("Error: " . $e->getMessage());
     }
 }
예제 #24
0
 private function printAvailableVersion(Updater $updater, OutputInterface $output)
 {
     $strategy = $updater->getStrategy();
     if (!$strategy instanceof GithubStrategy) {
         throw new \UnexpectedValueException('Unexpected strategy type');
     }
     /* @var $strategy GithubStrategy */
     $stability = $strategy->getStability() === GithubStrategy::STABLE ? 'stable' : 'pre-release';
     try {
         if ($updater->hasUpdate()) {
             $output->writeln(sprintf('The current %s build available is: <options=bold>%s</options=bold>', $stability, $updater->getNewVersion()));
         } elseif ($updater->getNewVersion() === false) {
             $output->writeln(sprintf('There are no %s builds available.', $stability));
         } else {
             $output->writeln(sprintf('You have the current %s build installed.', $stability));
         }
     } catch (\Exception $ex) {
         $output->writeln(sprintf('Error: <error>%s</error>', $ex->getMessage()));
     }
 }
예제 #25
0
 /**
  * @return Updater
  */
 private function getVictorUpdater()
 {
     $updater = new Updater(NULL, FALSE, Updater::STRATEGY_GITHUB);
     /** @var \Humbug\SelfUpdate\Strategy\GithubStrategy $strategy */
     $strategy = $updater->getStrategy();
     $strategy->setPackageName('nella/victor');
     $strategy->setPharName('victor.phar');
     $strategy->setCurrentLocalVersion(Victor::VERSION);
     return $updater;
 }
예제 #26
0
파일: Tg.php 프로젝트: twhiston/tg
 public function selfUpdate()
 {
     if (!extension_loaded('Phar') || !\Phar::running(false)) {
         $this->yell('Can only update Phar version. Update via a vcs');
         return;
     }
     $updater = new Updater(null, false);
     $updater->setStrategyObject(new BitBucketStrategy($updater));
     //Yep, that sucks
     $updater->getStrategy()->setPackageName('twhiston/tg');
     $updater->getStrategy()->setPharName('tg.phar');
     $updater->getStrategy()->setCurrentLocalVersion(TgApp::VERSION);
     try {
         $this->yell('Updating', 100, 'green');
         $result = $updater->update();
         if (!$result) {
             $this->yell('You have the most recent version', 100, 'yellow');
         }
     } catch (\Exception $e) {
         $this->yell('Error updating: ' . $e->getMessage(), 100, 'red');
     }
 }
예제 #27
0
 /**
  * Custom Strategies
  */
 public function testCanSetCustomStrategyObjects()
 {
     $this->updater->setStrategyObject(new FooStrategy());
     $this->assertTrue($this->updater->getStrategy() instanceof FooStrategy);
 }