@cloudbase/manager-node 5.8.4 → 5.8.6
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/CHANGELOG.md +15 -0
- package/lib/cloudrun/index.js +9 -5
- package/lib/deploy/StaticDeployer.js +12 -18
- package/lib/deploy/framework.js +34 -0
- package/lib/function/index.js +2 -3
- package/lib/index.js +12 -0
- package/package.json +1 -1
- package/types/cloudrun/index.d.ts +1 -1
- package/types/deploy/StaticDeployer.d.ts +7 -3
- package/types/deploy/framework.d.ts +13 -0
- package/types/index.d.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## @cloudbase/manager-node v5.8.5 版本发布 🚀(2026-09-07)
|
|
2
|
+
|
|
3
|
+
- 新增 deploy 支持自定义 OpenAccessTypes 访问类型(默认值兜底,兼容存量调用)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## @cloudbase/manager-node v5.8.4 版本发布 🚀(2026-09-02)
|
|
8
|
+
|
|
9
|
+
- 新增 move declarative image config preparation to manager
|
|
10
|
+
- 新增 移除本地 state 快照与 skip 判定
|
|
11
|
+
- 重构 ProjectValidator 移除 version 字段
|
|
12
|
+
- 修复 resolve build context path and fix Rego package declaration
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
1
16
|
## @cloudbase/manager-node v5.8.3 版本发布 🚀(2026-08-28)
|
|
2
17
|
|
|
3
18
|
- 新增 完善云函数镜像部署闭环
|
package/lib/cloudrun/index.js
CHANGED
|
@@ -17,6 +17,10 @@ const fs_extra_1 = require("fs-extra");
|
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
19
|
const type_1 = require("./type");
|
|
20
|
+
/**
|
|
21
|
+
* 默认开放访问类型(serverConfig.OpenAccessTypes 未显式传入时使用)
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_OPEN_ACCESS_TYPES = ['OA', 'PUBLIC', 'MINIAPP'];
|
|
20
24
|
/**
|
|
21
25
|
* 云托管服务管理类
|
|
22
26
|
* 提供云托管服务的初始化、下载、列表查询和删除等功能
|
|
@@ -331,7 +335,7 @@ class CloudRunService {
|
|
|
331
335
|
* @param {string} params.serverName 要部署的服务名称
|
|
332
336
|
* @param {string} params.targetPath 本地代码路径
|
|
333
337
|
* @param {Object} [params.serverConfig] 服务配置项(可选)
|
|
334
|
-
* @param {string[]} [params.serverConfig.OpenAccessTypes]
|
|
338
|
+
* @param {string[]} [params.serverConfig.OpenAccessTypes] 开放访问类型,不传时默认 ['OA', 'PUBLIC', 'MINIAPP']
|
|
335
339
|
* @param {number} [params.serverConfig.Cpu] CPU规格
|
|
336
340
|
* @param {number} [params.serverConfig.Mem] 内存规格
|
|
337
341
|
* @param {number} [params.serverConfig.MinNum] 最小实例数
|
|
@@ -349,7 +353,7 @@ class CloudRunService {
|
|
|
349
353
|
* @returns {Promise<IResponseInfo>} 返回部署操作的响应信息
|
|
350
354
|
*/
|
|
351
355
|
async deploy(params) {
|
|
352
|
-
var _a;
|
|
356
|
+
var _a, _b, _c;
|
|
353
357
|
const { serverName, targetPath = process.cwd(), serverConfig, vpcInfo, imageUrl } = params;
|
|
354
358
|
/**
|
|
355
359
|
* 参数校验和默认值设置
|
|
@@ -401,7 +405,7 @@ class CloudRunService {
|
|
|
401
405
|
if (await this._checkFunctionExist(serverName)) {
|
|
402
406
|
// 更新
|
|
403
407
|
const serverDetail = await this.detail({ serverName });
|
|
404
|
-
const _serverConfig = Object.assign(Object.assign(Object.assign({}, serverConfig), { OpenAccessTypes:
|
|
408
|
+
const _serverConfig = Object.assign(Object.assign(Object.assign({}, serverConfig), { OpenAccessTypes: (_a = serverConfig === null || serverConfig === void 0 ? void 0 : serverConfig.OpenAccessTypes) !== null && _a !== void 0 ? _a : DEFAULT_OPEN_ACCESS_TYPES }), ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:' ? { Port: 3000 } : {}) // 函数型不能指定端口,需要固定为3000
|
|
405
409
|
);
|
|
406
410
|
if ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:') {
|
|
407
411
|
deployInfo.BuildPacks = {
|
|
@@ -409,7 +413,7 @@ class CloudRunService {
|
|
|
409
413
|
RepoLanguage: 'Node.js'
|
|
410
414
|
};
|
|
411
415
|
}
|
|
412
|
-
deployInfo.ReleaseType = ((
|
|
416
|
+
deployInfo.ReleaseType = ((_b = params.deployInfo) === null || _b === void 0 ? void 0 : _b.ReleaseType) || "FULL";
|
|
413
417
|
return this._upsertFunction(false, {
|
|
414
418
|
name: serverName,
|
|
415
419
|
deployInfo,
|
|
@@ -436,7 +440,7 @@ class CloudRunService {
|
|
|
436
440
|
RepoLanguage: 'Node.js'
|
|
437
441
|
};
|
|
438
442
|
}
|
|
439
|
-
const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes:
|
|
443
|
+
const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes: (_c = serverConfig === null || serverConfig === void 0 ? void 0 : serverConfig.OpenAccessTypes) !== null && _c !== void 0 ? _c : DEFAULT_OPEN_ACCESS_TYPES,
|
|
440
444
|
// Cpu: 0,
|
|
441
445
|
// Mem: 0,
|
|
442
446
|
MinNum: 0,
|
|
@@ -52,7 +52,8 @@ class StaticDeployer {
|
|
|
52
52
|
/**
|
|
53
53
|
* hosting 部署(固定静态流程,不写版本记录)
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* 支持本地构建:buildCommand 非空时自动执行 build 后上传产物(依赖由用户自行安装,
|
|
56
|
+
* 不代为执行 npm install);
|
|
56
57
|
* 纯静态(buildCommand 空/未配置且无法检测框架)时直接上传 outputDir(默认 root,保持现状)。
|
|
57
58
|
* 访问地址 = https://{CdnDomain}{deployPath}(与 tcb hosting deploy 一致)
|
|
58
59
|
*/
|
|
@@ -63,7 +64,7 @@ class StaticDeployer {
|
|
|
63
64
|
const cloudPath = config.deployPath || '/';
|
|
64
65
|
// 1. 解析构建命令:显式 buildCommand > framework 映射 > package.json 自动探测 > null(纯静态)
|
|
65
66
|
const buildCommand = (0, framework_1.resolveBuildCommand)(config, root);
|
|
66
|
-
// 2. 有构建命令 →
|
|
67
|
+
// 2. 有构建命令 → 本地构建(仅 build,依赖由用户自行安装);纯静态 → 跳过构建直接上传
|
|
67
68
|
if (buildCommand) {
|
|
68
69
|
this.runLocalBuild(root, Object.assign(Object.assign({}, config), { buildCommand }), config.envVariables);
|
|
69
70
|
}
|
|
@@ -188,34 +189,27 @@ class StaticDeployer {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
/**
|
|
191
|
-
*
|
|
192
|
+
* 本地构建(仅执行 buildCommand,不安装依赖)
|
|
193
|
+
*
|
|
194
|
+
* 只跑用户的构建命令,依赖由用户自行安装(对齐业界:Vercel/Netlify/Cloudflare
|
|
195
|
+
* 均不在本地构建时代装依赖)。installCommand 不再被本地执行 —— CLI 侧通过
|
|
196
|
+
* installCommand: '' 已可跳过云端安装;本地一律不装。
|
|
192
197
|
*
|
|
193
|
-
* - installCommand:默认 npm install,显式空字符串跳过安装
|
|
194
198
|
* - buildCommand:由调用方保证非空(hosting 经 resolveBuildCommand 判定;app local 由 if 判定)
|
|
195
199
|
* - envVariables:注入构建进程环境变量(值统一转字符串)
|
|
196
200
|
*/
|
|
197
201
|
runLocalBuild(projectPath, config, envVariables) {
|
|
198
|
-
var _a;
|
|
199
|
-
const installCommand = (_a = config.installCommand) !== null && _a !== void 0 ? _a : 'npm install';
|
|
200
202
|
const buildCommand = config.buildCommand || '';
|
|
201
203
|
const env = Object.assign(Object.assign({}, process.env), stringifyEnvValues(envVariables));
|
|
202
|
-
const commands = [];
|
|
203
|
-
if (installCommand) {
|
|
204
|
-
commands.push({ cmd: installCommand, label: '安装依赖' });
|
|
205
|
-
}
|
|
206
|
-
if (buildCommand) {
|
|
207
|
-
commands.push({ cmd: buildCommand, label: '构建' });
|
|
208
|
-
}
|
|
209
204
|
try {
|
|
210
|
-
|
|
211
|
-
(0, child_process_1.execSync)(
|
|
205
|
+
if (buildCommand) {
|
|
206
|
+
(0, child_process_1.execSync)(buildCommand, { cwd: projectPath, stdio: 'inherit', env });
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
209
|
catch (e) {
|
|
215
210
|
const detail = ((e === null || e === void 0 ? void 0 : e.stderr) || (e === null || e === void 0 ? void 0 : e.stdout) || (e === null || e === void 0 ? void 0 : e.message) || String(e)).toString().trim();
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
`请先在项目目录手动执行该命令排查原因(常见原因:npm registry 网络不可达、依赖安装权限、lockfile 不一致)。\n` +
|
|
211
|
+
throw new error_1.CloudBaseError(`本地构建失败:在 ${projectPath} 执行「${buildCommand}」失败。\n` +
|
|
212
|
+
`请先在项目目录手动执行该命令排查原因(常见原因:构建脚本报错、依赖未安装、lockfile 不一致)。\n` +
|
|
219
213
|
(detail ? `原始错误:${detail.slice(0, 500)}` : ''));
|
|
220
214
|
}
|
|
221
215
|
}
|
package/lib/deploy/framework.js
CHANGED
|
@@ -38,8 +38,10 @@ exports.detectFramework = detectFramework;
|
|
|
38
38
|
exports.resolveBuildCommand = resolveBuildCommand;
|
|
39
39
|
exports.resolveOutputDir = resolveOutputDir;
|
|
40
40
|
exports.resolveHostingOutputDir = resolveHostingOutputDir;
|
|
41
|
+
exports.buildHostingItem = buildHostingItem;
|
|
41
42
|
const fs = __importStar(require("fs"));
|
|
42
43
|
const path = __importStar(require("path"));
|
|
44
|
+
const child_process_1 = require("child_process");
|
|
43
45
|
/**
|
|
44
46
|
* 框架 → 默认构建命令映射(hosting 本地构建 / app 云端构建复用)
|
|
45
47
|
*/
|
|
@@ -228,3 +230,35 @@ function resolveHostingOutputDir(config, root, readPkgFile = defaultReadPkgFile)
|
|
|
228
230
|
}
|
|
229
231
|
return config.outputDir ? path.resolve(root, config.outputDir) : root;
|
|
230
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* 本地构建单个 hosting 项(仅执行 buildCommand,不安装依赖,不上传)
|
|
235
|
+
*
|
|
236
|
+
* 从 StaticDeployer.runLocalBuild 提炼的纯函数版:不依赖 Environment,
|
|
237
|
+
* 供 CLI 的 tcb app build 与任何需要「只构建不上传」的调用方复用,
|
|
238
|
+
* 避免各端各自复制推断/执行逻辑。buildCommand 为空 → 直接返回 null。
|
|
239
|
+
*
|
|
240
|
+
* @param config hosting 项配置(framework/buildCommand/outputDir,root 单独传参)
|
|
241
|
+
* @param root 项目目录(绝对路径)
|
|
242
|
+
* @returns 构建产物目录(resolveHostingOutputDir 结果);无可构建命令返回 null
|
|
243
|
+
* @throws 构建失败时(含 stderr 摘要)
|
|
244
|
+
*/
|
|
245
|
+
function buildHostingItem(config, root, envVariables) {
|
|
246
|
+
const buildCommand = resolveBuildCommand(config, root);
|
|
247
|
+
if (!buildCommand) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const env = Object.assign({}, process.env);
|
|
251
|
+
if (envVariables) {
|
|
252
|
+
for (const [key, value] of Object.entries(envVariables)) {
|
|
253
|
+
env[key] = String(value);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
(0, child_process_1.execSync)(buildCommand, { cwd: root, stdio: 'inherit', env });
|
|
258
|
+
}
|
|
259
|
+
catch (e) {
|
|
260
|
+
const detail = ((e === null || e === void 0 ? void 0 : e.stderr) || (e === null || e === void 0 ? void 0 : e.stdout) || (e === null || e === void 0 ? void 0 : e.message) || String(e)).toString().trim();
|
|
261
|
+
throw new Error(`本地构建失败:在 ${root} 执行「${buildCommand}」失败。\n${detail.slice(0, 500)}`);
|
|
262
|
+
}
|
|
263
|
+
return resolveHostingOutputDir(config, root);
|
|
264
|
+
}
|
package/lib/function/index.js
CHANGED
|
@@ -1154,9 +1154,8 @@ class FunctionService {
|
|
|
1154
1154
|
const { functions, envId } = options;
|
|
1155
1155
|
const promises = functions.map(func => (async () => {
|
|
1156
1156
|
try {
|
|
1157
|
-
func.triggers.
|
|
1158
|
-
|
|
1159
|
-
});
|
|
1157
|
+
await Promise.all(func.triggers.map(trigger => this.deleteFunctionTrigger(func.name, trigger.name)));
|
|
1158
|
+
(0, utils_1.successLog)(`[${func.name}] 删除云函数触发器成功!`);
|
|
1160
1159
|
}
|
|
1161
1160
|
catch (e) {
|
|
1162
1161
|
throw new error_1.CloudBaseError(e.message);
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const environmentManager_1 = require("./environmentManager");
|
|
|
4
4
|
const docs_1 = require("./docs");
|
|
5
5
|
const projectValidator_1 = require("./projectValidator");
|
|
6
6
|
const DeployOrchestrator_1 = require("./deploy/DeployOrchestrator");
|
|
7
|
+
const framework_1 = require("./deploy/framework");
|
|
7
8
|
class CloudBase {
|
|
8
9
|
/**
|
|
9
10
|
* init 初始化 为单例
|
|
@@ -188,4 +189,15 @@ class CloudBase {
|
|
|
188
189
|
return this.context.isInternalEndpoint();
|
|
189
190
|
}
|
|
190
191
|
}
|
|
192
|
+
// export = 模块只能通过 namespace 合并附加类型(TS 惯用法,规则见下)
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
194
|
+
(function (CloudBase) {
|
|
195
|
+
/**
|
|
196
|
+
* 声明式 hosting 构建推断与执行(CLI 侧 tcb app build / hosting 中立化复用,
|
|
197
|
+
* 避免各端复制同一套 framework 推断逻辑)。均为纯函数,不依赖环境上下文。
|
|
198
|
+
*/
|
|
199
|
+
CloudBase.resolveHostingBuildCommand = framework_1.resolveBuildCommand;
|
|
200
|
+
CloudBase.resolveHostingOutputDir = framework_1.resolveHostingOutputDir;
|
|
201
|
+
CloudBase.buildHosting = framework_1.buildHostingItem;
|
|
202
|
+
})(CloudBase || (CloudBase = {}));
|
|
191
203
|
module.exports = CloudBase;
|
package/package.json
CHANGED
|
@@ -146,7 +146,7 @@ export declare class CloudRunService {
|
|
|
146
146
|
* @param {string} params.serverName 要部署的服务名称
|
|
147
147
|
* @param {string} params.targetPath 本地代码路径
|
|
148
148
|
* @param {Object} [params.serverConfig] 服务配置项(可选)
|
|
149
|
-
* @param {string[]} [params.serverConfig.OpenAccessTypes]
|
|
149
|
+
* @param {string[]} [params.serverConfig.OpenAccessTypes] 开放访问类型,不传时默认 ['OA', 'PUBLIC', 'MINIAPP']
|
|
150
150
|
* @param {number} [params.serverConfig.Cpu] CPU规格
|
|
151
151
|
* @param {number} [params.serverConfig.Mem] 内存规格
|
|
152
152
|
* @param {number} [params.serverConfig.MinNum] 最小实例数
|
|
@@ -69,7 +69,8 @@ export declare class StaticDeployer {
|
|
|
69
69
|
/**
|
|
70
70
|
* hosting 部署(固定静态流程,不写版本记录)
|
|
71
71
|
*
|
|
72
|
-
*
|
|
72
|
+
* 支持本地构建:buildCommand 非空时自动执行 build 后上传产物(依赖由用户自行安装,
|
|
73
|
+
* 不代为执行 npm install);
|
|
73
74
|
* 纯静态(buildCommand 空/未配置且无法检测框架)时直接上传 outputDir(默认 root,保持现状)。
|
|
74
75
|
* 访问地址 = https://{CdnDomain}{deployPath}(与 tcb hosting deploy 一致)
|
|
75
76
|
*/
|
|
@@ -94,9 +95,12 @@ export declare class StaticDeployer {
|
|
|
94
95
|
*/
|
|
95
96
|
private resolveHostingUrl;
|
|
96
97
|
/**
|
|
97
|
-
*
|
|
98
|
+
* 本地构建(仅执行 buildCommand,不安装依赖)
|
|
99
|
+
*
|
|
100
|
+
* 只跑用户的构建命令,依赖由用户自行安装(对齐业界:Vercel/Netlify/Cloudflare
|
|
101
|
+
* 均不在本地构建时代装依赖)。installCommand 不再被本地执行 —— CLI 侧通过
|
|
102
|
+
* installCommand: '' 已可跳过云端安装;本地一律不装。
|
|
98
103
|
*
|
|
99
|
-
* - installCommand:默认 npm install,显式空字符串跳过安装
|
|
100
104
|
* - buildCommand:由调用方保证非空(hosting 经 resolveBuildCommand 判定;app local 由 if 判定)
|
|
101
105
|
* - envVariables:注入构建进程环境变量(值统一转字符串)
|
|
102
106
|
*/
|
|
@@ -61,3 +61,16 @@ export declare function resolveOutputDir(config: IHostingOutputConfig, root: str
|
|
|
61
61
|
* - outputDir 未配置回退 root(纯静态直传)
|
|
62
62
|
*/
|
|
63
63
|
export declare function resolveHostingOutputDir(config: IHostingOutputConfig, root: string, readPkgFile?: ReadPkgFile): string;
|
|
64
|
+
/**
|
|
65
|
+
* 本地构建单个 hosting 项(仅执行 buildCommand,不安装依赖,不上传)
|
|
66
|
+
*
|
|
67
|
+
* 从 StaticDeployer.runLocalBuild 提炼的纯函数版:不依赖 Environment,
|
|
68
|
+
* 供 CLI 的 tcb app build 与任何需要「只构建不上传」的调用方复用,
|
|
69
|
+
* 避免各端各自复制推断/执行逻辑。buildCommand 为空 → 直接返回 null。
|
|
70
|
+
*
|
|
71
|
+
* @param config hosting 项配置(framework/buildCommand/outputDir,root 单独传参)
|
|
72
|
+
* @param root 项目目录(绝对路径)
|
|
73
|
+
* @returns 构建产物目录(resolveHostingOutputDir 结果);无可构建命令返回 null
|
|
74
|
+
* @throws 构建失败时(含 stderr 摘要)
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildHostingItem(config: IHostingOutputConfig, root: string, envVariables?: Record<string, string | number | boolean>): string | null;
|
package/types/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { IntegrationService } from './integration';
|
|
|
25
25
|
import { MonitorService } from './monitor';
|
|
26
26
|
import { ProjectValidator } from './projectValidator';
|
|
27
27
|
import { DeployOrchestrator } from './deploy/DeployOrchestrator';
|
|
28
|
+
import { resolveBuildCommand as frameworkResolveBuildCommand, resolveHostingOutputDir as frameworkResolveHostingOutputDir, buildHostingItem as frameworkBuildHostingItem } from './deploy/framework';
|
|
28
29
|
interface CloudBaseConfig {
|
|
29
30
|
secretId?: string;
|
|
30
31
|
secretKey?: string;
|
|
@@ -127,5 +128,12 @@ declare class CloudBase {
|
|
|
127
128
|
}
|
|
128
129
|
declare namespace CloudBase {
|
|
129
130
|
type RequestFn = CloudApiRequestFn;
|
|
131
|
+
/**
|
|
132
|
+
* 声明式 hosting 构建推断与执行(CLI 侧 tcb app build / hosting 中立化复用,
|
|
133
|
+
* 避免各端复制同一套 framework 推断逻辑)。均为纯函数,不依赖环境上下文。
|
|
134
|
+
*/
|
|
135
|
+
const resolveHostingBuildCommand: typeof frameworkResolveBuildCommand;
|
|
136
|
+
const resolveHostingOutputDir: typeof frameworkResolveHostingOutputDir;
|
|
137
|
+
const buildHosting: typeof frameworkBuildHostingItem;
|
|
130
138
|
}
|
|
131
139
|
export = CloudBase;
|