@cloudbase/manager-node 4.10.0 → 4.10.1

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/lib/constant.js CHANGED
@@ -62,5 +62,13 @@ exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
62
62
  // SCF 临时 COS 配置(用于函数代码上传)
63
63
  exports.SCF_TEMP_COS = {
64
64
  APPID: '1253665819',
65
- REGION: 'ap-shanghai'
65
+ // 区域前缀映射:region -> bucket 前缀
66
+ REGION_PREFIX_MAP: {
67
+ 'ap-shanghai': 'sh',
68
+ 'ap-guangzhou': 'gz',
69
+ 'ap-beijing': 'bj',
70
+ 'ap-singapore': 'sg'
71
+ },
72
+ DEFAULT_REGION_PREFIX: 'sh',
73
+ DEFAULT_REGION: 'ap-shanghai'
66
74
  };
@@ -1237,11 +1237,14 @@ class FunctionService {
1237
1237
  });
1238
1238
  const zipFilePath = await packer.compressFiles();
1239
1239
  // 3. 初始化 cos 并上传
1240
+ // 根据环境 region 获取对应的 bucket 前缀
1241
+ const region = this.environment.cloudBaseContext.region || constant_1.SCF_TEMP_COS.DEFAULT_REGION;
1242
+ const regionPrefix = constant_1.SCF_TEMP_COS.REGION_PREFIX_MAP[region] || constant_1.SCF_TEMP_COS.DEFAULT_REGION_PREFIX;
1240
1243
  const tempCosObjectName = `/${cosDate}/${objectPath}`;
1241
1244
  const uploadParams = {
1242
- Bucket: `shtempcos-${constant_1.SCF_TEMP_COS.APPID}`,
1245
+ Bucket: `${regionPrefix}tempcos-${constant_1.SCF_TEMP_COS.APPID}`,
1243
1246
  Key: tempCosObjectName,
1244
- Region: constant_1.SCF_TEMP_COS.REGION,
1247
+ Region: region,
1245
1248
  FilePath: zipFilePath,
1246
1249
  };
1247
1250
  const cos = new cos_nodejs_sdk_v5_1.default({
@@ -1384,9 +1387,10 @@ class FunctionService {
1384
1387
  }
1385
1388
  // 默认走 COS 上传
1386
1389
  console.log(`[${func.name}] 部署方式: COS 上传`);
1390
+ const region = this.environment.cloudBaseContext.region || constant_1.SCF_TEMP_COS.DEFAULT_REGION;
1387
1391
  const legacyResult = await this.uploadFunctionZipToCosLegacy(options, installDependency);
1388
1392
  return {
1389
- CosBucketRegion: constant_1.SCF_TEMP_COS.REGION,
1393
+ CosBucketRegion: region,
1390
1394
  TempCosObjectName: `/${legacyResult.Key}`
1391
1395
  };
1392
1396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.10.0",
3
+ "version": "4.10.1",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -50,5 +50,7 @@ export declare const COS_SDK_PROTOCOL: string;
50
50
  export declare const COS_SDK_KEEPALIVE: string;
51
51
  export declare const SCF_TEMP_COS: {
52
52
  APPID: string;
53
- REGION: string;
53
+ REGION_PREFIX_MAP: Record<string, string>;
54
+ DEFAULT_REGION_PREFIX: string;
55
+ DEFAULT_REGION: string;
54
56
  };