fe-deploy-kit 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +368 -2
- package/examples/deploy.config.example.json +24 -0
- package/examples/deploy.config.example.mjs +36 -0
- package/examples/github-actions.yml +64 -0
- package/package.json +57 -4
- package/src/build.js +241 -0
- package/src/cli.js +171 -0
- package/src/commands.js +174 -0
- package/src/config.js +388 -0
- package/src/core/flow.js +463 -0
- package/src/core/fs-ops.js +87 -0
- package/src/core/guard.js +321 -0
- package/src/core/memory-remote.js +196 -0
- package/src/core/remote.js +162 -0
- package/src/deploy.js +118 -0
- package/src/index.js +111 -0
- package/src/logger.js +54 -0
- package/src/prompts.js +67 -0
- package/src/ssh.js +249 -0
- package/src/state.js +79 -0
- package/types/index.d.ts +500 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fe-deploy-kit 类型声明。
|
|
3
|
+
*
|
|
4
|
+
* 配置分两层:
|
|
5
|
+
* - DeployConfig:你在 deploy.config.json / .mjs 里写的"原始配置";
|
|
6
|
+
* - ResolvedConfig:loadConfig 之后拿到的、路径已解析、默认值已填充的可执行配置。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* ------------------------------------------------------------------ */
|
|
10
|
+
/* 配置 */
|
|
11
|
+
/* ------------------------------------------------------------------ */
|
|
12
|
+
|
|
13
|
+
export interface BuildContext {
|
|
14
|
+
projectRoot: string;
|
|
15
|
+
cwd: string;
|
|
16
|
+
env: Record<string, string | undefined>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BuildCommandResult {
|
|
20
|
+
command: string;
|
|
21
|
+
args?: string[];
|
|
22
|
+
shell?: boolean;
|
|
23
|
+
label?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface BuildOptions {
|
|
27
|
+
/** 构建命令:字符串(走 shell)、[cmd, ...args]、或函数 */
|
|
28
|
+
command?: string | string[] | ((context: BuildContext) => string | BuildCommandResult | null | undefined);
|
|
29
|
+
args?: string[];
|
|
30
|
+
/** 构建目录,默认 projectRoot */
|
|
31
|
+
cwd?: string;
|
|
32
|
+
env?: Record<string, string>;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
/** vite 模式:等价于 vite build --mode <mode> */
|
|
35
|
+
mode?: string;
|
|
36
|
+
packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ValidateOptions {
|
|
40
|
+
/** 产物里必须有 index.html(默认 true) */
|
|
41
|
+
requireIndexHtml?: boolean;
|
|
42
|
+
/** index.html 里必须出现的资源前缀,例如 "/assets/";null 表示不检查 */
|
|
43
|
+
assetPrefix?: string | null;
|
|
44
|
+
/** 禁止上传的 glob 列表,默认 ['.env', '.env.*', '.git/**'] */
|
|
45
|
+
forbidPatterns?: string[];
|
|
46
|
+
/** 发现 .map 文件时是否警告,默认 true */
|
|
47
|
+
warnOnSourcemaps?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface EnvNames {
|
|
51
|
+
/** 密码环境变量名,默认 DEPLOY_PASSWORD */
|
|
52
|
+
password?: string;
|
|
53
|
+
/** 私钥口令环境变量名,默认 DEPLOY_KEY_PASSPHRASE */
|
|
54
|
+
keyPassphrase?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface DeployConfig {
|
|
58
|
+
/** 服务器地址(IP 或域名) */
|
|
59
|
+
host: string;
|
|
60
|
+
/** SSH 端口,默认 22 */
|
|
61
|
+
port?: number;
|
|
62
|
+
/** 登录账号 */
|
|
63
|
+
username: string;
|
|
64
|
+
/** 允许操作范围的根目录(必须是项目自己的目录,不能是 /www 这类公共目录) */
|
|
65
|
+
remoteRoot: string;
|
|
66
|
+
/** 站点产物目录,必须严格位于 remoteRoot 内部 */
|
|
67
|
+
remotePath: string;
|
|
68
|
+
/** 服务器主机公钥指纹(SHA256:...),首次 check/deploy 会提示记录 */
|
|
69
|
+
hostFingerprint?: string | null;
|
|
70
|
+
/** 私钥文件路径(相对配置文件目录,支持 ~) */
|
|
71
|
+
keyFile?: string | null;
|
|
72
|
+
/** 保留几份备份,默认 5(0-50) */
|
|
73
|
+
keepBackups?: number;
|
|
74
|
+
/** 部署标识,默认取 remotePath 最后一段;备份/暂存目录为 <remoteRoot>/.deploy/<appName> */
|
|
75
|
+
appName?: string;
|
|
76
|
+
/** 发布时保持不动的文件/目录名,默认 ['.htaccess', '.user.ini', '.well-known'] */
|
|
77
|
+
preserve?: string[];
|
|
78
|
+
/** 发布后把目录设为 755、文件设为 644 */
|
|
79
|
+
setPermissions?: boolean;
|
|
80
|
+
/** 项目根目录(相对配置文件所在目录),默认配置文件所在目录 */
|
|
81
|
+
projectRoot?: string;
|
|
82
|
+
/** 构建产物目录(相对构建目录),默认 dist */
|
|
83
|
+
dist?: string;
|
|
84
|
+
/** 构建配置;false 表示跳过构建 */
|
|
85
|
+
build?: BuildOptions | string | string[] | false | null;
|
|
86
|
+
/** 兼容老配置:等价于 build.mode */
|
|
87
|
+
buildMode?: string;
|
|
88
|
+
/** 产物校验规则 */
|
|
89
|
+
validate?: ValidateOptions;
|
|
90
|
+
/** 凭据环境变量名 */
|
|
91
|
+
env?: EnvNames;
|
|
92
|
+
/** 本地状态目录(锁 / 上次部署 / 备份索引),默认 <projectRoot>/.deploy */
|
|
93
|
+
stateDir?: string;
|
|
94
|
+
/** 日志目录,默认 <stateDir>/logs */
|
|
95
|
+
logDir?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ResolvedBuild {
|
|
99
|
+
skip: boolean;
|
|
100
|
+
command: string | string[] | ((context: BuildContext) => unknown) | null;
|
|
101
|
+
args: string[] | null;
|
|
102
|
+
cwd: string;
|
|
103
|
+
env: Record<string, string>;
|
|
104
|
+
timeoutMs: number;
|
|
105
|
+
mode: string | null;
|
|
106
|
+
packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ResolvedValidate {
|
|
110
|
+
requireIndexHtml: boolean;
|
|
111
|
+
assetPrefix: string | null;
|
|
112
|
+
forbidPatterns: readonly string[];
|
|
113
|
+
warnOnSourcemaps: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface ResolvedConfig {
|
|
117
|
+
host: string;
|
|
118
|
+
port: number;
|
|
119
|
+
username: string;
|
|
120
|
+
remoteRoot: string;
|
|
121
|
+
remotePath: string;
|
|
122
|
+
hostFingerprint: string | null;
|
|
123
|
+
keyFile: string | null;
|
|
124
|
+
keepBackups: number;
|
|
125
|
+
appName: string;
|
|
126
|
+
preserve: readonly string[];
|
|
127
|
+
setPermissions: boolean;
|
|
128
|
+
/** 兼容老配置的 buildMode:用户真的写了才有值,否则为 null */
|
|
129
|
+
buildMode: string | null;
|
|
130
|
+
projectRoot: string;
|
|
131
|
+
distDir: string;
|
|
132
|
+
build: ResolvedBuild;
|
|
133
|
+
validate: ResolvedValidate;
|
|
134
|
+
env: Required<EnvNames>;
|
|
135
|
+
stateDir: string;
|
|
136
|
+
logDir: string;
|
|
137
|
+
configPath: string | null;
|
|
138
|
+
raw: DeployConfig;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface BuildPlan {
|
|
142
|
+
command: string;
|
|
143
|
+
args: string[];
|
|
144
|
+
shell: boolean;
|
|
145
|
+
cwd: string;
|
|
146
|
+
env: Record<string, string | undefined>;
|
|
147
|
+
label: string;
|
|
148
|
+
timeoutMs: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* ------------------------------------------------------------------ */
|
|
152
|
+
/* 远程文件系统(传输层可替换) */
|
|
153
|
+
/* ------------------------------------------------------------------ */
|
|
154
|
+
|
|
155
|
+
export type RemoteEntryType = 'dir' | 'file' | 'link';
|
|
156
|
+
|
|
157
|
+
export interface RemoteStat {
|
|
158
|
+
type: RemoteEntryType;
|
|
159
|
+
size: number;
|
|
160
|
+
mtimeMs: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface RemoteEntry extends RemoteStat {
|
|
164
|
+
name: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface Remote {
|
|
168
|
+
kind: string;
|
|
169
|
+
realpath(path: string): Promise<string>;
|
|
170
|
+
stat(path: string): Promise<RemoteStat | null>;
|
|
171
|
+
readdir(path: string): Promise<RemoteEntry[] | null>;
|
|
172
|
+
mkdir(path: string): Promise<void>;
|
|
173
|
+
rmdir(path: string): Promise<void>;
|
|
174
|
+
unlink(path: string): Promise<void>;
|
|
175
|
+
rename(from: string, to: string): Promise<void>;
|
|
176
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
177
|
+
putFile(localPath: string, remotePath: string, options?: { size?: number }): Promise<number>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface LocalFile {
|
|
181
|
+
rel: string;
|
|
182
|
+
abs: string;
|
|
183
|
+
size: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface LocalDir {
|
|
187
|
+
rel: string;
|
|
188
|
+
abs: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface LocalTree {
|
|
192
|
+
root?: string;
|
|
193
|
+
files: LocalFile[];
|
|
194
|
+
dirs: LocalDir[];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface DeployPlan {
|
|
198
|
+
stamp: string;
|
|
199
|
+
targetExists: boolean;
|
|
200
|
+
targetEntryCount: number;
|
|
201
|
+
swapNames: string[];
|
|
202
|
+
preservedNames: string[];
|
|
203
|
+
localFileCount: number;
|
|
204
|
+
localBytes: number;
|
|
205
|
+
looksLikeSite: boolean;
|
|
206
|
+
metaDir: string;
|
|
207
|
+
backupsDir: string;
|
|
208
|
+
stagingDir: string;
|
|
209
|
+
backupDir: string;
|
|
210
|
+
rollbackDir: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface BackupInfo {
|
|
214
|
+
stamp: string;
|
|
215
|
+
files: number;
|
|
216
|
+
bytes: number;
|
|
217
|
+
mtimeMs: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface MetaPaths {
|
|
221
|
+
metaDir: string;
|
|
222
|
+
backupsDir: string;
|
|
223
|
+
stagingDir: string | null;
|
|
224
|
+
backupDir: string | null;
|
|
225
|
+
rollbackDir: string | null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ------------------------------------------------------------------ */
|
|
229
|
+
/* 日志与选项 */
|
|
230
|
+
/* ------------------------------------------------------------------ */
|
|
231
|
+
|
|
232
|
+
export interface Logger {
|
|
233
|
+
file?: string | null;
|
|
234
|
+
step(text: string): void;
|
|
235
|
+
info(text: string): void;
|
|
236
|
+
ok(text: string): void;
|
|
237
|
+
warn(text: string): void;
|
|
238
|
+
error(text: string): void;
|
|
239
|
+
plain(text: string): void;
|
|
240
|
+
verbose(text: string): void;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface FingerprintStore {
|
|
244
|
+
file: string;
|
|
245
|
+
get(): string | null;
|
|
246
|
+
set(fingerprint: string): { target: 'config' | 'store'; path: string };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface CommandOptions {
|
|
250
|
+
/** 在哪个目录下查找配置、执行构建 */
|
|
251
|
+
cwd?: string;
|
|
252
|
+
/** 配置文件路径 */
|
|
253
|
+
config?: string;
|
|
254
|
+
skipBuild?: boolean;
|
|
255
|
+
dryRun?: boolean;
|
|
256
|
+
yes?: boolean;
|
|
257
|
+
force?: boolean;
|
|
258
|
+
verbose?: boolean;
|
|
259
|
+
json?: boolean;
|
|
260
|
+
trustFingerprint?: boolean;
|
|
261
|
+
createRemotePath?: boolean;
|
|
262
|
+
backup?: string;
|
|
263
|
+
keep?: number;
|
|
264
|
+
logger?: Logger;
|
|
265
|
+
/** 编程式确认回调;不给且非 TTY 时会报错 */
|
|
266
|
+
confirm?: (question: string) => boolean | Promise<boolean>;
|
|
267
|
+
fingerprintStore?: FingerprintStore;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface DeployResult {
|
|
271
|
+
ok: true;
|
|
272
|
+
action: 'deploy';
|
|
273
|
+
config: Record<string, unknown>;
|
|
274
|
+
dryRun?: boolean;
|
|
275
|
+
cancelled?: boolean;
|
|
276
|
+
plan?: DeployPlan;
|
|
277
|
+
stamp?: string;
|
|
278
|
+
backupDir?: string | null;
|
|
279
|
+
uploadedFiles?: number;
|
|
280
|
+
uploadedBytes?: number;
|
|
281
|
+
finalEntryCount?: number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export interface CheckResult {
|
|
285
|
+
ok: true;
|
|
286
|
+
action: 'check';
|
|
287
|
+
rootReal: string;
|
|
288
|
+
targetReal: string | null;
|
|
289
|
+
targetExists: boolean;
|
|
290
|
+
looksLikeSite: boolean;
|
|
291
|
+
backups: string[];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface RollbackResult {
|
|
295
|
+
ok: true;
|
|
296
|
+
action: 'rollback';
|
|
297
|
+
cancelled?: boolean;
|
|
298
|
+
stamp?: string;
|
|
299
|
+
restoredFiles?: number;
|
|
300
|
+
replacedFiles?: number;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface ListBackupsResult {
|
|
304
|
+
ok: true;
|
|
305
|
+
action: 'list-backups';
|
|
306
|
+
backups: BackupInfo[];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface InitResult {
|
|
310
|
+
ok: true;
|
|
311
|
+
action: 'init';
|
|
312
|
+
cancelled: boolean;
|
|
313
|
+
configPath: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/* ------------------------------------------------------------------ */
|
|
317
|
+
/* 错误 */
|
|
318
|
+
/* ------------------------------------------------------------------ */
|
|
319
|
+
|
|
320
|
+
export class DeployError extends Error {
|
|
321
|
+
constructor(message: string, options?: { cause?: unknown });
|
|
322
|
+
cause?: unknown;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export class GuardError extends Error {}
|
|
326
|
+
export class ConfigError extends GuardError {}
|
|
327
|
+
export class RemoteError extends Error {
|
|
328
|
+
constructor(message: string, options?: { code?: number | string; path?: string });
|
|
329
|
+
code?: number | string;
|
|
330
|
+
path?: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* ------------------------------------------------------------------ */
|
|
334
|
+
/* 配置相关函数 */
|
|
335
|
+
/* ------------------------------------------------------------------ */
|
|
336
|
+
|
|
337
|
+
export const CONFIG_FILENAMES: string[];
|
|
338
|
+
|
|
339
|
+
export function defineConfig(config: DeployConfig): DeployConfig;
|
|
340
|
+
|
|
341
|
+
export function findConfigFile(options?: { cwd?: string; configPath?: string | null }): string | null;
|
|
342
|
+
|
|
343
|
+
export function readConfigFile(file: string): Promise<DeployConfig>;
|
|
344
|
+
|
|
345
|
+
export function resolveConfig(raw: DeployConfig, options?: { configPath?: string | null; cwd?: string }): ResolvedConfig;
|
|
346
|
+
|
|
347
|
+
export function loadConfig(
|
|
348
|
+
input?: ConfigInput | null,
|
|
349
|
+
options?: { cwd?: string; configPath?: string | null }
|
|
350
|
+
): Promise<ResolvedConfig>;
|
|
351
|
+
|
|
352
|
+
export function isResolvedConfig(value: unknown): value is ResolvedConfig;
|
|
353
|
+
|
|
354
|
+
export type ConfigInput = DeployConfig | ResolvedConfig | string;
|
|
355
|
+
|
|
356
|
+
export function saveConfigFile(file: string, config: DeployConfig | ResolvedConfig): Record<string, unknown>;
|
|
357
|
+
|
|
358
|
+
export function createFingerprintStore(config: ResolvedConfig): FingerprintStore;
|
|
359
|
+
|
|
360
|
+
export function describeResolvedConfig(config: ResolvedConfig): Record<string, unknown>;
|
|
361
|
+
|
|
362
|
+
/* ------------------------------------------------------------------ */
|
|
363
|
+
/* 构建与产物 */
|
|
364
|
+
/* ------------------------------------------------------------------ */
|
|
365
|
+
|
|
366
|
+
export function detectPackageManager(projectRoot: string): 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
367
|
+
|
|
368
|
+
export function resolveBuildCommand(config: ResolvedConfig): BuildPlan | null;
|
|
369
|
+
|
|
370
|
+
export function runBuild(plan: BuildPlan, options?: { log?: Logger }): Promise<void>;
|
|
371
|
+
|
|
372
|
+
export function buildLocalTree(distDir: string): LocalTree & { root: string };
|
|
373
|
+
|
|
374
|
+
export function matchForbidden(rel: string, pattern: string): boolean;
|
|
375
|
+
|
|
376
|
+
export function validateDist(
|
|
377
|
+
config: ResolvedConfig,
|
|
378
|
+
options?: { log?: Logger }
|
|
379
|
+
): { distDir: string; files: LocalFile[]; dirs: LocalDir[]; bytes: number; mapFiles: string[] };
|
|
380
|
+
|
|
381
|
+
/* ------------------------------------------------------------------ */
|
|
382
|
+
/* 编排(低层 API) */
|
|
383
|
+
/* ------------------------------------------------------------------ */
|
|
384
|
+
|
|
385
|
+
export function metaPaths(config: ResolvedConfig | DeployConfig, stamp?: string): MetaPaths;
|
|
386
|
+
|
|
387
|
+
export function verifyRemoteLayout(options: {
|
|
388
|
+
remote: Remote;
|
|
389
|
+
config: ResolvedConfig;
|
|
390
|
+
createRemotePath?: boolean;
|
|
391
|
+
}): Promise<{ rootReal: string; targetReal: string | null; targetExists: boolean }>;
|
|
392
|
+
|
|
393
|
+
export function planDeploy(options: {
|
|
394
|
+
remote: Remote;
|
|
395
|
+
config: ResolvedConfig;
|
|
396
|
+
localTree: LocalTree;
|
|
397
|
+
force?: boolean;
|
|
398
|
+
now?: Date;
|
|
399
|
+
}): Promise<DeployPlan>;
|
|
400
|
+
|
|
401
|
+
export function executeDeploy(options: {
|
|
402
|
+
remote: Remote;
|
|
403
|
+
config: ResolvedConfig;
|
|
404
|
+
localTree: LocalTree;
|
|
405
|
+
plan: DeployPlan;
|
|
406
|
+
log?: (message: string) => void;
|
|
407
|
+
}): Promise<{
|
|
408
|
+
stamp: string;
|
|
409
|
+
backupDir: string | null;
|
|
410
|
+
uploadedFiles: number;
|
|
411
|
+
uploadedBytes: number;
|
|
412
|
+
finalEntryCount: number;
|
|
413
|
+
}>;
|
|
414
|
+
|
|
415
|
+
export function inspectBackups(options: { remote: Remote; config: ResolvedConfig }): Promise<BackupInfo[]>;
|
|
416
|
+
|
|
417
|
+
export function listBackupStamps(options: { remote: Remote; config: ResolvedConfig }): Promise<string[]>;
|
|
418
|
+
|
|
419
|
+
export function pruneBackups(options: { remote: Remote; config: ResolvedConfig; log?: (message: string) => void }): Promise<string[]>;
|
|
420
|
+
|
|
421
|
+
export function cleanupStaleStaging(options: {
|
|
422
|
+
remote: Remote;
|
|
423
|
+
config: ResolvedConfig;
|
|
424
|
+
log?: (message: string) => void;
|
|
425
|
+
now?: number;
|
|
426
|
+
}): Promise<string[]>;
|
|
427
|
+
|
|
428
|
+
export function rollbackRelease(options: {
|
|
429
|
+
remote: Remote;
|
|
430
|
+
config: ResolvedConfig;
|
|
431
|
+
log?: (message: string) => void;
|
|
432
|
+
targetStamp?: string | null;
|
|
433
|
+
now?: Date;
|
|
434
|
+
}): Promise<{ stamp: string; restoredFiles: number; replacedFiles: number }>;
|
|
435
|
+
|
|
436
|
+
/* ------------------------------------------------------------------ */
|
|
437
|
+
/* 传输层 */
|
|
438
|
+
/* ------------------------------------------------------------------ */
|
|
439
|
+
|
|
440
|
+
export function createSftpRemote(sftp: unknown, options: { root: string; check?: (path: string) => void }): Remote;
|
|
441
|
+
|
|
442
|
+
export function createMemoryRemote(initial?: {
|
|
443
|
+
dirs?: string[];
|
|
444
|
+
files?: Record<string, number>;
|
|
445
|
+
links?: Record<string, string>;
|
|
446
|
+
now?: number;
|
|
447
|
+
}): Remote & {
|
|
448
|
+
snapshot(): { dirs: string[]; files: { path: string; size: number }[]; links: [string, string][] };
|
|
449
|
+
hooks: Record<string, (...args: unknown[]) => void>;
|
|
450
|
+
clock: { now: number };
|
|
451
|
+
setNow(value: number): void;
|
|
452
|
+
setFile(path: string, size: number): void;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
/* ------------------------------------------------------------------ */
|
|
456
|
+
/* 安全守卫 */
|
|
457
|
+
/* ------------------------------------------------------------------ */
|
|
458
|
+
|
|
459
|
+
export const BLOCKED_REMOTE_ROOTS: Set<string>;
|
|
460
|
+
export const STAMP_PATTERN: RegExp;
|
|
461
|
+
|
|
462
|
+
export function normalizeRemotePath(raw: unknown, label?: string): string;
|
|
463
|
+
export function assertRemoteRoot(raw: unknown): string;
|
|
464
|
+
export function assertRemotePath(raw: unknown, remoteRoot: unknown): string;
|
|
465
|
+
export function isInside(root: string, target: string): boolean;
|
|
466
|
+
export function assertSafeEntryName(name: unknown): string;
|
|
467
|
+
export function hostFingerprint(keyBlob: Uint8Array | string): string;
|
|
468
|
+
export function assertFingerprint(value: unknown): string;
|
|
469
|
+
export function makeStamp(date?: Date): string;
|
|
470
|
+
export function validateConfig(raw: unknown, options?: { allowMissingFingerprint?: boolean }): Record<string, unknown>;
|
|
471
|
+
export function describeConfig(config: Record<string, unknown>): Record<string, unknown>;
|
|
472
|
+
export function formatBytes(bytes: number): string;
|
|
473
|
+
|
|
474
|
+
/* ------------------------------------------------------------------ */
|
|
475
|
+
/* 日志 */
|
|
476
|
+
/* ------------------------------------------------------------------ */
|
|
477
|
+
|
|
478
|
+
export function createLogger(options?: { file?: string | null; verbose?: boolean; silent?: boolean }): Logger;
|
|
479
|
+
export function createSilentLogger(): Logger;
|
|
480
|
+
export function createActionLogger(options: { config: { logDir: string }; action: string; options?: CommandOptions }): Logger;
|
|
481
|
+
|
|
482
|
+
/* ------------------------------------------------------------------ */
|
|
483
|
+
/* 命令实现(需要自己接管流程时用) */
|
|
484
|
+
/* ------------------------------------------------------------------ */
|
|
485
|
+
|
|
486
|
+
export function runDeploy(config: ResolvedConfig, options?: CommandOptions): Promise<DeployResult>;
|
|
487
|
+
export function runCheck(config: ResolvedConfig, options?: CommandOptions): Promise<CheckResult>;
|
|
488
|
+
export function runRollback(config: ResolvedConfig, options?: CommandOptions): Promise<RollbackResult>;
|
|
489
|
+
export function runListBackups(config: ResolvedConfig, options?: CommandOptions): Promise<ListBackupsResult>;
|
|
490
|
+
export function runInit(options?: CommandOptions): Promise<InitResult>;
|
|
491
|
+
|
|
492
|
+
/* ------------------------------------------------------------------ */
|
|
493
|
+
/* 一站式 API */
|
|
494
|
+
/* ------------------------------------------------------------------ */
|
|
495
|
+
|
|
496
|
+
export function deploy(configInput?: ConfigInput, options?: CommandOptions): Promise<DeployResult>;
|
|
497
|
+
export function check(configInput?: ConfigInput, options?: CommandOptions): Promise<CheckResult>;
|
|
498
|
+
export function rollback(configInput?: ConfigInput, options?: CommandOptions): Promise<RollbackResult>;
|
|
499
|
+
export function listBackups(configInput?: ConfigInput, options?: CommandOptions): Promise<ListBackupsResult>;
|
|
500
|
+
export function init(options?: CommandOptions): Promise<InitResult>;
|