edgeone 1.0.32 → 1.0.34
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/edgeone-dist/cli.js +84 -16
- package/package.json +1 -1
package/edgeone-dist/cli.js
CHANGED
|
@@ -164695,7 +164695,7 @@ var yargs_default = Yargs;
|
|
|
164695
164695
|
// package.json
|
|
164696
164696
|
var package_default = {
|
|
164697
164697
|
name: "edgeone",
|
|
164698
|
-
version: "1.0.
|
|
164698
|
+
version: "1.0.34",
|
|
164699
164699
|
description: "Command-line interface for TencentCloud Pages Functions",
|
|
164700
164700
|
bin: {
|
|
164701
164701
|
edgeone: "./edgeone-bin/edgeone.js"
|
|
@@ -175165,6 +175165,16 @@ if (proxyUrl) {
|
|
|
175165
175165
|
} else {
|
|
175166
175166
|
}
|
|
175167
175167
|
import_dotenv2.default.config();
|
|
175168
|
+
var UPLOAD_CONFIG = {
|
|
175169
|
+
// 文件并发数,可通过环境变量调整
|
|
175170
|
+
FILE_PARALLEL_LIMIT: parseInt(process.env.COS_FILE_PARALLEL_LIMIT || "10"),
|
|
175171
|
+
// 分片并发数
|
|
175172
|
+
CHUNK_PARALLEL_LIMIT: parseInt(process.env.COS_CHUNK_PARALLEL_LIMIT || "8"),
|
|
175173
|
+
// 分片大小 (MB)
|
|
175174
|
+
CHUNK_SIZE_MB: parseInt(process.env.COS_CHUNK_SIZE_MB || "8"),
|
|
175175
|
+
// 分片重试次数
|
|
175176
|
+
CHUNK_RETRY_TIMES: parseInt(process.env.COS_CHUNK_RETRY_TIMES || "2")
|
|
175177
|
+
};
|
|
175168
175178
|
var BASE_API_URL1 = "https://pages-api.cloud.tencent.com/v1";
|
|
175169
175179
|
var BASE_API_URL2 = "https://pages-api.edgeone.ai/v1";
|
|
175170
175180
|
var BASE_API_URL = "";
|
|
@@ -175443,7 +175453,7 @@ var describePagesProjects = async (opts) => {
|
|
|
175443
175453
|
};
|
|
175444
175454
|
}
|
|
175445
175455
|
};
|
|
175446
|
-
var describePagesDeployments = async (projectId) => {
|
|
175456
|
+
var describePagesDeployments = async (projectId, throwOnError = true) => {
|
|
175447
175457
|
return await callApi({
|
|
175448
175458
|
action: "DescribePagesDeployments",
|
|
175449
175459
|
data: {
|
|
@@ -175452,7 +175462,8 @@ var describePagesDeployments = async (projectId) => {
|
|
|
175452
175462
|
Limit: 50,
|
|
175453
175463
|
OrderBy: "CreatedOn",
|
|
175454
175464
|
Order: "Desc"
|
|
175455
|
-
}
|
|
175465
|
+
},
|
|
175466
|
+
throwOnError
|
|
175456
175467
|
});
|
|
175457
175468
|
};
|
|
175458
175469
|
var describePagesEncipherToken = async (url2) => {
|
|
@@ -175502,7 +175513,19 @@ var getCosInstance = async () => {
|
|
|
175502
175513
|
const cos = new import_cos_nodejs_sdk_v5.default({
|
|
175503
175514
|
SecretId: credentials.TmpSecretId,
|
|
175504
175515
|
SecretKey: credentials.TmpSecretKey,
|
|
175505
|
-
SecurityToken: credentials.Token
|
|
175516
|
+
SecurityToken: credentials.Token,
|
|
175517
|
+
FileParallelLimit: UPLOAD_CONFIG.FILE_PARALLEL_LIMIT,
|
|
175518
|
+
// 文件并发数
|
|
175519
|
+
ChunkParallelLimit: UPLOAD_CONFIG.CHUNK_PARALLEL_LIMIT,
|
|
175520
|
+
// 分片并发数
|
|
175521
|
+
ChunkRetryTimes: UPLOAD_CONFIG.CHUNK_RETRY_TIMES,
|
|
175522
|
+
// 分片重试次数
|
|
175523
|
+
ChunkSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
|
|
175524
|
+
// 分片大小
|
|
175525
|
+
SliceSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
|
|
175526
|
+
// 触发分片上传的阈值
|
|
175527
|
+
ProgressInterval: 1e3
|
|
175528
|
+
// 进度回调间隔1秒
|
|
175506
175529
|
});
|
|
175507
175530
|
tokenCache.cos = cos;
|
|
175508
175531
|
return cos;
|
|
@@ -175558,16 +175581,50 @@ var getFiles = (list, localFolder, bucket, region, targetPath) => {
|
|
|
175558
175581
|
};
|
|
175559
175582
|
var uploadFiles = async (files) => {
|
|
175560
175583
|
const cos = await getCosInstance();
|
|
175584
|
+
progressLog(`[uploadFiles] Starting upload of ${files.length} files with optimized settings...`);
|
|
175585
|
+
const BATCH_SIZE = 100;
|
|
175586
|
+
if (files.length > BATCH_SIZE) {
|
|
175587
|
+
progressLog(`[uploadFiles] Large file count detected (${files.length}), processing in batches of ${BATCH_SIZE}...`);
|
|
175588
|
+
const results = [];
|
|
175589
|
+
for (let i2 = 0; i2 < files.length; i2 += BATCH_SIZE) {
|
|
175590
|
+
const batch = files.slice(i2, i2 + BATCH_SIZE);
|
|
175591
|
+
progressLog(`[uploadFiles] Processing batch ${Math.floor(i2 / BATCH_SIZE) + 1}/${Math.ceil(files.length / BATCH_SIZE)} (${batch.length} files)...`);
|
|
175592
|
+
const batchResult = await uploadFilesBatch(cos, batch);
|
|
175593
|
+
results.push(batchResult);
|
|
175594
|
+
}
|
|
175595
|
+
return { files: results.flat() };
|
|
175596
|
+
} else {
|
|
175597
|
+
return uploadFilesBatch(cos, files);
|
|
175598
|
+
}
|
|
175599
|
+
};
|
|
175600
|
+
var uploadFilesBatch = async (cos, files) => {
|
|
175561
175601
|
return new Promise((resolve5, reject) => {
|
|
175562
175602
|
cos.uploadFiles(
|
|
175563
175603
|
{
|
|
175564
175604
|
files,
|
|
175565
|
-
SliceSize: 1024 * 1024
|
|
175605
|
+
SliceSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
|
|
175606
|
+
// 分片大小,提升大文件上传效率
|
|
175607
|
+
onProgress: function(progressData) {
|
|
175608
|
+
if (progressData.percent) {
|
|
175609
|
+
const percent = Math.round(progressData.percent * 100);
|
|
175610
|
+
}
|
|
175611
|
+
},
|
|
175612
|
+
onFileFinish: function(err2, data, options) {
|
|
175613
|
+
if (err2) {
|
|
175614
|
+
errorLog(`[uploadFilesBatch] File upload failed: ${options.Key} - ${err2.message}`);
|
|
175615
|
+
} else {
|
|
175616
|
+
if (process.env.DEBUG_UPLOAD) {
|
|
175617
|
+
progressLog(`[uploadFilesBatch] File uploaded successfully: ${options.Key}`);
|
|
175618
|
+
}
|
|
175619
|
+
}
|
|
175620
|
+
}
|
|
175566
175621
|
},
|
|
175567
175622
|
function(err2, data) {
|
|
175568
175623
|
if (err2) {
|
|
175624
|
+
errorLog(`[uploadFilesBatch] Batch upload failed: ${err2.message}`);
|
|
175569
175625
|
reject(err2);
|
|
175570
175626
|
} else {
|
|
175627
|
+
progressLog(`[uploadFilesBatch] Batch uploaded successfully (${files.length} files)`);
|
|
175571
175628
|
resolve5(data);
|
|
175572
175629
|
}
|
|
175573
175630
|
}
|
|
@@ -175660,18 +175717,29 @@ var pollProjectStatus = async (projectId, deploymentId) => {
|
|
|
175660
175717
|
let isProcessing = true;
|
|
175661
175718
|
let deployment = null;
|
|
175662
175719
|
while (isProcessing) {
|
|
175663
|
-
|
|
175664
|
-
|
|
175665
|
-
(
|
|
175666
|
-
|
|
175667
|
-
|
|
175668
|
-
|
|
175669
|
-
|
|
175670
|
-
|
|
175671
|
-
|
|
175672
|
-
|
|
175673
|
-
|
|
175720
|
+
try {
|
|
175721
|
+
const deploymentsResult = await describePagesDeployments(projectId, false);
|
|
175722
|
+
if (deploymentsResult.Code !== 0) {
|
|
175723
|
+
progressLog(`[pollProjectStatus] Polling failed, retrying in 5 seconds...`);
|
|
175724
|
+
await sleep(5e3);
|
|
175725
|
+
continue;
|
|
175726
|
+
}
|
|
175727
|
+
deployment = deploymentsResult.Data.Response.Deployments.find(
|
|
175728
|
+
(deploy) => deploy.DeploymentId === deploymentId
|
|
175729
|
+
);
|
|
175730
|
+
if (!deployment) {
|
|
175731
|
+
throw new Error(`Deployment with ID ${deploymentId} not found`);
|
|
175732
|
+
}
|
|
175733
|
+
progressLog(`[pollProjectStatus] Deployment status: ${deployment.Status}`);
|
|
175734
|
+
if (deployment.Status !== "Process") {
|
|
175735
|
+
isProcessing = false;
|
|
175736
|
+
} else {
|
|
175737
|
+
await sleep(5e3);
|
|
175738
|
+
}
|
|
175739
|
+
} catch (error3) {
|
|
175740
|
+
progressLog(`[pollProjectStatus] Polling failed, retrying in 5 seconds...`);
|
|
175674
175741
|
await sleep(5e3);
|
|
175742
|
+
continue;
|
|
175675
175743
|
}
|
|
175676
175744
|
}
|
|
175677
175745
|
return deployment;
|