diff --git a/lib/config/file.js b/lib/config/file.js index 00040488c5e5b71897cea291958599604db54055..bf542b8df0f4f7e9cc3c1f30d27be2419938b21c 100644 --- a/lib/config/file.js +++ b/lib/config/file.js @@ -1,4 +1,5 @@ const path = require('path'); +const { migrateConfig } = require('./migration'); module.exports = { getConfig, @@ -17,5 +18,13 @@ function getConfig(env) { // Do nothing logger.debug('No config file found on disk - skipping'); } + const { isMigrated, migratedConfig } = migrateConfig(config); + if (isMigrated) { + logger.warn( + { originalConfig: config, migratedConfig }, + 'Renovate bot config needs migrating' + ); + config = migratedConfig; + } return config; } diff --git a/test/_fixtures/config/file.js b/test/_fixtures/config/file.js index e2ec5f0f64459286256e15b747dbe7f63e3546b0..c0d636dd5549016a6222f8b6781f33a4220cc070 100644 --- a/test/_fixtures/config/file.js +++ b/test/_fixtures/config/file.js @@ -1,20 +1,4 @@ module.exports = { token: 'abcdefg', - logLevel: 'error', - repositories: [ - 'singapore/lint-condo', - { - repository: 'renovatebot/renovate', - packageFiles: ['package2.json'], - }, - { - repository: 'renovatebot/renovate', - packageFiles: [ - { - packageFile: 'package.json', - labels: ['a'], - }, - ], - }, - ], + logLevel: 'error' }; diff --git a/test/_fixtures/config/file2.js b/test/_fixtures/config/file2.js new file mode 100644 index 0000000000000000000000000000000000000000..b8b35e670de78050b35a331f64671fe22e4f8c9d --- /dev/null +++ b/test/_fixtures/config/file2.js @@ -0,0 +1,3 @@ +module.exports = { + upgradeInRange: true +}; diff --git a/test/config/__snapshots__/file.spec.js.snap b/test/config/__snapshots__/file.spec.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..2050852983026d89f2b084319af40138191283cf --- /dev/null +++ b/test/config/__snapshots__/file.spec.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`config/file .getConfig() migrates 1`] = ` +Object { + "rangeStrategy": "bump", +} +`; diff --git a/test/config/file.spec.js b/test/config/file.spec.js index 0573dda9ca59c2142de4d7de6f112d2259aaa56d..5b55c93e9c74208075e0e18cc803cb93af8822d1 100644 --- a/test/config/file.spec.js +++ b/test/config/file.spec.js @@ -5,13 +5,24 @@ const customConfig = require('../_fixtures/config/file'); describe('config/file', () => { describe('.getConfig()', () => { it('returns empty env', () => { - file.getConfig({}).should.eql({}); + expect(file.getConfig({ RENOVATE_CONFIG_FILE: 'dummylocation' })).toEqual( + {} + ); }); it('parses custom config file', () => { const configFile = path.resolve(__dirname, '../_fixtures/config/file.js'); - file - .getConfig({ RENOVATE_CONFIG_FILE: configFile }) - .should.eql(customConfig); + expect(file.getConfig({ RENOVATE_CONFIG_FILE: configFile })).toEqual( + customConfig + ); + }); + it('migrates', () => { + const configFile = path.resolve( + __dirname, + '../_fixtures/config/file2.js' + ); + const res = file.getConfig({ RENOVATE_CONFIG_FILE: configFile }); + expect(res).toMatchSnapshot(); + expect(res.rangeStrategy).toEqual('bump'); }); }); });