@plexus-ms/cli 0.118.0 → 0.120.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 +283 -665
- package/package.json +3 -3
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
|
|
7570
|
-
var
|
|
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
|
-
var WORKFLOW_REF = "plexus-ms/primitives/.github/workflows/";
|
|
7589
|
-
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" });
|
|
7561
|
+
var WORKFLOW_REF = "plexus-ms/tooling/.github/workflows/";
|
|
7562
|
+
var bumpWorkflowRefs = (text, version2) => text.replace(/(plexus-ms\/tooling\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${version2}`);
|
|
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";
|
|
@@ -7684,13 +7645,22 @@ ${stderr.trimEnd()}` : ""}`);
|
|
|
7684
7645
|
this.stderr = stderr;
|
|
7685
7646
|
}
|
|
7686
7647
|
};
|
|
7648
|
+
async function orAbsent(read, absent = () => true) {
|
|
7649
|
+
try {
|
|
7650
|
+
return await read;
|
|
7651
|
+
} catch (error) {
|
|
7652
|
+
if (error instanceof ExecError && absent(error))
|
|
7653
|
+
return void 0;
|
|
7654
|
+
throw error;
|
|
7655
|
+
}
|
|
7656
|
+
}
|
|
7687
7657
|
var isInteractive = () => process.stdin.isTTY === true && process.stderr.isTTY === true;
|
|
7688
7658
|
function realIo(prompt) {
|
|
7689
7659
|
return {
|
|
7690
7660
|
stdout: process.stdout,
|
|
7691
7661
|
stderr: process.stderr,
|
|
7692
7662
|
prompt: prompt && isInteractive() ? prompt : void 0,
|
|
7693
|
-
exec: (command, args, options = {}) => new Promise((
|
|
7663
|
+
exec: (command, args, options = {}) => new Promise((resolve9, reject) => {
|
|
7694
7664
|
const child = spawn(command, args, {
|
|
7695
7665
|
cwd: options.cwd,
|
|
7696
7666
|
env: options.env,
|
|
@@ -7713,7 +7683,7 @@ function realIo(prompt) {
|
|
|
7713
7683
|
child.on("error", reject);
|
|
7714
7684
|
child.on("close", (code) => {
|
|
7715
7685
|
if (code === 0)
|
|
7716
|
-
|
|
7686
|
+
resolve9(stdout);
|
|
7717
7687
|
else
|
|
7718
7688
|
reject(new ExecError(render(command, args), code, stderr));
|
|
7719
7689
|
});
|
|
@@ -7850,15 +7820,7 @@ async function readChangeset(ctx, dir, base, branch) {
|
|
|
7850
7820
|
const git2 = (args) => ctx.read("git", args, { cwd: dir });
|
|
7851
7821
|
const head = branch ?? (await git2(["rev-parse", "--abbrev-ref", "HEAD"])).trim();
|
|
7852
7822
|
const mergeBase = (await git2(["merge-base", base, "HEAD"])).trim();
|
|
7853
|
-
const show =
|
|
7854
|
-
try {
|
|
7855
|
-
return await git2(["show", `${mergeBase}:${path4}`]);
|
|
7856
|
-
} catch (error) {
|
|
7857
|
-
if (error instanceof ExecError)
|
|
7858
|
-
return void 0;
|
|
7859
|
-
throw error;
|
|
7860
|
-
}
|
|
7861
|
-
};
|
|
7823
|
+
const show = (path4) => orAbsent(git2(["show", `${mergeBase}:${path4}`]));
|
|
7862
7824
|
const current = async (path4) => {
|
|
7863
7825
|
try {
|
|
7864
7826
|
return await ctx.readFile(join2(dir, path4));
|
|
@@ -7903,135 +7865,18 @@ async function expand(ctx, root, glob) {
|
|
|
7903
7865
|
}
|
|
7904
7866
|
|
|
7905
7867
|
// ../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
7868
|
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
7869
|
|
|
7970
|
-
// ../lib/dist/
|
|
7971
|
-
var PRIMITIVES = "primitives";
|
|
7870
|
+
// ../lib/dist/version.js
|
|
7972
7871
|
var COMPENDIUM = "compendium";
|
|
7973
|
-
var
|
|
7974
|
-
|
|
7975
|
-
"
|
|
7976
|
-
"
|
|
7977
|
-
"
|
|
7872
|
+
var VERSIONED_REPOS = [
|
|
7873
|
+
"tooling",
|
|
7874
|
+
"template-repo-turbo",
|
|
7875
|
+
"template-app-nextjs",
|
|
7876
|
+
"template-repo-operations",
|
|
7978
7877
|
COMPENDIUM
|
|
7979
7878
|
];
|
|
7980
|
-
var
|
|
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
|
-
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
|
-
}
|
|
7879
|
+
var isPlexusVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
|
|
8035
7880
|
async function preflightForge(ctx) {
|
|
8036
7881
|
try {
|
|
8037
7882
|
await ctx.read("gh", ["auth", "status"]);
|
|
@@ -8039,30 +7884,11 @@ async function preflightForge(ctx) {
|
|
|
8039
7884
|
throw new Error("gh is not logged in (gh auth status failed) \u2014 run gh auth login first");
|
|
8040
7885
|
}
|
|
8041
7886
|
}
|
|
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
7887
|
var UsageError = class extends Error {
|
|
8062
7888
|
};
|
|
8063
7889
|
|
|
8064
7890
|
// ../lib/dist/consumers.js
|
|
8065
|
-
var
|
|
7891
|
+
var TEMPLATES = VERSIONED_REPOS.filter((r) => r.startsWith("template-"));
|
|
8066
7892
|
function expectedBranch(declaration, answers = {}) {
|
|
8067
7893
|
if (!declaration)
|
|
8068
7894
|
return void 0;
|
|
@@ -8072,29 +7898,32 @@ function expectedBranch(declaration, answers = {}) {
|
|
|
8072
7898
|
return answers.publishes_packages === true ? "main" : "develop";
|
|
8073
7899
|
return void 0;
|
|
8074
7900
|
}
|
|
8075
|
-
var
|
|
8076
|
-
var
|
|
8077
|
-
"preset-repo-web": "
|
|
8078
|
-
"preset-repo-platform": "
|
|
7901
|
+
var templateSource = (template) => `gh:plexus-ms/${template}`;
|
|
7902
|
+
var RENAMED_TEMPLATES = {
|
|
7903
|
+
"preset-repo-web": "template-repo-turbo",
|
|
7904
|
+
"preset-repo-platform": "template-repo-operations",
|
|
7905
|
+
"preset-repo-turbo": "template-repo-turbo",
|
|
7906
|
+
"preset-app-nextjs": "template-app-nextjs",
|
|
7907
|
+
"preset-repo-operations": "template-repo-operations"
|
|
8079
7908
|
};
|
|
8080
|
-
function
|
|
8081
|
-
for (const p of
|
|
8082
|
-
if (
|
|
7909
|
+
function templateOf(src, templates) {
|
|
7910
|
+
for (const p of templates)
|
|
7911
|
+
if (templateSource(p) === src)
|
|
8083
7912
|
return p;
|
|
8084
|
-
for (const [old, current] of Object.entries(
|
|
8085
|
-
if (
|
|
7913
|
+
for (const [old, current] of Object.entries(RENAMED_TEMPLATES))
|
|
7914
|
+
if (templateSource(old) === src && templates.includes(current))
|
|
8086
7915
|
return current;
|
|
8087
7916
|
return void 0;
|
|
8088
7917
|
}
|
|
8089
|
-
async function findConsumers(ctx, root,
|
|
7918
|
+
async function findConsumers(ctx, root, templates) {
|
|
8090
7919
|
const consumers = /* @__PURE__ */ new Map();
|
|
8091
7920
|
const orphans = [];
|
|
8092
7921
|
const visit = (dir, repo, inTemplate) => {
|
|
8093
7922
|
const here = dir.git ? dir : repo;
|
|
8094
|
-
const
|
|
8095
|
-
const
|
|
8096
|
-
if (
|
|
8097
|
-
const site = { path: dir.path, rel:
|
|
7923
|
+
const within = inTemplate || Boolean(dir.template);
|
|
7924
|
+
const template = dir.copier?.src ? templateOf(dir.copier.src, templates) : void 0;
|
|
7925
|
+
if (template && !within) {
|
|
7926
|
+
const site = { path: dir.path, rel: relative(root.path, dir.path) || ".", template };
|
|
8098
7927
|
if (!here)
|
|
8099
7928
|
orphans.push(site);
|
|
8100
7929
|
else {
|
|
@@ -8103,7 +7932,7 @@ async function findConsumers(ctx, root, presets) {
|
|
|
8103
7932
|
const expected = expectedBranch(here.declaration, here.copier?.answers);
|
|
8104
7933
|
consumer = {
|
|
8105
7934
|
path: here.path,
|
|
8106
|
-
rel:
|
|
7935
|
+
rel: relative(root.path, here.path) || ".",
|
|
8107
7936
|
branch: expected ?? here.git?.branch ?? "main",
|
|
8108
7937
|
expected,
|
|
8109
7938
|
sites: []
|
|
@@ -8114,7 +7943,7 @@ async function findConsumers(ctx, root, presets) {
|
|
|
8114
7943
|
}
|
|
8115
7944
|
}
|
|
8116
7945
|
for (const child of dir.children)
|
|
8117
|
-
visit(child, here,
|
|
7946
|
+
visit(child, here, within);
|
|
8118
7947
|
};
|
|
8119
7948
|
visit(root, void 0, false);
|
|
8120
7949
|
for (const site of orphans)
|
|
@@ -8282,11 +8111,11 @@ function parseAnswers(text) {
|
|
|
8282
8111
|
// ../lib/dist/deploy.js
|
|
8283
8112
|
import { randomBytes } from "node:crypto";
|
|
8284
8113
|
import { tmpdir } from "node:os";
|
|
8285
|
-
import { join as
|
|
8114
|
+
import { join as join4 } from "node:path";
|
|
8286
8115
|
|
|
8287
8116
|
// ../lib/dist/deployTargets.js
|
|
8288
8117
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
8289
|
-
import { join as
|
|
8118
|
+
import { join as join3 } from "node:path";
|
|
8290
8119
|
var VARS_DIRS = ["group_vars", "host_vars"];
|
|
8291
8120
|
var DEFAULT_ENVIRONMENT = "production";
|
|
8292
8121
|
function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
|
|
@@ -8350,7 +8179,7 @@ async function readDeployTargets(ctx, inventory) {
|
|
|
8350
8179
|
const files = [];
|
|
8351
8180
|
let found = false;
|
|
8352
8181
|
for (const sub of VARS_DIRS) {
|
|
8353
|
-
const dir =
|
|
8182
|
+
const dir = join3(inventory, sub);
|
|
8354
8183
|
const entries = await ctx.readDir(dir).catch(() => void 0);
|
|
8355
8184
|
if (entries === void 0)
|
|
8356
8185
|
continue;
|
|
@@ -8358,7 +8187,7 @@ async function readDeployTargets(ctx, inventory) {
|
|
|
8358
8187
|
for (const e of entries) {
|
|
8359
8188
|
if (e.directory || !/\.ya?ml$/.test(e.name))
|
|
8360
8189
|
continue;
|
|
8361
|
-
const path3 =
|
|
8190
|
+
const path3 = join3(dir, e.name);
|
|
8362
8191
|
files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
|
|
8363
8192
|
}
|
|
8364
8193
|
}
|
|
@@ -8387,7 +8216,7 @@ function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
|
|
|
8387
8216
|
}
|
|
8388
8217
|
var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
|
|
8389
8218
|
var Remote = class {
|
|
8390
|
-
socket =
|
|
8219
|
+
socket = join4(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
|
|
8391
8220
|
ctx;
|
|
8392
8221
|
host;
|
|
8393
8222
|
constructor(ctx, host) {
|
|
@@ -8427,13 +8256,9 @@ var Remote = class {
|
|
|
8427
8256
|
}
|
|
8428
8257
|
/** A check on the host: whether the command succeeds, or undefined under --dry-run. */
|
|
8429
8258
|
async test(command, show = false) {
|
|
8430
|
-
|
|
8431
|
-
return
|
|
8432
|
-
|
|
8433
|
-
if (error instanceof ExecError)
|
|
8434
|
-
return false;
|
|
8435
|
-
throw error;
|
|
8436
|
-
}
|
|
8259
|
+
if (this.ctx.dryRun)
|
|
8260
|
+
return this.read(command, show).then(() => void 0);
|
|
8261
|
+
return await orAbsent(this.read(command, show)) !== void 0;
|
|
8437
8262
|
}
|
|
8438
8263
|
/** Close the shared connection; nothing to close when no call was made. */
|
|
8439
8264
|
close() {
|
|
@@ -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 && compareVersions(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 compareVersions(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
|
-
var MANIFEST_FILE = "
|
|
8445
|
+
var MANIFEST_FILE = "modules.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) {
|
|
@@ -8573,24 +8451,24 @@ function parseManifest(text) {
|
|
|
8573
8451
|
try {
|
|
8574
8452
|
data = JSON.parse(text);
|
|
8575
8453
|
} catch {
|
|
8576
|
-
throw new Error("the
|
|
8454
|
+
throw new Error("the module manifest is not JSON");
|
|
8577
8455
|
}
|
|
8578
8456
|
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
8579
|
-
throw new Error("the
|
|
8580
|
-
const { schema,
|
|
8457
|
+
throw new Error("the module manifest is not an object");
|
|
8458
|
+
const { schema, version: version2, date, modules } = data;
|
|
8581
8459
|
if (schema !== MANIFEST_SCHEMA)
|
|
8582
|
-
throw new Error(`the
|
|
8583
|
-
if (typeof
|
|
8584
|
-
throw new Error(`the
|
|
8460
|
+
throw new Error(`the module manifest has schema ${JSON.stringify(schema)}; this plx reads ${MANIFEST_SCHEMA}`);
|
|
8461
|
+
if (typeof version2 !== "string" || !isPlexusVersion(version2))
|
|
8462
|
+
throw new Error(`the module manifest names '${String(version2)}', not a version`);
|
|
8585
8463
|
if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(date))
|
|
8586
|
-
throw new Error(`the
|
|
8464
|
+
throw new Error(`the module manifest is dated '${String(date)}', not YYYY-MM-DD`);
|
|
8587
8465
|
if (!Array.isArray(modules))
|
|
8588
|
-
throw new Error("the
|
|
8589
|
-
return { schema: MANIFEST_SCHEMA,
|
|
8466
|
+
throw new Error("the module manifest lists no modules");
|
|
8467
|
+
return { schema: MANIFEST_SCHEMA, version: version2, date, modules: modules.map(parseEntry) };
|
|
8590
8468
|
}
|
|
8591
8469
|
function parseEntry(entry) {
|
|
8592
8470
|
const m = entry ?? {};
|
|
8593
|
-
const where = `the
|
|
8471
|
+
const where = `the module manifest's module ${typeof m.code === "string" ? m.code : JSON.stringify(entry)}`;
|
|
8594
8472
|
if (typeof m.code !== "string" || m.code === "")
|
|
8595
8473
|
throw new Error(`${where} has no code`);
|
|
8596
8474
|
if (m.kind !== "contract" && m.kind !== "approach")
|
|
@@ -8600,7 +8478,7 @@ function parseEntry(entry) {
|
|
|
8600
8478
|
if (!strings(m.depends) || !strings(m.consumes))
|
|
8601
8479
|
throw new Error(`${where} lacks depends or consumes`);
|
|
8602
8480
|
if (m.changed !== void 0 && typeof m.changed !== "string")
|
|
8603
|
-
throw new Error(`${where} has a changed that is no
|
|
8481
|
+
throw new Error(`${where} has a changed that is no version`);
|
|
8604
8482
|
return {
|
|
8605
8483
|
code: m.code,
|
|
8606
8484
|
kind: m.kind,
|
|
@@ -8647,42 +8525,42 @@ function needOf({ recorded, releases, asked, stale = [], maxAge, now }) {
|
|
|
8647
8525
|
trigger: "module",
|
|
8648
8526
|
why: `${first.code} changed in ${first.changed}, declared at ${first.declared} in ${first.where}${more.length > 0 ? `, and ${more.length} more` : ""}`
|
|
8649
8527
|
};
|
|
8650
|
-
const odd = recorded.findIndex((r) => !r || !
|
|
8528
|
+
const odd = recorded.findIndex((r) => !r || !isPlexusVersion(r));
|
|
8651
8529
|
if (recorded.length === 0 || odd >= 0)
|
|
8652
8530
|
return {
|
|
8653
8531
|
take: true,
|
|
8654
8532
|
trigger: "backstop",
|
|
8655
|
-
why: `a site records ${recorded[odd] ? `'${recorded[odd]}'` : "no version"}, not a
|
|
8533
|
+
why: `a site records ${recorded[odd] ? `'${recorded[odd]}'` : "no version"}, not a version`
|
|
8656
8534
|
};
|
|
8657
|
-
const
|
|
8658
|
-
const oldest =
|
|
8659
|
-
const untaken = releases.filter((r) =>
|
|
8535
|
+
const versions = recorded;
|
|
8536
|
+
const oldest = versions.reduce((a, b) => compareVersions(a, b) <= 0 ? a : b);
|
|
8537
|
+
const untaken = releases.filter((r) => isPlexusVersion(r.version) && compareVersions(r.version, oldest) > 0).sort((a, b) => Date.parse(a.published) - Date.parse(b.published));
|
|
8660
8538
|
const oldestUntaken = untaken[0];
|
|
8661
8539
|
if (!oldestUntaken)
|
|
8662
|
-
return { take: false, why: `no
|
|
8540
|
+
return { take: false, why: `no version newer than ${oldest}` };
|
|
8663
8541
|
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(oldestUntaken.published)) / DAY));
|
|
8664
|
-
const count = `${untaken.length} newer
|
|
8542
|
+
const count = `${untaken.length} newer version${untaken.length === 1 ? "" : "s"}`;
|
|
8665
8543
|
if (maxAge === 0)
|
|
8666
|
-
return { take: true, trigger: "backstop", why: `a backstop age of zero takes every
|
|
8544
|
+
return { take: true, trigger: "backstop", why: `a backstop age of zero takes every version (${count})` };
|
|
8667
8545
|
if (age >= maxAge)
|
|
8668
8546
|
return {
|
|
8669
8547
|
take: true,
|
|
8670
8548
|
trigger: "backstop",
|
|
8671
|
-
why: `${oldestUntaken.
|
|
8549
|
+
why: `${oldestUntaken.version}, the oldest version not taken, was cut ${days(age)} ago (backstop: ${days(maxAge)}; ${count})`
|
|
8672
8550
|
};
|
|
8673
8551
|
return {
|
|
8674
8552
|
take: false,
|
|
8675
|
-
why: `${count}, the oldest (${oldestUntaken.
|
|
8553
|
+
why: `${count}, the oldest (${oldestUntaken.version}) cut ${days(age)} ago; the backstop is ${days(maxAge)}`
|
|
8676
8554
|
};
|
|
8677
8555
|
}
|
|
8678
8556
|
function staleModules(markers, catalog) {
|
|
8679
8557
|
const stale = [];
|
|
8680
8558
|
for (const { where, plexus, modules } of markers) {
|
|
8681
|
-
if (!
|
|
8559
|
+
if (!isPlexusVersion(plexus))
|
|
8682
8560
|
continue;
|
|
8683
8561
|
for (const code of modules) {
|
|
8684
8562
|
const changed = catalog.get(code)?.changed;
|
|
8685
|
-
if (changed &&
|
|
8563
|
+
if (changed && isPlexusVersion(changed) && compareVersions(changed, plexus) > 0)
|
|
8686
8564
|
stale.push({ code, changed, where, declared: plexus });
|
|
8687
8565
|
}
|
|
8688
8566
|
}
|
|
@@ -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);
|
|
@@ -8843,8 +8718,8 @@ function mergeSummary(into, from) {
|
|
|
8843
8718
|
into.pulls.push(...from.pulls);
|
|
8844
8719
|
into.mergeable.push(...from.mergeable);
|
|
8845
8720
|
}
|
|
8846
|
-
var emptySummary = (
|
|
8847
|
-
|
|
8721
|
+
var emptySummary = (version2, preview) => ({
|
|
8722
|
+
version: version2,
|
|
8848
8723
|
preview,
|
|
8849
8724
|
clean: [],
|
|
8850
8725
|
conflicted: [],
|
|
@@ -8856,17 +8731,17 @@ var emptySummary = (train, preview) => ({
|
|
|
8856
8731
|
});
|
|
8857
8732
|
var CLEAN_BODY = "Merged clean at every site.";
|
|
8858
8733
|
var ofConsumer = (list2, consumer) => list2.filter((p) => p === consumer.rel || p.startsWith(`${consumer.rel}/`));
|
|
8859
|
-
var
|
|
8734
|
+
var versionBranch = (version2) => `plexus/${version2}`;
|
|
8860
8735
|
var copierIn = (dir, args) => [
|
|
8861
8736
|
"env",
|
|
8862
8737
|
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, "mise", ...copierVia(args)]
|
|
8863
8738
|
];
|
|
8864
|
-
async function
|
|
8739
|
+
async function takeVersion(ctx, consumer, dir, take, summary) {
|
|
8865
8740
|
const base = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim();
|
|
8866
8741
|
for (const site of consumer.sites)
|
|
8867
8742
|
await updateSite(ctx, consumer, site, dir, take, summary);
|
|
8868
8743
|
await refreshLockfile(ctx, consumer, dir, base, summary);
|
|
8869
|
-
await bumpConsumerRefs(ctx, consumer, dir, take.
|
|
8744
|
+
await bumpConsumerRefs(ctx, consumer, dir, take.version);
|
|
8870
8745
|
await openPull(ctx, consumer, dir, take, summary);
|
|
8871
8746
|
}
|
|
8872
8747
|
var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], { cwd: dir })).then(() => ctx.stage(run("git", [
|
|
@@ -8884,24 +8759,24 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
|
|
|
8884
8759
|
message
|
|
8885
8760
|
], { cwd: dir })));
|
|
8886
8761
|
async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
8887
|
-
const target =
|
|
8762
|
+
const target = join6(dir, relative3(consumer.path, site.path));
|
|
8888
8763
|
try {
|
|
8889
8764
|
if (take.previewFrom) {
|
|
8890
|
-
const
|
|
8891
|
-
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${
|
|
8892
|
-
const answers = await ctx.readFile(
|
|
8893
|
-
await ctx.stage(write(
|
|
8894
|
-
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${
|
|
8765
|
+
const localTemplate = join6(take.previewFrom, site.template);
|
|
8766
|
+
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localTemplate}@main)`);
|
|
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: ${localTemplate}`)));
|
|
8769
|
+
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localTemplate} from the local checkout`);
|
|
8895
8770
|
await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
|
|
8896
8771
|
} else {
|
|
8897
8772
|
ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
|
|
8898
|
-
const answers = await ctx.readFile(
|
|
8899
|
-
const current =
|
|
8773
|
+
const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
|
|
8774
|
+
const current = templateSource(site.template);
|
|
8900
8775
|
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
8901
|
-
if (recorded && recorded !== current && Object.keys(
|
|
8902
|
-
ctx.say(` ${site.rel}: the
|
|
8903
|
-
await ctx.stage(write(
|
|
8904
|
-
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the
|
|
8776
|
+
if (recorded && recorded !== current && Object.keys(RENAMED_TEMPLATES).some((old) => templateSource(old) === recorded)) {
|
|
8777
|
+
ctx.say(` ${site.rel}: the template is ${current} now; the answers follow`);
|
|
8778
|
+
await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
|
|
8779
|
+
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the template's name since its rename`);
|
|
8905
8780
|
}
|
|
8906
8781
|
const args = [
|
|
8907
8782
|
"update",
|
|
@@ -8926,7 +8801,7 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8926
8801
|
let conflict = hasUnmergedEntries(status);
|
|
8927
8802
|
const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
|
|
8928
8803
|
for (const f of changed) {
|
|
8929
|
-
const text = await ctx.readFile(
|
|
8804
|
+
const text = await ctx.readFile(join6(target, f)).catch(() => "");
|
|
8930
8805
|
if (hasConflictMarkers(text))
|
|
8931
8806
|
conflict = true;
|
|
8932
8807
|
}
|
|
@@ -8946,20 +8821,20 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8946
8821
|
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
8947
8822
|
}
|
|
8948
8823
|
async function syncSiteMarker(ctx, site, target) {
|
|
8949
|
-
const marker = await ctx.readFile(
|
|
8824
|
+
const marker = await ctx.readFile(join6(target, MARKER_FILE)).catch(() => void 0);
|
|
8950
8825
|
if (marker === void 0)
|
|
8951
8826
|
return;
|
|
8952
|
-
const { commit } = parseAnswers(await ctx.readFile(
|
|
8827
|
+
const { commit } = parseAnswers(await ctx.readFile(join6(target, ANSWERS_FILE)));
|
|
8953
8828
|
if (!commit)
|
|
8954
8829
|
return;
|
|
8955
8830
|
const synced = syncMarker(marker, commit);
|
|
8956
8831
|
if (synced === marker)
|
|
8957
8832
|
return;
|
|
8958
8833
|
ctx.say(` marker: plexus \u2192 ${commit} in ${site.rel}/${MARKER_FILE}`);
|
|
8959
|
-
await ctx.stage(write(
|
|
8834
|
+
await ctx.stage(write(join6(target, MARKER_FILE), synced));
|
|
8960
8835
|
}
|
|
8961
8836
|
async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
8962
|
-
if (await ctx.readFile(
|
|
8837
|
+
if (await ctx.readFile(join6(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
|
|
8963
8838
|
return;
|
|
8964
8839
|
const manifests = ["*package.json", "pnpm-workspace.yaml"];
|
|
8965
8840
|
const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
|
|
@@ -8967,34 +8842,36 @@ async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
|
8967
8842
|
return;
|
|
8968
8843
|
ctx.say(`\u2192 ${consumer.rel}: pnpm install (manifests changed)`);
|
|
8969
8844
|
try {
|
|
8970
|
-
await ctx.apply([
|
|
8845
|
+
await ctx.apply([
|
|
8846
|
+
run("mise", ["exec", "--", "pnpm", "install", "--no-frozen-lockfile", "--reporter=silent"], { cwd: dir })
|
|
8847
|
+
]);
|
|
8971
8848
|
} catch (error) {
|
|
8972
8849
|
ctx.say(` \u2717 pnpm install failed${detail(error)}`);
|
|
8973
8850
|
summary.failed.push(`${consumer.rel}/pnpm-lock.yaml`);
|
|
8974
8851
|
}
|
|
8975
8852
|
}
|
|
8976
|
-
async function bumpConsumerRefs(ctx, consumer, dir,
|
|
8977
|
-
const workflows =
|
|
8853
|
+
async function bumpConsumerRefs(ctx, consumer, dir, version2) {
|
|
8854
|
+
const workflows = join6(dir, ".github", "workflows");
|
|
8978
8855
|
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
8979
8856
|
const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
|
|
8980
8857
|
for (const f of files) {
|
|
8981
|
-
const text = await ctx.readFile(
|
|
8858
|
+
const text = await ctx.readFile(join6(workflows, f));
|
|
8982
8859
|
if (!text.includes(WORKFLOW_REF))
|
|
8983
8860
|
continue;
|
|
8984
|
-
const bumped = bumpWorkflowRefs(text,
|
|
8861
|
+
const bumped = bumpWorkflowRefs(text, version2);
|
|
8985
8862
|
if (bumped === text)
|
|
8986
8863
|
continue;
|
|
8987
|
-
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${
|
|
8988
|
-
await ctx.stage(write(
|
|
8864
|
+
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${version2}`);
|
|
8865
|
+
await ctx.stage(write(join6(workflows, f), bumped));
|
|
8989
8866
|
}
|
|
8990
8867
|
}
|
|
8991
|
-
async function openPullUrl(ctx, consumer, dir,
|
|
8992
|
-
const args = ["pr", "list", "--head",
|
|
8868
|
+
async function openPullUrl(ctx, consumer, dir, version2) {
|
|
8869
|
+
const args = ["pr", "list", "--head", versionBranch(version2), "--base", consumer.branch, "--state", "open"];
|
|
8993
8870
|
return (await ctx.read("gh", [...args, "--json", "url", "--jq", ".[0].url"], { cwd: dir }).catch(() => "")).trim();
|
|
8994
8871
|
}
|
|
8995
8872
|
async function openPull(ctx, consumer, dir, take, summary) {
|
|
8996
|
-
const {
|
|
8997
|
-
const branch =
|
|
8873
|
+
const { version: version2 } = take;
|
|
8874
|
+
const branch = versionBranch(version2);
|
|
8998
8875
|
if (ctx.dryRun) {
|
|
8999
8876
|
ctx.say(` (preview) ${consumer.rel}: would commit, push ${branch} and open a pull request against ${consumer.branch}`);
|
|
9000
8877
|
return;
|
|
@@ -9007,7 +8884,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9007
8884
|
try {
|
|
9008
8885
|
await ctx.apply([
|
|
9009
8886
|
run("git", ["add", "-A"], { cwd: dir }),
|
|
9010
|
-
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore:
|
|
8887
|
+
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore: Plexus ${version2}`], { cwd: dir })
|
|
9011
8888
|
]);
|
|
9012
8889
|
await ctx.read("git", ["fetch", "--quiet", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`], {
|
|
9013
8890
|
cwd: dir
|
|
@@ -9025,7 +8902,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9025
8902
|
const conflicted = ofConsumer(summary.conflicted, consumer);
|
|
9026
8903
|
const failed = ofConsumer(summary.failed, consumer);
|
|
9027
8904
|
const clean = conflicted.length === 0 && failed.length === 0;
|
|
9028
|
-
const existing = await openPullUrl(ctx, consumer, dir,
|
|
8905
|
+
const existing = await openPullUrl(ctx, consumer, dir, version2);
|
|
9029
8906
|
if (existing) {
|
|
9030
8907
|
ctx.say(`\u2022 ${consumer.rel}: pull request updated: ${existing}`);
|
|
9031
8908
|
summary.pulls.push(existing);
|
|
@@ -9035,7 +8912,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9035
8912
|
}
|
|
9036
8913
|
const sites = consumer.sites.map((s) => s.rel);
|
|
9037
8914
|
const body2 = [
|
|
9038
|
-
`
|
|
8915
|
+
`Plexus ${version2} (\xA7 1.5 PLX): \`copier update\` at ${sites.join(", ")}, the marker, the lockfile where manifests moved, and the workflow refs.`,
|
|
9039
8916
|
...conflicted.length > 0 ? [`Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.`] : [],
|
|
9040
8917
|
...failed.length > 0 ? [`Failed, and left as it was: ${failed.join(", ")}.`] : [],
|
|
9041
8918
|
...clean ? [CLEAN_BODY] : [],
|
|
@@ -9051,7 +8928,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9051
8928
|
"--head",
|
|
9052
8929
|
branch,
|
|
9053
8930
|
"--title",
|
|
9054
|
-
`chore:
|
|
8931
|
+
`chore: Plexus ${version2}`,
|
|
9055
8932
|
"--body",
|
|
9056
8933
|
body2
|
|
9057
8934
|
], { cwd: dir })
|
|
@@ -9061,7 +8938,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
9061
8938
|
summary.failed.push(consumer.rel);
|
|
9062
8939
|
return;
|
|
9063
8940
|
}
|
|
9064
|
-
const url = await openPullUrl(ctx, consumer, dir,
|
|
8941
|
+
const url = await openPullUrl(ctx, consumer, dir, version2);
|
|
9065
8942
|
ctx.say(`\u2022 ${consumer.rel}: pull request opened${url ? `: ${url}` : ""}`);
|
|
9066
8943
|
summary.pulls.push(url || `${consumer.rel} ${branch}`);
|
|
9067
8944
|
if (url && clean)
|
|
@@ -9073,89 +8950,48 @@ var detail = (error) => {
|
|
|
9073
8950
|
return last && !/exited with/.test(last) ? `: ${last}` : "";
|
|
9074
8951
|
};
|
|
9075
8952
|
|
|
9076
|
-
// ../lib/dist/preview.js
|
|
9077
|
-
async function previewConsumers(ctx, workspace, train) {
|
|
9078
|
-
const summary = emptySummary(train, ctx.dryRun);
|
|
9079
|
-
const upstream = join8(workspace, UPSTREAM);
|
|
9080
|
-
const tree = await overview(ctx, workspace);
|
|
9081
|
-
const upstreamDir = tree.children.find((c) => c.path === upstream);
|
|
9082
|
-
const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
|
|
9083
|
-
const consumers = await findConsumers(ctx, tree, presets);
|
|
9084
|
-
for (const c of consumers) {
|
|
9085
|
-
if (!c.skipped)
|
|
9086
|
-
continue;
|
|
9087
|
-
ctx.say(`\u26A0 ${c.rel}: ${c.skipped} \u2014 not previewed`);
|
|
9088
|
-
summary.skipped.push({ path: c.rel, reason: c.skipped });
|
|
9089
|
-
}
|
|
9090
|
-
for (const preset of presets)
|
|
9091
|
-
if (!consumers.some((c) => c.sites.some((s) => s.preset === preset)))
|
|
9092
|
-
ctx.say(`\u2022 no consumers of ${presetSource(preset)} found under ${workspace}`);
|
|
9093
|
-
const take = { train, opener: "`plx ship`", previewFrom: upstream };
|
|
9094
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9095
|
-
try {
|
|
9096
|
-
for (const consumer of consumers) {
|
|
9097
|
-
if (consumer.skipped || !consumer.origin)
|
|
9098
|
-
continue;
|
|
9099
|
-
const clone = join8(scratch, consumer.rel);
|
|
9100
|
-
ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
|
|
9101
|
-
try {
|
|
9102
|
-
await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
|
|
9103
|
-
} catch (error) {
|
|
9104
|
-
ctx.say(` \u2717 FAILED \u2014 clone${detail(error)}`);
|
|
9105
|
-
summary.failed.push(consumer.rel);
|
|
9106
|
-
continue;
|
|
9107
|
-
}
|
|
9108
|
-
await takeTrain(ctx, consumer, clone, take, summary);
|
|
9109
|
-
}
|
|
9110
|
-
} finally {
|
|
9111
|
-
if (scratch)
|
|
9112
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9113
|
-
}
|
|
9114
|
-
return summary;
|
|
9115
|
-
}
|
|
9116
|
-
|
|
9117
8953
|
// ../lib/dist/update.js
|
|
9118
|
-
import { basename, join as
|
|
8954
|
+
import { basename, join as join7, relative as relative4 } from "node:path";
|
|
9119
8955
|
async function update(ctx, options) {
|
|
9120
8956
|
const { repo } = options;
|
|
9121
8957
|
const name = options.name ?? basename(repo);
|
|
9122
|
-
if (options.
|
|
9123
|
-
throw new UsageError(`'${options.
|
|
8958
|
+
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
8959
|
+
throw new UsageError(`'${options.to}' is not plain semver (X.Y.Z, no v)`);
|
|
9124
8960
|
const tree = await overview(ctx, repo);
|
|
9125
|
-
const consumer = (await findConsumers(ctx, tree,
|
|
8961
|
+
const consumer = (await findConsumers(ctx, tree, TEMPLATES)).find((c) => c.path === tree.path);
|
|
9126
8962
|
if (!consumer)
|
|
9127
|
-
throw new Error(`${repo} is not a repo generated from the
|
|
8963
|
+
throw new Error(`${repo} is not a repo generated from the templates: no ${ANSWERS_FILE} at its root naming one of ${TEMPLATES.map(templateSource).join(", ")}`);
|
|
9128
8964
|
if (consumer.skipped)
|
|
9129
8965
|
throw new Error(`${name}: ${consumer.skipped}`);
|
|
9130
8966
|
consumer.rel = name;
|
|
9131
8967
|
for (const s of consumer.sites)
|
|
9132
|
-
s.rel = s.rel === "." ? name :
|
|
8968
|
+
s.rel = s.rel === "." ? name : join7(name, s.rel);
|
|
9133
8969
|
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
9134
8970
|
if (!root)
|
|
9135
|
-
throw new Error(`${name}: its root is not a site of a repo
|
|
8971
|
+
throw new Error(`${name}: its root is not a site of a repo template`);
|
|
9136
8972
|
await preflightForge(ctx);
|
|
9137
|
-
const releases = options.
|
|
9138
|
-
const
|
|
9139
|
-
const summary = emptySummary(
|
|
8973
|
+
const releases = options.to === void 0 ? await releasesOf(ctx) : [];
|
|
8974
|
+
const version2 = options.to ?? newestOf(releases);
|
|
8975
|
+
const summary = emptySummary(version2, ctx.dryRun);
|
|
9140
8976
|
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
9141
8977
|
const answers = await Promise.all(consumer.sites.map(async (s) => {
|
|
9142
|
-
const file =
|
|
8978
|
+
const file = join7(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
9143
8979
|
const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
|
|
9144
|
-
return parseAnswers(onOrigin2 ?? await ctx.readFile(
|
|
8980
|
+
return parseAnswers(onOrigin2 ?? await ctx.readFile(join7(s.path, ANSWERS_FILE)));
|
|
9145
8981
|
}));
|
|
9146
8982
|
const recorded = answers.map((a) => a.commit);
|
|
9147
|
-
if (recorded.every((c) => c ===
|
|
9148
|
-
ctx.say(`\u2022 ${name}: already at ${
|
|
8983
|
+
if (recorded.every((c) => c === version2)) {
|
|
8984
|
+
ctx.say(`\u2022 ${name}: already at ${version2}`);
|
|
9149
8985
|
return summary;
|
|
9150
8986
|
}
|
|
9151
|
-
const past = recorded.find((c) => c &&
|
|
8987
|
+
const past = recorded.find((c) => c && isPlexusVersion(c) && compareVersions(c, version2) > 0);
|
|
9152
8988
|
if (past)
|
|
9153
|
-
throw new Error(`${name} is at ${past}, past ${
|
|
9154
|
-
const branch =
|
|
8989
|
+
throw new Error(`${name} is at ${past}, past ${version2}; a repo is never taken back to an older version`);
|
|
8990
|
+
const branch = versionBranch(version2);
|
|
9155
8991
|
const onOrigin = await ctx.read("git", ["ls-remote", "--exit-code", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo }).then(() => true).catch(() => false);
|
|
9156
8992
|
if (onOrigin) {
|
|
9157
|
-
const url = await openPullUrl(ctx, consumer, repo,
|
|
9158
|
-
ctx.say(`\u2022 ${name}: ${branch} is already on origin${url ? ` (${url})` : ""} \u2014 nothing to do; delete the branch to pull the
|
|
8993
|
+
const url = await openPullUrl(ctx, consumer, repo, version2);
|
|
8994
|
+
ctx.say(`\u2022 ${name}: ${branch} is already on origin${url ? ` (${url})` : ""} \u2014 nothing to do; delete the branch to pull the version again`);
|
|
9159
8995
|
if (url) {
|
|
9160
8996
|
summary.pulls.push(url);
|
|
9161
8997
|
const body2 = await ctx.read("gh", ["pr", "view", url, "--json", "body", "--jq", ".body"], { cwd: repo }).catch(() => "");
|
|
@@ -9164,23 +9000,23 @@ async function update(ctx, options) {
|
|
|
9164
9000
|
}
|
|
9165
9001
|
return summary;
|
|
9166
9002
|
}
|
|
9167
|
-
const asked = options.
|
|
9003
|
+
const asked = options.to !== void 0 ? `--to ${version2}` : options.now ? "--now" : void 0;
|
|
9168
9004
|
const need = needOf({
|
|
9169
9005
|
recorded,
|
|
9170
9006
|
releases,
|
|
9171
9007
|
asked,
|
|
9172
|
-
stale: asked ? [] : await staleIn(ctx, consumer, repo,
|
|
9008
|
+
stale: asked ? [] : await staleIn(ctx, consumer, repo, version2),
|
|
9173
9009
|
maxAge: options.maxAge ?? maxAgeOf(answers[consumer.sites.indexOf(root)]?.answers ?? {}),
|
|
9174
9010
|
now: options.today === void 0 ? /* @__PURE__ */ new Date() : new Date(options.today)
|
|
9175
9011
|
});
|
|
9176
9012
|
if (!need.take) {
|
|
9177
|
-
ctx.say(`\u2022 ${name}: rests \u2014 ${need.why} (plx update --now takes ${
|
|
9013
|
+
ctx.say(`\u2022 ${name}: rests \u2014 ${need.why} (plx update --now takes ${version2})`);
|
|
9178
9014
|
summary.resting.push({ path: name, reason: need.why });
|
|
9179
9015
|
return summary;
|
|
9180
9016
|
}
|
|
9181
|
-
ctx.say(`\u2022 ${name}: takes ${
|
|
9017
|
+
ctx.say(`\u2022 ${name}: takes ${version2} \u2014 ${need.why}`);
|
|
9182
9018
|
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9183
|
-
const dir =
|
|
9019
|
+
const dir = join7(scratch, name);
|
|
9184
9020
|
try {
|
|
9185
9021
|
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
9186
9022
|
try {
|
|
@@ -9191,7 +9027,7 @@ async function update(ctx, options) {
|
|
|
9191
9027
|
summary.failed.push(name);
|
|
9192
9028
|
return summary;
|
|
9193
9029
|
}
|
|
9194
|
-
await
|
|
9030
|
+
await takeVersion(ctx, consumer, dir, { version: version2, ref: version2, opener: "`plx update`", why: need.why }, summary);
|
|
9195
9031
|
} finally {
|
|
9196
9032
|
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
9197
9033
|
if (scratch)
|
|
@@ -9199,49 +9035,49 @@ async function update(ctx, options) {
|
|
|
9199
9035
|
}
|
|
9200
9036
|
return summary;
|
|
9201
9037
|
}
|
|
9202
|
-
async function staleIn(ctx, consumer, repo,
|
|
9203
|
-
const text = await ctx.read("gh", ["release", "download",
|
|
9038
|
+
async function staleIn(ctx, consumer, repo, version2) {
|
|
9039
|
+
const text = await ctx.read("gh", ["release", "download", version2, "-R", RELEASES_REPO, "-p", MANIFEST_FILE, "-O", "-"]).catch(() => void 0);
|
|
9204
9040
|
if (text === void 0) {
|
|
9205
|
-
ctx.say(` ${consumer.rel}:
|
|
9041
|
+
ctx.say(` ${consumer.rel}: Plexus ${version2} carries no ${MANIFEST_FILE} that can be read; its modules are not checked`);
|
|
9206
9042
|
return [];
|
|
9207
9043
|
}
|
|
9208
9044
|
const catalog = catalogOf(parseManifest(text));
|
|
9209
9045
|
const markers = [];
|
|
9210
9046
|
for (const site of consumer.sites) {
|
|
9211
|
-
const file =
|
|
9212
|
-
const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(
|
|
9047
|
+
const file = join7(relative4(consumer.path, site.path), MARKER_FILE);
|
|
9048
|
+
const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(join7(site.path, MARKER_FILE)).catch(() => void 0);
|
|
9213
9049
|
if (marker === void 0)
|
|
9214
9050
|
continue;
|
|
9215
9051
|
try {
|
|
9216
9052
|
const { plexus, modules } = parseMarker(marker);
|
|
9217
|
-
markers.push({ where:
|
|
9053
|
+
markers.push({ where: join7(site.rel, MARKER_FILE), plexus, modules });
|
|
9218
9054
|
} catch {
|
|
9219
9055
|
}
|
|
9220
9056
|
}
|
|
9221
9057
|
return staleModules(markers, catalog);
|
|
9222
9058
|
}
|
|
9223
|
-
var
|
|
9224
|
-
async function
|
|
9059
|
+
var RELEASES_REPO = `plexus-ms/${COMPENDIUM}`;
|
|
9060
|
+
async function releasesOf(ctx) {
|
|
9225
9061
|
const jq = '.[] | select(.draft | not) | "\\(.tag_name) \\(.published_at)"';
|
|
9226
|
-
const lines = await ctx.read("gh", ["api", `repos/${
|
|
9227
|
-
return lines.split("\n").map((l) => l.trim().split(/\s+/)).filter((p) => p.length === 2 &&
|
|
9062
|
+
const lines = await ctx.read("gh", ["api", `repos/${RELEASES_REPO}/releases`, "--paginate", "--jq", jq]).catch(() => "");
|
|
9063
|
+
return lines.split("\n").map((l) => l.trim().split(/\s+/)).filter((p) => p.length === 2 && isPlexusVersion(p[0] ?? "")).map(([version2, published]) => ({ version: version2, published }));
|
|
9228
9064
|
}
|
|
9229
9065
|
function newestOf(releases) {
|
|
9230
|
-
const newest = releases.map((r) => r.
|
|
9066
|
+
const newest = releases.map((r) => r.version).reduce((a, b) => a && compareVersions(a, b) >= 0 ? a : b, "");
|
|
9231
9067
|
if (!newest)
|
|
9232
|
-
throw new Error(`no release of ${
|
|
9068
|
+
throw new Error(`no release of ${RELEASES_REPO} found \u2014 pass the version explicitly (--to <version>)`);
|
|
9233
9069
|
return newest;
|
|
9234
9070
|
}
|
|
9235
9071
|
|
|
9236
9072
|
// ../lib/dist/propagate.js
|
|
9237
9073
|
async function propagate(ctx, options) {
|
|
9238
9074
|
const { dir, ...rest } = options;
|
|
9239
|
-
if (options.
|
|
9240
|
-
throw new UsageError(`'${options.
|
|
9241
|
-
const summary = emptySummary(options.
|
|
9242
|
-
const consumers = await findConsumers(ctx, await overview(ctx, dir),
|
|
9075
|
+
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
9076
|
+
throw new UsageError(`'${options.to}' is not plain semver (X.Y.Z, no v)`);
|
|
9077
|
+
const summary = emptySummary(options.to ?? "", ctx.dryRun);
|
|
9078
|
+
const consumers = await findConsumers(ctx, await overview(ctx, dir), TEMPLATES);
|
|
9243
9079
|
if (consumers.length === 0)
|
|
9244
|
-
ctx.say(`\u2022 no repo generated from ${
|
|
9080
|
+
ctx.say(`\u2022 no repo generated from ${TEMPLATES.map(templateSource).join(", ")} found under ${dir}`);
|
|
9245
9081
|
for (const consumer of consumers) {
|
|
9246
9082
|
if (consumer.skipped) {
|
|
9247
9083
|
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run propagate)`);
|
|
@@ -9251,7 +9087,7 @@ async function propagate(ctx, options) {
|
|
|
9251
9087
|
try {
|
|
9252
9088
|
const one = await update(ctx, { repo: consumer.path, name: consumer.rel, ...rest });
|
|
9253
9089
|
mergeSummary(summary, one);
|
|
9254
|
-
summary.
|
|
9090
|
+
summary.version ||= one.version;
|
|
9255
9091
|
} catch (error) {
|
|
9256
9092
|
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}${detail(error)}`);
|
|
9257
9093
|
summary.failed.push(consumer.rel);
|
|
@@ -9261,7 +9097,7 @@ async function propagate(ctx, options) {
|
|
|
9261
9097
|
}
|
|
9262
9098
|
|
|
9263
9099
|
// ../lib/dist/requirements.js
|
|
9264
|
-
import { join as
|
|
9100
|
+
import { join as join8 } from "node:path";
|
|
9265
9101
|
var KEYWORD = /MUST|SHOULD|MAY/;
|
|
9266
9102
|
var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
|
|
9267
9103
|
var list = (value) => value.replace(/^\s*\[/, "").replace(/\].*$/, "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -9354,7 +9190,7 @@ var MAP_PAGE = "essentials/standard.md";
|
|
|
9354
9190
|
async function modulePages(ctx, compendium) {
|
|
9355
9191
|
const pages = [];
|
|
9356
9192
|
for (const dir of Object.keys(CATALOG_DIRS)) {
|
|
9357
|
-
const entries = await ctx.readDir(
|
|
9193
|
+
const entries = await ctx.readDir(join8(compendium, dir));
|
|
9358
9194
|
for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
|
|
9359
9195
|
pages.push(`${dir}/${e.name}`);
|
|
9360
9196
|
}
|
|
@@ -9362,11 +9198,11 @@ async function modulePages(ctx, compendium) {
|
|
|
9362
9198
|
}
|
|
9363
9199
|
async function checkCompendium(ctx, compendium) {
|
|
9364
9200
|
const defects = [];
|
|
9365
|
-
defects.push(...scanPage(await ctx.readFile(
|
|
9201
|
+
defects.push(...scanPage(await ctx.readFile(join8(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
|
|
9366
9202
|
const pages = await modulePages(ctx, compendium);
|
|
9367
9203
|
const scans = /* @__PURE__ */ new Map();
|
|
9368
9204
|
for (const page of pages) {
|
|
9369
|
-
const scan = scanPage(await ctx.readFile(
|
|
9205
|
+
const scan = scanPage(await ctx.readFile(join8(compendium, page)), page, "module");
|
|
9370
9206
|
defects.push(...scan.defects);
|
|
9371
9207
|
scans.set(page, scan);
|
|
9372
9208
|
}
|
|
@@ -9412,214 +9248,39 @@ async function checkCompendium(ctx, compendium) {
|
|
|
9412
9248
|
};
|
|
9413
9249
|
}
|
|
9414
9250
|
|
|
9415
|
-
// ../lib/dist/
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
const latest = (await ctx.read("npm", ["view", SELF_PACKAGE, "version"]).catch(() => "")).trim();
|
|
9419
|
-
if (!latest) {
|
|
9420
|
-
ctx.say(`\u26A0 could not ask the registry for the newest ${SELF_PACKAGE}; going on with plx ${running}`);
|
|
9421
|
-
return;
|
|
9422
|
-
}
|
|
9423
|
-
if (compareTrains(running, latest) < 0)
|
|
9424
|
-
throw new Error(`plx ${running} is behind ${latest}, the newest release; update it first: mise cache clear npm:${SELF_PACKAGE} && mise up npm:${SELF_PACKAGE}`);
|
|
9425
|
-
}
|
|
9426
|
-
|
|
9427
|
-
// ../lib/dist/ship.js
|
|
9428
|
-
import { join as join11 } from "node:path";
|
|
9429
|
-
var DEFAULT_WAIT = { interval: 15e3, timeout: 20 * 6e4 };
|
|
9430
|
-
async function ship(ctx, options) {
|
|
9431
|
-
const upstream = join11(options.workspace, UPSTREAM);
|
|
9432
|
-
if (options.plx)
|
|
9433
|
-
await preflightSelf(ctx, options.plx);
|
|
9434
|
-
const train = await readTrain(ctx, upstream);
|
|
9435
|
-
await preflightForge(ctx);
|
|
9436
|
-
await preflightRelease(ctx, train);
|
|
9437
|
-
await preflightImmutable(ctx, train);
|
|
9438
|
-
const next = resolveVersion(train, options.train, false);
|
|
9439
|
-
await release(ctx, train, next, options.today ?? today(), { ...DEFAULT_WAIT, ...options.wait });
|
|
9440
|
-
if (ctx.dryRun)
|
|
9441
|
-
return { ...await previewConsumers(ctx, options.workspace, next), released: true };
|
|
9442
|
-
ctx.say(`\u2022 train ${next} is cut; every repo takes it itself, when it needs it (plx update)`);
|
|
9443
|
-
return { ...emptySummary(next, false), released: true };
|
|
9444
|
-
}
|
|
9445
|
-
async function preflightImmutable(ctx, train) {
|
|
9446
|
-
for (const repo of train.repos) {
|
|
9447
|
-
const newest = (await ctx.read("gh", ["api", "repos/{owner}/{repo}/releases?per_page=1", "--jq", ".[0].immutable"], { cwd: repo.path }).catch(() => "")).trim();
|
|
9448
|
-
if (newest === "false")
|
|
9449
|
-
throw new Error(mutableRelease(`${repo.name}: its newest GitHub release is not immutable`));
|
|
9450
|
-
}
|
|
9451
|
-
}
|
|
9452
|
-
var mutableRelease = (what) => `${what} \u2014 enable immutable releases on the plexus-ms organisation (Settings \u2192 General \u2192 Releases); existing releases stay as they are (never delete one: a deleted immutable release burns its number)`;
|
|
9453
|
-
async function release(ctx, train, next, today2, wait) {
|
|
9454
|
-
ctx.say(`\u2192 train ${train.last ?? "none"} \u2192 ${next}`);
|
|
9455
|
-
for (const repo of train.repos) {
|
|
9456
|
-
if (repo.pending.length === 0)
|
|
9457
|
-
ctx.say(` ${repo.name}: no changes since ${repo.latest} \u2014 tag only`);
|
|
9458
|
-
else {
|
|
9459
|
-
ctx.say(` ${repo.name} (since ${repo.latest ?? "the beginning"}):`);
|
|
9460
|
-
for (const line of repo.pending.slice(0, PENDING_SHOWN))
|
|
9461
|
-
ctx.say(` ${line}`);
|
|
9462
|
-
if (repo.pending.length > PENDING_SHOWN)
|
|
9463
|
-
ctx.say(` \u2026 and ${repo.pending.length - PENDING_SHOWN} more`);
|
|
9464
|
-
}
|
|
9465
|
-
}
|
|
9466
|
-
if (!await ctx.confirm(`tag all ${train.repos.length} repos as ${next}, release them and push?`))
|
|
9467
|
-
throw new Error("aborted");
|
|
9468
|
-
const [one = [], two = []] = phasesOf(train);
|
|
9469
|
-
try {
|
|
9470
|
-
await releasePhase(ctx, train, one, next, today2);
|
|
9471
|
-
await awaitPublished(ctx, next, wait);
|
|
9472
|
-
await releasePhase(ctx, train, two, next, today2);
|
|
9473
|
-
} catch (error) {
|
|
9474
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
9475
|
-
throw new Error(`${message}
|
|
9476
|
-
\u2717 ship stopped during the release; re-run with --train ${next} to finish it (tagged repos and existing releases are skipped; if the registry already has ${next}, update plx first: it is the same code, built from the commit phase one tagged)`);
|
|
9477
|
-
}
|
|
9478
|
-
}
|
|
9479
|
-
var PENDING_SHOWN = 20;
|
|
9480
|
-
async function releasePhase(ctx, train, repos2, next, today2) {
|
|
9481
|
-
ctx.say(`\u2192 phase: ${repos2.map((r) => r.name).join(", ")}`);
|
|
9482
|
-
await ctx.apply(await planBookkeeping(ctx, train, repos2, next, today2));
|
|
9483
|
-
for (const repo of repos2)
|
|
9484
|
-
await tagAndRelease(ctx, repo, next, today2);
|
|
9485
|
-
}
|
|
9486
|
-
async function tagAndRelease(ctx, repo, next, today2) {
|
|
9487
|
-
const tagged = await ctx.read("git", ["rev-parse", "-q", "--verify", `refs/tags/${next}`], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9488
|
-
if (tagged)
|
|
9489
|
-
ctx.say(`\u2022 ${repo.name}: already tagged ${next}`);
|
|
9490
|
-
else
|
|
9491
|
-
await ctx.apply([run("git", ["tag", "-a", next, "-m", `train ${next}`], { cwd: repo.path })]);
|
|
9492
|
-
await ctx.apply([run("git", ["push", "origin", "main", next], { cwd: repo.path })]);
|
|
9493
|
-
const create = ["release", "create", next, "--verify-tag", "--generate-notes", "--title", next];
|
|
9494
|
-
if (repo.name === COMPENDIUM) {
|
|
9495
|
-
if (!await releaseWithManifest(ctx, repo, next, today2, create))
|
|
9496
|
-
return;
|
|
9497
|
-
} else {
|
|
9498
|
-
const released = await ctx.read("gh", ["release", "view", next], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9499
|
-
if (released) {
|
|
9500
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9501
|
-
return;
|
|
9502
|
-
}
|
|
9503
|
-
await ctx.apply([run("gh", create, { cwd: repo.path })]);
|
|
9504
|
-
}
|
|
9505
|
-
if (ctx.dryRun)
|
|
9506
|
-
return;
|
|
9507
|
-
const immutable = (await ctx.read("gh", ["api", `repos/{owner}/{repo}/releases/tags/${next}`, "--jq", ".immutable"], {
|
|
9508
|
-
cwd: repo.path
|
|
9509
|
-
})).trim();
|
|
9510
|
-
if (immutable !== "true")
|
|
9511
|
-
throw new Error(mutableRelease(`${repo.name}: release ${next} was created mutable, and its tag can still move`));
|
|
9512
|
-
}
|
|
9513
|
-
async function releaseWithManifest(ctx, repo, next, today2, create) {
|
|
9514
|
-
const state = (await ctx.read("gh", ["release", "view", next, "--json", "isDraft", "--jq", ".isDraft"], { cwd: repo.path }).catch(() => "")).trim();
|
|
9515
|
-
if (state === "false") {
|
|
9516
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9517
|
-
return false;
|
|
9518
|
-
}
|
|
9519
|
-
if (state === "true")
|
|
9520
|
-
ctx.say(`\u2022 ${repo.name}: release ${next} is still a draft \u2014 finishing it`);
|
|
9521
|
-
else
|
|
9522
|
-
await ctx.apply([run("gh", [...create, "--draft"], { cwd: repo.path })]);
|
|
9523
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9524
|
-
const file = join11(scratch, MANIFEST_FILE);
|
|
9525
|
-
try {
|
|
9526
|
-
const manifest2 = buildManifest(await readCatalog(ctx, repo.path), next, today2);
|
|
9527
|
-
ctx.say(` ${repo.name}: ${MANIFEST_FILE}: train ${next}, ${manifest2.modules.length} modules`);
|
|
9528
|
-
await ctx.stage(write(file, renderManifest(manifest2)));
|
|
9529
|
-
await ctx.apply([
|
|
9530
|
-
run("gh", ["release", "upload", next, file, "--clobber"], { cwd: repo.path }),
|
|
9531
|
-
run("gh", ["release", "edit", next, "--draft=false"], { cwd: repo.path })
|
|
9532
|
-
]);
|
|
9533
|
-
} finally {
|
|
9534
|
-
if (scratch)
|
|
9535
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9536
|
-
}
|
|
9537
|
-
return true;
|
|
9251
|
+
// ../lib/dist/summary.js
|
|
9252
|
+
function mergeLine(urls) {
|
|
9253
|
+
return urls.map((url) => /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/(\d+)$/.exec(url)).filter((m) => m !== null).map((m) => `gh pr merge -md -R ${m[1]} ${m[2]}`).join(" && ");
|
|
9538
9254
|
}
|
|
9539
|
-
|
|
9540
|
-
const
|
|
9541
|
-
const
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
const
|
|
9548
|
-
|
|
9549
|
-
for (
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
}
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
}
|
|
9563
|
-
|
|
9564
|
-
}
|
|
9565
|
-
async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
9566
|
-
const plan = [];
|
|
9567
|
-
const touched = /* @__PURE__ */ new Set();
|
|
9568
|
-
const repo = (name) => repos2.find((r) => r.name === name);
|
|
9569
|
-
const edit = async (r, rel, what, transform) => {
|
|
9570
|
-
const path3 = join11(r.path, rel);
|
|
9571
|
-
const text = await ctx.readFile(path3).catch(() => void 0);
|
|
9572
|
-
if (text === void 0)
|
|
9573
|
-
return;
|
|
9574
|
-
const edited = transform(text);
|
|
9575
|
-
if (edited === text)
|
|
9576
|
-
return;
|
|
9577
|
-
ctx.say(` ${r.name}: ${rel}: ${what}`);
|
|
9578
|
-
plan.push(write(path3, edited));
|
|
9579
|
-
touched.add(r);
|
|
9580
|
-
};
|
|
9581
|
-
const grep = async (r, needle, pathspecs) => (await ctx.read("git", ["grep", "-l", needle, "--", ...pathspecs], { cwd: r.path }).catch(() => "")).split("\n").filter(Boolean);
|
|
9582
|
-
const primitives = repo(PRIMITIVES);
|
|
9583
|
-
if (primitives) {
|
|
9584
|
-
for (const c of COLLECTIONS)
|
|
9585
|
-
await edit(primitives, galaxyFile(c), `plexus.${c} version \u2192 ${next}`, (t) => bumpGalaxyVersion(t, next));
|
|
9586
|
-
await edit(primitives, RUNNER_IMAGE_PIN_FILE, `runner image \u2192 ${next}`, (t) => bumpRunnerImagePin(t, next));
|
|
9587
|
-
for (const p of TRAIN_PACKAGES)
|
|
9588
|
-
await edit(primitives, `${p.dir}/package.json`, `${p.name} \u2192 ${next}`, (t) => bumpManifestVersion(t, next));
|
|
9589
|
-
}
|
|
9590
|
-
const operationsPreset = repo("preset-repo-operations");
|
|
9591
|
-
if (operationsPreset)
|
|
9592
|
-
await edit(operationsPreset, "template/requirements.yml", `plexus.* pins \u2192 ${next}`, (t) => bumpCollectionPin(t, next));
|
|
9593
|
-
for (const r of repos2) {
|
|
9594
|
-
for (const f of await grep(r, WORKFLOW_REF, ["*.yml", "*.yaml", "*.jinja"]))
|
|
9595
|
-
await edit(r, f, `workflow refs \u2192 @${next}`, (t) => bumpWorkflowRefs(t, next));
|
|
9596
|
-
for (const f of await grep(r, PLX_PIN, ["*.toml", "*.toml.jinja"]))
|
|
9597
|
-
await edit(r, f, `plx pin \u2192 ${next}`, (t) => bumpPlxPin(t, next));
|
|
9598
|
-
for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*package.json", "*package.json.jinja"]))
|
|
9599
|
-
await edit(r, f, `${CONFIG_PIN} pin \u2192 ${next}`, (t) => bumpConfigPin(t, next));
|
|
9600
|
-
for (const f of await grep(r, `"${CONFIG_PIN}"`, ["*pnpm-workspace.yaml", "*pnpm-workspace.yaml.jinja"]))
|
|
9601
|
-
await edit(r, f, `${CONFIG_PIN} catalog entry \u2192 ${next}`, (t) => bumpCatalogPin(t, next));
|
|
9602
|
-
}
|
|
9603
|
-
const comp = repo("compendium");
|
|
9604
|
-
if (comp) {
|
|
9605
|
-
await edit(comp, MAP_PAGE, `version \u2192 ${next}, timestamp \u2192 ${today2}`, (t) => stampStandard(t, next, today2));
|
|
9606
|
-
for (const page of await modulePages(ctx, comp.path)) {
|
|
9607
|
-
const text = await ctx.readFile(join11(comp.path, page));
|
|
9608
|
-
if (frontmatterField(text, "maturity") !== "standard")
|
|
9609
|
-
continue;
|
|
9610
|
-
const previous = comp.tag ? await ctx.read("git", ["show", `${comp.tag}:${page}`], { cwd: comp.path }).catch(() => "") : "";
|
|
9611
|
-
if (extractRequirements(text).join("\n") === extractRequirements(previous).join("\n"))
|
|
9612
|
-
continue;
|
|
9613
|
-
await edit(comp, page, `requirements changed since ${comp.latest ?? "the beginning"} \u2192 changed: ${next}`, (t) => stampChanged(t, next));
|
|
9614
|
-
}
|
|
9615
|
-
}
|
|
9616
|
-
for (const r of train.repos) {
|
|
9617
|
-
if (!touched.has(r))
|
|
9618
|
-
continue;
|
|
9619
|
-
plan.push(run("git", ["add", "-A"], { cwd: r.path }));
|
|
9620
|
-
plan.push(run("git", ["commit", "--quiet", "-m", `chore: train ${next} bookkeeping`], { cwd: r.path }));
|
|
9255
|
+
function renderSummary(s, realCommand, verb = "propagate") {
|
|
9256
|
+
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"];
|
|
9257
|
+
for (const p of s.clean)
|
|
9258
|
+
lines.push(` \u2713 clean: ${p}`);
|
|
9259
|
+
for (const p of s.conflicted)
|
|
9260
|
+
lines.push(` \u2717 conflicts: ${p}`);
|
|
9261
|
+
for (const p of s.failed)
|
|
9262
|
+
lines.push(` \u2717 failed: ${p}`);
|
|
9263
|
+
for (const { path: path3, reason } of s.skipped)
|
|
9264
|
+
lines.push(` \u26A0 skipped: ${path3} (${reason})`);
|
|
9265
|
+
for (const { path: path3, reason } of s.resting)
|
|
9266
|
+
lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
9267
|
+
for (const url of s.pulls)
|
|
9268
|
+
lines.push(` \u2192 pull: ${url}`);
|
|
9269
|
+
const merge = s.preview ? "" : mergeLine(s.mergeable);
|
|
9270
|
+
if (merge)
|
|
9271
|
+
lines.push(" the clean ones, to merge once their checks pass:", ` ${merge}`);
|
|
9272
|
+
const clean = isClean(s);
|
|
9273
|
+
const idle = clean && s.clean.length === 0;
|
|
9274
|
+
if (s.preview && !idle) {
|
|
9275
|
+
lines.push(" (preview only \u2014 nothing was changed)");
|
|
9276
|
+
if (clean)
|
|
9277
|
+
lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
|
|
9278
|
+
} else if (clean) {
|
|
9279
|
+
lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
|
|
9621
9280
|
}
|
|
9622
|
-
|
|
9281
|
+
if (!clean)
|
|
9282
|
+
lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
|
|
9283
|
+
return lines.join("\n");
|
|
9623
9284
|
}
|
|
9624
9285
|
|
|
9625
9286
|
// src/program.ts
|
|
@@ -10568,13 +10229,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
|
10568
10229
|
|
|
10569
10230
|
// ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
|
|
10570
10231
|
function withResolver() {
|
|
10571
|
-
let
|
|
10232
|
+
let resolve9;
|
|
10572
10233
|
let reject;
|
|
10573
10234
|
const promise = new Promise((res, rej) => {
|
|
10574
|
-
|
|
10235
|
+
resolve9 = res;
|
|
10575
10236
|
reject = rej;
|
|
10576
10237
|
});
|
|
10577
|
-
return { promise, resolve:
|
|
10238
|
+
return { promise, resolve: resolve9, reject };
|
|
10578
10239
|
}
|
|
10579
10240
|
|
|
10580
10241
|
// ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
@@ -10953,7 +10614,7 @@ function createPrompt(view) {
|
|
|
10953
10614
|
});
|
|
10954
10615
|
output.mute();
|
|
10955
10616
|
const screen = new ScreenManager(rl);
|
|
10956
|
-
const { promise, resolve:
|
|
10617
|
+
const { promise, resolve: resolve9, reject } = withResolver();
|
|
10957
10618
|
return withHooks(rl, (cycle) => {
|
|
10958
10619
|
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
10959
10620
|
const settlePrompt = (settle) => {
|
|
@@ -10964,7 +10625,7 @@ function createPrompt(view) {
|
|
|
10964
10625
|
reject(error);
|
|
10965
10626
|
}
|
|
10966
10627
|
};
|
|
10967
|
-
const resolvePrompt = (value) => settlePrompt(() =>
|
|
10628
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve9(value));
|
|
10968
10629
|
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
10969
10630
|
const promptPromise = Object.assign(promise.finally(() => {
|
|
10970
10631
|
cleanups.forEach((cleanup) => cleanup());
|
|
@@ -14563,7 +14224,7 @@ function register3(program2) {
|
|
|
14563
14224
|
|
|
14564
14225
|
// src/commands/doctor.ts
|
|
14565
14226
|
import { existsSync } from "node:fs";
|
|
14566
|
-
import { join as
|
|
14227
|
+
import { join as join9, resolve as resolve4 } from "node:path";
|
|
14567
14228
|
|
|
14568
14229
|
// src/style.ts
|
|
14569
14230
|
function style(enabled) {
|
|
@@ -14581,8 +14242,8 @@ function register4(program2) {
|
|
|
14581
14242
|
).option("--color", "colour the report even when piped").option("--no-color", "never colour the report").action(async (dir, opts, command) => {
|
|
14582
14243
|
const ctx = contextOf2(command);
|
|
14583
14244
|
const root = resolve4(dir);
|
|
14584
|
-
const compendium = resolve4(opts.compendium ??
|
|
14585
|
-
if (!existsSync(
|
|
14245
|
+
const compendium = resolve4(opts.compendium ?? join9(root, WORKSPACE_COMPENDIUM));
|
|
14246
|
+
if (!existsSync(join9(compendium, "contracts")))
|
|
14586
14247
|
throw new Error(
|
|
14587
14248
|
`no compendium at ${compendium}; pass --compendium <path to a checkout of plexus-ms/compendium>`
|
|
14588
14249
|
);
|
|
@@ -14658,76 +14319,34 @@ function annotate(dir, s, modules) {
|
|
|
14658
14319
|
}
|
|
14659
14320
|
|
|
14660
14321
|
// src/commands/propagate.ts
|
|
14661
|
-
import { resolve as resolve7 } from "node:path";
|
|
14662
|
-
|
|
14663
|
-
// src/commands/ship.ts
|
|
14664
14322
|
import { resolve as resolve6 } from "node:path";
|
|
14665
14323
|
function register6(program2) {
|
|
14666
|
-
program2.command("ship").description(
|
|
14667
|
-
"cut the train: tag and release every train repo identically; repos take it themselves (update, propagate)"
|
|
14668
|
-
).argument("[dir]", "the workspace: plexus-ms/ sits under it, and the consumers the dry run previews", ".").option("--train <version>", "the train version, plain semver (default: minor+1 over the latest train)").action(async (dir, opts, command) => {
|
|
14669
|
-
const ctx = contextOf2(command);
|
|
14670
|
-
const result = await ship(ctx, { workspace: resolve6(dir), train: opts.train, plx: version });
|
|
14671
|
-
ctx.result(
|
|
14672
|
-
result,
|
|
14673
|
-
(r) => r.preview ? renderSummary(r, `plx -y ship --train ${r.train} ${dir}`, "ship") : `\u2713 train ${r.train} cut \u2014 repos take it themselves; to take it now where it matters: plx propagate --now ${dir}`
|
|
14674
|
-
);
|
|
14675
|
-
if (!isClean(result)) process.exitCode = 1;
|
|
14676
|
-
});
|
|
14677
|
-
}
|
|
14678
|
-
function mergeLine(urls) {
|
|
14679
|
-
return urls.map((url) => /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/(\d+)$/.exec(url)).filter((m) => m !== null).map((m) => `gh pr merge -md -R ${m[1]} ${m[2]}`).join(" && ");
|
|
14680
|
-
}
|
|
14681
|
-
function renderSummary(s, realCommand, verb = "propagate") {
|
|
14682
|
-
const lines = ["\u2500\u2500 summary \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];
|
|
14683
|
-
for (const p of s.clean) lines.push(` \u2713 clean: ${p}`);
|
|
14684
|
-
for (const p of s.conflicted) lines.push(` \u2717 conflicts: ${p}`);
|
|
14685
|
-
for (const p of s.failed) lines.push(` \u2717 failed: ${p}`);
|
|
14686
|
-
for (const { path: path3, reason } of s.skipped) lines.push(` \u26A0 skipped: ${path3} (${reason})`);
|
|
14687
|
-
for (const { path: path3, reason } of s.resting) lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
14688
|
-
for (const url of s.pulls) lines.push(` \u2192 pull: ${url}`);
|
|
14689
|
-
const merge = s.preview ? "" : mergeLine(s.mergeable);
|
|
14690
|
-
if (merge) lines.push(" the clean ones, to merge once their checks pass:", ` ${merge}`);
|
|
14691
|
-
const clean = isClean(s);
|
|
14692
|
-
const idle = clean && s.clean.length === 0;
|
|
14693
|
-
if (s.preview && !idle) {
|
|
14694
|
-
lines.push(" (preview only \u2014 nothing was changed)");
|
|
14695
|
-
if (clean) lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
|
|
14696
|
-
} else if (clean) {
|
|
14697
|
-
lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
|
|
14698
|
-
}
|
|
14699
|
-
if (!clean) lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
|
|
14700
|
-
return lines.join("\n");
|
|
14701
|
-
}
|
|
14702
|
-
|
|
14703
|
-
// src/commands/propagate.ts
|
|
14704
|
-
function register7(program2) {
|
|
14705
14324
|
program2.command("propagate").description(
|
|
14706
|
-
"run update in every repo generated from the
|
|
14325
|
+
"run update in every repo generated from the templates under a directory: each takes the newest version when it needs it, as one pull request per repo"
|
|
14707
14326
|
).argument("[dir]", "a directory the repos sit under, at any depth", ".").option(
|
|
14708
|
-
"--
|
|
14709
|
-
"the
|
|
14710
|
-
).option("--now", "take the newest
|
|
14327
|
+
"--to <version>",
|
|
14328
|
+
"the version every repo takes, whatever the triggers say (default: each template's newest)"
|
|
14329
|
+
).option("--now", "take the newest version in every repo, whatever the triggers say").option(
|
|
14711
14330
|
"--max-age <days>",
|
|
14712
|
-
"the backstop for every repo (default: each repo's answer update_max_age, else 30; 0 takes every
|
|
14331
|
+
"the backstop for every repo (default: each repo's answer update_max_age, else 30; 0 takes every version)",
|
|
14713
14332
|
(v) => parseMaxAge(v, "--max-age")
|
|
14714
14333
|
).action(async (dir, opts, command) => {
|
|
14715
14334
|
const ctx = contextOf2(command);
|
|
14716
|
-
const result = await propagate(ctx, { dir:
|
|
14717
|
-
const flags = [opts.
|
|
14335
|
+
const result = await propagate(ctx, { dir: resolve6(dir), to: opts.to, now: opts.now, maxAge: opts.maxAge });
|
|
14336
|
+
const flags = [opts.to ? `--to ${opts.to}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
|
|
14718
14337
|
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
14719
14338
|
if (!isClean(result)) process.exitCode = 1;
|
|
14720
14339
|
});
|
|
14721
14340
|
}
|
|
14722
14341
|
|
|
14723
14342
|
// src/commands/requirements.ts
|
|
14724
|
-
import { join as
|
|
14725
|
-
function
|
|
14343
|
+
import { join as join10, resolve as resolve7 } from "node:path";
|
|
14344
|
+
function register7(program2) {
|
|
14726
14345
|
program2.command("requirements").description("lint the standard's map and module pages, or extract one module's requirement lines").argument("[dir]", "a checkout of the compendium", ".").option("--extract <page>", "print a module page's requirement lines instead of linting (path relative to dir)").action(async (dir, opts, command) => {
|
|
14727
14346
|
const ctx = contextOf2(command);
|
|
14728
|
-
const compendium =
|
|
14347
|
+
const compendium = resolve7(dir);
|
|
14729
14348
|
if (opts.extract) {
|
|
14730
|
-
ctx.result(extractRequirements(await ctx.readFile(
|
|
14349
|
+
ctx.result(extractRequirements(await ctx.readFile(join10(compendium, opts.extract))));
|
|
14731
14350
|
return;
|
|
14732
14351
|
}
|
|
14733
14352
|
const check = await checkCompendium(ctx, compendium);
|
|
@@ -14741,18 +14360,18 @@ function renderCheck(c) {
|
|
|
14741
14360
|
}
|
|
14742
14361
|
|
|
14743
14362
|
// src/commands/update.ts
|
|
14744
|
-
import { resolve as
|
|
14745
|
-
function
|
|
14363
|
+
import { resolve as resolve8 } from "node:path";
|
|
14364
|
+
function register8(program2) {
|
|
14746
14365
|
program2.command("update").description(
|
|
14747
|
-
"bring this repo up to the newest
|
|
14748
|
-
).argument("[dir]", "a repo generated from the
|
|
14366
|
+
"bring this repo up to the newest version 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"
|
|
14367
|
+
).argument("[dir]", "a repo generated from the templates", ".").option("--to <version>", "the version to take, whatever the triggers say (default: the template's newest release)").option("--now", "take the newest version whatever the triggers say").option(
|
|
14749
14368
|
"--max-age <days>",
|
|
14750
|
-
"the backstop: take the newest
|
|
14369
|
+
"the backstop: take the newest version once the oldest one not taken is this old (default: the repo's answer update_max_age, else 30; 0 takes every version)",
|
|
14751
14370
|
(v) => parseMaxAge(v, "--max-age")
|
|
14752
14371
|
).action(async (dir, opts, command) => {
|
|
14753
14372
|
const ctx = contextOf2(command);
|
|
14754
|
-
const result = await update(ctx, { repo:
|
|
14755
|
-
ctx.result(result, (r) => renderSummary(r, `plx -y update --
|
|
14373
|
+
const result = await update(ctx, { repo: resolve8(dir), to: opts.to, now: opts.now, maxAge: opts.maxAge });
|
|
14374
|
+
ctx.result(result, (r) => renderSummary(r, `plx -y update --to ${r.version} ${dir}`, "update"));
|
|
14756
14375
|
if (!isClean(result)) process.exitCode = 1;
|
|
14757
14376
|
});
|
|
14758
14377
|
}
|
|
@@ -14762,9 +14381,8 @@ var commands = [
|
|
|
14762
14381
|
register5,
|
|
14763
14382
|
register4,
|
|
14764
14383
|
register6,
|
|
14765
|
-
register7,
|
|
14766
|
-
register9,
|
|
14767
14384
|
register8,
|
|
14385
|
+
register7,
|
|
14768
14386
|
register,
|
|
14769
14387
|
register3,
|
|
14770
14388
|
register2
|
|
@@ -14777,7 +14395,7 @@ function buildProgram() {
|
|
|
14777
14395
|
program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
|
|
14778
14396
|
new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
|
|
14779
14397
|
).addOption(new Option("-q, --quiet", "say nothing but results and errors").env("PLX_QUIET")).addOption(new Option("-y, --yes", "answer every confirmation with yes (needed off a terminal)").env("PLX_YES")).addOption(new Option("--json", "print results as JSON").env("PLX_JSON"));
|
|
14780
|
-
for (const
|
|
14398
|
+
for (const register9 of commands) register9(program2);
|
|
14781
14399
|
return program2;
|
|
14782
14400
|
}
|
|
14783
14401
|
function contextOf2(command) {
|