2021-08-15 05:25:30 +00:00
|
|
|
import { getOptions } from './options';
|
2021-06-02 09:25:10 +00:00
|
|
|
import type { AllConfig, RenovateOptions } from './types';
|
2017-01-20 13:03:18 +00:00
|
|
|
|
|
|
|
const defaultValues = {
|
|
|
|
boolean: true,
|
2019-03-31 06:01:06 +00:00
|
|
|
array: [],
|
2017-01-20 13:03:18 +00:00
|
|
|
string: null,
|
2019-03-31 06:01:06 +00:00
|
|
|
object: null,
|
2017-01-20 13:03:18 +00:00
|
|
|
};
|
|
|
|
|
2019-08-23 13:46:31 +00:00
|
|
|
export function getDefault(option: RenovateOptions): any {
|
2017-04-21 08:12:41 +00:00
|
|
|
return option.default === undefined
|
|
|
|
? defaultValues[option.type]
|
|
|
|
: option.default;
|
2017-01-20 13:03:18 +00:00
|
|
|
}
|
|
|
|
|
2021-06-02 09:25:10 +00:00
|
|
|
export function getConfig(): AllConfig {
|
2019-08-23 13:46:31 +00:00
|
|
|
const options = getOptions();
|
2021-06-02 09:25:10 +00:00
|
|
|
const config: AllConfig = {};
|
2020-04-12 16:09:36 +00:00
|
|
|
options.forEach((option) => {
|
2018-05-06 06:29:38 +00:00
|
|
|
if (!option.parent) {
|
2018-05-03 12:07:20 +00:00
|
|
|
config[option.name] = getDefault(option);
|
|
|
|
}
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
2017-06-26 11:08:57 +00:00
|
|
|
return config;
|
|
|
|
}
|