generated from garrettmills/template-npm-typescript
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
47 lines
1.4 KiB
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<void> {
|
|
Logger.info('Start compile...')
|
|
for ( const phase of this.phases ) {
|
|
await phase.run()
|
|
}
|
|
Logger.success('Compiled successfully!')
|
|
}
|
|
}
|