@getmonoceros/workbench 1.7.1 → 1.7.3

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
@@ -824,22 +824,42 @@ function proxyUrlsFor(name, ports, hostPort = 80) {
824
824
  }
825
825
 
826
826
  // src/proxy/port-check.ts
827
- import { createServer } from "net";
827
+ import { Socket } from "net";
828
+ var CONNECT_TIMEOUT_MS = 750;
828
829
  var realPortProbe = (port) => {
829
830
  return new Promise((resolve) => {
830
- const server = createServer();
831
- server.unref();
832
- server.once("error", (err) => {
833
- resolve({
831
+ const socket = new Socket();
832
+ let settled = false;
833
+ const settle = (result) => {
834
+ if (settled) return;
835
+ settled = true;
836
+ socket.destroy();
837
+ resolve(result);
838
+ };
839
+ socket.setTimeout(CONNECT_TIMEOUT_MS);
840
+ socket.once("connect", () => {
841
+ settle({
834
842
  ok: false,
835
- code: err.code ?? "UNKNOWN",
836
- message: err.message
843
+ code: "EADDRINUSE",
844
+ message: `another process is listening on ${port}`
837
845
  });
838
846
  });
839
- server.once("listening", () => {
840
- server.close(() => resolve({ ok: true }));
847
+ socket.once("timeout", () => {
848
+ settle({ ok: true });
841
849
  });
842
- server.listen(port, "0.0.0.0");
850
+ socket.once("error", (err) => {
851
+ const code = err.code ?? "UNKNOWN";
852
+ if (code === "ECONNREFUSED") {
853
+ settle({ ok: true });
854
+ } else {
855
+ settle({
856
+ ok: false,
857
+ code,
858
+ message: err.message
859
+ });
860
+ }
861
+ });
862
+ socket.connect(port, "127.0.0.1");
843
863
  });
844
864
  };
845
865
  async function preflightHostPort(hostPort, opts = {}) {
@@ -887,16 +907,16 @@ function formatHostPortHeldError(hostPort, code, systemMessage) {
887
907
  lines.push("");
888
908
  lines.push(`Aborting \u2014 re-run after the conflict is resolved.`);
889
909
  } else {
890
- lines.push(`Cannot bind host port ${hostPort}: ${systemMessage}`);
910
+ lines.push(`Cannot reach host port ${hostPort}: ${systemMessage}`);
911
+ lines.push("");
912
+ lines.push(`This is not the typical "port already in use" case \u2014`);
913
+ lines.push(`Monoceros's pre-flight uses a TCP-connect probe (not a`);
914
+ lines.push(`bind), so EACCES / privileged-port errors normally don't`);
915
+ lines.push(`appear here. Most likely something on your host network`);
916
+ lines.push(`stack (firewall, network namespace, \u2026) is interfering with`);
917
+ lines.push(`loopback connects.`);
891
918
  lines.push("");
892
- if (code === "EACCES") {
893
- lines.push(`Port ${hostPort} is a privileged port (<1024) and your`);
894
- lines.push(`current Docker setup can't bind it. For rootful Docker`);
895
- lines.push(`(what Monoceros requires) this should normally work \u2014`);
896
- lines.push(`check that the docker daemon is running as root.`);
897
- lines.push("");
898
- }
899
- lines.push("You can also move Monoceros off this port by setting");
919
+ lines.push("Workaround: move Monoceros off this port by setting");
900
920
  lines.push("`routing.hostPort` in ~/.monoceros/monoceros-config.yml.");
901
921
  lines.push("");
902
922
  lines.push(`Aborting \u2014 re-run after the issue is resolved.`);
@@ -3611,7 +3631,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
3611
3631
  }
3612
3632
 
3613
3633
  // src/version.ts
3614
- var CLI_VERSION = true ? "1.7.1" : "dev";
3634
+ var CLI_VERSION = true ? "1.7.3" : "dev";
3615
3635
 
3616
3636
  // src/commands/_dispatch.ts
3617
3637
  import { consola as consola12 } from "consola";
@@ -4086,7 +4106,7 @@ function generateComposedYml(name, components, lookupManifest, repoUrls = [], po
4086
4106
  );
4087
4107
  }
4088
4108
  if (ports.length > 0) {
4089
- renderActiveRoutingBlock(lines, ports);
4109
+ renderActiveRoutingBlock(lines, name, ports);
4090
4110
  }
4091
4111
  return ensureTrailingNewline(lines.join("\n"));
4092
4112
  }
@@ -4198,7 +4218,7 @@ function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = [], por
4198
4218
  repoUrls.length === 0
4199
4219
  );
4200
4220
  if (ports.length > 0) {
4201
- renderActiveRoutingBlock(lines, ports);
4221
+ renderActiveRoutingBlock(lines, name, ports);
4202
4222
  } else {
4203
4223
  renderRoutingHintBlock(lines);
4204
4224
  }
@@ -4327,19 +4347,21 @@ function renderRoutingHintBlock(out) {
4327
4347
  );
4328
4348
  out.push("");
4329
4349
  }
4330
- function renderActiveRoutingBlock(out, ports) {
4350
+ function renderActiveRoutingBlock(out, name, ports) {
4331
4351
  out.push("# Routing \u2014 expose these container ports to the host through");
4332
4352
  out.push("# the shared Traefik singleton. First entry doubles as");
4333
- out.push("# http://<name>.localhost (the default route). See ADR 0007.");
4353
+ out.push(`# http://${name}.localhost (the default route). See ADR 0007.`);
4334
4354
  out.push("routing:");
4335
4355
  out.push(" ports:");
4336
4356
  ports.forEach((port, idx) => {
4337
4357
  if (idx === 0) {
4338
- out.push(` - ${port} # default \u2192 http://<name>.localhost`);
4358
+ out.push(` - ${port} # default \u2192 http://${name}.localhost`);
4339
4359
  } else {
4340
4360
  out.push(` - ${port}`);
4341
4361
  }
4342
4362
  });
4363
+ out.push(" # vscodeAutoForward: false # set true to keep VS Code's");
4364
+ out.push(" # # port-panel alongside Traefik");
4343
4365
  out.push("");
4344
4366
  }
4345
4367
  function deriveDefaultPath(url) {