public setInput ( Symfony\Component\Console\Input\InputInterface $input ) | ||
$input | Symfony\Component\Console\Input\InputInterface |
/** * @param InputInterface $input The input instance * @param OutputInterface $output The output instance * * @throws JsonValidationException * @throws ParsingException * @throws \Exception * * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $verbose = $input->getOption('verbose'); $configFile = $input->getArgument('file'); $packagesFilter = $input->getArgument('packages'); $repositoryUrl = $input->getOption('repository-url'); $skipErrors = (bool) $input->getOption('skip-errors'); // load auth.json authentication information and pass it to the io interface $io = $this->getIO(); $io->loadConfiguration($this->getConfiguration()); if (preg_match('{^https?://}i', $configFile)) { $rfs = new RemoteFilesystem($io); $contents = $rfs->getContents(parse_url($configFile, PHP_URL_HOST), $configFile, false); $config = JsonFile::parseJson($contents, $configFile); } else { $file = new JsonFile($configFile); if (!$file->exists()) { $output->writeln('<error>File not found: ' . $configFile . '</error>'); return 1; } $config = $file->read(); } try { $this->check($configFile); } catch (JsonValidationException $e) { foreach ($e->getErrors() as $error) { $output->writeln(sprintf('<error>%s</error>', $error)); } if (!$skipErrors) { throw $e; } $output->writeln(sprintf('<warning>%s: %s</warning>', get_class($e), $e->getMessage())); } catch (ParsingException $e) { if (!$skipErrors) { throw $e; } $output->writeln(sprintf('<warning>%s: %s</warning>', get_class($e), $e->getMessage())); } catch (\UnexpectedValueException $e) { if (!$skipErrors) { throw $e; } $output->writeln(sprintf('<warning>%s: %s</warning>', get_class($e), $e->getMessage())); } if ($repositoryUrl !== null && count($packagesFilter) > 0) { throw new \InvalidArgumentException('The arguments "package" and "repository-url" can not be used together.'); } // disable packagist by default unset(Config::$defaultRepositories['packagist']); if (!($outputDir = $input->getArgument('output-dir'))) { $outputDir = isset($config['output-dir']) ? $config['output-dir'] : null; } if (null === $outputDir) { throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside ' . $input->getArgument('file')); } /** @var $application Application */ $application = $this->getApplication(); $composer = $application->getComposer(true, $config); $packageSelection = new PackageSelection($output, $outputDir, $config, $skipErrors); if ($repositoryUrl !== null) { $packageSelection->setRepositoryFilter($repositoryUrl); } else { $packageSelection->setPackagesFilter($packagesFilter); } $packages = $packageSelection->select($composer, $verbose); if (isset($config['archive']['directory'])) { $downloads = new ArchiveBuilder($output, $outputDir, $config, $skipErrors); $downloads->setComposer($composer); $downloads->setInput($input); $downloads->dump($packages); } if ($packageSelection->hasFilterForPackages() || $packageSelection->hasRepositoryFilter()) { // in case of an active filter we need to load the dumped packages.json and merge the // updated packages in $oldPackages = $packageSelection->load(); $packages += $oldPackages; ksort($packages); } $packagesBuilder = new PackagesBuilder($output, $outputDir, $config, $skipErrors); $packagesBuilder->dump($packages); if ($htmlView = !$input->getOption('no-html-output')) { $htmlView = !isset($config['output-html']) || $config['output-html']; } if ($htmlView) { $web = new WebBuilder($output, $outputDir, $config, $skipErrors); $web->setRootPackage($composer->getPackage()); $web->dump($packages); } return 0; }