mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
96c4df2776
* chore: use ExtractConfig for git-submodules * chore: drop ManagerConfig from config/types * chore: remove unused ManagerConfig from manager types
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { logger } from '../logger';
|
|
import { get, getLanguageList, getManagerList } from '../manager';
|
|
import * as options from './options';
|
|
import type { AllConfig, RenovateConfig, RenovateConfigStage } from './types';
|
|
import { mergeChildConfig } from './utils';
|
|
|
|
export { mergeChildConfig };
|
|
|
|
export function getManagerConfig(
|
|
config: RenovateConfig,
|
|
manager: string
|
|
): RenovateConfig {
|
|
let managerConfig: RenovateConfig = {
|
|
...config,
|
|
language: null,
|
|
manager: null,
|
|
};
|
|
const language = get(manager, 'language');
|
|
if (language) {
|
|
managerConfig = mergeChildConfig(managerConfig, config[language]);
|
|
}
|
|
managerConfig = mergeChildConfig(managerConfig, config[manager]);
|
|
for (const i of getLanguageList().concat(getManagerList())) {
|
|
delete managerConfig[i];
|
|
}
|
|
managerConfig.language = language;
|
|
managerConfig.manager = manager;
|
|
return managerConfig;
|
|
}
|
|
|
|
export function filterConfig(
|
|
inputConfig: AllConfig,
|
|
targetStage: RenovateConfigStage
|
|
): AllConfig {
|
|
logger.trace({ config: inputConfig }, `filterConfig('${targetStage}')`);
|
|
const outputConfig: RenovateConfig = { ...inputConfig };
|
|
const stages = ['global', 'repository', 'package', 'branch', 'pr'];
|
|
const targetIndex = stages.indexOf(targetStage);
|
|
for (const option of options.getOptions()) {
|
|
const optionIndex = stages.indexOf(option.stage);
|
|
if (optionIndex !== -1 && optionIndex < targetIndex) {
|
|
delete outputConfig[option.name];
|
|
}
|
|
}
|
|
return outputConfig;
|
|
}
|