@plexus-ms/cli 0.119.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 +142 -140
- package/package.json +3 -3
package/dist/plx.js
CHANGED
|
@@ -7558,8 +7558,8 @@ function setFrontmatterField(text, key, value, options = {}) {
|
|
|
7558
7558
|
}
|
|
7559
7559
|
|
|
7560
7560
|
// ../lib/dist/bookkeeping.js
|
|
7561
|
-
var WORKFLOW_REF = "plexus-ms/
|
|
7562
|
-
var bumpWorkflowRefs = (text,
|
|
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}`);
|
|
7563
7563
|
var hasConflictMarkers = (text) => /^<<<<<<< /m.test(text);
|
|
7564
7564
|
var hasUnmergedEntries = (porcelain) => /^(UU|AA|DU|UD)/m.test(porcelain);
|
|
7565
7565
|
function syncMarker(marker, commit) {
|
|
@@ -7645,6 +7645,15 @@ ${stderr.trimEnd()}` : ""}`);
|
|
|
7645
7645
|
this.stderr = stderr;
|
|
7646
7646
|
}
|
|
7647
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
|
+
}
|
|
7648
7657
|
var isInteractive = () => process.stdin.isTTY === true && process.stderr.isTTY === true;
|
|
7649
7658
|
function realIo(prompt) {
|
|
7650
7659
|
return {
|
|
@@ -7811,15 +7820,7 @@ async function readChangeset(ctx, dir, base, branch) {
|
|
|
7811
7820
|
const git2 = (args) => ctx.read("git", args, { cwd: dir });
|
|
7812
7821
|
const head = branch ?? (await git2(["rev-parse", "--abbrev-ref", "HEAD"])).trim();
|
|
7813
7822
|
const mergeBase = (await git2(["merge-base", base, "HEAD"])).trim();
|
|
7814
|
-
const show =
|
|
7815
|
-
try {
|
|
7816
|
-
return await git2(["show", `${mergeBase}:${path4}`]);
|
|
7817
|
-
} catch (error) {
|
|
7818
|
-
if (error instanceof ExecError)
|
|
7819
|
-
return void 0;
|
|
7820
|
-
throw error;
|
|
7821
|
-
}
|
|
7822
|
-
};
|
|
7823
|
+
const show = (path4) => orAbsent(git2(["show", `${mergeBase}:${path4}`]));
|
|
7823
7824
|
const current = async (path4) => {
|
|
7824
7825
|
try {
|
|
7825
7826
|
return await ctx.readFile(join2(dir, path4));
|
|
@@ -7866,16 +7867,16 @@ async function expand(ctx, root, glob) {
|
|
|
7866
7867
|
// ../lib/dist/consumers.js
|
|
7867
7868
|
import { relative } from "node:path";
|
|
7868
7869
|
|
|
7869
|
-
// ../lib/dist/
|
|
7870
|
+
// ../lib/dist/version.js
|
|
7870
7871
|
var COMPENDIUM = "compendium";
|
|
7871
|
-
var
|
|
7872
|
-
"
|
|
7873
|
-
"
|
|
7874
|
-
"
|
|
7875
|
-
"
|
|
7872
|
+
var VERSIONED_REPOS = [
|
|
7873
|
+
"tooling",
|
|
7874
|
+
"template-repo-turbo",
|
|
7875
|
+
"template-app-nextjs",
|
|
7876
|
+
"template-repo-operations",
|
|
7876
7877
|
COMPENDIUM
|
|
7877
7878
|
];
|
|
7878
|
-
var
|
|
7879
|
+
var isPlexusVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
|
|
7879
7880
|
async function preflightForge(ctx) {
|
|
7880
7881
|
try {
|
|
7881
7882
|
await ctx.read("gh", ["auth", "status"]);
|
|
@@ -7887,7 +7888,7 @@ var UsageError = class extends Error {
|
|
|
7887
7888
|
};
|
|
7888
7889
|
|
|
7889
7890
|
// ../lib/dist/consumers.js
|
|
7890
|
-
var
|
|
7891
|
+
var TEMPLATES = VERSIONED_REPOS.filter((r) => r.startsWith("template-"));
|
|
7891
7892
|
function expectedBranch(declaration, answers = {}) {
|
|
7892
7893
|
if (!declaration)
|
|
7893
7894
|
return void 0;
|
|
@@ -7897,29 +7898,32 @@ function expectedBranch(declaration, answers = {}) {
|
|
|
7897
7898
|
return answers.publishes_packages === true ? "main" : "develop";
|
|
7898
7899
|
return void 0;
|
|
7899
7900
|
}
|
|
7900
|
-
var
|
|
7901
|
-
var
|
|
7902
|
-
"preset-repo-web": "
|
|
7903
|
-
"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"
|
|
7904
7908
|
};
|
|
7905
|
-
function
|
|
7906
|
-
for (const p of
|
|
7907
|
-
if (
|
|
7909
|
+
function templateOf(src, templates) {
|
|
7910
|
+
for (const p of templates)
|
|
7911
|
+
if (templateSource(p) === src)
|
|
7908
7912
|
return p;
|
|
7909
|
-
for (const [old, current] of Object.entries(
|
|
7910
|
-
if (
|
|
7913
|
+
for (const [old, current] of Object.entries(RENAMED_TEMPLATES))
|
|
7914
|
+
if (templateSource(old) === src && templates.includes(current))
|
|
7911
7915
|
return current;
|
|
7912
7916
|
return void 0;
|
|
7913
7917
|
}
|
|
7914
|
-
async function findConsumers(ctx, root,
|
|
7918
|
+
async function findConsumers(ctx, root, templates) {
|
|
7915
7919
|
const consumers = /* @__PURE__ */ new Map();
|
|
7916
7920
|
const orphans = [];
|
|
7917
7921
|
const visit = (dir, repo, inTemplate) => {
|
|
7918
7922
|
const here = dir.git ? dir : repo;
|
|
7919
|
-
const
|
|
7920
|
-
const
|
|
7921
|
-
if (
|
|
7922
|
-
const site = { path: dir.path, rel: relative(root.path, dir.path) || ".",
|
|
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 };
|
|
7923
7927
|
if (!here)
|
|
7924
7928
|
orphans.push(site);
|
|
7925
7929
|
else {
|
|
@@ -7939,7 +7943,7 @@ async function findConsumers(ctx, root, presets) {
|
|
|
7939
7943
|
}
|
|
7940
7944
|
}
|
|
7941
7945
|
for (const child of dir.children)
|
|
7942
|
-
visit(child, here,
|
|
7946
|
+
visit(child, here, within);
|
|
7943
7947
|
};
|
|
7944
7948
|
visit(root, void 0, false);
|
|
7945
7949
|
for (const site of orphans)
|
|
@@ -8252,13 +8256,9 @@ var Remote = class {
|
|
|
8252
8256
|
}
|
|
8253
8257
|
/** A check on the host: whether the command succeeds, or undefined under --dry-run. */
|
|
8254
8258
|
async test(command, show = false) {
|
|
8255
|
-
|
|
8256
|
-
return
|
|
8257
|
-
|
|
8258
|
-
if (error instanceof ExecError)
|
|
8259
|
-
return false;
|
|
8260
|
-
throw error;
|
|
8261
|
-
}
|
|
8259
|
+
if (this.ctx.dryRun)
|
|
8260
|
+
return this.read(command, show).then(() => void 0);
|
|
8261
|
+
return await orAbsent(this.read(command, show)) !== void 0;
|
|
8262
8262
|
}
|
|
8263
8263
|
/** Close the shared connection; nothing to close when no call was made. */
|
|
8264
8264
|
close() {
|
|
@@ -8409,7 +8409,7 @@ function diagnoseUnit(unit, units, catalog, root) {
|
|
|
8409
8409
|
findings.push(`declares ${code}, which no module carries`);
|
|
8410
8410
|
continue;
|
|
8411
8411
|
}
|
|
8412
|
-
if (module.changed &&
|
|
8412
|
+
if (module.changed && compareVersions(module.changed, plexus) > 0)
|
|
8413
8413
|
findings.push(`${code} changed in ${module.changed}, declared at ${plexus}`);
|
|
8414
8414
|
for (const dep of module.depends)
|
|
8415
8415
|
if (!modules.includes(dep) && !context.has(dep))
|
|
@@ -8432,7 +8432,7 @@ function contextOf(unit, units) {
|
|
|
8432
8432
|
function descendants(dir) {
|
|
8433
8433
|
return dir.children.flatMap((c) => [...c.declaration ? [c] : [], ...descendants(c)]);
|
|
8434
8434
|
}
|
|
8435
|
-
function
|
|
8435
|
+
function compareVersions(a, b) {
|
|
8436
8436
|
const nums = (v) => v.split(".").slice(0, 3).map((p) => Number.parseInt(p, 10) || 0);
|
|
8437
8437
|
const [x, y] = [nums(a), nums(b)];
|
|
8438
8438
|
for (let i = 0; i < 3; i++)
|
|
@@ -8442,7 +8442,7 @@ function compareTrains(a, b) {
|
|
|
8442
8442
|
}
|
|
8443
8443
|
|
|
8444
8444
|
// ../lib/dist/manifest.js
|
|
8445
|
-
var MANIFEST_FILE = "
|
|
8445
|
+
var MANIFEST_FILE = "modules.json";
|
|
8446
8446
|
var MANIFEST_SCHEMA = 1;
|
|
8447
8447
|
var catalogOf = (manifest2) => new Map(manifest2.modules.map((m) => [m.code, m]));
|
|
8448
8448
|
var strings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
@@ -8451,24 +8451,24 @@ function parseManifest(text) {
|
|
|
8451
8451
|
try {
|
|
8452
8452
|
data = JSON.parse(text);
|
|
8453
8453
|
} catch {
|
|
8454
|
-
throw new Error("the
|
|
8454
|
+
throw new Error("the module manifest is not JSON");
|
|
8455
8455
|
}
|
|
8456
8456
|
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
8457
|
-
throw new Error("the
|
|
8458
|
-
const { schema,
|
|
8457
|
+
throw new Error("the module manifest is not an object");
|
|
8458
|
+
const { schema, version: version2, date, modules } = data;
|
|
8459
8459
|
if (schema !== MANIFEST_SCHEMA)
|
|
8460
|
-
throw new Error(`the
|
|
8461
|
-
if (typeof
|
|
8462
|
-
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`);
|
|
8463
8463
|
if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(date))
|
|
8464
|
-
throw new Error(`the
|
|
8464
|
+
throw new Error(`the module manifest is dated '${String(date)}', not YYYY-MM-DD`);
|
|
8465
8465
|
if (!Array.isArray(modules))
|
|
8466
|
-
throw new Error("the
|
|
8467
|
-
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) };
|
|
8468
8468
|
}
|
|
8469
8469
|
function parseEntry(entry) {
|
|
8470
8470
|
const m = entry ?? {};
|
|
8471
|
-
const where = `the
|
|
8471
|
+
const where = `the module manifest's module ${typeof m.code === "string" ? m.code : JSON.stringify(entry)}`;
|
|
8472
8472
|
if (typeof m.code !== "string" || m.code === "")
|
|
8473
8473
|
throw new Error(`${where} has no code`);
|
|
8474
8474
|
if (m.kind !== "contract" && m.kind !== "approach")
|
|
@@ -8478,7 +8478,7 @@ function parseEntry(entry) {
|
|
|
8478
8478
|
if (!strings(m.depends) || !strings(m.consumes))
|
|
8479
8479
|
throw new Error(`${where} lacks depends or consumes`);
|
|
8480
8480
|
if (m.changed !== void 0 && typeof m.changed !== "string")
|
|
8481
|
-
throw new Error(`${where} has a changed that is no
|
|
8481
|
+
throw new Error(`${where} has a changed that is no version`);
|
|
8482
8482
|
return {
|
|
8483
8483
|
code: m.code,
|
|
8484
8484
|
kind: m.kind,
|
|
@@ -8525,42 +8525,42 @@ function needOf({ recorded, releases, asked, stale = [], maxAge, now }) {
|
|
|
8525
8525
|
trigger: "module",
|
|
8526
8526
|
why: `${first.code} changed in ${first.changed}, declared at ${first.declared} in ${first.where}${more.length > 0 ? `, and ${more.length} more` : ""}`
|
|
8527
8527
|
};
|
|
8528
|
-
const odd = recorded.findIndex((r) => !r || !
|
|
8528
|
+
const odd = recorded.findIndex((r) => !r || !isPlexusVersion(r));
|
|
8529
8529
|
if (recorded.length === 0 || odd >= 0)
|
|
8530
8530
|
return {
|
|
8531
8531
|
take: true,
|
|
8532
8532
|
trigger: "backstop",
|
|
8533
|
-
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`
|
|
8534
8534
|
};
|
|
8535
|
-
const
|
|
8536
|
-
const oldest =
|
|
8537
|
-
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));
|
|
8538
8538
|
const oldestUntaken = untaken[0];
|
|
8539
8539
|
if (!oldestUntaken)
|
|
8540
|
-
return { take: false, why: `no
|
|
8540
|
+
return { take: false, why: `no version newer than ${oldest}` };
|
|
8541
8541
|
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(oldestUntaken.published)) / DAY));
|
|
8542
|
-
const count = `${untaken.length} newer
|
|
8542
|
+
const count = `${untaken.length} newer version${untaken.length === 1 ? "" : "s"}`;
|
|
8543
8543
|
if (maxAge === 0)
|
|
8544
|
-
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})` };
|
|
8545
8545
|
if (age >= maxAge)
|
|
8546
8546
|
return {
|
|
8547
8547
|
take: true,
|
|
8548
8548
|
trigger: "backstop",
|
|
8549
|
-
why: `${oldestUntaken.
|
|
8549
|
+
why: `${oldestUntaken.version}, the oldest version not taken, was cut ${days(age)} ago (backstop: ${days(maxAge)}; ${count})`
|
|
8550
8550
|
};
|
|
8551
8551
|
return {
|
|
8552
8552
|
take: false,
|
|
8553
|
-
why: `${count}, the oldest (${oldestUntaken.
|
|
8553
|
+
why: `${count}, the oldest (${oldestUntaken.version}) cut ${days(age)} ago; the backstop is ${days(maxAge)}`
|
|
8554
8554
|
};
|
|
8555
8555
|
}
|
|
8556
8556
|
function staleModules(markers, catalog) {
|
|
8557
8557
|
const stale = [];
|
|
8558
8558
|
for (const { where, plexus, modules } of markers) {
|
|
8559
|
-
if (!
|
|
8559
|
+
if (!isPlexusVersion(plexus))
|
|
8560
8560
|
continue;
|
|
8561
8561
|
for (const code of modules) {
|
|
8562
8562
|
const changed = catalog.get(code)?.changed;
|
|
8563
|
-
if (changed &&
|
|
8563
|
+
if (changed && isPlexusVersion(changed) && compareVersions(changed, plexus) > 0)
|
|
8564
8564
|
stale.push({ code, changed, where, declared: plexus });
|
|
8565
8565
|
}
|
|
8566
8566
|
}
|
|
@@ -8718,8 +8718,8 @@ function mergeSummary(into, from) {
|
|
|
8718
8718
|
into.pulls.push(...from.pulls);
|
|
8719
8719
|
into.mergeable.push(...from.mergeable);
|
|
8720
8720
|
}
|
|
8721
|
-
var emptySummary = (
|
|
8722
|
-
|
|
8721
|
+
var emptySummary = (version2, preview) => ({
|
|
8722
|
+
version: version2,
|
|
8723
8723
|
preview,
|
|
8724
8724
|
clean: [],
|
|
8725
8725
|
conflicted: [],
|
|
@@ -8731,17 +8731,17 @@ var emptySummary = (train, preview) => ({
|
|
|
8731
8731
|
});
|
|
8732
8732
|
var CLEAN_BODY = "Merged clean at every site.";
|
|
8733
8733
|
var ofConsumer = (list2, consumer) => list2.filter((p) => p === consumer.rel || p.startsWith(`${consumer.rel}/`));
|
|
8734
|
-
var
|
|
8734
|
+
var versionBranch = (version2) => `plexus/${version2}`;
|
|
8735
8735
|
var copierIn = (dir, args) => [
|
|
8736
8736
|
"env",
|
|
8737
8737
|
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, "mise", ...copierVia(args)]
|
|
8738
8738
|
];
|
|
8739
|
-
async function
|
|
8739
|
+
async function takeVersion(ctx, consumer, dir, take, summary) {
|
|
8740
8740
|
const base = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim();
|
|
8741
8741
|
for (const site of consumer.sites)
|
|
8742
8742
|
await updateSite(ctx, consumer, site, dir, take, summary);
|
|
8743
8743
|
await refreshLockfile(ctx, consumer, dir, base, summary);
|
|
8744
|
-
await bumpConsumerRefs(ctx, consumer, dir, take.
|
|
8744
|
+
await bumpConsumerRefs(ctx, consumer, dir, take.version);
|
|
8745
8745
|
await openPull(ctx, consumer, dir, take, summary);
|
|
8746
8746
|
}
|
|
8747
8747
|
var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], { cwd: dir })).then(() => ctx.stage(run("git", [
|
|
@@ -8762,21 +8762,21 @@ async function updateSite(ctx, consumer, site, dir, take, summary) {
|
|
|
8762
8762
|
const target = join6(dir, relative3(consumer.path, site.path));
|
|
8763
8763
|
try {
|
|
8764
8764
|
if (take.previewFrom) {
|
|
8765
|
-
const
|
|
8766
|
-
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${
|
|
8765
|
+
const localTemplate = join6(take.previewFrom, site.template);
|
|
8766
|
+
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localTemplate}@main)`);
|
|
8767
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: ${
|
|
8769
|
-
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${
|
|
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`);
|
|
8770
8770
|
await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
|
|
8771
8771
|
} else {
|
|
8772
8772
|
ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
|
|
8773
8773
|
const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
|
|
8774
|
-
const current =
|
|
8774
|
+
const current = templateSource(site.template);
|
|
8775
8775
|
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
8776
|
-
if (recorded && recorded !== current && Object.keys(
|
|
8777
|
-
ctx.say(` ${site.rel}: 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
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
|
|
8779
|
+
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the template's name since its rename`);
|
|
8780
8780
|
}
|
|
8781
8781
|
const args = [
|
|
8782
8782
|
"update",
|
|
@@ -8842,13 +8842,15 @@ async function refreshLockfile(ctx, consumer, dir, base, summary) {
|
|
|
8842
8842
|
return;
|
|
8843
8843
|
ctx.say(`\u2192 ${consumer.rel}: pnpm install (manifests changed)`);
|
|
8844
8844
|
try {
|
|
8845
|
-
await ctx.apply([
|
|
8845
|
+
await ctx.apply([
|
|
8846
|
+
run("mise", ["exec", "--", "pnpm", "install", "--no-frozen-lockfile", "--reporter=silent"], { cwd: dir })
|
|
8847
|
+
]);
|
|
8846
8848
|
} catch (error) {
|
|
8847
8849
|
ctx.say(` \u2717 pnpm install failed${detail(error)}`);
|
|
8848
8850
|
summary.failed.push(`${consumer.rel}/pnpm-lock.yaml`);
|
|
8849
8851
|
}
|
|
8850
8852
|
}
|
|
8851
|
-
async function bumpConsumerRefs(ctx, consumer, dir,
|
|
8853
|
+
async function bumpConsumerRefs(ctx, consumer, dir, version2) {
|
|
8852
8854
|
const workflows = join6(dir, ".github", "workflows");
|
|
8853
8855
|
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
8854
8856
|
const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
|
|
@@ -8856,20 +8858,20 @@ async function bumpConsumerRefs(ctx, consumer, dir, train) {
|
|
|
8856
8858
|
const text = await ctx.readFile(join6(workflows, f));
|
|
8857
8859
|
if (!text.includes(WORKFLOW_REF))
|
|
8858
8860
|
continue;
|
|
8859
|
-
const bumped = bumpWorkflowRefs(text,
|
|
8861
|
+
const bumped = bumpWorkflowRefs(text, version2);
|
|
8860
8862
|
if (bumped === text)
|
|
8861
8863
|
continue;
|
|
8862
|
-
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${
|
|
8864
|
+
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${version2}`);
|
|
8863
8865
|
await ctx.stage(write(join6(workflows, f), bumped));
|
|
8864
8866
|
}
|
|
8865
8867
|
}
|
|
8866
|
-
async function openPullUrl(ctx, consumer, dir,
|
|
8867
|
-
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"];
|
|
8868
8870
|
return (await ctx.read("gh", [...args, "--json", "url", "--jq", ".[0].url"], { cwd: dir }).catch(() => "")).trim();
|
|
8869
8871
|
}
|
|
8870
8872
|
async function openPull(ctx, consumer, dir, take, summary) {
|
|
8871
|
-
const {
|
|
8872
|
-
const branch =
|
|
8873
|
+
const { version: version2 } = take;
|
|
8874
|
+
const branch = versionBranch(version2);
|
|
8873
8875
|
if (ctx.dryRun) {
|
|
8874
8876
|
ctx.say(` (preview) ${consumer.rel}: would commit, push ${branch} and open a pull request against ${consumer.branch}`);
|
|
8875
8877
|
return;
|
|
@@ -8882,7 +8884,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8882
8884
|
try {
|
|
8883
8885
|
await ctx.apply([
|
|
8884
8886
|
run("git", ["add", "-A"], { cwd: dir }),
|
|
8885
|
-
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore:
|
|
8887
|
+
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore: Plexus ${version2}`], { cwd: dir })
|
|
8886
8888
|
]);
|
|
8887
8889
|
await ctx.read("git", ["fetch", "--quiet", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`], {
|
|
8888
8890
|
cwd: dir
|
|
@@ -8900,7 +8902,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8900
8902
|
const conflicted = ofConsumer(summary.conflicted, consumer);
|
|
8901
8903
|
const failed = ofConsumer(summary.failed, consumer);
|
|
8902
8904
|
const clean = conflicted.length === 0 && failed.length === 0;
|
|
8903
|
-
const existing = await openPullUrl(ctx, consumer, dir,
|
|
8905
|
+
const existing = await openPullUrl(ctx, consumer, dir, version2);
|
|
8904
8906
|
if (existing) {
|
|
8905
8907
|
ctx.say(`\u2022 ${consumer.rel}: pull request updated: ${existing}`);
|
|
8906
8908
|
summary.pulls.push(existing);
|
|
@@ -8910,7 +8912,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8910
8912
|
}
|
|
8911
8913
|
const sites = consumer.sites.map((s) => s.rel);
|
|
8912
8914
|
const body2 = [
|
|
8913
|
-
`
|
|
8915
|
+
`Plexus ${version2} (\xA7 1.5 PLX): \`copier update\` at ${sites.join(", ")}, the marker, the lockfile where manifests moved, and the workflow refs.`,
|
|
8914
8916
|
...conflicted.length > 0 ? [`Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.`] : [],
|
|
8915
8917
|
...failed.length > 0 ? [`Failed, and left as it was: ${failed.join(", ")}.`] : [],
|
|
8916
8918
|
...clean ? [CLEAN_BODY] : [],
|
|
@@ -8926,7 +8928,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8926
8928
|
"--head",
|
|
8927
8929
|
branch,
|
|
8928
8930
|
"--title",
|
|
8929
|
-
`chore:
|
|
8931
|
+
`chore: Plexus ${version2}`,
|
|
8930
8932
|
"--body",
|
|
8931
8933
|
body2
|
|
8932
8934
|
], { cwd: dir })
|
|
@@ -8936,7 +8938,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8936
8938
|
summary.failed.push(consumer.rel);
|
|
8937
8939
|
return;
|
|
8938
8940
|
}
|
|
8939
|
-
const url = await openPullUrl(ctx, consumer, dir,
|
|
8941
|
+
const url = await openPullUrl(ctx, consumer, dir, version2);
|
|
8940
8942
|
ctx.say(`\u2022 ${consumer.rel}: pull request opened${url ? `: ${url}` : ""}`);
|
|
8941
8943
|
summary.pulls.push(url || `${consumer.rel} ${branch}`);
|
|
8942
8944
|
if (url && clean)
|
|
@@ -8953,12 +8955,12 @@ import { basename, join as join7, relative as relative4 } from "node:path";
|
|
|
8953
8955
|
async function update(ctx, options) {
|
|
8954
8956
|
const { repo } = options;
|
|
8955
8957
|
const name = options.name ?? basename(repo);
|
|
8956
|
-
if (options.
|
|
8957
|
-
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)`);
|
|
8958
8960
|
const tree = await overview(ctx, repo);
|
|
8959
|
-
const consumer = (await findConsumers(ctx, tree,
|
|
8961
|
+
const consumer = (await findConsumers(ctx, tree, TEMPLATES)).find((c) => c.path === tree.path);
|
|
8960
8962
|
if (!consumer)
|
|
8961
|
-
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(", ")}`);
|
|
8962
8964
|
if (consumer.skipped)
|
|
8963
8965
|
throw new Error(`${name}: ${consumer.skipped}`);
|
|
8964
8966
|
consumer.rel = name;
|
|
@@ -8966,11 +8968,11 @@ async function update(ctx, options) {
|
|
|
8966
8968
|
s.rel = s.rel === "." ? name : join7(name, s.rel);
|
|
8967
8969
|
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
8968
8970
|
if (!root)
|
|
8969
|
-
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`);
|
|
8970
8972
|
await preflightForge(ctx);
|
|
8971
|
-
const releases = options.
|
|
8972
|
-
const
|
|
8973
|
-
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);
|
|
8974
8976
|
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
8975
8977
|
const answers = await Promise.all(consumer.sites.map(async (s) => {
|
|
8976
8978
|
const file = join7(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
@@ -8978,18 +8980,18 @@ async function update(ctx, options) {
|
|
|
8978
8980
|
return parseAnswers(onOrigin2 ?? await ctx.readFile(join7(s.path, ANSWERS_FILE)));
|
|
8979
8981
|
}));
|
|
8980
8982
|
const recorded = answers.map((a) => a.commit);
|
|
8981
|
-
if (recorded.every((c) => c ===
|
|
8982
|
-
ctx.say(`\u2022 ${name}: already at ${
|
|
8983
|
+
if (recorded.every((c) => c === version2)) {
|
|
8984
|
+
ctx.say(`\u2022 ${name}: already at ${version2}`);
|
|
8983
8985
|
return summary;
|
|
8984
8986
|
}
|
|
8985
|
-
const past = recorded.find((c) => c &&
|
|
8987
|
+
const past = recorded.find((c) => c && isPlexusVersion(c) && compareVersions(c, version2) > 0);
|
|
8986
8988
|
if (past)
|
|
8987
|
-
throw new Error(`${name} is at ${past}, past ${
|
|
8988
|
-
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);
|
|
8989
8991
|
const onOrigin = await ctx.read("git", ["ls-remote", "--exit-code", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo }).then(() => true).catch(() => false);
|
|
8990
8992
|
if (onOrigin) {
|
|
8991
|
-
const url = await openPullUrl(ctx, consumer, repo,
|
|
8992
|
-
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`);
|
|
8993
8995
|
if (url) {
|
|
8994
8996
|
summary.pulls.push(url);
|
|
8995
8997
|
const body2 = await ctx.read("gh", ["pr", "view", url, "--json", "body", "--jq", ".body"], { cwd: repo }).catch(() => "");
|
|
@@ -8998,21 +9000,21 @@ async function update(ctx, options) {
|
|
|
8998
9000
|
}
|
|
8999
9001
|
return summary;
|
|
9000
9002
|
}
|
|
9001
|
-
const asked = options.
|
|
9003
|
+
const asked = options.to !== void 0 ? `--to ${version2}` : options.now ? "--now" : void 0;
|
|
9002
9004
|
const need = needOf({
|
|
9003
9005
|
recorded,
|
|
9004
9006
|
releases,
|
|
9005
9007
|
asked,
|
|
9006
|
-
stale: asked ? [] : await staleIn(ctx, consumer, repo,
|
|
9008
|
+
stale: asked ? [] : await staleIn(ctx, consumer, repo, version2),
|
|
9007
9009
|
maxAge: options.maxAge ?? maxAgeOf(answers[consumer.sites.indexOf(root)]?.answers ?? {}),
|
|
9008
9010
|
now: options.today === void 0 ? /* @__PURE__ */ new Date() : new Date(options.today)
|
|
9009
9011
|
});
|
|
9010
9012
|
if (!need.take) {
|
|
9011
|
-
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})`);
|
|
9012
9014
|
summary.resting.push({ path: name, reason: need.why });
|
|
9013
9015
|
return summary;
|
|
9014
9016
|
}
|
|
9015
|
-
ctx.say(`\u2022 ${name}: takes ${
|
|
9017
|
+
ctx.say(`\u2022 ${name}: takes ${version2} \u2014 ${need.why}`);
|
|
9016
9018
|
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9017
9019
|
const dir = join7(scratch, name);
|
|
9018
9020
|
try {
|
|
@@ -9025,7 +9027,7 @@ async function update(ctx, options) {
|
|
|
9025
9027
|
summary.failed.push(name);
|
|
9026
9028
|
return summary;
|
|
9027
9029
|
}
|
|
9028
|
-
await
|
|
9030
|
+
await takeVersion(ctx, consumer, dir, { version: version2, ref: version2, opener: "`plx update`", why: need.why }, summary);
|
|
9029
9031
|
} finally {
|
|
9030
9032
|
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
9031
9033
|
if (scratch)
|
|
@@ -9033,10 +9035,10 @@ async function update(ctx, options) {
|
|
|
9033
9035
|
}
|
|
9034
9036
|
return summary;
|
|
9035
9037
|
}
|
|
9036
|
-
async function staleIn(ctx, consumer, repo,
|
|
9037
|
-
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);
|
|
9038
9040
|
if (text === void 0) {
|
|
9039
|
-
ctx.say(` ${consumer.rel}:
|
|
9041
|
+
ctx.say(` ${consumer.rel}: Plexus ${version2} carries no ${MANIFEST_FILE} that can be read; its modules are not checked`);
|
|
9040
9042
|
return [];
|
|
9041
9043
|
}
|
|
9042
9044
|
const catalog = catalogOf(parseManifest(text));
|
|
@@ -9054,28 +9056,28 @@ async function staleIn(ctx, consumer, repo, train) {
|
|
|
9054
9056
|
}
|
|
9055
9057
|
return staleModules(markers, catalog);
|
|
9056
9058
|
}
|
|
9057
|
-
var
|
|
9058
|
-
async function
|
|
9059
|
+
var RELEASES_REPO = `plexus-ms/${COMPENDIUM}`;
|
|
9060
|
+
async function releasesOf(ctx) {
|
|
9059
9061
|
const jq = '.[] | select(.draft | not) | "\\(.tag_name) \\(.published_at)"';
|
|
9060
|
-
const lines = await ctx.read("gh", ["api", `repos/${
|
|
9061
|
-
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 }));
|
|
9062
9064
|
}
|
|
9063
9065
|
function newestOf(releases) {
|
|
9064
|
-
const newest = releases.map((r) => r.
|
|
9066
|
+
const newest = releases.map((r) => r.version).reduce((a, b) => a && compareVersions(a, b) >= 0 ? a : b, "");
|
|
9065
9067
|
if (!newest)
|
|
9066
|
-
throw new Error(`no release of ${
|
|
9068
|
+
throw new Error(`no release of ${RELEASES_REPO} found \u2014 pass the version explicitly (--to <version>)`);
|
|
9067
9069
|
return newest;
|
|
9068
9070
|
}
|
|
9069
9071
|
|
|
9070
9072
|
// ../lib/dist/propagate.js
|
|
9071
9073
|
async function propagate(ctx, options) {
|
|
9072
9074
|
const { dir, ...rest } = options;
|
|
9073
|
-
if (options.
|
|
9074
|
-
throw new UsageError(`'${options.
|
|
9075
|
-
const summary = emptySummary(options.
|
|
9076
|
-
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);
|
|
9077
9079
|
if (consumers.length === 0)
|
|
9078
|
-
ctx.say(`\u2022 no repo generated from ${
|
|
9080
|
+
ctx.say(`\u2022 no repo generated from ${TEMPLATES.map(templateSource).join(", ")} found under ${dir}`);
|
|
9079
9081
|
for (const consumer of consumers) {
|
|
9080
9082
|
if (consumer.skipped) {
|
|
9081
9083
|
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run propagate)`);
|
|
@@ -9085,7 +9087,7 @@ async function propagate(ctx, options) {
|
|
|
9085
9087
|
try {
|
|
9086
9088
|
const one = await update(ctx, { repo: consumer.path, name: consumer.rel, ...rest });
|
|
9087
9089
|
mergeSummary(summary, one);
|
|
9088
|
-
summary.
|
|
9090
|
+
summary.version ||= one.version;
|
|
9089
9091
|
} catch (error) {
|
|
9090
9092
|
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}${detail(error)}`);
|
|
9091
9093
|
summary.failed.push(consumer.rel);
|
|
@@ -14320,18 +14322,18 @@ function annotate(dir, s, modules) {
|
|
|
14320
14322
|
import { resolve as resolve6 } from "node:path";
|
|
14321
14323
|
function register6(program2) {
|
|
14322
14324
|
program2.command("propagate").description(
|
|
14323
|
-
"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"
|
|
14324
14326
|
).argument("[dir]", "a directory the repos sit under, at any depth", ".").option(
|
|
14325
|
-
"--
|
|
14326
|
-
"the
|
|
14327
|
-
).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(
|
|
14328
14330
|
"--max-age <days>",
|
|
14329
|
-
"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)",
|
|
14330
14332
|
(v) => parseMaxAge(v, "--max-age")
|
|
14331
14333
|
).action(async (dir, opts, command) => {
|
|
14332
14334
|
const ctx = contextOf2(command);
|
|
14333
|
-
const result = await propagate(ctx, { dir: resolve6(dir),
|
|
14334
|
-
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(" ");
|
|
14335
14337
|
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
14336
14338
|
if (!isClean(result)) process.exitCode = 1;
|
|
14337
14339
|
});
|
|
@@ -14361,15 +14363,15 @@ function renderCheck(c) {
|
|
|
14361
14363
|
import { resolve as resolve8 } from "node:path";
|
|
14362
14364
|
function register8(program2) {
|
|
14363
14365
|
program2.command("update").description(
|
|
14364
|
-
"bring this repo up to the newest
|
|
14365
|
-
).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(
|
|
14366
14368
|
"--max-age <days>",
|
|
14367
|
-
"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)",
|
|
14368
14370
|
(v) => parseMaxAge(v, "--max-age")
|
|
14369
14371
|
).action(async (dir, opts, command) => {
|
|
14370
14372
|
const ctx = contextOf2(command);
|
|
14371
|
-
const result = await update(ctx, { repo: resolve8(dir),
|
|
14372
|
-
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"));
|
|
14373
14375
|
if (!isClean(result)) process.exitCode = 1;
|
|
14374
14376
|
});
|
|
14375
14377
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexus-ms/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.120.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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/plexus-ms/
|
|
15
|
+
"url": "git+https://github.com/plexus-ms/tooling.git",
|
|
16
16
|
"directory": "packages/cli"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
@@ -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.120.0",
|
|
28
28
|
"commander": "^15.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|