@getmonoceros/workbench 1.7.0 → 1.7.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 +87 -9
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -3611,7 +3611,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
|
|
|
3611
3611
|
}
|
|
3612
3612
|
|
|
3613
3613
|
// src/version.ts
|
|
3614
|
-
var CLI_VERSION = true ? "1.7.
|
|
3614
|
+
var CLI_VERSION = true ? "1.7.1" : "dev";
|
|
3615
3615
|
|
|
3616
3616
|
// src/commands/_dispatch.ts
|
|
3617
3617
|
import { consola as consola12 } from "consola";
|
|
@@ -4046,7 +4046,7 @@ var SCHEMA_HEADER = [
|
|
|
4046
4046
|
"# under `features:` also accepts options not shown here \u2014 check",
|
|
4047
4047
|
"# the feature's `devcontainer-feature.json` for the full list."
|
|
4048
4048
|
];
|
|
4049
|
-
function generateComposedYml(name, components, lookupManifest, repoUrls = []) {
|
|
4049
|
+
function generateComposedYml(name, components, lookupManifest, repoUrls = [], ports = []) {
|
|
4050
4050
|
const merged = mergeComponents(components);
|
|
4051
4051
|
const lines = [];
|
|
4052
4052
|
for (const h of SCHEMA_HEADER) lines.push(h);
|
|
@@ -4085,9 +4085,12 @@ function generateComposedYml(name, components, lookupManifest, repoUrls = []) {
|
|
|
4085
4085
|
false
|
|
4086
4086
|
);
|
|
4087
4087
|
}
|
|
4088
|
+
if (ports.length > 0) {
|
|
4089
|
+
renderActiveRoutingBlock(lines, ports);
|
|
4090
|
+
}
|
|
4088
4091
|
return ensureTrailingNewline(lines.join("\n"));
|
|
4089
4092
|
}
|
|
4090
|
-
function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = []) {
|
|
4093
|
+
function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = [], ports = []) {
|
|
4091
4094
|
const byCategory = groupByCategory(catalog);
|
|
4092
4095
|
const lines = [];
|
|
4093
4096
|
for (const h of SCHEMA_HEADER) lines.push(h);
|
|
@@ -4194,7 +4197,11 @@ function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = []) {
|
|
|
4194
4197
|
/* commented */
|
|
4195
4198
|
repoUrls.length === 0
|
|
4196
4199
|
);
|
|
4197
|
-
|
|
4200
|
+
if (ports.length > 0) {
|
|
4201
|
+
renderActiveRoutingBlock(lines, ports);
|
|
4202
|
+
} else {
|
|
4203
|
+
renderRoutingHintBlock(lines);
|
|
4204
|
+
}
|
|
4198
4205
|
return ensureTrailingNewline(lines.join("\n"));
|
|
4199
4206
|
}
|
|
4200
4207
|
var COMMENT_WIDTH = 72;
|
|
@@ -4294,13 +4301,14 @@ function renderReposBlock(out, urls, commented) {
|
|
|
4294
4301
|
}
|
|
4295
4302
|
out.push("");
|
|
4296
4303
|
}
|
|
4297
|
-
function
|
|
4304
|
+
function renderRoutingHintBlock(out) {
|
|
4298
4305
|
out.push("# Routing \u2014 expose container ports to the host through the");
|
|
4299
4306
|
out.push("# shared Traefik singleton. Once any port is declared the");
|
|
4300
4307
|
out.push("# container joins the monoceros-proxy network and the proxy");
|
|
4301
4308
|
out.push("# routes <name>.localhost (default port) and");
|
|
4302
4309
|
out.push("# <name>-<port>.localhost (explicit). `monoceros add-port`");
|
|
4303
|
-
out.push("# manages the list; the block appears on first add.");
|
|
4310
|
+
out.push("# manages the list; the block appears on first add. You can");
|
|
4311
|
+
out.push("# also pre-seed at init time via `--with-ports=3000,5173,\u2026`.");
|
|
4304
4312
|
out.push("#");
|
|
4305
4313
|
out.push("# routing:");
|
|
4306
4314
|
out.push("# ports: # internal container ports");
|
|
@@ -4319,6 +4327,21 @@ function renderRoutingBlock(out) {
|
|
|
4319
4327
|
);
|
|
4320
4328
|
out.push("");
|
|
4321
4329
|
}
|
|
4330
|
+
function renderActiveRoutingBlock(out, ports) {
|
|
4331
|
+
out.push("# Routing \u2014 expose these container ports to the host through");
|
|
4332
|
+
out.push("# the shared Traefik singleton. First entry doubles as");
|
|
4333
|
+
out.push("# http://<name>.localhost (the default route). See ADR 0007.");
|
|
4334
|
+
out.push("routing:");
|
|
4335
|
+
out.push(" ports:");
|
|
4336
|
+
ports.forEach((port, idx) => {
|
|
4337
|
+
if (idx === 0) {
|
|
4338
|
+
out.push(` - ${port} # default \u2192 http://<name>.localhost`);
|
|
4339
|
+
} else {
|
|
4340
|
+
out.push(` - ${port}`);
|
|
4341
|
+
}
|
|
4342
|
+
});
|
|
4343
|
+
out.push("");
|
|
4344
|
+
}
|
|
4322
4345
|
function deriveDefaultPath(url) {
|
|
4323
4346
|
let last = url;
|
|
4324
4347
|
const slash = url.lastIndexOf("/");
|
|
@@ -4482,13 +4505,26 @@ async function runInit(opts) {
|
|
|
4482
4505
|
);
|
|
4483
4506
|
}
|
|
4484
4507
|
}
|
|
4508
|
+
const portsRaw = opts.withPorts ?? [];
|
|
4509
|
+
const ports = [];
|
|
4510
|
+
const seenPorts = /* @__PURE__ */ new Set();
|
|
4511
|
+
for (const raw of portsRaw) {
|
|
4512
|
+
if (!Number.isInteger(raw) || raw < 1 || raw > 65535) {
|
|
4513
|
+
throw new Error(
|
|
4514
|
+
`Invalid port in --with-ports: ${JSON.stringify(raw)}. Expected integers between 1 and 65535.`
|
|
4515
|
+
);
|
|
4516
|
+
}
|
|
4517
|
+
if (seenPorts.has(raw)) continue;
|
|
4518
|
+
seenPorts.add(raw);
|
|
4519
|
+
ports.push(raw);
|
|
4520
|
+
}
|
|
4485
4521
|
let text;
|
|
4486
4522
|
const requested = opts.with ?? [];
|
|
4487
4523
|
if (requested.length === 0) {
|
|
4488
|
-
text = generateDocumentedYml(opts.name, catalog, lookup, repos);
|
|
4524
|
+
text = generateDocumentedYml(opts.name, catalog, lookup, repos, ports);
|
|
4489
4525
|
} else {
|
|
4490
4526
|
const components = resolveComponents(catalog, requested);
|
|
4491
|
-
text = generateComposedYml(opts.name, components, lookup, repos);
|
|
4527
|
+
text = generateComposedYml(opts.name, components, lookup, repos, ports);
|
|
4492
4528
|
}
|
|
4493
4529
|
await fs12.mkdir(containerConfigsDir(home), { recursive: true });
|
|
4494
4530
|
await fs12.writeFile(dest, text, "utf8");
|
|
@@ -4531,16 +4567,23 @@ var initCommand = defineCommand10({
|
|
|
4531
4567
|
type: "string",
|
|
4532
4568
|
description: "Git URL of a repo to clone into projects/ on first apply. Repeatable: pass --with-repo=URL1 --with-repo=URL2 for multiple repos. Folder name derived from URL (foo.git \u2192 projects/foo/); use `monoceros add-repo --path=...` post-init for subfolder paths.",
|
|
4533
4569
|
required: false
|
|
4570
|
+
},
|
|
4571
|
+
"with-ports": {
|
|
4572
|
+
type: "string",
|
|
4573
|
+
description: "Comma-separated list of container-internal ports to expose via Traefik, e.g. --with-ports=3000,5173,6006. First entry doubles as http://<name>.localhost (default route). Equivalent to `monoceros add-port` after init. Each must be an integer in 1\u201365535.",
|
|
4574
|
+
required: false
|
|
4534
4575
|
}
|
|
4535
4576
|
},
|
|
4536
4577
|
async run({ args, rawArgs }) {
|
|
4537
4578
|
try {
|
|
4538
4579
|
const withList = collectWithList(args.with, rawArgs);
|
|
4539
4580
|
const withRepoList = collectWithRepoList(rawArgs);
|
|
4581
|
+
const withPortsList = collectWithPortsList(args["with-ports"], rawArgs);
|
|
4540
4582
|
await runInit({
|
|
4541
4583
|
name: args.name,
|
|
4542
4584
|
...withList ? { with: withList } : {},
|
|
4543
|
-
...withRepoList.length > 0 ? { withRepo: withRepoList } : {}
|
|
4585
|
+
...withRepoList.length > 0 ? { withRepo: withRepoList } : {},
|
|
4586
|
+
...withPortsList && withPortsList.length > 0 ? { withPorts: withPortsList } : {}
|
|
4544
4587
|
});
|
|
4545
4588
|
} catch (err) {
|
|
4546
4589
|
consola14.error(err instanceof Error ? err.message : String(err));
|
|
@@ -4548,6 +4591,41 @@ var initCommand = defineCommand10({
|
|
|
4548
4591
|
}
|
|
4549
4592
|
}
|
|
4550
4593
|
});
|
|
4594
|
+
function collectWithPortsList(_withPortsArg, rawArgs) {
|
|
4595
|
+
const pieces = [];
|
|
4596
|
+
for (let i = 0; i < rawArgs.length; i += 1) {
|
|
4597
|
+
const t = rawArgs[i];
|
|
4598
|
+
let scanStart = -1;
|
|
4599
|
+
if (t === "--with-ports") {
|
|
4600
|
+
scanStart = i + 1;
|
|
4601
|
+
} else if (t.startsWith("--with-ports=")) {
|
|
4602
|
+
pieces.push(t.slice("--with-ports=".length));
|
|
4603
|
+
scanStart = i + 1;
|
|
4604
|
+
}
|
|
4605
|
+
if (scanStart < 0) continue;
|
|
4606
|
+
let j = scanStart;
|
|
4607
|
+
while (j < rawArgs.length) {
|
|
4608
|
+
const u = rawArgs[j];
|
|
4609
|
+
if (u.startsWith("-")) break;
|
|
4610
|
+
pieces.push(u);
|
|
4611
|
+
j += 1;
|
|
4612
|
+
}
|
|
4613
|
+
i = j - 1;
|
|
4614
|
+
}
|
|
4615
|
+
const parts = pieces.flatMap((s) => s.split(",")).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4616
|
+
if (parts.length === 0) return void 0;
|
|
4617
|
+
const out = [];
|
|
4618
|
+
for (const p of parts) {
|
|
4619
|
+
const n = Number(p);
|
|
4620
|
+
if (!Number.isInteger(n) || n < 1 || n > 65535) {
|
|
4621
|
+
throw new Error(
|
|
4622
|
+
`Invalid port in --with-ports: ${JSON.stringify(p)}. Expected integers between 1 and 65535, comma-separated.`
|
|
4623
|
+
);
|
|
4624
|
+
}
|
|
4625
|
+
out.push(n);
|
|
4626
|
+
}
|
|
4627
|
+
return out;
|
|
4628
|
+
}
|
|
4551
4629
|
function collectWithRepoList(rawArgs) {
|
|
4552
4630
|
const urls = [];
|
|
4553
4631
|
for (let i = 0; i < rawArgs.length; i += 1) {
|