mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-18 23:55:02 +00:00
Initial work on new automod
This commit is contained in:
parent
8914fe83c4
commit
846e623e3e
6 changed files with 888 additions and 5 deletions
|
@ -56,6 +56,14 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
|
|||
return (this.constructor as typeof ZeppelinPlugin).getStaticDefaultOptions() as IPluginOptions<TConfig>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the plugin to preprocess the config before it's validated.
|
||||
* Useful for e.g. adding default properties to dynamic objects.
|
||||
*/
|
||||
protected static preprocessStaticConfig(config: any) {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the given options and default options and decodes them according to the config schema of the plugin (if any).
|
||||
* Throws on any decoding/validation errors.
|
||||
|
@ -68,11 +76,13 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
|
|||
*/
|
||||
protected static mergeAndDecodeStaticOptions(options: any): IPluginOptions {
|
||||
const defaultOptions: any = this.getStaticDefaultOptions();
|
||||
const mergedConfig = mergeConfig({}, defaultOptions.config || {}, options.config || {});
|
||||
let mergedConfig = mergeConfig({}, defaultOptions.config || {}, options.config || {});
|
||||
const mergedOverrides = options["=overrides"]
|
||||
? options["=overrides"]
|
||||
: (options.overrides || []).concat(defaultOptions.overrides || []);
|
||||
|
||||
mergedConfig = this.preprocessStaticConfig(mergedConfig);
|
||||
|
||||
const decodedConfig = this.configSchema ? decodeAndValidateStrict(this.configSchema, mergedConfig) : mergedConfig;
|
||||
if (decodedConfig instanceof StrictValidationError) {
|
||||
throw decodedConfig;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue