/
global.ts
53 lines (46 loc) · 1.37 KB
/
global.ts
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
import type { RenovateConfig, RepoGlobalConfig } from './types';
export class GlobalConfig {
// TODO: once global config work is complete, add a test to make sure this list includes all options with globalOnly=true (#9603)
private static readonly OPTIONS = [
'allowCustomCrateRegistries',
'allowedPostUpgradeCommands',
'allowPlugins',
'allowPostUpgradeCommandTemplating',
'allowScripts',
'binarySource',
'cacheDir',
'customEnvVariables',
'dockerChildPrefix',
'dockerImagePrefix',
'dockerUser',
'dryRun',
'exposeAllEnv',
'executionTimeout',
'localDir',
'migratePresets',
'privateKey',
'privateKeyOld',
];
private static config: RepoGlobalConfig = {};
static get(): RepoGlobalConfig;
static get<Key extends keyof RepoGlobalConfig>(
key?: Key
): RepoGlobalConfig[Key];
static get<Key extends keyof RepoGlobalConfig>(
key?: Key
): RepoGlobalConfig | RepoGlobalConfig[Key] {
return key ? GlobalConfig.config[key] : GlobalConfig.config;
}
static set(config: RenovateConfig | RepoGlobalConfig): RenovateConfig {
GlobalConfig.reset();
const result = { ...config };
for (const option of GlobalConfig.OPTIONS) {
GlobalConfig.config[option] = config[option];
delete result[option];
}
return result;
}
static reset(): void {
GlobalConfig.config = {};
}
}