@plexus-ms/cli 0.117.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.
- package/dist/plx.js +169 -532
- 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((
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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
|
|
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,
|
|
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(
|
|
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
|
|
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);
|
|
@@ -8841,6 +8716,7 @@ function mergeSummary(into, from) {
|
|
|
8841
8716
|
into.skipped.push(...from.skipped);
|
|
8842
8717
|
into.resting.push(...from.resting);
|
|
8843
8718
|
into.pulls.push(...from.pulls);
|
|
8719
|
+
into.mergeable.push(...from.mergeable);
|
|
8844
8720
|
}
|
|
8845
8721
|
var emptySummary = (train, preview) => ({
|
|
8846
8722
|
train,
|
|
@@ -8850,8 +8726,11 @@ var emptySummary = (train, preview) => ({
|
|
|
8850
8726
|
failed: [],
|
|
8851
8727
|
skipped: [],
|
|
8852
8728
|
resting: [],
|
|
8853
|
-
pulls: []
|
|
8729
|
+
pulls: [],
|
|
8730
|
+
mergeable: []
|
|
8854
8731
|
});
|
|
8732
|
+
var CLEAN_BODY = "Merged clean at every site.";
|
|
8733
|
+
var ofConsumer = (list2, consumer) => list2.filter((p) => p === consumer.rel || p.startsWith(`${consumer.rel}/`));
|
|
8855
8734
|
var trainBranch = (train) => `plexus/${train}`;
|
|
8856
8735
|
var copierIn = (dir, args) => [
|
|
8857
8736
|
"env",
|
|
@@ -8880,23 +8759,23 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
|
|
|
8880
8759
|
message
|
|
8881
8760
|
], { cwd: dir })));
|
|
8882
8761
|
async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
8883
|
-
const target =
|
|
8762
|
+
const target = join6(dir, relative3(consumer.path, site.path));
|
|
8884
8763
|
try {
|
|
8885
8764
|
if (take.previewFrom) {
|
|
8886
|
-
const localPreset =
|
|
8765
|
+
const localPreset = join6(take.previewFrom, site.preset);
|
|
8887
8766
|
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localPreset}@main)`);
|
|
8888
|
-
const answers = await ctx.readFile(
|
|
8889
|
-
await ctx.stage(write(
|
|
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}`)));
|
|
8890
8769
|
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localPreset} from the local checkout`);
|
|
8891
8770
|
await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
|
|
8892
8771
|
} else {
|
|
8893
8772
|
ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
|
|
8894
|
-
const answers = await ctx.readFile(
|
|
8773
|
+
const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
|
|
8895
8774
|
const current = presetSource(site.preset);
|
|
8896
8775
|
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
8897
8776
|
if (recorded && recorded !== current && Object.keys(RENAMED_PRESETS).some((old) => presetSource(old) === recorded)) {
|
|
8898
8777
|
ctx.say(` ${site.rel}: the preset is ${current} now; the answers follow`);
|
|
8899
|
-
await ctx.stage(write(
|
|
8778
|
+
await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
|
|
8900
8779
|
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the preset's name since its rename`);
|
|
8901
8780
|
}
|
|
8902
8781
|
const args = [
|
|
@@ -8922,7 +8801,7 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8922
8801
|
let conflict = hasUnmergedEntries(status);
|
|
8923
8802
|
const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
|
|
8924
8803
|
for (const f of changed) {
|
|
8925
|
-
const text = await ctx.readFile(
|
|
8804
|
+
const text = await ctx.readFile(join6(target, f)).catch(() => "");
|
|
8926
8805
|
if (hasConflictMarkers(text))
|
|
8927
8806
|
conflict = true;
|
|
8928
8807
|
}
|
|
@@ -8942,20 +8821,20 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8942
8821
|
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
8943
8822
|
}
|
|
8944
8823
|
async function syncSiteMarker(ctx, site, target) {
|
|
8945
|
-
const marker = await ctx.readFile(
|
|
8824
|
+
const marker = await ctx.readFile(join6(target, MARKER_FILE)).catch(() => void 0);
|
|
8946
8825
|
if (marker === void 0)
|
|
8947
8826
|
return;
|
|
8948
|
-
const { commit } = parseAnswers(await ctx.readFile(
|
|
8827
|
+
const { commit } = parseAnswers(await ctx.readFile(join6(target, ANSWERS_FILE)));
|
|
8949
8828
|
if (!commit)
|
|
8950
8829
|
return;
|
|
8951
8830
|
const synced = syncMarker(marker, commit);
|
|
8952
8831
|
if (synced === marker)
|
|
8953
8832
|
return;
|
|
8954
8833
|
ctx.say(` marker: plexus \u2192 ${commit} in ${site.rel}/${MARKER_FILE}`);
|
|
8955
|
-
await ctx.stage(write(
|
|
8834
|
+
await ctx.stage(write(join6(target, MARKER_FILE), synced));
|
|
8956
8835
|
}
|
|
8957
8836
|
async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
8958
|
-
if (await ctx.readFile(
|
|
8837
|
+
if (await ctx.readFile(join6(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
|
|
8959
8838
|
return;
|
|
8960
8839
|
const manifests = ["*package.json", "pnpm-workspace.yaml"];
|
|
8961
8840
|
const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
|
|
@@ -8970,18 +8849,18 @@ async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
|
8970
8849
|
}
|
|
8971
8850
|
}
|
|
8972
8851
|
async function bumpConsumerRefs(ctx, consumer, dir, train) {
|
|
8973
|
-
const workflows =
|
|
8852
|
+
const workflows = join6(dir, ".github", "workflows");
|
|
8974
8853
|
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
8975
8854
|
const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
|
|
8976
8855
|
for (const f of files) {
|
|
8977
|
-
const text = await ctx.readFile(
|
|
8856
|
+
const text = await ctx.readFile(join6(workflows, f));
|
|
8978
8857
|
if (!text.includes(WORKFLOW_REF))
|
|
8979
8858
|
continue;
|
|
8980
8859
|
const bumped = bumpWorkflowRefs(text, train);
|
|
8981
8860
|
if (bumped === text)
|
|
8982
8861
|
continue;
|
|
8983
8862
|
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${train}`);
|
|
8984
|
-
await ctx.stage(write(
|
|
8863
|
+
await ctx.stage(write(join6(workflows, f), bumped));
|
|
8985
8864
|
}
|
|
8986
8865
|
}
|
|
8987
8866
|
async function openPullUrl(ctx, consumer, dir, train) {
|
|
@@ -9018,17 +8897,23 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9018
8897
|
summary.failed.push(consumer.rel);
|
|
9019
8898
|
return;
|
|
9020
8899
|
}
|
|
8900
|
+
const conflicted = ofConsumer(summary.conflicted, consumer);
|
|
8901
|
+
const failed = ofConsumer(summary.failed, consumer);
|
|
8902
|
+
const clean = conflicted.length === 0 && failed.length === 0;
|
|
9021
8903
|
const existing = await openPullUrl(ctx, consumer, dir, train);
|
|
9022
8904
|
if (existing) {
|
|
9023
8905
|
ctx.say(`\u2022 ${consumer.rel}: pull request updated: ${existing}`);
|
|
9024
8906
|
summary.pulls.push(existing);
|
|
8907
|
+
if (clean)
|
|
8908
|
+
summary.mergeable.push(existing);
|
|
9025
8909
|
return;
|
|
9026
8910
|
}
|
|
9027
8911
|
const sites = consumer.sites.map((s) => s.rel);
|
|
9028
|
-
const conflicted = sites.filter((s) => summary.conflicted.includes(s));
|
|
9029
8912
|
const body2 = [
|
|
9030
8913
|
`Train ${train} (\xA7 1.5 PLX): \`copier update\` at ${sites.join(", ")}, the marker, the lockfile where manifests moved, and the workflow refs.`,
|
|
9031
|
-
conflicted.length > 0 ? `Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.` :
|
|
8914
|
+
...conflicted.length > 0 ? [`Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.`] : [],
|
|
8915
|
+
...failed.length > 0 ? [`Failed, and left as it was: ${failed.join(", ")}.`] : [],
|
|
8916
|
+
...clean ? [CLEAN_BODY] : [],
|
|
9032
8917
|
`Opened by ${take.opener}${take.why ? `: ${take.why}` : ""}.`
|
|
9033
8918
|
].join("\n\n");
|
|
9034
8919
|
try {
|
|
@@ -9054,6 +8939,8 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9054
8939
|
const url = await openPullUrl(ctx, consumer, dir, train);
|
|
9055
8940
|
ctx.say(`\u2022 ${consumer.rel}: pull request opened${url ? `: ${url}` : ""}`);
|
|
9056
8941
|
summary.pulls.push(url || `${consumer.rel} ${branch}`);
|
|
8942
|
+
if (url && clean)
|
|
8943
|
+
summary.mergeable.push(url);
|
|
9057
8944
|
}
|
|
9058
8945
|
var detail = (error) => {
|
|
9059
8946
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -9061,49 +8948,8 @@ var detail = (error) => {
|
|
|
9061
8948
|
return last && !/exited with/.test(last) ? `: ${last}` : "";
|
|
9062
8949
|
};
|
|
9063
8950
|
|
|
9064
|
-
// ../lib/dist/preview.js
|
|
9065
|
-
async function previewConsumers(ctx, workspace, train) {
|
|
9066
|
-
const summary = emptySummary(train, ctx.dryRun);
|
|
9067
|
-
const upstream = join8(workspace, UPSTREAM);
|
|
9068
|
-
const tree = await overview(ctx, workspace);
|
|
9069
|
-
const upstreamDir = tree.children.find((c) => c.path === upstream);
|
|
9070
|
-
const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
|
|
9071
|
-
const consumers = await findConsumers(ctx, tree, presets);
|
|
9072
|
-
for (const c of consumers) {
|
|
9073
|
-
if (!c.skipped)
|
|
9074
|
-
continue;
|
|
9075
|
-
ctx.say(`\u26A0 ${c.rel}: ${c.skipped} \u2014 not previewed`);
|
|
9076
|
-
summary.skipped.push({ path: c.rel, reason: c.skipped });
|
|
9077
|
-
}
|
|
9078
|
-
for (const preset of presets)
|
|
9079
|
-
if (!consumers.some((c) => c.sites.some((s) => s.preset === preset)))
|
|
9080
|
-
ctx.say(`\u2022 no consumers of ${presetSource(preset)} found under ${workspace}`);
|
|
9081
|
-
const take = { train, opener: "`plx ship`", previewFrom: upstream };
|
|
9082
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9083
|
-
try {
|
|
9084
|
-
for (const consumer of consumers) {
|
|
9085
|
-
if (consumer.skipped || !consumer.origin)
|
|
9086
|
-
continue;
|
|
9087
|
-
const clone = join8(scratch, consumer.rel);
|
|
9088
|
-
ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
|
|
9089
|
-
try {
|
|
9090
|
-
await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
|
|
9091
|
-
} catch (error) {
|
|
9092
|
-
ctx.say(` \u2717 FAILED \u2014 clone${detail(error)}`);
|
|
9093
|
-
summary.failed.push(consumer.rel);
|
|
9094
|
-
continue;
|
|
9095
|
-
}
|
|
9096
|
-
await takeTrain(ctx, consumer, clone, take, summary);
|
|
9097
|
-
}
|
|
9098
|
-
} finally {
|
|
9099
|
-
if (scratch)
|
|
9100
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9101
|
-
}
|
|
9102
|
-
return summary;
|
|
9103
|
-
}
|
|
9104
|
-
|
|
9105
8951
|
// ../lib/dist/update.js
|
|
9106
|
-
import { basename, join as
|
|
8952
|
+
import { basename, join as join7, relative as relative4 } from "node:path";
|
|
9107
8953
|
async function update(ctx, options) {
|
|
9108
8954
|
const { repo } = options;
|
|
9109
8955
|
const name = options.name ?? basename(repo);
|
|
@@ -9117,7 +8963,7 @@ async function update(ctx, options) {
|
|
|
9117
8963
|
throw new Error(`${name}: ${consumer.skipped}`);
|
|
9118
8964
|
consumer.rel = name;
|
|
9119
8965
|
for (const s of consumer.sites)
|
|
9120
|
-
s.rel = s.rel === "." ? name :
|
|
8966
|
+
s.rel = s.rel === "." ? name : join7(name, s.rel);
|
|
9121
8967
|
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
9122
8968
|
if (!root)
|
|
9123
8969
|
throw new Error(`${name}: its root is not a site of a repo preset`);
|
|
@@ -9127,9 +8973,9 @@ async function update(ctx, options) {
|
|
|
9127
8973
|
const summary = emptySummary(train, ctx.dryRun);
|
|
9128
8974
|
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
9129
8975
|
const answers = await Promise.all(consumer.sites.map(async (s) => {
|
|
9130
|
-
const file =
|
|
8976
|
+
const file = join7(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
9131
8977
|
const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
|
|
9132
|
-
return parseAnswers(onOrigin2 ?? await ctx.readFile(
|
|
8978
|
+
return parseAnswers(onOrigin2 ?? await ctx.readFile(join7(s.path, ANSWERS_FILE)));
|
|
9133
8979
|
}));
|
|
9134
8980
|
const recorded = answers.map((a) => a.commit);
|
|
9135
8981
|
if (recorded.every((c) => c === train)) {
|
|
@@ -9144,8 +8990,12 @@ async function update(ctx, options) {
|
|
|
9144
8990
|
if (onOrigin) {
|
|
9145
8991
|
const url = await openPullUrl(ctx, consumer, repo, train);
|
|
9146
8992
|
ctx.say(`\u2022 ${name}: ${branch} is already on origin${url ? ` (${url})` : ""} \u2014 nothing to do; delete the branch to pull the train again`);
|
|
9147
|
-
if (url)
|
|
8993
|
+
if (url) {
|
|
9148
8994
|
summary.pulls.push(url);
|
|
8995
|
+
const body2 = await ctx.read("gh", ["pr", "view", url, "--json", "body", "--jq", ".body"], { cwd: repo }).catch(() => "");
|
|
8996
|
+
if (body2.includes(CLEAN_BODY))
|
|
8997
|
+
summary.mergeable.push(url);
|
|
8998
|
+
}
|
|
9149
8999
|
return summary;
|
|
9150
9000
|
}
|
|
9151
9001
|
const asked = options.train !== void 0 ? `--train ${train}` : options.now ? "--now" : void 0;
|
|
@@ -9164,7 +9014,7 @@ async function update(ctx, options) {
|
|
|
9164
9014
|
}
|
|
9165
9015
|
ctx.say(`\u2022 ${name}: takes ${train} \u2014 ${need.why}`);
|
|
9166
9016
|
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9167
|
-
const dir =
|
|
9017
|
+
const dir = join7(scratch, name);
|
|
9168
9018
|
try {
|
|
9169
9019
|
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
9170
9020
|
try {
|
|
@@ -9192,13 +9042,13 @@ async function staleIn(ctx, consumer, repo, train) {
|
|
|
9192
9042
|
const catalog = catalogOf(parseManifest(text));
|
|
9193
9043
|
const markers = [];
|
|
9194
9044
|
for (const site of consumer.sites) {
|
|
9195
|
-
const file =
|
|
9196
|
-
const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(
|
|
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);
|
|
9197
9047
|
if (marker === void 0)
|
|
9198
9048
|
continue;
|
|
9199
9049
|
try {
|
|
9200
9050
|
const { plexus, modules } = parseMarker(marker);
|
|
9201
|
-
markers.push({ where:
|
|
9051
|
+
markers.push({ where: join7(site.rel, MARKER_FILE), plexus, modules });
|
|
9202
9052
|
} catch {
|
|
9203
9053
|
}
|
|
9204
9054
|
}
|
|
@@ -9245,7 +9095,7 @@ async function propagate(ctx, options) {
|
|
|
9245
9095
|
}
|
|
9246
9096
|
|
|
9247
9097
|
// ../lib/dist/requirements.js
|
|
9248
|
-
import { join as
|
|
9098
|
+
import { join as join8 } from "node:path";
|
|
9249
9099
|
var KEYWORD = /MUST|SHOULD|MAY/;
|
|
9250
9100
|
var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
|
|
9251
9101
|
var list = (value) => value.replace(/^\s*\[/, "").replace(/\].*$/, "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -9338,7 +9188,7 @@ var MAP_PAGE = "essentials/standard.md";
|
|
|
9338
9188
|
async function modulePages(ctx, compendium) {
|
|
9339
9189
|
const pages = [];
|
|
9340
9190
|
for (const dir of Object.keys(CATALOG_DIRS)) {
|
|
9341
|
-
const entries = await ctx.readDir(
|
|
9191
|
+
const entries = await ctx.readDir(join8(compendium, dir));
|
|
9342
9192
|
for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
|
|
9343
9193
|
pages.push(`${dir}/${e.name}`);
|
|
9344
9194
|
}
|
|
@@ -9346,11 +9196,11 @@ async function modulePages(ctx, compendium) {
|
|
|
9346
9196
|
}
|
|
9347
9197
|
async function checkCompendium(ctx, compendium) {
|
|
9348
9198
|
const defects = [];
|
|
9349
|
-
defects.push(...scanPage(await ctx.readFile(
|
|
9199
|
+
defects.push(...scanPage(await ctx.readFile(join8(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
|
|
9350
9200
|
const pages = await modulePages(ctx, compendium);
|
|
9351
9201
|
const scans = /* @__PURE__ */ new Map();
|
|
9352
9202
|
for (const page of pages) {
|
|
9353
|
-
const scan = scanPage(await ctx.readFile(
|
|
9203
|
+
const scan = scanPage(await ctx.readFile(join8(compendium, page)), page, "module");
|
|
9354
9204
|
defects.push(...scan.defects);
|
|
9355
9205
|
scans.set(page, scan);
|
|
9356
9206
|
}
|
|
@@ -9396,214 +9246,39 @@ async function checkCompendium(ctx, compendium) {
|
|
|
9396
9246
|
};
|
|
9397
9247
|
}
|
|
9398
9248
|
|
|
9399
|
-
// ../lib/dist/
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
const latest = (await ctx.read("npm", ["view", SELF_PACKAGE, "version"]).catch(() => "")).trim();
|
|
9403
|
-
if (!latest) {
|
|
9404
|
-
ctx.say(`\u26A0 could not ask the registry for the newest ${SELF_PACKAGE}; going on with plx ${running}`);
|
|
9405
|
-
return;
|
|
9406
|
-
}
|
|
9407
|
-
if (compareTrains(running, latest) < 0)
|
|
9408
|
-
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}`);
|
|
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(" && ");
|
|
9409
9252
|
}
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
const
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
const
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
}
|
|
9436
|
-
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)`;
|
|
9437
|
-
async function release(ctx, train, next, today2, wait) {
|
|
9438
|
-
ctx.say(`\u2192 train ${train.last ?? "none"} \u2192 ${next}`);
|
|
9439
|
-
for (const repo of train.repos) {
|
|
9440
|
-
if (repo.pending.length === 0)
|
|
9441
|
-
ctx.say(` ${repo.name}: no changes since ${repo.latest} \u2014 tag only`);
|
|
9442
|
-
else {
|
|
9443
|
-
ctx.say(` ${repo.name} (since ${repo.latest ?? "the beginning"}):`);
|
|
9444
|
-
for (const line of repo.pending.slice(0, PENDING_SHOWN))
|
|
9445
|
-
ctx.say(` ${line}`);
|
|
9446
|
-
if (repo.pending.length > PENDING_SHOWN)
|
|
9447
|
-
ctx.say(` \u2026 and ${repo.pending.length - PENDING_SHOWN} more`);
|
|
9448
|
-
}
|
|
9449
|
-
}
|
|
9450
|
-
if (!await ctx.confirm(`tag all ${train.repos.length} repos as ${next}, release them and push?`))
|
|
9451
|
-
throw new Error("aborted");
|
|
9452
|
-
const [one = [], two = []] = phasesOf(train);
|
|
9453
|
-
try {
|
|
9454
|
-
await releasePhase(ctx, train, one, next, today2);
|
|
9455
|
-
await awaitPublished(ctx, next, wait);
|
|
9456
|
-
await releasePhase(ctx, train, two, next, today2);
|
|
9457
|
-
} catch (error) {
|
|
9458
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
9459
|
-
throw new Error(`${message}
|
|
9460
|
-
\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)`);
|
|
9461
|
-
}
|
|
9462
|
-
}
|
|
9463
|
-
var PENDING_SHOWN = 20;
|
|
9464
|
-
async function releasePhase(ctx, train, repos2, next, today2) {
|
|
9465
|
-
ctx.say(`\u2192 phase: ${repos2.map((r) => r.name).join(", ")}`);
|
|
9466
|
-
await ctx.apply(await planBookkeeping(ctx, train, repos2, next, today2));
|
|
9467
|
-
for (const repo of repos2)
|
|
9468
|
-
await tagAndRelease(ctx, repo, next, today2);
|
|
9469
|
-
}
|
|
9470
|
-
async function tagAndRelease(ctx, repo, next, today2) {
|
|
9471
|
-
const tagged = await ctx.read("git", ["rev-parse", "-q", "--verify", `refs/tags/${next}`], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9472
|
-
if (tagged)
|
|
9473
|
-
ctx.say(`\u2022 ${repo.name}: already tagged ${next}`);
|
|
9474
|
-
else
|
|
9475
|
-
await ctx.apply([run("git", ["tag", "-a", next, "-m", `train ${next}`], { cwd: repo.path })]);
|
|
9476
|
-
await ctx.apply([run("git", ["push", "origin", "main", next], { cwd: repo.path })]);
|
|
9477
|
-
const create = ["release", "create", next, "--verify-tag", "--generate-notes", "--title", next];
|
|
9478
|
-
if (repo.name === COMPENDIUM) {
|
|
9479
|
-
if (!await releaseWithManifest(ctx, repo, next, today2, create))
|
|
9480
|
-
return;
|
|
9481
|
-
} else {
|
|
9482
|
-
const released = await ctx.read("gh", ["release", "view", next], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9483
|
-
if (released) {
|
|
9484
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9485
|
-
return;
|
|
9486
|
-
}
|
|
9487
|
-
await ctx.apply([run("gh", create, { cwd: repo.path })]);
|
|
9488
|
-
}
|
|
9489
|
-
if (ctx.dryRun)
|
|
9490
|
-
return;
|
|
9491
|
-
const immutable = (await ctx.read("gh", ["api", `repos/{owner}/{repo}/releases/tags/${next}`, "--jq", ".immutable"], {
|
|
9492
|
-
cwd: repo.path
|
|
9493
|
-
})).trim();
|
|
9494
|
-
if (immutable !== "true")
|
|
9495
|
-
throw new Error(mutableRelease(`${repo.name}: release ${next} was created mutable, and its tag can still move`));
|
|
9496
|
-
}
|
|
9497
|
-
async function releaseWithManifest(ctx, repo, next, today2, create) {
|
|
9498
|
-
const state = (await ctx.read("gh", ["release", "view", next, "--json", "isDraft", "--jq", ".isDraft"], { cwd: repo.path }).catch(() => "")).trim();
|
|
9499
|
-
if (state === "false") {
|
|
9500
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9501
|
-
return false;
|
|
9502
|
-
}
|
|
9503
|
-
if (state === "true")
|
|
9504
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} is still a draft \u2014 finishing it`);
|
|
9505
|
-
else
|
|
9506
|
-
await ctx.apply([run("gh", [...create, "--draft"], { cwd: repo.path })]);
|
|
9507
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9508
|
-
const file = join11(scratch, MANIFEST_FILE);
|
|
9509
|
-
try {
|
|
9510
|
-
const manifest2 = buildManifest(await readCatalog(ctx, repo.path), next, today2);
|
|
9511
|
-
ctx.say(` ${repo.name}: ${MANIFEST_FILE}: train ${next}, ${manifest2.modules.length} modules`);
|
|
9512
|
-
await ctx.stage(write(file, renderManifest(manifest2)));
|
|
9513
|
-
await ctx.apply([
|
|
9514
|
-
run("gh", ["release", "upload", next, file, "--clobber"], { cwd: repo.path }),
|
|
9515
|
-
run("gh", ["release", "edit", next, "--draft=false"], { cwd: repo.path })
|
|
9516
|
-
]);
|
|
9517
|
-
} finally {
|
|
9518
|
-
if (scratch)
|
|
9519
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9520
|
-
}
|
|
9521
|
-
return true;
|
|
9522
|
-
}
|
|
9523
|
-
async function awaitPublished(ctx, next, wait) {
|
|
9524
|
-
const names = TRAIN_PACKAGES.map((p) => p.name);
|
|
9525
|
-
const list2 = names.map((n) => `${n}@${next}`).join(", ");
|
|
9526
|
-
if (ctx.dryRun) {
|
|
9527
|
-
ctx.say(`\u23F3 [dry-run] would wait for ${list2} on npm (${PRIMITIVES}' release workflow publishes them)`);
|
|
9528
|
-
return;
|
|
9529
|
-
}
|
|
9530
|
-
ctx.say(`\u23F3 waiting for ${list2} on npm (${PRIMITIVES}' release workflow publishes them)`);
|
|
9531
|
-
const started = Date.now();
|
|
9532
|
-
let missing = [...names];
|
|
9533
|
-
for (; ; ) {
|
|
9534
|
-
const still = [];
|
|
9535
|
-
for (const name of missing) {
|
|
9536
|
-
const seen = (await ctx.read("npm", ["view", `${name}@${next}`, "version", "--prefer-online"]).catch(() => "")).trim();
|
|
9537
|
-
if (seen !== next)
|
|
9538
|
-
still.push(name);
|
|
9539
|
-
}
|
|
9540
|
-
missing = still;
|
|
9541
|
-
if (missing.length === 0)
|
|
9542
|
-
break;
|
|
9543
|
-
if (Date.now() - started >= wait.timeout)
|
|
9544
|
-
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})`);
|
|
9545
|
-
await new Promise((resolve10) => setTimeout(resolve10, wait.interval));
|
|
9546
|
-
}
|
|
9547
|
-
ctx.say(` \u2713 ${list2} on npm`);
|
|
9548
|
-
}
|
|
9549
|
-
async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
9550
|
-
const plan = [];
|
|
9551
|
-
const touched = /* @__PURE__ */ new Set();
|
|
9552
|
-
const repo = (name) => repos2.find((r) => r.name === name);
|
|
9553
|
-
const edit = async (r, rel, what, transform) => {
|
|
9554
|
-
const path3 = join11(r.path, rel);
|
|
9555
|
-
const text = await ctx.readFile(path3).catch(() => void 0);
|
|
9556
|
-
if (text === void 0)
|
|
9557
|
-
return;
|
|
9558
|
-
const edited = transform(text);
|
|
9559
|
-
if (edited === text)
|
|
9560
|
-
return;
|
|
9561
|
-
ctx.say(` ${r.name}: ${rel}: ${what}`);
|
|
9562
|
-
plan.push(write(path3, edited));
|
|
9563
|
-
touched.add(r);
|
|
9564
|
-
};
|
|
9565
|
-
const grep = async (r, needle, pathspecs) => (await ctx.read("git", ["grep", "-l", needle, "--", ...pathspecs], { cwd: r.path }).catch(() => "")).split("\n").filter(Boolean);
|
|
9566
|
-
const primitives = repo(PRIMITIVES);
|
|
9567
|
-
if (primitives) {
|
|
9568
|
-
for (const c of COLLECTIONS)
|
|
9569
|
-
await edit(primitives, galaxyFile(c), `plexus.${c} version \u2192 ${next}`, (t) => bumpGalaxyVersion(t, next));
|
|
9570
|
-
await edit(primitives, RUNNER_IMAGE_PIN_FILE, `runner image \u2192 ${next}`, (t) => bumpRunnerImagePin(t, next));
|
|
9571
|
-
for (const p of TRAIN_PACKAGES)
|
|
9572
|
-
await edit(primitives, `${p.dir}/package.json`, `${p.name} \u2192 ${next}`, (t) => bumpManifestVersion(t, next));
|
|
9573
|
-
}
|
|
9574
|
-
const operationsPreset = repo("preset-repo-operations");
|
|
9575
|
-
if (operationsPreset)
|
|
9576
|
-
await edit(operationsPreset, "template/requirements.yml", `plexus.* pins \u2192 ${next}`, (t) => bumpCollectionPin(t, next));
|
|
9577
|
-
for (const r of repos2) {
|
|
9578
|
-
for (const f of await grep(r, WORKFLOW_REF, ["*.yml", "*.yaml", "*.jinja"]))
|
|
9579
|
-
await edit(r, f, `workflow refs \u2192 @${next}`, (t) => bumpWorkflowRefs(t, next));
|
|
9580
|
-
for (const f of await grep(r, PLX_PIN, ["*.toml", "*.toml.jinja"]))
|
|
9581
|
-
await edit(r, f, `plx pin \u2192 ${next}`, (t) => bumpPlxPin(t, next));
|
|
9582
|
-
for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*package.json", "*package.json.jinja"]))
|
|
9583
|
-
await edit(r, f, `${CONFIG_PIN} pin \u2192 ${next}`, (t) => bumpConfigPin(t, next));
|
|
9584
|
-
for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*pnpm-workspace.yaml", "*pnpm-workspace.yaml.jinja"]))
|
|
9585
|
-
await edit(r, f, `${CONFIG_PIN} catalog entry \u2192 ${next}`, (t) => bumpCatalogPin(t, next));
|
|
9586
|
-
}
|
|
9587
|
-
const comp = repo("compendium");
|
|
9588
|
-
if (comp) {
|
|
9589
|
-
await edit(comp, MAP_PAGE, `version \u2192 ${next}, timestamp \u2192 ${today2}`, (t) => stampStandard(t, next, today2));
|
|
9590
|
-
for (const page of await modulePages(ctx, comp.path)) {
|
|
9591
|
-
const text = await ctx.readFile(join11(comp.path, page));
|
|
9592
|
-
if (frontmatterField(text, "maturity") !== "standard")
|
|
9593
|
-
continue;
|
|
9594
|
-
const previous = comp.tag ? await ctx.read("git", ["show", `${comp.tag}:${page}`], { cwd: comp.path }).catch(() => "") : "";
|
|
9595
|
-
if (extractRequirements(text).join("\n") === extractRequirements(previous).join("\n"))
|
|
9596
|
-
continue;
|
|
9597
|
-
await edit(comp, page, `requirements changed since ${comp.latest ?? "the beginning"} \u2192 changed: ${next}`, (t) => stampChanged(t, next));
|
|
9598
|
-
}
|
|
9599
|
-
}
|
|
9600
|
-
for (const r of train.repos) {
|
|
9601
|
-
if (!touched.has(r))
|
|
9602
|
-
continue;
|
|
9603
|
-
plan.push(run("git", ["add", "-A"], { cwd: r.path }));
|
|
9604
|
-
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");
|
|
9605
9278
|
}
|
|
9606
|
-
|
|
9279
|
+
if (!clean)
|
|
9280
|
+
lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
|
|
9281
|
+
return lines.join("\n");
|
|
9607
9282
|
}
|
|
9608
9283
|
|
|
9609
9284
|
// src/program.ts
|
|
@@ -10552,13 +10227,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
|
10552
10227
|
|
|
10553
10228
|
// ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
|
|
10554
10229
|
function withResolver() {
|
|
10555
|
-
let
|
|
10230
|
+
let resolve9;
|
|
10556
10231
|
let reject;
|
|
10557
10232
|
const promise = new Promise((res, rej) => {
|
|
10558
|
-
|
|
10233
|
+
resolve9 = res;
|
|
10559
10234
|
reject = rej;
|
|
10560
10235
|
});
|
|
10561
|
-
return { promise, resolve:
|
|
10236
|
+
return { promise, resolve: resolve9, reject };
|
|
10562
10237
|
}
|
|
10563
10238
|
|
|
10564
10239
|
// ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
@@ -10937,7 +10612,7 @@ function createPrompt(view) {
|
|
|
10937
10612
|
});
|
|
10938
10613
|
output.mute();
|
|
10939
10614
|
const screen = new ScreenManager(rl);
|
|
10940
|
-
const { promise, resolve:
|
|
10615
|
+
const { promise, resolve: resolve9, reject } = withResolver();
|
|
10941
10616
|
return withHooks(rl, (cycle) => {
|
|
10942
10617
|
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
10943
10618
|
const settlePrompt = (settle) => {
|
|
@@ -10948,7 +10623,7 @@ function createPrompt(view) {
|
|
|
10948
10623
|
reject(error);
|
|
10949
10624
|
}
|
|
10950
10625
|
};
|
|
10951
|
-
const resolvePrompt = (value) => settlePrompt(() =>
|
|
10626
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve9(value));
|
|
10952
10627
|
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
10953
10628
|
const promptPromise = Object.assign(promise.finally(() => {
|
|
10954
10629
|
cleanups.forEach((cleanup) => cleanup());
|
|
@@ -14547,7 +14222,7 @@ function register3(program2) {
|
|
|
14547
14222
|
|
|
14548
14223
|
// src/commands/doctor.ts
|
|
14549
14224
|
import { existsSync } from "node:fs";
|
|
14550
|
-
import { join as
|
|
14225
|
+
import { join as join9, resolve as resolve4 } from "node:path";
|
|
14551
14226
|
|
|
14552
14227
|
// src/style.ts
|
|
14553
14228
|
function style(enabled) {
|
|
@@ -14565,8 +14240,8 @@ function register4(program2) {
|
|
|
14565
14240
|
).option("--color", "colour the report even when piped").option("--no-color", "never colour the report").action(async (dir, opts, command) => {
|
|
14566
14241
|
const ctx = contextOf2(command);
|
|
14567
14242
|
const root = resolve4(dir);
|
|
14568
|
-
const compendium = resolve4(opts.compendium ??
|
|
14569
|
-
if (!existsSync(
|
|
14243
|
+
const compendium = resolve4(opts.compendium ?? join9(root, WORKSPACE_COMPENDIUM));
|
|
14244
|
+
if (!existsSync(join9(compendium, "contracts")))
|
|
14570
14245
|
throw new Error(
|
|
14571
14246
|
`no compendium at ${compendium}; pass --compendium <path to a checkout of plexus-ms/compendium>`
|
|
14572
14247
|
);
|
|
@@ -14642,45 +14317,8 @@ function annotate(dir, s, modules) {
|
|
|
14642
14317
|
}
|
|
14643
14318
|
|
|
14644
14319
|
// src/commands/propagate.ts
|
|
14645
|
-
import { resolve as resolve7 } from "node:path";
|
|
14646
|
-
|
|
14647
|
-
// src/commands/ship.ts
|
|
14648
14320
|
import { resolve as resolve6 } from "node:path";
|
|
14649
14321
|
function register6(program2) {
|
|
14650
|
-
program2.command("ship").description(
|
|
14651
|
-
"cut the train: tag and release every train repo identically; repos take it themselves (update, propagate)"
|
|
14652
|
-
).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) => {
|
|
14653
|
-
const ctx = contextOf2(command);
|
|
14654
|
-
const result = await ship(ctx, { workspace: resolve6(dir), train: opts.train, plx: version });
|
|
14655
|
-
ctx.result(
|
|
14656
|
-
result,
|
|
14657
|
-
(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}`
|
|
14658
|
-
);
|
|
14659
|
-
if (!isClean(result)) process.exitCode = 1;
|
|
14660
|
-
});
|
|
14661
|
-
}
|
|
14662
|
-
function renderSummary(s, realCommand, verb = "propagate") {
|
|
14663
|
-
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"];
|
|
14664
|
-
for (const p of s.clean) lines.push(` \u2713 clean: ${p}`);
|
|
14665
|
-
for (const p of s.conflicted) lines.push(` \u2717 conflicts: ${p}`);
|
|
14666
|
-
for (const p of s.failed) lines.push(` \u2717 failed: ${p}`);
|
|
14667
|
-
for (const { path: path3, reason } of s.skipped) lines.push(` \u26A0 skipped: ${path3} (${reason})`);
|
|
14668
|
-
for (const { path: path3, reason } of s.resting) lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
14669
|
-
for (const url of s.pulls) lines.push(` \u2192 pull: ${url}`);
|
|
14670
|
-
const clean = isClean(s);
|
|
14671
|
-
const idle = clean && s.clean.length === 0 && s.pulls.length === 0;
|
|
14672
|
-
if (s.preview && !idle) {
|
|
14673
|
-
lines.push(" (preview only \u2014 nothing was changed)");
|
|
14674
|
-
if (clean) lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
|
|
14675
|
-
} else if (clean) {
|
|
14676
|
-
lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
|
|
14677
|
-
}
|
|
14678
|
-
if (!clean) lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
|
|
14679
|
-
return lines.join("\n");
|
|
14680
|
-
}
|
|
14681
|
-
|
|
14682
|
-
// src/commands/propagate.ts
|
|
14683
|
-
function register7(program2) {
|
|
14684
14322
|
program2.command("propagate").description(
|
|
14685
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"
|
|
14686
14324
|
).argument("[dir]", "a directory the repos sit under, at any depth", ".").option(
|
|
@@ -14692,7 +14330,7 @@ function register7(program2) {
|
|
|
14692
14330
|
(v) => parseMaxAge(v, "--max-age")
|
|
14693
14331
|
).action(async (dir, opts, command) => {
|
|
14694
14332
|
const ctx = contextOf2(command);
|
|
14695
|
-
const result = await propagate(ctx, { dir:
|
|
14333
|
+
const result = await propagate(ctx, { dir: resolve6(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
|
|
14696
14334
|
const flags = [opts.train ? `--train ${opts.train}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
|
|
14697
14335
|
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
14698
14336
|
if (!isClean(result)) process.exitCode = 1;
|
|
@@ -14700,13 +14338,13 @@ function register7(program2) {
|
|
|
14700
14338
|
}
|
|
14701
14339
|
|
|
14702
14340
|
// src/commands/requirements.ts
|
|
14703
|
-
import { join as
|
|
14704
|
-
function
|
|
14341
|
+
import { join as join10, resolve as resolve7 } from "node:path";
|
|
14342
|
+
function register7(program2) {
|
|
14705
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) => {
|
|
14706
14344
|
const ctx = contextOf2(command);
|
|
14707
|
-
const compendium =
|
|
14345
|
+
const compendium = resolve7(dir);
|
|
14708
14346
|
if (opts.extract) {
|
|
14709
|
-
ctx.result(extractRequirements(await ctx.readFile(
|
|
14347
|
+
ctx.result(extractRequirements(await ctx.readFile(join10(compendium, opts.extract))));
|
|
14710
14348
|
return;
|
|
14711
14349
|
}
|
|
14712
14350
|
const check = await checkCompendium(ctx, compendium);
|
|
@@ -14720,8 +14358,8 @@ function renderCheck(c) {
|
|
|
14720
14358
|
}
|
|
14721
14359
|
|
|
14722
14360
|
// src/commands/update.ts
|
|
14723
|
-
import { resolve as
|
|
14724
|
-
function
|
|
14361
|
+
import { resolve as resolve8 } from "node:path";
|
|
14362
|
+
function register8(program2) {
|
|
14725
14363
|
program2.command("update").description(
|
|
14726
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"
|
|
14727
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(
|
|
@@ -14730,7 +14368,7 @@ function register9(program2) {
|
|
|
14730
14368
|
(v) => parseMaxAge(v, "--max-age")
|
|
14731
14369
|
).action(async (dir, opts, command) => {
|
|
14732
14370
|
const ctx = contextOf2(command);
|
|
14733
|
-
const result = await update(ctx, { repo:
|
|
14371
|
+
const result = await update(ctx, { repo: resolve8(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
|
|
14734
14372
|
ctx.result(result, (r) => renderSummary(r, `plx -y update --train ${r.train} ${dir}`, "update"));
|
|
14735
14373
|
if (!isClean(result)) process.exitCode = 1;
|
|
14736
14374
|
});
|
|
@@ -14741,9 +14379,8 @@ var commands = [
|
|
|
14741
14379
|
register5,
|
|
14742
14380
|
register4,
|
|
14743
14381
|
register6,
|
|
14744
|
-
register7,
|
|
14745
|
-
register9,
|
|
14746
14382
|
register8,
|
|
14383
|
+
register7,
|
|
14747
14384
|
register,
|
|
14748
14385
|
register3,
|
|
14749
14386
|
register2
|
|
@@ -14756,7 +14393,7 @@ function buildProgram() {
|
|
|
14756
14393
|
program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
|
|
14757
14394
|
new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
|
|
14758
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"));
|
|
14759
|
-
for (const
|
|
14396
|
+
for (const register9 of commands) register9(program2);
|
|
14760
14397
|
return program2;
|
|
14761
14398
|
}
|
|
14762
14399
|
function contextOf2(command) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexus-ms/cli",
|
|
3
|
-
"version": "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.
|
|
27
|
+
"@plexus-ms/lib": "0.119.0",
|
|
28
28
|
"commander": "^15.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|