@cloudbase/manager-node 5.8.3 → 5.8.5
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 +18 -0
- package/lib/cloudrun/index.js +9 -5
- package/lib/deploy/DeployOrchestrator.js +165 -287
- package/lib/deploy/FunctionDeployer.js +61 -33
- package/lib/deploy/function/artifact.js +55 -41
- package/lib/deploy/function/builders/cloud.js +13 -11
- package/lib/deploy/function/cam-preflight.js +2 -1
- package/lib/deploy/function/config-guard.js +181 -36
- package/lib/deploy/function/enterprise-tcr.js +7 -6
- package/lib/deploy/function/local-builder.js +10 -9
- package/lib/deploy/function/preflight.js +3 -2
- package/lib/projectValidator/index.js +0 -3
- package/package.json +1 -1
- package/types/cloudrun/index.d.ts +1 -1
- package/types/deploy/DeployOrchestrator.d.ts +9 -25
- package/types/deploy/FunctionDeployer.d.ts +15 -1
- package/types/deploy/function/artifact.d.ts +0 -5
- package/types/deploy/function/config-guard.d.ts +18 -0
- package/types/deploy/function/enterprise-tcr.d.ts +2 -2
- package/types/deploy/types.d.ts +76 -20
- package/types/projectValidator/types.d.ts +0 -1
- package/lib/deploy/StateStore.js +0 -328
- package/types/deploy/StateStore.d.ts +0 -174
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/** hosting 文件指纹(hash + size;size 用于懒加载 diff 预判,避免为未变文件重复读内容) */
|
|
2
|
-
export interface IHostingFileFingerprint {
|
|
3
|
-
hash: string;
|
|
4
|
-
size: number;
|
|
5
|
-
}
|
|
6
|
-
/** 快照中指纹值:兼容旧格式(纯 string = 仅 hash,size 未知) */
|
|
7
|
-
export type HostingFileValue = string | IHostingFileFingerprint;
|
|
8
|
-
/** hosting 状态快照条目(产物指纹,不存文件内容) */
|
|
9
|
-
export interface IHostingStateEntry {
|
|
10
|
-
name: string;
|
|
11
|
-
deployPath?: string;
|
|
12
|
-
/** 相对路径 → 文件指纹(兼容旧格式:纯字符串 = 仅 hash,size 未知) */
|
|
13
|
-
files: Record<string, HostingFileValue>;
|
|
14
|
-
}
|
|
15
|
-
/** hosting 文件级 diff 结果(懒加载:size 预判 + 按需 hash) */
|
|
16
|
-
export interface IHostingFileDiff {
|
|
17
|
-
added: string[];
|
|
18
|
-
modified: string[];
|
|
19
|
-
deleted: string[];
|
|
20
|
-
totalChanged: number;
|
|
21
|
-
/** 本地与快照完全一致(可跳过部署) */
|
|
22
|
-
unchanged: boolean;
|
|
23
|
-
/** true = 文件数超过指纹上限,diff 被放弃,需降级为全量部署 */
|
|
24
|
-
overLimit?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/** hosting 指纹扫描选项 */
|
|
27
|
-
export interface IHostingScanOptions {
|
|
28
|
-
/** 指纹文件数上限:超过则抛 HostingFilesOverLimitError(默认 50000;0 = 不限) */
|
|
29
|
-
maxFiles?: number;
|
|
30
|
-
/** hash 截断长度(hex 位数,默认 16;64 = 完整 sha256) */
|
|
31
|
-
hashLength?: number;
|
|
32
|
-
}
|
|
33
|
-
/** diffHostingFiles 选项(继承扫描选项,追加忽略规则) */
|
|
34
|
-
export interface IHostingDiffOptions extends IHostingScanOptions {
|
|
35
|
-
/** 自定义忽略规则(追加到默认 node_modules / .DS_Store 之后) */
|
|
36
|
-
ignore?: string[];
|
|
37
|
-
}
|
|
38
|
-
/** hosting 指纹文件数超过上限时抛出(触发降级为全量部署) */
|
|
39
|
-
export declare class HostingFilesOverLimitError extends Error {
|
|
40
|
-
fileCount: number;
|
|
41
|
-
limit: number;
|
|
42
|
-
constructor(fileCount: number, limit: number);
|
|
43
|
-
}
|
|
44
|
-
/** 默认指纹文件数上限(防快照膨胀与 I/O 失控) */
|
|
45
|
-
export declare const DEFAULT_MAX_HOSTING_FILES = 50000;
|
|
46
|
-
/** 默认 hash 截断长度(16 位 hex = 64bit,碰撞概率可忽略;快照体积减半) */
|
|
47
|
-
export declare const DEFAULT_HASH_LENGTH = 16;
|
|
48
|
-
/** app 状态快照条目(仅 diff 相关字段,不写 envVariables 等敏感信息) */
|
|
49
|
-
export interface IAppStateEntry {
|
|
50
|
-
serviceName?: string;
|
|
51
|
-
installCommand?: string;
|
|
52
|
-
buildCommand?: string;
|
|
53
|
-
outputDir?: string;
|
|
54
|
-
deployPath?: string;
|
|
55
|
-
}
|
|
56
|
-
/** 部署状态快照(.cloudbase/state.json) */
|
|
57
|
-
export interface IDeployState {
|
|
58
|
-
version: number;
|
|
59
|
-
updatedAt: string;
|
|
60
|
-
gitCommit?: string;
|
|
61
|
-
/** 写入快照时的目标环境 ID:跨环境切换(如上海 → 新加坡)后旧快照不可信,skip 判定强制失效 */
|
|
62
|
-
envId?: string;
|
|
63
|
-
resources: {
|
|
64
|
-
hosting?: IHostingStateEntry[];
|
|
65
|
-
gateway?: unknown;
|
|
66
|
-
app?: IAppStateEntry;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
interface IStateStoreOptions {
|
|
70
|
-
/** 项目根目录(默认 process.cwd()) */
|
|
71
|
-
cwd?: string;
|
|
72
|
-
/** 环境名(--env production 等):按环境分文件 state.{env}.json */
|
|
73
|
-
env?: string;
|
|
74
|
-
/** 自定义 state 路径(优先于 cwd+env 推导) */
|
|
75
|
-
stateFile?: string;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 部署状态快照(StateStore)
|
|
79
|
-
*
|
|
80
|
-
* 职责:读写 `.cloudbase/state.json`(默认),为 dry-run 的 hosting/app diff 提供本地基准,
|
|
81
|
-
* 避免每次 diff 都拉取云端。
|
|
82
|
-
*
|
|
83
|
-
* 指纹算法:hosting = 产物目录逐文件内容 sha256(相对路径为 key)。
|
|
84
|
-
* 只存 hash 不存内容,体积 = O(文件数);app 快照不写入 envVariables(敏感过滤)。
|
|
85
|
-
*/
|
|
86
|
-
export declare class StateStore {
|
|
87
|
-
private cwd;
|
|
88
|
-
private env?;
|
|
89
|
-
private stateFile?;
|
|
90
|
-
constructor(options?: IStateStoreOptions);
|
|
91
|
-
/**
|
|
92
|
-
* 计算 state 文件路径:
|
|
93
|
-
* - 自定义 stateFile 优先
|
|
94
|
-
* - 否则 {cwd}/.cloudbase/state.json(无 env)或 state.{env}.json(多环境隔离)
|
|
95
|
-
*/
|
|
96
|
-
getFilePath(): string;
|
|
97
|
-
/**
|
|
98
|
-
* 读取状态快照;文件不存在或 JSON 损坏返回 null(缺失降级,由调用方走云端兜底)
|
|
99
|
-
*/
|
|
100
|
-
read(): IDeployState | null;
|
|
101
|
-
/**
|
|
102
|
-
* 写入状态快照(自动补 version/updatedAt/gitCommit,自动创建 .cloudbase 目录)
|
|
103
|
-
*/
|
|
104
|
-
write(state: {
|
|
105
|
-
resources: IDeployState['resources'];
|
|
106
|
-
gitCommit?: string;
|
|
107
|
-
/** 本次部署的目标环境 ID(用于跨环境切换时使旧快照 skip 判定失效) */
|
|
108
|
-
envId?: string;
|
|
109
|
-
}): void;
|
|
110
|
-
/**
|
|
111
|
-
* 计算产物目录逐文件 sha256 指纹(仅 hash,兼容旧调用)
|
|
112
|
-
*
|
|
113
|
-
* @param projectPath 产物目录(hosting 的 outputDir / root)
|
|
114
|
-
* @param ignore 自定义忽略规则(追加到默认 node_modules / .DS_Store 之后)
|
|
115
|
-
* @param options 扫描选项(maxFiles / hashLength)
|
|
116
|
-
* @returns 相对路径(/ 分隔)→ 文件内容 sha256(默认截断 16 位)
|
|
117
|
-
*/
|
|
118
|
-
computeHostingFiles(projectPath: string, ignore?: string[], options?: IHostingScanOptions): Promise<Record<string, string>>;
|
|
119
|
-
/**
|
|
120
|
-
* 计算产物目录逐文件指纹(hash + size)
|
|
121
|
-
*
|
|
122
|
-
* - 强制忽略 node_modules / .DS_Store(与传入 ignore 合并,不可关闭)
|
|
123
|
-
* - hash 默认截断为 16 位 hex(hashLength 可调,64 = 完整 sha256)
|
|
124
|
-
* - 文件数超过 maxFiles 抛 HostingFilesOverLimitError(防快照膨胀与 I/O 失控)
|
|
125
|
-
*
|
|
126
|
-
* @param projectPath 产物目录(hosting 的 outputDir / root)
|
|
127
|
-
* @param ignore 自定义忽略规则
|
|
128
|
-
* @param options 扫描选项(maxFiles / hashLength)
|
|
129
|
-
* @returns 相对路径(/ 分隔)→ { hash, size }
|
|
130
|
-
*/
|
|
131
|
-
computeHostingFingerprints(projectPath: string, ignore?: string[], options?: IHostingScanOptions): Promise<Record<string, IHostingFileFingerprint>>;
|
|
132
|
-
/**
|
|
133
|
-
* 计算产物目录与快照的变更集(懒加载)
|
|
134
|
-
*
|
|
135
|
-
* 优化:先 stat 拿 size,size 与快照不同的文件直接判定变更(不读文件内容),
|
|
136
|
-
* 只有 size 相同(或旧快照 size 未知)的文件才读内容 hash 对比,
|
|
137
|
-
* 避免为未变文件做无谓的 I/O 与 hash。
|
|
138
|
-
* 文件数超过 maxFiles 时放弃 diff,返回 overLimit=true(调用方应降级为全量部署)。
|
|
139
|
-
*
|
|
140
|
-
* @param projectPath 产物目录(hosting 的 outputDir / root)
|
|
141
|
-
* @param previous 上次快照指纹(undefined = 首次部署,全部视为新增)
|
|
142
|
-
* @param options 选项(ignore / maxFiles / hashLength)
|
|
143
|
-
*/
|
|
144
|
-
diffHostingFiles(projectPath: string, previous: Record<string, HostingFileValue> | undefined, options?: IHostingDiffOptions): Promise<IHostingFileDiff>;
|
|
145
|
-
/**
|
|
146
|
-
* 提取 app 配置快照(仅 diff 白名单字段)
|
|
147
|
-
* envVariables / ignore 等非 diff 字段与敏感信息不进入快照
|
|
148
|
-
*/
|
|
149
|
-
buildAppConfig(config: {
|
|
150
|
-
serviceName?: string;
|
|
151
|
-
installCommand?: string;
|
|
152
|
-
buildCommand?: string;
|
|
153
|
-
outputDir?: string;
|
|
154
|
-
deployPath?: string;
|
|
155
|
-
[key: string]: unknown;
|
|
156
|
-
}): IAppStateEntry | undefined;
|
|
157
|
-
private hashFile;
|
|
158
|
-
/** 合并默认忽略规则(node_modules / .DS_Store 不可被调用方关闭) */
|
|
159
|
-
private mergeIgnore;
|
|
160
|
-
/** 归一化快照指纹值:旧格式(纯 string = 仅 hash,size 未知用 -1 表示) */
|
|
161
|
-
private normalizeFileValue;
|
|
162
|
-
/**
|
|
163
|
-
* 是否命中忽略规则:
|
|
164
|
-
* - 目录模式(结尾 /):匹配该目录及其下所有
|
|
165
|
-
* - glob(含 **):转换为正则匹配相对路径
|
|
166
|
-
* - 其余:精确/前缀匹配
|
|
167
|
-
*/
|
|
168
|
-
private isIgnored;
|
|
169
|
-
private matchPattern;
|
|
170
|
-
private escapeRegExp;
|
|
171
|
-
/** 解析当前 git commit(非 git 仓库或失败返回 undefined,不阻断) */
|
|
172
|
-
private resolveGitCommit;
|
|
173
|
-
}
|
|
174
|
-
export {};
|