@dhlab/e2e-autogen
Version:
Google 스프레드시트 기반 시나리오를 Playwright 테스트 스텁 코드로 자동 생성하고, 테스트 실행 결과를 다시 시트에 업데이트하는 CLI 도구
49 lines (47 loc) • 2.3 kB
JavaScript
;
var _CliApplication_instances, _CliApplication_parsedCommandType;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CliApplication = void 0;
const tslib_1 = require("tslib");
const ts_pattern_1 = require("ts-pattern");
const config_1 = require("../../config");
const generate_command_1 = require("./generate-command");
const help_command_1 = require("./help-command");
const init_command_1 = require("./init-command");
const update_command_1 = require("./update-command");
const version_command_1 = require("./version-command");
class CliApplication {
constructor() {
_CliApplication_instances.add(this);
}
async run(args) {
const commandType = tslib_1.__classPrivateFieldGet(this, _CliApplication_instances, "m", _CliApplication_parsedCommandType).call(this, args);
const command = (0, ts_pattern_1.match)(commandType)
.with("init", () => new init_command_1.InitCommand())
.with("help", () => new help_command_1.HelpCommand())
.with("version", () => new version_command_1.VersionCommand())
.with("generate", async () => {
const config = await (0, config_1.loadUserConfig)();
return new generate_command_1.GenerateCommand(config);
})
.with("update", async () => {
const config = await (0, config_1.loadUserConfig)();
return new update_command_1.UpdateCommand(config);
})
.exhaustive();
const resolvedCommand = await command;
await resolvedCommand.execute();
}
}
exports.CliApplication = CliApplication;
_CliApplication_instances = new WeakSet(), _CliApplication_parsedCommandType = function _CliApplication_parsedCommandType(args) {
return (0, ts_pattern_1.match)(args)
.when((args) => args.length === 0 || args.includes("--help") || args.includes("-h"), () => "help")
.when((args) => args.includes("--version") || args.includes("-v"), () => "version")
.when((args) => args[0] === "init", () => "init")
.when((args) => args[0] === "generate", () => "generate")
.when((args) => args[0] === "update", () => "update")
.otherwise(() => {
throw new Error(`알 수 없는 명령어: ${args[0] || "없음"}`);
});
};