@plexus-ms/cli 0.118.0 → 0.119.0

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.
Files changed (2) hide show
  1. package/dist/plx.js +149 -533
  2. package/package.json +2 -2
package/dist/plx.js CHANGED
@@ -7556,45 +7556,10 @@ function setFrontmatterField(text, key, value, options = {}) {
7556
7556
  }
7557
7557
  return lines.join("\n");
7558
7558
  }
7559
- function frontmatterField(text, key) {
7560
- const lines = text.split("\n");
7561
- const fm = frontmatterLines(lines);
7562
- if (!fm)
7563
- return void 0;
7564
- const line = lines.slice(fm.start, fm.end).find((l) => l.startsWith(`${key}:`));
7565
- return line?.slice(key.length + 1).trim();
7566
- }
7567
7559
 
7568
7560
  // ../lib/dist/bookkeeping.js
7569
- var COLLECTIONS = ["host", "platform", "infrastructure", "ci"];
7570
- var galaxyFile = (collection) => `ansible/${collection}/galaxy.yml`;
7571
- var bumpGalaxyVersion = (text, train) => text.replace(/^(version: )\d+\.\d+\.\d+/m, `$1${train}`);
7572
- var COLLECTION_SOURCE = "plexus-ms/primitives.git";
7573
- function bumpCollectionPin(text, train) {
7574
- const lines = text.split("\n");
7575
- let ours = false;
7576
- for (let i = 0; i < lines.length; i++) {
7577
- const line = lines[i] ?? "";
7578
- if (/^\s*- /.test(line))
7579
- ours = line.includes(COLLECTION_SOURCE);
7580
- const m = /^(\s*version: )v?[\d.]+$/.exec(line);
7581
- if (ours && m)
7582
- lines[i] = `${m[1]}${train}`;
7583
- }
7584
- return lines.join("\n");
7585
- }
7586
- var RUNNER_IMAGE_PIN_FILE = "ansible/ci/roles/actions_runners/defaults/main.yml";
7587
- var bumpRunnerImagePin = (text, train) => text.replace(/(ghcr\.io\/plexus-ms\/ci-runner:)\d+\.\d+\.\d+/g, `$1${train}`);
7588
7561
  var WORKFLOW_REF = "plexus-ms/primitives/.github/workflows/";
7589
7562
  var bumpWorkflowRefs = (text, train) => text.replace(/(plexus-ms\/primitives\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${train}`);
7590
- var bumpManifestVersion = (text, train) => text.replace(/^(\s*"version":\s*")[^"]*(")/m, `$1${train}$2`);
7591
- var PLX_PIN = "npm:@plexus-ms/cli";
7592
- var bumpPlxPin = (text, train) => text.replace(/("npm:@plexus-ms\/cli(?:-ci)?"\s*=\s*(?:\{\s*version\s*=\s*)?")[^"]*(")/g, `$1${train}$2`);
7593
- var CONFIG_PIN = "@plexus-ms/config";
7594
- var bumpConfigPin = (text, train) => text.replace(/("@plexus-ms\/config":\s*")(?!workspace:|catalog:)[^"]*(")/g, `$1${train}$2`);
7595
- var bumpCatalogPin = (text, train) => text.replace(/^(\s+"@plexus-ms\/config":\s*)\S+$/m, `$1${train}`);
7596
- var stampStandard = (text, train, today2) => setFrontmatterField(setFrontmatterField(text, "version", train), "timestamp", today2);
7597
- var stampChanged = (text, train) => setFrontmatterField(text, "changed", train, { after: "binds" });
7598
7563
  var hasConflictMarkers = (text) => /^<<<<<<< /m.test(text);
7599
7564
  var hasUnmergedEntries = (porcelain) => /^(UU|AA|DU|UD)/m.test(porcelain);
7600
7565
  function syncMarker(marker, commit) {
@@ -7602,10 +7567,6 @@ function syncMarker(marker, commit) {
7602
7567
  return marker;
7603
7568
  return setFrontmatterField(marker, "plexus", commit);
7604
7569
  }
7605
- function today(now = /* @__PURE__ */ new Date()) {
7606
- const pad = (n) => String(n).padStart(2, "0");
7607
- return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
7608
- }
7609
7570
 
7610
7571
  // ../lib/dist/catalog.js
7611
7572
  import { join } from "node:path";
@@ -7690,7 +7651,7 @@ function realIo(prompt) {
7690
7651
  stdout: process.stdout,
7691
7652
  stderr: process.stderr,
7692
7653
  prompt: prompt && isInteractive() ? prompt : void 0,
7693
- exec: (command, args, options = {}) => new Promise((resolve10, reject) => {
7654
+ exec: (command, args, options = {}) => new Promise((resolve9, reject) => {
7694
7655
  const child = spawn(command, args, {
7695
7656
  cwd: options.cwd,
7696
7657
  env: options.env,
@@ -7713,7 +7674,7 @@ function realIo(prompt) {
7713
7674
  child.on("error", reject);
7714
7675
  child.on("close", (code) => {
7715
7676
  if (code === 0)
7716
- resolve10(stdout);
7677
+ resolve9(stdout);
7717
7678
  else
7718
7679
  reject(new ExecError(render(command, args), code, stderr));
7719
7680
  });
@@ -7903,135 +7864,18 @@ async function expand(ctx, root, glob) {
7903
7864
  }
7904
7865
 
7905
7866
  // ../lib/dist/consumers.js
7906
- import { relative as relative2 } from "node:path";
7907
-
7908
- // ../lib/dist/train.js
7909
- import { join as join3 } from "node:path";
7910
-
7911
- // ../lib/dist/doctor.js
7912
7867
  import { relative } from "node:path";
7913
- function diagnose(root, catalog) {
7914
- const units = collect(root, []);
7915
- const declarations = units.map((u) => diagnoseUnit(u, units, catalog, root.path));
7916
- return { declarations, stale: declarations.filter((d) => d.findings.length > 0).length };
7917
- }
7918
- function collect(dir, ancestors, parent) {
7919
- const here = dir.declaration || dir.problems?.some((p) => p.startsWith("PLEXUS.md")) ? [{ dir, ancestors, parent }] : [];
7920
- const below = dir.declaration ? [...ancestors, dir] : ancestors;
7921
- return [...here, ...dir.children.flatMap((c) => collect(c, below, dir))];
7922
- }
7923
- function diagnoseUnit(unit, units, catalog, root) {
7924
- const { dir } = unit;
7925
- const path3 = relative(root, dir.path) || ".";
7926
- const problem = dir.problems?.find((p) => p.startsWith("PLEXUS.md"));
7927
- if (!dir.declaration)
7928
- return { path: path3, modules: [], findings: [problem?.replace(/^PLEXUS\.md: /, "") ?? "unreadable marker"] };
7929
- const { plexus, modules } = dir.declaration;
7930
- const context = new Set(contextOf(unit, units).flatMap((d) => d.declaration?.modules ?? []));
7931
- const findings = [];
7932
- for (const code of modules) {
7933
- const module = catalog.get(code);
7934
- if (!module) {
7935
- findings.push(`declares ${code}, which no module carries`);
7936
- continue;
7937
- }
7938
- if (module.changed && compareTrains(module.changed, plexus) > 0)
7939
- findings.push(`${code} changed in ${module.changed}, declared at ${plexus}`);
7940
- for (const dep of module.depends)
7941
- if (!modules.includes(dep) && !context.has(dep))
7942
- findings.push(`${code} depends on ${dep}, declared neither here nor by an enclosing or contained declaration`);
7943
- }
7944
- return { path: path3, plexus, modules, findings };
7945
- }
7946
- function contextOf(unit, units) {
7947
- const { dir, ancestors } = unit;
7948
- const context = [...ancestors, ...descendants(dir)];
7949
- const repo = ancestors[0] ?? dir;
7950
- const repoParent = units.find((u) => u.dir === repo)?.parent;
7951
- const siblings = repoParent?.children.filter((c) => c !== repo && c.declaration) ?? [];
7952
- const isTenancy = (d) => d.declaration?.modules.includes("PLX-Tenancy") ?? false;
7953
- context.push(...siblings.filter(isTenancy));
7954
- if (isTenancy(dir))
7955
- context.push(...siblings);
7956
- return context;
7957
- }
7958
- function descendants(dir) {
7959
- return dir.children.flatMap((c) => [...c.declaration ? [c] : [], ...descendants(c)]);
7960
- }
7961
- function compareTrains(a, b) {
7962
- const nums = (v) => v.split(".").slice(0, 3).map((p) => Number.parseInt(p, 10) || 0);
7963
- const [x, y] = [nums(a), nums(b)];
7964
- for (let i = 0; i < 3; i++)
7965
- if ((x[i] ?? 0) !== (y[i] ?? 0))
7966
- return (x[i] ?? 0) > (y[i] ?? 0) ? 1 : -1;
7967
- return 0;
7968
- }
7969
7868
 
7970
7869
  // ../lib/dist/train.js
7971
- var PRIMITIVES = "primitives";
7972
7870
  var COMPENDIUM = "compendium";
7973
7871
  var TRAIN_REPOS = [
7974
- PRIMITIVES,
7872
+ "primitives",
7975
7873
  "preset-repo-turbo",
7976
7874
  "preset-app-nextjs",
7977
7875
  "preset-repo-operations",
7978
7876
  COMPENDIUM
7979
7877
  ];
7980
- var PHASES = [[PRIMITIVES], TRAIN_REPOS.filter((r) => r !== PRIMITIVES)];
7981
- var TRAIN_PACKAGES = [
7982
- { name: "@plexus-ms/cli", dir: "packages/cli" },
7983
- { name: "@plexus-ms/cli-ci", dir: "packages/cli-ci" },
7984
- { name: "@plexus-ms/lib", dir: "packages/lib" },
7985
- { name: "@plexus-ms/config", dir: "packages/config" }
7986
- ];
7987
- var UPSTREAM = "plexus-ms";
7988
7878
  var isTrainVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
7989
- function nextMinor(version2) {
7990
- const [major = "0", minor = "0"] = version2.split(".");
7991
- return `${major}.${Number(minor) + 1}.0`;
7992
- }
7993
- function latestTag(tags) {
7994
- return tags.filter((t) => /^v?\d+(\.\d+){1,2}$/.test(t)).sort((a, b) => compareTrains(a.replace(/^v/, ""), b.replace(/^v/, ""))).at(-1);
7995
- }
7996
- async function readTrain(ctx, upstream) {
7997
- const repos2 = [];
7998
- const all = /* @__PURE__ */ new Set();
7999
- for (const name of TRAIN_REPOS) {
8000
- const path3 = join3(upstream, name);
8001
- try {
8002
- await ctx.read("git", ["rev-parse", "--git-dir"], { cwd: path3 });
8003
- } catch {
8004
- throw new Error(`${path3} is not a git repo`);
8005
- }
8006
- try {
8007
- await ctx.read("git", ["fetch", "origin", "--tags", "--quiet"], { cwd: path3 });
8008
- } catch {
8009
- throw new Error(`${name}: fetch from origin failed`);
8010
- }
8011
- const tags = (await ctx.read("git", ["tag", "--list", "v*", "[0-9]*"], { cwd: path3 })).split("\n").filter(Boolean);
8012
- for (const t of tags)
8013
- all.add(t.replace(/^v/, ""));
8014
- const tag = latestTag(tags);
8015
- const range = tag ? `${tag}..HEAD` : "HEAD";
8016
- const pending = (await ctx.read("git", ["log", "--oneline", range], { cwd: path3 })).split("\n").filter(Boolean);
8017
- repos2.push({ name, path: path3, tag, latest: tag?.replace(/^v/, ""), pending });
8018
- }
8019
- const latest = repos2.map((r) => r.latest);
8020
- return { repos: repos2, last: latestTag([...all]), skew: latest.some((l) => l !== latest[0]) };
8021
- }
8022
- var phasesOf = (train) => PHASES.map((names) => train.repos.filter((r) => names.includes(r.name)));
8023
- async function preflightRelease(ctx, train) {
8024
- for (const { name, path: path3 } of train.repos) {
8025
- const branch = (await ctx.read("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: path3 })).trim();
8026
- if (branch !== "main")
8027
- throw new Error(`${name} is on '${branch}', trains cut from main`);
8028
- if ((await ctx.read("git", ["status", "--porcelain"], { cwd: path3 })).trim() !== "")
8029
- throw new Error(`${name} has uncommitted changes \u2014 commit first`);
8030
- const behind = (await ctx.read("git", ["rev-list", "--count", "main..origin/main"], { cwd: path3 })).trim();
8031
- if (behind !== "0")
8032
- throw new Error(`${name} is ${behind} commit(s) behind origin/main \u2014 pull first, or the tag lands on a stale commit`);
8033
- }
8034
- }
8035
7879
  async function preflightForge(ctx) {
8036
7880
  try {
8037
7881
  await ctx.read("gh", ["auth", "status"]);
@@ -8039,25 +7883,6 @@ async function preflightForge(ctx) {
8039
7883
  throw new Error("gh is not logged in (gh auth status failed) \u2014 run gh auth login first");
8040
7884
  }
8041
7885
  }
8042
- function resolveVersion(train, explicit, propagateOnly) {
8043
- if (explicit !== void 0 && !isTrainVersion(explicit))
8044
- throw new UsageError(`'${explicit}' is not plain semver (X.Y.Z, no v)`);
8045
- if (propagateOnly) {
8046
- const v = explicit ?? train.last;
8047
- if (!v)
8048
- throw new Error("no train version found to propagate");
8049
- return v;
8050
- }
8051
- if (explicit)
8052
- return explicit;
8053
- if (train.skew) {
8054
- const report = train.repos.map((r) => ` ${r.name}: ${r.latest ?? "none"}`).join("\n");
8055
- throw new Error(`the train repos' latest tags disagree:
8056
- ${report}
8057
- pass the version explicitly (--train ${train.last}) to finish the half-tagged train, or a higher one to start a new one`);
8058
- }
8059
- return train.last ? nextMinor(train.last) : "0.1.0";
8060
- }
8061
7886
  var UsageError = class extends Error {
8062
7887
  };
8063
7888
 
@@ -8094,7 +7919,7 @@ async function findConsumers(ctx, root, presets) {
8094
7919
  const template = inTemplate || Boolean(dir.template);
8095
7920
  const preset = dir.copier?.src ? presetOf(dir.copier.src, presets) : void 0;
8096
7921
  if (preset && !template) {
8097
- const site = { path: dir.path, rel: relative2(root.path, dir.path) || ".", preset };
7922
+ const site = { path: dir.path, rel: relative(root.path, dir.path) || ".", preset };
8098
7923
  if (!here)
8099
7924
  orphans.push(site);
8100
7925
  else {
@@ -8103,7 +7928,7 @@ async function findConsumers(ctx, root, presets) {
8103
7928
  const expected = expectedBranch(here.declaration, here.copier?.answers);
8104
7929
  consumer = {
8105
7930
  path: here.path,
8106
- rel: relative2(root.path, here.path) || ".",
7931
+ rel: relative(root.path, here.path) || ".",
8107
7932
  branch: expected ?? here.git?.branch ?? "main",
8108
7933
  expected,
8109
7934
  sites: []
@@ -8282,11 +8107,11 @@ function parseAnswers(text) {
8282
8107
  // ../lib/dist/deploy.js
8283
8108
  import { randomBytes } from "node:crypto";
8284
8109
  import { tmpdir } from "node:os";
8285
- import { join as join5 } from "node:path";
8110
+ import { join as join4 } from "node:path";
8286
8111
 
8287
8112
  // ../lib/dist/deployTargets.js
8288
8113
  var import_yaml4 = __toESM(require_dist(), 1);
8289
- import { join as join4 } from "node:path";
8114
+ import { join as join3 } from "node:path";
8290
8115
  var VARS_DIRS = ["group_vars", "host_vars"];
8291
8116
  var DEFAULT_ENVIRONMENT = "production";
8292
8117
  function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
@@ -8350,7 +8175,7 @@ async function readDeployTargets(ctx, inventory) {
8350
8175
  const files = [];
8351
8176
  let found = false;
8352
8177
  for (const sub of VARS_DIRS) {
8353
- const dir = join4(inventory, sub);
8178
+ const dir = join3(inventory, sub);
8354
8179
  const entries = await ctx.readDir(dir).catch(() => void 0);
8355
8180
  if (entries === void 0)
8356
8181
  continue;
@@ -8358,7 +8183,7 @@ async function readDeployTargets(ctx, inventory) {
8358
8183
  for (const e of entries) {
8359
8184
  if (e.directory || !/\.ya?ml$/.test(e.name))
8360
8185
  continue;
8361
- const path3 = join4(dir, e.name);
8186
+ const path3 = join3(dir, e.name);
8362
8187
  files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
8363
8188
  }
8364
8189
  }
@@ -8387,7 +8212,7 @@ function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
8387
8212
  }
8388
8213
  var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
8389
8214
  var Remote = class {
8390
- socket = join5(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8215
+ socket = join4(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8391
8216
  ctx;
8392
8217
  host;
8393
8218
  constructor(ctx, host) {
@@ -8452,7 +8277,7 @@ async function deploy(ctx, options) {
8452
8277
  let text = "";
8453
8278
  for (const candidate of [`${source}/docker/compose.yaml`, `${source}/compose.yaml`]) {
8454
8279
  try {
8455
- text = await ctx.readFile(join5(dir, candidate));
8280
+ text = await ctx.readFile(join4(dir, candidate));
8456
8281
  compose = candidate;
8457
8282
  break;
8458
8283
  } catch {
@@ -8557,15 +8382,68 @@ async function resolveHealthUrl(remote, D, dc, ctx) {
8557
8382
  return url;
8558
8383
  }
8559
8384
 
8385
+ // ../lib/dist/doctor.js
8386
+ import { relative as relative2 } from "node:path";
8387
+ function diagnose(root, catalog) {
8388
+ const units = collect(root, []);
8389
+ const declarations = units.map((u) => diagnoseUnit(u, units, catalog, root.path));
8390
+ return { declarations, stale: declarations.filter((d) => d.findings.length > 0).length };
8391
+ }
8392
+ function collect(dir, ancestors, parent) {
8393
+ const here = dir.declaration || dir.problems?.some((p) => p.startsWith("PLEXUS.md")) ? [{ dir, ancestors, parent }] : [];
8394
+ const below = dir.declaration ? [...ancestors, dir] : ancestors;
8395
+ return [...here, ...dir.children.flatMap((c) => collect(c, below, dir))];
8396
+ }
8397
+ function diagnoseUnit(unit, units, catalog, root) {
8398
+ const { dir } = unit;
8399
+ const path3 = relative2(root, dir.path) || ".";
8400
+ const problem = dir.problems?.find((p) => p.startsWith("PLEXUS.md"));
8401
+ if (!dir.declaration)
8402
+ return { path: path3, modules: [], findings: [problem?.replace(/^PLEXUS\.md: /, "") ?? "unreadable marker"] };
8403
+ const { plexus, modules } = dir.declaration;
8404
+ const context = new Set(contextOf(unit, units).flatMap((d) => d.declaration?.modules ?? []));
8405
+ const findings = [];
8406
+ for (const code of modules) {
8407
+ const module = catalog.get(code);
8408
+ if (!module) {
8409
+ findings.push(`declares ${code}, which no module carries`);
8410
+ continue;
8411
+ }
8412
+ if (module.changed && compareTrains(module.changed, plexus) > 0)
8413
+ findings.push(`${code} changed in ${module.changed}, declared at ${plexus}`);
8414
+ for (const dep of module.depends)
8415
+ if (!modules.includes(dep) && !context.has(dep))
8416
+ findings.push(`${code} depends on ${dep}, declared neither here nor by an enclosing or contained declaration`);
8417
+ }
8418
+ return { path: path3, plexus, modules, findings };
8419
+ }
8420
+ function contextOf(unit, units) {
8421
+ const { dir, ancestors } = unit;
8422
+ const context = [...ancestors, ...descendants(dir)];
8423
+ const repo = ancestors[0] ?? dir;
8424
+ const repoParent = units.find((u) => u.dir === repo)?.parent;
8425
+ const siblings = repoParent?.children.filter((c) => c !== repo && c.declaration) ?? [];
8426
+ const isTenancy = (d) => d.declaration?.modules.includes("PLX-Tenancy") ?? false;
8427
+ context.push(...siblings.filter(isTenancy));
8428
+ if (isTenancy(dir))
8429
+ context.push(...siblings);
8430
+ return context;
8431
+ }
8432
+ function descendants(dir) {
8433
+ return dir.children.flatMap((c) => [...c.declaration ? [c] : [], ...descendants(c)]);
8434
+ }
8435
+ function compareTrains(a, b) {
8436
+ const nums = (v) => v.split(".").slice(0, 3).map((p) => Number.parseInt(p, 10) || 0);
8437
+ const [x, y] = [nums(a), nums(b)];
8438
+ for (let i = 0; i < 3; i++)
8439
+ if ((x[i] ?? 0) !== (y[i] ?? 0))
8440
+ return (x[i] ?? 0) > (y[i] ?? 0) ? 1 : -1;
8441
+ return 0;
8442
+ }
8443
+
8560
8444
  // ../lib/dist/manifest.js
8561
8445
  var MANIFEST_FILE = "train.json";
8562
8446
  var MANIFEST_SCHEMA = 1;
8563
- function buildManifest(catalog, train, date) {
8564
- const modules = [...catalog.values()].sort((a, b) => a.code.localeCompare(b.code));
8565
- return { schema: MANIFEST_SCHEMA, train, date, modules };
8566
- }
8567
- var renderManifest = (manifest2) => `${JSON.stringify(manifest2, null, 2)}
8568
- `;
8569
8447
  var catalogOf = (manifest2) => new Map(manifest2.modules.map((m) => [m.code, m]));
8570
8448
  var strings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
8571
8449
  function parseManifest(text) {
@@ -8701,7 +8579,7 @@ function parseMaxAge(value, what) {
8701
8579
  }
8702
8580
 
8703
8581
  // ../lib/dist/overview.js
8704
- import { join as join6 } from "node:path";
8582
+ import { join as join5 } from "node:path";
8705
8583
  var PRUNED = /* @__PURE__ */ new Set([
8706
8584
  "node_modules",
8707
8585
  ".hg",
@@ -8782,7 +8660,7 @@ async function walk(ctx, path3, name, options) {
8782
8660
  }
8783
8661
  const subdirs = entries.filter((e) => e.directory && e.name !== ".git" && !PRUNED.has(e.name)).map((e) => e.name).sort();
8784
8662
  for (const sub of subdirs) {
8785
- const child = await walk(ctx, join6(path3, sub), sub, options);
8663
+ const child = await walk(ctx, join5(path3, sub), sub, options);
8786
8664
  if (isNotable(child) || child.children.length > 0)
8787
8665
  dir.children.push(child);
8788
8666
  }
@@ -8790,7 +8668,7 @@ async function walk(ctx, path3, name, options) {
8790
8668
  }
8791
8669
  async function facet(ctx, dir, file, read) {
8792
8670
  try {
8793
- read(await ctx.readFile(join6(dir.path, file)));
8671
+ read(await ctx.readFile(join5(dir.path, file)));
8794
8672
  } catch (error) {
8795
8673
  dir.problems ??= [];
8796
8674
  dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
@@ -8828,11 +8706,8 @@ async function templateFacet(ctx, cwd) {
8828
8706
  return tag ? { tag } : {};
8829
8707
  }
8830
8708
 
8831
- // ../lib/dist/preview.js
8832
- import { join as join8 } from "node:path";
8833
-
8834
8709
  // ../lib/dist/take.js
8835
- import { join as join7, relative as relative3 } from "node:path";
8710
+ import { join as join6, relative as relative3 } from "node:path";
8836
8711
  var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
8837
8712
  function mergeSummary(into, from) {
8838
8713
  into.clean.push(...from.clean);
@@ -8884,23 +8759,23 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
8884
8759
  message
8885
8760
  ], { cwd: dir })));
8886
8761
  async function updateSite(ctx, consumer, site, dir, take, summary) {
8887
- const target = join7(dir, relative3(consumer.path, site.path));
8762
+ const target = join6(dir, relative3(consumer.path, site.path));
8888
8763
  try {
8889
8764
  if (take.previewFrom) {
8890
- const localPreset = join7(take.previewFrom, site.preset);
8765
+ const localPreset = join6(take.previewFrom, site.preset);
8891
8766
  ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localPreset}@main)`);
8892
- const answers = await ctx.readFile(join7(target, ANSWERS_FILE));
8893
- await ctx.stage(write(join7(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localPreset}`)));
8767
+ const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
8768
+ await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localPreset}`)));
8894
8769
  await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localPreset} from the local checkout`);
8895
8770
  await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
8896
8771
  } else {
8897
8772
  ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
8898
- const answers = await ctx.readFile(join7(target, ANSWERS_FILE));
8773
+ const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
8899
8774
  const current = presetSource(site.preset);
8900
8775
  const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
8901
8776
  if (recorded && recorded !== current && Object.keys(RENAMED_PRESETS).some((old) => presetSource(old) === recorded)) {
8902
8777
  ctx.say(` ${site.rel}: the preset is ${current} now; the answers follow`);
8903
- await ctx.stage(write(join7(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
8778
+ await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
8904
8779
  await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the preset's name since its rename`);
8905
8780
  }
8906
8781
  const args = [
@@ -8926,7 +8801,7 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
8926
8801
  let conflict = hasUnmergedEntries(status);
8927
8802
  const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
8928
8803
  for (const f of changed) {
8929
- const text = await ctx.readFile(join7(target, f)).catch(() => "");
8804
+ const text = await ctx.readFile(join6(target, f)).catch(() => "");
8930
8805
  if (hasConflictMarkers(text))
8931
8806
  conflict = true;
8932
8807
  }
@@ -8946,20 +8821,20 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
8946
8821
  await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
8947
8822
  }
8948
8823
  async function syncSiteMarker(ctx, site, target) {
8949
- const marker = await ctx.readFile(join7(target, MARKER_FILE)).catch(() => void 0);
8824
+ const marker = await ctx.readFile(join6(target, MARKER_FILE)).catch(() => void 0);
8950
8825
  if (marker === void 0)
8951
8826
  return;
8952
- const { commit } = parseAnswers(await ctx.readFile(join7(target, ANSWERS_FILE)));
8827
+ const { commit } = parseAnswers(await ctx.readFile(join6(target, ANSWERS_FILE)));
8953
8828
  if (!commit)
8954
8829
  return;
8955
8830
  const synced = syncMarker(marker, commit);
8956
8831
  if (synced === marker)
8957
8832
  return;
8958
8833
  ctx.say(` marker: plexus \u2192 ${commit} in ${site.rel}/${MARKER_FILE}`);
8959
- await ctx.stage(write(join7(target, MARKER_FILE), synced));
8834
+ await ctx.stage(write(join6(target, MARKER_FILE), synced));
8960
8835
  }
8961
8836
  async function refreshLockfile(ctx, consumer, dir, base, summary) {
8962
- if (await ctx.readFile(join7(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
8837
+ if (await ctx.readFile(join6(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
8963
8838
  return;
8964
8839
  const manifests = ["*package.json", "pnpm-workspace.yaml"];
8965
8840
  const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
@@ -8974,18 +8849,18 @@ async function refreshLockfile(ctx, consumer, dir, base, summary) {
8974
8849
  }
8975
8850
  }
8976
8851
  async function bumpConsumerRefs(ctx, consumer, dir, train) {
8977
- const workflows = join7(dir, ".github", "workflows");
8852
+ const workflows = join6(dir, ".github", "workflows");
8978
8853
  const entries = await ctx.readDir(workflows).catch(() => []);
8979
8854
  const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
8980
8855
  for (const f of files) {
8981
- const text = await ctx.readFile(join7(workflows, f));
8856
+ const text = await ctx.readFile(join6(workflows, f));
8982
8857
  if (!text.includes(WORKFLOW_REF))
8983
8858
  continue;
8984
8859
  const bumped = bumpWorkflowRefs(text, train);
8985
8860
  if (bumped === text)
8986
8861
  continue;
8987
8862
  ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${train}`);
8988
- await ctx.stage(write(join7(workflows, f), bumped));
8863
+ await ctx.stage(write(join6(workflows, f), bumped));
8989
8864
  }
8990
8865
  }
8991
8866
  async function openPullUrl(ctx, consumer, dir, train) {
@@ -9073,49 +8948,8 @@ var detail = (error) => {
9073
8948
  return last && !/exited with/.test(last) ? `: ${last}` : "";
9074
8949
  };
9075
8950
 
9076
- // ../lib/dist/preview.js
9077
- async function previewConsumers(ctx, workspace, train) {
9078
- const summary = emptySummary(train, ctx.dryRun);
9079
- const upstream = join8(workspace, UPSTREAM);
9080
- const tree = await overview(ctx, workspace);
9081
- const upstreamDir = tree.children.find((c) => c.path === upstream);
9082
- const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
9083
- const consumers = await findConsumers(ctx, tree, presets);
9084
- for (const c of consumers) {
9085
- if (!c.skipped)
9086
- continue;
9087
- ctx.say(`\u26A0 ${c.rel}: ${c.skipped} \u2014 not previewed`);
9088
- summary.skipped.push({ path: c.rel, reason: c.skipped });
9089
- }
9090
- for (const preset of presets)
9091
- if (!consumers.some((c) => c.sites.some((s) => s.preset === preset)))
9092
- ctx.say(`\u2022 no consumers of ${presetSource(preset)} found under ${workspace}`);
9093
- const take = { train, opener: "`plx ship`", previewFrom: upstream };
9094
- const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
9095
- try {
9096
- for (const consumer of consumers) {
9097
- if (consumer.skipped || !consumer.origin)
9098
- continue;
9099
- const clone = join8(scratch, consumer.rel);
9100
- ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
9101
- try {
9102
- await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
9103
- } catch (error) {
9104
- ctx.say(` \u2717 FAILED \u2014 clone${detail(error)}`);
9105
- summary.failed.push(consumer.rel);
9106
- continue;
9107
- }
9108
- await takeTrain(ctx, consumer, clone, take, summary);
9109
- }
9110
- } finally {
9111
- if (scratch)
9112
- await ctx.stage(run("rm", ["-rf", scratch]));
9113
- }
9114
- return summary;
9115
- }
9116
-
9117
8951
  // ../lib/dist/update.js
9118
- import { basename, join as join9, relative as relative4 } from "node:path";
8952
+ import { basename, join as join7, relative as relative4 } from "node:path";
9119
8953
  async function update(ctx, options) {
9120
8954
  const { repo } = options;
9121
8955
  const name = options.name ?? basename(repo);
@@ -9129,7 +8963,7 @@ async function update(ctx, options) {
9129
8963
  throw new Error(`${name}: ${consumer.skipped}`);
9130
8964
  consumer.rel = name;
9131
8965
  for (const s of consumer.sites)
9132
- s.rel = s.rel === "." ? name : join9(name, s.rel);
8966
+ s.rel = s.rel === "." ? name : join7(name, s.rel);
9133
8967
  const root = consumer.sites.find((s) => s.path === consumer.path);
9134
8968
  if (!root)
9135
8969
  throw new Error(`${name}: its root is not a site of a repo preset`);
@@ -9139,9 +8973,9 @@ async function update(ctx, options) {
9139
8973
  const summary = emptySummary(train, ctx.dryRun);
9140
8974
  await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
9141
8975
  const answers = await Promise.all(consumer.sites.map(async (s) => {
9142
- const file = join9(relative4(consumer.path, s.path), ANSWERS_FILE);
8976
+ const file = join7(relative4(consumer.path, s.path), ANSWERS_FILE);
9143
8977
  const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
9144
- return parseAnswers(onOrigin2 ?? await ctx.readFile(join9(s.path, ANSWERS_FILE)));
8978
+ return parseAnswers(onOrigin2 ?? await ctx.readFile(join7(s.path, ANSWERS_FILE)));
9145
8979
  }));
9146
8980
  const recorded = answers.map((a) => a.commit);
9147
8981
  if (recorded.every((c) => c === train)) {
@@ -9180,7 +9014,7 @@ async function update(ctx, options) {
9180
9014
  }
9181
9015
  ctx.say(`\u2022 ${name}: takes ${train} \u2014 ${need.why}`);
9182
9016
  const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
9183
- const dir = join9(scratch, name);
9017
+ const dir = join7(scratch, name);
9184
9018
  try {
9185
9019
  ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
9186
9020
  try {
@@ -9208,13 +9042,13 @@ async function staleIn(ctx, consumer, repo, train) {
9208
9042
  const catalog = catalogOf(parseManifest(text));
9209
9043
  const markers = [];
9210
9044
  for (const site of consumer.sites) {
9211
- const file = join9(relative4(consumer.path, site.path), MARKER_FILE);
9212
- const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(join9(site.path, MARKER_FILE)).catch(() => void 0);
9045
+ const file = join7(relative4(consumer.path, site.path), MARKER_FILE);
9046
+ const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(join7(site.path, MARKER_FILE)).catch(() => void 0);
9213
9047
  if (marker === void 0)
9214
9048
  continue;
9215
9049
  try {
9216
9050
  const { plexus, modules } = parseMarker(marker);
9217
- markers.push({ where: join9(site.rel, MARKER_FILE), plexus, modules });
9051
+ markers.push({ where: join7(site.rel, MARKER_FILE), plexus, modules });
9218
9052
  } catch {
9219
9053
  }
9220
9054
  }
@@ -9261,7 +9095,7 @@ async function propagate(ctx, options) {
9261
9095
  }
9262
9096
 
9263
9097
  // ../lib/dist/requirements.js
9264
- import { join as join10 } from "node:path";
9098
+ import { join as join8 } from "node:path";
9265
9099
  var KEYWORD = /MUST|SHOULD|MAY/;
9266
9100
  var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
9267
9101
  var list = (value) => value.replace(/^\s*\[/, "").replace(/\].*$/, "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -9354,7 +9188,7 @@ var MAP_PAGE = "essentials/standard.md";
9354
9188
  async function modulePages(ctx, compendium) {
9355
9189
  const pages = [];
9356
9190
  for (const dir of Object.keys(CATALOG_DIRS)) {
9357
- const entries = await ctx.readDir(join10(compendium, dir));
9191
+ const entries = await ctx.readDir(join8(compendium, dir));
9358
9192
  for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
9359
9193
  pages.push(`${dir}/${e.name}`);
9360
9194
  }
@@ -9362,11 +9196,11 @@ async function modulePages(ctx, compendium) {
9362
9196
  }
9363
9197
  async function checkCompendium(ctx, compendium) {
9364
9198
  const defects = [];
9365
- defects.push(...scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
9199
+ defects.push(...scanPage(await ctx.readFile(join8(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
9366
9200
  const pages = await modulePages(ctx, compendium);
9367
9201
  const scans = /* @__PURE__ */ new Map();
9368
9202
  for (const page of pages) {
9369
- const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
9203
+ const scan = scanPage(await ctx.readFile(join8(compendium, page)), page, "module");
9370
9204
  defects.push(...scan.defects);
9371
9205
  scans.set(page, scan);
9372
9206
  }
@@ -9412,214 +9246,39 @@ async function checkCompendium(ctx, compendium) {
9412
9246
  };
9413
9247
  }
9414
9248
 
9415
- // ../lib/dist/self.js
9416
- var SELF_PACKAGE = "@plexus-ms/cli";
9417
- async function preflightSelf(ctx, running) {
9418
- const latest = (await ctx.read("npm", ["view", SELF_PACKAGE, "version"]).catch(() => "")).trim();
9419
- if (!latest) {
9420
- ctx.say(`\u26A0 could not ask the registry for the newest ${SELF_PACKAGE}; going on with plx ${running}`);
9421
- return;
9422
- }
9423
- if (compareTrains(running, latest) < 0)
9424
- throw new Error(`plx ${running} is behind ${latest}, the newest release; update it first: mise cache clear npm:${SELF_PACKAGE} && mise up npm:${SELF_PACKAGE}`);
9425
- }
9426
-
9427
- // ../lib/dist/ship.js
9428
- import { join as join11 } from "node:path";
9429
- var DEFAULT_WAIT = { interval: 15e3, timeout: 20 * 6e4 };
9430
- async function ship(ctx, options) {
9431
- const upstream = join11(options.workspace, UPSTREAM);
9432
- if (options.plx)
9433
- await preflightSelf(ctx, options.plx);
9434
- const train = await readTrain(ctx, upstream);
9435
- await preflightForge(ctx);
9436
- await preflightRelease(ctx, train);
9437
- await preflightImmutable(ctx, train);
9438
- const next = resolveVersion(train, options.train, false);
9439
- await release(ctx, train, next, options.today ?? today(), { ...DEFAULT_WAIT, ...options.wait });
9440
- if (ctx.dryRun)
9441
- return { ...await previewConsumers(ctx, options.workspace, next), released: true };
9442
- ctx.say(`\u2022 train ${next} is cut; every repo takes it itself, when it needs it (plx update)`);
9443
- return { ...emptySummary(next, false), released: true };
9444
- }
9445
- async function preflightImmutable(ctx, train) {
9446
- for (const repo of train.repos) {
9447
- const newest = (await ctx.read("gh", ["api", "repos/{owner}/{repo}/releases?per_page=1", "--jq", ".[0].immutable"], { cwd: repo.path }).catch(() => "")).trim();
9448
- if (newest === "false")
9449
- throw new Error(mutableRelease(`${repo.name}: its newest GitHub release is not immutable`));
9450
- }
9451
- }
9452
- var mutableRelease = (what) => `${what} \u2014 enable immutable releases on the plexus-ms organisation (Settings \u2192 General \u2192 Releases); existing releases stay as they are (never delete one: a deleted immutable release burns its number)`;
9453
- async function release(ctx, train, next, today2, wait) {
9454
- ctx.say(`\u2192 train ${train.last ?? "none"} \u2192 ${next}`);
9455
- for (const repo of train.repos) {
9456
- if (repo.pending.length === 0)
9457
- ctx.say(` ${repo.name}: no changes since ${repo.latest} \u2014 tag only`);
9458
- else {
9459
- ctx.say(` ${repo.name} (since ${repo.latest ?? "the beginning"}):`);
9460
- for (const line of repo.pending.slice(0, PENDING_SHOWN))
9461
- ctx.say(` ${line}`);
9462
- if (repo.pending.length > PENDING_SHOWN)
9463
- ctx.say(` \u2026 and ${repo.pending.length - PENDING_SHOWN} more`);
9464
- }
9465
- }
9466
- if (!await ctx.confirm(`tag all ${train.repos.length} repos as ${next}, release them and push?`))
9467
- throw new Error("aborted");
9468
- const [one = [], two = []] = phasesOf(train);
9469
- try {
9470
- await releasePhase(ctx, train, one, next, today2);
9471
- await awaitPublished(ctx, next, wait);
9472
- await releasePhase(ctx, train, two, next, today2);
9473
- } catch (error) {
9474
- const message = error instanceof Error ? error.message : String(error);
9475
- throw new Error(`${message}
9476
- \u2717 ship stopped during the release; re-run with --train ${next} to finish it (tagged repos and existing releases are skipped; if the registry already has ${next}, update plx first: it is the same code, built from the commit phase one tagged)`);
9477
- }
9478
- }
9479
- var PENDING_SHOWN = 20;
9480
- async function releasePhase(ctx, train, repos2, next, today2) {
9481
- ctx.say(`\u2192 phase: ${repos2.map((r) => r.name).join(", ")}`);
9482
- await ctx.apply(await planBookkeeping(ctx, train, repos2, next, today2));
9483
- for (const repo of repos2)
9484
- await tagAndRelease(ctx, repo, next, today2);
9485
- }
9486
- async function tagAndRelease(ctx, repo, next, today2) {
9487
- const tagged = await ctx.read("git", ["rev-parse", "-q", "--verify", `refs/tags/${next}`], { cwd: repo.path }).then(() => true).catch(() => false);
9488
- if (tagged)
9489
- ctx.say(`\u2022 ${repo.name}: already tagged ${next}`);
9490
- else
9491
- await ctx.apply([run("git", ["tag", "-a", next, "-m", `train ${next}`], { cwd: repo.path })]);
9492
- await ctx.apply([run("git", ["push", "origin", "main", next], { cwd: repo.path })]);
9493
- const create = ["release", "create", next, "--verify-tag", "--generate-notes", "--title", next];
9494
- if (repo.name === COMPENDIUM) {
9495
- if (!await releaseWithManifest(ctx, repo, next, today2, create))
9496
- return;
9497
- } else {
9498
- const released = await ctx.read("gh", ["release", "view", next], { cwd: repo.path }).then(() => true).catch(() => false);
9499
- if (released) {
9500
- ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
9501
- return;
9502
- }
9503
- await ctx.apply([run("gh", create, { cwd: repo.path })]);
9504
- }
9505
- if (ctx.dryRun)
9506
- return;
9507
- const immutable = (await ctx.read("gh", ["api", `repos/{owner}/{repo}/releases/tags/${next}`, "--jq", ".immutable"], {
9508
- cwd: repo.path
9509
- })).trim();
9510
- if (immutable !== "true")
9511
- throw new Error(mutableRelease(`${repo.name}: release ${next} was created mutable, and its tag can still move`));
9512
- }
9513
- async function releaseWithManifest(ctx, repo, next, today2, create) {
9514
- const state = (await ctx.read("gh", ["release", "view", next, "--json", "isDraft", "--jq", ".isDraft"], { cwd: repo.path }).catch(() => "")).trim();
9515
- if (state === "false") {
9516
- ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
9517
- return false;
9518
- }
9519
- if (state === "true")
9520
- ctx.say(`\u2022 ${repo.name}: release ${next} is still a draft \u2014 finishing it`);
9521
- else
9522
- await ctx.apply([run("gh", [...create, "--draft"], { cwd: repo.path })]);
9523
- const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
9524
- const file = join11(scratch, MANIFEST_FILE);
9525
- try {
9526
- const manifest2 = buildManifest(await readCatalog(ctx, repo.path), next, today2);
9527
- ctx.say(` ${repo.name}: ${MANIFEST_FILE}: train ${next}, ${manifest2.modules.length} modules`);
9528
- await ctx.stage(write(file, renderManifest(manifest2)));
9529
- await ctx.apply([
9530
- run("gh", ["release", "upload", next, file, "--clobber"], { cwd: repo.path }),
9531
- run("gh", ["release", "edit", next, "--draft=false"], { cwd: repo.path })
9532
- ]);
9533
- } finally {
9534
- if (scratch)
9535
- await ctx.stage(run("rm", ["-rf", scratch]));
9536
- }
9537
- return true;
9249
+ // ../lib/dist/summary.js
9250
+ function mergeLine(urls) {
9251
+ return urls.map((url) => /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/(\d+)$/.exec(url)).filter((m) => m !== null).map((m) => `gh pr merge -md -R ${m[1]} ${m[2]}`).join(" && ");
9538
9252
  }
9539
- async function awaitPublished(ctx, next, wait) {
9540
- const names = TRAIN_PACKAGES.map((p) => p.name);
9541
- const list2 = names.map((n) => `${n}@${next}`).join(", ");
9542
- if (ctx.dryRun) {
9543
- ctx.say(`\u23F3 [dry-run] would wait for ${list2} on npm (${PRIMITIVES}' release workflow publishes them)`);
9544
- return;
9545
- }
9546
- ctx.say(`\u23F3 waiting for ${list2} on npm (${PRIMITIVES}' release workflow publishes them)`);
9547
- const started = Date.now();
9548
- let missing = [...names];
9549
- for (; ; ) {
9550
- const still = [];
9551
- for (const name of missing) {
9552
- const seen = (await ctx.read("npm", ["view", `${name}@${next}`, "version", "--prefer-online"]).catch(() => "")).trim();
9553
- if (seen !== next)
9554
- still.push(name);
9555
- }
9556
- missing = still;
9557
- if (missing.length === 0)
9558
- break;
9559
- if (Date.now() - started >= wait.timeout)
9560
- throw new Error(`${missing.join(", ")} not on npm at ${next} after ${Math.round(wait.timeout / 6e4)} min \u2014 check the release workflow (gh run list -R plexus-ms/${PRIMITIVES})`);
9561
- await new Promise((resolve10) => setTimeout(resolve10, wait.interval));
9562
- }
9563
- ctx.say(` \u2713 ${list2} on npm`);
9564
- }
9565
- async function planBookkeeping(ctx, train, repos2, next, today2) {
9566
- const plan = [];
9567
- const touched = /* @__PURE__ */ new Set();
9568
- const repo = (name) => repos2.find((r) => r.name === name);
9569
- const edit = async (r, rel, what, transform) => {
9570
- const path3 = join11(r.path, rel);
9571
- const text = await ctx.readFile(path3).catch(() => void 0);
9572
- if (text === void 0)
9573
- return;
9574
- const edited = transform(text);
9575
- if (edited === text)
9576
- return;
9577
- ctx.say(` ${r.name}: ${rel}: ${what}`);
9578
- plan.push(write(path3, edited));
9579
- touched.add(r);
9580
- };
9581
- const grep = async (r, needle, pathspecs) => (await ctx.read("git", ["grep", "-l", needle, "--", ...pathspecs], { cwd: r.path }).catch(() => "")).split("\n").filter(Boolean);
9582
- const primitives = repo(PRIMITIVES);
9583
- if (primitives) {
9584
- for (const c of COLLECTIONS)
9585
- await edit(primitives, galaxyFile(c), `plexus.${c} version \u2192 ${next}`, (t) => bumpGalaxyVersion(t, next));
9586
- await edit(primitives, RUNNER_IMAGE_PIN_FILE, `runner image \u2192 ${next}`, (t) => bumpRunnerImagePin(t, next));
9587
- for (const p of TRAIN_PACKAGES)
9588
- await edit(primitives, `${p.dir}/package.json`, `${p.name} \u2192 ${next}`, (t) => bumpManifestVersion(t, next));
9589
- }
9590
- const operationsPreset = repo("preset-repo-operations");
9591
- if (operationsPreset)
9592
- await edit(operationsPreset, "template/requirements.yml", `plexus.* pins \u2192 ${next}`, (t) => bumpCollectionPin(t, next));
9593
- for (const r of repos2) {
9594
- for (const f of await grep(r, WORKFLOW_REF, ["*.yml", "*.yaml", "*.jinja"]))
9595
- await edit(r, f, `workflow refs \u2192 @${next}`, (t) => bumpWorkflowRefs(t, next));
9596
- for (const f of await grep(r, PLX_PIN, ["*.toml", "*.toml.jinja"]))
9597
- await edit(r, f, `plx pin \u2192 ${next}`, (t) => bumpPlxPin(t, next));
9598
- for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*package.json", "*package.json.jinja"]))
9599
- await edit(r, f, `${CONFIG_PIN} pin \u2192 ${next}`, (t) => bumpConfigPin(t, next));
9600
- for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*pnpm-workspace.yaml", "*pnpm-workspace.yaml.jinja"]))
9601
- await edit(r, f, `${CONFIG_PIN} catalog entry \u2192 ${next}`, (t) => bumpCatalogPin(t, next));
9602
- }
9603
- const comp = repo("compendium");
9604
- if (comp) {
9605
- await edit(comp, MAP_PAGE, `version \u2192 ${next}, timestamp \u2192 ${today2}`, (t) => stampStandard(t, next, today2));
9606
- for (const page of await modulePages(ctx, comp.path)) {
9607
- const text = await ctx.readFile(join11(comp.path, page));
9608
- if (frontmatterField(text, "maturity") !== "standard")
9609
- continue;
9610
- const previous = comp.tag ? await ctx.read("git", ["show", `${comp.tag}:${page}`], { cwd: comp.path }).catch(() => "") : "";
9611
- if (extractRequirements(text).join("\n") === extractRequirements(previous).join("\n"))
9612
- continue;
9613
- await edit(comp, page, `requirements changed since ${comp.latest ?? "the beginning"} \u2192 changed: ${next}`, (t) => stampChanged(t, next));
9614
- }
9615
- }
9616
- for (const r of train.repos) {
9617
- if (!touched.has(r))
9618
- continue;
9619
- plan.push(run("git", ["add", "-A"], { cwd: r.path }));
9620
- plan.push(run("git", ["commit", "--quiet", "-m", `chore: train ${next} bookkeeping`], { cwd: r.path }));
9253
+ function renderSummary(s, realCommand, verb = "propagate") {
9254
+ const lines = ["\u2500\u2500 summary \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];
9255
+ for (const p of s.clean)
9256
+ lines.push(` \u2713 clean: ${p}`);
9257
+ for (const p of s.conflicted)
9258
+ lines.push(` \u2717 conflicts: ${p}`);
9259
+ for (const p of s.failed)
9260
+ lines.push(` \u2717 failed: ${p}`);
9261
+ for (const { path: path3, reason } of s.skipped)
9262
+ lines.push(` \u26A0 skipped: ${path3} (${reason})`);
9263
+ for (const { path: path3, reason } of s.resting)
9264
+ lines.push(` \u2022 resting: ${path3} (${reason})`);
9265
+ for (const url of s.pulls)
9266
+ lines.push(` \u2192 pull: ${url}`);
9267
+ const merge = s.preview ? "" : mergeLine(s.mergeable);
9268
+ if (merge)
9269
+ lines.push(" the clean ones, to merge once their checks pass:", ` ${merge}`);
9270
+ const clean = isClean(s);
9271
+ const idle = clean && s.clean.length === 0;
9272
+ if (s.preview && !idle) {
9273
+ lines.push(" (preview only \u2014 nothing was changed)");
9274
+ if (clean)
9275
+ lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
9276
+ } else if (clean) {
9277
+ lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
9621
9278
  }
9622
- return plan;
9279
+ if (!clean)
9280
+ lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
9281
+ return lines.join("\n");
9623
9282
  }
9624
9283
 
9625
9284
  // src/program.ts
@@ -10568,13 +10227,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
10568
10227
 
10569
10228
  // ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
10570
10229
  function withResolver() {
10571
- let resolve10;
10230
+ let resolve9;
10572
10231
  let reject;
10573
10232
  const promise = new Promise((res, rej) => {
10574
- resolve10 = res;
10233
+ resolve9 = res;
10575
10234
  reject = rej;
10576
10235
  });
10577
- return { promise, resolve: resolve10, reject };
10236
+ return { promise, resolve: resolve9, reject };
10578
10237
  }
10579
10238
 
10580
10239
  // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
@@ -10953,7 +10612,7 @@ function createPrompt(view) {
10953
10612
  });
10954
10613
  output.mute();
10955
10614
  const screen = new ScreenManager(rl);
10956
- const { promise, resolve: resolve10, reject } = withResolver();
10615
+ const { promise, resolve: resolve9, reject } = withResolver();
10957
10616
  return withHooks(rl, (cycle) => {
10958
10617
  const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
10959
10618
  const settlePrompt = (settle) => {
@@ -10964,7 +10623,7 @@ function createPrompt(view) {
10964
10623
  reject(error);
10965
10624
  }
10966
10625
  };
10967
- const resolvePrompt = (value) => settlePrompt(() => resolve10(value));
10626
+ const resolvePrompt = (value) => settlePrompt(() => resolve9(value));
10968
10627
  const rejectPrompt = (error) => settlePrompt(() => reject(error));
10969
10628
  const promptPromise = Object.assign(promise.finally(() => {
10970
10629
  cleanups.forEach((cleanup) => cleanup());
@@ -14563,7 +14222,7 @@ function register3(program2) {
14563
14222
 
14564
14223
  // src/commands/doctor.ts
14565
14224
  import { existsSync } from "node:fs";
14566
- import { join as join12, resolve as resolve4 } from "node:path";
14225
+ import { join as join9, resolve as resolve4 } from "node:path";
14567
14226
 
14568
14227
  // src/style.ts
14569
14228
  function style(enabled) {
@@ -14581,8 +14240,8 @@ function register4(program2) {
14581
14240
  ).option("--color", "colour the report even when piped").option("--no-color", "never colour the report").action(async (dir, opts, command) => {
14582
14241
  const ctx = contextOf2(command);
14583
14242
  const root = resolve4(dir);
14584
- const compendium = resolve4(opts.compendium ?? join12(root, WORKSPACE_COMPENDIUM));
14585
- if (!existsSync(join12(compendium, "contracts")))
14243
+ const compendium = resolve4(opts.compendium ?? join9(root, WORKSPACE_COMPENDIUM));
14244
+ if (!existsSync(join9(compendium, "contracts")))
14586
14245
  throw new Error(
14587
14246
  `no compendium at ${compendium}; pass --compendium <path to a checkout of plexus-ms/compendium>`
14588
14247
  );
@@ -14658,50 +14317,8 @@ function annotate(dir, s, modules) {
14658
14317
  }
14659
14318
 
14660
14319
  // src/commands/propagate.ts
14661
- import { resolve as resolve7 } from "node:path";
14662
-
14663
- // src/commands/ship.ts
14664
14320
  import { resolve as resolve6 } from "node:path";
14665
14321
  function register6(program2) {
14666
- program2.command("ship").description(
14667
- "cut the train: tag and release every train repo identically; repos take it themselves (update, propagate)"
14668
- ).argument("[dir]", "the workspace: plexus-ms/ sits under it, and the consumers the dry run previews", ".").option("--train <version>", "the train version, plain semver (default: minor+1 over the latest train)").action(async (dir, opts, command) => {
14669
- const ctx = contextOf2(command);
14670
- const result = await ship(ctx, { workspace: resolve6(dir), train: opts.train, plx: version });
14671
- ctx.result(
14672
- result,
14673
- (r) => r.preview ? renderSummary(r, `plx -y ship --train ${r.train} ${dir}`, "ship") : `\u2713 train ${r.train} cut \u2014 repos take it themselves; to take it now where it matters: plx propagate --now ${dir}`
14674
- );
14675
- if (!isClean(result)) process.exitCode = 1;
14676
- });
14677
- }
14678
- function mergeLine(urls) {
14679
- return urls.map((url) => /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/(\d+)$/.exec(url)).filter((m) => m !== null).map((m) => `gh pr merge -md -R ${m[1]} ${m[2]}`).join(" && ");
14680
- }
14681
- function renderSummary(s, realCommand, verb = "propagate") {
14682
- const lines = ["\u2500\u2500 summary \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];
14683
- for (const p of s.clean) lines.push(` \u2713 clean: ${p}`);
14684
- for (const p of s.conflicted) lines.push(` \u2717 conflicts: ${p}`);
14685
- for (const p of s.failed) lines.push(` \u2717 failed: ${p}`);
14686
- for (const { path: path3, reason } of s.skipped) lines.push(` \u26A0 skipped: ${path3} (${reason})`);
14687
- for (const { path: path3, reason } of s.resting) lines.push(` \u2022 resting: ${path3} (${reason})`);
14688
- for (const url of s.pulls) lines.push(` \u2192 pull: ${url}`);
14689
- const merge = s.preview ? "" : mergeLine(s.mergeable);
14690
- if (merge) lines.push(" the clean ones, to merge once their checks pass:", ` ${merge}`);
14691
- const clean = isClean(s);
14692
- const idle = clean && s.clean.length === 0;
14693
- if (s.preview && !idle) {
14694
- lines.push(" (preview only \u2014 nothing was changed)");
14695
- if (clean) lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
14696
- } else if (clean) {
14697
- lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
14698
- }
14699
- if (!clean) lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
14700
- return lines.join("\n");
14701
- }
14702
-
14703
- // src/commands/propagate.ts
14704
- function register7(program2) {
14705
14322
  program2.command("propagate").description(
14706
14323
  "run update in every repo generated from the presets under a directory: each takes the newest train when it needs it, as one pull request per repo"
14707
14324
  ).argument("[dir]", "a directory the repos sit under, at any depth", ".").option(
@@ -14713,7 +14330,7 @@ function register7(program2) {
14713
14330
  (v) => parseMaxAge(v, "--max-age")
14714
14331
  ).action(async (dir, opts, command) => {
14715
14332
  const ctx = contextOf2(command);
14716
- const result = await propagate(ctx, { dir: resolve7(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
14333
+ const result = await propagate(ctx, { dir: resolve6(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
14717
14334
  const flags = [opts.train ? `--train ${opts.train}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
14718
14335
  ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
14719
14336
  if (!isClean(result)) process.exitCode = 1;
@@ -14721,13 +14338,13 @@ function register7(program2) {
14721
14338
  }
14722
14339
 
14723
14340
  // src/commands/requirements.ts
14724
- import { join as join13, resolve as resolve8 } from "node:path";
14725
- function register8(program2) {
14341
+ import { join as join10, resolve as resolve7 } from "node:path";
14342
+ function register7(program2) {
14726
14343
  program2.command("requirements").description("lint the standard's map and module pages, or extract one module's requirement lines").argument("[dir]", "a checkout of the compendium", ".").option("--extract <page>", "print a module page's requirement lines instead of linting (path relative to dir)").action(async (dir, opts, command) => {
14727
14344
  const ctx = contextOf2(command);
14728
- const compendium = resolve8(dir);
14345
+ const compendium = resolve7(dir);
14729
14346
  if (opts.extract) {
14730
- ctx.result(extractRequirements(await ctx.readFile(join13(compendium, opts.extract))));
14347
+ ctx.result(extractRequirements(await ctx.readFile(join10(compendium, opts.extract))));
14731
14348
  return;
14732
14349
  }
14733
14350
  const check = await checkCompendium(ctx, compendium);
@@ -14741,8 +14358,8 @@ function renderCheck(c) {
14741
14358
  }
14742
14359
 
14743
14360
  // src/commands/update.ts
14744
- import { resolve as resolve9 } from "node:path";
14745
- function register9(program2) {
14361
+ import { resolve as resolve8 } from "node:path";
14362
+ function register8(program2) {
14746
14363
  program2.command("update").description(
14747
14364
  "bring this repo up to the newest train when it needs it (asked, or past the backstop age), as a pull request on plexus/<version>: copier update at every site, the marker, the lockfile, the workflow refs"
14748
14365
  ).argument("[dir]", "a repo generated from the presets", ".").option("--train <version>", "the train to take, whatever the triggers say (default: the preset's newest release)").option("--now", "take the newest train whatever the triggers say").option(
@@ -14751,7 +14368,7 @@ function register9(program2) {
14751
14368
  (v) => parseMaxAge(v, "--max-age")
14752
14369
  ).action(async (dir, opts, command) => {
14753
14370
  const ctx = contextOf2(command);
14754
- const result = await update(ctx, { repo: resolve9(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
14371
+ const result = await update(ctx, { repo: resolve8(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
14755
14372
  ctx.result(result, (r) => renderSummary(r, `plx -y update --train ${r.train} ${dir}`, "update"));
14756
14373
  if (!isClean(result)) process.exitCode = 1;
14757
14374
  });
@@ -14762,9 +14379,8 @@ var commands = [
14762
14379
  register5,
14763
14380
  register4,
14764
14381
  register6,
14765
- register7,
14766
- register9,
14767
14382
  register8,
14383
+ register7,
14768
14384
  register,
14769
14385
  register3,
14770
14386
  register2
@@ -14777,7 +14393,7 @@ function buildProgram() {
14777
14393
  program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
14778
14394
  new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
14779
14395
  ).addOption(new Option("-q, --quiet", "say nothing but results and errors").env("PLX_QUIET")).addOption(new Option("-y, --yes", "answer every confirmation with yes (needed off a terminal)").env("PLX_YES")).addOption(new Option("--json", "print results as JSON").env("PLX_JSON"));
14780
- for (const register10 of commands) register10(program2);
14396
+ for (const register9 of commands) register9(program2);
14781
14397
  return program2;
14782
14398
  }
14783
14399
  function contextOf2(command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexus-ms/cli",
3
- "version": "0.118.0",
3
+ "version": "0.119.0",
4
4
  "description": "plx, the Plexus command-line tool: a single-script adapter over @plexus-ms/lib",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@inquirer/prompts": "^8.7.5",
27
- "@plexus-ms/lib": "0.118.0",
27
+ "@plexus-ms/lib": "0.119.0",
28
28
  "commander": "^15.0.0"
29
29
  },
30
30
  "devDependencies": {