@fabioplunser/epd 0.5.19 → 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.
Files changed (3) hide show
  1. package/README.md +10 -3
  2. package/dist/cli.js +259 -81
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -134,11 +134,18 @@ scripts, and the dashboard SSH test runner select a running Docker, Podman or ne
134
134
  engine, in that order. OrbStack, Colima and Rancher Desktop can work through
135
135
  their Docker-compatible CLI. Set `container_engine: podman` in `epd.yml`,
136
136
  or use a custom Docker-compatible executable name or path. The environment
137
- variable `EPD_CONTAINER_ENGINE` overrides YAML. When no engine works, a terminal
138
- session asks for an executable. Scripts fail with setup instructions.
137
+ variable `EPD_CONTAINER_ENGINE` overrides YAML. When an engine is installed but
138
+ not running, a terminal session offers to start it: `podman machine start` (after
139
+ `podman machine init` if no machine exists), Docker Desktop in the background,
140
+ OrbStack, Colima, Rancher Desktop or the system service. epd then waits until the
141
+ engine answers. Scripts and CI fail with setup instructions instead of asking.
139
142
  An explicit choice never silently falls back.
140
143
 
141
- On macOS, start the Podman VM with `podman machine start`. Then run
144
+ Build, push and engine start output is drawn in a frame under the step that
145
+ started it, with image digests shortened. `--log-format json` and run logs keep
146
+ every line unchanged.
147
+
148
+ To run the dashboard locally with Podman on macOS, start the VM first. Then run
142
149
  `bun run dashboard:up` as usual. Podman Compose needs an installed Compose
143
150
  provider such as `podman-compose`. Podman builds use the configured platform
144
151
  and Docker image format so images can be loaded on Docker servers.
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 probe = async (engine) => {
665
- const executable = Bun.which(engine, { PATH: process.env.PATH });
666
- if (!executable)
667
- return false;
668
- try {
669
- const child = Bun.spawn([executable, "info"], { stdout: "ignore", stderr: "ignore", timeout: 1e4 });
670
- return await child.exited === 0;
671
- } catch {
672
- return false;
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
- throw new EpdError("No usable local container engine", "Start Docker, Podman or nerdctl, or set container_engine in epd.yml to a Docker-compatible executable. EPD_CONTAINER_ENGINE overrides YAML. On macOS, start your Podman machine.");
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,7 +968,7 @@ var init_names = __esm(() => {
796
968
  });
797
969
 
798
970
  // src/config/load.ts
799
- import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync, statSync } from "fs";
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";
@@ -810,7 +982,7 @@ function findConfigFile(startDir) {
810
982
  if (statSync(p, { throwIfNoEntry: false })?.isFile())
811
983
  return p;
812
984
  }
813
- if (existsSync2(join3(dir, ".git"))) {
985
+ if (existsSync3(join3(dir, ".git"))) {
814
986
  searchRoot = dir;
815
987
  break;
816
988
  }
@@ -886,7 +1058,7 @@ function loadEnvironment(root, destination) {
886
1058
  env[k] = v;
887
1059
  for (const f of files) {
888
1060
  const p = join3(root, f);
889
- if (!existsSync2(p))
1061
+ if (!existsSync3(p))
890
1062
  continue;
891
1063
  for (const [k, v] of Object.entries(parseDotenv(readFileSync(p, "utf8")))) {
892
1064
  if (process.env[k] === undefined)
@@ -1318,7 +1490,7 @@ function parseHealth(raw, path, dflt) {
1318
1490
  function loadConfig(opts = {}) {
1319
1491
  const cwd = opts.cwd ?? process.cwd();
1320
1492
  const configPath = opts.file ? resolve(cwd, opts.file) : findConfigFile(cwd) ?? fail("epd.yml", "not found", "Run `epd init` to create one.");
1321
- if (!existsSync2(configPath))
1493
+ if (!existsSync3(configPath))
1322
1494
  throw new EpdError(`config file not found: ${configPath}`);
1323
1495
  const root = dirname2(configPath);
1324
1496
  const destination = opts.destination;
@@ -1330,7 +1502,7 @@ function loadConfig(opts = {}) {
1330
1502
  join3(root, `epd.${destination}.yml`),
1331
1503
  join3(root, `epd.${destination}.yaml`),
1332
1504
  join3(root, "config", `epd.${destination}.yml`)
1333
- ].filter(existsSync2);
1505
+ ].filter(existsSync3);
1334
1506
  if (!overlays.length) {
1335
1507
  throw new EpdError(`no config found for destination "${destination}"`, `Create ${join3(root, `epd.${destination}.yml`)} with the values that differ.`);
1336
1508
  }
@@ -2202,7 +2374,7 @@ function proxyHosts(cfg) {
2202
2374
  }
2203
2375
 
2204
2376
  // src/commands/action.ts
2205
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
2377
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
2206
2378
  import { dirname as dirname3, join as join4 } from "path";
2207
2379
  function detectGitBranch(root) {
2208
2380
  try {
@@ -2426,7 +2598,7 @@ Aliases
2426
2598
  const destination = ctx.loadOptions.destination;
2427
2599
  const defaultFile = join4(root, ".github", "workflows", destination ? `deploy-${destination}.yml` : "deploy.yml");
2428
2600
  const targetFile = ctx.values.file || defaultFile;
2429
- if (existsSync3(targetFile) && !ctx.values.force) {
2601
+ if (existsSync4(targetFile) && !ctx.values.force) {
2430
2602
  const ok = interactive() && await confirm(`${targetFile} already exists. Overwrite?`, false);
2431
2603
  if (!ok) {
2432
2604
  log.info(`Aborted. Use ${c.cyan("--force")} to overwrite.`);
@@ -2574,7 +2746,7 @@ var init_http = __esm(() => {
2574
2746
  });
2575
2747
 
2576
2748
  // src/util/auth.ts
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";
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";
2578
2750
  import { homedir as homedir3 } from "os";
2579
2751
  import { dirname as dirname4, isAbsolute as isAbsolute2, join as join5 } from "path";
2580
2752
  import { spawn } from "child_process";
@@ -2601,9 +2773,9 @@ function userHome() {
2601
2773
  function getGlobalAuthPath() {
2602
2774
  const xdgDir = join5(userHome(), ".config", "epd");
2603
2775
  const fallbackDir = join5(userHome(), ".epd");
2604
- if (existsSync4(join5(xdgDir, "auth.json")))
2776
+ if (existsSync5(join5(xdgDir, "auth.json")))
2605
2777
  return join5(xdgDir, "auth.json");
2606
- if (existsSync4(join5(fallbackDir, "auth.json")))
2778
+ if (existsSync5(join5(fallbackDir, "auth.json")))
2607
2779
  return join5(fallbackDir, "auth.json");
2608
2780
  return join5(xdgDir, "auth.json");
2609
2781
  }
@@ -2612,7 +2784,7 @@ function corruptAuthError(path) {
2612
2784
  }
2613
2785
  function getGlobalAuth() {
2614
2786
  const path = getGlobalAuthPath();
2615
- if (!existsSync4(path))
2787
+ if (!existsSync5(path))
2616
2788
  return {};
2617
2789
  let raw;
2618
2790
  try {
@@ -2703,7 +2875,7 @@ function writeTarget(path) {
2703
2875
  }
2704
2876
  function saveProjectEnv(entries, root = process.cwd()) {
2705
2877
  const envPath = writeTarget(join5(root, ".env"));
2706
- const exists = existsSync4(envPath);
2878
+ const exists = existsSync5(envPath);
2707
2879
  let content = exists ? readFileSync3(envPath, "utf8") : "";
2708
2880
  for (const [key, val] of Object.entries(entries)) {
2709
2881
  registerSecret(val);
@@ -2732,7 +2904,7 @@ function getCloudflareToken(root = process.cwd()) {
2732
2904
  if (process.env.CF_DNS_API_TOKEN)
2733
2905
  return secret(process.env.CF_DNS_API_TOKEN);
2734
2906
  const envPath = join5(root, ".env");
2735
- if (existsSync4(envPath)) {
2907
+ if (existsSync5(envPath)) {
2736
2908
  try {
2737
2909
  const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
2738
2910
  if (parsed.CLOUDFLARE_API_TOKEN)
@@ -2750,7 +2922,7 @@ function getCloudflareTokenSource(root = process.cwd()) {
2750
2922
  if (process.env.CF_DNS_API_TOKEN)
2751
2923
  return "environment variable (CF_DNS_API_TOKEN)";
2752
2924
  const envPath = join5(root, ".env");
2753
- if (existsSync4(envPath)) {
2925
+ if (existsSync5(envPath)) {
2754
2926
  try {
2755
2927
  const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
2756
2928
  if (parsed.CLOUDFLARE_API_TOKEN || parsed.CF_DNS_API_TOKEN)
@@ -2768,7 +2940,7 @@ function getHetznerToken(root = process.cwd()) {
2768
2940
  if (process.env.HCLOUD_TOKEN)
2769
2941
  return secret(process.env.HCLOUD_TOKEN);
2770
2942
  const envPath = join5(root, ".env");
2771
- if (existsSync4(envPath)) {
2943
+ if (existsSync5(envPath)) {
2772
2944
  try {
2773
2945
  const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
2774
2946
  if (parsed.HETZNER_API_TOKEN)
@@ -2786,7 +2958,7 @@ function getHetznerTokenSource(root = process.cwd()) {
2786
2958
  if (process.env.HCLOUD_TOKEN)
2787
2959
  return "environment variable (HCLOUD_TOKEN)";
2788
2960
  const envPath = join5(root, ".env");
2789
- if (existsSync4(envPath)) {
2961
+ if (existsSync5(envPath)) {
2790
2962
  try {
2791
2963
  const parsed = parseDotenv(readFileSync3(envPath, "utf8"));
2792
2964
  if (parsed.HETZNER_API_TOKEN || parsed.HCLOUD_TOKEN)
@@ -3266,18 +3438,18 @@ var init_cloudflare = __esm(() => {
3266
3438
  });
3267
3439
 
3268
3440
  // src/commands/init.ts
3269
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
3441
+ import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
3270
3442
  import { basename as basename2, join as join6, resolve as resolve3 } from "path";
3271
3443
  function detect(root) {
3272
3444
  const name = basename2(root).toLowerCase().replace(/[^a-z0-9_-]/g, "-");
3273
- const hasDockerfile = existsSync5(join6(root, "Dockerfile"));
3445
+ const hasDockerfile = existsSync6(join6(root, "Dockerfile"));
3274
3446
  const pkgPath = join6(root, "package.json");
3275
- if (existsSync5(pkgPath)) {
3447
+ if (existsSync6(pkgPath)) {
3276
3448
  let pkg = {};
3277
3449
  try {
3278
3450
  pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
3279
3451
  } catch {}
3280
- const bun = existsSync5(join6(root, "bun.lockb")) || existsSync5(join6(root, "bun.lock"));
3452
+ const bun = existsSync6(join6(root, "bun.lockb")) || existsSync6(join6(root, "bun.lock"));
3281
3453
  const scripts = pkg.scripts ?? {};
3282
3454
  const runner = bun ? "bun" : "npm";
3283
3455
  return {
@@ -3290,13 +3462,13 @@ function detect(root) {
3290
3462
  hasDockerfile
3291
3463
  };
3292
3464
  }
3293
- if (existsSync5(join6(root, "pyproject.toml")) || existsSync5(join6(root, "requirements.txt"))) {
3465
+ if (existsSync6(join6(root, "pyproject.toml")) || existsSync6(join6(root, "requirements.txt"))) {
3294
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 };
3295
3467
  }
3296
- if (existsSync5(join6(root, "Gemfile"))) {
3468
+ if (existsSync6(join6(root, "Gemfile"))) {
3297
3469
  return { name, runtime: "ruby", port: 3000, install: "bundle install --deployment", start: "bundle exec rails server -p $PORT", hasDockerfile };
3298
3470
  }
3299
- if (existsSync5(join6(root, "go.mod"))) {
3471
+ if (existsSync6(join6(root, "go.mod"))) {
3300
3472
  return { name, runtime: "go", port: 8080, build: "go build -o server .", start: "./server", hasDockerfile };
3301
3473
  }
3302
3474
  return { name, runtime: "unknown", port: 3000, hasDockerfile };
@@ -3541,7 +3713,7 @@ Options
3541
3713
  throw new EpdError("Use either --interactive or --yes");
3542
3714
  const wizard = interactive() && !ctx.values.yes;
3543
3715
  const target = ctx.loadOptions.file ? resolve3(root, ctx.loadOptions.file) : join6(root, "epd.yml");
3544
- if (existsSync5(target) && !ctx.values.force) {
3716
+ if (existsSync6(target) && !ctx.values.force) {
3545
3717
  throw new EpdError("epd.yml already exists", "Pass --force to overwrite it.");
3546
3718
  }
3547
3719
  const ask2 = wizard ? ask : async (_question, value) => value || "";
@@ -3585,9 +3757,15 @@ Options
3585
3757
  let engine = validateContainerEngine(ctx.values["container-engine"] || "auto");
3586
3758
  if (mode === "docker" && wizard && !ctx.values["container-engine"]) {
3587
3759
  engine = validateContainerEngine(await ask2("Local container engine, auto or a Docker-compatible executable", "auto"));
3588
- const detectedEngine = await containerEngine(engine);
3589
- if (engine !== "auto")
3590
- engine = detectedEngine;
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
+ }
3591
3769
  }
3592
3770
  let hosts = ctx.values.host ?? [];
3593
3771
  if (!hosts.length && hetznerToken && wizard) {
@@ -3850,7 +4028,7 @@ var init_bootstrap = __esm(() => {
3850
4028
  });
3851
4029
 
3852
4030
  // src/core/ssh.ts
3853
- import { chmodSync as chmodSync2, existsSync as existsSync6, lstatSync, mkdirSync as mkdirSync5, mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
4031
+ import { chmodSync as chmodSync2, existsSync as existsSync7, lstatSync, mkdirSync as mkdirSync5, mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
3854
4032
  import { tmpdir } from "os";
3855
4033
  import { join as join7 } from "path";
3856
4034
  function controlDirectory(base = tmpdir()) {
@@ -3985,7 +4163,7 @@ class Host {
3985
4163
  `, { mode: 384, flag: "wx" });
3986
4164
  chmodSync2(keyPath, 384);
3987
4165
  } catch {}
3988
- } else if (existsSync6(rawEnvKey)) {
4166
+ } else if (existsSync7(rawEnvKey)) {
3989
4167
  keyPath = rawEnvKey;
3990
4168
  }
3991
4169
  }
@@ -4414,7 +4592,7 @@ var init_baseline = __esm(() => {
4414
4592
  });
4415
4593
 
4416
4594
  // src/core/ssh-setup.ts
4417
- import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "fs";
4595
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync5, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "fs";
4418
4596
  import { homedir as homedir4, tmpdir as tmpdir2 } from "os";
4419
4597
  import { join as join8 } from "path";
4420
4598
  function askpassBody(password) {
@@ -4488,7 +4666,7 @@ grep -qxF -- ${shq(key)} "$HOME/.ssh/authorized_keys" || printf '\\n%s\\n' ${shq
4488
4666
  setSudoPassword(host.sudoKey, password);
4489
4667
  }
4490
4668
  } finally {
4491
- if (existsSync7(askpassScript))
4669
+ if (existsSync8(askpassScript))
4492
4670
  unlinkSync3(askpassScript);
4493
4671
  }
4494
4672
  }
@@ -4530,9 +4708,9 @@ async function publicKeyFor(host) {
4530
4708
  const identityIndex = options.indexOf("-i");
4531
4709
  const identity = identityIndex >= 0 ? options[identityIndex + 1] : undefined;
4532
4710
  if (identity) {
4533
- if (existsSync7(`${identity}.pub`))
4711
+ if (existsSync8(`${identity}.pub`))
4534
4712
  return validateKey(readFileSync5(`${identity}.pub`, "utf8"));
4535
- if (!existsSync7(identity))
4713
+ if (!existsSync8(identity))
4536
4714
  throw new EpdError(`SSH identity does not exist: ${identity}`);
4537
4715
  const proc = Bun.spawn(["ssh-keygen", "-y", "-f", identity], {
4538
4716
  stdin: "inherit",
@@ -4554,11 +4732,11 @@ async function publicKeyFor(host) {
4554
4732
  const sshDir = join8(homedir4(), ".ssh");
4555
4733
  for (const name of ["id_ed25519", "gh_deploy", "id_ecdsa", "id_rsa"]) {
4556
4734
  const path = join8(sshDir, `${name}.pub`);
4557
- if (existsSync7(path))
4735
+ if (existsSync8(path))
4558
4736
  return validateKey(readFileSync5(path, "utf8"));
4559
4737
  }
4560
4738
  const keyPath = join8(sshDir, "id_ed25519");
4561
- if (existsSync7(keyPath)) {
4739
+ if (existsSync8(keyPath)) {
4562
4740
  throw new EpdError(`Missing public key for ${keyPath}`, "Load it with ssh-add, or set ssh.key to its path, then retry.");
4563
4741
  }
4564
4742
  mkdirSync6(sshDir, { recursive: true, mode: 448 });
@@ -4589,7 +4767,7 @@ var init_ssh_setup = __esm(() => {
4589
4767
  });
4590
4768
 
4591
4769
  // src/proxy/detect.ts
4592
- import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
4770
+ import { existsSync as existsSync9, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "fs";
4593
4771
  import { basename as basename3, resolve as resolve4 } from "path";
4594
4772
  async function detectExistingProxy(host, checkPorts = [80, 443]) {
4595
4773
  const portsSet = new Set(checkPorts);
@@ -4803,7 +4981,7 @@ http:
4803
4981
  }
4804
4982
  function updateLocalConfigDisableProxy(configPath = "epd.yml") {
4805
4983
  const configFile = resolve4(configPath);
4806
- if (!existsSync8(configFile))
4984
+ if (!existsSync9(configFile))
4807
4985
  return;
4808
4986
  try {
4809
4987
  const raw = readFileSync6(configFile, "utf8");
@@ -4905,7 +5083,7 @@ ${c.gray(snippet)}`);
4905
5083
  log.plain(`
4906
5084
  ${c.yellow("!")} Unrecognized reverse proxy detected (${detected.details}).`);
4907
5085
  const customConfig = await ask("Provide path to your custom proxy configuration file to deploy (or leave empty to configure manually):");
4908
- if (customConfig && existsSync8(customConfig)) {
5086
+ if (customConfig && existsSync9(customConfig)) {
4909
5087
  const content = readFileSync6(customConfig, "utf8");
4910
5088
  const defaultRemote = `/etc/proxy/${basename3(customConfig)}`;
4911
5089
  const remotePath = await ask(`Remote destination path on ${host.name}:`, defaultRemote);
@@ -5948,12 +6126,12 @@ var init_state = __esm(() => {
5948
6126
  });
5949
6127
 
5950
6128
  // src/deploy/image.ts
5951
- import { existsSync as existsSync9 } from "fs";
6129
+ import { existsSync as existsSync10 } from "fs";
5952
6130
  import { join as join9 } from "path";
5953
6131
  async function resolveVersion(cfg, explicit) {
5954
6132
  if (explicit)
5955
6133
  return { id: explicit, source: "explicit", dirty: false };
5956
- if (existsSync9(join9(cfg.root, ".git")) && await which("git")) {
6134
+ if (existsSync10(join9(cfg.root, ".git")) && await which("git")) {
5957
6135
  const sha = await run(["git", "-C", cfg.root, "rev-parse", "--short=12", "HEAD"], { allowFailure: true });
5958
6136
  if (sha.code === 0 && sha.stdout) {
5959
6137
  const status = await run(["git", "-C", cfg.root, "status", "--porcelain"], { allowFailure: true });
@@ -5971,7 +6149,7 @@ async function hasBuildx(configured) {
5971
6149
  }
5972
6150
  async function buildImage(cfg, version, env) {
5973
6151
  const dockerfile = join9(cfg.root, cfg.build.dockerfile);
5974
- if (!existsSync9(dockerfile)) {
6152
+ if (!existsSync10(dockerfile)) {
5975
6153
  throw new EpdError(`${cfg.build.dockerfile} not found`, "Add a Dockerfile, point build.dockerfile at yours, or switch to `mode: process`.");
5976
6154
  }
5977
6155
  cfg.containerEngine = await containerEngine(cfg.containerEngine);
@@ -6010,7 +6188,7 @@ async function buildWithBuildx(cfg, ref, version, env) {
6010
6188
  }
6011
6189
  args.push(cfg.build.context);
6012
6190
  await ensureBuilder(engine);
6013
- 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}`)}` });
6014
6192
  }
6015
6193
  async function buildWithLegacyDocker(cfg, ref, version, env) {
6016
6194
  const engine = await containerEngine(cfg.containerEngine);
@@ -6039,11 +6217,11 @@ async function buildWithLegacyDocker(cfg, ref, version, env) {
6039
6217
  args.push("--build-arg", `${k}=${v}`);
6040
6218
  args.push("--label", `epd.app=${cfg.name}`, "--label", `epd.version=${version}`);
6041
6219
  args.push(cfg.build.context);
6042
- 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}`)}` });
6043
6221
  if (cfg.registry) {
6044
6222
  log.step(`Pushing ${ref}`, "push");
6045
- await run([engine, "push", ref], { stream: true });
6046
- 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")}` });
6047
6225
  }
6048
6226
  }
6049
6227
  async function ensureBuilder(engine = "docker") {
@@ -6322,7 +6500,7 @@ var init_docker = __esm(() => {
6322
6500
  });
6323
6501
 
6324
6502
  // src/deploy/process.ts
6325
- import { existsSync as existsSync10 } from "fs";
6503
+ import { existsSync as existsSync11 } from "fs";
6326
6504
  import { join as join10 } from "path";
6327
6505
  function releaseDir(cfg, version) {
6328
6506
  return `${paths(cfg).releases}/${version}`;
@@ -6332,7 +6510,7 @@ async function uploadSource(host, cfg, version) {
6332
6510
  const p = paths(cfg);
6333
6511
  await host.exec(`mkdir -p ${shq(p.releases)} ${shq(p.shared)}`, asUser);
6334
6512
  if (cfg.process.source === "git") {
6335
- if (!existsSync10(join10(cfg.root, ".git")))
6513
+ if (!existsSync11(join10(cfg.root, ".git")))
6336
6514
  throw new EpdError('process.source is "git" but this is not a git repository');
6337
6515
  log.host(host.name, `uploading HEAD as ${version}`);
6338
6516
  await host.pipeInto(`mkdir -p ${shq(dest)} && tar -x -C ${shq(dest)}`, ["git", "-C", cfg.root, "archive", "--format=tar", "HEAD"]);
@@ -9560,7 +9738,7 @@ ${c.bold("SEVALLA MANAGED DATABASES")} (${dbs.length})
9560
9738
 
9561
9739
  // src/core/update.ts
9562
9740
  import { createHash } from "crypto";
9563
- import { chmodSync as chmodSync3, existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync7, renameSync as renameSync2, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "fs";
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";
9564
9742
  import { homedir as homedir5 } from "os";
9565
9743
  import { basename as basename4, dirname as dirname5, join as join11 } from "path";
9566
9744
  function isValidVersion(version) {
@@ -9662,7 +9840,7 @@ function getCachePath() {
9662
9840
  function readCache() {
9663
9841
  try {
9664
9842
  const p = getCachePath();
9665
- if (existsSync11(p)) {
9843
+ if (existsSync12(p)) {
9666
9844
  return JSON.parse(readFileSync7(p, "utf8"));
9667
9845
  }
9668
9846
  } catch {}
@@ -9801,7 +9979,7 @@ var init_update = __esm(() => {
9801
9979
  });
9802
9980
 
9803
9981
  // package.json
9804
- var version = "0.5.19";
9982
+ var version = "0.5.20";
9805
9983
  var init_package = () => {};
9806
9984
 
9807
9985
  // src/version.ts
@@ -11004,7 +11182,7 @@ Options
11004
11182
  });
11005
11183
 
11006
11184
  // src/commands/restore.ts
11007
- import { createReadStream as createReadStream3, existsSync as existsSync12 } from "fs";
11185
+ import { createReadStream as createReadStream3, existsSync as existsSync13 } from "fs";
11008
11186
  import { basename as basename5, resolve as resolve6 } from "path";
11009
11187
  var restore;
11010
11188
  var init_restore = __esm(() => {
@@ -11032,7 +11210,7 @@ Options
11032
11210
  if (!backupPath)
11033
11211
  throw new EpdError("Please provide a path to the backup file to restore.");
11034
11212
  const absPath = resolve6(backupPath);
11035
- if (!existsSync12(absPath))
11213
+ if (!existsSync13(absPath))
11036
11214
  throw new EpdError(`Backup file not found: ${absPath}`);
11037
11215
  const loaded = ctx.load();
11038
11216
  const cfg = loaded.config;
@@ -11134,7 +11312,7 @@ Options
11134
11312
  });
11135
11313
 
11136
11314
  // src/commands/doctor.ts
11137
- import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
11315
+ import { existsSync as existsSync14, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
11138
11316
  import { homedir as homedir6 } from "os";
11139
11317
  import { join as join13 } from "path";
11140
11318
  function printResults(results, prefix = " ") {
@@ -11235,7 +11413,7 @@ Options
11235
11413
  status: "ok",
11236
11414
  message: "SSH_PRIVATE_KEY is set in the environment (ideal for CI)"
11237
11415
  });
11238
- } else if (existsSync13(sshDir)) {
11416
+ } else if (existsSync14(sshDir)) {
11239
11417
  const keys = readdirSync3(sshDir).filter((f) => ["id_ed25519", "id_rsa", "gh_deploy"].includes(f));
11240
11418
  if (keys.length > 0) {
11241
11419
  const keyIssues = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabioplunser/epd",
3
- "version": "0.5.19",
3
+ "version": "0.5.20",
4
4
  "description": "Easy Project Deployer — deploy any project to one or many servers with Docker or PM2, fronted by Traefik.",
5
5
  "type": "module",
6
6
  "author": "Fabio Plünser",