diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 986d8bc395d6f4..26e13ba8e45673 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -4947,6 +4947,29 @@ describe('workers/repository/process/lookup/index', () => { ]); }); + it('handles replacements - from datasource', async () => { + config.currentValue = '2.0.0'; + config.packageName = 'org.example:foo'; + config.datasource = MavenDatasource.id; + getMavenReleases.mockResolvedValueOnce({ + releases: [{ version: '2.0.0' }], + replacementName: 'foo:bar', + replacementVersion: '2.0.0', + }); + + const { updates } = await Result.wrap( + lookup.lookupUpdates(config), + ).unwrapOrThrow(); + + expect(updates).toEqual([ + { + updateType: 'replacement', + newName: 'foo:bar', + newValue: '2.0.0', + }, + ]); + }); + it('rollback for invalid version to last stable version', async () => { config.currentValue = '2.5.17'; config.packageName = 'vue'; diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index e481f6b3acbc0d..7c674c80080dd1 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -571,6 +571,12 @@ export async function lookupUpdates( if (isReplacementRulesConfigured(config)) { addReplacementUpdateIfValid(res.updates, config); + } else if (dependency?.replacementName && dependency.replacementVersion) { + res.updates.push({ + updateType: 'replacement', + newName: dependency.replacementName, + newValue: dependency.replacementVersion, + }); } // Record if the dep is fixed to a version