@lark-apaas/fullstack-cli 1.1.22-alpha.26 → 1.1.22-alpha.28

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/dist/index.js CHANGED
@@ -7261,7 +7261,6 @@ async function uploadStatic(options) {
7261
7261
  appId,
7262
7262
  staticDir = "shared/static",
7263
7263
  tosutilPath = "/workspace/tosutil",
7264
- tosutilUrl,
7265
7264
  endpoint = "tos-cn-beijing.volces.com",
7266
7265
  region = "cn-beijing"
7267
7266
  } = options;
@@ -7274,14 +7273,18 @@ async function uploadStatic(options) {
7274
7273
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E3A\u7A7A: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7275
7274
  return;
7276
7275
  }
7277
- const resolvedTosutilPath = ensureTosutil(tosutilPath, tosutilUrl);
7276
+ if (!fs25.existsSync(tosutilPath)) {
7277
+ throw new Error(
7278
+ `tosutil \u4E0D\u5B58\u5728: ${tosutilPath}\u3002\u8BF7\u786E\u4FDD\u6D41\u6C34\u7EBF\u5DF2\u5728"\u4EA7\u7269\u6253\u5305\u4E0A\u4F20"\u6B65\u9AA4\u4E2D\u4E0B\u8F7D tosutil\u3002`
7279
+ );
7280
+ }
7278
7281
  const bucketId = await resolveBucketId(appId);
7279
7282
  console.error(`${LOG_PREFIX} \u8C03\u7528 preUploadStatic...`);
7280
7283
  const preUploadResp = await fetchPreUpload(appId, bucketId);
7281
7284
  const { uploadPrefix, uploadID, uploadCredential } = preUploadResp.data;
7282
7285
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7283
7286
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7284
- configureTosutil(resolvedTosutilPath, {
7287
+ configureTosutil(tosutilPath, {
7285
7288
  endpoint,
7286
7289
  region,
7287
7290
  accessKeyID: uploadCredential.accessKeyID,
@@ -7289,7 +7292,7 @@ async function uploadStatic(options) {
7289
7292
  sessionToken: uploadCredential.sessionToken
7290
7293
  });
7291
7294
  console.error(`${LOG_PREFIX} \u4E0A\u4F20 ${resolvedStaticDir} -> ${uploadPrefix}`);
7292
- uploadToTos(resolvedTosutilPath, resolvedStaticDir, uploadPrefix);
7295
+ uploadToTos(tosutilPath, resolvedStaticDir, uploadPrefix);
7293
7296
  console.error(`${LOG_PREFIX} tosutil \u4E0A\u4F20\u5B8C\u6210`);
7294
7297
  console.error(`${LOG_PREFIX} \u8C03\u7528 callbackStatic (uploadID: ${uploadID})...`);
7295
7298
  const callbackResp = await uploadStaticAttachmentCallback(appId, bucketId, { uploadID });
@@ -7314,45 +7317,12 @@ async function fetchPreUpload(appId, bucketId) {
7314
7317
  if (!uploadPrefix || !uploadID) {
7315
7318
  throw new Error("preUploadStatic \u8FD4\u56DE\u6570\u636E\u4E0D\u5B8C\u6574\uFF0C\u7F3A\u5C11 uploadPrefix \u6216 uploadID");
7316
7319
  }
7320
+ console.log("!!!!!!!!!!!response:", response.data);
7317
7321
  if (!uploadCredential?.accessKeyID || !uploadCredential?.secretAccessKey || !uploadCredential?.sessionToken) {
7318
7322
  throw new Error("preUploadStatic \u8FD4\u56DE\u7684\u51ED\u8BC1\u5B57\u6BB5\u4E0D\u5B8C\u6574");
7319
7323
  }
7320
7324
  return response;
7321
7325
  }
7322
- function ensureTosutil(tosutilPath, tosutilUrl) {
7323
- if (isTosutilAvailable(tosutilPath)) {
7324
- console.error(`${LOG_PREFIX} tosutil \u5DF2\u5C31\u7EEA: ${tosutilPath}`);
7325
- return tosutilPath;
7326
- }
7327
- if (!tosutilUrl) {
7328
- throw new Error(
7329
- `tosutil \u4E0D\u53EF\u7528 (\u8DEF\u5F84: ${tosutilPath})\uFF0C\u4E14\u672A\u63D0\u4F9B --tosutil-url \u4E0B\u8F7D\u5730\u5740\u3002\u8BF7\u786E\u4FDD tosutil \u5DF2\u5B58\u5728\uFF0C\u6216\u901A\u8FC7 --tosutil-url \u6307\u5B9A\u4E0B\u8F7D\u5730\u5740\u3002`
7330
- );
7331
- }
7332
- console.error(`${LOG_PREFIX} tosutil \u4E0D\u5B58\u5728\uFF0C\u4ECE ${tosutilUrl} \u4E0B\u8F7D...`);
7333
- downloadTosutil(tosutilUrl, tosutilPath);
7334
- if (!isTosutilAvailable(tosutilPath)) {
7335
- throw new Error(`tosutil \u4E0B\u8F7D\u540E\u4ECD\u4E0D\u53EF\u7528 (\u8DEF\u5F84: ${tosutilPath})`);
7336
- }
7337
- console.error(`${LOG_PREFIX} tosutil \u4E0B\u8F7D\u5B8C\u6210: ${tosutilPath}`);
7338
- return tosutilPath;
7339
- }
7340
- function isTosutilAvailable(tosutilPath) {
7341
- try {
7342
- execSync3(`${tosutilPath} --version`, { stdio: "pipe" });
7343
- return true;
7344
- } catch {
7345
- return false;
7346
- }
7347
- }
7348
- function downloadTosutil(url, destPath) {
7349
- const destDir = path21.dirname(destPath);
7350
- if (!fs25.existsSync(destDir)) {
7351
- fs25.mkdirSync(destDir, { recursive: true });
7352
- }
7353
- execSync3(`curl -L --fail -o "${destPath}" "${url}"`, { stdio: "pipe" });
7354
- execSync3(`chmod +x "${destPath}"`, { stdio: "pipe" });
7355
- }
7356
7326
  function configureTosutil(tosutilPath, config) {
7357
7327
  const { endpoint, region, accessKeyID, secretAccessKey, sessionToken } = config;
7358
7328
  execSync3(
@@ -7391,7 +7361,7 @@ var uploadStaticCommand = {
7391
7361
  name: "upload-static",
7392
7362
  description: "Upload shared/static files to TOS",
7393
7363
  register(program) {
7394
- program.command(this.name).description(this.description).requiredOption("--app-id <id>", "Application ID").option("--static-dir <dir>", "Static files directory", "shared/static").option("--tosutil-path <path>", "Path to tosutil binary", "/workspace/tosutil").option("--tosutil-url <url>", "URL to download tosutil if not present").option("--endpoint <endpoint>", "TOS endpoint", "tos-cn-beijing.volces.com").option("--region <region>", "TOS region", "cn-beijing").action(async (options) => {
7364
+ program.command(this.name).description(this.description).requiredOption("--app-id <id>", "Application ID").option("--static-dir <dir>", "Static files directory", "shared/static").option("--tosutil-path <path>", "Path to tosutil binary", "/workspace/tosutil").option("--endpoint <endpoint>", "TOS endpoint", "tos-cn-beijing.volces.com").option("--region <region>", "TOS region", "cn-beijing").action(async (options) => {
7395
7365
  await uploadStatic(options);
7396
7366
  });
7397
7367
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.22-alpha.26",
3
+ "version": "1.1.22-alpha.28",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,28 +19,28 @@ print_time() {
19
19
  }
20
20
 
21
21
  # ==================== 步骤 0 ====================
22
- echo "🗑️ [0/6] 安装插件"
22
+ echo "🗑️ [0/5] 安装插件"
23
23
  STEP_START=$(node -e "console.log(Date.now())")
24
24
  npx fullstack-cli action-plugin init
25
25
  print_time $STEP_START
26
26
  echo ""
27
27
 
28
28
  # ==================== 步骤 1 ====================
29
- echo "📝 [1/6] 更新 openapi 代码"
29
+ echo "📝 [1/5] 更新 openapi 代码"
30
30
  STEP_START=$(node -e "console.log(Date.now())")
31
31
  npm run gen:openapi
32
32
  print_time $STEP_START
33
33
  echo ""
34
34
 
35
35
  # ==================== 步骤 2 ====================
36
- echo "🗑️ [2/6] 清理 dist 目录"
36
+ echo "🗑️ [2/5] 清理 dist 目录"
37
37
  STEP_START=$(node -e "console.log(Date.now())")
38
38
  rm -rf "$ROOT_DIR/dist"
39
39
  print_time $STEP_START
40
40
  echo ""
41
41
 
42
42
  # ==================== 步骤 3 ====================
43
- echo "🔨 [3/6] 并行构建 server 和 client"
43
+ echo "🔨 [3/5] 并行构建 server 和 client"
44
44
  STEP_START=$(node -e "console.log(Date.now())")
45
45
 
46
46
  # 并行构建
@@ -78,7 +78,7 @@ print_time $STEP_START
78
78
  echo ""
79
79
 
80
80
  # ==================== 步骤 4 ====================
81
- echo "📦 [4/6] 准备 server 依赖产物"
81
+ echo "📦 [4/5] 准备 server 依赖产物"
82
82
  STEP_START=$(node -e "console.log(Date.now())")
83
83
 
84
84
  mkdir -p "$OUT_DIR/dist/client"
@@ -97,7 +97,7 @@ print_time $STEP_START
97
97
  echo ""
98
98
 
99
99
  # ==================== 步骤 5 ====================
100
- echo "✂️ [5/6] 智能依赖裁剪"
100
+ echo "✂️ [5/5] 智能依赖裁剪"
101
101
  STEP_START=$(node -e "console.log(Date.now())")
102
102
 
103
103
  # 分析实际依赖、复制并裁剪 node_modules、生成精简的 package.json
@@ -106,25 +106,6 @@ node "$ROOT_DIR/scripts/prune-smart.js"
106
106
  print_time $STEP_START
107
107
  echo ""
108
108
 
109
- # ==================== 步骤 6 ====================
110
- echo "☁️ [6/6] 上传静态资源到 TOS"
111
- STEP_START=$(node -e "console.log(Date.now())")
112
-
113
- # 环境变量(与产物上传脚本共享同一 CI 环境):
114
- # app_id - 应用 ID
115
- # tosutil_url - tosutil 下载地址
116
- # bucket_id 由 CLI 自动通过 get_published_v2 获取,也可通过 --bucket-id 显式指定
117
- if [ -d "$ROOT_DIR/shared/static" ] && [ "$(ls -A "$ROOT_DIR/shared/static" 2>/dev/null)" ]; then
118
- npx fullstack-cli build upload-static \
119
- --app-id "${app_id}" \
120
- --tosutil-url "${tosutil_url}"
121
- else
122
- echo " ⏭️ shared/static 目录为空或不存在,跳过上传"
123
- fi
124
-
125
- print_time $STEP_START
126
- echo ""
127
-
128
109
  # 总耗时
129
110
  echo "构建完成"
130
111
  print_time $TOTAL_START