@cloudbase/manager-node 4.9.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/cloudrun/index.js +10 -0
- package/lib/constant.js +9 -1
- package/lib/function/index.js +7 -3
- package/package.json +1 -1
- package/types/cloudrun/index.d.ts +4 -1
- package/types/cloudrun/type.d.ts +9 -0
- package/types/constant.d.ts +3 -1
package/lib/cloudrun/index.js
CHANGED
|
@@ -401,6 +401,13 @@ class CloudRunService {
|
|
|
401
401
|
Offset: 0,
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
+
async getProcessLog(params) {
|
|
405
|
+
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
406
|
+
return this.tcbrService.request('DescribeCloudRunProcessLog', {
|
|
407
|
+
EnvId: envConfig.EnvId,
|
|
408
|
+
RunId: params.RunId,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
404
411
|
}
|
|
405
412
|
exports.CloudRunService = CloudRunService;
|
|
406
413
|
__decorate([
|
|
@@ -436,6 +443,9 @@ __decorate([
|
|
|
436
443
|
__decorate([
|
|
437
444
|
(0, utils_1.preLazy)()
|
|
438
445
|
], CloudRunService.prototype, "getBuildLog", null);
|
|
446
|
+
__decorate([
|
|
447
|
+
(0, utils_1.preLazy)()
|
|
448
|
+
], CloudRunService.prototype, "getProcessLog", null);
|
|
439
449
|
async function codeToZip(cwd, options) {
|
|
440
450
|
const archive = (0, archiver_1.default)('zip', {
|
|
441
451
|
zlib: { level: 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo } from '../interfaces';
|
|
3
|
-
import { CloudrunServerType, ICloudrunDetailResponse, ICloudrunListResponse, ICloudrunServerBaseConfig, ICloudrunServerBaseInfo, IBuildLogResponse, IDiffConfigItem, ITemplate, ReleaseTypeEnum, IDescribeCloudRunDeployRecordResponse } from './type';
|
|
3
|
+
import { CloudrunServerType, ICloudrunDetailResponse, ICloudrunListResponse, ICloudrunServerBaseConfig, ICloudrunServerBaseInfo, IBuildLogResponse, IProcessLogResponse, IDiffConfigItem, ITemplate, ReleaseTypeEnum, IDescribeCloudRunDeployRecordResponse } from './type';
|
|
4
4
|
/**
|
|
5
5
|
* 云托管服务管理类
|
|
6
6
|
* 提供云托管服务的初始化、下载、列表查询和删除等功能
|
|
@@ -147,6 +147,9 @@ export declare class CloudRunService {
|
|
|
147
147
|
serverName: string;
|
|
148
148
|
buildId?: number;
|
|
149
149
|
}): Promise<IBuildLogResponse>;
|
|
150
|
+
getProcessLog(params: {
|
|
151
|
+
RunId: string;
|
|
152
|
+
}): Promise<IProcessLogResponse>;
|
|
150
153
|
}
|
|
151
154
|
export declare function codeToZip(cwd: string, options?: {
|
|
152
155
|
installDependency?: boolean;
|
package/types/cloudrun/type.d.ts
CHANGED
|
@@ -460,3 +460,12 @@ export interface IBuildLogResponse {
|
|
|
460
460
|
Log: IBuildLog;
|
|
461
461
|
RequestId: string;
|
|
462
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* DescribeCloudRunProcessLog 响应
|
|
465
|
+
*/
|
|
466
|
+
export interface IProcessLogResponse {
|
|
467
|
+
/** 日志内容数组 */
|
|
468
|
+
Logs: string[];
|
|
469
|
+
/** 请求ID */
|
|
470
|
+
RequestId: string;
|
|
471
|
+
}
|
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
|
};
|