@lark-apaas/fullstack-cli 1.1.23 → 1.1.24

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 +77 -1
  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
@@ -6502,6 +6502,81 @@ var readLogsCommand = {
6502
6502
  }
6503
6503
  };
6504
6504
 
6505
+ // src/commands/build/types.ts
6506
+ var SCENE_CONFIGS = {
6507
+ pipeline: {
6508
+ name: "pipeline",
6509
+ requiredOptions: ["commitId"],
6510
+ buildRequestBody: (opts) => ({ commitID: opts.commitId })
6511
+ },
6512
+ static: {
6513
+ name: "static",
6514
+ requiredOptions: [],
6515
+ buildRequestBody: () => ({ commitID: "" })
6516
+ }
6517
+ };
6518
+
6519
+ // src/commands/build/api-client.ts
6520
+ async function genArtifactUploadCredential(appId, body) {
6521
+ const client = getHttpClient();
6522
+ const url = `/v1/app/${appId}/pipeline/gen_artifact_upload_credential`;
6523
+ const response = await client.post(url, body);
6524
+ if (!response.ok || response.status !== 200) {
6525
+ throw new Error(
6526
+ `API request failed: ${response.status} ${response.statusText}`
6527
+ );
6528
+ }
6529
+ return response.json();
6530
+ }
6531
+
6532
+ // src/commands/build/get-token.handler.ts
6533
+ async function getToken(options) {
6534
+ try {
6535
+ const sceneConfig = SCENE_CONFIGS[options.scene];
6536
+ if (!sceneConfig) {
6537
+ const available = Object.keys(SCENE_CONFIGS).join(", ");
6538
+ console.error(
6539
+ `[build] Error: invalid scene "${options.scene}". Available scenes: ${available}`
6540
+ );
6541
+ process.exit(1);
6542
+ }
6543
+ for (const key of sceneConfig.requiredOptions) {
6544
+ if (!options[key]) {
6545
+ console.error(
6546
+ `[build] Error: --${camelToKebab(key)} is required for scene "${options.scene}"`
6547
+ );
6548
+ process.exit(1);
6549
+ }
6550
+ }
6551
+ const body = sceneConfig.buildRequestBody(options);
6552
+ const response = await genArtifactUploadCredential(options.appId, body);
6553
+ console.log(JSON.stringify(response));
6554
+ } catch (error) {
6555
+ const message = error instanceof Error ? error.message : String(error);
6556
+ console.error(`[build] Error: ${message}`);
6557
+ process.exit(1);
6558
+ }
6559
+ }
6560
+ function camelToKebab(str) {
6561
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
6562
+ }
6563
+
6564
+ // src/commands/build/index.ts
6565
+ var getTokenCommand = {
6566
+ name: "get-token",
6567
+ description: "Get artifact upload credential (STI token)",
6568
+ register(program) {
6569
+ 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) => {
6570
+ await getToken(options);
6571
+ });
6572
+ }
6573
+ };
6574
+ var buildCommandGroup = {
6575
+ name: "build",
6576
+ description: "Build related commands",
6577
+ commands: [getTokenCommand]
6578
+ };
6579
+
6505
6580
  // src/commands/index.ts
6506
6581
  var commands = [
6507
6582
  genDbSchemaCommand,
@@ -6510,7 +6585,8 @@ var commands = [
6510
6585
  capabilityCommandGroup,
6511
6586
  componentCommandGroup,
6512
6587
  migrationCommand,
6513
- readLogsCommand
6588
+ readLogsCommand,
6589
+ buildCommandGroup
6514
6590
  ];
6515
6591
 
6516
6592
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.23",
3
+ "version": "1.1.24",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",