Ejemplo n.º 1
0
 /**
  * @param CompletePackageInterface $package
  *
  * @return Package
  */
 public static function createFromComposerPackage(CompletePackageInterface $package)
 {
     $class = new self();
     $class->type = $package->getType();
     $class->name = $package->getPrettyName();
     $class->description = $package->getDescription();
     $class->authors = $package->getAuthors();
     $class->keywords = $package->getKeywords();
     if ($package->getVersion() === '9999999-dev') {
         $class->version = sprintf('%s (%s)', $package->getPrettyVersion(), substr($package->getSourceReference(), 0, 6));
     } else {
         $class->version = $package->getPrettyVersion();
     }
     return $class;
 }
Ejemplo n.º 2
0
 /**
  * prints package meta data
  */
 protected function printMeta(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
 {
     $output->writeln('<info>name</info>     : ' . $package->getPrettyName());
     $output->writeln('<info>descrip.</info> : ' . $package->getDescription());
     $output->writeln('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
     $this->printVersions($input, $output, $package, $versions, $installedRepo, $repos);
     $output->writeln('<info>type</info>     : ' . $package->getType());
     $output->writeln('<info>license</info>  : ' . implode(', ', $package->getLicense()));
     $output->writeln('<info>source</info>   : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
     $output->writeln('<info>dist</info>     : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
     $output->writeln('<info>names</info>    : ' . implode(', ', $package->getNames()));
     if ($package->getSupport()) {
         $output->writeln("\n<info>support</info>");
         foreach ($package->getSupport() as $type => $value) {
             $output->writeln('<comment>' . $type . '</comment> : ' . $value);
         }
     }
     if ($package->getAutoload()) {
         $output->writeln("\n<info>autoload</info>");
         foreach ($package->getAutoload() as $type => $autoloads) {
             $output->writeln('<comment>' . $type . '</comment>');
             if ($type === 'psr-0') {
                 foreach ($autoloads as $name => $path) {
                     $output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                 }
             } elseif ($type === 'psr-4') {
                 foreach ($autoloads as $name => $path) {
                     $output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                 }
             } elseif ($type === 'classmap') {
                 $output->writeln(implode(', ', $autoloads));
             }
         }
         if ($package->getIncludePaths()) {
             $output->writeln('<comment>include-path</comment>');
             $output->writeln(implode(', ', $package->getIncludePaths()));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Prints package metadata.
  *
  * @param CompletePackageInterface $package
  * @param array                    $versions
  * @param RepositoryInterface      $installedRepo
  */
 protected function printMeta(CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, PackageInterface $latestPackage = null)
 {
     $io = $this->getIO();
     $io->write('<info>name</info>     : ' . $package->getPrettyName());
     $io->write('<info>descrip.</info> : ' . $package->getDescription());
     $io->write('<info>keywords</info> : ' . join(', ', $package->getKeywords() ?: array()));
     $this->printVersions($package, $versions, $installedRepo);
     if ($latestPackage) {
         $style = $this->getVersionStyle($latestPackage, $package);
         $io->write('<info>latest</info>   : <' . $style . '>' . $latestPackage->getPrettyVersion() . '</' . $style . '>');
     } else {
         $latestPackage = $package;
     }
     $io->write('<info>type</info>     : ' . $package->getType());
     $this->printLicenses($package);
     $io->write('<info>source</info>   : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
     $io->write('<info>dist</info>     : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
     $io->write('<info>names</info>    : ' . implode(', ', $package->getNames()));
     if ($latestPackage->isAbandoned()) {
         $replacement = $latestPackage->getReplacementPackage() !== null ? ' The author suggests using the ' . $latestPackage->getReplacementPackage() . ' package instead.' : null;
         $io->writeError(sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement));
     }
     if ($package->getSupport()) {
         $io->write("\n<info>support</info>");
         foreach ($package->getSupport() as $type => $value) {
             $io->write('<comment>' . $type . '</comment> : ' . $value);
         }
     }
     if ($package->getAutoload()) {
         $io->write("\n<info>autoload</info>");
         foreach ($package->getAutoload() as $type => $autoloads) {
             $io->write('<comment>' . $type . '</comment>');
             if ($type === 'psr-0') {
                 foreach ($autoloads as $name => $path) {
                     $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                 }
             } elseif ($type === 'psr-4') {
                 foreach ($autoloads as $name => $path) {
                     $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                 }
             } elseif ($type === 'classmap') {
                 $io->write(implode(', ', $autoloads));
             }
         }
         if ($package->getIncludePaths()) {
             $io->write('<comment>include-path</comment>');
             $io->write(implode(', ', $package->getIncludePaths()));
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Returns a package tag list.
  *
  * @param CompletePackageInterface $package
  *
  * @return array
  */
 public function getPackageTags(CompletePackageInterface $package)
 {
     $ds = DIRECTORY_SEPARATOR;
     putenv("COMPOSER_HOME={$this->vendorDir}{$ds}composer");
     $repos = Factory::createDefaultRepositories(new NullIO());
     $compositeRepo = new CompositeRepository($repos);
     $pkgs = $compositeRepo->findPackages($package->getPrettyName());
     $tags = array();
     foreach ($pkgs as $pkg) {
         $tags[] = $pkg->getPrettyVersion();
     }
     return $tags;
 }