@plexus-ms/cli 0.127.0 → 0.129.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 +1317 -692
- package/package.json +2 -2
package/dist/plx.js
CHANGED
|
@@ -103,7 +103,7 @@ var require_visit = __commonJS({
|
|
|
103
103
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
104
104
|
var SKIP = /* @__PURE__ */ Symbol("skip children");
|
|
105
105
|
var REMOVE = /* @__PURE__ */ Symbol("remove node");
|
|
106
|
-
function
|
|
106
|
+
function visit2(node, visitor) {
|
|
107
107
|
const visitor_ = initVisitor(visitor);
|
|
108
108
|
if (identity2.isDocument(node)) {
|
|
109
109
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -112,9 +112,9 @@ var require_visit = __commonJS({
|
|
|
112
112
|
} else
|
|
113
113
|
visit_(null, node, visitor_, Object.freeze([]));
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
visit2.BREAK = BREAK;
|
|
116
|
+
visit2.SKIP = SKIP;
|
|
117
|
+
visit2.REMOVE = REMOVE;
|
|
118
118
|
function visit_(key, node, visitor, path3) {
|
|
119
119
|
const ctrl = callVisitor(key, node, visitor, path3);
|
|
120
120
|
if (identity2.isNode(ctrl) || identity2.isPair(ctrl)) {
|
|
@@ -248,7 +248,7 @@ var require_visit = __commonJS({
|
|
|
248
248
|
throw new Error(`Cannot replace node with ${pt} parent`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
exports.visit =
|
|
251
|
+
exports.visit = visit2;
|
|
252
252
|
exports.visitAsync = visitAsync;
|
|
253
253
|
}
|
|
254
254
|
});
|
|
@@ -258,7 +258,7 @@ var require_directives = __commonJS({
|
|
|
258
258
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/directives.js"(exports) {
|
|
259
259
|
"use strict";
|
|
260
260
|
var identity2 = require_identity();
|
|
261
|
-
var
|
|
261
|
+
var visit2 = require_visit();
|
|
262
262
|
var escapeChars = {
|
|
263
263
|
"!": "%21",
|
|
264
264
|
",": "%2C",
|
|
@@ -402,7 +402,7 @@ var require_directives = __commonJS({
|
|
|
402
402
|
let tagNames;
|
|
403
403
|
if (doc && tagEntries.length > 0 && identity2.isNode(doc.contents)) {
|
|
404
404
|
const tags = {};
|
|
405
|
-
|
|
405
|
+
visit2.visit(doc.contents, (_key, node) => {
|
|
406
406
|
if (identity2.isNode(node) && node.tag)
|
|
407
407
|
tags[node.tag] = true;
|
|
408
408
|
});
|
|
@@ -429,7 +429,7 @@ var require_anchors = __commonJS({
|
|
|
429
429
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/anchors.js"(exports) {
|
|
430
430
|
"use strict";
|
|
431
431
|
var identity2 = require_identity();
|
|
432
|
-
var
|
|
432
|
+
var visit2 = require_visit();
|
|
433
433
|
function anchorIsValid(anchor) {
|
|
434
434
|
if (/[\x00-\x19\s,[\]{}]/.test(anchor)) {
|
|
435
435
|
const sa = JSON.stringify(anchor);
|
|
@@ -440,7 +440,7 @@ var require_anchors = __commonJS({
|
|
|
440
440
|
}
|
|
441
441
|
function anchorNames(root) {
|
|
442
442
|
const anchors = /* @__PURE__ */ new Set();
|
|
443
|
-
|
|
443
|
+
visit2.visit(root, {
|
|
444
444
|
Value(_key, node) {
|
|
445
445
|
if (node.anchor)
|
|
446
446
|
anchors.add(node.anchor);
|
|
@@ -620,7 +620,7 @@ var require_Alias = __commonJS({
|
|
|
620
620
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/nodes/Alias.js"(exports) {
|
|
621
621
|
"use strict";
|
|
622
622
|
var anchors = require_anchors();
|
|
623
|
-
var
|
|
623
|
+
var visit2 = require_visit();
|
|
624
624
|
var identity2 = require_identity();
|
|
625
625
|
var Node = require_Node();
|
|
626
626
|
var toJS = require_toJS();
|
|
@@ -646,7 +646,7 @@ var require_Alias = __commonJS({
|
|
|
646
646
|
nodes = ctx.aliasResolveCache;
|
|
647
647
|
} else {
|
|
648
648
|
nodes = [];
|
|
649
|
-
|
|
649
|
+
visit2.visit(doc, {
|
|
650
650
|
Node: (_key, node) => {
|
|
651
651
|
if (identity2.isAlias(node) || identity2.hasAnchor(node))
|
|
652
652
|
nodes.push(node);
|
|
@@ -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":
|
|
@@ -5568,15 +5568,15 @@ var require_cst_visit = __commonJS({
|
|
|
5568
5568
|
var BREAK = /* @__PURE__ */ Symbol("break visit");
|
|
5569
5569
|
var SKIP = /* @__PURE__ */ Symbol("skip children");
|
|
5570
5570
|
var REMOVE = /* @__PURE__ */ Symbol("remove item");
|
|
5571
|
-
function
|
|
5571
|
+
function visit2(cst, visitor) {
|
|
5572
5572
|
if ("type" in cst && cst.type === "document")
|
|
5573
5573
|
cst = { start: cst.start, value: cst.value };
|
|
5574
5574
|
_visit(Object.freeze([]), cst, visitor);
|
|
5575
5575
|
}
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5576
|
+
visit2.BREAK = BREAK;
|
|
5577
|
+
visit2.SKIP = SKIP;
|
|
5578
|
+
visit2.REMOVE = REMOVE;
|
|
5579
|
+
visit2.itemAtPath = (cst, path3) => {
|
|
5580
5580
|
let item = cst;
|
|
5581
5581
|
for (const [field, index] of path3) {
|
|
5582
5582
|
const tok = item?.[field];
|
|
@@ -5587,8 +5587,8 @@ var require_cst_visit = __commonJS({
|
|
|
5587
5587
|
}
|
|
5588
5588
|
return item;
|
|
5589
5589
|
};
|
|
5590
|
-
|
|
5591
|
-
const parent =
|
|
5590
|
+
visit2.parentCollection = (cst, path3) => {
|
|
5591
|
+
const parent = visit2.itemAtPath(cst, path3.slice(0, -1));
|
|
5592
5592
|
const field = path3[path3.length - 1][0];
|
|
5593
5593
|
const coll = parent?.[field];
|
|
5594
5594
|
if (coll && "items" in coll)
|
|
@@ -5619,7 +5619,7 @@ var require_cst_visit = __commonJS({
|
|
|
5619
5619
|
}
|
|
5620
5620
|
return typeof ctrl === "function" ? ctrl(item, path3) : ctrl;
|
|
5621
5621
|
}
|
|
5622
|
-
exports.visit =
|
|
5622
|
+
exports.visit = visit2;
|
|
5623
5623
|
}
|
|
5624
5624
|
});
|
|
5625
5625
|
|
|
@@ -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 parseDocument3(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 = parseDocument3(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 = parseDocument3;
|
|
7315
7315
|
exports.stringify = stringify2;
|
|
7316
7316
|
}
|
|
7317
7317
|
});
|
|
@@ -7335,7 +7335,7 @@ var require_dist = __commonJS({
|
|
|
7335
7335
|
var lineCounter = require_line_counter();
|
|
7336
7336
|
var parser = require_parser();
|
|
7337
7337
|
var publicApi = require_public_api();
|
|
7338
|
-
var
|
|
7338
|
+
var visit2 = require_visit();
|
|
7339
7339
|
exports.Composer = composer.Composer;
|
|
7340
7340
|
exports.Document = Document.Document;
|
|
7341
7341
|
exports.Schema = Schema.Schema;
|
|
@@ -7363,8 +7363,8 @@ var require_dist = __commonJS({
|
|
|
7363
7363
|
exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
7364
7364
|
exports.parseDocument = publicApi.parseDocument;
|
|
7365
7365
|
exports.stringify = publicApi.stringify;
|
|
7366
|
-
exports.visit =
|
|
7367
|
-
exports.visitAsync =
|
|
7366
|
+
exports.visit = visit2.visit;
|
|
7367
|
+
exports.visitAsync = visit2.visitAsync;
|
|
7368
7368
|
}
|
|
7369
7369
|
});
|
|
7370
7370
|
|
|
@@ -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);
|
|
@@ -10370,6 +10378,8 @@ function parseCompose(text, path3) {
|
|
|
10370
10378
|
return { services, ...isMapping(doc) && doc.include != null ? { includes: true } : {} };
|
|
10371
10379
|
}
|
|
10372
10380
|
var IMAGE_PLACEHOLDER = /\$\{PLEXUS_DEPLOYMENT_IMAGE(:[^}]*)?\}/g;
|
|
10381
|
+
var DISPLAY_VERSION_PLACEHOLDER = /\$\{PLEXUS_DISPLAY_VERSION(:[^}]*)?\}/g;
|
|
10382
|
+
var COMMIT_SHA_PLACEHOLDER = /\$\{PLEXUS_COMMIT_SHA(:[^}]*)?\}/g;
|
|
10373
10383
|
var normalImage = (image) => image.replace(IMAGE_PLACEHOLDER, "${PLEXUS_DEPLOYMENT_IMAGE}");
|
|
10374
10384
|
var CONCATENATED = /* @__PURE__ */ new Set([
|
|
10375
10385
|
"ports",
|
|
@@ -10401,7 +10411,7 @@ function union(base, own) {
|
|
|
10401
10411
|
function resolveExtends(written, path3) {
|
|
10402
10412
|
const resolved = {};
|
|
10403
10413
|
const chain = [];
|
|
10404
|
-
const
|
|
10414
|
+
const resolve10 = (name) => {
|
|
10405
10415
|
const done = resolved[name];
|
|
10406
10416
|
if (done)
|
|
10407
10417
|
return done;
|
|
@@ -10413,14 +10423,14 @@ function resolveExtends(written, path3) {
|
|
|
10413
10423
|
let merged = service;
|
|
10414
10424
|
if (ref !== void 0 && written[ref]) {
|
|
10415
10425
|
chain.push(name);
|
|
10416
|
-
merged = merge(
|
|
10426
|
+
merged = merge(resolve10(ref), service);
|
|
10417
10427
|
chain.pop();
|
|
10418
10428
|
}
|
|
10419
10429
|
resolved[name] = merged;
|
|
10420
10430
|
return merged;
|
|
10421
10431
|
};
|
|
10422
10432
|
for (const name of Object.keys(written))
|
|
10423
|
-
|
|
10433
|
+
resolve10(name);
|
|
10424
10434
|
return resolved;
|
|
10425
10435
|
}
|
|
10426
10436
|
function merge(base, service) {
|
|
@@ -10465,11 +10475,54 @@ function labelsOf(service) {
|
|
|
10465
10475
|
}));
|
|
10466
10476
|
}
|
|
10467
10477
|
|
|
10478
|
+
// ../lib/dist/conflicts.js
|
|
10479
|
+
import { join as join2 } from "node:path";
|
|
10480
|
+
var MARKER = /^(?:<<<<<<<|>>>>>>>)(?: |\r?$)/m;
|
|
10481
|
+
var hasConflictMarkers = (text) => MARKER.test(text);
|
|
10482
|
+
var hasUnmergedEntries = (porcelain) => /^(UU|AA|DU|UD)/m.test(porcelain);
|
|
10483
|
+
async function filesWithConflictMarkers(ctx, dir, ref) {
|
|
10484
|
+
const args = ["grep", "-l", "-z", "--no-color", "-E", "-e", "^(<<<<<<<|>>>>>>>)", ...ref ? [ref] : [], "--"];
|
|
10485
|
+
const listed = await orAbsent(ctx.read("git", args, { cwd: dir }), (error) => error.code === 1);
|
|
10486
|
+
const candidates = (listed ?? "").split("\0").filter(Boolean).map((name) => ref && name.startsWith(`${ref}:`) ? name.slice(ref.length + 1) : name);
|
|
10487
|
+
const held = [];
|
|
10488
|
+
for (const file of candidates) {
|
|
10489
|
+
const text = ref ? await ctx.read("git", ["cat-file", "blob", `${ref}:${file}`], { cwd: dir }) : await ctx.readFile(join2(dir, file));
|
|
10490
|
+
if (hasConflictMarkers(text))
|
|
10491
|
+
held.push(file);
|
|
10492
|
+
}
|
|
10493
|
+
return held.sort();
|
|
10494
|
+
}
|
|
10495
|
+
|
|
10468
10496
|
// ../lib/dist/consumers.js
|
|
10469
|
-
import { relative } from "node:path";
|
|
10497
|
+
import { join as join4, relative } from "node:path";
|
|
10470
10498
|
|
|
10471
|
-
// ../lib/dist/
|
|
10499
|
+
// ../lib/dist/copier.js
|
|
10472
10500
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
10501
|
+
var ANSWERS_FILE = ".copier-answers.yml";
|
|
10502
|
+
var TEMPLATE_FILES = ["copier.yml", "copier.yaml"];
|
|
10503
|
+
var COPIER_VERSION = "9.19.1";
|
|
10504
|
+
var copierVia = (args) => ["exec", `copier@${COPIER_VERSION}`, "--", "copier", ...args];
|
|
10505
|
+
function parseAnswers(text) {
|
|
10506
|
+
const data = (0, import_yaml3.parse)(text);
|
|
10507
|
+
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
10508
|
+
throw new Error("answers file is not a mapping");
|
|
10509
|
+
const { _commit, _src_path, ...answers } = data;
|
|
10510
|
+
return {
|
|
10511
|
+
commit: _commit === void 0 ? void 0 : String(_commit),
|
|
10512
|
+
src: _src_path === void 0 ? void 0 : String(_src_path),
|
|
10513
|
+
answers
|
|
10514
|
+
};
|
|
10515
|
+
}
|
|
10516
|
+
function setAnswer(text, key, value) {
|
|
10517
|
+
const doc = (0, import_yaml3.parseDocument)(text);
|
|
10518
|
+
if (doc.errors.length > 0)
|
|
10519
|
+
throw new Error(`answers file is not YAML: ${doc.errors[0]?.message}`);
|
|
10520
|
+
doc.set(key, value);
|
|
10521
|
+
return doc.toString();
|
|
10522
|
+
}
|
|
10523
|
+
|
|
10524
|
+
// ../lib/dist/marker.js
|
|
10525
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10473
10526
|
var OBSOLETE_KEYS = ["plexus", "modules"];
|
|
10474
10527
|
var MARKER_FILE = "PLEXUS.md";
|
|
10475
10528
|
function parseMarker(text) {
|
|
@@ -10492,7 +10545,7 @@ function splitFrontmatter(text) {
|
|
|
10492
10545
|
const match = /^\uFEFF?---\r?\n(?:([\s\S]*?)\r?\n)?---(?:\r?\n|$)([\s\S]*)$/.exec(text);
|
|
10493
10546
|
if (!match)
|
|
10494
10547
|
throw new Error("no frontmatter: expected a `---` block at the top");
|
|
10495
|
-
const data = (0,
|
|
10548
|
+
const data = (0, import_yaml4.parse)(match[1] ?? "") ?? {};
|
|
10496
10549
|
if (typeof data !== "object" || Array.isArray(data))
|
|
10497
10550
|
throw new Error("frontmatter is not a mapping");
|
|
10498
10551
|
return { data, body: match[2] ?? "" };
|
|
@@ -10584,7 +10637,7 @@ var holdsApp = (entries) => entries.some((e) => !e.name.startsWith(".")) && !ent
|
|
|
10584
10637
|
var isOperations = (dir) => dir.copier?.src !== void 0 && templateOf(dir.copier.src, [OPERATIONS_TEMPLATE]) !== void 0;
|
|
10585
10638
|
function unitsOf(root) {
|
|
10586
10639
|
const units = [];
|
|
10587
|
-
const
|
|
10640
|
+
const visit2 = (dir, repo, inApps) => {
|
|
10588
10641
|
let here = repo;
|
|
10589
10642
|
if (dir.gitRoot) {
|
|
10590
10643
|
here = dir;
|
|
@@ -10595,12 +10648,12 @@ function unitsOf(root) {
|
|
|
10595
10648
|
for (const child of dir.children) {
|
|
10596
10649
|
if (child.name === APPS_DIR && here === dir)
|
|
10597
10650
|
for (const app of child.children)
|
|
10598
|
-
|
|
10651
|
+
visit2(app, here, true);
|
|
10599
10652
|
else
|
|
10600
|
-
|
|
10653
|
+
visit2(child, here, false);
|
|
10601
10654
|
}
|
|
10602
10655
|
};
|
|
10603
|
-
|
|
10656
|
+
visit2(root, void 0, false);
|
|
10604
10657
|
return units;
|
|
10605
10658
|
}
|
|
10606
10659
|
function shortRemote(url) {
|
|
@@ -10612,6 +10665,225 @@ function isNotable(dir) {
|
|
|
10612
10665
|
return Boolean(dir.gitRoot || dir.git || dir.template || dir.copier || dir.declaration || dir.problems?.length || dir.unreadable || dir.symlink);
|
|
10613
10666
|
}
|
|
10614
10667
|
|
|
10668
|
+
// ../lib/dist/overview.js
|
|
10669
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
10670
|
+
var PRUNED = /* @__PURE__ */ new Set([
|
|
10671
|
+
"node_modules",
|
|
10672
|
+
".hg",
|
|
10673
|
+
".svn",
|
|
10674
|
+
".next",
|
|
10675
|
+
".nuxt",
|
|
10676
|
+
".turbo",
|
|
10677
|
+
".svelte-kit",
|
|
10678
|
+
"dist",
|
|
10679
|
+
"build",
|
|
10680
|
+
"out",
|
|
10681
|
+
".output",
|
|
10682
|
+
".venv",
|
|
10683
|
+
"venv",
|
|
10684
|
+
"__pycache__",
|
|
10685
|
+
"target",
|
|
10686
|
+
".cache",
|
|
10687
|
+
".pnpm-store",
|
|
10688
|
+
"coverage",
|
|
10689
|
+
"vendor",
|
|
10690
|
+
".terraform",
|
|
10691
|
+
".gradle"
|
|
10692
|
+
]);
|
|
10693
|
+
var descends = (name, app) => name !== ".git" && (app || !PRUNED.has(name));
|
|
10694
|
+
function answersDirs(files) {
|
|
10695
|
+
const present = new Set(files);
|
|
10696
|
+
const holdsTemplate = (dir) => TEMPLATE_FILES.some((f) => present.has(dir === "." ? f : `${dir}/${f}`));
|
|
10697
|
+
const namesIn = (dir) => files.filter((f) => f.startsWith(`${dir}/`)).map((f) => ({ name: f.slice(dir.length + 1).split("/")[0] ?? "" }));
|
|
10698
|
+
const dirs = [];
|
|
10699
|
+
for (const file of files) {
|
|
10700
|
+
if (file !== ANSWERS_FILE && !file.endsWith(`/${ANSWERS_FILE}`))
|
|
10701
|
+
continue;
|
|
10702
|
+
const dir = dirname2(file);
|
|
10703
|
+
const parts2 = dir === "." ? [] : dir.split("/");
|
|
10704
|
+
let reached = !holdsTemplate(".");
|
|
10705
|
+
for (let i = 0; reached && i < parts2.length; i++) {
|
|
10706
|
+
const at = parts2.slice(0, i + 1).join("/");
|
|
10707
|
+
const app = i === 1 && parts2[0] === APPS_DIR && holdsApp(namesIn(at));
|
|
10708
|
+
reached = descends(parts2[i] ?? "", app) && !holdsTemplate(at);
|
|
10709
|
+
}
|
|
10710
|
+
if (reached)
|
|
10711
|
+
dirs.push(dir);
|
|
10712
|
+
}
|
|
10713
|
+
return dirs;
|
|
10714
|
+
}
|
|
10715
|
+
var MISE_FILE = "mise.toml";
|
|
10716
|
+
var FETCHES = 8;
|
|
10717
|
+
async function overview(ctx, root, options = {}) {
|
|
10718
|
+
const opts = { git: true, fetch: false, ...options };
|
|
10719
|
+
const tree = await walk(ctx, root, root.replace(/\/+$/, "").split("/").pop() || root, opts);
|
|
10720
|
+
if (opts.git && opts.fetch)
|
|
10721
|
+
await syncAll(ctx, repos(tree));
|
|
10722
|
+
return tree;
|
|
10723
|
+
}
|
|
10724
|
+
function repos(dir) {
|
|
10725
|
+
return [...dir.git ? [dir] : [], ...dir.children.flatMap(repos)];
|
|
10726
|
+
}
|
|
10727
|
+
async function syncAll(ctx, dirs) {
|
|
10728
|
+
const queue = [...dirs];
|
|
10729
|
+
const worker = async () => {
|
|
10730
|
+
for (let dir = queue.shift(); dir; dir = queue.shift())
|
|
10731
|
+
await sync(ctx, dir);
|
|
10732
|
+
};
|
|
10733
|
+
await Promise.all(Array.from({ length: Math.min(FETCHES, queue.length) }, worker));
|
|
10734
|
+
}
|
|
10735
|
+
async function sync(ctx, dir) {
|
|
10736
|
+
const facet2 = dir.git;
|
|
10737
|
+
if (!facet2)
|
|
10738
|
+
return;
|
|
10739
|
+
try {
|
|
10740
|
+
await ctx.read("git", ["fetch", "--all", "--quiet"], { cwd: dir.path });
|
|
10741
|
+
} catch (error) {
|
|
10742
|
+
dir.problems ??= [];
|
|
10743
|
+
dir.problems.push(`git fetch: ${error instanceof Error ? error.message : String(error)}`);
|
|
10744
|
+
}
|
|
10745
|
+
const counts = await git(ctx, dir.path, ["rev-list", "--left-right", "--count", "HEAD...@{upstream}"]);
|
|
10746
|
+
const [ahead, behind] = (counts ?? "").split(/\s+/).map(Number);
|
|
10747
|
+
if (ahead === void 0 || behind === void 0 || Number.isNaN(ahead) || Number.isNaN(behind))
|
|
10748
|
+
return;
|
|
10749
|
+
facet2.ahead = ahead;
|
|
10750
|
+
facet2.behind = behind;
|
|
10751
|
+
}
|
|
10752
|
+
var whyUnreadable = (error) => error.code ?? (error instanceof Error ? error.message : String(error));
|
|
10753
|
+
var isMissing = (error) => ["ENOENT", "ENOTDIR"].includes(error.code ?? "");
|
|
10754
|
+
async function appsOf(ctx, repo) {
|
|
10755
|
+
const read = { apps: [], links: [], unreadable: [] };
|
|
10756
|
+
const dir = join3(repo, APPS_DIR);
|
|
10757
|
+
let entries;
|
|
10758
|
+
try {
|
|
10759
|
+
entries = await ctx.readDir(dir);
|
|
10760
|
+
} catch (error) {
|
|
10761
|
+
if (!isMissing(error))
|
|
10762
|
+
read.unreadable.push({ path: dir, why: whyUnreadable(error) });
|
|
10763
|
+
return read;
|
|
10764
|
+
}
|
|
10765
|
+
for (const entry of [...entries].sort(byName)) {
|
|
10766
|
+
const path3 = join3(dir, entry.name);
|
|
10767
|
+
if (entry.symlink) {
|
|
10768
|
+
if (await isDirectory(ctx, path3))
|
|
10769
|
+
read.links.push(path3);
|
|
10770
|
+
continue;
|
|
10771
|
+
}
|
|
10772
|
+
if (!entry.directory)
|
|
10773
|
+
continue;
|
|
10774
|
+
try {
|
|
10775
|
+
if (holdsApp(await ctx.readDir(path3)))
|
|
10776
|
+
read.apps.push(path3);
|
|
10777
|
+
} catch (error) {
|
|
10778
|
+
read.unreadable.push({ path: path3, why: whyUnreadable(error) });
|
|
10779
|
+
}
|
|
10780
|
+
}
|
|
10781
|
+
return read;
|
|
10782
|
+
}
|
|
10783
|
+
var byName = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
|
|
10784
|
+
var isDirectory = (ctx, path3) => ctx.readDir(path3).then(() => true, () => false);
|
|
10785
|
+
var linksToRepo = (ctx, path3) => ctx.readDir(path3).then((entries) => entries.some((e) => e.name === ".git"), () => false);
|
|
10786
|
+
async function walk(ctx, path3, name, options, apps) {
|
|
10787
|
+
let entries;
|
|
10788
|
+
try {
|
|
10789
|
+
entries = await ctx.readDir(path3);
|
|
10790
|
+
} catch (error) {
|
|
10791
|
+
return { name, path: path3, children: [], unreadable: whyUnreadable(error) };
|
|
10792
|
+
}
|
|
10793
|
+
const dir = await facetsOf(ctx, path3, name, entries, options);
|
|
10794
|
+
const own = dir.gitRoot ? await appsOf(ctx, path3) : void 0;
|
|
10795
|
+
if (own)
|
|
10796
|
+
dir.apps = own.apps;
|
|
10797
|
+
for (const entry of [...entries].sort(byName)) {
|
|
10798
|
+
const sub = join3(path3, entry.name);
|
|
10799
|
+
if (entry.symlink) {
|
|
10800
|
+
if (apps?.links.includes(sub) || await linksToRepo(ctx, sub))
|
|
10801
|
+
dir.children.push({ name: entry.name, path: sub, symlink: true, children: [] });
|
|
10802
|
+
continue;
|
|
10803
|
+
}
|
|
10804
|
+
const app = apps?.apps.includes(sub) ?? false;
|
|
10805
|
+
if (!entry.directory || !descends(entry.name, app))
|
|
10806
|
+
continue;
|
|
10807
|
+
const child = await walk(ctx, sub, entry.name, options, own && entry.name === APPS_DIR ? own : void 0);
|
|
10808
|
+
if (app || isNotable(child) || child.children.length > 0)
|
|
10809
|
+
dir.children.push(child);
|
|
10810
|
+
}
|
|
10811
|
+
return dir;
|
|
10812
|
+
}
|
|
10813
|
+
async function directoryAt(ctx, path3) {
|
|
10814
|
+
const name = path3.replace(/\/+$/, "").split("/").pop() || path3;
|
|
10815
|
+
return facetsOf(ctx, path3, name, await ctx.readDir(path3), { git: false, fetch: false });
|
|
10816
|
+
}
|
|
10817
|
+
async function facetsOf(ctx, path3, name, entries, options) {
|
|
10818
|
+
const files = new Set(entries.filter((e) => !e.directory).map((e) => e.name));
|
|
10819
|
+
const names = new Set(entries.map((e) => e.name));
|
|
10820
|
+
const dir = { name, path: path3, children: [] };
|
|
10821
|
+
if (names.has(".git")) {
|
|
10822
|
+
dir.gitRoot = true;
|
|
10823
|
+
if (options.git)
|
|
10824
|
+
dir.git = await gitFacet(ctx, path3);
|
|
10825
|
+
}
|
|
10826
|
+
if (TEMPLATE_FILES.some((f) => files.has(f)))
|
|
10827
|
+
dir.template = options.git ? await templateFacet(ctx, path3) : {};
|
|
10828
|
+
if (files.has(ANSWERS_FILE)) {
|
|
10829
|
+
await facet(ctx, dir, ANSWERS_FILE, (text) => {
|
|
10830
|
+
dir.copier = parseAnswers(text);
|
|
10831
|
+
});
|
|
10832
|
+
}
|
|
10833
|
+
if (files.has(MARKER_FILE)) {
|
|
10834
|
+
await facet(ctx, dir, MARKER_FILE, (text) => {
|
|
10835
|
+
dir.declaration = parseMarker(text);
|
|
10836
|
+
});
|
|
10837
|
+
}
|
|
10838
|
+
if (files.has(MISE_FILE)) {
|
|
10839
|
+
await facet(ctx, dir, MISE_FILE, (text) => {
|
|
10840
|
+
const pin = plxPinOf(text);
|
|
10841
|
+
if (pin)
|
|
10842
|
+
dir.pin = pin;
|
|
10843
|
+
});
|
|
10844
|
+
}
|
|
10845
|
+
return dir;
|
|
10846
|
+
}
|
|
10847
|
+
async function facet(ctx, dir, file, read) {
|
|
10848
|
+
try {
|
|
10849
|
+
read(await ctx.readFile(join3(dir.path, file)));
|
|
10850
|
+
} catch (error) {
|
|
10851
|
+
dir.problems ??= [];
|
|
10852
|
+
dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
10853
|
+
}
|
|
10854
|
+
}
|
|
10855
|
+
async function git(ctx, cwd, args) {
|
|
10856
|
+
try {
|
|
10857
|
+
const out = (await ctx.read("git", args, { cwd })).trim();
|
|
10858
|
+
return out === "" ? void 0 : out;
|
|
10859
|
+
} catch {
|
|
10860
|
+
return void 0;
|
|
10861
|
+
}
|
|
10862
|
+
}
|
|
10863
|
+
async function gitFacet(ctx, cwd) {
|
|
10864
|
+
const branch = await git(ctx, cwd, ["symbolic-ref", "--short", "-q", "HEAD"]) ?? await git(ctx, cwd, ["rev-parse", "--short", "HEAD"]) ?? "?";
|
|
10865
|
+
const dirty = await git(ctx, cwd, ["status", "--porcelain"]) !== void 0;
|
|
10866
|
+
const remote = await git(ctx, cwd, ["remote", "get-url", "origin"]);
|
|
10867
|
+
let defaultRef = await git(ctx, cwd, ["symbolic-ref", "--short", "-q", "refs/remotes/origin/HEAD"]);
|
|
10868
|
+
for (const b of ["main", "master"]) {
|
|
10869
|
+
if (defaultRef)
|
|
10870
|
+
break;
|
|
10871
|
+
if (await git(ctx, cwd, ["rev-parse", "--verify", "-q", `refs/heads/${b}`]))
|
|
10872
|
+
defaultRef = b;
|
|
10873
|
+
}
|
|
10874
|
+
const tag = defaultRef ? await git(ctx, cwd, ["describe", "--tags", "--abbrev=0", defaultRef]) : void 0;
|
|
10875
|
+
const facet2 = { branch, dirty };
|
|
10876
|
+
if (tag)
|
|
10877
|
+
facet2.tag = tag;
|
|
10878
|
+
if (remote)
|
|
10879
|
+
facet2.remote = shortRemote(remote);
|
|
10880
|
+
return facet2;
|
|
10881
|
+
}
|
|
10882
|
+
async function templateFacet(ctx, cwd) {
|
|
10883
|
+
const tag = await git(ctx, cwd, ["describe", "--tags", "--abbrev=0"]) ?? (await git(ctx, cwd, ["tag", "--list", "--sort=-v:refname"]))?.split("\n")[0];
|
|
10884
|
+
return tag ? { tag } : {};
|
|
10885
|
+
}
|
|
10886
|
+
|
|
10615
10887
|
// ../lib/dist/consumers.js
|
|
10616
10888
|
function expectedBranch(repo) {
|
|
10617
10889
|
if (!repo.declaration)
|
|
@@ -10623,14 +10895,14 @@ function expectedBranch(repo) {
|
|
|
10623
10895
|
async function findConsumers(ctx, root, templates) {
|
|
10624
10896
|
const consumers = /* @__PURE__ */ new Map();
|
|
10625
10897
|
const orphans = [];
|
|
10626
|
-
const
|
|
10898
|
+
const visit2 = (dir, repo, inTemplate) => {
|
|
10627
10899
|
const here = dir.git ? dir : repo;
|
|
10628
10900
|
const within = inTemplate || Boolean(dir.template);
|
|
10629
10901
|
const template = dir.copier?.src ? templateOf(dir.copier.src, templates) : void 0;
|
|
10630
10902
|
if (template && !within) {
|
|
10631
|
-
const
|
|
10903
|
+
const site2 = { path: dir.path, rel: relative(root.path, dir.path) || ".", template };
|
|
10632
10904
|
if (!here)
|
|
10633
|
-
orphans.push(
|
|
10905
|
+
orphans.push(site2);
|
|
10634
10906
|
else {
|
|
10635
10907
|
let consumer = consumers.get(here.path);
|
|
10636
10908
|
if (!consumer) {
|
|
@@ -10644,15 +10916,15 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10644
10916
|
};
|
|
10645
10917
|
consumers.set(here.path, consumer);
|
|
10646
10918
|
}
|
|
10647
|
-
consumer.sites.push(
|
|
10919
|
+
consumer.sites.push(site2);
|
|
10648
10920
|
}
|
|
10649
10921
|
}
|
|
10650
10922
|
for (const child of dir.children)
|
|
10651
|
-
|
|
10923
|
+
visit2(child, here, within);
|
|
10652
10924
|
};
|
|
10653
|
-
|
|
10654
|
-
for (const
|
|
10655
|
-
ctx.say(`\u26A0 ${
|
|
10925
|
+
visit2(root, void 0, false);
|
|
10926
|
+
for (const site2 of orphans)
|
|
10927
|
+
ctx.say(`\u26A0 ${site2.rel}: not inside a git repo \u2014 skipped`);
|
|
10656
10928
|
for (const c of consumers.values()) {
|
|
10657
10929
|
const origin = (await ctx.read("git", ["remote", "get-url", "origin"], { cwd: c.path }).catch(() => "")).trim();
|
|
10658
10930
|
if (origin === "")
|
|
@@ -10662,6 +10934,25 @@ async function findConsumers(ctx, root, templates) {
|
|
|
10662
10934
|
}
|
|
10663
10935
|
return [...consumers.values()];
|
|
10664
10936
|
}
|
|
10937
|
+
async function sitesOfTree(ctx, repo, commit) {
|
|
10938
|
+
const files = (await ctx.read("git", ["ls-tree", "-r", "-z", "--name-only", commit], { cwd: repo })).split("\0").filter(Boolean);
|
|
10939
|
+
const sites = [];
|
|
10940
|
+
for (const dir of answersDirs(files)) {
|
|
10941
|
+
const text = await ctx.read("git", ["cat-file", "blob", `${commit}:${join4(dir, ANSWERS_FILE)}`], { cwd: repo });
|
|
10942
|
+
let answers;
|
|
10943
|
+
try {
|
|
10944
|
+
answers = parseAnswers(text);
|
|
10945
|
+
} catch {
|
|
10946
|
+
sites.push({ dir });
|
|
10947
|
+
continue;
|
|
10948
|
+
}
|
|
10949
|
+
const template = answers.src ? templateOf(answers.src, TEMPLATES) : void 0;
|
|
10950
|
+
if (template)
|
|
10951
|
+
sites.push({ dir, answers, template });
|
|
10952
|
+
}
|
|
10953
|
+
sites.sort((a, b) => Number(b.dir === ".") - Number(a.dir === "."));
|
|
10954
|
+
return { files, sites };
|
|
10955
|
+
}
|
|
10665
10956
|
|
|
10666
10957
|
// ../lib/dist/context.js
|
|
10667
10958
|
var Context = class {
|
|
@@ -10804,32 +11095,15 @@ function indent(text) {
|
|
|
10804
11095
|
return text.trimEnd().split("\n").map((l) => ` ${l}`).join("\n");
|
|
10805
11096
|
}
|
|
10806
11097
|
|
|
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
11098
|
// ../lib/dist/deploy.js
|
|
11099
|
+
var import_yaml6 = __toESM(require_dist(), 1);
|
|
10826
11100
|
import { randomBytes } from "node:crypto";
|
|
10827
11101
|
import { tmpdir } from "node:os";
|
|
10828
|
-
import { join as
|
|
11102
|
+
import { join as join6 } from "node:path";
|
|
10829
11103
|
|
|
10830
11104
|
// ../lib/dist/deployTargets.js
|
|
10831
11105
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
10832
|
-
import { join as
|
|
11106
|
+
import { join as join5 } from "node:path";
|
|
10833
11107
|
var VARS_DIRS = ["group_vars", "host_vars"];
|
|
10834
11108
|
var DEFAULT_ENVIRONMENT = "production";
|
|
10835
11109
|
function deploymentSlug(app, environment = DEFAULT_ENVIRONMENT) {
|
|
@@ -10877,23 +11151,48 @@ function targetsIn(targets, environment) {
|
|
|
10877
11151
|
}
|
|
10878
11152
|
return flat;
|
|
10879
11153
|
}
|
|
10880
|
-
function
|
|
11154
|
+
function recordsWithoutTarget(files, environment) {
|
|
11155
|
+
const targeted = targetsIn(selectDeployTargets(files), environment);
|
|
11156
|
+
const found = {};
|
|
11157
|
+
for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
|
|
11158
|
+
if (file.target !== void 0)
|
|
11159
|
+
continue;
|
|
11160
|
+
for (const d of file.apps) {
|
|
11161
|
+
if (d.environment !== environment || d.app in targeted)
|
|
11162
|
+
continue;
|
|
11163
|
+
const paths = found[d.app] ?? [];
|
|
11164
|
+
if (!paths.includes(file.path))
|
|
11165
|
+
paths.push(file.path);
|
|
11166
|
+
found[d.app] = paths;
|
|
11167
|
+
}
|
|
11168
|
+
}
|
|
11169
|
+
return found;
|
|
11170
|
+
}
|
|
11171
|
+
function deployLegs(targets, apps, recordsWithout = {}) {
|
|
10881
11172
|
const legs = [];
|
|
11173
|
+
const untargeted = [];
|
|
10882
11174
|
const without = [];
|
|
10883
11175
|
for (const app of [...apps].sort()) {
|
|
10884
11176
|
const host = targets[app];
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
else
|
|
11177
|
+
const files = recordsWithout[app];
|
|
11178
|
+
if (host !== void 0)
|
|
10888
11179
|
legs.push({ app, host });
|
|
11180
|
+
else if (files !== void 0)
|
|
11181
|
+
untargeted.push({ app, files });
|
|
11182
|
+
else
|
|
11183
|
+
without.push(app);
|
|
10889
11184
|
}
|
|
10890
|
-
return { legs, without };
|
|
11185
|
+
return { legs, untargeted, without };
|
|
10891
11186
|
}
|
|
10892
|
-
|
|
11187
|
+
function untargetedError(untargeted, environment) {
|
|
11188
|
+
const lines = untargeted.map(({ app, files }) => `${app} has a record in ${environment} in ${files.join(" and ")}, which names no plexus_deploy_target`);
|
|
11189
|
+
return new Error(lines.join("\n"));
|
|
11190
|
+
}
|
|
11191
|
+
async function readInventory(ctx, inventory) {
|
|
10893
11192
|
const files = [];
|
|
10894
11193
|
let found = false;
|
|
10895
11194
|
for (const sub of VARS_DIRS) {
|
|
10896
|
-
const dir =
|
|
11195
|
+
const dir = join5(inventory, sub);
|
|
10897
11196
|
const entries = await ctx.readDir(dir).catch(() => void 0);
|
|
10898
11197
|
if (entries === void 0)
|
|
10899
11198
|
continue;
|
|
@@ -10901,13 +11200,13 @@ async function readDeployTargets(ctx, inventory) {
|
|
|
10901
11200
|
for (const e of entries) {
|
|
10902
11201
|
if (e.directory || !/\.ya?ml$/.test(e.name))
|
|
10903
11202
|
continue;
|
|
10904
|
-
const path3 =
|
|
11203
|
+
const path3 = join5(dir, e.name);
|
|
10905
11204
|
files.push(parseInventoryFile(path3, await ctx.readFile(path3)));
|
|
10906
11205
|
}
|
|
10907
11206
|
}
|
|
10908
11207
|
if (!found && await ctx.readDir(inventory).catch(() => void 0) === void 0)
|
|
10909
11208
|
throw new UsageError(`no inventory directory at ${inventory}`);
|
|
10910
|
-
return
|
|
11209
|
+
return files;
|
|
10911
11210
|
}
|
|
10912
11211
|
|
|
10913
11212
|
// ../lib/dist/deploy.js
|
|
@@ -10924,12 +11223,96 @@ function renderCompose(text, image, path3) {
|
|
|
10924
11223
|
throw new UsageError(`${path3} references \${PLEXUS_DEPLOYMENT_IMAGE} but no image ref was given`);
|
|
10925
11224
|
return text;
|
|
10926
11225
|
}
|
|
11226
|
+
var DISPLAY_VERSION_PIN = {
|
|
11227
|
+
key: "displayVersion",
|
|
11228
|
+
placeholder: DISPLAY_VERSION_PLACEHOLDER,
|
|
11229
|
+
held: "[0-9A-Za-z][0-9A-Za-z.+_-]*",
|
|
11230
|
+
sentinel: "PLEXUSDISPLAYVERSION0"
|
|
11231
|
+
};
|
|
11232
|
+
var COMMIT_SHA_PIN = {
|
|
11233
|
+
key: "commitSha",
|
|
11234
|
+
placeholder: COMMIT_SHA_PLACEHOLDER,
|
|
11235
|
+
held: "[0-9a-f]+",
|
|
11236
|
+
sentinel: "PLEXUSCOMMITSHA0"
|
|
11237
|
+
};
|
|
11238
|
+
var PINS = [DISPLAY_VERSION_PIN, COMMIT_SHA_PIN];
|
|
11239
|
+
function pinValue(text, pin, value, path3) {
|
|
11240
|
+
const placeholder = new RegExp(pin.placeholder.source, "g");
|
|
11241
|
+
if (!placeholder.test(text))
|
|
11242
|
+
return text;
|
|
11243
|
+
const whole = new RegExp(`^${pin.placeholder.source}$`);
|
|
11244
|
+
const plain = [];
|
|
11245
|
+
const doc = (0, import_yaml6.parseDocument)(text);
|
|
11246
|
+
if (doc.errors.length > 0)
|
|
11247
|
+
throw new UsageError(`${path3} is not valid YAML: ${doc.errors[0]?.message}`);
|
|
11248
|
+
(0, import_yaml6.visit)(doc, {
|
|
11249
|
+
Scalar(_key, node) {
|
|
11250
|
+
if (node.type === "PLAIN" && typeof node.value === "string" && whole.test(node.value) && node.range)
|
|
11251
|
+
plain.push([node.range[0], node.range[1]]);
|
|
11252
|
+
}
|
|
11253
|
+
});
|
|
11254
|
+
let out = text;
|
|
11255
|
+
for (const [start, end] of plain.sort((a, b) => b[0] - a[0]))
|
|
11256
|
+
out = `${out.slice(0, start)}${JSON.stringify(value)}${out.slice(end)}`;
|
|
11257
|
+
return out.replace(new RegExp(pin.placeholder.source, "g"), value);
|
|
11258
|
+
}
|
|
11259
|
+
var DISPLAY_VERSION = /^[0-9A-Za-z][0-9A-Za-z.+_-]*$/;
|
|
11260
|
+
function renderDisplayVersion(text, displayVersion, path3) {
|
|
11261
|
+
if (!displayVersion)
|
|
11262
|
+
return text;
|
|
11263
|
+
if (!DISPLAY_VERSION.test(displayVersion))
|
|
11264
|
+
throw new UsageError(`display version ${JSON.stringify(displayVersion)}: only letters, digits and . + _ - are allowed, starting with a letter or digit`);
|
|
11265
|
+
return pinValue(text, DISPLAY_VERSION_PIN, displayVersion, path3);
|
|
11266
|
+
}
|
|
11267
|
+
var COMMIT_SHA = /^([0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
11268
|
+
function renderCommitSha(text, commitSha, path3) {
|
|
11269
|
+
if (!commitSha)
|
|
11270
|
+
return text;
|
|
11271
|
+
if (!COMMIT_SHA.test(commitSha))
|
|
11272
|
+
throw new UsageError(`commit sha ${JSON.stringify(commitSha)}: a full commit hash, 40 or 64 hex digits in lower case`);
|
|
11273
|
+
return pinValue(text, COMMIT_SHA_PIN, commitSha, path3);
|
|
11274
|
+
}
|
|
11275
|
+
function shownBy(shape, given, serving) {
|
|
11276
|
+
let marked = shape;
|
|
11277
|
+
const used = [];
|
|
11278
|
+
for (const pin of PINS) {
|
|
11279
|
+
if (!given[pin.key])
|
|
11280
|
+
continue;
|
|
11281
|
+
const next = pinValue(marked, pin, pin.sentinel, "");
|
|
11282
|
+
if (next !== marked)
|
|
11283
|
+
used.push(pin);
|
|
11284
|
+
marked = next;
|
|
11285
|
+
}
|
|
11286
|
+
marked = marked.trimEnd();
|
|
11287
|
+
if (used.length === 0)
|
|
11288
|
+
return serving.trimEnd() === marked ? {} : void 0;
|
|
11289
|
+
const groups = /* @__PURE__ */ new Map();
|
|
11290
|
+
let source = "";
|
|
11291
|
+
for (const part of marked.split(new RegExp(`(${used.map((pin) => pin.sentinel).join("|")})`))) {
|
|
11292
|
+
const pin = used.find((u) => u.sentinel === part);
|
|
11293
|
+
if (!pin) {
|
|
11294
|
+
source += part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11295
|
+
continue;
|
|
11296
|
+
}
|
|
11297
|
+
const group = groups.get(pin.key);
|
|
11298
|
+
if (group === void 0) {
|
|
11299
|
+
groups.set(pin.key, groups.size + 1);
|
|
11300
|
+
source += `(${pin.held})`;
|
|
11301
|
+
} else
|
|
11302
|
+
source += `\\${group}`;
|
|
11303
|
+
}
|
|
11304
|
+
const match = new RegExp(`^${source}$`).exec(serving.trimEnd());
|
|
11305
|
+
if (!match)
|
|
11306
|
+
return void 0;
|
|
11307
|
+
return Object.fromEntries([...groups].map(([key, group]) => [key, match[group]]));
|
|
11308
|
+
}
|
|
11309
|
+
var describeShown = (shown) => [shown.displayVersion, shown.commitSha && `at ${shown.commitSha.slice(0, 7)}`].filter(Boolean).join(" ");
|
|
10927
11310
|
function defaultAppDir(app, environment = DEFAULT_ENVIRONMENT) {
|
|
10928
11311
|
return `/opt/stacks/${deploymentSlug(app, environment)}`;
|
|
10929
11312
|
}
|
|
10930
11313
|
var q = (word) => `'${word.replaceAll("'", "'\\''")}'`;
|
|
10931
11314
|
var Remote = class {
|
|
10932
|
-
socket =
|
|
11315
|
+
socket = join6(tmpdir(), `plx-deploy-${randomBytes(4).toString("hex")}.sock`);
|
|
10933
11316
|
ctx;
|
|
10934
11317
|
host;
|
|
10935
11318
|
constructor(ctx, host) {
|
|
@@ -11007,7 +11390,7 @@ async function deploy(ctx, options) {
|
|
|
11007
11390
|
let text = "";
|
|
11008
11391
|
for (const candidate of [`${source}/docker/compose.yaml`, `${source}/compose.yaml`]) {
|
|
11009
11392
|
try {
|
|
11010
|
-
text = await ctx.readFile(
|
|
11393
|
+
text = await ctx.readFile(join6(dir, candidate));
|
|
11011
11394
|
compose = candidate;
|
|
11012
11395
|
break;
|
|
11013
11396
|
} catch {
|
|
@@ -11015,7 +11398,13 @@ async function deploy(ctx, options) {
|
|
|
11015
11398
|
}
|
|
11016
11399
|
if (compose === void 0)
|
|
11017
11400
|
throw new UsageError(`no compose.yaml under ${source}; run from the app's source repo (\xA7 2 PLX-App)`);
|
|
11018
|
-
const
|
|
11401
|
+
const withImage = renderCompose(text, image, compose);
|
|
11402
|
+
const withVersion = renderDisplayVersion(withImage, options.displayVersion || void 0, compose);
|
|
11403
|
+
const rendered = renderCommitSha(withVersion, options.commitSha || void 0, compose);
|
|
11404
|
+
const pinned = {
|
|
11405
|
+
...withVersion === withImage ? {} : { displayVersion: options.displayVersion },
|
|
11406
|
+
...rendered === withVersion ? {} : { commitSha: options.commitSha }
|
|
11407
|
+
};
|
|
11019
11408
|
const budget = retries * 2;
|
|
11020
11409
|
const check = healthcheckOf(parseCompose(rendered, compose));
|
|
11021
11410
|
if (!declaresHealthcheck(check))
|
|
@@ -11026,6 +11415,14 @@ async function deploy(ctx, options) {
|
|
|
11026
11415
|
ctx.say(` host: ${host}`);
|
|
11027
11416
|
ctx.say(` dir: ${appDir}`);
|
|
11028
11417
|
ctx.say(` compose: ${compose}`);
|
|
11418
|
+
if (pinned.displayVersion)
|
|
11419
|
+
ctx.say(` display: ${pinned.displayVersion}`);
|
|
11420
|
+
else if (options.displayVersion)
|
|
11421
|
+
ctx.say(` (${compose} does not use \${PLEXUS_DISPLAY_VERSION}; the display version is not pinned)`, 1);
|
|
11422
|
+
if (pinned.commitSha)
|
|
11423
|
+
ctx.say(` commit: ${pinned.commitSha}`);
|
|
11424
|
+
else if (options.commitSha)
|
|
11425
|
+
ctx.say(` (${compose} does not use \${PLEXUS_COMMIT_SHA}; the commit sha is not pinned)`, 1);
|
|
11029
11426
|
ctx.say(" health: the healthcheck of service web, as Docker reports it");
|
|
11030
11427
|
if (slow)
|
|
11031
11428
|
ctx.say(`\u26A0 ${compose}: the web healthcheck ${slow}, so Docker may probe it only every interval while the deploy waits, which then sees it healthy late or rolls it back; set start_interval: 1s and start_period: ${budget}s`);
|
|
@@ -11041,7 +11438,17 @@ async function deploy(ctx, options) {
|
|
|
11041
11438
|
// one fixed loopback port (§ 4 PLX-App), which a second replica could not.
|
|
11042
11439
|
liveImage: `${dc} ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Config.Image}}' 2>/dev/null || true`,
|
|
11043
11440
|
image,
|
|
11044
|
-
|
|
11441
|
+
shows: (ref, serving) => shownBy(renderCompose(text, ref, compose), pinned, serving),
|
|
11442
|
+
pinned,
|
|
11443
|
+
result: {
|
|
11444
|
+
host,
|
|
11445
|
+
appDir,
|
|
11446
|
+
compose,
|
|
11447
|
+
image,
|
|
11448
|
+
...pinned,
|
|
11449
|
+
healthy: false,
|
|
11450
|
+
rolledBack: false
|
|
11451
|
+
}
|
|
11045
11452
|
};
|
|
11046
11453
|
const { result } = s;
|
|
11047
11454
|
let staged = false;
|
|
@@ -11086,262 +11493,88 @@ async function alreadyServing(s) {
|
|
|
11086
11493
|
ctx.say(" (nothing more runs when the host already serves this image from this file, healthy)");
|
|
11087
11494
|
return false;
|
|
11088
11495
|
}
|
|
11089
|
-
if (
|
|
11496
|
+
if (result.previous === void 0)
|
|
11090
11497
|
return false;
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
if (
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
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
|
-
});
|
|
11498
|
+
let same;
|
|
11499
|
+
let shown = {};
|
|
11500
|
+
if (s.image === void 0 || result.previous === s.image && Object.keys(s.pinned).length === 0) {
|
|
11501
|
+
if (!await s.remote.test(`cd ${s.D} && cmp -s compose.yaml ${INCOMING}/compose.yaml`))
|
|
11502
|
+
return false;
|
|
11503
|
+
} else {
|
|
11504
|
+
if (result.previous !== s.image) {
|
|
11505
|
+
if (!await sameImage(s, s.image))
|
|
11506
|
+
return false;
|
|
11507
|
+
same = s.image;
|
|
11508
|
+
}
|
|
11509
|
+
const serving = await s.remote.read(`cat ${s.D}/compose.yaml`);
|
|
11510
|
+
const live = serving === void 0 ? void 0 : s.shows(result.previous, serving);
|
|
11511
|
+
if (live === void 0)
|
|
11512
|
+
return false;
|
|
11513
|
+
shown = live;
|
|
11299
11514
|
}
|
|
11300
|
-
|
|
11515
|
+
if (!await awaitHealthy(s, 1))
|
|
11516
|
+
return false;
|
|
11517
|
+
result.live = result.previous;
|
|
11518
|
+
result.healthy = true;
|
|
11519
|
+
result.unchanged = true;
|
|
11520
|
+
delete result.displayVersion;
|
|
11521
|
+
delete result.commitSha;
|
|
11522
|
+
Object.assign(result, shown);
|
|
11523
|
+
const showing = describeShown(shown);
|
|
11524
|
+
ctx.done(`${result.previous}${same ? ` (the image ${same} names)` : ""}${showing ? `, showing ${showing},` : ""} is already live and healthy; nothing to do`);
|
|
11525
|
+
return true;
|
|
11301
11526
|
}
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
} catch (error) {
|
|
11306
|
-
dir.problems ??= [];
|
|
11307
|
-
dir.problems.push(`${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
11308
|
-
}
|
|
11527
|
+
function sameImage(s, ref) {
|
|
11528
|
+
const running = `docker compose ps -q web 2>/dev/null | head -1 | xargs -r docker inspect --format '{{.Image}}' 2>/dev/null`;
|
|
11529
|
+
return s.remote.test(`cd ${s.D} && docker pull -q ${q(ref)} >/dev/null && id=$(docker image inspect --format '{{.Id}}' ${q(ref)}) && [ -n "$id" ] && [ "$id" = "$(${running})" ]`);
|
|
11309
11530
|
}
|
|
11310
|
-
async function
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11531
|
+
async function pullAndMigrate(s) {
|
|
11532
|
+
await s.remote.exec(`${s.dci} pull`);
|
|
11533
|
+
const migrate = await s.remote.test(`${s.dci} --profile migrate config --services 2>/dev/null | grep -qx migrate`);
|
|
11534
|
+
if (migrate === void 0)
|
|
11535
|
+
s.ctx.say(" (if compose.yaml declares a migrate service:)");
|
|
11536
|
+
if (migrate !== false)
|
|
11537
|
+
await s.remote.exec(`${s.dci} run --rm migrate </dev/null`);
|
|
11317
11538
|
}
|
|
11318
|
-
async function
|
|
11319
|
-
const
|
|
11320
|
-
const
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
if (await git(ctx, cwd, ["rev-parse", "--verify", "-q", `refs/heads/${b}`]))
|
|
11327
|
-
defaultRef = b;
|
|
11328
|
-
}
|
|
11329
|
-
const tag = defaultRef ? await git(ctx, cwd, ["describe", "--tags", "--abbrev=0", defaultRef]) : void 0;
|
|
11330
|
-
const facet2 = { branch, dirty };
|
|
11331
|
-
if (tag)
|
|
11332
|
-
facet2.tag = tag;
|
|
11333
|
-
if (remote)
|
|
11334
|
-
facet2.remote = shortRemote(remote);
|
|
11335
|
-
return facet2;
|
|
11539
|
+
async function swapAndUp(s) {
|
|
11540
|
+
const { D } = s;
|
|
11541
|
+
const hadPrev = await s.remote.test(`test -f ${D}/compose.yaml`);
|
|
11542
|
+
if (hadPrev !== false)
|
|
11543
|
+
await s.remote.exec(`cd ${D} && cp -p compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11544
|
+
await s.remote.exec(`cd ${D} && mv ${INCOMING}/compose.yaml compose.yaml`);
|
|
11545
|
+
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11546
|
+
return hadPrev;
|
|
11336
11547
|
}
|
|
11337
|
-
|
|
11338
|
-
const
|
|
11339
|
-
return
|
|
11548
|
+
function awaitHealthy(s, attempts, show = false) {
|
|
11549
|
+
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`;
|
|
11550
|
+
return s.remote.test(`cd ${s.D} && for _ in $(seq 1 ${attempts}); do [ "$(${status})" = healthy ] && exit 0; sleep 2; done; exit 1`, show);
|
|
11340
11551
|
}
|
|
11552
|
+
async function rollback(s, hadPrev, retries) {
|
|
11553
|
+
const { ctx, D, result } = s;
|
|
11554
|
+
const differs = hadPrev && await s.remote.test(`cd ${D} && ! cmp -s compose.yaml ${INCOMING}/compose.yaml.prev`);
|
|
11555
|
+
if (!differs) {
|
|
11556
|
+
ctx.done("nothing to roll back to (first deploy, or the same run shape re-deployed); manual intervention needed", false);
|
|
11557
|
+
return;
|
|
11558
|
+
}
|
|
11559
|
+
await s.remote.exec(`cd ${D} && cp -p ${INCOMING}/compose.yaml.prev compose.yaml`);
|
|
11560
|
+
ctx.say(`\u21A9 rolling back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11561
|
+
await s.remote.exec(`${s.dc} up -d --remove-orphans`);
|
|
11562
|
+
result.rolledBack = true;
|
|
11563
|
+
if (await awaitHealthy(s, retries)) {
|
|
11564
|
+
result.live = result.previous;
|
|
11565
|
+
ctx.done(`rolled back to ${result.previous ?? "the previous compose.yaml"}`);
|
|
11566
|
+
} else {
|
|
11567
|
+
ctx.done("rollback also unhealthy; manual intervention needed", false);
|
|
11568
|
+
}
|
|
11569
|
+
}
|
|
11570
|
+
|
|
11571
|
+
// ../lib/dist/doctor.js
|
|
11572
|
+
import { realpath } from "node:fs/promises";
|
|
11573
|
+
import { dirname as dirname3, join as join7, relative as relative2, resolve } from "node:path";
|
|
11341
11574
|
|
|
11342
11575
|
// ../lib/dist/standard-index.json
|
|
11343
11576
|
var standard_index_default = {
|
|
11344
|
-
version: "0.
|
|
11577
|
+
version: "0.129.0",
|
|
11345
11578
|
citable: [
|
|
11346
11579
|
"\xA7 1 PLX",
|
|
11347
11580
|
"\xA7 1.1 PLX",
|
|
@@ -11387,6 +11620,7 @@ var standard_index_default = {
|
|
|
11387
11620
|
"\xA7 6.7 PLX",
|
|
11388
11621
|
"\xA7 6.8 PLX",
|
|
11389
11622
|
"\xA7 6.9 PLX",
|
|
11623
|
+
"\xA7 6.10 PLX",
|
|
11390
11624
|
"\xA7 7 PLX",
|
|
11391
11625
|
"\xA7 7.1 PLX",
|
|
11392
11626
|
"\xA7 7.2 PLX",
|
|
@@ -11552,6 +11786,12 @@ var standard_index_default = {
|
|
|
11552
11786
|
"PLX-Platform/AppRecord",
|
|
11553
11787
|
"PLX-Platform/UniqueAppName",
|
|
11554
11788
|
"PLX-Platform/RecordValues",
|
|
11789
|
+
"\xA7 1 PLX-Releases",
|
|
11790
|
+
"\xA7 2 PLX-Releases",
|
|
11791
|
+
"\xA7 3 PLX-Releases",
|
|
11792
|
+
"\xA7 4 PLX-Releases",
|
|
11793
|
+
"\xA7 5 PLX-Releases",
|
|
11794
|
+
"\xA7 6 PLX-Releases",
|
|
11555
11795
|
"\xA7 1 PLX-Secrets",
|
|
11556
11796
|
"\xA7 2 PLX-Secrets",
|
|
11557
11797
|
"\xA7 3 PLX-Secrets",
|
|
@@ -11759,6 +11999,9 @@ function diagnoseUnit(unit, known) {
|
|
|
11759
11999
|
for (const problem of run2(c, unit, profile))
|
|
11760
12000
|
findings.push({ requirement: name, problem });
|
|
11761
12001
|
}
|
|
12002
|
+
if (unit.kind !== "app")
|
|
12003
|
+
for (const file of unit.conflicted ?? [])
|
|
12004
|
+
findings.push({ problem: `\`${file}\` holds a conflict marker` });
|
|
11762
12005
|
const obsolete = (declaration?.obsolete ?? []).map((k) => `\`${k}\``).join(" and ");
|
|
11763
12006
|
const hints = [];
|
|
11764
12007
|
if (obsolete)
|
|
@@ -11793,7 +12036,7 @@ async function examine(ctx, dir) {
|
|
|
11793
12036
|
let top = own.some((e) => e.name === ".git") ? given : void 0;
|
|
11794
12037
|
const tree = top ? void 0 : await overview(ctx, given, { git: false });
|
|
11795
12038
|
if (tree && !holdsGitRoot(tree))
|
|
11796
|
-
top = await enclosingGitRoot(ctx,
|
|
12039
|
+
top = await enclosingGitRoot(ctx, dirname3(given));
|
|
11797
12040
|
if (top) {
|
|
11798
12041
|
const repo = await directoryAt(ctx, top);
|
|
11799
12042
|
const found = await appsOf(ctx, top);
|
|
@@ -11809,7 +12052,7 @@ async function examine(ctx, dir) {
|
|
|
11809
12052
|
}
|
|
11810
12053
|
const examination = { root: given, inRepo: false, facts: [], skipped: [], links: [], unreadable: [] };
|
|
11811
12054
|
const rel = (path3) => relative2(given, path3) || ".";
|
|
11812
|
-
const
|
|
12055
|
+
const visit2 = async (d) => {
|
|
11813
12056
|
if (d.unreadable)
|
|
11814
12057
|
examination.unreadable.push({ path: rel(d.path), why: d.unreadable });
|
|
11815
12058
|
if (d.symlink)
|
|
@@ -11822,19 +12065,19 @@ async function examine(ctx, dir) {
|
|
|
11822
12065
|
examination.skipped.push(rel(d.path));
|
|
11823
12066
|
}
|
|
11824
12067
|
for (const child of d.children)
|
|
11825
|
-
await
|
|
12068
|
+
await visit2(child);
|
|
11826
12069
|
};
|
|
11827
12070
|
if (tree)
|
|
11828
|
-
await
|
|
12071
|
+
await visit2(tree);
|
|
11829
12072
|
return examination;
|
|
11830
12073
|
}
|
|
11831
12074
|
var holdsGitRoot = (d) => Boolean(d.gitRoot) || d.children.some(holdsGitRoot);
|
|
11832
12075
|
async function enclosingGitRoot(ctx, dir) {
|
|
11833
|
-
for (let at = resolve(dir); ; at =
|
|
12076
|
+
for (let at = resolve(dir); ; at = dirname3(at)) {
|
|
11834
12077
|
const entries = await ctx.readDir(at).catch(() => []);
|
|
11835
12078
|
if (entries.some((e) => e.name === ".git"))
|
|
11836
12079
|
return at;
|
|
11837
|
-
if (
|
|
12080
|
+
if (dirname3(at) === at)
|
|
11838
12081
|
return void 0;
|
|
11839
12082
|
}
|
|
11840
12083
|
}
|
|
@@ -11859,7 +12102,16 @@ async function readRepo(ctx, dir, path3, kind) {
|
|
|
11859
12102
|
return void 0;
|
|
11860
12103
|
throw error;
|
|
11861
12104
|
});
|
|
11862
|
-
|
|
12105
|
+
const conflicted = tracked === void 0 ? void 0 : await filesWithConflictMarkers(ctx, dir.path);
|
|
12106
|
+
return {
|
|
12107
|
+
kind,
|
|
12108
|
+
path: path3,
|
|
12109
|
+
...marker ? { marker } : {},
|
|
12110
|
+
tasks: await rootTasks(ctx, dir.path),
|
|
12111
|
+
tracked,
|
|
12112
|
+
...conflicted?.length ? { conflicted } : {},
|
|
12113
|
+
apps: []
|
|
12114
|
+
};
|
|
11863
12115
|
}
|
|
11864
12116
|
async function rootTasks(ctx, repo) {
|
|
11865
12117
|
let out;
|
|
@@ -11909,9 +12161,9 @@ async function readApp(ctx, dir, path3, inRepo, repo) {
|
|
|
11909
12161
|
dir: inRepo,
|
|
11910
12162
|
thirdParty: repo.kind === "operations",
|
|
11911
12163
|
marker: markerOf(dir) ?? {},
|
|
11912
|
-
dockerfile: (await ctx.readDir(
|
|
12164
|
+
dockerfile: (await ctx.readDir(join7(dir.path, "docker")).catch(() => [])).some((e) => e.name === "Dockerfile" && !e.directory)
|
|
11913
12165
|
};
|
|
11914
|
-
const compose = await ctx.readFile(
|
|
12166
|
+
const compose = await ctx.readFile(join7(dir.path, "docker/compose.yaml")).catch(() => void 0);
|
|
11915
12167
|
if (compose !== void 0) {
|
|
11916
12168
|
try {
|
|
11917
12169
|
app.compose = parseCompose(compose, "docker/compose.yaml");
|
|
@@ -11919,7 +12171,7 @@ async function readApp(ctx, dir, path3, inRepo, repo) {
|
|
|
11919
12171
|
app.composeProblem = error.message;
|
|
11920
12172
|
}
|
|
11921
12173
|
}
|
|
11922
|
-
const manifest2 = await ctx.readFile(
|
|
12174
|
+
const manifest2 = await ctx.readFile(join7(dir.path, "package.json")).catch(() => void 0);
|
|
11923
12175
|
if (manifest2 !== void 0) {
|
|
11924
12176
|
try {
|
|
11925
12177
|
const data = JSON.parse(manifest2);
|
|
@@ -12063,45 +12315,294 @@ function parseMaxAge(value, what) {
|
|
|
12063
12315
|
return Number(value.trim());
|
|
12064
12316
|
}
|
|
12065
12317
|
|
|
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}/`));
|
|
12318
|
+
// ../lib/dist/pull.js
|
|
12091
12319
|
var versionBranch = (version2) => `plexus/${version2}`;
|
|
12320
|
+
var REVIEWERS_ANSWER = "pr_reviewers";
|
|
12321
|
+
function parseReviewers(value, what) {
|
|
12322
|
+
const logins = value.split(",").map((l) => l.trim()).filter(Boolean);
|
|
12323
|
+
for (const login of logins) {
|
|
12324
|
+
if (login.includes("/"))
|
|
12325
|
+
throw new Error(`${what} names \`${login}\`, a team; only users are requested`);
|
|
12326
|
+
if (!/^[A-Za-z0-9-]+$/.test(login))
|
|
12327
|
+
throw new Error(`${what} names \`${login}\`, not a GitHub user login`);
|
|
12328
|
+
}
|
|
12329
|
+
return [...new Set(logins)];
|
|
12330
|
+
}
|
|
12331
|
+
function answersOf(text) {
|
|
12332
|
+
if (text.trim() === "")
|
|
12333
|
+
throw new Error(`the root ${ANSWERS_FILE} is empty or missing`);
|
|
12334
|
+
try {
|
|
12335
|
+
return parseAnswers(text).answers;
|
|
12336
|
+
} catch (error) {
|
|
12337
|
+
throw new Error(`the root ${ANSWERS_FILE} cannot be read: ${error.message.split("\n")[0]}`);
|
|
12338
|
+
}
|
|
12339
|
+
}
|
|
12340
|
+
function reviewersOf(answers) {
|
|
12341
|
+
const value = answers[REVIEWERS_ANSWER];
|
|
12342
|
+
if (value === void 0 || value === null)
|
|
12343
|
+
return [];
|
|
12344
|
+
return parseReviewers(String(value), `the answer ${REVIEWERS_ANSWER}`);
|
|
12345
|
+
}
|
|
12346
|
+
var requestReviews = (number, logins, cwd) => run("gh", [
|
|
12347
|
+
"api",
|
|
12348
|
+
`repos/{owner}/{repo}/pulls/${number}/requested_reviewers`,
|
|
12349
|
+
"--method",
|
|
12350
|
+
"POST",
|
|
12351
|
+
...logins.flatMap((l) => ["-f", `reviewers[]=${l}`])
|
|
12352
|
+
], { cwd });
|
|
12353
|
+
async function createPull(ctx, name, req, cwd) {
|
|
12354
|
+
const create = (draft) => run("gh", [
|
|
12355
|
+
"pr",
|
|
12356
|
+
"create",
|
|
12357
|
+
...draft ? ["--draft"] : [],
|
|
12358
|
+
"--base",
|
|
12359
|
+
req.base,
|
|
12360
|
+
"--head",
|
|
12361
|
+
versionBranch(req.version),
|
|
12362
|
+
"--title",
|
|
12363
|
+
`chore: Plexus ${req.version}`,
|
|
12364
|
+
"--body",
|
|
12365
|
+
req.body
|
|
12366
|
+
], { cwd });
|
|
12367
|
+
if (!req.draft) {
|
|
12368
|
+
await ctx.apply([create(false)]);
|
|
12369
|
+
return false;
|
|
12370
|
+
}
|
|
12371
|
+
try {
|
|
12372
|
+
await ctx.apply([create(true)]);
|
|
12373
|
+
return true;
|
|
12374
|
+
} catch (refused) {
|
|
12375
|
+
try {
|
|
12376
|
+
await ctx.apply([create(false)]);
|
|
12377
|
+
} catch (error) {
|
|
12378
|
+
throw new Error(`as a draft: ${detailOf(refused) || "refused"}; as an ordinary one: ${detailOf(error) || "refused"}`);
|
|
12379
|
+
}
|
|
12380
|
+
ctx.say(`\u2022 ${name}: the pull request is no draft: the forge refused one${detailOf(refused) ? ` (${detailOf(refused)})` : ""}`);
|
|
12381
|
+
return false;
|
|
12382
|
+
}
|
|
12383
|
+
}
|
|
12384
|
+
var LISTED = 1e3;
|
|
12385
|
+
async function pullOf(ctx, consumer, dir, version2, tip) {
|
|
12386
|
+
const args = ["pr", "list", "--head", versionBranch(version2), "--base", consumer.branch, "--state", "all"];
|
|
12387
|
+
const fields = "url,number,isDraft,state,author,headRefOid,isCrossRepository";
|
|
12388
|
+
const out = await ctx.read("gh", [...args, "--limit", String(LISTED), "--json", fields], { cwd: dir });
|
|
12389
|
+
let listed;
|
|
12390
|
+
try {
|
|
12391
|
+
listed = JSON.parse(out);
|
|
12392
|
+
} catch {
|
|
12393
|
+
throw new Error(`gh pr list gave no JSON for ${versionBranch(version2)}`);
|
|
12394
|
+
}
|
|
12395
|
+
if (!Array.isArray(listed))
|
|
12396
|
+
throw new Error(`gh pr list gave no list for ${versionBranch(version2)}`);
|
|
12397
|
+
const pulls = listed.flatMap((p) => {
|
|
12398
|
+
if (typeof p !== "object" || p === null)
|
|
12399
|
+
return [];
|
|
12400
|
+
const { url, number, isDraft, state, author, headRefOid, isCrossRepository } = p;
|
|
12401
|
+
if (typeof url !== "string" || typeof number !== "number" || isCrossRepository !== false)
|
|
12402
|
+
return [];
|
|
12403
|
+
const login = author?.login;
|
|
12404
|
+
return [
|
|
12405
|
+
{
|
|
12406
|
+
url,
|
|
12407
|
+
number,
|
|
12408
|
+
draft: isDraft === true,
|
|
12409
|
+
open: state === "OPEN",
|
|
12410
|
+
...typeof login === "string" ? { author: login } : {},
|
|
12411
|
+
...typeof headRefOid === "string" ? { head: headRefOid } : {}
|
|
12412
|
+
}
|
|
12413
|
+
];
|
|
12414
|
+
});
|
|
12415
|
+
const open = pulls.find((p) => p.open);
|
|
12416
|
+
if (open)
|
|
12417
|
+
return open;
|
|
12418
|
+
return pulls.filter((p) => tip !== void 0 && p.head === tip).sort((a, b) => b.number - a.number)[0];
|
|
12419
|
+
}
|
|
12420
|
+
async function askForReviews(ctx, name, pull, from, cwd) {
|
|
12421
|
+
let named;
|
|
12422
|
+
try {
|
|
12423
|
+
named = "named" in from ? from.named : reviewersOf(answersOf(from.answersFile));
|
|
12424
|
+
} catch (error) {
|
|
12425
|
+
const why = error.message;
|
|
12426
|
+
ctx.say(` \u2717 FAILED \u2014 ${name}: no review requested: ${why}`);
|
|
12427
|
+
return { failed: why };
|
|
12428
|
+
}
|
|
12429
|
+
const author = pull.author?.toLowerCase();
|
|
12430
|
+
const reviewers = named.filter((l) => l.toLowerCase() !== author);
|
|
12431
|
+
if (reviewers.length < named.length)
|
|
12432
|
+
ctx.say(`\u2022 ${name}: ${pull.author} opened the pull request and is not asked to review it`);
|
|
12433
|
+
if (reviewers.length === 0)
|
|
12434
|
+
return void 0;
|
|
12435
|
+
try {
|
|
12436
|
+
await ctx.apply([requestReviews(pull.number, reviewers, cwd)]);
|
|
12437
|
+
return { requested: reviewers };
|
|
12438
|
+
} catch (error) {
|
|
12439
|
+
const why = detailOf(error);
|
|
12440
|
+
ctx.say(` \u2717 FAILED \u2014 ${name}: review request from ${reviewers.join(", ")}${why ? `: ${why}` : ""}`);
|
|
12441
|
+
return { failed: why || "the forge refused it" };
|
|
12442
|
+
}
|
|
12443
|
+
}
|
|
12444
|
+
async function tipOnOrigin(ctx, repo, branch) {
|
|
12445
|
+
const tip = (await ctx.read("git", ["ls-remote", "--heads", "origin", `refs/heads/${branch}`], { cwd: repo })).split(" ")[0]?.trim();
|
|
12446
|
+
if (!tip)
|
|
12447
|
+
throw new Error(`origin no longer has ${branch}`);
|
|
12448
|
+
return tip;
|
|
12449
|
+
}
|
|
12450
|
+
async function fetchTip(ctx, repo, tip) {
|
|
12451
|
+
const shallow = (await ctx.read("git", ["rev-parse", "--is-shallow-repository"], { cwd: repo })).trim() === "true";
|
|
12452
|
+
await ctx.read("git", ["fetch", "--quiet", "--no-write-fetch-head", "--refmap=", ...shallow ? ["--depth", "1"] : [], "origin", tip], { cwd: repo });
|
|
12453
|
+
}
|
|
12454
|
+
async function aheadOf(ctx, consumer, tip) {
|
|
12455
|
+
const out = await ctx.read("gh", ["api", `repos/{owner}/{repo}/compare/${consumer.branch}...${tip}`, "--jq", ".ahead_by"], { cwd: consumer.path });
|
|
12456
|
+
const ahead = Number(out.trim());
|
|
12457
|
+
if (out.trim() === "" || !Number.isInteger(ahead))
|
|
12458
|
+
throw new Error(`the forge gave no count of commits for ${tip}`);
|
|
12459
|
+
return ahead;
|
|
12460
|
+
}
|
|
12461
|
+
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;
|
|
12462
|
+
var code = (s) => `\`${s}\``;
|
|
12463
|
+
var byHand = (version2) => ["mise", ...copierVia(["update", "--trust", "--skip-answered", "--vcs-ref", version2])].join(" ");
|
|
12464
|
+
var site = (s) => s === "." ? "the root" : code(s);
|
|
12465
|
+
function pullBody(p) {
|
|
12466
|
+
const hand = [
|
|
12467
|
+
...p.conflicted?.length ? [`- Conflicts at ${p.conflicted.map(site).join(", ")}, committed with their markers.`] : [],
|
|
12468
|
+
...p.marked.length ? [`- Files that hold conflict markers: ${p.marked.map(code).join(", ")}.`] : [],
|
|
12469
|
+
...p.failed?.length ? [`- \`copier update\` failed at ${p.failed.map(site).join(", ")}, left as it was; run it there by hand.`] : [],
|
|
12470
|
+
...(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.`),
|
|
12471
|
+
...p.lockfile && !p.checked ? ["- The lockfile did not refresh: run `pnpm install` after resolving, and commit the lockfile."] : []
|
|
12472
|
+
];
|
|
12473
|
+
const lockfile = p.lockfile && p.checked ? ["- Run `pnpm install` once resolved, and commit the lockfile."] : [];
|
|
12474
|
+
const settled = lockfile.length ? ["- Run `pnpm install`, and commit the lockfile if it changes."] : [];
|
|
12475
|
+
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.
|
|
12476
|
+
|
|
12477
|
+
${[...hand, ...lockfile].join("\n")}` : p.checked ? `Ready for review: no tracked file holds a conflict marker, and every site's answers record ${p.version}.${settled.length ? `
|
|
12478
|
+
|
|
12479
|
+
${settled.join("\n")}` : ""}` : "Nothing needs a hand: every site merged clean.";
|
|
12480
|
+
return [
|
|
12481
|
+
head,
|
|
12482
|
+
`Plexus ${p.version} (\xA7 1.5 PLX): \`copier update\` at ${p.sites.map(site).join(", ")}, the lockfile where manifests moved, and the workflow refs.`,
|
|
12483
|
+
p.note
|
|
12484
|
+
].join("\n\n");
|
|
12485
|
+
}
|
|
12486
|
+
var REVISITED = "Opened by `plx update`; rewritten by a later run from what it found at the branch's tip.";
|
|
12487
|
+
async function readTip(ctx, consumer, version2, tip) {
|
|
12488
|
+
const repo = consumer.path;
|
|
12489
|
+
await fetchTip(ctx, repo, tip);
|
|
12490
|
+
const marked = await filesWithConflictMarkers(ctx, repo, tip);
|
|
12491
|
+
const { files, sites: held } = await sitesOfTree(ctx, repo, tip);
|
|
12492
|
+
const sites = held.map((s) => s.dir);
|
|
12493
|
+
const behind = held.filter((s) => s.answers?.commit !== version2).map((s) => s.dir);
|
|
12494
|
+
const ready = marked.length === 0 && behind.length === 0;
|
|
12495
|
+
const lockfile = files.includes("pnpm-lock.yaml") && (!ready || await aheadOf(ctx, consumer, tip) > 1);
|
|
12496
|
+
return { tip, sites, marked, behind, ready, lockfile };
|
|
12497
|
+
}
|
|
12498
|
+
function foundAt(at, version2) {
|
|
12499
|
+
const n = at.marked.length;
|
|
12500
|
+
const parts2 = [
|
|
12501
|
+
...n > 0 ? [`${n} file${n === 1 ? "" : "s"} still hold${n === 1 ? "s" : ""} conflict markers`] : [],
|
|
12502
|
+
...at.behind.length > 0 ? [`${at.behind.map(site).join(", ")} not at ${version2}: copier did not run there`] : []
|
|
12503
|
+
];
|
|
12504
|
+
return parts2.length > 0 ? parts2.join("; ") : `no conflict marker remains, and every site is at ${version2}`;
|
|
12505
|
+
}
|
|
12506
|
+
async function revisit(ctx, consumer, pull, version2, tip) {
|
|
12507
|
+
const { path: repo, rel: name } = consumer;
|
|
12508
|
+
const branch = versionBranch(version2);
|
|
12509
|
+
const at = await readTip(ctx, consumer, version2, tip);
|
|
12510
|
+
const { marked, behind, ready } = at;
|
|
12511
|
+
const body2 = pullBody({
|
|
12512
|
+
version: version2,
|
|
12513
|
+
sites: at.sites,
|
|
12514
|
+
marked,
|
|
12515
|
+
behind,
|
|
12516
|
+
lockfile: at.lockfile,
|
|
12517
|
+
checked: true,
|
|
12518
|
+
note: REVISITED
|
|
12519
|
+
});
|
|
12520
|
+
const line = `\u2022 ${name}: ${branch} is on origin (${pull.url}); ${foundAt(at, version2)}`;
|
|
12521
|
+
const undo = !ready && !pull.draft;
|
|
12522
|
+
if (!undo)
|
|
12523
|
+
ctx.say(ready && pull.draft ? `${line} \u2014 ready for review` : line);
|
|
12524
|
+
try {
|
|
12525
|
+
await ctx.apply([
|
|
12526
|
+
run("gh", ["api", `repos/{owner}/{repo}/pulls/${pull.number}`, "--method", "PATCH", "-f", `body=${body2}`], {
|
|
12527
|
+
cwd: repo
|
|
12528
|
+
}),
|
|
12529
|
+
...ready && pull.draft ? [run("gh", ["pr", "ready", pull.url], { cwd: repo })] : []
|
|
12530
|
+
]);
|
|
12531
|
+
} catch (error) {
|
|
12532
|
+
if (undo)
|
|
12533
|
+
ctx.say(line);
|
|
12534
|
+
return { url: pull.url, marked, behind, mergeable: false, failed: `pull request ${pull.url}: ${detailOf(error)}` };
|
|
12535
|
+
}
|
|
12536
|
+
if (undo)
|
|
12537
|
+
await ctx.apply([run("gh", ["pr", "ready", pull.url, "--undo"], { cwd: repo })]).then(() => ctx.say(`${line} \u2014 a draft again`), (error) => {
|
|
12538
|
+
const why = detailOf(error);
|
|
12539
|
+
ctx.say(`${line} \u2014 no draft: the forge refused one${why ? ` (${why})` : ""}`);
|
|
12540
|
+
});
|
|
12541
|
+
const draft = ctx.dryRun ? pull.draft : !ready;
|
|
12542
|
+
return { url: pull.url, marked, behind, mergeable: ready && !draft };
|
|
12543
|
+
}
|
|
12544
|
+
var OPENED_LATE = "Opened by `plx update`: a later run found the branch on origin with no pull request.";
|
|
12545
|
+
async function openLate(ctx, consumer, version2, reviewers, tip) {
|
|
12546
|
+
const { path: repo, rel: name } = consumer;
|
|
12547
|
+
const branch = versionBranch(version2);
|
|
12548
|
+
const at = await readTip(ctx, consumer, version2, tip);
|
|
12549
|
+
const { marked, behind, ready } = at;
|
|
12550
|
+
const state = {
|
|
12551
|
+
version: version2,
|
|
12552
|
+
sites: at.sites,
|
|
12553
|
+
marked,
|
|
12554
|
+
behind,
|
|
12555
|
+
lockfile: at.lockfile,
|
|
12556
|
+
checked: true,
|
|
12557
|
+
note: OPENED_LATE
|
|
12558
|
+
};
|
|
12559
|
+
const asDraft = !ready;
|
|
12560
|
+
ctx.say(`\u2022 ${name}: ${branch} is on origin with no pull request \u2014 opening it${asDraft ? " as a draft" : ""}`);
|
|
12561
|
+
let draft;
|
|
12562
|
+
try {
|
|
12563
|
+
draft = await createPull(ctx, name, { base: consumer.branch, version: version2, body: pullBody(state), draft: asDraft }, repo);
|
|
12564
|
+
} catch (error) {
|
|
12565
|
+
const why = detailOf(error);
|
|
12566
|
+
ctx.say(` \u2717 FAILED \u2014 pull request${why ? `: ${why}` : ""}`);
|
|
12567
|
+
return { marked, behind, ready, failed: `pull request: ${why}` };
|
|
12568
|
+
}
|
|
12569
|
+
if (ctx.dryRun) {
|
|
12570
|
+
ctx.say(` (preview) ${name}: would open a pull request of ${branch} against ${consumer.branch}`);
|
|
12571
|
+
return { marked, behind, ready, previewed: true };
|
|
12572
|
+
}
|
|
12573
|
+
const pull = await pullOf(ctx, consumer, repo, version2);
|
|
12574
|
+
if (!pull)
|
|
12575
|
+
return { marked, behind, ready, failed: "pull request: the forge did not list it after opening it" };
|
|
12576
|
+
ctx.say(`\u2022 ${name}: ${draft ? "draft " : ""}pull request opened: ${pull.url}`);
|
|
12577
|
+
const from = reviewers ?? {
|
|
12578
|
+
answersFile: await ctx.read("git", ["cat-file", "blob", `${at.tip}:${ANSWERS_FILE}`], { cwd: repo }).catch(() => "")
|
|
12579
|
+
};
|
|
12580
|
+
const review = await askForReviews(ctx, name, pull, from, repo);
|
|
12581
|
+
return { pull, marked, behind, ready, ...review ? { review } : {} };
|
|
12582
|
+
}
|
|
12583
|
+
|
|
12584
|
+
// ../lib/dist/update.js
|
|
12585
|
+
import { basename, join as join9, relative as relative4 } from "node:path";
|
|
12586
|
+
|
|
12587
|
+
// ../lib/dist/take.js
|
|
12588
|
+
import { join as join8, relative as relative3 } from "node:path";
|
|
12589
|
+
var needsHand = (t) => t.sites.some((s) => s.outcome !== "clean") || (t.marked?.length ?? 0) > 0 || t.lockfile === "failed" || t.failed !== void 0;
|
|
12092
12590
|
var copierIn = (dir, args) => [
|
|
12093
12591
|
"env",
|
|
12094
12592
|
[`MISE_IGNORED_CONFIG_PATHS=${dir}`, "mise", ...copierVia(args)]
|
|
12095
12593
|
];
|
|
12096
|
-
async function takeVersion(ctx, consumer, dir, take
|
|
12594
|
+
async function takeVersion(ctx, consumer, dir, take) {
|
|
12097
12595
|
const base = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim();
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
|
|
12596
|
+
const update2 = take.update ?? fromTemplate(take.ref);
|
|
12597
|
+
const sites = [];
|
|
12598
|
+
for (const site2 of consumer.sites)
|
|
12599
|
+
sites.push(await updateSite(ctx, consumer, site2, dir, update2));
|
|
12600
|
+
const lockfile = await refreshLockfile(ctx, consumer, dir, base);
|
|
12101
12601
|
await bumpConsumerRefs(ctx, consumer, dir, take.version);
|
|
12102
|
-
|
|
12602
|
+
const taken = { rel: consumer.rel, sites, ...lockfile ? { lockfile } : {} };
|
|
12603
|
+
return { ...taken, ...await openPull(ctx, consumer, dir, base, take, taken) };
|
|
12103
12604
|
}
|
|
12104
|
-
var
|
|
12605
|
+
var scratchCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], { cwd: dir })).then(() => ctx.stage(run("git", [
|
|
12105
12606
|
"-c",
|
|
12106
12607
|
"commit.gpgsign=false",
|
|
12107
12608
|
"-c",
|
|
@@ -12115,275 +12616,311 @@ var previewCommit = (ctx, dir, message) => ctx.stage(run("git", ["add", "-A"], {
|
|
|
12115
12616
|
"-m",
|
|
12116
12617
|
message
|
|
12117
12618
|
], { cwd: dir })));
|
|
12118
|
-
|
|
12119
|
-
|
|
12619
|
+
var fromTemplate = (ref) => async (ctx, site2, target, dir) => {
|
|
12620
|
+
ctx.say(`\u2192 ${site2.rel}: copier update${ref ? ` to ${ref}` : ""}`);
|
|
12621
|
+
const answers = await ctx.readFile(join8(target, ANSWERS_FILE));
|
|
12622
|
+
const current = templateSource(site2.template);
|
|
12623
|
+
const recorded = parseAnswers(answers).src;
|
|
12624
|
+
if (recorded && namesOldTemplate(recorded)) {
|
|
12625
|
+
ctx.say(` ${site2.rel}: the template is ${current} now; the answers follow`);
|
|
12626
|
+
await ctx.stage(write(join8(target, ANSWERS_FILE), setAnswer(answers, "_src_path", current)));
|
|
12627
|
+
await scratchCommit(ctx, dir, `plx: ${site2.rel} reads ${current}, the template's name since its rename`);
|
|
12628
|
+
}
|
|
12629
|
+
const args = [
|
|
12630
|
+
"update",
|
|
12631
|
+
"--skip-answered",
|
|
12632
|
+
"--trust",
|
|
12633
|
+
"--skip-tasks",
|
|
12634
|
+
...ref ? ["--vcs-ref", ref] : [],
|
|
12635
|
+
...ctx.yes || ctx.dryRun ? ["--defaults"] : []
|
|
12636
|
+
];
|
|
12637
|
+
const step = run(...copierIn(dir, args), { cwd: target, interactive: !ctx.dryRun });
|
|
12638
|
+
if (ctx.dryRun)
|
|
12639
|
+
await ctx.stage(step);
|
|
12640
|
+
else
|
|
12641
|
+
await ctx.apply([step]);
|
|
12642
|
+
};
|
|
12643
|
+
async function updateSite(ctx, consumer, site2, dir, update2) {
|
|
12644
|
+
const target = join8(dir, relative3(consumer.path, site2.path));
|
|
12120
12645
|
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
|
-
}
|
|
12646
|
+
await update2(ctx, site2, target, dir);
|
|
12152
12647
|
} catch (error) {
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
return;
|
|
12648
|
+
const why = detailOf(error);
|
|
12649
|
+
ctx.say(` \u2717 FAILED \u2014 copier update exited nonzero${why ? `: ${why}` : ""}`);
|
|
12650
|
+
return { rel: site2.rel, outcome: "failed", ...why ? { detail: why } : {} };
|
|
12156
12651
|
}
|
|
12157
12652
|
const status = await ctx.read("git", ["status", "--porcelain", "--", "."], { cwd: target });
|
|
12158
12653
|
let conflict = hasUnmergedEntries(status);
|
|
12159
12654
|
const changed = (await ctx.read("git", ["diff", "--name-only", "--relative", "--", "."], { cwd: target })).split("\n").filter(Boolean);
|
|
12160
12655
|
for (const f of changed) {
|
|
12161
|
-
const text = await ctx.readFile(
|
|
12656
|
+
const text = await ctx.readFile(join8(target, f)).catch(() => "");
|
|
12162
12657
|
if (hasConflictMarkers(text))
|
|
12163
12658
|
conflict = true;
|
|
12164
12659
|
}
|
|
12165
|
-
if (conflict)
|
|
12660
|
+
if (conflict)
|
|
12166
12661
|
ctx.say(" \u2717 CONFLICTS \u2014 committed with their <<<<<<< markers, to resolve in the pull request:");
|
|
12167
|
-
|
|
12168
|
-
} else {
|
|
12662
|
+
else
|
|
12169
12663
|
ctx.say(" \u2713 merged clean:");
|
|
12170
|
-
summary.clean.push(site.rel);
|
|
12171
|
-
}
|
|
12172
12664
|
for (const line of status.split("\n").filter(Boolean))
|
|
12173
12665
|
ctx.say(` ${line}`);
|
|
12174
|
-
|
|
12175
|
-
|
|
12176
|
-
else
|
|
12177
|
-
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
12666
|
+
await ctx.stage(run("git", ["add", "-A"], { cwd: dir }));
|
|
12667
|
+
return { rel: site2.rel, outcome: conflict ? "conflicted" : "clean" };
|
|
12178
12668
|
}
|
|
12179
|
-
async function refreshLockfile(ctx, consumer, dir, base
|
|
12180
|
-
if (await ctx.readFile(
|
|
12181
|
-
return;
|
|
12669
|
+
async function refreshLockfile(ctx, consumer, dir, base) {
|
|
12670
|
+
if (await ctx.readFile(join8(dir, "pnpm-workspace.yaml")).catch(() => void 0) === void 0)
|
|
12671
|
+
return void 0;
|
|
12182
12672
|
const manifests = ["*package.json", "pnpm-workspace.yaml"];
|
|
12183
12673
|
const unchanged = await ctx.read("git", ["diff", "--quiet", base, "--", ...manifests], { cwd: dir }).then(() => true).catch(() => false);
|
|
12184
12674
|
if (unchanged)
|
|
12185
|
-
return;
|
|
12675
|
+
return void 0;
|
|
12186
12676
|
ctx.say(`\u2192 ${consumer.rel}: pnpm install (manifests changed)`);
|
|
12187
12677
|
try {
|
|
12188
12678
|
await ctx.apply([
|
|
12189
12679
|
run("mise", ["exec", "--", "pnpm", "install", "--no-frozen-lockfile", "--reporter=silent"], { cwd: dir })
|
|
12190
12680
|
]);
|
|
12681
|
+
return "refreshed";
|
|
12191
12682
|
} catch (error) {
|
|
12192
|
-
|
|
12193
|
-
|
|
12683
|
+
const why = detailOf(error);
|
|
12684
|
+
ctx.say(` \u2717 pnpm install failed${why ? `: ${why}` : ""}`);
|
|
12685
|
+
return "failed";
|
|
12194
12686
|
}
|
|
12195
12687
|
}
|
|
12196
12688
|
async function bumpConsumerRefs(ctx, consumer, dir, version2) {
|
|
12197
|
-
const workflows =
|
|
12689
|
+
const workflows = join8(dir, ".github", "workflows");
|
|
12198
12690
|
const entries = await ctx.readDir(workflows).catch(() => []);
|
|
12199
12691
|
const files = entries.filter((e) => !e.directory && /\.ya?ml$/.test(e.name)).map((e) => e.name).sort();
|
|
12200
12692
|
for (const f of files) {
|
|
12201
|
-
const text = await ctx.readFile(
|
|
12693
|
+
const text = await ctx.readFile(join8(workflows, f));
|
|
12202
12694
|
if (!text.includes(WORKFLOW_REF))
|
|
12203
12695
|
continue;
|
|
12204
12696
|
const bumped = bumpWorkflowRefs(text, version2);
|
|
12205
12697
|
if (bumped === text)
|
|
12206
12698
|
continue;
|
|
12207
12699
|
ctx.say(`\u2192 ${consumer.rel}: ${f} workflow refs \u2192 @${version2}`);
|
|
12208
|
-
await ctx.stage(write(
|
|
12700
|
+
await ctx.stage(write(join8(workflows, f), bumped));
|
|
12209
12701
|
}
|
|
12210
12702
|
}
|
|
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) {
|
|
12703
|
+
async function openPull(ctx, consumer, dir, base, take, taken) {
|
|
12216
12704
|
const { version: version2 } = take;
|
|
12217
12705
|
const branch = versionBranch(version2);
|
|
12218
12706
|
if (ctx.dryRun) {
|
|
12219
12707
|
ctx.say(` (preview) ${consumer.rel}: would commit, push ${branch} and open a pull request against ${consumer.branch}`);
|
|
12220
|
-
return;
|
|
12708
|
+
return {};
|
|
12221
12709
|
}
|
|
12222
|
-
|
|
12710
|
+
const moved = (await ctx.read("git", ["rev-parse", "HEAD"], { cwd: dir })).trim() !== base;
|
|
12711
|
+
if (!moved && (await ctx.read("git", ["status", "--porcelain"], { cwd: dir })).trim() === "") {
|
|
12223
12712
|
ctx.say(`\u2022 ${consumer.rel}: nothing changed \u2014 no pull request`);
|
|
12224
|
-
return;
|
|
12713
|
+
return {};
|
|
12225
12714
|
}
|
|
12226
12715
|
const head = `${consumer.origin ?? "origin"} ${branch}`;
|
|
12227
12716
|
try {
|
|
12228
12717
|
await ctx.apply([
|
|
12718
|
+
// Staged first: a site whose copier run failed mid-merge can leave unmerged entries, which a reset refuses.
|
|
12229
12719
|
run("git", ["add", "-A"], { cwd: dir }),
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12720
|
+
// One commit on the branch, the scratch ones folded in: a later run tells it from a human's by the count.
|
|
12721
|
+
run("git", ["reset", "--quiet", "--soft", base], { cwd: dir }),
|
|
12722
|
+
run("git", ["commit", "--quiet", "--no-verify", "-m", `chore: Plexus ${version2}`], { cwd: dir }),
|
|
12723
|
+
// An empty expected value: the branch must not exist on origin yet.
|
|
12724
|
+
run("git", [
|
|
12725
|
+
"push",
|
|
12726
|
+
"--quiet",
|
|
12727
|
+
"--no-verify",
|
|
12728
|
+
`--force-with-lease=refs/heads/${branch}:`,
|
|
12729
|
+
"origin",
|
|
12730
|
+
`HEAD:refs/heads/${branch}`
|
|
12731
|
+
], { cwd: dir })
|
|
12239
12732
|
]);
|
|
12240
12733
|
} 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");
|
|
12734
|
+
const why = detailOf(error);
|
|
12735
|
+
ctx.say(` \u2717 FAILED \u2014 push to ${head}${why ? `: ${why}` : ""}`);
|
|
12736
|
+
return { failed: `push to ${head}${why ? `: ${why}` : ""}` };
|
|
12737
|
+
}
|
|
12738
|
+
const marked = await filesWithConflictMarkers(ctx, dir);
|
|
12739
|
+
const of = (outcome) => taken.sites.filter((s) => s.outcome === outcome).map((s) => siteOf(consumer, s.rel));
|
|
12740
|
+
const state = {
|
|
12741
|
+
version: version2,
|
|
12742
|
+
sites: consumer.sites.map((s) => relative3(consumer.path, s.path) || "."),
|
|
12743
|
+
conflicted: of("conflicted"),
|
|
12744
|
+
marked,
|
|
12745
|
+
failed: of("failed"),
|
|
12746
|
+
lockfile: taken.lockfile === "failed",
|
|
12747
|
+
note: `Opened by ${take.opener}${take.why ? `: ${take.why}` : ""}.`
|
|
12748
|
+
};
|
|
12749
|
+
if (marked.length > 0)
|
|
12750
|
+
ctx.say(` ${consumer.rel}: conflict markers in ${marked.join(", ")}`);
|
|
12751
|
+
let draft;
|
|
12264
12752
|
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
|
-
]);
|
|
12753
|
+
draft = await createPull(ctx, consumer.rel, { base: consumer.branch, version: version2, body: pullBody(state), draft: needsAHand(state) }, dir);
|
|
12279
12754
|
} catch (error) {
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
return;
|
|
12755
|
+
const why = detailOf(error);
|
|
12756
|
+
ctx.say(` \u2717 FAILED \u2014 pull request${why ? `: ${why}` : ""}`);
|
|
12757
|
+
return { marked, failed: `pull request${why ? `: ${why}` : ""}` };
|
|
12283
12758
|
}
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12759
|
+
let opened;
|
|
12760
|
+
try {
|
|
12761
|
+
opened = await pullOf(ctx, consumer, dir, version2);
|
|
12762
|
+
} catch (error) {
|
|
12763
|
+
const why = detailOf(error);
|
|
12764
|
+
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}: the pull request opened, but listing it failed${why ? `: ${why}` : ""}`);
|
|
12765
|
+
return { marked, pull: { branch, draft }, failed: `listing the pull request: ${why}` };
|
|
12766
|
+
}
|
|
12767
|
+
const url = opened?.url;
|
|
12768
|
+
ctx.say(`\u2022 ${consumer.rel}: ${draft ? "draft " : ""}pull request opened${url ? `: ${url}` : ""}`);
|
|
12769
|
+
const pull = { branch, draft, ...url ? { url } : {} };
|
|
12770
|
+
if (!opened)
|
|
12771
|
+
return { marked, pull, failed: "the forge did not list the pull request it opened" };
|
|
12772
|
+
const from = take.reviewers ?? {
|
|
12773
|
+
answersFile: await ctx.readFile(join8(dir, ANSWERS_FILE)).catch(() => "")
|
|
12774
|
+
};
|
|
12775
|
+
const review = await askForReviews(ctx, consumer.rel, opened, from, dir);
|
|
12776
|
+
return { marked, pull, ...review ? { review } : {} };
|
|
12777
|
+
}
|
|
12778
|
+
function siteOf(consumer, rel) {
|
|
12779
|
+
const s = consumer.sites.find((x) => x.rel === rel);
|
|
12780
|
+
return s ? relative3(consumer.path, s.path) || "." : rel;
|
|
12289
12781
|
}
|
|
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
12782
|
|
|
12296
12783
|
// ../lib/dist/update.js
|
|
12297
|
-
|
|
12298
|
-
async function update(ctx, options) {
|
|
12299
|
-
const { repo } = options;
|
|
12300
|
-
const name = options.name ?? basename(repo);
|
|
12784
|
+
async function update(ctx, options, known) {
|
|
12301
12785
|
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
12302
12786
|
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);
|
|
12787
|
+
const consumer = known?.consumer ?? await repoAt(ctx, options.repo, options.name ?? basename(options.repo));
|
|
12788
|
+
const { path: repo, rel: name } = consumer;
|
|
12312
12789
|
const root = consumer.sites.find((s) => s.path === consumer.path);
|
|
12313
12790
|
if (!root)
|
|
12314
12791
|
throw new Error(`${name}: its root is not a site of a repo template`);
|
|
12315
|
-
|
|
12316
|
-
|
|
12792
|
+
if (!known)
|
|
12793
|
+
await preflightForge(ctx);
|
|
12794
|
+
const releases = known?.releases ?? (options.to === void 0 ? await releasesOf(ctx) : []);
|
|
12317
12795
|
const newest2 = options.to ?? newestOf(releases);
|
|
12318
12796
|
if (await onOrigin(ctx, repo, consumer.branch) === false) {
|
|
12319
12797
|
const reason = `origin has no branch \`${consumer.branch}\`, the one the version lands on`;
|
|
12320
12798
|
ctx.say(`\u26A0 ${name}: ${reason} \u2014 skipped`);
|
|
12321
|
-
|
|
12322
|
-
skipped.skipped.push({ path: name, reason });
|
|
12323
|
-
return skipped;
|
|
12799
|
+
return { repo: name, version: newest2, kind: "skipped", reason };
|
|
12324
12800
|
}
|
|
12325
12801
|
await ctx.read("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }).catch(() => "");
|
|
12326
|
-
const
|
|
12327
|
-
|
|
12802
|
+
const onBranch = await sitesOfTree(ctx, repo, `refs/remotes/origin/${consumer.branch}`).catch(() => void 0);
|
|
12803
|
+
const answers = onBranch ? onBranch.sites.map((s) => s.answers ?? { answers: {} }) : await Promise.all(consumer.sites.map(async (s) => {
|
|
12804
|
+
const file = join9(relative4(consumer.path, s.path), ANSWERS_FILE);
|
|
12328
12805
|
const onOrigin2 = await ctx.read("git", ["show", `origin/${consumer.branch}:${file}`], { cwd: repo }).catch(() => void 0);
|
|
12329
|
-
return parseAnswers(onOrigin2 ?? await ctx.readFile(
|
|
12806
|
+
return parseAnswers(onOrigin2 ?? await ctx.readFile(join9(s.path, ANSWERS_FILE)));
|
|
12330
12807
|
}));
|
|
12808
|
+
const rootAnswers = onBranch ? onBranch.sites.find((s) => s.dir === ".")?.answers : answers[consumer.sites.indexOf(root)];
|
|
12331
12809
|
const recorded = answers.map((a) => a.commit);
|
|
12332
12810
|
if (recorded.every((c) => c === newest2)) {
|
|
12333
12811
|
ctx.say(`\u2022 ${name}: already at ${newest2}`);
|
|
12334
|
-
return
|
|
12812
|
+
return { repo: name, version: newest2, kind: "current" };
|
|
12335
12813
|
}
|
|
12336
12814
|
const past = recorded.find((c) => c && isPlexusVersion(c) && compareVersions(c, newest2) > 0);
|
|
12337
12815
|
if (past)
|
|
12338
12816
|
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 (${
|
|
12817
|
+
const asked = options.to !== void 0 || options.now === true;
|
|
12818
|
+
const need = asked ? { take: true, version: newest2, why: `asked for (${options.to !== void 0 ? `--to ${newest2}` : "--now"})` } : needOf({
|
|
12341
12819
|
recorded,
|
|
12342
12820
|
releases,
|
|
12343
|
-
maxAge: options.maxAge ?? maxAgeOf(
|
|
12821
|
+
maxAge: options.maxAge ?? maxAgeOf(rootAnswers?.answers ?? {}),
|
|
12344
12822
|
now: options.today === void 0 ? /* @__PURE__ */ new Date() : new Date(options.today)
|
|
12345
12823
|
});
|
|
12346
12824
|
if (need.held)
|
|
12347
12825
|
ctx.say(`\u2022 ${name}: ${need.held} (plx update --now takes it)`);
|
|
12826
|
+
const reviewers = options.reviewers ? { named: options.reviewers } : void 0;
|
|
12348
12827
|
const version2 = need.take ? need.version : newest2;
|
|
12349
|
-
const summary = emptySummary(version2, ctx.dryRun);
|
|
12350
12828
|
const branch = versionBranch(version2);
|
|
12351
12829
|
if (await onOrigin(ctx, repo, branch)) {
|
|
12352
|
-
const
|
|
12353
|
-
|
|
12354
|
-
if (
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12830
|
+
const tip = await tipOnOrigin(ctx, repo, branch);
|
|
12831
|
+
const pull = await pullOf(ctx, consumer, repo, version2, tip);
|
|
12832
|
+
if (!pull) {
|
|
12833
|
+
try {
|
|
12834
|
+
const late = await openLate(ctx, consumer, version2, reviewers, tip);
|
|
12835
|
+
if (late.failed)
|
|
12836
|
+
ctx.say(` \u2717 FAILED \u2014 ${late.failed}`);
|
|
12837
|
+
return {
|
|
12838
|
+
repo: name,
|
|
12839
|
+
version: version2,
|
|
12840
|
+
kind: "found",
|
|
12841
|
+
...late.pull ? { pull: late.pull.url } : {},
|
|
12842
|
+
...late.previewed ? { opening: true } : {},
|
|
12843
|
+
marked: late.marked,
|
|
12844
|
+
behind: late.behind,
|
|
12845
|
+
mergeable: late.pull !== void 0 && !late.pull.draft && late.ready,
|
|
12846
|
+
...late.failed ? { failed: late.failed } : {},
|
|
12847
|
+
...late.review ? { review: late.review } : {}
|
|
12848
|
+
};
|
|
12849
|
+
} catch (error) {
|
|
12850
|
+
const why = detailOf(error);
|
|
12851
|
+
ctx.say(` \u2717 FAILED \u2014 ${branch} as origin has it${why ? `: ${why}` : ""}`);
|
|
12852
|
+
return { repo: name, version: version2, kind: "found", marked: [], behind: [], mergeable: false, failed: why };
|
|
12853
|
+
}
|
|
12854
|
+
}
|
|
12855
|
+
if (!pull.open) {
|
|
12856
|
+
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`);
|
|
12857
|
+
return { repo: name, version: version2, kind: "found", marked: [], behind: [], mergeable: false };
|
|
12858
|
+
}
|
|
12859
|
+
try {
|
|
12860
|
+
const { url, ...found } = await revisit(ctx, consumer, pull, version2, tip);
|
|
12861
|
+
if (found.failed)
|
|
12862
|
+
ctx.say(` \u2717 FAILED \u2014 ${found.failed}`);
|
|
12863
|
+
return { repo: name, version: version2, kind: "found", pull: url, ...found };
|
|
12864
|
+
} catch (error) {
|
|
12865
|
+
const why = detailOf(error);
|
|
12866
|
+
ctx.say(` \u2717 FAILED \u2014 ${branch} as origin has it${why ? `: ${why}` : ""}`);
|
|
12867
|
+
return {
|
|
12868
|
+
repo: name,
|
|
12869
|
+
version: version2,
|
|
12870
|
+
kind: "found",
|
|
12871
|
+
pull: pull.url,
|
|
12872
|
+
marked: [],
|
|
12873
|
+
behind: [],
|
|
12874
|
+
mergeable: false,
|
|
12875
|
+
failed: why
|
|
12876
|
+
};
|
|
12359
12877
|
}
|
|
12360
|
-
return summary;
|
|
12361
12878
|
}
|
|
12362
12879
|
if (!need.take) {
|
|
12363
12880
|
ctx.say(`\u2022 ${name}: rests \u2014 ${need.why} (plx update --now takes ${version2})`);
|
|
12364
|
-
|
|
12365
|
-
return summary;
|
|
12881
|
+
return { repo: name, version: version2, kind: "resting", reason: need.why };
|
|
12366
12882
|
}
|
|
12367
12883
|
ctx.say(`\u2022 ${name}: takes ${version2} \u2014 ${need.why}`);
|
|
12368
12884
|
const scratch = (await ctx.stage(run("mktemp", ["-d"])))?.trim() ?? "";
|
|
12369
|
-
const dir =
|
|
12885
|
+
const dir = join9(scratch, name);
|
|
12370
12886
|
try {
|
|
12371
12887
|
ctx.say(`\u2192 ${name}: worktree of origin/${consumer.branch}`);
|
|
12372
12888
|
try {
|
|
12373
12889
|
await ctx.stage(run("git", ["fetch", "--quiet", "origin", consumer.branch], { cwd: repo }));
|
|
12374
12890
|
await ctx.stage(run("git", ["worktree", "add", "--quiet", "--detach", dir, `origin/${consumer.branch}`], { cwd: repo }));
|
|
12375
12891
|
} catch (error) {
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
return
|
|
12379
|
-
}
|
|
12380
|
-
await
|
|
12892
|
+
const why = detailOf(error);
|
|
12893
|
+
ctx.say(` \u2717 FAILED \u2014 worktree of origin/${consumer.branch}${why ? `: ${why}` : ""}`);
|
|
12894
|
+
return { repo: name, version: version2, kind: "failed", detail: `worktree of origin/${consumer.branch}: ${why}` };
|
|
12895
|
+
}
|
|
12896
|
+
const held = (await sitesOfTree(ctx, dir, "HEAD")).sites;
|
|
12897
|
+
const sites = held.flatMap((s) => s.template ? [{ path: join9(repo, s.dir), rel: s.dir === "." ? name : join9(name, s.dir), template: s.template }] : []);
|
|
12898
|
+
const taken = await takeVersion(ctx, { ...consumer, sites }, dir, {
|
|
12899
|
+
version: version2,
|
|
12900
|
+
ref: version2,
|
|
12901
|
+
opener: "`plx update`",
|
|
12902
|
+
why: need.why,
|
|
12903
|
+
...reviewers ? { reviewers } : {}
|
|
12904
|
+
});
|
|
12905
|
+
return { repo: name, version: version2, kind: "taken", taken };
|
|
12381
12906
|
} finally {
|
|
12382
12907
|
await ctx.stage(run("git", ["worktree", "remove", "--force", dir], { cwd: repo })).catch(() => void 0);
|
|
12383
12908
|
if (scratch)
|
|
12384
12909
|
await ctx.stage(run("rm", ["-rf", scratch]));
|
|
12385
12910
|
}
|
|
12386
|
-
|
|
12911
|
+
}
|
|
12912
|
+
async function repoAt(ctx, path3, name) {
|
|
12913
|
+
const tree = await overview(ctx, path3);
|
|
12914
|
+
const found = (await findConsumers(ctx, tree, TEMPLATES)).find((c) => c.path === tree.path);
|
|
12915
|
+
if (!found)
|
|
12916
|
+
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(", ")}`);
|
|
12917
|
+
if (found.skipped)
|
|
12918
|
+
throw new Error(`${name}: ${found.skipped}`);
|
|
12919
|
+
return {
|
|
12920
|
+
...found,
|
|
12921
|
+
rel: name,
|
|
12922
|
+
sites: found.sites.map((s) => ({ ...s, rel: s.rel === "." ? name : join9(name, s.rel) }))
|
|
12923
|
+
};
|
|
12387
12924
|
}
|
|
12388
12925
|
async function onOrigin(ctx, repo, branch) {
|
|
12389
12926
|
try {
|
|
@@ -12406,35 +12943,41 @@ function newestOf(releases) {
|
|
|
12406
12943
|
return newest2;
|
|
12407
12944
|
}
|
|
12408
12945
|
|
|
12409
|
-
// ../lib/dist/
|
|
12410
|
-
async function
|
|
12946
|
+
// ../lib/dist/recursive.js
|
|
12947
|
+
async function updateRecursive(ctx, options) {
|
|
12411
12948
|
const { dir, ...rest } = options;
|
|
12412
12949
|
if (options.to !== void 0 && !isPlexusVersion(options.to))
|
|
12413
12950
|
throw new UsageError(`'${options.to}' is not plain semver (X.Y.Z, no v)`);
|
|
12414
|
-
const summary = emptySummary(options.to ?? "", ctx.dryRun);
|
|
12415
12951
|
const consumers = await findConsumers(ctx, await overview(ctx, dir), TEMPLATES);
|
|
12416
12952
|
if (consumers.length === 0)
|
|
12417
12953
|
ctx.say(`\u2022 no repo generated from ${TEMPLATES.map(templateSource).join(", ")} found under ${dir}`);
|
|
12954
|
+
let releases = [];
|
|
12955
|
+
if (consumers.some((c) => !c.skipped)) {
|
|
12956
|
+
await preflightForge(ctx);
|
|
12957
|
+
if (options.to === void 0)
|
|
12958
|
+
releases = await releasesOf(ctx);
|
|
12959
|
+
}
|
|
12960
|
+
const version2 = options.to ?? "";
|
|
12961
|
+
const outcomes = [];
|
|
12418
12962
|
for (const consumer of consumers) {
|
|
12419
12963
|
if (consumer.skipped) {
|
|
12420
|
-
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run
|
|
12421
|
-
|
|
12964
|
+
ctx.say(`\u26A0 ${consumer.rel}: ${consumer.skipped} \u2014 skipped (fix it, then re-run plx update --recursive)`);
|
|
12965
|
+
outcomes.push({ repo: consumer.rel, version: version2, kind: "skipped", reason: consumer.skipped });
|
|
12422
12966
|
continue;
|
|
12423
12967
|
}
|
|
12424
12968
|
try {
|
|
12425
|
-
|
|
12426
|
-
mergeSummary(summary, one);
|
|
12427
|
-
summary.version ||= one.version;
|
|
12969
|
+
outcomes.push(await update(ctx, { repo: consumer.path, ...rest }, { consumer, releases }));
|
|
12428
12970
|
} catch (error) {
|
|
12429
|
-
|
|
12430
|
-
|
|
12971
|
+
const why = detailOf(error);
|
|
12972
|
+
ctx.say(` \u2717 FAILED \u2014 ${consumer.rel}${why ? `: ${why}` : ""}`);
|
|
12973
|
+
outcomes.push({ repo: consumer.rel, version: version2, kind: "failed", detail: why });
|
|
12431
12974
|
}
|
|
12432
12975
|
}
|
|
12433
|
-
return
|
|
12976
|
+
return outcomes;
|
|
12434
12977
|
}
|
|
12435
12978
|
|
|
12436
12979
|
// ../lib/dist/requirements.js
|
|
12437
|
-
import { join as
|
|
12980
|
+
import { join as join10 } from "node:path";
|
|
12438
12981
|
var KEYWORD = /MUST|SHOULD|MAY/;
|
|
12439
12982
|
var hasKeyword = (line) => KEYWORD.test(line.replace(/MUSTs|SHOULDs|MAYs/g, ""));
|
|
12440
12983
|
function requirementName(bullet) {
|
|
@@ -12529,16 +13072,16 @@ function scanPage(text, name, mode) {
|
|
|
12529
13072
|
defect(i, `BCP 14 keyword outside a requirement: ${line}`);
|
|
12530
13073
|
}
|
|
12531
13074
|
if (mode === "module") {
|
|
12532
|
-
const { maturity = "", binds = "", code = "" } = scan;
|
|
13075
|
+
const { maturity = "", binds = "", code: code2 = "" } = scan;
|
|
12533
13076
|
const n = text.endsWith("\n") ? lines.length - 1 : lines.length;
|
|
12534
13077
|
if (!/^(note|candidate|standard)$/.test(maturity))
|
|
12535
13078
|
defect(n - 1, `maturity must be note, candidate or standard, not "${maturity}"`);
|
|
12536
13079
|
if (!/^(repo|app|host|organisation)$/.test(binds))
|
|
12537
13080
|
defect(n - 1, `binds must be repo, app, host or organisation, not "${binds}"`);
|
|
12538
|
-
if (maturity === "note" &&
|
|
13081
|
+
if (maturity === "note" && code2 !== "")
|
|
12539
13082
|
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 "${
|
|
13083
|
+
if (maturity !== "note" && !/^PLX-[A-Z][A-Za-z]+$/.test(code2))
|
|
13084
|
+
defect(n - 1, `code must be PLX- plus one capitalised word, not "${code2}"`);
|
|
12542
13085
|
}
|
|
12543
13086
|
return scan;
|
|
12544
13087
|
}
|
|
@@ -12548,7 +13091,7 @@ var MODULE_DIRS = ["contracts", "approaches"];
|
|
|
12548
13091
|
async function modulePages(ctx, compendium) {
|
|
12549
13092
|
const pages = [];
|
|
12550
13093
|
for (const dir of MODULE_DIRS) {
|
|
12551
|
-
const entries = await ctx.readDir(
|
|
13094
|
+
const entries = await ctx.readDir(join10(compendium, dir));
|
|
12552
13095
|
for (const e of entries.filter((e2) => !e2.directory && e2.name.endsWith(".md") && e2.name !== "index.md").sort())
|
|
12553
13096
|
pages.push(`${dir}/${e.name}`);
|
|
12554
13097
|
}
|
|
@@ -12556,11 +13099,11 @@ async function modulePages(ctx, compendium) {
|
|
|
12556
13099
|
}
|
|
12557
13100
|
async function checkCompendium(ctx, compendium) {
|
|
12558
13101
|
const defects = [];
|
|
12559
|
-
defects.push(...scanPage(await ctx.readFile(
|
|
13102
|
+
defects.push(...scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").defects);
|
|
12560
13103
|
const pages = await modulePages(ctx, compendium);
|
|
12561
13104
|
const scans = /* @__PURE__ */ new Map();
|
|
12562
13105
|
for (const page of pages) {
|
|
12563
|
-
const scan = scanPage(await ctx.readFile(
|
|
13106
|
+
const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
|
|
12564
13107
|
defects.push(...scan.defects);
|
|
12565
13108
|
scans.set(page, scan);
|
|
12566
13109
|
}
|
|
@@ -12568,9 +13111,9 @@ async function checkCompendium(ctx, compendium) {
|
|
|
12568
13111
|
for (const [page, s] of scans)
|
|
12569
13112
|
if (s.code)
|
|
12570
13113
|
byCode.set(s.code, [...byCode.get(s.code) ?? [], page]);
|
|
12571
|
-
for (const [
|
|
13114
|
+
for (const [code2, where] of byCode)
|
|
12572
13115
|
if (where.length > 1)
|
|
12573
|
-
defects.push(`\u2717 duplicate module code: ${
|
|
13116
|
+
defects.push(`\u2717 duplicate module code: ${code2}`);
|
|
12574
13117
|
const named = /* @__PURE__ */ new Set();
|
|
12575
13118
|
for (const s of scans.values())
|
|
12576
13119
|
for (const name of s.names) {
|
|
@@ -12588,8 +13131,8 @@ async function checkCompendium(ctx, compendium) {
|
|
|
12588
13131
|
defects.push(`\u2717 unknown module in depends: ${dep}`);
|
|
12589
13132
|
const kindOf2 = (page) => page.startsWith("contracts/") ? "contract" : "approach";
|
|
12590
13133
|
const side = (binds2) => binds2 === "repo" || binds2 === "app" ? "dev" : "ops";
|
|
12591
|
-
const kinds = new Map([...byCode].map(([
|
|
12592
|
-
const binds = new Map([...byCode].map(([
|
|
13134
|
+
const kinds = new Map([...byCode].map(([code2, [page = ""]]) => [code2, kindOf2(page)]));
|
|
13135
|
+
const binds = new Map([...byCode].map(([code2, [page = ""]]) => [code2, scans.get(page)?.binds ?? ""]));
|
|
12593
13136
|
for (const [page, s] of scans) {
|
|
12594
13137
|
const m = s.code ?? page.replace(/.*\//, "");
|
|
12595
13138
|
const kind = kindOf2(page);
|
|
@@ -12621,9 +13164,9 @@ async function readCitable(ctx, compendium) {
|
|
|
12621
13164
|
}
|
|
12622
13165
|
async function readPages(ctx, compendium) {
|
|
12623
13166
|
const own = /* @__PURE__ */ new Map([[MAP_PAGE, "PLX"]]);
|
|
12624
|
-
const citable = scanPage(await ctx.readFile(
|
|
13167
|
+
const citable = scanPage(await ctx.readFile(join10(compendium, MAP_PAGE)), MAP_PAGE, "map").sections.map((n) => `\xA7 ${n} PLX`);
|
|
12625
13168
|
for (const page of await modulePages(ctx, compendium)) {
|
|
12626
|
-
const scan = scanPage(await ctx.readFile(
|
|
13169
|
+
const scan = scanPage(await ctx.readFile(join10(compendium, page)), page, "module");
|
|
12627
13170
|
if (!scan.code)
|
|
12628
13171
|
continue;
|
|
12629
13172
|
own.set(page, scan.code);
|
|
@@ -12633,10 +13176,10 @@ async function readPages(ctx, compendium) {
|
|
|
12633
13176
|
}
|
|
12634
13177
|
var COPIER_FILES = ["copier.yml", "copier.yaml"];
|
|
12635
13178
|
async function kindOf(ctx, dir) {
|
|
12636
|
-
if (await ctx.readFile(
|
|
13179
|
+
if (await ctx.readFile(join10(dir, MAP_PAGE)).then(() => true, () => false))
|
|
12637
13180
|
return { kind: "compendium" };
|
|
12638
13181
|
for (const file of COPIER_FILES) {
|
|
12639
|
-
const text = await ctx.readFile(
|
|
13182
|
+
const text = await ctx.readFile(join10(dir, file)).catch(() => void 0);
|
|
12640
13183
|
const sub = text === void 0 ? void 0 : /^_subdirectory:\s*["']?([^"'\s#]+)/m.exec(text)?.[1];
|
|
12641
13184
|
if (sub)
|
|
12642
13185
|
return { kind: "template", templateDir: sub.replace(/\/+$/, "") };
|
|
@@ -12672,7 +13215,7 @@ async function lintRepo(ctx, dir, options = {}) {
|
|
|
12672
13215
|
for (const file of await trackedFiles(ctx, dir)) {
|
|
12673
13216
|
if (file === BASELINE_FILE)
|
|
12674
13217
|
continue;
|
|
12675
|
-
const text = await ctx.readFile(
|
|
13218
|
+
const text = await ctx.readFile(join10(dir, file)).catch(() => void 0);
|
|
12676
13219
|
if (text === void 0 || text.includes("\0"))
|
|
12677
13220
|
continue;
|
|
12678
13221
|
if (kind === "compendium" && /\.mdx?$/.test(file))
|
|
@@ -12686,7 +13229,7 @@ async function lintRepo(ctx, dir, options = {}) {
|
|
|
12686
13229
|
}
|
|
12687
13230
|
async function checkRepo(ctx, dir, options = {}) {
|
|
12688
13231
|
const lint = await lintRepo(ctx, dir, options);
|
|
12689
|
-
const baseline = parseBaseline(await ctx.readFile(
|
|
13232
|
+
const baseline = parseBaseline(await ctx.readFile(join10(dir, BASELINE_FILE)).catch(() => ""));
|
|
12690
13233
|
const { fresh, stale, known } = compareBaseline(lint.violations, baseline);
|
|
12691
13234
|
return {
|
|
12692
13235
|
kind: lint.kind,
|
|
@@ -12704,7 +13247,7 @@ async function checkRepo(ctx, dir, options = {}) {
|
|
|
12704
13247
|
async function planBaseline(ctx, dir, options = {}) {
|
|
12705
13248
|
const lint = await lintRepo(ctx, dir, options);
|
|
12706
13249
|
ctx.say(`\u2022 ${lint.violations.length} known violations \u2192 ${BASELINE_FILE}`);
|
|
12707
|
-
return [write(
|
|
13250
|
+
return [write(join10(dir, BASELINE_FILE), renderBaseline(lint.violations))];
|
|
12708
13251
|
}
|
|
12709
13252
|
async function checkCommitMessage(ctx, file, dir) {
|
|
12710
13253
|
const config = async (key) => (await ctx.read("git", ["config", "--get", key], { cwd: dir }).catch(() => "")).trim();
|
|
@@ -12713,10 +13256,80 @@ async function checkCommitMessage(ctx, file, dir) {
|
|
|
12713
13256
|
}
|
|
12714
13257
|
|
|
12715
13258
|
// ../lib/dist/summary.js
|
|
13259
|
+
var inRun = (repo, file) => repo === "." ? file : `${repo}/${file}`;
|
|
13260
|
+
var isClean = (s) => s.conflicted.length === 0 && s.failed.length === 0 && s.skipped.length === 0;
|
|
13261
|
+
function summarize(outcomes, preview, version2 = outcomes.find((o) => o.version)?.version ?? "") {
|
|
13262
|
+
const s = {
|
|
13263
|
+
version: version2,
|
|
13264
|
+
preview,
|
|
13265
|
+
clean: [],
|
|
13266
|
+
conflicted: [],
|
|
13267
|
+
failed: [],
|
|
13268
|
+
skipped: [],
|
|
13269
|
+
resting: [],
|
|
13270
|
+
pulls: [],
|
|
13271
|
+
mergeable: [],
|
|
13272
|
+
opening: []
|
|
13273
|
+
};
|
|
13274
|
+
for (const o of outcomes) {
|
|
13275
|
+
switch (o.kind) {
|
|
13276
|
+
case "current":
|
|
13277
|
+
break;
|
|
13278
|
+
case "skipped":
|
|
13279
|
+
s.skipped.push({ path: o.repo, reason: o.reason });
|
|
13280
|
+
break;
|
|
13281
|
+
case "resting":
|
|
13282
|
+
s.resting.push({ path: o.repo, reason: o.reason });
|
|
13283
|
+
break;
|
|
13284
|
+
case "failed":
|
|
13285
|
+
s.failed.push(o.repo);
|
|
13286
|
+
break;
|
|
13287
|
+
case "found":
|
|
13288
|
+
for (const file of o.marked)
|
|
13289
|
+
s.conflicted.push(inRun(o.repo, file));
|
|
13290
|
+
for (const site2 of o.behind)
|
|
13291
|
+
s.failed.push(`${site2 === "." ? o.repo : inRun(o.repo, site2)} (not at ${o.version})`);
|
|
13292
|
+
if (o.failed !== void 0)
|
|
13293
|
+
s.failed.push(o.repo);
|
|
13294
|
+
if (o.pull)
|
|
13295
|
+
s.pulls.push(o.pull);
|
|
13296
|
+
if (o.opening)
|
|
13297
|
+
s.opening.push(`${o.repo} ${versionBranch(o.version)}`);
|
|
13298
|
+
if (o.pull && o.mergeable)
|
|
13299
|
+
s.mergeable.push(o.pull);
|
|
13300
|
+
if (o.review && "failed" in o.review)
|
|
13301
|
+
s.failed.push(`${o.repo} (review request)`);
|
|
13302
|
+
break;
|
|
13303
|
+
case "taken": {
|
|
13304
|
+
const t = o.taken;
|
|
13305
|
+
for (const site2 of t.sites)
|
|
13306
|
+
s[site2.outcome].push(site2.rel);
|
|
13307
|
+
const conflicted = t.sites.filter((x) => x.outcome === "conflicted").map((x) => x.rel);
|
|
13308
|
+
for (const file of t.marked ?? []) {
|
|
13309
|
+
const path3 = inRun(t.rel, file);
|
|
13310
|
+
if (!conflicted.some((site2) => site2 === "." || path3 === site2 || path3.startsWith(`${site2}/`)))
|
|
13311
|
+
s.conflicted.push(path3);
|
|
13312
|
+
}
|
|
13313
|
+
if (t.lockfile === "failed")
|
|
13314
|
+
s.failed.push(`${t.rel}/pnpm-lock.yaml`);
|
|
13315
|
+
if (t.failed !== void 0)
|
|
13316
|
+
s.failed.push(t.rel);
|
|
13317
|
+
if (t.pull)
|
|
13318
|
+
s.pulls.push(t.pull.url ?? `${t.rel} ${t.pull.branch}`);
|
|
13319
|
+
if (t.pull?.url && !t.pull.draft && !needsHand(t))
|
|
13320
|
+
s.mergeable.push(t.pull.url);
|
|
13321
|
+
if (t.review && "failed" in t.review)
|
|
13322
|
+
s.failed.push(`${t.rel} (review request)`);
|
|
13323
|
+
break;
|
|
13324
|
+
}
|
|
13325
|
+
}
|
|
13326
|
+
}
|
|
13327
|
+
return s;
|
|
13328
|
+
}
|
|
12716
13329
|
function mergeLine(urls) {
|
|
12717
13330
|
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
13331
|
}
|
|
12719
|
-
function renderSummary(s, realCommand, verb = "
|
|
13332
|
+
function renderSummary(s, realCommand, verb = "update") {
|
|
12720
13333
|
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
13334
|
for (const p of s.clean)
|
|
12722
13335
|
lines.push(` \u2713 clean: ${p}`);
|
|
@@ -12730,11 +13343,13 @@ function renderSummary(s, realCommand, verb = "propagate") {
|
|
|
12730
13343
|
lines.push(` \u2022 resting: ${path3} (${reason})`);
|
|
12731
13344
|
for (const url of s.pulls)
|
|
12732
13345
|
lines.push(` \u2192 pull: ${url}`);
|
|
13346
|
+
for (const branch of s.opening)
|
|
13347
|
+
lines.push(` \u2192 to open: ${branch}`);
|
|
12733
13348
|
const merge2 = s.preview ? "" : mergeLine(s.mergeable);
|
|
12734
13349
|
if (merge2)
|
|
12735
13350
|
lines.push(" the clean ones, to merge once their checks pass:", ` ${merge2}`);
|
|
12736
13351
|
const clean = isClean(s);
|
|
12737
|
-
const idle = clean && s.clean.length === 0;
|
|
13352
|
+
const idle = clean && s.clean.length === 0 && s.opening.length === 0;
|
|
12738
13353
|
if (s.preview && !idle) {
|
|
12739
13354
|
lines.push(" (preview only \u2014 nothing was changed)");
|
|
12740
13355
|
if (clean)
|
|
@@ -12749,8 +13364,8 @@ function renderSummary(s, realCommand, verb = "propagate") {
|
|
|
12749
13364
|
|
|
12750
13365
|
// ../lib/dist/umbrella.js
|
|
12751
13366
|
var import_semver = __toESM(require_semver2(), 1);
|
|
12752
|
-
var
|
|
12753
|
-
import { join as
|
|
13367
|
+
var import_yaml7 = __toESM(require_dist(), 1);
|
|
13368
|
+
import { join as join11 } from "node:path";
|
|
12754
13369
|
var UMBRELLA_MARK = "Generated by `plx umbrella up`; `plx umbrella down` removes it.";
|
|
12755
13370
|
var UMBRELLA_STATE = ".plx-umbrella";
|
|
12756
13371
|
var UMBRELLA_ROOT_VAR = "PLX_UMBRELLA_ROOT";
|
|
@@ -12793,7 +13408,7 @@ function mergeWorkspaces(repos2) {
|
|
|
12793
13408
|
let settings = {};
|
|
12794
13409
|
const seen = {};
|
|
12795
13410
|
for (const repo of repos2) {
|
|
12796
|
-
const own = (0,
|
|
13411
|
+
const own = (0, import_yaml7.parse)(repo.workspace);
|
|
12797
13412
|
const { packages: globs, ...rest } = isMapping2(own) ? own : {};
|
|
12798
13413
|
packages.push(repo.name);
|
|
12799
13414
|
for (const glob of Array.isArray(globs) ? globs.map(String) : [])
|
|
@@ -12863,16 +13478,16 @@ function planUp(dir, repos2) {
|
|
|
12863
13478
|
const linked = [...new Set(links.filter((l) => l.linked).map((l) => l.to))].sort();
|
|
12864
13479
|
const has = (script) => (name) => packages.get(name)?.scripts.includes(script) === true;
|
|
12865
13480
|
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(
|
|
13481
|
+
const pnpm = { cwd: join11(dir, newestPnpm(repos2) ?? ""), env: { [WORKSPACE_VAR]: dir } };
|
|
13482
|
+
const state = join11(dir, UMBRELLA_STATE);
|
|
13483
|
+
const log = join11(state, "watch.log");
|
|
13484
|
+
const start = `set -m; nohup pnpm ${[...filters(watched), "--parallel", "run", "dev"].join(" ")} > ${quoted(log)} 2>&1 & echo $! > ${quoted(join11(state, "watch.pid"))}`;
|
|
12870
13485
|
const plan = [
|
|
12871
13486
|
stopWatcher(dir),
|
|
12872
|
-
run("mkdir", ["-p",
|
|
12873
|
-
write(
|
|
12874
|
-
${(0,
|
|
12875
|
-
write(
|
|
13487
|
+
run("mkdir", ["-p", join11(dir, UMBRELLA_STATE)]),
|
|
13488
|
+
write(join11(dir, WORKSPACE), `# ${UMBRELLA_MARK}
|
|
13489
|
+
${(0, import_yaml7.stringify)(settings)}`),
|
|
13490
|
+
write(join11(dir, MISE), `# ${UMBRELLA_MARK}
|
|
12876
13491
|
[env]
|
|
12877
13492
|
${UMBRELLA_ROOT_VAR} = "{{config_root}}"
|
|
12878
13493
|
${WORKSPACE_VAR} = "{{config_root}}"
|
|
@@ -12898,7 +13513,7 @@ function planDown(dir, repos2) {
|
|
|
12898
13513
|
stopWatcher(dir),
|
|
12899
13514
|
run("rm", ["-rf", UMBRELLA_STATE, "node_modules", "pnpm-lock.yaml", WORKSPACE, MISE], { cwd: dir }),
|
|
12900
13515
|
// The variable names the repo itself, whatever a shell under the umbrella still carries.
|
|
12901
|
-
...repos2.map((repo) => run("pnpm", ["install", "--force"], { cwd:
|
|
13516
|
+
...repos2.map((repo) => run("pnpm", ["install", "--force"], { cwd: join11(dir, repo), env: { [WORKSPACE_VAR]: join11(dir, repo) } }))
|
|
12902
13517
|
];
|
|
12903
13518
|
}
|
|
12904
13519
|
async function readOptional(ctx, path3) {
|
|
@@ -12919,21 +13534,21 @@ async function expand2(ctx, root, glob) {
|
|
|
12919
13534
|
if (star < 0)
|
|
12920
13535
|
return [glob.replace(/\/$/, "")];
|
|
12921
13536
|
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) =>
|
|
13537
|
+
const entries = await ctx.readDir(join11(root, parent)).catch(() => []);
|
|
13538
|
+
return entries.filter((e) => e.directory && !e.name.startsWith(".")).map((e) => join11(parent, e.name));
|
|
12924
13539
|
}
|
|
12925
13540
|
async function readRepo2(ctx, dir, name, workspace) {
|
|
12926
|
-
const own = (0,
|
|
13541
|
+
const own = (0, import_yaml7.parse)(workspace);
|
|
12927
13542
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
12928
13543
|
const packages = [];
|
|
12929
13544
|
for (const glob of globs.filter((g) => !g.startsWith("!"))) {
|
|
12930
|
-
for (const pkgDir of (await expand2(ctx,
|
|
12931
|
-
const manifest2 = await readManifest(ctx,
|
|
13545
|
+
for (const pkgDir of (await expand2(ctx, join11(dir, name), glob)).sort()) {
|
|
13546
|
+
const manifest2 = await readManifest(ctx, join11(dir, name, pkgDir, "package.json"));
|
|
12932
13547
|
if (!manifest2)
|
|
12933
13548
|
continue;
|
|
12934
13549
|
packages.push({
|
|
12935
13550
|
repo: name,
|
|
12936
|
-
dir:
|
|
13551
|
+
dir: join11(name, pkgDir),
|
|
12937
13552
|
name: manifest2.name,
|
|
12938
13553
|
version: manifest2.version,
|
|
12939
13554
|
scripts: Object.keys(manifest2.scripts ?? {}),
|
|
@@ -12946,13 +13561,13 @@ async function readRepo2(ctx, dir, name, workspace) {
|
|
|
12946
13561
|
});
|
|
12947
13562
|
}
|
|
12948
13563
|
}
|
|
12949
|
-
const root = await readManifest(ctx,
|
|
13564
|
+
const root = await readManifest(ctx, join11(dir, name, "package.json"));
|
|
12950
13565
|
return { name, workspace, packageManager: root?.packageManager, packages };
|
|
12951
13566
|
}
|
|
12952
13567
|
async function generated(ctx, dir) {
|
|
12953
13568
|
const [workspace, mise] = await Promise.all([
|
|
12954
|
-
readOptional(ctx,
|
|
12955
|
-
readOptional(ctx,
|
|
13569
|
+
readOptional(ctx, join11(dir, WORKSPACE)),
|
|
13570
|
+
readOptional(ctx, join11(dir, MISE))
|
|
12956
13571
|
]);
|
|
12957
13572
|
const marked = (text) => text?.startsWith(`# ${UMBRELLA_MARK}`) === true;
|
|
12958
13573
|
const foreign = [
|
|
@@ -12972,10 +13587,10 @@ async function readUmbrella(ctx, dir, only) {
|
|
|
12972
13587
|
continue;
|
|
12973
13588
|
if (only && !only.includes(entry.name))
|
|
12974
13589
|
continue;
|
|
12975
|
-
const names = (await ctx.readDir(
|
|
13590
|
+
const names = (await ctx.readDir(join11(dir, entry.name)).catch(() => [])).map((e) => e.name);
|
|
12976
13591
|
if (!names.includes(".git") || !names.includes(WORKSPACE))
|
|
12977
13592
|
continue;
|
|
12978
|
-
repos2.push(await readRepo2(ctx, dir, entry.name, await ctx.readFile(
|
|
13593
|
+
repos2.push(await readRepo2(ctx, dir, entry.name, await ctx.readFile(join11(dir, entry.name, WORKSPACE))));
|
|
12979
13594
|
}
|
|
12980
13595
|
const paths = (only ?? []).filter((name) => name.includes("/"));
|
|
12981
13596
|
if (paths.length > 0)
|
|
@@ -12993,7 +13608,7 @@ async function readUmbrellaDown(ctx, dir) {
|
|
|
12993
13608
|
throw refuse(dir, foreign);
|
|
12994
13609
|
if (!up)
|
|
12995
13610
|
return { repos: [], plan: [] };
|
|
12996
|
-
const own = (0,
|
|
13611
|
+
const own = (0, import_yaml7.parse)(await ctx.readFile(join11(dir, WORKSPACE)));
|
|
12997
13612
|
const globs = isMapping2(own) && Array.isArray(own.packages) ? own.packages.map(String) : [];
|
|
12998
13613
|
const repos2 = globs.filter((g) => !g.includes("/") && !g.startsWith("!"));
|
|
12999
13614
|
return { repos: repos2, plan: planDown(dir, repos2) };
|
|
@@ -13760,7 +14375,7 @@ var getClosingCode = (openingCode) => {
|
|
|
13760
14375
|
return 0;
|
|
13761
14376
|
return void 0;
|
|
13762
14377
|
};
|
|
13763
|
-
var wrapAnsiCode = (
|
|
14378
|
+
var wrapAnsiCode = (code2) => `${ESC}${ANSI_CSI}${code2}${ANSI_SGR_TERMINATOR}`;
|
|
13764
14379
|
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
13765
14380
|
var wrapWord = (rows, word, columns) => {
|
|
13766
14381
|
const characters = word[Symbol.iterator]();
|
|
@@ -13903,8 +14518,8 @@ var exec = (string, columns, options = {}) => {
|
|
|
13903
14518
|
const groupsResult = GROUP_REGEX.exec(preString);
|
|
13904
14519
|
const groups = groupsResult?.groups;
|
|
13905
14520
|
if (groups?.code !== void 0) {
|
|
13906
|
-
const
|
|
13907
|
-
escapeCode =
|
|
14521
|
+
const code2 = Number.parseFloat(groups.code);
|
|
14522
|
+
escapeCode = code2 === END_CODE ? void 0 : code2;
|
|
13908
14523
|
} else if (groups?.uri !== void 0) {
|
|
13909
14524
|
escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
|
|
13910
14525
|
}
|
|
@@ -13947,13 +14562,13 @@ import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
|
13947
14562
|
|
|
13948
14563
|
// ../../node_modules/.pnpm/@inquirer+type@4.3.0_@types+node@24.19.2/node_modules/@inquirer/type/dist/utils.js
|
|
13949
14564
|
function withResolver() {
|
|
13950
|
-
let
|
|
14565
|
+
let resolve10;
|
|
13951
14566
|
let reject;
|
|
13952
14567
|
const promise = new Promise((res, rej) => {
|
|
13953
|
-
|
|
14568
|
+
resolve10 = res;
|
|
13954
14569
|
reject = rej;
|
|
13955
14570
|
});
|
|
13956
|
-
return { promise, resolve:
|
|
14571
|
+
return { promise, resolve: resolve10, reject };
|
|
13957
14572
|
}
|
|
13958
14573
|
|
|
13959
14574
|
// ../../node_modules/.pnpm/@inquirer+core@12.1.0_@types+node@24.19.2/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
@@ -14025,17 +14640,17 @@ var Emitter = class {
|
|
|
14025
14640
|
list2.splice(i, 1);
|
|
14026
14641
|
}
|
|
14027
14642
|
}
|
|
14028
|
-
emit(ev,
|
|
14643
|
+
emit(ev, code2, signal) {
|
|
14029
14644
|
if (this.emitted[ev]) {
|
|
14030
14645
|
return false;
|
|
14031
14646
|
}
|
|
14032
14647
|
this.emitted[ev] = true;
|
|
14033
14648
|
let ret = false;
|
|
14034
14649
|
for (const fn of this.listeners[ev]) {
|
|
14035
|
-
ret = fn(
|
|
14650
|
+
ret = fn(code2, signal) === true || ret;
|
|
14036
14651
|
}
|
|
14037
14652
|
if (ev === "exit") {
|
|
14038
|
-
ret = this.emit("afterExit",
|
|
14653
|
+
ret = this.emit("afterExit", code2, signal) || ret;
|
|
14039
14654
|
}
|
|
14040
14655
|
return ret;
|
|
14041
14656
|
}
|
|
@@ -14135,8 +14750,8 @@ var SignalExit = class extends SignalExitBase {
|
|
|
14135
14750
|
this.#process.emit = (ev, ...a) => {
|
|
14136
14751
|
return this.#processEmit(ev, ...a);
|
|
14137
14752
|
};
|
|
14138
|
-
this.#process.reallyExit = (
|
|
14139
|
-
return this.#processReallyExit(
|
|
14753
|
+
this.#process.reallyExit = (code2) => {
|
|
14754
|
+
return this.#processReallyExit(code2);
|
|
14140
14755
|
};
|
|
14141
14756
|
}
|
|
14142
14757
|
unload() {
|
|
@@ -14158,11 +14773,11 @@ var SignalExit = class extends SignalExitBase {
|
|
|
14158
14773
|
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
14159
14774
|
this.#emitter.count -= 1;
|
|
14160
14775
|
}
|
|
14161
|
-
#processReallyExit(
|
|
14776
|
+
#processReallyExit(code2) {
|
|
14162
14777
|
if (!processOk(this.#process)) {
|
|
14163
14778
|
return 0;
|
|
14164
14779
|
}
|
|
14165
|
-
this.#process.exitCode =
|
|
14780
|
+
this.#process.exitCode = code2 || 0;
|
|
14166
14781
|
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
14167
14782
|
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
14168
14783
|
}
|
|
@@ -14332,7 +14947,7 @@ function createPrompt(view) {
|
|
|
14332
14947
|
});
|
|
14333
14948
|
output.mute();
|
|
14334
14949
|
const screen = new ScreenManager(rl);
|
|
14335
|
-
const { promise, resolve:
|
|
14950
|
+
const { promise, resolve: resolve10, reject } = withResolver();
|
|
14336
14951
|
return withHooks(rl, (cycle) => {
|
|
14337
14952
|
const clearEffects = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
14338
14953
|
const settlePrompt = (settle) => {
|
|
@@ -14343,7 +14958,7 @@ function createPrompt(view) {
|
|
|
14343
14958
|
reject(error);
|
|
14344
14959
|
}
|
|
14345
14960
|
};
|
|
14346
|
-
const resolvePrompt = (value) => settlePrompt(() =>
|
|
14961
|
+
const resolvePrompt = (value) => settlePrompt(() => resolve10(value));
|
|
14347
14962
|
const rejectPrompt = (error) => settlePrompt(() => reject(error));
|
|
14348
14963
|
const promptPromise = Object.assign(promise.finally(() => {
|
|
14349
14964
|
cleanups2.forEach((cleanup) => cleanup());
|
|
@@ -14358,8 +14973,8 @@ function createPrompt(view) {
|
|
|
14358
14973
|
}
|
|
14359
14974
|
cleanups2.add(listenTo(signal, "abort", abort));
|
|
14360
14975
|
}
|
|
14361
|
-
cleanups2.add(onExit((
|
|
14362
|
-
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${
|
|
14976
|
+
cleanups2.add(onExit((code2, signal2) => {
|
|
14977
|
+
rejectPrompt(new ExitPromptError(`User force closed the prompt with ${code2} ${signal2}`));
|
|
14363
14978
|
}));
|
|
14364
14979
|
cleanups2.add(listenTo(rl, "SIGINT", () => rejectPrompt(new ExitPromptError(`User force closed the prompt with SIGINT`))));
|
|
14365
14980
|
cleanups2.add(listenTo(rl, "close", clearEffects));
|
|
@@ -14502,11 +15117,11 @@ var CommanderError = class extends Error {
|
|
|
14502
15117
|
* @param {string} code an id string representing the error
|
|
14503
15118
|
* @param {string} message human-readable description of the error
|
|
14504
15119
|
*/
|
|
14505
|
-
constructor(exitCode,
|
|
15120
|
+
constructor(exitCode, code2, message) {
|
|
14506
15121
|
super(message);
|
|
14507
15122
|
Error.captureStackTrace(this, this.constructor);
|
|
14508
15123
|
this.name = this.constructor.name;
|
|
14509
|
-
this.code =
|
|
15124
|
+
this.code = code2;
|
|
14510
15125
|
this.exitCode = exitCode;
|
|
14511
15126
|
this.nestedError = void 0;
|
|
14512
15127
|
}
|
|
@@ -15923,8 +16538,8 @@ var Command = class _Command extends EventEmitter {
|
|
|
15923
16538
|
* @return {Command} `this` command for chaining
|
|
15924
16539
|
*/
|
|
15925
16540
|
arguments(names) {
|
|
15926
|
-
names.trim().split(/ +/).forEach((
|
|
15927
|
-
this.argument(
|
|
16541
|
+
names.trim().split(/ +/).forEach((detail) => {
|
|
16542
|
+
this.argument(detail);
|
|
15928
16543
|
});
|
|
15929
16544
|
return this;
|
|
15930
16545
|
}
|
|
@@ -16063,9 +16678,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
16063
16678
|
* @return never
|
|
16064
16679
|
* @private
|
|
16065
16680
|
*/
|
|
16066
|
-
_exit(exitCode,
|
|
16681
|
+
_exit(exitCode, code2, message) {
|
|
16067
16682
|
if (this._exitCallback) {
|
|
16068
|
-
this._exitCallback(new CommanderError(exitCode,
|
|
16683
|
+
this._exitCallback(new CommanderError(exitCode, code2, message));
|
|
16069
16684
|
}
|
|
16070
16685
|
process4.exit(exitCode);
|
|
16071
16686
|
}
|
|
@@ -16705,14 +17320,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
16705
17320
|
});
|
|
16706
17321
|
}
|
|
16707
17322
|
const exitCallback = this._exitCallback;
|
|
16708
|
-
proc.on("close", (
|
|
16709
|
-
|
|
17323
|
+
proc.on("close", (code2) => {
|
|
17324
|
+
code2 = code2 ?? 1;
|
|
16710
17325
|
if (!exitCallback) {
|
|
16711
|
-
process4.exit(
|
|
17326
|
+
process4.exit(code2);
|
|
16712
17327
|
} else {
|
|
16713
17328
|
exitCallback(
|
|
16714
17329
|
new CommanderError(
|
|
16715
|
-
|
|
17330
|
+
code2,
|
|
16716
17331
|
"commander.executeSubCommandAsync",
|
|
16717
17332
|
"(close)"
|
|
16718
17333
|
)
|
|
@@ -17219,8 +17834,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
17219
17834
|
}
|
|
17220
17835
|
const config = errorOptions || {};
|
|
17221
17836
|
const exitCode = config.exitCode || 1;
|
|
17222
|
-
const
|
|
17223
|
-
this._exit(exitCode,
|
|
17837
|
+
const code2 = config.code || "commander.error";
|
|
17838
|
+
this._exit(exitCode, code2, message);
|
|
17224
17839
|
}
|
|
17225
17840
|
/**
|
|
17226
17841
|
* Apply any option related environment variables, if option does
|
|
@@ -17889,7 +18504,13 @@ import { resolve as resolve3 } from "node:path";
|
|
|
17889
18504
|
function register2(program2) {
|
|
17890
18505
|
program2.command("deploy").description(
|
|
17891
18506
|
"render the app\u2019s compose file with the image pinned, stage it on the host, pull, migrate, swap, up, wait for the healthcheck, roll back on failure"
|
|
17892
|
-
).argument("<host>", "ssh target, deploy@host").argument("<app>", "the app, apps/<app> in the checkout").option("--image <ref>", "the image ref to pin; absent for a third-party app whose compose.yaml pins its own").option(
|
|
18507
|
+
).argument("<host>", "ssh target, deploy@host").argument("<app>", "the app, apps/<app> in the checkout").option("--image <ref>", "the image ref to pin; absent for a third-party app whose compose.yaml pins its own").option(
|
|
18508
|
+
"--display-version <string>",
|
|
18509
|
+
"the string the app shows as its version, pinned where its compose.yaml uses ${PLEXUS_DISPLAY_VERSION}; ignored where it does not"
|
|
18510
|
+
).option(
|
|
18511
|
+
"--commit-sha <sha>",
|
|
18512
|
+
"the commit the deployment is started from, a full hash, pinned where its compose.yaml uses ${PLEXUS_COMMIT_SHA}; ignored where it does not"
|
|
18513
|
+
).option("--retries <n>", "looks at the app container\u2019s health status, two seconds apart", "30").option(
|
|
17893
18514
|
"-e, --environment <name>",
|
|
17894
18515
|
"the environment deployed into; decides the app dir\u2019s slug (default: production)"
|
|
17895
18516
|
).option(
|
|
@@ -17901,6 +18522,8 @@ function register2(program2) {
|
|
|
17901
18522
|
host,
|
|
17902
18523
|
app,
|
|
17903
18524
|
image: opts.image,
|
|
18525
|
+
displayVersion: opts.displayVersion,
|
|
18526
|
+
commitSha: opts.commitSha,
|
|
17904
18527
|
retries: Number(opts.retries),
|
|
17905
18528
|
environment: opts.environment,
|
|
17906
18529
|
appDir: opts.appDir,
|
|
@@ -17917,7 +18540,7 @@ function renderDeploy(d) {
|
|
|
17917
18540
|
}
|
|
17918
18541
|
|
|
17919
18542
|
// src/commands/deploy-targets.ts
|
|
17920
|
-
import { resolve as resolve4 } from "node:path";
|
|
18543
|
+
import { relative as relative5, resolve as resolve4 } from "node:path";
|
|
17921
18544
|
function register3(program2) {
|
|
17922
18545
|
program2.command("deploy-targets").description(
|
|
17923
18546
|
"map each app of a platform repo, per environment, to the deploy target of the inventory file that declares it"
|
|
@@ -17926,12 +18549,22 @@ function register3(program2) {
|
|
|
17926
18549
|
"with --environment: only the apps with a directory under <dir>, as a list of {app, host} for a matrix"
|
|
17927
18550
|
).action(async (inventory, opts, command) => {
|
|
17928
18551
|
const ctx = contextOf(command);
|
|
17929
|
-
const
|
|
18552
|
+
const files = await readInventory(ctx, resolve4(inventory));
|
|
18553
|
+
const targets = selectDeployTargets(files);
|
|
17930
18554
|
if (opts.apps !== void 0) {
|
|
17931
18555
|
if (!opts.environment) throw new UsageError("--apps needs --environment");
|
|
17932
18556
|
const dirs = (await ctx.readDir(resolve4(opts.apps)).catch(() => [])).filter((e) => e.directory).map((e) => e.name);
|
|
17933
|
-
const { legs, without } = deployLegs(
|
|
17934
|
-
|
|
18557
|
+
const { legs, untargeted, without } = deployLegs(
|
|
18558
|
+
targetsIn(targets, opts.environment),
|
|
18559
|
+
dirs,
|
|
18560
|
+
recordsWithoutTarget(files, opts.environment)
|
|
18561
|
+
);
|
|
18562
|
+
for (const app of without) ctx.say(`${app} has no record in ${opts.environment}; nothing to deploy`);
|
|
18563
|
+
if (untargeted.length > 0)
|
|
18564
|
+
throw untargetedError(
|
|
18565
|
+
untargeted.map((u) => ({ app: u.app, files: u.files.map((f) => relative5(process.cwd(), f)) })),
|
|
18566
|
+
opts.environment
|
|
18567
|
+
);
|
|
17935
18568
|
ctx.result(legs, (l) => JSON.stringify(l));
|
|
17936
18569
|
return;
|
|
17937
18570
|
}
|
|
@@ -17945,7 +18578,7 @@ import { resolve as resolve5 } from "node:path";
|
|
|
17945
18578
|
|
|
17946
18579
|
// src/style.ts
|
|
17947
18580
|
function style(enabled) {
|
|
17948
|
-
const wrap = (
|
|
18581
|
+
const wrap = (code2) => (s) => enabled ? `\x1B[${code2}m${s}\x1B[0m` : s;
|
|
17949
18582
|
return { dim: wrap(2), bold: wrap(1), ok: wrap(32), warn: wrap(33), info: wrap(36), note: wrap(35) };
|
|
17950
18583
|
}
|
|
17951
18584
|
var colorByDefault = () => process.stdout.isTTY === true && !process.env.NO_COLOR;
|
|
@@ -17973,7 +18606,8 @@ function renderReport(report, s, showPassing, given = report.root) {
|
|
|
17973
18606
|
const note = notes.filter(Boolean).join(", ");
|
|
17974
18607
|
if (showPassing) lines.push(`${s.ok("\u2713")} ${u.path}${note ? ` ${s.dim(`[${note}]`)}` : ""}`);
|
|
17975
18608
|
}
|
|
17976
|
-
for (const f of u.findings)
|
|
18609
|
+
for (const f of u.findings)
|
|
18610
|
+
lines.push(`${s.warn("\u2717")} ${f.requirement ? `${f.requirement} ` : ""}${u.path}: ${f.problem}`);
|
|
17977
18611
|
if (showPassing) for (const h of u.hints ?? []) lines.push(s.dim(`\u2022 ${u.path}: ${h}`));
|
|
17978
18612
|
}
|
|
17979
18613
|
if (report.skipped.length > 0)
|
|
@@ -18035,8 +18669,8 @@ function annotation(dir, kind, s) {
|
|
|
18035
18669
|
tags.push(s.info(`[copier ${dir.copier.commit ?? "?"} \u2190 ${src}]`));
|
|
18036
18670
|
}
|
|
18037
18671
|
if (kind) {
|
|
18038
|
-
const
|
|
18039
|
-
tags.push(s.bold(`[${kind}${
|
|
18672
|
+
const detail = kind === "app" ? dir.declaration?.profile : dir.pin;
|
|
18673
|
+
tags.push(s.bold(`[${kind}${detail ? ` ${detail}` : ""}]`));
|
|
18040
18674
|
}
|
|
18041
18675
|
if (dir.symlink) tags.push(s.dim("[symbolic link, not followed]"));
|
|
18042
18676
|
if (dir.unreadable) tags.push(s.warn(`[! cannot be read: ${dir.unreadable}]`));
|
|
@@ -18044,39 +18678,21 @@ function annotation(dir, kind, s) {
|
|
|
18044
18678
|
return tags.length ? ` ${tags.join(" ")}` : "";
|
|
18045
18679
|
}
|
|
18046
18680
|
|
|
18047
|
-
// src/commands/propagate.ts
|
|
18048
|
-
import { resolve as resolve7 } from "node:path";
|
|
18049
|
-
function register6(program2) {
|
|
18050
|
-
program2.command("propagate").description(
|
|
18051
|
-
"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"
|
|
18052
|
-
).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(
|
|
18053
|
-
"--max-age <days>",
|
|
18054
|
-
"the interval for every repo, in days (default: each repo's answer update_max_age, else 7; 0 takes every version)",
|
|
18055
|
-
(v) => parseMaxAge(v, "--max-age")
|
|
18056
|
-
).action(async (dir, opts, command) => {
|
|
18057
|
-
const ctx = contextOf(command);
|
|
18058
|
-
const result = await propagate(ctx, { dir: resolve7(dir), to: opts.to, now: opts.now, maxAge: opts.maxAge });
|
|
18059
|
-
const flags = [opts.to ? `--to ${opts.to}` : "", opts.now ? "--now" : ""].filter(Boolean).join(" ");
|
|
18060
|
-
ctx.result(result, (r) => renderSummary(r, `plx -y propagate ${flags} ${dir}`.replace(/ +/g, " ")));
|
|
18061
|
-
if (!isClean(result)) process.exitCode = 1;
|
|
18062
|
-
});
|
|
18063
|
-
}
|
|
18064
|
-
|
|
18065
18681
|
// src/commands/requirements.ts
|
|
18066
|
-
import { join as
|
|
18067
|
-
function
|
|
18682
|
+
import { join as join12, resolve as resolve7 } from "node:path";
|
|
18683
|
+
function register6(program2) {
|
|
18068
18684
|
program2.command("requirements").description(
|
|
18069
18685
|
"lint a repo: the standard's pages in the compendium, citations, dates, template headers and issue identifiers everywhere"
|
|
18070
18686
|
).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) => {
|
|
18071
18687
|
const ctx = contextOf(command);
|
|
18072
|
-
const repo =
|
|
18073
|
-
const options = { compendium: opts.compendium ?
|
|
18688
|
+
const repo = resolve7(dir);
|
|
18689
|
+
const options = { compendium: opts.compendium ? resolve7(opts.compendium) : void 0 };
|
|
18074
18690
|
if (opts.extract) {
|
|
18075
|
-
ctx.result(extractRequirements(await ctx.readFile(
|
|
18691
|
+
ctx.result(extractRequirements(await ctx.readFile(join12(repo, opts.extract))));
|
|
18076
18692
|
return;
|
|
18077
18693
|
}
|
|
18078
18694
|
if (opts.commitMsg) {
|
|
18079
|
-
const violations = await checkCommitMessage(ctx,
|
|
18695
|
+
const violations = await checkCommitMessage(ctx, resolve7(opts.commitMsg), repo);
|
|
18080
18696
|
ctx.result(violations, (vs) => vs.map(renderViolation).join("\n"));
|
|
18081
18697
|
if (violations.length > 0) process.exitCode = 1;
|
|
18082
18698
|
return;
|
|
@@ -18099,12 +18715,12 @@ function renderCheck(c) {
|
|
|
18099
18715
|
|
|
18100
18716
|
// src/commands/umbrella.ts
|
|
18101
18717
|
import { spawn as spawn2 } from "node:child_process";
|
|
18102
|
-
import { resolve as
|
|
18103
|
-
function
|
|
18718
|
+
import { resolve as resolve8 } from "node:path";
|
|
18719
|
+
function register7(program2) {
|
|
18104
18720
|
const umbrella = program2.command("umbrella").description("develop across repos: one pnpm workspace over the repos under a directory, linking their packages");
|
|
18105
18721
|
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) => {
|
|
18106
18722
|
const ctx = contextOf(command);
|
|
18107
|
-
const root =
|
|
18723
|
+
const root = resolve8(dir);
|
|
18108
18724
|
const plan = await readUmbrella(ctx, root, opts.only?.split(",").filter(Boolean));
|
|
18109
18725
|
await ctx.apply(plan.plan);
|
|
18110
18726
|
ctx.result(plan, renderUmbrella);
|
|
@@ -18118,7 +18734,7 @@ function register8(program2) {
|
|
|
18118
18734
|
await down(ctx, root);
|
|
18119
18735
|
});
|
|
18120
18736
|
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) => {
|
|
18121
|
-
await down(contextOf(command),
|
|
18737
|
+
await down(contextOf(command), resolve8(dir));
|
|
18122
18738
|
});
|
|
18123
18739
|
}
|
|
18124
18740
|
async function down(ctx, root) {
|
|
@@ -18151,18 +18767,28 @@ function renderUmbrella(u) {
|
|
|
18151
18767
|
}
|
|
18152
18768
|
|
|
18153
18769
|
// src/commands/update.ts
|
|
18154
|
-
import { resolve as
|
|
18155
|
-
function
|
|
18770
|
+
import { resolve as resolve9 } from "node:path";
|
|
18771
|
+
function register8(program2) {
|
|
18156
18772
|
program2.command("update").description(
|
|
18157
|
-
"take a version as a pull request on plexus/<version> (copier update at every site, the
|
|
18158
|
-
).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(
|
|
18773
|
+
"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"
|
|
18774
|
+
).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(
|
|
18159
18775
|
"--max-age <days>",
|
|
18160
18776
|
"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)",
|
|
18161
18777
|
(v) => parseMaxAge(v, "--max-age")
|
|
18778
|
+
).option(
|
|
18779
|
+
"--reviewer <login>",
|
|
18780
|
+
"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)",
|
|
18781
|
+
(v, previous = []) => [...previous, ...parseReviewers(v, "--reviewer")]
|
|
18162
18782
|
).action(async (dir, opts, command) => {
|
|
18163
18783
|
const ctx = contextOf(command);
|
|
18164
|
-
const
|
|
18165
|
-
|
|
18784
|
+
const { recursive, reviewer, ...asked } = opts;
|
|
18785
|
+
const options = { ...asked, ...reviewer ? { reviewers: [...new Set(reviewer)] } : {} };
|
|
18786
|
+
const outcomes = recursive ? await updateRecursive(ctx, { dir: resolve9(dir), ...options }) : [await update(ctx, { repo: resolve9(dir), ...options })];
|
|
18787
|
+
const result = summarize(outcomes, ctx.dryRun, opts.to);
|
|
18788
|
+
const flags = recursive ? ["-r", opts.to ? `--to ${opts.to}` : "", opts.now ? "--now" : ""] : [`--to ${result.version}`];
|
|
18789
|
+
if (reviewer) flags.push(`--reviewer '${[...new Set(reviewer)].join(",")}'`);
|
|
18790
|
+
const real = `plx -y update ${flags.filter(Boolean).join(" ")} ${dir}`;
|
|
18791
|
+
ctx.result(result, (r) => renderSummary(r, real, recursive ? "update --recursive" : "update"));
|
|
18166
18792
|
if (!isClean(result)) process.exitCode = 1;
|
|
18167
18793
|
});
|
|
18168
18794
|
}
|
|
@@ -18171,10 +18797,9 @@ function register9(program2) {
|
|
|
18171
18797
|
var commands = [
|
|
18172
18798
|
register5,
|
|
18173
18799
|
register4,
|
|
18174
|
-
register6,
|
|
18175
|
-
register9,
|
|
18176
18800
|
register8,
|
|
18177
18801
|
register7,
|
|
18802
|
+
register6,
|
|
18178
18803
|
register,
|
|
18179
18804
|
register3,
|
|
18180
18805
|
register2
|
|
@@ -18187,7 +18812,7 @@ function buildProgram() {
|
|
|
18187
18812
|
program2.addOption(new Option("-n, --dry-run", "print every effect this run would have, perform none").env("PLX_DRY_RUN")).addOption(
|
|
18188
18813
|
new Option("-v, --verbose", "say more: once for reads and inputs, twice for command output").argParser((_value, previous) => previous + 1).default(0)
|
|
18189
18814
|
).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"));
|
|
18190
|
-
for (const
|
|
18815
|
+
for (const register9 of commands) register9(program2);
|
|
18191
18816
|
return program2;
|
|
18192
18817
|
}
|
|
18193
18818
|
function contextOf(command) {
|