Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pluginsBlueprint[pluralName] = array(union>([
string().notEmpty(),
shape({ [singularName]: string().notEmpty() }),
instance(contract, true),
], []));
});
const config = optimal(
this.inheritFromArgs(this.parseAndExtend(configPath), args),
{
...configBlueprint,
...pluginsBlueprint,
debug: bool(),
extends: array(string()),
locale: string(),
output: number(2).between(1, 3, true),
// shape() requires a non-empty object
settings: isEmpty(settingsBlueprint) ? object() : shape(settingsBlueprint),
silent: bool(),
theme: string('default').notEmpty(),
},
{
file: configPath instanceof Path ? configPath.name() : '',
name: 'ConfigLoader',
unknown: true,
},
);
return (config as unknown) as T;
}
protected toString(state: ProgressState): string {
const { color, current, style: styleName, template, total, transparent } = optimal(
state,
{
color: bool(),
current: number()
.required()
.gte(0),
style: string('bar').oneOf(Object.keys(STYLES) as ProgressStyle[]),
template: string('{percent} {bar} {progress}').notEmpty(),
total: number()
.required()
.gt(0),
transparent: bool(),
},
{
name: 'ProgressOutput',
},
);
// Mark as final for convenience
if (current >= total) {
pluginsBlueprint[pluralName] = array(union>([
string().notEmpty(),
shape({ [singularName]: string().notEmpty() }),
instance(contract as Constructor, true),
], []));
});
const config = optimal(
this.inheritFromArgs(this.parseAndExtend(configPath), args),
{
...configBlueprint,
...pluginsBlueprint,
debug: bool(),
extends: array(string()),
locale: string(),
output: number(2).between(1, 3, true),
// shape() requires a non-empty object
settings: isEmptyObject(settingsBlueprint) ? object() : shape(settingsBlueprint),
silent: bool(),
theme: string('default').notEmpty(),
},
{
file: typeof configPath === 'string' ? path.basename(configPath) : '',
name: 'ConfigLoader',
unknown: true,
},
);
return config as T;
}
constructor(tool: Tool, context: Ctx, options?: PoolExecutorOptions) {
super(tool, context, options);
this.options = optimal(
{ ...options },
{
concurrency: number(os.cpus().length).gte(1),
fifo: bool(true),
timeout: number(0).gte(0),
},
{
name: 'PoolExecutor',
},
);
}
export function configBlueprint() {
return {
configure: shape({
cleanup: bool(false),
parallel: bool(true),
}),
execute: shape({
concurrency: number(),
graph: bool(true),
}),
module: process.env.BEEMO_CONFIG_MODULE
? string(process.env.BEEMO_CONFIG_MODULE)
: string().required(),
};
}
constructor(tool: Tool, context: Ctx, options?: PoolExecutorOptions) {
super(tool, context, options);
this.options = optimal(
{ ...options },
{
concurrency: number(os.cpus().length).gte(1),
fifo: bool(true),
timeout: number(0).gte(0),
},
{
name: 'PoolExecutor',
},
);
}