@getmonoceros/workbench 1.38.0 → 1.38.1
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 +84 -67
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -4593,75 +4593,87 @@ function generateAgentsMd(input) {
|
|
|
4593
4593
|
" DataGrip) to one of the services."
|
|
4594
4594
|
);
|
|
4595
4595
|
lines.push("");
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
"Declare it in the app's own launch config at",
|
|
4608
|
-
"`projects/<app>/.monoceros/launch.json`, then start it with",
|
|
4609
|
-
"`monoceros-ctl`. Add or update an entry whenever you set up a",
|
|
4610
|
-
"long-running server. The file travels with the app, so the human can",
|
|
4611
|
-
"restart it later without knowing your start command:"
|
|
4612
|
-
);
|
|
4613
|
-
lines.push("");
|
|
4614
|
-
lines.push("```json");
|
|
4615
|
-
lines.push("{");
|
|
4616
|
-
lines.push(' "configurations": [');
|
|
4617
|
-
lines.push(
|
|
4618
|
-
` { "name": "web", "command": "<the project's start command>", "port": ${input.ports[0]}, "default": true }`
|
|
4619
|
-
);
|
|
4620
|
-
lines.push(" ]");
|
|
4621
|
-
lines.push("}");
|
|
4622
|
-
lines.push("```");
|
|
4623
|
-
lines.push("");
|
|
4596
|
+
const examplePort = input.ports.length > 0 ? String(input.ports[0]) : "<port>";
|
|
4597
|
+
lines.push("## Running a long-running server");
|
|
4598
|
+
lines.push("");
|
|
4599
|
+
lines.push(
|
|
4600
|
+
"When you build something that serves on a port (a web app, an API),",
|
|
4601
|
+
"it must keep running after this session ends. A plain `npm start` (or",
|
|
4602
|
+
"any foreground start) dies the moment the user exits you or closes the",
|
|
4603
|
+
input.ports.length > 0 ? `terminal, and then \`${input.containerName}.localhost${portSuffix}\` returns 502 Bad Gateway.` : "terminal, and the app stops responding."
|
|
4604
|
+
);
|
|
4605
|
+
lines.push("");
|
|
4606
|
+
if (input.ports.length === 0) {
|
|
4624
4607
|
lines.push(
|
|
4625
|
-
"
|
|
4626
|
-
"
|
|
4627
|
-
"
|
|
4628
|
-
"`projects/`; `port` must be a port already exposed on the container."
|
|
4608
|
+
"This container exposes **no ports yet**, so a server has nothing to be",
|
|
4609
|
+
"reached on. Before serving one, ask the user to add a port on the host",
|
|
4610
|
+
"and re-apply - you cannot do this from inside:"
|
|
4629
4611
|
);
|
|
4630
4612
|
lines.push("");
|
|
4631
|
-
lines.push("Start it, stop it, tail its log:");
|
|
4632
|
-
lines.push("");
|
|
4633
4613
|
lines.push("```");
|
|
4634
|
-
lines.push(
|
|
4635
|
-
lines.push(
|
|
4636
|
-
lines.push("monoceros-ctl logs <app>");
|
|
4614
|
+
lines.push(`monoceros add-port ${input.containerName} <port>`);
|
|
4615
|
+
lines.push(`monoceros apply ${input.containerName}`);
|
|
4637
4616
|
lines.push("```");
|
|
4638
4617
|
lines.push("");
|
|
4639
|
-
lines.push(
|
|
4640
|
-
"`start` launches it detached (it survives your session) and, when a",
|
|
4641
|
-
"`port` is set, waits until it actually listens before returning. The",
|
|
4642
|
-
"human can do the same from the host with",
|
|
4643
|
-
`\`monoceros start ${input.containerName} <app>\` / \`monoceros stop ${input.containerName} <app>\`,`,
|
|
4644
|
-
`and follow output with \`monoceros logs ${input.containerName} <app>\`.`
|
|
4645
|
-
);
|
|
4646
|
-
lines.push("");
|
|
4647
|
-
lines.push(
|
|
4648
|
-
"An app can declare several servers (e.g. an API and a web frontend).",
|
|
4649
|
-
'Mark every server that should come up together with `"default": true`;',
|
|
4650
|
-
"`monoceros-ctl start <app>` (no `--target`) then starts the whole default",
|
|
4651
|
-
"set in the order the entries appear in the file, waiting for each",
|
|
4652
|
-
"server's `port` to listen before starting the next - so order an entry",
|
|
4653
|
-
"before anything that depends on it. If one fails to come up, the rest are",
|
|
4654
|
-
"not started. Pass `--target <name>` to start or stop a single one."
|
|
4655
|
-
);
|
|
4656
|
-
lines.push("");
|
|
4657
|
-
lines.push(
|
|
4658
|
-
"The server must listen on `0.0.0.0` (not `127.0.0.1`) on the exposed",
|
|
4659
|
-
"port, or Traefik cannot reach it. You only have the ports already",
|
|
4660
|
-
"declared on the container; if you need another, ask the human to add it",
|
|
4661
|
-
`on the host (\`monoceros add-port ${input.containerName} <port>\`) and re-apply.`
|
|
4662
|
-
);
|
|
4663
|
-
lines.push("");
|
|
4664
4618
|
}
|
|
4619
|
+
lines.push(
|
|
4620
|
+
"Declare the server in the app's own launch config at",
|
|
4621
|
+
"`projects/<app>/.monoceros/launch.json`, then start it with",
|
|
4622
|
+
"`monoceros-ctl`. Add or update an entry whenever you set up a",
|
|
4623
|
+
"long-running server. The file travels with the app, so the human can",
|
|
4624
|
+
"restart it later without knowing your start command:"
|
|
4625
|
+
);
|
|
4626
|
+
lines.push("");
|
|
4627
|
+
lines.push("```json");
|
|
4628
|
+
lines.push("{");
|
|
4629
|
+
lines.push(' "configurations": [');
|
|
4630
|
+
lines.push(
|
|
4631
|
+
` { "name": "web", "command": "<the project's start command>", "port": ${examplePort}, "default": true }`
|
|
4632
|
+
);
|
|
4633
|
+
lines.push(" ]");
|
|
4634
|
+
lines.push("}");
|
|
4635
|
+
lines.push("```");
|
|
4636
|
+
lines.push("");
|
|
4637
|
+
lines.push(
|
|
4638
|
+
"Use whatever start command the project actually uses (`npm run dev`,",
|
|
4639
|
+
"`./mvnw spring-boot:run`, `python manage.py runserver`, `go run .`, \u2026).",
|
|
4640
|
+
"Do not force a language-specific one. `<app>` is the path under",
|
|
4641
|
+
"`projects/`; `port` must be a port exposed on the container."
|
|
4642
|
+
);
|
|
4643
|
+
lines.push("");
|
|
4644
|
+
lines.push("Start it, stop it, tail its log:");
|
|
4645
|
+
lines.push("");
|
|
4646
|
+
lines.push("```");
|
|
4647
|
+
lines.push("monoceros-ctl start <app>");
|
|
4648
|
+
lines.push("monoceros-ctl stop <app>");
|
|
4649
|
+
lines.push("monoceros-ctl logs <app>");
|
|
4650
|
+
lines.push("```");
|
|
4651
|
+
lines.push("");
|
|
4652
|
+
lines.push(
|
|
4653
|
+
"`start` launches it detached (it survives your session) and, when a",
|
|
4654
|
+
"`port` is set, waits until it actually listens before returning. The",
|
|
4655
|
+
"human can do the same from the host with",
|
|
4656
|
+
`\`monoceros start ${input.containerName} <app>\` / \`monoceros stop ${input.containerName} <app>\`,`,
|
|
4657
|
+
`and follow output with \`monoceros logs ${input.containerName} <app>\`.`
|
|
4658
|
+
);
|
|
4659
|
+
lines.push("");
|
|
4660
|
+
lines.push(
|
|
4661
|
+
"An app can declare several servers (e.g. an API and a web frontend).",
|
|
4662
|
+
'Mark every server that should come up together with `"default": true`;',
|
|
4663
|
+
"`monoceros-ctl start <app>` (no `--target`) then starts the whole default",
|
|
4664
|
+
"set in the order the entries appear in the file, waiting for each",
|
|
4665
|
+
"server's `port` to listen before starting the next - so order an entry",
|
|
4666
|
+
"before anything that depends on it. If one fails to come up, the rest are",
|
|
4667
|
+
"not started. Pass `--target <name>` to start or stop a single one."
|
|
4668
|
+
);
|
|
4669
|
+
lines.push("");
|
|
4670
|
+
lines.push(
|
|
4671
|
+
"The server must listen on `0.0.0.0` (not `127.0.0.1`) on the exposed",
|
|
4672
|
+
"port, or Traefik cannot reach it. You only have the ports already",
|
|
4673
|
+
"declared on the container; if you need another, ask the human to add it",
|
|
4674
|
+
`on the host (\`monoceros add-port ${input.containerName} <port>\`) and re-apply.`
|
|
4675
|
+
);
|
|
4676
|
+
lines.push("");
|
|
4665
4677
|
lines.push("## Command reference");
|
|
4666
4678
|
lines.push("");
|
|
4667
4679
|
lines.push(
|
|
@@ -8974,7 +8986,7 @@ var CLI_VERSION;
|
|
|
8974
8986
|
var init_version = __esm({
|
|
8975
8987
|
"src/version.ts"() {
|
|
8976
8988
|
"use strict";
|
|
8977
|
-
CLI_VERSION = true ? "1.38.
|
|
8989
|
+
CLI_VERSION = true ? "1.38.1" : "dev";
|
|
8978
8990
|
}
|
|
8979
8991
|
});
|
|
8980
8992
|
|
|
@@ -12372,6 +12384,7 @@ var init_run3 = __esm({
|
|
|
12372
12384
|
|
|
12373
12385
|
// src/tls/ca.ts
|
|
12374
12386
|
import { promises as fs21 } from "fs";
|
|
12387
|
+
import os3 from "os";
|
|
12375
12388
|
import path33 from "path";
|
|
12376
12389
|
import forge from "node-forge";
|
|
12377
12390
|
function homeDir(monocerosHome2) {
|
|
@@ -12380,6 +12393,10 @@ function homeDir(monocerosHome2) {
|
|
|
12380
12393
|
function randomSerial() {
|
|
12381
12394
|
return "00" + forge.util.bytesToHex(forge.random.getBytesSync(16));
|
|
12382
12395
|
}
|
|
12396
|
+
function caCommonName() {
|
|
12397
|
+
const host = os3.hostname().replace(/\.local$/, "").trim();
|
|
12398
|
+
return host ? `Monoceros Local CA (${host})` : "Monoceros Local CA";
|
|
12399
|
+
}
|
|
12383
12400
|
async function fileExists(p) {
|
|
12384
12401
|
try {
|
|
12385
12402
|
await fs21.access(p);
|
|
@@ -12409,7 +12426,7 @@ async function loadOrCreateCa(monocerosHome2) {
|
|
|
12409
12426
|
cert.validity.notAfter = new Date(
|
|
12410
12427
|
cert.validity.notBefore.getTime() + CA_DAYS * 24 * 60 * 60 * 1e3
|
|
12411
12428
|
);
|
|
12412
|
-
const attrs = [{ name: "commonName", value:
|
|
12429
|
+
const attrs = [{ name: "commonName", value: caCommonName() }];
|
|
12413
12430
|
cert.setSubject(attrs);
|
|
12414
12431
|
cert.setIssuer(attrs);
|
|
12415
12432
|
cert.setExtensions([
|
|
@@ -12571,14 +12588,14 @@ var init_caddy = __esm({
|
|
|
12571
12588
|
});
|
|
12572
12589
|
|
|
12573
12590
|
// src/share/run.ts
|
|
12574
|
-
import
|
|
12591
|
+
import os4 from "os";
|
|
12575
12592
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12576
12593
|
import { consola as consola35 } from "consola";
|
|
12577
12594
|
import { promises as fs22 } from "fs";
|
|
12578
12595
|
import path34 from "path";
|
|
12579
12596
|
function realHostAddresses() {
|
|
12580
12597
|
let ip;
|
|
12581
|
-
for (const list of Object.values(
|
|
12598
|
+
for (const list of Object.values(os4.networkInterfaces())) {
|
|
12582
12599
|
for (const addr of list ?? []) {
|
|
12583
12600
|
if (addr.family === "IPv4" && !addr.internal) {
|
|
12584
12601
|
ip = addr.address;
|
|
@@ -12597,7 +12614,7 @@ function mdnsHostName() {
|
|
|
12597
12614
|
const name = res.status === 0 ? res.stdout.trim() : "";
|
|
12598
12615
|
if (name) return `${name}.local`;
|
|
12599
12616
|
}
|
|
12600
|
-
const hn =
|
|
12617
|
+
const hn = os4.hostname();
|
|
12601
12618
|
return hn.endsWith(".local") ? hn : `${hn}.local`;
|
|
12602
12619
|
}
|
|
12603
12620
|
async function runShare(opts) {
|