protected function execute(InputInterface $input, OutputInterface $output)
 {
     $manifest = $input->getOption('manifest') ?: 'https://platform.sh/cli/manifest.json';
     $currentVersion = $input->getOption('current-version') ?: $this->getApplication()->getVersion();
     if (extension_loaded('Phar') && !($localPhar = \Phar::running(false))) {
         $this->stdErr->writeln('This instance of the CLI was not installed as a Phar archive.');
         if (file_exists(CLI_ROOT . '/../../autoload.php')) {
             $this->stdErr->writeln('Update using: <info>composer global update</info>');
         }
         return 1;
     }
     $manager = new Manager(Manifest::loadFile($manifest));
     if (isset($localPhar)) {
         $manager->setRunningFile($localPhar);
     }
     $onlyMinor = !$input->getOption('major');
     $updated = $manager->update($currentVersion, $onlyMinor);
     if ($updated) {
         $this->stdErr->writeln("Successfully updated");
         $localPhar = $manager->getRunningFile();
         passthru('php ' . escapeshellarg($localPhar) . ' --version');
     } else {
         $this->stdErr->writeln("No updates found. The Platform.sh CLI is up-to-date.");
     }
     return 0;
 }
Ejemplo n.º 2
0
 public function testUpdateNone()
 {
     $manager = new Manager(new Manifest(array(new Update('new.phar', 'test', 'test', Version::create('2.0.1')))));
     $manager->setRunningFile($this->createFile());
     $this->assertFalse($manager->update('1.0.0', true));
 }