1
0
Fork 0

Merge remote-tracking branch 'bamarni/config-repo-options'

pull/4837/head
Jordi Boggiano 2016-01-25 21:28:22 +00:00
commit c5cb2327cf
4 changed files with 51 additions and 3 deletions

View File

@ -466,6 +466,12 @@ changes to the repositories section by using it the following way:
php composer.phar config repositories.foo vcs https://github.com/foo/bar
```
If your repository requires more configuration options, you can instead pass its JSON representation :
```sh
php composer.phar config repositories.foo '{"type": "vcs", "url": "http://svn.example.org/my-project/", "trunk-path": "master"}'
```
## create-project
You can use Composer to create new projects from an existing package. This is

View File

@ -438,9 +438,18 @@ EOT
}
if (1 === count($values)) {
$bool = strtolower($values[0]);
if (true === $booleanValidator($bool) && false === $booleanNormalizer($bool)) {
return $this->configSource->addRepository($matches[1], false);
$value = strtolower($values[0]);
if (true === $booleanValidator($value)) {
if (false === $booleanNormalizer($value)) {
return $this->configSource->addRepository($matches[1], false);
}
} else {
$value = json_decode($values[0], true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(sprintf('%s is not valid JSON.', $values[0]));
}
return $this->configSource->addRepository($matches[1], $value);
}
}

View File

@ -0,0 +1,15 @@
{
"name": "my-vend/my-app",
"license": "MIT",
"repositories": {
"example_tld": {
"type": "composer",
"url": "https://example.tld",
"options": {
"ssl": {
"local_cert": "/home/composer/.ssl/composer.pem"
}
}
}
}
}

View File

@ -52,6 +52,24 @@ class JsonConfigSourceTest extends \PHPUnit_Framework_TestCase
$this->assertFileEquals($this->fixturePath('config/config-with-exampletld-repository.json'), $config);
}
public function testAddRepositoryWithOptions()
{
$config = $this->workingDir.'/composer.json';
copy($this->fixturePath('composer-repositories.json'), $config);
$jsonConfigSource = new JsonConfigSource(new JsonFile($config));
$jsonConfigSource->addRepository('example_tld', array(
'type' => 'composer',
'url' => 'https://example.tld',
'options' => array(
'ssl' => array(
'local_cert' => '/home/composer/.ssl/composer.pem'
)
)
));
$this->assertFileEquals($this->fixturePath('config/config-with-exampletld-repository-and-options.json'), $config);
}
public function testRemoveRepository()
{
$config = $this->workingDir.'/composer.json';