1
0
Fork 0

Merge pull request #1658 from miklosm/iss553

Adds 'prefer-source' option to config
pull/1661/merge
Jordi Boggiano 2013-03-05 04:46:36 -08:00
commit b10bd5f161
6 changed files with 61 additions and 8 deletions

View File

@ -581,6 +581,9 @@ The following options are supported:
higher if you have a slow connection or huge vendors. higher if you have a slow connection or huge vendors.
* **use-include-path:** Defaults to `false`. If true, the Composer autoloader * **use-include-path:** Defaults to `false`. If true, the Composer autoloader
will also look for classes in the PHP include path. will also look for classes in the PHP include path.
* **preferred-install:** Defaults to `auto` and can be any of `source`, `dist` or
`auto`. This option allows you to set the install method Composer will prefer to
use.
* **github-protocols:** Defaults to `["git", "https", "http"]`. A list of * **github-protocols:** Defaults to `["git", "https", "http"]`. A list of
protocols to use for github.com clones, in priority order. Use this if you are protocols to use for github.com clones, in priority order. Use this if you are
behind a proxy or have somehow bad performances with the git protocol. behind a proxy or have somehow bad performances with the git protocol.

View File

@ -116,6 +116,10 @@
"type": "boolean", "type": "boolean",
"description": "If true, the Composer autoloader will also look for classes in the PHP include path." "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
}, },
"preferred-install": {
"type": "string",
"description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist or auto."
},
"notify-on-install": { "notify-on-install": {
"type": "boolean", "type": "boolean",
"description": "Composer allows repositories to define a notification URL, so that they get notified whenever a package from that repository is installed. This option allows you to disable that behaviour, defaults to true." "description": "Composer allows repositories to define a notification URL, so that they get notified whenever a package from that repository is installed. This option allows you to disable that behaviour, defaults to true."

View File

@ -248,16 +248,23 @@ EOT
return $this->configSource->addConfigSetting('github-oauth.'.$matches[1], $values[0]); return $this->configSource->addConfigSetting('github-oauth.'.$matches[1], $values[0]);
} }
$booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); };
$booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; };
// handle config values // handle config values
$uniqueConfigValues = array( $uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'), 'process-timeout' => array('is_numeric', 'intval'),
'use-include-path' => array( 'use-include-path' => array(
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }, $booleanValidator,
function ($val) { return $val !== 'false' && (bool) $val; } $booleanNormalizer
),
'preferred-install' => array(
function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); },
function ($val) { return $val; }
), ),
'notify-on-install' => array( 'notify-on-install' => array(
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }, $booleanValidator,
function ($val) { return $val !== 'false' && (bool) $val; } $booleanNormalizer
), ),
'vendor-dir' => array('is_string', function ($val) { return $val; }), 'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }), 'bin-dir' => array('is_string', function ($val) { return $val; }),

View File

@ -61,11 +61,30 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
$install = Installer::create($io, $composer); $install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install $install
->setDryRun($input->getOption('dry-run')) ->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($preferSource)
->setPreferDist($input->getOption('prefer-dist')) ->setPreferDist($preferDist)
->setDevMode($input->getOption('dev')) ->setDevMode($input->getOption('dev'))
->setRunScripts(!$input->getOption('no-scripts')) ->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader')) ->setOptimizeAutoloader($input->getOption('optimize-autoloader'))

View File

@ -64,11 +64,30 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
$install = Installer::create($io, $composer); $install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install $install
->setDryRun($input->getOption('dry-run')) ->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($preferSource)
->setPreferDist($input->getOption('prefer-dist')) ->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev')) ->setDevMode(!$input->getOption('no-dev'))
->setRunScripts(!$input->getOption('no-scripts')) ->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader')) ->setOptimizeAutoloader($input->getOption('optimize-autoloader'))

View File

@ -22,6 +22,7 @@ class Config
public static $defaultConfig = array( public static $defaultConfig = array(
'process-timeout' => 300, 'process-timeout' => 300,
'use-include-path' => false, 'use-include-path' => false,
'preferred-install' => 'auto',
'notify-on-install' => true, 'notify-on-install' => true,
'github-protocols' => array('git', 'https', 'http'), 'github-protocols' => array('git', 'https', 'http'),
'vendor-dir' => 'vendor', 'vendor-dir' => 'vendor',