Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/Composer/Satis/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function configure()
new InputArgument('output-dir', InputArgument::OPTIONAL, 'Location where to output built files', null),
new InputOption('no-html-output', null, InputOption::VALUE_NONE, 'Turn off HTML view'),
new InputOption('skip-errors', null, InputOption::VALUE_NONE, 'Skip Download or Archive errors'),
new InputOption('repository-url', null, InputOption::VALUE_OPTIONAL, 'Only update the repository at given url', null),
))
->setHelp(<<<EOT
The <info>build</info> command reads the given json file
Expand Down Expand Up @@ -128,8 +129,39 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside '.$input->getArgument('file'));
}

$composer = $this->getApplication()->getComposer(true, $config);
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies);

if (($singleRepositoryUrl = $input->getOption('repository-url')) !== null
&& FALSE !== ($otherPackagesCache = @file_get_contents($outputDir.'/packages.cache')))
{
$singleRepositoryUrl = $input->getOption('repository-url');

$otherPackages = unserialize($otherPackagesCache);

// find repository configuration
$singleRepositoryConfig = null;
foreach ($config['repositories'] as $r) {
if ($r['url'] == $singleRepositoryUrl) {
$singleRepositoryConfig = $r;
break;
}
}
if ($singleRepositoryConfig === null) {
throw new \InvalidArgumentException('Requested repository not found in configuration: '.$singleRepositoryUrl);
}

// use only selected repository
$config['repositories'] = array($singleRepositoryConfig);

$composer = $this->getApplication()->getComposer(true, $config);
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies);

// merge with cached data
$packages = array_merge($otherPackages, $packages);
ksort($packages, SORT_STRING);
} else {
$composer = $this->getApplication()->getComposer(true, $config);
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies);
}

if ($htmlView = !$input->getOption('no-html-output')) {
$htmlView = !isset($config['output-html']) || $config['output-html'];
Expand All @@ -140,6 +172,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->dumpDownloads($config, $packages, $output, $outputDir, $skipErrors);
}

file_put_contents($outputDir.'/packages.cache', serialize($packages));

$filename = $outputDir.'/packages.json';
$this->dumpJson($packages, $output, $filename);

Expand Down