@dhlab/e2e-autogen
Version:
Google 스프레드시트 기반 시나리오를 Playwright 테스트 스텁 코드로 자동 생성하고, 테스트 실행 결과를 다시 시트에 업데이트하는 CLI 도구
65 lines (63 loc) • 3.89 kB
JavaScript
'use strict';
var _Command_instances, _Command_args, _Command_config, _Command_hasFlag;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Command = void 0;
const tslib_1 = require("tslib");
const ts_pattern_1 = require("ts-pattern");
class Command {
constructor(args, config) {
_Command_instances.add(this);
_Command_args.set(this, void 0);
_Command_config.set(this, void 0);
tslib_1.__classPrivateFieldSet(this, _Command_args, args, "f");
tslib_1.__classPrivateFieldSet(this, _Command_config, config, "f");
}
get type() {
return (0, ts_pattern_1.match)(tslib_1.__classPrivateFieldGet(this, _Command_args, "f"))
.when(() => tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "--help") ||
tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "-h") ||
tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "--version") ||
tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "-v"), () => "FLAG")
.when((args) => args[0] === "generate" || args[0] === "update", () => "SUB_COMMAND")
.otherwise(() => {
throw new Error("flag 또는 sub command 필요");
});
}
get flag() {
return (0, ts_pattern_1.match)(tslib_1.__classPrivateFieldGet(this, _Command_args, "f"))
.when(() => tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "--help") || tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "-h"), () => "HELP")
.when(() => tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "--version") || tslib_1.__classPrivateFieldGet(this, _Command_instances, "m", _Command_hasFlag).call(this, "-v"), () => "VERSION")
.otherwise(() => {
throw new Error("플래그 명령이 아닙니다.");
});
}
get subCommand() {
return (0, ts_pattern_1.match)(tslib_1.__classPrivateFieldGet(this, _Command_args, "f")[0])
.with("generate", () => "GENERATE")
.with("update", () => "UPDATE")
.otherwise(() => {
throw new Error("서브커맨드가 필요합니다. 'generate' 또는 'update'를 지정해주세요.");
});
}
optionsOf(subCommand) {
return (0, ts_pattern_1.match)(subCommand)
.with("GENERATE", () => ({
sheetsUrl: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").sheetsUrl,
credentialsFile: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").credentialsFile,
stubOutputFolder: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").stubOutputFolder,
framework: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").framework,
googleSheetColumns: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").googleSheetColumns,
}))
.with("UPDATE", () => ({
sheetsUrl: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").sheetsUrl,
credentialsFile: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").credentialsFile,
jsonReporterFile: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").jsonReporterFile,
googleSheetColumns: tslib_1.__classPrivateFieldGet(this, _Command_config, "f").googleSheetColumns,
}))
.exhaustive();
}
}
exports.Command = Command;
_Command_args = new WeakMap(), _Command_config = new WeakMap(), _Command_instances = new WeakSet(), _Command_hasFlag = function _Command_hasFlag(flag) {
return tslib_1.__classPrivateFieldGet(this, _Command_args, "f").includes(flag);
};