Merge remote-tracking branch 'lcobucci/master'
Conflicts: src/Composer/Downloader/FileDownloader.phppull/2604/head
commit
016a016455
|
@ -118,7 +118,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
$retries = 3;
|
$retries = 3;
|
||||||
while ($retries--) {
|
while ($retries--) {
|
||||||
try {
|
try {
|
||||||
$rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
|
$rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress, $package->getOptions());
|
||||||
break;
|
break;
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
// if we got an http response with a proper code, then requesting again will probably not help, abort
|
// if we got an http response with a proper code, then requesting again will probably not help, abort
|
||||||
|
|
|
@ -49,6 +49,7 @@ abstract class BasePackage implements PackageInterface
|
||||||
|
|
||||||
protected $repository;
|
protected $repository;
|
||||||
protected $id;
|
protected $id;
|
||||||
|
protected $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All descendants' constructors should call this parent constructor
|
* All descendants' constructors should call this parent constructor
|
||||||
|
@ -60,6 +61,7 @@ abstract class BasePackage implements PackageInterface
|
||||||
$this->prettyName = $name;
|
$this->prettyName = $name;
|
||||||
$this->name = strtolower($name);
|
$this->name = strtolower($name);
|
||||||
$this->id = -1;
|
$this->id = -1;
|
||||||
|
$this->options = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,6 +135,22 @@ abstract class BasePackage implements PackageInterface
|
||||||
return $this->repository;
|
return $this->repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getOptions()
|
||||||
|
{
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function setOptions(array $options)
|
||||||
|
{
|
||||||
|
$this->options = $options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if this package is a platform package
|
* checks if this package is a platform package
|
||||||
*
|
*
|
||||||
|
|
|
@ -108,6 +108,10 @@ class ArrayDumper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($package->getOptions()) > 0) {
|
||||||
|
$data['options'] = $package->getOptions();
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,6 +197,10 @@ class ArrayLoader implements LoaderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($config['options'])) {
|
||||||
|
$package->setOptions($config['options']);
|
||||||
|
}
|
||||||
|
|
||||||
return $package;
|
return $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,6 +230,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
// TODO validate package repositories' packages using this recursively
|
// TODO validate package repositories' packages using this recursively
|
||||||
|
|
||||||
$this->validateFlatArray('include-path');
|
$this->validateFlatArray('include-path');
|
||||||
|
$this->validateArray('options');
|
||||||
|
|
||||||
// branch alias validation
|
// branch alias validation
|
||||||
if (isset($this->config['extra']['branch-alias'])) {
|
if (isset($this->config['extra']['branch-alias'])) {
|
||||||
|
|
|
@ -313,4 +313,18 @@ interface PackageInterface
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getArchiveExcludes();
|
public function getArchiveExcludes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the list of options to download package dist files
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function setOptions(array $options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of options to download package dist files
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getOptions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\Repository;
|
namespace Composer\Repository;
|
||||||
|
|
||||||
use Composer\Package\Loader\ArrayLoader;
|
use Composer\Package\Loader\ArrayLoader;
|
||||||
|
use Composer\Package\Package;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\AliasPackage;
|
use Composer\Package\AliasPackage;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
@ -209,10 +210,19 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
||||||
$package = $package->getAliasOf();
|
$package = $package->getAliasOf();
|
||||||
}
|
}
|
||||||
$package->setRepository($this);
|
$package->setRepository($this);
|
||||||
|
$this->configurePackageOptions($package);
|
||||||
|
|
||||||
return $package;
|
return $package;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function configurePackageOptions(PackageInterface $package)
|
||||||
|
{
|
||||||
|
if ($package instanceof Package
|
||||||
|
&& strpos($package->getDistUrl(), $this->baseUrl) === 0) {
|
||||||
|
$package->setOptions($this->options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -381,6 +391,17 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new package to the repository
|
||||||
|
*
|
||||||
|
* @param PackageInterface $package
|
||||||
|
*/
|
||||||
|
public function addPackage(PackageInterface $package)
|
||||||
|
{
|
||||||
|
parent::addPackage($package);
|
||||||
|
$this->configurePackageOptions($package);
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadRootServerFile()
|
protected function loadRootServerFile()
|
||||||
{
|
{
|
||||||
if (null !== $this->rootData) {
|
if (null !== $this->rootData) {
|
||||||
|
|
|
@ -89,6 +89,10 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getDistUrl')
|
->method('getDistUrl')
|
||||||
->will($this->returnValue('http://example.com/script.js'))
|
->will($this->returnValue('http://example.com/script.js'))
|
||||||
;
|
;
|
||||||
|
$packageMock->expects($this->atLeastOnce())
|
||||||
|
->method('getOptions')
|
||||||
|
->will($this->returnValue(array()))
|
||||||
|
;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$path = sys_get_temp_dir().'/'.md5(time().mt_rand());
|
$path = sys_get_temp_dir().'/'.md5(time().mt_rand());
|
||||||
|
@ -161,6 +165,10 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getDistUrl')
|
->method('getDistUrl')
|
||||||
->will($this->returnValue('http://example.com/script.js'))
|
->will($this->returnValue('http://example.com/script.js'))
|
||||||
;
|
;
|
||||||
|
$packageMock->expects($this->atLeastOnce())
|
||||||
|
->method('getOptions')
|
||||||
|
->will($this->returnValue(array()))
|
||||||
|
;
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getDistSha1Checksum')
|
->method('getDistSha1Checksum')
|
||||||
->will($this->returnValue('invalid'))
|
->will($this->returnValue('invalid'))
|
||||||
|
|
|
@ -30,6 +30,10 @@ class ZipDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->method('getDistUrl')
|
->method('getDistUrl')
|
||||||
->will($this->returnValue('file://'.__FILE__))
|
->will($this->returnValue('file://'.__FILE__))
|
||||||
;
|
;
|
||||||
|
$packageMock->expects($this->atLeastOnce())
|
||||||
|
->method('getOptions')
|
||||||
|
->will($this->returnValue(array()))
|
||||||
|
;
|
||||||
|
|
||||||
$io = $this->getMock('Composer\IO\IOInterface');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
$config = $this->getMock('Composer\Config');
|
$config = $this->getMock('Composer\Config');
|
||||||
|
|
|
@ -194,6 +194,10 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
'conflicts',
|
'conflicts',
|
||||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'options',
|
||||||
|
array('ssl' => array('local_cert' => '/opt/certs/test.pem'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
'archive' => array(
|
'archive' => array(
|
||||||
'exclude' => array('/foo/bar', 'baz', '!/foo/bar/baz'),
|
'exclude' => array('/foo/bar', 'baz', '!/foo/bar/baz'),
|
||||||
),
|
),
|
||||||
|
'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$package = $this->loader->load($config);
|
$package = $this->loader->load($config);
|
||||||
|
|
|
@ -146,6 +146,7 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
'bin/foo',
|
'bin/foo',
|
||||||
'bin/bar',
|
'bin/bar',
|
||||||
),
|
),
|
||||||
|
'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem'))
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
array( // test as array
|
array( // test as array
|
||||||
|
@ -263,6 +264,15 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
'autoload : invalid value (psr0), must be one of psr-0, psr-4, classmap, files'
|
'autoload : invalid value (psr0), must be one of psr-0, psr-4, classmap, files'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'name' => 'foo/bar',
|
||||||
|
'options' => 'test',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'options : should be an array, string given'
|
||||||
|
)
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue