Implement the RemoteFilesystem Factory everywhere...
- also fixes impacted testpull/2745/head
parent
9881d76216
commit
306ba77e93
|
@ -234,7 +234,7 @@ EOT
|
||||||
if (null === $repositoryUrl) {
|
if (null === $repositoryUrl) {
|
||||||
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
|
$sourceRepo = new CompositeRepository(Factory::createDefaultRepositories($io, $config));
|
||||||
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION)) {
|
} elseif ("json" === pathinfo($repositoryUrl, PATHINFO_EXTENSION)) {
|
||||||
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, new RemoteFilesystem($io)));
|
$sourceRepo = new FilesystemRepository(new JsonFile($repositoryUrl, Factory::createRemoteFilesystem($io, $config)));
|
||||||
} elseif (0 === strpos($repositoryUrl, 'http')) {
|
} elseif (0 === strpos($repositoryUrl, 'http')) {
|
||||||
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
|
$sourceRepo = new ComposerRepository(array('url' => $repositoryUrl), $io, $config);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
use Composer\Cache;
|
use Composer\Cache;
|
||||||
|
use Composer\Factory;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
@ -56,7 +57,7 @@ class FileDownloader implements DownloaderInterface
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->rfs = $rfs ?: new RemoteFilesystem($io);
|
$this->rfs = $rfs ?: Factory::createRemoteFilesystem($this->io, $config);
|
||||||
$this->filesystem = $filesystem ?: new Filesystem();
|
$this->filesystem = $filesystem ?: new Filesystem();
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\Downloader;
|
namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
use Composer\Factory;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
|
|
|
@ -195,24 +195,7 @@ class Factory
|
||||||
if (is_string($localConfig)) {
|
if (is_string($localConfig)) {
|
||||||
$composerFile = $localConfig;
|
$composerFile = $localConfig;
|
||||||
|
|
||||||
$rfs = null;
|
$rfs = Factory::createRemoteFilesystem($io);
|
||||||
if (preg_match("|^https?://|i", $localConfig)) {
|
|
||||||
$disableTls = false;
|
|
||||||
if($input->getOption('disable-tls')) {
|
|
||||||
//$output->writeln('<warning>You are running Composer with SSL/TLS protection disabled.</warning>'); //TODO
|
|
||||||
$disableTls = true;
|
|
||||||
} elseif (!extension_loaded('openssl')) {
|
|
||||||
throw new \RuntimeException('The openssl extension is required for SSL/TLS protection but is not available. '
|
|
||||||
. 'You can disable this error, at your own risk, by passing the \'--disable-tls\' option to this command.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rfsOptions = array();
|
|
||||||
if ($disableTls === false && !is_null($input->getOption('cafile'))) {
|
|
||||||
$rfsOptions = array('ssl'=>array('cafile'=>$input->getOption('cafile')));
|
|
||||||
}
|
|
||||||
$rfs = new RemoteFilesystem($io, $rfsOptions, $disableTls);
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = new JsonFile($localConfig, $rfs);
|
$file = new JsonFile($localConfig, $rfs);
|
||||||
|
|
||||||
if (!$file->exists()) {
|
if (!$file->exists()) {
|
||||||
|
@ -468,10 +451,16 @@ class Factory
|
||||||
return $factory->createComposer($io, $config, $disablePlugins, $input);
|
return $factory->createComposer($io, $config, $disablePlugins, $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createRemoteFilesystem(IOInterface $io, Config $config, $options = array())
|
/**
|
||||||
|
* @param IOInterface $io IO instance
|
||||||
|
* @param Config $config Config instance
|
||||||
|
* @param array $options Array of options passed directly to RemoteFilesystem constructor
|
||||||
|
* @return RemoteFilesystem
|
||||||
|
*/
|
||||||
|
public static function createRemoteFilesystem(IOInterface $io, Config $config = null, $options = array())
|
||||||
{
|
{
|
||||||
$disableTls = false;
|
$disableTls = false;
|
||||||
if($config->get('disable-tls') === true || $io->getInputOption('disable-tls')) {
|
if((isset($config) && $config->get('disable-tls') === true) || $io->getInputOption('disable-tls')) {
|
||||||
$io->write('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
|
$io->write('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
|
||||||
$disableTls = true;
|
$disableTls = true;
|
||||||
} elseif (!extension_loaded('openssl')) {
|
} elseif (!extension_loaded('openssl')) {
|
||||||
|
@ -480,7 +469,7 @@ class Factory
|
||||||
}
|
}
|
||||||
$remoteFilesystemOptions = array();
|
$remoteFilesystemOptions = array();
|
||||||
if ($disableTls === false) {
|
if ($disableTls === false) {
|
||||||
if (!empty($config->get('cafile'))) {
|
if (isset($config) && !empty($config->get('cafile'))) {
|
||||||
$remoteFilesystemOptions = array('ssl'=>array('cafile'=>$config->get('cafile')));
|
$remoteFilesystemOptions = array('ssl'=>array('cafile'=>$config->get('cafile')));
|
||||||
}
|
}
|
||||||
if (!empty($io->getInputOption('cafile'))) {
|
if (!empty($io->getInputOption('cafile'))) {
|
||||||
|
|
|
@ -164,4 +164,22 @@ interface IOInterface
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
*/
|
*/
|
||||||
public function loadConfiguration(Config $config);
|
public function loadConfiguration(Config $config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of an input option
|
||||||
|
*
|
||||||
|
* @param string $optionName The name of the option whose value is to be retrieved
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getInputOption($optionName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of an input argument
|
||||||
|
*
|
||||||
|
* @param string $argumentName The name of the argument whose value is to be retrieved
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getInputArgument($argumentName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,4 +104,20 @@ class NullIO extends BaseIO
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getInputOption($optionName)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getInputArgument($ArgumentName)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Composer\DependencyResolver\Pool;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
use Composer\Cache;
|
use Composer\Cache;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
use Composer\Factory;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
use Composer\Plugin\PluginEvents;
|
use Composer\Plugin\PluginEvents;
|
||||||
|
@ -85,7 +86,7 @@ class ComposerRepository extends ArrayRepository implements StreamableRepository
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
|
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
|
||||||
$this->loader = new ArrayLoader();
|
$this->loader = new ArrayLoader();
|
||||||
$this->rfs = new RemoteFilesystem($this->io, $this->options);
|
$this->rfs = Factory::createRemoteFilesystem($this->io, $this->config, $this->options);
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use Composer\Package\Link;
|
||||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
use Composer\Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds list of package from PEAR channel.
|
* Builds list of package from PEAR channel.
|
||||||
|
@ -57,7 +58,7 @@ class PearRepository extends ArrayRepository
|
||||||
|
|
||||||
$this->url = rtrim($repoConfig['url'], '/');
|
$this->url = rtrim($repoConfig['url'], '/');
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->rfs = $rfs ?: new RemoteFilesystem($this->io);
|
$this->rfs = $rfs ?: Factory::createRemoteFilesystem($this->io, $config);
|
||||||
$this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null;
|
$this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null;
|
||||||
$this->versionParser = new VersionParser();
|
$this->versionParser = new VersionParser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Composer\Repository\Vcs;
|
||||||
|
|
||||||
use Composer\Downloader\TransportException;
|
use Composer\Downloader\TransportException;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
|
use Composer\Factory;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
|
@ -57,7 +58,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->process = $process ?: new ProcessExecutor($io);
|
$this->process = $process ?: new ProcessExecutor($io);
|
||||||
$this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io);
|
$this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ class ConfigValidator
|
||||||
// validate json schema
|
// validate json schema
|
||||||
$laxValid = false;
|
$laxValid = false;
|
||||||
try {
|
try {
|
||||||
$json = new JsonFile($file, new RemoteFilesystem($this->io)); //TODO
|
$json = new JsonFile($file, Factory::createRemoteFilesystem($this->io)); //TODO
|
||||||
$manifest = $json->read();
|
$manifest = $json->read();
|
||||||
|
|
||||||
$json->validateSchema(JsonFile::LAX_SCHEMA);
|
$json->validateSchema(JsonFile::LAX_SCHEMA);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class GitHub
|
||||||
$this->io = $io;
|
$this->io = $io;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->process = $process ?: new ProcessExecutor;
|
$this->process = $process ?: new ProcessExecutor;
|
||||||
$this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io);
|
$this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,15 @@ class ZipDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$io = $this->getMock('Composer\IO\IOInterface');
|
$io = $this->getMock('Composer\IO\IOInterface');
|
||||||
$config = $this->getMock('Composer\Config');
|
$config = $this->getMock('Composer\Config');
|
||||||
$config->expects($this->any())
|
$config->expects($this->at(0))
|
||||||
|
->method('get')
|
||||||
|
->with('disable-tls')
|
||||||
|
->will($this->returnValue(false));
|
||||||
|
$config->expects($this->at(1))
|
||||||
|
->method('get')
|
||||||
|
->with('cafile')
|
||||||
|
->will($this->returnValue(null));
|
||||||
|
$config->expects($this->at(2))
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('vendor-dir')
|
->with('vendor-dir')
|
||||||
->will($this->returnValue(sys_get_temp_dir().'/composer-zip-test-vendor'));
|
->will($this->returnValue(sys_get_temp_dir().'/composer-zip-test-vendor'));
|
||||||
|
|
Loading…
Reference in New Issue