@plexus-ms/cli 0.115.0 → 0.117.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 +576 -318
- package/package.json +2 -2
package/dist/plx.js
CHANGED
|
@@ -7903,7 +7903,166 @@ async function expand(ctx, root, glob) {
|
|
|
7903
7903
|
}
|
|
7904
7904
|
|
|
7905
7905
|
// ../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
|
|
7906
7912
|
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
|
+
|
|
7970
|
+
// ../lib/dist/train.js
|
|
7971
|
+
var PRIMITIVES = "primitives";
|
|
7972
|
+
var COMPENDIUM = "compendium";
|
|
7973
|
+
var TRAIN_REPOS = [
|
|
7974
|
+
PRIMITIVES,
|
|
7975
|
+
"preset-repo-turbo",
|
|
7976
|
+
"preset-app-nextjs",
|
|
7977
|
+
"preset-repo-operations",
|
|
7978
|
+
COMPENDIUM
|
|
7979
|
+
];
|
|
7980
|
+
var PHASES = [[PRIMITIVES], TRAIN_REPOS.filter((r) => r !== PRIMITIVES)];
|
|
7981
|
+
var TRAIN_PACKAGES = [
|
|
7982
|
+
{ name: "@plexus-ms/cli", dir: "packages/cli" },
|
|
7983
|
+
{ name: "@plexus-ms/cli-ci", dir: "packages/cli-ci" },
|
|
7984
|
+
{ name: "@plexus-ms/lib", dir: "packages/lib" },
|
|
7985
|
+
{ name: "@plexus-ms/config", dir: "packages/config" }
|
|
7986
|
+
];
|
|
7987
|
+
var UPSTREAM = "plexus-ms";
|
|
7988
|
+
var isTrainVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
|
|
7989
|
+
function nextMinor(version2) {
|
|
7990
|
+
const [major = "0", minor = "0"] = version2.split(".");
|
|
7991
|
+
return `${major}.${Number(minor) + 1}.0`;
|
|
7992
|
+
}
|
|
7993
|
+
function latestTag(tags) {
|
|
7994
|
+
return tags.filter((t) => /^v?\d+(\.\d+){1,2}$/.test(t)).sort((a, b) => compareTrains(a.replace(/^v/, ""), b.replace(/^v/, ""))).at(-1);
|
|
7995
|
+
}
|
|
7996
|
+
async function readTrain(ctx, upstream) {
|
|
7997
|
+
const repos2 = [];
|
|
7998
|
+
const all = /* @__PURE__ */ new Set();
|
|
7999
|
+
for (const name of TRAIN_REPOS) {
|
|
8000
|
+
const path3 = join3(upstream, name);
|
|
8001
|
+
try {
|
|
8002
|
+
await ctx.read("git", ["rev-parse", "--git-dir"], { cwd: path3 });
|
|
8003
|
+
} catch {
|
|
8004
|
+
throw new Error(`${path3} is not a git repo`);
|
|
8005
|
+
}
|
|
8006
|
+
try {
|
|
8007
|
+
await ctx.read("git", ["fetch", "origin", "--tags", "--quiet"], { cwd: path3 });
|
|
8008
|
+
} catch {
|
|
8009
|
+
throw new Error(`${name}: fetch from origin failed`);
|
|
8010
|
+
}
|
|
8011
|
+
const tags = (await ctx.read("git", ["tag", "--list", "v*", "[0-9]*"], { cwd: path3 })).split("\n").filter(Boolean);
|
|
8012
|
+
for (const t of tags)
|
|
8013
|
+
all.add(t.replace(/^v/, ""));
|
|
8014
|
+
const tag = latestTag(tags);
|
|
8015
|
+
const range = tag ? `${tag}..HEAD` : "HEAD";
|
|
8016
|
+
const pending = (await ctx.read("git", ["log", "--oneline", range], { cwd: path3 })).split("\n").filter(Boolean);
|
|
8017
|
+
repos2.push({ name, path: path3, tag, latest: tag?.replace(/^v/, ""), pending });
|
|
8018
|
+
}
|
|
8019
|
+
const latest = repos2.map((r) => r.latest);
|
|
8020
|
+
return { repos: repos2, last: latestTag([...all]), skew: latest.some((l) => l !== latest[0]) };
|
|
8021
|
+
}
|
|
8022
|
+
var phasesOf = (train) => PHASES.map((names) => train.repos.filter((r) => names.includes(r.name)));
|
|
8023
|
+
async function preflightRelease(ctx, train) {
|
|
8024
|
+
for (const { name, path: path3 } of train.repos) {
|
|
8025
|
+
const branch = (await ctx.read("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: path3 })).trim();
|
|
8026
|
+
if (branch !== "main")
|
|
8027
|
+
throw new Error(`${name} is on '${branch}', trains cut from main`);
|
|
8028
|
+
if ((await ctx.read("git", ["status", "--porcelain"], { cwd: path3 })).trim() !== "")
|
|
8029
|
+
throw new Error(`${name} has uncommitted changes \u2014 commit first`);
|
|
8030
|
+
const behind = (await ctx.read("git", ["rev-list", "--count", "main..origin/main"], { cwd: path3 })).trim();
|
|
8031
|
+
if (behind !== "0")
|
|
8032
|
+
throw new Error(`${name} is ${behind} commit(s) behind origin/main \u2014 pull first, or the tag lands on a stale commit`);
|
|
8033
|
+
}
|
|
8034
|
+
}
|
|
8035
|
+
async function preflightForge(ctx) {
|
|
8036
|
+
try {
|
|
8037
|
+
await ctx.read("gh", ["auth", "status"]);
|
|
8038
|
+
} catch {
|
|
8039
|
+
throw new Error("gh is not logged in (gh auth status failed) \u2014 run gh auth login first");
|
|
8040
|
+
}
|
|
8041
|
+
}
|
|
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
|
+
var UsageError = class extends Error {
|
|
8062
|
+
};
|
|
8063
|
+
|
|
8064
|
+
// ../lib/dist/consumers.js
|
|
8065
|
+
var PRESETS = TRAIN_REPOS.filter((r) => r.startsWith("preset-"));
|
|
7907
8066
|
function expectedBranch(declaration, answers = {}) {
|
|
7908
8067
|
if (!declaration)
|
|
7909
8068
|
return void 0;
|
|
@@ -7935,7 +8094,7 @@ async function findConsumers(ctx, root, presets) {
|
|
|
7935
8094
|
const template = inTemplate || Boolean(dir.template);
|
|
7936
8095
|
const preset = dir.copier?.src ? presetOf(dir.copier.src, presets) : void 0;
|
|
7937
8096
|
if (preset && !template) {
|
|
7938
|
-
const site = { path: dir.path, rel:
|
|
8097
|
+
const site = { path: dir.path, rel: relative2(root.path, dir.path) || ".", preset };
|
|
7939
8098
|
if (!here)
|
|
7940
8099
|
orphans.push(site);
|
|
7941
8100
|
else {
|
|
@@ -7944,7 +8103,7 @@ async function findConsumers(ctx, root, presets) {
|
|
|
7944
8103
|
const expected = expectedBranch(here.declaration, here.copier?.answers);
|
|
7945
8104
|
consumer = {
|
|
7946
8105
|
path: here.path,
|
|
7947
|
-
rel:
|
|
8106
|
+
rel: relative2(root.path, here.path) || ".",
|
|
7948
8107
|
branch: expected ?? here.git?.branch ?? "main",
|
|
7949
8108
|
expected,
|
|
7950
8109
|
sites: []
|
|
@@ -8122,169 +8281,12 @@ function parseAnswers(text) {
|
|
|
8122
8281
|
|
|
8123
8282
|
// ../lib/dist/deploy.js
|
|
8124
8283
|
import { randomBytes } from "node:crypto";
|
|
8125
|
-
import { tmpdir } from "node:os";
|
|
8126
|
-
import { join as join5 } from "node:path";
|
|
8127
|
-
|
|
8128
|
-
// ../lib/dist/deployTargets.js
|
|
8129
|
-
var import_yaml4 = __toESM(require_dist(), 1);
|
|
8130
|
-
import { join as join4 } from "node:path";
|
|
8131
|
-
|
|
8132
|
-
// ../lib/dist/train.js
|
|
8133
|
-
import { join as join3 } from "node:path";
|
|
8134
|
-
|
|
8135
|
-
// ../lib/dist/doctor.js
|
|
8136
|
-
import { relative as relative2 } from "node:path";
|
|
8137
|
-
function diagnose(root, catalog) {
|
|
8138
|
-
const units = collect(root, []);
|
|
8139
|
-
const declarations = units.map((u) => diagnoseUnit(u, units, catalog, root.path));
|
|
8140
|
-
return { declarations, stale: declarations.filter((d) => d.findings.length > 0).length };
|
|
8141
|
-
}
|
|
8142
|
-
function collect(dir, ancestors, parent) {
|
|
8143
|
-
const here = dir.declaration || dir.problems?.some((p) => p.startsWith("PLEXUS.md")) ? [{ dir, ancestors, parent }] : [];
|
|
8144
|
-
const below = dir.declaration ? [...ancestors, dir] : ancestors;
|
|
8145
|
-
return [...here, ...dir.children.flatMap((c) => collect(c, below, dir))];
|
|
8146
|
-
}
|
|
8147
|
-
function diagnoseUnit(unit, units, catalog, root) {
|
|
8148
|
-
const { dir } = unit;
|
|
8149
|
-
const path3 = relative2(root, dir.path) || ".";
|
|
8150
|
-
const problem = dir.problems?.find((p) => p.startsWith("PLEXUS.md"));
|
|
8151
|
-
if (!dir.declaration)
|
|
8152
|
-
return { path: path3, modules: [], findings: [problem?.replace(/^PLEXUS\.md: /, "") ?? "unreadable marker"] };
|
|
8153
|
-
const { plexus, modules } = dir.declaration;
|
|
8154
|
-
const context = new Set(contextOf(unit, units).flatMap((d) => d.declaration?.modules ?? []));
|
|
8155
|
-
const findings = [];
|
|
8156
|
-
for (const code of modules) {
|
|
8157
|
-
const module = catalog.get(code);
|
|
8158
|
-
if (!module) {
|
|
8159
|
-
findings.push(`declares ${code}, which no module carries`);
|
|
8160
|
-
continue;
|
|
8161
|
-
}
|
|
8162
|
-
if (module.changed && compareTrains(module.changed, plexus) > 0)
|
|
8163
|
-
findings.push(`${code} changed in ${module.changed}, declared at ${plexus}`);
|
|
8164
|
-
for (const dep of module.depends)
|
|
8165
|
-
if (!modules.includes(dep) && !context.has(dep))
|
|
8166
|
-
findings.push(`${code} depends on ${dep}, declared neither here nor by an enclosing or contained declaration`);
|
|
8167
|
-
}
|
|
8168
|
-
return { path: path3, plexus, modules, findings };
|
|
8169
|
-
}
|
|
8170
|
-
function contextOf(unit, units) {
|
|
8171
|
-
const { dir, ancestors } = unit;
|
|
8172
|
-
const context = [...ancestors, ...descendants(dir)];
|
|
8173
|
-
const repo = ancestors[0] ?? dir;
|
|
8174
|
-
const repoParent = units.find((u) => u.dir === repo)?.parent;
|
|
8175
|
-
const siblings = repoParent?.children.filter((c) => c !== repo && c.declaration) ?? [];
|
|
8176
|
-
const isTenancy = (d) => d.declaration?.modules.includes("PLX-Tenancy") ?? false;
|
|
8177
|
-
context.push(...siblings.filter(isTenancy));
|
|
8178
|
-
if (isTenancy(dir))
|
|
8179
|
-
context.push(...siblings);
|
|
8180
|
-
return context;
|
|
8181
|
-
}
|
|
8182
|
-
function descendants(dir) {
|
|
8183
|
-
return dir.children.flatMap((c) => [...c.declaration ? [c] : [], ...descendants(c)]);
|
|
8184
|
-
}
|
|
8185
|
-
function compareTrains(a, b) {
|
|
8186
|
-
const nums = (v) => v.split(".").slice(0, 3).map((p) => Number.parseInt(p, 10) || 0);
|
|
8187
|
-
const [x, y] = [nums(a), nums(b)];
|
|
8188
|
-
for (let i = 0; i < 3; i++)
|
|
8189
|
-
if ((x[i] ?? 0) !== (y[i] ?? 0))
|
|
8190
|
-
return (x[i] ?? 0) > (y[i] ?? 0) ? 1 : -1;
|
|
8191
|
-
return 0;
|
|
8192
|
-
}
|
|
8193
|
-
|
|
8194
|
-
// ../lib/dist/train.js
|
|
8195
|
-
var PRIMITIVES = "primitives";
|
|
8196
|
-
var TRAIN_REPOS = [
|
|
8197
|
-
PRIMITIVES,
|
|
8198
|
-
"preset-repo-turbo",
|
|
8199
|
-
"preset-app-nextjs",
|
|
8200
|
-
"preset-repo-operations",
|
|
8201
|
-
"compendium"
|
|
8202
|
-
];
|
|
8203
|
-
var PHASES = [[PRIMITIVES], TRAIN_REPOS.filter((r) => r !== PRIMITIVES)];
|
|
8204
|
-
var TRAIN_PACKAGES = [
|
|
8205
|
-
{ name: "@plexus-ms/cli", dir: "packages/cli" },
|
|
8206
|
-
{ name: "@plexus-ms/cli-ci", dir: "packages/cli-ci" },
|
|
8207
|
-
{ name: "@plexus-ms/lib", dir: "packages/lib" },
|
|
8208
|
-
{ name: "@plexus-ms/config", dir: "packages/config" }
|
|
8209
|
-
];
|
|
8210
|
-
var UPSTREAM = "plexus-ms";
|
|
8211
|
-
var isTrainVersion = (v) => /^\d+\.\d+\.\d+$/.test(v);
|
|
8212
|
-
function nextMinor(version2) {
|
|
8213
|
-
const [major = "0", minor = "0"] = version2.split(".");
|
|
8214
|
-
return `${major}.${Number(minor) + 1}.0`;
|
|
8215
|
-
}
|
|
8216
|
-
function latestTag(tags) {
|
|
8217
|
-
return tags.filter((t) => /^v?\d+(\.\d+){1,2}$/.test(t)).sort((a, b) => compareTrains(a.replace(/^v/, ""), b.replace(/^v/, ""))).at(-1);
|
|
8218
|
-
}
|
|
8219
|
-
async function readTrain(ctx, upstream) {
|
|
8220
|
-
const repos2 = [];
|
|
8221
|
-
const all = /* @__PURE__ */ new Set();
|
|
8222
|
-
for (const name of TRAIN_REPOS) {
|
|
8223
|
-
const path3 = join3(upstream, name);
|
|
8224
|
-
try {
|
|
8225
|
-
await ctx.read("git", ["rev-parse", "--git-dir"], { cwd: path3 });
|
|
8226
|
-
} catch {
|
|
8227
|
-
throw new Error(`${path3} is not a git repo`);
|
|
8228
|
-
}
|
|
8229
|
-
try {
|
|
8230
|
-
await ctx.read("git", ["fetch", "origin", "--tags", "--quiet"], { cwd: path3 });
|
|
8231
|
-
} catch {
|
|
8232
|
-
throw new Error(`${name}: fetch from origin failed`);
|
|
8233
|
-
}
|
|
8234
|
-
const tags = (await ctx.read("git", ["tag", "--list", "v*", "[0-9]*"], { cwd: path3 })).split("\n").filter(Boolean);
|
|
8235
|
-
for (const t of tags)
|
|
8236
|
-
all.add(t.replace(/^v/, ""));
|
|
8237
|
-
const tag = latestTag(tags);
|
|
8238
|
-
const range = tag ? `${tag}..HEAD` : "HEAD";
|
|
8239
|
-
const pending = (await ctx.read("git", ["log", "--oneline", range], { cwd: path3 })).split("\n").filter(Boolean);
|
|
8240
|
-
repos2.push({ name, path: path3, tag, latest: tag?.replace(/^v/, ""), pending });
|
|
8241
|
-
}
|
|
8242
|
-
const latest = repos2.map((r) => r.latest);
|
|
8243
|
-
return { repos: repos2, last: latestTag([...all]), skew: latest.some((l) => l !== latest[0]) };
|
|
8244
|
-
}
|
|
8245
|
-
var phasesOf = (train) => PHASES.map((names) => train.repos.filter((r) => names.includes(r.name)));
|
|
8246
|
-
async function preflightRelease(ctx, train) {
|
|
8247
|
-
for (const { name, path: path3 } of train.repos) {
|
|
8248
|
-
const branch = (await ctx.read("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: path3 })).trim();
|
|
8249
|
-
if (branch !== "main")
|
|
8250
|
-
throw new Error(`${name} is on '${branch}', trains cut from main`);
|
|
8251
|
-
if ((await ctx.read("git", ["status", "--porcelain"], { cwd: path3 })).trim() !== "")
|
|
8252
|
-
throw new Error(`${name} has uncommitted changes \u2014 commit first`);
|
|
8253
|
-
const behind = (await ctx.read("git", ["rev-list", "--count", "main..origin/main"], { cwd: path3 })).trim();
|
|
8254
|
-
if (behind !== "0")
|
|
8255
|
-
throw new Error(`${name} is ${behind} commit(s) behind origin/main \u2014 pull first, or the tag lands on a stale commit`);
|
|
8256
|
-
}
|
|
8257
|
-
}
|
|
8258
|
-
async function preflightForge(ctx) {
|
|
8259
|
-
try {
|
|
8260
|
-
await ctx.read("gh", ["auth", "status"]);
|
|
8261
|
-
} catch {
|
|
8262
|
-
throw new Error("gh is not logged in (gh auth status failed) \u2014 run gh auth login first");
|
|
8263
|
-
}
|
|
8264
|
-
}
|
|
8265
|
-
function resolveVersion(train, explicit, propagateOnly) {
|
|
8266
|
-
if (explicit !== void 0 && !isTrainVersion(explicit))
|
|
8267
|
-
throw new UsageError(`'${explicit}' is not plain semver (X.Y.Z, no v)`);
|
|
8268
|
-
if (propagateOnly) {
|
|
8269
|
-
const v = explicit ?? train.last;
|
|
8270
|
-
if (!v)
|
|
8271
|
-
throw new Error("no train version found to propagate");
|
|
8272
|
-
return v;
|
|
8273
|
-
}
|
|
8274
|
-
if (explicit)
|
|
8275
|
-
return explicit;
|
|
8276
|
-
if (train.skew) {
|
|
8277
|
-
const report = train.repos.map((r) => ` ${r.name}: ${r.latest ?? "none"}`).join("\n");
|
|
8278
|
-
throw new Error(`the train repos' latest tags disagree:
|
|
8279
|
-
${report}
|
|
8280
|
-
pass the version explicitly (--train ${train.last}) to finish the half-tagged train, or a higher one to start a new one`);
|
|
8281
|
-
}
|
|
8282
|
-
return train.last ? nextMinor(train.last) : "0.1.0";
|
|
8283
|
-
}
|
|
8284
|
-
var UsageError = class extends Error {
|
|
8285
|
-
};
|
|
8284
|
+
import { tmpdir } from "node:os";
|
|
8285
|
+
import { join as join5 } from "node:path";
|
|
8286
8286
|
|
|
8287
8287
|
// ../lib/dist/deployTargets.js
|
|
8288
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
8289
|
+
import { join as join4 } from "node:path";
|
|
8288
8290
|
var VARS_DIRS = ["group_vars", "host_vars"];
|
|
8289
8291
|
var DEFAULT_ENVIRONMENT = "production";
|
|
8290
8292
|
function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
|
|
@@ -8555,6 +8557,61 @@ async function resolveHealthUrl(remote, D, dc, ctx) {
|
|
|
8555
8557
|
return url;
|
|
8556
8558
|
}
|
|
8557
8559
|
|
|
8560
|
+
// ../lib/dist/manifest.js
|
|
8561
|
+
var MANIFEST_FILE = "train.json";
|
|
8562
|
+
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
|
+
var catalogOf = (manifest2) => new Map(manifest2.modules.map((m) => [m.code, m]));
|
|
8570
|
+
var strings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
8571
|
+
function parseManifest(text) {
|
|
8572
|
+
let data;
|
|
8573
|
+
try {
|
|
8574
|
+
data = JSON.parse(text);
|
|
8575
|
+
} catch {
|
|
8576
|
+
throw new Error("the train manifest is not JSON");
|
|
8577
|
+
}
|
|
8578
|
+
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
8579
|
+
throw new Error("the train manifest is not an object");
|
|
8580
|
+
const { schema, train, date, modules } = data;
|
|
8581
|
+
if (schema !== MANIFEST_SCHEMA)
|
|
8582
|
+
throw new Error(`the train manifest has schema ${JSON.stringify(schema)}; this plx reads ${MANIFEST_SCHEMA}`);
|
|
8583
|
+
if (typeof train !== "string" || !isTrainVersion(train))
|
|
8584
|
+
throw new Error(`the train manifest names '${String(train)}', not a train`);
|
|
8585
|
+
if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(date))
|
|
8586
|
+
throw new Error(`the train manifest is dated '${String(date)}', not YYYY-MM-DD`);
|
|
8587
|
+
if (!Array.isArray(modules))
|
|
8588
|
+
throw new Error("the train manifest lists no modules");
|
|
8589
|
+
return { schema: MANIFEST_SCHEMA, train, date, modules: modules.map(parseEntry) };
|
|
8590
|
+
}
|
|
8591
|
+
function parseEntry(entry) {
|
|
8592
|
+
const m = entry ?? {};
|
|
8593
|
+
const where = `the train manifest's module ${typeof m.code === "string" ? m.code : JSON.stringify(entry)}`;
|
|
8594
|
+
if (typeof m.code !== "string" || m.code === "")
|
|
8595
|
+
throw new Error(`${where} has no code`);
|
|
8596
|
+
if (m.kind !== "contract" && m.kind !== "approach")
|
|
8597
|
+
throw new Error(`${where} is neither contract nor approach`);
|
|
8598
|
+
if (typeof m.maturity !== "string" || typeof m.binds !== "string")
|
|
8599
|
+
throw new Error(`${where} lacks maturity or binds`);
|
|
8600
|
+
if (!strings(m.depends) || !strings(m.consumes))
|
|
8601
|
+
throw new Error(`${where} lacks depends or consumes`);
|
|
8602
|
+
if (m.changed !== void 0 && typeof m.changed !== "string")
|
|
8603
|
+
throw new Error(`${where} has a changed that is no train`);
|
|
8604
|
+
return {
|
|
8605
|
+
code: m.code,
|
|
8606
|
+
kind: m.kind,
|
|
8607
|
+
maturity: m.maturity,
|
|
8608
|
+
binds: m.binds,
|
|
8609
|
+
changed: m.changed,
|
|
8610
|
+
depends: m.depends,
|
|
8611
|
+
consumes: m.consumes
|
|
8612
|
+
};
|
|
8613
|
+
}
|
|
8614
|
+
|
|
8558
8615
|
// ../lib/dist/model.js
|
|
8559
8616
|
function kindOf(declaration) {
|
|
8560
8617
|
const has = (code) => declaration.modules.includes(code);
|
|
@@ -8575,6 +8632,74 @@ function isNotable(dir) {
|
|
|
8575
8632
|
return Boolean(dir.git || dir.template || dir.copier || dir.declaration || dir.problems?.length);
|
|
8576
8633
|
}
|
|
8577
8634
|
|
|
8635
|
+
// ../lib/dist/need.js
|
|
8636
|
+
var DEFAULT_MAX_AGE = 30;
|
|
8637
|
+
var MAX_AGE_ANSWER = "update_max_age";
|
|
8638
|
+
var DAY = 24 * 60 * 60 * 1e3;
|
|
8639
|
+
var days = (n) => `${n} day${n === 1 ? "" : "s"}`;
|
|
8640
|
+
function needOf({ recorded, releases, asked, stale = [], maxAge, now }) {
|
|
8641
|
+
if (asked)
|
|
8642
|
+
return { take: true, trigger: "asked", why: `asked for (${asked})` };
|
|
8643
|
+
const [first, ...more] = stale;
|
|
8644
|
+
if (first)
|
|
8645
|
+
return {
|
|
8646
|
+
take: true,
|
|
8647
|
+
trigger: "module",
|
|
8648
|
+
why: `${first.code} changed in ${first.changed}, declared at ${first.declared} in ${first.where}${more.length > 0 ? `, and ${more.length} more` : ""}`
|
|
8649
|
+
};
|
|
8650
|
+
const odd = recorded.findIndex((r) => !r || !isTrainVersion(r));
|
|
8651
|
+
if (recorded.length === 0 || odd >= 0)
|
|
8652
|
+
return {
|
|
8653
|
+
take: true,
|
|
8654
|
+
trigger: "backstop",
|
|
8655
|
+
why: `a site records ${recorded[odd] ? `'${recorded[odd]}'` : "no version"}, not a train`
|
|
8656
|
+
};
|
|
8657
|
+
const trains2 = recorded;
|
|
8658
|
+
const oldest = trains2.reduce((a, b) => compareTrains(a, b) <= 0 ? a : b);
|
|
8659
|
+
const untaken = releases.filter((r) => isTrainVersion(r.train) && compareTrains(r.train, oldest) > 0).sort((a, b) => Date.parse(a.published) - Date.parse(b.published));
|
|
8660
|
+
const oldestUntaken = untaken[0];
|
|
8661
|
+
if (!oldestUntaken)
|
|
8662
|
+
return { take: false, why: `no train newer than ${oldest}` };
|
|
8663
|
+
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(oldestUntaken.published)) / DAY));
|
|
8664
|
+
const count = `${untaken.length} newer train${untaken.length === 1 ? "" : "s"}`;
|
|
8665
|
+
if (maxAge === 0)
|
|
8666
|
+
return { take: true, trigger: "backstop", why: `a backstop age of zero takes every train (${count})` };
|
|
8667
|
+
if (age >= maxAge)
|
|
8668
|
+
return {
|
|
8669
|
+
take: true,
|
|
8670
|
+
trigger: "backstop",
|
|
8671
|
+
why: `${oldestUntaken.train}, the oldest train not taken, was cut ${days(age)} ago (backstop: ${days(maxAge)}; ${count})`
|
|
8672
|
+
};
|
|
8673
|
+
return {
|
|
8674
|
+
take: false,
|
|
8675
|
+
why: `${count}, the oldest (${oldestUntaken.train}) cut ${days(age)} ago; the backstop is ${days(maxAge)}`
|
|
8676
|
+
};
|
|
8677
|
+
}
|
|
8678
|
+
function staleModules(markers, catalog) {
|
|
8679
|
+
const stale = [];
|
|
8680
|
+
for (const { where, plexus, modules } of markers) {
|
|
8681
|
+
if (!isTrainVersion(plexus))
|
|
8682
|
+
continue;
|
|
8683
|
+
for (const code of modules) {
|
|
8684
|
+
const changed = catalog.get(code)?.changed;
|
|
8685
|
+
if (changed && isTrainVersion(changed) && compareTrains(changed, plexus) > 0)
|
|
8686
|
+
stale.push({ code, changed, where, declared: plexus });
|
|
8687
|
+
}
|
|
8688
|
+
}
|
|
8689
|
+
return stale;
|
|
8690
|
+
}
|
|
8691
|
+
function maxAgeOf(answers) {
|
|
8692
|
+
const value = answers[MAX_AGE_ANSWER];
|
|
8693
|
+
if (value === void 0 || value === null || value === "")
|
|
8694
|
+
return DEFAULT_MAX_AGE;
|
|
8695
|
+
return parseMaxAge(String(value), `the answer ${MAX_AGE_ANSWER}`);
|
|
8696
|
+
}
|
|
8697
|
+
function parseMaxAge(value, what) {
|
|
8698
|
+
if (!/^\d+$/.test(value.trim()))
|
|
8699
|
+
throw new Error(`${what} is '${value}', not a whole number of days`);
|
|
8700
|
+
return Number(value.trim());
|
|
8701
|
+
}
|
|
8702
|
+
|
|
8578
8703
|
// ../lib/dist/overview.js
|
|
8579
8704
|
import { join as join6 } from "node:path";
|
|
8580
8705
|
var PRUNED = /* @__PURE__ */ new Set([
|
|
@@ -8703,9 +8828,20 @@ async function templateFacet(ctx, cwd) {
|
|
|
8703
8828
|
return tag ? { tag } : {};
|
|
8704
8829
|
}
|
|
8705
8830
|
|
|
8706
|
-
// ../lib/dist/
|
|
8831
|
+
// ../lib/dist/preview.js
|
|
8832
|
+
import { join as join8 } from "node:path";
|
|
8833
|
+
|
|
8834
|
+
// ../lib/dist/take.js
|
|
8707
8835
|
import { join as join7, relative as relative3 } from "node:path";
|
|
8708
8836
|
var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
|
|
8837
|
+
function mergeSummary(into, from) {
|
|
8838
|
+
into.clean.push(...from.clean);
|
|
8839
|
+
into.conflicted.push(...from.conflicted);
|
|
8840
|
+
into.failed.push(...from.failed);
|
|
8841
|
+
into.skipped.push(...from.skipped);
|
|
8842
|
+
into.resting.push(...from.resting);
|
|
8843
|
+
into.pulls.push(...from.pulls);
|
|
8844
|
+
}
|
|
8709
8845
|
var emptySummary = (train, preview) => ({
|
|
8710
8846
|
train,
|
|
8711
8847
|
preview,
|
|
@@ -8713,6 +8849,7 @@ var emptySummary = (train, preview) => ({
|
|
|
8713
8849
|
conflicted: [],
|
|
8714
8850
|
failed: [],
|
|
8715
8851
|
skipped: [],
|
|
8852
|
+
resting: [],
|
|
8716
8853
|
pulls: []
|
|
8717
8854
|
});
|
|
8718
8855
|
var trainBranch = (train) => `plexus/${train}`;
|
|
@@ -8720,45 +8857,6 @@ var copierIn = (dir, args) => [
|
|
|
8720
8857
|
"env",
|
|
8721
8858
|
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, "mise", ...copierVia(args)]
|
|
8722
8859
|
];
|
|
8723
|
-
async function propagate(ctx, workspace, train) {
|
|
8724
|
-
const summary = emptySummary(train, ctx.dryRun);
|
|
8725
|
-
const upstream = join7(workspace, UPSTREAM);
|
|
8726
|
-
const tree = await overview(ctx, workspace);
|
|
8727
|
-
const upstreamDir = tree.children.find((c) => c.path === upstream);
|
|
8728
|
-
const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
|
|
8729
|
-
const consumers = await findConsumers(ctx, tree, presets);
|
|
8730
|
-
for (const c of consumers) {
|
|
8731
|
-
if (!c.skipped)
|
|
8732
|
-
continue;
|
|
8733
|
-
ctx.say(`\u26A0 ${c.rel}: ${c.skipped} \u2014 skipped (fix it, then re-run propagate)`);
|
|
8734
|
-
summary.skipped.push({ path: c.rel, reason: c.skipped });
|
|
8735
|
-
}
|
|
8736
|
-
for (const preset of presets)
|
|
8737
|
-
if (!consumers.some((c) => c.sites.some((s) => s.preset === preset)))
|
|
8738
|
-
ctx.say(`\u2022 no consumers of ${presetSource(preset)} found under ${workspace}`);
|
|
8739
|
-
const take = { train, opener: "`plx ship`", ...ctx.dryRun ? { previewFrom: upstream } : {} };
|
|
8740
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
8741
|
-
try {
|
|
8742
|
-
for (const consumer of consumers) {
|
|
8743
|
-
if (consumer.skipped || !consumer.origin)
|
|
8744
|
-
continue;
|
|
8745
|
-
const clone = join7(scratch, consumer.rel);
|
|
8746
|
-
ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
|
|
8747
|
-
try {
|
|
8748
|
-
await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
|
|
8749
|
-
} catch (error) {
|
|
8750
|
-
ctx.say(` \u2717 FAILED \u2014 clone${detail(error)}`);
|
|
8751
|
-
summary.failed.push(consumer.rel);
|
|
8752
|
-
continue;
|
|
8753
|
-
}
|
|
8754
|
-
await takeTrain(ctx, consumer, clone, take, summary);
|
|
8755
|
-
}
|
|
8756
|
-
} finally {
|
|
8757
|
-
if (scratch)
|
|
8758
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
8759
|
-
}
|
|
8760
|
-
return summary;
|
|
8761
|
-
}
|
|
8762
8860
|
async function takeTrain(ctx, consumer, dir, take, summary) {
|
|
8763
8861
|
const base = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim();
|
|
8764
8862
|
for (const site of consumer.sites)
|
|
@@ -8931,7 +9029,7 @@ async function openPull(ctx, consumer, dir, take, summary) {
|
|
|
8931
9029
|
const body2 = [
|
|
8932
9030
|
`Train ${train} (\xA7 1.5 PLX): \`copier update\` at ${sites.join(", ")}, the marker, the lockfile where manifests moved, and the workflow refs.`,
|
|
8933
9031
|
conflicted.length > 0 ? `Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.` : "Merged clean at every site.",
|
|
8934
|
-
`Opened by ${take.opener}.`
|
|
9032
|
+
`Opened by ${take.opener}${take.why ? `: ${take.why}` : ""}.`
|
|
8935
9033
|
].join("\n\n");
|
|
8936
9034
|
try {
|
|
8937
9035
|
await ctx.apply([
|
|
@@ -8963,8 +9061,191 @@ var detail = (error) => {
|
|
|
8963
9061
|
return last && !/exited with/.test(last) ? `: ${last}` : "";
|
|
8964
9062
|
};
|
|
8965
9063
|
|
|
9064
|
+
// ../lib/dist/preview.js
|
|
9065
|
+
async function previewConsumers(ctx, workspace, train) {
|
|
9066
|
+
const summary = emptySummary(train, ctx.dryRun);
|
|
9067
|
+
const upstream = join8(workspace, UPSTREAM);
|
|
9068
|
+
const tree = await overview(ctx, workspace);
|
|
9069
|
+
const upstreamDir = tree.children.find((c) => c.path === upstream);
|
|
9070
|
+
const presets = TRAIN_REPOS.filter((r) => upstreamDir?.children.some((c) => c.name === r && c.template));
|
|
9071
|
+
const consumers = await findConsumers(ctx, tree, presets);
|
|
9072
|
+
for (const c of consumers) {
|
|
9073
|
+
if (!c.skipped)
|
|
9074
|
+
continue;
|
|
9075
|
+
ctx.say(`\u26A0 ${c.rel}: ${c.skipped} \u2014 not previewed`);
|
|
9076
|
+
summary.skipped.push({ path: c.rel, reason: c.skipped });
|
|
9077
|
+
}
|
|
9078
|
+
for (const preset of presets)
|
|
9079
|
+
if (!consumers.some((c) => c.sites.some((s) => s.preset === preset)))
|
|
9080
|
+
ctx.say(`\u2022 no consumers of ${presetSource(preset)} found under ${workspace}`);
|
|
9081
|
+
const take = { train, opener: "`plx ship`", previewFrom: upstream };
|
|
9082
|
+
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9083
|
+
try {
|
|
9084
|
+
for (const consumer of consumers) {
|
|
9085
|
+
if (consumer.skipped || !consumer.origin)
|
|
9086
|
+
continue;
|
|
9087
|
+
const clone = join8(scratch, consumer.rel);
|
|
9088
|
+
ctx.say(`\u2192 ${consumer.rel}: clone ${consumer.origin} at ${consumer.branch}`);
|
|
9089
|
+
try {
|
|
9090
|
+
await ctx.stage(run("git", ["clone", "--quiet", "--branch", consumer.branch, consumer.origin, clone]));
|
|
9091
|
+
} catch (error) {
|
|
9092
|
+
ctx.say(` \u2717 FAILED \u2014 clone${detail(error)}`);
|
|
9093
|
+
summary.failed.push(consumer.rel);
|
|
9094
|
+
continue;
|
|
9095
|
+
}
|
|
9096
|
+
await takeTrain(ctx, consumer, clone, take, summary);
|
|
9097
|
+
}
|
|
9098
|
+
} finally {
|
|
9099
|
+
if (scratch)
|
|
9100
|
+
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9101
|
+
}
|
|
9102
|
+
return summary;
|
|
9103
|
+
}
|
|
9104
|
+
|
|
9105
|
+
// ../lib/dist/update.js
|
|
9106
|
+
import { basename, join as join9, relative as relative4 } from "node:path";
|
|
9107
|
+
async function update(ctx, options) {
|
|
9108
|
+
const { repo } = options;
|
|
9109
|
+
const name = options.name ?? basename(repo);
|
|
9110
|
+
if (options.train !== void 0 && !isTrainVersion(options.train))
|
|
9111
|
+
throw new UsageError(`'${options.train}' is not plain semver (X.Y.Z, no v)`);
|
|
9112
|
+
const tree = await overview(ctx, repo);
|
|
9113
|
+
const consumer = (await findConsumers(ctx, tree, PRESETS)).find((c) => c.path === tree.path);
|
|
9114
|
+
if (!consumer)
|
|
9115
|
+
throw new Error(`${repo} is not a repo generated from the presets: no ${ANSWERS_FILE} at its root naming one of ${PRESETS.map(presetSource).join(", ")}`);
|
|
9116
|
+
if (consumer.skipped)
|
|
9117
|
+
throw new Error(`${name}: ${consumer.skipped}`);
|
|
9118
|
+
consumer.rel = name;
|
|
9119
|
+
for (const s of consumer.sites)
|
|
9120
|
+
s.rel = s.rel === "." ? name : join9(name, s.rel);
|
|
9121
|
+
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
9122
|
+
if (!root)
|
|
9123
|
+
throw new Error(`${name}: its root is not a site of a repo preset`);
|
|
9124
|
+
await preflightForge(ctx);
|
|
9125
|
+
const releases = options.train === void 0 ? await trains(ctx) : [];
|
|
9126
|
+
const train = options.train ?? newestOf(releases);
|
|
9127
|
+
const summary = emptySummary(train, ctx.dryRun);
|
|
9128
|
+
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
9129
|
+
const answers = await Promise.all(consumer.sites.map(async (s) => {
|
|
9130
|
+
const file = join9(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
9131
|
+
const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
|
|
9132
|
+
return parseAnswers(onOrigin2 ?? await ctx.readFile(join9(s.path, ANSWERS_FILE)));
|
|
9133
|
+
}));
|
|
9134
|
+
const recorded = answers.map((a) => a.commit);
|
|
9135
|
+
if (recorded.every((c) => c === train)) {
|
|
9136
|
+
ctx.say(`\u2022 ${name}: already at ${train}`);
|
|
9137
|
+
return summary;
|
|
9138
|
+
}
|
|
9139
|
+
const past = recorded.find((c) => c && isTrainVersion(c) && compareTrains(c, train) > 0);
|
|
9140
|
+
if (past)
|
|
9141
|
+
throw new Error(`${name} is at ${past}, past ${train}; a repo is never taken back to an older train`);
|
|
9142
|
+
const branch = trainBranch(train);
|
|
9143
|
+
const onOrigin = await ctx.read("git", ["ls-remote", "--exit-code", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo }).then(() => true).catch(() => false);
|
|
9144
|
+
if (onOrigin) {
|
|
9145
|
+
const url = await openPullUrl(ctx, consumer, repo, train);
|
|
9146
|
+
ctx.say(`\u2022 ${name}: ${branch} is already on origin${url ? ` (${url})` : ""} \u2014 nothing to do; delete the branch to pull the train again`);
|
|
9147
|
+
if (url)
|
|
9148
|
+
summary.pulls.push(url);
|
|
9149
|
+
return summary;
|
|
9150
|
+
}
|
|
9151
|
+
const asked = options.train !== void 0 ? `--train ${train}` : options.now ? "--now" : void 0;
|
|
9152
|
+
const need = needOf({
|
|
9153
|
+
recorded,
|
|
9154
|
+
releases,
|
|
9155
|
+
asked,
|
|
9156
|
+
stale: asked ? [] : await staleIn(ctx, consumer, repo, train),
|
|
9157
|
+
maxAge: options.maxAge ?? maxAgeOf(answers[consumer.sites.indexOf(root)]?.answers ?? {}),
|
|
9158
|
+
now: options.today === void 0 ? /* @__PURE__ */ new Date() : new Date(options.today)
|
|
9159
|
+
});
|
|
9160
|
+
if (!need.take) {
|
|
9161
|
+
ctx.say(`\u2022 ${name}: rests \u2014 ${need.why} (plx update --now takes ${train})`);
|
|
9162
|
+
summary.resting.push({ path: name, reason: need.why });
|
|
9163
|
+
return summary;
|
|
9164
|
+
}
|
|
9165
|
+
ctx.say(`\u2022 ${name}: takes ${train} \u2014 ${need.why}`);
|
|
9166
|
+
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9167
|
+
const dir = join9(scratch, name);
|
|
9168
|
+
try {
|
|
9169
|
+
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
9170
|
+
try {
|
|
9171
|
+
await ctx.stage(run("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }));
|
|
9172
|
+
await ctx.stage(run("git", ["worktree", "add", "--quiet", "--detach", dir, `origin/${consumer.branch}`], { cwd: repo }));
|
|
9173
|
+
} catch (error) {
|
|
9174
|
+
ctx.say(` \u2717 FAILED \u2014 worktree of origin/${consumer.branch}${detail(error)}`);
|
|
9175
|
+
summary.failed.push(name);
|
|
9176
|
+
return summary;
|
|
9177
|
+
}
|
|
9178
|
+
await takeTrain(ctx, consumer, dir, { train, ref: train, opener: "`plx update`", why: need.why }, summary);
|
|
9179
|
+
} finally {
|
|
9180
|
+
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
9181
|
+
if (scratch)
|
|
9182
|
+
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9183
|
+
}
|
|
9184
|
+
return summary;
|
|
9185
|
+
}
|
|
9186
|
+
async function staleIn(ctx, consumer, repo, train) {
|
|
9187
|
+
const text = await ctx.read("gh", ["release", "download", train, "-R", TRAINS, "-p", MANIFEST_FILE, "-O", "-"]).catch(() => void 0);
|
|
9188
|
+
if (text === void 0) {
|
|
9189
|
+
ctx.say(` ${consumer.rel}: train ${train} carries no ${MANIFEST_FILE} that can be read; its modules are not checked`);
|
|
9190
|
+
return [];
|
|
9191
|
+
}
|
|
9192
|
+
const catalog = catalogOf(parseManifest(text));
|
|
9193
|
+
const markers = [];
|
|
9194
|
+
for (const site of consumer.sites) {
|
|
9195
|
+
const file = join9(relative4(consumer.path, site.path), MARKER_FILE);
|
|
9196
|
+
const marker = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0) ?? await ctx.readFile(join9(site.path, MARKER_FILE)).catch(() => void 0);
|
|
9197
|
+
if (marker === void 0)
|
|
9198
|
+
continue;
|
|
9199
|
+
try {
|
|
9200
|
+
const { plexus, modules } = parseMarker(marker);
|
|
9201
|
+
markers.push({ where: join9(site.rel, MARKER_FILE), plexus, modules });
|
|
9202
|
+
} catch {
|
|
9203
|
+
}
|
|
9204
|
+
}
|
|
9205
|
+
return staleModules(markers, catalog);
|
|
9206
|
+
}
|
|
9207
|
+
var TRAINS = `plexus-ms/${COMPENDIUM}`;
|
|
9208
|
+
async function trains(ctx) {
|
|
9209
|
+
const jq = '.[] | select(.draft | not) | "\\(.tag_name) \\(.published_at)"';
|
|
9210
|
+
const lines = await ctx.read("gh", ["api", `repos/${TRAINS}/releases`, "--paginate", "--jq", jq]).catch(() => "");
|
|
9211
|
+
return lines.split("\n").map((l) => l.trim().split(/\s+/)).filter((p) => p.length === 2 && isTrainVersion(p[0] ?? "")).map(([train, published]) => ({ train, published }));
|
|
9212
|
+
}
|
|
9213
|
+
function newestOf(releases) {
|
|
9214
|
+
const newest = releases.map((r) => r.train).reduce((a, b) => a && compareTrains(a, b) >= 0 ? a : b, "");
|
|
9215
|
+
if (!newest)
|
|
9216
|
+
throw new Error(`no release of ${TRAINS} found \u2014 pass the train explicitly (--train <version>)`);
|
|
9217
|
+
return newest;
|
|
9218
|
+
}
|
|
9219
|
+
|
|
9220
|
+
// ../lib/dist/propagate.js
|
|
9221
|
+
async function propagate(ctx, options) {
|
|
9222
|
+
const { dir, ...rest } = options;
|
|
9223
|
+
if (options.train !== void 0 && !isTrainVersion(options.train))
|
|
9224
|
+
throw new UsageError(`'${options.train}' is not plain semver (X.Y.Z, no v)`);
|
|
9225
|
+
const summary = emptySummary(options.train ?? "", ctx.dryRun);
|
|
9226
|
+
const consumers = await findConsumers(ctx, await overview(ctx, dir), PRESETS);
|
|
9227
|
+
if (consumers.length === 0)
|
|
9228
|
+
ctx.say(`\u2022 no repo generated from ${PRESETS.map(presetSource).join(", ")} found under ${dir}`);
|
|
9229
|
+
for (const consumer of consumers) {
|
|
9230
|
+
if (consumer.skipped) {
|
|
9231
|
+
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run propagate)`);
|
|
9232
|
+
summary.skipped.push({ path: consumer.rel, reason: consumer.skipped });
|
|
9233
|
+
continue;
|
|
9234
|
+
}
|
|
9235
|
+
try {
|
|
9236
|
+
const one = await update(ctx, { repo: consumer.path, name: consumer.rel, ...rest });
|
|
9237
|
+
mergeSummary(summary, one);
|
|
9238
|
+
summary.train ||= one.train;
|
|
9239
|
+
} catch (error) {
|
|
9240
|
+
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}${detail(error)}`);
|
|
9241
|
+
summary.failed.push(consumer.rel);
|
|
9242
|
+
}
|
|
9243
|
+
}
|
|
9244
|
+
return summary;
|
|
9245
|
+
}
|
|
9246
|
+
|
|
8966
9247
|
// ../lib/dist/requirements.js
|
|
8967
|
-
import { join as
|
|
9248
|
+
import { join as join10 } from "node:path";
|
|
8968
9249
|
var KEYWORD = /MUST|SHOULD|MAY/;
|
|
8969
9250
|
var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
|
|
8970
9251
|
var list = (value) => value.replace(/^\s*\[/, "").replace(/\].*$/, "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -9057,7 +9338,7 @@ var MAP_PAGE = "essentials/standard.md";
|
|
|
9057
9338
|
async function modulePages(ctx, compendium) {
|
|
9058
9339
|
const pages = [];
|
|
9059
9340
|
for (const dir of Object.keys(CATALOG_DIRS)) {
|
|
9060
|
-
const entries = await ctx.readDir(
|
|
9341
|
+
const entries = await ctx.readDir(join10(compendium, dir));
|
|
9061
9342
|
for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
|
|
9062
9343
|
pages.push(`${dir}/${e.name}`);
|
|
9063
9344
|
}
|
|
@@ -9065,11 +9346,11 @@ async function modulePages(ctx, compendium) {
|
|
|
9065
9346
|
}
|
|
9066
9347
|
async function checkCompendium(ctx, compendium) {
|
|
9067
9348
|
const defects = [];
|
|
9068
|
-
defects.push(...scanPage(await ctx.readFile(
|
|
9349
|
+
defects.push(...scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
|
|
9069
9350
|
const pages = await modulePages(ctx, compendium);
|
|
9070
9351
|
const scans = /* @__PURE__ */ new Map();
|
|
9071
9352
|
for (const page of pages) {
|
|
9072
|
-
const scan = scanPage(await ctx.readFile(
|
|
9353
|
+
const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
|
|
9073
9354
|
defects.push(...scan.defects);
|
|
9074
9355
|
scans.set(page, scan);
|
|
9075
9356
|
}
|
|
@@ -9128,24 +9409,22 @@ async function preflightSelf(ctx, running) {
|
|
|
9128
9409
|
}
|
|
9129
9410
|
|
|
9130
9411
|
// ../lib/dist/ship.js
|
|
9131
|
-
import { join as
|
|
9412
|
+
import { join as join11 } from "node:path";
|
|
9132
9413
|
var DEFAULT_WAIT = { interval: 15e3, timeout: 20 * 6e4 };
|
|
9133
9414
|
async function ship(ctx, options) {
|
|
9134
|
-
const upstream =
|
|
9135
|
-
const propagateOnly = options.propagateOnly ?? false;
|
|
9415
|
+
const upstream = join11(options.workspace, UPSTREAM);
|
|
9136
9416
|
if (options.plx)
|
|
9137
9417
|
await preflightSelf(ctx, options.plx);
|
|
9138
9418
|
const train = await readTrain(ctx, upstream);
|
|
9139
9419
|
await preflightForge(ctx);
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
}
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
return { ...summary, released: !propagateOnly };
|
|
9420
|
+
await preflightRelease(ctx, train);
|
|
9421
|
+
await preflightImmutable(ctx, train);
|
|
9422
|
+
const next = resolveVersion(train, options.train, false);
|
|
9423
|
+
await release(ctx, train, next, options.today ?? today(), { ...DEFAULT_WAIT, ...options.wait });
|
|
9424
|
+
if (ctx.dryRun)
|
|
9425
|
+
return { ...await previewConsumers(ctx, options.workspace, next), released: true };
|
|
9426
|
+
ctx.say(`\u2022 train ${next} is cut; every repo takes it itself, when it needs it (plx update)`);
|
|
9427
|
+
return { ...emptySummary(next, false), released: true };
|
|
9149
9428
|
}
|
|
9150
9429
|
async function preflightImmutable(ctx, train) {
|
|
9151
9430
|
for (const repo of train.repos) {
|
|
@@ -9186,23 +9465,27 @@ async function releasePhase(ctx, train, repos2, next, today2) {
|
|
|
9186
9465
|
ctx.say(`\u2192 phase: ${repos2.map((r) => r.name).join(", ")}`);
|
|
9187
9466
|
await ctx.apply(await planBookkeeping(ctx, train, repos2, next, today2));
|
|
9188
9467
|
for (const repo of repos2)
|
|
9189
|
-
await tagAndRelease(ctx, repo, next);
|
|
9468
|
+
await tagAndRelease(ctx, repo, next, today2);
|
|
9190
9469
|
}
|
|
9191
|
-
async function tagAndRelease(ctx, repo, next) {
|
|
9470
|
+
async function tagAndRelease(ctx, repo, next, today2) {
|
|
9192
9471
|
const tagged = await ctx.read("git", ["rev-parse", "-q", "--verify", `refs/tags/${next}`], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9193
9472
|
if (tagged)
|
|
9194
9473
|
ctx.say(`\u2022 ${repo.name}: already tagged ${next}`);
|
|
9195
9474
|
else
|
|
9196
9475
|
await ctx.apply([run("git", ["tag", "-a", next, "-m", `train ${next}`], { cwd: repo.path })]);
|
|
9197
9476
|
await ctx.apply([run("git", ["push", "origin", "main", next], { cwd: repo.path })]);
|
|
9198
|
-
const
|
|
9199
|
-
if (
|
|
9200
|
-
|
|
9201
|
-
|
|
9477
|
+
const create = ["release", "create", next, "--verify-tag", "--generate-notes", "--title", next];
|
|
9478
|
+
if (repo.name === COMPENDIUM) {
|
|
9479
|
+
if (!await releaseWithManifest(ctx, repo, next, today2, create))
|
|
9480
|
+
return;
|
|
9481
|
+
} else {
|
|
9482
|
+
const released = await ctx.read("gh", ["release", "view", next], { cwd: repo.path }).then(() => true).catch(() => false);
|
|
9483
|
+
if (released) {
|
|
9484
|
+
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9485
|
+
return;
|
|
9486
|
+
}
|
|
9487
|
+
await ctx.apply([run("gh", create, { cwd: repo.path })]);
|
|
9202
9488
|
}
|
|
9203
|
-
await ctx.apply([
|
|
9204
|
-
run("gh", ["release", "create", next, "--verify-tag", "--generate-notes", "--title", next], { cwd: repo.path })
|
|
9205
|
-
]);
|
|
9206
9489
|
if (ctx.dryRun)
|
|
9207
9490
|
return;
|
|
9208
9491
|
const immutable = (await ctx.read("gh", ["api", `repos/{owner}/{repo}/releases/tags/${next}`, "--jq", ".immutable"], {
|
|
@@ -9211,6 +9494,32 @@ async function tagAndRelease(ctx, repo, next) {
|
|
|
9211
9494
|
if (immutable !== "true")
|
|
9212
9495
|
throw new Error(mutableRelease(`${repo.name}: release ${next} was created mutable, and its tag can still move`));
|
|
9213
9496
|
}
|
|
9497
|
+
async function releaseWithManifest(ctx, repo, next, today2, create) {
|
|
9498
|
+
const state = (await ctx.read("gh", ["release", "view", next, "--json", "isDraft", "--jq", ".isDraft"], { cwd: repo.path }).catch(() => "")).trim();
|
|
9499
|
+
if (state === "false") {
|
|
9500
|
+
ctx.say(`\u2022 ${repo.name}: release ${next} exists`);
|
|
9501
|
+
return false;
|
|
9502
|
+
}
|
|
9503
|
+
if (state === "true")
|
|
9504
|
+
ctx.say(`\u2022 ${repo.name}: release ${next} is still a draft \u2014 finishing it`);
|
|
9505
|
+
else
|
|
9506
|
+
await ctx.apply([run("gh", [...create, "--draft"], { cwd: repo.path })]);
|
|
9507
|
+
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9508
|
+
const file = join11(scratch, MANIFEST_FILE);
|
|
9509
|
+
try {
|
|
9510
|
+
const manifest2 = buildManifest(await readCatalog(ctx, repo.path), next, today2);
|
|
9511
|
+
ctx.say(` ${repo.name}: ${MANIFEST_FILE}: train ${next}, ${manifest2.modules.length} modules`);
|
|
9512
|
+
await ctx.stage(write(file, renderManifest(manifest2)));
|
|
9513
|
+
await ctx.apply([
|
|
9514
|
+
run("gh", ["release", "upload", next, file, "--clobber"], { cwd: repo.path }),
|
|
9515
|
+
run("gh", ["release", "edit", next, "--draft=false"], { cwd: repo.path })
|
|
9516
|
+
]);
|
|
9517
|
+
} finally {
|
|
9518
|
+
if (scratch)
|
|
9519
|
+
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9520
|
+
}
|
|
9521
|
+
return true;
|
|
9522
|
+
}
|
|
9214
9523
|
async function awaitPublished(ctx, next, wait) {
|
|
9215
9524
|
const names = TRAIN_PACKAGES.map((p) => p.name);
|
|
9216
9525
|
const list2 = names.map((n) => `${n}@${next}`).join(", ");
|
|
@@ -9242,7 +9551,7 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
|
9242
9551
|
const touched = /* @__PURE__ */ new Set();
|
|
9243
9552
|
const repo = (name) => repos2.find((r) => r.name === name);
|
|
9244
9553
|
const edit = async (r, rel, what, transform) => {
|
|
9245
|
-
const path3 =
|
|
9554
|
+
const path3 = join11(r.path, rel);
|
|
9246
9555
|
const text = await ctx.readFile(path3).catch(() => void 0);
|
|
9247
9556
|
if (text === void 0)
|
|
9248
9557
|
return;
|
|
@@ -9279,7 +9588,7 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
|
9279
9588
|
if (comp) {
|
|
9280
9589
|
await edit(comp, MAP_PAGE, `version \u2192 ${next}, timestamp \u2192 ${today2}`, (t) => stampStandard(t, next, today2));
|
|
9281
9590
|
for (const page of await modulePages(ctx, comp.path)) {
|
|
9282
|
-
const text = await ctx.readFile(
|
|
9591
|
+
const text = await ctx.readFile(join11(comp.path, page));
|
|
9283
9592
|
if (frontmatterField(text, "maturity") !== "standard")
|
|
9284
9593
|
continue;
|
|
9285
9594
|
const previous = comp.tag ? await ctx.read("git", ["show", `${comp.tag}:${page}`], { cwd: comp.path }).catch(() => "") : "";
|
|
@@ -9297,76 +9606,6 @@ async function planBookkeeping(ctx, train, repos2, next, today2) {
|
|
|
9297
9606
|
return plan;
|
|
9298
9607
|
}
|
|
9299
9608
|
|
|
9300
|
-
// ../lib/dist/update.js
|
|
9301
|
-
import { basename, join as join10 } from "node:path";
|
|
9302
|
-
var PRESETS = TRAIN_REPOS.filter((r) => r.startsWith("preset-"));
|
|
9303
|
-
async function update(ctx, options) {
|
|
9304
|
-
const { repo } = options;
|
|
9305
|
-
const name = basename(repo);
|
|
9306
|
-
if (options.train !== void 0 && !isTrainVersion(options.train))
|
|
9307
|
-
throw new UsageError(`'${options.train}' is not plain semver (X.Y.Z, no v)`);
|
|
9308
|
-
const tree = await overview(ctx, repo);
|
|
9309
|
-
const consumer = (await findConsumers(ctx, tree, PRESETS)).find((c) => c.path === tree.path);
|
|
9310
|
-
if (!consumer)
|
|
9311
|
-
throw new Error(`${repo} is not a repo generated from the presets: no ${ANSWERS_FILE} at its root naming one of ${PRESETS.map(presetSource).join(", ")}`);
|
|
9312
|
-
if (consumer.skipped)
|
|
9313
|
-
throw new Error(`${name}: ${consumer.skipped}`);
|
|
9314
|
-
consumer.rel = name;
|
|
9315
|
-
for (const s of consumer.sites)
|
|
9316
|
-
s.rel = s.rel === "." ? name : join10(name, s.rel);
|
|
9317
|
-
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
9318
|
-
if (!root)
|
|
9319
|
-
throw new Error(`${name}: its root is not a site of a repo preset`);
|
|
9320
|
-
await preflightForge(ctx);
|
|
9321
|
-
const train = options.train ?? await newestTrain(ctx, root.preset);
|
|
9322
|
-
const summary = emptySummary(train, ctx.dryRun);
|
|
9323
|
-
const recorded = await Promise.all(consumer.sites.map(async (s) => parseAnswers(await ctx.readFile(join10(s.path, ANSWERS_FILE))).commit));
|
|
9324
|
-
if (recorded.every((c) => c === train)) {
|
|
9325
|
-
ctx.say(`\u2022 ${name}: already at ${train}`);
|
|
9326
|
-
return summary;
|
|
9327
|
-
}
|
|
9328
|
-
const past = recorded.find((c) => c && isTrainVersion(c) && compareTrains(c, train) > 0);
|
|
9329
|
-
if (past)
|
|
9330
|
-
throw new Error(`${name} is at ${past}, past ${train}; a repo is never taken back to an older train`);
|
|
9331
|
-
const branch = trainBranch(train);
|
|
9332
|
-
const onOrigin = await ctx.read("git", ["ls-remote", "--exit-code", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo }).then(() => true).catch(() => false);
|
|
9333
|
-
if (onOrigin) {
|
|
9334
|
-
const url = await openPullUrl(ctx, consumer, repo, train);
|
|
9335
|
-
ctx.say(`\u2022 ${name}: ${branch} is already on origin${url ? ` (${url})` : ""} \u2014 nothing to do; delete the branch to pull the train again`);
|
|
9336
|
-
if (url)
|
|
9337
|
-
summary.pulls.push(url);
|
|
9338
|
-
return summary;
|
|
9339
|
-
}
|
|
9340
|
-
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
9341
|
-
const dir = join10(scratch, name);
|
|
9342
|
-
try {
|
|
9343
|
-
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
9344
|
-
try {
|
|
9345
|
-
await ctx.stage(run("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }));
|
|
9346
|
-
await ctx.stage(run("git", ["worktree", "add", "--quiet", "--detach", dir, `origin/${consumer.branch}`], { cwd: repo }));
|
|
9347
|
-
} catch (error) {
|
|
9348
|
-
ctx.say(` \u2717 FAILED \u2014 worktree of origin/${consumer.branch}${detail(error)}`);
|
|
9349
|
-
summary.failed.push(name);
|
|
9350
|
-
return summary;
|
|
9351
|
-
}
|
|
9352
|
-
await takeTrain(ctx, consumer, dir, { train, ref: train, opener: "`plx update`" }, summary);
|
|
9353
|
-
} finally {
|
|
9354
|
-
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
9355
|
-
if (scratch)
|
|
9356
|
-
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
9357
|
-
}
|
|
9358
|
-
return summary;
|
|
9359
|
-
}
|
|
9360
|
-
async function newestTrain(ctx, preset) {
|
|
9361
|
-
const source = presetSource(preset).replace(/^gh:/, "");
|
|
9362
|
-
const tag = (await ctx.read("gh", ["api", `repos/${source}/releases/latest`, "--jq", ".tag_name"]).catch(() => "")).trim();
|
|
9363
|
-
if (!tag)
|
|
9364
|
-
throw new Error(`no release of ${source} found \u2014 pass the train explicitly (--train <version>)`);
|
|
9365
|
-
if (!isTrainVersion(tag))
|
|
9366
|
-
throw new Error(`the newest release of ${source} is '${tag}', not a train`);
|
|
9367
|
-
return tag;
|
|
9368
|
-
}
|
|
9369
|
-
|
|
9370
9609
|
// src/program.ts
|
|
9371
9610
|
import { createRequire } from "node:module";
|
|
9372
9611
|
|
|
@@ -14308,7 +14547,7 @@ function register3(program2) {
|
|
|
14308
14547
|
|
|
14309
14548
|
// src/commands/doctor.ts
|
|
14310
14549
|
import { existsSync } from "node:fs";
|
|
14311
|
-
import { join as
|
|
14550
|
+
import { join as join12, resolve as resolve4 } from "node:path";
|
|
14312
14551
|
|
|
14313
14552
|
// src/style.ts
|
|
14314
14553
|
function style(enabled) {
|
|
@@ -14326,8 +14565,8 @@ function register4(program2) {
|
|
|
14326
14565
|
).option("--color", "colour the report even when piped").option("--no-color", "never colour the report").action(async (dir, opts, command) => {
|
|
14327
14566
|
const ctx = contextOf2(command);
|
|
14328
14567
|
const root = resolve4(dir);
|
|
14329
|
-
const compendium = resolve4(opts.compendium ??
|
|
14330
|
-
if (!existsSync(
|
|
14568
|
+
const compendium = resolve4(opts.compendium ?? join12(root, WORKSPACE_COMPENDIUM));
|
|
14569
|
+
if (!existsSync(join12(compendium, "contracts")))
|
|
14331
14570
|
throw new Error(
|
|
14332
14571
|
`no compendium at ${compendium}; pass --compendium <path to a checkout of plexus-ms/compendium>`
|
|
14333
14572
|
);
|
|
@@ -14409,11 +14648,14 @@ import { resolve as resolve7 } from "node:path";
|
|
|
14409
14648
|
import { resolve as resolve6 } from "node:path";
|
|
14410
14649
|
function register6(program2) {
|
|
14411
14650
|
program2.command("ship").description(
|
|
14412
|
-
"
|
|
14413
|
-
).argument("[dir]", "the workspace: plexus-ms/ and the consumers
|
|
14651
|
+
"cut the train: tag and release every train repo identically; repos take it themselves (update, propagate)"
|
|
14652
|
+
).argument("[dir]", "the workspace: plexus-ms/ sits under it, and the consumers the dry run previews", ".").option("--train <version>", "the train version, plain semver (default: minor+1 over the latest train)").action(async (dir, opts, command) => {
|
|
14414
14653
|
const ctx = contextOf2(command);
|
|
14415
14654
|
const result = await ship(ctx, { workspace: resolve6(dir), train: opts.train, plx: version });
|
|
14416
|
-
ctx.result(
|
|
14655
|
+
ctx.result(
|
|
14656
|
+
result,
|
|
14657
|
+
(r) => r.preview ? renderSummary(r, `plx -y ship --train ${r.train} ${dir}`, "ship") : `\u2713 train ${r.train} cut \u2014 repos take it themselves; to take it now where it matters: plx propagate --now ${dir}`
|
|
14658
|
+
);
|
|
14417
14659
|
if (!isClean(result)) process.exitCode = 1;
|
|
14418
14660
|
});
|
|
14419
14661
|
}
|
|
@@ -14423,36 +14665,48 @@ function renderSummary(s, realCommand, verb = "propagate") {
|
|
|
14423
14665
|
for (const p of s.conflicted) lines.push(` \u2717 conflicts: ${p}`);
|
|
14424
14666
|
for (const p of s.failed) lines.push(` \u2717 failed: ${p}`);
|
|
14425
14667
|
for (const { path: path3, reason } of s.skipped) lines.push(` \u26A0 skipped: ${path3} (${reason})`);
|
|
14668
|
+
for (const { path: path3, reason } of s.resting) lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
14426
14669
|
for (const url of s.pulls) lines.push(` \u2192 pull: ${url}`);
|
|
14427
14670
|
const clean = isClean(s);
|
|
14428
|
-
|
|
14671
|
+
const idle = clean && s.clean.length === 0 && s.pulls.length === 0;
|
|
14672
|
+
if (s.preview && !idle) {
|
|
14429
14673
|
lines.push(" (preview only \u2014 nothing was changed)");
|
|
14430
14674
|
if (clean) lines.push(`\u2713 dry run clean \u2014 run it for real: ${realCommand}`);
|
|
14431
14675
|
} else if (clean) {
|
|
14432
|
-
lines.push("\u2713 done \u2014 review and merge the pull requests");
|
|
14676
|
+
lines.push(s.pulls.length > 0 ? "\u2713 done \u2014 review and merge the pull requests" : "\u2713 done \u2014 no pull request");
|
|
14433
14677
|
}
|
|
14434
|
-
if (!clean) lines.push(`\u2717 needs attention \u2014 see above; fix the
|
|
14678
|
+
if (!clean) lines.push(`\u2717 needs attention \u2014 see above; fix the repo, then re-run ${verb}`);
|
|
14435
14679
|
return lines.join("\n");
|
|
14436
14680
|
}
|
|
14437
14681
|
|
|
14438
14682
|
// src/commands/propagate.ts
|
|
14439
14683
|
function register7(program2) {
|
|
14440
|
-
program2.command("propagate").description(
|
|
14684
|
+
program2.command("propagate").description(
|
|
14685
|
+
"run update in every repo generated from the presets under a directory: each takes the newest train when it needs it, as one pull request per repo"
|
|
14686
|
+
).argument("[dir]", "a directory the repos sit under, at any depth", ".").option(
|
|
14687
|
+
"--train <version>",
|
|
14688
|
+
"the train every repo takes, whatever the triggers say (default: each preset's newest)"
|
|
14689
|
+
).option("--now", "take the newest train in every repo, whatever the triggers say").option(
|
|
14690
|
+
"--max-age <days>",
|
|
14691
|
+
"the backstop for every repo (default: each repo's answer update_max_age, else 30; 0 takes every train)",
|
|
14692
|
+
(v) => parseMaxAge(v, "--max-age")
|
|
14693
|
+
).action(async (dir, opts, command) => {
|
|
14441
14694
|
const ctx = contextOf2(command);
|
|
14442
|
-
const result = await
|
|
14443
|
-
|
|
14695
|
+
const result = await propagate(ctx, { dir: resolve7(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
|
|
14696
|
+
const flags = [opts.train ? `--train ${opts.train}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
|
|
14697
|
+
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
14444
14698
|
if (!isClean(result)) process.exitCode = 1;
|
|
14445
14699
|
});
|
|
14446
14700
|
}
|
|
14447
14701
|
|
|
14448
14702
|
// src/commands/requirements.ts
|
|
14449
|
-
import { join as
|
|
14703
|
+
import { join as join13, resolve as resolve8 } from "node:path";
|
|
14450
14704
|
function register8(program2) {
|
|
14451
14705
|
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) => {
|
|
14452
14706
|
const ctx = contextOf2(command);
|
|
14453
14707
|
const compendium = resolve8(dir);
|
|
14454
14708
|
if (opts.extract) {
|
|
14455
|
-
ctx.result(extractRequirements(await ctx.readFile(
|
|
14709
|
+
ctx.result(extractRequirements(await ctx.readFile(join13(compendium, opts.extract))));
|
|
14456
14710
|
return;
|
|
14457
14711
|
}
|
|
14458
14712
|
const check = await checkCompendium(ctx, compendium);
|
|
@@ -14469,10 +14723,14 @@ function renderCheck(c) {
|
|
|
14469
14723
|
import { resolve as resolve9 } from "node:path";
|
|
14470
14724
|
function register9(program2) {
|
|
14471
14725
|
program2.command("update").description(
|
|
14472
|
-
"bring this repo up to
|
|
14473
|
-
).argument("[dir]", "a repo generated from the presets", ".").option("--train <version>", "the train to take (default: the preset's newest release)").
|
|
14726
|
+
"bring this repo up to the newest train when it needs it (asked, or past the backstop age), as a pull request on plexus/<version>: copier update at every site, the marker, the lockfile, the workflow refs"
|
|
14727
|
+
).argument("[dir]", "a repo generated from the presets", ".").option("--train <version>", "the train to take, whatever the triggers say (default: the preset's newest release)").option("--now", "take the newest train whatever the triggers say").option(
|
|
14728
|
+
"--max-age <days>",
|
|
14729
|
+
"the backstop: take the newest train once the oldest one not taken is this old (default: the repo's answer update_max_age, else 30; 0 takes every train)",
|
|
14730
|
+
(v) => parseMaxAge(v, "--max-age")
|
|
14731
|
+
).action(async (dir, opts, command) => {
|
|
14474
14732
|
const ctx = contextOf2(command);
|
|
14475
|
-
const result = await update(ctx, { repo: resolve9(dir), train: opts.train });
|
|
14733
|
+
const result = await update(ctx, { repo: resolve9(dir), train: opts.train, now: opts.now, maxAge: opts.maxAge });
|
|
14476
14734
|
ctx.result(result, (r) => renderSummary(r, `plx -y update --train ${r.train} ${dir}`, "update"));
|
|
14477
14735
|
if (!isClean(result)) process.exitCode = 1;
|
|
14478
14736
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexus-ms/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.117.0",
|
|
4
4
|
"description": "plx, the Plexus command-line tool: a single-script adapter over @plexus-ms/lib",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@inquirer/prompts": "^8.7.5",
|
|
27
|
-
"@plexus-ms/lib": "0.
|
|
27
|
+
"@plexus-ms/lib": "0.117.0",
|
|
28
28
|
"commander": "^15.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|