mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: updateLockFiles (#1703)
Adds an option “updateLockFiles” which defaults to true. Setting to false means that updating lock files (e.g. package-lock.json, yarn.lock and shrinkwrap.yaml) will be skipped. The main reason for doing this is for repositories that use a dependency we can’t resolve, so that they can keep updating the package.json without lock file.
This commit is contained in:
parent
aa56c049b4
commit
3a4a0cb029
6 changed files with 36 additions and 1 deletions
|
@ -213,6 +213,11 @@ const options = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'updateLockFiles',
|
||||||
|
description: 'Set to false to disable lock file updating',
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'ignoreNpmrcFile',
|
name: 'ignoreNpmrcFile',
|
||||||
description: 'Whether to ignore any .npmrc file found in repository',
|
description: 'Whether to ignore any .npmrc file found in repository',
|
||||||
|
|
|
@ -50,7 +50,10 @@ async function getPackageUpdates(config) {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Failed to look up dependency',
|
message: 'Failed to look up dependency',
|
||||||
};
|
};
|
||||||
if (config.yarnLock || config.packageLock || config.npmShrinkwrap) {
|
if (
|
||||||
|
config.updateLockFiles &&
|
||||||
|
(config.yarnLock || config.packageLock || config.npmShrinkwrap)
|
||||||
|
) {
|
||||||
result.message +=
|
result.message +=
|
||||||
'. This will block *all* dependencies from being updated due to presence of lock file.';
|
'. This will block *all* dependencies from being updated due to presence of lock file.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,6 +374,10 @@ async function getUpdatedLockFiles(config) {
|
||||||
logger.debug('Getting updated lock files');
|
logger.debug('Getting updated lock files');
|
||||||
const lockFileErrors = [];
|
const lockFileErrors = [];
|
||||||
const updatedLockFiles = [];
|
const updatedLockFiles = [];
|
||||||
|
if (!config.updateLockFiles) {
|
||||||
|
logger.info('Skipping lock file generation');
|
||||||
|
return { lockFileErrors, updatedLockFiles };
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
config.type === 'lockFileMaintenance' &&
|
config.type === 'lockFileMaintenance' &&
|
||||||
config.parentBranch &&
|
config.parentBranch &&
|
||||||
|
|
|
@ -73,6 +73,13 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`workers/branch/lock-files getUpdatedLockFiles returns no error and empty lockfiles if updateLockFiles false 1`] = `
|
||||||
|
Object {
|
||||||
|
"lockFileErrors": Array [],
|
||||||
|
"updatedLockFiles": Array [],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`workers/branch/lock-files getUpdatedLockFiles tries lerna npm 1`] = `
|
exports[`workers/branch/lock-files getUpdatedLockFiles tries lerna npm 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"lockFileErrors": Array [],
|
"lockFileErrors": Array [],
|
||||||
|
|
|
@ -491,6 +491,13 @@ describe('workers/branch/lock-files', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
it('returns no error and empty lockfiles if updateLockFiles false', async () => {
|
||||||
|
config.updateLockFiles = false;
|
||||||
|
const res = await getUpdatedLockFiles(config);
|
||||||
|
expect(res).toMatchSnapshot();
|
||||||
|
expect(res.lockFileErrors).toHaveLength(0);
|
||||||
|
expect(res.updatedLockFiles).toHaveLength(0);
|
||||||
|
});
|
||||||
it('returns no error and empty lockfiles if lock file maintenance exists', async () => {
|
it('returns no error and empty lockfiles if lock file maintenance exists', async () => {
|
||||||
config.type = 'lockFileMaintenance';
|
config.type = 'lockFileMaintenance';
|
||||||
config.parentBranch = 'renovate/lock-file-maintenance';
|
config.parentBranch = 'renovate/lock-file-maintenance';
|
||||||
|
|
|
@ -1069,6 +1069,15 @@ Because Docker uses tags instead of semver, there is no fixed convention for how
|
||||||
|
|
||||||
This field is currently used by some config prefixes.
|
This field is currently used by some config prefixes.
|
||||||
|
|
||||||
|
## updateLockFiles
|
||||||
|
|
||||||
|
Set to false to disable lock file updating.
|
||||||
|
|
||||||
|
| name | value |
|
||||||
|
| ------- | ------- |
|
||||||
|
| type | boolean |
|
||||||
|
| default | true |
|
||||||
|
|
||||||
## updateNotScheduled
|
## updateNotScheduled
|
||||||
|
|
||||||
Whether to update (but not create) branches when not scheduled.
|
Whether to update (but not create) branches when not scheduled.
|
||||||
|
|
Loading…
Reference in a new issue