mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 13:38:32 +00:00
0a438657e8
Co-authored-by: Rhys Arkins <rhys@arkins.net>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { dequal } from 'dequal';
|
|
import { massageConfig } from '../../../../config/massage';
|
|
import { migrateConfig } from '../../../../config/migration';
|
|
import type { RenovateConfig } from '../../../../config/types';
|
|
import { validateConfig } from '../../../../config/validation';
|
|
import { logger } from '../../../../logger';
|
|
|
|
export async function migrateAndValidateConfig(
|
|
config: RenovateConfig,
|
|
configType: string,
|
|
): Promise<RenovateConfig> {
|
|
const { isMigrated, migratedConfig } = migrateConfig(config);
|
|
if (isMigrated) {
|
|
logger.warn(
|
|
{ originalConfig: config, migratedConfig },
|
|
`${configType} needs migrating`,
|
|
);
|
|
}
|
|
const massagedConfig = massageConfig(migratedConfig);
|
|
// log only if it's changed
|
|
if (!dequal(migratedConfig, massagedConfig)) {
|
|
logger.trace({ config: massagedConfig }, 'Post-massage config');
|
|
}
|
|
|
|
const { warnings, errors } = await validateConfig('global', massagedConfig);
|
|
|
|
if (warnings.length) {
|
|
logger.warn(
|
|
{ warnings },
|
|
`Config validation warnings found in ${configType}`,
|
|
);
|
|
}
|
|
if (errors.length) {
|
|
logger.warn({ errors }, `Config validation errors found in ${configType}`);
|
|
}
|
|
|
|
return massagedConfig;
|
|
}
|