2022-08-06 17:51:21 +00:00
|
|
|
import './core/logger/index.ts';
|
2022-08-07 23:51:36 +00:00
|
|
|
import type { CommandInterface } from './commands/command/command-interface.ts';
|
|
|
|
|
import type { EnvVariables } from './core/env/env-variables.ts';
|
|
|
|
|
import { Options } from './config/options.ts';
|
|
|
|
|
import { CommandFactory } from './commands/command-factory.ts';
|
|
|
|
|
import { ArgumentsParser } from './core/cli/arguments-parser.ts';
|
2022-08-09 21:53:46 +00:00
|
|
|
import System from './model/system.ts';
|
2022-08-07 23:51:36 +00:00
|
|
|
|
|
|
|
|
export class GameCI {
|
|
|
|
|
private readonly commandFactory: CommandFactory;
|
|
|
|
|
private readonly argumentsParser: ArgumentsParser;
|
|
|
|
|
private readonly env: EnvVariables;
|
|
|
|
|
|
|
|
|
|
private options?: Options;
|
|
|
|
|
private command?: CommandInterface;
|
|
|
|
|
|
|
|
|
|
constructor(envVariables: EnvVariables) {
|
|
|
|
|
this.env = envVariables;
|
2021-03-13 23:44:01 +00:00
|
|
|
|
2022-08-07 23:51:36 +00:00
|
|
|
this.commandFactory = new CommandFactory();
|
|
|
|
|
this.argumentsParser = new ArgumentsParser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async run(cliArguments: string[]) {
|
|
|
|
|
try {
|
|
|
|
|
const { commandName, args } = this.argumentsParser.parse(cliArguments);
|
|
|
|
|
|
|
|
|
|
this.options = await new Options(this.env).generateParameters(args);
|
|
|
|
|
this.command = this.commandFactory.createCommand(commandName);
|
|
|
|
|
|
|
|
|
|
await this.command.execute(this.options);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
log.error(error);
|
|
|
|
|
Deno.exit(1);
|
|
|
|
|
}
|
2021-03-13 23:44:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-06-07 21:59:34 +00:00
|
|
|
|
2022-08-07 23:51:36 +00:00
|
|
|
await new GameCI(Deno.env.toObject()).run(Deno.args);
|