@getmonoceros/workbench 1.38.6 → 1.38.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -9005,7 +9005,7 @@ var CLI_VERSION;
9005
9005
  var init_version = __esm({
9006
9006
  "src/version.ts"() {
9007
9007
  "use strict";
9008
- CLI_VERSION = true ? "1.38.6" : "dev";
9008
+ CLI_VERSION = true ? "1.38.7" : "dev";
9009
9009
  }
9010
9010
  });
9011
9011
 
@@ -12587,6 +12587,12 @@ function renderCaddyfile(sites, certFile, keyFile) {
12587
12587
  "{",
12588
12588
  " auto_https off",
12589
12589
  " admin off",
12590
+ // `share` is a foreground user command, not a server; Caddy's default
12591
+ // info-level JSON (maxprocs, GOMEMLIMIT, "server running", autosave, …)
12592
+ // is pure noise there. Keep only genuine errors.
12593
+ " log {",
12594
+ " level ERROR",
12595
+ " }",
12590
12596
  " servers {",
12591
12597
  " protocols h1 h2",
12592
12598
  " }",
@@ -12619,7 +12625,7 @@ var init_caddy = __esm({
12619
12625
 
12620
12626
  // src/share/run.ts
12621
12627
  import os4 from "os";
12622
- import { spawnSync as spawnSync2 } from "child_process";
12628
+ import { spawn as spawn14, spawnSync as spawnSync2 } from "child_process";
12623
12629
  import { consola as consola35 } from "consola";
12624
12630
  import { promises as fs22 } from "fs";
12625
12631
  import path34 from "path";
@@ -12647,6 +12653,38 @@ function mdnsHostName() {
12647
12653
  const hn = os4.hostname();
12648
12654
  return hn.endsWith(".local") ? hn : `${hn}.local`;
12649
12655
  }
12656
+ async function defaultEnsureImage(image, log) {
12657
+ const present = await new Promise((resolve) => {
12658
+ const c = spawn14("docker", ["image", "inspect", image], { stdio: "ignore" });
12659
+ c.on("error", () => resolve(false));
12660
+ c.on("exit", (code) => resolve(code === 0));
12661
+ });
12662
+ if (present) return;
12663
+ log.info(dim(`Pulling ${image} (first run, one-time)\u2026`));
12664
+ await new Promise((resolve, reject) => {
12665
+ const c = spawn14("docker", ["pull", "-q", image], {
12666
+ stdio: ["ignore", "ignore", "pipe"]
12667
+ });
12668
+ let err = "";
12669
+ c.stderr?.on("data", (d) => err += d.toString());
12670
+ c.on("error", reject);
12671
+ c.on(
12672
+ "exit",
12673
+ (code) => code === 0 ? resolve() : reject(
12674
+ new Error(
12675
+ `docker pull ${image} failed: ${err.trim() || `exit ${code}`}`
12676
+ )
12677
+ )
12678
+ );
12679
+ });
12680
+ }
12681
+ async function caTrustDisplayPath(caCertPath, home) {
12682
+ if (!isWsl()) return caCertPath;
12683
+ const prof = await resolveWindowsProfile();
12684
+ if (!prof) return caCertPath;
12685
+ const rel = path34.relative(home, caCertPath).split(path34.sep).join("\\");
12686
+ return `${prof.homeWin}\\.monoceros\\${rel}`;
12687
+ }
12650
12688
  async function runShare(opts) {
12651
12689
  const log = opts.logger ?? {
12652
12690
  info: (m) => consola35.info(m),
@@ -12702,6 +12740,8 @@ async function runShare(opts) {
12702
12740
  caddyfilePath,
12703
12741
  renderCaddyfile(sites, tls.certFile, tls.keyFile)
12704
12742
  );
12743
+ const ensureImage = opts.ensureImage ?? ((image) => defaultEnsureImage(image, log));
12744
+ await ensureImage(CADDY_IMAGE);
12705
12745
  const dockerSpawn = opts.dockerSpawn ?? defaultDockerSpawn;
12706
12746
  const handles = [
12707
12747
  dockerSpawn(
@@ -12728,9 +12768,10 @@ async function runShare(opts) {
12728
12768
  )
12729
12769
  );
12730
12770
  }
12771
+ const caPath = await caTrustDisplayPath(tls.caCertPath, home);
12731
12772
  log.info(
12732
12773
  dim(
12733
- ` First device? Trust the local CA once so HTTPS is warning-free: ${tls.caCertPath}`
12774
+ ` First device? Trust the local CA once so HTTPS is warning-free: ${caPath}`
12734
12775
  )
12735
12776
  );
12736
12777
  const installSignalHandler = opts.installSignalHandler ?? installSigintDefault;
@@ -12759,6 +12800,7 @@ var init_run4 = __esm({
12759
12800
  init_ca();
12760
12801
  init_caddy();
12761
12802
  init_paths();
12803
+ init_ssh_attach();
12762
12804
  init_format();
12763
12805
  SHARE_ADDRESS = "0.0.0.0";
12764
12806
  }