@cloudbase/manager-node 5.0.0 → 5.1.0
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/cloudbase-manager-node/.claude/settings.local.json +9 -0
- package/cloudbase-manager-node/.editorconfig +8 -0
- package/cloudbase-manager-node/.eslintignore +3 -0
- package/cloudbase-manager-node/.eslintrc.js +27 -0
- package/cloudbase-manager-node/.prettierrc.js +31 -0
- package/cloudbase-manager-node/CHANGELOG.md +109 -0
- package/cloudbase-manager-node/LICENSE +6 -0
- package/cloudbase-manager-node/README.md +46 -0
- package/cloudbase-manager-node/jest.config.js +18 -0
- package/cloudbase-manager-node/package.json +70 -0
- package/cloudbase-manager-node/scripts/link.js +98 -0
- package/cloudbase-manager-node/tsconfig.json +19 -0
- package/cloudbase-manager-node/tsconfig.test.json +14 -0
- package/lib/env/index.js +135 -1
- package/lib/function/index.js +20 -14
- package/package.json +1 -1
- package/types/env/index.d.ts +586 -1
- package/types/function/index.d.ts +5 -4
package/lib/function/index.js
CHANGED
|
@@ -1477,14 +1477,16 @@ class FunctionService {
|
|
|
1477
1477
|
});
|
|
1478
1478
|
}
|
|
1479
1479
|
/**
|
|
1480
|
-
* 通过
|
|
1480
|
+
* 通过 SCF COS 上传方式(通过 GetTempCosInfo + COS SDK 上传)
|
|
1481
1481
|
* 返回 TempCosObjectName 用于创建/更新函数
|
|
1482
1482
|
*/
|
|
1483
|
-
async
|
|
1483
|
+
async uploadFunctionZipToCos(options, installDependency) {
|
|
1484
1484
|
const { func, functionPath, functionRootPath } = options;
|
|
1485
|
-
const { env } = this.getFunctionConfig();
|
|
1486
|
-
|
|
1487
|
-
|
|
1485
|
+
const { env, appId } = this.getFunctionConfig();
|
|
1486
|
+
if (!appId) {
|
|
1487
|
+
throw new error_1.CloudBaseError('无法获取 AppId,请确认环境已开通存储服务');
|
|
1488
|
+
}
|
|
1489
|
+
const objectPath = `${appId}/${env}/${func.name}.zip`;
|
|
1488
1490
|
// 1. 生成存放函数包的临时 Cos 目录
|
|
1489
1491
|
const { Date: cosDate, Sign } = await this.scfService.request('GetTempCosInfo', {
|
|
1490
1492
|
ObjectPath: `${objectPath}`
|
|
@@ -1545,10 +1547,11 @@ class FunctionService {
|
|
|
1545
1547
|
});
|
|
1546
1548
|
}
|
|
1547
1549
|
/**
|
|
1548
|
-
*
|
|
1550
|
+
* 旧的 COS 上传方式(通过 DescribeBuildServiceCosInfo + PUT 上传)
|
|
1549
1551
|
* 返回 CosTimestamp 用于创建/更新函数
|
|
1552
|
+
* @deprecated 请使用 uploadFunctionZipToCos 代替
|
|
1550
1553
|
*/
|
|
1551
|
-
async
|
|
1554
|
+
async uploadFunctionZipToCosLegacy(options, installDependency) {
|
|
1552
1555
|
const { func, functionPath, functionRootPath } = options;
|
|
1553
1556
|
const { env } = this.getFunctionConfig();
|
|
1554
1557
|
// 1. 生成存放函数包的临时 Cos 目录
|
|
@@ -1649,13 +1652,13 @@ class FunctionService {
|
|
|
1649
1652
|
ZipFile: base64
|
|
1650
1653
|
};
|
|
1651
1654
|
}
|
|
1652
|
-
// 默认走 COS
|
|
1655
|
+
// 默认走 COS 上传(GetTempCosInfo + COS SDK)
|
|
1653
1656
|
console.log(`[${func.name}] 部署方式: COS 上传`);
|
|
1654
1657
|
const region = this.environment.cloudBaseContext.region || constant_1.SCF_TEMP_COS.DEFAULT_REGION;
|
|
1655
|
-
const
|
|
1658
|
+
const result = await this.uploadFunctionZipToCos(options, installDependency);
|
|
1656
1659
|
return {
|
|
1657
1660
|
CosBucketRegion: region,
|
|
1658
|
-
TempCosObjectName: `/${
|
|
1661
|
+
TempCosObjectName: `/${result.Key}`
|
|
1659
1662
|
};
|
|
1660
1663
|
}
|
|
1661
1664
|
async createAccessPath(name, path) {
|
|
@@ -1717,11 +1720,14 @@ class FunctionService {
|
|
|
1717
1720
|
* @memberof FunctionService
|
|
1718
1721
|
*/
|
|
1719
1722
|
getFunctionConfig() {
|
|
1720
|
-
var _a, _b, _c, _d;
|
|
1723
|
+
var _a, _b, _c, _d, _e;
|
|
1721
1724
|
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
1722
1725
|
// Functions 可能为空
|
|
1723
1726
|
const namespace = ((_b = (_a = envConfig.Functions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Namespace) || '';
|
|
1724
|
-
|
|
1727
|
+
// AppId 可能为空字符串,从 Bucket 名称中提取
|
|
1728
|
+
// COS Bucket 格式: {BucketName}-{APPID},APPID 为纯数字
|
|
1729
|
+
const storage = (_c = envConfig.Storages) === null || _c === void 0 ? void 0 : _c[0];
|
|
1730
|
+
const appId = (storage === null || storage === void 0 ? void 0 : storage.AppId) || ((_e = (_d = storage === null || storage === void 0 ? void 0 : storage.Bucket) === null || _d === void 0 ? void 0 : _d.match(/-(\d+)$/)) === null || _e === void 0 ? void 0 : _e[1]) || '';
|
|
1725
1731
|
const { proxy } = this.environment.cloudBaseContext;
|
|
1726
1732
|
return {
|
|
1727
1733
|
proxy,
|
|
@@ -1882,10 +1888,10 @@ __decorate([
|
|
|
1882
1888
|
], FunctionService.prototype, "getFunctionAlias", null);
|
|
1883
1889
|
__decorate([
|
|
1884
1890
|
(0, utils_1.preLazy)()
|
|
1885
|
-
], FunctionService.prototype, "
|
|
1891
|
+
], FunctionService.prototype, "uploadFunctionZipToCos", null);
|
|
1886
1892
|
__decorate([
|
|
1887
1893
|
(0, utils_1.preLazy)()
|
|
1888
|
-
], FunctionService.prototype, "
|
|
1894
|
+
], FunctionService.prototype, "uploadFunctionZipToCosLegacy", null);
|
|
1889
1895
|
__decorate([
|
|
1890
1896
|
(0, utils_1.preLazy)()
|
|
1891
1897
|
], FunctionService.prototype, "getCodeParams", null);
|