@fabioplunser/epd 0.5.17 → 0.5.19
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/README.md +37 -14
- package/bin/epd.js +0 -0
- package/dist/cli.js +363 -132
- package/package.json +15 -29
- package/docs/.vitepress/config.mts +0 -92
- package/docs/.vitepress/theme/DeployAnimation.vue +0 -989
- package/docs/.vitepress/theme/index.ts +0 -10
- package/docs/.vitepress/theme/style.css +0 -151
- package/docs/agents.md +0 -166
- package/docs/ci-cd.md +0 -152
- package/docs/getting-started.md +0 -296
- package/docs/guide/accessories.md +0 -103
- package/docs/guide/architecture.md +0 -94
- package/docs/guide/blue-green.md +0 -93
- package/docs/guide/dashboard-validation.md +0 -181
- package/docs/guide/deployment-modes.md +0 -135
- package/docs/guide/getting-started.md +0 -296
- package/docs/guide/high-availability.md +0 -89
- package/docs/guide/installation.md +0 -124
- package/docs/guide/multi-site.md +0 -101
- package/docs/guide/private-repositories.md +0 -44
- package/docs/guide/routing.md +0 -129
- package/docs/guide/secrets.md +0 -132
- package/docs/guide/server-baseline.md +0 -104
- package/docs/guide/storage-validation.md +0 -40
- package/docs/guide/troubleshooting.md +0 -113
- package/docs/guide.md +0 -150
- package/docs/hetzner-dns.md +0 -95
- package/docs/index.md +0 -44
- package/docs/public/CNAME +0 -1
- package/docs/public/favicon.svg +0 -52
- package/docs/public/llms-full.txt +0 -344
- package/docs/public/llms.txt +0 -43
- package/docs/reference/cli.md +0 -510
- package/docs/reference/config.md +0 -237
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,12 @@ function redact(text) {
|
|
|
29
29
|
out = out.replace(re, replacement);
|
|
30
30
|
return out;
|
|
31
31
|
}
|
|
32
|
+
function hostColor(name) {
|
|
33
|
+
let h = 0;
|
|
34
|
+
for (const ch of name)
|
|
35
|
+
h = h * 31 + ch.charCodeAt(0) >>> 0;
|
|
36
|
+
return HOST_COLORS[h % HOST_COLORS.length];
|
|
37
|
+
}
|
|
32
38
|
function setVerbose(v) {
|
|
33
39
|
verbose = v;
|
|
34
40
|
}
|
|
@@ -93,25 +99,31 @@ function redactArgv(argv) {
|
|
|
93
99
|
return argv.map((a, i) => /password|token|secret|key/i.test(argv[i - 1] ?? "") ? "***" : a);
|
|
94
100
|
}
|
|
95
101
|
function stamp(t) {
|
|
96
|
-
return c.gray(`${(t / 1000).toFixed(1).padStart(5, " ")}s`);
|
|
102
|
+
return c.dim(c.gray(`${(t / 1000).toFixed(1).padStart(5, " ")}s`));
|
|
97
103
|
}
|
|
98
104
|
function render(e) {
|
|
99
105
|
const s = stamp(e.t);
|
|
100
106
|
switch (e.level) {
|
|
101
107
|
case "step":
|
|
102
|
-
return `${
|
|
108
|
+
return `${stepsShown++ ? `
|
|
109
|
+
` : ""}${s} ${c.cyan(glyph.step)} ${c.bold(e.msg)}`;
|
|
103
110
|
case "ok":
|
|
104
|
-
return `${s} ${c.green(
|
|
111
|
+
return `${s} ${c.green(glyph.ok)} ${e.msg}`;
|
|
105
112
|
case "warn":
|
|
106
|
-
return `${s} ${c.yellow(
|
|
107
|
-
case "error":
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
${c.gray(
|
|
113
|
+
return `${s} ${c.yellow(glyph.warn)} ${c.yellow(e.msg)}`;
|
|
114
|
+
case "error": {
|
|
115
|
+
const hint = e.hint ? `
|
|
116
|
+
${e.hint.split(`
|
|
117
|
+
`).map((l) => ` ${c.gray(glyph.pipe)} ${c.gray(l)}`).join(`
|
|
118
|
+
`)}` : "";
|
|
119
|
+
return `${s} ${c.red(glyph.error)} ${c.bold(c.red(e.msg))}${hint}`;
|
|
120
|
+
}
|
|
111
121
|
case "debug":
|
|
112
|
-
return `${s} ${c.gray(
|
|
113
|
-
case "host":
|
|
114
|
-
|
|
122
|
+
return `${s} ${c.gray(glyph.debug)} ${c.gray(e.msg)}`;
|
|
123
|
+
case "host": {
|
|
124
|
+
const name = e.host ?? "";
|
|
125
|
+
return `${s} ${hostColor(name)(name.padEnd(15).slice(0, 15))} ${c.gray(glyph.pipe)} ${e.msg}`;
|
|
126
|
+
}
|
|
115
127
|
case "output":
|
|
116
128
|
return e.msg;
|
|
117
129
|
case "plain":
|
|
@@ -172,7 +184,7 @@ function emitLines(level, args) {
|
|
|
172
184
|
`))
|
|
173
185
|
emit({ level, msg: line });
|
|
174
186
|
}
|
|
175
|
-
var knownSecrets, REDACTED = "[REDACTED]", SECRET_PATTERNS, format, colorOn, wrap = (code) => (s) => colorOn ? `\x1B[${code}m${s}\x1B[0m` : s, c, verbose = false, started, ANSI, stripAnsi = (s) => s.replace(ANSI, ""), fileFd = null, filePath = null, TAIL_MAX = 60, tail, listeners, realLog, realError, log, EpdError;
|
|
187
|
+
var knownSecrets, REDACTED = "[REDACTED]", SECRET_PATTERNS, format, colorOn, wrap = (code) => (s) => colorOn ? `\x1B[${code}m${s.replaceAll("\x1B[0m", `\x1B[0m\x1B[${code}m`)}\x1B[0m` : s, c, unicode, glyph, HOST_COLORS, verbose = false, started, ANSI, stripAnsi = (s) => s.replace(ANSI, ""), fileFd = null, filePath = null, TAIL_MAX = 60, tail, listeners, realLog, realError, stepsShown = 0, log, EpdError;
|
|
176
188
|
var init_log = __esm(() => {
|
|
177
189
|
knownSecrets = new Set;
|
|
178
190
|
SECRET_PATTERNS = [
|
|
@@ -188,6 +200,8 @@ var init_log = __esm(() => {
|
|
|
188
200
|
c = {
|
|
189
201
|
dim: wrap("2"),
|
|
190
202
|
bold: wrap("1"),
|
|
203
|
+
italic: wrap("3"),
|
|
204
|
+
underline: wrap("4"),
|
|
191
205
|
red: wrap("31"),
|
|
192
206
|
green: wrap("32"),
|
|
193
207
|
yellow: wrap("33"),
|
|
@@ -196,6 +210,45 @@ var init_log = __esm(() => {
|
|
|
196
210
|
cyan: wrap("36"),
|
|
197
211
|
gray: wrap("90")
|
|
198
212
|
};
|
|
213
|
+
unicode = process.env.EPD_ASCII !== "1" && (process.platform !== "win32" || Boolean(process.env.WT_SESSION || process.env.TERM_PROGRAM || process.env.ConEmuANSI));
|
|
214
|
+
glyph = unicode ? {
|
|
215
|
+
step: "\u25C6",
|
|
216
|
+
ok: "\u2714",
|
|
217
|
+
warn: "\u25B2",
|
|
218
|
+
error: "\u2716",
|
|
219
|
+
debug: "\xB7",
|
|
220
|
+
info: " ",
|
|
221
|
+
pipe: "\u2502",
|
|
222
|
+
arrow: "\u2192",
|
|
223
|
+
bullet: "\u2022",
|
|
224
|
+
rule: "\u2500",
|
|
225
|
+
dotOn: "\u25CF",
|
|
226
|
+
dotOff: "\u25CB",
|
|
227
|
+
barFull: "\u2588",
|
|
228
|
+
barEmpty: "\u2591",
|
|
229
|
+
prompt: "?",
|
|
230
|
+
enter: "\u21B5",
|
|
231
|
+
box: { tl: "\u256D", tr: "\u256E", bl: "\u2570", br: "\u256F", h: "\u2500", v: "\u2502" }
|
|
232
|
+
} : {
|
|
233
|
+
step: ">",
|
|
234
|
+
ok: "+",
|
|
235
|
+
warn: "!",
|
|
236
|
+
error: "x",
|
|
237
|
+
debug: ".",
|
|
238
|
+
info: " ",
|
|
239
|
+
pipe: "|",
|
|
240
|
+
arrow: "->",
|
|
241
|
+
bullet: "*",
|
|
242
|
+
rule: "-",
|
|
243
|
+
dotOn: "*",
|
|
244
|
+
dotOff: "o",
|
|
245
|
+
barFull: "#",
|
|
246
|
+
barEmpty: "-",
|
|
247
|
+
prompt: "?",
|
|
248
|
+
enter: ">",
|
|
249
|
+
box: { tl: "+", tr: "+", bl: "+", br: "+", h: "-", v: "|" }
|
|
250
|
+
};
|
|
251
|
+
HOST_COLORS = [c.magenta, c.cyan, c.blue, c.yellow, c.green];
|
|
199
252
|
started = Date.now();
|
|
200
253
|
ANSI = /\x1b\[[0-9;?]*[A-Za-z]/g;
|
|
201
254
|
tail = [];
|
|
@@ -344,6 +397,64 @@ var init_misc = __esm(() => {
|
|
|
344
397
|
init_log();
|
|
345
398
|
});
|
|
346
399
|
|
|
400
|
+
// src/util/ui.ts
|
|
401
|
+
function stripAnsi2(s) {
|
|
402
|
+
return s.replace(ANSI2, "");
|
|
403
|
+
}
|
|
404
|
+
function visibleLength(s) {
|
|
405
|
+
return [...stripAnsi2(s)].length;
|
|
406
|
+
}
|
|
407
|
+
function padVisible(s, width) {
|
|
408
|
+
return s + " ".repeat(Math.max(0, width - visibleLength(s)));
|
|
409
|
+
}
|
|
410
|
+
function termWidth(max = 100) {
|
|
411
|
+
const cols = process.stdout.columns || 80;
|
|
412
|
+
return Math.max(40, Math.min(cols, max));
|
|
413
|
+
}
|
|
414
|
+
function heading(title) {
|
|
415
|
+
const rule = glyph.rule.repeat(Math.max(4, Math.min(48, termWidth() - visibleLength(title) - 4)));
|
|
416
|
+
return `${c.bold(title)} ${c.gray(rule)}`;
|
|
417
|
+
}
|
|
418
|
+
function section(title) {
|
|
419
|
+
log.plain("");
|
|
420
|
+
log.plain(heading(title));
|
|
421
|
+
}
|
|
422
|
+
function kv(rows, indent = 2) {
|
|
423
|
+
const shown = rows.filter((r) => Boolean(r[1]));
|
|
424
|
+
const width = Math.max(0, ...shown.map(([k]) => visibleLength(k)));
|
|
425
|
+
return shown.map(([k, v]) => `${" ".repeat(indent)}${c.gray(padVisible(k, width))} ${v}`).join(`
|
|
426
|
+
`);
|
|
427
|
+
}
|
|
428
|
+
function table(head, rows, indent = 2) {
|
|
429
|
+
const all = [head, ...rows];
|
|
430
|
+
const widths = head.map((_, i) => Math.max(...all.map((r) => visibleLength(r[i] ?? ""))));
|
|
431
|
+
const pad = " ".repeat(indent);
|
|
432
|
+
const line = (r) => (pad + r.map((cell, i) => padVisible(cell ?? "", widths[i])).join(" ")).trimEnd();
|
|
433
|
+
return [c.gray(line(head)), ...rows.map(line)].join(`
|
|
434
|
+
`);
|
|
435
|
+
}
|
|
436
|
+
function box(lines, opts = {}) {
|
|
437
|
+
const color = opts.color ?? c.gray;
|
|
438
|
+
const pad = " ".repeat(opts.padding ?? 1);
|
|
439
|
+
const title = opts.title ? ` ${opts.title} ` : "";
|
|
440
|
+
const inner = Math.max(visibleLength(title) + 2, ...lines.map((l) => visibleLength(l) + pad.length * 2));
|
|
441
|
+
const b = glyph.box;
|
|
442
|
+
const top = color(b.tl + b.h) + title + color(b.h.repeat(Math.max(0, inner - visibleLength(title) - 1)) + b.tr);
|
|
443
|
+
const body = lines.map((l) => `${color(b.v)}${pad}${padVisible(l, inner - pad.length * 2)}${pad}${color(b.v)}`);
|
|
444
|
+
const bottom = color(b.bl + b.h.repeat(inner) + b.br);
|
|
445
|
+
return [top, ...body, bottom].join(`
|
|
446
|
+
`);
|
|
447
|
+
}
|
|
448
|
+
function dot(ok) {
|
|
449
|
+
return ok ? c.green(glyph.dotOn) : c.red(glyph.dotOff);
|
|
450
|
+
}
|
|
451
|
+
var ANSI2;
|
|
452
|
+
var init_ui = __esm(() => {
|
|
453
|
+
init_log();
|
|
454
|
+
init_log();
|
|
455
|
+
ANSI2 = /\x1b\[[0-9;?]*[A-Za-z]/g;
|
|
456
|
+
});
|
|
457
|
+
|
|
347
458
|
// src/util/prompt.ts
|
|
348
459
|
function interactive() {
|
|
349
460
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY) && logFormat() !== "json" && !process.env.CI;
|
|
@@ -356,21 +467,21 @@ async function readLine() {
|
|
|
356
467
|
async function ask(question, dflt) {
|
|
357
468
|
if (!interactive())
|
|
358
469
|
return dflt ?? "";
|
|
359
|
-
process.stdout.write(`${
|
|
470
|
+
process.stdout.write(`${mark()} ${c.bold(question)}${dflt ? c.gray(` (${dflt})`) : ""} ${c.gray(glyph.arrow)} `);
|
|
360
471
|
const answer = (await readLine()).trim();
|
|
361
472
|
return answer || dflt || "";
|
|
362
473
|
}
|
|
363
474
|
async function askSecret(question) {
|
|
364
475
|
if (!interactive())
|
|
365
476
|
return "";
|
|
366
|
-
process.stdout.write(`${c.
|
|
477
|
+
process.stdout.write(`${mark()} ${c.bold(question)} ${c.gray(glyph.arrow)} `);
|
|
367
478
|
const answer = (await readLine()).trim();
|
|
368
479
|
return answer;
|
|
369
480
|
}
|
|
370
481
|
async function askPassword(question) {
|
|
371
482
|
if (!interactive())
|
|
372
483
|
return "";
|
|
373
|
-
process.stdout.write(`${c.
|
|
484
|
+
process.stdout.write(`${mark()} ${c.bold(question)} ${c.gray(glyph.arrow)} `);
|
|
374
485
|
const echo = await setEcho(false);
|
|
375
486
|
try {
|
|
376
487
|
return (await readLine()).trim();
|
|
@@ -392,13 +503,13 @@ async function setEcho(on) {
|
|
|
392
503
|
async function pressEnter(message) {
|
|
393
504
|
if (!interactive())
|
|
394
505
|
return;
|
|
395
|
-
process.stdout.write(`${c.cyan(
|
|
506
|
+
process.stdout.write(`${c.cyan(glyph.enter)} ${message} ${c.gray("[press Enter]")} `);
|
|
396
507
|
await readLine();
|
|
397
508
|
}
|
|
398
509
|
async function confirm(question, dflt = false) {
|
|
399
510
|
if (!interactive())
|
|
400
511
|
return dflt;
|
|
401
|
-
const answer = (await ask(`${question} ${dflt ? "[Y/n]" : "[y/N]"}`)).toLowerCase();
|
|
512
|
+
const answer = (await ask(`${question} ${c.gray(dflt ? "[Y/n]" : "[y/N]")}`)).toLowerCase();
|
|
402
513
|
if (!answer)
|
|
403
514
|
return dflt;
|
|
404
515
|
return answer === "y" || answer === "yes";
|
|
@@ -406,12 +517,17 @@ async function confirm(question, dflt = false) {
|
|
|
406
517
|
async function choose(question, options, dflt) {
|
|
407
518
|
if (!interactive())
|
|
408
519
|
return dflt;
|
|
409
|
-
console.log(`${
|
|
410
|
-
options.forEach((o, i) =>
|
|
520
|
+
console.log(`${mark()} ${c.bold(question)}`);
|
|
521
|
+
options.forEach((o, i) => {
|
|
522
|
+
const isDefault = o.value === dflt;
|
|
523
|
+
const num = c.cyan(String(i + 1).padStart(String(options.length).length));
|
|
524
|
+
console.log(` ${num} ${isDefault ? c.cyan(glyph.step) : " "} ${isDefault ? c.bold(o.label) : o.label}${isDefault ? c.gray(" default") : ""}`);
|
|
525
|
+
});
|
|
411
526
|
const answer = (await ask("Choose", String(options.findIndex((o) => o.value === dflt) + 1))).trim();
|
|
412
527
|
const idx = Number(answer) - 1;
|
|
413
528
|
return options[idx]?.value ?? dflt;
|
|
414
529
|
}
|
|
530
|
+
var mark = () => c.bold(c.cyan(glyph.prompt));
|
|
415
531
|
var init_prompt = __esm(() => {
|
|
416
532
|
init_log();
|
|
417
533
|
});
|
|
@@ -680,23 +796,56 @@ var init_names = __esm(() => {
|
|
|
680
796
|
});
|
|
681
797
|
|
|
682
798
|
// src/config/load.ts
|
|
683
|
-
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
799
|
+
import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync, statSync } from "fs";
|
|
684
800
|
import { isIPv6 } from "net";
|
|
685
801
|
import { dirname as dirname2, join as join3, resolve } from "path";
|
|
686
802
|
import { homedir as homedir2 } from "os";
|
|
687
803
|
function findConfigFile(startDir) {
|
|
688
|
-
|
|
804
|
+
const start = resolve(startDir);
|
|
805
|
+
let searchRoot = start;
|
|
806
|
+
let dir = start;
|
|
689
807
|
for (;; ) {
|
|
690
808
|
for (const name of CONFIG_NAMES) {
|
|
691
809
|
const p = join3(dir, name);
|
|
692
|
-
if (
|
|
810
|
+
if (statSync(p, { throwIfNoEntry: false })?.isFile())
|
|
693
811
|
return p;
|
|
694
812
|
}
|
|
813
|
+
if (existsSync2(join3(dir, ".git"))) {
|
|
814
|
+
searchRoot = dir;
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
695
817
|
const parent = dirname2(dir);
|
|
696
818
|
if (parent === dir)
|
|
697
|
-
|
|
819
|
+
break;
|
|
698
820
|
dir = parent;
|
|
699
821
|
}
|
|
822
|
+
const matches = [];
|
|
823
|
+
const pending = [searchRoot];
|
|
824
|
+
while (pending.length) {
|
|
825
|
+
const current = pending.pop();
|
|
826
|
+
let entries;
|
|
827
|
+
try {
|
|
828
|
+
entries = readdirSync2(current, { withFileTypes: true });
|
|
829
|
+
} catch (error) {
|
|
830
|
+
throw new EpdError(`cannot search for epd.yml in ${current}`, `Use --config <file> to select a config directly. ${error instanceof Error ? error.message : String(error)}`);
|
|
831
|
+
}
|
|
832
|
+
if (current !== searchRoot && entries.some((entry) => entry.name === ".git"))
|
|
833
|
+
continue;
|
|
834
|
+
const name = CONFIG_FILENAMES.find((name) => entries.some((entry) => entry.name === name && entry.isFile()));
|
|
835
|
+
if (name)
|
|
836
|
+
matches.push(join3(current, name));
|
|
837
|
+
for (const entry of entries) {
|
|
838
|
+
if (entry.isDirectory() && !SEARCH_EXCLUDES.has(entry.name))
|
|
839
|
+
pending.push(join3(current, entry.name));
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
matches.sort();
|
|
843
|
+
if (matches.length > 1) {
|
|
844
|
+
throw new EpdError(`multiple EPD configs found in ${searchRoot}:
|
|
845
|
+
${matches.map((file) => ` ${file}`).join(`
|
|
846
|
+
`)}`, "Use --config <file> to choose the deployment.");
|
|
847
|
+
}
|
|
848
|
+
return matches[0] ?? null;
|
|
700
849
|
}
|
|
701
850
|
function parseDotenv(text) {
|
|
702
851
|
const out = {};
|
|
@@ -1698,13 +1847,31 @@ function validateCrossReferences(cfg) {
|
|
|
1698
1847
|
}
|
|
1699
1848
|
if (cfg.mode === "docker" && !cfg.registry && cfg.services.some((s) => s.hosts.length > 1)) {}
|
|
1700
1849
|
}
|
|
1701
|
-
var CONFIG_NAMES, nameProblem, HOST_LABEL, HOST_HINT = 'Use a DNS name such as "example.com", "*.example.com" or an IP address.', PATH_HINT = 'Write a path such as "/health" or "/api".', HOST_PORT, BRACKETED_IPV6, asPort = (v, path, dflt) => asInt(v, path, dflt, 1, 65535), IMAGE_REF, IMAGE_HINT = 'Write an image such as "ghcr.io/acme/api:1.2" or "postgres:17". The repository name must be lower case.', SSH_HOST, SSH_USER, ENV_NAME, ENV_NAME_HINT = "Use letters, digits and underscores, starting with a letter or underscore.", TOP_LEVEL_KEYS;
|
|
1850
|
+
var CONFIG_FILENAMES, CONFIG_NAMES, SEARCH_EXCLUDES, nameProblem, HOST_LABEL, HOST_HINT = 'Use a DNS name such as "example.com", "*.example.com" or an IP address.', PATH_HINT = 'Write a path such as "/health" or "/api".', HOST_PORT, BRACKETED_IPV6, asPort = (v, path, dflt) => asInt(v, path, dflt, 1, 65535), IMAGE_REF, IMAGE_HINT = 'Write an image such as "ghcr.io/acme/api:1.2" or "postgres:17". The repository name must be lower case.', SSH_HOST, SSH_USER, ENV_NAME, ENV_NAME_HINT = "Use letters, digits and underscores, starting with a letter or underscore.", TOP_LEVEL_KEYS;
|
|
1702
1851
|
var init_load = __esm(() => {
|
|
1703
1852
|
init_container_engine();
|
|
1704
1853
|
init_log();
|
|
1705
1854
|
init_misc();
|
|
1706
1855
|
init_names();
|
|
1707
|
-
|
|
1856
|
+
CONFIG_FILENAMES = ["epd.yml", "epd.yaml", ".epd.yml"];
|
|
1857
|
+
CONFIG_NAMES = [...CONFIG_FILENAMES, "config/epd.yml"];
|
|
1858
|
+
SEARCH_EXCLUDES = new Set([
|
|
1859
|
+
".git",
|
|
1860
|
+
"node_modules",
|
|
1861
|
+
"vendor",
|
|
1862
|
+
".venv",
|
|
1863
|
+
"venv",
|
|
1864
|
+
"dist",
|
|
1865
|
+
"build",
|
|
1866
|
+
"coverage",
|
|
1867
|
+
".svelte-kit",
|
|
1868
|
+
".vitepress",
|
|
1869
|
+
".next",
|
|
1870
|
+
".nuxt",
|
|
1871
|
+
".output",
|
|
1872
|
+
".turbo",
|
|
1873
|
+
".cache"
|
|
1874
|
+
]);
|
|
1708
1875
|
nameProblem = `must be ${MAX_NAME_LENGTH} characters or fewer: lowercase letters, digits, dashes or underscores, starting with a letter or digit`;
|
|
1709
1876
|
HOST_LABEL = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/i;
|
|
1710
1877
|
HOST_PORT = /:(\d{1,5})$/;
|
|
@@ -1830,7 +1997,7 @@ Use environment variable names for secrets and registry.password. Keep values in
|
|
|
1830
1997
|
the user's shell or a gitignored .env file. Build secrets map IDs to variable
|
|
1831
1998
|
names. Never put secret values in Dockerfiles, command arguments or committed YAML.
|
|
1832
1999
|
|
|
1833
|
-
More schema details are available at https://
|
|
2000
|
+
More schema details are available at https://epddocs.peppi.dev/llms-full.txt.
|
|
1834
2001
|
Validate the installed CLI's behavior instead of guessing flags or JSON schemas.
|
|
1835
2002
|
|
|
1836
2003
|
## Validation and deployment
|
|
@@ -2407,7 +2574,7 @@ var init_http = __esm(() => {
|
|
|
2407
2574
|
});
|
|
2408
2575
|
|
|
2409
2576
|
// src/util/auth.ts
|
|
2410
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readlinkSync, realpathSync, statSync, writeFileSync as writeFileSync3, chmodSync, renameSync, rmSync, unlinkSync as unlinkSync2 } from "fs";
|
|
2577
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readlinkSync, realpathSync, statSync as statSync2, writeFileSync as writeFileSync3, chmodSync, renameSync, rmSync, unlinkSync as unlinkSync2 } from "fs";
|
|
2411
2578
|
import { homedir as homedir3 } from "os";
|
|
2412
2579
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join5 } from "path";
|
|
2413
2580
|
import { spawn } from "child_process";
|
|
@@ -2553,7 +2720,7 @@ function saveProjectEnv(entries, root = process.cwd()) {
|
|
|
2553
2720
|
`;
|
|
2554
2721
|
}
|
|
2555
2722
|
}
|
|
2556
|
-
writeSecretFile(envPath, content, exists ?
|
|
2723
|
+
writeSecretFile(envPath, content, exists ? statSync2(envPath).mode & 511 : 384);
|
|
2557
2724
|
}
|
|
2558
2725
|
function secret(value) {
|
|
2559
2726
|
registerSecret(value);
|
|
@@ -3183,7 +3350,7 @@ ssh:
|
|
|
3183
3350
|
hetzner:
|
|
3184
3351
|
# api_token: \${HETZNER_API_TOKEN}
|
|
3185
3352
|
` : "";
|
|
3186
|
-
return `# ${o.name} \u2014 deployed with epd (https://
|
|
3353
|
+
return `# ${o.name} \u2014 deployed with epd (https://epddocs.peppi.dev)
|
|
3187
3354
|
#
|
|
3188
3355
|
# epd setup prepare the servers and deploy for the first time
|
|
3189
3356
|
# epd deploy build and deploy the current commit
|
|
@@ -5935,7 +6102,17 @@ async function ensureImage(host, cfg, version) {
|
|
|
5935
6102
|
await host.exec(`docker pull ${shq(ref)} >/dev/null`, { label: `${host.name}: docker pull` });
|
|
5936
6103
|
} else {
|
|
5937
6104
|
log.host(host.name, `shipping ${ref} over ssh (no registry configured)`);
|
|
5938
|
-
|
|
6105
|
+
const engine = await containerEngine(cfg.containerEngine);
|
|
6106
|
+
const image = await run([engine, "image", "inspect", "--format", "{{.Id}}", ref]);
|
|
6107
|
+
const digest = image.stdout.trim().replace(/^sha256:/, "");
|
|
6108
|
+
if (!/^[a-f0-9]{64}$/.test(digest)) {
|
|
6109
|
+
throw new EpdError(`Cannot determine image ID for ${ref}`);
|
|
6110
|
+
}
|
|
6111
|
+
const id = `sha256:${digest}`;
|
|
6112
|
+
const firstPart = ref.split("/")[0];
|
|
6113
|
+
const loadedRef = engineKind(engine) === "podman" && (!ref.includes("/") || !firstPart.includes(".") && !firstPart.includes(":") && firstPart !== "localhost") ? `localhost/${ref}` : ref;
|
|
6114
|
+
const restoreTag = loadedRef !== ref ? `docker tag ${shq(loadedRef)} ${shq(ref)}` : `docker tag ${shq(id)} ${shq(ref)}`;
|
|
6115
|
+
await host.pipeInto(`gunzip | docker load && (docker image inspect ${shq(ref)} >/dev/null 2>&1 || ${restoreTag}) && docker image inspect ${shq(ref)} >/dev/null`, [localShell("bash"), "-c", `set -o pipefail; ${shq(engine)} save ${shq(ref)} | gzip -1`]);
|
|
5939
6116
|
}
|
|
5940
6117
|
}
|
|
5941
6118
|
async function pruneImages(host, cfg, keep, inUse) {
|
|
@@ -6786,58 +6963,50 @@ async function deploy(loaded, opts = {}) {
|
|
|
6786
6963
|
const version = (await resolveVersion(cfg, opts.version)).id;
|
|
6787
6964
|
log.step(`Deploying ${c.bold(cfg.name)} ${c.cyan(version)}${cfg.destination ? ` \u2192 ${cfg.destination}` : ""} to ${targetHosts.length} host(s)`, "plan");
|
|
6788
6965
|
if (opts.dryRun) {
|
|
6789
|
-
|
|
6790
|
-
log.plain(
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
log.plain(` Process: ${cfg.process.start}`);
|
|
6801
|
-
}
|
|
6802
|
-
log.plain(`
|
|
6803
|
-
${c.bold("Host & Service Details")}`);
|
|
6966
|
+
section(`Deployment plan ${c.yellow("(dry run)")}`);
|
|
6967
|
+
log.plain(kv([
|
|
6968
|
+
["App", c.bold(cfg.name)],
|
|
6969
|
+
["Mode", cfg.mode],
|
|
6970
|
+
["Version", c.cyan(version)],
|
|
6971
|
+
["Destination", cfg.destination],
|
|
6972
|
+
["Target hosts", targetHosts.map((h) => hostColor(h)(h)).join(c.gray(", "))],
|
|
6973
|
+
["Services", services.map((s) => s.name).join(", ")],
|
|
6974
|
+
cfg.mode === "docker" ? ["Image", `${cfg.image}:${version} ${c.gray(cfg.registry ? `(push to ${cfg.registry.server ?? "docker.io"})` : "(ship over SSH)")}`] : ["Process", cfg.process.start]
|
|
6975
|
+
]));
|
|
6976
|
+
section("Hosts & services");
|
|
6804
6977
|
for (const h of targetHosts) {
|
|
6805
|
-
log.plain(` ${c.
|
|
6978
|
+
log.plain(` ${hostColor(h)(c.bold(h))}`);
|
|
6806
6979
|
for (const svc of services) {
|
|
6807
|
-
log.plain(`
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
}
|
|
6980
|
+
log.plain(` ${c.cyan(glyph.bullet)} ${c.bold(svc.name)} ${c.gray(`${svc.replicas} replica(s) on port ${svc.port}`)}`);
|
|
6981
|
+
const rows = [
|
|
6982
|
+
["health", `${svc.health.path ?? "tcp connect"} ${c.gray(`(status ${svc.health.status}, timeout ${svc.health.timeout}s)`)}`],
|
|
6983
|
+
["host ports", usesHostPorts(cfg) ? `blue=${hostPort(cfg, svc, "blue", 0)}, green=${hostPort(cfg, svc, "green", 0)}` : undefined],
|
|
6984
|
+
...svc.routes.map((r) => ["route", `${c.underline(`${r.ssl ? "https" : "http"}://${r.hosts.join(", ")}${r.path ?? ""}`)} ${c.gray(`${glyph.arrow} :${r.port}`)}`])
|
|
6985
|
+
];
|
|
6986
|
+
log.plain(kv(rows, 6));
|
|
6815
6987
|
}
|
|
6816
6988
|
}
|
|
6817
6989
|
if (cfg.accessories.length) {
|
|
6818
|
-
|
|
6819
|
-
${c.
|
|
6820
|
-
for (const acc of cfg.accessories) {
|
|
6821
|
-
log.plain(` \u2022 ${c.bold(acc.name)}: ${acc.image} on ${acc.host}`);
|
|
6822
|
-
}
|
|
6990
|
+
section("Accessories");
|
|
6991
|
+
log.plain(kv(cfg.accessories.map((acc) => [acc.name, `${acc.image} ${c.gray(`on ${acc.host}`)}`])));
|
|
6823
6992
|
}
|
|
6824
6993
|
if (cfg.proxy.enabled) {
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6994
|
+
section("Proxy & routing");
|
|
6995
|
+
log.plain(kv([
|
|
6996
|
+
["Traefik on", proxyHosts(cfg).join(", ")],
|
|
6997
|
+
["Network", cfg.proxy.network],
|
|
6998
|
+
["SSL", cfg.proxy.ssl ? c.green("enabled") : c.yellow("disabled")]
|
|
6999
|
+
]));
|
|
6829
7000
|
} else {
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
log.plain(` External proxy synchronization enabled (Caddy / Nginx / Traefik)`);
|
|
7001
|
+
section("External proxy");
|
|
7002
|
+
log.plain(" External proxy synchronization enabled (Caddy / Nginx / Traefik)");
|
|
6833
7003
|
}
|
|
6834
7004
|
if (cfg.dns?.enabled && cfg.dns.autoSync || cfg.cloudflare?.enabled && cfg.cloudflare.autoSync) {
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
log.plain(` Auto-sync configured for ${cfg.dns?.provider || "cloudflare"}`);
|
|
7005
|
+
section("DNS");
|
|
7006
|
+
log.plain(kv([["Auto-sync", cfg.dns?.provider || "cloudflare"]]));
|
|
6838
7007
|
}
|
|
6839
|
-
log.plain(
|
|
6840
|
-
|
|
7008
|
+
log.plain("");
|
|
7009
|
+
log.ok(`[dry-run] Plan validated successfully. ${c.gray("No changes were made.")}`);
|
|
6841
7010
|
return;
|
|
6842
7011
|
}
|
|
6843
7012
|
log.step(`Connecting to ${hosts.map((h) => h.target).join(", ")}`, "connect");
|
|
@@ -6879,7 +7048,7 @@ ${c.green("\u2713")} [dry-run] Plan validated successfully. No changes were made
|
|
|
6879
7048
|
if (!opts.skipHooks && cfg.hooks.postDeploy)
|
|
6880
7049
|
await hook(cfg, "post_deploy", cfg.hooks.postDeploy, version);
|
|
6881
7050
|
log.ok(`Deployed ${cfg.name} ${version} in ${dur(Date.now() - started)}`);
|
|
6882
|
-
printUrls(cfg);
|
|
7051
|
+
printUrls(cfg, `${c.green(glyph.ok)} ${c.bold(cfg.name)} ${c.cyan(version)} is live ${c.gray(`(${dur(Date.now() - started)})`)}`);
|
|
6883
7052
|
}
|
|
6884
7053
|
async function deployLocked(cfg, hosts, services, version, opts, fx, prep) {
|
|
6885
7054
|
const snapshot = await snapshotLive(cfg, fx, true);
|
|
@@ -7340,7 +7509,7 @@ async function hook(cfg, name, script, version) {
|
|
|
7340
7509
|
label: `hook ${name}`
|
|
7341
7510
|
});
|
|
7342
7511
|
}
|
|
7343
|
-
function printUrls(cfg) {
|
|
7512
|
+
function printUrls(cfg, title) {
|
|
7344
7513
|
const urls = new Set;
|
|
7345
7514
|
for (const svc of cfg.services) {
|
|
7346
7515
|
for (const route of svc.routes) {
|
|
@@ -7354,12 +7523,19 @@ function printUrls(cfg) {
|
|
|
7354
7523
|
urls.add(`${route.ssl ? "https" : "http"}://${h}${route.path ?? ""}`);
|
|
7355
7524
|
}
|
|
7356
7525
|
}
|
|
7357
|
-
|
|
7358
|
-
|
|
7526
|
+
if (logFormat() === "json" || !title) {
|
|
7527
|
+
for (const u of urls)
|
|
7528
|
+
log.info(c.cyan(u));
|
|
7529
|
+
return;
|
|
7530
|
+
}
|
|
7531
|
+
const lines = urls.size ? [...urls].map((u) => `${c.cyan(glyph.arrow)} ${c.underline(u)}`) : [c.gray("no public routes configured")];
|
|
7532
|
+
log.plain("");
|
|
7533
|
+
log.plain(box(lines, { title, color: c.green, padding: 2 }));
|
|
7359
7534
|
}
|
|
7360
7535
|
var errMsg = (e) => e instanceof Error ? e.message : String(e);
|
|
7361
7536
|
var init_deploy = __esm(() => {
|
|
7362
7537
|
init_log();
|
|
7538
|
+
init_ui();
|
|
7363
7539
|
init_misc();
|
|
7364
7540
|
init_proc();
|
|
7365
7541
|
init_bootstrap();
|
|
@@ -7637,19 +7813,13 @@ Options
|
|
|
7637
7813
|
});
|
|
7638
7814
|
|
|
7639
7815
|
// src/commands/status.ts
|
|
7640
|
-
function
|
|
7641
|
-
|
|
7642
|
-
const widths = head.map((_, i) => Math.max(...all.map((r) => stripAnsi2(r[i] ?? "").length)));
|
|
7643
|
-
const line = (r) => r.map((cell, i) => cell + " ".repeat(Math.max(0, widths[i] - stripAnsi2(cell).length))).join(" ").trimEnd();
|
|
7644
|
-
return [c.gray(line(head)), ...rows.map(line)].join(`
|
|
7645
|
-
`);
|
|
7646
|
-
}
|
|
7647
|
-
function stripAnsi2(s) {
|
|
7648
|
-
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
7816
|
+
function table2(rows, head) {
|
|
7817
|
+
return table(head, rows);
|
|
7649
7818
|
}
|
|
7650
7819
|
var status;
|
|
7651
7820
|
var init_status = __esm(() => {
|
|
7652
7821
|
init_log();
|
|
7822
|
+
init_ui();
|
|
7653
7823
|
init_misc();
|
|
7654
7824
|
init_state();
|
|
7655
7825
|
init_ssh();
|
|
@@ -7690,20 +7860,24 @@ Options
|
|
|
7690
7860
|
console.log(JSON.stringify({ app: cfg.name, mode: cfg.mode, hosts: report }, null, 2));
|
|
7691
7861
|
return;
|
|
7692
7862
|
}
|
|
7693
|
-
log.plain(
|
|
7863
|
+
log.plain("");
|
|
7864
|
+
log.plain(`${c.cyan(glyph.step)} ${c.bold(cfg.name)} ${c.gray(`${cfg.mode}${cfg.destination ? ` \xB7 ${cfg.destination}` : ""} \xB7 ${report.length} host(s)`)}`);
|
|
7694
7865
|
for (const r of report) {
|
|
7695
7866
|
log.plain("");
|
|
7696
7867
|
if (!r.ok) {
|
|
7697
|
-
log.plain(
|
|
7868
|
+
log.plain(heading(hostColor(r.name)(r.name)));
|
|
7869
|
+
log.plain(` ${dot(false)} ${c.red("unreachable")} ${c.gray(r.error)}`);
|
|
7698
7870
|
continue;
|
|
7699
7871
|
}
|
|
7700
7872
|
const version = r.state?.version ? c.cyan(r.state.version) : c.gray("nothing deployed");
|
|
7701
7873
|
const proxyBit = r.proxy ? r.proxy.running ? c.green("proxy up") : c.red(`proxy ${r.proxy.status}`) : c.gray("no proxy");
|
|
7702
|
-
log.plain(
|
|
7874
|
+
log.plain(heading(hostColor(r.name)(r.name)));
|
|
7875
|
+
log.plain(kv([["version", version], ["proxy", proxyBit]]));
|
|
7876
|
+
log.plain("");
|
|
7703
7877
|
if (cfg.mode === "docker") {
|
|
7704
7878
|
const live = new Set(Object.values(r.state?.services ?? {}).map((s) => s.slot));
|
|
7705
7879
|
const rows = r.containers.filter((ct) => ct.service).sort((a, b) => a.name.localeCompare(b.name)).map((ct) => [
|
|
7706
|
-
ct.running
|
|
7880
|
+
dot(ct.running),
|
|
7707
7881
|
ct.service,
|
|
7708
7882
|
live.has(ct.slot) ? c.bold(ct.slot) : c.gray(ct.slot),
|
|
7709
7883
|
ct.version,
|
|
@@ -7711,33 +7885,32 @@ Options
|
|
|
7711
7885
|
]);
|
|
7712
7886
|
const accessories = r.containers.filter((ct) => !ct.service && ct.name.includes("-acc-"));
|
|
7713
7887
|
for (const a of accessories)
|
|
7714
|
-
rows.push([a.running
|
|
7715
|
-
log.plain(rows.length ?
|
|
7888
|
+
rows.push([dot(a.running), c.gray("accessory"), a.name.split("-acc-")[1] ?? "", "", a.status]);
|
|
7889
|
+
log.plain(rows.length ? table2(rows, ["", "server", "slot", "version", "status"]) : c.gray(" no containers"));
|
|
7716
7890
|
} else {
|
|
7717
7891
|
const rows = r.processes.map((p) => [
|
|
7718
|
-
p.status === "online"
|
|
7892
|
+
dot(p.status === "online"),
|
|
7719
7893
|
p.name.replace(`epd-${cfg.name}-`, ""),
|
|
7720
7894
|
p.status,
|
|
7721
7895
|
`${p.restarts} restarts`,
|
|
7722
7896
|
`${Math.round(p.memory / 1024 / 1024)}MB`
|
|
7723
7897
|
]);
|
|
7724
|
-
log.plain(rows.length ?
|
|
7898
|
+
log.plain(rows.length ? table2(rows, ["", "process", "status", "", "memory"]) : c.gray(" no processes"));
|
|
7725
7899
|
}
|
|
7726
7900
|
}
|
|
7727
7901
|
const urls = new Set;
|
|
7728
7902
|
for (const svc of cfg.services)
|
|
7729
7903
|
for (const route of svc.routes)
|
|
7730
7904
|
for (const h of route.hosts)
|
|
7731
|
-
urls.add(`${route.ssl ? "https" : "http"}://${h}${route.path ?? ""} ${c.gray(
|
|
7905
|
+
urls.add(`${route.ssl ? "https" : "http"}://${h}${route.path ?? ""} ${c.gray(`${glyph.arrow} ${svc.name}:${route.port}`)}`);
|
|
7732
7906
|
for (const acc of cfg.accessories)
|
|
7733
7907
|
for (const route of acc.routes)
|
|
7734
7908
|
for (const h of route.hosts)
|
|
7735
|
-
urls.add(`${route.ssl ? "https" : "http"}://${h}${route.path ?? ""} ${c.gray(
|
|
7909
|
+
urls.add(`${route.ssl ? "https" : "http"}://${h}${route.path ?? ""} ${c.gray(`${glyph.arrow} ${acc.name}:${route.port}`)}`);
|
|
7736
7910
|
if (urls.size) {
|
|
7737
|
-
|
|
7738
|
-
${c.bold("Routes")}`);
|
|
7911
|
+
section("Routes");
|
|
7739
7912
|
for (const u of urls)
|
|
7740
|
-
log.plain(` ${u}`);
|
|
7913
|
+
log.plain(` ${c.cyan(glyph.arrow)} ${u}`);
|
|
7741
7914
|
}
|
|
7742
7915
|
}
|
|
7743
7916
|
};
|
|
@@ -9628,7 +9801,7 @@ var init_update = __esm(() => {
|
|
|
9628
9801
|
});
|
|
9629
9802
|
|
|
9630
9803
|
// package.json
|
|
9631
|
-
var version = "0.5.
|
|
9804
|
+
var version = "0.5.19";
|
|
9632
9805
|
var init_package = () => {};
|
|
9633
9806
|
|
|
9634
9807
|
// src/version.ts
|
|
@@ -10673,7 +10846,7 @@ Uses a PostgreSQL accessory in epd.yml. Publishes only to host loopback; use an
|
|
|
10673
10846
|
});
|
|
10674
10847
|
|
|
10675
10848
|
// src/commands/backup.ts
|
|
10676
|
-
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync8, statSync as
|
|
10849
|
+
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync8, statSync as statSync3 } from "fs";
|
|
10677
10850
|
import { dirname as dirname6, join as join12, resolve as resolve5 } from "path";
|
|
10678
10851
|
function detectAccessoryType(decl, cfg) {
|
|
10679
10852
|
const name = decl.name;
|
|
@@ -10821,7 +10994,7 @@ Options
|
|
|
10821
10994
|
});
|
|
10822
10995
|
}
|
|
10823
10996
|
});
|
|
10824
|
-
const stats =
|
|
10997
|
+
const stats = statSync3(localFile);
|
|
10825
10998
|
const sizeMb = (stats.size / (1024 * 1024)).toFixed(2);
|
|
10826
10999
|
const elapsed = dur(Date.now() - t0);
|
|
10827
11000
|
log.ok(`Backed up ${c.bold(target.name)} \u2192 ${c.cyan(localFile)} (${sizeMb} MB in ${elapsed})`);
|
|
@@ -10961,7 +11134,7 @@ Options
|
|
|
10961
11134
|
});
|
|
10962
11135
|
|
|
10963
11136
|
// src/commands/doctor.ts
|
|
10964
|
-
import { existsSync as existsSync13, readdirSync as
|
|
11137
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
10965
11138
|
import { homedir as homedir6 } from "os";
|
|
10966
11139
|
import { join as join13 } from "path";
|
|
10967
11140
|
function printResults(results, prefix = " ") {
|
|
@@ -11063,13 +11236,13 @@ Options
|
|
|
11063
11236
|
message: "SSH_PRIVATE_KEY is set in the environment (ideal for CI)"
|
|
11064
11237
|
});
|
|
11065
11238
|
} else if (existsSync13(sshDir)) {
|
|
11066
|
-
const keys =
|
|
11239
|
+
const keys = readdirSync3(sshDir).filter((f) => ["id_ed25519", "id_rsa", "gh_deploy"].includes(f));
|
|
11067
11240
|
if (keys.length > 0) {
|
|
11068
11241
|
const keyIssues = [];
|
|
11069
11242
|
for (const k of keys) {
|
|
11070
11243
|
const p = join13(sshDir, k);
|
|
11071
11244
|
try {
|
|
11072
|
-
const st =
|
|
11245
|
+
const st = statSync4(p);
|
|
11073
11246
|
const mode = st.mode & 511;
|
|
11074
11247
|
if (mode !== 384 && mode !== 256) {
|
|
11075
11248
|
keyIssues.push(`${k} has insecure permissions (${mode.toString(8)} instead of 600)`);
|
|
@@ -11568,6 +11741,7 @@ var init_commands = __esm(() => {
|
|
|
11568
11741
|
init_log();
|
|
11569
11742
|
init_interrupt();
|
|
11570
11743
|
init_misc();
|
|
11744
|
+
init_ui();
|
|
11571
11745
|
init_prompt();
|
|
11572
11746
|
init_load();
|
|
11573
11747
|
init_commands();
|
|
@@ -11596,45 +11770,99 @@ var CATEGORIES = [
|
|
|
11596
11770
|
commands: ["doctor", "completion", "update"]
|
|
11597
11771
|
}
|
|
11598
11772
|
];
|
|
11773
|
+
var GLOBAL_OPTIONS = [
|
|
11774
|
+
["-c, --config <file>", "Path to epd.yml"],
|
|
11775
|
+
["-d, --destination <d>", "Overlay epd.<d>.yml (staging, production, \u2026)"],
|
|
11776
|
+
["-v, --verbose", "Show every command epd runs"],
|
|
11777
|
+
[" --log-format <f>", `pretty (default) or json: one JSON event per line on stdout,
|
|
11778
|
+
ending with a "result" event (EPD_LOG_FORMAT)`],
|
|
11779
|
+
["-h, --help", "Show help for a command"],
|
|
11780
|
+
[" --version", "Print the epd version"]
|
|
11781
|
+
];
|
|
11782
|
+
var EXAMPLES = [
|
|
11783
|
+
["epd init", "Create an epd.yml for this project"],
|
|
11784
|
+
["epd doctor", "Run pre-flight health & config diagnostics"],
|
|
11785
|
+
["epd setup", "Prepare the servers, then deploy"],
|
|
11786
|
+
["epd deploy", "Build and deploy the current commit"],
|
|
11787
|
+
["epd deploy --dry-run", "Simulate deployment plan without making changes"],
|
|
11788
|
+
["epd deploy -d staging", "Deploy with the staging overlay"],
|
|
11789
|
+
["epd rollback", "Go back to the previous version"],
|
|
11790
|
+
["epd logs -f", "Follow logs from every server"],
|
|
11791
|
+
["epd docker-command", "Print the docker run command epd would use"],
|
|
11792
|
+
["epd completion zsh", "Generate shell autocompletion"]
|
|
11793
|
+
];
|
|
11794
|
+
function columns(rows, color, indent = 4, minWidth = 0) {
|
|
11795
|
+
const width = Math.max(minWidth, ...rows.map(([l]) => l.length + 3));
|
|
11796
|
+
return rows.map(([left, right]) => {
|
|
11797
|
+
const [first, ...more] = right.split(`
|
|
11798
|
+
`);
|
|
11799
|
+
const cont = more.map((l) => `
|
|
11800
|
+
${" ".repeat(indent + width)}${l}`).join("");
|
|
11801
|
+
return `${" ".repeat(indent)}${color(left.padEnd(width))}${first}${cont}`;
|
|
11802
|
+
}).join(`
|
|
11803
|
+
`);
|
|
11804
|
+
}
|
|
11805
|
+
function banner() {
|
|
11806
|
+
return `${c.cyan(c.bold(`${glyph.step} epd`))} ${c.bold("Easy Project Deployer")} ${c.gray(`v${VERSION}`)}`;
|
|
11807
|
+
}
|
|
11599
11808
|
function renderUsage() {
|
|
11809
|
+
const nameWidth = Math.max(...commands.filter((cmd) => !cmd.hidden).map((cmd) => cmd.name.length)) + 3;
|
|
11600
11810
|
const renderedCategories = CATEGORIES.map((cat) => {
|
|
11601
|
-
const
|
|
11811
|
+
const cmds = cat.commands.map((name) => commands.find((cmd) => cmd.name === name)).filter((cmd) => Boolean(cmd && !cmd.hidden));
|
|
11812
|
+
const rows = cmds.map((cmd) => [
|
|
11813
|
+
cmd.name,
|
|
11814
|
+
cmd.summary + (cmd.aliases?.length ? c.gray(` (${cmd.aliases.join(", ")})`) : "")
|
|
11815
|
+
]);
|
|
11602
11816
|
return ` ${c.bold(cat.title)}
|
|
11603
|
-
${
|
|
11604
|
-
`)}`;
|
|
11817
|
+
${columns(rows, c.cyan, 4, nameWidth)}`;
|
|
11605
11818
|
}).join(`
|
|
11606
11819
|
|
|
11607
11820
|
`);
|
|
11608
|
-
|
|
11821
|
+
const examples = columns(EXAMPLES.map(([cmd, desc]) => [cmd, c.gray(desc)]), (s) => `${c.gray("$")} ${s}`, 2);
|
|
11822
|
+
return `
|
|
11823
|
+
${banner()}
|
|
11824
|
+
${c.gray("Zero-downtime deploys to your own servers, with Docker or PM2 behind Traefik.")}
|
|
11609
11825
|
|
|
11610
|
-
${
|
|
11611
|
-
epd <command> [options]
|
|
11826
|
+
${heading("Usage")}
|
|
11827
|
+
${c.gray("$")} epd ${c.cyan("<command>")} ${c.gray("[options]")}
|
|
11612
11828
|
|
|
11613
|
-
${
|
|
11829
|
+
${heading("Commands")}
|
|
11614
11830
|
${renderedCategories}
|
|
11615
11831
|
|
|
11616
|
-
${
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
--version Print the epd version
|
|
11624
|
-
|
|
11625
|
-
${c.bold("Examples")}
|
|
11626
|
-
epd init Create an epd.yml for this project
|
|
11627
|
-
epd doctor Run pre-flight health & config diagnostics
|
|
11628
|
-
epd setup Prepare the servers, then deploy
|
|
11629
|
-
epd deploy Build and deploy the current commit
|
|
11630
|
-
epd deploy --dry-run Simulate deployment plan without making changes
|
|
11631
|
-
epd deploy -d staging Deploy with the staging overlay
|
|
11632
|
-
epd rollback Go back to the previous version
|
|
11633
|
-
epd logs -f Follow logs from every server
|
|
11634
|
-
epd docker-command Print the docker run command epd would use
|
|
11635
|
-
epd completion zsh Generate shell autocompletion
|
|
11832
|
+
${heading("Global options")}
|
|
11833
|
+
${columns(GLOBAL_OPTIONS, c.cyan, 2)}
|
|
11834
|
+
|
|
11835
|
+
${heading("Examples")}
|
|
11836
|
+
${examples}
|
|
11837
|
+
|
|
11838
|
+
${c.gray(`Run ${c.cyan("epd <command> --help")} for details on a command. Docs: ${c.underline("https://epddocs.peppi.dev")}`)}
|
|
11636
11839
|
`;
|
|
11637
11840
|
}
|
|
11841
|
+
function styleHelp(text) {
|
|
11842
|
+
return text.split(`
|
|
11843
|
+
`).map((line, i) => {
|
|
11844
|
+
if (i === 0)
|
|
11845
|
+
return `
|
|
11846
|
+
${line.replace(/^(\x1b\[1m)?(epd[\w -]*?)(\x1b\[0m)?(?= \u2014)/, (_m, _a, name) => c.cyan(c.bold(name)))}`;
|
|
11847
|
+
if (/^[A-Z][A-Za-z0-9 &/()-]{1,40}:?$/.test(stripAnsi2(line)))
|
|
11848
|
+
return heading(stripAnsi2(line).replace(/:$/, ""));
|
|
11849
|
+
if (/\x1b\[/.test(line))
|
|
11850
|
+
return line;
|
|
11851
|
+
const opt = line.match(/^(\s+)(-{1,2}[A-Za-z0-9][^\s]*(?:,? -{1,2}[^\s]+)*(?: <[^>]+>| \[[^\]]+\])?)(\s{2,}|(?<=[>\]])\s+)(.*)$/);
|
|
11852
|
+
if (opt) {
|
|
11853
|
+
const flag = opt[2].replace(/(<[^>]+>|\[[^\]]+\])/g, (m) => c.gray(m));
|
|
11854
|
+
return `${opt[1]}${c.cyan(flag)}${opt[3]}${opt[4]}`;
|
|
11855
|
+
}
|
|
11856
|
+
const env = line.match(/^(\s+)([A-Z][A-Z0-9_]{2,})(\s{2,}.*)$/);
|
|
11857
|
+
if (env)
|
|
11858
|
+
return `${env[1]}${c.cyan(env[2])}${env[3]}`;
|
|
11859
|
+
const ex = line.match(/^(\s+)(epd\b.*?)((?:\s{2,}|\s+#).*)?$/);
|
|
11860
|
+
if (ex)
|
|
11861
|
+
return `${ex[1]}${c.gray("$")} ${ex[2]}${ex[3] ? c.gray(ex[3]) : ""}`;
|
|
11862
|
+
return line;
|
|
11863
|
+
}).join(`
|
|
11864
|
+
`);
|
|
11865
|
+
}
|
|
11638
11866
|
async function main(argv) {
|
|
11639
11867
|
if (argv.includes("--version") && !argv[0]?.startsWith("-")) {}
|
|
11640
11868
|
const first = argv[0];
|
|
@@ -11699,11 +11927,11 @@ Run ${c.cyan("epd --help")} to see the available commands.
|
|
|
11699
11927
|
} catch (e) {
|
|
11700
11928
|
log.error(e instanceof Error ? e.message : String(e));
|
|
11701
11929
|
console.log(`
|
|
11702
|
-
${command.help()}`);
|
|
11930
|
+
${styleHelp(command.help())}`);
|
|
11703
11931
|
return 1;
|
|
11704
11932
|
}
|
|
11705
11933
|
if (parsed.values.help) {
|
|
11706
|
-
console.log(command.help());
|
|
11934
|
+
console.log(styleHelp(command.help()));
|
|
11707
11935
|
return 0;
|
|
11708
11936
|
}
|
|
11709
11937
|
setVerbose(Boolean(parsed.values.verbose));
|
|
@@ -11788,3 +12016,6 @@ try {
|
|
|
11788
12016
|
process.exitCode = 1;
|
|
11789
12017
|
finish(false, 1, error instanceof Error ? error.message : String(error), error instanceof EpdError ? error.hint : undefined);
|
|
11790
12018
|
}
|
|
12019
|
+
export {
|
|
12020
|
+
styleHelp
|
|
12021
|
+
};
|