@lark-apaas/fullstack-cli 1.1.16-beta.11 → 1.1.16-beta.12
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 +41 -24
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7264,26 +7264,48 @@ var UPLOAD_STATIC_DEFAULTS = {
|
|
|
7264
7264
|
};
|
|
7265
7265
|
|
|
7266
7266
|
// src/commands/build/api-client.ts
|
|
7267
|
+
var ERROR_RESPONSE_PREVIEW_LIMIT = 2e3;
|
|
7268
|
+
async function getErrorResponseDetails(response) {
|
|
7269
|
+
try {
|
|
7270
|
+
if (typeof response.text === "function") {
|
|
7271
|
+
const text = await response.text();
|
|
7272
|
+
if (!text) {
|
|
7273
|
+
return "";
|
|
7274
|
+
}
|
|
7275
|
+
return `, response: ${text.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT)}`;
|
|
7276
|
+
}
|
|
7277
|
+
if (typeof response.json === "function") {
|
|
7278
|
+
const data = await response.json();
|
|
7279
|
+
const serialized = JSON.stringify(data);
|
|
7280
|
+
if (!serialized) {
|
|
7281
|
+
return "";
|
|
7282
|
+
}
|
|
7283
|
+
return `, response: ${serialized.slice(0, ERROR_RESPONSE_PREVIEW_LIMIT)}`;
|
|
7284
|
+
}
|
|
7285
|
+
} catch {
|
|
7286
|
+
return "";
|
|
7287
|
+
}
|
|
7288
|
+
return "";
|
|
7289
|
+
}
|
|
7290
|
+
async function throwIfResponseNotOk(response, message) {
|
|
7291
|
+
if (response.ok && response.status === 200) {
|
|
7292
|
+
return;
|
|
7293
|
+
}
|
|
7294
|
+
const details = await getErrorResponseDetails(response);
|
|
7295
|
+
throw new Error(`${message}: ${response.status} ${response.statusText}${details}`);
|
|
7296
|
+
}
|
|
7267
7297
|
async function genArtifactUploadCredential(appId, body) {
|
|
7268
7298
|
const client = getHttpClient();
|
|
7269
7299
|
const url = `/v1/app/${appId}/pipeline/gen_artifact_upload_credential`;
|
|
7270
7300
|
const response = await client.post(url, body);
|
|
7271
|
-
|
|
7272
|
-
throw new Error(
|
|
7273
|
-
`gen_artifact_upload_credential \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
|
|
7274
|
-
);
|
|
7275
|
-
}
|
|
7301
|
+
await throwIfResponseNotOk(response, "gen_artifact_upload_credential \u8BF7\u6C42\u5931\u8D25");
|
|
7276
7302
|
return response.json();
|
|
7277
7303
|
}
|
|
7278
7304
|
async function getDefaultBucketId(appId) {
|
|
7279
7305
|
const client = getHttpClient();
|
|
7280
7306
|
const url = `/v1/app/${appId}/storage/inner/staticBucket`;
|
|
7281
7307
|
const response = await client.post(url, {});
|
|
7282
|
-
|
|
7283
|
-
throw new Error(
|
|
7284
|
-
`getOrCreateStaticBucket \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
|
|
7285
|
-
);
|
|
7286
|
-
}
|
|
7308
|
+
await throwIfResponseNotOk(response, "getOrCreateStaticBucket \u8BF7\u6C42\u5931\u8D25");
|
|
7287
7309
|
const data = await response.json();
|
|
7288
7310
|
if (data.status_code !== "0") {
|
|
7289
7311
|
throw new Error(`getOrCreateStaticBucket \u8FD4\u56DE\u5F02\u5E38, status_code: ${data.status_code}`);
|
|
@@ -7298,22 +7320,14 @@ async function preUploadStaticAttachment(appId, bucketId) {
|
|
|
7298
7320
|
const client = getHttpClient();
|
|
7299
7321
|
const url = `/v1/app/${appId}/storage/bucket/${bucketId}/preUploadStatic`;
|
|
7300
7322
|
const response = await client.post(url, {});
|
|
7301
|
-
|
|
7302
|
-
throw new Error(
|
|
7303
|
-
`preUploadStatic \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
|
|
7304
|
-
);
|
|
7305
|
-
}
|
|
7323
|
+
await throwIfResponseNotOk(response, "preUploadStatic \u8BF7\u6C42\u5931\u8D25");
|
|
7306
7324
|
return response.json();
|
|
7307
7325
|
}
|
|
7308
7326
|
async function uploadStaticAttachmentCallback(appId, bucketId, body) {
|
|
7309
7327
|
const client = getHttpClient();
|
|
7310
7328
|
const url = `/v1/app/${appId}/storage/bucket/${bucketId}/object/callbackStatic`;
|
|
7311
7329
|
const response = await client.post(url, body);
|
|
7312
|
-
|
|
7313
|
-
throw new Error(
|
|
7314
|
-
`callbackStatic \u8BF7\u6C42\u5931\u8D25: ${response.status} ${response.statusText}`
|
|
7315
|
-
);
|
|
7316
|
-
}
|
|
7330
|
+
await throwIfResponseNotOk(response, "callbackStatic \u8BF7\u6C42\u5931\u8D25");
|
|
7317
7331
|
return response.json();
|
|
7318
7332
|
}
|
|
7319
7333
|
|
|
@@ -7433,7 +7447,7 @@ async function uploadStatic(options) {
|
|
|
7433
7447
|
console.error(`${LOG_PREFIX} \u8C03\u7528 callbackStatic (uploadID: ${uploadID})...`);
|
|
7434
7448
|
const callbackResp = await uploadStaticAttachmentCallback(appId, bucketId, { uploadID });
|
|
7435
7449
|
if (callbackResp.status_code !== "0") {
|
|
7436
|
-
throw new Error(`callbackStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${callbackResp.status_code}`);
|
|
7450
|
+
throw new Error(`callbackStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${callbackResp.status_code}, response: ${JSON.stringify(callbackResp)}`);
|
|
7437
7451
|
}
|
|
7438
7452
|
const attachments = callbackResp.data?.attachments || [];
|
|
7439
7453
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u5B8C\u6210\uFF0C\u5171 ${attachments.length} \u4E2A\u6587\u4EF6`);
|
|
@@ -7458,14 +7472,14 @@ function resolveTosutilPath(tosutilPath) {
|
|
|
7458
7472
|
async function fetchPreUpload(appId, bucketId) {
|
|
7459
7473
|
const response = await preUploadStaticAttachment(appId, bucketId);
|
|
7460
7474
|
if (response.status_code !== "0") {
|
|
7461
|
-
throw new Error(`preUploadStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${response.status_code}`);
|
|
7475
|
+
throw new Error(`preUploadStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${response.status_code}, response: ${JSON.stringify(response)}`);
|
|
7462
7476
|
}
|
|
7463
7477
|
const { uploadPrefix, uploadID, uploadCredential } = response.data || {};
|
|
7464
7478
|
if (!uploadPrefix || !uploadID) {
|
|
7465
|
-
throw new Error(
|
|
7479
|
+
throw new Error(`preUploadStatic \u8FD4\u56DE\u6570\u636E\u4E0D\u5B8C\u6574\uFF0C\u7F3A\u5C11 uploadPrefix \u6216 uploadID, response: ${JSON.stringify(response)}`);
|
|
7466
7480
|
}
|
|
7467
7481
|
if (!uploadCredential?.AccessKeyID || !uploadCredential?.SecretAccessKey || !uploadCredential?.SessionToken) {
|
|
7468
|
-
throw new Error(
|
|
7482
|
+
throw new Error(`preUploadStatic \u8FD4\u56DE\u7684\u51ED\u8BC1\u5B57\u6BB5\u4E0D\u5B8C\u6574, response: ${JSON.stringify(response)}`);
|
|
7469
7483
|
}
|
|
7470
7484
|
return response;
|
|
7471
7485
|
}
|
|
@@ -7510,15 +7524,18 @@ async function preUploadStatic(options) {
|
|
|
7510
7524
|
const response = await preUploadStaticAttachment(appId, bucketId);
|
|
7511
7525
|
if (response.status_code !== "0") {
|
|
7512
7526
|
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u5F02\u5E38, status_code: ${response.status_code}`);
|
|
7527
|
+
console.error(`${LOG_PREFIX2} preUploadStatic \u54CD\u5E94: ${JSON.stringify(response)}`);
|
|
7513
7528
|
return;
|
|
7514
7529
|
}
|
|
7515
7530
|
const { downloadURLPrefix, uploadPrefix, uploadID, uploadCredential } = response.data || {};
|
|
7516
7531
|
if (!downloadURLPrefix || !uploadPrefix || !uploadID) {
|
|
7517
7532
|
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u6570\u636E\u4E0D\u5B8C\u6574`);
|
|
7533
|
+
console.error(`${LOG_PREFIX2} preUploadStatic \u54CD\u5E94: ${JSON.stringify(response)}`);
|
|
7518
7534
|
return;
|
|
7519
7535
|
}
|
|
7520
7536
|
if (!uploadCredential?.AccessKeyID || !uploadCredential?.SecretAccessKey || !uploadCredential?.SessionToken) {
|
|
7521
7537
|
console.error(`${LOG_PREFIX2} preUploadStatic \u8FD4\u56DE\u7684\u51ED\u8BC1\u5B57\u6BB5\u4E0D\u5B8C\u6574`);
|
|
7538
|
+
console.error(`${LOG_PREFIX2} preUploadStatic \u54CD\u5E94: ${JSON.stringify(response)}`);
|
|
7522
7539
|
return;
|
|
7523
7540
|
}
|
|
7524
7541
|
console.log(`export STATIC_ASSETS_BASE_URL="${shellEscape(downloadURLPrefix)}"`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-cli",
|
|
3
|
-
"version": "1.1.16-beta.
|
|
3
|
+
"version": "1.1.16-beta.12",
|
|
4
4
|
"description": "CLI tool for fullstack template management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/node": "^22.0.0",
|
|
53
53
|
"tsup": "^8.3.5",
|
|
54
54
|
"typescript": "^5.9.2",
|
|
55
|
-
"vitest": "^2.
|
|
55
|
+
"vitest": "^3.2.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"typescript": "^5.9.2"
|