Beispiel #1
0
 /**
  * Creates a new in memory package.
  *
  * @param string $name        The package's name
  * @param string $version     The package's version
  * @param string $prettyVersion The package's non-normalized version
  */
 public function __construct($name, $version, $prettyVersion)
 {
     parent::__construct($name);
     $this->version = $version;
     $this->prettyVersion = $prettyVersion;
     $this->dev = VersionParser::isDev($version);
 }
 /**
  * Clean a package, based on its rules.
  *
  * @param BasePackage  $package  The package to clean
  * @return bool True if cleaned
  */
 protected function cleanPackage(BasePackage $package)
 {
     // Only clean 'dist' packages
     if ($package->getInstallationSource() !== 'dist') {
         return false;
     }
     $vendorDir = $this->config->get('vendor-dir');
     $targetDir = $package->getTargetDir();
     $packageName = $package->getPrettyName();
     $packageDir = $targetDir ? $packageName . '/' . $targetDir : $packageName;
     $rules = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;
     if (!$rules) {
         return;
     }
     $dir = $this->filesystem->normalizePath(realpath($vendorDir . '/' . $packageDir));
     if (!is_dir($dir)) {
         return false;
     }
     foreach ((array) $rules as $part) {
         // Split patterns for single globs (should be max 260 chars)
         $patterns = explode(' ', trim($part));
         foreach ($patterns as $pattern) {
             try {
                 foreach (glob($dir . '/' . $pattern) as $file) {
                     $this->filesystem->remove($file);
                 }
             } catch (\Exception $e) {
                 $this->io->write("Could not parse {$packageDir} ({$pattern}): " . $e->getMessage());
             }
         }
     }
     return true;
 }
Beispiel #3
0
 public function __construct($name, $version, $prettyVersion)
 {
     parent::__construct($name);
     $this->version = $version;
     $this->prettyVersion = $prettyVersion;
     $this->stability = VersionParser::parseStability($version);
     $this->dev = $this->stability === 'dev';
 }
 public function __toString()
 {
     return parent::__toString() . ' (alias of ' . $this->aliasOf->getVersion() . ')';
 }
 /**
  * @dataProvider formattedVersions
  */
 public function testFormatVersionForDevPackage(BasePackage $package, $truncate, $expected)
 {
     $this->assertSame($expected, $package->getFullPrettyVersion($truncate));
 }
Beispiel #6
0
 /**
  * Clean a package, based on its rules.
  *
  * @param BasePackage $package The package to clean
  * @return bool True if cleaned
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function cleanPackage(BasePackage $package)
 {
     $vendorDir = $this->config->get('vendor-dir');
     $targetDir = $package->getTargetDir();
     $packageName = $package->getPrettyName();
     $packageDir = $targetDir ? $packageName . '/' . $targetDir : $packageName;
     $rules = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;
     if (!$rules) {
         $this->io->writeError('Rules not found: ' . $packageName);
         return false;
     }
     $dir = $this->filesystem->normalizePath(realpath($vendorDir . '/' . $packageDir));
     if (!is_dir($dir)) {
         $this->io->writeError('Vendor dir not found: ' . $vendorDir . '/' . $packageDir);
         return false;
     }
     //$this->io->write('Rules: ' . print_r($rules, true));
     foreach ((array) $rules as $part) {
         // Split patterns for single globs (should be max 260 chars)
         $patterns = (array) $part;
         foreach ($patterns as $pattern) {
             try {
                 foreach (glob($dir . '/' . $pattern) as $file) {
                     $this->filesystem->remove($file);
                     //$this->io->write('File removed: ' . $file);
                 }
             } catch (\Exception $e) {
                 $this->io->write("Could not parse {$packageDir} ({$pattern}): " . $e->getMessage());
             }
         }
     }
     return true;
 }
Beispiel #7
0
 /**
  * Returns locker data for given package
  *
  * @param BasePackage
  * @return string
  */
 private function getLockerData(BasePackage $package)
 {
     $data = $this->composer->getLocker()->getLockData();
     foreach ((array) $data['packages'] as $pkgData) {
         if ($pkgData['name'] == $package->getName()) {
             return $pkgData;
         }
     }
     return NULL;
 }
Beispiel #8
0
 /**
  * Check if a given Composer package is compatible with this functionality.
  *
  * Compatible packages always have a vendor name of "message" and the
  * package name is either "cog" (for Cog itself) or is prefixed with "cog-"
  * (for cogules).
  *
  * @param  BasePackage $package The Composer package to check
  *
  * @return boolean              True if the package is compatible
  */
 public static function isPackageCompatible(BasePackage $package)
 {
     list($vendor, $name) = explode('/', $package->getPrettyName());
     return 'cog-' === substr($name, 0, 4) || 'cog' === $name;
 }