diff --git a/lib/config/definitions.js b/lib/config/definitions.js index e9e263a3dae0c77b59a1b963a84b57b0a9a2dfbd..a76b6fbec366761d3671a68be4b88028e2896531 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -523,7 +523,6 @@ const options = [ { name: 'rangeStrategy', description: 'Policy for how to modify/update existing ranges.', - stage: 'package', type: 'string', default: 'replace', allowedValues: ['auto', 'pin', 'bump', 'replace', 'widen'], diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js index 90f96ae4ed18743a93d32e81a47da096756b1671..1517a26e194207fcbd0bb823ec9332598e981532 100644 --- a/lib/manager/npm/post-update/index.js +++ b/lib/manager/npm/post-update/index.js @@ -191,7 +191,31 @@ async function writeExistingFiles(config, packageFiles) { await fs.remove(npmLockPath); } else { logger.debug(`Writing ${npmLock}`); - const existingNpmLock = await platform.getFile(npmLock); + let existingNpmLock = await platform.getFile(npmLock); + const widens = []; + for (const upgrade of config.upgrades) { + if ( + upgrade.rangeStrategy === 'widen' && + upgrade.npmLock === npmLock + ) { + widens.push(upgrade.depName); + } + } + if (widens.length) { + logger.info(`Removing ${widens} from ${npmLock} to force an update`); + try { + const npmLockParsed = JSON.parse(existingNpmLock); + widens.forEach(depName => { + delete npmLockParsed.dependencies[depName]; + }); + existingNpmLock = JSON.stringify(npmLockParsed, null, 2); + } catch (err) { + logger.warn( + { npmLock }, + 'Error massing package-lock.json for widen' + ); + } + } await fs.outputFile(npmLockPath, existingNpmLock); } } diff --git a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap index ae58066b0cae5a1445117a20441cf5600620fb6c..cfde3adb656545dd3a3e367468a92eab631618c7 100644 --- a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap +++ b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap @@ -62,6 +62,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false, @@ -149,6 +150,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false, @@ -233,6 +235,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": true, "recreateClosed": true, @@ -323,6 +326,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false, @@ -407,6 +411,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": true, "recreateClosed": true, @@ -497,6 +502,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false, @@ -584,6 +590,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false, @@ -671,6 +678,7 @@ Array [ "prNotPendingHours": 25, "prTitle": null, "raiseDeprecationWarnings": true, + "rangeStrategy": "replace", "rebaseLabel": "rebase", "rebaseStalePrs": null, "recreateClosed": false,