@dongnanyang/deploy-cli 0.5.0 → 0.5.1
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/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const argv = process.argv.slice(2);
|
|
3
3
|
if (argv.length === 0 || argv[0] === "tui") await import("./main.js");
|
|
4
4
|
else {
|
|
5
|
-
const cli = await import("./cli-
|
|
5
|
+
const cli = await import("./cli-DC-8dd-4.js");
|
|
6
6
|
process.exitCode = await cli.main(argv);
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
@@ -490,6 +490,18 @@ function execFailure(cmd, args, result, note) {
|
|
|
490
490
|
const summary = result.stderr.trim().split("\n").filter((line) => line.trim() !== "").slice(0, 3).join(" ");
|
|
491
491
|
return new ExecError(`${note ? `${note}: ` : ""}命令失败: ${[cmd, ...args].join(" ")}(exit ${result.code})${summary ? `: ${summary}` : "(stderr 无输出)"}`, result);
|
|
492
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* 路径探测:sites-available 与 sites-enabled 同时存在 → sites 模式(软链);否则 conf.d 模式(无软链)。
|
|
495
|
+
* 仅凭 sites-available 存在不足以走 sites 模式:无 sites-enabled 时(nginx.conf 直接 include sites-available/*)
|
|
496
|
+
* 软链无处落地,且 .bak/.new 会被 `include ...*` 通配吸入,破坏回滚与删除的生效性。
|
|
497
|
+
*/
|
|
498
|
+
function resolveNginxPaths(exists = existsSync$1) {
|
|
499
|
+
if (exists(DEFAULT_SITES_AVAILABLE) && exists(DEFAULT_SITES_ENABLED)) return {
|
|
500
|
+
sitesAvailable: DEFAULT_SITES_AVAILABLE,
|
|
501
|
+
sitesEnabled: DEFAULT_SITES_ENABLED
|
|
502
|
+
};
|
|
503
|
+
return { sitesAvailable: DEFAULT_CONF_D };
|
|
504
|
+
}
|
|
493
505
|
/** 渲染 server 块;withSsl 时要求 certPath/keyPath(acme 需先 requestCert 取得) */
|
|
494
506
|
function renderBlock(spec, withSsl) {
|
|
495
507
|
validateSpec(spec);
|
|
@@ -525,8 +537,9 @@ function renderBlock(spec, withSsl) {
|
|
|
525
537
|
return lines.join("\n") + "\n";
|
|
526
538
|
}
|
|
527
539
|
function createNginx(runner = run, paths) {
|
|
528
|
-
const
|
|
529
|
-
const
|
|
540
|
+
const resolved = paths ?? resolveNginxPaths();
|
|
541
|
+
const sitesAvailable = resolved.sitesAvailable;
|
|
542
|
+
const sitesEnabled = resolved.sitesEnabled;
|
|
530
543
|
const confName = (slug) => `${CONF_PREFIX}${slug}${CONF_SUFFIX}`;
|
|
531
544
|
/**
|
|
532
545
|
* 写盘/回滚流程:新内容写 .conf.new → 旧 conf 备份 .bak → .new 原子改名 → 建 sites-enabled 软链 → nginx -t;
|