@antelopejs/tooling-configs 0.2.7 → 0.2.9
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 +31 -18
- package/dist/bin/api-diff.mjs +15 -8
- package/dist/bin/check-size.mjs +4 -3
- package/dist/bin/checks.mjs +2 -1
- package/dist/bin/comment-proof.mjs +3 -2
- package/dist/bin/garden.d.mts +1 -0
- package/dist/bin/garden.mjs +1480 -0
- package/dist/bin/ratchet.mjs +4 -3
- package/dist/bin/suppressions.mjs +11 -5
- package/dist/bin/sync.mjs +37 -34
- package/dist/ci-workflow-BDy6hQJ6.mjs +164 -0
- package/dist/cli-4Tv71vYk.mjs +19 -0
- package/dist/{files-BMxKg5IR.mjs → files-2FikHZ9F.mjs} +1 -11
- package/dist/{ratchet-zzo2tT74.mjs → ratchet-B2qYUs51.mjs} +3 -3
- package/dist/{size-Fp3aWSkN.mjs → size-BVgNbLO6.mjs} +1 -1
- package/dist/{staged-ratchet-CJHjp2kx.mjs → staged-ratchet-BNfjcbih.mjs} +1 -1
- package/dist/suppression-budget-Bq30tJDS.mjs +282 -0
- package/dist/{suppressions-CgGa-kh7.mjs → suppressions-BJAngUxo.mjs} +104 -18
- package/dist/{typescript-DIXhKgXR.mjs → typescript-C54ONh9m.mjs} +63 -14
- package/package.json +2 -1
- package/dist/suppression-budget-N5ONsh2g.mjs +0 -144
package/dist/bin/ratchet.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as CEILINGS_FILE } from "../ceilings-BSw9p4YB.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
3
|
+
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
4
|
+
import { a as repositoryPath, o as repositoryRoot, s as resolveRevision } from "../files-2FikHZ9F.mjs";
|
|
5
|
+
import { n as stagedRatchet } from "../staged-ratchet-BNfjcbih.mjs";
|
|
6
|
+
import { n as ratchet } from "../ratchet-B2qYUs51.mjs";
|
|
6
7
|
import { resolve } from "node:path";
|
|
7
8
|
import { parseArgs } from "node:util";
|
|
8
9
|
//#region src/bin/ratchet.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
+
import { o as repositoryRoot, s as resolveRevision } from "../files-2FikHZ9F.mjs";
|
|
4
|
+
import { a as parseBudget, c as checkPolicy, i as checkSuppressions, n as SUPPRESSIONS_FILE, o as safetyCeiling, s as stagedSuppressions } from "../suppression-budget-Bq30tJDS.mjs";
|
|
4
5
|
import { readFileSync } from "node:fs";
|
|
5
6
|
import { join } from "node:path";
|
|
6
7
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
@@ -53,7 +54,8 @@ function suppressionBase(root, base) {
|
|
|
53
54
|
/**
|
|
54
55
|
* Fails each ceiling of the working-tree budget that is higher than on
|
|
55
56
|
* `revision`, and each rule that `revision` lists but the working tree
|
|
56
|
-
* dropped.
|
|
57
|
+
* dropped. The safety ceiling may rise by what the SAFETY rule's own
|
|
58
|
+
* ceiling falls. A base without a budget, a first adoption, passes.
|
|
57
59
|
*/
|
|
58
60
|
function raisedCeilings(root, revision) {
|
|
59
61
|
const committed = spawnSync("git", ["show", `${revision}:${SUPPRESSIONS_FILE}`], {
|
|
@@ -72,7 +74,7 @@ function raisedCeilings(root, revision) {
|
|
|
72
74
|
for (const rule of /* @__PURE__ */ new Set([...Object.keys(base.rules), ...Object.keys(current.rules)])) compare(`lint rule \`${rule}\``, base.rules[rule] ?? 0, Object.hasOwn(base.rules, rule) ? current.rules[rule] : current.rules[rule] ?? 0);
|
|
73
75
|
compare("`@ts-expect-error`", base.tsExpectError, current.tsExpectError);
|
|
74
76
|
compare("`@ts-ignore`", base.tsIgnore, current.tsIgnore);
|
|
75
|
-
compare("`SAFETY:` comments", base.safety, current.safety);
|
|
77
|
+
compare("`SAFETY:` comments", safetyCeiling(base, current.rules["anti-slop/require-safety-comment-for-type-assertion"] ?? 0), current.safety);
|
|
76
78
|
return failures.length ? [...failures, "Ceilings only go down. Fix the code, or remove another suppression of the same kind; raising a ceiling needs the operator's approval through the ruleset bypass."] : [];
|
|
77
79
|
}
|
|
78
80
|
//#endregion
|
|
@@ -80,7 +82,11 @@ function raisedCeilings(root, revision) {
|
|
|
80
82
|
function fullCheck(root, update, base) {
|
|
81
83
|
const failures = checkSuppressions(root, update);
|
|
82
84
|
const revision = suppressionBase(root, base);
|
|
83
|
-
return revision === void 0 ? failures
|
|
85
|
+
return revision === void 0 ? [...failures, ...checkPolicy(root)] : [
|
|
86
|
+
...raisedCeilings(root, revision),
|
|
87
|
+
...failures,
|
|
88
|
+
...checkPolicy(root, revision)
|
|
89
|
+
];
|
|
84
90
|
}
|
|
85
91
|
runCli(() => {
|
|
86
92
|
const { values } = parseArgs({
|
package/dist/bin/sync.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as formatCeilings, o as isRetired, s as readCeilings, t as CEILINGS_FILE } from "../ceilings-BSw9p4YB.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
4
|
+
import { o as repositoryRoot } from "../files-2FikHZ9F.mjs";
|
|
4
5
|
import { a as repositoryTools, i as parseManifest, n as managedPackage, o as toolingVersions, r as packageManager, t as execCommand } from "../package-Dtjt_lSa.mjs";
|
|
5
|
-
import { t as measureBaseline } from "../ratchet-
|
|
6
|
-
import { n as
|
|
6
|
+
import { t as measureBaseline } from "../ratchet-B2qYUs51.mjs";
|
|
7
|
+
import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-Bq30tJDS.mjs";
|
|
8
|
+
import { a as ciWorkflow, c as ciNodeCallers, i as MUTATION_PATH, l as hasChecksWorkflow, o as mutationCaller, r as CI_PATH, s as MISSING_CHECKS_WORKFLOW } from "../ci-workflow-BDy6hQJ6.mjs";
|
|
7
9
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
10
|
import { dirname, join, resolve } from "node:path";
|
|
9
11
|
import { execFileSync } from "node:child_process";
|
|
10
12
|
import { parseArgs } from "node:util";
|
|
11
|
-
import { isMap,
|
|
13
|
+
import { isMap, parseDocument } from "yaml";
|
|
12
14
|
//#region src/guardrails/agents-block.ts
|
|
13
15
|
const AGENTS_BLOCK_START = "<!-- antelopejs-guardrails:start -->";
|
|
14
16
|
const AGENTS_BLOCK_END = "<!-- antelopejs-guardrails:end -->";
|
|
@@ -34,10 +36,14 @@ Copy counts from the proof's base and HEAD table. Never type counts by hand. Kee
|
|
|
34
36
|
|
|
35
37
|
Pass \`--probe <file.cjs>\` to api-diff when changing receivers, positional calls, or modules that no published entry reaches. The same captured script runs against both worktree roots, supplied as \`argv[2]\`, and prints JSON observations. Matching metadata alone does not prove those behaviours.
|
|
36
38
|
|
|
37
|
-
An entry-only rule exempts only its own module. Add a second module entry rather than exempting another importer. A no-upward rule must reject peers in the same tier as well as higher tiers. Probe the rank decision with an import, not just a reading of the configuration
|
|
39
|
+
An entry-only rule exempts only its own module. Add a second module entry rather than exempting another importer. A no-upward rule must reject peers in the same tier as well as higher tiers. Probe the rank decision with an import, not just a reading of the configuration.
|
|
40
|
+
|
|
41
|
+
Moving a method body into a function keeps how it is called: the same receiver, argument count, read order and laziness.
|
|
42
|
+
|
|
43
|
+
Verify a boundary against the imports a developer or agent would plausibly write: static and dynamic imports, re-exports, Vue \`src\`, CSS \`@import\`, and worker or child-process entries in normally named files. A construction only an evasion would write, an edit to resolution configuration (\`package.json\` \`browser\`, \`exports\`, \`main\` or \`imports\`, bundler aliases, tsconfig \`paths\`), and a difference observable only by patching private fields or internal methods go under Attention and never block. Public API and ordinary subclass behaviour stay part of the contract.`;
|
|
38
44
|
const SUPPRESSION_BUDGET = `### Suppression budget
|
|
39
45
|
|
|
40
|
-
\`guardrails.suppressions.json\` caps the suppressions in authored code: lint directives per rule they name (\`*\` for none), \`@ts-expect-error\`, \`@ts-ignore\` and \`SAFETY:\` comments. A suppression over its ceiling fails: fix the code, or remove another suppression of the same kind. A rule that keeps needing suppressions should be changed in the preset. Never raise or remove a number in that file: the check fails a ceiling higher than on the pull request base, and only the operator approves a raise. After you remove suppressions, run \`pnpm run suppressions:update\` and commit the lowered file.`;
|
|
46
|
+
\`guardrails.suppressions.json\` caps the suppressions in authored code: lint directives per rule they name (\`*\` for none), \`@ts-expect-error\`, \`@ts-ignore\` and \`SAFETY:\` comments. A suppression over its ceiling fails: fix the code, or remove another suppression of the same kind. A rule that keeps needing suppressions should be changed in the preset. Never raise or remove a number in that file: the check fails a ceiling higher than on the pull request base, and only the operator approves a raise. A directive disabling \`anti-slop/require-safety-comment-for-type-assertion\` is burn-down debt: remove the assertion, or, where it holds, replace the directive with \`SAFETY: <why it holds>\`, which takes over its room without a raise. After you remove suppressions, run \`pnpm run suppressions:update\` and commit the lowered file.`;
|
|
41
47
|
const SHARED_RULES = [
|
|
42
48
|
["Formatting", "oxfmt"],
|
|
43
49
|
["Lint findings are errors; no rule warns", "oxlint preset"],
|
|
@@ -51,13 +57,17 @@ const SHARED_RULES = [
|
|
|
51
57
|
["Comment-only changes preserve JavaScript emit", "`antelopejs-comment-proof <base-ref>`"],
|
|
52
58
|
["PR-body counts come from tracked code files", "api-diff and comment-proof tables"],
|
|
53
59
|
["Receiver, positional and unpublished-module behaviour", "`antelopejs-api-diff <base-ref> --probe <file.cjs>`"],
|
|
54
|
-
["
|
|
60
|
+
["Directive and `SAFETY:` reasons are true of the code", "review; no tool"],
|
|
61
|
+
["Evasion-only and patched-internal findings go under Attention", "review; no tool"],
|
|
55
62
|
["No-upward rules reject same-tier peers", "review and import probes"],
|
|
56
63
|
["No `@ts-ignore`", "`typescript/ban-ts-comment`"]
|
|
57
64
|
];
|
|
58
65
|
const FULL_RULES = [
|
|
59
66
|
["Files ≤ 20,000 bytes, tests included", "`antelopejs-check-size` (pre-commit)"],
|
|
60
67
|
["Suppressions stay within `guardrails.suppressions.json`", "`antelopejs-suppressions` (pre-commit, checks)"],
|
|
68
|
+
["No added directive disables the `SAFETY:`, comment or test rules", "`antelopejs-suppressions` (pre-commit, checks)"],
|
|
69
|
+
["An added suppression gives a specific reason", "`antelopejs-suppressions` (pre-commit, checks)"],
|
|
70
|
+
["A block disable is closed in its file", "`antelopejs-suppressions` (pre-commit, checks)"],
|
|
61
71
|
["Types check", "`tsc` (pre-push)"],
|
|
62
72
|
["No dead files, exports, or dependencies", "knip"],
|
|
63
73
|
["Managed files match the pack", "`antelopejs-sync --check`"],
|
|
@@ -260,32 +270,6 @@ case "$manager" in
|
|
|
260
270
|
esac
|
|
261
271
|
`;
|
|
262
272
|
//#endregion
|
|
263
|
-
//#region src/guardrails/workflow.ts
|
|
264
|
-
const MISSING_CHECKS_WORKFLOW = "No workflow in .github/workflows runs pnpm run checks. Add a step running `pnpm run checks` (or `pnpm checks`), or a job using AntelopeJS/.github/.github/workflows/ci-node.yml@<ref>.";
|
|
265
|
-
function hasChecksWorkflow(root) {
|
|
266
|
-
const directory = join(root, ".github/workflows");
|
|
267
|
-
if (!existsSync(directory)) return false;
|
|
268
|
-
for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
|
|
269
|
-
const document = parseDocument(readFileSync(join(directory, file), "utf8"));
|
|
270
|
-
if (document.errors.length) continue;
|
|
271
|
-
const jobs = document.get("jobs", true);
|
|
272
|
-
if (!isMap(jobs)) continue;
|
|
273
|
-
for (const { value: job } of jobs.items) {
|
|
274
|
-
if (!isMap(job)) continue;
|
|
275
|
-
const uses = job.get("uses", true);
|
|
276
|
-
if (isScalar(uses) && /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/.test(String(uses.value))) return true;
|
|
277
|
-
const steps = job.get("steps", true);
|
|
278
|
-
if (!isSeq(steps)) continue;
|
|
279
|
-
for (const step of steps.items) {
|
|
280
|
-
if (!isMap(step)) continue;
|
|
281
|
-
const run = step.get("run", true);
|
|
282
|
-
if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
//#endregion
|
|
289
273
|
//#region src/guardrails/entry-only.ts
|
|
290
274
|
const LOAD_RULES = `
|
|
291
275
|
const advisories = [];
|
|
@@ -395,6 +379,22 @@ const MANAGED_ARTIFACTS = [
|
|
|
395
379
|
notes: []
|
|
396
380
|
})
|
|
397
381
|
},
|
|
382
|
+
{
|
|
383
|
+
path: CI_PATH,
|
|
384
|
+
profiles: ["full", "template"],
|
|
385
|
+
desired: (current) => ({
|
|
386
|
+
content: ciWorkflow(current, current === void 0 ? [] : ciNodeCallers(current)),
|
|
387
|
+
notes: []
|
|
388
|
+
})
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
path: MUTATION_PATH,
|
|
392
|
+
profiles: ["full"],
|
|
393
|
+
desired: (_current, context) => ({
|
|
394
|
+
content: mutationCaller(context.packageName),
|
|
395
|
+
notes: []
|
|
396
|
+
})
|
|
397
|
+
},
|
|
398
398
|
{
|
|
399
399
|
path: "package.json",
|
|
400
400
|
profiles: ["full"],
|
|
@@ -460,6 +460,7 @@ function planSync(current, modes, context) {
|
|
|
460
460
|
for (const artifact of MANAGED_ARTIFACTS) {
|
|
461
461
|
if (!artifact.profiles.includes(context.profile)) continue;
|
|
462
462
|
if (artifact.path === "guardrails.ratchet.json" && !context.ratchet) continue;
|
|
463
|
+
if (artifact.path === ".github/workflows/ci.yml" && !context.managesCi) continue;
|
|
463
464
|
try {
|
|
464
465
|
const { content, notes } = artifact.desired(current.get(artifact.path), context);
|
|
465
466
|
const changed = current.get(artifact.path) !== content || artifact.mode !== void 0 && (artifact.mode & 73) !== 0 && ((modes.get(artifact.path) ?? 0) & 73) === 0;
|
|
@@ -543,6 +544,8 @@ function repositoryContext(root, current, profile) {
|
|
|
543
544
|
claude: profile === "full" ? claudeProse(root, current) : "",
|
|
544
545
|
baseline: "",
|
|
545
546
|
suppressionBudget: profile === "full" && !current.has("guardrails.suppressions.json") ? adoptedBudget(root) : "",
|
|
547
|
+
packageName: manifest.name ?? "",
|
|
548
|
+
managesCi: current.has(".github/workflows/ci.yml") || !hasChecksWorkflow(root),
|
|
546
549
|
verificationSkill: verificationSkill(root),
|
|
547
550
|
glossary: ["GLOSSARY.md", "docs/GLOSSARY.md"].find((file) => existsSync(join(root, file)))
|
|
548
551
|
};
|
|
@@ -558,7 +561,7 @@ function writeArtifacts(root, artifacts) {
|
|
|
558
561
|
}
|
|
559
562
|
function repositoryNotices(root, context) {
|
|
560
563
|
const notices = [];
|
|
561
|
-
if (context.profile === "full" && !hasChecksWorkflow(root)) notices.push(MISSING_CHECKS_WORKFLOW);
|
|
564
|
+
if (context.profile === "full" && !hasChecksWorkflow(root) && existsSync(join(root, ".github/workflows/ci.yml"))) notices.push(MISSING_CHECKS_WORKFLOW);
|
|
562
565
|
if (context.ratchet && isRetired(readCeilings(root))) notices.push(RETIRED_RATCHET);
|
|
563
566
|
return notices;
|
|
564
567
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
4
|
+
//#region src/guardrails/workflow.ts
|
|
5
|
+
const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
|
|
6
|
+
const MISSING_CHECKS_WORKFLOW = "No workflow in .github/workflows runs pnpm run checks. Add a step running `pnpm run checks` (or `pnpm checks`), or a job using AntelopeJS/.github/.github/workflows/ci-node.yml@<ref>.";
|
|
7
|
+
function hasChecksWorkflow(root) {
|
|
8
|
+
const directory = join(root, ".github/workflows");
|
|
9
|
+
if (!existsSync(directory)) return false;
|
|
10
|
+
for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
|
|
11
|
+
const document = parseDocument(readFileSync(join(directory, file), "utf8"));
|
|
12
|
+
if (document.errors.length) continue;
|
|
13
|
+
const jobs = document.get("jobs", true);
|
|
14
|
+
if (!isMap(jobs)) continue;
|
|
15
|
+
for (const { value: job } of jobs.items) {
|
|
16
|
+
if (!isMap(job)) continue;
|
|
17
|
+
const uses = job.get("uses", true);
|
|
18
|
+
if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
|
|
19
|
+
const steps = job.get("steps", true);
|
|
20
|
+
if (!isSeq(steps)) continue;
|
|
21
|
+
for (const step of steps.items) {
|
|
22
|
+
if (!isMap(step)) continue;
|
|
23
|
+
const run = step.get("run", true);
|
|
24
|
+
if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
/** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
|
|
31
|
+
function ciNodeCallers(text) {
|
|
32
|
+
const document = parseDocument(text);
|
|
33
|
+
const jobs = document.errors.length ? void 0 : document.get("jobs", true);
|
|
34
|
+
if (!isMap(jobs)) return [];
|
|
35
|
+
const callers = [];
|
|
36
|
+
for (const { key, value: job } of jobs.items) {
|
|
37
|
+
if (!isMap(job)) continue;
|
|
38
|
+
const uses = job.get("uses", true);
|
|
39
|
+
if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) callers.push({
|
|
40
|
+
id: String(isScalar(key) ? key.value : key),
|
|
41
|
+
uses: String(uses.value),
|
|
42
|
+
named: job.has("name")
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return callers;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/guardrails/ci-workflow.ts
|
|
49
|
+
const CI_PATH = ".github/workflows/ci.yml";
|
|
50
|
+
const MUTATION_PATH = ".github/workflows/mutation.yml";
|
|
51
|
+
/** The status context GitHub derives from the caller job id and the shared workflow's `checks` job. */
|
|
52
|
+
const CI_CONTEXT = `ci / checks`;
|
|
53
|
+
const CI_NODE_REF = "AntelopeJS/.github/.github/workflows/ci-node.yml@v1";
|
|
54
|
+
const MUTATION_REF = "AntelopeJS/.github/.github/workflows/mutation.yml@v1";
|
|
55
|
+
const CI_CALLER = `name: ci
|
|
56
|
+
|
|
57
|
+
on:
|
|
58
|
+
push:
|
|
59
|
+
branches:
|
|
60
|
+
- main
|
|
61
|
+
- next
|
|
62
|
+
pull_request:
|
|
63
|
+
workflow_dispatch:
|
|
64
|
+
|
|
65
|
+
permissions:
|
|
66
|
+
contents: read
|
|
67
|
+
|
|
68
|
+
jobs:
|
|
69
|
+
ci:
|
|
70
|
+
permissions:
|
|
71
|
+
contents: write
|
|
72
|
+
actions: write
|
|
73
|
+
uses: ${CI_NODE_REF}
|
|
74
|
+
`;
|
|
75
|
+
const WEEK_MINUTES = 10080;
|
|
76
|
+
/** Spreads the weekly runs of different repositories over the week so they do not queue together. */
|
|
77
|
+
function mutationCaller(packageName) {
|
|
78
|
+
let slot = 0;
|
|
79
|
+
for (const character of packageName) slot = (slot * 31 + character.charCodeAt(0)) % WEEK_MINUTES;
|
|
80
|
+
const day = Math.floor(slot / 1440) % 7;
|
|
81
|
+
return `name: mutation
|
|
82
|
+
|
|
83
|
+
on:
|
|
84
|
+
schedule:
|
|
85
|
+
- cron: "${slot % 60} ${Math.floor(slot % 1440 / 60)} * * ${day}"
|
|
86
|
+
workflow_dispatch:
|
|
87
|
+
|
|
88
|
+
permissions:
|
|
89
|
+
contents: read
|
|
90
|
+
|
|
91
|
+
jobs:
|
|
92
|
+
mutation:
|
|
93
|
+
uses: ${MUTATION_REF}
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
function renameNeeds(document, from, to) {
|
|
97
|
+
const jobs = document.get("jobs", true);
|
|
98
|
+
if (!isMap(jobs)) return;
|
|
99
|
+
for (const { value: job } of jobs.items) {
|
|
100
|
+
if (!isMap(job)) continue;
|
|
101
|
+
const needs = job.get("needs", true);
|
|
102
|
+
if (isScalar(needs) && needs.value === from) needs.value = to;
|
|
103
|
+
if (isSeq(needs)) {
|
|
104
|
+
for (const entry of needs.items) if (isScalar(entry) && entry.value === from) entry.value = to;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function hasDispatch(document) {
|
|
109
|
+
const trigger = document.get("on", true);
|
|
110
|
+
if (isMap(trigger)) return trigger.has("workflow_dispatch");
|
|
111
|
+
if (isSeq(trigger)) return trigger.items.some((entry) => isScalar(entry) && entry.value === "workflow_dispatch");
|
|
112
|
+
return isScalar(trigger) && trigger.value === "workflow_dispatch";
|
|
113
|
+
}
|
|
114
|
+
function addDispatch(document) {
|
|
115
|
+
const trigger = document.get("on", true);
|
|
116
|
+
if (isMap(trigger)) trigger.set("workflow_dispatch", null);
|
|
117
|
+
else if (isSeq(trigger)) trigger.add("workflow_dispatch");
|
|
118
|
+
else document.set("on", document.createNode(isScalar(trigger) && trigger.value ? [String(trigger.value), "workflow_dispatch"] : ["workflow_dispatch"]));
|
|
119
|
+
}
|
|
120
|
+
function grantsDispatch(job) {
|
|
121
|
+
const granted = job.get("permissions", true);
|
|
122
|
+
return isMap(granted) && granted.items.length === 2 && granted.get("contents") === "write" && granted.get("actions") === "write";
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Keeps the shared CI caller on the job id `ci` with no `name`, so the shared workflow reports `ci / checks`,
|
|
126
|
+
* dispatchable and granted the write permissions the renovate-sync job needs to dispatch it.
|
|
127
|
+
* A workflow with no caller job is repository-specific CI and is left as it is.
|
|
128
|
+
*/
|
|
129
|
+
function ciWorkflow(current, callers) {
|
|
130
|
+
if (current === void 0) return CI_CALLER;
|
|
131
|
+
if (!callers.length) return current;
|
|
132
|
+
const document = parseDocument(current);
|
|
133
|
+
if (document.errors.length) throw new Error(`${CI_PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
|
|
134
|
+
const jobs = document.get("jobs", true);
|
|
135
|
+
if (!isMap(jobs)) return current;
|
|
136
|
+
const caller = callers.find(({ id }) => id === "ci") ?? callers[0];
|
|
137
|
+
if (caller.id !== "ci" && jobs.has("ci")) throw new Error(`${CI_PATH}: a job named ci already exists besides the ${caller.id} job that calls ci-node.yml. Rename or merge them, then rerun antelopejs-sync.`);
|
|
138
|
+
const pair = jobs.items.find(({ key }) => isScalar(key) && key.value === caller.id);
|
|
139
|
+
if (!pair || !isMap(pair.value)) return current;
|
|
140
|
+
let changed = false;
|
|
141
|
+
if (caller.named) {
|
|
142
|
+
pair.value.delete("name");
|
|
143
|
+
changed = true;
|
|
144
|
+
}
|
|
145
|
+
if (caller.id !== "ci") {
|
|
146
|
+
if (isScalar(pair.key)) pair.key.value = "ci";
|
|
147
|
+
renameNeeds(document, caller.id, "ci");
|
|
148
|
+
changed = true;
|
|
149
|
+
}
|
|
150
|
+
if (!grantsDispatch(pair.value)) {
|
|
151
|
+
pair.value.set("permissions", document.createNode({
|
|
152
|
+
contents: "write",
|
|
153
|
+
actions: "write"
|
|
154
|
+
}));
|
|
155
|
+
changed = true;
|
|
156
|
+
}
|
|
157
|
+
if (!hasDispatch(document)) {
|
|
158
|
+
addDispatch(document);
|
|
159
|
+
changed = true;
|
|
160
|
+
}
|
|
161
|
+
return changed ? document.toString({ lineWidth: 0 }) : current;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { ciWorkflow as a, ciNodeCallers as c, MUTATION_PATH as i, hasChecksWorkflow as l, CI_NODE_REF as n, mutationCaller as o, CI_PATH as r, MISSING_CHECKS_WORKFLOW as s, CI_CONTEXT as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/guardrails/cli.ts
|
|
2
|
+
function runCli(main) {
|
|
3
|
+
try {
|
|
4
|
+
process.exitCode = main();
|
|
5
|
+
} catch (error) {
|
|
6
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function runCliAsync(main) {
|
|
11
|
+
try {
|
|
12
|
+
process.exitCode = await main();
|
|
13
|
+
} catch (error) {
|
|
14
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { runCliAsync as n, runCli as t };
|
|
@@ -3,16 +3,6 @@ import { n as IGNORE_PATTERNS, t as AGENT_IGNORE_PATTERNS } from "./shared-CsXIM
|
|
|
3
3
|
import { closeSync, existsSync, lstatSync, openSync, readSync } from "node:fs";
|
|
4
4
|
import { dirname, join, matchesGlob, relative, resolve } from "node:path";
|
|
5
5
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
6
|
-
//#region src/guardrails/cli.ts
|
|
7
|
-
function runCli(main) {
|
|
8
|
-
try {
|
|
9
|
-
process.exitCode = main();
|
|
10
|
-
} catch (error) {
|
|
11
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
12
|
-
process.exitCode = 1;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
6
|
//#region src/guardrails/files.ts
|
|
17
7
|
const SIZE_EXCLUSIONS = [
|
|
18
8
|
{
|
|
@@ -189,4 +179,4 @@ function authoredSizes(root, files = gitFiles(root), staged = false) {
|
|
|
189
179
|
return sizes;
|
|
190
180
|
}
|
|
191
181
|
//#endregion
|
|
192
|
-
export { repositoryPath as a, trackedManifests as c, gitFiles as i,
|
|
182
|
+
export { repositoryPath as a, trackedManifests as c, gitFiles as i, changedFiles as n, repositoryRoot as o, generatedOutput as r, resolveRevision as s, authoredSizes as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as formatCeilings, n as MAX_FILE_BYTES, o as isRetired, t as CEILINGS_FILE } from "./ceilings-BSw9p4YB.mjs";
|
|
2
2
|
import { t as readCarriedCeilings } from "./renames-BGO4dWJ8.mjs";
|
|
3
|
-
import { n as changedFiles, t as authoredSizes } from "./files-
|
|
4
|
-
import { r as lintDiagnostics } from "./staged-ratchet-
|
|
5
|
-
import { n as sizeFailure } from "./size-
|
|
3
|
+
import { n as changedFiles, t as authoredSizes } from "./files-2FikHZ9F.mjs";
|
|
4
|
+
import { r as lintDiagnostics } from "./staged-ratchet-BNfjcbih.mjs";
|
|
5
|
+
import { n as sizeFailure } from "./size-BVgNbLO6.mjs";
|
|
6
6
|
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
//#region src/guardrails/ratchet.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./ceilings-BSw9p4YB.mjs";
|
|
2
2
|
import { t as readCarriedCeilings } from "./renames-BGO4dWJ8.mjs";
|
|
3
|
-
import { t as authoredSizes } from "./files-
|
|
3
|
+
import { t as authoredSizes } from "./files-2FikHZ9F.mjs";
|
|
4
4
|
//#region src/guardrails/size.ts
|
|
5
5
|
function sizeFailure(file, size, limit) {
|
|
6
6
|
return `${file}: ${size} bytes, ${size - limit} bytes over the ${limit}-byte ceiling. Split by responsibility into sibling modules, one cohesive group of exports each; keep the original path re-exporting only if it is a public entry point. Split a test file by behaviour under test, one file per describe. Do not minify, strip whitespace, or move code under an excluded path to pass.`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as MEASURE_ENV, s as readCeilings } from "./ceilings-BSw9p4YB.mjs";
|
|
2
2
|
import { n as renamedPaths } from "./renames-BGO4dWJ8.mjs";
|
|
3
|
-
import { a as repositoryPath } from "./files-
|
|
3
|
+
import { a as repositoryPath } from "./files-2FikHZ9F.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, join } from "node:path";
|