diff --git a/lib/manager/common.ts b/lib/manager/common.ts index 309f2c2e2e43b5129664e95637ec1cad8ec02273..578b7eceb2d47c1dc23dba0f86e4eee86863a655 100644 --- a/lib/manager/common.ts +++ b/lib/manager/common.ts @@ -134,6 +134,7 @@ export interface LookupUpdate { commitMessageAction?: string; displayFrom?: string; displayTo?: string; + isBump?: boolean; isLockfileUpdate?: boolean; isPin?: boolean; isRange?: boolean; diff --git a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap index eef57230dbdcae662db170b7e699761790ce7445..ef33c27800cd4f0a2126cd1cfead3155234354de 100644 --- a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap @@ -1683,7 +1683,7 @@ Array [ "newValue": "~1.0.1", "releaseTimestamp": "2014-03-11T18:47:17.560Z", "toVersion": "1.0.1", - "updateType": "minor", + "updateType": "patch", }, Object { "fromVersion": "1.0.0", @@ -1726,7 +1726,7 @@ Array [ "0.4.2", ], "toVersion": "0.4.4", - "updateType": "minor", + "updateType": "patch", }, Object { "fromVersion": "0.4.4", diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 3eff2f0b727c9ca65256faf1b2169a48878fa0bb..d6655f8625bb90f9d9d10c53d668b25bb3badee3 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -79,6 +79,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'update-lockfile'; config.depName = 'q'; config.datasource = datasourceNpmId; + config.separateMinorPatch = true; config.lockedVersion = '0.4.0'; nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); @@ -840,6 +841,7 @@ describe('workers/repository/process/lookup', () => { config.rangeStrategy = 'bump'; config.currentValue = '~1.0.0'; config.depName = 'q'; + config.separateMinorPatch = true; config.datasource = datasourceNpmId; nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); @@ -866,6 +868,7 @@ describe('workers/repository/process/lookup', () => { config.currentValue = '>=0.9.0'; config.depName = 'q'; config.datasource = datasourceNpmId; + config.separateMajorMinor = false; nock('https://registry.npmjs.org').get('/q').reply(200, qJson); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index bdc17e62ca9521d8b7ac670d919d68b7e7ef1c67..4f0508ef424113568b25db6472f2b930d2b3af3b 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -61,11 +61,8 @@ function getType( fromVersion: string, toVersion: string ): UpdateType { - const { versioning, rangeStrategy, currentValue } = config; + const { versioning } = config; const version = allVersioning.get(versioning); - if (rangeStrategy === 'bump' && version.matches(toVersion, currentValue)) { - return 'bump'; - } if (version.getMajor(toVersion) > version.getMajor(fromVersion)) { return 'major'; } @@ -118,9 +115,6 @@ function getFromVersion( function getBucket(config: LookupUpdateConfig, update: LookupUpdate): string { const { separateMajorMinor, separateMultipleMajor } = config; const { updateType, newMajor } = update; - if (updateType === 'lockfileUpdate') { - return updateType; - } if ( !separateMajorMinor || config.major.automerge === true || @@ -331,7 +325,6 @@ export async function lookupUpdates( ); continue; // eslint-disable-line no-continue } - update.updateType = 'lockfileUpdate'; update.fromVersion = lockedVersion; update.displayFrom = lockedVersion; update.displayTo = toVersion; @@ -376,6 +369,18 @@ export async function lookupUpdates( if (sortedUpdates.length) { update.skippedOverVersions = sortedUpdates.map((u) => u.toVersion); } + if ( + rangeStrategy === 'update-lockfile' && + currentValue === update.newValue + ) { + update.isLockfileUpdate = true; + } + if ( + rangeStrategy === 'bump' && + version.matches(toVersion, currentValue) + ) { + update.isBump = true; + } res.updates.push(update); } } else if (!currentValue) { @@ -441,22 +446,6 @@ export async function lookupUpdates( } } } - for (const update of res.updates) { - const { updateType, fromVersion, toVersion } = update; - if (['bump', 'lockfileUpdate'].includes(updateType)) { - update[updateType === 'bump' ? 'isBump' : 'isLockfileUpdate'] = true; - if (version.getMajor(toVersion) > version.getMajor(fromVersion)) { - update.updateType = 'major'; - } else if ( - config.separateMinorPatch && - version.getMinor(toVersion) === version.getMinor(fromVersion) - ) { - update.updateType = 'patch'; - } else { - update.updateType = 'minor'; - } - } - } if (res.updates.length) { delete res.skipReason; }