added --prefer-dist option
parent
a04591bbd7
commit
aa0ff14be5
|
@ -31,6 +31,7 @@ class InstallCommand extends Command
|
||||||
->setDescription('Parses the composer.json file and downloads the needed dependencies.')
|
->setDescription('Parses the composer.json file and downloads the needed dependencies.')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
||||||
|
new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
|
||||||
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
||||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
||||||
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
|
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
|
||||||
|
@ -59,6 +60,7 @@ EOT
|
||||||
->setDryRun($input->getOption('dry-run'))
|
->setDryRun($input->getOption('dry-run'))
|
||||||
->setVerbose($input->getOption('verbose'))
|
->setVerbose($input->getOption('verbose'))
|
||||||
->setPreferSource($input->getOption('prefer-source'))
|
->setPreferSource($input->getOption('prefer-source'))
|
||||||
|
->setPreferDist($input->getOption('prefer-dist'))
|
||||||
->setDevMode($input->getOption('dev'))
|
->setDevMode($input->getOption('dev'))
|
||||||
->setRunScripts(!$input->getOption('no-scripts'))
|
->setRunScripts(!$input->getOption('no-scripts'))
|
||||||
;
|
;
|
||||||
|
|
|
@ -31,6 +31,7 @@ class UpdateCommand extends Command
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
|
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
|
||||||
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
||||||
|
new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
|
||||||
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
||||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
||||||
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
|
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
|
||||||
|
@ -63,6 +64,7 @@ EOT
|
||||||
->setDryRun($input->getOption('dry-run'))
|
->setDryRun($input->getOption('dry-run'))
|
||||||
->setVerbose($input->getOption('verbose'))
|
->setVerbose($input->getOption('verbose'))
|
||||||
->setPreferSource($input->getOption('prefer-source'))
|
->setPreferSource($input->getOption('prefer-source'))
|
||||||
|
->setPreferDist($input->getOption('prefer-dist'))
|
||||||
->setDevMode($input->getOption('dev'))
|
->setDevMode($input->getOption('dev'))
|
||||||
->setRunScripts(!$input->getOption('no-scripts'))
|
->setRunScripts(!$input->getOption('no-scripts'))
|
||||||
->setUpdate(true)
|
->setUpdate(true)
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Composer\Util\Filesystem;
|
||||||
*/
|
*/
|
||||||
class DownloadManager
|
class DownloadManager
|
||||||
{
|
{
|
||||||
|
private $preferDist = false;
|
||||||
private $preferSource = false;
|
private $preferSource = false;
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
private $downloaders = array();
|
private $downloaders = array();
|
||||||
|
@ -51,6 +52,18 @@ class DownloadManager
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes downloader prefer dist installation over the source.
|
||||||
|
*
|
||||||
|
* @param bool $preferDist prefer downloading from dist
|
||||||
|
*/
|
||||||
|
public function setPreferDist($preferDist)
|
||||||
|
{
|
||||||
|
$this->preferDist = $preferDist;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets installer downloader for a specific installation type.
|
* Sets installer downloader for a specific installation type.
|
||||||
*
|
*
|
||||||
|
@ -134,12 +147,12 @@ class DownloadManager
|
||||||
$sourceType = $package->getSourceType();
|
$sourceType = $package->getSourceType();
|
||||||
$distType = $package->getDistType();
|
$distType = $package->getDistType();
|
||||||
|
|
||||||
if (!$package->isDev() && !($preferSource && $sourceType) && $distType) {
|
if ((!$package->isDev() || $this->preferDist) && !($preferSource && $sourceType) && $distType) {
|
||||||
$package->setInstallationSource('dist');
|
$package->setInstallationSource('dist');
|
||||||
} elseif ($sourceType) {
|
} elseif ($sourceType) {
|
||||||
$package->setInstallationSource('source');
|
$package->setInstallationSource('source');
|
||||||
} elseif ($package->isDev()) {
|
} elseif ($package->isDev() && $distType) {
|
||||||
throw new \InvalidArgumentException('Dev package '.$package.' must have a source specified');
|
throw new \InvalidArgumentException('Dev package '.$package.' should have a source specified because for dev packages dist is used only with --prefer-dist option');
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
|
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ class Installer
|
||||||
protected $autoloadGenerator;
|
protected $autoloadGenerator;
|
||||||
|
|
||||||
protected $preferSource = false;
|
protected $preferSource = false;
|
||||||
|
protected $preferDist = false;
|
||||||
protected $devMode = false;
|
protected $devMode = false;
|
||||||
protected $dryRun = false;
|
protected $dryRun = false;
|
||||||
protected $verbose = false;
|
protected $verbose = false;
|
||||||
|
@ -148,6 +149,9 @@ class Installer
|
||||||
if ($this->preferSource) {
|
if ($this->preferSource) {
|
||||||
$this->downloadManager->setPreferSource(true);
|
$this->downloadManager->setPreferSource(true);
|
||||||
}
|
}
|
||||||
|
if ($this->preferDist) {
|
||||||
|
$this->downloadManager->setPreferDist(true);
|
||||||
|
}
|
||||||
|
|
||||||
// create installed repo, this contains all local packages + platform packages (php & extensions)
|
// create installed repo, this contains all local packages + platform packages (php & extensions)
|
||||||
$installedRootPackage = clone $this->package;
|
$installedRootPackage = clone $this->package;
|
||||||
|
@ -679,6 +683,19 @@ class Installer
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prefer dist installation
|
||||||
|
*
|
||||||
|
* @param boolean $preferDist
|
||||||
|
* @return Installer
|
||||||
|
*/
|
||||||
|
public function setPreferDist($preferDist = true)
|
||||||
|
{
|
||||||
|
$this->preferDist = (boolean) $preferDist;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update packages
|
* update packages
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue