Merge pull request #8384 from aboks/no-lock
Config option to disable lockfile generationpull/8390/head
commit
82e0fdccca
|
@ -296,4 +296,9 @@ Example:
|
||||||
Defaults to `true`. If set to `false`, Composer will not create `.htaccess` files
|
Defaults to `true`. If set to `false`, Composer will not create `.htaccess` files
|
||||||
in the composer home, cache, and data directories.
|
in the composer home, cache, and data directories.
|
||||||
|
|
||||||
|
## lock
|
||||||
|
|
||||||
|
Defaults to `true`. If set to `false`, Composer will not create a `composer.lock`
|
||||||
|
file.
|
||||||
|
|
||||||
← [Repositories](05-repositories.md) | [Community](07-community.md) →
|
← [Repositories](05-repositories.md) | [Community](07-community.md) →
|
||||||
|
|
|
@ -290,6 +290,10 @@
|
||||||
"sort-packages": {
|
"sort-packages": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
|
"description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
|
||||||
|
},
|
||||||
|
"lock": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -412,6 +412,7 @@ EOT
|
||||||
),
|
),
|
||||||
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
|
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
|
||||||
'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
|
'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
|
||||||
|
'lock' => array($booleanValidator, $booleanNormalizer),
|
||||||
);
|
);
|
||||||
$multiConfigValues = array(
|
$multiConfigValues = array(
|
||||||
'github-protocols' => array(
|
'github-protocols' => array(
|
||||||
|
|
|
@ -63,6 +63,7 @@ class Config
|
||||||
'archive-dir' => '.',
|
'archive-dir' => '.',
|
||||||
'htaccess-protect' => true,
|
'htaccess-protect' => true,
|
||||||
'use-github-api' => true,
|
'use-github-api' => true,
|
||||||
|
'lock' => true,
|
||||||
// valid keys without defaults (auth config stuff):
|
// valid keys without defaults (auth config stuff):
|
||||||
// bitbucket-oauth
|
// bitbucket-oauth
|
||||||
// github-oauth
|
// github-oauth
|
||||||
|
@ -329,6 +330,8 @@ class Config
|
||||||
return $this->config[$key] !== 'false' && (bool) $this->config[$key];
|
return $this->config[$key] !== 'false' && (bool) $this->config[$key];
|
||||||
case 'use-github-api':
|
case 'use-github-api':
|
||||||
return $this->config[$key] !== 'false' && (bool) $this->config[$key];
|
return $this->config[$key] !== 'false' && (bool) $this->config[$key];
|
||||||
|
case 'lock':
|
||||||
|
return $this->config[$key] !== 'false' && (bool) $this->config[$key];
|
||||||
default:
|
default:
|
||||||
if (!isset($this->config[$key])) {
|
if (!isset($this->config[$key])) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Installer
|
||||||
protected $preferStable = false;
|
protected $preferStable = false;
|
||||||
protected $preferLowest = false;
|
protected $preferLowest = false;
|
||||||
protected $skipSuggest = false;
|
protected $skipSuggest = false;
|
||||||
protected $writeLock = true;
|
protected $writeLock;
|
||||||
protected $executeOperations = true;
|
protected $executeOperations = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,6 +164,8 @@ class Installer
|
||||||
$this->installationManager = $installationManager;
|
$this->installationManager = $installationManager;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->autoloadGenerator = $autoloadGenerator;
|
$this->autoloadGenerator = $autoloadGenerator;
|
||||||
|
|
||||||
|
$this->writeLock = $config->get('lock');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
Installs from composer.json without writing a lock file
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "a/a", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/a": "1.0.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"lock": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
install
|
||||||
|
--EXPECT--
|
||||||
|
Installing a/a (1.0.0)
|
||||||
|
--EXPECT-LOCK--
|
||||||
|
false
|
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
Updates when no lock file is present without writing a lock file
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "a/a", "version": "1.0.0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"a/a": "1.0.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"lock": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
update
|
||||||
|
--EXPECT--
|
||||||
|
Installing a/a (1.0.0)
|
||||||
|
--EXPECT-LOCK--
|
||||||
|
false
|
|
@ -197,6 +197,9 @@ class InstallerTest extends TestCase
|
||||||
// so store value temporarily in reference for later assetion
|
// so store value temporarily in reference for later assetion
|
||||||
$actualLock = $hash;
|
$actualLock = $hash;
|
||||||
}));
|
}));
|
||||||
|
} elseif ($expectLock === false) {
|
||||||
|
$lockJsonMock->expects($this->never())
|
||||||
|
->method('write');
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = json_encode($composerConfig);
|
$contents = json_encode($composerConfig);
|
||||||
|
@ -319,7 +322,11 @@ class InstallerTest extends TestCase
|
||||||
}
|
}
|
||||||
$run = $testData['RUN'];
|
$run = $testData['RUN'];
|
||||||
if (!empty($testData['EXPECT-LOCK'])) {
|
if (!empty($testData['EXPECT-LOCK'])) {
|
||||||
$expectLock = JsonFile::parseJson($testData['EXPECT-LOCK']);
|
if ($testData['EXPECT-LOCK'] === 'false') {
|
||||||
|
$expectLock = false;
|
||||||
|
} else {
|
||||||
|
$expectLock = JsonFile::parseJson($testData['EXPECT-LOCK']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$expectOutput = isset($testData['EXPECT-OUTPUT']) ? $testData['EXPECT-OUTPUT'] : null;
|
$expectOutput = isset($testData['EXPECT-OUTPUT']) ? $testData['EXPECT-OUTPUT'] : null;
|
||||||
$expect = $testData['EXPECT'];
|
$expect = $testData['EXPECT'];
|
||||||
|
|
Loading…
Reference in New Issue