예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setGithubToken($output);
     $packageName = $input->getArgument('package');
     $property = $input->getArgument('property');
     $packageNameVersion = PackageNameVersionExtractor::fromString($packageName);
     $package = new Package($packageNameVersion->name, $packageNameVersion->version);
     $bowerphp = $this->getBowerphp($output);
     $bowerJsonFile = $bowerphp->getPackageBowerFile($package);
     if ($packageNameVersion->version == '*') {
         $versions = $bowerphp->getPackageInfo($package, 'versions');
     }
     if (!is_null($property)) {
         $bowerArray = json_decode($bowerJsonFile, true);
         $propertyValue = isset($bowerArray[$property]) ? $bowerArray[$property] : '';
         $this->consoleOutput->writelnJsonText($propertyValue);
         return;
     }
     $this->consoleOutput->writelnJson($bowerJsonFile);
     if ($packageNameVersion->version != '*') {
         return;
     }
     $output->writeln('');
     if (empty($versions)) {
         $output->writeln('No versions available.');
     } else {
         $output->writeln('<fg=cyan>Available versions:</fg=cyan>');
         foreach ($versions as $vrs) {
             $output->writeln("- {$vrs}");
         }
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setGithubToken($output);
     $packageName = $input->getArgument('package');
     $packageNameVersion = PackageNameVersionExtractor::fromString($packageName);
     $package = new Package($packageNameVersion->name, $packageNameVersion->version);
     $bowerphp = $this->getBowerphp($output);
     $url = $bowerphp->getPackageInfo($package);
     $default = $this->getDefaultBrowser();
     $arg = "{$default} \"{$url}\"";
     if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) {
         $output->writeln($arg);
     } else {
         $output->writeln('');
     }
     // @codeCoverageIgnoreStart
     if (!defined('PHPUNIT_BOWER_TESTSUITE')) {
         $browser = new Process($arg);
         $browser->start();
         while ($browser->isRunning()) {
             // do nothing...
         }
     }
     // @codeCoverageIgnoreEnd
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setGithubToken($output);
     $name = $input->getArgument('package');
     $packageNameVersion = PackageNameVersionExtractor::fromString($name);
     $bowerphp = $this->getBowerphp($output);
     $package = $bowerphp->lookupPackage($packageNameVersion->name);
     $this->consoleOutput->writelnSearchOrLookup($package['name'], $package['url']);
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setGithubToken($output);
     $packageName = $input->getArgument('package');
     $bowerphp = $this->getBowerphp($output);
     try {
         $installer = new Installer($this->filesystem, new ZipArchive(), $this->config);
         $packageNameVersion = PackageNameVersionExtractor::fromString($packageName);
         $package = new Package($packageNameVersion->name, $packageNameVersion->version);
         $bowerphp->uninstallPackage($package, $installer);
     } catch (\RuntimeException $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
         return 1;
     }
     $output->writeln('');
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setGithubToken($output);
     $this->config->setSaveToBowerJsonFile($input->getOption('save'));
     $packageName = $input->getArgument('package');
     $bowerphp = $this->getBowerphp($output);
     try {
         $installer = new Installer($this->filesystem, new ZipArchive(), $this->config);
         if (is_null($packageName)) {
             $bowerphp->installDependencies($installer);
         } else {
             if (substr($packageName, -10) === 'bower.json') {
                 if (!is_readable($packageName)) {
                     $output->writeln(sprintf('<error>Cannot read file %s</error>', $packageName));
                     return 1;
                 }
                 $json = json_decode($this->filesystem->read($packageName), true);
                 if (empty($json['dependencies'])) {
                     $output->writeln(sprintf('<error>Nothing to install in %s</error>', $packageName));
                     return 1;
                 }
                 foreach ($json['dependencies'] as $name => $version) {
                     $package = new Package($name, $version);
                     $bowerphp->installPackage($package, $installer);
                 }
             } else {
                 $packageNameVersion = PackageNameVersionExtractor::fromString($packageName);
                 $package = new Package($packageNameVersion->name, $packageNameVersion->version);
                 $bowerphp->installPackage($package, $installer);
             }
         }
     } catch (\RuntimeException $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
         if ($e->getCode() == GithubRepository::VERSION_NOT_FOUND && !empty($package)) {
             $output->writeln(sprintf('Available versions: %s', implode(', ', $bowerphp->getPackageInfo($package, 'versions'))));
         }
         return 1;
     }
     $output->writeln('');
 }