@dongnanyang/deploy-cli 0.11.0 → 0.12.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/dist/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as generateCompose, c as loadProject, d as
|
|
1
|
+
import { a as generateCompose, c as loadProject, d as managedRoot, f as removeProject, h as PROJECT_LABEL, i as createManagedProject, m as COMPOSE_SERVICE_LABEL, n as ProjectConfigError, o as hasComposeMarker, p as saveProject, r as addProject, s as listProjects, t as COMPOSE_MARKER, u as managedDir } from "./project-BL00JHAo.js";
|
|
2
2
|
export { COMPOSE_MARKER, COMPOSE_SERVICE_LABEL, PROJECT_LABEL, ProjectConfigError, addProject, createManagedProject, generateCompose, hasComposeMarker, listProjects, loadProject, managedDir, managedRoot, removeProject, saveProject };
|
package/dist/bin.js
CHANGED
|
@@ -18,7 +18,7 @@ async function runEntry(argv = process.argv.slice(2)) {
|
|
|
18
18
|
await import("./tui/main.js");
|
|
19
19
|
break;
|
|
20
20
|
case "cli": {
|
|
21
|
-
const cli = await import("./cli-
|
|
21
|
+
const cli = await import("./cli-BxZa7ok5.js");
|
|
22
22
|
process.exitCode = await cli.main(argv);
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
@@ -1,166 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as run, S as execFailureMessage, _ as acmeProbeCommand, c as loadProject, f as removeProject, g as ACME_BIN, r as addProject, s as listProjects, v as certbotProbeCommand, x as resolveNginxPaths, y as createNginx } from "./project-BL00JHAo.js";
|
|
2
2
|
import { n as loadConfig, r as saveConfig, t as expandPath } from "./config-xUl8Oa3T.js";
|
|
3
|
-
import { a as
|
|
4
|
-
import { accessSync, constants, existsSync, readFileSync
|
|
5
|
-
import { dirname, join
|
|
3
|
+
import { a as createDocker, i as findProjectContainers, n as runDeploy, o as logsArgs, r as checkProjectHealth, t as buildSpec } from "./deploy-DNT8Hzl1.js";
|
|
4
|
+
import { accessSync, constants, existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
//#region src/core/deploy.ts
|
|
8
|
-
/** deploy.yaml → NginxSiteSpec(slug=项目 name);custom 型缺 certPath/keyPath 来源,暂不支持 */
|
|
9
|
-
function buildSpec(d, noSsl) {
|
|
10
|
-
if (!d.nginx) throw new Error(`项目 ${d.name} 未配置 nginx(deploy.yaml 缺 nginx 段)`);
|
|
11
|
-
const ssl = noSsl ? "none" : d.nginx.ssl;
|
|
12
|
-
if (ssl === "custom") throw new Error("ssl:custom 需要 certPath/keyPath,deploy.yaml 暂不支持;请改用 ssl:acme 或 ssl:none");
|
|
13
|
-
const spec = {
|
|
14
|
-
slug: d.name,
|
|
15
|
-
serverName: d.nginx.domain,
|
|
16
|
-
ssl
|
|
17
|
-
};
|
|
18
|
-
if (d.type === "static") spec.root = d.root;
|
|
19
|
-
else {
|
|
20
|
-
if (!d.nginx.upstream) throw new Error(`项目 ${d.name} 为 ${d.type} 型,缺少 nginx.upstream(代理目标,如 127.0.0.1:3000)`);
|
|
21
|
-
spec.upstream = d.nginx.upstream;
|
|
22
|
-
}
|
|
23
|
-
return spec;
|
|
24
|
-
}
|
|
25
|
-
/** 非零退出码 → 抛失败信息(命令原文 + stderr 摘要,可附提示) */
|
|
26
|
-
function expectOk(result, cmd, args, hint) {
|
|
27
|
-
if (result.code !== 0) throw new Error(`${execFailureMessage(cmd, args, result)}${hint ? `;${hint}` : ""}`);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* 流水线步超时(终审 M1 明文落定:全部步骤都挂超时,不保留「构建步不设超时、靠 Ctrl-C」的无超时步——
|
|
31
|
-
* git pull 挂起不得永久挂死流水线;超时走 ExecError,消息含 stderr 摘要)。
|
|
32
|
-
* 长步 600s:update(git pull)/pre/post 钩子(可能跑迁移)/build/up(docker 构建与镜像拉取耗时不可控),
|
|
33
|
-
* docker 子进程(含 health 步的 docker ps 查询)同为 600s;
|
|
34
|
-
* 短步 120s:nginx 配置下发(nginx -t / reload / acme 签发)。
|
|
35
|
-
*/
|
|
36
|
-
const STEP_TIMEOUT_LONG_MS = 6e5;
|
|
37
|
-
const STEP_TIMEOUT_SHORT_MS = 12e4;
|
|
38
|
-
/**
|
|
39
|
-
* 部署流水线(失败即停):update(git pull) → pre → build → up → nginx → health → post(R10 上线后钩子)。
|
|
40
|
-
* 步骤跳过口径:update 仅 deploy.update==='git-pull' 时执行(缺省/none 跳过);pre/post 无钩子跳过;
|
|
41
|
-
* static 型跳过 build/up(自定义 build 也不跑);image 型无自定义 build 跳过 build(compose 文件在 up 步才生成);
|
|
42
|
-
* nginx 在 applyNginx!==false 且有 nginx 配置时执行;health 在有 healthUrl 或非 static 型时执行。
|
|
43
|
-
* 某步失败(含 Runner reject:spawn 失败/超时)→ 该步 fail 事件 + 后续步骤绝不执行。
|
|
44
|
-
*/
|
|
45
|
-
async function runDeploy(project, opts) {
|
|
46
|
-
const rawRunner = opts.runner ?? run;
|
|
47
|
-
/** 给 shell-out 挂默认超时(终审 M1 防挂起):调用方显式传 timeoutMs 时以其为准 */
|
|
48
|
-
const withTimeout = (ms) => (cmd, args, o = {}) => rawRunner(cmd, args, {
|
|
49
|
-
...o,
|
|
50
|
-
timeoutMs: o.timeoutMs ?? ms
|
|
51
|
-
});
|
|
52
|
-
const runner = withTimeout(STEP_TIMEOUT_LONG_MS);
|
|
53
|
-
const docker = opts.docker ?? createDocker(runner);
|
|
54
|
-
const emit = opts.onEvent;
|
|
55
|
-
/** 包裹单步:start → fn → ok;fn 抛错 → fail 事件 + 停(返回结果由调用方 return) */
|
|
56
|
-
async function step(name, startLine, fn) {
|
|
57
|
-
emit({
|
|
58
|
-
step: name,
|
|
59
|
-
status: "start",
|
|
60
|
-
line: startLine
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
await fn();
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const line = error instanceof Error ? error.message : String(error);
|
|
66
|
-
emit({
|
|
67
|
-
step: name,
|
|
68
|
-
status: "fail",
|
|
69
|
-
line
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
ok: false,
|
|
73
|
-
failedStep: name
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
emit({
|
|
77
|
-
step: name,
|
|
78
|
-
status: "ok"
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
const gitArgs = [
|
|
82
|
-
"-C",
|
|
83
|
-
opts.cwd,
|
|
84
|
-
"pull"
|
|
85
|
-
];
|
|
86
|
-
if (project.deploy?.update === "git-pull") {
|
|
87
|
-
const stopped = await step("update", `git ${gitArgs.join(" ")}`, async () => {
|
|
88
|
-
expectOk(await runner("git", gitArgs), "git", gitArgs, "非 git 目录或拉取失败;如无需自动更新请改 deploy.update: none");
|
|
89
|
-
});
|
|
90
|
-
if (stopped) return stopped;
|
|
91
|
-
}
|
|
92
|
-
const pre = project.deploy?.pre ?? [];
|
|
93
|
-
if (pre.length > 0) {
|
|
94
|
-
const stopped = await step("pre", void 0, async () => {
|
|
95
|
-
for (const cmd of pre) expectOk(await runner("bash", ["-c", cmd]), "bash", ["-c", cmd]);
|
|
96
|
-
});
|
|
97
|
-
if (stopped) return stopped;
|
|
98
|
-
}
|
|
99
|
-
const composeFile = project.composeFile ?? "docker-compose.yml";
|
|
100
|
-
const customBuild = project.deploy?.build;
|
|
101
|
-
if (project.type === "static" && customBuild !== void 0) emit({
|
|
102
|
-
step: "build",
|
|
103
|
-
status: "warn",
|
|
104
|
-
line: "static 型项目不执行 build,deploy.build 已忽略;如需构建步骤请改用 deploy.pre 钩子"
|
|
105
|
-
});
|
|
106
|
-
if (project.type !== "static" && (customBuild !== void 0 || project.type === "compose")) {
|
|
107
|
-
const stopped = await step("build", customBuild ?? `docker compose -f ${composeFile} build`, async () => {
|
|
108
|
-
if (customBuild !== void 0) expectOk(await runner("bash", ["-c", customBuild]), "bash", ["-c", customBuild]);
|
|
109
|
-
else expectOk(await docker.composeBuild(opts.cwd, composeFile), "docker", [
|
|
110
|
-
"compose",
|
|
111
|
-
"-f",
|
|
112
|
-
composeFile,
|
|
113
|
-
"build"
|
|
114
|
-
]);
|
|
115
|
-
});
|
|
116
|
-
if (stopped) return stopped;
|
|
117
|
-
}
|
|
118
|
-
if (project.type !== "static") {
|
|
119
|
-
const upFile = project.type === "image" ? "docker-compose.yml" : composeFile;
|
|
120
|
-
const stopped = await step("up", `docker compose -f ${upFile} up -d`, async () => {
|
|
121
|
-
if (project.type === "image") {
|
|
122
|
-
const target = resolve(opts.cwd, upFile);
|
|
123
|
-
if (existsSync(target) && !hasComposeMarker(readFileSync(target, "utf-8"))) throw new Error(`${upFile} 已存在且非 deploy-cli 生成(缺 marker 头 "${COMPOSE_MARKER}"),拒绝覆盖;请改名/移走该文件,或改用 compose 型项目`);
|
|
124
|
-
writeFileSync(target, generateCompose(project), "utf-8");
|
|
125
|
-
}
|
|
126
|
-
expectOk(await docker.composeUp(opts.cwd, upFile), "docker", [
|
|
127
|
-
"compose",
|
|
128
|
-
"-f",
|
|
129
|
-
upFile,
|
|
130
|
-
"up",
|
|
131
|
-
"-d"
|
|
132
|
-
]);
|
|
133
|
-
});
|
|
134
|
-
if (stopped) return stopped;
|
|
135
|
-
}
|
|
136
|
-
if ((opts.applyNginx ?? true) && project.nginx) {
|
|
137
|
-
const stopped = await step("nginx", void 0, async () => {
|
|
138
|
-
await (opts.nginx ?? createNginx(withTimeout(STEP_TIMEOUT_SHORT_MS))).applySite(buildSpec(project, false));
|
|
139
|
-
});
|
|
140
|
-
if (stopped) return stopped;
|
|
141
|
-
}
|
|
142
|
-
if (project.healthUrl !== void 0 || project.type !== "static") {
|
|
143
|
-
const stopped = await step("health", project.healthUrl, async () => {
|
|
144
|
-
if (project.healthUrl) {
|
|
145
|
-
const probe = await httpProbe(project.healthUrl);
|
|
146
|
-
if (!probe.ok) throw new Error(`健康探测失败: ${project.healthUrl}: ${probe.error ?? `HTTP ${probe.status}`}`);
|
|
147
|
-
}
|
|
148
|
-
if (project.type !== "static") {
|
|
149
|
-
if (!(await findProjectContainers(docker, project.name, { services: project.services })).some((c) => c.state === "running")) throw new Error(`无运行中容器: ${project.name}(docker ps 未见 running 状态容器)`);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
if (stopped) return stopped;
|
|
153
|
-
}
|
|
154
|
-
const post = project.deploy?.post ?? [];
|
|
155
|
-
if (post.length > 0) {
|
|
156
|
-
const stopped = await step("post", void 0, async () => {
|
|
157
|
-
for (const cmd of post) expectOk(await runner("bash", ["-c", cmd]), "bash", ["-c", cmd]);
|
|
158
|
-
});
|
|
159
|
-
if (stopped) return stopped;
|
|
160
|
-
}
|
|
161
|
-
return { ok: true };
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
7
|
//#region src/cli/commands/deploy.ts
|
|
165
8
|
const USAGE$6 = `用法: deploy-cli deploy <project> [--yes] [--no-nginx]
|
|
166
9
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as run, S as execFailureMessage, a as generateCompose, h as PROJECT_LABEL, m as COMPOSE_SERVICE_LABEL, o as hasComposeMarker, t as COMPOSE_MARKER, y as createNginx } from "./project-BL00JHAo.js";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
2
4
|
//#region src/core/docker.ts
|
|
3
5
|
/** docker 调用默认超时(F5:docker daemon 挂起不得永久挂死 CLI),与流水线 600s 长步档同口径;--follow 流式豁免 */
|
|
4
6
|
const DOCKER_TIMEOUT_MS = 6e5;
|
|
@@ -214,4 +216,161 @@ async function checkProjectHealth(project, opts) {
|
|
|
214
216
|
};
|
|
215
217
|
}
|
|
216
218
|
//#endregion
|
|
217
|
-
|
|
219
|
+
//#region src/core/deploy.ts
|
|
220
|
+
/** deploy.yaml → NginxSiteSpec(slug=项目 name);custom 型缺 certPath/keyPath 来源,暂不支持 */
|
|
221
|
+
function buildSpec(d, noSsl) {
|
|
222
|
+
if (!d.nginx) throw new Error(`项目 ${d.name} 未配置 nginx(deploy.yaml 缺 nginx 段)`);
|
|
223
|
+
const ssl = noSsl ? "none" : d.nginx.ssl;
|
|
224
|
+
if (ssl === "custom") throw new Error("ssl:custom 需要 certPath/keyPath,deploy.yaml 暂不支持;请改用 ssl:acme 或 ssl:none");
|
|
225
|
+
const spec = {
|
|
226
|
+
slug: d.name,
|
|
227
|
+
serverName: d.nginx.domain,
|
|
228
|
+
ssl
|
|
229
|
+
};
|
|
230
|
+
if (d.type === "static") spec.root = d.root;
|
|
231
|
+
else {
|
|
232
|
+
if (!d.nginx.upstream) throw new Error(`项目 ${d.name} 为 ${d.type} 型,缺少 nginx.upstream(代理目标,如 127.0.0.1:3000)`);
|
|
233
|
+
spec.upstream = d.nginx.upstream;
|
|
234
|
+
}
|
|
235
|
+
return spec;
|
|
236
|
+
}
|
|
237
|
+
/** 非零退出码 → 抛失败信息(命令原文 + stderr 摘要,可附提示) */
|
|
238
|
+
function expectOk(result, cmd, args, hint) {
|
|
239
|
+
if (result.code !== 0) throw new Error(`${execFailureMessage(cmd, args, result)}${hint ? `;${hint}` : ""}`);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 流水线步超时(终审 M1 明文落定:全部步骤都挂超时,不保留「构建步不设超时、靠 Ctrl-C」的无超时步——
|
|
243
|
+
* git pull 挂起不得永久挂死流水线;超时走 ExecError,消息含 stderr 摘要)。
|
|
244
|
+
* 长步 600s:update(git pull)/pre/post 钩子(可能跑迁移)/build/up(docker 构建与镜像拉取耗时不可控),
|
|
245
|
+
* docker 子进程(含 health 步的 docker ps 查询)同为 600s;
|
|
246
|
+
* 短步 120s:nginx 配置下发(nginx -t / reload / acme 签发)。
|
|
247
|
+
*/
|
|
248
|
+
const STEP_TIMEOUT_LONG_MS = 6e5;
|
|
249
|
+
const STEP_TIMEOUT_SHORT_MS = 12e4;
|
|
250
|
+
/**
|
|
251
|
+
* 部署流水线(失败即停):update(git pull) → pre → build → up → nginx → health → post(R10 上线后钩子)。
|
|
252
|
+
* 步骤跳过口径:update 仅 deploy.update==='git-pull' 时执行(缺省/none 跳过);pre/post 无钩子跳过;
|
|
253
|
+
* static 型跳过 build/up(自定义 build 也不跑);image 型无自定义 build 跳过 build(compose 文件在 up 步才生成);
|
|
254
|
+
* nginx 在 applyNginx!==false 且有 nginx 配置时执行;health 在有 healthUrl 或非 static 型时执行。
|
|
255
|
+
* 某步失败(含 Runner reject:spawn 失败/超时)→ 该步 fail 事件 + 后续步骤绝不执行。
|
|
256
|
+
*/
|
|
257
|
+
async function runDeploy(project, opts) {
|
|
258
|
+
const rawRunner = opts.runner ?? run;
|
|
259
|
+
/** 给 shell-out 挂默认超时(终审 M1 防挂起):调用方显式传 timeoutMs 时以其为准 */
|
|
260
|
+
const withTimeout = (ms) => (cmd, args, o = {}) => rawRunner(cmd, args, {
|
|
261
|
+
...o,
|
|
262
|
+
timeoutMs: o.timeoutMs ?? ms
|
|
263
|
+
});
|
|
264
|
+
const runner = withTimeout(STEP_TIMEOUT_LONG_MS);
|
|
265
|
+
const docker = opts.docker ?? createDocker(runner);
|
|
266
|
+
const emit = opts.onEvent;
|
|
267
|
+
/** 包裹单步:start → fn → ok;fn 抛错 → fail 事件 + 停(返回结果由调用方 return) */
|
|
268
|
+
async function step(name, startLine, fn) {
|
|
269
|
+
emit({
|
|
270
|
+
step: name,
|
|
271
|
+
status: "start",
|
|
272
|
+
line: startLine
|
|
273
|
+
});
|
|
274
|
+
try {
|
|
275
|
+
await fn();
|
|
276
|
+
} catch (error) {
|
|
277
|
+
const line = error instanceof Error ? error.message : String(error);
|
|
278
|
+
emit({
|
|
279
|
+
step: name,
|
|
280
|
+
status: "fail",
|
|
281
|
+
line
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
ok: false,
|
|
285
|
+
failedStep: name
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
emit({
|
|
289
|
+
step: name,
|
|
290
|
+
status: "ok"
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
const gitArgs = [
|
|
294
|
+
"-C",
|
|
295
|
+
opts.cwd,
|
|
296
|
+
"pull"
|
|
297
|
+
];
|
|
298
|
+
if (project.deploy?.update === "git-pull") {
|
|
299
|
+
const stopped = await step("update", `git ${gitArgs.join(" ")}`, async () => {
|
|
300
|
+
expectOk(await runner("git", gitArgs), "git", gitArgs, "非 git 目录或拉取失败;如无需自动更新请改 deploy.update: none");
|
|
301
|
+
});
|
|
302
|
+
if (stopped) return stopped;
|
|
303
|
+
}
|
|
304
|
+
const pre = project.deploy?.pre ?? [];
|
|
305
|
+
if (pre.length > 0) {
|
|
306
|
+
const stopped = await step("pre", void 0, async () => {
|
|
307
|
+
for (const cmd of pre) expectOk(await runner("bash", ["-c", cmd]), "bash", ["-c", cmd]);
|
|
308
|
+
});
|
|
309
|
+
if (stopped) return stopped;
|
|
310
|
+
}
|
|
311
|
+
const composeFile = project.composeFile ?? "docker-compose.yml";
|
|
312
|
+
const customBuild = project.deploy?.build;
|
|
313
|
+
if (project.type === "static" && customBuild !== void 0) emit({
|
|
314
|
+
step: "build",
|
|
315
|
+
status: "warn",
|
|
316
|
+
line: "static 型项目不执行 build,deploy.build 已忽略;如需构建步骤请改用 deploy.pre 钩子"
|
|
317
|
+
});
|
|
318
|
+
if (project.type !== "static" && (customBuild !== void 0 || project.type === "compose")) {
|
|
319
|
+
const stopped = await step("build", customBuild ?? `docker compose -f ${composeFile} build`, async () => {
|
|
320
|
+
if (customBuild !== void 0) expectOk(await runner("bash", ["-c", customBuild]), "bash", ["-c", customBuild]);
|
|
321
|
+
else expectOk(await docker.composeBuild(opts.cwd, composeFile), "docker", [
|
|
322
|
+
"compose",
|
|
323
|
+
"-f",
|
|
324
|
+
composeFile,
|
|
325
|
+
"build"
|
|
326
|
+
]);
|
|
327
|
+
});
|
|
328
|
+
if (stopped) return stopped;
|
|
329
|
+
}
|
|
330
|
+
if (project.type !== "static") {
|
|
331
|
+
const upFile = project.type === "image" ? "docker-compose.yml" : composeFile;
|
|
332
|
+
const stopped = await step("up", `docker compose -f ${upFile} up -d`, async () => {
|
|
333
|
+
if (project.type === "image") {
|
|
334
|
+
const target = resolve(opts.cwd, upFile);
|
|
335
|
+
if (existsSync(target) && !hasComposeMarker(readFileSync(target, "utf-8"))) throw new Error(`${upFile} 已存在且非 deploy-cli 生成(缺 marker 头 "${COMPOSE_MARKER}"),拒绝覆盖;请改名/移走该文件,或改用 compose 型项目`);
|
|
336
|
+
writeFileSync(target, generateCompose(project), "utf-8");
|
|
337
|
+
}
|
|
338
|
+
expectOk(await docker.composeUp(opts.cwd, upFile), "docker", [
|
|
339
|
+
"compose",
|
|
340
|
+
"-f",
|
|
341
|
+
upFile,
|
|
342
|
+
"up",
|
|
343
|
+
"-d"
|
|
344
|
+
]);
|
|
345
|
+
});
|
|
346
|
+
if (stopped) return stopped;
|
|
347
|
+
}
|
|
348
|
+
if ((opts.applyNginx ?? true) && project.nginx) {
|
|
349
|
+
const stopped = await step("nginx", void 0, async () => {
|
|
350
|
+
await (opts.nginx ?? createNginx(withTimeout(STEP_TIMEOUT_SHORT_MS))).applySite(buildSpec(project, false));
|
|
351
|
+
});
|
|
352
|
+
if (stopped) return stopped;
|
|
353
|
+
}
|
|
354
|
+
if (project.healthUrl !== void 0 || project.type !== "static") {
|
|
355
|
+
const stopped = await step("health", project.healthUrl, async () => {
|
|
356
|
+
if (project.healthUrl) {
|
|
357
|
+
const probe = await httpProbe(project.healthUrl);
|
|
358
|
+
if (!probe.ok) throw new Error(`健康探测失败: ${project.healthUrl}: ${probe.error ?? `HTTP ${probe.status}`}`);
|
|
359
|
+
}
|
|
360
|
+
if (project.type !== "static") {
|
|
361
|
+
if (!(await findProjectContainers(docker, project.name, { services: project.services })).some((c) => c.state === "running")) throw new Error(`无运行中容器: ${project.name}(docker ps 未见 running 状态容器)`);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
if (stopped) return stopped;
|
|
365
|
+
}
|
|
366
|
+
const post = project.deploy?.post ?? [];
|
|
367
|
+
if (post.length > 0) {
|
|
368
|
+
const stopped = await step("post", void 0, async () => {
|
|
369
|
+
for (const cmd of post) expectOk(await runner("bash", ["-c", cmd]), "bash", ["-c", cmd]);
|
|
370
|
+
});
|
|
371
|
+
if (stopped) return stopped;
|
|
372
|
+
}
|
|
373
|
+
return { ok: true };
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
export { createDocker as a, findProjectContainers as i, runDeploy as n, logsArgs as o, checkProjectHealth as r, buildSpec as t };
|
|
@@ -676,6 +676,14 @@ function managedDir(name) {
|
|
|
676
676
|
return resolve(managedRoot(), name);
|
|
677
677
|
}
|
|
678
678
|
/**
|
|
679
|
+
* compose 型向导闸(M2-T6 concern④):托管目录内默认 compose 文件(docker-compose.yml)是否就位。
|
|
680
|
+
* createManagedProject 只落 deploy.yaml(compose 文件归用户自备),缺文件=造出不可部署项目——
|
|
681
|
+
* 向导在完成前用本检查拦下(src/tui 不得 import fs,存在性检查归 core)。
|
|
682
|
+
*/
|
|
683
|
+
function managedComposeExists(name) {
|
|
684
|
+
return existsSync(resolve(managedDir(name), DEFAULT_COMPOSE_FILE));
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
679
687
|
* 一键建托管项目(M2-T3,Task 6 创建向导的 API):校验 → 托管目录落 deploy.yaml(image 型加生成 compose,含 COMPOSE_MARKER+归属 label)→ 自动注册进 config.json。
|
|
680
688
|
* 护栏:非法输入/注册冲突零落盘;既有 deploy.yaml 与无 marker 头 compose 一律拒绝覆盖(防绑架项目文件);文件绝不写 cwd。
|
|
681
689
|
*/
|
|
@@ -711,4 +719,4 @@ function createManagedProject(input) {
|
|
|
711
719
|
};
|
|
712
720
|
}
|
|
713
721
|
//#endregion
|
|
714
|
-
export {
|
|
722
|
+
export { run as C, execFailureMessage as S, acmeProbeCommand as _, generateCompose as a, isValidSlug as b, loadProject as c, managedRoot as d, removeProject as f, ACME_BIN as g, PROJECT_LABEL as h, createManagedProject as i, managedComposeExists as l, COMPOSE_SERVICE_LABEL as m, ProjectConfigError as n, hasComposeMarker as o, saveProject as p, addProject as r, listProjects as s, COMPOSE_MARKER as t, managedDir as u, certbotProbeCommand as v, resolveNginxPaths as x, createNginx as y };
|