@mark1russell7/conventions 0.40.5 → 0.40.7
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/README.md +1 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/{run-CFCxbx_x.js → run-CMtFuxIb.js} +354 -109
- package/build/run-CMtFuxIb.js.map +1 -0
- package/package.json +2 -1
- package/build/run-CFCxbx_x.js.map +0 -1
|
@@ -8229,7 +8229,7 @@ const HOME_EXPORTS = {
|
|
|
8229
8229
|
};
|
|
8230
8230
|
// src/map.ts
|
|
8231
8231
|
/** The rule of the map. Each session and each review applies it. */
|
|
8232
|
-
const MAP_RULE = "Before you write a helper, find its home in this map. If the home does not have the function, add it to the home, in a pull request of the home repository. Do not make a local copy, a new package or a new repository for an area that has a home: that needs the strategist. A home that is not on npm is used with workspace:*
|
|
8232
|
+
const MAP_RULE = "Before you write a helper, find its home in this map. If the home does not have the function, add it to the home, in a pull request of the home repository. Do not make a local copy, a new package or a new repository for an area that has a home: that needs the strategist. A home that is not on npm is used with workspace:* inside its own repository. In another repository, a github: specifier pinned to a commit works only for a package that keeps its built files in git. For any other package, wait for its first npm publish (ask the strategist). If no area fits, ask the strategist for a home before you write the code.";
|
|
8233
8233
|
/** The public homes. Each package that other code can use has one area. */
|
|
8234
8234
|
const HOMES = [
|
|
8235
8235
|
{
|
|
@@ -8587,9 +8587,9 @@ const HOMES = [
|
|
|
8587
8587
|
area: "headless-browser",
|
|
8588
8588
|
title: "Headless browser runs",
|
|
8589
8589
|
covers: "finding the browser of the system, a headless run with argv, a temporary profile, a time limit and a signal, and its output: PDF files, screenshots in PNG or JPEG, page text",
|
|
8590
|
-
packages: [],
|
|
8590
|
+
packages: ["@procedures/browser"],
|
|
8591
8591
|
repo: "mark1russell7/client",
|
|
8592
|
-
state: "
|
|
8592
|
+
state: "unpublished",
|
|
8593
8593
|
words: [
|
|
8594
8594
|
"browser",
|
|
8595
8595
|
"chromium",
|
|
@@ -8604,7 +8604,7 @@ const HOMES = [
|
|
|
8604
8604
|
"playwright"
|
|
8605
8605
|
],
|
|
8606
8606
|
signatures: ["findBrowser", "renderScreenshot"],
|
|
8607
|
-
note: "
|
|
8607
|
+
note: "@procedures/browser is in mark1russell7/client, and @procedures/pdf depends on it. Its first npm version is 0.54.1. Before that publish, use it only with workspace:* inside client: client does not keep its built files in git, so a github: specifier does not work."
|
|
8608
8608
|
},
|
|
8609
8609
|
{
|
|
8610
8610
|
area: "cli",
|
|
@@ -8684,7 +8684,7 @@ const HOMES = [
|
|
|
8684
8684
|
{
|
|
8685
8685
|
area: "geometry",
|
|
8686
8686
|
title: "Geometry and layout records",
|
|
8687
|
-
covers: "points, boxes, segments, tolerances, the input and record formats of the layout engines, converters",
|
|
8687
|
+
covers: "points, boxes, segments, tolerances, space-filling curves (Hilbert, Moore, Morton) on a grid, 3D points, boxes and transforms (planned), the input and record formats of the layout engines, converters",
|
|
8688
8688
|
packages: ["@mark1russell7/layout-contract"],
|
|
8689
8689
|
repo: "mark1russell7/layout-contract",
|
|
8690
8690
|
state: "published",
|
|
@@ -8697,7 +8697,13 @@ const HOMES = [
|
|
|
8697
8697
|
"tolerance",
|
|
8698
8698
|
"overlap",
|
|
8699
8699
|
"intersection",
|
|
8700
|
-
"bounds"
|
|
8700
|
+
"bounds",
|
|
8701
|
+
"curve",
|
|
8702
|
+
"space-filling",
|
|
8703
|
+
"hilbert",
|
|
8704
|
+
"moore",
|
|
8705
|
+
"morton",
|
|
8706
|
+
"z-order"
|
|
8701
8707
|
],
|
|
8702
8708
|
signatures: [
|
|
8703
8709
|
"segmentsIntersect",
|
|
@@ -8709,7 +8715,14 @@ const HOMES = [
|
|
|
8709
8715
|
"rectsIntersect",
|
|
8710
8716
|
"pointInPolygon",
|
|
8711
8717
|
"distanceToSegment",
|
|
8712
|
-
"pointSegmentDistance"
|
|
8718
|
+
"pointSegmentDistance",
|
|
8719
|
+
"hilbertRank",
|
|
8720
|
+
"hilbertIndex",
|
|
8721
|
+
"hilbertCell",
|
|
8722
|
+
"d2xy",
|
|
8723
|
+
"xy2d",
|
|
8724
|
+
"mortonIndex",
|
|
8725
|
+
"mortonCode"
|
|
8713
8726
|
],
|
|
8714
8727
|
note: "Exact predicates go to algebra. @mark1russell7/vex-domains has 2D vectors for Vex formulas only."
|
|
8715
8728
|
},
|
|
@@ -8732,6 +8745,97 @@ const HOMES = [
|
|
|
8732
8745
|
"seeded config sample"
|
|
8733
8746
|
]
|
|
8734
8747
|
},
|
|
8748
|
+
{
|
|
8749
|
+
area: "search",
|
|
8750
|
+
title: "Search and optimization over a space",
|
|
8751
|
+
covers: "search over a strategy space: sweeps, genetic algorithms, many objectives and Pareto fronts, hard and soft constraints, a seed for each run, a record of each evaluation",
|
|
8752
|
+
packages: [],
|
|
8753
|
+
repo: "mark1russell7/strategy-space",
|
|
8754
|
+
state: "planned",
|
|
8755
|
+
words: [
|
|
8756
|
+
"optimizer",
|
|
8757
|
+
"optimize",
|
|
8758
|
+
"optimization",
|
|
8759
|
+
"genetic",
|
|
8760
|
+
"evolutionary",
|
|
8761
|
+
"pareto",
|
|
8762
|
+
"multi-objective",
|
|
8763
|
+
"sweep",
|
|
8764
|
+
"search",
|
|
8765
|
+
"annealing",
|
|
8766
|
+
"hill climb",
|
|
8767
|
+
"constraint solver",
|
|
8768
|
+
"tuning"
|
|
8769
|
+
],
|
|
8770
|
+
note: "The planned package is @mark1russell7/strategy-search. It knows no domain. The local sweeps of the layout projects move to it."
|
|
8771
|
+
},
|
|
8772
|
+
{
|
|
8773
|
+
area: "market",
|
|
8774
|
+
title: "Products, offers and price history",
|
|
8775
|
+
covers: "a live catalog of products with the offers of many sellers, the price of each offer over time, trends, one adapter for each seller (the official API first)",
|
|
8776
|
+
packages: [],
|
|
8777
|
+
repo: "mark1russell7/market",
|
|
8778
|
+
state: "planned",
|
|
8779
|
+
words: [
|
|
8780
|
+
"price",
|
|
8781
|
+
"prices",
|
|
8782
|
+
"offer",
|
|
8783
|
+
"seller",
|
|
8784
|
+
"catalog",
|
|
8785
|
+
"product",
|
|
8786
|
+
"parts",
|
|
8787
|
+
"price history",
|
|
8788
|
+
"trend",
|
|
8789
|
+
"deal",
|
|
8790
|
+
"listing",
|
|
8791
|
+
"sku"
|
|
8792
|
+
],
|
|
8793
|
+
note: "The planned packages are @mark1russell7/market and @mark1russell7/market-sources. Fetches go through polite-crawler, live loops through @mark1russell7/service, trend statistics through rigor-statistics."
|
|
8794
|
+
},
|
|
8795
|
+
{
|
|
8796
|
+
area: "cluster-design",
|
|
8797
|
+
title: "Computer cluster design",
|
|
8798
|
+
covers: "part classes and fit rules (socket, memory type, power supply), runner capacity, watts, heat, noise, circuit load, as formulas with units over a configuration",
|
|
8799
|
+
packages: [],
|
|
8800
|
+
repo: "mark1russell7/cluster-design",
|
|
8801
|
+
state: "planned",
|
|
8802
|
+
words: [
|
|
8803
|
+
"cluster",
|
|
8804
|
+
"hardware",
|
|
8805
|
+
"pc build",
|
|
8806
|
+
"socket",
|
|
8807
|
+
"psu",
|
|
8808
|
+
"watts",
|
|
8809
|
+
"circuit",
|
|
8810
|
+
"runner capacity",
|
|
8811
|
+
"heat",
|
|
8812
|
+
"noise",
|
|
8813
|
+
"rack",
|
|
8814
|
+
"compatibility"
|
|
8815
|
+
],
|
|
8816
|
+
note: "It has no site facts and no prices: a site and part records are input data. Units come from quantity, roll-ups from Vex."
|
|
8817
|
+
},
|
|
8818
|
+
{
|
|
8819
|
+
area: "room-view",
|
|
8820
|
+
title: "3D room viewer",
|
|
8821
|
+
covers: "a three.js viewer of a room model (glTF) with placed objects, outlets and circuits as data",
|
|
8822
|
+
packages: [],
|
|
8823
|
+
repo: "mark1russell7/room-view",
|
|
8824
|
+
state: "planned",
|
|
8825
|
+
words: [
|
|
8826
|
+
"3d",
|
|
8827
|
+
"three.js",
|
|
8828
|
+
"threejs",
|
|
8829
|
+
"gltf",
|
|
8830
|
+
"room",
|
|
8831
|
+
"floor plan",
|
|
8832
|
+
"scene",
|
|
8833
|
+
"outlet",
|
|
8834
|
+
"blender",
|
|
8835
|
+
"viewer"
|
|
8836
|
+
],
|
|
8837
|
+
note: "3D geometry records go to layout-contract."
|
|
8838
|
+
},
|
|
8735
8839
|
{
|
|
8736
8840
|
area: "packing",
|
|
8737
8841
|
title: "Rectangle packing",
|
|
@@ -9138,7 +9242,7 @@ function repoOf(context) {
|
|
|
9138
9242
|
function messageOf(file, name, home) {
|
|
9139
9243
|
const exporter = home.packages.find((pkg) => HOME_EXPORTS[pkg]?.names.includes(name) === true);
|
|
9140
9244
|
const where = home.packages.length === 0 ? home.repo : home.packages.map((pkg) => `\`${pkg}\``).join(", ");
|
|
9141
|
-
const use = home.state === "unpublished" ? ` (not on npm: use a github: specifier pinned to a commit
|
|
9245
|
+
const use = home.state === "unpublished" ? ` (not on npm: use workspace:* inside ${home.repo}; elsewhere a github: specifier pinned to a commit works only if ${home.repo} keeps its built files in git, else wait for the first npm publish)` : "";
|
|
9142
9246
|
return exporter === void 0 ? `${file} adds \`${name}\`, a function of the area ${home.title} (${home.area}). Its home is ${where}${use}, which does not export \`${name}\` yet: add it to the home in a pull request of ${home.repo}, then import it.` : `${file} adds \`${name}\`, a function of the area ${home.title} (${home.area}). Import \`${name}\` from \`${exporter}\`${use} in place of a local copy.`;
|
|
9143
9247
|
}
|
|
9144
9248
|
const homePackage = {
|
|
@@ -9345,6 +9449,245 @@ const licenseFile = {
|
|
|
9345
9449
|
return breaks;
|
|
9346
9450
|
}
|
|
9347
9451
|
};
|
|
9452
|
+
// src/rules/api-report-script.ts
|
|
9453
|
+
/**
|
|
9454
|
+
* The rule `api-report-script`: a repository with a public package has the root script that checks its API reports.
|
|
9455
|
+
*/
|
|
9456
|
+
/** The package of the reports. */
|
|
9457
|
+
const API_REPORT = "@mark1russell7/api-report";
|
|
9458
|
+
/** The range that the fix adds. The train moves it after that. */
|
|
9459
|
+
const API_REPORT_RANGE = "^0.5.0";
|
|
9460
|
+
/** The command of the script. */
|
|
9461
|
+
const COMMAND = "api-report check";
|
|
9462
|
+
/**
|
|
9463
|
+
* This function gives `text` with one more entry in the block `field` of a `package.json` file. The entry goes in the
|
|
9464
|
+
* order of the names when `sorted` is true, else at the end. It gives undefined when the block is not on separate lines.
|
|
9465
|
+
*/
|
|
9466
|
+
function addEntry(text, field, name, value, sorted) {
|
|
9467
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
9468
|
+
const lines = text.split(/\r?\n/);
|
|
9469
|
+
const start = lines.findIndex((line) => line === ` "${field}": {`);
|
|
9470
|
+
if (start < 0) return void 0;
|
|
9471
|
+
const end = lines.findIndex((line, index) => index > start && /^ {2}\},?$/.test(line));
|
|
9472
|
+
if (end < 0) return void 0;
|
|
9473
|
+
const entry = ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
|
9474
|
+
const nameOf = (line) => line.trim().slice(1).split("\"")[0] ?? "";
|
|
9475
|
+
const next = sorted ? lines.findIndex((line, index) => index > start && index < end && nameOf(line) > name) : -1;
|
|
9476
|
+
if (next >= 0) lines.splice(next, 0, `${entry},`);
|
|
9477
|
+
else {
|
|
9478
|
+
if (end - 1 > start) lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
9479
|
+
lines.splice(end, 0, entry);
|
|
9480
|
+
}
|
|
9481
|
+
return lines.join(eol);
|
|
9482
|
+
}
|
|
9483
|
+
/** This function adds a block with one entry after the last block of the root object. */
|
|
9484
|
+
function addBlock(text, field, name, value) {
|
|
9485
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
9486
|
+
const lines = text.split(/\r?\n/);
|
|
9487
|
+
const end = lines.lastIndexOf("}");
|
|
9488
|
+
if (end < 1) return void 0;
|
|
9489
|
+
lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
9490
|
+
lines.splice(end, 0, ` ${JSON.stringify(field)}: {`, ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`, " }");
|
|
9491
|
+
return lines.join(eol);
|
|
9492
|
+
}
|
|
9493
|
+
/** This function gives the text of the root `package.json` with the script and the dependency, or undefined. */
|
|
9494
|
+
function withScript(root, script) {
|
|
9495
|
+
const add = (text, field, name, value, sorted) => root.manifest[field] === void 0 ? addBlock(text, field, name, value) : addEntry(text, field, name, value, sorted);
|
|
9496
|
+
const scripted = add(root.text, "scripts", script, COMMAND, false);
|
|
9497
|
+
if (scripted === void 0) return void 0;
|
|
9498
|
+
return DEPENDENCY_FIELDS.some((field) => specifiersOf(root.manifest, field).some(([name]) => name === API_REPORT)) ? scripted : add(scripted, "devDependencies", API_REPORT, API_REPORT_RANGE, true);
|
|
9499
|
+
}
|
|
9500
|
+
const apiReportScript = {
|
|
9501
|
+
id: "api-report-script",
|
|
9502
|
+
title: "A repository with a public package has the root script `check:api`.",
|
|
9503
|
+
reason: "The shared CI starts each script of its list that `package.json` has, and it skips the others. On 2026-11-04, 8 of the 12 repositories without the script had a public package, so a change of their API had no check.",
|
|
9504
|
+
fix: "Add the script `\"check:api\": \"api-report check\"` and a dev dependency on `@mark1russell7/api-report`. Then build and start `api-report update`. The release train writes the first report in its update.",
|
|
9505
|
+
sources: [
|
|
9506
|
+
{
|
|
9507
|
+
repo: "template",
|
|
9508
|
+
rule: "api-report",
|
|
9509
|
+
doc: "CLAUDE.md:27"
|
|
9510
|
+
},
|
|
9511
|
+
{
|
|
9512
|
+
repo: "packing",
|
|
9513
|
+
rule: "api-report",
|
|
9514
|
+
doc: "CLAUDE.md:20"
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
repo: "layout-contract",
|
|
9518
|
+
rule: "api-report",
|
|
9519
|
+
doc: "CLAUDE.md:20"
|
|
9520
|
+
}
|
|
9521
|
+
],
|
|
9522
|
+
options: { script: {
|
|
9523
|
+
type: "string",
|
|
9524
|
+
default: "check:api",
|
|
9525
|
+
description: "The root script that checks the API reports."
|
|
9526
|
+
} },
|
|
9527
|
+
check(context, options) {
|
|
9528
|
+
const script = typeof options["script"] === "string" ? options["script"] : "check:api";
|
|
9529
|
+
const published = rootAndCodePackages(context).filter(isPublic);
|
|
9530
|
+
if (published.length === 0) return [];
|
|
9531
|
+
const root = context.rootPackage;
|
|
9532
|
+
const value = root.manifest["scripts"];
|
|
9533
|
+
const scripts = typeof value === "object" && value !== null ? value : {};
|
|
9534
|
+
if (typeof scripts[script] === "string" && scripts[script] !== "") return [];
|
|
9535
|
+
const names = published.map((pkg) => String(pkg.manifest["name"] ?? pkg.folder));
|
|
9536
|
+
const line = lineOf(root.text, "\"scripts\"");
|
|
9537
|
+
const after = withScript(root, script);
|
|
9538
|
+
const edits = after === void 0 ? [] : [{
|
|
9539
|
+
file: root.file,
|
|
9540
|
+
before: root.text,
|
|
9541
|
+
after
|
|
9542
|
+
}];
|
|
9543
|
+
return [{
|
|
9544
|
+
file: root.file,
|
|
9545
|
+
...line === void 0 ? {} : { line },
|
|
9546
|
+
message: `The root package.json has no script "${script}", and the repository has a public package: ${names.join(", ")}.`,
|
|
9547
|
+
...edits.length > 0 ? { edits } : {}
|
|
9548
|
+
}];
|
|
9549
|
+
}
|
|
9550
|
+
};
|
|
9551
|
+
// src/rules/coverage-provider.ts
|
|
9552
|
+
/**
|
|
9553
|
+
* The rule `coverage-provider`: the shared CI starts the action `coverage`. Then each package whose test script starts
|
|
9554
|
+
* Vitest has `@vitest/coverage-v8` at the range of its Vitest. Without the provider, the action skips the package on
|
|
9555
|
+
* `main`, so the artifact `coverage` has no report of it.
|
|
9556
|
+
*/
|
|
9557
|
+
/** The provider of the coverage of Vitest. */
|
|
9558
|
+
const COVERAGE_PROVIDER = "@vitest/coverage-v8";
|
|
9559
|
+
/** The `uses` value of a job that calls the shared CI, from another repository or from the template itself. */
|
|
9560
|
+
const SHARED_CI_CALL = /^(?:mark1russell7\/template\/|\.\/)\.github\/workflows\/reusable-ci\.ya?ml(?:@|$)/;
|
|
9561
|
+
/** This function gives the id of the key of a line of YAML. */
|
|
9562
|
+
const keyOf$1 = (line) => {
|
|
9563
|
+
const text = line.trim();
|
|
9564
|
+
const colon = text.indexOf(":");
|
|
9565
|
+
return (colon < 0 ? text : text.slice(0, colon)).replace(/^["']|["']$/g, "");
|
|
9566
|
+
};
|
|
9567
|
+
/** This function gives the coverage inputs of each job of a workflow text that calls the shared CI. */
|
|
9568
|
+
function coverageInputs(text) {
|
|
9569
|
+
const lines = workflowLines(text);
|
|
9570
|
+
const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && keyValue(line, "jobs") !== void 0);
|
|
9571
|
+
if (jobs < 0) return [];
|
|
9572
|
+
const found = [];
|
|
9573
|
+
for (const job of childKeys(lines, jobs)) {
|
|
9574
|
+
const keys = childKeys(lines, job);
|
|
9575
|
+
const uses = keys.map((at) => keyValue(lines[at] ?? "", "uses")).find((value) => value !== void 0);
|
|
9576
|
+
if (uses === void 0 || !SHARED_CI_CALL.test(uses)) continue;
|
|
9577
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
9578
|
+
const block = keys.find((at) => keyOf$1(lines[at] ?? "") === "with");
|
|
9579
|
+
for (const at of block === void 0 ? [] : childKeys(lines, block)) {
|
|
9580
|
+
const name = keyOf$1(lines[at] ?? "");
|
|
9581
|
+
inputs.set(name, (keyValue(lines[at] ?? "", name) ?? "").replace(/^["']|["']$/g, ""));
|
|
9582
|
+
}
|
|
9583
|
+
found.push({
|
|
9584
|
+
coverage: inputs.get("coverage") ?? "",
|
|
9585
|
+
onMain: inputs.get("coverage-on-main") ?? ""
|
|
9586
|
+
});
|
|
9587
|
+
}
|
|
9588
|
+
return found;
|
|
9589
|
+
}
|
|
9590
|
+
/** This function gives the specifier of a dependency in a manifest, and its field, or undefined. */
|
|
9591
|
+
function specifierOf(pkg, name) {
|
|
9592
|
+
for (const field of DEPENDENCY_FIELDS) {
|
|
9593
|
+
const found = specifiersOf(pkg.manifest, field).find(([key]) => key === name);
|
|
9594
|
+
if (found !== void 0) return {
|
|
9595
|
+
field,
|
|
9596
|
+
range: found[1]
|
|
9597
|
+
};
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9600
|
+
/** This function gives the test script of a package, or an empty text. */
|
|
9601
|
+
function testScript(pkg) {
|
|
9602
|
+
const scripts = pkg.manifest["scripts"];
|
|
9603
|
+
if (typeof scripts !== "object" || scripts === null) return "";
|
|
9604
|
+
const test = scripts["test"];
|
|
9605
|
+
return typeof test === "string" ? test : "";
|
|
9606
|
+
}
|
|
9607
|
+
/** This function gives `text` with the range of a dependency in the block `field` changed to `range`, or undefined. */
|
|
9608
|
+
function withRange(text, field, name, from, range) {
|
|
9609
|
+
const lines = text.split(/\r?\n/);
|
|
9610
|
+
const start = lines.findIndex((line) => line === ` "${field}": {`);
|
|
9611
|
+
if (start < 0) return void 0;
|
|
9612
|
+
const entry = `${JSON.stringify(name)}: ${JSON.stringify(from)}`;
|
|
9613
|
+
const at = lines.findIndex((line, index) => index > start && line.trim().startsWith(entry));
|
|
9614
|
+
if (at < 0) return void 0;
|
|
9615
|
+
lines[at] = (lines[at] ?? "").replace(entry, `${JSON.stringify(name)}: ${JSON.stringify(range)}`);
|
|
9616
|
+
return lines.join(text.includes("\r\n") ? "\r\n" : "\n");
|
|
9617
|
+
}
|
|
9618
|
+
const coverageProvider = {
|
|
9619
|
+
id: "coverage-provider",
|
|
9620
|
+
title: "When the shared CI starts the action `coverage`, each package with Vitest tests has `@vitest/coverage-v8` at the range of its Vitest.",
|
|
9621
|
+
reason: "On `main` of a public repository, the shared CI starts the action `coverage`, and the action skips a package with no `@vitest/coverage-v8`. The artifact `coverage` then has no report of it, and the atlas has no coverage of its functions. On 2026-11-09, 15 of 43 public repositories had no provider. Only `pnpm package add` adds it, and only to a new package. A provider at another range than Vitest fails to load.",
|
|
9622
|
+
fix: "Add `\"@vitest/coverage-v8\"` to `devDependencies` at the range of `vitest`, in the manifest that has `vitest`. `conventions fix` writes it. Then start `pnpm install`. A repository that turns off the coverage of its CI (`coverage-on-main: false`) does not break.",
|
|
9623
|
+
sources: [
|
|
9624
|
+
{
|
|
9625
|
+
repo: "template",
|
|
9626
|
+
rule: "coverage-provider",
|
|
9627
|
+
doc: "packages/cli/src/commands/package/add.ts: the LOCKSTEP of @vitest/coverage-v8 and vitest in each new package"
|
|
9628
|
+
},
|
|
9629
|
+
{
|
|
9630
|
+
repo: "ireko",
|
|
9631
|
+
rule: "coverage-provider",
|
|
9632
|
+
doc: "packages/ireko/package.json: @vitest/coverage-v8 at the range of vitest, and the artifact coverage of ci.yml"
|
|
9633
|
+
},
|
|
9634
|
+
{
|
|
9635
|
+
repo: "codeatlas",
|
|
9636
|
+
rule: "coverage-provider",
|
|
9637
|
+
doc: "packages/*/package.json: @vitest/coverage-v8 at the range of vitest in each package with tests"
|
|
9638
|
+
}
|
|
9639
|
+
],
|
|
9640
|
+
options: {},
|
|
9641
|
+
failsFrom: "2026-11-25",
|
|
9642
|
+
check(context) {
|
|
9643
|
+
const folder = join(context.root, ".github", "workflows");
|
|
9644
|
+
const calls = existsSync(folder) ? readdirSync(folder).filter((file) => /\.ya?ml$/.test(file)).sort().flatMap((file) => coverageInputs(readFileSync(join(folder, file), "utf8"))) : [];
|
|
9645
|
+
if (calls.length === 0) return { skipped: "no workflow calls the shared CI of the template" };
|
|
9646
|
+
const isPublic = repositoryIsPublic(context);
|
|
9647
|
+
if (!calls.some((call) => call.coverage === "true" || call.onMain !== "false" && isPublic !== false)) return { skipped: "the shared CI does not start the action coverage (coverage and coverage-on-main are off)" };
|
|
9648
|
+
const root = context.rootPackage;
|
|
9649
|
+
const breaks = /* @__PURE__ */ new Map();
|
|
9650
|
+
for (const pkg of codePackages(context)) {
|
|
9651
|
+
if (!/\bvitest\b/.test(testScript(pkg))) continue;
|
|
9652
|
+
const owner = specifierOf(pkg, "vitest") === void 0 ? root : pkg;
|
|
9653
|
+
const vitest = specifierOf(owner, "vitest");
|
|
9654
|
+
if (vitest === void 0) continue;
|
|
9655
|
+
const providerAt = specifierOf(pkg, "@vitest/coverage-v8") === void 0 ? root : pkg;
|
|
9656
|
+
const provider = specifierOf(providerAt, COVERAGE_PROVIDER);
|
|
9657
|
+
const name = String(pkg.manifest["name"] ?? (pkg.folder === "" ? "the root" : pkg.folder));
|
|
9658
|
+
if (provider === void 0) {
|
|
9659
|
+
if (breaks.has(owner.file)) continue;
|
|
9660
|
+
const after = vitest.range.startsWith("catalog:") ? void 0 : owner.manifest["devDependencies"] === void 0 ? addBlock(owner.text, "devDependencies", COVERAGE_PROVIDER, vitest.range) : addEntry(owner.text, "devDependencies", COVERAGE_PROVIDER, vitest.range, true);
|
|
9661
|
+
const line = keyLine(owner.text, vitest.field, "vitest");
|
|
9662
|
+
breaks.set(owner.file, {
|
|
9663
|
+
file: owner.file,
|
|
9664
|
+
...line === void 0 ? {} : { line },
|
|
9665
|
+
message: `${name} starts Vitest in its test script, and no manifest gives it ${COVERAGE_PROVIDER}. The action coverage of the shared CI skips it.`,
|
|
9666
|
+
...after === void 0 ? { fix: `Add "${COVERAGE_PROVIDER}": "${vitest.range}" to devDependencies of ${owner.file}.` } : { edits: [{
|
|
9667
|
+
file: owner.file,
|
|
9668
|
+
before: owner.text,
|
|
9669
|
+
after
|
|
9670
|
+
}] }
|
|
9671
|
+
});
|
|
9672
|
+
continue;
|
|
9673
|
+
}
|
|
9674
|
+
if (provider.range === vitest.range || breaks.has(providerAt.file)) continue;
|
|
9675
|
+
const after = withRange(providerAt.text, provider.field, COVERAGE_PROVIDER, provider.range, vitest.range);
|
|
9676
|
+
const line = keyLine(providerAt.text, provider.field, COVERAGE_PROVIDER);
|
|
9677
|
+
breaks.set(providerAt.file, {
|
|
9678
|
+
file: providerAt.file,
|
|
9679
|
+
...line === void 0 ? {} : { line },
|
|
9680
|
+
message: `${COVERAGE_PROVIDER} has the range ${provider.range} in ${providerAt.file}, and vitest has ${vitest.range}. The provider must have the range of Vitest.`,
|
|
9681
|
+
...after === void 0 ? { fix: `Set "${COVERAGE_PROVIDER}" to "${vitest.range}" in ${providerAt.file}.` } : { edits: [{
|
|
9682
|
+
file: providerAt.file,
|
|
9683
|
+
before: providerAt.text,
|
|
9684
|
+
after
|
|
9685
|
+
}] }
|
|
9686
|
+
});
|
|
9687
|
+
}
|
|
9688
|
+
return [...breaks.values()];
|
|
9689
|
+
}
|
|
9690
|
+
};
|
|
9348
9691
|
// src/rules/main-check.ts
|
|
9349
9692
|
/**
|
|
9350
9693
|
* The rule `main-check`: a script does not find out that it is the main module by a compare of `process.argv[1]` with
|
|
@@ -10420,105 +10763,6 @@ const packNoBuildinfo = {
|
|
|
10420
10763
|
return breaks;
|
|
10421
10764
|
}
|
|
10422
10765
|
};
|
|
10423
|
-
// src/rules/api-report-script.ts
|
|
10424
|
-
/**
|
|
10425
|
-
* The rule `api-report-script`: a repository with a public package has the root script that checks its API reports.
|
|
10426
|
-
*/
|
|
10427
|
-
/** The package of the reports. */
|
|
10428
|
-
const API_REPORT = "@mark1russell7/api-report";
|
|
10429
|
-
/** The range that the fix adds. The train moves it after that. */
|
|
10430
|
-
const API_REPORT_RANGE = "^0.5.0";
|
|
10431
|
-
/** The command of the script. */
|
|
10432
|
-
const COMMAND = "api-report check";
|
|
10433
|
-
/**
|
|
10434
|
-
* This function gives `text` with one more entry in the block `field` of a `package.json` file. The entry goes in the
|
|
10435
|
-
* order of the names when `sorted` is true, else at the end. It gives undefined when the block is not on separate lines.
|
|
10436
|
-
*/
|
|
10437
|
-
function addEntry(text, field, name, value, sorted) {
|
|
10438
|
-
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
10439
|
-
const lines = text.split(/\r?\n/);
|
|
10440
|
-
const start = lines.findIndex((line) => line === ` "${field}": {`);
|
|
10441
|
-
if (start < 0) return void 0;
|
|
10442
|
-
const end = lines.findIndex((line, index) => index > start && /^ {2}\},?$/.test(line));
|
|
10443
|
-
if (end < 0) return void 0;
|
|
10444
|
-
const entry = ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
|
10445
|
-
const nameOf = (line) => line.trim().slice(1).split("\"")[0] ?? "";
|
|
10446
|
-
const next = sorted ? lines.findIndex((line, index) => index > start && index < end && nameOf(line) > name) : -1;
|
|
10447
|
-
if (next >= 0) lines.splice(next, 0, `${entry},`);
|
|
10448
|
-
else {
|
|
10449
|
-
if (end - 1 > start) lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
10450
|
-
lines.splice(end, 0, entry);
|
|
10451
|
-
}
|
|
10452
|
-
return lines.join(eol);
|
|
10453
|
-
}
|
|
10454
|
-
/** This function adds a block with one entry after the last block of the root object. */
|
|
10455
|
-
function addBlock(text, field, name, value) {
|
|
10456
|
-
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
10457
|
-
const lines = text.split(/\r?\n/);
|
|
10458
|
-
const end = lines.lastIndexOf("}");
|
|
10459
|
-
if (end < 1) return void 0;
|
|
10460
|
-
lines[end - 1] = `${lines[end - 1] ?? ""},`;
|
|
10461
|
-
lines.splice(end, 0, ` ${JSON.stringify(field)}: {`, ` ${JSON.stringify(name)}: ${JSON.stringify(value)}`, " }");
|
|
10462
|
-
return lines.join(eol);
|
|
10463
|
-
}
|
|
10464
|
-
/** This function gives the text of the root `package.json` with the script and the dependency, or undefined. */
|
|
10465
|
-
function withScript(root, script) {
|
|
10466
|
-
const add = (text, field, name, value, sorted) => root.manifest[field] === void 0 ? addBlock(text, field, name, value) : addEntry(text, field, name, value, sorted);
|
|
10467
|
-
const scripted = add(root.text, "scripts", script, COMMAND, false);
|
|
10468
|
-
if (scripted === void 0) return void 0;
|
|
10469
|
-
return DEPENDENCY_FIELDS.some((field) => specifiersOf(root.manifest, field).some(([name]) => name === API_REPORT)) ? scripted : add(scripted, "devDependencies", API_REPORT, API_REPORT_RANGE, true);
|
|
10470
|
-
}
|
|
10471
|
-
const apiReportScript = {
|
|
10472
|
-
id: "api-report-script",
|
|
10473
|
-
title: "A repository with a public package has the root script `check:api`.",
|
|
10474
|
-
reason: "The shared CI starts each script of its list that `package.json` has, and it skips the others. On 2026-11-04, 8 of the 12 repositories without the script had a public package, so a change of their API had no check.",
|
|
10475
|
-
fix: "Add the script `\"check:api\": \"api-report check\"` and a dev dependency on `@mark1russell7/api-report`. Then build and start `api-report update`. The release train writes the first report in its update.",
|
|
10476
|
-
sources: [
|
|
10477
|
-
{
|
|
10478
|
-
repo: "template",
|
|
10479
|
-
rule: "api-report",
|
|
10480
|
-
doc: "CLAUDE.md:27"
|
|
10481
|
-
},
|
|
10482
|
-
{
|
|
10483
|
-
repo: "packing",
|
|
10484
|
-
rule: "api-report",
|
|
10485
|
-
doc: "CLAUDE.md:20"
|
|
10486
|
-
},
|
|
10487
|
-
{
|
|
10488
|
-
repo: "layout-contract",
|
|
10489
|
-
rule: "api-report",
|
|
10490
|
-
doc: "CLAUDE.md:20"
|
|
10491
|
-
}
|
|
10492
|
-
],
|
|
10493
|
-
options: { script: {
|
|
10494
|
-
type: "string",
|
|
10495
|
-
default: "check:api",
|
|
10496
|
-
description: "The root script that checks the API reports."
|
|
10497
|
-
} },
|
|
10498
|
-
check(context, options) {
|
|
10499
|
-
const script = typeof options["script"] === "string" ? options["script"] : "check:api";
|
|
10500
|
-
const published = rootAndCodePackages(context).filter(isPublic);
|
|
10501
|
-
if (published.length === 0) return [];
|
|
10502
|
-
const root = context.rootPackage;
|
|
10503
|
-
const value = root.manifest["scripts"];
|
|
10504
|
-
const scripts = typeof value === "object" && value !== null ? value : {};
|
|
10505
|
-
if (typeof scripts[script] === "string" && scripts[script] !== "") return [];
|
|
10506
|
-
const names = published.map((pkg) => String(pkg.manifest["name"] ?? pkg.folder));
|
|
10507
|
-
const line = lineOf(root.text, "\"scripts\"");
|
|
10508
|
-
const after = withScript(root, script);
|
|
10509
|
-
const edits = after === void 0 ? [] : [{
|
|
10510
|
-
file: root.file,
|
|
10511
|
-
before: root.text,
|
|
10512
|
-
after
|
|
10513
|
-
}];
|
|
10514
|
-
return [{
|
|
10515
|
-
file: root.file,
|
|
10516
|
-
...line === void 0 ? {} : { line },
|
|
10517
|
-
message: `The root package.json has no script "${script}", and the repository has a public package: ${names.join(", ")}.`,
|
|
10518
|
-
...edits.length > 0 ? { edits } : {}
|
|
10519
|
-
}];
|
|
10520
|
-
}
|
|
10521
|
-
};
|
|
10522
10766
|
// src/rules/pages-site.ts
|
|
10523
10767
|
/**
|
|
10524
10768
|
* The rule `pages-site`: a public repository has a site. A workflow uses the Pages workflow of the template, and the
|
|
@@ -13921,6 +14165,7 @@ const RULES = [
|
|
|
13921
14165
|
setupCue,
|
|
13922
14166
|
homePackage,
|
|
13923
14167
|
licenseFile,
|
|
14168
|
+
coverageProvider,
|
|
13924
14169
|
packNoBuildinfo,
|
|
13925
14170
|
pagesSite,
|
|
13926
14171
|
pagesAfterRelease,
|
|
@@ -14808,6 +15053,6 @@ function runHook(args, io) {
|
|
|
14808
15053
|
git: (gitArgs) => runGit(io.cwd, gitArgs)
|
|
14809
15054
|
}, io);
|
|
14810
15055
|
}
|
|
14811
|
-
export { unreleasedChangeRule as $,
|
|
15056
|
+
export { unreleasedChangeRule as $, findHomes as $t, typedFiles as A, STRICT_OPTIONS as An, nameMatches as At, roadmapParses as B, matchesAny as Bn, authorOf as Bt, versionTitle as C, convertGate as Cn, PRIVATE_NAME_LIST as Ct, typedScripts as D, gateAfterCancel as Dn, isCommonUse as Dt, trustPolicy as E, summaryName as En, isAllowedHit as Et, HOME_TIMEOUT_MS as F, codePackages as Fn, hasImportMetaMain as Ft, publishedMinor as G, specifiersOf as Gn, declaredName as Gt, releaseFiles as H, readJsonc as Hn, licenseFileOf as Ht, blockHash as I, hasFile as In, mainCheck as It, NPM_REGISTRY as J, repoOf as Jt, publishedMinorRule as K, defaultOptions as Kn, homePackage as Kt, githubFetch as L, inFolder as Ln, coverageProvider as Lt, isSourcePath as M, DEPENDENCY_FIELDS as Mn, pathNameHit as Mt, pathsOf as N, RULE_WARN_DAYS as Nn, noBuildOutput as Nt, configsOfScript as O, readAction as On, lineNameHit as Ot, sourceMain as P, cleanPath as Pn, REAL_COMPARE as Pt, unreleasedChange as Q, MAP_RULE as Qt, sharedDocsRule as R, keyLine as Rn, apiReportScript as Rt, setVersions as S, ACTIONS_COMMIT as Sn, privateTextBreaks as St, TRAIN_SCOPES as T, prPathFilters as Tn, firstNameMatch as Tt, lockedVersions as U, replaceLine as Un, mitText as Ut, requiredScripts as V, parseJsonc as Vn, licenseFile as Vt, minorOf as W, runGit as Wn, repositoryIsPublic as Wt, UNSHIPPED_FILES as X, signaturesOf as Xt, SHIPPED_FIELDS as Y, reposOf as Yt, npmLookup as Z, HOMES as Zt, workspaceProtocol as _, SECURITY_SCAN_INPUTS as _n, PRIVATE_PATTERNS_VARIABLE as _t, listRules as a, SERVICE_PACKAGE as an, repositoryOfRemote as at, yamlFaults as b, securityOneJob as bn, privateNamesFile as bt, runCli as c, hasTests as cn, pushMainOnly as ct, HOOK_MARKER as d, SHARED_CI as dn, pagesSite as dt, mapMarkdown as en, pipeFails as et, NO_READ_LINE as f, SHARED_WORKFLOWS as fn, packNoBuildinfo as ft, RULES as g, SECURITY_SCAN_COMMIT as gn, PRIVATE_NAMES_FILE_VARIABLE as gt, prePush as h, setupCue as hn, PRIVATE_NAMES_FILE_CONFIG as ht, formatResult as i, HOME_EXPORTS as in, pagesAfterRelease as it, testsRequired as j, cuePreset as jn, parsePrivateNames as jt, scriptsOf as k, readWorkflow as kn, lineNameHits as kt, runFix as l, tsconfigTest as ln, PAGES_WORKFLOWS as lt, installHook as m, sharedCi as mn, HOME_PATTERNS as mt, annotations as n, mergeHomes as nn, isPinned as nt, readConfig as o, runCalls as on, runnerBudget as ot, PRE_PUSH_HOOK as p, callsSharedCi as pn, DEFAULT_ALLOWED as pt, reachOf as q, parseConfig as qn, messageOf as qt, createContext as r, readOverlay as rn, pinnedGitDeps as rt, runChecks as s, serviceRunMain as sn, scheduleMinute as st, USAGE as t, mapText as tn, isGitSpecifier as tt, summaryMarkdown as u, SHARED_ACTIONS as un, pagesCalls as ut, GITHUB_YAML as v, SECURITY_TIMEOUT_MINUTES as vn, invalidPatternBreaks as vt, IGNORE_AFTER as w, gateTrigger as wn, PrivateNameListError as wt, namedVersions as x, withOneJob as xn, privatePatterns as xt, workflowParses as y, securityCallers as yn, noLocalPaths as yt, roadmapOfLine as z, lineOf as zn, LICENSE_TEXTS as zt };
|
|
14812
15057
|
|
|
14813
|
-
//# sourceMappingURL=run-
|
|
15058
|
+
//# sourceMappingURL=run-CMtFuxIb.js.map
|