@radicaltools/cli 0.5.0 → 0.6.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/{chunk-J5ULJOOY.js → chunk-CWKX2ULF.js} +1 -1
- package/dist/{dist-TKLLLHVM.js → dist-KTTOUFHF.js} +2 -2
- package/dist/hub-catalogue/concern/concern-accessibility.radical +871 -0
- package/dist/hub-catalogue/concern/concern-ci-cd-pipeline.radical +975 -0
- package/dist/hub-catalogue/concern/concern-frontend-stack.radical +84 -311
- package/dist/hub-catalogue/concern/concern-mobile-performance.radical +710 -0
- package/dist/hub-catalogue/concern/concern-release-versioning.radical +294 -57
- package/dist/hub-catalogue/concern/concern-test-strategy.radical +1 -1
- package/dist/hub-catalogue/concern/concern-usability.radical +1266 -0
- package/dist/index.js +1019 -261
- package/dist/{pdfjs-SWTQBTNZ.js → pdfjs-ABY3IR7F.js} +1 -1
- package/dist/{undici-ZXQJUQQA.js → undici-7Z7ZFI7Q.js} +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
define_RADICAL_BUILD_default,
|
|
4
4
|
init_define_RADICAL_BUILD
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CWKX2ULF.js";
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
init_define_RADICAL_BUILD();
|
|
9
|
-
import { spawn as
|
|
9
|
+
import { spawn as spawn10 } from "child_process";
|
|
10
10
|
import { createInterface } from "readline/promises";
|
|
11
11
|
|
|
12
12
|
// src/cli.ts
|
|
@@ -2677,10 +2677,10 @@ function filterRuns(filters) {
|
|
|
2677
2677
|
function applyFilters(source, filters, ctx) {
|
|
2678
2678
|
let nodes = source;
|
|
2679
2679
|
const counts = [];
|
|
2680
|
-
for (const
|
|
2681
|
-
const on2 =
|
|
2680
|
+
for (const run3 of filterRuns(filters)) {
|
|
2681
|
+
const on2 = run3.map((i) => filters[i]).filter((f) => !f.off);
|
|
2682
2682
|
if (on2.length) nodes = nodes.filter((n) => on2.some((f) => matchesFilter(f, n, ctx)));
|
|
2683
|
-
for (const i of
|
|
2683
|
+
for (const i of run3) counts[i] = nodes.length;
|
|
2684
2684
|
}
|
|
2685
2685
|
return { nodes, counts };
|
|
2686
2686
|
}
|
|
@@ -4042,7 +4042,7 @@ var MdFolderSession = class {
|
|
|
4042
4042
|
/** Lists the files after an open from the cache: those that differ are
|
|
4043
4043
|
* read into the baseline's place for them by the next read. */
|
|
4044
4044
|
verifyLater() {
|
|
4045
|
-
const
|
|
4045
|
+
const run3 = this.tail.then(async () => {
|
|
4046
4046
|
this.running++;
|
|
4047
4047
|
try {
|
|
4048
4048
|
const stamps = await this.storage.list();
|
|
@@ -4056,9 +4056,9 @@ var MdFolderSession = class {
|
|
|
4056
4056
|
this.running--;
|
|
4057
4057
|
}
|
|
4058
4058
|
});
|
|
4059
|
-
this.tail =
|
|
4059
|
+
this.tail = run3.catch(() => {
|
|
4060
4060
|
});
|
|
4061
|
-
return
|
|
4061
|
+
return run3;
|
|
4062
4062
|
}
|
|
4063
4063
|
/** Brings the cache up to the baseline: changes.json, or model.json
|
|
4064
4064
|
* again when it is missing or more files differ from it than it can
|
|
@@ -4067,7 +4067,7 @@ var MdFolderSession = class {
|
|
|
4067
4067
|
keepCache() {
|
|
4068
4068
|
if (this.options.writeCache === false || !this.storage.writeCache) return;
|
|
4069
4069
|
if (!isValidMdFolderManifest(this.baseline.get(MD_MANIFEST_FILE)?.content)) return;
|
|
4070
|
-
const
|
|
4070
|
+
const run3 = this.tail.then(async () => {
|
|
4071
4071
|
this.running++;
|
|
4072
4072
|
try {
|
|
4073
4073
|
const files = {};
|
|
@@ -4085,8 +4085,8 @@ var MdFolderSession = class {
|
|
|
4085
4085
|
this.running--;
|
|
4086
4086
|
}
|
|
4087
4087
|
});
|
|
4088
|
-
this.tail =
|
|
4089
|
-
this.cacheWrite =
|
|
4088
|
+
this.tail = run3;
|
|
4089
|
+
this.cacheWrite = run3;
|
|
4090
4090
|
}
|
|
4091
4091
|
/** Resolves once the cache is written as far as the session has gone. */
|
|
4092
4092
|
cacheWritten() {
|
|
@@ -4151,14 +4151,14 @@ var MdFolderSession = class {
|
|
|
4151
4151
|
}
|
|
4152
4152
|
exclusive(fn) {
|
|
4153
4153
|
this.running++;
|
|
4154
|
-
const
|
|
4155
|
-
this.tail =
|
|
4154
|
+
const run3 = this.tail.then(fn, fn);
|
|
4155
|
+
this.tail = run3.catch(() => {
|
|
4156
4156
|
});
|
|
4157
4157
|
const done = () => {
|
|
4158
4158
|
this.running--;
|
|
4159
4159
|
};
|
|
4160
|
-
|
|
4161
|
-
return
|
|
4160
|
+
run3.then(done, done);
|
|
4161
|
+
return run3;
|
|
4162
4162
|
}
|
|
4163
4163
|
};
|
|
4164
4164
|
function sameStamps(a2, b) {
|
|
@@ -4186,7 +4186,7 @@ init_define_RADICAL_BUILD();
|
|
|
4186
4186
|
|
|
4187
4187
|
// ../../packages/common/src/check/sensors.ts
|
|
4188
4188
|
init_define_RADICAL_BUILD();
|
|
4189
|
-
var SENSOR_NAMES = ["command", "json", "playwright"];
|
|
4189
|
+
var SENSOR_NAMES = ["command", "github-actions", "json", "lighthouse", "machine", "playwright"];
|
|
4190
4190
|
function commandWords(line) {
|
|
4191
4191
|
const words = [];
|
|
4192
4192
|
let word = "";
|
|
@@ -4584,6 +4584,7 @@ function parseMeasurementStore(text3) {
|
|
|
4584
4584
|
var TEST_LINE = /^test\((.+)\)(?:\s+passed)?$/;
|
|
4585
4585
|
var REVIEW_LINE = /^review\((.+)\)\s+passed$/i;
|
|
4586
4586
|
var REVIEW_METRIC = "review";
|
|
4587
|
+
var SCALED = /\s+scaled$/i;
|
|
4587
4588
|
var METRIC_LINE = /^([A-Za-z_][\w.:/-]*)\s*(?:\{([^}]*)\})?\s*(<=|>=|==|!=|=|<|>)\s*(-?\d+(?:\.\d+)?(?:e-?\d+)?)\s*(\S+)?$/i;
|
|
4588
4589
|
var BASELINE_LINE = /^([A-Za-z_][\w.:/-]*)\s*(?:\{([^}]*)\})?\s*(<=|>=|==|!=|=|<|>)\s*baseline(?:\s*([+-])\s*(\d+(?:\.\d+)?(?:e-?\d+)?)\s*(%|[^\s%]+)?)?$/i;
|
|
4589
4590
|
function parseLabels(text3) {
|
|
@@ -4612,11 +4613,14 @@ function parseCondition(line) {
|
|
|
4612
4613
|
const baseline = b[4] ? { sign: b[4] === "-" ? -1 : 1, by: Number(b[5]), percent: b[6] === "%", ...b[6] !== "%" ? { unit: b[6] } : {} } : { sign: 1, by: 0, percent: true };
|
|
4613
4614
|
return { kind: "metric", raw, metric: b[1], labels: labels2, op: b[3] === "=" ? "==" : b[3], value: Number.NaN, baseline };
|
|
4614
4615
|
}
|
|
4615
|
-
const
|
|
4616
|
-
|
|
4616
|
+
const scaled = SCALED.test(raw);
|
|
4617
|
+
const m = METRIC_LINE.exec(scaled ? raw.replace(SCALED, "") : raw);
|
|
4618
|
+
if (!m) return { kind: "invalid", raw, problem: "it is neither `test(<file> \u203A <title>) passed`, `review(<name>) passed`, `<metric>{<labels>} <op> <number> [unit] [scaled]` nor `<metric>{<labels>} <op> baseline [+|- <number> %|unit]`" };
|
|
4617
4619
|
const labels = m[2] === void 0 ? {} : parseLabels(m[2]);
|
|
4618
4620
|
if (typeof labels === "string") return { kind: "invalid", raw, problem: labels };
|
|
4619
|
-
|
|
4621
|
+
const op = m[3] === "=" ? "==" : m[3];
|
|
4622
|
+
if (scaled && (op === "==" || op === "!=")) return { kind: "invalid", raw, problem: "scaled stretches a limit: it takes <, <=, > or >=, not == or !=" };
|
|
4623
|
+
return { kind: "metric", raw, metric: m[1], labels, op, value: Number(m[4]), ...m[5] ? { unit: m[5] } : {}, ...scaled ? { scaled: true } : {} };
|
|
4620
4624
|
}
|
|
4621
4625
|
function parseConditions(text3) {
|
|
4622
4626
|
if (typeof text3 !== "string") return [];
|
|
@@ -4680,6 +4684,25 @@ function baselineOf(condition2, baseline, unit) {
|
|
|
4680
4684
|
return { median: values.length % 2 ? values[mid] : (values[mid - 1] + values[mid]) / 2, runs: values.length };
|
|
4681
4685
|
}
|
|
4682
4686
|
var round = (n) => Math.round(n * 100) / 100;
|
|
4687
|
+
var MACHINE_WORK_METRIC = "machine.work";
|
|
4688
|
+
var MACHINE_SPEED_METRIC = "machine.speed";
|
|
4689
|
+
function machineSpeedAt(measurements, at) {
|
|
4690
|
+
const t = Date.parse(at);
|
|
4691
|
+
let best;
|
|
4692
|
+
for (const m of measurements) {
|
|
4693
|
+
if (m.metric !== MACHINE_SPEED_METRIC || !Number.isFinite(m.value) || m.value <= 0) continue;
|
|
4694
|
+
if (!best || Math.abs(Date.parse(m.at) - t) < Math.abs(Date.parse(best.at) - t)) best = m;
|
|
4695
|
+
}
|
|
4696
|
+
return best;
|
|
4697
|
+
}
|
|
4698
|
+
function scaledLimit(condition2, speed) {
|
|
4699
|
+
const factor = Math.max(1, round(speed));
|
|
4700
|
+
const upper = condition2.op === "<" || condition2.op === "<=";
|
|
4701
|
+
const limit = upper ? condition2.value * factor : condition2.value / factor;
|
|
4702
|
+
const unit = condition2.unit ? ` ${condition2.unit}` : "";
|
|
4703
|
+
const text3 = `${condition2.value}${unit} ${upper ? "\xD7" : "\xF7"} ${factor} = ${round(limit)}${unit}${speed < 1 ? ` (machine.speed ${round(speed)}, never below \xD71)` : ""}`;
|
|
4704
|
+
return { limit, factor, text: text3 };
|
|
4705
|
+
}
|
|
4683
4706
|
function evaluateMetric(condition2, measurements, maxAge, now, baseline = []) {
|
|
4684
4707
|
const measurement = latestMeasurement(condition2, measurements);
|
|
4685
4708
|
if (!measurement) return { outcome: "not-run" };
|
|
@@ -4707,6 +4730,12 @@ function evaluateMetric(condition2, measurements, maxAge, now, baseline = []) {
|
|
|
4707
4730
|
value = converted;
|
|
4708
4731
|
}
|
|
4709
4732
|
if (maxAge !== void 0 && age > maxAge) return { outcome: "stale", measurement, detail: `measured ${formatAge(age)} ago` };
|
|
4733
|
+
if (condition2.scaled) {
|
|
4734
|
+
const machine = machineSpeedAt(measurements, measurement.at);
|
|
4735
|
+
if (!machine) return { outcome: "not-run", measurement, detail: `scaled to the machine, and no ${MACHINE_SPEED_METRIC} was measured: run radical sense machine where the value is measured` };
|
|
4736
|
+
const scaled = scaledLimit(condition2, machine.value);
|
|
4737
|
+
return { outcome: COMPARE[condition2.op](value, scaled.limit) ? "passed" : "failed", measurement, detail: `limit ${scaled.text}` };
|
|
4738
|
+
}
|
|
4710
4739
|
return { outcome: COMPARE[condition2.op](value, condition2.value) ? "passed" : "failed", measurement };
|
|
4711
4740
|
}
|
|
4712
4741
|
|
|
@@ -6085,18 +6114,22 @@ function concernStatuses(packs, nodes, relations) {
|
|
|
6085
6114
|
const targets = concernTargets(pack, nodes, relations, asked);
|
|
6086
6115
|
if (!targets.length) continue;
|
|
6087
6116
|
const marked = adrsBy.get(pack.concern.id) ?? [];
|
|
6088
|
-
const
|
|
6117
|
+
const settled2 = /* @__PURE__ */ new Set();
|
|
6089
6118
|
for (const n of marked) {
|
|
6090
|
-
if (prop2(n, "status") === "accepted") for (const id of constrained.get(n.id) ?? [])
|
|
6119
|
+
if (prop2(n, "status") === "accepted") for (const id of constrained.get(n.id) ?? []) settled2.add(id);
|
|
6091
6120
|
}
|
|
6092
6121
|
const covered = (id) => {
|
|
6093
|
-
for (let cur = id; cur; cur = nodes[cur]?.parentId) if (
|
|
6122
|
+
for (let cur = id; cur; cur = nodes[cur]?.parentId) if (settled2.has(cur)) return true;
|
|
6094
6123
|
return false;
|
|
6095
6124
|
};
|
|
6096
6125
|
out.push({ pack, targets, open: targets.filter((id) => !covered(id)), pending: marked.filter((n) => prop2(n, "status") === "proposed") });
|
|
6097
6126
|
}
|
|
6098
6127
|
return out;
|
|
6099
6128
|
}
|
|
6129
|
+
function openConcerns(packs, nodes, relations, metamodel) {
|
|
6130
|
+
if (!holdsConcerns(metamodel)) return [];
|
|
6131
|
+
return concernStatuses(packs, nodes, relations).filter((s2) => s2.open.length);
|
|
6132
|
+
}
|
|
6100
6133
|
var prop2 = (node, key) => {
|
|
6101
6134
|
const value = node[key];
|
|
6102
6135
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -6245,11 +6278,11 @@ var SCALES = { hundred: 100, thousand: 1e3, million: 1e6 };
|
|
|
6245
6278
|
var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
6246
6279
|
var isNumberWord = (w) => has(UNITS, w) || has(TENS, w) || has(SCALES, w);
|
|
6247
6280
|
function numerals(text3) {
|
|
6248
|
-
return text3.replace(/\b(?:(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|million)(?:[ -]+(?:and[ -]+)?|\b))+/gi, (
|
|
6249
|
-
const words =
|
|
6250
|
-
if (!words.length || words.some((w) => !isNumberWord(w))) return
|
|
6251
|
-
if (words.length === 1 && words[0] === "one") return
|
|
6252
|
-
if (has(SCALES, words[0])) return
|
|
6281
|
+
return text3.replace(/\b(?:(?:zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|million)(?:[ -]+(?:and[ -]+)?|\b))+/gi, (run3) => {
|
|
6282
|
+
const words = run3.toLowerCase().split(/[ -]+/).filter((w) => w && w !== "and");
|
|
6283
|
+
if (!words.length || words.some((w) => !isNumberWord(w))) return run3;
|
|
6284
|
+
if (words.length === 1 && words[0] === "one") return run3;
|
|
6285
|
+
if (has(SCALES, words[0])) return run3;
|
|
6253
6286
|
let total = 0;
|
|
6254
6287
|
let current = 0;
|
|
6255
6288
|
for (const w of words) {
|
|
@@ -6261,7 +6294,7 @@ function numerals(text3) {
|
|
|
6261
6294
|
current = 0;
|
|
6262
6295
|
}
|
|
6263
6296
|
}
|
|
6264
|
-
return `${total + current}${/\s$/.test(
|
|
6297
|
+
return `${total + current}${/\s$/.test(run3) ? " " : ""}`;
|
|
6265
6298
|
});
|
|
6266
6299
|
}
|
|
6267
6300
|
var DURATION = [
|
|
@@ -6310,13 +6343,13 @@ function valuesOf(text3) {
|
|
|
6310
6343
|
const id = (m[1] ?? m[2] ?? m[3]).trim().toLowerCase();
|
|
6311
6344
|
if (/^[a-z0-9][a-z0-9_-]*$/.test(id) && !/^\d+$/.test(id)) values.add(id);
|
|
6312
6345
|
}
|
|
6313
|
-
t = t.replace(/\b(\d{4}-\d{2}-\d{2})(?:[t ](\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?z?)?\b/gi, (_, date,
|
|
6346
|
+
t = t.replace(/\b(\d{4}-\d{2}-\d{2})(?:[t ](\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?z?)?\b/gi, (_, date, time2) => {
|
|
6314
6347
|
values.add(date);
|
|
6315
|
-
if (
|
|
6348
|
+
if (time2) values.add(time2);
|
|
6316
6349
|
return " ";
|
|
6317
6350
|
});
|
|
6318
|
-
t = t.replace(/(?<![\d:])(\d{1,2}:\d{2})(?![\d:])/g, (_,
|
|
6319
|
-
values.add(
|
|
6351
|
+
t = t.replace(/(?<![\d:])(\d{1,2}:\d{2})(?![\d:])/g, (_, time2) => {
|
|
6352
|
+
values.add(time2.padStart(5, "0"));
|
|
6320
6353
|
return " ";
|
|
6321
6354
|
});
|
|
6322
6355
|
t = minusSigns(numerals(t));
|
|
@@ -7096,7 +7129,7 @@ var CHECK_RULES = [
|
|
|
7096
7129
|
description: "Every concern a Hub concern pack finds in the model is settled by an accepted ADR marked with it (property `concern`) that constrains the elements it applies to, or what contains them.",
|
|
7097
7130
|
severity: "warning",
|
|
7098
7131
|
dimension: "decisions",
|
|
7099
|
-
run: (model) =>
|
|
7132
|
+
run: (model) => openConcerns(model.concerns ?? [], model.nodes, model.relations, model.metamodel).map(({ pack, open: open4, pending }) => {
|
|
7100
7133
|
const names = open4.map((id) => quote(model.nodes[id])).join(", ");
|
|
7101
7134
|
const being = pending.length ? ` ${pending.map(quote).join(", ")} ${pending.length === 1 ? "is" : "are"} proposed: the decision is being made.` : "";
|
|
7102
7135
|
return {
|
|
@@ -7106,7 +7139,7 @@ var CHECK_RULES = [
|
|
|
7106
7139
|
message: `${pack.name}: ${pack.concern.why} No accepted ADR marked "${pack.concern.id}" settles it for ${names}.${being}`,
|
|
7107
7140
|
details: (pack.templateParams ?? []).map(questionLine)
|
|
7108
7141
|
};
|
|
7109
|
-
})
|
|
7142
|
+
})
|
|
7110
7143
|
},
|
|
7111
7144
|
{
|
|
7112
7145
|
id: "concern-unbound",
|
|
@@ -7309,6 +7342,59 @@ function testBinding(model) {
|
|
|
7309
7342
|
return byFile;
|
|
7310
7343
|
}
|
|
7311
7344
|
|
|
7345
|
+
// ../../packages/common/src/check/profiles.ts
|
|
7346
|
+
init_define_RADICAL_BUILD();
|
|
7347
|
+
var ADOPT_RULE = {
|
|
7348
|
+
id: "baselines-pending",
|
|
7349
|
+
description: 'check.json does not wait for the baselines of its first run ("adopt": true); radical check --adopt takes them once.',
|
|
7350
|
+
severity: "error",
|
|
7351
|
+
dimension: "consistency"
|
|
7352
|
+
};
|
|
7353
|
+
var ADOPT_MESSAGE = 'check.json waits for the baselines of its first run ("adopt": true): run radical check --adopt and commit check.json.';
|
|
7354
|
+
function strictCheckConfig(ruleIds, metricIds) {
|
|
7355
|
+
return {
|
|
7356
|
+
rules: Object.fromEntries(ruleIds.filter((id) => id !== ADOPT_RULE.id).map((id) => [id, "error"])),
|
|
7357
|
+
goals: Object.fromEntries(metricIds.map((id) => [id, { min: 100 }]))
|
|
7358
|
+
};
|
|
7359
|
+
}
|
|
7360
|
+
function existingCodeCheckConfig(ruleIds) {
|
|
7361
|
+
return {
|
|
7362
|
+
adopt: true,
|
|
7363
|
+
rules: Object.fromEntries(ruleIds.filter((id) => id !== ADOPT_RULE.id).map((id) => [id, "error"]))
|
|
7364
|
+
};
|
|
7365
|
+
}
|
|
7366
|
+
var severityOf = (setting2) => typeof setting2 === "object" ? setting2.severity : setting2;
|
|
7367
|
+
function adoptBaselines(config, result) {
|
|
7368
|
+
if (!config.adopt) throw new Error('check.json does not wait for baselines (no "adopt": true): they were taken already, and only radical check --ratchet lowers them');
|
|
7369
|
+
const rules = { ...config.rules ?? {} };
|
|
7370
|
+
const baselines = [];
|
|
7371
|
+
const notRun = [];
|
|
7372
|
+
for (const r of result.rules) {
|
|
7373
|
+
if (r.id === ADOPT_RULE.id || r.id.startsWith("goal-unmet")) continue;
|
|
7374
|
+
if (r.notRun) {
|
|
7375
|
+
notRun.push(r.id);
|
|
7376
|
+
continue;
|
|
7377
|
+
}
|
|
7378
|
+
if (r.severity === "off" || r.count === 0) continue;
|
|
7379
|
+
const severity = severityOf(rules[r.id]) ?? r.severity;
|
|
7380
|
+
rules[r.id] = { ...typeof rules[r.id] === "object" ? rules[r.id] : {}, severity, max: r.count };
|
|
7381
|
+
baselines.push({ id: r.id, max: r.count });
|
|
7382
|
+
}
|
|
7383
|
+
const goals = [];
|
|
7384
|
+
for (const m of result.metrics) {
|
|
7385
|
+
if (m.total === 0) continue;
|
|
7386
|
+
goals.push({ id: m.id, min: m.percent });
|
|
7387
|
+
}
|
|
7388
|
+
for (const g of result.goalsNotRun) notRun.push(g.id);
|
|
7389
|
+
const { adopt: _adopt, ...rest } = config;
|
|
7390
|
+
return {
|
|
7391
|
+
config: { ...rest, rules, goals: { ...config.goals ?? {}, ...Object.fromEntries(goals.map((g) => [g.id, { min: g.min }])) } },
|
|
7392
|
+
baselines,
|
|
7393
|
+
goals,
|
|
7394
|
+
notRun
|
|
7395
|
+
};
|
|
7396
|
+
}
|
|
7397
|
+
|
|
7312
7398
|
// ../../packages/common/src/check/goals.ts
|
|
7313
7399
|
init_define_RADICAL_BUILD();
|
|
7314
7400
|
var GOAL_RULE = {
|
|
@@ -7452,6 +7538,70 @@ function measureGoals(ctx, goals) {
|
|
|
7452
7538
|
return { metrics, findings, notRun };
|
|
7453
7539
|
}
|
|
7454
7540
|
|
|
7541
|
+
// ../../packages/common/src/check/files.ts
|
|
7542
|
+
init_define_RADICAL_BUILD();
|
|
7543
|
+
var CHECK_CONFIG_FILE = "check.json";
|
|
7544
|
+
var TEST_RESULTS_FILE = `${STATE_DIR}/test-results.json`;
|
|
7545
|
+
var MEASUREMENTS_FILE = `${STATE_DIR}/measurements.json`;
|
|
7546
|
+
function serializeTestResults(cases, reports, readAt = /* @__PURE__ */ new Date(), from = {}) {
|
|
7547
|
+
const results = { version: 1, readAt: readAt.toISOString(), reports, cases, ...from.commit ? { commit: from.commit } : {}, ...from.ci ? { ci: from.ci } : {} };
|
|
7548
|
+
return JSON.stringify(results);
|
|
7549
|
+
}
|
|
7550
|
+
function testsRanAt(results) {
|
|
7551
|
+
const runs = results.ci?.runs.map((r) => r.ranAt).filter((at) => !Number.isNaN(Date.parse(at))).sort() ?? [];
|
|
7552
|
+
return runs.length ? runs[runs.length - 1] : results.readAt;
|
|
7553
|
+
}
|
|
7554
|
+
function ciSourceOf(value) {
|
|
7555
|
+
const ci = value;
|
|
7556
|
+
if (!ci || ci.provider !== "github" || typeof ci.commit !== "string" || typeof ci.behind !== "number" || !Array.isArray(ci.runs)) return void 0;
|
|
7557
|
+
const runs = ci.runs.filter((r) => !!r && typeof r.id === "number" && typeof r.url === "string" && typeof r.sha === "string" && typeof r.ranAt === "string" && typeof r.workflow === "string" && Array.isArray(r.artifacts));
|
|
7558
|
+
return { provider: "github", commit: ci.commit, behind: ci.behind, runs };
|
|
7559
|
+
}
|
|
7560
|
+
var STATUSES = /* @__PURE__ */ new Set(["passed", "failed", "skipped"]);
|
|
7561
|
+
function parseTestResults(text3) {
|
|
7562
|
+
let data;
|
|
7563
|
+
try {
|
|
7564
|
+
data = JSON.parse(text3);
|
|
7565
|
+
} catch {
|
|
7566
|
+
return null;
|
|
7567
|
+
}
|
|
7568
|
+
const r = data;
|
|
7569
|
+
if (r?.version !== 1 || typeof r.readAt !== "string" || !Array.isArray(r.cases)) return null;
|
|
7570
|
+
const cases = r.cases.filter((c) => !!c && typeof c.file === "string" && Array.isArray(c.title) && c.title.every((t) => typeof t === "string") && STATUSES.has(c.status));
|
|
7571
|
+
const ci = ciSourceOf(r.ci);
|
|
7572
|
+
return {
|
|
7573
|
+
version: 1,
|
|
7574
|
+
readAt: r.readAt,
|
|
7575
|
+
reports: Array.isArray(r.reports) ? r.reports.filter((x) => typeof x === "string") : [],
|
|
7576
|
+
cases,
|
|
7577
|
+
...typeof r.commit === "string" ? { commit: r.commit } : {},
|
|
7578
|
+
...ci ? { ci } : {}
|
|
7579
|
+
};
|
|
7580
|
+
}
|
|
7581
|
+
function parseCheckConfig(text3) {
|
|
7582
|
+
const data = JSON.parse(stripBom(text3));
|
|
7583
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error("a config is a JSON object");
|
|
7584
|
+
const rules = data.rules;
|
|
7585
|
+
if (rules !== void 0 && (typeof rules !== "object" || rules === null || Array.isArray(rules))) throw new Error('"rules" is an object of rule settings');
|
|
7586
|
+
const goals = data.goals;
|
|
7587
|
+
if (goals !== void 0) {
|
|
7588
|
+
if (typeof goals !== "object" || goals === null || Array.isArray(goals)) throw new Error('"goals" is an object of goals by metric');
|
|
7589
|
+
for (const [id, goal] of Object.entries(goals)) {
|
|
7590
|
+
const min = goal?.min;
|
|
7591
|
+
if (typeof min !== "number" || !(min >= 0 && min <= 100)) throw new Error(`goal "${id}" needs a "min" from 0 to 100 (percent)`);
|
|
7592
|
+
}
|
|
7593
|
+
}
|
|
7594
|
+
const adopt = data.adopt;
|
|
7595
|
+
if (adopt !== void 0 && typeof adopt !== "boolean") throw new Error('"adopt" is true while check.json waits for the baselines of its first run (radical check --adopt), else left out');
|
|
7596
|
+
const ci = data.ci;
|
|
7597
|
+
if (ci !== void 0) {
|
|
7598
|
+
const artifacts = ci?.artifacts;
|
|
7599
|
+
if (typeof ci !== "object" || ci === null || Array.isArray(ci) || artifacts !== void 0 && !(Array.isArray(artifacts) && artifacts.every((a2) => typeof a2 === "string" && a2)))
|
|
7600
|
+
throw new Error('"ci" is an object whose "artifacts" lists the names of the CI artifacts that hold test reports');
|
|
7601
|
+
}
|
|
7602
|
+
return data;
|
|
7603
|
+
}
|
|
7604
|
+
|
|
7455
7605
|
// ../../packages/common/src/check/testSource.ts
|
|
7456
7606
|
init_define_RADICAL_BUILD();
|
|
7457
7607
|
function splitTestId(id) {
|
|
@@ -7616,68 +7766,6 @@ function formatTrace(trace, nodes, now = Date.now()) {
|
|
|
7616
7766
|
return out.join("\n");
|
|
7617
7767
|
}
|
|
7618
7768
|
|
|
7619
|
-
// ../../packages/common/src/check/files.ts
|
|
7620
|
-
init_define_RADICAL_BUILD();
|
|
7621
|
-
var CHECK_CONFIG_FILE = "check.json";
|
|
7622
|
-
var TEST_RESULTS_FILE = `${STATE_DIR}/test-results.json`;
|
|
7623
|
-
var MEASUREMENTS_FILE = `${STATE_DIR}/measurements.json`;
|
|
7624
|
-
function serializeTestResults(cases, reports, readAt = /* @__PURE__ */ new Date(), from = {}) {
|
|
7625
|
-
const results = { version: 1, readAt: readAt.toISOString(), reports, cases, ...from.commit ? { commit: from.commit } : {}, ...from.ci ? { ci: from.ci } : {} };
|
|
7626
|
-
return JSON.stringify(results);
|
|
7627
|
-
}
|
|
7628
|
-
function testsRanAt(results) {
|
|
7629
|
-
const runs = results.ci?.runs.map((r) => r.ranAt).filter((at) => !Number.isNaN(Date.parse(at))).sort() ?? [];
|
|
7630
|
-
return runs.length ? runs[runs.length - 1] : results.readAt;
|
|
7631
|
-
}
|
|
7632
|
-
function ciSourceOf(value) {
|
|
7633
|
-
const ci = value;
|
|
7634
|
-
if (!ci || ci.provider !== "github" || typeof ci.commit !== "string" || typeof ci.behind !== "number" || !Array.isArray(ci.runs)) return void 0;
|
|
7635
|
-
const runs = ci.runs.filter((r) => !!r && typeof r.id === "number" && typeof r.url === "string" && typeof r.sha === "string" && typeof r.ranAt === "string" && typeof r.workflow === "string" && Array.isArray(r.artifacts));
|
|
7636
|
-
return { provider: "github", commit: ci.commit, behind: ci.behind, runs };
|
|
7637
|
-
}
|
|
7638
|
-
var STATUSES = /* @__PURE__ */ new Set(["passed", "failed", "skipped"]);
|
|
7639
|
-
function parseTestResults(text3) {
|
|
7640
|
-
let data;
|
|
7641
|
-
try {
|
|
7642
|
-
data = JSON.parse(text3);
|
|
7643
|
-
} catch {
|
|
7644
|
-
return null;
|
|
7645
|
-
}
|
|
7646
|
-
const r = data;
|
|
7647
|
-
if (r?.version !== 1 || typeof r.readAt !== "string" || !Array.isArray(r.cases)) return null;
|
|
7648
|
-
const cases = r.cases.filter((c) => !!c && typeof c.file === "string" && Array.isArray(c.title) && c.title.every((t) => typeof t === "string") && STATUSES.has(c.status));
|
|
7649
|
-
const ci = ciSourceOf(r.ci);
|
|
7650
|
-
return {
|
|
7651
|
-
version: 1,
|
|
7652
|
-
readAt: r.readAt,
|
|
7653
|
-
reports: Array.isArray(r.reports) ? r.reports.filter((x) => typeof x === "string") : [],
|
|
7654
|
-
cases,
|
|
7655
|
-
...typeof r.commit === "string" ? { commit: r.commit } : {},
|
|
7656
|
-
...ci ? { ci } : {}
|
|
7657
|
-
};
|
|
7658
|
-
}
|
|
7659
|
-
function parseCheckConfig(text3) {
|
|
7660
|
-
const data = JSON.parse(stripBom(text3));
|
|
7661
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error("a config is a JSON object");
|
|
7662
|
-
const rules = data.rules;
|
|
7663
|
-
if (rules !== void 0 && (typeof rules !== "object" || rules === null || Array.isArray(rules))) throw new Error('"rules" is an object of rule settings');
|
|
7664
|
-
const goals = data.goals;
|
|
7665
|
-
if (goals !== void 0) {
|
|
7666
|
-
if (typeof goals !== "object" || goals === null || Array.isArray(goals)) throw new Error('"goals" is an object of goals by metric');
|
|
7667
|
-
for (const [id, goal] of Object.entries(goals)) {
|
|
7668
|
-
const min = goal?.min;
|
|
7669
|
-
if (typeof min !== "number" || !(min >= 0 && min <= 100)) throw new Error(`goal "${id}" needs a "min" from 0 to 100 (percent)`);
|
|
7670
|
-
}
|
|
7671
|
-
}
|
|
7672
|
-
const ci = data.ci;
|
|
7673
|
-
if (ci !== void 0) {
|
|
7674
|
-
const artifacts = ci?.artifacts;
|
|
7675
|
-
if (typeof ci !== "object" || ci === null || Array.isArray(ci) || artifacts !== void 0 && !(Array.isArray(artifacts) && artifacts.every((a2) => typeof a2 === "string" && a2)))
|
|
7676
|
-
throw new Error('"ci" is an object whose "artifacts" lists the names of the CI artifacts that hold test reports');
|
|
7677
|
-
}
|
|
7678
|
-
return data;
|
|
7679
|
-
}
|
|
7680
|
-
|
|
7681
7769
|
// ../../packages/common/src/check/reviews.ts
|
|
7682
7770
|
init_define_RADICAL_BUILD();
|
|
7683
7771
|
var REVIEWS_FILE2 = "reviews.json";
|
|
@@ -7793,9 +7881,9 @@ var FOLDER_RULES = [
|
|
|
7793
7881
|
];
|
|
7794
7882
|
var FATAL = /* @__PURE__ */ new Set(["folder-manifest", "folder-json", "folder-conflict"]);
|
|
7795
7883
|
var STALE_REFERENCE = "stale-reference";
|
|
7796
|
-
var MODEL_RULE_IDS = /* @__PURE__ */ new Set([STALE_REFERENCE, ...CHECK_RULES.map((r) => r.id), GOAL_RULE.id]);
|
|
7884
|
+
var MODEL_RULE_IDS = /* @__PURE__ */ new Set([STALE_REFERENCE, ...CHECK_RULES.map((r) => r.id), GOAL_RULE.id, ADOPT_RULE.id]);
|
|
7797
7885
|
var byId = (items) => Object.fromEntries(items.map((item) => [item.id, item]));
|
|
7798
|
-
var ALL_RULES = [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE];
|
|
7886
|
+
var ALL_RULES = [...FOLDER_RULES, ...CHECK_RULES, GOAL_RULE, ADOPT_RULE];
|
|
7799
7887
|
var RENAMED_RULES = {
|
|
7800
7888
|
"scenario-without-tests": "scenario-without-metrics",
|
|
7801
7889
|
"fitness-fn-without-tests": "fitness-fn-without-metrics",
|
|
@@ -7931,6 +8019,7 @@ function checkData(data, options, config) {
|
|
|
7931
8019
|
const evidence = options.tests || options.measurements ? computeEvidence(model) : void 0;
|
|
7932
8020
|
const goals = measureGoals({ model: ownModel2, found, ...evidence ? { evidence } : {} }, config.goals ?? {});
|
|
7933
8021
|
goals.findings.forEach((finding) => found.push({ rule: GOAL_RULE.id, ...finding }));
|
|
8022
|
+
if (config.adopt) found.push({ rule: ADOPT_RULE.id, message: ADOPT_MESSAGE, path: CHECK_CONFIG_FILE });
|
|
7934
8023
|
return {
|
|
7935
8024
|
found,
|
|
7936
8025
|
nodeCount: Object.keys(ownModel2.nodes).length,
|
|
@@ -7997,18 +8086,18 @@ function settle(found, config, { nodeCount, relationCount, metrics, notRun, goal
|
|
|
7997
8086
|
continue;
|
|
7998
8087
|
}
|
|
7999
8088
|
const withinBaseline = max2 !== void 0 && list.length <= max2;
|
|
8000
|
-
const
|
|
8089
|
+
const settled2 = list.map((f) => ({
|
|
8001
8090
|
...f,
|
|
8002
8091
|
key,
|
|
8003
8092
|
severity: withinBaseline || f.asOf ? "warning" : set2 ?? f.severity ?? ruleSeverity
|
|
8004
8093
|
}));
|
|
8005
|
-
findings.push(...
|
|
8094
|
+
findings.push(...settled2);
|
|
8006
8095
|
results.push({
|
|
8007
8096
|
id: key,
|
|
8008
8097
|
count: list.length,
|
|
8009
8098
|
severity: set2 ?? ruleSeverity,
|
|
8010
8099
|
...max2 !== void 0 ? { max: max2 } : {},
|
|
8011
|
-
failed:
|
|
8100
|
+
failed: settled2.some((f) => f.severity === "error")
|
|
8012
8101
|
});
|
|
8013
8102
|
}
|
|
8014
8103
|
const errors = findings.filter((f) => f.severity === "error").length;
|
|
@@ -8037,6 +8126,9 @@ function ratchetConfig(config, result) {
|
|
|
8037
8126
|
}
|
|
8038
8127
|
return { config: { ...config, rules }, lowered };
|
|
8039
8128
|
}
|
|
8129
|
+
var strictCheckConfig2 = () => strictCheckConfig(ALL_RULES.map((r) => r.id), CHECK_METRICS.map((m) => m.id));
|
|
8130
|
+
var existingCodeCheckConfig2 = () => existingCodeCheckConfig(ALL_RULES.map((r) => r.id));
|
|
8131
|
+
var serializeCheckConfig = (config) => JSON.stringify(config, null, 2) + "\n";
|
|
8040
8132
|
|
|
8041
8133
|
// ../../packages/common/src/federation.ts
|
|
8042
8134
|
init_define_RADICAL_BUILD();
|
|
@@ -13279,21 +13371,21 @@ async function findCiRuns(root, gh, names) {
|
|
|
13279
13371
|
const runs = [];
|
|
13280
13372
|
for (const { sha, pr: pr2 } of candidates) {
|
|
13281
13373
|
for (const [id, artifacts] of byCommit.get(sha)) {
|
|
13282
|
-
const
|
|
13283
|
-
if (
|
|
13284
|
-
const number = pr2 ??
|
|
13285
|
-
runs.push({ id, url:
|
|
13374
|
+
const run3 = await json(gh, root, `repos/{owner}/{repo}/actions/runs/${id}`);
|
|
13375
|
+
if (run3.status !== "completed") continue;
|
|
13376
|
+
const number = pr2 ?? run3.pull_requests?.[0]?.number;
|
|
13377
|
+
runs.push({ id, url: run3.html_url, sha, ranAt: run3.updated_at, workflow: run3.name, ...number ? { pr: number } : {}, artifacts: [...artifacts].sort() });
|
|
13286
13378
|
}
|
|
13287
13379
|
}
|
|
13288
13380
|
if (!runs.length) continue;
|
|
13289
13381
|
runs.sort((a2, b) => Date.parse(b.ranAt) - Date.parse(a2.ranAt));
|
|
13290
13382
|
const taken = /* @__PURE__ */ new Set();
|
|
13291
13383
|
const chosen = [];
|
|
13292
|
-
for (const
|
|
13293
|
-
const artifacts =
|
|
13384
|
+
for (const run3 of runs) {
|
|
13385
|
+
const artifacts = run3.artifacts.filter((name) => !taken.has(name));
|
|
13294
13386
|
if (!artifacts.length) continue;
|
|
13295
13387
|
artifacts.forEach((name) => taken.add(name));
|
|
13296
|
-
chosen.push({ ...
|
|
13388
|
+
chosen.push({ ...run3, artifacts });
|
|
13297
13389
|
}
|
|
13298
13390
|
return { provider: "github", commit, behind, runs: chosen.sort((a2, b) => a2.id - b.id) };
|
|
13299
13391
|
}
|
|
@@ -13313,10 +13405,10 @@ async function downloadCiReports(root, gh, source) {
|
|
|
13313
13405
|
try {
|
|
13314
13406
|
const cases = [];
|
|
13315
13407
|
const reports = [];
|
|
13316
|
-
for (const
|
|
13317
|
-
for (const artifact of
|
|
13318
|
-
const into = join9(dir, String(
|
|
13319
|
-
await gh(["run", "download", String(
|
|
13408
|
+
for (const run3 of source.runs) {
|
|
13409
|
+
for (const artifact of run3.artifacts) {
|
|
13410
|
+
const into = join9(dir, String(run3.id), artifact);
|
|
13411
|
+
await gh(["run", "download", String(run3.id), "--name", artifact, "--dir", into], root);
|
|
13320
13412
|
for (const file of await filesUnder(into)) {
|
|
13321
13413
|
let read2;
|
|
13322
13414
|
try {
|
|
@@ -13326,7 +13418,7 @@ async function downloadCiReports(root, gh, source) {
|
|
|
13326
13418
|
}
|
|
13327
13419
|
if (!read2.length) continue;
|
|
13328
13420
|
cases.push(...read2);
|
|
13329
|
-
reports.push(`run ${
|
|
13421
|
+
reports.push(`run ${run3.id} ${artifact}/${relative3(into, file).replace(/\\/g, "/")}`);
|
|
13330
13422
|
}
|
|
13331
13423
|
}
|
|
13332
13424
|
}
|
|
@@ -13575,7 +13667,7 @@ async function readModelAtCommit(folder, commit, from) {
|
|
|
13575
13667
|
return Object.fromEntries(blobs.map((blob, i) => [blob.path, contents[i]]));
|
|
13576
13668
|
}
|
|
13577
13669
|
function catFiles(cwd, shas) {
|
|
13578
|
-
return new Promise((
|
|
13670
|
+
return new Promise((resolve28, reject) => {
|
|
13579
13671
|
const child = spawn("git", ["cat-file", "--batch"], { cwd, windowsHide: true });
|
|
13580
13672
|
const chunks = [];
|
|
13581
13673
|
let stderr = "";
|
|
@@ -13603,7 +13695,7 @@ function catFiles(cwd, shas) {
|
|
|
13603
13695
|
contents.push(stripBom(out.subarray(start, start + Number(size)).toString("utf8")));
|
|
13604
13696
|
at = start + Number(size) + 1;
|
|
13605
13697
|
}
|
|
13606
|
-
|
|
13698
|
+
resolve28(contents);
|
|
13607
13699
|
});
|
|
13608
13700
|
child.stdin.end(shas.join("\n") + "\n");
|
|
13609
13701
|
});
|
|
@@ -13667,9 +13759,9 @@ async function modelChangesSince(folder, current, since, options = {}) {
|
|
|
13667
13759
|
// ../../packages/node-files/src/gitDeps.ts
|
|
13668
13760
|
var exec3 = promisify3(execFile3);
|
|
13669
13761
|
async function git3(cwd, args, input) {
|
|
13670
|
-
const
|
|
13671
|
-
if (input !== void 0)
|
|
13672
|
-
const { stdout } = await
|
|
13762
|
+
const run3 = exec3("git", args, { cwd, maxBuffer: 256 * 1024 * 1024, encoding: "utf8", windowsHide: true });
|
|
13763
|
+
if (input !== void 0) run3.child.stdin?.end(input);
|
|
13764
|
+
const { stdout } = await run3;
|
|
13673
13765
|
return stdout.trim();
|
|
13674
13766
|
}
|
|
13675
13767
|
var gitOk2 = (cwd, args) => git3(cwd, args).catch(() => null);
|
|
@@ -13840,11 +13932,11 @@ function addressKey(address) {
|
|
|
13840
13932
|
}
|
|
13841
13933
|
async function ownLocations(root) {
|
|
13842
13934
|
const own = /* @__PURE__ */ new Set([`file:${await realpath3(root).catch(() => root)}`]);
|
|
13843
|
-
const
|
|
13844
|
-
const top = await
|
|
13935
|
+
const run3 = (args) => exec4("git", args, { cwd: root, windowsHide: true }).then((r) => r.stdout.trim(), () => "");
|
|
13936
|
+
const top = await run3(["rev-parse", "--show-toplevel"]);
|
|
13845
13937
|
if (!top) return own;
|
|
13846
13938
|
const folder = relative4(await realpath3(top).catch(() => top), await realpath3(root).catch(() => root)) || ".";
|
|
13847
|
-
for (const line of (await
|
|
13939
|
+
for (const line of (await run3(["remote", "-v"])).split("\n")) {
|
|
13848
13940
|
const address = line.split(/\s+/)[1];
|
|
13849
13941
|
if (!address) continue;
|
|
13850
13942
|
if (isAddress(address)) own.add(`${addressKey(address)}#${folder}`);
|
|
@@ -13869,8 +13961,8 @@ function federationOthers(files, fetched) {
|
|
|
13869
13961
|
}
|
|
13870
13962
|
async function latestRef(repo, home) {
|
|
13871
13963
|
const address = repoAddress(repo, home);
|
|
13872
|
-
const
|
|
13873
|
-
const tags = (await
|
|
13964
|
+
const run3 = (args) => exec4("git", args, { cwd: home, windowsHide: true, timeout: 3e4 }).then((r) => r.stdout, () => "");
|
|
13965
|
+
const tags = (await run3(["ls-remote", "--tags", "--refs", address])).split("\n").map((line) => line.split("refs/tags/")[1]?.trim()).filter((tag2) => !!tag2 && /^v?\d+(\.\d+)*$/.test(tag2));
|
|
13874
13966
|
if (tags.length) {
|
|
13875
13967
|
const parts2 = (tag2) => tag2.replace(/^v/, "").split(".").map(Number);
|
|
13876
13968
|
return tags.sort((a2, b) => {
|
|
@@ -13879,7 +13971,7 @@ async function latestRef(repo, home) {
|
|
|
13879
13971
|
return 0;
|
|
13880
13972
|
}).at(-1);
|
|
13881
13973
|
}
|
|
13882
|
-
return (await
|
|
13974
|
+
return (await run3(["ls-remote", "--symref", address, "HEAD"])).match(/^ref: refs\/heads\/(\S+)\s+HEAD/m)?.[1] ?? "main";
|
|
13883
13975
|
}
|
|
13884
13976
|
function parseDependsOn(spec) {
|
|
13885
13977
|
const at = spec.indexOf("=");
|
|
@@ -14117,6 +14209,15 @@ its own ("model": { "repo": \u2026 }), it judges that repository's part of the m
|
|
|
14117
14209
|
baseline of the model's check.json (exit 2): only one
|
|
14118
14210
|
--config names. With --alone or --trigger, which leave
|
|
14119
14211
|
part of the model out, it lowers none (exit 2)
|
|
14212
|
+
--adopt take the baselines of this first run into check.json
|
|
14213
|
+
once: each rule that finds something gets its count as
|
|
14214
|
+
max, each measured metric its share as the goal, and
|
|
14215
|
+
"adopt": true goes. Only for a check.json that waits for
|
|
14216
|
+
them (radical setup and Assay write one for existing
|
|
14217
|
+
code), or none (it writes one with every rule an error);
|
|
14218
|
+
from then on only --ratchet lowers them. Give the test
|
|
14219
|
+
reports and measurements too, or the rules that read
|
|
14220
|
+
them get no baseline
|
|
14120
14221
|
--alone check without the models deps.json names; with a
|
|
14121
14222
|
deps.json the model is checked composed with them, at
|
|
14122
14223
|
their pinned refs (radical federation --help)
|
|
@@ -14154,6 +14255,7 @@ async function checkCommand(args, io2) {
|
|
|
14154
14255
|
evidence: { type: "string" },
|
|
14155
14256
|
trace: { type: "string" },
|
|
14156
14257
|
ratchet: { type: "boolean", default: false },
|
|
14258
|
+
adopt: { type: "boolean", default: false },
|
|
14157
14259
|
alone: { type: "boolean", default: false },
|
|
14158
14260
|
verbose: { type: "boolean", default: false },
|
|
14159
14261
|
"list-rules": { type: "boolean", default: false },
|
|
@@ -14178,11 +14280,15 @@ ${CHECK_USAGE}`);
|
|
|
14178
14280
|
return 0;
|
|
14179
14281
|
}
|
|
14180
14282
|
const fromCi = values["from-ci"];
|
|
14181
|
-
if (positionals.length > 1 || !["text", "json", "github"].includes(values.format) || fromCi && values.report?.length || values.evidence && !values.report?.length && !fromCi && !values.metrics?.length || values.trace !== void 0 && (!values.trace.trim() || values.format === "github" || values.ratchet)) {
|
|
14283
|
+
if (positionals.length > 1 || !["text", "json", "github"].includes(values.format) || fromCi && values.report?.length || values.evidence && !values.report?.length && !fromCi && !values.metrics?.length || values.trace !== void 0 && (!values.trace.trim() || values.format === "github" || values.ratchet || values.adopt)) {
|
|
14182
14284
|
io2.err(CHECK_USAGE);
|
|
14183
14285
|
return 2;
|
|
14184
14286
|
}
|
|
14185
14287
|
const partial = values.alone ? "--alone" : values.trigger !== void 0 ? "--trigger" : null;
|
|
14288
|
+
if (values.adopt && (values.ratchet || partial)) {
|
|
14289
|
+
io2.err(`radical check --adopt: ${values.ratchet ? "takes the first baselines; --ratchet lowers them later, not in the same run" : `with ${partial} the check leaves part of the model out, and a baseline counts the whole model`}.`);
|
|
14290
|
+
return 2;
|
|
14291
|
+
}
|
|
14186
14292
|
if (values.ratchet && partial) {
|
|
14187
14293
|
io2.err(`radical check --ratchet: with ${partial} the check leaves part of the model out (${partial === "--alone" ? "the models deps.json names" : "the metric conditions of other events"}), and a baseline counts the whole model. Ratchet with a check of all of it.`);
|
|
14188
14294
|
return 2;
|
|
@@ -14216,6 +14322,7 @@ ${CHECK_USAGE}`);
|
|
|
14216
14322
|
io2.err(missing2 ? `No config at ${configPath}.` : `Cannot read the config ${configPath}: ${error.message}`);
|
|
14217
14323
|
return 2;
|
|
14218
14324
|
}
|
|
14325
|
+
if (values.adopt) config = existingCodeCheckConfig2();
|
|
14219
14326
|
}
|
|
14220
14327
|
let repository;
|
|
14221
14328
|
let mappedFrom = root;
|
|
@@ -14362,7 +14469,23 @@ ${CHECK_USAGE}`);
|
|
|
14362
14469
|
}
|
|
14363
14470
|
const testSources = repository?.verifies?.length ? await boundTestSources(mappedFrom, repository.verifies) : void 0;
|
|
14364
14471
|
const baseNodes = await baseModelNodes(root);
|
|
14365
|
-
const
|
|
14472
|
+
const checkOptions = { sensors, repository, missingPaths, ...testSources ? { testSources } : {}, ...baseNodes ? { baseNodes } : {}, ...tests ? { tests } : {}, ...testsReadAt ? { testsReadAt } : {}, ...measurements ? { measurements } : {}, ...baseline ? { baseline } : {}, ...values.trigger ? { trigger: values.trigger } : {}, concerns: concernPacks(), ...others2 ? { others: others2 } : {} };
|
|
14473
|
+
let result = runCheck(files, config, checkOptions);
|
|
14474
|
+
if (values.adopt) {
|
|
14475
|
+
let adopted;
|
|
14476
|
+
try {
|
|
14477
|
+
adopted = adoptBaselines(config, result);
|
|
14478
|
+
} catch (error) {
|
|
14479
|
+
io2.err(`radical check --adopt: ${error.message}.`);
|
|
14480
|
+
return 2;
|
|
14481
|
+
}
|
|
14482
|
+
await writeFile5(configPath, serializeCheckConfig(adopted.config));
|
|
14483
|
+
result = runCheck(files, adopted.config, checkOptions);
|
|
14484
|
+
if (!values.quiet) {
|
|
14485
|
+
io2.err(`Adopted the first run's baselines into ${configPath}: ${adopted.baselines.length ? adopted.baselines.map((b) => `${b.id} max ${b.max}`).join(", ") : "no rule found anything"}; goals ${adopted.goals.length ? adopted.goals.map((g) => `${g.id} ${g.min}%`).join(", ") : "none measured"}. From now on only --ratchet lowers them. Commit it.`);
|
|
14486
|
+
if (adopted.notRun.length) io2.err(`Not run, so no baseline taken (give the test reports with --report, the measurements with --metrics): ${adopted.notRun.join(", ")}.`);
|
|
14487
|
+
}
|
|
14488
|
+
}
|
|
14366
14489
|
if (tests && !fromKept && (keep || !fromCi)) {
|
|
14367
14490
|
await writeBeside(join13(root, TEST_RESULTS_FILE), serializeTestResults(
|
|
14368
14491
|
tests,
|
|
@@ -14655,8 +14778,8 @@ ${HOOKS_USAGE}`);
|
|
|
14655
14778
|
const launcher = launcherEnv?.endsWith(".sh") ? relative6(top, await realpath6(launcherEnv).catch(() => launcherEnv)) : null;
|
|
14656
14779
|
const viaLauncher = launcher !== null && !launcher.startsWith("..") && !isAbsolute3(launcher);
|
|
14657
14780
|
const command = viaLauncher ? `sh ${quote2(launcher)}` : viaNpx ? `npx -y ${cliPackage()}` : io2.cli ? `${io2.cli.node} ${quote2(inRepo ? fromTop : script)}` : io2.command ?? "radical";
|
|
14658
|
-
const
|
|
14659
|
-
const line = inRepo && !viaLauncher ? `if [ -f ${quote2(fromTop)} ]; then ${
|
|
14781
|
+
const run3 = `${command} diff ${folderArg} --save-base --quiet </dev/null || true; ${command} check ${folderArg} --from-ci --quiet --detach </dev/null >/dev/null 2>&1 || true; ${command} federation fetch ${folderArg} --quiet --detach </dev/null >/dev/null 2>&1 || true`;
|
|
14782
|
+
const line = inRepo && !viaLauncher ? `if [ -f ${quote2(fromTop)} ]; then ${run3}; else echo ${quote2(`radical hooks: ${fromTop} is not in this working tree, so the base of ${relative6(top, root) || "."} was not saved; build the CLI there, or install the hooks again.`)} >&2; fi` : run3;
|
|
14660
14783
|
const written = [];
|
|
14661
14784
|
const updated = [];
|
|
14662
14785
|
const foreign = [];
|
|
@@ -15360,9 +15483,9 @@ ${HARDEN_USAGE}`);
|
|
|
15360
15483
|
io2.out(bound === 0 ? said.join("\n") : `Not bound to scenario "${values.scenario}" (${said[0]?.split("\n")[0] ?? "no model"}): ${bind}`);
|
|
15361
15484
|
return 0;
|
|
15362
15485
|
}
|
|
15363
|
-
const
|
|
15364
|
-
if (typeof
|
|
15365
|
-
io2.err(
|
|
15486
|
+
const run3 = finding ? findingRun(finding, config, root) : testRun(values.test, config, root);
|
|
15487
|
+
if (typeof run3 === "string") {
|
|
15488
|
+
io2.err(run3);
|
|
15366
15489
|
return 2;
|
|
15367
15490
|
}
|
|
15368
15491
|
const top = git4(root, ["rev-parse", "--show-toplevel"]).stdout?.trim();
|
|
@@ -15384,7 +15507,7 @@ ${HARDEN_USAGE}`);
|
|
|
15384
15507
|
io2.err(`No source file changed since ${base}: no fix to set back.`);
|
|
15385
15508
|
return 2;
|
|
15386
15509
|
}
|
|
15387
|
-
io2.out(`Gate for ${
|
|
15510
|
+
io2.out(`Gate for ${run3.label}, base ${base}, ${changed.length} source file${changed.length === 1 ? "" : "s"} changed since:`);
|
|
15388
15511
|
for (const f of changed) io2.out(` ${f}`);
|
|
15389
15512
|
let putBack;
|
|
15390
15513
|
const interrupted = (signal) => {
|
|
@@ -15400,11 +15523,11 @@ ${HARDEN_USAGE}`);
|
|
|
15400
15523
|
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
15401
15524
|
for (const s2 of signals) process.on(s2, interrupted);
|
|
15402
15525
|
try {
|
|
15403
|
-
return await gate(
|
|
15526
|
+
return await gate(run3, runs, io2, async () => {
|
|
15404
15527
|
putBack = setBack(top, base, changed);
|
|
15405
15528
|
try {
|
|
15406
|
-
if (!await build(
|
|
15407
|
-
return await runTest(
|
|
15529
|
+
if (!await build(run3, "without the fix", io2)) return BUILD_FAILED;
|
|
15530
|
+
return await runTest(run3, io2);
|
|
15408
15531
|
} finally {
|
|
15409
15532
|
const done = putBack;
|
|
15410
15533
|
putBack = void 0;
|
|
@@ -15415,7 +15538,7 @@ ${HARDEN_USAGE}`);
|
|
|
15415
15538
|
for (const s2 of signals) process.off(s2, interrupted);
|
|
15416
15539
|
}
|
|
15417
15540
|
}
|
|
15418
|
-
async function gate(
|
|
15541
|
+
async function gate(run3, runs, io2, withoutFix) {
|
|
15419
15542
|
const without2 = await withoutFix();
|
|
15420
15543
|
if (without2 === BUILD_FAILED) return 2;
|
|
15421
15544
|
if (without2 === 0) {
|
|
@@ -15423,15 +15546,15 @@ async function gate(run2, runs, io2, withoutFix) {
|
|
|
15423
15546
|
return 1;
|
|
15424
15547
|
}
|
|
15425
15548
|
io2.out(`1. Without the fix: failed (exit ${without2}), as it should.`);
|
|
15426
|
-
if (!await build(
|
|
15427
|
-
const withFix = await runTest(
|
|
15549
|
+
if (!await build(run3, "with the fix", io2)) return 2;
|
|
15550
|
+
const withFix = await runTest(run3, io2);
|
|
15428
15551
|
if (withFix !== 0) {
|
|
15429
15552
|
io2.out(`2. With the fix: failed (exit ${withFix}). \u2716`);
|
|
15430
15553
|
return 1;
|
|
15431
15554
|
}
|
|
15432
15555
|
io2.out("2. With the fix: passed.");
|
|
15433
|
-
if (
|
|
15434
|
-
const code = await runTest({ ...
|
|
15556
|
+
if (run3.repeat) {
|
|
15557
|
+
const code = await runTest({ ...run3, ...run3.repeat, args: run3.repeat.args.map((a2) => a2.replace("{runs}", String(runs))) }, { ...io2, out: () => {
|
|
15435
15558
|
}, err: () => {
|
|
15436
15559
|
} });
|
|
15437
15560
|
if (code !== 0) {
|
|
@@ -15442,7 +15565,7 @@ async function gate(run2, runs, io2, withoutFix) {
|
|
|
15442
15565
|
io2.out("The gate passed.");
|
|
15443
15566
|
return 0;
|
|
15444
15567
|
}
|
|
15445
|
-
const codes = await Promise.all(Array.from({ length: runs }, () => runTest(
|
|
15568
|
+
const codes = await Promise.all(Array.from({ length: runs }, () => runTest(run3, { ...io2, out: () => {
|
|
15446
15569
|
}, err: () => {
|
|
15447
15570
|
} })));
|
|
15448
15571
|
const failed = codes.filter((c) => c !== 0).length;
|
|
@@ -15547,8 +15670,8 @@ function setBack(root, base, files) {
|
|
|
15547
15670
|
return putBack;
|
|
15548
15671
|
}
|
|
15549
15672
|
var BUILD_FAILED = -1;
|
|
15550
|
-
async function build(
|
|
15551
|
-
for (const step of
|
|
15673
|
+
async function build(run3, stage, io2) {
|
|
15674
|
+
for (const step of run3.build ?? []) {
|
|
15552
15675
|
const line = [step.command, ...step.args].join(" ");
|
|
15553
15676
|
io2.out(`Building ${stage}: ${line}`);
|
|
15554
15677
|
let printed = "";
|
|
@@ -15566,9 +15689,9 @@ async function build(run2, stage, io2) {
|
|
|
15566
15689
|
return true;
|
|
15567
15690
|
}
|
|
15568
15691
|
var running = /* @__PURE__ */ new Set();
|
|
15569
|
-
function runTest(
|
|
15692
|
+
function runTest(run3, io2) {
|
|
15570
15693
|
return new Promise((done) => {
|
|
15571
|
-
const child = spawn3(
|
|
15694
|
+
const child = spawn3(run3.command, run3.args, { cwd: run3.cwd, shell: process.platform === "win32" });
|
|
15572
15695
|
running.add(child);
|
|
15573
15696
|
child.on("close", () => running.delete(child));
|
|
15574
15697
|
child.stdout.on("data", (d) => {
|
|
@@ -15578,7 +15701,7 @@ function runTest(run2, io2) {
|
|
|
15578
15701
|
for (const line of d.toString().split("\n")) if (line.trim()) io2.err(` ${line}`);
|
|
15579
15702
|
});
|
|
15580
15703
|
child.on("error", (error) => {
|
|
15581
|
-
io2.err(`${
|
|
15704
|
+
io2.err(`${run3.command}: ${error.message}`);
|
|
15582
15705
|
done(2);
|
|
15583
15706
|
});
|
|
15584
15707
|
child.on("close", (code) => done(code ?? 1));
|
|
@@ -15729,13 +15852,13 @@ function rounds(dir) {
|
|
|
15729
15852
|
if (!existsSync7(dir)) return [];
|
|
15730
15853
|
return readdirSync3(dir).map((d) => join18(dir, d, "round.json")).filter((f) => existsSync7(f)).map((f) => JSON.parse(readFileSync5(f, "utf8"))).sort((a2, b) => a2.from - b.from);
|
|
15731
15854
|
}
|
|
15732
|
-
function portsOf(explore,
|
|
15733
|
-
const nn2 =
|
|
15855
|
+
function portsOf(explore, run3) {
|
|
15856
|
+
const nn2 = run3 % 100;
|
|
15734
15857
|
return { app: explore.ports + nn2, hub: explore.ports + 100 + nn2, other: explore.ports + 200 + nn2 };
|
|
15735
15858
|
}
|
|
15736
|
-
function serveCommands(settings,
|
|
15859
|
+
function serveCommands(settings, round4, entry) {
|
|
15737
15860
|
return settings.explore.serve.map((serve) => {
|
|
15738
|
-
const fill = (part) => part.replace(/\{port\}/g, String(entry.ports.app)).replace(/\{hubPort\}/g, String(entry.ports.hub)).replace(/\{otherPort\}/g, String(entry.ports.other)).replace(/\{build\}/g, join18(
|
|
15861
|
+
const fill = (part) => part.replace(/\{port\}/g, String(entry.ports.app)).replace(/\{hubPort\}/g, String(entry.ports.hub)).replace(/\{otherPort\}/g, String(entry.ports.other)).replace(/\{build\}/g, join18(round4, "build")).replace(/\{run\}/g, entry.folder);
|
|
15739
15862
|
return { cwd: resolve16(settings.root, serve.cwd ?? "."), command: serve.command.map(fill), port: entry.ports[serve.port] };
|
|
15740
15863
|
});
|
|
15741
15864
|
}
|
|
@@ -15788,12 +15911,12 @@ ${r.stdout ?? ""}${r.stderr ?? ""}
|
|
|
15788
15911
|
cpSync(source, join18(dir, "build", copyName), { recursive: true });
|
|
15789
15912
|
}
|
|
15790
15913
|
const runs = [];
|
|
15791
|
-
for (let
|
|
15792
|
-
const folder = join18(dir, `run-${
|
|
15914
|
+
for (let run3 = from; run3 <= to2; run3++) {
|
|
15915
|
+
const folder = join18(dir, `run-${run3}`);
|
|
15793
15916
|
mkdirSync4(folder, { recursive: true });
|
|
15794
|
-
runs.push({ run:
|
|
15917
|
+
runs.push({ run: run3, area: areas[run3 - from], folder, ports: portsOf(explore, run3), verified: [] });
|
|
15795
15918
|
}
|
|
15796
|
-
const
|
|
15919
|
+
const round4 = { round: name, from, to: to2, commit, ...since ? { since } : {}, created: (/* @__PURE__ */ new Date()).toISOString(), runs };
|
|
15797
15920
|
const commits = since ? git5(root, ["log", "--oneline", "--no-decorate", `${since}..HEAD`]).stdout.trim().split("\n").filter(Boolean) : [];
|
|
15798
15921
|
const modelAreas = since && explore.model ? await changedAreas(root, explore.model, since) : [];
|
|
15799
15922
|
const open4 = readFindings(resolve16(root, settings.findings)).filter((f) => f.status === "open" || f.status === "question" || f.status === "hardened");
|
|
@@ -15860,7 +15983,7 @@ ${r.stdout ?? ""}${r.stderr ?? ""}
|
|
|
15860
15983
|
""
|
|
15861
15984
|
].join("\n"));
|
|
15862
15985
|
}
|
|
15863
|
-
writeFileSync3(join18(dir, "round.json"), JSON.stringify(
|
|
15986
|
+
writeFileSync3(join18(dir, "round.json"), JSON.stringify(round4, null, 2) + "\n");
|
|
15864
15987
|
io2.out(`Prepared runs ${from}\u2013${to2} at ${commit} in ${relative10(io2.cwd, dir) || "."}:`);
|
|
15865
15988
|
for (const entry of runs) io2.out(` run ${entry.run}: port ${entry.ports.app}, ${entry.area ?? "area of its choice"} \u2014 ${relative10(io2.cwd, join18(entry.folder, "PROMPT.md"))}`);
|
|
15866
15989
|
if (modelAreas.length) io2.out(`Candidate areas from the model:
|
|
@@ -15886,25 +16009,25 @@ async function changedAreas(root, model, since) {
|
|
|
15886
16009
|
return [...byArea].sort((a2, b) => count(b[1]) - count(a2[1])).map(([area, c]) => `${area}: ${[c.added.length && `${c.added.length} added`, c.changed.length && `${c.changed.length} changed`, c.removed.length && `${c.removed.length} removed`].filter(Boolean).join(", ")} \u2014 ${[...c.changed, ...c.added, ...c.removed].slice(0, 6).join(", ")}${count(c) > 6 ? ", \u2026" : ""}`);
|
|
15887
16010
|
}
|
|
15888
16011
|
var count = (c) => c.added.length + c.changed.length + c.removed.length;
|
|
15889
|
-
var runFolder = (roundsDir,
|
|
15890
|
-
function findRun(settings,
|
|
16012
|
+
var runFolder = (roundsDir, round4, entry) => join18(roundsDir, round4.round, `run-${entry.run}`);
|
|
16013
|
+
function findRun(settings, run3) {
|
|
15891
16014
|
const roundsDir = resolve16(settings.root, settings.explore.rounds);
|
|
15892
|
-
for (const
|
|
15893
|
-
const entry =
|
|
16015
|
+
for (const round4 of rounds(roundsDir)) {
|
|
16016
|
+
const entry = round4.runs.find((r) => r.run === run3);
|
|
15894
16017
|
if (entry) {
|
|
15895
|
-
entry.folder = runFolder(roundsDir,
|
|
15896
|
-
return { dir: join18(roundsDir,
|
|
16018
|
+
entry.folder = runFolder(roundsDir, round4, entry);
|
|
16019
|
+
return { dir: join18(roundsDir, round4.round), round: round4, entry };
|
|
15897
16020
|
}
|
|
15898
16021
|
}
|
|
15899
16022
|
return void 0;
|
|
15900
16023
|
}
|
|
15901
|
-
async function verify(settings,
|
|
15902
|
-
const found = findRun(settings,
|
|
16024
|
+
async function verify(settings, run3, scripts, io2) {
|
|
16025
|
+
const found = findRun(settings, run3);
|
|
15903
16026
|
if (!found) {
|
|
15904
|
-
io2.err(`No round has run ${
|
|
16027
|
+
io2.err(`No round has run ${run3}.`);
|
|
15905
16028
|
return 2;
|
|
15906
16029
|
}
|
|
15907
|
-
const { dir, round:
|
|
16030
|
+
const { dir, round: round4, entry } = found;
|
|
15908
16031
|
const absent = scripts.map((line) => line.trim().split(/\s+/)[0]).find((script) => !existsSync7(resolve16(entry.folder, script)));
|
|
15909
16032
|
if (absent !== void 0) {
|
|
15910
16033
|
io2.err(`No script ${absent} in ${relative10(io2.cwd, entry.folder)}: nothing was run.`);
|
|
@@ -15927,7 +16050,7 @@ async function verify(settings, run2, scripts, io2) {
|
|
|
15927
16050
|
}
|
|
15928
16051
|
if (servers.length) {
|
|
15929
16052
|
const ports = servers.map((s2) => s2.port);
|
|
15930
|
-
io2.out(`Serving run ${
|
|
16053
|
+
io2.out(`Serving run ${run3}'s build on port${ports.length === 1 ? "" : "s"} ${ports.length === 1 ? ports[0] : `${ports.slice(0, -1).join(", ")} and ${ports[ports.length - 1]}`}.`);
|
|
15931
16054
|
}
|
|
15932
16055
|
const shown3 = [];
|
|
15933
16056
|
const notShown = [];
|
|
@@ -15946,7 +16069,7 @@ async function verify(settings, run2, scripts, io2) {
|
|
|
15946
16069
|
entry.verified.push({ at: (/* @__PURE__ */ new Date()).toISOString(), script: line, exit: r.status ?? -1, ...judged.shown !== void 0 ? { shown: judged.shown } : {}, ...says2.length ? { says: says2 } : {} });
|
|
15947
16070
|
}
|
|
15948
16071
|
if (shown3.length || notShown.length) io2.out(`Shows the bug: ${shown3.join(", ") || "none"}. Does not: ${notShown.join(", ") || "none"}.`);
|
|
15949
|
-
writeFileSync3(join18(dir, "round.json"), JSON.stringify(
|
|
16072
|
+
writeFileSync3(join18(dir, "round.json"), JSON.stringify(round4, null, 2) + "\n");
|
|
15950
16073
|
return 0;
|
|
15951
16074
|
} finally {
|
|
15952
16075
|
for (const server of started) {
|
|
@@ -16459,10 +16582,10 @@ function askServer(entry, cwd, place, timeoutMs) {
|
|
|
16459
16582
|
let stdout = "";
|
|
16460
16583
|
let stderr = "";
|
|
16461
16584
|
let version;
|
|
16462
|
-
let
|
|
16585
|
+
let settled2 = false;
|
|
16463
16586
|
const finish = (answer) => {
|
|
16464
|
-
if (
|
|
16465
|
-
|
|
16587
|
+
if (settled2) return;
|
|
16588
|
+
settled2 = true;
|
|
16466
16589
|
clearTimeout(timer);
|
|
16467
16590
|
child.stdin.end();
|
|
16468
16591
|
child.kill();
|
|
@@ -16616,10 +16739,10 @@ async function statusCommand(options, io2) {
|
|
|
16616
16739
|
}
|
|
16617
16740
|
configured++;
|
|
16618
16741
|
const before = problems;
|
|
16619
|
-
const
|
|
16620
|
-
const command = isAbsolute5(
|
|
16742
|
+
const run3 = expanded(entry, place);
|
|
16743
|
+
const command = isAbsolute5(run3.command) ? existsSync10(run3.command) ? run3.command : null : onPath(run3.command, place, entry.env?.PATH);
|
|
16621
16744
|
const launcher = launcherPath(entry, client, place);
|
|
16622
|
-
if (!command &&
|
|
16745
|
+
if (!command && run3.command !== launcherOf(run3)) fail(`${where2}: its command ${entry.command} is not there${entry.env?.PATH ? ` (PATH ${entry.env.PATH})` : ""}: radical setup writes it again`);
|
|
16623
16746
|
if (launcher && !existsSync10(launcher)) fail(`${where2}: its launcher ${shown2(launcher, place)} is not there: download it from https://radical.tools/${launcher.endsWith(".cmd") ? "radical.cmd" : "radical.sh"}`);
|
|
16624
16747
|
if (!servesReal) fail(`${where2}: names no --folder`);
|
|
16625
16748
|
else if (!existsSync10(resolve18(servesReal, "radical.md")) && !folder) fail(`${where2}: serves ${shown2(servesReal, place)}, which holds no model`);
|
|
@@ -16750,13 +16873,24 @@ async function pointAtModel(root, from, to2) {
|
|
|
16750
16873
|
|
|
16751
16874
|
// src/setup.ts
|
|
16752
16875
|
var exec8 = promisify8(execFile8);
|
|
16876
|
+
var NOT_CODE = /^(\.|docs?\/|LICEN[CS]E|COPYING|NOTICE|AUTHORS|CODEOWNERS)|\.(md|markdown|txt|rst|adoc)$/i;
|
|
16877
|
+
async function hasCode(root, folder) {
|
|
16878
|
+
const inModel = (path) => !relative14(folder, resolve20(root, path)).startsWith("..");
|
|
16879
|
+
const listed = await exec8("git", ["ls-files", "--cached", "--others", "--exclude-standard"], { cwd: root, windowsHide: true, maxBuffer: 64 * 1024 * 1024 }).then(({ stdout }) => stdout.split("\n").filter(Boolean), () => null);
|
|
16880
|
+
const files = listed ?? (await readdir5(root, { withFileTypes: true }).catch(() => [])).map((e2) => e2.name + (e2.isDirectory() ? "/" : ""));
|
|
16881
|
+
return files.some((path) => !NOT_CODE.test(path) && !inModel(path));
|
|
16882
|
+
}
|
|
16753
16883
|
var METAMODELS = { radical: builtInGovernanceMetamodel, c4: builtInC4Metamodel };
|
|
16754
16884
|
var SETUP_USAGE = `Usage: radical setup [folder] [options]
|
|
16755
16885
|
radical setup --status [folder] [--no-start] [--timeout <s>]
|
|
16756
16886
|
|
|
16757
16887
|
Connects your coding agents to a Radical model folder, step by step:
|
|
16758
16888
|
1. Node checks the version
|
|
16759
|
-
2. Folder a missing or empty folder becomes a new model
|
|
16889
|
+
2. Folder a missing or empty folder becomes a new model, with the
|
|
16890
|
+
check.json its gate starts from: in a repository without
|
|
16891
|
+
code every rule an error and every goal at 100%; in one with
|
|
16892
|
+
code every rule an error, waiting for the baselines of its
|
|
16893
|
+
first run (radical check --adopt)
|
|
16760
16894
|
3. Other models
|
|
16761
16895
|
the models this one depends on (a federation): their names,
|
|
16762
16896
|
repositories, model folders and versions go into deps.json,
|
|
@@ -16981,6 +17115,15 @@ ${SETUP_USAGE}`);
|
|
|
16981
17115
|
}
|
|
16982
17116
|
io2.out(` + started a new model (${metamodel} metamodel) in ${folderArg}`);
|
|
16983
17117
|
}
|
|
17118
|
+
if (!existsSync12(resolve20(folder, CHECK_CONFIG_FILE))) {
|
|
17119
|
+
const code2 = await hasCode(await repositoryRoot(existsSync12(folder) ? folder : io2.cwd) ?? io2.cwd, folder);
|
|
17120
|
+
const what = code2 ? "every rule an error, waiting for the baselines of its first run: radical check --adopt takes them once the model describes the code" : "every rule an error and every goal at 100%";
|
|
17121
|
+
if (dry) io2.out(` would write ${CHECK_CONFIG_FILE}: ${what}`);
|
|
17122
|
+
else {
|
|
17123
|
+
await writeFile11(resolve20(folder, CHECK_CONFIG_FILE), serializeCheckConfig(code2 ? existingCodeCheckConfig2() : strictCheckConfig2()));
|
|
17124
|
+
io2.out(` + ${CHECK_CONFIG_FILE}: ${what}`);
|
|
17125
|
+
}
|
|
17126
|
+
}
|
|
16984
17127
|
} else if (!existsSync12(resolve20(folder, "radical.md"))) {
|
|
16985
17128
|
io2.err(`radical setup: ${folderArg} holds other files and no radical.md, so it is not a Radical model folder. Name an empty or new folder, or one with a model.`);
|
|
16986
17129
|
return 2;
|
|
@@ -17098,8 +17241,8 @@ Next: restart the agents you connected (quit Claude Desktop and Cursor fully, ru
|
|
|
17098
17241
|
|
|
17099
17242
|
// src/sense.ts
|
|
17100
17243
|
init_define_RADICAL_BUILD();
|
|
17101
|
-
import { mkdir as
|
|
17102
|
-
import { basename as basename5, dirname as
|
|
17244
|
+
import { mkdir as mkdir13, readFile as readFile21, rm as rm6, stat as stat12, writeFile as writeFile13 } from "fs/promises";
|
|
17245
|
+
import { basename as basename5, dirname as dirname20, join as join25, resolve as resolve24 } from "path";
|
|
17103
17246
|
import { parseArgs as parseArgs13 } from "util";
|
|
17104
17247
|
|
|
17105
17248
|
// src/sensors/registry.ts
|
|
@@ -17122,11 +17265,11 @@ var commandAdapter = {
|
|
|
17122
17265
|
if (!args.length) throw new Error("no command after --");
|
|
17123
17266
|
const name = typeof options.name === "string" && options.name ? options.name : "command";
|
|
17124
17267
|
const started = process.hrtime.bigint();
|
|
17125
|
-
const code = await new Promise((
|
|
17268
|
+
const code = await new Promise((resolve28, reject) => {
|
|
17126
17269
|
const child = spawn6(args[0], args.slice(1), { cwd, stdio: ["ignore", "pipe", "inherit"], shell: process.platform === "win32" });
|
|
17127
17270
|
child.stdout?.pipe(process.stderr);
|
|
17128
17271
|
child.on("error", (error) => reject(new Error(`cannot run ${args[0]}: ${error.message}`)));
|
|
17129
|
-
child.on("close", (status, signal) =>
|
|
17272
|
+
child.on("close", (status, signal) => resolve28(status ?? (signal ? 128 : 1)));
|
|
17130
17273
|
});
|
|
17131
17274
|
const seconds = Number(process.hrtime.bigint() - started) / 1e9;
|
|
17132
17275
|
return [
|
|
@@ -17137,6 +17280,296 @@ var commandAdapter = {
|
|
|
17137
17280
|
fixture: { args: [process.execPath, "-e", "process.exit(3)"], options: { name: "fixture" } }
|
|
17138
17281
|
};
|
|
17139
17282
|
|
|
17283
|
+
// src/sensors/github-actions.ts
|
|
17284
|
+
init_define_RADICAL_BUILD();
|
|
17285
|
+
import { spawn as spawn7 } from "child_process";
|
|
17286
|
+
var GH = "gh";
|
|
17287
|
+
var DAYS = 30;
|
|
17288
|
+
var BRANCH = "main";
|
|
17289
|
+
function runGh(command, base, args, cwd) {
|
|
17290
|
+
return new Promise((done, fail) => {
|
|
17291
|
+
const child = spawn7(command, [...base, ...args], { cwd, stdio: ["ignore", "pipe", "pipe"], shell: process.platform === "win32" });
|
|
17292
|
+
let stdout = "";
|
|
17293
|
+
let stderr = "";
|
|
17294
|
+
child.stdout.setEncoding("utf8").on("data", (d) => {
|
|
17295
|
+
stdout += d;
|
|
17296
|
+
});
|
|
17297
|
+
child.stderr.setEncoding("utf8").on("data", (d) => {
|
|
17298
|
+
stderr += d;
|
|
17299
|
+
});
|
|
17300
|
+
child.on("error", (error) => fail(new Error(`cannot run ${command}: ${error.message}${command === GH ? " (install the GitHub CLI, https://cli.github.com, and sign in with gh auth login)" : ""}`)));
|
|
17301
|
+
child.on("close", (status, signal) => done({ code: status ?? (signal ? 128 : 1), stdout, stderr }));
|
|
17302
|
+
});
|
|
17303
|
+
}
|
|
17304
|
+
function jsonValues(text3) {
|
|
17305
|
+
const out = [];
|
|
17306
|
+
let depth = 0;
|
|
17307
|
+
let start = -1;
|
|
17308
|
+
let inString = false;
|
|
17309
|
+
let escaped = false;
|
|
17310
|
+
for (let i = 0; i < text3.length; i++) {
|
|
17311
|
+
const ch = text3[i];
|
|
17312
|
+
if (inString) {
|
|
17313
|
+
if (escaped) escaped = false;
|
|
17314
|
+
else if (ch === "\\") escaped = true;
|
|
17315
|
+
else if (ch === '"') inString = false;
|
|
17316
|
+
continue;
|
|
17317
|
+
}
|
|
17318
|
+
if (ch === '"') {
|
|
17319
|
+
inString = true;
|
|
17320
|
+
if (start < 0) start = i;
|
|
17321
|
+
continue;
|
|
17322
|
+
}
|
|
17323
|
+
if (ch === "{" || ch === "[") {
|
|
17324
|
+
if (depth === 0) start = i;
|
|
17325
|
+
depth++;
|
|
17326
|
+
continue;
|
|
17327
|
+
}
|
|
17328
|
+
if (ch === "}" || ch === "]") {
|
|
17329
|
+
depth--;
|
|
17330
|
+
if (depth === 0 && start >= 0) {
|
|
17331
|
+
out.push(JSON.parse(text3.slice(start, i + 1)));
|
|
17332
|
+
start = -1;
|
|
17333
|
+
}
|
|
17334
|
+
continue;
|
|
17335
|
+
}
|
|
17336
|
+
if (depth === 0 && /\s/.test(ch) && start >= 0) {
|
|
17337
|
+
out.push(JSON.parse(text3.slice(start, i)));
|
|
17338
|
+
start = -1;
|
|
17339
|
+
continue;
|
|
17340
|
+
}
|
|
17341
|
+
if (depth === 0 && !/\s/.test(ch) && start < 0) start = i;
|
|
17342
|
+
}
|
|
17343
|
+
if (start >= 0) out.push(JSON.parse(text3.slice(start)));
|
|
17344
|
+
return out;
|
|
17345
|
+
}
|
|
17346
|
+
var httpStatus = (r) => {
|
|
17347
|
+
const m = /\(HTTP (\d{3})\)/.exec(r.stderr);
|
|
17348
|
+
return m ? Number(m[1]) : void 0;
|
|
17349
|
+
};
|
|
17350
|
+
var time = (iso) => iso ? Date.parse(iso) : NaN;
|
|
17351
|
+
function percentile(values, p) {
|
|
17352
|
+
const v = [...values].sort((a2, b) => a2 - b);
|
|
17353
|
+
const at = (v.length - 1) * p;
|
|
17354
|
+
const lo = Math.floor(at);
|
|
17355
|
+
const hi2 = Math.ceil(at);
|
|
17356
|
+
return v[lo] + (v[hi2] - v[lo]) * (at - lo);
|
|
17357
|
+
}
|
|
17358
|
+
var round2 = (n, digits) => Math.round(n * 10 ** digits) / 10 ** digits;
|
|
17359
|
+
function settled(runs) {
|
|
17360
|
+
const counted = runs.filter((r) => !(r.status === "completed" && (r.conclusion === "cancelled" || r.conclusion === "skipped")));
|
|
17361
|
+
return counted.length && counted.every((r) => r.status === "completed") ? counted : void 0;
|
|
17362
|
+
}
|
|
17363
|
+
function bySha(runs) {
|
|
17364
|
+
const groups = /* @__PURE__ */ new Map();
|
|
17365
|
+
for (const r of runs) {
|
|
17366
|
+
if (!r.head_sha) continue;
|
|
17367
|
+
groups.set(r.head_sha, [...groups.get(r.head_sha) ?? [], r]);
|
|
17368
|
+
}
|
|
17369
|
+
return [...groups.values()];
|
|
17370
|
+
}
|
|
17371
|
+
var matchesWorkflow = (run3, names) => !names.length || names.some((w) => run3.name === w || run3.path === w || (run3.path ?? "").endsWith(`/${w}`));
|
|
17372
|
+
function runValues(runs, branch) {
|
|
17373
|
+
const values = [];
|
|
17374
|
+
const pr2 = [];
|
|
17375
|
+
for (const group of bySha(runs.filter((r) => r.event === "pull_request"))) {
|
|
17376
|
+
const done = settled(group);
|
|
17377
|
+
if (!done) continue;
|
|
17378
|
+
const start = Math.min(...done.map((r) => time(r.run_started_at ?? r.created_at)));
|
|
17379
|
+
const end = Math.max(...done.map((r) => time(r.updated_at)));
|
|
17380
|
+
if (Number.isFinite(start) && Number.isFinite(end) && end >= start) pr2.push((end - start) / 6e4);
|
|
17381
|
+
}
|
|
17382
|
+
if (pr2.length) {
|
|
17383
|
+
values.push({ metric: "ci.pr.duration.p50", value: round2(percentile(pr2, 0.5), 2), unit: "min" });
|
|
17384
|
+
values.push({ metric: "ci.pr.duration.p90", value: round2(percentile(pr2, 0.9), 2), unit: "min" });
|
|
17385
|
+
}
|
|
17386
|
+
const commits = bySha(runs.filter((r) => r.event === "push" && r.head_branch === branch)).map(settled).filter((g) => !!g);
|
|
17387
|
+
if (commits.length) {
|
|
17388
|
+
const green = commits.filter((g) => g.every((r) => r.conclusion === "success")).length;
|
|
17389
|
+
values.push({ metric: "ci.main.success.rate", value: round2(green / commits.length * 100, 1), unit: "%" });
|
|
17390
|
+
}
|
|
17391
|
+
const completed = runs.filter((r) => r.status === "completed");
|
|
17392
|
+
if (completed.length) {
|
|
17393
|
+
const reruns = completed.filter((r) => (r.run_attempt ?? 1) > 1).length;
|
|
17394
|
+
values.push({ metric: "ci.rerun.rate", value: round2(reruns / completed.length * 100, 1), unit: "%" });
|
|
17395
|
+
}
|
|
17396
|
+
values.push({ metric: "ci.runs", value: completed.length });
|
|
17397
|
+
return values;
|
|
17398
|
+
}
|
|
17399
|
+
function branchRules(rules, protection) {
|
|
17400
|
+
const checks = /* @__PURE__ */ new Set();
|
|
17401
|
+
let reviews = 0;
|
|
17402
|
+
for (const rule of rules.flatMap((page) => Array.isArray(page) ? page : [page])) {
|
|
17403
|
+
if (rule?.type === "required_status_checks") {
|
|
17404
|
+
for (const c of rule.parameters?.required_status_checks ?? []) if (typeof c?.context === "string") checks.add(c.context);
|
|
17405
|
+
} else if (rule?.type === "pull_request") {
|
|
17406
|
+
const n2 = rule.parameters?.required_approving_review_count;
|
|
17407
|
+
if (typeof n2 === "number") reviews = Math.max(reviews, n2);
|
|
17408
|
+
}
|
|
17409
|
+
}
|
|
17410
|
+
const p = protection;
|
|
17411
|
+
for (const c of p?.required_status_checks?.contexts ?? []) if (typeof c === "string") checks.add(c);
|
|
17412
|
+
for (const c of p?.required_status_checks?.checks ?? []) if (typeof c?.context === "string") checks.add(c.context);
|
|
17413
|
+
const n = p?.required_pull_request_reviews?.required_approving_review_count;
|
|
17414
|
+
if (typeof n === "number") reviews = Math.max(reviews, n);
|
|
17415
|
+
return { checks: checks.size, reviews };
|
|
17416
|
+
}
|
|
17417
|
+
var option = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
17418
|
+
var run2 = (o) => ({
|
|
17419
|
+
workflow_id: 0,
|
|
17420
|
+
run_number: o.id,
|
|
17421
|
+
status: "completed",
|
|
17422
|
+
conclusion: "success",
|
|
17423
|
+
run_attempt: 1,
|
|
17424
|
+
...o
|
|
17425
|
+
});
|
|
17426
|
+
var FIXTURE_RUNS = [
|
|
17427
|
+
run2({ id: 101, name: "CI", path: ".github/workflows/ci.yml", event: "pull_request", head_branch: "feat/cart", head_sha: "a1", run_started_at: "2026-11-20T10:00:00Z", created_at: "2026-11-20T10:00:00Z", updated_at: "2026-11-20T10:08:00Z" }),
|
|
17428
|
+
run2({ id: 102, name: "Lint", path: ".github/workflows/lint.yml", event: "pull_request", head_branch: "feat/cart", head_sha: "a1", run_started_at: "2026-11-20T10:00:30Z", created_at: "2026-11-20T10:00:30Z", updated_at: "2026-11-20T10:03:00Z" }),
|
|
17429
|
+
run2({ id: 103, name: "CI", path: ".github/workflows/ci.yml", event: "pull_request", head_branch: "feat/cart", head_sha: "a2", run_started_at: "2026-11-20T11:00:00Z", created_at: "2026-11-20T11:00:00Z", updated_at: "2026-11-20T11:12:00Z" }),
|
|
17430
|
+
run2({ id: 104, name: "E2E", path: ".github/workflows/e2e.yml", event: "pull_request", head_branch: "feat/cart", head_sha: "a2", run_attempt: 2, run_started_at: "2026-11-20T11:01:00Z", created_at: "2026-11-20T11:00:10Z", updated_at: "2026-11-20T11:20:00Z" }),
|
|
17431
|
+
run2({ id: 105, name: "CI", path: ".github/workflows/ci.yml", event: "pull_request", head_branch: "fix/tax", head_sha: "a3", run_started_at: "2026-11-21T12:00:00Z", created_at: "2026-11-21T12:00:00Z", updated_at: "2026-11-21T12:05:00Z" }),
|
|
17432
|
+
run2({ id: 106, name: "CI", path: ".github/workflows/ci.yml", event: "pull_request", head_branch: "fix/tax", head_sha: "a3", conclusion: "cancelled", run_started_at: "2026-11-21T11:58:00Z", created_at: "2026-11-21T11:58:00Z", updated_at: "2026-11-21T12:30:00Z" }),
|
|
17433
|
+
run2({ id: 107, name: "CI", path: ".github/workflows/ci.yml", event: "pull_request", head_branch: "fix/tax", head_sha: "a4", status: "in_progress", conclusion: null, run_started_at: "2026-11-24T08:00:00Z", created_at: "2026-11-24T08:00:00Z", updated_at: "2026-11-24T08:02:00Z" }),
|
|
17434
|
+
run2({ id: 201, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "main", head_sha: "m1", run_started_at: "2026-11-20T13:00:00Z", created_at: "2026-11-20T13:00:00Z", updated_at: "2026-11-20T13:09:00Z" }),
|
|
17435
|
+
run2({ id: 202, name: "Deploy", path: ".github/workflows/deploy.yml", event: "push", head_branch: "main", head_sha: "m1", run_started_at: "2026-11-20T13:00:05Z", created_at: "2026-11-20T13:00:05Z", updated_at: "2026-11-20T13:04:00Z" }),
|
|
17436
|
+
run2({ id: 203, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "main", head_sha: "m2", conclusion: "failure", run_started_at: "2026-11-21T09:00:00Z", created_at: "2026-11-21T09:00:00Z", updated_at: "2026-11-21T09:07:00Z" }),
|
|
17437
|
+
run2({ id: 204, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "main", head_sha: "m3", run_started_at: "2026-11-22T09:00:00Z", created_at: "2026-11-22T09:00:00Z", updated_at: "2026-11-22T09:08:00Z" }),
|
|
17438
|
+
run2({ id: 205, name: "Deploy", path: ".github/workflows/deploy.yml", event: "push", head_branch: "main", head_sha: "m3", conclusion: "cancelled", run_started_at: "2026-11-22T09:00:05Z", created_at: "2026-11-22T09:00:05Z", updated_at: "2026-11-22T09:01:00Z" }),
|
|
17439
|
+
run2({ id: 206, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "main", head_sha: "m4", conclusion: "cancelled", run_started_at: "2026-11-22T10:00:00Z", created_at: "2026-11-22T10:00:00Z", updated_at: "2026-11-22T10:01:00Z" }),
|
|
17440
|
+
run2({ id: 207, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "main", head_sha: "m5", run_attempt: 2, run_started_at: "2026-11-23T09:20:00Z", created_at: "2026-11-23T09:00:00Z", updated_at: "2026-11-23T09:29:00Z" }),
|
|
17441
|
+
run2({ id: 208, name: "CI", path: ".github/workflows/ci.yml", event: "push", head_branch: "feat/cart", head_sha: "a1", conclusion: "failure", run_started_at: "2026-11-20T09:50:00Z", created_at: "2026-11-20T09:50:00Z", updated_at: "2026-11-20T09:55:00Z" })
|
|
17442
|
+
];
|
|
17443
|
+
var FIXTURE_ANSWERS = {
|
|
17444
|
+
"repo view": { out: "acme/shop" },
|
|
17445
|
+
"actions/runs": { pages: [
|
|
17446
|
+
{ total_count: FIXTURE_RUNS.length, workflow_runs: FIXTURE_RUNS.slice(0, 8) },
|
|
17447
|
+
{ total_count: FIXTURE_RUNS.length, workflow_runs: FIXTURE_RUNS.slice(8) }
|
|
17448
|
+
] },
|
|
17449
|
+
"rules/branches/": { pages: [[
|
|
17450
|
+
{ type: "deletion", ruleset_source_type: "Repository", ruleset_source: "acme/shop", ruleset_id: 42 },
|
|
17451
|
+
{ type: "required_status_checks", ruleset_source_type: "Repository", ruleset_source: "acme/shop", ruleset_id: 42, parameters: { strict_required_status_checks_policy: true, required_status_checks: [{ context: "CI / test", integration_id: 15368 }, { context: "Lint" }] } },
|
|
17452
|
+
{ type: "pull_request", ruleset_source_type: "Organization", ruleset_source: "acme", ruleset_id: 7, parameters: { required_approving_review_count: 1, dismiss_stale_reviews_on_push: true, require_code_owner_review: false, require_last_push_approval: false, required_review_thread_resolution: false } }
|
|
17453
|
+
]] },
|
|
17454
|
+
"/protection": { out: {
|
|
17455
|
+
url: "https://api.github.com/repos/acme/shop/branches/main/protection",
|
|
17456
|
+
required_status_checks: { strict: true, contexts: ["CI / test", "E2E"], checks: [{ context: "CI / test", app_id: 15368 }, { context: "E2E", app_id: 15368 }] },
|
|
17457
|
+
required_pull_request_reviews: { dismiss_stale_reviews: false, require_code_owner_reviews: false, required_approving_review_count: 2 },
|
|
17458
|
+
enforce_admins: { enabled: false }
|
|
17459
|
+
} }
|
|
17460
|
+
};
|
|
17461
|
+
var FIXTURE_GH = `import { appendFileSync, readFileSync } from 'node:fs'
|
|
17462
|
+
const args = process.argv.slice(2)
|
|
17463
|
+
appendFileSync('gh-calls.log', JSON.stringify(args) + '\\n')
|
|
17464
|
+
const line = args.join(' ')
|
|
17465
|
+
const answers = JSON.parse(readFileSync('gh-answers.json', 'utf8'))
|
|
17466
|
+
const found = Object.entries(answers).find(([pattern]) => line.includes(pattern))
|
|
17467
|
+
if (!found) { process.stderr.write('gh: no answer for ' + line + '\\n'); process.exit(1) }
|
|
17468
|
+
const answer = found[1]
|
|
17469
|
+
if (answer.status) {
|
|
17470
|
+
process.stdout.write(JSON.stringify({ message: answer.message, status: String(answer.status) }))
|
|
17471
|
+
process.stderr.write('gh: ' + answer.message + ' (HTTP ' + answer.status + ')\\n')
|
|
17472
|
+
process.exit(1)
|
|
17473
|
+
}
|
|
17474
|
+
if (answer.pages) process.stdout.write(answer.pages.map((p) => JSON.stringify(p, null, 2)).join(''))
|
|
17475
|
+
else process.stdout.write(typeof answer.out === 'string' ? answer.out + '\\n' : JSON.stringify(answer.out))
|
|
17476
|
+
`;
|
|
17477
|
+
var githubActionsAdapter = {
|
|
17478
|
+
name: "github-actions",
|
|
17479
|
+
description: "reads a repository's GitHub Actions runs and branch rules with the GitHub CLI (gh): pipeline time, success, reruns, required checks",
|
|
17480
|
+
usage: `radical sense github-actions [--repo <owner/name>] [--branch <name>] [--days <n>] [--workflow <name>]\u2026 [--gh <command>]
|
|
17481
|
+
|
|
17482
|
+
--repo <owner/name> the repository (default: the one gh finds in the working
|
|
17483
|
+
directory, gh repo view)
|
|
17484
|
+
--branch <name> the branch that is pushed to and protected (default: ${BRANCH})
|
|
17485
|
+
--days <n> the runs created in the last n days (default: ${DAYS};
|
|
17486
|
+
GitHub lists at most 1000 runs)
|
|
17487
|
+
--workflow <name> only the runs of this workflow, by its name or its file
|
|
17488
|
+
(ci.yml); repeat for more (default: every workflow)
|
|
17489
|
+
--gh <command> the command that runs the GitHub CLI (default: ${GH}); it
|
|
17490
|
+
must be signed in (gh auth login, or GH_TOKEN)
|
|
17491
|
+
Measures, with no labels:
|
|
17492
|
+
ci.pr.duration.p50, ci.pr.duration.p90 (min): the wall time of one pull
|
|
17493
|
+
request commit, from the first start to the last end of its runs (event
|
|
17494
|
+
pull_request, by head commit), over the commits whose runs completed
|
|
17495
|
+
ci.main.success.rate (%): the share of the commits pushed to the branch
|
|
17496
|
+
whose completed runs all succeeded
|
|
17497
|
+
ci.rerun.rate (%): the share of completed runs that ran more than once
|
|
17498
|
+
ci.runs: the completed runs read
|
|
17499
|
+
ci.required-checks: the required status checks of the branch, its classic
|
|
17500
|
+
protection and its rulesets together (protection gh may not read, which
|
|
17501
|
+
needs admin rights, counts as none)
|
|
17502
|
+
ci.required-reviews: the required approving reviews, the larger of the two
|
|
17503
|
+
Cancelled and skipped runs are left out of the time and the success rate.`,
|
|
17504
|
+
options: {
|
|
17505
|
+
repo: { type: "string" },
|
|
17506
|
+
branch: { type: "string" },
|
|
17507
|
+
days: { type: "string" },
|
|
17508
|
+
workflow: { type: "string", multiple: true },
|
|
17509
|
+
gh: { type: "string" }
|
|
17510
|
+
},
|
|
17511
|
+
async measure({ args, options, cwd }) {
|
|
17512
|
+
if (args.length) throw new Error(`github-actions takes no input (${args.join(" ")}): name the repository with --repo`);
|
|
17513
|
+
const [command, ...base] = commandWords(option(options.gh) ?? GH);
|
|
17514
|
+
const gh = async (...a2) => runGh(command, base, a2, cwd);
|
|
17515
|
+
const failed = (what, r) => new Error(`${what}: ${r.stderr.trim() || `${command} exited with ${r.code}`}`);
|
|
17516
|
+
const branch = option(options.branch) ?? BRANCH;
|
|
17517
|
+
const daysText = option(options.days) ?? String(DAYS);
|
|
17518
|
+
const days = Number(daysText);
|
|
17519
|
+
if (!Number.isInteger(days) || days < 1) throw new Error(`--days ${daysText} is not a whole number of days`);
|
|
17520
|
+
const workflows = (Array.isArray(options.workflow) ? options.workflow : []).map((w) => w.trim()).filter(Boolean);
|
|
17521
|
+
let repo = option(options.repo);
|
|
17522
|
+
if (!repo) {
|
|
17523
|
+
const r = await gh("repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner");
|
|
17524
|
+
if (r.code !== 0) throw failed("cannot tell the repository (name it with --repo)", r);
|
|
17525
|
+
repo = r.stdout.trim();
|
|
17526
|
+
}
|
|
17527
|
+
if (!/^[\w.-]+\/[\w.-]+$/.test(repo)) throw new Error(`${repo} is not <owner>/<name>`);
|
|
17528
|
+
const since = new Date(Date.now() - days * 864e5).toISOString().slice(0, 10);
|
|
17529
|
+
const listed = await gh("api", "--paginate", `repos/${repo}/actions/runs?created=%3E%3D${since}&exclude_pull_requests=true&per_page=100`);
|
|
17530
|
+
if (listed.code !== 0) throw failed(`cannot read the workflow runs of ${repo}`, listed);
|
|
17531
|
+
let pages;
|
|
17532
|
+
try {
|
|
17533
|
+
pages = jsonValues(listed.stdout);
|
|
17534
|
+
} catch (error) {
|
|
17535
|
+
throw new Error(`the workflow runs of ${repo} are no JSON: ${error.message}`);
|
|
17536
|
+
}
|
|
17537
|
+
const runs = pages.flatMap((page) => {
|
|
17538
|
+
if (Array.isArray(page)) return page;
|
|
17539
|
+
const list = page?.workflow_runs;
|
|
17540
|
+
return Array.isArray(list) ? list : [page];
|
|
17541
|
+
}).filter((r) => r && typeof r === "object" && matchesWorkflow(r, workflows));
|
|
17542
|
+
const ref = encodeURIComponent(branch);
|
|
17543
|
+
const optional = async (path, what, paginate) => {
|
|
17544
|
+
const r = await gh("api", ...paginate ? ["--paginate"] : [], path);
|
|
17545
|
+
if (r.code === 0) return jsonValues(r.stdout);
|
|
17546
|
+
const status = httpStatus(r);
|
|
17547
|
+
if (status === 404 || status === 403) {
|
|
17548
|
+
if (status === 403) process.stderr.write(`radical sense github-actions: cannot read the ${what} of ${branch} (HTTP 403); counted as none
|
|
17549
|
+
`);
|
|
17550
|
+
return [];
|
|
17551
|
+
}
|
|
17552
|
+
throw failed(`cannot read the ${what} of ${branch}`, r);
|
|
17553
|
+
};
|
|
17554
|
+
const rules = await optional(`repos/${repo}/rules/branches/${ref}`, "rulesets", true);
|
|
17555
|
+
const [protection] = await optional(`repos/${repo}/branches/${ref}/protection`, "branch protection", false);
|
|
17556
|
+
const { checks, reviews } = branchRules(rules, protection ?? null);
|
|
17557
|
+
return [
|
|
17558
|
+
...runValues(runs, branch),
|
|
17559
|
+
{ metric: "ci.required-checks", value: checks },
|
|
17560
|
+
{ metric: "ci.required-reviews", value: reviews }
|
|
17561
|
+
];
|
|
17562
|
+
},
|
|
17563
|
+
fixture: {
|
|
17564
|
+
args: [],
|
|
17565
|
+
options: { gh: `"${process.execPath}" gh.mjs`, branch: "main", days: "30" },
|
|
17566
|
+
files: {
|
|
17567
|
+
"gh.mjs": FIXTURE_GH,
|
|
17568
|
+
"gh-answers.json": JSON.stringify(FIXTURE_ANSWERS, null, 2)
|
|
17569
|
+
}
|
|
17570
|
+
}
|
|
17571
|
+
};
|
|
17572
|
+
|
|
17140
17573
|
// src/sensors/json.ts
|
|
17141
17574
|
init_define_RADICAL_BUILD();
|
|
17142
17575
|
import { readFile as readFile17 } from "fs/promises";
|
|
@@ -17189,12 +17622,336 @@ var jsonAdapter = {
|
|
|
17189
17622
|
}
|
|
17190
17623
|
};
|
|
17191
17624
|
|
|
17625
|
+
// src/sensors/lighthouse.ts
|
|
17626
|
+
init_define_RADICAL_BUILD();
|
|
17627
|
+
import { readdir as readdir6, readFile as readFile18, stat as stat11 } from "fs/promises";
|
|
17628
|
+
import { join as join22, resolve as resolve22 } from "path";
|
|
17629
|
+
var DEFAULT_INPUT = ".lighthouseci";
|
|
17630
|
+
var AUDITS = [
|
|
17631
|
+
{ metric: "web.lab.lcp", audit: "largest-contentful-paint", unit: "ms" },
|
|
17632
|
+
{ metric: "web.lab.fcp", audit: "first-contentful-paint", unit: "ms" },
|
|
17633
|
+
{ metric: "web.lab.tbt", audit: "total-blocking-time", unit: "ms" },
|
|
17634
|
+
{ metric: "web.lab.speed_index", audit: "speed-index", unit: "ms" },
|
|
17635
|
+
{ metric: "web.lab.cls", audit: "cumulative-layout-shift" },
|
|
17636
|
+
// Only timespan reports (a user flow's interactions) have it.
|
|
17637
|
+
{ metric: "web.lab.inp", audit: "interaction-to-next-paint", unit: "ms" },
|
|
17638
|
+
{ metric: "web.lab.bytes", audit: "total-byte-weight", unit: "B" }
|
|
17639
|
+
];
|
|
17640
|
+
var CATEGORIES = ["performance", "accessibility", "best-practices", "seo"];
|
|
17641
|
+
var isLhr = (data) => !!data && typeof data === "object" && typeof data.lighthouseVersion === "string" && !!data.audits && typeof data.audits === "object";
|
|
17642
|
+
function reportsIn(data) {
|
|
17643
|
+
if (isLhr(data)) return [data];
|
|
17644
|
+
const steps = data?.steps;
|
|
17645
|
+
if (Array.isArray(steps)) return steps.map((s2) => s2?.lhr).filter(isLhr);
|
|
17646
|
+
return [];
|
|
17647
|
+
}
|
|
17648
|
+
var finite = (v) => typeof v === "number" && Number.isFinite(v);
|
|
17649
|
+
function pageOf2(lhr, file) {
|
|
17650
|
+
const url = lhr.finalDisplayedUrl ?? lhr.finalUrl ?? lhr.requestedUrl;
|
|
17651
|
+
if (!url) throw new Error(`${file}: the report names no URL (finalDisplayedUrl, finalUrl, requestedUrl)`);
|
|
17652
|
+
try {
|
|
17653
|
+
const u = new URL(url);
|
|
17654
|
+
return `${u.pathname}${u.search}`;
|
|
17655
|
+
} catch {
|
|
17656
|
+
return url;
|
|
17657
|
+
}
|
|
17658
|
+
}
|
|
17659
|
+
var deviceOf = (lhr) => (lhr.configSettings?.formFactor ?? lhr.configSettings?.emulatedFormFactor) === "desktop" ? "desktop" : "mobile";
|
|
17660
|
+
function valuesOf2(lhr) {
|
|
17661
|
+
const out = [];
|
|
17662
|
+
for (const a2 of AUDITS) {
|
|
17663
|
+
const value = lhr.audits[a2.audit]?.numericValue;
|
|
17664
|
+
if (finite(value)) out.push({ metric: a2.metric, value, ...a2.unit ? { unit: a2.unit } : {} });
|
|
17665
|
+
}
|
|
17666
|
+
const items = lhr.audits["resource-summary"]?.details?.items;
|
|
17667
|
+
const script = Array.isArray(items) ? items.find((i) => i?.resourceType === "script")?.transferSize : void 0;
|
|
17668
|
+
if (finite(script)) out.push({ metric: "web.lab.script_bytes", value: script, unit: "B" });
|
|
17669
|
+
for (const category of CATEGORIES) {
|
|
17670
|
+
const score = lhr.categories?.[category]?.score;
|
|
17671
|
+
if (finite(score)) out.push({ metric: "web.lab.score", value: Math.round(score * 100), category });
|
|
17672
|
+
}
|
|
17673
|
+
return out;
|
|
17674
|
+
}
|
|
17675
|
+
function median(values) {
|
|
17676
|
+
const v = [...values].sort((a2, b) => a2 - b);
|
|
17677
|
+
const mid = Math.floor(v.length / 2);
|
|
17678
|
+
return v.length % 2 ? v[mid] : (v[mid - 1] + v[mid]) / 2;
|
|
17679
|
+
}
|
|
17680
|
+
var round3 = (n) => Math.round(n * 1e3) / 1e3;
|
|
17681
|
+
async function readReports(inputs, cwd) {
|
|
17682
|
+
const out = [];
|
|
17683
|
+
const parse3 = async (path, shown3) => {
|
|
17684
|
+
const text3 = await readFile18(path, "utf8");
|
|
17685
|
+
try {
|
|
17686
|
+
return JSON.parse(text3);
|
|
17687
|
+
} catch (error) {
|
|
17688
|
+
throw new Error(`${shown3} is no JSON: ${error.message}`);
|
|
17689
|
+
}
|
|
17690
|
+
};
|
|
17691
|
+
for (const input of inputs) {
|
|
17692
|
+
const path = resolve22(cwd, input);
|
|
17693
|
+
const kind = await stat11(path).then((s2) => s2.isDirectory() ? "dir" : "file", () => null);
|
|
17694
|
+
if (!kind) throw new Error(`cannot read ${input}: no such file or directory${input === DEFAULT_INPUT ? " (run Lighthouse CI first, or name the reports)" : ""}`);
|
|
17695
|
+
if (kind === "file") {
|
|
17696
|
+
const reports = reportsIn(await parse3(path, input));
|
|
17697
|
+
if (!reports.length) throw new Error(`${input} is no Lighthouse report (no lighthouseVersion and audits)`);
|
|
17698
|
+
out.push(...reports.map((lhr) => ({ file: input, lhr })));
|
|
17699
|
+
continue;
|
|
17700
|
+
}
|
|
17701
|
+
for (const name of (await readdir6(path)).filter((f) => f.endsWith(".json")).sort()) {
|
|
17702
|
+
const shown3 = join22(input, name);
|
|
17703
|
+
out.push(...reportsIn(await parse3(join22(path, name), shown3)).map((lhr) => ({ file: shown3, lhr })));
|
|
17704
|
+
}
|
|
17705
|
+
}
|
|
17706
|
+
return out;
|
|
17707
|
+
}
|
|
17708
|
+
function lighthouseValues(reports) {
|
|
17709
|
+
const series = /* @__PURE__ */ new Map();
|
|
17710
|
+
for (const { file, lhr } of reports) {
|
|
17711
|
+
if (lhr.runtimeError?.code) continue;
|
|
17712
|
+
const labels = { page: pageOf2(lhr, file), device: deviceOf(lhr) };
|
|
17713
|
+
for (const v of valuesOf2(lhr)) {
|
|
17714
|
+
const l = v.category ? { ...labels, category: v.category } : labels;
|
|
17715
|
+
const key = JSON.stringify([v.metric, l.page, l.device, v.category ?? ""]);
|
|
17716
|
+
const s2 = series.get(key) ?? { metric: v.metric, ...v.unit ? { unit: v.unit } : {}, labels: l, values: [] };
|
|
17717
|
+
s2.values.push(v.value);
|
|
17718
|
+
series.set(key, s2);
|
|
17719
|
+
}
|
|
17720
|
+
}
|
|
17721
|
+
const perPage = [...series.values()].map((s2) => ({ metric: s2.metric, value: round3(median(s2.values)), ...s2.unit ? { unit: s2.unit } : {}, labels: s2.labels }));
|
|
17722
|
+
const across = /* @__PURE__ */ new Map();
|
|
17723
|
+
for (const v of perPage) {
|
|
17724
|
+
const { page: _page, ...labels } = v.labels ?? {};
|
|
17725
|
+
const score = v.metric === "web.lab.score";
|
|
17726
|
+
const metric = `${v.metric}.${score ? "min" : "max"}`;
|
|
17727
|
+
const key = JSON.stringify([metric, labels.device, labels.category ?? ""]);
|
|
17728
|
+
const at = across.get(key);
|
|
17729
|
+
if (!at || (score ? v.value < at.value : v.value > at.value)) across.set(key, { metric, value: v.value, ...v.unit ? { unit: v.unit } : {}, labels });
|
|
17730
|
+
}
|
|
17731
|
+
return [...perPage, ...across.values()];
|
|
17732
|
+
}
|
|
17733
|
+
function fixtureLhr(o) {
|
|
17734
|
+
const ms = (id, title, value, score) => ({ id, title, score, scoreDisplayMode: "numeric", numericValue: value, numericUnit: "millisecond", displayValue: `${(value / 1e3).toFixed(1)} s` });
|
|
17735
|
+
return JSON.stringify({
|
|
17736
|
+
lighthouseVersion: "12.2.1",
|
|
17737
|
+
requestedUrl: o.url,
|
|
17738
|
+
mainDocumentUrl: o.url,
|
|
17739
|
+
finalDisplayedUrl: o.url,
|
|
17740
|
+
finalUrl: o.url,
|
|
17741
|
+
fetchTime: o.fetchTime,
|
|
17742
|
+
gatherMode: "navigation",
|
|
17743
|
+
runWarnings: [],
|
|
17744
|
+
userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/131.0.0.0 Safari/537.36",
|
|
17745
|
+
configSettings: { output: ["json"], formFactor: o.device, throttlingMethod: "simulate", screenEmulation: o.device === "mobile" ? { mobile: true, width: 412, height: 823, deviceScaleFactor: 1.75, disabled: false } : { mobile: false, width: 1350, height: 940, deviceScaleFactor: 1, disabled: false }, onlyCategories: null },
|
|
17746
|
+
audits: {
|
|
17747
|
+
"first-contentful-paint": ms("first-contentful-paint", "First Contentful Paint", o.fcp, 0.9),
|
|
17748
|
+
"largest-contentful-paint": ms("largest-contentful-paint", "Largest Contentful Paint", o.lcp, 0.7),
|
|
17749
|
+
"total-blocking-time": { ...ms("total-blocking-time", "Total Blocking Time", o.tbt, 0.8), displayValue: `${o.tbt} ms` },
|
|
17750
|
+
"speed-index": ms("speed-index", "Speed Index", o.si, 0.85),
|
|
17751
|
+
"cumulative-layout-shift": { id: "cumulative-layout-shift", title: "Cumulative Layout Shift", score: 0.95, scoreDisplayMode: "numeric", numericValue: o.cls, numericUnit: "unitless", displayValue: String(o.cls) },
|
|
17752
|
+
"total-byte-weight": { id: "total-byte-weight", title: "Avoids enormous network payloads", score: 1, scoreDisplayMode: "numeric", numericValue: o.bytes, numericUnit: "byte", displayValue: `Total size was ${Math.round(o.bytes / 1024)} KiB` },
|
|
17753
|
+
"resource-summary": {
|
|
17754
|
+
id: "resource-summary",
|
|
17755
|
+
title: "Keep request counts low and transfer sizes small",
|
|
17756
|
+
score: null,
|
|
17757
|
+
scoreDisplayMode: "informative",
|
|
17758
|
+
details: { type: "table", items: [
|
|
17759
|
+
{ resourceType: "total", label: "Total", requestCount: 24, transferSize: o.bytes },
|
|
17760
|
+
{ resourceType: "script", label: "Script", requestCount: 9, transferSize: o.script },
|
|
17761
|
+
{ resourceType: "stylesheet", label: "Stylesheet", requestCount: 2, transferSize: 18204 }
|
|
17762
|
+
] }
|
|
17763
|
+
}
|
|
17764
|
+
},
|
|
17765
|
+
categories: {
|
|
17766
|
+
performance: { id: "performance", title: "Performance", score: o.scores[0] },
|
|
17767
|
+
accessibility: { id: "accessibility", title: "Accessibility", score: o.scores[1] },
|
|
17768
|
+
"best-practices": { id: "best-practices", title: "Best Practices", score: o.scores[2] },
|
|
17769
|
+
seo: { id: "seo", title: "SEO", score: o.scores[3] }
|
|
17770
|
+
}
|
|
17771
|
+
});
|
|
17772
|
+
}
|
|
17773
|
+
var lighthouseAdapter = {
|
|
17774
|
+
name: "lighthouse",
|
|
17775
|
+
description: "reads Lighthouse result JSON (LHR) files, e.g. Lighthouse CI's .lighthouseci, as lab Web Vitals per page and device",
|
|
17776
|
+
usage: `radical sense lighthouse [<file>|<dir>]\u2026
|
|
17777
|
+
|
|
17778
|
+
Reads Lighthouse results (LHR, \`lighthouse --output json\`, or a user flow's
|
|
17779
|
+
result) from the files named, or every *.json report in the directories
|
|
17780
|
+
named (other JSON there, such as Lighthouse CI's manifest.json, is left
|
|
17781
|
+
out); with none, from ${DEFAULT_INPUT} (where \`lhci collect\` writes).
|
|
17782
|
+
Run it once a page several times: each value is the median of the runs of
|
|
17783
|
+
one page on one device, labelled page (path and query of the final URL,
|
|
17784
|
+
e.g. /pricing) and device (mobile or desktop, the report's formFactor):
|
|
17785
|
+
web.lab.lcp, web.lab.fcp, web.lab.tbt, web.lab.speed_index (ms),
|
|
17786
|
+
web.lab.cls, web.lab.inp (ms; only timespan reports measure it),
|
|
17787
|
+
web.lab.bytes, web.lab.script_bytes (B, all and script transfer size),
|
|
17788
|
+
web.lab.score{category=performance|accessibility|best-practices|seo} (0-100)
|
|
17789
|
+
and across the pages, labelled only device (and category):
|
|
17790
|
+
web.lab.<metric>.max of each metric above, web.lab.score.min
|
|
17791
|
+
so a condition states the worst page:
|
|
17792
|
+
web.lab.lcp.max{device=mobile} <= 2500 ms
|
|
17793
|
+
A report with a runtime error is left out.`,
|
|
17794
|
+
async measure({ args, cwd }) {
|
|
17795
|
+
const inputs = args.length ? args : [DEFAULT_INPUT];
|
|
17796
|
+
const reports = await readReports(inputs, cwd);
|
|
17797
|
+
if (!reports.length) throw new Error(`no Lighthouse report in ${inputs.join(", ")}`);
|
|
17798
|
+
const values = lighthouseValues(reports);
|
|
17799
|
+
if (!values.length) throw new Error(`the Lighthouse reports in ${inputs.join(", ")} measured nothing (each has a runtime error)`);
|
|
17800
|
+
return values;
|
|
17801
|
+
},
|
|
17802
|
+
fixture: {
|
|
17803
|
+
// Lighthouse CI's output: three mobile runs of /, one desktop run of /,
|
|
17804
|
+
// one mobile run of /pricing, beside its manifest and assertion results.
|
|
17805
|
+
args: [],
|
|
17806
|
+
files: {
|
|
17807
|
+
".lighthouseci/lhr-1732435200001.json": fixtureLhr({ url: "https://example.com/", device: "mobile", fetchTime: "2026-11-24T08:00:01.000Z", lcp: 2400, fcp: 1500, tbt: 180, si: 3e3, cls: 0.02, bytes: 82e4, script: 31e4, scores: [0.86, 0.95, 1, 0.92] }),
|
|
17808
|
+
".lighthouseci/lhr-1732435200002.json": fixtureLhr({ url: "https://example.com/", device: "mobile", fetchTime: "2026-11-24T08:00:15.000Z", lcp: 3100, fcp: 1700, tbt: 260, si: 3600, cls: 0.05, bytes: 83e4, script: 312e3, scores: [0.78, 0.95, 1, 0.92] }),
|
|
17809
|
+
".lighthouseci/lhr-1732435200003.json": fixtureLhr({ url: "https://example.com/", device: "mobile", fetchTime: "2026-11-24T08:00:29.000Z", lcp: 2800, fcp: 1600, tbt: 220, si: 3300, cls: 0.03, bytes: 825e3, script: 311e3, scores: [0.82, 0.95, 1, 0.92] }),
|
|
17810
|
+
".lighthouseci/lhr-1732435200004.json": fixtureLhr({ url: "https://example.com/", device: "desktop", fetchTime: "2026-11-24T08:00:43.000Z", lcp: 900, fcp: 500, tbt: 40, si: 1100, cls: 0.01, bytes: 815e3, script: 309e3, scores: [0.99, 0.95, 1, 0.92] }),
|
|
17811
|
+
".lighthouseci/lhr-1732435200005.json": fixtureLhr({ url: "https://example.com/pricing?plan=team", device: "mobile", fetchTime: "2026-11-24T08:00:57.000Z", lcp: 3500, fcp: 1400, tbt: 150, si: 3900, cls: 0.12, bytes: 124e4, script: 45e4, scores: [0.74, 0.88, 0.96, 1] }),
|
|
17812
|
+
".lighthouseci/manifest.json": JSON.stringify([{ url: "https://example.com/", isRepresentativeRun: true, jsonPath: ".lighthouseci/lhr-1732435200003.json", htmlPath: ".lighthouseci/lhr-1732435200003.html", summary: { performance: 0.82, accessibility: 0.95, "best-practices": 1, seo: 0.92 } }]),
|
|
17813
|
+
".lighthouseci/assertion-results.json": JSON.stringify([])
|
|
17814
|
+
}
|
|
17815
|
+
}
|
|
17816
|
+
};
|
|
17817
|
+
|
|
17818
|
+
// src/sensors/machine.ts
|
|
17819
|
+
init_define_RADICAL_BUILD();
|
|
17820
|
+
import { spawn as spawn8 } from "child_process";
|
|
17821
|
+
import { mkdir as mkdir12, readFile as readFile19, writeFile as writeFile12 } from "fs/promises";
|
|
17822
|
+
import { dirname as dirname19, join as join23 } from "path";
|
|
17823
|
+
import { performance } from "perf_hooks";
|
|
17824
|
+
var AGAIN_WITHIN = 2 * 36e5;
|
|
17825
|
+
function builtInWork() {
|
|
17826
|
+
const n = 2e4;
|
|
17827
|
+
const samples = Array.from({ length: n }, (_, i) => ({ t: i, v: 3 + Math.sin(i / 50), h: 120 + i % 30 }));
|
|
17828
|
+
let sum = 0;
|
|
17829
|
+
for (let k = 0; k < 40; k++) {
|
|
17830
|
+
const means = [];
|
|
17831
|
+
for (let i = 0; i < n; i += 10) {
|
|
17832
|
+
let m = 0;
|
|
17833
|
+
for (let j = i; j < i + 10 && j < n; j++) m += samples[j].v * (1 + k / 100);
|
|
17834
|
+
means.push(m / 10);
|
|
17835
|
+
}
|
|
17836
|
+
means.sort((a2, b) => a2 - b);
|
|
17837
|
+
sum += means[means.length >> 1];
|
|
17838
|
+
}
|
|
17839
|
+
return sum + JSON.parse(JSON.stringify(samples.slice(0, 5e3))).length;
|
|
17840
|
+
}
|
|
17841
|
+
var median2 = (xs) => {
|
|
17842
|
+
const s2 = [...xs].sort((a2, b) => a2 - b);
|
|
17843
|
+
const mid = s2.length >> 1;
|
|
17844
|
+
return s2.length % 2 ? s2[mid] : (s2[mid - 1] + s2[mid]) / 2;
|
|
17845
|
+
};
|
|
17846
|
+
var round1 = (n) => Math.round(n * 10) / 10;
|
|
17847
|
+
var round22 = (n) => Math.round(n * 100) / 100;
|
|
17848
|
+
function timeBuiltIn(runs) {
|
|
17849
|
+
for (let i = 0; i < 3; i++) builtInWork();
|
|
17850
|
+
const times = [];
|
|
17851
|
+
for (let i = 0; i < runs; i++) {
|
|
17852
|
+
const t0 = performance.now();
|
|
17853
|
+
builtInWork();
|
|
17854
|
+
times.push(performance.now() - t0);
|
|
17855
|
+
}
|
|
17856
|
+
return median2(times);
|
|
17857
|
+
}
|
|
17858
|
+
async function timeCommand(command, runs, cwd) {
|
|
17859
|
+
const [cmd, ...args] = commandWords(command);
|
|
17860
|
+
if (!cmd) throw new Error("--work names no command");
|
|
17861
|
+
const once = () => new Promise((done, fail) => {
|
|
17862
|
+
const t0 = performance.now();
|
|
17863
|
+
const child = spawn8(cmd, args, { cwd, stdio: ["ignore", "ignore", "inherit"], shell: process.platform === "win32" });
|
|
17864
|
+
child.on("error", (error) => fail(new Error(`cannot run ${cmd}: ${error.message}`)));
|
|
17865
|
+
child.on("close", (status) => status === 0 ? done(performance.now() - t0) : fail(new Error(`${command} exited with ${status}`)));
|
|
17866
|
+
});
|
|
17867
|
+
await once();
|
|
17868
|
+
const times = [];
|
|
17869
|
+
for (let i = 0; i < runs; i++) times.push(await once());
|
|
17870
|
+
return median2(times);
|
|
17871
|
+
}
|
|
17872
|
+
async function repositoryFile(cwd) {
|
|
17873
|
+
const found = await findRepositoryFile(cwd, REPOSITORY_FILE, REPOSITORY_FILE);
|
|
17874
|
+
if (found) return { path: found.path, file: parseRepositoryFile(await readFile19(found.path, "utf8"), found.path) };
|
|
17875
|
+
return { path: join23(await repositoryRoot(cwd) ?? cwd, REPOSITORY_FILE), file: null };
|
|
17876
|
+
}
|
|
17877
|
+
function readReference(file) {
|
|
17878
|
+
const m = file?.machine;
|
|
17879
|
+
return m && typeof m.ms === "number" && m.ms > 0 && typeof m.work === "string" ? { ms: m.ms, work: m.work, at: typeof m.at === "string" ? m.at : "" } : null;
|
|
17880
|
+
}
|
|
17881
|
+
var machineAdapter = {
|
|
17882
|
+
name: "machine",
|
|
17883
|
+
description: "times a fixed piece of work against the reference machine, for limits scaled to the machine",
|
|
17884
|
+
usage: `radical sense machine [--reference] [--again] [--work <command>] [--runs <n>]
|
|
17885
|
+
|
|
17886
|
+
Times a fixed piece of work and measures it as machine.work (ms) and as
|
|
17887
|
+
machine.speed, its ratio to the reference time the repository keeps in
|
|
17888
|
+
.radical/radical.json ("machine"). A condition that ends in scaled
|
|
17889
|
+
(\`test.duration.max{kind=unit} <= 100 ms scaled\`) has its limit multiplied
|
|
17890
|
+
by the machine.speed measured nearest in time to its value (a lower limit
|
|
17891
|
+
divided), never below \xD71.
|
|
17892
|
+
|
|
17893
|
+
--reference measure on the machine the limits were set on and keep the
|
|
17894
|
+
time as the reference in .radical/radical.json (commit it)
|
|
17895
|
+
--again run after the tests: keep the slower of this run and the
|
|
17896
|
+
one measured before them (a shared runner's speed changes
|
|
17897
|
+
while it works)
|
|
17898
|
+
--work <command> time this command instead of Radical's own work (when the
|
|
17899
|
+
limits depend on disk or network); the reference must have
|
|
17900
|
+
been taken with the same command
|
|
17901
|
+
--runs <n> how many timed runs the median is taken over (default 9
|
|
17902
|
+
for the built-in work, 5 for a command)`,
|
|
17903
|
+
options: {
|
|
17904
|
+
reference: { type: "boolean", default: false },
|
|
17905
|
+
again: { type: "boolean", default: false },
|
|
17906
|
+
work: { type: "string" },
|
|
17907
|
+
runs: { type: "string" }
|
|
17908
|
+
},
|
|
17909
|
+
async measure({ args, options, cwd, previous }) {
|
|
17910
|
+
if (args.length) throw new Error(`takes no arguments: ${args.join(" ")}`);
|
|
17911
|
+
const command = typeof options.work === "string" && options.work.trim() ? options.work.trim() : void 0;
|
|
17912
|
+
const work = command ?? "builtin";
|
|
17913
|
+
const runs = options.runs === void 0 ? command ? 5 : 9 : Number(options.runs);
|
|
17914
|
+
if (!Number.isInteger(runs) || runs < 1) throw new Error(`--runs ${String(options.runs)} is no whole number of runs`);
|
|
17915
|
+
const { path, file } = await repositoryFile(cwd);
|
|
17916
|
+
const reference = readReference(file);
|
|
17917
|
+
if (!options.reference) {
|
|
17918
|
+
if (!reference) throw new Error(`no reference time in ${REPOSITORY_FILE}: run radical sense machine --reference on the machine the limits were set on, and commit ${REPOSITORY_FILE}`);
|
|
17919
|
+
if (reference.work !== work) throw new Error(`the reference in ${REPOSITORY_FILE} was taken with ${reference.work === "builtin" ? "the built-in work" : `--work "${reference.work}"`}, not ${command ? `--work "${command}"` : "the built-in work"}: time the same work, or take the reference again`);
|
|
17920
|
+
}
|
|
17921
|
+
let ms = command ? await timeCommand(command, runs, cwd) : timeBuiltIn(runs);
|
|
17922
|
+
if (options.again) {
|
|
17923
|
+
const before = (previous ?? []).filter((m) => m.metric === MACHINE_WORK_METRIC && m.labels.work === work && Date.now() - Date.parse(m.at) <= AGAIN_WITHIN).sort((a2, b) => Date.parse(b.at) - Date.parse(a2.at))[0];
|
|
17924
|
+
if (before) ms = Math.max(ms, before.value);
|
|
17925
|
+
}
|
|
17926
|
+
ms = round1(ms);
|
|
17927
|
+
if (options.reference) {
|
|
17928
|
+
const next = { ...file ?? { implements: [], verifies: [] }, machine: { ms, work, at: (/* @__PURE__ */ new Date()).toISOString() } };
|
|
17929
|
+
await mkdir12(dirname19(path), { recursive: true });
|
|
17930
|
+
await writeFile12(path, serializeRepositoryFile(next));
|
|
17931
|
+
}
|
|
17932
|
+
const base = options.reference ? ms : reference.ms;
|
|
17933
|
+
const values = [
|
|
17934
|
+
{ metric: MACHINE_WORK_METRIC, value: ms, unit: "ms", labels: { work } },
|
|
17935
|
+
{ metric: MACHINE_SPEED_METRIC, value: round22(ms / base) }
|
|
17936
|
+
];
|
|
17937
|
+
return values;
|
|
17938
|
+
},
|
|
17939
|
+
fixture: {
|
|
17940
|
+
args: [],
|
|
17941
|
+
options: { runs: "1" },
|
|
17942
|
+
files: {
|
|
17943
|
+
// A reference no machine reaches, so the fixture measures a speed.
|
|
17944
|
+
[REPOSITORY_FILE]: JSON.stringify({ machine: { ms: 1e-3, work: "builtin", at: "2026-11-24T00:00:00.000Z" }, implements: [], verifies: [] })
|
|
17945
|
+
}
|
|
17946
|
+
}
|
|
17947
|
+
};
|
|
17948
|
+
|
|
17192
17949
|
// src/sensors/playwright.ts
|
|
17193
17950
|
init_define_RADICAL_BUILD();
|
|
17194
|
-
import { spawn as
|
|
17195
|
-
import { mkdtemp as mkdtemp2, readdir as
|
|
17951
|
+
import { spawn as spawn9 } from "child_process";
|
|
17952
|
+
import { mkdtemp as mkdtemp2, readdir as readdir7, readFile as readFile20, rm as rm5 } from "fs/promises";
|
|
17196
17953
|
import { tmpdir as tmpdir4 } from "os";
|
|
17197
|
-
import { join as
|
|
17954
|
+
import { join as join24, resolve as resolve23 } from "path";
|
|
17198
17955
|
var RUNNER = "npx playwright test";
|
|
17199
17956
|
function envPairs(list) {
|
|
17200
17957
|
const out = {};
|
|
@@ -17225,14 +17982,14 @@ var playwrightAdapter = {
|
|
|
17225
17982
|
},
|
|
17226
17983
|
async measure({ args, options, cwd }) {
|
|
17227
17984
|
if (!args.length) throw new Error("no spec to run");
|
|
17228
|
-
const dir =
|
|
17985
|
+
const dir = resolve23(cwd, typeof options.cwd === "string" ? options.cwd : ".");
|
|
17229
17986
|
const env = envPairs(options.env);
|
|
17230
17987
|
const [command, ...runnerArgs] = commandWords(typeof options.runner === "string" && options.runner ? options.runner : RUNNER);
|
|
17231
|
-
const out = await mkdtemp2(
|
|
17988
|
+
const out = await mkdtemp2(join24(tmpdir4(), "radical-playwright-"));
|
|
17232
17989
|
try {
|
|
17233
17990
|
const project = typeof options.project === "string" && options.project ? [`--project=${options.project}`] : [];
|
|
17234
17991
|
const code = await new Promise((done, fail) => {
|
|
17235
|
-
const child =
|
|
17992
|
+
const child = spawn9(command, [...runnerArgs, ...args, ...project], {
|
|
17236
17993
|
cwd: dir,
|
|
17237
17994
|
env: { ...process.env, ...env, RADICAL_METRICS_DIR: out },
|
|
17238
17995
|
stdio: ["ignore", "pipe", "inherit"],
|
|
@@ -17242,10 +17999,10 @@ var playwrightAdapter = {
|
|
|
17242
17999
|
child.on("error", (error) => fail(new Error(`cannot run ${command}: ${error.message}`)));
|
|
17243
18000
|
child.on("close", (status, signal) => done(status ?? (signal ? 128 : 1)));
|
|
17244
18001
|
});
|
|
17245
|
-
const files = (await
|
|
18002
|
+
const files = (await readdir7(out)).filter((f) => f.endsWith(".json")).sort();
|
|
17246
18003
|
const values = [];
|
|
17247
18004
|
for (const file of files) {
|
|
17248
|
-
for (const m of parseMetricsFile(await
|
|
18005
|
+
for (const m of parseMetricsFile(await readFile20(join24(out, file), "utf8"), file)) {
|
|
17249
18006
|
values.push({ metric: m.metric, value: m.value, ...m.unit ? { unit: m.unit } : {}, ...Object.keys(m.labels).length ? { labels: m.labels } : {} });
|
|
17250
18007
|
}
|
|
17251
18008
|
}
|
|
@@ -17271,7 +18028,7 @@ writeFileSync(process.env.RADICAL_METRICS_DIR + '/spec.json', JSON.stringify({
|
|
|
17271
18028
|
};
|
|
17272
18029
|
|
|
17273
18030
|
// src/sensors/registry.ts
|
|
17274
|
-
var SENSOR_ADAPTERS = [commandAdapter, jsonAdapter, playwrightAdapter];
|
|
18031
|
+
var SENSOR_ADAPTERS = [commandAdapter, githubActionsAdapter, jsonAdapter, lighthouseAdapter, machineAdapter, playwrightAdapter];
|
|
17275
18032
|
var sensorAdapter = (name) => SENSOR_ADAPTERS.find((a2) => a2.name === name);
|
|
17276
18033
|
|
|
17277
18034
|
// src/sense.ts
|
|
@@ -17321,11 +18078,11 @@ var COMMON = {
|
|
|
17321
18078
|
list: { type: "boolean", default: false },
|
|
17322
18079
|
help: { type: "boolean", short: "h", default: false }
|
|
17323
18080
|
};
|
|
17324
|
-
function pairs(list,
|
|
18081
|
+
function pairs(list, option2) {
|
|
17325
18082
|
const out = {};
|
|
17326
18083
|
for (const item of list ?? []) {
|
|
17327
18084
|
const m = /^([\w.-]+)=(.*)$/.exec(item);
|
|
17328
|
-
if (!m) throw new Error(`--${
|
|
18085
|
+
if (!m) throw new Error(`--${option2} ${item} is not <name>=<value>`);
|
|
17329
18086
|
out[m[1]] = m[2];
|
|
17330
18087
|
}
|
|
17331
18088
|
return out;
|
|
@@ -17382,12 +18139,12 @@ ${SENSE_USAGE}`);
|
|
|
17382
18139
|
return 2;
|
|
17383
18140
|
}
|
|
17384
18141
|
const named = await modelFolderArg(given, io2.cwd);
|
|
17385
|
-
const folder =
|
|
18142
|
+
const folder = resolve24(io2.cwd, named);
|
|
17386
18143
|
let nodes;
|
|
17387
18144
|
let model;
|
|
17388
18145
|
let sensors;
|
|
17389
18146
|
try {
|
|
17390
|
-
if (!await
|
|
18147
|
+
if (!await stat12(join25(folder, MD_MANIFEST_FILE)).then((s2) => s2.isFile(), () => false)) throw new Error(`no ${MD_MANIFEST_FILE}`);
|
|
17391
18148
|
const files = await new MdFolderSession(diskFolderStorage(folder), { writeCache: false }).readAll();
|
|
17392
18149
|
const own = deserializeFromMdFolder(files).data;
|
|
17393
18150
|
const federation = await composeFolder(folder);
|
|
@@ -17427,9 +18184,9 @@ ${SENSE_USAGE}`);
|
|
|
17427
18184
|
if (sensor) {
|
|
17428
18185
|
for (const element of elements.length ? elements : [null]) {
|
|
17429
18186
|
ran++;
|
|
17430
|
-
const file2 =
|
|
18187
|
+
const file2 = join25(resolve24(io2.cwd, out), `${base}${element ? `-${slug(element.label)}` : ""}.json`);
|
|
17431
18188
|
const metricsOut = file2.replace(/\.json$/, ".sensor.json");
|
|
17432
|
-
await
|
|
18189
|
+
await mkdir13(dirname20(metricsOut), { recursive: true });
|
|
17433
18190
|
await rm6(metricsOut, { force: true });
|
|
17434
18191
|
const sensorContext = model.context(node, element, metricsOut);
|
|
17435
18192
|
const labels = element ? ["--label", `${ELEMENT_LABEL}=${element.id}`] : [];
|
|
@@ -17439,11 +18196,11 @@ ${SENSE_USAGE}`);
|
|
|
17439
18196
|
failed++;
|
|
17440
18197
|
continue;
|
|
17441
18198
|
}
|
|
17442
|
-
const written = await
|
|
18199
|
+
const written = await readFile21(metricsOut, "utf8").catch(() => null);
|
|
17443
18200
|
if (written === null) continue;
|
|
17444
18201
|
try {
|
|
17445
18202
|
const measured = parseMetricsFile(written, line.sensor);
|
|
17446
|
-
await
|
|
18203
|
+
await writeFile13(metricsOut, serializeMetricsFile({
|
|
17447
18204
|
source: line.sensor,
|
|
17448
18205
|
at: now().toISOString(),
|
|
17449
18206
|
measurements: measured.map(({ source: _s, at: _a5, context: _c, ...m }) => ({ ...m, labels: { ...m.labels, ...element ? { [ELEMENT_LABEL]: element.id } : {} } }))
|
|
@@ -17457,7 +18214,7 @@ ${SENSE_USAGE}`);
|
|
|
17457
18214
|
continue;
|
|
17458
18215
|
}
|
|
17459
18216
|
ran++;
|
|
17460
|
-
const file =
|
|
18217
|
+
const file = join25(resolve24(io2.cwd, out), `${base}.json`);
|
|
17461
18218
|
if (!isSensorName(line.sensor)) {
|
|
17462
18219
|
failed++;
|
|
17463
18220
|
io2.err(`${node.label}: cannot measure "${line.raw}": no sensor ${line.sensor}, neither an adapter (radical sense --list) nor in ${sensors ? sensors.file : `the repository's ${SENSORS_FILE}`}.`);
|
|
@@ -17487,13 +18244,13 @@ ${SENSE_USAGE}`);
|
|
|
17487
18244
|
${SENSE_USAGE}`);
|
|
17488
18245
|
return 2;
|
|
17489
18246
|
}
|
|
17490
|
-
const folder =
|
|
17491
|
-
if (!await
|
|
18247
|
+
const folder = resolve24(io2.cwd, await modelFolderArg(values.folder, io2.cwd));
|
|
18248
|
+
if (!await stat12(join25(folder, MD_MANIFEST_FILE)).then((s2) => s2.isFile(), () => false)) {
|
|
17492
18249
|
io2.err(`${values.folder ?? "The working directory"} is no model folder (no ${MD_MANIFEST_FILE}); name one with --folder.`);
|
|
17493
18250
|
return 2;
|
|
17494
18251
|
}
|
|
17495
|
-
const path =
|
|
17496
|
-
const existing = await
|
|
18252
|
+
const path = join25(await mappingRoot(folder), REVIEWS_FILE);
|
|
18253
|
+
const existing = await readFile21(path, "utf8").catch(() => void 0);
|
|
17497
18254
|
const result = values.passed ? "passed" : "failed";
|
|
17498
18255
|
let text3;
|
|
17499
18256
|
try {
|
|
@@ -17502,8 +18259,8 @@ ${SENSE_USAGE}`);
|
|
|
17502
18259
|
io2.err(`Cannot read ${REVIEWS_FILE}: ${error.message}`);
|
|
17503
18260
|
return 2;
|
|
17504
18261
|
}
|
|
17505
|
-
await
|
|
17506
|
-
await
|
|
18262
|
+
await mkdir13(dirname20(path), { recursive: true });
|
|
18263
|
+
await writeFile13(path, text3, "utf8");
|
|
17507
18264
|
io2.out(`Recorded in ${REVIEWS_FILE}: ${name} ${result}, by ${values.by.trim()}. Commit it.`);
|
|
17508
18265
|
return 0;
|
|
17509
18266
|
}
|
|
@@ -17555,9 +18312,10 @@ ${adapter.usage}`);
|
|
|
17555
18312
|
return 2;
|
|
17556
18313
|
}
|
|
17557
18314
|
const options = Object.fromEntries(Object.entries(values).filter(([k]) => !(k in COMMON)));
|
|
18315
|
+
const previous = typeof values.out === "string" ? await readFile21(resolve24(io2.cwd, values.out), "utf8").then((text4) => parseMetricsFile(text4, values.out), () => []) : await modelFolderArg(typeof values.folder === "string" ? values.folder : void 0, io2.cwd).then((named) => readEditorStateFile(resolve24(io2.cwd, named), MEASUREMENTS_FILE)).then((text4) => parseMeasurementStore(text4 ?? ""), () => []);
|
|
17558
18316
|
let measured;
|
|
17559
18317
|
try {
|
|
17560
|
-
measured = await adapter.measure({ args: [...positionals, ...after], options, cwd: io2.cwd });
|
|
18318
|
+
measured = await adapter.measure({ args: [...positionals, ...after], options, cwd: io2.cwd, previous });
|
|
17561
18319
|
} catch (error) {
|
|
17562
18320
|
io2.err(`radical sense ${adapter.name}: ${error.message}
|
|
17563
18321
|
|
|
@@ -17576,14 +18334,14 @@ ${adapter.usage}`);
|
|
|
17576
18334
|
return 2;
|
|
17577
18335
|
}
|
|
17578
18336
|
if (typeof values.out === "string") {
|
|
17579
|
-
await writeBeside(
|
|
18337
|
+
await writeBeside(resolve24(io2.cwd, values.out), text3);
|
|
17580
18338
|
} else {
|
|
17581
|
-
const folder =
|
|
17582
|
-
if (!await
|
|
18339
|
+
const folder = resolve24(io2.cwd, await modelFolderArg(typeof values.folder === "string" ? values.folder : void 0, io2.cwd));
|
|
18340
|
+
if (!await stat12(join25(folder, MD_MANIFEST_FILE)).then((s2) => s2.isFile(), () => false)) {
|
|
17583
18341
|
io2.err(`${typeof values.folder === "string" ? values.folder : "The working directory"} is no model folder (no ${MD_MANIFEST_FILE}); name one with --folder, or write a file with --out.`);
|
|
17584
18342
|
return 2;
|
|
17585
18343
|
}
|
|
17586
|
-
const store =
|
|
18344
|
+
const store = join25(folder, MEASUREMENTS_FILE);
|
|
17587
18345
|
const existing = parseMeasurementStore(await readEditorStateFile(folder, MEASUREMENTS_FILE) ?? "");
|
|
17588
18346
|
await writeBeside(store, serializeMeasurementStore(mergeMeasurements(existing, parseMetricsFile(text3, adapter.name))));
|
|
17589
18347
|
}
|
|
@@ -17593,8 +18351,8 @@ ${adapter.usage}`);
|
|
|
17593
18351
|
|
|
17594
18352
|
// src/assay.ts
|
|
17595
18353
|
init_define_RADICAL_BUILD();
|
|
17596
|
-
import { mkdir as
|
|
17597
|
-
import { dirname as
|
|
18354
|
+
import { mkdir as mkdir14, writeFile as writeFile14 } from "fs/promises";
|
|
18355
|
+
import { dirname as dirname23, join as join34 } from "path";
|
|
17598
18356
|
import { parseArgs as parseArgs14 } from "util";
|
|
17599
18357
|
|
|
17600
18358
|
// ../../packages/assay/src/index.ts
|
|
@@ -17603,10 +18361,10 @@ init_define_RADICAL_BUILD();
|
|
|
17603
18361
|
// ../../packages/assay/src/facts.ts
|
|
17604
18362
|
init_define_RADICAL_BUILD();
|
|
17605
18363
|
import { existsSync as existsSync13 } from "fs";
|
|
17606
|
-
import { join as
|
|
18364
|
+
import { join as join26 } from "path";
|
|
17607
18365
|
var FACTS_FILE = ".radical/assay/facts.json";
|
|
17608
18366
|
var FOLDER_FACTS_DIR = ".radical/assay/facts";
|
|
17609
|
-
var factsFileOf = (dir, name, root) => existsSync13(
|
|
18367
|
+
var factsFileOf = (dir, name, root) => existsSync13(join26(dir, ".git")) ? join26(dir, FACTS_FILE) : join26(root, FOLDER_FACTS_DIR, `${name}.json`);
|
|
17610
18368
|
var FORMAT = "radical-assay-facts/1";
|
|
17611
18369
|
var emptyFacts = (repository, dir) => ({
|
|
17612
18370
|
repository,
|
|
@@ -17641,13 +18399,13 @@ function serializeFacts(facts) {
|
|
|
17641
18399
|
// ../../packages/assay/src/cite.ts
|
|
17642
18400
|
init_define_RADICAL_BUILD();
|
|
17643
18401
|
import { existsSync as existsSync16, readFileSync as readFileSync9, realpathSync as realpathSync4, statSync as statSync4 } from "fs";
|
|
17644
|
-
import { isAbsolute as isAbsolute7, join as
|
|
18402
|
+
import { isAbsolute as isAbsolute7, join as join29, sep as sep5 } from "path";
|
|
17645
18403
|
|
|
17646
18404
|
// ../../packages/assay/src/files.ts
|
|
17647
18405
|
init_define_RADICAL_BUILD();
|
|
17648
18406
|
import { execFileSync } from "child_process";
|
|
17649
18407
|
import { existsSync as existsSync14, readFileSync as readFileSync7, readdirSync as readdirSync4, statSync as statSync2 } from "fs";
|
|
17650
|
-
import { join as
|
|
18408
|
+
import { join as join27, sep as sep4 } from "path";
|
|
17651
18409
|
var withoutComments = (code) => code.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")).replace(/(^|[^:"'])\/\/[^\n]*/g, (m, lead) => lead + " ".repeat(m.length - lead.length));
|
|
17652
18410
|
function shownOnly(text3, at, file) {
|
|
17653
18411
|
if (!/\.(svelte|vue|[cm]?[jt]sx?)$/i.test(file)) return false;
|
|
@@ -17689,11 +18447,11 @@ var MAX_FILES = 2e5;
|
|
|
17689
18447
|
var GIT = ["-c", "core.fsmonitor=false"];
|
|
17690
18448
|
function listFiles(root) {
|
|
17691
18449
|
try {
|
|
17692
|
-
if (!existsSync14(
|
|
18450
|
+
if (!existsSync14(join27(root, ".git"))) throw new Error("no repository");
|
|
17693
18451
|
const out = execFileSync("git", [...GIT, "ls-files", "-co", "--exclude-standard", "-z"], { cwd: root, maxBuffer: 1 << 28, stdio: ["ignore", "pipe", "ignore"] }).toString();
|
|
17694
18452
|
return { files: out.split("\0").filter((f) => f && !f.endsWith("/")).filter((f) => {
|
|
17695
18453
|
try {
|
|
17696
|
-
return statSync2(
|
|
18454
|
+
return statSync2(join27(root, f)).isFile();
|
|
17697
18455
|
} catch {
|
|
17698
18456
|
return false;
|
|
17699
18457
|
}
|
|
@@ -17703,7 +18461,7 @@ function listFiles(root) {
|
|
|
17703
18461
|
const walk = (dir) => {
|
|
17704
18462
|
let entries;
|
|
17705
18463
|
try {
|
|
17706
|
-
entries = readdirSync4(
|
|
18464
|
+
entries = readdirSync4(join27(root, dir), { withFileTypes: true });
|
|
17707
18465
|
} catch {
|
|
17708
18466
|
return;
|
|
17709
18467
|
}
|
|
@@ -17711,7 +18469,7 @@ function listFiles(root) {
|
|
|
17711
18469
|
const path = dir ? `${dir}/${d.name}` : d.name;
|
|
17712
18470
|
if (d.isDirectory()) {
|
|
17713
18471
|
if (SKIPPED.has(d.name)) continue;
|
|
17714
|
-
if (existsSync14(
|
|
18472
|
+
if (existsSync14(join27(root, path, ".git"))) listing.nested.push(path);
|
|
17715
18473
|
else walk(path);
|
|
17716
18474
|
} else if (d.isFile()) {
|
|
17717
18475
|
if (listing.files.length < MAX_FILES) listing.files.push(path);
|
|
@@ -17745,7 +18503,7 @@ var RepoFiles = class {
|
|
|
17745
18503
|
if (cached !== void 0) return cached;
|
|
17746
18504
|
let text3 = "";
|
|
17747
18505
|
try {
|
|
17748
|
-
const full =
|
|
18506
|
+
const full = join27(this.root, file);
|
|
17749
18507
|
if (statSync2(full).size <= (SQL_DUMP.test(file) ? MAX_SQL_FILE : MAX_FILE)) text3 = decodeText(readFileSync7(full));
|
|
17750
18508
|
} catch {
|
|
17751
18509
|
}
|
|
@@ -17801,7 +18559,7 @@ import { lookup as lookupCallback } from "dns";
|
|
|
17801
18559
|
import { lookup } from "dns/promises";
|
|
17802
18560
|
import { existsSync as existsSync15, mkdirSync as mkdirSync5, readFileSync as readFileSync8, readdirSync as readdirSync5, realpathSync as realpathSync3, renameSync, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
17803
18561
|
import { isIP } from "net";
|
|
17804
|
-
import { basename as basename6, dirname as
|
|
18562
|
+
import { basename as basename6, dirname as dirname21, extname, isAbsolute as isAbsolute6, join as join28, relative as relative15, resolve as resolve25 } from "path";
|
|
17805
18563
|
|
|
17806
18564
|
// ../../node_modules/fflate/esm/index.mjs
|
|
17807
18565
|
init_define_RADICAL_BUILD();
|
|
@@ -19245,9 +20003,9 @@ function replaceFolder(parent, into, write) {
|
|
|
19245
20003
|
if (had) rmSync3(old, { recursive: true, force: true });
|
|
19246
20004
|
}
|
|
19247
20005
|
function writeInside(dir, name, data) {
|
|
19248
|
-
const path =
|
|
20006
|
+
const path = resolve25(dir, name);
|
|
19249
20007
|
if (!within(dir, path)) throw new Error(`${name} would land outside ${basename6(dir)}`);
|
|
19250
|
-
mkdirSync5(
|
|
20008
|
+
mkdirSync5(dirname21(path), { recursive: true });
|
|
19251
20009
|
writeFileSync4(path, data);
|
|
19252
20010
|
}
|
|
19253
20011
|
function unpackZip(zip, parent, into) {
|
|
@@ -19259,7 +20017,7 @@ function unpackZip(zip, parent, into) {
|
|
|
19259
20017
|
}
|
|
19260
20018
|
function ignored(dir) {
|
|
19261
20019
|
mkdirSync5(dir, { recursive: true });
|
|
19262
|
-
const file =
|
|
20020
|
+
const file = join28(dir, ".gitignore");
|
|
19263
20021
|
if (!existsSync15(file)) writeFileSync4(file, "# Radical Assay's copies: kept out of git unless the team chooses otherwise.\n*\n");
|
|
19264
20022
|
}
|
|
19265
20023
|
|
|
@@ -19336,7 +20094,7 @@ function describeFacts(repositories, links, from, brief = false) {
|
|
|
19336
20094
|
init_define_RADICAL_BUILD();
|
|
19337
20095
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
19338
20096
|
import { existsSync as existsSync18, readFileSync as readFileSync11, readdirSync as readdirSync6, realpathSync as realpathSync5, statSync as statSync5 } from "fs";
|
|
19339
|
-
import { basename as basename10, isAbsolute as isAbsolute8, join as
|
|
20097
|
+
import { basename as basename10, isAbsolute as isAbsolute8, join as join32, relative as relative17, resolve as resolve26 } from "path";
|
|
19340
20098
|
|
|
19341
20099
|
// ../../packages/assay/src/yaml.ts
|
|
19342
20100
|
init_define_RADICAL_BUILD();
|
|
@@ -22859,8 +23617,8 @@ function npm(files, notes) {
|
|
|
22859
23617
|
const d = draft("npm", path, file, typeof json3.name === "string" ? json3.name : void 0, lineOf(text3, /"name"\s*:/));
|
|
22860
23618
|
const scripts = json3.scripts && typeof json3.scripts === "object" ? json3.scripts : {};
|
|
22861
23619
|
if (json3.bin) d.reasons.push("it has a bin");
|
|
22862
|
-
const
|
|
22863
|
-
if (
|
|
23620
|
+
const run3 = ["start", "dev", "serve", "preview"].find((s2) => typeof scripts[s2] === "string");
|
|
23621
|
+
if (run3) d.reasons.push(`it has a ${run3} script`);
|
|
22864
23622
|
if (files.has(`${path === "." ? "" : `${path}/`}index.html`)) d.reasons.push("it has an index.html");
|
|
22865
23623
|
if (json3.engines?.vscode) d.reasons.push("it is a VS Code extension");
|
|
22866
23624
|
for (const field of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
@@ -23911,7 +24669,7 @@ function vbValues(files, texts, iniFiles) {
|
|
|
23911
24669
|
}
|
|
23912
24670
|
return void 0;
|
|
23913
24671
|
};
|
|
23914
|
-
const
|
|
24672
|
+
const resolve28 = (expr, depth, seen) => {
|
|
23915
24673
|
let e2 = expr.trim();
|
|
23916
24674
|
for (let w = WRAPPER.exec(e2); w; w = WRAPPER.exec(e2)) e2 = w[1].trim();
|
|
23917
24675
|
const literal3 = /^"((?:[^"]|"")*)"$/.exec(e2);
|
|
@@ -23922,10 +24680,10 @@ function vbValues(files, texts, iniFiles) {
|
|
|
23922
24680
|
if (!/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*\$?$/.test(e2) || depth > 6) return void 0;
|
|
23923
24681
|
const key = e2.replace(/\$$/, "").replace(/^Me\./i, "").toLowerCase();
|
|
23924
24682
|
if (seen.has(key)) return void 0;
|
|
23925
|
-
const values = new Set((assigned.get(key) ?? []).map((v) =>
|
|
24683
|
+
const values = new Set((assigned.get(key) ?? []).map((v) => resolve28(v, depth + 1, /* @__PURE__ */ new Set([...seen, key]))).filter((v) => v !== void 0));
|
|
23926
24684
|
return values.size === 1 ? [...values][0] : void 0;
|
|
23927
24685
|
};
|
|
23928
|
-
return { resolve: (expr) =>
|
|
24686
|
+
return { resolve: (expr) => resolve28(expr, 0, /* @__PURE__ */ new Set()) };
|
|
23929
24687
|
}
|
|
23930
24688
|
var CONNECTION = /\b(?:Server|Database|Driver|Data Source|DSN|Provider|Initial Catalog|Dbq|Uid|Host)\s*=/i;
|
|
23931
24689
|
function inlineValues(text3, values) {
|
|
@@ -24118,7 +24876,7 @@ function readCode(files, repo, units) {
|
|
|
24118
24876
|
const accessNamed = /* @__PURE__ */ new Map();
|
|
24119
24877
|
const accessUsers = /* @__PURE__ */ new Set();
|
|
24120
24878
|
const valuesByUnit = /* @__PURE__ */ new Map();
|
|
24121
|
-
const
|
|
24879
|
+
const valuesOf3 = (unit) => {
|
|
24122
24880
|
const known = valuesByUnit.get(unit.id);
|
|
24123
24881
|
if (known) return known;
|
|
24124
24882
|
const mine = files.list.filter((f) => owner(units, f)?.id === unit.id);
|
|
@@ -24148,7 +24906,7 @@ function readCode(files, repo, units) {
|
|
|
24148
24906
|
let text3 = configures.has(file) ? settingsFor(files, file, unit) : files.read(file);
|
|
24149
24907
|
if (!text3) continue;
|
|
24150
24908
|
const vb = VB_CODE.test(file);
|
|
24151
|
-
if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)),
|
|
24909
|
+
if (vb) text3 = inlineValues(joinContinuations(withoutVbComments(text3)), valuesOf3(unit));
|
|
24152
24910
|
if (config && /\.(ya?ml|properties|env|toml|conf|ini)$|(^|\/)\.env(\.[\w-]+)?$/i.test(file)) text3 = text3.replace(/^[ \t]*#.*$/gm, "").replace(/\.ini$/i.test(file) ? /^[ \t]*;.*$/gm : /$^/, "");
|
|
24153
24911
|
const unresolved = text3;
|
|
24154
24912
|
text3 = text3.replace(/\$\{([\w.-]+):([^${}\n]*)\}/g, (_, key, value) => value.startsWith("?") ? `\${${key}}` : value.replace(/^-/, ""));
|
|
@@ -24213,7 +24971,7 @@ function readCode(files, repo, units) {
|
|
|
24213
24971
|
accessNamed.set(unit.id, [...accessNamed.get(unit.id) ?? [], { name: m[2], evidence: at(m.index) }]);
|
|
24214
24972
|
}
|
|
24215
24973
|
if (/\.(frm|dob|pag|ctl)$/i.test(file)) formAddress(text3, file, unit, repo, out, once);
|
|
24216
|
-
const values =
|
|
24974
|
+
const values = valuesOf3(unit);
|
|
24217
24975
|
const hostOf = (expr) => (values.resolve(expr) ?? /^"([^"]+)"$/.exec(expr.trim())?.[1] ?? expr.trim()).toLowerCase();
|
|
24218
24976
|
const remoteHost = /\.RemoteHost\s*=\s*([^\n]+)/i.exec(text3)?.[1];
|
|
24219
24977
|
const connects = [
|
|
@@ -24381,7 +25139,7 @@ function formAddress(text3, file, unit, repo, out, once) {
|
|
|
24381
25139
|
// ../../packages/assay/src/domain.ts
|
|
24382
25140
|
init_define_RADICAL_BUILD();
|
|
24383
25141
|
import { readFileSync as readFileSync10 } from "fs";
|
|
24384
|
-
import { extname as extname3, join as
|
|
25142
|
+
import { extname as extname3, join as join31 } from "path";
|
|
24385
25143
|
|
|
24386
25144
|
// ../../packages/assay/src/laravel.ts
|
|
24387
25145
|
init_define_RADICAL_BUILD();
|
|
@@ -24854,7 +25612,7 @@ function readRoutineCalls(files, repo, units) {
|
|
|
24854
25612
|
init_define_RADICAL_BUILD();
|
|
24855
25613
|
import { existsSync as existsSync17 } from "fs";
|
|
24856
25614
|
import { createRequire as createRequire2 } from "module";
|
|
24857
|
-
import { dirname as
|
|
25615
|
+
import { dirname as dirname22, join as join30 } from "path";
|
|
24858
25616
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
24859
25617
|
|
|
24860
25618
|
// ../../packages/assay/src/grammars.json
|
|
@@ -24874,20 +25632,20 @@ var grammars_default = {
|
|
|
24874
25632
|
var GRAMMARS = grammars_default.grammars;
|
|
24875
25633
|
var RUNTIME = grammars_default.runtime;
|
|
24876
25634
|
function wasmDir() {
|
|
24877
|
-
const beside =
|
|
25635
|
+
const beside = join30(dirname22(fileURLToPath3(import.meta.url)), "tree-sitter");
|
|
24878
25636
|
const shipped = RUNTIME[0].replace(/\.js$/, ".cjs");
|
|
24879
|
-
if (existsSync17(
|
|
24880
|
-
return { dir:
|
|
25637
|
+
if (existsSync17(join30(beside, shipped))) return { dir: beside, runtime: shipped };
|
|
25638
|
+
return { dir: dirname22(createRequire2(import.meta.url).resolve("@vscode/tree-sitter-wasm")), runtime: RUNTIME[0] };
|
|
24881
25639
|
}
|
|
24882
25640
|
var loaded;
|
|
24883
25641
|
var loading;
|
|
24884
25642
|
function prepareSyntax() {
|
|
24885
25643
|
loading ??= (async () => {
|
|
24886
25644
|
const { dir, runtime: file } = wasmDir();
|
|
24887
|
-
const runtime = createRequire2(import.meta.url)(
|
|
24888
|
-
await runtime.Parser.init({ locateFile: (name) =>
|
|
25645
|
+
const runtime = createRequire2(import.meta.url)(join30(dir, file));
|
|
25646
|
+
await runtime.Parser.init({ locateFile: (name) => join30(dir, name) });
|
|
24889
25647
|
const languages = /* @__PURE__ */ new Map();
|
|
24890
|
-
for (const [name, file2] of Object.entries(GRAMMARS)) languages.set(name, await runtime.Language.load(
|
|
25648
|
+
for (const [name, file2] of Object.entries(GRAMMARS)) languages.set(name, await runtime.Language.load(join30(dir, file2)));
|
|
24891
25649
|
loaded = { parser: new runtime.Parser(), languages, Query: runtime.Query };
|
|
24892
25650
|
})();
|
|
24893
25651
|
return loading;
|
|
@@ -25531,7 +26289,7 @@ function readDomain(files, repo, units, named, used = [], access, dependencies =
|
|
|
25531
26289
|
}
|
|
25532
26290
|
let schema2;
|
|
25533
26291
|
try {
|
|
25534
|
-
schema2 = access(readFileSync10(
|
|
26292
|
+
schema2 = access(readFileSync10(join31(files.root, file)));
|
|
25535
26293
|
} catch (error) {
|
|
25536
26294
|
notes.push(`${file}: an Access file not read (${error.message.split("\n")[0]})`);
|
|
25537
26295
|
continue;
|
|
@@ -25564,9 +26322,9 @@ function readDomain(files, repo, units, named, used = [], access, dependencies =
|
|
|
25564
26322
|
const runByInstall = new Set(scripts.filter((f) => !TEARDOWN.test(f)).flatMap(runOf));
|
|
25565
26323
|
const dropsOnly = (f) => ((t) => /\bdrop\s+\w/i.test(t) && !/\bcreate\b/i.test(t) && !/^\s*(?:@@?|start\s+)\S/im.test(t))(withoutSqlComments(files.read(f)));
|
|
25566
26324
|
const resets = new Set(scripts.flatMap((runner) => {
|
|
25567
|
-
const
|
|
25568
|
-
const first =
|
|
25569
|
-
return
|
|
26325
|
+
const run3 = runOf(runner);
|
|
26326
|
+
const first = run3.findIndex((f) => !dropsOnly(f));
|
|
26327
|
+
return run3.filter((f, i) => dropsOnly(f) && first >= 0 && i < first);
|
|
25570
26328
|
}));
|
|
25571
26329
|
for (const file of sqitchOrder(files, files.list).filter((f) => SQL_SCRIPT.test(f) && !DEV_TOOLING.test(f) && !/(^|\/)(tests?|__tests__|e2e|testdata|revert|verify)\//i.test(f) && !dumped(f) && !/\.down\.sql$|(^|\/)U\d+__[^/]*\.sql$/i.test(f))) {
|
|
25572
26330
|
const schema2 = readSchema(files.read(file), file);
|
|
@@ -27044,11 +27802,11 @@ function openApiOperations(text3, file) {
|
|
|
27044
27802
|
return ops;
|
|
27045
27803
|
}
|
|
27046
27804
|
function extractRepository(dir, options = {}) {
|
|
27047
|
-
const given =
|
|
27805
|
+
const given = resolve26(dir);
|
|
27048
27806
|
const repo = basename10(given);
|
|
27049
27807
|
const root = realpathSync5(given);
|
|
27050
27808
|
const facts = emptyFacts(repo, given);
|
|
27051
|
-
if (existsSync18(
|
|
27809
|
+
if (existsSync18(join32(root, ".git"))) {
|
|
27052
27810
|
try {
|
|
27053
27811
|
const commit = execFileSync2("git", [...GIT, "rev-parse", "HEAD"], { cwd: root, stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
|
|
27054
27812
|
if (commit) facts.commit = commit;
|
|
@@ -27135,16 +27893,16 @@ function extractRepository(dir, options = {}) {
|
|
|
27135
27893
|
return facts;
|
|
27136
27894
|
}
|
|
27137
27895
|
function reportFiles2(root, given, notes) {
|
|
27138
|
-
const entries = given ?? (existsSync18(
|
|
27896
|
+
const entries = given ?? (existsSync18(join32(root, "reports")) ? ["reports"] : []);
|
|
27139
27897
|
const out = [];
|
|
27140
27898
|
for (const entry of entries) {
|
|
27141
|
-
const path = isAbsolute8(entry) ? entry :
|
|
27899
|
+
const path = isAbsolute8(entry) ? entry : join32(root, entry);
|
|
27142
27900
|
if (!existsSync18(path)) {
|
|
27143
27901
|
notes.push(`report ${entry} does not exist`);
|
|
27144
27902
|
continue;
|
|
27145
27903
|
}
|
|
27146
27904
|
if (statSync5(path).isDirectory()) {
|
|
27147
|
-
for (const f of readdirSync6(path).sort()) if (/\.(json|xml)$/i.test(f)) out.push(
|
|
27905
|
+
for (const f of readdirSync6(path).sort()) if (/\.(json|xml)$/i.test(f)) out.push(join32(path, f));
|
|
27148
27906
|
} else {
|
|
27149
27907
|
out.push(path);
|
|
27150
27908
|
}
|
|
@@ -27195,7 +27953,7 @@ function repositoryPath(root, file, files, byName, report) {
|
|
|
27195
27953
|
if (!rel.startsWith("..") && files.has(rel)) return rel;
|
|
27196
27954
|
} else {
|
|
27197
27955
|
if (files.has(name)) return name;
|
|
27198
|
-
const beside = posix(
|
|
27956
|
+
const beside = posix(join32(report.includes("/") ? report.slice(0, report.lastIndexOf("/")) : ".", name));
|
|
27199
27957
|
if (files.has(beside)) return beside;
|
|
27200
27958
|
}
|
|
27201
27959
|
const base = name.slice(name.lastIndexOf("/") + 1);
|
|
@@ -27229,8 +27987,8 @@ function checksNothing(text3, at) {
|
|
|
27229
27987
|
// ../../packages/assay/src/repositories.ts
|
|
27230
27988
|
init_define_RADICAL_BUILD();
|
|
27231
27989
|
import { existsSync as existsSync19, readdirSync as readdirSync7, statSync as statSync6 } from "fs";
|
|
27232
|
-
import { basename as basename11, join as
|
|
27233
|
-
var isRepository = (dir) => existsSync19(
|
|
27990
|
+
import { basename as basename11, join as join33, resolve as resolve27 } from "path";
|
|
27991
|
+
var isRepository = (dir) => existsSync19(join33(dir, ".git"));
|
|
27234
27992
|
var DEPTH = 3;
|
|
27235
27993
|
var ASIDE = /^(readme|license|licence|notice|changelog)(\.|$)/i;
|
|
27236
27994
|
function repositoriesBelow(dir, depth) {
|
|
@@ -27238,7 +27996,7 @@ function repositoriesBelow(dir, depth) {
|
|
|
27238
27996
|
const found = [];
|
|
27239
27997
|
for (const d of readdirSync7(dir, { withFileTypes: true }).sort((a2, b) => a2.name.localeCompare(b.name))) {
|
|
27240
27998
|
if (!d.isDirectory() || d.name.startsWith(".") || SKIPPED.has(d.name)) continue;
|
|
27241
|
-
const path =
|
|
27999
|
+
const path = join33(dir, d.name);
|
|
27242
28000
|
if (isRepository(path)) found.push(path);
|
|
27243
28001
|
else found.push(...repositoriesBelow(path, depth - 1));
|
|
27244
28002
|
}
|
|
@@ -27251,16 +28009,16 @@ function repositoriesIn(given, cwd = process.cwd(), unpackInto) {
|
|
|
27251
28009
|
const notes = [];
|
|
27252
28010
|
const unpacked = /* @__PURE__ */ new Set();
|
|
27253
28011
|
for (const entry of given) {
|
|
27254
|
-
let dir =
|
|
28012
|
+
let dir = resolve27(cwd, entry);
|
|
27255
28013
|
if (existsSync19(dir) && statSync6(dir).isFile() && /\.zip$/i.test(dir)) {
|
|
27256
28014
|
if (!unpackInto) throw new Error(`${entry}: a .zip file needs a folder to be unpacked into`);
|
|
27257
28015
|
let name = safeName(basename11(dir).replace(/\.zip$/i, ""), "code");
|
|
27258
28016
|
for (let i = 2, base = name; unpacked.has(name.toLowerCase()); i++) name = `${base}-${i}`;
|
|
27259
28017
|
unpacked.add(name.toLowerCase());
|
|
27260
|
-
const into =
|
|
28018
|
+
const into = join33(unpackInto, name);
|
|
27261
28019
|
const packed = unpackZip(dir, unpackInto, into);
|
|
27262
28020
|
if (packed.length && !packed.includes("")) {
|
|
27263
|
-
dirs.push(...packed.map((r) =>
|
|
28021
|
+
dirs.push(...packed.map((r) => join33(into, r)));
|
|
27264
28022
|
notes.push(`${entry} holds ${packed.length} repositor${packed.length === 1 ? "y" : "ies"} (${packed.join(", ")}): each is read as a folder of code, without its .git folder`);
|
|
27265
28023
|
continue;
|
|
27266
28024
|
}
|
|
@@ -27362,8 +28120,8 @@ ${ASSAY_USAGE}`);
|
|
|
27362
28120
|
}
|
|
27363
28121
|
let found;
|
|
27364
28122
|
try {
|
|
27365
|
-
if (parsed.positionals.some((p) => /\.zip$/i.test(p))) ignored(
|
|
27366
|
-
found = repositoriesIn(parsed.positionals, io2.cwd,
|
|
28123
|
+
if (parsed.positionals.some((p) => /\.zip$/i.test(p))) ignored(join34(io2.cwd, UNPACKED_DIR));
|
|
28124
|
+
found = repositoriesIn(parsed.positionals, io2.cwd, join34(io2.cwd, UNPACKED_DIR));
|
|
27367
28125
|
} catch (error) {
|
|
27368
28126
|
io2.err(error.message);
|
|
27369
28127
|
return 2;
|
|
@@ -27384,9 +28142,9 @@ ${ASSAY_USAGE}`);
|
|
|
27384
28142
|
repositories.push(facts);
|
|
27385
28143
|
const file = factsFileOf(dir, facts.repository, io2.cwd);
|
|
27386
28144
|
try {
|
|
27387
|
-
if (!isRepository(dir)) ignored(
|
|
27388
|
-
await
|
|
27389
|
-
await
|
|
28145
|
+
if (!isRepository(dir)) ignored(join34(io2.cwd, FOLDER_FACTS_DIR));
|
|
28146
|
+
await mkdir14(dirname23(file), { recursive: true });
|
|
28147
|
+
await writeFile14(file, serializeFacts(facts));
|
|
27390
28148
|
} catch (error) {
|
|
27391
28149
|
facts.notes.push(`${file} not written: ${error.message}`);
|
|
27392
28150
|
}
|
|
@@ -27497,7 +28255,7 @@ var io = {
|
|
|
27497
28255
|
cli: { node: `"$(command -v node || echo '${process.execPath.replace(/\\/g, "/")}')"`, script: process.argv[1] },
|
|
27498
28256
|
// This very CLI again, on its own: the git hook that started this one
|
|
27499
28257
|
// returns at once, and nothing the child prints reaches it.
|
|
27500
|
-
background: (args) =>
|
|
28258
|
+
background: (args) => spawn10(process.execPath, [process.argv[1], ...args], { cwd: process.cwd(), detached: true, stdio: "ignore", windowsHide: true }).unref()
|
|
27501
28259
|
};
|
|
27502
28260
|
main(process.argv.slice(2), io).then(
|
|
27503
28261
|
(code) => {
|