1
0
Fork 0

Add allow-missing-requirements config setting to ignore missing requirements (#11966)

* Add allow-missing-requirements configuration to ignore error during install if there are any missing requirements

* Add test for allow-missing-requirements config

---------

Co-authored-by: Joe <joe@wpj.cz>
pull/12086/head
Joe 2024-09-18 11:00:09 +02:00 committed by GitHub
parent be7d9abc66
commit 8f455d7c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 61 additions and 1 deletions

View File

@ -481,4 +481,10 @@ throw, but you can set this config option to `["example.org"]` to allow using sv
URLs on that hostname. This is a better/safer alternative to disabling `secure-http`
altogether.
## allow-missing-requirements
Defaults to `false`. Ignores error during `install` if there are any missing
requirements - the lock file is not up to date with the latest changes in
`composer.json`.
&larr; [Repositories](05-repositories.md) | [Runtime](07-runtime.md) &rarr;

View File

@ -662,6 +662,10 @@
"platform-check": {
"type": ["boolean", "string"],
"description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
},
"allow-missing-requirements": {
"type": ["boolean"],
"description": "Defaults to false. If set to true, Composer will allow install when lock file is not up to date with the latest changes in composer.json."
}
}
},

View File

@ -84,6 +84,7 @@ class Config
'gitlab-token' => [],
'http-basic' => [],
'bearer' => [],
'allow-missing-requirements' => false,
];
/** @var array<string, mixed> */

View File

@ -742,7 +742,9 @@ class Installer
if ($missingRequirementInfo !== []) {
$this->io->writeError($missingRequirementInfo);
return self::ERROR_LOCK_FILE_INVALID;
if (!$this->config->get('allow-missing-requirements')) {
return self::ERROR_LOCK_FILE_INVALID;
}
}
foreach ($lockedRepository->getPackages() as $package) {

View File

@ -0,0 +1,47 @@
--TEST--
Requirements from the composer file are not installed if the lock file is present and missing requirements warning
is issued when allow-missing-requirements if enabled
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "required/pkg", "version": "1.0.0" },
{ "name": "newly-required/pkg", "version": "1.0.0" }
]
}
],
"require": {
"required/pkg": "1.0.0",
"newly-required/pkg": "1.0.0"
},
"config": {
"allow-missing-requirements": true
}
}
--LOCK--
{
"packages": [
{ "name": "required/pkg", "version": "1.0.0" }
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false
}
--RUN--
install
--EXPECT-OUTPUT--
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
- Required package "newly-required/pkg" is not present in the lock file.
This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.
Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md
and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r
Package operations: 1 install, 0 updates, 0 removals
Generating autoload files
--EXPECT--
Installing required/pkg (1.0.0)