1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import { logger } from '../logger';
import { get, getLanguageList, getManagerList } from '../modules/manager';
import * as options from './options';
import type {
AllConfig,
ManagerConfig,
RenovateConfig,
RenovateConfigStage,
} from './types';
import { mergeChildConfig } from './utils';
export { mergeChildConfig };
export function getManagerConfig(
config: RenovateConfig,
manager: string
): ManagerConfig {
let managerConfig: ManagerConfig = {
...config,
language: null,
manager,
};
const language = get(manager, 'language');
if (language) {
// TODO: fix types #7154
managerConfig = mergeChildConfig(managerConfig, config[language] as any);
managerConfig.language = language;
}
// TODO: fix types #7154
managerConfig = mergeChildConfig(managerConfig, config[manager] as any);
for (const i of getLanguageList().concat(getManagerList())) {
delete managerConfig[i];
}
return managerConfig;
}
export function filterConfig(
inputConfig: AllConfig,
targetStage: RenovateConfigStage
): AllConfig {
logger.trace({ config: inputConfig }, `filterConfig('${targetStage}')`);
const outputConfig: RenovateConfig = { ...inputConfig };
const stages: (string | undefined)[] = [
'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;
}
|