-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplemented PR#232, PR#110 #266
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/.settings | ||
/.project | ||
/.buildpath | ||
/satis.phar | ||
/vendor | ||
/phpunit.xml | ||
composer.phar | ||
.php_cs.cache | ||
/.settings | ||
/.project | ||
/.idea | ||
/.buildpath | ||
/satis.phar | ||
/vendor | ||
/phpunit.xml | ||
composer.phar | ||
.php_cs.cache |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ protected function configure() | |
new InputArgument('file', InputArgument::OPTIONAL, 'Json file to use', './satis.json'), | ||
new InputArgument('output-dir', InputArgument::OPTIONAL, 'Location where to output built files', null), | ||
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be built, if not provided all packages are.', null), | ||
new InputOption('repository-url', null, InputOption::VALUE_OPTIONAL, 'Only update the repository at given url', 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'), | ||
)) | ||
|
@@ -91,8 +92,13 @@ 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'); | ||
|
||
if ($repositoryUrl !== null && count($packagesFilter) > 0) { | ||
throw new \InvalidArgumentException('Package and repository-url argument can not be used together.'); | ||
} | ||
|
||
// load auth.json authentication information and pass it to the io interface | ||
$io = $this->getIO(); | ||
$io->loadConfiguration($this->getConfiguration()); | ||
|
@@ -124,7 +130,13 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
|
||
$composer = $this->getApplication()->getComposer(true, $config); | ||
$packageSelection = new PackageSelection($output, $outputDir, $config, $skipErrors); | ||
$packageSelection->setPackagesFilter($packagesFilter); | ||
|
||
if($repositoryUrl !== null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space here. |
||
$packageSelection->setRepositoryFilter($repositoryUrl); | ||
} else { | ||
$packageSelection->setPackagesFilter($packagesFilter); | ||
} | ||
|
||
$packages = $packageSelection->select($composer, $verbose); | ||
|
||
if (isset($config['archive']['directory'])) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ class PackageSelection | |
/** @var array The active package filter to merge. */ | ||
private $packagesFilter = array(); | ||
|
||
/** @var string The active repository filter to merge. */ | ||
private $repositoryFilter; | ||
|
||
/** @var array The selected packages from config */ | ||
private $selected = array(); | ||
|
||
|
@@ -89,6 +92,28 @@ private function fetchOptions($config) | |
$this->minimumStability = isset($config['minimum-stability']) ? $config['minimum-stability'] : 'dev'; | ||
} | ||
|
||
/** | ||
* Sets the active repository filter to merge | ||
* | ||
* @param string $repositoryFilter The active repository filter to merge | ||
*/ | ||
public function setRepositoryFilter($repositoryFilter) | ||
{ | ||
$this->repositoryFilter = $repositoryFilter; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Tells if repository list should be reduced to single repository | ||
* | ||
* @return bool true if repository filter is set | ||
*/ | ||
public function hasRepositoryFilter() | ||
{ | ||
return $this->repositoryFilter !== null; | ||
} | ||
|
||
/** | ||
* Sets the active package filter to merge | ||
* | ||
|
@@ -126,7 +151,16 @@ public function select(Composer $composer, $verbose) | |
|
||
$repos = $composer->getRepositoryManager()->getRepositories(); | ||
$pool = new Pool($this->minimumStability); | ||
foreach ($repos as $repo) { | ||
foreach ($repos as $key => $repo) { | ||
if ($this->hasRepositoryFilter()) { | ||
$repoConfig = $repo->getRepoConfig(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not safe to use the 'getRepoConfig()' method. It's not defined in the RepositoryInterface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So does Composer\Repository\ArtifactRepository, I guess. It really lacks of tests ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to submit more PR's guys. I'll accept anything, as long as it does not look insane. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both Pear and Artifact repository lack this method even though they both accept and work with $repoConfig. @alcohol Could this perhaps be implemented in Composer with a PR? Because at the moment I don't know how to get hold of repository url. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an additional interface with the method 'getRepoConfig()' would be ideal. In the satis code, it's then possible to check if the repository implements this interface. Meanwhile this could be fixed by checking, if the repo extends the ArrayRepository class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like a sane patch @realshadow if you wanna submit a PR.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dol, @JamesRezo this issue should be resolved after merging of composer/composer#4638. I can add additional check if repository class implements required interface later tonight, if neccessary. Sorry for delay :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great ! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @realshadow Don't worry about the delay. I'm happy that we'll be able to speed up our satis build soon. Thank you for your work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @realshadow don't forget to update the lockfile to depend on the latest version of |
||
if (isset($repoConfig['url']) && $repoConfig['url'] !== $this->repositoryFilter) { | ||
unset($repos[$key]); | ||
|
||
continue; | ||
} | ||
} | ||
|
||
try { | ||
$pool->addRepository($repo); | ||
} catch (\Exception $exception) { | ||
|
@@ -137,6 +171,10 @@ public function select(Composer $composer, $verbose) | |
} | ||
} | ||
|
||
if($this->hasRepositoryFilter() && count($repos) !== 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space here. |
||
throw new \InvalidArgumentException(sprintf('Specified repository url %s does not exist.', $this->repositoryFilter)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use quotes ( |
||
} | ||
|
||
$links = $this->requireAll ? $this->getAllLinks($repos, $this->minimumStability, $verbose) : $this->getFilteredLinks($composer); | ||
|
||
// process links if any | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to
The arguments "package" and "repository-url" ...