listpage_cli 0.0.293 → 0.0.294

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.
Files changed (33) hide show
  1. package/bin/adapters/node-fs-adapter.js +109 -0
  2. package/bin/app/dispatch.js +15 -0
  3. package/bin/app/execute.js +33 -0
  4. package/bin/app/parse-args.js +34 -0
  5. package/bin/cli.js +55 -74
  6. package/bin/commands/build-project-command.js +9 -0
  7. package/bin/commands/init-command.js +9 -0
  8. package/bin/commands/install-skill-command.js +9 -0
  9. package/bin/copy.js +14 -126
  10. package/bin/domain/command-result.js +34 -0
  11. package/bin/domain/interaction-result.js +14 -0
  12. package/bin/ports/build-project-command.js +2 -0
  13. package/bin/ports/filesystem-capability.js +2 -0
  14. package/bin/ports/fs-port.js +22 -0
  15. package/bin/ports/init-command.js +2 -0
  16. package/bin/ports/install-skill-command.js +2 -0
  17. package/bin/prompts.js +105 -16
  18. package/bin/services/artifact-validator.js +2 -0
  19. package/bin/services/build-project-service.js +190 -0
  20. package/bin/services/command-runner.js +44 -0
  21. package/bin/services/config-loader.js +113 -0
  22. package/bin/services/filesystem-capability-service.js +136 -0
  23. package/bin/services/init-service.js +64 -0
  24. package/bin/services/install-skill-service.js +34 -0
  25. package/package.json +6 -4
  26. package/templates/backend-template/package.json.tmpl +1 -1
  27. package/templates/frontend-template/package.json.tmpl +2 -2
  28. package/templates/package-app-template/package.json +1 -1
  29. package/templates/skills-template/listpage/examples.md +565 -0
  30. package/skills/listpage/examples.md +0 -243
  31. package/templates/rush-template/docs/ListPage-AI/347/224/237/346/210/220/350/247/204/350/214/203.md +0 -305
  32. /package/{skills → templates/skills-template}/listpage/SKILL.md +0 -0
  33. /package/{skills → templates/skills-template}/listpage/api.md +0 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runInitFlow = runInitFlow;
4
+ const command_result_1 = require("../domain/command-result");
5
+ async function runInitFlow(deps) {
6
+ const projectNameResult = await deps.prompts.askProjectPath();
7
+ if (projectNameResult.status !== "value") {
8
+ return mapInteractionToCommandResult(projectNameResult, "项目路径输入");
9
+ }
10
+ const projectName = projectNameResult.value;
11
+ const targetDir = deps.fs.resolve(deps.fs.cwd(), projectName);
12
+ if (!deps.files.isDirEmpty(targetDir)) {
13
+ const overwriteResult = await deps.prompts.askOverwrite();
14
+ if (overwriteResult.status !== "value") {
15
+ return mapInteractionToCommandResult(overwriteResult, "覆盖确认");
16
+ }
17
+ if (!overwriteResult.value) {
18
+ return (0, command_result_1.commandError)("已取消", command_result_1.COMMAND_ERROR_CODES.userCancelled, 1);
19
+ }
20
+ }
21
+ deps.fs.ensureDir(targetDir);
22
+ return runInitRushFlow(deps, targetDir, projectName);
23
+ }
24
+ async function runInitRushFlow(deps, targetDir, projectName) {
25
+ const rushQuestionsResult = await deps.prompts.askRushQuestions();
26
+ if (rushQuestionsResult.status !== "value") {
27
+ return mapInteractionToCommandResult(rushQuestionsResult, "项目信息输入");
28
+ }
29
+ const { frontendName, backendName } = rushQuestionsResult.value;
30
+ const appName = projectName === "." ? deps.fs.basename(targetDir) : projectName;
31
+ const vars = {
32
+ APP_NAME: appName,
33
+ BACKEND_NAME: backendName,
34
+ FRONTEND_NAME: frontendName,
35
+ };
36
+ deps.files.copyRushTemplate(targetDir, vars);
37
+ const installDeployScriptResult = await deps.prompts.askInstallDeployScript();
38
+ if (installDeployScriptResult.status !== "value") {
39
+ return mapInteractionToCommandResult(installDeployScriptResult, "部署脚本确认");
40
+ }
41
+ if (installDeployScriptResult.value) {
42
+ deps.files.copyDeployScriptTemplate(targetDir, vars);
43
+ }
44
+ deps.files.updateRushJsonProjects(deps.fs.join(targetDir, "rush.json"), frontendName, backendName);
45
+ if (frontendName) {
46
+ deps.files.copyFrontendTemplate(targetDir, vars);
47
+ }
48
+ if (backendName) {
49
+ deps.files.copyBackendTemplate(targetDir, vars);
50
+ }
51
+ if (projectName !== ".") {
52
+ return (0, command_result_1.commandOk)(`cd ${projectName}\n请手动执行 rush update 安装依赖`);
53
+ }
54
+ return (0, command_result_1.commandOk)("请手动执行 rush update 安装依赖");
55
+ }
56
+ function mapInteractionToCommandResult(result, interactionName) {
57
+ if (result.status === "cancelled") {
58
+ return (0, command_result_1.commandError)(`${interactionName}已取消`, command_result_1.COMMAND_ERROR_CODES.userCancelled, 1);
59
+ }
60
+ if (result.status === "invalid") {
61
+ return (0, command_result_1.commandError)(`${interactionName}无效: ${result.reason}`, command_result_1.COMMAND_ERROR_CODES.invalidInteraction, 1);
62
+ }
63
+ return (0, command_result_1.commandError)(`${interactionName}返回未知状态`, command_result_1.COMMAND_ERROR_CODES.invalidInteraction, 1);
64
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runInstallSkillFlow = runInstallSkillFlow;
4
+ const command_result_1 = require("../domain/command-result");
5
+ function runInstallSkillFlow(input, deps) {
6
+ const skillName = input.positionals[0] || deps.config.defaultSkillName;
7
+ const sourceDir = deps.fs.join(deps.config.getSkillTemplateRoot(), skillName);
8
+ if (!deps.fs.exists(sourceDir)) {
9
+ return (0, command_result_1.commandError)(`技能 ${skillName} 不存在: ${sourceDir}`, command_result_1.COMMAND_ERROR_CODES.skillNotFound, 1);
10
+ }
11
+ const targetDirResult = resolveTargetDir(input, skillName, deps.fs);
12
+ if (targetDirResult.kind === "error") {
13
+ return targetDirResult.result;
14
+ }
15
+ try {
16
+ deps.files.copySkillDir(sourceDir, targetDirResult.targetDir);
17
+ return (0, command_result_1.commandOk)(`已安装 ${skillName} 技能到 ${targetDirResult.targetDir}`);
18
+ }
19
+ catch (error) {
20
+ const message = error instanceof Error ? error.message : String(error);
21
+ return (0, command_result_1.commandError)(`安装技能失败(${skillName} -> ${targetDirResult.targetDir}): ${message}`, command_result_1.COMMAND_ERROR_CODES.fsOperationFailed, 1);
22
+ }
23
+ }
24
+ function resolveTargetDir(input, skillName, fs) {
25
+ const baseDir = fs.cwd();
26
+ if (!baseDir || !baseDir.trim()) {
27
+ return {
28
+ kind: "error",
29
+ result: (0, command_result_1.commandError)("无法解析命令执行目录,无法安装技能", command_result_1.COMMAND_ERROR_CODES.invalidPath, 1),
30
+ };
31
+ }
32
+ const targetDir = fs.resolve(baseDir, ".cursor", "skills", skillName);
33
+ return { kind: "ok", targetDir };
34
+ }
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "listpage_cli",
3
- "version": "0.0.293",
3
+ "version": "0.0.294",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "listpage_cli": "bin/cli.js"
7
7
  },
8
8
  "scripts": {
9
9
  "build": "tsc -p tsconfig.json",
10
+ "build:tests": "tsc -p tsconfig.tests.json",
11
+ "test:unit": "npm run build:tests && node --test .tmp-tests/tests/unit/**/*.test.js",
12
+ "test:integration": "npm run build && npm run build:tests && node --test .tmp-tests/tests/integration/**/*.test.js",
13
+ "test:story-1-1": "npm run test:unit && npm run test:integration",
10
14
  "prepublishOnly": "npm run build",
11
15
  "start": "node bin/cli.js init",
12
- "start:sync-docs": "node bin/cli.js sync-docs",
13
16
  "test": "node bin/cli.js --help"
14
17
  },
15
18
  "files": [
16
19
  "bin",
17
- "templates",
18
- "skills"
20
+ "templates"
19
21
  ],
20
22
  "devDependencies": {
21
23
  "typescript": "^5.6.2",
@@ -25,7 +25,7 @@
25
25
  "class-transformer": "^0.5.1",
26
26
  "class-validator": "~0.14.2",
27
27
  "rxjs": "^7.8.1",
28
- "listpage-next-nest": "~0.0.293"
28
+ "listpage-next-nest": "~0.0.294"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@nestjs/schematics": "^11.0.0",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "react": "^19.2.0",
14
14
  "react-dom": "^19.2.0",
15
- "listpage-next": "~0.0.293",
15
+ "listpage-next": "~0.0.294",
16
16
  "react-router-dom": ">=6.0.0",
17
17
  "@ant-design/v5-patch-for-react-19": "~1.0.3",
18
18
  "ahooks": "^3.9.5",
@@ -23,7 +23,7 @@
23
23
  "styled-components": "^6.1.19",
24
24
  "mobx": "~6.15.0",
25
25
  "@ant-design/icons": "~6.0.2",
26
- "listpage-components": "~0.0.293",
26
+ "listpage-components": "~0.0.294",
27
27
  "lucide-react": "~0.575.0"
28
28
  "mobx-react-lite": "~4.1.1"
29
29
  },
@@ -9,7 +9,7 @@
9
9
  "publish": "ts-node src/publish.ts"
10
10
  },
11
11
  "dependencies": {
12
- "listpage-next-deploy": "0.0.293"
12
+ "listpage-next-deploy": "0.0.294"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/node": "^20.0.0",