@fabioplunser/epd 0.5.18 → 0.5.20
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 +47 -17
- package/bin/epd.js +0 -0
- package/dist/cli.js +333 -94
- 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
|
@@ -101,8 +101,87 @@ function redactArgv(argv) {
|
|
|
101
101
|
function stamp(t) {
|
|
102
102
|
return c.dim(c.gray(`${(t / 1000).toFixed(1).padStart(5, " ")}s`));
|
|
103
103
|
}
|
|
104
|
+
function frameWidth() {
|
|
105
|
+
const cols = process.stdout.columns || 80;
|
|
106
|
+
return Math.max(30, Math.min(cols, 120) - FRAME_INDENT.length);
|
|
107
|
+
}
|
|
108
|
+
function frameRule(label, color, corner) {
|
|
109
|
+
const b = glyph.box;
|
|
110
|
+
const room = frameWidth() - 3;
|
|
111
|
+
const text = [...stripAnsi(label)].length > room - 2 ? `${[...stripAnsi(label)].slice(0, room - 3).join("")}\u2026` : label;
|
|
112
|
+
const fill = Math.max(2, room - [...stripAnsi(text)].length - 2);
|
|
113
|
+
return `${FRAME_INDENT}${color(corner + b.h)} ${text} ${color(b.h.repeat(fill))}`;
|
|
114
|
+
}
|
|
115
|
+
function beginFrame(title) {
|
|
116
|
+
if (frame || format !== "pretty")
|
|
117
|
+
return false;
|
|
118
|
+
frame = { title, started: Date.now(), open: false };
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
function endFrame(ok, detail) {
|
|
122
|
+
const f = frame;
|
|
123
|
+
frame = null;
|
|
124
|
+
if (!f?.open)
|
|
125
|
+
return;
|
|
126
|
+
const secs = `${((Date.now() - f.started) / 1000).toFixed(1)}s`;
|
|
127
|
+
const label = ok ? `${c.green(glyph.ok)} ${c.gray(`${detail ?? "done"} in ${secs}`)}` : `${c.red(glyph.error)} ${c.red(detail ?? "failed")} ${c.gray(`after ${secs}`)}`;
|
|
128
|
+
realLog(frameRule(label, ok ? c.gray : c.red, glyph.box.bl));
|
|
129
|
+
}
|
|
130
|
+
function styleOutput(line) {
|
|
131
|
+
line = shortDigests(line);
|
|
132
|
+
if (/^[a-f0-9]{12}$/.test(line))
|
|
133
|
+
return c.gray(line);
|
|
134
|
+
if (/^(Resolved "|Resolving "|Trying to pull|Getting image source signatures|Copying (blob|config)|[a-f0-9]{12}: (Pulling|Waiting|Download|Verifying|Extracting|Pull complete|Already exists))/.test(line))
|
|
135
|
+
return c.gray(line);
|
|
136
|
+
let m = line.match(/^(\[\d+\/\d+\] )?(STEP \d+\/\d+:)(.*)$/);
|
|
137
|
+
if (m)
|
|
138
|
+
return `${m[1] ? c.gray(m[1]) : ""}${c.cyan(m[2])}${c.bold(m[3])}`;
|
|
139
|
+
m = line.match(/^(-->|STEP \d+: COMMIT|COMMIT)(.*)$/);
|
|
140
|
+
if (m)
|
|
141
|
+
return c.gray(line);
|
|
142
|
+
m = line.match(/^(#\d+) (DONE [\d.]+s|CACHED)$/);
|
|
143
|
+
if (m)
|
|
144
|
+
return c.gray(line);
|
|
145
|
+
m = line.match(/^(#\d+) (\[[^\]]+\])(.*)$/);
|
|
146
|
+
if (m)
|
|
147
|
+
return `${c.gray(m[1])} ${c.cyan(m[2])}${c.bold(m[3])}`;
|
|
148
|
+
if (/^#\d+ /.test(line))
|
|
149
|
+
return c.gray(line);
|
|
150
|
+
if (/^(Successfully (tagged|built)|Writing manifest|Storing signatures|Loaded image)/i.test(line))
|
|
151
|
+
return c.green(line);
|
|
152
|
+
if (/^(WARN|WARNING|\[WARNING\])\b/i.test(line))
|
|
153
|
+
return c.yellow(line);
|
|
154
|
+
if (/^(ERROR|Error:|error:|FATAL)/.test(line))
|
|
155
|
+
return c.red(line);
|
|
156
|
+
return line;
|
|
157
|
+
}
|
|
158
|
+
function framed(raw, style = styleOutput) {
|
|
159
|
+
const f = frame;
|
|
160
|
+
const rail = `${FRAME_INDENT}${c.gray(glyph.box.v)} `;
|
|
161
|
+
let out = "";
|
|
162
|
+
if (!f.open) {
|
|
163
|
+
f.open = true;
|
|
164
|
+
out = `${frameRule(c.bold(f.title), c.gray, glyph.box.tl)}
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
const line = shortDigests(stripAnsi(raw).replace(/\t/g, " "));
|
|
168
|
+
const room = frameWidth() - 2;
|
|
169
|
+
const chars = [...line];
|
|
170
|
+
if (!process.stdout.isTTY || chars.length <= room)
|
|
171
|
+
return out + rail + style(line);
|
|
172
|
+
const chunks = [chars.slice(0, room).join("")];
|
|
173
|
+
for (let i = room;i < chars.length; i += room - 2)
|
|
174
|
+
chunks.push(chars.slice(i, i + room - 2).join(""));
|
|
175
|
+
const tone = /^(ERROR|Error:|error:|FATAL)/.test(line) ? c.red : /^(WARN|WARNING)/i.test(line) ? c.yellow : (s) => s;
|
|
176
|
+
return out + chunks.map((chunk, i) => rail + (i === 0 ? style(chunk) : ` ${tone(chunk)}`)).join(`
|
|
177
|
+
`);
|
|
178
|
+
}
|
|
104
179
|
function render(e) {
|
|
105
180
|
const s = stamp(e.t);
|
|
181
|
+
if (frame && (e.level === "info" || e.level === "warn" || e.level === "debug") && !e.host) {
|
|
182
|
+
const color = e.level === "warn" ? c.yellow : c.gray;
|
|
183
|
+
return framed(e.msg.trim(), color);
|
|
184
|
+
}
|
|
106
185
|
switch (e.level) {
|
|
107
186
|
case "step":
|
|
108
187
|
return `${stepsShown++ ? `
|
|
@@ -125,7 +204,7 @@ ${e.hint.split(`
|
|
|
125
204
|
return `${s} ${hostColor(name)(name.padEnd(15).slice(0, 15))} ${c.gray(glyph.pipe)} ${e.msg}`;
|
|
126
205
|
}
|
|
127
206
|
case "output":
|
|
128
|
-
return e.msg;
|
|
207
|
+
return frame ? framed(e.msg) : e.msg;
|
|
129
208
|
case "plain":
|
|
130
209
|
case "result":
|
|
131
210
|
return e.msg;
|
|
@@ -184,7 +263,7 @@ function emitLines(level, args) {
|
|
|
184
263
|
`))
|
|
185
264
|
emit({ level, msg: line });
|
|
186
265
|
}
|
|
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;
|
|
266
|
+
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, frame = null, FRAME_INDENT = " ", shortDigests = (line) => line.replace(/\b(sha256:)?([a-f0-9]{12})[a-f0-9]{52}\b/g, "$1$2"), log, EpdError;
|
|
188
267
|
var init_log = __esm(() => {
|
|
189
268
|
knownSecrets = new Set;
|
|
190
269
|
SECRET_PATTERNS = [
|
|
@@ -561,7 +640,9 @@ async function run(cmd, opts = {}) {
|
|
|
561
640
|
};
|
|
562
641
|
let stdout;
|
|
563
642
|
let stderr;
|
|
564
|
-
let code;
|
|
643
|
+
let code = -1;
|
|
644
|
+
const framed = opts.stream && opts.frame !== false && beginFrame((opts.frame ?? label).split(`
|
|
645
|
+
`)[0].trim());
|
|
565
646
|
try {
|
|
566
647
|
[stdout, stderr, code] = await Promise.all([
|
|
567
648
|
collect(proc.stdout, onLine("stdout"), !opts.stream),
|
|
@@ -570,6 +651,8 @@ async function run(cmd, opts = {}) {
|
|
|
570
651
|
]);
|
|
571
652
|
} finally {
|
|
572
653
|
clearInterval(heartbeat);
|
|
654
|
+
if (framed)
|
|
655
|
+
endFrame(code === 0, code === 0 ? undefined : code === -1 ? "interrupted" : `exit ${code}`);
|
|
573
656
|
}
|
|
574
657
|
log.debug(`exit ${code} after ${Date.now() - startedAt}ms: ${label}`);
|
|
575
658
|
const result = { code, stdout: stdout.trim(), stderr: stderr.trim() };
|
|
@@ -648,6 +731,7 @@ var init_proc = __esm(() => {
|
|
|
648
731
|
});
|
|
649
732
|
|
|
650
733
|
// src/util/container-engine.ts
|
|
734
|
+
import { existsSync as existsSync2 } from "fs";
|
|
651
735
|
import { basename } from "path";
|
|
652
736
|
function validateContainerEngine(value) {
|
|
653
737
|
if (!value.trim() || value.startsWith("-") || /[\s\x00-\x1f;&|`$<>]/.test(value)) {
|
|
@@ -658,42 +742,130 @@ function validateContainerEngine(value) {
|
|
|
658
742
|
function engineKind(engine) {
|
|
659
743
|
return basename(engine).replace(/\.exe$/i, "");
|
|
660
744
|
}
|
|
745
|
+
async function engineStatus(engine) {
|
|
746
|
+
const executable = Bun.which(engine, { PATH: process.env.PATH });
|
|
747
|
+
if (!executable)
|
|
748
|
+
return "missing";
|
|
749
|
+
try {
|
|
750
|
+
const child = Bun.spawn([executable, "info"], { stdout: "ignore", stderr: "ignore", timeout: 1e4 });
|
|
751
|
+
return await child.exited === 0 ? "running" : "stopped";
|
|
752
|
+
} catch {
|
|
753
|
+
return "stopped";
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function startPlan(engine, env) {
|
|
757
|
+
const kind = engineKind(engine);
|
|
758
|
+
const { platform, has } = env;
|
|
759
|
+
if (kind === "podman") {
|
|
760
|
+
if (platform === "linux") {
|
|
761
|
+
return { steps: [{ title: "podman socket", argv: ["systemctl", "--user", "start", "podman.socket"] }] };
|
|
762
|
+
}
|
|
763
|
+
const steps = [];
|
|
764
|
+
if (!env.podmanMachines?.length)
|
|
765
|
+
steps.push({ title: "podman machine init", argv: [engine, "machine", "init"] });
|
|
766
|
+
steps.push({ title: "podman machine start", argv: [engine, "machine", "start"] });
|
|
767
|
+
return { steps };
|
|
768
|
+
}
|
|
769
|
+
if (kind === "docker") {
|
|
770
|
+
if (platform === "darwin") {
|
|
771
|
+
if (env.exists("/Applications/Docker.app"))
|
|
772
|
+
return { steps: [{ title: "Docker Desktop", argv: ["open", "-g", "-a", "Docker"] }] };
|
|
773
|
+
if (has("orbctl"))
|
|
774
|
+
return { steps: [{ title: "OrbStack", argv: ["orbctl", "start"] }] };
|
|
775
|
+
if (has("colima"))
|
|
776
|
+
return { steps: [{ title: "colima start", argv: ["colima", "start"] }] };
|
|
777
|
+
return { steps: [], hint: "Start Docker Desktop, OrbStack or Colima, then run the command again." };
|
|
778
|
+
}
|
|
779
|
+
if (platform === "win32")
|
|
780
|
+
return { steps: [{ title: "Docker Desktop", argv: [engine, "desktop", "start"] }] };
|
|
781
|
+
if (has("systemctl")) {
|
|
782
|
+
return { steps: [{ title: "systemctl start docker", argv: has("sudo") ? ["sudo", "systemctl", "start", "docker"] : ["systemctl", "start", "docker"] }] };
|
|
783
|
+
}
|
|
784
|
+
return { steps: [], hint: "Start the Docker daemon (dockerd), then run the command again." };
|
|
785
|
+
}
|
|
786
|
+
if (kind === "nerdctl") {
|
|
787
|
+
if (has("rdctl"))
|
|
788
|
+
return { steps: [{ title: "Rancher Desktop", argv: ["rdctl", "start"] }] };
|
|
789
|
+
if (has("colima"))
|
|
790
|
+
return { steps: [{ title: "colima start", argv: ["colima", "start", "--runtime", "containerd"] }] };
|
|
791
|
+
if (platform === "linux" && has("systemctl")) {
|
|
792
|
+
return { steps: [{ title: "systemctl start containerd", argv: has("sudo") ? ["sudo", "systemctl", "start", "containerd"] : ["systemctl", "start", "containerd"] }] };
|
|
793
|
+
}
|
|
794
|
+
return { steps: [], hint: "Start containerd (Rancher Desktop, Colima or Lima), then run the command again." };
|
|
795
|
+
}
|
|
796
|
+
return { steps: [], hint: `Start the service ${engine} talks to, then run the command again.` };
|
|
797
|
+
}
|
|
798
|
+
async function podmanMachines(engine) {
|
|
799
|
+
const res = await run([engine, "machine", "list", "--format", "{{.Name}}"], { allowFailure: true });
|
|
800
|
+
return res.code === 0 ? res.stdout.split(`
|
|
801
|
+
`).map((l) => l.trim()).filter(Boolean) : [];
|
|
802
|
+
}
|
|
803
|
+
async function startEngine(engine, timeoutMs = Number(process.env.EPD_ENGINE_START_TIMEOUT_MS ?? 180000)) {
|
|
804
|
+
const name = displayName(engine);
|
|
805
|
+
const platform = process.platform;
|
|
806
|
+
const plan = startPlan(engine, {
|
|
807
|
+
platform,
|
|
808
|
+
has: (bin) => Boolean(Bun.which(bin)),
|
|
809
|
+
exists: existsSync2,
|
|
810
|
+
podmanMachines: engineKind(engine) === "podman" && platform !== "linux" ? await podmanMachines(engine) : undefined
|
|
811
|
+
});
|
|
812
|
+
if (!plan.steps.length)
|
|
813
|
+
throw new EpdError(`Cannot start ${name} from epd`, plan.hint);
|
|
814
|
+
log.step(`Starting ${name}`, "prepare");
|
|
815
|
+
for (const step of plan.steps) {
|
|
816
|
+
const res = await run(step.argv, { stream: true, allowFailure: true, label: step.argv.join(" "), frame: step.title });
|
|
817
|
+
if (res.code !== 0 && !/already running/i.test(`${res.stdout}
|
|
818
|
+
${res.stderr}`)) {
|
|
819
|
+
throw new EpdError(`Could not start ${name}: ${step.argv.join(" ")} exited ${res.code}`, (res.stderr || res.stdout || "").split(`
|
|
820
|
+
`).slice(-8).join(`
|
|
821
|
+
`) || plan.hint);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
const started = Date.now();
|
|
825
|
+
let announced = false;
|
|
826
|
+
while (Date.now() - started < timeoutMs) {
|
|
827
|
+
if (await engineStatus(engine) === "running") {
|
|
828
|
+
const waited = (Date.now() - started) / 1000;
|
|
829
|
+
log.ok(`${name} is running${waited >= 1 ? c.gray(` (ready after ${waited.toFixed(1)}s)`) : ""}`);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
if (!announced) {
|
|
833
|
+
log.info(c.gray(`waiting for ${name} to accept connections\u2026`));
|
|
834
|
+
announced = true;
|
|
835
|
+
}
|
|
836
|
+
await Bun.sleep(1500);
|
|
837
|
+
}
|
|
838
|
+
throw new EpdError(`${name} did not come up within ${Math.round(timeoutMs / 1000)}s`, `Check ${name} itself, then run the command again.`);
|
|
839
|
+
}
|
|
661
840
|
async function containerEngine(configured = "auto", prompt = true) {
|
|
662
841
|
const requested = validateContainerEngine(process.env.EPD_CONTAINER_ENGINE || configured);
|
|
663
842
|
const candidates = requested === "auto" ? CONTAINER_ENGINES : [requested];
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
};
|
|
675
|
-
for (const engine of candidates)
|
|
676
|
-
if (await probe(engine))
|
|
843
|
+
const statuses = await Promise.all(candidates.map(engineStatus));
|
|
844
|
+
const running = candidates.find((_, i) => statuses[i] === "running");
|
|
845
|
+
if (running)
|
|
846
|
+
return running;
|
|
847
|
+
const stopped = candidates.filter((_, i) => statuses[i] === "stopped");
|
|
848
|
+
if (stopped.length && prompt && interactive()) {
|
|
849
|
+
const engine = stopped.length === 1 ? stopped[0] : await choose("Several container engines are installed but none is running. Which one should epd start?", stopped.map((e) => ({ value: e, label: displayName(e) })), stopped[0]);
|
|
850
|
+
const question = stopped.length === 1 ? `${displayName(engine)} is installed but not running. Start it now?` : `Start ${displayName(engine)} now?`;
|
|
851
|
+
if (await confirm(question, true)) {
|
|
852
|
+
await startEngine(engine);
|
|
677
853
|
return engine;
|
|
678
|
-
if (prompt && interactive()) {
|
|
679
|
-
for (;; ) {
|
|
680
|
-
const answer = await ask(`No usable container engine found. Start one and enter its executable, or enter cancel`, requested === "auto" ? "podman" : requested);
|
|
681
|
-
if (answer === "cancel")
|
|
682
|
-
break;
|
|
683
|
-
const engine = validateContainerEngine(answer);
|
|
684
|
-
if (engine !== "auto" && await probe(engine))
|
|
685
|
-
return engine;
|
|
686
|
-
console.error(`Cannot connect with ${engine}. Start its service or VM and try again.`);
|
|
687
854
|
}
|
|
688
855
|
}
|
|
689
|
-
|
|
856
|
+
if (stopped.length) {
|
|
857
|
+
const names = stopped.map(displayName).join(" and ");
|
|
858
|
+
throw new EpdError(`${names} ${stopped.length === 1 ? "is" : "are"} installed but not running`, stopped.some((e) => engineKind(e) === "podman") && process.platform !== "linux" ? "Start it with `podman machine start` (or Docker Desktop for Docker), then run the command again." : "Start the engine's service or VM, then run the command again. EPD_CONTAINER_ENGINE overrides container_engine in epd.yml.");
|
|
859
|
+
}
|
|
860
|
+
throw new EpdError(requested === "auto" ? "No container engine is installed" : `${requested} was not found on this machine`, "Install Docker (https://docs.docker.com/get-docker/) or Podman (https://podman.io/docs/installation), or set container_engine in epd.yml to a Docker-compatible executable. EPD_CONTAINER_ENGINE overrides YAML.");
|
|
690
861
|
}
|
|
691
|
-
var CONTAINER_ENGINES;
|
|
862
|
+
var CONTAINER_ENGINES, DISPLAY, displayName = (engine) => DISPLAY[engineKind(engine)] ?? engine;
|
|
692
863
|
var init_container_engine = __esm(() => {
|
|
693
864
|
init_log();
|
|
694
865
|
init_proc();
|
|
695
866
|
init_prompt();
|
|
696
867
|
CONTAINER_ENGINES = ["docker", "podman", "nerdctl"];
|
|
868
|
+
DISPLAY = { docker: "Docker", podman: "Podman", nerdctl: "nerdctl" };
|
|
697
869
|
});
|
|
698
870
|
|
|
699
871
|
// src/core/names.ts
|
|
@@ -796,23 +968,56 @@ var init_names = __esm(() => {
|
|
|
796
968
|
});
|
|
797
969
|
|
|
798
970
|
// src/config/load.ts
|
|
799
|
-
import { existsSync as
|
|
971
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync, statSync } from "fs";
|
|
800
972
|
import { isIPv6 } from "net";
|
|
801
973
|
import { dirname as dirname2, join as join3, resolve } from "path";
|
|
802
974
|
import { homedir as homedir2 } from "os";
|
|
803
975
|
function findConfigFile(startDir) {
|
|
804
|
-
|
|
976
|
+
const start = resolve(startDir);
|
|
977
|
+
let searchRoot = start;
|
|
978
|
+
let dir = start;
|
|
805
979
|
for (;; ) {
|
|
806
980
|
for (const name of CONFIG_NAMES) {
|
|
807
981
|
const p = join3(dir, name);
|
|
808
|
-
if (
|
|
982
|
+
if (statSync(p, { throwIfNoEntry: false })?.isFile())
|
|
809
983
|
return p;
|
|
810
984
|
}
|
|
985
|
+
if (existsSync3(join3(dir, ".git"))) {
|
|
986
|
+
searchRoot = dir;
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
811
989
|
const parent = dirname2(dir);
|
|
812
990
|
if (parent === dir)
|
|
813
|
-
|
|
991
|
+
break;
|
|
814
992
|
dir = parent;
|
|
815
993
|
}
|
|
994
|
+
const matches = [];
|
|
995
|
+
const pending = [searchRoot];
|
|
996
|
+
while (pending.length) {
|
|
997
|
+
const current = pending.pop();
|
|
998
|
+
let entries;
|
|
999
|
+
try {
|
|
1000
|
+
entries = readdirSync2(current, { withFileTypes: true });
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
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)}`);
|
|
1003
|
+
}
|
|
1004
|
+
if (current !== searchRoot && entries.some((entry) => entry.name === ".git"))
|
|
1005
|
+
continue;
|
|
1006
|
+
const name = CONFIG_FILENAMES.find((name) => entries.some((entry) => entry.name === name && entry.isFile()));
|
|
1007
|
+
if (name)
|
|
1008
|
+
matches.push(join3(current, name));
|
|
1009
|
+
for (const entry of entries) {
|
|
1010
|
+
if (entry.isDirectory() && !SEARCH_EXCLUDES.has(entry.name))
|
|
1011
|
+
pending.push(join3(current, entry.name));
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
matches.sort();
|
|
1015
|
+
if (matches.length > 1) {
|
|
1016
|
+
throw new EpdError(`multiple EPD configs found in ${searchRoot}:
|
|
1017
|
+
${matches.map((file) => ` ${file}`).join(`
|
|
1018
|
+
`)}`, "Use --config <file> to choose the deployment.");
|
|
1019
|
+
}
|
|
1020
|
+
return matches[0] ?? null;
|
|
816
1021
|
}
|
|
817
1022
|
function parseDotenv(text) {
|
|
818
1023
|
const out = {};
|
|
@@ -853,7 +1058,7 @@ function loadEnvironment(root, destination) {
|
|
|
853
1058
|
env[k] = v;
|
|
854
1059
|
for (const f of files) {
|
|
855
1060
|
const p = join3(root, f);
|
|
856
|
-
if (!
|
|
1061
|
+
if (!existsSync3(p))
|
|
857
1062
|
continue;
|
|
858
1063
|
for (const [k, v] of Object.entries(parseDotenv(readFileSync(p, "utf8")))) {
|
|
859
1064
|
if (process.env[k] === undefined)
|
|
@@ -1285,7 +1490,7 @@ function parseHealth(raw, path, dflt) {
|
|
|
1285
1490
|
function loadConfig(opts = {}) {
|
|
1286
1491
|
const cwd = opts.cwd ?? process.cwd();
|
|
1287
1492
|
const configPath = opts.file ? resolve(cwd, opts.file) : findConfigFile(cwd) ?? fail("epd.yml", "not found", "Run `epd init` to create one.");
|
|
1288
|
-
if (!
|
|
1493
|
+
if (!existsSync3(configPath))
|
|
1289
1494
|
throw new EpdError(`config file not found: ${configPath}`);
|
|
1290
1495
|
const root = dirname2(configPath);
|
|
1291
1496
|
const destination = opts.destination;
|
|
@@ -1297,7 +1502,7 @@ function loadConfig(opts = {}) {
|
|
|
1297
1502
|
join3(root, `epd.${destination}.yml`),
|
|
1298
1503
|
join3(root, `epd.${destination}.yaml`),
|
|
1299
1504
|
join3(root, "config", `epd.${destination}.yml`)
|
|
1300
|
-
].filter(
|
|
1505
|
+
].filter(existsSync3);
|
|
1301
1506
|
if (!overlays.length) {
|
|
1302
1507
|
throw new EpdError(`no config found for destination "${destination}"`, `Create ${join3(root, `epd.${destination}.yml`)} with the values that differ.`);
|
|
1303
1508
|
}
|
|
@@ -1814,13 +2019,31 @@ function validateCrossReferences(cfg) {
|
|
|
1814
2019
|
}
|
|
1815
2020
|
if (cfg.mode === "docker" && !cfg.registry && cfg.services.some((s) => s.hosts.length > 1)) {}
|
|
1816
2021
|
}
|
|
1817
|
-
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;
|
|
2022
|
+
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;
|
|
1818
2023
|
var init_load = __esm(() => {
|
|
1819
2024
|
init_container_engine();
|
|
1820
2025
|
init_log();
|
|
1821
2026
|
init_misc();
|
|
1822
2027
|
init_names();
|
|
1823
|
-
|
|
2028
|
+
CONFIG_FILENAMES = ["epd.yml", "epd.yaml", ".epd.yml"];
|
|
2029
|
+
CONFIG_NAMES = [...CONFIG_FILENAMES, "config/epd.yml"];
|
|
2030
|
+
SEARCH_EXCLUDES = new Set([
|
|
2031
|
+
".git",
|
|
2032
|
+
"node_modules",
|
|
2033
|
+
"vendor",
|
|
2034
|
+
".venv",
|
|
2035
|
+
"venv",
|
|
2036
|
+
"dist",
|
|
2037
|
+
"build",
|
|
2038
|
+
"coverage",
|
|
2039
|
+
".svelte-kit",
|
|
2040
|
+
".vitepress",
|
|
2041
|
+
".next",
|
|
2042
|
+
".nuxt",
|
|
2043
|
+
".output",
|
|
2044
|
+
".turbo",
|
|
2045
|
+
".cache"
|
|
2046
|
+
]);
|
|
1824
2047
|
nameProblem = `must be ${MAX_NAME_LENGTH} characters or fewer: lowercase letters, digits, dashes or underscores, starting with a letter or digit`;
|
|
1825
2048
|
HOST_LABEL = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/i;
|
|
1826
2049
|
HOST_PORT = /:(\d{1,5})$/;
|
|
@@ -1946,7 +2169,7 @@ Use environment variable names for secrets and registry.password. Keep values in
|
|
|
1946
2169
|
the user's shell or a gitignored .env file. Build secrets map IDs to variable
|
|
1947
2170
|
names. Never put secret values in Dockerfiles, command arguments or committed YAML.
|
|
1948
2171
|
|
|
1949
|
-
More schema details are available at https://
|
|
2172
|
+
More schema details are available at https://epddocs.peppi.dev/llms-full.txt.
|
|
1950
2173
|
Validate the installed CLI's behavior instead of guessing flags or JSON schemas.
|
|
1951
2174
|
|
|
1952
2175
|
## Validation and deployment
|
|
@@ -2151,7 +2374,7 @@ function proxyHosts(cfg) {
|
|
|
2151
2374
|
}
|
|
2152
2375
|
|
|
2153
2376
|
// src/commands/action.ts
|
|
2154
|
-
import { existsSync as
|
|
2377
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
2155
2378
|
import { dirname as dirname3, join as join4 } from "path";
|
|
2156
2379
|
function detectGitBranch(root) {
|
|
2157
2380
|
try {
|
|
@@ -2375,7 +2598,7 @@ Aliases
|
|
|
2375
2598
|
const destination = ctx.loadOptions.destination;
|
|
2376
2599
|
const defaultFile = join4(root, ".github", "workflows", destination ? `deploy-${destination}.yml` : "deploy.yml");
|
|
2377
2600
|
const targetFile = ctx.values.file || defaultFile;
|
|
2378
|
-
if (
|
|
2601
|
+
if (existsSync4(targetFile) && !ctx.values.force) {
|
|
2379
2602
|
const ok = interactive() && await confirm(`${targetFile} already exists. Overwrite?`, false);
|
|
2380
2603
|
if (!ok) {
|
|
2381
2604
|
log.info(`Aborted. Use ${c.cyan("--force")} to overwrite.`);
|
|
@@ -2523,7 +2746,7 @@ var init_http = __esm(() => {
|
|
|
2523
2746
|
});
|
|
2524
2747
|
|
|
2525
2748
|
// src/util/auth.ts
|
|
2526
|
-
import { existsSync as
|
|
2749
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync3, readlinkSync, realpathSync, statSync as statSync2, writeFileSync as writeFileSync3, chmodSync, renameSync, rmSync, unlinkSync as unlinkSync2 } from "fs";
|
|
2527
2750
|
import { homedir as homedir3 } from "os";
|
|
2528
2751
|
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join5 } from "path";
|
|
2529
2752
|
import { spawn } from "child_process";
|
|
@@ -2550,9 +2773,9 @@ function userHome() {
|
|
|
2550
2773
|
function getGlobalAuthPath() {
|
|
2551
2774
|
const xdgDir = join5(userHome(), ".config", "epd");
|
|
2552
2775
|
const fallbackDir = join5(userHome(), ".epd");
|
|
2553
|
-
if (
|
|
2776
|
+
if (existsSync5(join5(xdgDir, "auth.json")))
|
|
2554
2777
|
return join5(xdgDir, "auth.json");
|
|
2555
|
-
if (
|
|
2778
|
+
if (existsSync5(join5(fallbackDir, "auth.json")))
|
|
2556
2779
|
return join5(fallbackDir, "auth.json");
|
|
2557
2780
|
return join5(xdgDir, "auth.json");
|
|
2558
2781
|
}
|
|
@@ -2561,7 +2784,7 @@ function corruptAuthError(path) {
|
|
|
2561
2784
|
}
|
|
2562
2785
|
function getGlobalAuth() {
|
|
2563
2786
|
const path = getGlobalAuthPath();
|
|
2564
|
-
if (!
|
|
2787
|
+
if (!existsSync5(path))
|
|
2565
2788
|
return {};
|
|
2566
2789
|
let raw;
|
|
2567
2790
|
try {
|
|
@@ -2652,7 +2875,7 @@ function writeTarget(path) {
|
|
|
2652
2875
|
}
|
|
2653
2876
|
function saveProjectEnv(entries, root = process.cwd()) {
|
|
2654
2877
|
const envPath = writeTarget(join5(root, ".env"));
|
|
2655
|
-
const exists =
|
|
2878
|
+
const exists = existsSync5(envPath);
|
|
2656
2879
|
let content = exists ? readFileSync3(envPath, "utf8") : "";
|
|
2657
2880
|
for (const [key, val] of Object.entries(entries)) {
|
|
2658
2881
|
registerSecret(val);
|
|
@@ -2669,7 +2892,7 @@ function saveProjectEnv(entries, root = process.cwd()) {
|
|
|
2669
2892
|
`;
|
|
2670
2893
|
}
|
|
2671
2894
|
}
|
|
2672
|
-
writeSecretFile(envPath, content, exists ?
|
|
2895
|
+
writeSecretFile(envPath, content, exists ? statSync2(envPath).mode & 511 : 384);
|
|
2673
2896
|
}
|
|
2674
2897
|
function secret(value) {
|
|
2675
2898
|
registerSecret(value);
|
|
@@ -2681,7 +2904,7 @@ function getCloudflareToken(root = process.cwd()) {
|
|
|
2681
2904
|
if (process.env.CF_DNS_API_TOKEN)
|
|
2682
2905
|
return secret(process.env.CF_DNS_API_TOKEN);
|
|
2683
2906
|
const envPath = join5(root, ".env");
|
|
2684
|
-
if (
|
|
2907
|
+
if (existsSync5(envPath)) {
|
|
2685
2908
|
try {
|
|
2686
2909
|
const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
|
|
2687
2910
|
if (parsed.CLOUDFLARE_API_TOKEN)
|
|
@@ -2699,7 +2922,7 @@ function getCloudflareTokenSource(root = process.cwd()) {
|
|
|
2699
2922
|
if (process.env.CF_DNS_API_TOKEN)
|
|
2700
2923
|
return "environment variable (CF_DNS_API_TOKEN)";
|
|
2701
2924
|
const envPath = join5(root, ".env");
|
|
2702
|
-
if (
|
|
2925
|
+
if (existsSync5(envPath)) {
|
|
2703
2926
|
try {
|
|
2704
2927
|
const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
|
|
2705
2928
|
if (parsed.CLOUDFLARE_API_TOKEN || parsed.CF_DNS_API_TOKEN)
|
|
@@ -2717,7 +2940,7 @@ function getHetznerToken(root = process.cwd()) {
|
|
|
2717
2940
|
if (process.env.HCLOUD_TOKEN)
|
|
2718
2941
|
return secret(process.env.HCLOUD_TOKEN);
|
|
2719
2942
|
const envPath = join5(root, ".env");
|
|
2720
|
-
if (
|
|
2943
|
+
if (existsSync5(envPath)) {
|
|
2721
2944
|
try {
|
|
2722
2945
|
const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
|
|
2723
2946
|
if (parsed.HETZNER_API_TOKEN)
|
|
@@ -2735,7 +2958,7 @@ function getHetznerTokenSource(root = process.cwd()) {
|
|
|
2735
2958
|
if (process.env.HCLOUD_TOKEN)
|
|
2736
2959
|
return "environment variable (HCLOUD_TOKEN)";
|
|
2737
2960
|
const envPath = join5(root, ".env");
|
|
2738
|
-
if (
|
|
2961
|
+
if (existsSync5(envPath)) {
|
|
2739
2962
|
try {
|
|
2740
2963
|
const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
|
|
2741
2964
|
if (parsed.HETZNER_API_TOKEN || parsed.HCLOUD_TOKEN)
|
|
@@ -3215,18 +3438,18 @@ var init_cloudflare = __esm(() => {
|
|
|
3215
3438
|
});
|
|
3216
3439
|
|
|
3217
3440
|
// src/commands/init.ts
|
|
3218
|
-
import { existsSync as
|
|
3441
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
3219
3442
|
import { basename as basename2, join as join6, resolve as resolve3 } from "path";
|
|
3220
3443
|
function detect(root) {
|
|
3221
3444
|
const name = basename2(root).toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
3222
|
-
const hasDockerfile =
|
|
3445
|
+
const hasDockerfile = existsSync6(join6(root, "Dockerfile"));
|
|
3223
3446
|
const pkgPath = join6(root, "package.json");
|
|
3224
|
-
if (
|
|
3447
|
+
if (existsSync6(pkgPath)) {
|
|
3225
3448
|
let pkg = {};
|
|
3226
3449
|
try {
|
|
3227
3450
|
pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
|
|
3228
3451
|
} catch {}
|
|
3229
|
-
const bun =
|
|
3452
|
+
const bun = existsSync6(join6(root, "bun.lockb")) || existsSync6(join6(root, "bun.lock"));
|
|
3230
3453
|
const scripts = pkg.scripts ?? {};
|
|
3231
3454
|
const runner = bun ? "bun" : "npm";
|
|
3232
3455
|
return {
|
|
@@ -3239,13 +3462,13 @@ function detect(root) {
|
|
|
3239
3462
|
hasDockerfile
|
|
3240
3463
|
};
|
|
3241
3464
|
}
|
|
3242
|
-
if (
|
|
3465
|
+
if (existsSync6(join6(root, "pyproject.toml")) || existsSync6(join6(root, "requirements.txt"))) {
|
|
3243
3466
|
return { name, runtime: "python", port: 8000, install: "pip install -r requirements.txt", start: "python -m uvicorn main:app --host 127.0.0.1 --port $PORT", hasDockerfile };
|
|
3244
3467
|
}
|
|
3245
|
-
if (
|
|
3468
|
+
if (existsSync6(join6(root, "Gemfile"))) {
|
|
3246
3469
|
return { name, runtime: "ruby", port: 3000, install: "bundle install --deployment", start: "bundle exec rails server -p $PORT", hasDockerfile };
|
|
3247
3470
|
}
|
|
3248
|
-
if (
|
|
3471
|
+
if (existsSync6(join6(root, "go.mod"))) {
|
|
3249
3472
|
return { name, runtime: "go", port: 8080, build: "go build -o server .", start: "./server", hasDockerfile };
|
|
3250
3473
|
}
|
|
3251
3474
|
return { name, runtime: "unknown", port: 3000, hasDockerfile };
|
|
@@ -3299,7 +3522,7 @@ ssh:
|
|
|
3299
3522
|
hetzner:
|
|
3300
3523
|
# api_token: \${HETZNER_API_TOKEN}
|
|
3301
3524
|
` : "";
|
|
3302
|
-
return `# ${o.name} \u2014 deployed with epd (https://
|
|
3525
|
+
return `# ${o.name} \u2014 deployed with epd (https://epddocs.peppi.dev)
|
|
3303
3526
|
#
|
|
3304
3527
|
# epd setup prepare the servers and deploy for the first time
|
|
3305
3528
|
# epd deploy build and deploy the current commit
|
|
@@ -3490,7 +3713,7 @@ Options
|
|
|
3490
3713
|
throw new EpdError("Use either --interactive or --yes");
|
|
3491
3714
|
const wizard = interactive() && !ctx.values.yes;
|
|
3492
3715
|
const target = ctx.loadOptions.file ? resolve3(root, ctx.loadOptions.file) : join6(root, "epd.yml");
|
|
3493
|
-
if (
|
|
3716
|
+
if (existsSync6(target) && !ctx.values.force) {
|
|
3494
3717
|
throw new EpdError("epd.yml already exists", "Pass --force to overwrite it.");
|
|
3495
3718
|
}
|
|
3496
3719
|
const ask2 = wizard ? ask : async (_question, value) => value || "";
|
|
@@ -3534,9 +3757,15 @@ Options
|
|
|
3534
3757
|
let engine = validateContainerEngine(ctx.values["container-engine"] || "auto");
|
|
3535
3758
|
if (mode === "docker" && wizard && !ctx.values["container-engine"]) {
|
|
3536
3759
|
engine = validateContainerEngine(await ask2("Local container engine, auto or a Docker-compatible executable", "auto"));
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
engine
|
|
3760
|
+
try {
|
|
3761
|
+
const detectedEngine = await containerEngine(engine);
|
|
3762
|
+
if (engine !== "auto")
|
|
3763
|
+
engine = detectedEngine;
|
|
3764
|
+
} catch (error) {
|
|
3765
|
+
if (!(error instanceof EpdError))
|
|
3766
|
+
throw error;
|
|
3767
|
+
log.warn(`${error.message}. epd will ask again when it needs to build.`);
|
|
3768
|
+
}
|
|
3540
3769
|
}
|
|
3541
3770
|
let hosts = ctx.values.host ?? [];
|
|
3542
3771
|
if (!hosts.length && hetznerToken && wizard) {
|
|
@@ -3799,7 +4028,7 @@ var init_bootstrap = __esm(() => {
|
|
|
3799
4028
|
});
|
|
3800
4029
|
|
|
3801
4030
|
// src/core/ssh.ts
|
|
3802
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
4031
|
+
import { chmodSync as chmodSync2, existsSync as existsSync7, lstatSync, mkdirSync as mkdirSync5, mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
3803
4032
|
import { tmpdir } from "os";
|
|
3804
4033
|
import { join as join7 } from "path";
|
|
3805
4034
|
function controlDirectory(base = tmpdir()) {
|
|
@@ -3934,7 +4163,7 @@ class Host {
|
|
|
3934
4163
|
`, { mode: 384, flag: "wx" });
|
|
3935
4164
|
chmodSync2(keyPath, 384);
|
|
3936
4165
|
} catch {}
|
|
3937
|
-
} else if (
|
|
4166
|
+
} else if (existsSync7(rawEnvKey)) {
|
|
3938
4167
|
keyPath = rawEnvKey;
|
|
3939
4168
|
}
|
|
3940
4169
|
}
|
|
@@ -4363,7 +4592,7 @@ var init_baseline = __esm(() => {
|
|
|
4363
4592
|
});
|
|
4364
4593
|
|
|
4365
4594
|
// src/core/ssh-setup.ts
|
|
4366
|
-
import { existsSync as
|
|
4595
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
4367
4596
|
import { homedir as homedir4, tmpdir as tmpdir2 } from "os";
|
|
4368
4597
|
import { join as join8 } from "path";
|
|
4369
4598
|
function askpassBody(password) {
|
|
@@ -4437,7 +4666,7 @@ grep -qxF -- ${shq(key)} "$HOME/.ssh/authorized_keys" || printf '\\n%s\\n' ${shq
|
|
|
4437
4666
|
setSudoPassword(host.sudoKey, password);
|
|
4438
4667
|
}
|
|
4439
4668
|
} finally {
|
|
4440
|
-
if (
|
|
4669
|
+
if (existsSync8(askpassScript))
|
|
4441
4670
|
unlinkSync3(askpassScript);
|
|
4442
4671
|
}
|
|
4443
4672
|
}
|
|
@@ -4479,9 +4708,9 @@ async function publicKeyFor(host) {
|
|
|
4479
4708
|
const identityIndex = options.indexOf("-i");
|
|
4480
4709
|
const identity = identityIndex >= 0 ? options[identityIndex + 1] : undefined;
|
|
4481
4710
|
if (identity) {
|
|
4482
|
-
if (
|
|
4711
|
+
if (existsSync8(`${identity}.pub`))
|
|
4483
4712
|
return validateKey(readFileSync5(`${identity}.pub`, "utf8"));
|
|
4484
|
-
if (!
|
|
4713
|
+
if (!existsSync8(identity))
|
|
4485
4714
|
throw new EpdError(`SSH identity does not exist: ${identity}`);
|
|
4486
4715
|
const proc = Bun.spawn(["ssh-keygen", "-y", "-f", identity], {
|
|
4487
4716
|
stdin: "inherit",
|
|
@@ -4503,11 +4732,11 @@ async function publicKeyFor(host) {
|
|
|
4503
4732
|
const sshDir = join8(homedir4(), ".ssh");
|
|
4504
4733
|
for (const name of ["id_ed25519", "gh_deploy", "id_ecdsa", "id_rsa"]) {
|
|
4505
4734
|
const path = join8(sshDir, `${name}.pub`);
|
|
4506
|
-
if (
|
|
4735
|
+
if (existsSync8(path))
|
|
4507
4736
|
return validateKey(readFileSync5(path, "utf8"));
|
|
4508
4737
|
}
|
|
4509
4738
|
const keyPath = join8(sshDir, "id_ed25519");
|
|
4510
|
-
if (
|
|
4739
|
+
if (existsSync8(keyPath)) {
|
|
4511
4740
|
throw new EpdError(`Missing public key for ${keyPath}`, "Load it with ssh-add, or set ssh.key to its path, then retry.");
|
|
4512
4741
|
}
|
|
4513
4742
|
mkdirSync6(sshDir, { recursive: true, mode: 448 });
|
|
@@ -4538,7 +4767,7 @@ var init_ssh_setup = __esm(() => {
|
|
|
4538
4767
|
});
|
|
4539
4768
|
|
|
4540
4769
|
// src/proxy/detect.ts
|
|
4541
|
-
import { existsSync as
|
|
4770
|
+
import { existsSync as existsSync9, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
|
|
4542
4771
|
import { basename as basename3, resolve as resolve4 } from "path";
|
|
4543
4772
|
async function detectExistingProxy(host, checkPorts = [80, 443]) {
|
|
4544
4773
|
const portsSet = new Set(checkPorts);
|
|
@@ -4752,7 +4981,7 @@ http:
|
|
|
4752
4981
|
}
|
|
4753
4982
|
function updateLocalConfigDisableProxy(configPath = "epd.yml") {
|
|
4754
4983
|
const configFile = resolve4(configPath);
|
|
4755
|
-
if (!
|
|
4984
|
+
if (!existsSync9(configFile))
|
|
4756
4985
|
return;
|
|
4757
4986
|
try {
|
|
4758
4987
|
const raw = readFileSync6(configFile, "utf8");
|
|
@@ -4854,7 +5083,7 @@ ${c.gray(snippet)}`);
|
|
|
4854
5083
|
log.plain(`
|
|
4855
5084
|
${c.yellow("!")} Unrecognized reverse proxy detected (${detected.details}).`);
|
|
4856
5085
|
const customConfig = await ask("Provide path to your custom proxy configuration file to deploy (or leave empty to configure manually):");
|
|
4857
|
-
if (customConfig &&
|
|
5086
|
+
if (customConfig && existsSync9(customConfig)) {
|
|
4858
5087
|
const content = readFileSync6(customConfig, "utf8");
|
|
4859
5088
|
const defaultRemote = `/etc/proxy/${basename3(customConfig)}`;
|
|
4860
5089
|
const remotePath = await ask(`Remote destination path on ${host.name}:`, defaultRemote);
|
|
@@ -5897,12 +6126,12 @@ var init_state = __esm(() => {
|
|
|
5897
6126
|
});
|
|
5898
6127
|
|
|
5899
6128
|
// src/deploy/image.ts
|
|
5900
|
-
import { existsSync as
|
|
6129
|
+
import { existsSync as existsSync10 } from "fs";
|
|
5901
6130
|
import { join as join9 } from "path";
|
|
5902
6131
|
async function resolveVersion(cfg, explicit) {
|
|
5903
6132
|
if (explicit)
|
|
5904
6133
|
return { id: explicit, source: "explicit", dirty: false };
|
|
5905
|
-
if (
|
|
6134
|
+
if (existsSync10(join9(cfg.root, ".git")) && await which("git")) {
|
|
5906
6135
|
const sha = await run(["git", "-C", cfg.root, "rev-parse", "--short=12", "HEAD"], { allowFailure: true });
|
|
5907
6136
|
if (sha.code === 0 && sha.stdout) {
|
|
5908
6137
|
const status = await run(["git", "-C", cfg.root, "status", "--porcelain"], { allowFailure: true });
|
|
@@ -5920,7 +6149,7 @@ async function hasBuildx(configured) {
|
|
|
5920
6149
|
}
|
|
5921
6150
|
async function buildImage(cfg, version, env) {
|
|
5922
6151
|
const dockerfile = join9(cfg.root, cfg.build.dockerfile);
|
|
5923
|
-
if (!
|
|
6152
|
+
if (!existsSync10(dockerfile)) {
|
|
5924
6153
|
throw new EpdError(`${cfg.build.dockerfile} not found`, "Add a Dockerfile, point build.dockerfile at yours, or switch to `mode: process`.");
|
|
5925
6154
|
}
|
|
5926
6155
|
cfg.containerEngine = await containerEngine(cfg.containerEngine);
|
|
@@ -5959,7 +6188,7 @@ async function buildWithBuildx(cfg, ref, version, env) {
|
|
|
5959
6188
|
}
|
|
5960
6189
|
args.push(cfg.build.context);
|
|
5961
6190
|
await ensureBuilder(engine);
|
|
5962
|
-
await run(args, { cwd: cfg.root, stream: true, env, label: "docker buildx build" });
|
|
6191
|
+
await run(args, { cwd: cfg.root, stream: true, env, label: "docker buildx build", frame: `docker buildx build ${c.gray(`\xB7 ${cfg.build.platform}`)}` });
|
|
5963
6192
|
}
|
|
5964
6193
|
async function buildWithLegacyDocker(cfg, ref, version, env) {
|
|
5965
6194
|
const engine = await containerEngine(cfg.containerEngine);
|
|
@@ -5988,11 +6217,11 @@ async function buildWithLegacyDocker(cfg, ref, version, env) {
|
|
|
5988
6217
|
args.push("--build-arg", `${k}=${v}`);
|
|
5989
6218
|
args.push("--label", `epd.app=${cfg.name}`, "--label", `epd.version=${version}`);
|
|
5990
6219
|
args.push(cfg.build.context);
|
|
5991
|
-
await run(args, { cwd: cfg.root, stream: true, env, label: `${engine} build` });
|
|
6220
|
+
await run(args, { cwd: cfg.root, stream: true, env, label: `${engine} build`, frame: `${engineKind(engine)} build ${c.gray(`\xB7 ${kind === "docker" ? localPlatform : cfg.build.platform}`)}` });
|
|
5992
6221
|
if (cfg.registry) {
|
|
5993
6222
|
log.step(`Pushing ${ref}`, "push");
|
|
5994
|
-
await run([engine, "push", ref], { stream: true });
|
|
5995
|
-
await run([engine, "push", `${cfg.image}:latest`], { stream: true, allowFailure: true });
|
|
6223
|
+
await run([engine, "push", ref], { stream: true, frame: `${engineKind(engine)} push` });
|
|
6224
|
+
await run([engine, "push", `${cfg.image}:latest`], { stream: true, allowFailure: true, frame: `${engineKind(engine)} push ${c.gray("\xB7 latest")}` });
|
|
5996
6225
|
}
|
|
5997
6226
|
}
|
|
5998
6227
|
async function ensureBuilder(engine = "docker") {
|
|
@@ -6051,7 +6280,17 @@ async function ensureImage(host, cfg, version) {
|
|
|
6051
6280
|
await host.exec(`docker pull ${shq(ref)} >/dev/null`, { label: `${host.name}: docker pull` });
|
|
6052
6281
|
} else {
|
|
6053
6282
|
log.host(host.name, `shipping ${ref} over ssh (no registry configured)`);
|
|
6054
|
-
|
|
6283
|
+
const engine = await containerEngine(cfg.containerEngine);
|
|
6284
|
+
const image = await run([engine, "image", "inspect", "--format", "{{.Id}}", ref]);
|
|
6285
|
+
const digest = image.stdout.trim().replace(/^sha256:/, "");
|
|
6286
|
+
if (!/^[a-f0-9]{64}$/.test(digest)) {
|
|
6287
|
+
throw new EpdError(`Cannot determine image ID for ${ref}`);
|
|
6288
|
+
}
|
|
6289
|
+
const id = `sha256:${digest}`;
|
|
6290
|
+
const firstPart = ref.split("/")[0];
|
|
6291
|
+
const loadedRef = engineKind(engine) === "podman" && (!ref.includes("/") || !firstPart.includes(".") && !firstPart.includes(":") && firstPart !== "localhost") ? `localhost/${ref}` : ref;
|
|
6292
|
+
const restoreTag = loadedRef !== ref ? `docker tag ${shq(loadedRef)} ${shq(ref)}` : `docker tag ${shq(id)} ${shq(ref)}`;
|
|
6293
|
+
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`]);
|
|
6055
6294
|
}
|
|
6056
6295
|
}
|
|
6057
6296
|
async function pruneImages(host, cfg, keep, inUse) {
|
|
@@ -6261,7 +6500,7 @@ var init_docker = __esm(() => {
|
|
|
6261
6500
|
});
|
|
6262
6501
|
|
|
6263
6502
|
// src/deploy/process.ts
|
|
6264
|
-
import { existsSync as
|
|
6503
|
+
import { existsSync as existsSync11 } from "fs";
|
|
6265
6504
|
import { join as join10 } from "path";
|
|
6266
6505
|
function releaseDir(cfg, version) {
|
|
6267
6506
|
return `${paths(cfg).releases}/${version}`;
|
|
@@ -6271,7 +6510,7 @@ async function uploadSource(host, cfg, version) {
|
|
|
6271
6510
|
const p = paths(cfg);
|
|
6272
6511
|
await host.exec(`mkdir -p ${shq(p.releases)} ${shq(p.shared)}`, asUser);
|
|
6273
6512
|
if (cfg.process.source === "git") {
|
|
6274
|
-
if (!
|
|
6513
|
+
if (!existsSync11(join10(cfg.root, ".git")))
|
|
6275
6514
|
throw new EpdError('process.source is "git" but this is not a git repository');
|
|
6276
6515
|
log.host(host.name, `uploading HEAD as ${version}`);
|
|
6277
6516
|
await host.pipeInto(`mkdir -p ${shq(dest)} && tar -x -C ${shq(dest)}`, ["git", "-C", cfg.root, "archive", "--format=tar", "HEAD"]);
|
|
@@ -9499,7 +9738,7 @@ ${c.bold("SEVALLA MANAGED DATABASES")} (${dbs.length})
|
|
|
9499
9738
|
|
|
9500
9739
|
// src/core/update.ts
|
|
9501
9740
|
import { createHash } from "crypto";
|
|
9502
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
9741
|
+
import { chmodSync as chmodSync3, existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync7, renameSync as renameSync2, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
9503
9742
|
import { homedir as homedir5 } from "os";
|
|
9504
9743
|
import { basename as basename4, dirname as dirname5, join as join11 } from "path";
|
|
9505
9744
|
function isValidVersion(version) {
|
|
@@ -9601,7 +9840,7 @@ function getCachePath() {
|
|
|
9601
9840
|
function readCache() {
|
|
9602
9841
|
try {
|
|
9603
9842
|
const p = getCachePath();
|
|
9604
|
-
if (
|
|
9843
|
+
if (existsSync12(p)) {
|
|
9605
9844
|
return JSON.parse(readFileSync7(p, "utf8"));
|
|
9606
9845
|
}
|
|
9607
9846
|
} catch {}
|
|
@@ -9740,7 +9979,7 @@ var init_update = __esm(() => {
|
|
|
9740
9979
|
});
|
|
9741
9980
|
|
|
9742
9981
|
// package.json
|
|
9743
|
-
var version = "0.5.
|
|
9982
|
+
var version = "0.5.20";
|
|
9744
9983
|
var init_package = () => {};
|
|
9745
9984
|
|
|
9746
9985
|
// src/version.ts
|
|
@@ -10785,7 +11024,7 @@ Uses a PostgreSQL accessory in epd.yml. Publishes only to host loopback; use an
|
|
|
10785
11024
|
});
|
|
10786
11025
|
|
|
10787
11026
|
// src/commands/backup.ts
|
|
10788
|
-
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync8, statSync as
|
|
11027
|
+
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync8, statSync as statSync3 } from "fs";
|
|
10789
11028
|
import { dirname as dirname6, join as join12, resolve as resolve5 } from "path";
|
|
10790
11029
|
function detectAccessoryType(decl, cfg) {
|
|
10791
11030
|
const name = decl.name;
|
|
@@ -10933,7 +11172,7 @@ Options
|
|
|
10933
11172
|
});
|
|
10934
11173
|
}
|
|
10935
11174
|
});
|
|
10936
|
-
const stats =
|
|
11175
|
+
const stats = statSync3(localFile);
|
|
10937
11176
|
const sizeMb = (stats.size / (1024 * 1024)).toFixed(2);
|
|
10938
11177
|
const elapsed = dur(Date.now() - t0);
|
|
10939
11178
|
log.ok(`Backed up ${c.bold(target.name)} \u2192 ${c.cyan(localFile)} (${sizeMb} MB in ${elapsed})`);
|
|
@@ -10943,7 +11182,7 @@ Options
|
|
|
10943
11182
|
});
|
|
10944
11183
|
|
|
10945
11184
|
// src/commands/restore.ts
|
|
10946
|
-
import { createReadStream as createReadStream3, existsSync as
|
|
11185
|
+
import { createReadStream as createReadStream3, existsSync as existsSync13 } from "fs";
|
|
10947
11186
|
import { basename as basename5, resolve as resolve6 } from "path";
|
|
10948
11187
|
var restore;
|
|
10949
11188
|
var init_restore = __esm(() => {
|
|
@@ -10971,7 +11210,7 @@ Options
|
|
|
10971
11210
|
if (!backupPath)
|
|
10972
11211
|
throw new EpdError("Please provide a path to the backup file to restore.");
|
|
10973
11212
|
const absPath = resolve6(backupPath);
|
|
10974
|
-
if (!
|
|
11213
|
+
if (!existsSync13(absPath))
|
|
10975
11214
|
throw new EpdError(`Backup file not found: ${absPath}`);
|
|
10976
11215
|
const loaded = ctx.load();
|
|
10977
11216
|
const cfg = loaded.config;
|
|
@@ -11073,7 +11312,7 @@ Options
|
|
|
11073
11312
|
});
|
|
11074
11313
|
|
|
11075
11314
|
// src/commands/doctor.ts
|
|
11076
|
-
import { existsSync as
|
|
11315
|
+
import { existsSync as existsSync14, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
11077
11316
|
import { homedir as homedir6 } from "os";
|
|
11078
11317
|
import { join as join13 } from "path";
|
|
11079
11318
|
function printResults(results, prefix = " ") {
|
|
@@ -11174,14 +11413,14 @@ Options
|
|
|
11174
11413
|
status: "ok",
|
|
11175
11414
|
message: "SSH_PRIVATE_KEY is set in the environment (ideal for CI)"
|
|
11176
11415
|
});
|
|
11177
|
-
} else if (
|
|
11178
|
-
const keys =
|
|
11416
|
+
} else if (existsSync14(sshDir)) {
|
|
11417
|
+
const keys = readdirSync3(sshDir).filter((f) => ["id_ed25519", "id_rsa", "gh_deploy"].includes(f));
|
|
11179
11418
|
if (keys.length > 0) {
|
|
11180
11419
|
const keyIssues = [];
|
|
11181
11420
|
for (const k of keys) {
|
|
11182
11421
|
const p = join13(sshDir, k);
|
|
11183
11422
|
try {
|
|
11184
|
-
const st =
|
|
11423
|
+
const st = statSync4(p);
|
|
11185
11424
|
const mode = st.mode & 511;
|
|
11186
11425
|
if (mode !== 384 && mode !== 256) {
|
|
11187
11426
|
keyIssues.push(`${k} has insecure permissions (${mode.toString(8)} instead of 600)`);
|
|
@@ -11774,7 +12013,7 @@ ${columns(GLOBAL_OPTIONS, c.cyan, 2)}
|
|
|
11774
12013
|
${heading("Examples")}
|
|
11775
12014
|
${examples}
|
|
11776
12015
|
|
|
11777
|
-
${c.gray(`Run ${c.cyan("epd <command> --help")} for details on a command. Docs: ${c.underline("https://
|
|
12016
|
+
${c.gray(`Run ${c.cyan("epd <command> --help")} for details on a command. Docs: ${c.underline("https://epddocs.peppi.dev")}`)}
|
|
11778
12017
|
`;
|
|
11779
12018
|
}
|
|
11780
12019
|
function styleHelp(text) {
|