1
0
Fork 0

Merge pull request #3506 from naderman/fix-require-use-repos

Fix require use repos
pull/2581/merge
Jordi Boggiano 2014-12-04 15:15:55 +00:00
commit 69275867cf
2 changed files with 18 additions and 8 deletions

View File

@ -33,8 +33,9 @@ use Symfony\Component\Process\ExecutableFinder;
*/
class InitCommand extends Command
{
protected $repos;
private $gitConfig;
private $repos;
private $pool;
public function parseAuthorString($author)

View File

@ -23,6 +23,8 @@ use Composer\Json\JsonManipulator;
use Composer\Package\Version\VersionParser;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@ -78,14 +80,22 @@ EOT
}
$json = new JsonFile($file);
$composer = $json->read();
$composerDefinition = $json->read();
$composerBackup = file_get_contents($json->getPath());
$composer = $this->getComposer();
$repos = $composer->getRepositoryManager()->getRepositories();
$this->repos = new CompositeRepository(array_merge(
array(new PlatformRepository),
$repos
));
$requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'));
$requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
$removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
$baseRequirements = array_key_exists($requireKey, $composer) ? $composer[$requireKey] : array();
$baseRequirements = array_key_exists($requireKey, $composerDefinition) ? $composerDefinition[$requireKey] : array();
$requirements = $this->formatRequirements($requirements);
// validate requirements format
@ -98,13 +108,13 @@ EOT
foreach ($requirements as $package => $version) {
$baseRequirements[$package] = $version;
if (isset($composer[$removeKey][$package])) {
unset($composer[$removeKey][$package]);
if (isset($composerDefinition[$removeKey][$package])) {
unset($composerDefinition[$removeKey][$package]);
}
}
$composer[$requireKey] = $baseRequirements;
$json->write($composer);
$composerDefinition[$requireKey] = $baseRequirements;
$json->write($composerDefinition);
}
$output->writeln('<info>'.$file.' has been '.($newlyCreated ? 'created' : 'updated').'</info>');
@ -115,7 +125,6 @@ EOT
$updateDevMode = !$input->getOption('update-no-dev');
// Update packages
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();