@lark-apaas/fullstack-cli 1.1.28-alpha.23 → 1.1.28-alpha.25

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 (2) hide show
  1. package/dist/index.js +59 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1414,15 +1414,14 @@ async function fetchSyncedTables(appId, workspace) {
1414
1414
  DEFAULT_TIMEOUT_MS2
1415
1415
  );
1416
1416
  });
1417
- const dbBranch = process.env.FORCE_DB_BRANCH || "main";
1418
1417
  const start = Date.now();
1419
1418
  console.log(
1420
- `[fetchSyncedTables] \u2192 GET listTableView (dbBranch=${dbBranch}) appId=${appId ? "set" : "unset"} workspace=${workspace ? "set" : "unset"}`
1419
+ `[fetchSyncedTables] \u2192 GET listTableView (dbBranch=main) appId=${appId ? "set" : "unset"} workspace=${workspace ? "set" : "unset"}`
1421
1420
  );
1422
1421
  const response = await Promise.race([
1423
1422
  client.get(
1424
1423
  `/api/v1/dataloom/inner/app/${appId}/workspaces/${workspace}/listTableView`,
1425
- { params: { dbBranch }, headers: { "x-supaas-bizsource": "miaoda" } }
1424
+ { params: { dbBranch: "main" }, headers: { "x-supaas-bizsource": "miaoda" } }
1426
1425
  ),
1427
1426
  timeoutPromise
1428
1427
  ]);
@@ -7256,6 +7255,12 @@ var SCENE_CONFIGS = {
7256
7255
  buildRequestBody: () => ({ commitID: "" })
7257
7256
  }
7258
7257
  };
7258
+ var UPLOAD_STATIC_DEFAULTS = {
7259
+ staticDir: "shared/static",
7260
+ tosutilPath: "tosutil",
7261
+ endpoint: "tos-cn-beijing.volces.com",
7262
+ region: "cn-beijing"
7263
+ };
7259
7264
 
7260
7265
  // src/commands/build/api-client.ts
7261
7266
  async function genArtifactUploadCredential(appId, body) {
@@ -7271,17 +7276,20 @@ async function genArtifactUploadCredential(appId, body) {
7271
7276
  }
7272
7277
  async function getDefaultBucketId(appId) {
7273
7278
  const client = getHttpClient();
7274
- const url = `/b/${appId}/get_published_v2`;
7275
- const response = await client.get(url);
7279
+ const url = `/v1/app/${appId}/storage/inner/staticBucket`;
7280
+ const response = await client.post(url, {});
7276
7281
  if (!response.ok || response.status !== 200) {
7277
7282
  throw new Error(
7278
- `get_published_v2 \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
7283
+ `getOrCreateStaticBucket \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
7279
7284
  );
7280
7285
  }
7281
7286
  const data = await response.json();
7282
- const bucketId = data?.data?.app_runtime_extra?.bucket?.default_bucket_id;
7287
+ if (data.status_code !== "0") {
7288
+ throw new Error(`getOrCreateStaticBucket \u8FD4\u56DE\u5F02\u5E38, status_code: ${data.status_code}`);
7289
+ }
7290
+ const bucketId = data?.data?.bucketID;
7283
7291
  if (!bucketId) {
7284
- throw new Error(`\u672A\u627E\u5230\u5E94\u7528 ${appId} \u7684\u9ED8\u8BA4\u5B58\u50A8\u6876`);
7292
+ throw new Error(`\u672A\u627E\u5230\u5E94\u7528 ${appId} \u7684\u9759\u6001\u8D44\u6E90\u5B58\u50A8\u6876`);
7285
7293
  }
7286
7294
  return bucketId;
7287
7295
  }
@@ -7342,6 +7350,7 @@ function camelToKebab(str) {
7342
7350
 
7343
7351
  // src/commands/build/upload-static.handler.ts
7344
7352
  import * as fs25 from "fs";
7353
+ import * as os2 from "os";
7345
7354
  import * as path21 from "path";
7346
7355
  import { execFileSync } from "child_process";
7347
7356
  function readCredentialsFromEnv() {
@@ -7361,10 +7370,10 @@ async function uploadStatic(options) {
7361
7370
  try {
7362
7371
  const {
7363
7372
  appId,
7364
- staticDir = "shared/static",
7365
- tosutilPath = "/workspace/tosutil",
7366
- endpoint = "tos-cn-beijing.volces.com",
7367
- region = "cn-beijing"
7373
+ staticDir = UPLOAD_STATIC_DEFAULTS.staticDir,
7374
+ tosutilPath = UPLOAD_STATIC_DEFAULTS.tosutilPath,
7375
+ endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7376
+ region = UPLOAD_STATIC_DEFAULTS.region
7368
7377
  } = options;
7369
7378
  const resolvedStaticDir = path21.resolve(staticDir);
7370
7379
  if (!fs25.existsSync(resolvedStaticDir)) {
@@ -7375,9 +7384,10 @@ async function uploadStatic(options) {
7375
7384
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E3A\u7A7A: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7376
7385
  return;
7377
7386
  }
7378
- if (!fs25.existsSync(tosutilPath)) {
7387
+ const resolvedTosutil = resolveTosutilPath(tosutilPath);
7388
+ if (!resolvedTosutil) {
7379
7389
  throw new Error(
7380
- `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`
7390
+ `tosutil \u4E0D\u5B58\u5728: ${tosutilPath}\u3002\u8BF7\u786E\u4FDD tosutil \u5DF2\u5B89\u88C5\u5728\u7CFB\u7EDF PATH \u4E2D\u6216\u901A\u8FC7 --tosutil-path \u6307\u5B9A\u8DEF\u5F84\u3002`
7381
7391
  );
7382
7392
  }
7383
7393
  let uploadPrefix;
@@ -7399,16 +7409,25 @@ async function uploadStatic(options) {
7399
7409
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7400
7410
  }
7401
7411
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7402
- console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7403
- configureTosutil(tosutilPath, {
7404
- endpoint,
7405
- region,
7406
- accessKeyID,
7407
- secretAccessKey,
7408
- sessionToken
7409
- });
7410
- console.error(`${LOG_PREFIX} \u4E0A\u4F20 ${resolvedStaticDir} -> ${uploadPrefix}`);
7411
- uploadToTos(tosutilPath, resolvedStaticDir, uploadPrefix);
7412
+ const confPath = path21.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7413
+ fs25.writeFileSync(confPath, "");
7414
+ try {
7415
+ console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7416
+ configureTosutil(resolvedTosutil, confPath, {
7417
+ endpoint,
7418
+ region,
7419
+ accessKeyID,
7420
+ secretAccessKey,
7421
+ sessionToken
7422
+ });
7423
+ console.error(`${LOG_PREFIX} \u4E0A\u4F20 ${resolvedStaticDir} -> ${uploadPrefix}`);
7424
+ uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7425
+ } finally {
7426
+ try {
7427
+ fs25.unlinkSync(confPath);
7428
+ } catch {
7429
+ }
7430
+ }
7412
7431
  console.error(`${LOG_PREFIX} tosutil \u4E0A\u4F20\u5B8C\u6210`);
7413
7432
  console.error(`${LOG_PREFIX} \u8C03\u7528 callbackStatic (uploadID: ${uploadID})...`);
7414
7433
  const callbackResp = await uploadStaticAttachmentCallback(appId, bucketId, { uploadID });
@@ -7424,6 +7443,17 @@ async function uploadStatic(options) {
7424
7443
  process.exit(1);
7425
7444
  }
7426
7445
  }
7446
+ function resolveTosutilPath(tosutilPath) {
7447
+ if (path21.isAbsolute(tosutilPath)) {
7448
+ return fs25.existsSync(tosutilPath) ? tosutilPath : null;
7449
+ }
7450
+ try {
7451
+ const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
7452
+ return resolved || null;
7453
+ } catch {
7454
+ return null;
7455
+ }
7456
+ }
7427
7457
  async function fetchPreUpload(appId, bucketId) {
7428
7458
  const response = await preUploadStaticAttachment(appId, bucketId);
7429
7459
  if (response.status_code !== "0") {
@@ -7438,18 +7468,18 @@ async function fetchPreUpload(appId, bucketId) {
7438
7468
  }
7439
7469
  return response;
7440
7470
  }
7441
- function configureTosutil(tosutilPath, config) {
7471
+ function configureTosutil(tosutilPath, confPath, config) {
7442
7472
  const { endpoint, region, accessKeyID, secretAccessKey, sessionToken } = config;
7443
7473
  execFileSync(
7444
7474
  tosutilPath,
7445
- ["config", "-e", endpoint, "-i", accessKeyID, "-k", secretAccessKey, "-t", sessionToken, "-re", region],
7475
+ ["config", "-conf", confPath, "-e", endpoint, "-i", accessKeyID, "-k", secretAccessKey, "-t", sessionToken, "-re", region],
7446
7476
  { stdio: "pipe" }
7447
7477
  );
7448
7478
  }
7449
- function uploadToTos(tosutilPath, sourceDir, destUrl) {
7479
+ function uploadToTos(tosutilPath, confPath, sourceDir, destUrl) {
7450
7480
  execFileSync(
7451
7481
  tosutilPath,
7452
- ["cp", sourceDir, destUrl, "-r", "-flat", "-j", "5", "-p", "3", "-ps", "10485760", "-f"],
7482
+ ["cp", "-conf", confPath, sourceDir, destUrl, "-r", "-flat", "-j", "5", "-p", "3", "-ps", "10485760", "-f"],
7453
7483
  { stdio: "inherit" }
7454
7484
  );
7455
7485
  }
@@ -7518,7 +7548,7 @@ var uploadStaticCommand = {
7518
7548
  name: "upload-static",
7519
7549
  description: "Upload shared/static files to TOS",
7520
7550
  register(program) {
7521
- 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) => {
7551
+ program.command(this.name).description(this.description).requiredOption("--app-id <id>", "Application ID").option("--static-dir <dir>", "Static files directory", UPLOAD_STATIC_DEFAULTS.staticDir).option("--tosutil-path <path>", "Path to tosutil binary", UPLOAD_STATIC_DEFAULTS.tosutilPath).option("--endpoint <endpoint>", "TOS endpoint", UPLOAD_STATIC_DEFAULTS.endpoint).option("--region <region>", "TOS region", UPLOAD_STATIC_DEFAULTS.region).action(async (options) => {
7522
7552
  await uploadStatic(options);
7523
7553
  });
7524
7554
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.28-alpha.23",
3
+ "version": "1.1.28-alpha.25",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",