@plexus-ms/cli 0.110.0 → 0.112.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 +115 -177
  2. package/package.json +2 -2
package/dist/plx.js CHANGED
@@ -7582,7 +7582,7 @@ function bumpCollectionPin(text, train) {
7582
7582
  }
7583
7583
  return lines.join("\n");
7584
7584
  }
7585
- var RUNNER_IMAGE_PIN_FILE = "ansible/roles/ci_hybrid_host/defaults/main.yml";
7585
+ var RUNNER_IMAGE_PIN_FILE = "ansible/roles/ci_runner_host/defaults/main.yml";
7586
7586
  var bumpRunnerImagePin = (text, train) => text.replace(/(ghcr\.io\/plexus-ms\/ci-runner:)\d+\.\d+\.\d+/g, `$1${train}`);
7587
7587
  var WORKFLOW_REF = "plexus-ms/primitives/.github/workflows/";
7588
7588
  var bumpWorkflowRefs = (text, train) => text.replace(/(plexus-ms\/primitives\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${train}`);
@@ -7664,83 +7664,9 @@ async function readCatalog(ctx, compendium) {
7664
7664
  return catalog;
7665
7665
  }
7666
7666
 
7667
- // ../lib/dist/changedApps.js
7668
- import { join as join2 } from "node:path";
7669
- var BOOKKEEPING = /(^|\/)(PLEXUS\.md|\.copier-answers\.yml)$/;
7670
- var GLOBALS = /^(pnpm-lock\.yaml|pnpm-workspace\.yaml|package\.json|turbo\.json|mise\.toml|\.npmrc)$/;
7671
- var NO_REF = /^0*$/;
7672
- async function selectChangedApps(input) {
7673
- const all = [...input.all].sort();
7674
- if (input.changed === void 0)
7675
- return { apps: all, reason: "no base ref: every app counts as changed" };
7676
- const changed = input.changed.filter((f) => !BOOKKEEPING.test(f));
7677
- const under = (app) => changed.some((f) => f.startsWith(`apps/${app}/`));
7678
- if (!input.workspace)
7679
- return { apps: all.filter(under), reason: "files under the apps changed" };
7680
- if (changed.length === 0)
7681
- return { apps: [], reason: "nothing but bookkeeping changed" };
7682
- if (changed.some((f) => GLOBALS.test(f)))
7683
- return { apps: all, reason: "a workspace-global input changed: every app counts as changed" };
7684
- const outside = changed.some((f) => !f.startsWith("apps/"));
7685
- const listed = new Set(await input.dependents?.() ?? []);
7686
- return {
7687
- apps: all.filter((app) => listed.has(app) && (outside || under(app))),
7688
- reason: "sources or their dependencies changed"
7689
- };
7690
- }
7691
- async function readChangedApps(ctx, dir, from, to = "HEAD") {
7692
- const git2 = (args) => ctx.read("git", args, { cwd: dir });
7693
- const workspace = await exists(ctx, join2(dir, "pnpm-workspace.yaml"));
7694
- const all = await deployableApps(ctx, dir, workspace);
7695
- let changed;
7696
- if (from !== "" && !NO_REF.test(from) && await isCommit(git2, from))
7697
- changed = (await git2(["diff", "--name-only", from, to])).split("\n").filter(Boolean);
7698
- const dependents = async () => {
7699
- const out = await ctx.read("pnpm", ["--filter", `...[${from}...${to}]`, "ls", "--depth", "-1", "--parseable"], {
7700
- cwd: dir
7701
- });
7702
- return out.split("\n").map((line) => /(?:^|\/)apps\/([^/]+)$/.exec(line.trim())?.[1]).filter((app) => app !== void 0);
7703
- };
7704
- const result = await selectChangedApps({ workspace, all, changed, dependents });
7705
- ctx.say(`\u2192 ${result.reason}`, 1);
7706
- return result;
7707
- }
7708
- async function isCommit(git2, ref) {
7709
- try {
7710
- await git2(["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
7711
- return true;
7712
- } catch {
7713
- return false;
7714
- }
7715
- }
7716
- async function deployableApps(ctx, dir, workspace) {
7717
- const entries = await ctx.readDir(join2(dir, "apps")).catch(() => []);
7718
- const apps = [];
7719
- for (const e of entries) {
7720
- if (!e.directory)
7721
- continue;
7722
- const marks = workspace ? ["package.json"] : ["docker/compose.yaml", "compose.yaml"];
7723
- for (const mark of marks) {
7724
- if (await exists(ctx, join2(dir, "apps", e.name, mark))) {
7725
- apps.push(e.name);
7726
- break;
7727
- }
7728
- }
7729
- }
7730
- return apps.sort();
7731
- }
7732
- async function exists(ctx, path3) {
7733
- try {
7734
- await ctx.readFile(path3);
7735
- return true;
7736
- } catch {
7737
- return false;
7738
- }
7739
- }
7740
-
7741
7667
  // ../lib/dist/changeset.js
7742
7668
  var import_yaml2 = __toESM(require_dist(), 1);
7743
- import { dirname, join as join3 } from "node:path";
7669
+ import { dirname, join as join2 } from "node:path";
7744
7670
 
7745
7671
  // ../lib/dist/io.js
7746
7672
  import { spawn } from "node:child_process";
@@ -7763,7 +7689,7 @@ function realIo(prompt) {
7763
7689
  stdout: process.stdout,
7764
7690
  stderr: process.stderr,
7765
7691
  prompt: prompt && isInteractive() ? prompt : void 0,
7766
- exec: (command, args, options = {}) => new Promise((resolve11, reject) => {
7692
+ exec: (command, args, options = {}) => new Promise((resolve10, reject) => {
7767
7693
  const child = spawn(command, args, {
7768
7694
  cwd: options.cwd,
7769
7695
  env: options.env,
@@ -7786,7 +7712,7 @@ function realIo(prompt) {
7786
7712
  child.on("error", reject);
7787
7713
  child.on("close", (code) => {
7788
7714
  if (code === 0)
7789
- resolve11(stdout);
7715
+ resolve10(stdout);
7790
7716
  else
7791
7717
  reject(new ExecError(render(command, args), code, stderr));
7792
7718
  });
@@ -7805,7 +7731,7 @@ function quote(arg) {
7805
7731
  return /^[\w./:@%+=,-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
7806
7732
  }
7807
7733
 
7808
- // ../lib/dist/plan.js
7734
+ // ../lib/dist/effects.js
7809
7735
  var run = (command, args = [], options = {}) => ({
7810
7736
  kind: "run",
7811
7737
  command,
@@ -7885,7 +7811,7 @@ ${header.join("\n")}
7885
7811
 
7886
7812
  ${lines.join("\n")}
7887
7813
  `;
7888
- return { path: path3, releases, changes, sources, content, plan: [write(root ? join3(root, path3) : path3, content)] };
7814
+ return { path: path3, releases, changes, sources, content, plan: [write(root ? join2(root, path3) : path3, content)] };
7889
7815
  }
7890
7816
  function describeChange(c) {
7891
7817
  const peer = c.field === "peerDependencies" ? " (peer)" : "";
@@ -7934,7 +7860,7 @@ async function readChangeset(ctx, dir, base, branch) {
7934
7860
  };
7935
7861
  const current = async (path4) => {
7936
7862
  try {
7937
- return await ctx.readFile(join3(dir, path4));
7863
+ return await ctx.readFile(join2(dir, path4));
7938
7864
  } catch {
7939
7865
  return void 0;
7940
7866
  }
@@ -7950,7 +7876,7 @@ async function readChangeset(ctx, dir, base, branch) {
7950
7876
  }
7951
7877
  const config = await current(`${CHANGESET_DIR}/config.json`);
7952
7878
  const ignore = config ? JSON.parse(config).ignore ?? [] : [];
7953
- const entries = await ctx.readDir(join3(dir, CHANGESET_DIR)).catch(() => []);
7879
+ const entries = await ctx.readDir(join2(dir, CHANGESET_DIR)).catch(() => []);
7954
7880
  const path3 = changesetPath(head);
7955
7881
  return planChangeset({
7956
7882
  branch: head,
@@ -7971,7 +7897,7 @@ async function expand(ctx, root, glob) {
7971
7897
  if (star < 0)
7972
7898
  return [glob.replace(/\/$/, "")];
7973
7899
  const parent = glob.slice(0, star).replace(/\/$/, "");
7974
- const entries = await ctx.readDir(join3(root, parent)).catch(() => []);
7900
+ const entries = await ctx.readDir(join2(root, parent)).catch(() => []);
7975
7901
  return entries.filter((e) => e.directory && !e.name.startsWith(".")).map((e) => parent ? `${parent}/${e.name}` : e.name).sort();
7976
7902
  }
7977
7903
 
@@ -8184,14 +8110,14 @@ function parseAnswers(text) {
8184
8110
  // ../lib/dist/deploy.js
8185
8111
  import { randomBytes } from "node:crypto";
8186
8112
  import { tmpdir } from "node:os";
8187
- import { join as join6 } from "node:path";
8113
+ import { join as join5 } from "node:path";
8188
8114
 
8189
8115
  // ../lib/dist/deployTargets.js
8190
8116
  var import_yaml4 = __toESM(require_dist(), 1);
8191
- import { join as join5 } from "node:path";
8117
+ import { join as join4 } from "node:path";
8192
8118
 
8193
8119
  // ../lib/dist/train.js
8194
- import { join as join4 } from "node:path";
8120
+ import { join as join3 } from "node:path";
8195
8121
 
8196
8122
  // ../lib/dist/doctor.js
8197
8123
  import { relative as relative2 } from "node:path";
@@ -8281,7 +8207,7 @@ async function readTrain(ctx, upstream) {
8281
8207
  const repos2 = [];
8282
8208
  const all = /* @__PURE__ */ new Set();
8283
8209
  for (const name of TRAIN_REPOS) {
8284
- const path3 = join4(upstream, name);
8210
+ const path3 = join3(upstream, name);
8285
8211
  try {
8286
8212
  await ctx.read("git", ["rev-parse", "--git-dir"], { cwd: path3 });
8287
8213
  } catch {
@@ -8393,11 +8319,23 @@ function targetsIn(targets, environment) {
8393
8319
  }
8394
8320
  return flat;
8395
8321
  }
8322
+ function deployLegs(targets, apps) {
8323
+ const legs = [];
8324
+ const without = [];
8325
+ for (const app of [...apps].sort()) {
8326
+ const host = targets[app];
8327
+ if (host === void 0)
8328
+ without.push(app);
8329
+ else
8330
+ legs.push({ app, host });
8331
+ }
8332
+ return { legs, without };
8333
+ }
8396
8334
  async function readDeployTargets(ctx, inventory) {
8397
8335
  const files = [];
8398
8336
  let found = false;
8399
8337
  for (const sub of VARS_DIRS) {
8400
- const dir = join5(inventory, sub);
8338
+ const dir = join4(inventory, sub);
8401
8339
  const entries = await ctx.readDir(dir).catch(() => void 0);
8402
8340
  if (entries === void 0)
8403
8341
  continue;
@@ -8405,7 +8343,7 @@ async function readDeployTargets(ctx, inventory) {
8405
8343
  for (const e of entries) {
8406
8344
  if (e.directory || !/\.ya?ml$/.test(e.name))
8407
8345
  continue;
8408
- const path3 = join5(dir, e.name);
8346
+ const path3 = join4(dir, e.name);
8409
8347
  files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
8410
8348
  }
8411
8349
  }
@@ -8434,7 +8372,7 @@ function defaultAppDir(tenant, app, environment = DEFAULT_ENVIRONMENT) {
8434
8372
  }
8435
8373
  var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
8436
8374
  var Remote = class {
8437
- socket = join6(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8375
+ socket = join5(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
8438
8376
  ctx;
8439
8377
  host;
8440
8378
  constructor(ctx, host) {
@@ -8499,7 +8437,7 @@ async function deploy(ctx, options) {
8499
8437
  let text = "";
8500
8438
  for (const candidate of [`${source}/docker/compose.yaml`, `${source}/compose.yaml`]) {
8501
8439
  try {
8502
- text = await ctx.readFile(join6(dir, candidate));
8440
+ text = await ctx.readFile(join5(dir, candidate));
8503
8441
  compose = candidate;
8504
8442
  break;
8505
8443
  } catch {
@@ -8534,15 +8472,15 @@ async function deploy(ctx, options) {
8534
8472
  };
8535
8473
  if (ctx.dryRun)
8536
8474
  ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
8537
- else if (image && result.previous === image) {
8475
+ else if (image ? result.previous === image : result.previous !== void 0) {
8538
8476
  const sameFile = await remote.test(`cd ${D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`);
8539
8477
  if (sameFile) {
8540
8478
  resolvedUrl = options.healthUrl || await resolveHealthUrl(remote, D, dc, ctx);
8541
8479
  if (await remote.test(poll(1))) {
8542
- result.live = image;
8480
+ result.live = result.previous;
8543
8481
  result.healthy = true;
8544
8482
  result.unchanged = true;
8545
- ctx.done(`${image} is already live and healthy; nothing to do`);
8483
+ ctx.done(`${result.previous} is already live and healthy; nothing to do`);
8546
8484
  return result;
8547
8485
  }
8548
8486
  }
@@ -8625,7 +8563,7 @@ function isNotable(dir) {
8625
8563
  }
8626
8564
 
8627
8565
  // ../lib/dist/overview.js
8628
- import { join as join7 } from "node:path";
8566
+ import { join as join6 } from "node:path";
8629
8567
  var PRUNED = /* @__PURE__ */ new Set([
8630
8568
  "node_modules",
8631
8569
  ".hg",
@@ -8706,7 +8644,7 @@ async function walk(ctx, path3, name, options) {
8706
8644
  }
8707
8645
  const subdirs = entries.filter((e) => e.directory && e.name !== ".git" && !PRUNED.has(e.name)).map((e) => e.name).sort();
8708
8646
  for (const sub of subdirs) {
8709
- const child = await walk(ctx, join7(path3, sub), sub, options);
8647
+ const child = await walk(ctx, join6(path3, sub), sub, options);
8710
8648
  if (isNotable(child) || child.children.length > 0)
8711
8649
  dir.children.push(child);
8712
8650
  }
@@ -8714,7 +8652,7 @@ async function walk(ctx, path3, name, options) {
8714
8652
  }
8715
8653
  async function facet(ctx, dir, file, read) {
8716
8654
  try {
8717
- read(await ctx.readFile(join7(dir.path, file)));
8655
+ read(await ctx.readFile(join6(dir.path, file)));
8718
8656
  } catch (error) {
8719
8657
  dir.problems ??= [];
8720
8658
  dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
@@ -8753,7 +8691,7 @@ async function templateFacet(ctx, cwd) {
8753
8691
  }
8754
8692
 
8755
8693
  // ../lib/dist/propagate.js
8756
- import { join as join8, relative as relative3 } from "node:path";
8694
+ import { join as join7, relative as relative3 } from "node:path";
8757
8695
  var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
8758
8696
  var emptySummary = (train, preview) => ({
8759
8697
  train,
@@ -8771,7 +8709,7 @@ var copierIn = (dir, args) => [
8771
8709
  ];
8772
8710
  async function propagate(ctx, workspace, train) {
8773
8711
  const summary = emptySummary(train, ctx.dryRun);
8774
- const upstream = join8(workspace, UPSTREAM);
8712
+ const upstream = join7(workspace, UPSTREAM);
8775
8713
  const tree = await overview(ctx, workspace);
8776
8714
  const upstreamDir = tree.children.find((c) => c.path === upstream);
8777
8715
  const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
@@ -8791,7 +8729,7 @@ async function propagate(ctx, workspace, train) {
8791
8729
  for (const consumer of consumers) {
8792
8730
  if (consumer.skipped || !consumer.origin)
8793
8731
  continue;
8794
- const clone = join8(scratch, consumer.rel);
8732
+ const clone = join7(scratch, consumer.rel);
8795
8733
  ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
8796
8734
  try {
8797
8735
  await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
@@ -8831,13 +8769,13 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
8831
8769
  message
8832
8770
  ], { cwd: dir })));
8833
8771
  async function updateSite(ctx, consumer, site, dir, take, summary) {
8834
- const target = join8(dir, relative3(consumer.path, site.path));
8772
+ const target = join7(dir, relative3(consumer.path, site.path));
8835
8773
  try {
8836
8774
  if (take.previewFrom) {
8837
- const localPreset = join8(take.previewFrom, site.preset);
8775
+ const localPreset = join7(take.previewFrom, site.preset);
8838
8776
  ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localPreset}@main)`);
8839
- const answers = await ctx.readFile(join8(target, ANSWERS_FILE));
8840
- await ctx.stage(write(join8(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localPreset}`)));
8777
+ const answers = await ctx.readFile(join7(target, ANSWERS_FILE));
8778
+ await ctx.stage(write(join7(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localPreset}`)));
8841
8779
  await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localPreset} from the local checkout`);
8842
8780
  await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
8843
8781
  } else {
@@ -8865,7 +8803,7 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
8865
8803
  let conflict = hasUnmergedEntries(status);
8866
8804
  const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
8867
8805
  for (const f of changed) {
8868
- const text = await ctx.readFile(join8(target, f)).catch(() => "");
8806
+ const text = await ctx.readFile(join7(target, f)).catch(() => "");
8869
8807
  if (hasConflictMarkers(text))
8870
8808
  conflict = true;
8871
8809
  }
@@ -8885,20 +8823,20 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
8885
8823
  await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
8886
8824
  }
8887
8825
  async function syncSiteMarker(ctx, site, target) {
8888
- const marker = await ctx.readFile(join8(target, MARKER_FILE)).catch(() => void 0);
8826
+ const marker = await ctx.readFile(join7(target, MARKER_FILE)).catch(() => void 0);
8889
8827
  if (marker === void 0)
8890
8828
  return;
8891
- const { commit } = parseAnswers(await ctx.readFile(join8(target, ANSWERS_FILE)));
8829
+ const { commit } = parseAnswers(await ctx.readFile(join7(target, ANSWERS_FILE)));
8892
8830
  if (!commit)
8893
8831
  return;
8894
8832
  const synced = syncMarker(marker, commit);
8895
8833
  if (synced === marker)
8896
8834
  return;
8897
8835
  ctx.say(` marker: plexus \u2192 ${commit} in ${site.rel}/${MARKER_FILE}`);
8898
- await ctx.stage(write(join8(target, MARKER_FILE), synced));
8836
+ await ctx.stage(write(join7(target, MARKER_FILE), synced));
8899
8837
  }
8900
8838
  async function refreshLockfile(ctx, consumer, dir, base, summary) {
8901
- if (await ctx.readFile(join8(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
8839
+ if (await ctx.readFile(join7(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
8902
8840
  return;
8903
8841
  const manifests = ["*package.json", "pnpm-workspace.yaml"];
8904
8842
  const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
@@ -8913,18 +8851,18 @@ async function refreshLockfile(ctx, consumer, dir, base, summary) {
8913
8851
  }
8914
8852
  }
8915
8853
  async function bumpConsumerRefs(ctx, consumer, dir, train) {
8916
- const workflows = join8(dir, ".github", "workflows");
8854
+ const workflows = join7(dir, ".github", "workflows");
8917
8855
  const entries = await ctx.readDir(workflows).catch(() => []);
8918
8856
  const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
8919
8857
  for (const f of files) {
8920
- const text = await ctx.readFile(join8(workflows, f));
8858
+ const text = await ctx.readFile(join7(workflows, f));
8921
8859
  if (!text.includes(WORKFLOW_REF))
8922
8860
  continue;
8923
8861
  const bumped = bumpWorkflowRefs(text, train);
8924
8862
  if (bumped === text)
8925
8863
  continue;
8926
8864
  ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${train}`);
8927
- await ctx.stage(write(join8(workflows, f), bumped));
8865
+ await ctx.stage(write(join7(workflows, f), bumped));
8928
8866
  }
8929
8867
  }
8930
8868
  async function openPullUrl(ctx, consumer, dir, train) {
@@ -9005,7 +8943,7 @@ var detail = (error) => {
9005
8943
  };
9006
8944
 
9007
8945
  // ../lib/dist/requirements.js
9008
- import { join as join9 } from "node:path";
8946
+ import { join as join8 } from "node:path";
9009
8947
  var KEYWORD = /MUST|SHOULD|MAY/;
9010
8948
  var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
9011
8949
  var list = (value) => value.replace(/^\s*\[/, "").replace(/\].*$/, "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -9098,7 +9036,7 @@ var MAP_PAGE = "essentials/standard.md";
9098
9036
  async function modulePages(ctx, compendium) {
9099
9037
  const pages = [];
9100
9038
  for (const dir of Object.keys(CATALOG_DIRS)) {
9101
- const entries = await ctx.readDir(join9(compendium, dir));
9039
+ const entries = await ctx.readDir(join8(compendium, dir));
9102
9040
  for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
9103
9041
  pages.push(`${dir}/${e.name}`);
9104
9042
  }
@@ -9106,11 +9044,11 @@ async function modulePages(ctx, compendium) {
9106
9044
  }
9107
9045
  async function checkCompendium(ctx, compendium) {
9108
9046
  const defects = [];
9109
- defects.push(...scanPage(await ctx.readFile(join9(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
9047
+ defects.push(...scanPage(await ctx.readFile(join8(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
9110
9048
  const pages = await modulePages(ctx, compendium);
9111
9049
  const scans = /* @__PURE__ */ new Map();
9112
9050
  for (const page of pages) {
9113
- const scan = scanPage(await ctx.readFile(join9(compendium, page)), page, "module");
9051
+ const scan = scanPage(await ctx.readFile(join8(compendium, page)), page, "module");
9114
9052
  defects.push(...scan.defects);
9115
9053
  scans.set(page, scan);
9116
9054
  }
@@ -9169,10 +9107,10 @@ async function preflightSelf(ctx, running) {
9169
9107
  }
9170
9108
 
9171
9109
  // ../lib/dist/ship.js
9172
- import { join as join10 } from "node:path";
9110
+ import { join as join9 } from "node:path";
9173
9111
  var DEFAULT_WAIT = { interval: 15e3, timeout: 20 * 6e4 };
9174
9112
  async function ship(ctx, options) {
9175
- const upstream = join10(options.workspace, UPSTREAM);
9113
+ const upstream = join9(options.workspace, UPSTREAM);
9176
9114
  const propagateOnly = options.propagateOnly ?? false;
9177
9115
  if (options.plx)
9178
9116
  await preflightSelf(ctx, options.plx);
@@ -9274,7 +9212,7 @@ async function awaitPublished(ctx, next, wait) {
9274
9212
  break;
9275
9213
  if (Date.now() - started >= wait.timeout)
9276
9214
  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})`);
9277
- await new Promise((resolve11) => setTimeout(resolve11, wait.interval));
9215
+ await new Promise((resolve10) => setTimeout(resolve10, wait.interval));
9278
9216
  }
9279
9217
  ctx.say(` \u2713 ${list2} on npm`);
9280
9218
  }
@@ -9283,7 +9221,7 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
9283
9221
  const touched = /* @__PURE__ */ new Set();
9284
9222
  const repo = (name) => repos2.find((r) => r.name === name);
9285
9223
  const edit = async (r, rel, what, transform) => {
9286
- const path3 = join10(r.path, rel);
9224
+ const path3 = join9(r.path, rel);
9287
9225
  const text = await ctx.readFile(path3).catch(() => void 0);
9288
9226
  if (text === void 0)
9289
9227
  return;
@@ -9319,7 +9257,7 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
9319
9257
  if (comp) {
9320
9258
  await edit(comp, MAP_PAGE, `version \u2192 ${next}, timestamp \u2192 ${today2}`, (t) => stampStandard(t, next, today2));
9321
9259
  for (const page of await modulePages(ctx, comp.path)) {
9322
- const text = await ctx.readFile(join10(comp.path, page));
9260
+ const text = await ctx.readFile(join9(comp.path, page));
9323
9261
  if (frontmatterField(text, "maturity") !== "standard")
9324
9262
  continue;
9325
9263
  const previous = comp.tag ? await ctx.read("git", ["show", `${comp.tag}:${page}`], { cwd: comp.path }).catch(() => "") : "";
@@ -9338,7 +9276,7 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
9338
9276
  }
9339
9277
 
9340
9278
  // ../lib/dist/update.js
9341
- import { basename, join as join11 } from "node:path";
9279
+ import { basename, join as join10 } from "node:path";
9342
9280
  var PRESETS = TRAIN_REPOS.filter((r) => r.startsWith("preset-"));
9343
9281
  async function update(ctx, options) {
9344
9282
  const { repo } = options;
@@ -9353,14 +9291,14 @@ async function update(ctx, options) {
9353
9291
  throw new Error(`${name}: ${consumer.skipped}`);
9354
9292
  consumer.rel = name;
9355
9293
  for (const s of consumer.sites)
9356
- s.rel = s.rel === "." ? name : join11(name, s.rel);
9294
+ s.rel = s.rel === "." ? name : join10(name, s.rel);
9357
9295
  const root = consumer.sites.find((s) => s.path === consumer.path);
9358
9296
  if (!root)
9359
9297
  throw new Error(`${name}: its root is not a site of a repo preset`);
9360
9298
  await preflightForge(ctx);
9361
9299
  const train = options.train ?? await newestTrain(ctx, root.preset);
9362
9300
  const summary = emptySummary(train, ctx.dryRun);
9363
- const recorded = await Promise.all(consumer.sites.map(async (s) => parseAnswers(await ctx.readFile(join11(s.path, ANSWERS_FILE))).commit));
9301
+ const recorded = await Promise.all(consumer.sites.map(async (s) => parseAnswers(await ctx.readFile(join10(s.path, ANSWERS_FILE))).commit));
9364
9302
  if (recorded.every((c) => c === train)) {
9365
9303
  ctx.say(`\u2022 ${name}: already at ${train}`);
9366
9304
  return summary;
@@ -9378,7 +9316,7 @@ async function update(ctx, options) {
9378
9316
  return summary;
9379
9317
  }
9380
9318
  const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
9381
- const dir = join11(scratch, name);
9319
+ const dir = join10(scratch, name);
9382
9320
  try {
9383
9321
  ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
9384
9322
  try {
@@ -10353,13 +10291,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
10353
10291
 
10354
10292
  // ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
10355
10293
  function withResolver() {
10356
- let resolve11;
10294
+ let resolve10;
10357
10295
  let reject;
10358
10296
  const promise = new Promise((res, rej) => {
10359
- resolve11 = res;
10297
+ resolve10 = res;
10360
10298
  reject = rej;
10361
10299
  });
10362
- return { promise, resolve: resolve11, reject };
10300
+ return { promise, resolve: resolve10, reject };
10363
10301
  }
10364
10302
 
10365
10303
  // ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
@@ -10738,7 +10676,7 @@ function createPrompt(view) {
10738
10676
  });
10739
10677
  output.mute();
10740
10678
  const screen = new ScreenManager(rl);
10741
- const { promise, resolve: resolve11, reject } = withResolver();
10679
+ const { promise, resolve: resolve10, reject } = withResolver();
10742
10680
  return withHooks(rl, (cycle) => {
10743
10681
  const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
10744
10682
  const settlePrompt = (settle) => {
@@ -10749,7 +10687,7 @@ function createPrompt(view) {
10749
10687
  reject(error);
10750
10688
  }
10751
10689
  };
10752
- const resolvePrompt = (value) => settlePrompt(() => resolve11(value));
10690
+ const resolvePrompt = (value) => settlePrompt(() => resolve10(value));
10753
10691
  const rejectPrompt = (error) => settlePrompt(() => reject(error));
10754
10692
  const promptPromise = Object.assign(promise.finally(() => {
10755
10693
  cleanups.forEach((cleanup) => cleanup());
@@ -14268,24 +14206,14 @@ function useColor() {
14268
14206
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/index.js
14269
14207
  var program = new Command();
14270
14208
 
14271
- // src/commands/changed-apps.ts
14209
+ // src/commands/changeset.ts
14272
14210
  import { resolve } from "node:path";
14273
14211
  function register(program2) {
14274
- program2.command("changed-apps").description("list the apps whose sources changed between two refs, dependents of a changed package included").argument("<from>", "the base ref; empty, all zeros or unknown lists every app").argument("[to]", "the ref compared against", "HEAD").option("-C, --dir <dir>", "the checkout to read", ".").action(async (from, to, opts, command) => {
14275
- const ctx = contextOf2(command);
14276
- const result = await readChangedApps(ctx, resolve(opts.dir), from, to);
14277
- ctx.result(result.apps);
14278
- });
14279
- }
14280
-
14281
- // src/commands/changeset.ts
14282
- import { resolve as resolve2 } from "node:path";
14283
- function register2(program2) {
14284
14212
  program2.command("changeset").description(
14285
14213
  "write the changeset a dependency bump owes: a patch per package whose runtime dependencies or shipped source moved"
14286
14214
  ).argument("[dir]", "a checkout of the package repo, on the bump branch", ".").option("--base <ref>", "the trunk the branch is diffed against, at the merge base", "origin/main").option("--branch <name>", "the branch name that names the file (default: the checked-out branch)").action(async (dir, opts, command) => {
14287
14215
  const ctx = contextOf2(command);
14288
- const changeset = await readChangeset(ctx, resolve2(dir), opts.base, opts.branch);
14216
+ const changeset = await readChangeset(ctx, resolve(dir), opts.base, opts.branch);
14289
14217
  await ctx.apply(changeset.plan);
14290
14218
  ctx.result(changeset, renderChangeset);
14291
14219
  });
@@ -14297,8 +14225,8 @@ function renderChangeset(c) {
14297
14225
  }
14298
14226
 
14299
14227
  // src/commands/deploy.ts
14300
- import { resolve as resolve3 } from "node:path";
14301
- function register3(program2) {
14228
+ import { resolve as resolve2 } from "node:path";
14229
+ function register2(program2) {
14302
14230
  program2.command("deploy").description(
14303
14231
  "render the app\u2019s compose file with the image pinned, stage it on the host, pull, migrate, swap, up, poll readiness, roll back on failure"
14304
14232
  ).argument("<host>", "ssh target, deploy@host").argument("<tenant>", "tenant slug, the first segment of the app dir on the host").argument("<app>", "the app, apps/<app> in the checkout").option("--image <ref>", "the image ref to pin; absent for a third-party app whose compose.yaml pins its own").option(
@@ -14322,7 +14250,7 @@ function register3(program2) {
14322
14250
  environment: opts.environment,
14323
14251
  appDir: opts.appDir,
14324
14252
  source: opts.source,
14325
- dir: resolve3(opts.dir)
14253
+ dir: resolve2(opts.dir)
14326
14254
  });
14327
14255
  ctx.result(result, renderDeploy);
14328
14256
  if (!result.healthy) process.exitCode = 1;
@@ -14334,13 +14262,24 @@ function renderDeploy(d) {
14334
14262
  }
14335
14263
 
14336
14264
  // src/commands/deploy-targets.ts
14337
- import { resolve as resolve4 } from "node:path";
14338
- function register4(program2) {
14265
+ import { resolve as resolve3 } from "node:path";
14266
+ function register3(program2) {
14339
14267
  program2.command("deploy-targets").description(
14340
14268
  "map each app of a platform repo, per environment, to the deploy target of the inventory file that declares it"
14341
- ).argument("[inventory]", "the inventory directory", "inventory").option("-e, --environment <name>", "one environment only, as a flat app \u2192 target map").action(async (inventory, opts, command) => {
14269
+ ).argument("[inventory]", "the inventory directory", "inventory").option("-e, --environment <name>", "one environment only, as a flat app \u2192 target map").option(
14270
+ "--apps <dir>",
14271
+ "with --environment: only the apps with a directory under <dir>, as a list of {app, host} for a matrix"
14272
+ ).action(async (inventory, opts, command) => {
14342
14273
  const ctx = contextOf2(command);
14343
- const targets = await readDeployTargets(ctx, resolve4(inventory));
14274
+ const targets = await readDeployTargets(ctx, resolve3(inventory));
14275
+ if (opts.apps !== void 0) {
14276
+ if (!opts.environment) throw new UsageError("--apps needs --environment");
14277
+ const dirs = (await ctx.readDir(resolve3(opts.apps)).catch(() => [])).filter((e) => e.directory).map((e) => e.name);
14278
+ const { legs, without } = deployLegs(targetsIn(targets, opts.environment), dirs);
14279
+ for (const app of without) ctx.say(`${app} has no deployment in ${opts.environment}; nothing to deploy`);
14280
+ ctx.result(legs, (l) => JSON.stringify(l));
14281
+ return;
14282
+ }
14344
14283
  const result = opts.environment ? targetsIn(targets, opts.environment) : targets;
14345
14284
  ctx.result(result, (t) => JSON.stringify(t));
14346
14285
  });
@@ -14348,7 +14287,7 @@ function register4(program2) {
14348
14287
 
14349
14288
  // src/commands/doctor.ts
14350
14289
  import { existsSync } from "node:fs";
14351
- import { join as join12, resolve as resolve5 } from "node:path";
14290
+ import { join as join11, resolve as resolve4 } from "node:path";
14352
14291
 
14353
14292
  // src/style.ts
14354
14293
  function style(enabled) {
@@ -14359,15 +14298,15 @@ var colorByDefault = () => process.stdout.isTTY === true && !process.env.NO_COLO
14359
14298
 
14360
14299
  // src/commands/doctor.ts
14361
14300
  var WORKSPACE_COMPENDIUM = "plexus-ms/compendium";
14362
- function register5(program2) {
14301
+ function register4(program2) {
14363
14302
  program2.command("doctor").description("check every PLEXUS.md under a directory for modules that changed since and dependencies not declared").argument("[dir]", "directory to check", ".").option(
14364
14303
  "--compendium <path>",
14365
14304
  `compendium checkout to read the modules from (default: <dir>/${WORKSPACE_COMPENDIUM})`
14366
14305
  ).option("--color", "colour the report even when piped").option("--no-color", "never colour the report").action(async (dir, opts, command) => {
14367
14306
  const ctx = contextOf2(command);
14368
- const root = resolve5(dir);
14369
- const compendium = resolve5(opts.compendium ?? join12(root, WORKSPACE_COMPENDIUM));
14370
- if (!existsSync(join12(compendium, "contracts")))
14307
+ const root = resolve4(dir);
14308
+ const compendium = resolve4(opts.compendium ?? join11(root, WORKSPACE_COMPENDIUM));
14309
+ if (!existsSync(join11(compendium, "contracts")))
14371
14310
  throw new Error(
14372
14311
  `no compendium at ${compendium}; pass --compendium <path to a checkout of plexus-ms/compendium>`
14373
14312
  );
@@ -14395,11 +14334,11 @@ function renderReport(report, s, showCurrent) {
14395
14334
  }
14396
14335
 
14397
14336
  // src/commands/overview.ts
14398
- import { resolve as resolve6 } from "node:path";
14399
- function register6(program2) {
14337
+ import { resolve as resolve5 } from "node:path";
14338
+ function register5(program2) {
14400
14339
  program2.command("overview").description("map the git repos, copier templates and projects, and Plexus units under a directory").argument("[dir]", "directory to map", ".").option("-s, --sync", "fetch every repo first, to show branches behind (or ahead of) their upstream").option("--color", "colour the tree even when piped").option("--no-color", "never colour the tree").action(async (dir, opts, command) => {
14401
14340
  const ctx = contextOf2(command);
14402
- const tree = await overview(ctx, resolve6(dir), { fetch: opts.sync ?? false });
14341
+ const tree = await overview(ctx, resolve5(dir), { fetch: opts.sync ?? false });
14403
14342
  const s = style(opts.color ?? colorByDefault());
14404
14343
  ctx.result(tree, (t) => renderTree(t, s, ctx.verbose >= 1));
14405
14344
  });
@@ -14443,16 +14382,16 @@ function annotate(dir, s, modules) {
14443
14382
  }
14444
14383
 
14445
14384
  // src/commands/propagate.ts
14446
- import { resolve as resolve8 } from "node:path";
14385
+ import { resolve as resolve7 } from "node:path";
14447
14386
 
14448
14387
  // src/commands/ship.ts
14449
- import { resolve as resolve7 } from "node:path";
14450
- function register7(program2) {
14388
+ import { resolve as resolve6 } from "node:path";
14389
+ function register6(program2) {
14451
14390
  program2.command("ship").description(
14452
14391
  "release the train: tag and release every train repo identically, then open a pull request per consumer"
14453
14392
  ).argument("[dir]", "the workspace: plexus-ms/ and the consumers sit under it", ".").option("--train <version>", "the train version, plain semver (default: minor+1 over the latest train)").action(async (dir, opts, command) => {
14454
14393
  const ctx = contextOf2(command);
14455
- const result = await ship(ctx, { workspace: resolve7(dir), train: opts.train, plx: version });
14394
+ const result = await ship(ctx, { workspace: resolve6(dir), train: opts.train, plx: version });
14456
14395
  ctx.result(result, (r) => renderSummary(r, `plx -y ship --train ${r.train} ${dir}`));
14457
14396
  if (!isClean(result)) process.exitCode = 1;
14458
14397
  });
@@ -14476,23 +14415,23 @@ function renderSummary(s, realCommand, verb = "propagate") {
14476
14415
  }
14477
14416
 
14478
14417
  // src/commands/propagate.ts
14479
- function register8(program2) {
14418
+ function register7(program2) {
14480
14419
  program2.command("propagate").description("copier-update every consumer of the presets to the current train, as one pull request per consumer").argument("[dir]", "the workspace: plexus-ms/ and the consumers sit under it", ".").option("--train <version>", "the train to propagate (default: the current one)").action(async (dir, opts, command) => {
14481
14420
  const ctx = contextOf2(command);
14482
- const result = await ship(ctx, { workspace: resolve8(dir), train: opts.train, propagateOnly: true, plx: version });
14421
+ const result = await ship(ctx, { workspace: resolve7(dir), train: opts.train, propagateOnly: true, plx: version });
14483
14422
  ctx.result(result, (r) => renderSummary(r, `plx -y propagate --train ${r.train} ${dir}`));
14484
14423
  if (!isClean(result)) process.exitCode = 1;
14485
14424
  });
14486
14425
  }
14487
14426
 
14488
14427
  // src/commands/requirements.ts
14489
- import { join as join13, resolve as resolve9 } from "node:path";
14490
- function register9(program2) {
14428
+ import { join as join12, resolve as resolve8 } from "node:path";
14429
+ function register8(program2) {
14491
14430
  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) => {
14492
14431
  const ctx = contextOf2(command);
14493
- const compendium = resolve9(dir);
14432
+ const compendium = resolve8(dir);
14494
14433
  if (opts.extract) {
14495
- ctx.result(extractRequirements(await ctx.readFile(join13(compendium, opts.extract))));
14434
+ ctx.result(extractRequirements(await ctx.readFile(join12(compendium, opts.extract))));
14496
14435
  return;
14497
14436
  }
14498
14437
  const check = await checkCompendium(ctx, compendium);
@@ -14506,13 +14445,13 @@ function renderCheck(c) {
14506
14445
  }
14507
14446
 
14508
14447
  // src/commands/update.ts
14509
- import { resolve as resolve10 } from "node:path";
14510
- function register10(program2) {
14448
+ import { resolve as resolve9 } from "node:path";
14449
+ function register9(program2) {
14511
14450
  program2.command("update").description(
14512
14451
  "bring this repo up to a train, as a pull request on plexus/<version>: copier update at every site, the marker, the lockfile, the workflow refs"
14513
14452
  ).argument("[dir]", "a repo generated from the presets", ".").option("--train <version>", "the train to take (default: the preset's newest release)").action(async (dir, opts, command) => {
14514
14453
  const ctx = contextOf2(command);
14515
- const result = await update(ctx, { repo: resolve10(dir), train: opts.train });
14454
+ const result = await update(ctx, { repo: resolve9(dir), train: opts.train });
14516
14455
  ctx.result(result, (r) => renderSummary(r, `plx -y update --train ${r.train} ${dir}`, "update"));
14517
14456
  if (!isClean(result)) process.exitCode = 1;
14518
14457
  });
@@ -14520,16 +14459,15 @@ function register10(program2) {
14520
14459
 
14521
14460
  // src/commands/index.ts
14522
14461
  var commands = [
14523
- register6,
14524
14462
  register5,
14463
+ register4,
14464
+ register6,
14525
14465
  register7,
14526
- register8,
14527
- register10,
14528
14466
  register9,
14529
- register2,
14467
+ register8,
14530
14468
  register,
14531
- register4,
14532
- register3
14469
+ register3,
14470
+ register2
14533
14471
  ];
14534
14472
 
14535
14473
  // src/program.ts
@@ -14539,7 +14477,7 @@ function buildProgram() {
14539
14477
  program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
14540
14478
  new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
14541
14479
  ).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"));
14542
- for (const register11 of commands) register11(program2);
14480
+ for (const register10 of commands) register10(program2);
14543
14481
  return program2;
14544
14482
  }
14545
14483
  function contextOf2(command) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexus-ms/cli",
3
- "version": "0.110.0",
3
+ "version": "0.112.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.110.0",
27
+ "@plexus-ms/lib": "0.112.0",
28
28
  "commander": "^15.0.0"
29
29
  },
30
30
  "devDependencies": {