@lark-apaas/fullstack-cli 1.1.22-alpha.5 → 1.1.22-alpha.7

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 (3) hide show
  1. package/README.md +41 -3
  2. package/dist/index.js +110 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lark-apaas/fullstack-cli
2
2
 
3
- > Fullstack 开发工具集 - 文件派生、数据库 Schema 生成、OpenAPI 生成、能力管理
3
+ > Fullstack 开发工具集 - 文件派生、数据库 Schema 生成、OpenAPI 生成、能力管理、构建工具
4
4
 
5
5
  ## 功能
6
6
 
@@ -9,6 +9,7 @@
9
9
  3. **OpenAPI 生成** - 自动生成 API 文档和客户端 SDK
10
10
  4. **Action 插件管理** - 安装、更新、删除 action 插件
11
11
  5. **能力配置管理** - 查看、充血、迁移能力配置
12
+ 6. **构建工具** - 获取 STI 制品上传凭证等构建相关操作
12
13
 
13
14
  ## 安装
14
15
 
@@ -201,7 +202,40 @@ fullstack-cli capability migration --skip-code
201
202
  }
202
203
  ```
203
204
 
204
- ### 7. CLI 命令
205
+ ### 7. 构建工具
206
+
207
+ 获取构建流程所需的 STI 制品上传凭证:
208
+
209
+ ```bash
210
+ # Pipeline 发布场景 - 需要 commit-id
211
+ fullstack-cli build get-token --app-id app_xxx --scene pipeline --commit-id abc123
212
+
213
+ # 静态资源部署场景
214
+ fullstack-cli build get-token --app-id app_xxx --scene static
215
+ ```
216
+
217
+ **参数说明:**
218
+
219
+ | 参数 | 必填 | 说明 |
220
+ |------|------|------|
221
+ | `--app-id <id>` | 是 | 应用 ID |
222
+ | `--scene <scene>` | 是 | 构建场景(`pipeline`、`static`) |
223
+ | `--commit-id <id>` | scene=pipeline 时必填 | Git Commit ID |
224
+
225
+ **输出:** stdout 输出 API 返回的完整 JSON,日志/错误输出到 stderr,便于脚本解析:
226
+
227
+ ```bash
228
+ token_response=$(fullstack-cli build get-token --app-id "$APP_ID" --scene pipeline --commit-id "$COMMIT_ID")
229
+ credential=$(echo "$token_response" | jq -r '.data.accessKeyID')
230
+ ```
231
+
232
+ **环境变量:**
233
+ - `FORCE_AUTHN_INNERAPI_DOMAIN` — API 域名
234
+ - `FORCE_AUTHN_ACCESS_KEY` — Access Key
235
+ - `FORCE_AUTHN_ACCESS_SECRET` — Secret Key
236
+ - `FORCE_FRAMEWORK_CLI_CANARY_ENV` — Canary 环境(可选)
237
+
238
+ ### 8. CLI 命令
205
239
 
206
240
  ```bash
207
241
  # 查看帮助
@@ -223,11 +257,15 @@ fullstack-cli capability --help
223
257
  fullstack-cli capability list
224
258
  fullstack-cli capability migration --dry-run
225
259
 
260
+ # 构建工具
261
+ fullstack-cli build --help
262
+ fullstack-cli build get-token --app-id <id> --scene <scene> [--commit-id <id>]
263
+
226
264
  # 查看版本
227
265
  fullstack-cli --version
228
266
  ```
229
267
 
230
- ### 8. 全局选项
268
+ ### 9. 全局选项
231
269
 
232
270
  #### Canary 环境
233
271
 
package/dist/index.js CHANGED
@@ -2475,7 +2475,25 @@ function getChangedFiles(cwd = process.cwd()) {
2475
2475
  }
2476
2476
  }
2477
2477
  function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2478
- const result = spawnSync2("git", ["add", "--ignore-missing", "--", ...filesToStage], {
2478
+ const filteredFiles = [];
2479
+ for (const filePath of filesToStage) {
2480
+ if (fs7.existsSync(path5.join(cwd, filePath))) {
2481
+ filteredFiles.push(filePath);
2482
+ continue;
2483
+ }
2484
+ const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
2485
+ cwd,
2486
+ stdio: "pipe",
2487
+ encoding: "utf-8"
2488
+ });
2489
+ if (tracked.status === 0) {
2490
+ filteredFiles.push(filePath);
2491
+ }
2492
+ }
2493
+ if (filteredFiles.length === 0) {
2494
+ return;
2495
+ }
2496
+ const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
2479
2497
  cwd,
2480
2498
  stdio: "pipe",
2481
2499
  encoding: "utf-8"
@@ -3768,6 +3786,9 @@ var capabilityCommandGroup = {
3768
3786
  commands: [listCommand2]
3769
3787
  };
3770
3788
 
3789
+ // src/commands/component/add.handler.ts
3790
+ import { execFile } from "child_process";
3791
+
3771
3792
  // src/commands/component/registry-preparer.ts
3772
3793
  import fs13 from "fs";
3773
3794
  import path11 from "path";
@@ -3997,6 +4018,16 @@ async function executeShadcnAdd(registryItemPath) {
3997
4018
  }
3998
4019
 
3999
4020
  // src/commands/component/add.handler.ts
4021
+ function runActionPluginInit() {
4022
+ return new Promise((resolve) => {
4023
+ execFile("fullstack-cli", ["action-plugin", "init"], { cwd: process.cwd(), stdio: "ignore" }, (error) => {
4024
+ if (error) {
4025
+ debug("action-plugin init \u5931\u8D25: %s", error.message);
4026
+ }
4027
+ resolve();
4028
+ });
4029
+ });
4030
+ }
4000
4031
  function printResult(result) {
4001
4032
  console.log(JSON.stringify(result, null, 2));
4002
4033
  }
@@ -4033,6 +4064,7 @@ async function add(key) {
4033
4064
  errors: [{ message: errorMessage }]
4034
4065
  });
4035
4066
  } finally {
4067
+ await runActionPluginInit();
4036
4068
  cleanupTempDir();
4037
4069
  }
4038
4070
  }
@@ -6807,6 +6839,81 @@ var readLogsCommand = {
6807
6839
  }
6808
6840
  };
6809
6841
 
6842
+ // src/commands/build/types.ts
6843
+ var SCENE_CONFIGS = {
6844
+ pipeline: {
6845
+ name: "pipeline",
6846
+ requiredOptions: ["commitId"],
6847
+ buildRequestBody: (opts) => ({ commitID: opts.commitId })
6848
+ },
6849
+ static: {
6850
+ name: "static",
6851
+ requiredOptions: [],
6852
+ buildRequestBody: () => ({ commitID: "" })
6853
+ }
6854
+ };
6855
+
6856
+ // src/commands/build/api-client.ts
6857
+ async function genArtifactUploadCredential(appId, body) {
6858
+ const client = getHttpClient();
6859
+ const url = `/v1/app/${appId}/pipeline/gen_artifact_upload_credential`;
6860
+ const response = await client.post(url, body);
6861
+ if (!response.ok || response.status !== 200) {
6862
+ throw new Error(
6863
+ `API request failed: ${response.status} ${response.statusText}`
6864
+ );
6865
+ }
6866
+ return response.json();
6867
+ }
6868
+
6869
+ // src/commands/build/get-token.handler.ts
6870
+ async function getToken(options) {
6871
+ try {
6872
+ const sceneConfig = SCENE_CONFIGS[options.scene];
6873
+ if (!sceneConfig) {
6874
+ const available = Object.keys(SCENE_CONFIGS).join(", ");
6875
+ console.error(
6876
+ `[build] Error: invalid scene "${options.scene}". Available scenes: ${available}`
6877
+ );
6878
+ process.exit(1);
6879
+ }
6880
+ for (const key of sceneConfig.requiredOptions) {
6881
+ if (!options[key]) {
6882
+ console.error(
6883
+ `[build] Error: --${camelToKebab(key)} is required for scene "${options.scene}"`
6884
+ );
6885
+ process.exit(1);
6886
+ }
6887
+ }
6888
+ const body = sceneConfig.buildRequestBody(options);
6889
+ const response = await genArtifactUploadCredential(options.appId, body);
6890
+ console.log(JSON.stringify(response));
6891
+ } catch (error) {
6892
+ const message = error instanceof Error ? error.message : String(error);
6893
+ console.error(`[build] Error: ${message}`);
6894
+ process.exit(1);
6895
+ }
6896
+ }
6897
+ function camelToKebab(str) {
6898
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
6899
+ }
6900
+
6901
+ // src/commands/build/index.ts
6902
+ var getTokenCommand = {
6903
+ name: "get-token",
6904
+ description: "Get artifact upload credential (STI token)",
6905
+ register(program) {
6906
+ program.command(this.name).description(this.description).requiredOption("--app-id <id>", "Application ID").requiredOption("--scene <scene>", "Build scene (pipeline, static)").option("--commit-id <id>", "Git commit ID (required for pipeline scene)").action(async (options) => {
6907
+ await getToken(options);
6908
+ });
6909
+ }
6910
+ };
6911
+ var buildCommandGroup = {
6912
+ name: "build",
6913
+ description: "Build related commands",
6914
+ commands: [getTokenCommand]
6915
+ };
6916
+
6810
6917
  // src/commands/index.ts
6811
6918
  var commands = [
6812
6919
  genDbSchemaCommand,
@@ -6816,7 +6923,8 @@ var commands = [
6816
6923
  capabilityCommandGroup,
6817
6924
  componentCommandGroup,
6818
6925
  migrationCommand,
6819
- readLogsCommand
6926
+ readLogsCommand,
6927
+ buildCommandGroup
6820
6928
  ];
6821
6929
 
6822
6930
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.22-alpha.5",
3
+ "version": "1.1.22-alpha.7",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",