import {ExtolloCompileConfig} from './types' import {Phase} from './phases/Phase' import {PreparePhase} from './phases/PreparePhase' import {ZodifyPhase} from './phases/ZodifyPhase' import {CompilePhase} from './phases/CompilePhase' import {NonSourcePhase} from './phases/NonSourcePhase' import {Logger} from './Logger' export class ExCompiler { protected phases: Phase[] = [] constructor( protected tsconfigPath: string, protected outputDirectory: string, protected tsconfig: any, protected config: ExtolloCompileConfig, ) { this.initialize() } protected initialize(): void { this.phases.push(new PreparePhase(this.config, this.tsconfig)) if ( this.config.zodify ) { for ( const zodPath of this.config.zodify ) { this.phases.push(new ZodifyPhase(this.config, this.tsconfig, zodPath)) } } this.phases.push(new CompilePhase(this.config, this.tsconfig, this.tsconfigPath)) if ( this.config['non-source'] ) { for ( const nonSourcePath of this.config['non-source'] ) { this.phases.push(new NonSourcePhase(this.config, this.tsconfig, nonSourcePath)) } } } public async run(): Promise { Logger.info('Start compile...') for ( const phase of this.phases ) { await phase.run() } Logger.success('Compiled successfully!') } }