1
0
Fork 0

Re-order repos so that packagist always has the lowest priority

pull/308/head
Jordi Boggiano 2012-02-17 16:59:26 +01:00
parent 4d7ecdcb69
commit b2076c2462
1 changed files with 18 additions and 7 deletions

View File

@ -67,7 +67,7 @@ class Factory
$binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir'];
// initialize repository manager
$rm = $this->createRepositoryManager($io, $vendorDir);
$rm = $this->createRepositoryManager($io);
// initialize download manager
$dm = $this->createDownloadManager($io);
@ -75,15 +75,17 @@ class Factory
// initialize installation manager
$im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io);
// load default repository unless it's explicitly disabled
if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) {
$this->addPackagistRepository($rm);
}
$this->addLocalRepository($rm, $vendorDir);
// load package
$loader = new Package\Loader\RootPackageLoader($rm);
$package = $loader->load($packageConfig);
// load default repository unless it's explicitly disabled
if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) {
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
}
// init locker
$lockFile = substr($composerFile, -5) === '.json' ? substr($composerFile, 0, -4).'lock' : $composerFile . '.lock';
$locker = new Package\Locker(new JsonFile($lockFile), $rm, md5_file($composerFile));
@ -102,7 +104,6 @@ class Factory
protected function createRepositoryManager(IOInterface $io, $vendorDir)
{
$rm = new Repository\RepositoryManager($io);
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
@ -111,6 +112,16 @@ class Factory
return $rm;
}
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
{
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
}
protected function addPackagistRepository(RepositoryManager $rm)
{
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
}
protected function createDownloadManager(IOInterface $io)
{
$dm = new Downloader\DownloadManager();