import type { Blueprint, Schemas } from '@boost/common'; import { Configuration } from '@boost/config'; import type { BuildParams, ConfigFile, ConfigMutator, ConfigMutatorWithBuild } from './types'; export class Config extends Configuration { blueprint({ bool, func }: Schemas): Blueprint { return { babelInput: func(), babelOutput: func(), rollupInput: func(), rollupOutput: func(), swc: bool(), swcInput: func(), swcOutput: func(), }; } override bootstrap() { this.configureFinder({ errorIfNoRootFound: false, extensions: ['js', 'ts'], }); this.addProcessHandler('babelInput', this.wrapMutator); this.addProcessHandler('babelOutput', this.wrapBuildMutator); this.addProcessHandler('rollupInput', this.wrapMutator); this.addProcessHandler('rollupOutput', this.wrapBuildMutator); } wrapMutator(prev?: ConfigMutator, next?: ConfigMutator) { return (options: T) => { prev?.(options); next?.(options); }; } wrapBuildMutator(prev?: ConfigMutatorWithBuild, next?: ConfigMutatorWithBuild) { return (options: T, build: BuildParams) => { prev?.(options, build); next?.(options, build); }; } }