Esempio n. 1
0
 /**
  * Collects versions.
  *
  * @return array[string]array
  */
 private static function collect(\ICanBoogie\Core $core)
 {
     $versions = array();
     $definitions = $core->registry->select('SUBSTR(name, LENGTH("thumbnailer.versions.") + 1) as name, value')->where('name LIKE ?', 'thumbnailer.versions.%')->pairs;
     foreach ($definitions as $name => $options) {
         if (!$options || !is_string($options) || $options[0] != '{') {
             \ICanBoogie\log_error('Bad version: %name, :options', array('name' => $name, 'options' => $options));
             continue;
         }
         $versions[$name] = Version::normalize(json_decode($options, true));
     }
     return $versions;
 }
Esempio n. 2
0
 /**
  * Get outdated packages with their current and latest version.
  *
  * @return array
  */
 public function getOutdatedPackages()
 {
     // Get all installed and required packages.
     $installed = $this->composer->getInstalledPackages();
     $required = $this->composer->getRequiredPackages();
     $outdated = [];
     // Get the installed version number of the required packages.
     $packages = array_intersect_key($installed, $required);
     foreach ($packages as $name => $version) {
         $package = new Package($name, Version::normalize($version), $required[$name]);
         if ($package->isOutdated()) {
             $outdated[] = $package;
         }
     }
     return $outdated;
 }
Esempio n. 3
0
 /**
  * Get outdated packages with their current and latest version.
  *
  * @param array $excluded
  *
  * @return array
  */
 public function getOutdatedPackages(array $excluded = [])
 {
     // Get all installed and required packages.
     $installed = $this->composer->getInstalledPackages();
     $required = $this->composer->getRequiredPackages();
     $outdated = [];
     // Get the installed version number of the required packages.
     $packages = array_intersect_key($installed, $required);
     foreach ($packages as $package) {
         $name = $package['name'];
         $version = Version::normalize($package['version']);
         $prettyVersion = $required[$name]['version'];
         $devDependency = $package['devDependency'];
         if (in_array($name, $excluded)) {
             continue;
         }
         $package = new Package($name, $version, $prettyVersion, $devDependency);
         if ($package->isOutdated()) {
             $outdated[] = $package;
         }
     }
     return $outdated;
 }
Esempio n. 4
0
 /**
  * Normalizes a version string to the number of components given in the
  * parameter $precision.
  *
  * A single digit release version and a single digit major version are
  * contracted to a two digit release version. If no major version is given,
  * it is substituted by zero.
  *
  * Examples:
  *
  *     IcuVersion::normalize('1.2.3.4');
  *     // => '12.3.4'
  *
  *     IcuVersion::normalize('1.2.3.4', 1);
  *     // => '12'
  *
  *     IcuVersion::normalize('1.2.3.4', 2);
  *     // => '12.3'
  *
  * @param string   $version   An ICU version string
  * @param int|null $precision The number of components to include. Pass
  *                            NULL to return the version unchanged.
  *
  * @return string|null The normalized ICU version or NULL if it couldn't be
  *                     normalized.
  */
 public static function normalize($version, $precision)
 {
     $version = preg_replace('/^(\\d)\\.(\\d)/', '$1$2', $version);
     if (1 === strlen($version)) {
         $version .= '0';
     }
     return Version::normalize($version, $precision);
 }