Merge remote-tracking branch 'bamarni/config-repo-options'
commit
c5cb2327cf
|
@ -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
|
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
|
## create-project
|
||||||
|
|
||||||
You can use Composer to create new projects from an existing package. This is
|
You can use Composer to create new projects from an existing package. This is
|
||||||
|
|
|
@ -438,10 +438,19 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 === count($values)) {
|
if (1 === count($values)) {
|
||||||
$bool = strtolower($values[0]);
|
$value = strtolower($values[0]);
|
||||||
if (true === $booleanValidator($bool) && false === $booleanNormalizer($bool)) {
|
if (true === $booleanValidator($value)) {
|
||||||
|
if (false === $booleanNormalizer($value)) {
|
||||||
return $this->configSource->addRepository($matches[1], false);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
|
throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,24 @@ class JsonConfigSourceTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertFileEquals($this->fixturePath('config/config-with-exampletld-repository.json'), $config);
|
$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()
|
public function testRemoveRepository()
|
||||||
{
|
{
|
||||||
$config = $this->workingDir.'/composer.json';
|
$config = $this->workingDir.'/composer.json';
|
||||||
|
|
Loading…
Reference in New Issue