listpage_cli 0.0.293 → 0.0.295
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/adapters/cli-interaction.js +172 -0
- package/bin/adapters/node-fs-adapter.js +109 -0
- package/bin/app/dispatch.js +15 -0
- package/bin/app/execute.js +33 -0
- package/bin/app/parse-args.js +39 -0
- package/bin/cli.js +61 -75
- package/bin/commands/build-project-command.js +9 -0
- package/bin/commands/deploy-project-command.js +9 -0
- package/bin/commands/init-command.js +9 -0
- package/bin/commands/install-skill-command.js +9 -0
- package/bin/copy.js +14 -126
- package/bin/domain/command-result.js +34 -0
- package/bin/domain/interaction-result.js +14 -0
- package/bin/domain/package-name.js +12 -0
- package/bin/ports/build-project-command.js +2 -0
- package/bin/ports/deploy-project-command.js +2 -0
- package/bin/ports/filesystem-capability.js +2 -0
- package/bin/ports/fs-port.js +22 -0
- package/bin/ports/init-command.js +2 -0
- package/bin/ports/install-skill-command.js +2 -0
- package/bin/prompts.js +105 -16
- package/bin/services/artifact-validator.js +47 -0
- package/bin/services/build-project-service.js +190 -0
- package/bin/services/command-runner.js +45 -0
- package/bin/services/config-loader.js +113 -0
- package/bin/services/deploy-project-service.js +237 -0
- package/bin/services/filesystem-capability-service.js +137 -0
- package/bin/services/init-service.js +64 -0
- package/bin/services/install-skill-service.js +34 -0
- package/bin/shared/json-with-comments.js +9 -0
- package/package.json +6 -4
- package/templates/backend-template/package.json.tmpl +1 -1
- package/templates/frontend-template/package.json.tmpl +2 -2
- package/templates/package-app-template/package.json +1 -1
- package/templates/skills-template/listpage/examples.md +565 -0
- package/skills/listpage/examples.md +0 -243
- package/templates/rush-template/docs/ListPage-AI/347/224/237/346/210/220/350/247/204/350/214/203.md +0 -305
- /package/{skills → templates/skills-template}/listpage/SKILL.md +0 -0
- /package/{skills → templates/skills-template}/listpage/api.md +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runPrompt = runPrompt;
|
|
7
|
+
exports.askRushQuestions = askRushQuestions;
|
|
8
|
+
exports.askProjectPath = askProjectPath;
|
|
9
|
+
exports.askOverwrite = askOverwrite;
|
|
10
|
+
exports.askInstallDeployScript = askInstallDeployScript;
|
|
11
|
+
exports.printHelp = printHelp;
|
|
12
|
+
exports.printVersion = printVersion;
|
|
13
|
+
const enquirer_1 = require("enquirer");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const interaction_result_1 = require("../domain/interaction-result");
|
|
17
|
+
let promptTestScript = null;
|
|
18
|
+
let promptTestScriptIndex = 0;
|
|
19
|
+
function getTestPromptMode() {
|
|
20
|
+
const mode = process.env.LISTPAGE_CLI_PROMPT_TEST_MODE;
|
|
21
|
+
if (mode === "cancel" || mode === "invalid") {
|
|
22
|
+
return mode;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function getNextScriptedPromptResult() {
|
|
27
|
+
if (promptTestScript === null) {
|
|
28
|
+
const raw = process.env.LISTPAGE_CLI_PROMPT_TEST_SCRIPT;
|
|
29
|
+
if (!raw) {
|
|
30
|
+
promptTestScript = [];
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(raw);
|
|
35
|
+
if (Array.isArray(parsed)) {
|
|
36
|
+
promptTestScript = parsed;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
promptTestScript = [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
promptTestScript = [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const next = promptTestScript[promptTestScriptIndex];
|
|
47
|
+
promptTestScriptIndex += 1;
|
|
48
|
+
return next;
|
|
49
|
+
}
|
|
50
|
+
function isCancelError(error) {
|
|
51
|
+
if (!(error instanceof Error)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const normalized = error.message.toLowerCase();
|
|
55
|
+
return (normalized.includes("cancel") ||
|
|
56
|
+
normalized.includes("aborted") ||
|
|
57
|
+
normalized.includes("interrupted"));
|
|
58
|
+
}
|
|
59
|
+
async function runPrompt(options, runner = enquirer_1.prompt) {
|
|
60
|
+
const testMode = getTestPromptMode();
|
|
61
|
+
if (testMode === "cancel") {
|
|
62
|
+
return (0, interaction_result_1.interactionCancelled)();
|
|
63
|
+
}
|
|
64
|
+
if (testMode === "invalid") {
|
|
65
|
+
return (0, interaction_result_1.interactionInvalid)("测试模式: 模拟无效输入");
|
|
66
|
+
}
|
|
67
|
+
const scripted = getNextScriptedPromptResult();
|
|
68
|
+
if (scripted !== undefined) {
|
|
69
|
+
if (scripted === "cancel") {
|
|
70
|
+
return (0, interaction_result_1.interactionCancelled)();
|
|
71
|
+
}
|
|
72
|
+
if (scripted === "invalid") {
|
|
73
|
+
return (0, interaction_result_1.interactionInvalid)("测试脚本: 模拟无效输入");
|
|
74
|
+
}
|
|
75
|
+
return (0, interaction_result_1.interactionValue)(scripted);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const value = (await runner(options));
|
|
79
|
+
return (0, interaction_result_1.interactionValue)(value);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (isCancelError(error)) {
|
|
83
|
+
return (0, interaction_result_1.interactionCancelled)();
|
|
84
|
+
}
|
|
85
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
86
|
+
return (0, interaction_result_1.interactionInvalid)(reason);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function askRushQuestions() {
|
|
90
|
+
const frontend = await runPrompt({
|
|
91
|
+
type: "input",
|
|
92
|
+
name: "name",
|
|
93
|
+
message: "请输入前端项目名称,为空表示不创建前端项目",
|
|
94
|
+
initial: "",
|
|
95
|
+
});
|
|
96
|
+
if (frontend.status !== "value") {
|
|
97
|
+
return frontend;
|
|
98
|
+
}
|
|
99
|
+
const backend = await runPrompt({
|
|
100
|
+
type: "input",
|
|
101
|
+
name: "name",
|
|
102
|
+
message: "请输入后端项目名称,为空表示不创建后端项目",
|
|
103
|
+
initial: "",
|
|
104
|
+
});
|
|
105
|
+
if (backend.status !== "value") {
|
|
106
|
+
return backend;
|
|
107
|
+
}
|
|
108
|
+
return (0, interaction_result_1.interactionValue)({
|
|
109
|
+
frontendName: frontend.value.name,
|
|
110
|
+
backendName: backend.value.name,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async function askProjectPath() {
|
|
114
|
+
const result = await runPrompt({
|
|
115
|
+
type: "input",
|
|
116
|
+
name: "path",
|
|
117
|
+
message: "请填写项目名称或路径,如果填.表示直接把项目放到当前目录下",
|
|
118
|
+
initial: ".",
|
|
119
|
+
});
|
|
120
|
+
if (result.status !== "value") {
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
const p = (result.value.path || ".").trim();
|
|
124
|
+
return (0, interaction_result_1.interactionValue)(p || ".");
|
|
125
|
+
}
|
|
126
|
+
async function askOverwrite() {
|
|
127
|
+
const result = await runPrompt({
|
|
128
|
+
type: "confirm",
|
|
129
|
+
name: "ok",
|
|
130
|
+
message: "目标目录非空,是否覆盖?",
|
|
131
|
+
initial: false,
|
|
132
|
+
});
|
|
133
|
+
if (result.status !== "value") {
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
return (0, interaction_result_1.interactionValue)(result.value.ok);
|
|
137
|
+
}
|
|
138
|
+
async function askInstallDeployScript() {
|
|
139
|
+
const result = await runPrompt({
|
|
140
|
+
type: "confirm",
|
|
141
|
+
name: "ok",
|
|
142
|
+
message: "是否添加部署脚本?这个脚本允许你可以帮你快速构建docker镜像,并发布到阿里云等环境,但是需要本机有docker环境。",
|
|
143
|
+
initial: false,
|
|
144
|
+
});
|
|
145
|
+
if (result.status !== "value") {
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
return (0, interaction_result_1.interactionValue)(result.value.ok);
|
|
149
|
+
}
|
|
150
|
+
function printHelp() {
|
|
151
|
+
const h = [
|
|
152
|
+
"用法: listpage_cli init",
|
|
153
|
+
"说明: 进入中文引导式交互,按提示填写即可",
|
|
154
|
+
"用法: listpage_cli install-skill [skillName] [--project]",
|
|
155
|
+
"说明: 安装技能到 Cursor。默认 skillName 为 test,安装到当前命令执行目录的 .cursor/skills/",
|
|
156
|
+
"用法: listpage_cli build-project",
|
|
157
|
+
"说明: 非交互校验当前目录是否为有效项目根(需存在 listpage.config.json)",
|
|
158
|
+
"用法: listpage_cli deploy-project",
|
|
159
|
+
"说明: 先校验 .listpage/output 产物,再按 login/build/tag/push 执行 Docker 部署",
|
|
160
|
+
].join("\n");
|
|
161
|
+
console.log(h);
|
|
162
|
+
}
|
|
163
|
+
function printVersion() {
|
|
164
|
+
try {
|
|
165
|
+
const p = path_1.default.join(__dirname, "..", "..", "package.json");
|
|
166
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(p, "utf8"));
|
|
167
|
+
console.log(pkg.version || "");
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
console.log("");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createNodeFsAdapter = createNodeFsAdapter;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const fs_port_1 = require("../ports/fs-port");
|
|
11
|
+
function createNodeFsAdapter() {
|
|
12
|
+
return {
|
|
13
|
+
cwd: () => process.cwd(),
|
|
14
|
+
homedir: () => os_1.default.homedir(),
|
|
15
|
+
resolve: (...parts) => path_1.default.resolve(...parts),
|
|
16
|
+
join: (...parts) => path_1.default.join(...parts),
|
|
17
|
+
basename: (value) => path_1.default.basename(value),
|
|
18
|
+
dirname: (value) => path_1.default.dirname(value),
|
|
19
|
+
exists: (targetPath) => {
|
|
20
|
+
try {
|
|
21
|
+
return (0, fs_1.existsSync)(targetPath);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw toFsPortError("exists", targetPath, error);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
isDirectory: (targetPath) => {
|
|
28
|
+
try {
|
|
29
|
+
return (0, fs_1.statSync)(targetPath).isDirectory();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw toFsPortError("stat", targetPath, error);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
readDir: (targetPath) => {
|
|
36
|
+
try {
|
|
37
|
+
return (0, fs_1.readdirSync)(targetPath);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw toFsPortError("readDir", targetPath, error);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
ensureDir: (targetPath) => {
|
|
44
|
+
try {
|
|
45
|
+
(0, fs_1.mkdirSync)(targetPath, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw toFsPortError("ensureDir", targetPath, error);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
copyFile: (sourcePath, targetPath) => {
|
|
52
|
+
try {
|
|
53
|
+
(0, fs_1.copyFileSync)(sourcePath, targetPath);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw toFsPortError("copyFile", targetPath, error);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
rename: (sourcePath, targetPath) => {
|
|
60
|
+
try {
|
|
61
|
+
(0, fs_1.renameSync)(sourcePath, targetPath);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw toFsPortError("rename", targetPath, error);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
readText: (targetPath) => {
|
|
68
|
+
try {
|
|
69
|
+
return (0, fs_1.readFileSync)(targetPath, "utf8");
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw toFsPortError("readText", targetPath, error);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
writeText: (targetPath, content) => {
|
|
76
|
+
try {
|
|
77
|
+
(0, fs_1.writeFileSync)(targetPath, content, { encoding: "utf8" });
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
throw toFsPortError("writeText", targetPath, error);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function toFsPortError(operation, targetPath, error) {
|
|
86
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
87
|
+
const nodeCode = getNodeErrnoCode(error);
|
|
88
|
+
const code = mapNodeCodeToFsCode(nodeCode);
|
|
89
|
+
return new fs_port_1.FsPortError(code, operation, targetPath, `[${operation}] ${targetPath}: ${message}`, error);
|
|
90
|
+
}
|
|
91
|
+
function getNodeErrnoCode(error) {
|
|
92
|
+
if (!error || typeof error !== "object") {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const withCode = error;
|
|
96
|
+
return typeof withCode.code === "string" ? withCode.code : undefined;
|
|
97
|
+
}
|
|
98
|
+
function mapNodeCodeToFsCode(nodeCode) {
|
|
99
|
+
if (nodeCode === "ENOENT" || nodeCode === "ENOTDIR") {
|
|
100
|
+
return fs_port_1.FS_PORT_ERROR_CODES.notFound;
|
|
101
|
+
}
|
|
102
|
+
if (nodeCode === "EACCES" || nodeCode === "EPERM") {
|
|
103
|
+
return fs_port_1.FS_PORT_ERROR_CODES.permissionDenied;
|
|
104
|
+
}
|
|
105
|
+
if (nodeCode === "EINVAL") {
|
|
106
|
+
return fs_port_1.FS_PORT_ERROR_CODES.invalidPath;
|
|
107
|
+
}
|
|
108
|
+
return fs_port_1.FS_PORT_ERROR_CODES.operationFailed;
|
|
109
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatchCommand = dispatchCommand;
|
|
4
|
+
const command_result_1 = require("../domain/command-result");
|
|
5
|
+
async function dispatchCommand(input, handlers) {
|
|
6
|
+
const handler = handlers[input.command];
|
|
7
|
+
if (!handler) {
|
|
8
|
+
return (0, command_result_1.commandError)(`命令处理器不存在: ${input.command}`, command_result_1.COMMAND_ERROR_CODES.handlerNotFound, 1);
|
|
9
|
+
}
|
|
10
|
+
const result = await handler(input);
|
|
11
|
+
if (!(0, command_result_1.isCommandResult)(result)) {
|
|
12
|
+
return (0, command_result_1.commandError)(`命令处理器返回非法结果: ${input.command}`, command_result_1.COMMAND_ERROR_CODES.invalidCommandResult, 1);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCommand = executeCommand;
|
|
4
|
+
const dispatch_1 = require("./dispatch");
|
|
5
|
+
const parse_args_1 = require("./parse-args");
|
|
6
|
+
const command_result_1 = require("../domain/command-result");
|
|
7
|
+
async function executeCommand(argv, deps) {
|
|
8
|
+
try {
|
|
9
|
+
const parsed = (0, parse_args_1.parseArgs)(argv);
|
|
10
|
+
if (parsed.command === "help") {
|
|
11
|
+
deps.printHelp();
|
|
12
|
+
return (0, command_result_1.commandOk)();
|
|
13
|
+
}
|
|
14
|
+
if (parsed.command === "version") {
|
|
15
|
+
deps.printVersion();
|
|
16
|
+
return (0, command_result_1.commandOk)();
|
|
17
|
+
}
|
|
18
|
+
if (parsed.command === "unknown") {
|
|
19
|
+
return (0, command_result_1.commandError)(`未知命令: ${parsed.unknownCommand ?? ""}`, command_result_1.COMMAND_ERROR_CODES.unknownCommand, 1);
|
|
20
|
+
}
|
|
21
|
+
const dispatchInput = {
|
|
22
|
+
command: parsed.command,
|
|
23
|
+
rawArgs: parsed.rawArgs,
|
|
24
|
+
options: parsed.options,
|
|
25
|
+
positionals: parsed.positionals,
|
|
26
|
+
};
|
|
27
|
+
return await (0, dispatch_1.dispatchCommand)(dispatchInput, deps.handlers);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31
|
+
return (0, command_result_1.commandError)(message, command_result_1.COMMAND_ERROR_CODES.unexpectedError, 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArgs = parseArgs;
|
|
4
|
+
const KNOWN_COMMANDS = new Set([
|
|
5
|
+
"init",
|
|
6
|
+
"install-skill",
|
|
7
|
+
"build-project",
|
|
8
|
+
"deploy-project",
|
|
9
|
+
]);
|
|
10
|
+
function parseArgs(argv) {
|
|
11
|
+
const rawArgs = [...argv];
|
|
12
|
+
const commandToken = rawArgs[0];
|
|
13
|
+
const options = rawArgs.filter((arg) => arg.startsWith("-"));
|
|
14
|
+
const positionals = rawArgs.slice(1).filter((arg) => !arg.startsWith("-"));
|
|
15
|
+
if (rawArgs.includes("--version") || rawArgs.includes("-V")) {
|
|
16
|
+
return { command: "version", rawArgs, options, positionals };
|
|
17
|
+
}
|
|
18
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
19
|
+
return { command: "help", rawArgs, options, positionals };
|
|
20
|
+
}
|
|
21
|
+
if (!commandToken) {
|
|
22
|
+
return { command: "help", rawArgs, options, positionals };
|
|
23
|
+
}
|
|
24
|
+
if (!KNOWN_COMMANDS.has(commandToken)) {
|
|
25
|
+
return {
|
|
26
|
+
command: "unknown",
|
|
27
|
+
rawArgs,
|
|
28
|
+
options,
|
|
29
|
+
positionals,
|
|
30
|
+
unknownCommand: commandToken,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
command: commandToken,
|
|
35
|
+
rawArgs,
|
|
36
|
+
options,
|
|
37
|
+
positionals,
|
|
38
|
+
};
|
|
39
|
+
}
|
package/bin/cli.js
CHANGED
|
@@ -1,82 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
4
|
+
const cli_interaction_1 = require("./adapters/cli-interaction");
|
|
5
|
+
const execute_1 = require("./app/execute");
|
|
6
|
+
const command_result_1 = require("./domain/command-result");
|
|
7
|
+
const init_command_1 = require("./commands/init-command");
|
|
8
|
+
const install_skill_command_1 = require("./commands/install-skill-command");
|
|
9
|
+
const build_project_command_1 = require("./commands/build-project-command");
|
|
10
|
+
const deploy_project_command_1 = require("./commands/deploy-project-command");
|
|
11
|
+
const node_fs_adapter_1 = require("./adapters/node-fs-adapter");
|
|
12
|
+
const filesystem_capability_service_1 = require("./services/filesystem-capability-service");
|
|
13
|
+
const fsAdapter = (0, node_fs_adapter_1.createNodeFsAdapter)();
|
|
14
|
+
const filesystemCapability = (0, filesystem_capability_service_1.createFilesystemCapabilityService)(fsAdapter, {
|
|
15
|
+
templateRootDir: fsAdapter.resolve(__dirname, "..", "templates"),
|
|
16
|
+
});
|
|
17
|
+
const initCommandHandler = (0, init_command_1.createInitCommandHandler)({
|
|
18
|
+
prompts: {
|
|
19
|
+
askProjectPath: cli_interaction_1.askProjectPath,
|
|
20
|
+
askOverwrite: cli_interaction_1.askOverwrite,
|
|
21
|
+
askRushQuestions: cli_interaction_1.askRushQuestions,
|
|
22
|
+
askInstallDeployScript: cli_interaction_1.askInstallDeployScript,
|
|
23
|
+
},
|
|
24
|
+
fs: fsAdapter,
|
|
25
|
+
files: filesystemCapability,
|
|
26
|
+
});
|
|
27
|
+
const installSkillCommandHandler = (0, install_skill_command_1.createInstallSkillCommandHandler)({
|
|
28
|
+
fs: fsAdapter,
|
|
29
|
+
files: filesystemCapability,
|
|
30
|
+
config: {
|
|
31
|
+
getSkillTemplateRoot: () => fsAdapter.join(__dirname, "..", "templates", "skills-template"),
|
|
32
|
+
defaultSkillName: "test",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const buildProjectCommandHandler = (0, build_project_command_1.createBuildProjectCommandHandler)({
|
|
36
|
+
fs: fsAdapter,
|
|
37
|
+
});
|
|
38
|
+
const deployProjectCommandHandler = (0, deploy_project_command_1.createDeployProjectCommandHandler)({
|
|
39
|
+
fs: fsAdapter,
|
|
40
|
+
});
|
|
45
41
|
async function main() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return installSkillCmd();
|
|
58
|
-
(0, prompts_1.printHelp)();
|
|
59
|
-
}
|
|
60
|
-
main();
|
|
61
|
-
async function syncDocsCmd() {
|
|
62
|
-
const execDir = process.cwd();
|
|
63
|
-
const sourceTrae = path_1.default.join(__dirname, "..", "templates", "rush-template", ".trae");
|
|
64
|
-
const sourceDocs = path_1.default.join(__dirname, "..", "templates", "rush-template", "docs");
|
|
65
|
-
const destTrae = path_1.default.join(execDir, ".trae");
|
|
66
|
-
const destDocs = path_1.default.join(execDir, "docs");
|
|
67
|
-
(0, copy_1.syncDirWithRename)(sourceTrae, destTrae);
|
|
68
|
-
(0, copy_1.syncDirWithRename)(sourceDocs, destDocs);
|
|
69
|
-
console.log("已同步 .trae 和 docs 到执行目录的同级目录");
|
|
42
|
+
const result = await (0, execute_1.executeCommand)(process.argv.slice(2), {
|
|
43
|
+
printHelp: cli_interaction_1.printHelp,
|
|
44
|
+
printVersion: cli_interaction_1.printVersion,
|
|
45
|
+
handlers: {
|
|
46
|
+
init: initCommandHandler,
|
|
47
|
+
"install-skill": installSkillCommandHandler,
|
|
48
|
+
"build-project": buildProjectCommandHandler,
|
|
49
|
+
"deploy-project": deployProjectCommandHandler,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
applyCommandResult(result);
|
|
70
53
|
}
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
54
|
+
main().catch((error) => {
|
|
55
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
+
applyCommandResult((0, command_result_1.commandError)(message, command_result_1.COMMAND_ERROR_CODES.unexpectedError, 1));
|
|
57
|
+
});
|
|
58
|
+
function applyCommandResult(result) {
|
|
59
|
+
if (result.message) {
|
|
60
|
+
if (result.ok) {
|
|
61
|
+
console.log(result.message);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.error(result.message);
|
|
65
|
+
}
|
|
78
66
|
}
|
|
79
|
-
|
|
80
|
-
(0, copy_1.copySkillDir)(sourceDir, targetDir);
|
|
81
|
-
console.log(`已安装 ${skillName} 技能到 ${targetDir}`);
|
|
67
|
+
process.exitCode = result.exitCode;
|
|
82
68
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBuildProjectCommandHandler = createBuildProjectCommandHandler;
|
|
4
|
+
const build_project_service_1 = require("../services/build-project-service");
|
|
5
|
+
function createBuildProjectCommandHandler(deps) {
|
|
6
|
+
return async (_input) => {
|
|
7
|
+
return (0, build_project_service_1.runBuildProjectFlow)(deps);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDeployProjectCommandHandler = createDeployProjectCommandHandler;
|
|
4
|
+
const deploy_project_service_1 = require("../services/deploy-project-service");
|
|
5
|
+
function createDeployProjectCommandHandler(deps) {
|
|
6
|
+
return async (_input) => {
|
|
7
|
+
return (0, deploy_project_service_1.runDeployProjectFlow)(deps);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInitCommandHandler = createInitCommandHandler;
|
|
4
|
+
const init_service_1 = require("../services/init-service");
|
|
5
|
+
function createInitCommandHandler(deps) {
|
|
6
|
+
return async (_input) => {
|
|
7
|
+
return (0, init_service_1.runInitFlow)(deps);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInstallSkillCommandHandler = createInstallSkillCommandHandler;
|
|
4
|
+
const install_skill_service_1 = require("../services/install-skill-service");
|
|
5
|
+
function createInstallSkillCommandHandler(deps) {
|
|
6
|
+
return async (input) => {
|
|
7
|
+
return (0, install_skill_service_1.runInstallSkillFlow)(input, deps);
|
|
8
|
+
};
|
|
9
|
+
}
|