Change dependency processing for update with whitelisted packages
By default dependencies of white listed packages are no longer installed automaticaly. To Install dependencies of whitelisted packages use --with-dependencies. - rework after review comments - precise documentation of option - add missing punctuation markspull/2327/head
parent
2f4a3aba26
commit
07a7284ffc
|
@ -122,7 +122,9 @@ You can also use wildcards to update a bunch of packages at once:
|
||||||
autoloader. This is recommended especially for production, but can take
|
autoloader. This is recommended especially for production, but can take
|
||||||
a bit of time to run so it is currently not done by default.
|
a bit of time to run so it is currently not done by default.
|
||||||
* **--lock:** Only updates the lock file hash to suppress warning about the
|
* **--lock:** Only updates the lock file hash to suppress warning about the
|
||||||
lock file being out of date
|
lock file being out of date.
|
||||||
|
* **--with-dependencies** Add also all dependencies of whitelisted packages to the whitelist.
|
||||||
|
So all packages with their dependencies are updated recursively.
|
||||||
|
|
||||||
## require
|
## require
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,9 @@ class UpdateCommand extends Command
|
||||||
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
|
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
|
||||||
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
|
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
|
||||||
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
|
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
|
||||||
|
new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist.'),
|
||||||
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
|
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
|
||||||
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump')
|
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.')
|
||||||
))
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
The <info>update</info> command reads the composer.json file from the
|
The <info>update</info> command reads the composer.json file from the
|
||||||
|
@ -107,6 +108,7 @@ EOT
|
||||||
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
|
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
|
||||||
->setUpdate(true)
|
->setUpdate(true)
|
||||||
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
|
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
|
||||||
|
->setWhitelistDependencies($input->getOption('with-dependencies'))
|
||||||
;
|
;
|
||||||
|
|
||||||
if ($input->getOption('no-plugins')) {
|
if ($input->getOption('no-plugins')) {
|
||||||
|
|
|
@ -106,6 +106,7 @@ class Installer
|
||||||
protected $update = false;
|
protected $update = false;
|
||||||
protected $runScripts = true;
|
protected $runScripts = true;
|
||||||
protected $updateWhitelist = null;
|
protected $updateWhitelist = null;
|
||||||
|
protected $whitelistDependencies = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
|
@ -851,6 +852,10 @@ class Installer
|
||||||
$seen[$package->getId()] = true;
|
$seen[$package->getId()] = true;
|
||||||
$this->updateWhitelist[$package->getName()] = true;
|
$this->updateWhitelist[$package->getName()] = true;
|
||||||
|
|
||||||
|
if (!$this->whitelistDependencies) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$requires = $package->getRequires();
|
$requires = $package->getRequires();
|
||||||
|
|
||||||
foreach ($requires as $require) {
|
foreach ($requires as $require) {
|
||||||
|
@ -1051,6 +1056,19 @@ class Installer
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should dependencies of whitelisted packages be updated recursively?
|
||||||
|
*
|
||||||
|
* @param boolean $updateDependencies
|
||||||
|
* @return Installer
|
||||||
|
*/
|
||||||
|
public function setWhitelistDependencies($updateDependencies = true)
|
||||||
|
{
|
||||||
|
$this->whitelistDependencies = (boolean) $updateDependencies;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables plugins.
|
* Disables plugins.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Update with a package whitelist only updates those packages and their dependencies if they are not present in composer.json
|
Update with a package whitelist only updates those packages if they are not present in composer.json
|
||||||
--COMPOSER--
|
--COMPOSER--
|
||||||
{
|
{
|
||||||
"repositories": [
|
"repositories": [
|
||||||
|
@ -30,7 +30,7 @@ Update with a package whitelist only updates those packages and their dependenci
|
||||||
{ "name": "fixed-sub-dependency", "version": "1.0.0" }
|
{ "name": "fixed-sub-dependency", "version": "1.0.0" }
|
||||||
]
|
]
|
||||||
--RUN--
|
--RUN--
|
||||||
update whitelisted
|
update whitelisted dependency
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Updating dependency (1.0.0) to dependency (1.1.0)
|
Updating dependency (1.0.0) to dependency (1.1.0)
|
||||||
Updating whitelisted (1.0.0) to whitelisted (1.1.0)
|
Updating whitelisted (1.0.0) to whitelisted (1.1.0)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
Update with a package whitelist only updates those packages and their dependencies listed as command arguments
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "fixed", "version": "1.1.0" },
|
||||||
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
|
{ "name": "whitelisted", "version": "1.1.0", "require": { "dependency": "1.1.0" } },
|
||||||
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
||||||
|
{ "name": "dependency", "version": "1.1.0" },
|
||||||
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
|
{ "name": "unrelated", "version": "1.1.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.1.0" },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"fixed": "1.*",
|
||||||
|
"whitelisted": "1.*",
|
||||||
|
"unrelated": "1.*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--INSTALLED--
|
||||||
|
[
|
||||||
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
||||||
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
|
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
--RUN--
|
||||||
|
update whitelisted --with-dependencies
|
||||||
|
--EXPECT--
|
||||||
|
Updating dependency (1.0.0) to dependency (1.1.0)
|
||||||
|
Updating whitelisted (1.0.0) to whitelisted (1.1.0)
|
|
@ -0,0 +1,38 @@
|
||||||
|
--TEST--
|
||||||
|
Update with a package whitelist only updates whitelisted packages if no dependency conflicts
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "fixed", "version": "1.1.0" },
|
||||||
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
|
{ "name": "whitelisted", "version": "1.1.0", "require": { "dependency": "1.1.0" } },
|
||||||
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
||||||
|
{ "name": "dependency", "version": "1.1.0" },
|
||||||
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
|
{ "name": "unrelated", "version": "1.1.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.1.0" },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"fixed": "1.*",
|
||||||
|
"whitelisted": "1.*",
|
||||||
|
"unrelated": "1.*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--INSTALLED--
|
||||||
|
[
|
||||||
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
||||||
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
|
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
--RUN--
|
||||||
|
update whitelisted
|
||||||
|
--EXPECT--
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Update with a package whitelist only updates those packages and their dependencies listed as command arguments
|
Update with a package whitelist only updates those packages listed as command arguments
|
||||||
--COMPOSER--
|
--COMPOSER--
|
||||||
{
|
{
|
||||||
"repositories": [
|
"repositories": [
|
||||||
|
@ -8,8 +8,8 @@ Update with a package whitelist only updates those packages and their dependenci
|
||||||
"package": [
|
"package": [
|
||||||
{ "name": "fixed", "version": "1.1.0" },
|
{ "name": "fixed", "version": "1.1.0" },
|
||||||
{ "name": "fixed", "version": "1.0.0" },
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
{ "name": "whitelisted", "version": "1.1.0", "require": { "dependency": "1.1.0" } },
|
{ "name": "whitelisted", "version": "1.1.0", "require": { "dependency": "1.*" } },
|
||||||
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.*" } },
|
||||||
{ "name": "dependency", "version": "1.1.0" },
|
{ "name": "dependency", "version": "1.1.0" },
|
||||||
{ "name": "dependency", "version": "1.0.0" },
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
{ "name": "unrelated", "version": "1.1.0", "require": { "unrelated-dependency": "1.*" } },
|
{ "name": "unrelated", "version": "1.1.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
|
@ -28,7 +28,7 @@ Update with a package whitelist only updates those packages and their dependenci
|
||||||
--INSTALLED--
|
--INSTALLED--
|
||||||
[
|
[
|
||||||
{ "name": "fixed", "version": "1.0.0" },
|
{ "name": "fixed", "version": "1.0.0" },
|
||||||
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.0.0" } },
|
{ "name": "whitelisted", "version": "1.0.0", "require": { "dependency": "1.*" } },
|
||||||
{ "name": "dependency", "version": "1.0.0" },
|
{ "name": "dependency", "version": "1.0.0" },
|
||||||
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
{ "name": "unrelated", "version": "1.0.0", "require": { "unrelated-dependency": "1.*" } },
|
||||||
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
{ "name": "unrelated-dependency", "version": "1.0.0" }
|
||||||
|
@ -36,5 +36,4 @@ Update with a package whitelist only updates those packages and their dependenci
|
||||||
--RUN--
|
--RUN--
|
||||||
update whitelisted
|
update whitelisted
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Updating dependency (1.0.0) to dependency (1.1.0)
|
|
||||||
Updating whitelisted (1.0.0) to whitelisted (1.1.0)
|
Updating whitelisted (1.0.0) to whitelisted (1.1.0)
|
||||||
|
|
|
@ -214,7 +214,8 @@ class InstallerTest extends TestCase
|
||||||
->setDevMode($input->getOption('dev'))
|
->setDevMode($input->getOption('dev'))
|
||||||
->setUpdate(true)
|
->setUpdate(true)
|
||||||
->setDryRun($input->getOption('dry-run'))
|
->setDryRun($input->getOption('dry-run'))
|
||||||
->setUpdateWhitelist($input->getArgument('packages'));
|
->setUpdateWhitelist($input->getArgument('packages'))
|
||||||
|
->setWhitelistDependencies($input->getOption('with-dependencies'));
|
||||||
|
|
||||||
return $installer->run() ? 0 : 1;
|
return $installer->run() ? 0 : 1;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue