Add COMPOSER_FUND=0 env var to disable calls for funding (#11779)
parent
071fbcf347
commit
44f02a5c86
|
@ -1145,6 +1145,10 @@ If set to 1, this env suppresses a warning when Composer is running with the Xde
|
||||||
|
|
||||||
This env var controls the [`discard-changes`](06-config.md#discard-changes) config option.
|
This env var controls the [`discard-changes`](06-config.md#discard-changes) config option.
|
||||||
|
|
||||||
|
### COMPOSER_FUND
|
||||||
|
|
||||||
|
If set to 0, this env suppresses funding notices when installing.
|
||||||
|
|
||||||
### COMPOSER_HOME
|
### COMPOSER_HOME
|
||||||
|
|
||||||
The `COMPOSER_HOME` var allows you to change the Composer home directory. This
|
The `COMPOSER_HOME` var allows you to change the Composer home directory. This
|
||||||
|
|
|
@ -372,6 +372,13 @@ class Installer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fundEnv = Platform::getEnv('COMPOSER_FUND');
|
||||||
|
$showFunding = true;
|
||||||
|
if (is_numeric($fundEnv)) {
|
||||||
|
$showFunding = intval($fundEnv) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showFunding) {
|
||||||
$fundingCount = 0;
|
$fundingCount = 0;
|
||||||
foreach ($localRepo->getPackages() as $package) {
|
foreach ($localRepo->getPackages() as $package) {
|
||||||
if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
|
if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
|
||||||
|
@ -389,6 +396,7 @@ class Installer
|
||||||
'<info>Use the `composer fund` command to find out more!</info>',
|
'<info>Use the `composer fund` command to find out more!</info>',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->runScripts) {
|
if ($this->runScripts) {
|
||||||
// dispatch post event
|
// dispatch post event
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
--TEST--
|
||||||
|
Installs a simple package with exact match requirement
|
||||||
|
--CONDITION--
|
||||||
|
putenv('COMPOSER_FUND=1')
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"name": "a/a",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }],
|
||||||
|
"require": {
|
||||||
|
"d/d": "^1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/b",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "c/c",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "d/d",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"require": {
|
||||||
|
"b/b": "^1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/a": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
install
|
||||||
|
--EXPECT-OUTPUT--
|
||||||
|
<warning>No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.</warning>
|
||||||
|
Loading composer repositories with package information
|
||||||
|
Updating dependencies
|
||||||
|
Lock file operations: 3 installs, 0 updates, 0 removals
|
||||||
|
- Locking a/a (1.0.0)
|
||||||
|
- Locking b/b (1.0.0)
|
||||||
|
- Locking d/d (1.0.0)
|
||||||
|
Writing lock file
|
||||||
|
Installing dependencies from lock file (including require-dev)
|
||||||
|
Package operations: 3 installs, 0 updates, 0 removals
|
||||||
|
Generating autoload files
|
||||||
|
2 packages you are using are looking for funding.
|
||||||
|
Use the `composer fund` command to find out more!
|
||||||
|
--EXPECT--
|
||||||
|
Installing b/b (1.0.0)
|
||||||
|
Installing d/d (1.0.0)
|
||||||
|
Installing a/a (1.0.0)
|
|
@ -0,0 +1,60 @@
|
||||||
|
--TEST--
|
||||||
|
Installs a simple package with exact match requirement
|
||||||
|
--CONDITION--
|
||||||
|
putenv('COMPOSER_FUND=0')
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{
|
||||||
|
"name": "a/a",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }],
|
||||||
|
"require": {
|
||||||
|
"d/d": "^1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b/b",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "c/c",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"funding": [{ "type": "example", "url": "http://example.org/fund" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "d/d",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"require": {
|
||||||
|
"b/b": "^1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/a": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
install
|
||||||
|
--EXPECT-OUTPUT--
|
||||||
|
<warning>No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.</warning>
|
||||||
|
Loading composer repositories with package information
|
||||||
|
Updating dependencies
|
||||||
|
Lock file operations: 3 installs, 0 updates, 0 removals
|
||||||
|
- Locking a/a (1.0.0)
|
||||||
|
- Locking b/b (1.0.0)
|
||||||
|
- Locking d/d (1.0.0)
|
||||||
|
Writing lock file
|
||||||
|
Installing dependencies from lock file (including require-dev)
|
||||||
|
Package operations: 3 installs, 0 updates, 0 removals
|
||||||
|
Generating autoload files
|
||||||
|
--EXPECT--
|
||||||
|
Installing b/b (1.0.0)
|
||||||
|
Installing d/d (1.0.0)
|
||||||
|
Installing a/a (1.0.0)
|
|
@ -59,6 +59,7 @@ class InstallerTest extends TestCase
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
Platform::clearEnv('COMPOSER_POOL_OPTIMIZER');
|
Platform::clearEnv('COMPOSER_POOL_OPTIMIZER');
|
||||||
|
Platform::clearEnv('COMPOSER_FUND');
|
||||||
|
|
||||||
chdir($this->prevCwd);
|
chdir($this->prevCwd);
|
||||||
if (isset($this->tempComposerHome) && is_dir($this->tempComposerHome)) {
|
if (isset($this->tempComposerHome) && is_dir($this->tempComposerHome)) {
|
||||||
|
|
Loading…
Reference in New Issue