@getmonoceros/workbench 1.6.0 → 1.6.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 CHANGED
@@ -3131,7 +3131,6 @@ import { consola as consola13 } from "consola";
3131
3131
  // src/init/index.ts
3132
3132
  import { existsSync as existsSync7, promises as fs10 } from "fs";
3133
3133
  import { consola as consola12 } from "consola";
3134
- import { parseDocument as parseDocument3 } from "yaml";
3135
3134
 
3136
3135
  // src/init/components.ts
3137
3136
  import { existsSync as existsSync5, promises as fs9 } from "fs";
@@ -3308,7 +3307,7 @@ var SCHEMA_HEADER = [
3308
3307
  "# under `features:` also accepts options not shown here \u2014 check",
3309
3308
  "# the feature's `devcontainer-feature.json` for the full list."
3310
3309
  ];
3311
- function generateComposedYml(name, components, lookupManifest) {
3310
+ function generateComposedYml(name, components, lookupManifest, repoUrls = []) {
3312
3311
  const merged = mergeComponents(components);
3313
3312
  const lines = [];
3314
3313
  for (const h of SCHEMA_HEADER) lines.push(h);
@@ -3339,9 +3338,17 @@ function generateComposedYml(name, components, lookupManifest) {
3339
3338
  }
3340
3339
  lines.push("");
3341
3340
  }
3341
+ if (repoUrls.length > 0) {
3342
+ renderReposBlock(
3343
+ lines,
3344
+ repoUrls,
3345
+ /* commented */
3346
+ false
3347
+ );
3348
+ }
3342
3349
  return ensureTrailingNewline(lines.join("\n"));
3343
3350
  }
3344
- function generateDocumentedYml(name, catalog, lookupManifest) {
3351
+ function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = []) {
3345
3352
  const byCategory = groupByCategory(catalog);
3346
3353
  const lines = [];
3347
3354
  for (const h of SCHEMA_HEADER) lines.push(h);
@@ -3442,6 +3449,12 @@ function generateDocumentedYml(name, catalog, lookupManifest) {
3442
3449
  }
3443
3450
  lines.push("");
3444
3451
  }
3452
+ renderReposBlock(
3453
+ lines,
3454
+ repoUrls,
3455
+ /* commented */
3456
+ repoUrls.length === 0
3457
+ );
3445
3458
  return ensureTrailingNewline(lines.join("\n"));
3446
3459
  }
3447
3460
  var COMMENT_WIDTH = 72;
@@ -3497,6 +3510,57 @@ function emitHint(out, hint, description, linePrefix) {
3497
3510
  }
3498
3511
  out.push(`${linePrefix}${hint}:`);
3499
3512
  }
3513
+ function renderReposBlock(out, urls, commented) {
3514
+ out.push("# Repos \u2014 git repositories cloned into projects/ during");
3515
+ out.push("# post-create. HTTPS-only (ADR 0006). Provider auto-detected");
3516
+ out.push("# for github.com, gitlab.com, bitbucket.org; for any other host");
3517
+ out.push("# (self-hosted GitLab, Bitbucket Data Center, Gitea/Forgejo,");
3518
+ out.push("# GitHub Enterprise, \u2026) declare provider explicitly.");
3519
+ out.push("#");
3520
+ if (commented) {
3521
+ out.push("# repos:");
3522
+ out.push("# - url: https://github.com/<org>/<repo>.git");
3523
+ out.push(
3524
+ "# # path: <folder> # subfolder under projects/; default: URL-derived"
3525
+ );
3526
+ out.push(
3527
+ "# # provider: github # github | gitlab | bitbucket | gitea"
3528
+ );
3529
+ out.push(
3530
+ "# # git: # per-repo committer identity override"
3531
+ );
3532
+ out.push("# # user:");
3533
+ out.push("# # name: Your Name");
3534
+ out.push("# # email: you@example.com");
3535
+ out.push("");
3536
+ return;
3537
+ }
3538
+ out.push("repos:");
3539
+ for (const url of urls) {
3540
+ const derivedPath = deriveDefaultPath(url);
3541
+ out.push(` - url: ${url}`);
3542
+ out.push(
3543
+ ` # path: ${derivedPath} # subfolder under projects/; default: URL-derived (${derivedPath})`
3544
+ );
3545
+ out.push(
3546
+ " # provider: github # github | gitlab | bitbucket | gitea"
3547
+ );
3548
+ out.push(
3549
+ " # git: # per-repo committer identity override"
3550
+ );
3551
+ out.push(" # user:");
3552
+ out.push(" # name: Your Name");
3553
+ out.push(" # email: you@example.com");
3554
+ }
3555
+ out.push("");
3556
+ }
3557
+ function deriveDefaultPath(url) {
3558
+ let last = url;
3559
+ const slash = url.lastIndexOf("/");
3560
+ if (slash >= 0) last = url.slice(slash + 1);
3561
+ if (last.endsWith(".git")) last = last.slice(0, -4);
3562
+ return last || "repo";
3563
+ }
3500
3564
  function wrapToComment(text, width) {
3501
3565
  const words = text.split(/\s+/).filter((w) => w.length > 0);
3502
3566
  if (words.length === 0) return [""];
@@ -3621,15 +3685,14 @@ async function runInit(opts) {
3621
3685
  }
3622
3686
  const checkoutRoot = opts.workbenchRoot ?? workbenchCheckoutRoot();
3623
3687
  const lookup = (ref) => loadFeatureManifestSummary(ref, checkoutRoot);
3624
- let text;
3625
- const requested = opts.with ?? [];
3626
- if (requested.length === 0) {
3627
- text = generateDocumentedYml(opts.name, catalog, lookup);
3628
- } else {
3629
- const components = resolveComponents(catalog, requested);
3630
- text = generateComposedYml(opts.name, components, lookup);
3688
+ const reposRaw = (opts.withRepo ?? []).map((u) => u.trim()).filter((u) => u.length > 0);
3689
+ const repos = [];
3690
+ const seenRepoUrls = /* @__PURE__ */ new Set();
3691
+ for (const url of reposRaw) {
3692
+ if (seenRepoUrls.has(url)) continue;
3693
+ seenRepoUrls.add(url);
3694
+ repos.push(url);
3631
3695
  }
3632
- const repos = (opts.withRepo ?? []).map((u) => u.trim()).filter((u) => u.length > 0);
3633
3696
  if (repos.length > 0) {
3634
3697
  const offending = [];
3635
3698
  for (const url of repos) {
@@ -3653,12 +3716,14 @@ async function runInit(opts) {
3653
3716
  ].join("\n")
3654
3717
  );
3655
3718
  }
3656
- const doc = parseDocument3(text);
3657
- for (const url of repos) {
3658
- const path13 = deriveRepoName(url);
3659
- addRepoToDoc(doc, { url, path: path13 });
3660
- }
3661
- text = String(doc);
3719
+ }
3720
+ let text;
3721
+ const requested = opts.with ?? [];
3722
+ if (requested.length === 0) {
3723
+ text = generateDocumentedYml(opts.name, catalog, lookup, repos);
3724
+ } else {
3725
+ const components = resolveComponents(catalog, requested);
3726
+ text = generateComposedYml(opts.name, components, lookup, repos);
3662
3727
  }
3663
3728
  await fs10.mkdir(containerConfigsDir(home), { recursive: true });
3664
3729
  await fs10.writeFile(dest, text, "utf8");