@lark-apaas/fullstack-cli 1.1.28-alpha.7 → 1.1.28-alpha.9
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 +20 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7198,18 +7198,13 @@ async function getDefaultBucketId(appId) {
|
|
|
7198
7198
|
async function preUploadStaticAttachment(appId, bucketId) {
|
|
7199
7199
|
const client = getHttpClient();
|
|
7200
7200
|
const url = `/v1/app/${appId}/storage/bucket/${bucketId}/preUploadStatic`;
|
|
7201
|
-
console.error(`[api-client] preUploadStatic request: POST ${url}, appId=${appId}, bucketId=${bucketId}`);
|
|
7202
7201
|
const response = await client.post(url, {});
|
|
7203
7202
|
if (!response.ok || response.status !== 200) {
|
|
7204
|
-
const body = await response.text().catch(() => "(unable to read body)");
|
|
7205
|
-
console.error(`[api-client] preUploadStatic HTTP error: ${response.status} ${response.statusText}, body: ${body}`);
|
|
7206
7203
|
throw new Error(
|
|
7207
7204
|
`preUploadStatic \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
|
|
7208
7205
|
);
|
|
7209
7206
|
}
|
|
7210
|
-
|
|
7211
|
-
console.error(`[api-client] preUploadStatic response: ${JSON.stringify(data)}`);
|
|
7212
|
-
return data;
|
|
7207
|
+
return response.json();
|
|
7213
7208
|
}
|
|
7214
7209
|
async function uploadStaticAttachmentCallback(appId, bucketId, body) {
|
|
7215
7210
|
const client = getHttpClient();
|
|
@@ -7258,7 +7253,7 @@ function camelToKebab(str) {
|
|
|
7258
7253
|
// src/commands/build/upload-static.handler.ts
|
|
7259
7254
|
import * as fs25 from "fs";
|
|
7260
7255
|
import * as path21 from "path";
|
|
7261
|
-
import {
|
|
7256
|
+
import { execFileSync } from "child_process";
|
|
7262
7257
|
function readCredentialsFromEnv() {
|
|
7263
7258
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
7264
7259
|
const uploadID = process.env.STATIC_UPLOAD_ID;
|
|
@@ -7342,7 +7337,7 @@ async function uploadStatic(options) {
|
|
|
7342
7337
|
async function fetchPreUpload(appId, bucketId) {
|
|
7343
7338
|
const response = await preUploadStaticAttachment(appId, bucketId);
|
|
7344
7339
|
if (response.status_code !== "0") {
|
|
7345
|
-
throw new Error(`preUploadStatic \u8FD4\u56DE\u5F02\u5E38,
|
|
7340
|
+
throw new Error(`preUploadStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${response.status_code}`);
|
|
7346
7341
|
}
|
|
7347
7342
|
const { uploadPrefix, uploadID, uploadCredential } = response.data || {};
|
|
7348
7343
|
if (!uploadPrefix || !uploadID) {
|
|
@@ -7355,14 +7350,16 @@ async function fetchPreUpload(appId, bucketId) {
|
|
|
7355
7350
|
}
|
|
7356
7351
|
function configureTosutil(tosutilPath, config) {
|
|
7357
7352
|
const { endpoint, region, accessKeyID, secretAccessKey, sessionToken } = config;
|
|
7358
|
-
|
|
7359
|
-
|
|
7353
|
+
execFileSync(
|
|
7354
|
+
tosutilPath,
|
|
7355
|
+
["config", "-e", endpoint, "-i", accessKeyID, "-k", secretAccessKey, "-t", sessionToken, "-re", region],
|
|
7360
7356
|
{ stdio: "pipe" }
|
|
7361
7357
|
);
|
|
7362
7358
|
}
|
|
7363
7359
|
function uploadToTos(tosutilPath, sourceDir, destUrl) {
|
|
7364
|
-
|
|
7365
|
-
|
|
7360
|
+
execFileSync(
|
|
7361
|
+
tosutilPath,
|
|
7362
|
+
["cp", sourceDir, destUrl, "-r", "-flat", "-j", "5", "-p", "3", "-ps", "10485760", "-f"],
|
|
7366
7363
|
{ stdio: "inherit" }
|
|
7367
7364
|
);
|
|
7368
7365
|
}
|
|
@@ -7379,6 +7376,9 @@ function isDirEmpty(dirPath) {
|
|
|
7379
7376
|
|
|
7380
7377
|
// src/commands/build/pre-upload-static.handler.ts
|
|
7381
7378
|
var LOG_PREFIX2 = "[pre-upload-static]";
|
|
7379
|
+
function shellEscape(value) {
|
|
7380
|
+
return value.replace(/["\\`$]/g, "\\$&");
|
|
7381
|
+
}
|
|
7382
7382
|
async function preUploadStatic(options) {
|
|
7383
7383
|
try {
|
|
7384
7384
|
const { appId } = options;
|
|
@@ -7388,7 +7388,7 @@ async function preUploadStatic(options) {
|
|
|
7388
7388
|
console.error(`${LOG_PREFIX2} \u8C03\u7528 preUploadStatic...`);
|
|
7389
7389
|
const response = await preUploadStaticAttachment(appId, bucketId);
|
|
7390
7390
|
if (response.status_code !== "0") {
|
|
7391
|
-
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u5F02\u5E38,
|
|
7391
|
+
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${response.status_code}`);
|
|
7392
7392
|
return;
|
|
7393
7393
|
}
|
|
7394
7394
|
const { downloadURLPrefix, uploadPrefix, uploadID, uploadCredential } = response.data || {};
|
|
@@ -7400,13 +7400,13 @@ async function preUploadStatic(options) {
|
|
|
7400
7400
|
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u7684\u51ED\u8BC1\u5B57\u6BB5\u4E0D\u5B8C\u6574`);
|
|
7401
7401
|
return;
|
|
7402
7402
|
}
|
|
7403
|
-
console.log(`export STATIC_ASSETS_BASE_URL="${downloadURLPrefix}"`);
|
|
7404
|
-
console.log(`export STATIC_UPLOAD_PREFIX="${uploadPrefix}"`);
|
|
7405
|
-
console.log(`export STATIC_UPLOAD_ID="${uploadID}"`);
|
|
7406
|
-
console.log(`export STATIC_UPLOAD_AK="${uploadCredential.AccessKeyID}"`);
|
|
7407
|
-
console.log(`export STATIC_UPLOAD_SK="${uploadCredential.SecretAccessKey}"`);
|
|
7408
|
-
console.log(`export STATIC_UPLOAD_TOKEN="${uploadCredential.SessionToken}"`);
|
|
7409
|
-
console.log(`export STATIC_UPLOAD_BUCKET_ID="${bucketId}"`);
|
|
7403
|
+
console.log(`export STATIC_ASSETS_BASE_URL="${shellEscape(downloadURLPrefix)}"`);
|
|
7404
|
+
console.log(`export STATIC_UPLOAD_PREFIX="${shellEscape(uploadPrefix)}"`);
|
|
7405
|
+
console.log(`export STATIC_UPLOAD_ID="${shellEscape(uploadID)}"`);
|
|
7406
|
+
console.log(`export STATIC_UPLOAD_AK="${shellEscape(uploadCredential.AccessKeyID)}"`);
|
|
7407
|
+
console.log(`export STATIC_UPLOAD_SK="${shellEscape(uploadCredential.SecretAccessKey)}"`);
|
|
7408
|
+
console.log(`export STATIC_UPLOAD_TOKEN="${shellEscape(uploadCredential.SessionToken)}"`);
|
|
7409
|
+
console.log(`export STATIC_UPLOAD_BUCKET_ID="${shellEscape(bucketId)}"`);
|
|
7410
7410
|
console.error(`${LOG_PREFIX2} \u73AF\u5883\u53D8\u91CF\u5DF2\u8F93\u51FA`);
|
|
7411
7411
|
} catch (error) {
|
|
7412
7412
|
const message = error instanceof Error ? error.message : String(error);
|