listpage_cli 0.0.310 → 0.0.311

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.
@@ -160,17 +160,15 @@ function printHelp() {
160
160
  ` 用法: ${helpColor("listpage_cli install-skill [skillName] [--project]", "dim")}`,
161
161
  " 说明: 安装技能到 Cursor;默认 skillName 为 test,安装到当前命令执行目录的 .cursor/skills/",
162
162
  "",
163
- ` ${helpColor("build-project", "green")}`,
164
- ` 用法: ${helpColor("listpage_cli build-project", "dim")}`,
165
- " 说明: 非交互校验当前目录是否为有效项目根(需存在 listpage.config.json",
163
+ ` ${helpColor("project", "green")}`,
164
+ ` 用法: ${helpColor("listpage_cli project build", "dim")}`,
165
+ " 说明: 非交互校验当前目录是否为有效项目根(需存在 listpage.config.json),构建并写入 .listpage/output",
166
166
  "",
167
- ` ${helpColor("release-project", "green")}`,
168
- ` 用法: ${helpColor("listpage_cli release-project [tag] [--profile dev] [--platform linux/amd64] [--env KEY=VALUE]", "dim")}`,
167
+ ` 用法: ${helpColor("listpage_cli project release [tag] [--profile dev] [--platform linux/amd64] [--env KEY=VALUE]", "dim")}`,
169
168
  " 说明: 先校验 .listpage/output 产物,再按 login/build/tag/push 执行 Docker 发布",
170
169
  ` 备注: ${helpColor("参数优先级为 CLI > profile > base", "yellow")}`,
171
170
  "",
172
- ` ${helpColor("deploy-project", "green")}`,
173
- ` 用法: ${helpColor("listpage_cli deploy-project [tag] [--profile dev] [--platform linux/amd64] [--env KEY=VALUE] [--skip-image]", "dim")}`,
171
+ ` 用法: ${helpColor("listpage_cli project deploy [tag] [--profile dev] [--platform linux/amd64] [--env KEY=VALUE] [--skip-image]", "dim")}`,
174
172
  " 说明: 使用 docker.remote + docker.container 执行部署,支持 ports[] 与 envFile/env 合并",
175
173
  ` 备注: ${helpColor("默认会清理并拉取镜像;传入 --skip-image 时只执行容器相关步骤(假定镜像已是最新且已存在)", "yellow")}`,
176
174
  ` ${helpColor("参数优先级为 CLI > profile > base", "yellow")}`,
@@ -1,16 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cliOptionArgStartIndex = cliOptionArgStartIndex;
4
+ exports.parseProjectTailPositionals = parseProjectTailPositionals;
3
5
  exports.parseArgs = parseArgs;
4
6
  exports.parseCommandOptions = parseCommandOptions;
5
7
  exports.parseCommandPositionals = parseCommandPositionals;
6
8
  const KNOWN_COMMANDS = new Set([
7
9
  "init",
8
10
  "install-skill",
9
- "build-project",
10
- "release-project",
11
- "deploy-project",
11
+ "project",
12
12
  "lark",
13
13
  ]);
14
+ function cliOptionArgStartIndex(command) {
15
+ return 1;
16
+ }
17
+ /**
18
+ * `project <sub> [tag] ...` 中,子命令之后的位置参数(如 release/deploy 的镜像 tag)。
19
+ */
20
+ function parseProjectTailPositionals(rawArgs) {
21
+ return parseCommandPositionals(rawArgs, "project").slice(1);
22
+ }
14
23
  function parseArgs(argv) {
15
24
  const rawArgs = [...argv];
16
25
  const commandToken = rawArgs[0];
@@ -41,8 +50,8 @@ function parseArgs(argv) {
41
50
  positionals,
42
51
  };
43
52
  }
44
- function parseCommandOptions(rawArgs) {
45
- const args = rawArgs.slice(1);
53
+ function parseCommandOptions(rawArgs, command) {
54
+ const args = rawArgs.slice(cliOptionArgStartIndex(command));
46
55
  const profile = readSingleOption(args, "profile");
47
56
  const platform = readSingleOption(args, "platform");
48
57
  const envEntries = readMultiOption(args, "env");
@@ -55,8 +64,8 @@ function parseCommandOptions(rawArgs) {
55
64
  skipImage: skipImage || undefined,
56
65
  };
57
66
  }
58
- function parseCommandPositionals(rawArgs) {
59
- const args = rawArgs.slice(1);
67
+ function parseCommandPositionals(rawArgs, command) {
68
+ const args = rawArgs.slice(cliOptionArgStartIndex(command));
60
69
  const positionals = [];
61
70
  const optionsWithValue = new Set(["--profile", "--platform", "--env"]);
62
71
  for (let index = 0; index < args.length; index += 1) {
package/bin/cli.js CHANGED
@@ -6,9 +6,7 @@ const execute_1 = require("./app/execute");
6
6
  const command_result_1 = require("./domain/command-result");
7
7
  const init_command_1 = require("./commands/init-command");
8
8
  const install_skill_command_1 = require("./commands/install-skill-command");
9
- const build_project_command_1 = require("./commands/build-project-command");
10
- const release_project_command_1 = require("./commands/release-project-command");
11
- const deploy_project_command_1 = require("./commands/deploy-project-command");
9
+ const project_command_1 = require("./commands/project-command");
12
10
  const lark_command_1 = require("./commands/lark-command");
13
11
  const node_fs_adapter_1 = require("./adapters/node-fs-adapter");
14
12
  const filesystem_capability_service_1 = require("./services/filesystem-capability-service");
@@ -33,14 +31,10 @@ const installSkillCommandHandler = (0, install_skill_command_1.createInstallSkil
33
31
  defaultSkillName: "test",
34
32
  },
35
33
  });
36
- const buildProjectCommandHandler = (0, build_project_command_1.createBuildProjectCommandHandler)({
37
- fs: fsAdapter,
38
- });
39
- const releaseProjectCommandHandler = (0, release_project_command_1.createReleaseProjectCommandHandler)({
40
- fs: fsAdapter,
41
- });
42
- const deployProjectCommandHandler = (0, deploy_project_command_1.createDeployProjectCommandHandler)({
43
- fs: fsAdapter,
34
+ const projectCommandHandler = (0, project_command_1.createProjectCommandHandler)({
35
+ build: { fs: fsAdapter },
36
+ release: { fs: fsAdapter },
37
+ deploy: { fs: fsAdapter },
44
38
  });
45
39
  const larkCommandHandler = (0, lark_command_1.createLarkCommandHandler)({
46
40
  fs: fsAdapter,
@@ -52,9 +46,7 @@ async function main() {
52
46
  handlers: {
53
47
  init: initCommandHandler,
54
48
  "install-skill": installSkillCommandHandler,
55
- "build-project": buildProjectCommandHandler,
56
- "release-project": releaseProjectCommandHandler,
57
- "deploy-project": deployProjectCommandHandler,
49
+ project: projectCommandHandler,
58
50
  lark: larkCommandHandler,
59
51
  },
60
52
  });
@@ -5,11 +5,11 @@ const parse_args_1 = require("../app/parse-args");
5
5
  const deploy_project_service_1 = require("../services/deploy-project-service");
6
6
  function createDeployProjectCommandHandler(deps) {
7
7
  return async (input) => {
8
- const firstPositional = (0, parse_args_1.parseCommandPositionals)(input.rawArgs)[0];
8
+ const firstPositional = (0, parse_args_1.parseProjectTailPositionals)(input.rawArgs)[0];
9
9
  const tag = typeof firstPositional === "string" && firstPositional.trim() !== ""
10
10
  ? firstPositional.trim()
11
11
  : undefined;
12
- const options = (0, parse_args_1.parseCommandOptions)(input.rawArgs);
12
+ const options = (0, parse_args_1.parseCommandOptions)(input.rawArgs, "project");
13
13
  const cliOverrides = {
14
14
  tag,
15
15
  profile: options.profile,
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProjectCommandHandler = createProjectCommandHandler;
4
+ const command_result_1 = require("../domain/command-result");
5
+ const build_project_command_1 = require("./build-project-command");
6
+ const release_project_command_1 = require("./release-project-command");
7
+ const deploy_project_command_1 = require("./deploy-project-command");
8
+ function createProjectCommandHandler(deps) {
9
+ const build = (0, build_project_command_1.createBuildProjectCommandHandler)(deps.build);
10
+ const release = (0, release_project_command_1.createReleaseProjectCommandHandler)(deps.release);
11
+ const deploy = (0, deploy_project_command_1.createDeployProjectCommandHandler)(deps.deploy);
12
+ return async (input) => {
13
+ const subCommand = input.positionals[0];
14
+ switch (subCommand) {
15
+ case "build":
16
+ return build(input);
17
+ case "release":
18
+ return release(input);
19
+ case "deploy":
20
+ return deploy(input);
21
+ default:
22
+ return (0, command_result_1.commandError)("错误: 未知的子命令。目前仅支持: build, release, deploy", "invalid_subcommand", 1);
23
+ }
24
+ };
25
+ }
@@ -5,11 +5,11 @@ const parse_args_1 = require("../app/parse-args");
5
5
  const release_project_service_1 = require("../services/release-project-service");
6
6
  function createReleaseProjectCommandHandler(deps) {
7
7
  return async (input) => {
8
- const firstPositional = (0, parse_args_1.parseCommandPositionals)(input.rawArgs)[0];
8
+ const firstPositional = (0, parse_args_1.parseProjectTailPositionals)(input.rawArgs)[0];
9
9
  const tag = typeof firstPositional === "string" && firstPositional.trim() !== ""
10
10
  ? firstPositional.trim()
11
11
  : undefined;
12
- const options = (0, parse_args_1.parseCommandOptions)(input.rawArgs);
12
+ const options = (0, parse_args_1.parseCommandOptions)(input.rawArgs, "project");
13
13
  const cliOverrides = {
14
14
  tag,
15
15
  profile: options.profile,
@@ -76,13 +76,36 @@ function getBuildTargets(projectRoot, config) {
76
76
  projectDir: resolveBuildTarget(projectRoot, item.projectDir),
77
77
  }));
78
78
  }
79
+ function resolveArtifactsBuildSlice(config) {
80
+ const artifacts = config.artifacts;
81
+ if (artifacts && typeof artifacts === "object" && !Array.isArray(artifacts)) {
82
+ const a = artifacts;
83
+ return {
84
+ frontend: a.frontend ?? config.frontend,
85
+ backend: a.backend ?? config.backend,
86
+ copyFiles: a.copyFiles ?? config.copyFiles,
87
+ };
88
+ }
89
+ return {
90
+ frontend: config.frontend,
91
+ backend: config.backend,
92
+ copyFiles: config.copyFiles,
93
+ };
94
+ }
79
95
  function toBuildProjectConfig(config) {
80
- const frontendRaw = config.frontend;
81
- const backendRaw = config.backend;
96
+ const slice = resolveArtifactsBuildSlice(config);
97
+ const frontendRaw = slice.frontend;
98
+ if (!Array.isArray(frontendRaw) || frontendRaw.length === 0) {
99
+ throw new Error("配置字段无效: frontend (至少包含一个构建项)");
100
+ }
101
+ const backendRaw = slice.backend;
102
+ if (!backendRaw || typeof backendRaw !== "object" || Array.isArray(backendRaw)) {
103
+ throw new Error("配置字段无效: backend");
104
+ }
82
105
  return {
83
106
  frontend: frontendRaw.map((item) => toBuildTarget(item)),
84
107
  backend: toBuildTarget(backendRaw),
85
- copyFiles: toCopySpecs(config.copyFiles),
108
+ copyFiles: toCopySpecs(slice.copyFiles),
86
109
  };
87
110
  }
88
111
  function toBuildTarget(item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage_cli",
3
- "version": "0.0.310",
3
+ "version": "0.0.311",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "listpage_cli": "bin/cli.js"
@@ -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.310"
28
+ "listpage-next-nest": "~0.0.311"
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.310",
15
+ "listpage-next": "~0.0.311",
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.310",
26
+ "listpage-components": "~0.0.311",
27
27
  "lucide-react": "~0.575.0"
28
28
  "mobx-react-lite": "~4.1.1"
29
29
  },