diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap index c4df79d9deb94f3c13c4d370b6f99cb676b26cea..db38d887a4b134f1e638e51af33199e214868a4e 100644 --- a/lib/config/__snapshots__/migration.spec.ts.snap +++ b/lib/config/__snapshots__/migration.spec.ts.snap @@ -172,6 +172,21 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1` }, "onboarding": false, "packageRules": [ + { + "enabled": false, + "matchCategories": [ + "python", + ], + "matchPackageNames": [ + "foo", + ], + }, + { + "enabled": false, + "matchCategories": [ + "dotnet", + ], + }, { "excludePackageNames": "foo", "groupName": "angular packages", @@ -311,17 +326,6 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack } `; -exports[`config/migration migrateConfig(config, parentConfig) migrates node to travis 1`] = ` -{ - "node": { - "automerge": false, - }, - "travis": { - "enabled": true, - }, -} -`; - exports[`config/migration migrateConfig(config, parentConfig) migrates packageFiles 1`] = ` { "includePaths": [ diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index 02efcb1ce6b321f401a2ce0d733145f0244b14b8..63e2e4d3ce49ac7a4a5b57e51c608d298191b40f 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -122,6 +122,9 @@ describe('config/migration', () => { ], }, ], + dotnet: { + enabled: false, + }, exposeEnv: true, lockFileMaintenance: { exposeEnv: false, @@ -133,6 +136,14 @@ describe('config/migration', () => { automerge: 'minor', schedule: null, }, + python: { + packageRules: [ + { + matchPackageNames: ['foo'], + enabled: false, + }, + ], + }, nvmrc: { pathRules: [ { @@ -159,7 +170,7 @@ describe('config/migration', () => { expect(isMigrated).toBeTrue(); expect(migratedConfig.depTypes).toBeUndefined(); expect(migratedConfig.automerge).toBe(false); - expect(migratedConfig.packageRules).toHaveLength(9); + expect(migratedConfig.packageRules).toHaveLength(11); expect(migratedConfig.hostRules).toHaveLength(1); }); @@ -309,25 +320,6 @@ describe('config/migration', () => { ).toBeFalse(); }); - it('migrates node to travis', () => { - const config: TestRenovateConfig = { - node: { - enabled: true, - automerge: 'none' as never, - }, - }; - const { isMigrated, migratedConfig } = - configMigration.migrateConfig(config); - expect(migratedConfig).toMatchSnapshot(); - expect(isMigrated).toBeTrue(); - expect( - (migratedConfig.node as RenovateSharedConfig).enabled - ).toBeUndefined(); - expect((migratedConfig.travis as RenovateSharedConfig).enabled).toBe( - true - ); - }); - it('migrates packageFiles', () => { const config: TestRenovateConfig = { packageFiles: [ diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 3679b9b01e3fd66fcf869d8255d49ee9a81f4de6..995bf55376fb0f3b6ef97e6fd8fa381773074d7e 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -104,6 +104,30 @@ export function migrateConfig(config: RenovateConfig): MigratedConfig { } } } + const languages = [ + 'docker', + 'dotnet', + 'golang', + 'java', + 'js', + 'node', + 'php', + 'python', + 'ruby', + 'rust', + ]; + for (const language of languages) { + if (is.nonEmptyObject(migratedConfig[language])) { + migratedConfig.packageRules ??= []; + const currentContent = migratedConfig[language] as any; + const packageRule = { + matchCategories: [language], + ...currentContent, + }; + migratedConfig.packageRules.unshift(packageRule); + delete migratedConfig[language]; + } + } // Migrate nested packageRules if (is.nonEmptyArray(migratedConfig.packageRules)) { const existingRules = migratedConfig.packageRules;