@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 +9 -1
- package/lib/function/index.js +7 -3
- package/package.json +1 -1
- package/types/constant.d.ts +3 -1
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
|
-
|
|
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
|
};
|
package/lib/function/index.js
CHANGED
|
@@ -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:
|
|
1245
|
+
Bucket: `${regionPrefix}tempcos-${constant_1.SCF_TEMP_COS.APPID}`,
|
|
1243
1246
|
Key: tempCosObjectName,
|
|
1244
|
-
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:
|
|
1393
|
+
CosBucketRegion: region,
|
|
1390
1394
|
TempCosObjectName: `/${legacyResult.Key}`
|
|
1391
1395
|
};
|
|
1392
1396
|
}
|
package/package.json
CHANGED
package/types/constant.d.ts
CHANGED
|
@@ -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
|
-
|
|
53
|
+
REGION_PREFIX_MAP: Record<string, string>;
|
|
54
|
+
DEFAULT_REGION_PREFIX: string;
|
|
55
|
+
DEFAULT_REGION: string;
|
|
54
56
|
};
|