@boost/config
Version:
Powerful convention based finder, loader, and manager of both configuration and ignore files.
45 lines (41 loc) • 1.69 kB
JavaScript
import { schemas } from '@boost/common/optimal';
/**
* Create an `optimal` schema for validating the structure of an "extends" setting.
*/
function createExtendsSchema(schematics = schemas) {
const array = schematics.array,
string = schematics.string,
union = schematics.union;
return union([]).of([string().notEmpty(), array().of(string().notEmpty())]).notNullable();
}
/**
* Create an `optimal` schema for validating the structure of a "plugins" setting.
*/
function createPluginsSchema(schematics = schemas) {
const array = schematics.array,
bool = schematics.bool,
object = schematics.object,
string = schematics.string,
tuple = schematics.tuple,
union = schematics.union;
const pluginOptions = union({}).of([bool(), object()]);
const pluginSource = string().notEmpty();
const pluginEntry = tuple([pluginSource, pluginOptions]);
return union({}).of([array().of(union('').of([pluginSource, pluginEntry])), object().of(pluginOptions).notNullable()]);
}
/**
* Create an `optimal` schema for validating the structure of an "overrides" setting.
*/
function createOverridesSchema(blueprint, schematics = schemas) {
const array = schematics.array,
shape = schematics.shape,
string = schematics.string,
union = schematics.union;
return array().of(shape({
exclude: union([]).of([string().notEmpty(), array().of(string().notEmpty())]),
include: union([]).of([string().notEmpty(), array().of(string().notEmpty())]),
settings: shape(blueprint).notNullable()
}).exact().notNullable()).notNullable();
}
export { createExtendsSchema, createOverridesSchema, createPluginsSchema };
//# sourceMappingURL=schemas.mjs.map