Example #1
0
 /**
  * Execute the command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return mixed
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $climate = new CLImate();
     $climate->br();
     try {
         $packages = $this->ladder->getOutdatedPackages();
         if (!$packages) {
             $climate->write('All dependencies match the latest package versions <green>:)</green>')->br();
             return;
         }
         $outdated = [];
         $upgradable = [];
         foreach ($packages as $name => list($constraint, $version, $latest)) {
             if (Version::satisfies($latest, $constraint)) {
                 $latest = $this->diff($version, $latest);
                 $upgradable[] = [$name, $version, '→', $latest];
             } else {
                 $latest = $this->diff($version, $latest);
                 $outdated[] = [$name, $version, '→', $latest];
             }
         }
         if ($outdated) {
             $climate->columns($outdated, 3)->br();
         }
         if ($upgradable) {
             $climate->write('The following dependencies are satisfied by their declared version constraint, but the installed versions are behind. You can install the latest versions without modifying your composer.json file by using \'composer update\'.')->br();
             $climate->columns($upgradable, 3)->br();
         }
     } catch (ClimbException $exception) {
         $climate->error($exception->getMessage())->br();
     }
 }
Example #2
0
 /**
  * Get a package's latest version.
  *
  * @param string $name
  *
  * @return string|void
  */
 public function getLatestVersion($name)
 {
     try {
         $package = $this->get($name);
         $versions = array_map(function ($version) {
             return $version->getVersion();
         }, $package->getVersions());
         return Version::latest($versions);
     } catch (ClientErrorResponseException $e) {
         return;
     }
 }
Example #3
0
 /**
  * Check if the package is upgradable.
  *
  * @return bool
  */
 public function isUpgradable()
 {
     return Version::satisfies($this->getLatestVersion(), $this->prettyVersion);
 }
Example #4
0
 /**
  * Get latest package version.
  *
  * @param string $name
  *
  * @return string|void
  */
 public function getLatestVersion($name)
 {
     try {
         // Get all package versions.
         $versions = array_map(function ($version) {
             return $version->getVersion();
         }, $this->packagist->get($name)->getVersions());
         return Version::latest($versions);
     } catch (ClientErrorResponseException $e) {
         return;
     }
 }