2017-11-03 07:25:51 +00:00
|
|
|
const configMigration = require('./migration');
|
|
|
|
const configMassage = require('./massage');
|
|
|
|
const configValidation = require('./validation');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
migrateAndValidate,
|
|
|
|
};
|
|
|
|
|
|
|
|
function migrateAndValidate(config, input) {
|
2017-12-18 08:39:52 +00:00
|
|
|
logger.debug('migrateAndValidate()');
|
2017-11-03 07:25:51 +00:00
|
|
|
const { isMigrated, migratedConfig } = configMigration.migrateConfig(input);
|
|
|
|
if (isMigrated) {
|
|
|
|
logger.info(
|
|
|
|
{ oldConfig: input, newConfig: migratedConfig },
|
|
|
|
'Config migration necessary'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
const massagedConfig = configMassage.massageConfig(migratedConfig);
|
|
|
|
const { warnings, errors } = configValidation.validateConfig(massagedConfig);
|
|
|
|
// istanbul ignore if
|
|
|
|
if (warnings.length) {
|
2017-12-18 08:39:52 +00:00
|
|
|
logger.info({ warnings }, 'Found renovate config warnings');
|
2017-11-03 07:25:51 +00:00
|
|
|
}
|
|
|
|
if (errors.length) {
|
2017-12-18 08:39:52 +00:00
|
|
|
logger.info({ errors }, 'Found renovate config errors');
|
2017-11-03 07:25:51 +00:00
|
|
|
}
|
2017-12-18 08:39:52 +00:00
|
|
|
massagedConfig.errors = (config.errors || []).concat(errors);
|
2017-11-03 07:25:51 +00:00
|
|
|
if (!config.repoIsOnboarded) {
|
|
|
|
// TODO #556 - enable warnings in real PRs
|
|
|
|
massagedConfig.warnings = (config.warnings || []).concat(warnings);
|
|
|
|
}
|
|
|
|
return massagedConfig;
|
|
|
|
}
|