@plexus-ms/cli 0.126.0 → 0.128.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 +1144 -666
- package/package.json +2 -2
package/dist/plx.js
CHANGED
|
@@ -1185,8 +1185,8 @@ var require_stringifyString = __commonJS({
|
|
|
1185
1185
|
case "u":
|
|
1186
1186
|
{
|
|
1187
1187
|
str += json.slice(start, i);
|
|
1188
|
-
const
|
|
1189
|
-
switch (
|
|
1188
|
+
const code2 = json.substr(i + 2, 4);
|
|
1189
|
+
switch (code2) {
|
|
1190
1190
|
case "0000":
|
|
1191
1191
|
str += "\\0";
|
|
1192
1192
|
break;
|
|
@@ -1212,8 +1212,8 @@ var require_stringifyString = __commonJS({
|
|
|
1212
1212
|
str += "\\P";
|
|
1213
1213
|
break;
|
|
1214
1214
|
default:
|
|
1215
|
-
if (
|
|
1216
|
-
str += "\\x" +
|
|
1215
|
+
if (code2.substr(0, 2) === "00")
|
|
1216
|
+
str += "\\x" + code2.substr(2);
|
|
1217
1217
|
else
|
|
1218
1218
|
str += json.substr(i, 6);
|
|
1219
1219
|
}
|
|
@@ -3712,22 +3712,22 @@ var require_errors = __commonJS({
|
|
|
3712
3712
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/errors.js"(exports) {
|
|
3713
3713
|
"use strict";
|
|
3714
3714
|
var YAMLError = class extends Error {
|
|
3715
|
-
constructor(name, pos,
|
|
3715
|
+
constructor(name, pos, code2, message) {
|
|
3716
3716
|
super();
|
|
3717
3717
|
this.name = name;
|
|
3718
|
-
this.code =
|
|
3718
|
+
this.code = code2;
|
|
3719
3719
|
this.message = message;
|
|
3720
3720
|
this.pos = pos;
|
|
3721
3721
|
}
|
|
3722
3722
|
};
|
|
3723
3723
|
var YAMLParseError = class extends YAMLError {
|
|
3724
|
-
constructor(pos,
|
|
3725
|
-
super("YAMLParseError", pos,
|
|
3724
|
+
constructor(pos, code2, message) {
|
|
3725
|
+
super("YAMLParseError", pos, code2, message);
|
|
3726
3726
|
}
|
|
3727
3727
|
};
|
|
3728
3728
|
var YAMLWarning = class extends YAMLError {
|
|
3729
|
-
constructor(pos,
|
|
3730
|
-
super("YAMLWarning", pos,
|
|
3729
|
+
constructor(pos, code2, message) {
|
|
3730
|
+
super("YAMLWarning", pos, code2, message);
|
|
3731
3731
|
}
|
|
3732
3732
|
};
|
|
3733
3733
|
var prettifyError = (src, lc) => (error) => {
|
|
@@ -4636,7 +4636,7 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4636
4636
|
const { offset, type, source, end } = scalar;
|
|
4637
4637
|
let _type;
|
|
4638
4638
|
let value;
|
|
4639
|
-
const _onError = (rel,
|
|
4639
|
+
const _onError = (rel, code2, msg) => onError(offset + rel, code2, msg);
|
|
4640
4640
|
switch (type) {
|
|
4641
4641
|
case "scalar":
|
|
4642
4642
|
_type = Scalar.Scalar.PLAIN;
|
|
@@ -4834,9 +4834,9 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4834
4834
|
function parseCharCode(source, offset, length, onError) {
|
|
4835
4835
|
const cc = source.substr(offset, length);
|
|
4836
4836
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
4837
|
-
const
|
|
4837
|
+
const code2 = ok ? parseInt(cc, 16) : NaN;
|
|
4838
4838
|
try {
|
|
4839
|
-
return String.fromCodePoint(
|
|
4839
|
+
return String.fromCodePoint(code2);
|
|
4840
4840
|
} catch {
|
|
4841
4841
|
const raw = source.substr(offset - 2, length + 2);
|
|
4842
4842
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
@@ -5158,12 +5158,12 @@ var require_composer = __commonJS({
|
|
|
5158
5158
|
this.prelude = [];
|
|
5159
5159
|
this.errors = [];
|
|
5160
5160
|
this.warnings = [];
|
|
5161
|
-
this.onError = (source,
|
|
5161
|
+
this.onError = (source, code2, message, warning) => {
|
|
5162
5162
|
const pos = getErrorPos(source);
|
|
5163
5163
|
if (warning)
|
|
5164
|
-
this.warnings.push(new errors.YAMLWarning(pos,
|
|
5164
|
+
this.warnings.push(new errors.YAMLWarning(pos, code2, message));
|
|
5165
5165
|
else
|
|
5166
|
-
this.errors.push(new errors.YAMLParseError(pos,
|
|
5166
|
+
this.errors.push(new errors.YAMLParseError(pos, code2, message));
|
|
5167
5167
|
};
|
|
5168
5168
|
this.directives = new directives.Directives({ version: options.version || "1.2" });
|
|
5169
5169
|
this.options = options;
|
|
@@ -5325,12 +5325,12 @@ var require_cst_scalar = __commonJS({
|
|
|
5325
5325
|
var stringifyString = require_stringifyString();
|
|
5326
5326
|
function resolveAsScalar(token, strict = true, onError) {
|
|
5327
5327
|
if (token) {
|
|
5328
|
-
const _onError = (pos,
|
|
5328
|
+
const _onError = (pos, code2, message) => {
|
|
5329
5329
|
const offset = typeof pos === "number" ? pos : Array.isArray(pos) ? pos[0] : pos.offset;
|
|
5330
5330
|
if (onError)
|
|
5331
|
-
onError(offset,
|
|
5331
|
+
onError(offset, code2, message);
|
|
5332
5332
|
else
|
|
5333
|
-
throw new errors.YAMLParseError([offset, offset + 1],
|
|
5333
|
+
throw new errors.YAMLParseError([offset, offset + 1], code2, message);
|
|
5334
5334
|
};
|
|
5335
5335
|
switch (token.type) {
|
|
5336
5336
|
case "scalar":
|
|
@@ -7249,7 +7249,7 @@ var require_public_api = __commonJS({
|
|
|
7249
7249
|
return docs;
|
|
7250
7250
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
7251
7251
|
}
|
|
7252
|
-
function
|
|
7252
|
+
function parseDocument2(source, options = {}) {
|
|
7253
7253
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
7254
7254
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
7255
7255
|
const composer$1 = new composer.Composer(options);
|
|
@@ -7275,7 +7275,7 @@ var require_public_api = __commonJS({
|
|
|
7275
7275
|
} else if (options === void 0 && reviver && typeof reviver === "object") {
|
|
7276
7276
|
options = reviver;
|
|
7277
7277
|
}
|
|
7278
|
-
const doc =
|
|
7278
|
+
const doc = parseDocument2(src, options);
|
|
7279
7279
|
if (!doc)
|
|
7280
7280
|
return null;
|
|
7281
7281
|
doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning));
|
|
@@ -7311,7 +7311,7 @@ var require_public_api = __commonJS({
|
|
|
7311
7311
|
}
|
|
7312
7312
|
exports.parse = parse7;
|
|
7313
7313
|
exports.parseAllDocuments = parseAllDocuments;
|
|
7314
|
-
exports.parseDocument =
|
|
7314
|
+
exports.parseDocument = parseDocument2;
|
|
7315
7315
|
exports.stringify = stringify2;
|
|
7316
7316
|
}
|
|
7317
7317
|
});
|
|
@@ -9821,17 +9821,17 @@ var FORWARD = new RegExp(`${SIGN}(${NUMBERS})${GAP}(${CODE})`, "g");
|
|
|
9821
9821
|
var REVERSE = new RegExp(`(?<![\\w-])(${CODE})[ \\t\\u00a0]*,?[ \\t\\u00a0]*${SIGN}(${NUMBERS})`, "g");
|
|
9822
9822
|
var BARE = new RegExp(`${SIGN}(${NUMBERS})`, "g");
|
|
9823
9823
|
var NAME_CITATION = new RegExp(`(?<![\\w/-])${NAME_LIKE}(?![\\w/])`, "g");
|
|
9824
|
-
var sectionKey = (n,
|
|
9824
|
+
var sectionKey = (n, code2) => `\xA7 ${n} ${code2}`;
|
|
9825
9825
|
var numbersOf = (list2) => list2.match(new RegExp(NUMBER, "g")) ?? [];
|
|
9826
9826
|
function lintCitations(text, file, citable, own) {
|
|
9827
9827
|
const codes = new Set([...citable].filter((c) => c.startsWith("\xA7 ")).map((c) => c.replace(/^§ \S+ /, "")));
|
|
9828
9828
|
const out = [];
|
|
9829
|
-
const sections = (list2,
|
|
9829
|
+
const sections = (list2, code2, line) => {
|
|
9830
9830
|
for (const n of numbersOf(list2)) {
|
|
9831
|
-
const excerpt = sectionKey(n,
|
|
9831
|
+
const excerpt = sectionKey(n, code2);
|
|
9832
9832
|
if (citable.has(excerpt))
|
|
9833
9833
|
continue;
|
|
9834
|
-
const message = codes.has(
|
|
9834
|
+
const message = codes.has(code2) ? `${excerpt} cites a section that does not exist` : `${excerpt} cites ${code2}, which is no module`;
|
|
9835
9835
|
out.push({ lint: "citations", file, line, excerpt, message });
|
|
9836
9836
|
}
|
|
9837
9837
|
};
|
|
@@ -10009,8 +10009,6 @@ function compareBaseline(violations, baseline) {
|
|
|
10009
10009
|
// ../lib/dist/bookkeeping.js
|
|
10010
10010
|
var WORKFLOW_REF = "plexus-ms/tooling/.github/workflows/";
|
|
10011
10011
|
var bumpWorkflowRefs = (text, version2) => text.replace(/(plexus-ms\/tooling\/\.github\/workflows\/[A-Za-z0-9._-]+)@v?[0-9.]+/g, `$1@${version2}`);
|
|
10012
|
-
var hasConflictMarkers = (text) => /^<<<<<<< /m.test(text);
|
|
10013
|
-
var hasUnmergedEntries = (porcelain) => /^(UU|AA|DU|UD)/m.test(porcelain);
|
|
10014
10012
|
|
|
10015
10013
|
// ../lib/dist/changeset.js
|
|
10016
10014
|
var import_yaml = __toESM(require_dist(), 1);
|
|
@@ -10023,11 +10021,11 @@ var ExecError = class extends Error {
|
|
|
10023
10021
|
command;
|
|
10024
10022
|
code;
|
|
10025
10023
|
stderr;
|
|
10026
|
-
constructor(command,
|
|
10027
|
-
super(`${command} exited with ${
|
|
10024
|
+
constructor(command, code2, stderr) {
|
|
10025
|
+
super(`${command} exited with ${code2 ?? "signal"}${stderr ? `
|
|
10028
10026
|
${stderr.trimEnd()}` : ""}`);
|
|
10029
10027
|
this.command = command;
|
|
10030
|
-
this.code =
|
|
10028
|
+
this.code = code2;
|
|
10031
10029
|
this.stderr = stderr;
|
|
10032
10030
|
}
|
|
10033
10031
|
};
|
|
@@ -10040,6 +10038,16 @@ ${stderr.trimEnd()}` : ""}`;
|
|
|
10040
10038
|
this.limit = limit;
|
|
10041
10039
|
}
|
|
10042
10040
|
};
|
|
10041
|
+
function detailOf(error) {
|
|
10042
|
+
if (error instanceof TimeoutError)
|
|
10043
|
+
return `did not finish within ${error.limit} ms`;
|
|
10044
|
+
if (error instanceof ExecError) {
|
|
10045
|
+
const last = error.stderr.split("\n").map((l) => l.trim()).filter(Boolean).at(-1);
|
|
10046
|
+
return last ?? (error.code === null ? "" : `exit code ${error.code}`);
|
|
10047
|
+
}
|
|
10048
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
10049
|
+
return message.trim().split("\n")[0] ?? "";
|
|
10050
|
+
}
|
|
10043
10051
|
var GRACE = 5e3;
|
|
10044
10052
|
var SIGNALS = ["SIGINT", "SIGTERM"];
|
|
10045
10053
|
var cleanups = [];
|
|
@@ -10083,7 +10091,7 @@ function realIo(prompt) {
|
|
|
10083
10091
|
stdout: process.stdout,
|
|
10084
10092
|
stderr: process.stderr,
|
|
10085
10093
|
prompt: prompt && isInteractive() ? prompt : void 0,
|
|
10086
|
-
exec: (command, args, options = {}) => new Promise((
|
|
10094
|
+
exec: (command, args, options = {}) => new Promise((resolve10, reject) => {
|
|
10087
10095
|
const limit = options.timeout;
|
|
10088
10096
|
const child = spawn(command, args, {
|
|
10089
10097
|
cwd: options.cwd,
|
|
@@ -10129,14 +10137,14 @@ function realIo(prompt) {
|
|
|
10129
10137
|
settle();
|
|
10130
10138
|
reject(error);
|
|
10131
10139
|
});
|
|
10132
|
-
child.on("close", (
|
|
10140
|
+
child.on("close", (code2) => {
|
|
10133
10141
|
settle();
|
|
10134
10142
|
if (timedOut && limit !== void 0)
|
|
10135
10143
|
reject(new TimeoutError(render(command, args), limit, stderr));
|
|
10136
|
-
else if (
|
|
10137
|
-
|
|
10144
|
+
else if (code2 === 0)
|
|
10145
|
+
resolve10(stdout);
|
|
10138
10146
|
else
|
|
10139
|
-
reject(new ExecError(render(command, args),
|
|
10147
|
+
reject(new ExecError(render(command, args), code2, stderr));
|
|
10140
10148
|
});
|
|
10141
10149
|
if (options.input !== void 0)
|
|
10142
10150
|
child.stdin?.end(options.input);
|
|
@@ -10401,7 +10409,7 @@ function union(base, own) {
|
|
|
10401
10409
|
function resolveExtends(written, path3) {
|
|
10402
10410
|
const resolved = {};
|
|
10403
10411
|
const chain = [];
|
|
10404
|
-
const
|
|
10412
|
+
const resolve10 = (name) => {
|
|
10405
10413
|
const done = resolved[name];
|
|
10406
10414
|
if (done)
|
|
10407
10415
|
return done;
|
|
@@ -10413,14 +10421,14 @@ function resolveExtends(written, path3) {
|
|
|
10413
10421
|
let merged = service;
|
|
10414
10422
|
if (ref !== void 0 && written[ref]) {
|
|
10415
10423
|
chain.push(name);
|
|
10416
|
-
merged = merge(
|
|
10424
|
+
merged = merge(resolve10(ref), service);
|
|
10417
10425
|
chain.pop();
|
|
10418
10426
|
}
|
|
10419
10427
|
resolved[name] = merged;
|
|
10420
10428
|
return merged;
|
|
10421
10429
|
};
|
|
10422
10430
|
for (const name of Object.keys(written))
|
|
10423
|
-
|
|
10431
|
+
resolve10(name);
|
|
10424
10432
|
return resolved;
|
|
10425
10433
|
}
|
|
10426
10434
|
function merge(base, service) {
|
|
@@ -10465,11 +10473,54 @@ function labelsOf(service) {
|
|
|
10465
10473
|
}));
|
|
10466
10474
|
}
|
|
10467
10475
|
|
|
10476
|
+
// ../lib/dist/conflicts.js
|
|
10477
|
+
import { join as join2 } from "node:path";
|
|
10478
|
+
var MARKER = /^(?:<<<<<<<|>>>>>>>)(?: |\r?$)/m;
|
|
10479
|
+
var hasConflictMarkers = (text) => MARKER.test(text);
|
|
10480
|
+
var hasUnmergedEntries = (porcelain) => /^(UU|AA|DU|UD)/m.test(porcelain);
|
|
10481
|
+
async function filesWithConflictMarkers(ctx, dir, ref) {
|
|
10482
|
+
const args = ["grep", "-l", "-z", "--no-color", "-E", "-e", "^(<<<<<<<|>>>>>>>)", ...ref ? [ref] : [], "--"];
|
|
10483
|
+
const listed = await orAbsent(ctx.read("git", args, { cwd: dir }), (error) => error.code === 1);
|
|
10484
|
+
const candidates = (listed ?? "").split("\0").filter(Boolean).map((name) => ref && name.startsWith(`${ref}:`) ? name.slice(ref.length + 1) : name);
|
|
10485
|
+
const held = [];
|
|
10486
|
+
for (const file of candidates) {
|
|
10487
|
+
const text = ref ? await ctx.read("git", ["cat-file", "blob", `${ref}:${file}`], { cwd: dir }) : await ctx.readFile(join2(dir, file));
|
|
10488
|
+
if (hasConflictMarkers(text))
|
|
10489
|
+
held.push(file);
|
|
10490
|
+
}
|
|
10491
|
+
return held.sort();
|
|
10492
|
+
}
|
|
10493
|
+
|
|
10468
10494
|
// ../lib/dist/consumers.js
|
|
10469
|
-
import { relative } from "node:path";
|
|
10495
|
+
import { join as join4, relative } from "node:path";
|
|
10470
10496
|
|
|
10471
|
-
// ../lib/dist/
|
|
10497
|
+
// ../lib/dist/copier.js
|
|
10472
10498
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
10499
|
+
var ANSWERS_FILE = ".copier-answers.yml";
|
|
10500
|
+
var TEMPLATE_FILES = ["copier.yml", "copier.yaml"];
|
|
10501
|
+
var COPIER_VERSION = "9.19.1";
|
|
10502
|
+
var copierVia = (args) => ["exec", `copier@${COPIER_VERSION}`, "--", "copier", ...args];
|
|
10503
|
+
function parseAnswers(text) {
|
|
10504
|
+
const data = (0, import_yaml3.parse)(text);
|
|
10505
|
+
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
10506
|
+
throw new Error("answers file is not a mapping");
|
|
10507
|
+
const { _commit, _src_path, ...answers } = data;
|
|
10508
|
+
return {
|
|
10509
|
+
commit: _commit === void 0 ? void 0 : String(_commit),
|
|
10510
|
+
src: _src_path === void 0 ? void 0 : String(_src_path),
|
|
10511
|
+
answers
|
|
10512
|
+
};
|
|
10513
|
+
}
|
|
10514
|
+
function setAnswer(text, key, value) {
|
|
10515
|
+
const doc = (0, import_yaml3.parseDocument)(text);
|
|
10516
|
+
if (doc.errors.length > 0)
|
|
10517
|
+
throw new Error(`answers file is not YAML: ${doc.errors[0]?.message}`);
|
|
10518
|
+
doc.set(key, value);
|
|
10519
|
+
return doc.toString();
|
|
10520
|
+
}
|
|
10521
|
+
|
|
10522
|
+
// ../lib/dist/marker.js
|
|
10523
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10473
10524
|
var OBSOLETE_KEYS = ["plexus", "modules"];
|
|
10474
10525
|
var MARKER_FILE = "PLEXUS.md";
|
|
10475
10526
|
function parseMarker(text) {
|
|
@@ -10492,7 +10543,7 @@ function splitFrontmatter(text) {
|
|
|
10492
10543
|
const match = /^\uFEFF?---\r?\n(?:([\s\S]*?)\r?\n)?---(?:\r?\n|$)([\s\S]*)$/.exec(text);
|
|
10493
10544
|
if (!match)
|
|
10494
10545
|
throw new Error("no frontmatter: expected a `---` block at the top");
|
|
10495
|
-
const data = (0,
|
|
10546
|
+
const data = (0, import_yaml4.parse)(match[1] ?? "") ?? {};
|
|
10496
10547
|
if (typeof data !== "object" || Array.isArray(data))
|
|
10497
10548
|
throw new Error("frontmatter is not a mapping");
|
|
10498
10549
|
return { data, body: match[2] ?? "" };
|
|
@@ -10612,6 +10663,225 @@ function isNotable(dir) {
|
|
|
10612
10663
|
return Boolean(dir.gitRoot || dir.git || dir.template || dir.copier || dir.declaration || dir.problems?.length || dir.unreadable || dir.symlink);
|
|
10613
10664
|
}
|
|
10614
10665
|
|
|
10666
|
+
// ../lib/dist/overview.js
|
|
10667
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
10668
|
+
var PRUNED = /* @__PURE__ */ new Set([
|
|
10669
|
+
"node_modules",
|
|
10670
|
+
".hg",
|
|
10671
|
+
".svn",
|
|
10672
|
+
".next",
|
|
10673
|
+
".nuxt",
|
|
10674
|
+
".turbo",
|
|
10675
|
+
".svelte-kit",
|
|
10676
|
+
"dist",
|
|
10677
|
+
"build",
|
|
10678
|
+
"out",
|
|
10679
|
+
".output",
|
|
10680
|
+
".venv",
|
|
10681
|
+
"venv",
|
|
10682
|
+
"__pycache__",
|
|
10683
|
+
"target",
|
|
10684
|
+
".cache",
|
|
10685
|
+
".pnpm-store",
|
|
10686
|
+
"coverage",
|
|
10687
|
+
"vendor",
|
|
10688
|
+
".terraform",
|
|
10689
|
+
".gradle"
|
|
10690
|
+
]);
|
|
10691
|
+
var descends = (name, app) => name !== ".git" && (app || !PRUNED.has(name));
|
|
10692
|
+
function answersDirs(files) {
|
|
10693
|
+
const present = new Set(files);
|
|
10694
|
+
const holdsTemplate = (dir) => TEMPLATE_FILES.some((f) => present.has(dir === "." ? f : `${dir}/${f}`));
|
|
10695
|
+
const namesIn = (dir) => files.filter((f) => f.startsWith(`${dir}/`)).map((f) => ({ name: f.slice(dir.length + 1).split("/")[0] ?? "" }));
|
|
10696
|
+
const dirs = [];
|
|
10697
|
+
for (const file of files) {
|
|
10698
|
+
if (file !== ANSWERS_FILE && !file.endsWith(`/${ANSWERS_FILE}`))
|
|
10699
|
+
continue;
|
|
10700
|
+
const dir = dirname2(file);
|
|
10701
|
+
const parts2 = dir === "." ? [] : dir.split("/");
|
|
10702
|
+
let reached = !holdsTemplate(".");
|
|
10703
|
+
for (let i = 0; reached && i < parts2.length; i++) {
|
|
10704
|
+
const at = parts2.slice(0, i + 1).join("/");
|
|
10705
|
+
const app = i === 1 && parts2[0] === APPS_DIR && holdsApp(namesIn(at));
|
|
10706
|
+
reached = descends(parts2[i] ?? "", app) && !holdsTemplate(at);
|
|
10707
|
+
}
|
|
10708
|
+
if (reached)
|
|
10709
|
+
dirs.push(dir);
|
|
10710
|
+
}
|
|
10711
|
+
return dirs;
|
|
10712
|
+
}
|
|
10713
|
+
var MISE_FILE = "mise.toml";
|
|
10714
|
+
var FETCHES = 8;
|
|
10715
|
+
async function overview(ctx, root, options = {}) {
|
|
10716
|
+
const opts = { git: true, fetch: false, ...options };
|
|
10717
|
+
const tree = await walk(ctx, root, root.replace(/\/+$/, "").split("/").pop() || root, opts);
|
|
10718
|
+
if (opts.git && opts.fetch)
|
|
10719
|
+
await syncAll(ctx, repos(tree));
|
|
10720
|
+
return tree;
|
|
10721
|
+
}
|
|
10722
|
+
function repos(dir) {
|
|
10723
|
+
return [...dir.git ? [dir] : [], ...dir.children.flatMap(repos)];
|
|
10724
|
+
}
|
|
10725
|
+
async function syncAll(ctx, dirs) {
|
|
10726
|
+
const queue = [...dirs];
|
|
10727
|
+
const worker = async () => {
|
|
10728
|
+
for (let dir = queue.shift(); dir; dir = queue.shift())
|
|
10729
|
+
await sync(ctx, dir);
|
|
10730
|
+
};
|
|
10731
|
+
await Promise.all(Array.from({ length: Math.min(FETCHES, queue.length) }, worker));
|
|
10732
|
+
}
|
|
10733
|
+
async function sync(ctx, dir) {
|
|
10734
|
+
const facet2 = dir.git;
|
|
10735
|
+
if (!facet2)
|
|
10736
|
+
return;
|
|
10737
|
+
try {
|
|
10738
|
+
await ctx.read("git", ["fetch", "--all", "--quiet"], { cwd: dir.path });
|
|
10739
|
+
} catch (error) {
|
|
10740
|
+
dir.problems ??= [];
|
|
10741
|
+
dir.problems.push(`git fetch: ${error instanceof Error ? error.message : String(error)}`);
|
|
10742
|
+
}
|
|
10743
|
+
const counts = await git(ctx, dir.path, ["rev-list", "--left-right", "--count", "HEAD...@{upstream}"]);
|
|
10744
|
+
const [ahead, behind] = (counts ?? "").split(/\s+/).map(Number);
|
|
10745
|
+
if (ahead === void 0 || behind === void 0 || Number.isNaN(ahead) || Number.isNaN(behind))
|
|
10746
|
+
return;
|
|
10747
|
+
facet2.ahead = ahead;
|
|
10748
|
+
facet2.behind = behind;
|
|
10749
|
+
}
|
|
10750
|
+
var whyUnreadable = (error) => error.code ?? (error instanceof Error ? error.message : String(error));
|
|
10751
|
+
var isMissing = (error) => ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
|
|
10752
|
+
async function appsOf(ctx, repo) {
|
|
10753
|
+
const read = { apps: [], links: [], unreadable: [] };
|
|
10754
|
+
const dir = join3(repo, APPS_DIR);
|
|
10755
|
+
let entries;
|
|
10756
|
+
try {
|
|
10757
|
+
entries = await ctx.readDir(dir);
|
|
10758
|
+
} catch (error) {
|
|
10759
|
+
if (!isMissing(error))
|
|
10760
|
+
read.unreadable.push({ path: dir, why: whyUnreadable(error) });
|
|
10761
|
+
return read;
|
|
10762
|
+
}
|
|
10763
|
+
for (const entry of [...entries].sort(byName)) {
|
|
10764
|
+
const path3 = join3(dir, entry.name);
|
|
10765
|
+
if (entry.symlink) {
|
|
10766
|
+
if (await isDirectory(ctx, path3))
|
|
10767
|
+
read.links.push(path3);
|
|
10768
|
+
continue;
|
|
10769
|
+
}
|
|
10770
|
+
if (!entry.directory)
|
|
10771
|
+
continue;
|
|
10772
|
+
try {
|
|
10773
|
+
if (holdsApp(await ctx.readDir(path3)))
|
|
10774
|
+
read.apps.push(path3);
|
|
10775
|
+
} catch (error) {
|
|
10776
|
+
read.unreadable.push({ path: path3, why: whyUnreadable(error) });
|
|
10777
|
+
}
|
|
10778
|
+
}
|
|
10779
|
+
return read;
|
|
10780
|
+
}
|
|
10781
|
+
var byName = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
|
|
10782
|
+
var isDirectory = (ctx, path3) => ctx.readDir(path3).then(() => true, () => false);
|
|
10783
|
+
var linksToRepo = (ctx, path3) => ctx.readDir(path3).then((entries) => entries.some((e) => e.name === ".git"), () => false);
|
|
10784
|
+
async function walk(ctx, path3, name, options, apps) {
|
|
10785
|
+
let entries;
|
|
10786
|
+
try {
|
|
10787
|
+
entries = await ctx.readDir(path3);
|
|
10788
|
+
} catch (error) {
|
|
10789
|
+
return { name, path: path3, children: [], unreadable: whyUnreadable(error) };
|
|
10790
|
+
}
|
|
10791
|
+
const dir = await facetsOf(ctx, path3, name, entries, options);
|
|
10792
|
+
const own = dir.gitRoot ? await appsOf(ctx, path3) : void 0;
|
|
10793
|
+
if (own)
|
|
10794
|
+
dir.apps = own.apps;
|
|
10795
|
+
for (const entry of [...entries].sort(byName)) {
|
|
10796
|
+
const sub = join3(path3, entry.name);
|
|
10797
|
+
if (entry.symlink) {
|
|
10798
|
+
if (apps?.links.includes(sub) || await linksToRepo(ctx, sub))
|
|
10799
|
+
dir.children.push({ name: entry.name, path: sub, symlink: true, children: [] });
|
|
10800
|
+
continue;
|
|
10801
|
+
}
|
|
10802
|
+
const app = apps?.apps.includes(sub) ?? false;
|
|
10803
|
+
if (!entry.directory || !descends(entry.name, app))
|
|
10804
|
+
continue;
|
|
10805
|
+
const child = await walk(ctx, sub, entry.name, options, own && entry.name === APPS_DIR ? own : void 0);
|
|
10806
|
+
if (app || isNotable(child) || child.children.length > 0)
|
|
10807
|
+
dir.children.push(child);
|
|
10808
|
+
}
|
|
10809
|
+
return dir;
|
|
10810
|
+
}
|
|
10811
|
+
async function directoryAt(ctx, path3) {
|
|
10812
|
+
const name = path3.replace(/\/+$/, "").split("/").pop() || path3;
|
|
10813
|
+
return facetsOf(ctx, path3, name, await ctx.readDir(path3), { git: false, fetch: false });
|
|
10814
|
+
}
|
|
10815
|
+
async function facetsOf(ctx, path3, name, entries, options) {
|
|
10816
|
+
const files = new Set(entries.filter((e) => !e.directory).map((e) => e.name));
|
|
10817
|
+
const names = new Set(entries.map((e) => e.name));
|
|
10818
|
+
const dir = { name, path: path3, children: [] };
|
|
10819
|
+
if (names.has(".git")) {
|
|
10820
|
+
dir.gitRoot = true;
|
|
10821
|
+
if (options.git)
|
|
10822
|
+
dir.git = await gitFacet(ctx, path3);
|
|
10823
|
+
}
|
|
10824
|
+
if (TEMPLATE_FILES.some((f) => files.has(f)))
|
|
10825
|
+
dir.template = options.git ? await templateFacet(ctx, path3) : {};
|
|
10826
|
+
if (files.has(ANSWERS_FILE)) {
|
|
10827
|
+
await facet(ctx, dir, ANSWERS_FILE, (text) => {
|
|
10828
|
+
dir.copier = parseAnswers(text);
|
|
10829
|
+
});
|
|
10830
|
+
}
|
|
10831
|
+
if (files.has(MARKER_FILE)) {
|
|
10832
|
+
await facet(ctx, dir, MARKER_FILE, (text) => {
|
|
10833
|
+
dir.declaration = parseMarker(text);
|
|
10834
|
+
});
|
|
10835
|
+
}
|
|
10836
|
+
if (files.has(MISE_FILE)) {
|
|
10837
|
+
await facet(ctx, dir, MISE_FILE, (text) => {
|
|
10838
|
+
const pin = plxPinOf(text);
|
|
10839
|
+
if (pin)
|
|
10840
|
+
dir.pin = pin;
|
|
10841
|
+
});
|
|
10842
|
+
}
|
|
10843
|
+
return dir;
|
|
10844
|
+
}
|
|
10845
|
+
async function facet(ctx, dir, file, read) {
|
|
10846
|
+
try {
|
|
10847
|
+
read(await ctx.readFile(join3(dir.path, file)));
|
|
10848
|
+
} catch (error) {
|
|
10849
|
+
dir.problems ??= [];
|
|
10850
|
+
dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
10851
|
+
}
|
|
10852
|
+
}
|
|
10853
|
+
async function git(ctx, cwd, args) {
|
|
10854
|
+
try {
|
|
10855
|
+
const out = (await ctx.read("git", args, { cwd })).trim();
|
|
10856
|
+
return out === "" ? void 0 : out;
|
|
10857
|
+
} catch {
|
|
10858
|
+
return void 0;
|
|
10859
|
+
}
|
|
10860
|
+
}
|
|
10861
|
+
async function gitFacet(ctx, cwd) {
|
|
10862
|
+
const branch = await git(ctx, cwd, ["symbolic-ref", "--short", "-q", "HEAD"]) ?? await git(ctx, cwd, ["rev-parse", "--short", "HEAD"]) ?? "?";
|
|
10863
|
+
const dirty = await git(ctx, cwd, ["status", "--porcelain"]) !== void 0;
|
|
10864
|
+
const remote = await git(ctx, cwd, ["remote", "get-url", "origin"]);
|
|
10865
|
+
let defaultRef = await git(ctx, cwd, ["symbolic-ref", "--short", "-q", "refs/remotes/origin/HEAD"]);
|
|
10866
|
+
for (const b of ["main", "master"]) {
|
|
10867
|
+
if (defaultRef)
|
|
10868
|
+
break;
|
|
10869
|
+
if (await git(ctx, cwd, ["rev-parse", "--verify", "-q", `refs/heads/${b}`]))
|
|
10870
|
+
defaultRef = b;
|
|
10871
|
+
}
|
|
10872
|
+
const tag = defaultRef ? await git(ctx, cwd, ["describe", "--tags", "--abbrev=0", defaultRef]) : void 0;
|
|
10873
|
+
const facet2 = { branch, dirty };
|
|
10874
|
+
if (tag)
|
|
10875
|
+
facet2.tag = tag;
|
|
10876
|
+
if (remote)
|
|
10877
|
+
facet2.remote = shortRemote(remote);
|
|
10878
|
+
return facet2;
|
|
10879
|
+
}
|
|
10880
|
+
async function templateFacet(ctx, cwd) {
|
|
10881
|
+
const tag = await git(ctx, cwd, ["describe", "--tags", "--abbrev=0"]) ?? (await git(ctx, cwd, ["tag", "--list", "--sort=-v:refname"]))?.split("\n")[0];
|
|
10882
|
+
return tag ? { tag } : {};
|
|
10883
|
+
}
|
|
10884
|
+
|
|
10615
10885
|
// ../lib/dist/consumers.js
|
|
10616
10886
|
function expectedBranch(repo) {
|
|
10617
10887
|
if (!repo.declaration)
|
|
@@ -10628,9 +10898,9 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10628
10898
|
const within = inTemplate || Boolean(dir.template);
|
|
10629
10899
|
const template = dir.copier?.src ? templateOf(dir.copier.src, templates) : void 0;
|
|
10630
10900
|
if (template && !within) {
|
|
10631
|
-
const
|
|
10901
|
+
const site2 = { path: dir.path, rel: relative(root.path, dir.path) || ".", template };
|
|
10632
10902
|
if (!here)
|
|
10633
|
-
orphans.push(
|
|
10903
|
+
orphans.push(site2);
|
|
10634
10904
|
else {
|
|
10635
10905
|
let consumer = consumers.get(here.path);
|
|
10636
10906
|
if (!consumer) {
|
|
@@ -10644,15 +10914,15 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10644
10914
|
};
|
|
10645
10915
|
consumers.set(here.path, consumer);
|
|
10646
10916
|
}
|
|
10647
|
-
consumer.sites.push(
|
|
10917
|
+
consumer.sites.push(site2);
|
|
10648
10918
|
}
|
|
10649
10919
|
}
|
|
10650
10920
|
for (const child of dir.children)
|
|
10651
10921
|
visit(child, here, within);
|
|
10652
10922
|
};
|
|
10653
10923
|
visit(root, void 0, false);
|
|
10654
|
-
for (const
|
|
10655
|
-
ctx.say(`\u26A0 ${
|
|
10924
|
+
for (const site2 of orphans)
|
|
10925
|
+
ctx.say(`\u26A0 ${site2.rel}: not inside a git repo \u2014 skipped`);
|
|
10656
10926
|
for (const c of consumers.values()) {
|
|
10657
10927
|
const origin = (await ctx.read("git", ["remote", "get-url", "origin"], { cwd: c.path }).catch(() => "")).trim();
|
|
10658
10928
|
if (origin === "")
|
|
@@ -10662,6 +10932,25 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10662
10932
|
}
|
|
10663
10933
|
return [...consumers.values()];
|
|
10664
10934
|
}
|
|
10935
|
+
async function sitesOfTree(ctx, repo, commit) {
|
|
10936
|
+
const files = (await ctx.read("git", ["ls-tree", "-r", "-z", "--name-only", commit], { cwd: repo })).split("\0").filter(Boolean);
|
|
10937
|
+
const sites = [];
|
|
10938
|
+
for (const dir of answersDirs(files)) {
|
|
10939
|
+
const text = await ctx.read("git", ["cat-file", "blob", `${commit}:${join4(dir, ANSWERS_FILE)}`], { cwd: repo });
|
|
10940
|
+
let answers;
|
|
10941
|
+
try {
|
|
10942
|
+
answers = parseAnswers(text);
|
|
10943
|
+
} catch {
|
|
10944
|
+
sites.push({ dir });
|
|
10945
|
+
continue;
|
|
10946
|
+
}
|
|
10947
|
+
const template = answers.src ? templateOf(answers.src, TEMPLATES) : void 0;
|
|
10948
|
+
if (template)
|
|
10949
|
+
sites.push({ dir, answers, template });
|
|
10950
|
+
}
|
|
10951
|
+
sites.sort((a, b) => Number(b.dir === ".") - Number(a.dir === "."));
|
|
10952
|
+
return { files, sites };
|
|
10953
|
+
}
|
|
10665
10954
|
|
|
10666
10955
|
// ../lib/dist/context.js
|
|
10667
10956
|
var Context = class {
|
|
@@ -10804,32 +11093,14 @@ function indent(text) {
|
|
|
10804
11093
|
return text.trimEnd().split("\n").map((l) => ` ${l}`).join("\n");
|
|
10805
11094
|
}
|
|
10806
11095
|
|
|
10807
|
-
// ../lib/dist/copier.js
|
|
10808
|
-
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10809
|
-
var ANSWERS_FILE = ".copier-answers.yml";
|
|
10810
|
-
var TEMPLATE_FILES = ["copier.yml", "copier.yaml"];
|
|
10811
|
-
var COPIER_VERSION = "9.19.1";
|
|
10812
|
-
var copierVia = (args) => ["exec", `copier@${COPIER_VERSION}`, "--", "copier", ...args];
|
|
10813
|
-
function parseAnswers(text) {
|
|
10814
|
-
const data = (0, import_yaml4.parse)(text);
|
|
10815
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
10816
|
-
throw new Error("answers file is not a mapping");
|
|
10817
|
-
const { _commit, _src_path, ...answers } = data;
|
|
10818
|
-
return {
|
|
10819
|
-
commit: _commit === void 0 ? void 0 : String(_commit),
|
|
10820
|
-
src: _src_path === void 0 ? void 0 : String(_src_path),
|
|
10821
|
-
answers
|
|
10822
|
-
};
|
|
10823
|
-
}
|
|
10824
|
-
|
|
10825
11096
|
// ../lib/dist/deploy.js
|
|
10826
11097
|
import { randomBytes } from "node:crypto";
|
|
10827
11098
|
import { tmpdir } from "node:os";
|
|
10828
|
-
import { join as
|
|
11099
|
+
import { join as join6 } from "node:path";
|
|
10829
11100
|
|
|
10830
11101
|
// ../lib/dist/deployTargets.js
|
|
10831
11102
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
10832
|
-
import { join as
|
|
11103
|
+
import { join as join5 } from "node:path";
|
|
10833
11104
|
var VARS_DIRS = ["group_vars", "host_vars"];
|
|
10834
11105
|
var DEFAULT_ENVIRONMENT = "production";
|
|
10835
11106
|
function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
|
|
@@ -10877,23 +11148,48 @@ function targetsIn(targets, environment) {
|
|
|
10877
11148
|
}
|
|
10878
11149
|
return flat;
|
|
10879
11150
|
}
|
|
10880
|
-
function
|
|
11151
|
+
function recordsWithoutTarget(files, environment) {
|
|
11152
|
+
const targeted = targetsIn(selectDeployTargets(files), environment);
|
|
11153
|
+
const found = {};
|
|
11154
|
+
for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
|
|
11155
|
+
if (file.target !== void 0)
|
|
11156
|
+
continue;
|
|
11157
|
+
for (const d of file.apps) {
|
|
11158
|
+
if (d.environment !== environment || d.app in targeted)
|
|
11159
|
+
continue;
|
|
11160
|
+
const paths = found[d.app] ?? [];
|
|
11161
|
+
if (!paths.includes(file.path))
|
|
11162
|
+
paths.push(file.path);
|
|
11163
|
+
found[d.app] = paths;
|
|
11164
|
+
}
|
|
11165
|
+
}
|
|
11166
|
+
return found;
|
|
11167
|
+
}
|
|
11168
|
+
function deployLegs(targets, apps, recordsWithout = {}) {
|
|
10881
11169
|
const legs = [];
|
|
11170
|
+
const untargeted = [];
|
|
10882
11171
|
const without = [];
|
|
10883
11172
|
for (const app of [...apps].sort()) {
|
|
10884
11173
|
const host = targets[app];
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
else
|
|
11174
|
+
const files = recordsWithout[app];
|
|
11175
|
+
if (host !== void 0)
|
|
10888
11176
|
legs.push({ app, host });
|
|
11177
|
+
else if (files !== void 0)
|
|
11178
|
+
untargeted.push({ app, files });
|
|
11179
|
+
else
|
|
11180
|
+
without.push(app);
|
|
10889
11181
|
}
|
|
10890
|
-
return { legs, without };
|
|
11182
|
+
return { legs, untargeted, without };
|
|
10891
11183
|
}
|
|
10892
|
-
|
|
11184
|
+
function untargetedError(untargeted, environment) {
|
|
11185
|
+
const lines = untargeted.map(({ app, files }) => `${app} has a record in ${environment} in ${files.join(" and ")}, which names no plexus_deploy_target`);
|
|
11186
|
+
return new Error(lines.join("\n"));
|
|
11187
|
+
}
|
|
11188
|
+
async function readInventory(ctx, inventory) {
|
|
10893
11189
|
const files = [];
|
|
10894
11190
|
let found = false;
|
|
10895
11191
|
for (const sub of VARS_DIRS) {
|
|
10896
|
-
const dir =
|
|
11192
|
+
const dir = join5(inventory, sub);
|
|
10897
11193
|
const entries = await ctx.readDir(dir).catch(() => void 0);
|
|
10898
11194
|
if (entries === void 0)
|
|
10899
11195
|
continue;
|
|
@@ -10901,13 +11197,13 @@ async function readDeployTargets(ctx, inventory) {
|
|
|
10901
11197
|
for (const e of entries) {
|
|
10902
11198
|
if (e.directory || !/\.ya?ml$/.test(e.name))
|
|
10903
11199
|
continue;
|
|
10904
|
-
const path3 =
|
|
11200
|
+
const path3 = join5(dir, e.name);
|
|
10905
11201
|
files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
|
|
10906
11202
|
}
|
|
10907
11203
|
}
|
|
10908
11204
|
if (!found && await ctx.readDir(inventory).catch(() => void 0) === void 0)
|
|
10909
11205
|
throw new UsageError(`no inventory directory at ${inventory}`);
|
|
10910
|
-
return
|
|
11206
|
+
return files;
|
|
10911
11207
|
}
|
|
10912
11208
|
|
|
10913
11209
|
// ../lib/dist/deploy.js
|
|
@@ -10929,7 +11225,7 @@ function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
|
|
|
10929
11225
|
}
|
|
10930
11226
|
var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
|
|
10931
11227
|
var Remote = class {
|
|
10932
|
-
socket =
|
|
11228
|
+
socket = join6(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
|
|
10933
11229
|
ctx;
|
|
10934
11230
|
host;
|
|
10935
11231
|
constructor(ctx, host) {
|
|
@@ -11007,7 +11303,7 @@ async function deploy(ctx, options) {
|
|
|
11007
11303
|
let text = "";
|
|
11008
11304
|
for (const candidate of [`${source}/docker/compose.yaml`, `${source}/compose.yaml`]) {
|
|
11009
11305
|
try {
|
|
11010
|
-
text = await ctx.readFile(
|
|
11306
|
+
text = await ctx.readFile(join6(dir, candidate));
|
|
11011
11307
|
compose = candidate;
|
|
11012
11308
|
break;
|
|
11013
11309
|
} catch {
|
|
@@ -11076,272 +11372,75 @@ async function deploy(ctx, options) {
|
|
|
11076
11372
|
await s.remote.close().catch(() => void 0);
|
|
11077
11373
|
}
|
|
11078
11374
|
}
|
|
11079
|
-
async function stage(s, rendered) {
|
|
11080
|
-
const { D } = s;
|
|
11081
|
-
await s.remote.exec(`rm -rf ${D}/${INCOMING} && mkdir -p ${D}/${INCOMING} && cat > ${D}/${INCOMING}/compose.yaml`, rendered);
|
|
11082
|
-
}
|
|
11083
|
-
async function alreadyServing(s) {
|
|
11084
|
-
const { ctx, result } = s;
|
|
11085
|
-
if (ctx.dryRun) {
|
|
11086
|
-
ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
|
|
11087
|
-
return false;
|
|
11088
|
-
}
|
|
11089
|
-
if (!(s.image ? result.previous === s.image : result.previous !== void 0))
|
|
11090
|
-
return false;
|
|
11091
|
-
if (!await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`))
|
|
11092
|
-
return false;
|
|
11093
|
-
if (!await awaitHealthy(s, 1))
|
|
11094
|
-
return false;
|
|
11095
|
-
result.live = result.previous;
|
|
11096
|
-
result.healthy = true;
|
|
11097
|
-
result.unchanged = true;
|
|
11098
|
-
ctx.done(`${result.previous} is already live and healthy; nothing to do`);
|
|
11099
|
-
return true;
|
|
11100
|
-
}
|
|
11101
|
-
async function pullAndMigrate(s) {
|
|
11102
|
-
await s.remote.exec(`${s.dci} pull`);
|
|
11103
|
-
const migrate = await s.remote.test(`${s.dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
|
|
11104
|
-
if (migrate === void 0)
|
|
11105
|
-
s.ctx.say(" (if compose.yaml declares a migrate service:)");
|
|
11106
|
-
if (migrate !== false)
|
|
11107
|
-
await s.remote.exec(`${s.dci} run --rm migrate </dev/null`);
|
|
11108
|
-
}
|
|
11109
|
-
async function swapAndUp(s) {
|
|
11110
|
-
const { D } = s;
|
|
11111
|
-
const hadPrev = await s.remote.test(`test -f ${D}/compose.yaml`);
|
|
11112
|
-
if (hadPrev !== false)
|
|
11113
|
-
await s.remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11114
|
-
await s.remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
|
|
11115
|
-
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11116
|
-
return hadPrev;
|
|
11117
|
-
}
|
|
11118
|
-
function awaitHealthy(s, attempts, show = false) {
|
|
11119
|
-
const status = `docker compose ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' 2>/dev/null`;
|
|
11120
|
-
return s.remote.test(`cd ${s.D} && for _ in $(seq 1 ${attempts}); do [ "$(${status})" = healthy ] && exit 0; sleep 2; done; exit 1`, show);
|
|
11121
|
-
}
|
|
11122
|
-
async function rollback(s, hadPrev, retries) {
|
|
11123
|
-
const { ctx, D, result } = s;
|
|
11124
|
-
const differs = hadPrev && await s.remote.test(`cd ${D} && ! cmp -s compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11125
|
-
if (!differs) {
|
|
11126
|
-
ctx.done("nothing to roll back to (first deploy, or the same run shape re-deployed); manual intervention needed", false);
|
|
11127
|
-
return;
|
|
11128
|
-
}
|
|
11129
|
-
await s.remote.exec(`cd ${D} && cp -p ${INCOMING}/compose.yaml.prev compose.yaml`);
|
|
11130
|
-
ctx.say(`\u21A9 rolling back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11131
|
-
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11132
|
-
result.rolledBack = true;
|
|
11133
|
-
if (await awaitHealthy(s, retries)) {
|
|
11134
|
-
result.live = result.previous;
|
|
11135
|
-
ctx.done(`rolled back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11136
|
-
} else {
|
|
11137
|
-
ctx.done("rollback also unhealthy; manual intervention needed", false);
|
|
11138
|
-
}
|
|
11139
|
-
}
|
|
11140
|
-
|
|
11141
|
-
// ../lib/dist/doctor.js
|
|
11142
|
-
import { realpath } from "node:fs/promises";
|
|
11143
|
-
import { dirname as dirname2, join as join5, relative as relative2, resolve } from "node:path";
|
|
11144
|
-
|
|
11145
|
-
// ../lib/dist/overview.js
|
|
11146
|
-
import { join as join4 } from "node:path";
|
|
11147
|
-
var PRUNED = /* @__PURE__ */ new Set([
|
|
11148
|
-
"node_modules",
|
|
11149
|
-
".hg",
|
|
11150
|
-
".svn",
|
|
11151
|
-
".next",
|
|
11152
|
-
".nuxt",
|
|
11153
|
-
".turbo",
|
|
11154
|
-
".svelte-kit",
|
|
11155
|
-
"dist",
|
|
11156
|
-
"build",
|
|
11157
|
-
"out",
|
|
11158
|
-
".output",
|
|
11159
|
-
".venv",
|
|
11160
|
-
"venv",
|
|
11161
|
-
"__pycache__",
|
|
11162
|
-
"target",
|
|
11163
|
-
".cache",
|
|
11164
|
-
".pnpm-store",
|
|
11165
|
-
"coverage",
|
|
11166
|
-
"vendor",
|
|
11167
|
-
".terraform",
|
|
11168
|
-
".gradle"
|
|
11169
|
-
]);
|
|
11170
|
-
var MISE_FILE = "mise.toml";
|
|
11171
|
-
var FETCHES = 8;
|
|
11172
|
-
async function overview(ctx, root, options = {}) {
|
|
11173
|
-
const opts = { git: true, fetch: false, ...options };
|
|
11174
|
-
const tree = await walk(ctx, root, root.replace(/\/+$/, "").split("/").pop() || root, opts);
|
|
11175
|
-
if (opts.git && opts.fetch)
|
|
11176
|
-
await syncAll(ctx, repos(tree));
|
|
11177
|
-
return tree;
|
|
11178
|
-
}
|
|
11179
|
-
function repos(dir) {
|
|
11180
|
-
return [...dir.git ? [dir] : [], ...dir.children.flatMap(repos)];
|
|
11181
|
-
}
|
|
11182
|
-
async function syncAll(ctx, dirs) {
|
|
11183
|
-
const queue = [...dirs];
|
|
11184
|
-
const worker = async () => {
|
|
11185
|
-
for (let dir = queue.shift(); dir; dir = queue.shift())
|
|
11186
|
-
await sync(ctx, dir);
|
|
11187
|
-
};
|
|
11188
|
-
await Promise.all(Array.from({ length: Math.min(FETCHES, queue.length) }, worker));
|
|
11189
|
-
}
|
|
11190
|
-
async function sync(ctx, dir) {
|
|
11191
|
-
const facet2 = dir.git;
|
|
11192
|
-
if (!facet2)
|
|
11193
|
-
return;
|
|
11194
|
-
try {
|
|
11195
|
-
await ctx.read("git", ["fetch", "--all", "--quiet"], { cwd: dir.path });
|
|
11196
|
-
} catch (error) {
|
|
11197
|
-
dir.problems ??= [];
|
|
11198
|
-
dir.problems.push(`git fetch: ${error instanceof Error ? error.message : String(error)}`);
|
|
11199
|
-
}
|
|
11200
|
-
const counts = await git(ctx, dir.path, ["rev-list", "--left-right", "--count", "HEAD...@{upstream}"]);
|
|
11201
|
-
const [ahead, behind] = (counts ?? "").split(/\s+/).map(Number);
|
|
11202
|
-
if (ahead === void 0 || behind === void 0 || Number.isNaN(ahead) || Number.isNaN(behind))
|
|
11203
|
-
return;
|
|
11204
|
-
facet2.ahead = ahead;
|
|
11205
|
-
facet2.behind = behind;
|
|
11206
|
-
}
|
|
11207
|
-
var whyUnreadable = (error) => error.code ?? (error instanceof Error ? error.message : String(error));
|
|
11208
|
-
var isMissing = (error) => ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
|
|
11209
|
-
async function appsOf(ctx, repo) {
|
|
11210
|
-
const read = { apps: [], links: [], unreadable: [] };
|
|
11211
|
-
const dir = join4(repo, APPS_DIR);
|
|
11212
|
-
let entries;
|
|
11213
|
-
try {
|
|
11214
|
-
entries = await ctx.readDir(dir);
|
|
11215
|
-
} catch (error) {
|
|
11216
|
-
if (!isMissing(error))
|
|
11217
|
-
read.unreadable.push({ path: dir, why: whyUnreadable(error) });
|
|
11218
|
-
return read;
|
|
11219
|
-
}
|
|
11220
|
-
for (const entry of [...entries].sort(byName)) {
|
|
11221
|
-
const path3 = join4(dir, entry.name);
|
|
11222
|
-
if (entry.symlink) {
|
|
11223
|
-
if (await isDirectory(ctx, path3))
|
|
11224
|
-
read.links.push(path3);
|
|
11225
|
-
continue;
|
|
11226
|
-
}
|
|
11227
|
-
if (!entry.directory)
|
|
11228
|
-
continue;
|
|
11229
|
-
try {
|
|
11230
|
-
if (holdsApp(await ctx.readDir(path3)))
|
|
11231
|
-
read.apps.push(path3);
|
|
11232
|
-
} catch (error) {
|
|
11233
|
-
read.unreadable.push({ path: path3, why: whyUnreadable(error) });
|
|
11234
|
-
}
|
|
11235
|
-
}
|
|
11236
|
-
return read;
|
|
11237
|
-
}
|
|
11238
|
-
var byName = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
|
|
11239
|
-
var isDirectory = (ctx, path3) => ctx.readDir(path3).then(() => true, () => false);
|
|
11240
|
-
var linksToRepo = (ctx, path3) => ctx.readDir(path3).then((entries) => entries.some((e) => e.name === ".git"), () => false);
|
|
11241
|
-
async function walk(ctx, path3, name, options, apps) {
|
|
11242
|
-
let entries;
|
|
11243
|
-
try {
|
|
11244
|
-
entries = await ctx.readDir(path3);
|
|
11245
|
-
} catch (error) {
|
|
11246
|
-
return { name, path: path3, children: [], unreadable: whyUnreadable(error) };
|
|
11247
|
-
}
|
|
11248
|
-
const dir = await facetsOf(ctx, path3, name, entries, options);
|
|
11249
|
-
const own = dir.gitRoot ? await appsOf(ctx, path3) : void 0;
|
|
11250
|
-
if (own)
|
|
11251
|
-
dir.apps = own.apps;
|
|
11252
|
-
for (const entry of [...entries].sort(byName)) {
|
|
11253
|
-
const sub = join4(path3, entry.name);
|
|
11254
|
-
if (entry.symlink) {
|
|
11255
|
-
if (apps?.links.includes(sub) || await linksToRepo(ctx, sub))
|
|
11256
|
-
dir.children.push({ name: entry.name, path: sub, symlink: true, children: [] });
|
|
11257
|
-
continue;
|
|
11258
|
-
}
|
|
11259
|
-
const app = apps?.apps.includes(sub) ?? false;
|
|
11260
|
-
if (!entry.directory || entry.name === ".git" || PRUNED.has(entry.name) && !app)
|
|
11261
|
-
continue;
|
|
11262
|
-
const child = await walk(ctx, sub, entry.name, options, own && entry.name === APPS_DIR ? own : void 0);
|
|
11263
|
-
if (app || isNotable(child) || child.children.length > 0)
|
|
11264
|
-
dir.children.push(child);
|
|
11265
|
-
}
|
|
11266
|
-
return dir;
|
|
11267
|
-
}
|
|
11268
|
-
async function directoryAt(ctx, path3) {
|
|
11269
|
-
const name = path3.replace(/\/+$/, "").split("/").pop() || path3;
|
|
11270
|
-
return facetsOf(ctx, path3, name, await ctx.readDir(path3), { git: false, fetch: false });
|
|
11271
|
-
}
|
|
11272
|
-
async function facetsOf(ctx, path3, name, entries, options) {
|
|
11273
|
-
const files = new Set(entries.filter((e) => !e.directory).map((e) => e.name));
|
|
11274
|
-
const names = new Set(entries.map((e) => e.name));
|
|
11275
|
-
const dir = { name, path: path3, children: [] };
|
|
11276
|
-
if (names.has(".git")) {
|
|
11277
|
-
dir.gitRoot = true;
|
|
11278
|
-
if (options.git)
|
|
11279
|
-
dir.git = await gitFacet(ctx, path3);
|
|
11280
|
-
}
|
|
11281
|
-
if (TEMPLATE_FILES.some((f) => files.has(f)))
|
|
11282
|
-
dir.template = options.git ? await templateFacet(ctx, path3) : {};
|
|
11283
|
-
if (files.has(ANSWERS_FILE)) {
|
|
11284
|
-
await facet(ctx, dir, ANSWERS_FILE, (text) => {
|
|
11285
|
-
dir.copier = parseAnswers(text);
|
|
11286
|
-
});
|
|
11287
|
-
}
|
|
11288
|
-
if (files.has(MARKER_FILE)) {
|
|
11289
|
-
await facet(ctx, dir, MARKER_FILE, (text) => {
|
|
11290
|
-
dir.declaration = parseMarker(text);
|
|
11291
|
-
});
|
|
11292
|
-
}
|
|
11293
|
-
if (files.has(MISE_FILE)) {
|
|
11294
|
-
await facet(ctx, dir, MISE_FILE, (text) => {
|
|
11295
|
-
const pin = plxPinOf(text);
|
|
11296
|
-
if (pin)
|
|
11297
|
-
dir.pin = pin;
|
|
11298
|
-
});
|
|
11299
|
-
}
|
|
11300
|
-
return dir;
|
|
11301
|
-
}
|
|
11302
|
-
async function facet(ctx, dir, file, read) {
|
|
11303
|
-
try {
|
|
11304
|
-
read(await ctx.readFile(join4(dir.path, file)));
|
|
11305
|
-
} catch (error) {
|
|
11306
|
-
dir.problems ??= [];
|
|
11307
|
-
dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
11308
|
-
}
|
|
11309
|
-
}
|
|
11310
|
-
async function git(ctx, cwd, args) {
|
|
11311
|
-
try {
|
|
11312
|
-
const out = (await ctx.read("git", args, { cwd })).trim();
|
|
11313
|
-
return out === "" ? void 0 : out;
|
|
11314
|
-
} catch {
|
|
11315
|
-
return void 0;
|
|
11316
|
-
}
|
|
11375
|
+
async function stage(s, rendered) {
|
|
11376
|
+
const { D } = s;
|
|
11377
|
+
await s.remote.exec(`rm -rf ${D}/${INCOMING} && mkdir -p ${D}/${INCOMING} && cat > ${D}/${INCOMING}/compose.yaml`, rendered);
|
|
11317
11378
|
}
|
|
11318
|
-
async function
|
|
11319
|
-
const
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
for (const b of ["main", "master"]) {
|
|
11324
|
-
if (defaultRef)
|
|
11325
|
-
break;
|
|
11326
|
-
if (await git(ctx, cwd, ["rev-parse", "--verify", "-q", `refs/heads/${b}`]))
|
|
11327
|
-
defaultRef = b;
|
|
11379
|
+
async function alreadyServing(s) {
|
|
11380
|
+
const { ctx, result } = s;
|
|
11381
|
+
if (ctx.dryRun) {
|
|
11382
|
+
ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
|
|
11383
|
+
return false;
|
|
11328
11384
|
}
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
if (
|
|
11332
|
-
|
|
11333
|
-
if (
|
|
11334
|
-
|
|
11335
|
-
|
|
11385
|
+
if (!(s.image ? result.previous === s.image : result.previous !== void 0))
|
|
11386
|
+
return false;
|
|
11387
|
+
if (!await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`))
|
|
11388
|
+
return false;
|
|
11389
|
+
if (!await awaitHealthy(s, 1))
|
|
11390
|
+
return false;
|
|
11391
|
+
result.live = result.previous;
|
|
11392
|
+
result.healthy = true;
|
|
11393
|
+
result.unchanged = true;
|
|
11394
|
+
ctx.done(`${result.previous} is already live and healthy; nothing to do`);
|
|
11395
|
+
return true;
|
|
11336
11396
|
}
|
|
11337
|
-
async function
|
|
11338
|
-
|
|
11339
|
-
|
|
11397
|
+
async function pullAndMigrate(s) {
|
|
11398
|
+
await s.remote.exec(`${s.dci} pull`);
|
|
11399
|
+
const migrate = await s.remote.test(`${s.dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
|
|
11400
|
+
if (migrate === void 0)
|
|
11401
|
+
s.ctx.say(" (if compose.yaml declares a migrate service:)");
|
|
11402
|
+
if (migrate !== false)
|
|
11403
|
+
await s.remote.exec(`${s.dci} run --rm migrate </dev/null`);
|
|
11404
|
+
}
|
|
11405
|
+
async function swapAndUp(s) {
|
|
11406
|
+
const { D } = s;
|
|
11407
|
+
const hadPrev = await s.remote.test(`test -f ${D}/compose.yaml`);
|
|
11408
|
+
if (hadPrev !== false)
|
|
11409
|
+
await s.remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11410
|
+
await s.remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
|
|
11411
|
+
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11412
|
+
return hadPrev;
|
|
11413
|
+
}
|
|
11414
|
+
function awaitHealthy(s, attempts, show = false) {
|
|
11415
|
+
const status = `docker compose ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' 2>/dev/null`;
|
|
11416
|
+
return s.remote.test(`cd ${s.D} && for _ in $(seq 1 ${attempts}); do [ "$(${status})" = healthy ] && exit 0; sleep 2; done; exit 1`, show);
|
|
11417
|
+
}
|
|
11418
|
+
async function rollback(s, hadPrev, retries) {
|
|
11419
|
+
const { ctx, D, result } = s;
|
|
11420
|
+
const differs = hadPrev && await s.remote.test(`cd ${D} && ! cmp -s compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11421
|
+
if (!differs) {
|
|
11422
|
+
ctx.done("nothing to roll back to (first deploy, or the same run shape re-deployed); manual intervention needed", false);
|
|
11423
|
+
return;
|
|
11424
|
+
}
|
|
11425
|
+
await s.remote.exec(`cd ${D} && cp -p ${INCOMING}/compose.yaml.prev compose.yaml`);
|
|
11426
|
+
ctx.say(`\u21A9 rolling back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11427
|
+
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11428
|
+
result.rolledBack = true;
|
|
11429
|
+
if (await awaitHealthy(s, retries)) {
|
|
11430
|
+
result.live = result.previous;
|
|
11431
|
+
ctx.done(`rolled back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11432
|
+
} else {
|
|
11433
|
+
ctx.done("rollback also unhealthy; manual intervention needed", false);
|
|
11434
|
+
}
|
|
11340
11435
|
}
|
|
11341
11436
|
|
|
11437
|
+
// ../lib/dist/doctor.js
|
|
11438
|
+
import { realpath } from "node:fs/promises";
|
|
11439
|
+
import { dirname as dirname3, join as join7, relative as relative2, resolve } from "node:path";
|
|
11440
|
+
|
|
11342
11441
|
// ../lib/dist/standard-index.json
|
|
11343
11442
|
var standard_index_default = {
|
|
11344
|
-
version: "0.
|
|
11443
|
+
version: "0.128.0",
|
|
11345
11444
|
citable: [
|
|
11346
11445
|
"\xA7 1 PLX",
|
|
11347
11446
|
"\xA7 1.1 PLX",
|
|
@@ -11759,6 +11858,9 @@ function diagnoseUnit(unit, known) {
|
|
|
11759
11858
|
for (const problem of run2(c, unit, profile))
|
|
11760
11859
|
findings.push({ requirement: name, problem });
|
|
11761
11860
|
}
|
|
11861
|
+
if (unit.kind !== "app")
|
|
11862
|
+
for (const file of unit.conflicted ?? [])
|
|
11863
|
+
findings.push({ problem: `\`${file}\` holds a conflict marker` });
|
|
11762
11864
|
const obsolete = (declaration?.obsolete ?? []).map((k) => `\`${k}\``).join(" and ");
|
|
11763
11865
|
const hints = [];
|
|
11764
11866
|
if (obsolete)
|
|
@@ -11793,7 +11895,7 @@ async function examine(ctx, dir) {
|
|
|
11793
11895
|
let top = own.some((e) => e.name === ".git") ? given : void 0;
|
|
11794
11896
|
const tree = top ? void 0 : await overview(ctx, given, { git: false });
|
|
11795
11897
|
if (tree && !holdsGitRoot(tree))
|
|
11796
|
-
top = await enclosingGitRoot(ctx,
|
|
11898
|
+
top = await enclosingGitRoot(ctx, dirname3(given));
|
|
11797
11899
|
if (top) {
|
|
11798
11900
|
const repo = await directoryAt(ctx, top);
|
|
11799
11901
|
const found = await appsOf(ctx, top);
|
|
@@ -11830,11 +11932,11 @@ async function examine(ctx, dir) {
|
|
|
11830
11932
|
}
|
|
11831
11933
|
var holdsGitRoot = (d) => Boolean(d.gitRoot) || d.children.some(holdsGitRoot);
|
|
11832
11934
|
async function enclosingGitRoot(ctx, dir) {
|
|
11833
|
-
for (let at = resolve(dir); ; at =
|
|
11935
|
+
for (let at = resolve(dir); ; at = dirname3(at)) {
|
|
11834
11936
|
const entries = await ctx.readDir(at).catch(() => []);
|
|
11835
11937
|
if (entries.some((e) => e.name === ".git"))
|
|
11836
11938
|
return at;
|
|
11837
|
-
if (
|
|
11939
|
+
if (dirname3(at) === at)
|
|
11838
11940
|
return void 0;
|
|
11839
11941
|
}
|
|
11840
11942
|
}
|
|
@@ -11859,7 +11961,16 @@ async function readRepo(ctx, dir, path3, kind) {
|
|
|
11859
11961
|
return void 0;
|
|
11860
11962
|
throw error;
|
|
11861
11963
|
});
|
|
11862
|
-
|
|
11964
|
+
const conflicted = tracked === void 0 ? void 0 : await filesWithConflictMarkers(ctx, dir.path);
|
|
11965
|
+
return {
|
|
11966
|
+
kind,
|
|
11967
|
+
path: path3,
|
|
11968
|
+
...marker ? { marker } : {},
|
|
11969
|
+
tasks: await rootTasks(ctx, dir.path),
|
|
11970
|
+
tracked,
|
|
11971
|
+
...conflicted?.length ? { conflicted } : {},
|
|
11972
|
+
apps: []
|
|
11973
|
+
};
|
|
11863
11974
|
}
|
|
11864
11975
|
async function rootTasks(ctx, repo) {
|
|
11865
11976
|
let out;
|
|
@@ -11909,9 +12020,9 @@ async function readApp(ctx, dir, path3, inRepo, repo) {
|
|
|
11909
12020
|
dir: inRepo,
|
|
11910
12021
|
thirdParty: repo.kind === "operations",
|
|
11911
12022
|
marker: markerOf(dir) ?? {},
|
|
11912
|
-
dockerfile: (await ctx.readDir(
|
|
12023
|
+
dockerfile: (await ctx.readDir(join7(dir.path, "docker")).catch(() => [])).some((e) => e.name === "Dockerfile" && !e.directory)
|
|
11913
12024
|
};
|
|
11914
|
-
const compose = await ctx.readFile(
|
|
12025
|
+
const compose = await ctx.readFile(join7(dir.path, "docker/compose.yaml")).catch(() => void 0);
|
|
11915
12026
|
if (compose !== void 0) {
|
|
11916
12027
|
try {
|
|
11917
12028
|
app.compose = parseCompose(compose, "docker/compose.yaml");
|
|
@@ -11919,7 +12030,7 @@ async function readApp(ctx, dir, path3, inRepo, repo) {
|
|
|
11919
12030
|
app.composeProblem = error.message;
|
|
11920
12031
|
}
|
|
11921
12032
|
}
|
|
11922
|
-
const manifest2 = await ctx.readFile(
|
|
12033
|
+
const manifest2 = await ctx.readFile(join7(dir.path, "package.json")).catch(() => void 0);
|
|
11923
12034
|
if (manifest2 !== void 0) {
|
|
11924
12035
|
try {
|
|
11925
12036
|
const data = JSON.parse(manifest2);
|
|
@@ -12063,45 +12174,293 @@ function parseMaxAge(value, what) {
|
|
|
12063
12174
|
return Number(value.trim());
|
|
12064
12175
|
}
|
|
12065
12176
|
|
|
12066
|
-
// ../lib/dist/
|
|
12067
|
-
import { join as join6, relative as relative3 } from "node:path";
|
|
12068
|
-
var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
|
|
12069
|
-
function mergeSummary(into, from) {
|
|
12070
|
-
into.clean.push(...from.clean);
|
|
12071
|
-
into.conflicted.push(...from.conflicted);
|
|
12072
|
-
into.failed.push(...from.failed);
|
|
12073
|
-
into.skipped.push(...from.skipped);
|
|
12074
|
-
into.resting.push(...from.resting);
|
|
12075
|
-
into.pulls.push(...from.pulls);
|
|
12076
|
-
into.mergeable.push(...from.mergeable);
|
|
12077
|
-
}
|
|
12078
|
-
var emptySummary = (version2, preview) => ({
|
|
12079
|
-
version: version2,
|
|
12080
|
-
preview,
|
|
12081
|
-
clean: [],
|
|
12082
|
-
conflicted: [],
|
|
12083
|
-
failed: [],
|
|
12084
|
-
skipped: [],
|
|
12085
|
-
resting: [],
|
|
12086
|
-
pulls: [],
|
|
12087
|
-
mergeable: []
|
|
12088
|
-
});
|
|
12089
|
-
var CLEAN_BODY = "Merged clean at every site.";
|
|
12090
|
-
var ofConsumer = (list2, consumer) => list2.filter((p) => p === consumer.rel || p.startsWith(`${consumer.rel}/`));
|
|
12177
|
+
// ../lib/dist/pull.js
|
|
12091
12178
|
var versionBranch = (version2) => `plexus/${version2}`;
|
|
12179
|
+
var REVIEWERS_ANSWER = "pr_reviewers";
|
|
12180
|
+
function parseReviewers(value, what) {
|
|
12181
|
+
const logins = value.split(",").map((l) => l.trim()).filter(Boolean);
|
|
12182
|
+
for (const login of logins) {
|
|
12183
|
+
if (login.includes("/"))
|
|
12184
|
+
throw new Error(`${what} names \`${login}\`, a team; only users are requested`);
|
|
12185
|
+
if (!/^[A-Za-z0-9-]+$/.test(login))
|
|
12186
|
+
throw new Error(`${what} names \`${login}\`, not a GitHub user login`);
|
|
12187
|
+
}
|
|
12188
|
+
return [...new Set(logins)];
|
|
12189
|
+
}
|
|
12190
|
+
function answersOf(text) {
|
|
12191
|
+
if (text.trim() === "")
|
|
12192
|
+
throw new Error(`the root ${ANSWERS_FILE} is empty or missing`);
|
|
12193
|
+
try {
|
|
12194
|
+
return parseAnswers(text).answers;
|
|
12195
|
+
} catch (error) {
|
|
12196
|
+
throw new Error(`the root ${ANSWERS_FILE} cannot be read: ${error.message.split("\n")[0]}`);
|
|
12197
|
+
}
|
|
12198
|
+
}
|
|
12199
|
+
function reviewersOf(answers) {
|
|
12200
|
+
const value = answers[REVIEWERS_ANSWER];
|
|
12201
|
+
if (value === void 0 || value === null)
|
|
12202
|
+
return [];
|
|
12203
|
+
return parseReviewers(String(value), `the answer ${REVIEWERS_ANSWER}`);
|
|
12204
|
+
}
|
|
12205
|
+
var requestReviews = (number, logins, cwd) => run("gh", [
|
|
12206
|
+
"api",
|
|
12207
|
+
`repos/{owner}/{repo}/pulls/${number}/requested_reviewers`,
|
|
12208
|
+
"--method",
|
|
12209
|
+
"POST",
|
|
12210
|
+
...logins.flatMap((l) => ["-f", `reviewers[]=${l}`])
|
|
12211
|
+
], { cwd });
|
|
12212
|
+
async function createPull(ctx, name, req, cwd) {
|
|
12213
|
+
const create = (draft) => run("gh", [
|
|
12214
|
+
"pr",
|
|
12215
|
+
"create",
|
|
12216
|
+
...draft ? ["--draft"] : [],
|
|
12217
|
+
"--base",
|
|
12218
|
+
req.base,
|
|
12219
|
+
"--head",
|
|
12220
|
+
versionBranch(req.version),
|
|
12221
|
+
"--title",
|
|
12222
|
+
`chore: Plexus ${req.version}`,
|
|
12223
|
+
"--body",
|
|
12224
|
+
req.body
|
|
12225
|
+
], { cwd });
|
|
12226
|
+
if (!req.draft) {
|
|
12227
|
+
await ctx.apply([create(false)]);
|
|
12228
|
+
return false;
|
|
12229
|
+
}
|
|
12230
|
+
try {
|
|
12231
|
+
await ctx.apply([create(true)]);
|
|
12232
|
+
return true;
|
|
12233
|
+
} catch (refused) {
|
|
12234
|
+
try {
|
|
12235
|
+
await ctx.apply([create(false)]);
|
|
12236
|
+
} catch (error) {
|
|
12237
|
+
throw new Error(`as a draft: ${detailOf(refused) || "refused"}; as an ordinary one: ${detailOf(error) || "refused"}`);
|
|
12238
|
+
}
|
|
12239
|
+
ctx.say(`\u2022 ${name}: the pull request is no draft: the forge refused one${detailOf(refused) ? ` (${detailOf(refused)})` : ""}`);
|
|
12240
|
+
return false;
|
|
12241
|
+
}
|
|
12242
|
+
}
|
|
12243
|
+
var LISTED = 1e3;
|
|
12244
|
+
async function pullOf(ctx, consumer, dir, version2, tip) {
|
|
12245
|
+
const args = ["pr", "list", "--head", versionBranch(version2), "--base", consumer.branch, "--state", "all"];
|
|
12246
|
+
const fields = "url,number,isDraft,state,author,headRefOid,isCrossRepository";
|
|
12247
|
+
const out = await ctx.read("gh", [...args, "--limit", String(LISTED), "--json", fields], { cwd: dir });
|
|
12248
|
+
let listed;
|
|
12249
|
+
try {
|
|
12250
|
+
listed = JSON.parse(out);
|
|
12251
|
+
} catch {
|
|
12252
|
+
throw new Error(`gh pr list gave no JSON for ${versionBranch(version2)}`);
|
|
12253
|
+
}
|
|
12254
|
+
if (!Array.isArray(listed))
|
|
12255
|
+
throw new Error(`gh pr list gave no list for ${versionBranch(version2)}`);
|
|
12256
|
+
const pulls = listed.flatMap((p) => {
|
|
12257
|
+
if (typeof p !== "object" || p === null)
|
|
12258
|
+
return [];
|
|
12259
|
+
const { url, number, isDraft, state, author, headRefOid, isCrossRepository } = p;
|
|
12260
|
+
if (typeof url !== "string" || typeof number !== "number" || isCrossRepository !== false)
|
|
12261
|
+
return [];
|
|
12262
|
+
const login = author?.login;
|
|
12263
|
+
return [
|
|
12264
|
+
{
|
|
12265
|
+
url,
|
|
12266
|
+
number,
|
|
12267
|
+
draft: isDraft === true,
|
|
12268
|
+
open: state === "OPEN",
|
|
12269
|
+
...typeof login === "string" ? { author: login } : {},
|
|
12270
|
+
...typeof headRefOid === "string" ? { head: headRefOid } : {}
|
|
12271
|
+
}
|
|
12272
|
+
];
|
|
12273
|
+
});
|
|
12274
|
+
const open = pulls.find((p) => p.open);
|
|
12275
|
+
if (open)
|
|
12276
|
+
return open;
|
|
12277
|
+
return pulls.filter((p) => tip !== void 0 && p.head === tip).sort((a, b) => b.number - a.number)[0];
|
|
12278
|
+
}
|
|
12279
|
+
async function askForReviews(ctx, name, pull, from, cwd) {
|
|
12280
|
+
let named;
|
|
12281
|
+
try {
|
|
12282
|
+
named = "named" in from ? from.named : reviewersOf(answersOf(from.answersFile));
|
|
12283
|
+
} catch (error) {
|
|
12284
|
+
const why = error.message;
|
|
12285
|
+
ctx.say(` \u2717 FAILED \u2014 ${name}: no review requested: ${why}`);
|
|
12286
|
+
return { failed: why };
|
|
12287
|
+
}
|
|
12288
|
+
const author = pull.author?.toLowerCase();
|
|
12289
|
+
const reviewers = named.filter((l) => l.toLowerCase() !== author);
|
|
12290
|
+
if (reviewers.length < named.length)
|
|
12291
|
+
ctx.say(`\u2022 ${name}: ${pull.author} opened the pull request and is not asked to review it`);
|
|
12292
|
+
if (reviewers.length === 0)
|
|
12293
|
+
return void 0;
|
|
12294
|
+
try {
|
|
12295
|
+
await ctx.apply([requestReviews(pull.number, reviewers, cwd)]);
|
|
12296
|
+
return { requested: reviewers };
|
|
12297
|
+
} catch (error) {
|
|
12298
|
+
const why = detailOf(error);
|
|
12299
|
+
ctx.say(` \u2717 FAILED \u2014 ${name}: review request from ${reviewers.join(", ")}${why ? `: ${why}` : ""}`);
|
|
12300
|
+
return { failed: why || "the forge refused it" };
|
|
12301
|
+
}
|
|
12302
|
+
}
|
|
12303
|
+
async function tipOnOrigin(ctx, repo, branch) {
|
|
12304
|
+
const tip = (await ctx.read("git", ["ls-remote", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo })).split(" ")[0]?.trim();
|
|
12305
|
+
if (!tip)
|
|
12306
|
+
throw new Error(`origin no longer has ${branch}`);
|
|
12307
|
+
return tip;
|
|
12308
|
+
}
|
|
12309
|
+
async function fetchTip(ctx, repo, tip) {
|
|
12310
|
+
const shallow = (await ctx.read("git", ["rev-parse", "--is-shallow-repository"], { cwd: repo })).trim() === "true";
|
|
12311
|
+
await ctx.read("git", ["fetch", "--quiet", "--no-write-fetch-head", "--refmap=", ...shallow ? ["--depth", "1"] : [], "origin", tip], { cwd: repo });
|
|
12312
|
+
}
|
|
12313
|
+
async function aheadOf(ctx, consumer, tip) {
|
|
12314
|
+
const out = await ctx.read("gh", ["api", `repos/{owner}/{repo}/compare/${consumer.branch}...${tip}`, "--jq", ".ahead_by"], { cwd: consumer.path });
|
|
12315
|
+
const ahead = Number(out.trim());
|
|
12316
|
+
if (out.trim() === "" || !Number.isInteger(ahead))
|
|
12317
|
+
throw new Error(`the forge gave no count of commits for ${tip}`);
|
|
12318
|
+
return ahead;
|
|
12319
|
+
}
|
|
12320
|
+
var needsAHand = (p) => (p.conflicted?.length ?? 0) > 0 || p.marked.length > 0 || (p.failed?.length ?? 0) > 0 || (p.behind?.length ?? 0) > 0 || p.lockfile === true && !p.checked;
|
|
12321
|
+
var code = (s) => `\`${s}\``;
|
|
12322
|
+
var byHand = (version2) => ["mise", ...copierVia(["update", "--trust", "--skip-answered", "--vcs-ref", version2])].join(" ");
|
|
12323
|
+
var site = (s) => s === "." ? "the root" : code(s);
|
|
12324
|
+
function pullBody(p) {
|
|
12325
|
+
const hand = [
|
|
12326
|
+
...p.conflicted?.length ? [`- Conflicts at ${p.conflicted.map(site).join(", ")}, committed with their markers.`] : [],
|
|
12327
|
+
...p.marked.length ? [`- Files that hold conflict markers: ${p.marked.map(code).join(", ")}.`] : [],
|
|
12328
|
+
...p.failed?.length ? [`- \`copier update\` failed at ${p.failed.map(site).join(", ")}, left as it was; run it there by hand.`] : [],
|
|
12329
|
+
...(p.behind ?? []).map((s) => `- The answers at ${site(s)} do not record ${p.version}: copier did not run here. On this branch, in ${site(s)}, run \`${byHand(p.version)}\` and commit what it changes.`),
|
|
12330
|
+
...p.lockfile && !p.checked ? ["- The lockfile did not refresh: run `pnpm install` after resolving, and commit the lockfile."] : []
|
|
12331
|
+
];
|
|
12332
|
+
const lockfile = p.lockfile && p.checked ? ["- Run `pnpm install` once resolved, and commit the lockfile."] : [];
|
|
12333
|
+
const head = hand.length > 0 ? `**Needs a hand.** \`plx update\` marks this pull request ready once no tracked file holds a conflict marker and every site's answers record the version.
|
|
12334
|
+
|
|
12335
|
+
${[...hand, ...lockfile].join("\n")}` : p.checked ? `Ready for review: no tracked file holds a conflict marker, and every site's answers record ${p.version}.${lockfile.length ? `
|
|
12336
|
+
|
|
12337
|
+
${lockfile.join("\n")}` : ""}` : "Nothing needs a hand: every site merged clean.";
|
|
12338
|
+
return [
|
|
12339
|
+
head,
|
|
12340
|
+
`Plexus ${p.version} (\xA7 1.5 PLX): \`copier update\` at ${p.sites.map(site).join(", ")}, the lockfile where manifests moved, and the workflow refs.`,
|
|
12341
|
+
p.note
|
|
12342
|
+
].join("\n\n");
|
|
12343
|
+
}
|
|
12344
|
+
var REVISITED = "Opened by `plx update`; rewritten by a later run from what it found at the branch's tip.";
|
|
12345
|
+
async function readTip(ctx, consumer, version2, tip) {
|
|
12346
|
+
const repo = consumer.path;
|
|
12347
|
+
await fetchTip(ctx, repo, tip);
|
|
12348
|
+
const marked = await filesWithConflictMarkers(ctx, repo, tip);
|
|
12349
|
+
const { files, sites: held } = await sitesOfTree(ctx, repo, tip);
|
|
12350
|
+
const sites = held.map((s) => s.dir);
|
|
12351
|
+
const behind = held.filter((s) => s.answers?.commit !== version2).map((s) => s.dir);
|
|
12352
|
+
const ready = marked.length === 0 && behind.length === 0;
|
|
12353
|
+
const lockfile = files.includes("pnpm-lock.yaml") && (!ready || await aheadOf(ctx, consumer, tip) > 1);
|
|
12354
|
+
return { tip, sites, marked, behind, ready, lockfile };
|
|
12355
|
+
}
|
|
12356
|
+
function foundAt(at, version2) {
|
|
12357
|
+
const n = at.marked.length;
|
|
12358
|
+
const parts2 = [
|
|
12359
|
+
...n > 0 ? [`${n} file${n === 1 ? "" : "s"} still hold${n === 1 ? "s" : ""} conflict markers`] : [],
|
|
12360
|
+
...at.behind.length > 0 ? [`${at.behind.map(site).join(", ")} not at ${version2}: copier did not run there`] : []
|
|
12361
|
+
];
|
|
12362
|
+
return parts2.length > 0 ? parts2.join("; ") : `no conflict marker remains, and every site is at ${version2}`;
|
|
12363
|
+
}
|
|
12364
|
+
async function revisit(ctx, consumer, pull, version2, tip) {
|
|
12365
|
+
const { path: repo, rel: name } = consumer;
|
|
12366
|
+
const branch = versionBranch(version2);
|
|
12367
|
+
const at = await readTip(ctx, consumer, version2, tip);
|
|
12368
|
+
const { marked, behind, ready } = at;
|
|
12369
|
+
const body2 = pullBody({
|
|
12370
|
+
version: version2,
|
|
12371
|
+
sites: at.sites,
|
|
12372
|
+
marked,
|
|
12373
|
+
behind,
|
|
12374
|
+
lockfile: at.lockfile,
|
|
12375
|
+
checked: true,
|
|
12376
|
+
note: REVISITED
|
|
12377
|
+
});
|
|
12378
|
+
const line = `\u2022 ${name}: ${branch} is on origin (${pull.url}); ${foundAt(at, version2)}`;
|
|
12379
|
+
const undo = !ready && !pull.draft;
|
|
12380
|
+
if (!undo)
|
|
12381
|
+
ctx.say(ready && pull.draft ? `${line} \u2014 ready for review` : line);
|
|
12382
|
+
try {
|
|
12383
|
+
await ctx.apply([
|
|
12384
|
+
run("gh", ["api", `repos/{owner}/{repo}/pulls/${pull.number}`, "--method", "PATCH", "-f", `body=${body2}`], {
|
|
12385
|
+
cwd: repo
|
|
12386
|
+
}),
|
|
12387
|
+
...ready && pull.draft ? [run("gh", ["pr", "ready", pull.url], { cwd: repo })] : []
|
|
12388
|
+
]);
|
|
12389
|
+
} catch (error) {
|
|
12390
|
+
if (undo)
|
|
12391
|
+
ctx.say(line);
|
|
12392
|
+
return { url: pull.url, marked, behind, mergeable: false, failed: `pull request ${pull.url}: ${detailOf(error)}` };
|
|
12393
|
+
}
|
|
12394
|
+
if (undo)
|
|
12395
|
+
await ctx.apply([run("gh", ["pr", "ready", pull.url, "--undo"], { cwd: repo })]).then(() => ctx.say(`${line} \u2014 a draft again`), (error) => {
|
|
12396
|
+
const why = detailOf(error);
|
|
12397
|
+
ctx.say(`${line} \u2014 no draft: the forge refused one${why ? ` (${why})` : ""}`);
|
|
12398
|
+
});
|
|
12399
|
+
const draft = ctx.dryRun ? pull.draft : !ready;
|
|
12400
|
+
return { url: pull.url, marked, behind, mergeable: ready && !draft };
|
|
12401
|
+
}
|
|
12402
|
+
var OPENED_LATE = "Opened by `plx update`: a later run found the branch on origin with no pull request.";
|
|
12403
|
+
async function openLate(ctx, consumer, version2, reviewers, tip) {
|
|
12404
|
+
const { path: repo, rel: name } = consumer;
|
|
12405
|
+
const branch = versionBranch(version2);
|
|
12406
|
+
const at = await readTip(ctx, consumer, version2, tip);
|
|
12407
|
+
const { marked, behind, ready } = at;
|
|
12408
|
+
const state = {
|
|
12409
|
+
version: version2,
|
|
12410
|
+
sites: at.sites,
|
|
12411
|
+
marked,
|
|
12412
|
+
behind,
|
|
12413
|
+
lockfile: at.lockfile,
|
|
12414
|
+
checked: true,
|
|
12415
|
+
note: OPENED_LATE
|
|
12416
|
+
};
|
|
12417
|
+
const asDraft = !ready;
|
|
12418
|
+
ctx.say(`\u2022 ${name}: ${branch} is on origin with no pull request \u2014 opening it${asDraft ? " as a draft" : ""}`);
|
|
12419
|
+
let draft;
|
|
12420
|
+
try {
|
|
12421
|
+
draft = await createPull(ctx, name, { base: consumer.branch, version: version2, body: pullBody(state), draft: asDraft }, repo);
|
|
12422
|
+
} catch (error) {
|
|
12423
|
+
const why = detailOf(error);
|
|
12424
|
+
ctx.say(` \u2717 FAILED \u2014 pull request${why ? `: ${why}` : ""}`);
|
|
12425
|
+
return { marked, behind, ready, failed: `pull request: ${why}` };
|
|
12426
|
+
}
|
|
12427
|
+
if (ctx.dryRun) {
|
|
12428
|
+
ctx.say(` (preview) ${name}: would open a pull request of ${branch} against ${consumer.branch}`);
|
|
12429
|
+
return { marked, behind, ready, previewed: true };
|
|
12430
|
+
}
|
|
12431
|
+
const pull = await pullOf(ctx, consumer, repo, version2);
|
|
12432
|
+
if (!pull)
|
|
12433
|
+
return { marked, behind, ready, failed: "pull request: the forge did not list it after opening it" };
|
|
12434
|
+
ctx.say(`\u2022 ${name}: ${draft ? "draft " : ""}pull request opened: ${pull.url}`);
|
|
12435
|
+
const from = reviewers ?? {
|
|
12436
|
+
answersFile: await ctx.read("git", ["cat-file", "blob", `${at.tip}:${ANSWERS_FILE}`], { cwd: repo }).catch(() => "")
|
|
12437
|
+
};
|
|
12438
|
+
const review = await askForReviews(ctx, name, pull, from, repo);
|
|
12439
|
+
return { pull, marked, behind, ready, ...review ? { review } : {} };
|
|
12440
|
+
}
|
|
12441
|
+
|
|
12442
|
+
// ../lib/dist/update.js
|
|
12443
|
+
import { basename, join as join9, relative as relative4 } from "node:path";
|
|
12444
|
+
|
|
12445
|
+
// ../lib/dist/take.js
|
|
12446
|
+
import { join as join8, relative as relative3 } from "node:path";
|
|
12447
|
+
var needsHand = (t) => t.sites.some((s) => s.outcome !== "clean") || (t.marked?.length ?? 0) > 0 || t.lockfile === "failed" || t.failed !== void 0;
|
|
12092
12448
|
var copierIn = (dir, args) => [
|
|
12093
12449
|
"env",
|
|
12094
12450
|
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, "mise", ...copierVia(args)]
|
|
12095
12451
|
];
|
|
12096
|
-
async function takeVersion(ctx, consumer, dir, take
|
|
12452
|
+
async function takeVersion(ctx, consumer, dir, take) {
|
|
12097
12453
|
const base = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim();
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12454
|
+
const update2 = take.update ?? fromTemplate(take.ref);
|
|
12455
|
+
const sites = [];
|
|
12456
|
+
for (const site2 of consumer.sites)
|
|
12457
|
+
sites.push(await updateSite(ctx, consumer, site2, dir, update2));
|
|
12458
|
+
const lockfile = await refreshLockfile(ctx, consumer, dir, base);
|
|
12101
12459
|
await bumpConsumerRefs(ctx, consumer, dir, take.version);
|
|
12102
|
-
|
|
12460
|
+
const taken = { rel: consumer.rel, sites, ...lockfile ? { lockfile } : {} };
|
|
12461
|
+
return { ...taken, ...await openPull(ctx, consumer, dir, base, take, taken) };
|
|
12103
12462
|
}
|
|
12104
|
-
var
|
|
12463
|
+
var scratchCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], { cwd: dir })).then(() => ctx.stage(run("git", [
|
|
12105
12464
|
"-c",
|
|
12106
12465
|
"commit.gpgsign=false",
|
|
12107
12466
|
"-c",
|
|
@@ -12115,275 +12474,311 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
|
|
|
12115
12474
|
"-m",
|
|
12116
12475
|
message
|
|
12117
12476
|
], { cwd: dir })));
|
|
12118
|
-
|
|
12119
|
-
|
|
12477
|
+
var fromTemplate = (ref) => async (ctx, site2, target, dir) => {
|
|
12478
|
+
ctx.say(`\u2192 ${site2.rel}: copier update${ref ? ` to ${ref}` : ""}`);
|
|
12479
|
+
const answers = await ctx.readFile(join8(target, ANSWERS_FILE));
|
|
12480
|
+
const current = templateSource(site2.template);
|
|
12481
|
+
const recorded = parseAnswers(answers).src;
|
|
12482
|
+
if (recorded && namesOldTemplate(recorded)) {
|
|
12483
|
+
ctx.say(` ${site2.rel}: the template is ${current} now; the answers follow`);
|
|
12484
|
+
await ctx.stage(write(join8(target, ANSWERS_FILE), setAnswer(answers, "_src_path", current)));
|
|
12485
|
+
await scratchCommit(ctx, dir, `plx: ${site2.rel} reads ${current}, the template's name since its rename`);
|
|
12486
|
+
}
|
|
12487
|
+
const args = [
|
|
12488
|
+
"update",
|
|
12489
|
+
"--skip-answered",
|
|
12490
|
+
"--trust",
|
|
12491
|
+
"--skip-tasks",
|
|
12492
|
+
...ref ? ["--vcs-ref", ref] : [],
|
|
12493
|
+
...ctx.yes || ctx.dryRun ? ["--defaults"] : []
|
|
12494
|
+
];
|
|
12495
|
+
const step = run(...copierIn(dir, args), { cwd: target, interactive: !ctx.dryRun });
|
|
12496
|
+
if (ctx.dryRun)
|
|
12497
|
+
await ctx.stage(step);
|
|
12498
|
+
else
|
|
12499
|
+
await ctx.apply([step]);
|
|
12500
|
+
};
|
|
12501
|
+
async function updateSite(ctx, consumer, site2, dir, update2) {
|
|
12502
|
+
const target = join8(dir, relative3(consumer.path, site2.path));
|
|
12120
12503
|
try {
|
|
12121
|
-
|
|
12122
|
-
const localTemplate = join6(take.previewFrom, site.template);
|
|
12123
|
-
ctx.say(`\u2192 ${site.rel}: copier update (preview from ${localTemplate}@main)`);
|
|
12124
|
-
const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
|
|
12125
|
-
await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${localTemplate}`)));
|
|
12126
|
-
await previewCommit(ctx, dir, `plx preview: ${site.rel} reads ${localTemplate} from the local checkout`);
|
|
12127
|
-
await ctx.stage(run(...copierIn(dir, ["update", "--skip-answered", "--trust", "--defaults", "--skip-tasks", "--vcs-ref", "main"]), { cwd: target }));
|
|
12128
|
-
} else {
|
|
12129
|
-
ctx.say(`\u2192 ${site.rel}: copier update${take.ref ? ` to ${take.ref}` : ""}`);
|
|
12130
|
-
const answers = await ctx.readFile(join6(target, ANSWERS_FILE));
|
|
12131
|
-
const current = templateSource(site.template);
|
|
12132
|
-
const recorded = /^_src_path: (.*)$/m.exec(answers)?.[1];
|
|
12133
|
-
if (recorded && namesOldTemplate(recorded)) {
|
|
12134
|
-
ctx.say(` ${site.rel}: the template is ${current} now; the answers follow`);
|
|
12135
|
-
await ctx.stage(write(join6(target, ANSWERS_FILE), answers.replace(/^_src_path: .*$/m, `_src_path: ${current}`)));
|
|
12136
|
-
await previewCommit(ctx, dir, `plx: ${site.rel} reads ${current}, the template's name since its rename`);
|
|
12137
|
-
}
|
|
12138
|
-
const args = [
|
|
12139
|
-
"update",
|
|
12140
|
-
"--skip-answered",
|
|
12141
|
-
"--trust",
|
|
12142
|
-
"--skip-tasks",
|
|
12143
|
-
...take.ref ? ["--vcs-ref", take.ref] : [],
|
|
12144
|
-
...ctx.yes || ctx.dryRun ? ["--defaults"] : []
|
|
12145
|
-
];
|
|
12146
|
-
const step = run(...copierIn(dir, args), { cwd: target, interactive: !ctx.dryRun });
|
|
12147
|
-
if (ctx.dryRun)
|
|
12148
|
-
await ctx.stage(step);
|
|
12149
|
-
else
|
|
12150
|
-
await ctx.apply([step]);
|
|
12151
|
-
}
|
|
12504
|
+
await update2(ctx, site2, target, dir);
|
|
12152
12505
|
} catch (error) {
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
return;
|
|
12506
|
+
const why = detailOf(error);
|
|
12507
|
+
ctx.say(` \u2717 FAILED \u2014 copier update exited nonzero${why ? `: ${why}` : ""}`);
|
|
12508
|
+
return { rel: site2.rel, outcome: "failed", ...why ? { detail: why } : {} };
|
|
12156
12509
|
}
|
|
12157
12510
|
const status = await ctx.read("git", ["status", "--porcelain", "--", "."], { cwd: target });
|
|
12158
12511
|
let conflict = hasUnmergedEntries(status);
|
|
12159
12512
|
const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
|
|
12160
12513
|
for (const f of changed) {
|
|
12161
|
-
const text = await ctx.readFile(
|
|
12514
|
+
const text = await ctx.readFile(join8(target, f)).catch(() => "");
|
|
12162
12515
|
if (hasConflictMarkers(text))
|
|
12163
12516
|
conflict = true;
|
|
12164
12517
|
}
|
|
12165
|
-
if (conflict)
|
|
12518
|
+
if (conflict)
|
|
12166
12519
|
ctx.say(" \u2717 CONFLICTS \u2014 committed with their <<<<<<< markers, to resolve in the pull request:");
|
|
12167
|
-
|
|
12168
|
-
} else {
|
|
12520
|
+
else
|
|
12169
12521
|
ctx.say(" \u2713 merged clean:");
|
|
12170
|
-
summary.clean.push(site.rel);
|
|
12171
|
-
}
|
|
12172
12522
|
for (const line of status.split("\n").filter(Boolean))
|
|
12173
12523
|
ctx.say(` ${line}`);
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
else
|
|
12177
|
-
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
12524
|
+
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
12525
|
+
return { rel: site2.rel, outcome: conflict ? "conflicted" : "clean" };
|
|
12178
12526
|
}
|
|
12179
|
-
async function refreshLockfile(ctx, consumer, dir, base
|
|
12180
|
-
if (await ctx.readFile(
|
|
12181
|
-
return;
|
|
12527
|
+
async function refreshLockfile(ctx, consumer, dir, base) {
|
|
12528
|
+
if (await ctx.readFile(join8(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
|
|
12529
|
+
return void 0;
|
|
12182
12530
|
const manifests = ["*package.json", "pnpm-workspace.yaml"];
|
|
12183
12531
|
const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
|
|
12184
12532
|
if (unchanged)
|
|
12185
|
-
return;
|
|
12533
|
+
return void 0;
|
|
12186
12534
|
ctx.say(`\u2192 ${consumer.rel}: pnpm install (manifests changed)`);
|
|
12187
12535
|
try {
|
|
12188
12536
|
await ctx.apply([
|
|
12189
12537
|
run("mise", ["exec", "--", "pnpm", "install", "--no-frozen-lockfile", "--reporter=silent"], { cwd: dir })
|
|
12190
12538
|
]);
|
|
12539
|
+
return "refreshed";
|
|
12191
12540
|
} catch (error) {
|
|
12192
|
-
|
|
12193
|
-
|
|
12541
|
+
const why = detailOf(error);
|
|
12542
|
+
ctx.say(` \u2717 pnpm install failed${why ? `: ${why}` : ""}`);
|
|
12543
|
+
return "failed";
|
|
12194
12544
|
}
|
|
12195
12545
|
}
|
|
12196
12546
|
async function bumpConsumerRefs(ctx, consumer, dir, version2) {
|
|
12197
|
-
const workflows =
|
|
12547
|
+
const workflows = join8(dir, ".github", "workflows");
|
|
12198
12548
|
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
12199
12549
|
const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
|
|
12200
12550
|
for (const f of files) {
|
|
12201
|
-
const text = await ctx.readFile(
|
|
12551
|
+
const text = await ctx.readFile(join8(workflows, f));
|
|
12202
12552
|
if (!text.includes(WORKFLOW_REF))
|
|
12203
12553
|
continue;
|
|
12204
12554
|
const bumped = bumpWorkflowRefs(text, version2);
|
|
12205
12555
|
if (bumped === text)
|
|
12206
12556
|
continue;
|
|
12207
12557
|
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${version2}`);
|
|
12208
|
-
await ctx.stage(write(
|
|
12558
|
+
await ctx.stage(write(join8(workflows, f), bumped));
|
|
12209
12559
|
}
|
|
12210
12560
|
}
|
|
12211
|
-
async function
|
|
12212
|
-
const args = ["pr", "list", "--head", versionBranch(version2), "--base", consumer.branch, "--state", "open"];
|
|
12213
|
-
return (await ctx.read("gh", [...args, "--json", "url", "--jq", ".[0].url"], { cwd: dir }).catch(() => "")).trim();
|
|
12214
|
-
}
|
|
12215
|
-
async function openPull(ctx, consumer, dir, take, summary) {
|
|
12561
|
+
async function openPull(ctx, consumer, dir, base, take, taken) {
|
|
12216
12562
|
const { version: version2 } = take;
|
|
12217
12563
|
const branch = versionBranch(version2);
|
|
12218
12564
|
if (ctx.dryRun) {
|
|
12219
12565
|
ctx.say(` (preview) ${consumer.rel}: would commit, push ${branch} and open a pull request against ${consumer.branch}`);
|
|
12220
|
-
return;
|
|
12566
|
+
return {};
|
|
12221
12567
|
}
|
|
12222
|
-
|
|
12568
|
+
const moved = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim() !== base;
|
|
12569
|
+
if (!moved && (await ctx.read("git", ["status", "--porcelain"], { cwd: dir })).trim() === "") {
|
|
12223
12570
|
ctx.say(`\u2022 ${consumer.rel}: nothing changed \u2014 no pull request`);
|
|
12224
|
-
return;
|
|
12571
|
+
return {};
|
|
12225
12572
|
}
|
|
12226
12573
|
const head = `${consumer.origin ?? "origin"} ${branch}`;
|
|
12227
12574
|
try {
|
|
12228
12575
|
await ctx.apply([
|
|
12576
|
+
// Staged first: a site whose copier run failed mid-merge can leave unmerged entries, which a reset refuses.
|
|
12229
12577
|
run("git", ["add", "-A"], { cwd: dir }),
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12578
|
+
// One commit on the branch, the scratch ones folded in: a later run tells it from a human's by the count.
|
|
12579
|
+
run("git", ["reset", "--quiet", "--soft", base], { cwd: dir }),
|
|
12580
|
+
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore: Plexus ${version2}`], { cwd: dir }),
|
|
12581
|
+
// An empty expected value: the branch must not exist on origin yet.
|
|
12582
|
+
run("git", [
|
|
12583
|
+
"push",
|
|
12584
|
+
"--quiet",
|
|
12585
|
+
"--no-verify",
|
|
12586
|
+
`--force-with-lease=refs/heads/${branch}:`,
|
|
12587
|
+
"origin",
|
|
12588
|
+
`HEAD:refs/heads/${branch}`
|
|
12589
|
+
], { cwd: dir })
|
|
12239
12590
|
]);
|
|
12240
12591
|
} catch (error) {
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
return;
|
|
12244
|
-
}
|
|
12245
|
-
const
|
|
12246
|
-
const
|
|
12247
|
-
const
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
}
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
...conflicted.length > 0 ? [`Conflicts to resolve, committed with their markers: ${conflicted.join(", ")}.`] : [],
|
|
12260
|
-
...failed.length > 0 ? [`Failed, and left as it was: ${failed.join(", ")}.`] : [],
|
|
12261
|
-
...clean ? [CLEAN_BODY] : [],
|
|
12262
|
-
`Opened by ${take.opener}${take.why ? `: ${take.why}` : ""}.`
|
|
12263
|
-
].join("\n\n");
|
|
12592
|
+
const why = detailOf(error);
|
|
12593
|
+
ctx.say(` \u2717 FAILED \u2014 push to ${head}${why ? `: ${why}` : ""}`);
|
|
12594
|
+
return { failed: `push to ${head}${why ? `: ${why}` : ""}` };
|
|
12595
|
+
}
|
|
12596
|
+
const marked = await filesWithConflictMarkers(ctx, dir);
|
|
12597
|
+
const of = (outcome) => taken.sites.filter((s) => s.outcome === outcome).map((s) => siteOf(consumer, s.rel));
|
|
12598
|
+
const state = {
|
|
12599
|
+
version: version2,
|
|
12600
|
+
sites: consumer.sites.map((s) => relative3(consumer.path, s.path) || "."),
|
|
12601
|
+
conflicted: of("conflicted"),
|
|
12602
|
+
marked,
|
|
12603
|
+
failed: of("failed"),
|
|
12604
|
+
lockfile: taken.lockfile === "failed",
|
|
12605
|
+
note: `Opened by ${take.opener}${take.why ? `: ${take.why}` : ""}.`
|
|
12606
|
+
};
|
|
12607
|
+
if (marked.length > 0)
|
|
12608
|
+
ctx.say(` ${consumer.rel}: conflict markers in ${marked.join(", ")}`);
|
|
12609
|
+
let draft;
|
|
12264
12610
|
try {
|
|
12265
|
-
await ctx.
|
|
12266
|
-
run("gh", [
|
|
12267
|
-
"pr",
|
|
12268
|
-
"create",
|
|
12269
|
-
"--base",
|
|
12270
|
-
consumer.branch,
|
|
12271
|
-
"--head",
|
|
12272
|
-
branch,
|
|
12273
|
-
"--title",
|
|
12274
|
-
`chore: Plexus ${version2}`,
|
|
12275
|
-
"--body",
|
|
12276
|
-
body2
|
|
12277
|
-
], { cwd: dir })
|
|
12278
|
-
]);
|
|
12611
|
+
draft = await createPull(ctx, consumer.rel, { base: consumer.branch, version: version2, body: pullBody(state), draft: needsAHand(state) }, dir);
|
|
12279
12612
|
} catch (error) {
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
return;
|
|
12613
|
+
const why = detailOf(error);
|
|
12614
|
+
ctx.say(` \u2717 FAILED \u2014 pull request${why ? `: ${why}` : ""}`);
|
|
12615
|
+
return { marked, failed: `pull request${why ? `: ${why}` : ""}` };
|
|
12283
12616
|
}
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12617
|
+
let opened;
|
|
12618
|
+
try {
|
|
12619
|
+
opened = await pullOf(ctx, consumer, dir, version2);
|
|
12620
|
+
} catch (error) {
|
|
12621
|
+
const why = detailOf(error);
|
|
12622
|
+
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}: the pull request opened, but listing it failed${why ? `: ${why}` : ""}`);
|
|
12623
|
+
return { marked, pull: { branch, draft }, failed: `listing the pull request: ${why}` };
|
|
12624
|
+
}
|
|
12625
|
+
const url = opened?.url;
|
|
12626
|
+
ctx.say(`\u2022 ${consumer.rel}: ${draft ? "draft " : ""}pull request opened${url ? `: ${url}` : ""}`);
|
|
12627
|
+
const pull = { branch, draft, ...url ? { url } : {} };
|
|
12628
|
+
if (!opened)
|
|
12629
|
+
return { marked, pull, failed: "the forge did not list the pull request it opened" };
|
|
12630
|
+
const from = take.reviewers ?? {
|
|
12631
|
+
answersFile: await ctx.readFile(join8(dir, ANSWERS_FILE)).catch(() => "")
|
|
12632
|
+
};
|
|
12633
|
+
const review = await askForReviews(ctx, consumer.rel, opened, from, dir);
|
|
12634
|
+
return { marked, pull, ...review ? { review } : {} };
|
|
12635
|
+
}
|
|
12636
|
+
function siteOf(consumer, rel) {
|
|
12637
|
+
const s = consumer.sites.find((x) => x.rel === rel);
|
|
12638
|
+
return s ? relative3(consumer.path, s.path) || "." : rel;
|
|
12289
12639
|
}
|
|
12290
|
-
var detail = (error) => {
|
|
12291
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
12292
|
-
const last = message.trim().split("\n").at(-1) ?? "";
|
|
12293
|
-
return last && !/exited with/.test(last) ? `: ${last}` : "";
|
|
12294
|
-
};
|
|
12295
12640
|
|
|
12296
12641
|
// ../lib/dist/update.js
|
|
12297
|
-
|
|
12298
|
-
async function update(ctx, options) {
|
|
12299
|
-
const { repo } = options;
|
|
12300
|
-
const name = options.name ?? basename(repo);
|
|
12642
|
+
async function update(ctx, options, known) {
|
|
12301
12643
|
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
12302
12644
|
throw new UsageError(`'${options.to}' is not plain semver (X.Y.Z, no v)`);
|
|
12303
|
-
const
|
|
12304
|
-
const
|
|
12305
|
-
if (!consumer)
|
|
12306
|
-
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(", ")}`);
|
|
12307
|
-
if (consumer.skipped)
|
|
12308
|
-
throw new Error(`${name}: ${consumer.skipped}`);
|
|
12309
|
-
consumer.rel = name;
|
|
12310
|
-
for (const s of consumer.sites)
|
|
12311
|
-
s.rel = s.rel === "." ? name : join7(name, s.rel);
|
|
12645
|
+
const consumer = known?.consumer ?? await repoAt(ctx, options.repo, options.name ?? basename(options.repo));
|
|
12646
|
+
const { path: repo, rel: name } = consumer;
|
|
12312
12647
|
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
12313
12648
|
if (!root)
|
|
12314
12649
|
throw new Error(`${name}: its root is not a site of a repo template`);
|
|
12315
|
-
|
|
12316
|
-
|
|
12650
|
+
if (!known)
|
|
12651
|
+
await preflightForge(ctx);
|
|
12652
|
+
const releases = known?.releases ?? (options.to === void 0 ? await releasesOf(ctx) : []);
|
|
12317
12653
|
const newest2 = options.to ?? newestOf(releases);
|
|
12318
12654
|
if (await onOrigin(ctx, repo, consumer.branch) === false) {
|
|
12319
12655
|
const reason = `origin has no branch \`${consumer.branch}\`, the one the version lands on`;
|
|
12320
12656
|
ctx.say(`\u26A0 ${name}: ${reason} \u2014 skipped`);
|
|
12321
|
-
|
|
12322
|
-
skipped.skipped.push({ path: name, reason });
|
|
12323
|
-
return skipped;
|
|
12657
|
+
return { repo: name, version: newest2, kind: "skipped", reason };
|
|
12324
12658
|
}
|
|
12325
12659
|
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
12326
|
-
const
|
|
12327
|
-
|
|
12660
|
+
const onBranch = await sitesOfTree(ctx, repo, `refs/remotes/origin/${consumer.branch}`).catch(() => void 0);
|
|
12661
|
+
const answers = onBranch ? onBranch.sites.map((s) => s.answers ?? { answers: {} }) : await Promise.all(consumer.sites.map(async (s) => {
|
|
12662
|
+
const file = join9(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
12328
12663
|
const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
|
|
12329
|
-
return parseAnswers(onOrigin2 ?? await ctx.readFile(
|
|
12664
|
+
return parseAnswers(onOrigin2 ?? await ctx.readFile(join9(s.path, ANSWERS_FILE)));
|
|
12330
12665
|
}));
|
|
12666
|
+
const rootAnswers = onBranch ? onBranch.sites.find((s) => s.dir === ".")?.answers : answers[consumer.sites.indexOf(root)];
|
|
12331
12667
|
const recorded = answers.map((a) => a.commit);
|
|
12332
12668
|
if (recorded.every((c) => c === newest2)) {
|
|
12333
12669
|
ctx.say(`\u2022 ${name}: already at ${newest2}`);
|
|
12334
|
-
return
|
|
12670
|
+
return { repo: name, version: newest2, kind: "current" };
|
|
12335
12671
|
}
|
|
12336
12672
|
const past = recorded.find((c) => c && isPlexusVersion(c) && compareVersions(c, newest2) > 0);
|
|
12337
12673
|
if (past)
|
|
12338
12674
|
throw new Error(`${name} is at ${past}, past ${newest2}; a repo is never taken back to an older version`);
|
|
12339
|
-
const asked = options.to !== void 0
|
|
12340
|
-
const need = asked ? { take: true, version: newest2, why: `asked for (${
|
|
12675
|
+
const asked = options.to !== void 0 || options.now === true;
|
|
12676
|
+
const need = asked ? { take: true, version: newest2, why: `asked for (${options.to !== void 0 ? `--to ${newest2}` : "--now"})` } : needOf({
|
|
12341
12677
|
recorded,
|
|
12342
12678
|
releases,
|
|
12343
|
-
maxAge: options.maxAge ?? maxAgeOf(
|
|
12679
|
+
maxAge: options.maxAge ?? maxAgeOf(rootAnswers?.answers ?? {}),
|
|
12344
12680
|
now: options.today === void 0 ? /* @__PURE__ */ new Date() : new Date(options.today)
|
|
12345
12681
|
});
|
|
12346
12682
|
if (need.held)
|
|
12347
12683
|
ctx.say(`\u2022 ${name}: ${need.held} (plx update --now takes it)`);
|
|
12684
|
+
const reviewers = options.reviewers ? { named: options.reviewers } : void 0;
|
|
12348
12685
|
const version2 = need.take ? need.version : newest2;
|
|
12349
|
-
const summary = emptySummary(version2, ctx.dryRun);
|
|
12350
12686
|
const branch = versionBranch(version2);
|
|
12351
12687
|
if (await onOrigin(ctx, repo, branch)) {
|
|
12352
|
-
const
|
|
12353
|
-
|
|
12354
|
-
if (
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12688
|
+
const tip = await tipOnOrigin(ctx, repo, branch);
|
|
12689
|
+
const pull = await pullOf(ctx, consumer, repo, version2, tip);
|
|
12690
|
+
if (!pull) {
|
|
12691
|
+
try {
|
|
12692
|
+
const late = await openLate(ctx, consumer, version2, reviewers, tip);
|
|
12693
|
+
if (late.failed)
|
|
12694
|
+
ctx.say(` \u2717 FAILED \u2014 ${late.failed}`);
|
|
12695
|
+
return {
|
|
12696
|
+
repo: name,
|
|
12697
|
+
version: version2,
|
|
12698
|
+
kind: "found",
|
|
12699
|
+
...late.pull ? { pull: late.pull.url } : {},
|
|
12700
|
+
...late.previewed ? { opening: true } : {},
|
|
12701
|
+
marked: late.marked,
|
|
12702
|
+
behind: late.behind,
|
|
12703
|
+
mergeable: late.pull !== void 0 && !late.pull.draft && late.ready,
|
|
12704
|
+
...late.failed ? { failed: late.failed } : {},
|
|
12705
|
+
...late.review ? { review: late.review } : {}
|
|
12706
|
+
};
|
|
12707
|
+
} catch (error) {
|
|
12708
|
+
const why = detailOf(error);
|
|
12709
|
+
ctx.say(` \u2717 FAILED \u2014 ${branch} as origin has it${why ? `: ${why}` : ""}`);
|
|
12710
|
+
return { repo: name, version: version2, kind: "found", marked: [], behind: [], mergeable: false, failed: why };
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
if (!pull.open) {
|
|
12714
|
+
ctx.say(`\u2022 ${name}: ${branch} is already on origin, its pull request closed (${pull.url}) \u2014 nothing to do; delete the branch to pull the version again`);
|
|
12715
|
+
return { repo: name, version: version2, kind: "found", marked: [], behind: [], mergeable: false };
|
|
12716
|
+
}
|
|
12717
|
+
try {
|
|
12718
|
+
const { url, ...found } = await revisit(ctx, consumer, pull, version2, tip);
|
|
12719
|
+
if (found.failed)
|
|
12720
|
+
ctx.say(` \u2717 FAILED \u2014 ${found.failed}`);
|
|
12721
|
+
return { repo: name, version: version2, kind: "found", pull: url, ...found };
|
|
12722
|
+
} catch (error) {
|
|
12723
|
+
const why = detailOf(error);
|
|
12724
|
+
ctx.say(` \u2717 FAILED \u2014 ${branch} as origin has it${why ? `: ${why}` : ""}`);
|
|
12725
|
+
return {
|
|
12726
|
+
repo: name,
|
|
12727
|
+
version: version2,
|
|
12728
|
+
kind: "found",
|
|
12729
|
+
pull: pull.url,
|
|
12730
|
+
marked: [],
|
|
12731
|
+
behind: [],
|
|
12732
|
+
mergeable: false,
|
|
12733
|
+
failed: why
|
|
12734
|
+
};
|
|
12359
12735
|
}
|
|
12360
|
-
return summary;
|
|
12361
12736
|
}
|
|
12362
12737
|
if (!need.take) {
|
|
12363
12738
|
ctx.say(`\u2022 ${name}: rests \u2014 ${need.why} (plx update --now takes ${version2})`);
|
|
12364
|
-
|
|
12365
|
-
return summary;
|
|
12739
|
+
return { repo: name, version: version2, kind: "resting", reason: need.why };
|
|
12366
12740
|
}
|
|
12367
12741
|
ctx.say(`\u2022 ${name}: takes ${version2} \u2014 ${need.why}`);
|
|
12368
12742
|
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
12369
|
-
const dir =
|
|
12743
|
+
const dir = join9(scratch, name);
|
|
12370
12744
|
try {
|
|
12371
12745
|
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
12372
12746
|
try {
|
|
12373
12747
|
await ctx.stage(run("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }));
|
|
12374
12748
|
await ctx.stage(run("git", ["worktree", "add", "--quiet", "--detach", dir, `origin/${consumer.branch}`], { cwd: repo }));
|
|
12375
12749
|
} catch (error) {
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
return
|
|
12379
|
-
}
|
|
12380
|
-
await
|
|
12750
|
+
const why = detailOf(error);
|
|
12751
|
+
ctx.say(` \u2717 FAILED \u2014 worktree of origin/${consumer.branch}${why ? `: ${why}` : ""}`);
|
|
12752
|
+
return { repo: name, version: version2, kind: "failed", detail: `worktree of origin/${consumer.branch}: ${why}` };
|
|
12753
|
+
}
|
|
12754
|
+
const held = (await sitesOfTree(ctx, dir, "HEAD")).sites;
|
|
12755
|
+
const sites = held.flatMap((s) => s.template ? [{ path: join9(repo, s.dir), rel: s.dir === "." ? name : join9(name, s.dir), template: s.template }] : []);
|
|
12756
|
+
const taken = await takeVersion(ctx, { ...consumer, sites }, dir, {
|
|
12757
|
+
version: version2,
|
|
12758
|
+
ref: version2,
|
|
12759
|
+
opener: "`plx update`",
|
|
12760
|
+
why: need.why,
|
|
12761
|
+
...reviewers ? { reviewers } : {}
|
|
12762
|
+
});
|
|
12763
|
+
return { repo: name, version: version2, kind: "taken", taken };
|
|
12381
12764
|
} finally {
|
|
12382
12765
|
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
12383
12766
|
if (scratch)
|
|
12384
12767
|
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
12385
12768
|
}
|
|
12386
|
-
|
|
12769
|
+
}
|
|
12770
|
+
async function repoAt(ctx, path3, name) {
|
|
12771
|
+
const tree = await overview(ctx, path3);
|
|
12772
|
+
const found = (await findConsumers(ctx, tree, TEMPLATES)).find((c) => c.path === tree.path);
|
|
12773
|
+
if (!found)
|
|
12774
|
+
throw new Error(`${path3} is not a repo generated from the templates: no ${ANSWERS_FILE} at its root naming one of ${TEMPLATES.map(templateSource).join(", ")}`);
|
|
12775
|
+
if (found.skipped)
|
|
12776
|
+
throw new Error(`${name}: ${found.skipped}`);
|
|
12777
|
+
return {
|
|
12778
|
+
...found,
|
|
12779
|
+
rel: name,
|
|
12780
|
+
sites: found.sites.map((s) => ({ ...s, rel: s.rel === "." ? name : join9(name, s.rel) }))
|
|
12781
|
+
};
|
|
12387
12782
|
}
|
|
12388
12783
|
async function onOrigin(ctx, repo, branch) {
|
|
12389
12784
|
try {
|
|
@@ -12406,35 +12801,41 @@ function newestOf(releases) {
|
|
|
12406
12801
|
return newest2;
|
|
12407
12802
|
}
|
|
12408
12803
|
|
|
12409
|
-
// ../lib/dist/
|
|
12410
|
-
async function
|
|
12804
|
+
// ../lib/dist/recursive.js
|
|
12805
|
+
async function updateRecursive(ctx, options) {
|
|
12411
12806
|
const { dir, ...rest } = options;
|
|
12412
12807
|
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
12413
12808
|
throw new UsageError(`'${options.to}' is not plain semver (X.Y.Z, no v)`);
|
|
12414
|
-
const summary = emptySummary(options.to ?? "", ctx.dryRun);
|
|
12415
12809
|
const consumers = await findConsumers(ctx, await overview(ctx, dir), TEMPLATES);
|
|
12416
12810
|
if (consumers.length === 0)
|
|
12417
12811
|
ctx.say(`\u2022 no repo generated from ${TEMPLATES.map(templateSource).join(", ")} found under ${dir}`);
|
|
12812
|
+
let releases = [];
|
|
12813
|
+
if (consumers.some((c) => !c.skipped)) {
|
|
12814
|
+
await preflightForge(ctx);
|
|
12815
|
+
if (options.to === void 0)
|
|
12816
|
+
releases = await releasesOf(ctx);
|
|
12817
|
+
}
|
|
12818
|
+
const version2 = options.to ?? "";
|
|
12819
|
+
const outcomes = [];
|
|
12418
12820
|
for (const consumer of consumers) {
|
|
12419
12821
|
if (consumer.skipped) {
|
|
12420
|
-
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run
|
|
12421
|
-
|
|
12822
|
+
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run plx update --recursive)`);
|
|
12823
|
+
outcomes.push({ repo: consumer.rel, version: version2, kind: "skipped", reason: consumer.skipped });
|
|
12422
12824
|
continue;
|
|
12423
12825
|
}
|
|
12424
12826
|
try {
|
|
12425
|
-
|
|
12426
|
-
mergeSummary(summary, one);
|
|
12427
|
-
summary.version ||= one.version;
|
|
12827
|
+
outcomes.push(await update(ctx, { repo: consumer.path, ...rest }, { consumer, releases }));
|
|
12428
12828
|
} catch (error) {
|
|
12429
|
-
|
|
12430
|
-
|
|
12829
|
+
const why = detailOf(error);
|
|
12830
|
+
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}${why ? `: ${why}` : ""}`);
|
|
12831
|
+
outcomes.push({ repo: consumer.rel, version: version2, kind: "failed", detail: why });
|
|
12431
12832
|
}
|
|
12432
12833
|
}
|
|
12433
|
-
return
|
|
12834
|
+
return outcomes;
|
|
12434
12835
|
}
|
|
12435
12836
|
|
|
12436
12837
|
// ../lib/dist/requirements.js
|
|
12437
|
-
import { join as
|
|
12838
|
+
import { join as join10 } from "node:path";
|
|
12438
12839
|
var KEYWORD = /MUST|SHOULD|MAY/;
|
|
12439
12840
|
var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
|
|
12440
12841
|
function requirementName(bullet) {
|
|
@@ -12529,16 +12930,16 @@ function scanPage(text, name, mode) {
|
|
|
12529
12930
|
defect(i, `BCP 14 keyword outside a requirement: ${line}`);
|
|
12530
12931
|
}
|
|
12531
12932
|
if (mode === "module") {
|
|
12532
|
-
const { maturity = "", binds = "", code = "" } = scan;
|
|
12933
|
+
const { maturity = "", binds = "", code: code2 = "" } = scan;
|
|
12533
12934
|
const n = text.endsWith("\n") ? lines.length - 1 : lines.length;
|
|
12534
12935
|
if (!/^(note|candidate|standard)$/.test(maturity))
|
|
12535
12936
|
defect(n - 1, `maturity must be note, candidate or standard, not "${maturity}"`);
|
|
12536
12937
|
if (!/^(repo|app|host|organisation)$/.test(binds))
|
|
12537
12938
|
defect(n - 1, `binds must be repo, app, host or organisation, not "${binds}"`);
|
|
12538
|
-
if (maturity === "note" &&
|
|
12939
|
+
if (maturity === "note" && code2 !== "")
|
|
12539
12940
|
defect(n - 1, "a note carries no code");
|
|
12540
|
-
if (maturity !== "note" && !/^PLX-[A-Z][A-Za-z]+$/.test(
|
|
12541
|
-
defect(n - 1, `code must be PLX- plus one capitalised word, not "${
|
|
12941
|
+
if (maturity !== "note" && !/^PLX-[A-Z][A-Za-z]+$/.test(code2))
|
|
12942
|
+
defect(n - 1, `code must be PLX- plus one capitalised word, not "${code2}"`);
|
|
12542
12943
|
}
|
|
12543
12944
|
return scan;
|
|
12544
12945
|
}
|
|
@@ -12548,7 +12949,7 @@ var MODULE_DIRS = ["contracts", "approaches"];
|
|
|
12548
12949
|
async function modulePages(ctx, compendium) {
|
|
12549
12950
|
const pages = [];
|
|
12550
12951
|
for (const dir of MODULE_DIRS) {
|
|
12551
|
-
const entries = await ctx.readDir(
|
|
12952
|
+
const entries = await ctx.readDir(join10(compendium, dir));
|
|
12552
12953
|
for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
|
|
12553
12954
|
pages.push(`${dir}/${e.name}`);
|
|
12554
12955
|
}
|
|
@@ -12556,11 +12957,11 @@ async function modulePages(ctx, compendium) {
|
|
|
12556
12957
|
}
|
|
12557
12958
|
async function checkCompendium(ctx, compendium) {
|
|
12558
12959
|
const defects = [];
|
|
12559
|
-
defects.push(...scanPage(await ctx.readFile(
|
|
12960
|
+
defects.push(...scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
|
|
12560
12961
|
const pages = await modulePages(ctx, compendium);
|
|
12561
12962
|
const scans = /* @__PURE__ */ new Map();
|
|
12562
12963
|
for (const page of pages) {
|
|
12563
|
-
const scan = scanPage(await ctx.readFile(
|
|
12964
|
+
const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
|
|
12564
12965
|
defects.push(...scan.defects);
|
|
12565
12966
|
scans.set(page, scan);
|
|
12566
12967
|
}
|
|
@@ -12568,9 +12969,9 @@ async function checkCompendium(ctx, compendium) {
|
|
|
12568
12969
|
for (const [page, s] of scans)
|
|
12569
12970
|
if (s.code)
|
|
12570
12971
|
byCode.set(s.code, [...byCode.get(s.code) ?? [], page]);
|
|
12571
|
-
for (const [
|
|
12972
|
+
for (const [code2, where] of byCode)
|
|
12572
12973
|
if (where.length > 1)
|
|
12573
|
-
defects.push(`\u2717 duplicate module code: ${
|
|
12974
|
+
defects.push(`\u2717 duplicate module code: ${code2}`);
|
|
12574
12975
|
const named = /* @__PURE__ */ new Set();
|
|
12575
12976
|
for (const s of scans.values())
|
|
12576
12977
|
for (const name of s.names) {
|
|
@@ -12588,8 +12989,8 @@ async function checkCompendium(ctx, compendium) {
|
|
|
12588
12989
|
defects.push(`\u2717 unknown module in depends: ${dep}`);
|
|
12589
12990
|
const kindOf2 = (page) => page.startsWith("contracts/") ? "contract" : "approach";
|
|
12590
12991
|
const side = (binds2) => binds2 === "repo" || binds2 === "app" ? "dev" : "ops";
|
|
12591
|
-
const kinds = new Map([...byCode].map(([
|
|
12592
|
-
const binds = new Map([...byCode].map(([
|
|
12992
|
+
const kinds = new Map([...byCode].map(([code2, [page = ""]]) => [code2, kindOf2(page)]));
|
|
12993
|
+
const binds = new Map([...byCode].map(([code2, [page = ""]]) => [code2, scans.get(page)?.binds ?? ""]));
|
|
12593
12994
|
for (const [page, s] of scans) {
|
|
12594
12995
|
const m = s.code ?? page.replace(/.*\//, "");
|
|
12595
12996
|
const kind = kindOf2(page);
|
|
@@ -12621,9 +13022,9 @@ async function readCitable(ctx, compendium) {
|
|
|
12621
13022
|
}
|
|
12622
13023
|
async function readPages(ctx, compendium) {
|
|
12623
13024
|
const own = /* @__PURE__ */ new Map([[MAP_PAGE, "PLX"]]);
|
|
12624
|
-
const citable = scanPage(await ctx.readFile(
|
|
13025
|
+
const citable = scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").sections.map((n) => `\xA7 ${n} PLX`);
|
|
12625
13026
|
for (const page of await modulePages(ctx, compendium)) {
|
|
12626
|
-
const scan = scanPage(await ctx.readFile(
|
|
13027
|
+
const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
|
|
12627
13028
|
if (!scan.code)
|
|
12628
13029
|
continue;
|
|
12629
13030
|
own.set(page, scan.code);
|
|
@@ -12633,10 +13034,10 @@ async function readPages(ctx, compendium) {
|
|
|
12633
13034
|
}
|
|
12634
13035
|
var COPIER_FILES = ["copier.yml", "copier.yaml"];
|
|
12635
13036
|
async function kindOf(ctx, dir) {
|
|
12636
|
-
if (await ctx.readFile(
|
|
13037
|
+
if (await ctx.readFile(join10(dir, MAP_PAGE)).then(() => true, () => false))
|
|
12637
13038
|
return { kind: "compendium" };
|
|
12638
13039
|
for (const file of COPIER_FILES) {
|
|
12639
|
-
const text = await ctx.readFile(
|
|
13040
|
+
const text = await ctx.readFile(join10(dir, file)).catch(() => void 0);
|
|
12640
13041
|
const sub = text === void 0 ? void 0 : /^_subdirectory:\s*["']?([^"'\s#]+)/m.exec(text)?.[1];
|
|
12641
13042
|
if (sub)
|
|
12642
13043
|
return { kind: "template", templateDir: sub.replace(/\/+$/, "") };
|
|
@@ -12672,7 +13073,7 @@ async function lintRepo(ctx, dir, options = {}) {
|
|
|
12672
13073
|
for (const file of await trackedFiles(ctx, dir)) {
|
|
12673
13074
|
if (file === BASELINE_FILE)
|
|
12674
13075
|
continue;
|
|
12675
|
-
const text = await ctx.readFile(
|
|
13076
|
+
const text = await ctx.readFile(join10(dir, file)).catch(() => void 0);
|
|
12676
13077
|
if (text === void 0 || text.includes("\0"))
|
|
12677
13078
|
continue;
|
|
12678
13079
|
if (kind === "compendium" && /\.mdx?$/.test(file))
|
|
@@ -12686,7 +13087,7 @@ async function lintRepo(ctx, dir, options = {}) {
|
|
|
12686
13087
|
}
|
|
12687
13088
|
async function checkRepo(ctx, dir, options = {}) {
|
|
12688
13089
|
const lint = await lintRepo(ctx, dir, options);
|
|
12689
|
-
const baseline = parseBaseline(await ctx.readFile(
|
|
13090
|
+
const baseline = parseBaseline(await ctx.readFile(join10(dir, BASELINE_FILE)).catch(() => ""));
|
|
12690
13091
|
const { fresh, stale, known } = compareBaseline(lint.violations, baseline);
|
|
12691
13092
|
return {
|
|
12692
13093
|
kind: lint.kind,
|
|
@@ -12704,7 +13105,7 @@ async function checkRepo(ctx, dir, options = {}) {
|
|
|
12704
13105
|
async function planBaseline(ctx, dir, options = {}) {
|
|
12705
13106
|
const lint = await lintRepo(ctx, dir, options);
|
|
12706
13107
|
ctx.say(`\u2022 ${lint.violations.length} known violations \u2192 ${BASELINE_FILE}`);
|
|
12707
|
-
return [write(
|
|
13108
|
+
return [write(join10(dir, BASELINE_FILE), renderBaseline(lint.violations))];
|
|
12708
13109
|
}
|
|
12709
13110
|
async function checkCommitMessage(ctx, file, dir) {
|
|
12710
13111
|
const config = async (key) => (await ctx.read("git", ["config", "--get", key], { cwd: dir }).catch(() => "")).trim();
|
|
@@ -12713,10 +13114,80 @@ async function checkCommitMessage(ctx, file, dir) {
|
|
|
12713
13114
|
}
|
|
12714
13115
|
|
|
12715
13116
|
// ../lib/dist/summary.js
|
|
13117
|
+
var inRun = (repo, file) => repo === "." ? file : `${repo}/${file}`;
|
|
13118
|
+
var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
|
|
13119
|
+
function summarize(outcomes, preview, version2 = outcomes.find((o) => o.version)?.version ?? "") {
|
|
13120
|
+
const s = {
|
|
13121
|
+
version: version2,
|
|
13122
|
+
preview,
|
|
13123
|
+
clean: [],
|
|
13124
|
+
conflicted: [],
|
|
13125
|
+
failed: [],
|
|
13126
|
+
skipped: [],
|
|
13127
|
+
resting: [],
|
|
13128
|
+
pulls: [],
|
|
13129
|
+
mergeable: [],
|
|
13130
|
+
opening: []
|
|
13131
|
+
};
|
|
13132
|
+
for (const o of outcomes) {
|
|
13133
|
+
switch (o.kind) {
|
|
13134
|
+
case "current":
|
|
13135
|
+
break;
|
|
13136
|
+
case "skipped":
|
|
13137
|
+
s.skipped.push({ path: o.repo, reason: o.reason });
|
|
13138
|
+
break;
|
|
13139
|
+
case "resting":
|
|
13140
|
+
s.resting.push({ path: o.repo, reason: o.reason });
|
|
13141
|
+
break;
|
|
13142
|
+
case "failed":
|
|
13143
|
+
s.failed.push(o.repo);
|
|
13144
|
+
break;
|
|
13145
|
+
case "found":
|
|
13146
|
+
for (const file of o.marked)
|
|
13147
|
+
s.conflicted.push(inRun(o.repo, file));
|
|
13148
|
+
for (const site2 of o.behind)
|
|
13149
|
+
s.failed.push(`${site2 === "." ? o.repo : inRun(o.repo, site2)} (not at ${o.version})`);
|
|
13150
|
+
if (o.failed !== void 0)
|
|
13151
|
+
s.failed.push(o.repo);
|
|
13152
|
+
if (o.pull)
|
|
13153
|
+
s.pulls.push(o.pull);
|
|
13154
|
+
if (o.opening)
|
|
13155
|
+
s.opening.push(`${o.repo} ${versionBranch(o.version)}`);
|
|
13156
|
+
if (o.pull && o.mergeable)
|
|
13157
|
+
s.mergeable.push(o.pull);
|
|
13158
|
+
if (o.review && "failed" in o.review)
|
|
13159
|
+
s.failed.push(`${o.repo} (review request)`);
|
|
13160
|
+
break;
|
|
13161
|
+
case "taken": {
|
|
13162
|
+
const t = o.taken;
|
|
13163
|
+
for (const site2 of t.sites)
|
|
13164
|
+
s[site2.outcome].push(site2.rel);
|
|
13165
|
+
const conflicted = t.sites.filter((x) => x.outcome === "conflicted").map((x) => x.rel);
|
|
13166
|
+
for (const file of t.marked ?? []) {
|
|
13167
|
+
const path3 = inRun(t.rel, file);
|
|
13168
|
+
if (!conflicted.some((site2) => site2 === "." || path3 === site2 || path3.startsWith(`${site2}/`)))
|
|
13169
|
+
s.conflicted.push(path3);
|
|
13170
|
+
}
|
|
13171
|
+
if (t.lockfile === "failed")
|
|
13172
|
+
s.failed.push(`${t.rel}/pnpm-lock.yaml`);
|
|
13173
|
+
if (t.failed !== void 0)
|
|
13174
|
+
s.failed.push(t.rel);
|
|
13175
|
+
if (t.pull)
|
|
13176
|
+
s.pulls.push(t.pull.url ?? `${t.rel} ${t.pull.branch}`);
|
|
13177
|
+
if (t.pull?.url && !t.pull.draft && !needsHand(t))
|
|
13178
|
+
s.mergeable.push(t.pull.url);
|
|
13179
|
+
if (t.review && "failed" in t.review)
|
|
13180
|
+
s.failed.push(`${t.rel} (review request)`);
|
|
13181
|
+
break;
|
|
13182
|
+
}
|
|
13183
|
+
}
|
|
13184
|
+
}
|
|
13185
|
+
return s;
|
|
13186
|
+
}
|
|
12716
13187
|
function mergeLine(urls) {
|
|
12717
13188
|
return urls.map((url) => /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/pull\/(\d+)$/.exec(url)).filter((m) => m !== null).map((m) => `gh pr merge -md -R ${m[1]} ${m[2]}`).join(" && ");
|
|
12718
13189
|
}
|
|
12719
|
-
function renderSummary(s, realCommand, verb = "
|
|
13190
|
+
function renderSummary(s, realCommand, verb = "update") {
|
|
12720
13191
|
const lines = ["\u2500\u2500 summary \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];
|
|
12721
13192
|
for (const p of s.clean)
|
|
12722
13193
|
lines.push(` \u2713 clean: ${p}`);
|
|
@@ -12730,11 +13201,13 @@ function renderSummary(s, realCommand, verb = "propagate") {
|
|
|
12730
13201
|
lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
12731
13202
|
for (const url of s.pulls)
|
|
12732
13203
|
lines.push(` \u2192 pull: ${url}`);
|
|
13204
|
+
for (const branch of s.opening)
|
|
13205
|
+
lines.push(` \u2192 to open: ${branch}`);
|
|
12733
13206
|
const merge2 = s.preview ? "" : mergeLine(s.mergeable);
|
|
12734
13207
|
if (merge2)
|
|
12735
13208
|
lines.push(" the clean ones, to merge once their checks pass:", ` ${merge2}`);
|
|
12736
13209
|
const clean = isClean(s);
|
|
12737
|
-
const idle = clean && s.clean.length === 0;
|
|
13210
|
+
const idle = clean && s.clean.length === 0 && s.opening.length === 0;
|
|
12738
13211
|
if (s.preview && !idle) {
|
|
12739
13212
|
lines.push(" (preview only \u2014 nothing was changed)");
|
|
12740
13213
|
if (clean)
|
|
@@ -12750,7 +13223,7 @@ function renderSummary(s, realCommand, verb = "propagate") {
|
|
|
12750
13223
|
// ../lib/dist/umbrella.js
|
|
12751
13224
|
var import_semver = __toESM(require_semver2(), 1);
|
|
12752
13225
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
12753
|
-
import { join as
|
|
13226
|
+
import { join as join11 } from "node:path";
|
|
12754
13227
|
var UMBRELLA_MARK = "Generated by `plx umbrella up`; `plx umbrella down` removes it.";
|
|
12755
13228
|
var UMBRELLA_STATE = ".plx-umbrella";
|
|
12756
13229
|
var UMBRELLA_ROOT_VAR = "PLX_UMBRELLA_ROOT";
|
|
@@ -12863,16 +13336,16 @@ function planUp(dir, repos2) {
|
|
|
12863
13336
|
const linked = [...new Set(links.filter((l) => l.linked).map((l) => l.to))].sort();
|
|
12864
13337
|
const has = (script) => (name) => packages.get(name)?.scripts.includes(script) === true;
|
|
12865
13338
|
const watched = linked.filter(has("dev"));
|
|
12866
|
-
const pnpm = { cwd:
|
|
12867
|
-
const state =
|
|
12868
|
-
const log =
|
|
12869
|
-
const start = `set -m; nohup pnpm ${[...filters(watched), "--parallel", "run", "dev"].join(" ")} > ${quoted(log)} 2>&1 & echo $! > ${quoted(
|
|
13339
|
+
const pnpm = { cwd: join11(dir, newestPnpm(repos2) ?? ""), env: { [WORKSPACE_VAR]: dir } };
|
|
13340
|
+
const state = join11(dir, UMBRELLA_STATE);
|
|
13341
|
+
const log = join11(state, "watch.log");
|
|
13342
|
+
const start = `set -m; nohup pnpm ${[...filters(watched), "--parallel", "run", "dev"].join(" ")} > ${quoted(log)} 2>&1 & echo $! > ${quoted(join11(state, "watch.pid"))}`;
|
|
12870
13343
|
const plan = [
|
|
12871
13344
|
stopWatcher(dir),
|
|
12872
|
-
run("mkdir", ["-p",
|
|
12873
|
-
write(
|
|
13345
|
+
run("mkdir", ["-p", join11(dir, UMBRELLA_STATE)]),
|
|
13346
|
+
write(join11(dir, WORKSPACE), `# ${UMBRELLA_MARK}
|
|
12874
13347
|
${(0, import_yaml6.stringify)(settings)}`),
|
|
12875
|
-
write(
|
|
13348
|
+
write(join11(dir, MISE), `# ${UMBRELLA_MARK}
|
|
12876
13349
|
[env]
|
|
12877
13350
|
${UMBRELLA_ROOT_VAR} = "{{config_root}}"
|
|
12878
13351
|
${WORKSPACE_VAR} = "{{config_root}}"
|
|
@@ -12898,7 +13371,7 @@ function planDown(dir, repos2) {
|
|
|
12898
13371
|
stopWatcher(dir),
|
|
12899
13372
|
run("rm", ["-rf", UMBRELLA_STATE, "node_modules", "pnpm-lock.yaml", WORKSPACE, MISE], { cwd: dir }),
|
|
12900
13373
|
// The variable names the repo itself, whatever a shell under the umbrella still carries.
|
|
12901
|
-
...repos2.map((repo) => run("pnpm", ["install", "--force"], { cwd:
|
|
13374
|
+
...repos2.map((repo) => run("pnpm", ["install", "--force"], { cwd: join11(dir, repo), env: { [WORKSPACE_VAR]: join11(dir, repo) } }))
|
|
12902
13375
|
];
|
|
12903
13376
|
}
|
|
12904
13377
|
async function readOptional(ctx, path3) {
|
|
@@ -12919,21 +13392,21 @@ async function expand2(ctx, root, glob) {
|
|
|
12919
13392
|
if (star < 0)
|
|
12920
13393
|
return [glob.replace(/\/$/, "")];
|
|
12921
13394
|
const parent = glob.slice(0, star).replace(/\/$/, "");
|
|
12922
|
-
const entries = await ctx.readDir(
|
|
12923
|
-
return entries.filter((e) => e.directory && !e.name.startsWith(".")).map((e) =>
|
|
13395
|
+
const entries = await ctx.readDir(join11(root, parent)).catch(() => []);
|
|
13396
|
+
return entries.filter((e) => e.directory && !e.name.startsWith(".")).map((e) => join11(parent, e.name));
|
|
12924
13397
|
}
|
|
12925
13398
|
async function readRepo2(ctx, dir, name, workspace) {
|
|
12926
13399
|
const own = (0, import_yaml6.parse)(workspace);
|
|
12927
13400
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
12928
13401
|
const packages = [];
|
|
12929
13402
|
for (const glob of globs.filter((g) => !g.startsWith("!"))) {
|
|
12930
|
-
for (const pkgDir of (await expand2(ctx,
|
|
12931
|
-
const manifest2 = await readManifest(ctx,
|
|
13403
|
+
for (const pkgDir of (await expand2(ctx, join11(dir, name), glob)).sort()) {
|
|
13404
|
+
const manifest2 = await readManifest(ctx, join11(dir, name, pkgDir, "package.json"));
|
|
12932
13405
|
if (!manifest2)
|
|
12933
13406
|
continue;
|
|
12934
13407
|
packages.push({
|
|
12935
13408
|
repo: name,
|
|
12936
|
-
dir:
|
|
13409
|
+
dir: join11(name, pkgDir),
|
|
12937
13410
|
name: manifest2.name,
|
|
12938
13411
|
version: manifest2.version,
|
|
12939
13412
|
scripts: Object.keys(manifest2.scripts ?? {}),
|
|
@@ -12946,13 +13419,13 @@ async function readRepo2(ctx, dir, name, workspace) {
|
|
|
12946
13419
|
});
|
|
12947
13420
|
}
|
|
12948
13421
|
}
|
|
12949
|
-
const root = await readManifest(ctx,
|
|
13422
|
+
const root = await readManifest(ctx, join11(dir, name, "package.json"));
|
|
12950
13423
|
return { name, workspace, packageManager: root?.packageManager, packages };
|
|
12951
13424
|
}
|
|
12952
13425
|
async function generated(ctx, dir) {
|
|
12953
13426
|
const [workspace, mise] = await Promise.all([
|
|
12954
|
-
readOptional(ctx,
|
|
12955
|
-
readOptional(ctx,
|
|
13427
|
+
readOptional(ctx, join11(dir, WORKSPACE)),
|
|
13428
|
+
readOptional(ctx, join11(dir, MISE))
|
|
12956
13429
|
]);
|
|
12957
13430
|
const marked = (text) => text?.startsWith(`# ${UMBRELLA_MARK}`) === true;
|
|
12958
13431
|
const foreign = [
|
|
@@ -12972,11 +13445,14 @@ async function readUmbrella(ctx, dir, only) {
|
|
|
12972
13445
|
continue;
|
|
12973
13446
|
if (only && !only.includes(entry.name))
|
|
12974
13447
|
continue;
|
|
12975
|
-
const names = (await ctx.readDir(
|
|
13448
|
+
const names = (await ctx.readDir(join11(dir, entry.name)).catch(() => [])).map((e) => e.name);
|
|
12976
13449
|
if (!names.includes(".git") || !names.includes(WORKSPACE))
|
|
12977
13450
|
continue;
|
|
12978
|
-
repos2.push(await readRepo2(ctx, dir, entry.name, await ctx.readFile(
|
|
13451
|
+
repos2.push(await readRepo2(ctx, dir, entry.name, await ctx.readFile(join11(dir, entry.name, WORKSPACE))));
|
|
12979
13452
|
}
|
|
13453
|
+
const paths = (only ?? []).filter((name) => name.includes("/"));
|
|
13454
|
+
if (paths.length > 0)
|
|
13455
|
+
throw new UsageError(`--only takes the names of repos directly under the directory, not paths (${paths.join(", ")}); pass the directory that holds the clones as the argument`);
|
|
12980
13456
|
const missing = (only ?? []).filter((name) => !repos2.some((r) => r.name === name));
|
|
12981
13457
|
if (missing.length > 0)
|
|
12982
13458
|
throw new UsageError(`no pnpm workspace in a git repo at ${missing.join(", ")} under ${dir}`);
|
|
@@ -12990,7 +13466,7 @@ async function readUmbrellaDown(ctx, dir) {
|
|
|
12990
13466
|
throw refuse(dir, foreign);
|
|
12991
13467
|
if (!up)
|
|
12992
13468
|
return { repos: [], plan: [] };
|
|
12993
|
-
const own = (0, import_yaml6.parse)(await ctx.readFile(
|
|
13469
|
+
const own = (0, import_yaml6.parse)(await ctx.readFile(join11(dir, WORKSPACE)));
|
|
12994
13470
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
12995
13471
|
const repos2 = globs.filter((g) => !g.includes("/") && !g.startsWith("!"));
|
|
12996
13472
|
return { repos: repos2, plan: planDown(dir, repos2) };
|
|
@@ -13757,7 +14233,7 @@ var getClosingCode = (openingCode) => {
|
|
|
13757
14233
|
return 0;
|
|
13758
14234
|
return void 0;
|
|
13759
14235
|
};
|
|
13760
|
-
var wrapAnsiCode = (
|
|
14236
|
+
var wrapAnsiCode = (code2) => `${ESC}${ANSI_CSI}${code2}${ANSI_SGR_TERMINATOR}`;
|
|
13761
14237
|
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
13762
14238
|
var wrapWord = (rows, word, columns) => {
|
|
13763
14239
|
const characters = word[Symbol.iterator]();
|
|
@@ -13900,8 +14376,8 @@ var exec = (string, columns, options = {}) => {
|
|
|
13900
14376
|
const groupsResult = GROUP_REGEX.exec(preString);
|
|
13901
14377
|
const groups = groupsResult?.groups;
|
|
13902
14378
|
if (groups?.code !== void 0) {
|
|
13903
|
-
const
|
|
13904
|
-
escapeCode =
|
|
14379
|
+
const code2 = Number.parseFloat(groups.code);
|
|
14380
|
+
escapeCode = code2 === END_CODE ? void 0 : code2;
|
|
13905
14381
|
} else if (groups?.uri !== void 0) {
|
|
13906
14382
|
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
13907
14383
|
}
|
|
@@ -13944,13 +14420,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
|
13944
14420
|
|
|
13945
14421
|
// ../../node_modules/.pnpm/@inquirer+type@4.3.0_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
|
|
13946
14422
|
function withResolver() {
|
|
13947
|
-
let
|
|
14423
|
+
let resolve10;
|
|
13948
14424
|
let reject;
|
|
13949
14425
|
const promise = new Promise((res, rej) => {
|
|
13950
|
-
|
|
14426
|
+
resolve10 = res;
|
|
13951
14427
|
reject = rej;
|
|
13952
14428
|
});
|
|
13953
|
-
return { promise, resolve:
|
|
14429
|
+
return { promise, resolve: resolve10, reject };
|
|
13954
14430
|
}
|
|
13955
14431
|
|
|
13956
14432
|
// ../../node_modules/.pnpm/@inquirer+core@12.1.0_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
@@ -14022,17 +14498,17 @@ var Emitter = class {
|
|
|
14022
14498
|
list2.splice(i, 1);
|
|
14023
14499
|
}
|
|
14024
14500
|
}
|
|
14025
|
-
emit(ev,
|
|
14501
|
+
emit(ev, code2, signal) {
|
|
14026
14502
|
if (this.emitted[ev]) {
|
|
14027
14503
|
return false;
|
|
14028
14504
|
}
|
|
14029
14505
|
this.emitted[ev] = true;
|
|
14030
14506
|
let ret = false;
|
|
14031
14507
|
for (const fn of this.listeners[ev]) {
|
|
14032
|
-
ret = fn(
|
|
14508
|
+
ret = fn(code2, signal) === true || ret;
|
|
14033
14509
|
}
|
|
14034
14510
|
if (ev === "exit") {
|
|
14035
|
-
ret = this.emit("afterExit",
|
|
14511
|
+
ret = this.emit("afterExit", code2, signal) || ret;
|
|
14036
14512
|
}
|
|
14037
14513
|
return ret;
|
|
14038
14514
|
}
|
|
@@ -14132,8 +14608,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
14132
14608
|
this.#process.emit = (ev, ...a) => {
|
|
14133
14609
|
return this.#processEmit(ev, ...a);
|
|
14134
14610
|
};
|
|
14135
|
-
this.#process.reallyExit = (
|
|
14136
|
-
return this.#processReallyExit(
|
|
14611
|
+
this.#process.reallyExit = (code2) => {
|
|
14612
|
+
return this.#processReallyExit(code2);
|
|
14137
14613
|
};
|
|
14138
14614
|
}
|
|
14139
14615
|
unload() {
|
|
@@ -14155,11 +14631,11 @@ var SignalExit = class extends SignalExitBase {
|
|
|
14155
14631
|
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
14156
14632
|
this.#emitter.count -= 1;
|
|
14157
14633
|
}
|
|
14158
|
-
#processReallyExit(
|
|
14634
|
+
#processReallyExit(code2) {
|
|
14159
14635
|
if (!processOk(this.#process)) {
|
|
14160
14636
|
return 0;
|
|
14161
14637
|
}
|
|
14162
|
-
this.#process.exitCode =
|
|
14638
|
+
this.#process.exitCode = code2 || 0;
|
|
14163
14639
|
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
14164
14640
|
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
14165
14641
|
}
|
|
@@ -14329,7 +14805,7 @@ function createPrompt(view) {
|
|
|
14329
14805
|
});
|
|
14330
14806
|
output.mute();
|
|
14331
14807
|
const screen = new ScreenManager(rl);
|
|
14332
|
-
const { promise, resolve:
|
|
14808
|
+
const { promise, resolve: resolve10, reject } = withResolver();
|
|
14333
14809
|
return withHooks(rl, (cycle) => {
|
|
14334
14810
|
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
14335
14811
|
const settlePrompt = (settle) => {
|
|
@@ -14340,7 +14816,7 @@ function createPrompt(view) {
|
|
|
14340
14816
|
reject(error);
|
|
14341
14817
|
}
|
|
14342
14818
|
};
|
|
14343
|
-
const resolvePrompt = (value) => settlePrompt(() =>
|
|
14819
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve10(value));
|
|
14344
14820
|
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
14345
14821
|
const promptPromise = Object.assign(promise.finally(() => {
|
|
14346
14822
|
cleanups2.forEach((cleanup) => cleanup());
|
|
@@ -14355,8 +14831,8 @@ function createPrompt(view) {
|
|
|
14355
14831
|
}
|
|
14356
14832
|
cleanups2.add(listenTo(signal, "abort", abort));
|
|
14357
14833
|
}
|
|
14358
|
-
cleanups2.add(onExit((
|
|
14359
|
-
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${
|
|
14834
|
+
cleanups2.add(onExit((code2, signal2) => {
|
|
14835
|
+
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code2} ${signal2}`));
|
|
14360
14836
|
}));
|
|
14361
14837
|
cleanups2.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
|
|
14362
14838
|
cleanups2.add(listenTo(rl, "close", clearEffects));
|
|
@@ -14499,11 +14975,11 @@ var CommanderError = class extends Error {
|
|
|
14499
14975
|
* @param {string} code an id string representing the error
|
|
14500
14976
|
* @param {string} message human-readable description of the error
|
|
14501
14977
|
*/
|
|
14502
|
-
constructor(exitCode,
|
|
14978
|
+
constructor(exitCode, code2, message) {
|
|
14503
14979
|
super(message);
|
|
14504
14980
|
Error.captureStackTrace(this, this.constructor);
|
|
14505
14981
|
this.name = this.constructor.name;
|
|
14506
|
-
this.code =
|
|
14982
|
+
this.code = code2;
|
|
14507
14983
|
this.exitCode = exitCode;
|
|
14508
14984
|
this.nestedError = void 0;
|
|
14509
14985
|
}
|
|
@@ -15920,8 +16396,8 @@ var Command = class _Command extends EventEmitter {
|
|
|
15920
16396
|
* @return {Command} `this` command for chaining
|
|
15921
16397
|
*/
|
|
15922
16398
|
arguments(names) {
|
|
15923
|
-
names.trim().split(/ +/).forEach((
|
|
15924
|
-
this.argument(
|
|
16399
|
+
names.trim().split(/ +/).forEach((detail) => {
|
|
16400
|
+
this.argument(detail);
|
|
15925
16401
|
});
|
|
15926
16402
|
return this;
|
|
15927
16403
|
}
|
|
@@ -16060,9 +16536,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
16060
16536
|
* @return never
|
|
16061
16537
|
* @private
|
|
16062
16538
|
*/
|
|
16063
|
-
_exit(exitCode,
|
|
16539
|
+
_exit(exitCode, code2, message) {
|
|
16064
16540
|
if (this._exitCallback) {
|
|
16065
|
-
this._exitCallback(new CommanderError(exitCode,
|
|
16541
|
+
this._exitCallback(new CommanderError(exitCode, code2, message));
|
|
16066
16542
|
}
|
|
16067
16543
|
process4.exit(exitCode);
|
|
16068
16544
|
}
|
|
@@ -16702,14 +17178,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
16702
17178
|
});
|
|
16703
17179
|
}
|
|
16704
17180
|
const exitCallback = this._exitCallback;
|
|
16705
|
-
proc.on("close", (
|
|
16706
|
-
|
|
17181
|
+
proc.on("close", (code2) => {
|
|
17182
|
+
code2 = code2 ?? 1;
|
|
16707
17183
|
if (!exitCallback) {
|
|
16708
|
-
process4.exit(
|
|
17184
|
+
process4.exit(code2);
|
|
16709
17185
|
} else {
|
|
16710
17186
|
exitCallback(
|
|
16711
17187
|
new CommanderError(
|
|
16712
|
-
|
|
17188
|
+
code2,
|
|
16713
17189
|
"commander.executeSubCommandAsync",
|
|
16714
17190
|
"(close)"
|
|
16715
17191
|
)
|
|
@@ -17216,8 +17692,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
17216
17692
|
}
|
|
17217
17693
|
const config = errorOptions || {};
|
|
17218
17694
|
const exitCode = config.exitCode || 1;
|
|
17219
|
-
const
|
|
17220
|
-
this._exit(exitCode,
|
|
17695
|
+
const code2 = config.code || "commander.error";
|
|
17696
|
+
this._exit(exitCode, code2, message);
|
|
17221
17697
|
}
|
|
17222
17698
|
/**
|
|
17223
17699
|
* Apply any option related environment variables, if option does
|
|
@@ -17914,7 +18390,7 @@ function renderDeploy(d) {
|
|
|
17914
18390
|
}
|
|
17915
18391
|
|
|
17916
18392
|
// src/commands/deploy-targets.ts
|
|
17917
|
-
import { resolve as resolve4 } from "node:path";
|
|
18393
|
+
import { relative as relative5, resolve as resolve4 } from "node:path";
|
|
17918
18394
|
function register3(program2) {
|
|
17919
18395
|
program2.command("deploy-targets").description(
|
|
17920
18396
|
"map each app of a platform repo, per environment, to the deploy target of the inventory file that declares it"
|
|
@@ -17923,12 +18399,22 @@ function register3(program2) {
|
|
|
17923
18399
|
"with --environment: only the apps with a directory under <dir>, as a list of {app, host} for a matrix"
|
|
17924
18400
|
).action(async (inventory, opts, command) => {
|
|
17925
18401
|
const ctx = contextOf(command);
|
|
17926
|
-
const
|
|
18402
|
+
const files = await readInventory(ctx, resolve4(inventory));
|
|
18403
|
+
const targets = selectDeployTargets(files);
|
|
17927
18404
|
if (opts.apps !== void 0) {
|
|
17928
18405
|
if (!opts.environment) throw new UsageError("--apps needs --environment");
|
|
17929
18406
|
const dirs = (await ctx.readDir(resolve4(opts.apps)).catch(() => [])).filter((e) => e.directory).map((e) => e.name);
|
|
17930
|
-
const { legs, without } = deployLegs(
|
|
17931
|
-
|
|
18407
|
+
const { legs, untargeted, without } = deployLegs(
|
|
18408
|
+
targetsIn(targets, opts.environment),
|
|
18409
|
+
dirs,
|
|
18410
|
+
recordsWithoutTarget(files, opts.environment)
|
|
18411
|
+
);
|
|
18412
|
+
for (const app of without) ctx.say(`${app} has no record in ${opts.environment}; nothing to deploy`);
|
|
18413
|
+
if (untargeted.length > 0)
|
|
18414
|
+
throw untargetedError(
|
|
18415
|
+
untargeted.map((u) => ({ app: u.app, files: u.files.map((f) => relative5(process.cwd(), f)) })),
|
|
18416
|
+
opts.environment
|
|
18417
|
+
);
|
|
17932
18418
|
ctx.result(legs, (l) => JSON.stringify(l));
|
|
17933
18419
|
return;
|
|
17934
18420
|
}
|
|
@@ -17942,7 +18428,7 @@ import { resolve as resolve5 } from "node:path";
|
|
|
17942
18428
|
|
|
17943
18429
|
// src/style.ts
|
|
17944
18430
|
function style(enabled) {
|
|
17945
|
-
const wrap = (
|
|
18431
|
+
const wrap = (code2) => (s) => enabled ? `\x1B[${code2}m${s}\x1B[0m` : s;
|
|
17946
18432
|
return { dim: wrap(2), bold: wrap(1), ok: wrap(32), warn: wrap(33), info: wrap(36), note: wrap(35) };
|
|
17947
18433
|
}
|
|
17948
18434
|
var colorByDefault = () => process.stdout.isTTY === true && !process.env.NO_COLOR;
|
|
@@ -17970,7 +18456,8 @@ function renderReport(report, s, showPassing, given = report.root) {
|
|
|
17970
18456
|
const note = notes.filter(Boolean).join(", ");
|
|
17971
18457
|
if (showPassing) lines.push(`${s.ok("\u2713")} ${u.path}${note ? ` ${s.dim(`[${note}]`)}` : ""}`);
|
|
17972
18458
|
}
|
|
17973
|
-
for (const f of u.findings)
|
|
18459
|
+
for (const f of u.findings)
|
|
18460
|
+
lines.push(`${s.warn("\u2717")} ${f.requirement ? `${f.requirement} ` : ""}${u.path}: ${f.problem}`);
|
|
17974
18461
|
if (showPassing) for (const h of u.hints ?? []) lines.push(s.dim(`\u2022 ${u.path}: ${h}`));
|
|
17975
18462
|
}
|
|
17976
18463
|
if (report.skipped.length > 0)
|
|
@@ -18032,8 +18519,8 @@ function annotation(dir, kind, s) {
|
|
|
18032
18519
|
tags.push(s.info(`[copier ${dir.copier.commit ?? "?"} \u2190 ${src}]`));
|
|
18033
18520
|
}
|
|
18034
18521
|
if (kind) {
|
|
18035
|
-
const
|
|
18036
|
-
tags.push(s.bold(`[${kind}${
|
|
18522
|
+
const detail = kind === "app" ? dir.declaration?.profile : dir.pin;
|
|
18523
|
+
tags.push(s.bold(`[${kind}${detail ? ` ${detail}` : ""}]`));
|
|
18037
18524
|
}
|
|
18038
18525
|
if (dir.symlink) tags.push(s.dim("[symbolic link, not followed]"));
|
|
18039
18526
|
if (dir.unreadable) tags.push(s.warn(`[! cannot be read: ${dir.unreadable}]`));
|
|
@@ -18041,39 +18528,21 @@ function annotation(dir, kind, s) {
|
|
|
18041
18528
|
return tags.length ? ` ${tags.join(" ")}` : "";
|
|
18042
18529
|
}
|
|
18043
18530
|
|
|
18044
|
-
// src/commands/propagate.ts
|
|
18045
|
-
import { resolve as resolve7 } from "node:path";
|
|
18046
|
-
function register6(program2) {
|
|
18047
|
-
program2.command("propagate").description(
|
|
18048
|
-
"run update in every repo generated from the templates under a directory: a patch at once, a minor at the next scheduled pull (--max-age), a major only when asked, one pull request per repo"
|
|
18049
|
-
).argument("[dir]", "a directory the repos sit under, at any depth", ".").option("--to <version>", "the version every repo takes, whatever its step: asking").option("--now", "take the newest version in every repo, whatever its step: asking").option(
|
|
18050
|
-
"--max-age <days>",
|
|
18051
|
-
"the interval for every repo, in days (default: each repo's answer update_max_age, else 7; 0 takes every version)",
|
|
18052
|
-
(v) => parseMaxAge(v, "--max-age")
|
|
18053
|
-
).action(async (dir, opts, command) => {
|
|
18054
|
-
const ctx = contextOf(command);
|
|
18055
|
-
const result = await propagate(ctx, { dir: resolve7(dir), to: opts.to, now: opts.now, maxAge: opts.maxAge });
|
|
18056
|
-
const flags = [opts.to ? `--to ${opts.to}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
|
|
18057
|
-
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
18058
|
-
if (!isClean(result)) process.exitCode = 1;
|
|
18059
|
-
});
|
|
18060
|
-
}
|
|
18061
|
-
|
|
18062
18531
|
// src/commands/requirements.ts
|
|
18063
|
-
import { join as
|
|
18064
|
-
function
|
|
18532
|
+
import { join as join12, resolve as resolve7 } from "node:path";
|
|
18533
|
+
function register6(program2) {
|
|
18065
18534
|
program2.command("requirements").description(
|
|
18066
18535
|
"lint a repo: the standard's pages in the compendium, citations, dates, template headers and issue identifiers everywhere"
|
|
18067
18536
|
).argument("[dir]", "a repo checkout: the compendium, a template or any other repo", ".").option("--extract <page>", "print a module page's requirement lines instead of linting (path relative to dir)").option("--write-baseline", `record every current violation in ${BASELINE_FILE} as known, instead of checking`).option("--commit-msg <file>", "check a commit message for issue identifiers instead (the commit-msg hook)").option("--compendium <dir>", "resolve citations against this compendium checkout, not this plx's own index").action(async (dir, opts, command) => {
|
|
18068
18537
|
const ctx = contextOf(command);
|
|
18069
|
-
const repo =
|
|
18070
|
-
const options = { compendium: opts.compendium ?
|
|
18538
|
+
const repo = resolve7(dir);
|
|
18539
|
+
const options = { compendium: opts.compendium ? resolve7(opts.compendium) : void 0 };
|
|
18071
18540
|
if (opts.extract) {
|
|
18072
|
-
ctx.result(extractRequirements(await ctx.readFile(
|
|
18541
|
+
ctx.result(extractRequirements(await ctx.readFile(join12(repo, opts.extract))));
|
|
18073
18542
|
return;
|
|
18074
18543
|
}
|
|
18075
18544
|
if (opts.commitMsg) {
|
|
18076
|
-
const violations = await checkCommitMessage(ctx,
|
|
18545
|
+
const violations = await checkCommitMessage(ctx, resolve7(opts.commitMsg), repo);
|
|
18077
18546
|
ctx.result(violations, (vs) => vs.map(renderViolation).join("\n"));
|
|
18078
18547
|
if (violations.length > 0) process.exitCode = 1;
|
|
18079
18548
|
return;
|
|
@@ -18096,12 +18565,12 @@ function renderCheck(c) {
|
|
|
18096
18565
|
|
|
18097
18566
|
// src/commands/umbrella.ts
|
|
18098
18567
|
import { spawn as spawn2 } from "node:child_process";
|
|
18099
|
-
import { resolve as
|
|
18100
|
-
function
|
|
18568
|
+
import { resolve as resolve8 } from "node:path";
|
|
18569
|
+
function register7(program2) {
|
|
18101
18570
|
const umbrella = program2.command("umbrella").description("develop across repos: one pnpm workspace over the repos under a directory, linking their packages");
|
|
18102
18571
|
umbrella.command("up").description("link the repos, build the linked packages and rebuild them on change; Ctrl+C restores").argument("[dir]", "the directory that holds the clones", ".").option("-d, --detach", "leave the watcher running in the background and return").option("--only <repos>", "the repos to link, comma-separated (default: every pnpm workspace under dir)").action(async (dir, opts, command) => {
|
|
18103
18572
|
const ctx = contextOf(command);
|
|
18104
|
-
const root =
|
|
18573
|
+
const root = resolve8(dir);
|
|
18105
18574
|
const plan = await readUmbrella(ctx, root, opts.only?.split(",").filter(Boolean));
|
|
18106
18575
|
await ctx.apply(plan.plan);
|
|
18107
18576
|
ctx.result(plan, renderUmbrella);
|
|
@@ -18115,7 +18584,7 @@ function register8(program2) {
|
|
|
18115
18584
|
await down(ctx, root);
|
|
18116
18585
|
});
|
|
18117
18586
|
umbrella.command("down").description("stop the watcher, delete what up wrote, and install every repo on its own again").argument("[dir]", "the directory that holds the clones", ".").action(async (dir, _opts, command) => {
|
|
18118
|
-
await down(contextOf(command),
|
|
18587
|
+
await down(contextOf(command), resolve8(dir));
|
|
18119
18588
|
});
|
|
18120
18589
|
}
|
|
18121
18590
|
async function down(ctx, root) {
|
|
@@ -18148,18 +18617,28 @@ function renderUmbrella(u) {
|
|
|
18148
18617
|
}
|
|
18149
18618
|
|
|
18150
18619
|
// src/commands/update.ts
|
|
18151
|
-
import { resolve as
|
|
18152
|
-
function
|
|
18620
|
+
import { resolve as resolve9 } from "node:path";
|
|
18621
|
+
function register8(program2) {
|
|
18153
18622
|
program2.command("update").description(
|
|
18154
|
-
"take a version as a pull request on plexus/<version> (copier update at every site, the
|
|
18155
|
-
).argument("[dir]", "a repo generated from the templates", ".").option("--to <version>", "take this version, whatever its step: asking").option("--now", "take the newest version, whatever its step: asking").option(
|
|
18623
|
+
"take a version as a pull request on plexus/<version> (copier update at every site, the lockfile, the workflow refs): a patch at once, a minor at the next scheduled pull (--max-age), a major only when asked; -r in every repo generated from the templates under a directory"
|
|
18624
|
+
).argument("[dir]", "a repo generated from the templates; with -r, a directory the repos sit under", ".").option("-r, --recursive", "run in every repo generated from the templates under the directory, at any depth").option("--to <version>", "take this version, whatever its step: asking").option("--now", "take the newest version, whatever its step: asking").option(
|
|
18156
18625
|
"--max-age <days>",
|
|
18157
18626
|
"the interval: a minor version is taken once the oldest one not taken is this many days old (default: the repo's answer update_max_age, else 7; 0 takes every version)",
|
|
18158
18627
|
(v) => parseMaxAge(v, "--max-age")
|
|
18628
|
+
).option(
|
|
18629
|
+
"--reviewer <login>",
|
|
18630
|
+
"a GitHub user asked to review the pull request it opens, repeatable or comma-separated; instead of the repo's answer pr_reviewers ('' asks nobody)",
|
|
18631
|
+
(v, previous = []) => [...previous, ...parseReviewers(v, "--reviewer")]
|
|
18159
18632
|
).action(async (dir, opts, command) => {
|
|
18160
18633
|
const ctx = contextOf(command);
|
|
18161
|
-
const
|
|
18162
|
-
|
|
18634
|
+
const { recursive, reviewer, ...asked } = opts;
|
|
18635
|
+
const options = { ...asked, ...reviewer ? { reviewers: [...new Set(reviewer)] } : {} };
|
|
18636
|
+
const outcomes = recursive ? await updateRecursive(ctx, { dir: resolve9(dir), ...options }) : [await update(ctx, { repo: resolve9(dir), ...options })];
|
|
18637
|
+
const result = summarize(outcomes, ctx.dryRun, opts.to);
|
|
18638
|
+
const flags = recursive ? ["-r", opts.to ? `--to ${opts.to}` : "", opts.now ? "--now" : ""] : [`--to ${result.version}`];
|
|
18639
|
+
if (reviewer) flags.push(`--reviewer '${[...new Set(reviewer)].join(",")}'`);
|
|
18640
|
+
const real = `plx -y update ${flags.filter(Boolean).join(" ")} ${dir}`;
|
|
18641
|
+
ctx.result(result, (r) => renderSummary(r, real, recursive ? "update --recursive" : "update"));
|
|
18163
18642
|
if (!isClean(result)) process.exitCode = 1;
|
|
18164
18643
|
});
|
|
18165
18644
|
}
|
|
@@ -18168,10 +18647,9 @@ function register9(program2) {
|
|
|
18168
18647
|
var commands = [
|
|
18169
18648
|
register5,
|
|
18170
18649
|
register4,
|
|
18171
|
-
register6,
|
|
18172
|
-
register9,
|
|
18173
18650
|
register8,
|
|
18174
18651
|
register7,
|
|
18652
|
+
register6,
|
|
18175
18653
|
register,
|
|
18176
18654
|
register3,
|
|
18177
18655
|
register2
|
|
@@ -18184,7 +18662,7 @@ function buildProgram() {
|
|
|
18184
18662
|
program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
|
|
18185
18663
|
new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
|
|
18186
18664
|
).addOption(new Option("-q, --quiet", "say nothing but results and errors").env("PLX_QUIET")).addOption(new Option("-y, --yes", "answer every confirmation with yes (needed off a terminal)").env("PLX_YES")).addOption(new Option("--json", "print results as JSON").env("PLX_JSON"));
|
|
18187
|
-
for (const
|
|
18665
|
+
for (const register9 of commands) register9(program2);
|
|
18188
18666
|
return program2;
|
|
18189
18667
|
}
|
|
18190
18668
|
function contextOf(command) {
|