edgeone 1.0.32 → 1.0.33

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.
@@ -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.32",
164698
+ version: "1.0.33",
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 = "";
@@ -175502,7 +175512,19 @@ var getCosInstance = async () => {
175502
175512
  const cos = new import_cos_nodejs_sdk_v5.default({
175503
175513
  SecretId: credentials.TmpSecretId,
175504
175514
  SecretKey: credentials.TmpSecretKey,
175505
- SecurityToken: credentials.Token
175515
+ SecurityToken: credentials.Token,
175516
+ FileParallelLimit: UPLOAD_CONFIG.FILE_PARALLEL_LIMIT,
175517
+ // 文件并发数
175518
+ ChunkParallelLimit: UPLOAD_CONFIG.CHUNK_PARALLEL_LIMIT,
175519
+ // 分片并发数
175520
+ ChunkRetryTimes: UPLOAD_CONFIG.CHUNK_RETRY_TIMES,
175521
+ // 分片重试次数
175522
+ ChunkSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
175523
+ // 分片大小
175524
+ SliceSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
175525
+ // 触发分片上传的阈值
175526
+ ProgressInterval: 1e3
175527
+ // 进度回调间隔1秒
175506
175528
  });
175507
175529
  tokenCache.cos = cos;
175508
175530
  return cos;
@@ -175558,16 +175580,50 @@ var getFiles = (list, localFolder, bucket, region, targetPath) => {
175558
175580
  };
175559
175581
  var uploadFiles = async (files) => {
175560
175582
  const cos = await getCosInstance();
175583
+ progressLog(`[uploadFiles] Starting upload of ${files.length} files with optimized settings...`);
175584
+ const BATCH_SIZE = 100;
175585
+ if (files.length > BATCH_SIZE) {
175586
+ progressLog(`[uploadFiles] Large file count detected (${files.length}), processing in batches of ${BATCH_SIZE}...`);
175587
+ const results = [];
175588
+ for (let i2 = 0; i2 < files.length; i2 += BATCH_SIZE) {
175589
+ const batch = files.slice(i2, i2 + BATCH_SIZE);
175590
+ progressLog(`[uploadFiles] Processing batch ${Math.floor(i2 / BATCH_SIZE) + 1}/${Math.ceil(files.length / BATCH_SIZE)} (${batch.length} files)...`);
175591
+ const batchResult = await uploadFilesBatch(cos, batch);
175592
+ results.push(batchResult);
175593
+ }
175594
+ return { files: results.flat() };
175595
+ } else {
175596
+ return uploadFilesBatch(cos, files);
175597
+ }
175598
+ };
175599
+ var uploadFilesBatch = async (cos, files) => {
175561
175600
  return new Promise((resolve5, reject) => {
175562
175601
  cos.uploadFiles(
175563
175602
  {
175564
175603
  files,
175565
- SliceSize: 1024 * 1024
175604
+ SliceSize: 1024 * 1024 * UPLOAD_CONFIG.CHUNK_SIZE_MB,
175605
+ // 分片大小,提升大文件上传效率
175606
+ onProgress: function(progressData) {
175607
+ if (progressData.percent) {
175608
+ const percent = Math.round(progressData.percent * 100);
175609
+ }
175610
+ },
175611
+ onFileFinish: function(err2, data, options) {
175612
+ if (err2) {
175613
+ errorLog(`[uploadFilesBatch] File upload failed: ${options.Key} - ${err2.message}`);
175614
+ } else {
175615
+ if (process.env.DEBUG_UPLOAD) {
175616
+ progressLog(`[uploadFilesBatch] File uploaded successfully: ${options.Key}`);
175617
+ }
175618
+ }
175619
+ }
175566
175620
  },
175567
175621
  function(err2, data) {
175568
175622
  if (err2) {
175623
+ errorLog(`[uploadFilesBatch] Batch upload failed: ${err2.message}`);
175569
175624
  reject(err2);
175570
175625
  } else {
175626
+ progressLog(`[uploadFilesBatch] Batch uploaded successfully (${files.length} files)`);
175571
175627
  resolve5(data);
175572
175628
  }
175573
175629
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edgeone",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Command-line interface for TencentCloud Pages Functions",
5
5
  "bin": {
6
6
  "edgeone": "./edgeone-bin/edgeone.js"