Skip to content
Snippets Groups Projects
Commit cffbc00f authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix: resolve all presets before merge (#710)

Previously, preset resolution was being done last, after merges of renoate.json or package.json config. This caused wrong ordering of config in cases where both presets + regular config was in use. Instead, resolving of presets is now done at each stage before merging.

Fixes #708
parent 71c49ecd
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ const configParser = require('../../config'); ...@@ -6,6 +6,7 @@ const configParser = require('../../config');
const configMigration = require('../../config/migration'); const configMigration = require('../../config/migration');
const configMassage = require('../../config/massage'); const configMassage = require('../../config/massage');
const configValidation = require('../../config/validation'); const configValidation = require('../../config/validation');
const presets = require('../../config/presets');
// API // API
const githubApi = require('../../api/github'); const githubApi = require('../../api/github');
const gitlabApi = require('../../api/gitlab'); const gitlabApi = require('../../api/gitlab');
...@@ -180,7 +181,19 @@ async function mergeRenovateJson(config, branchName) { ...@@ -180,7 +181,19 @@ async function mergeRenovateJson(config, branchName) {
renovateJson = JSON.parse(renovateJsonContent); renovateJson = JSON.parse(renovateJsonContent);
config.logger.debug({ config: renovateJson }, 'renovate.json config'); config.logger.debug({ config: renovateJson }, 'renovate.json config');
const migratedConfig = migrateAndValidate(config, renovateJson); const migratedConfig = migrateAndValidate(config, renovateJson);
returnConfig = configParser.mergeChildConfig(returnConfig, migratedConfig); config.logger.debug(
{ config: migratedConfig },
'renovate.json migrated config'
);
const resolvedConfig = await presets.resolveConfigPresets(
migratedConfig,
config.logger
);
config.logger.debug(
{ config: resolvedConfig },
'renovate.json resolved config'
);
returnConfig = configParser.mergeChildConfig(returnConfig, resolvedConfig);
returnConfig.renovateJsonPresent = true; returnConfig.renovateJsonPresent = true;
} catch (err) { } catch (err) {
// Add to config.errors // Add to config.errors
...@@ -247,14 +260,29 @@ async function resolvePackageFiles(inputConfig) { ...@@ -247,14 +260,29 @@ async function resolvePackageFiles(inputConfig) {
// hoist renovate config if exists // hoist renovate config if exists
if (packageFile.content.renovate) { if (packageFile.content.renovate) {
config.logger.debug( config.logger.debug(
{ packageFile: packageFile.packageFile }, {
`Found renovate config` packageFile: packageFile.packageFile,
config: packageFile.content.renovate,
},
`Found package.json renovate config`
);
const migratedConfig = migrateAndValidate(
config,
packageFile.content.renovate
); );
config.hasPackageJsonRenovateConfig = true; config.logger.debug(
Object.assign( { config: migratedConfig },
packageFile, 'package.json migrated config'
migrateAndValidate(config, packageFile.content.renovate) );
const resolvedConfig = await presets.resolveConfigPresets(
migratedConfig,
config.logger
); );
config.logger.debug(
{ config: resolvedConfig },
'package.json resolved config'
);
Object.assign(packageFile, resolvedConfig);
delete packageFile.content.renovate; delete packageFile.content.renovate;
} else { } else {
config.logger.debug( config.logger.debug(
...@@ -287,7 +315,7 @@ async function resolvePackageFiles(inputConfig) { ...@@ -287,7 +315,7 @@ async function resolvePackageFiles(inputConfig) {
) { ) {
config.logger.debug( config.logger.debug(
{ packageFile: packageFile.packageFile }, { packageFile: packageFile.packageFile },
'Found yarn.lock' 'Found package-lock.json'
); );
packageFile.hasPackageLock = true; packageFile.hasPackageLock = true;
} else { } else {
......
...@@ -60,9 +60,6 @@ async function renovateRepository(repoConfig, token) { ...@@ -60,9 +60,6 @@ async function renovateRepository(repoConfig, token) {
logger.debug('Resolving package files and content'); logger.debug('Resolving package files and content');
config = await apis.resolvePackageFiles(config); config = await apis.resolvePackageFiles(config);
logger.trace({ config }, 'post-packageFiles config'); logger.trace({ config }, 'post-packageFiles config');
logger.debug('Resolving config presets');
config = await presets.resolveConfigPresets(config);
logger.trace({ config }, 'post-presets config');
// TODO: why is this fix needed?! // TODO: why is this fix needed?!
config.logger = logger; config.logger = logger;
config.repoIsOnboarded = await onboarding.getOnboardingStatus(config); config.repoIsOnboarded = await onboarding.getOnboardingStatus(config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment