@antelopejs/tooling-configs 0.5.1 → 0.5.2
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 +16 -6
- package/dist/bin/api-diff.mjs +3 -3
- package/dist/bin/body-check.mjs +2 -2
- package/dist/bin/checks.mjs +121 -5
- package/dist/bin/comment-proof.mjs +2 -2
- package/dist/bin/garden.mjs +1 -1
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +1 -1
- package/dist/bin/sync.mjs +180 -550
- package/dist/oxc/lint.mjs +1 -1
- package/dist/{oxlint-DIV-lLSS.mjs → oxlint-BbpTFFmf.mjs} +7 -2
- package/dist/{package-Dn7VTFUW.mjs → package-DxxcxOzp.mjs} +28 -2
- package/dist/{proof-stamp-DLWpPwQE.mjs → proof-stamp-D9yo2dxU.mjs} +1 -1
- package/dist/{ratchet-ClfblHNJ.mjs → ratchet--WWa_w2O.mjs} +2 -2
- package/dist/script-steps-CgH2DSsp.mjs +594 -0
- package/dist/{templates-lJBZFskp.mjs → templates-BiXgdsRN.mjs} +1 -1
- package/dist/{typescript-BBbry7uU.mjs → typescript-D7SaSmsl.mjs} +1 -1
- package/dist/{ci-workflow-COJUT12b.mjs → workflow-B0FmthGv.mjs} +107 -107
- package/package.json +3 -2
|
@@ -1,112 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { Scalar, isMap, isNode, isPair, isScalar, isSeq, parseDocument, visit } from "yaml";
|
|
4
|
-
//#region src/guardrails/renovate.ts
|
|
5
|
-
/** The Renovate config file sync writes when a repository has none. */
|
|
6
|
-
const RENOVATE_PATH = "renovate.json";
|
|
7
|
-
/** The config files Renovate's `detectConfigFile` reads, in its lookup order (`getConfigFileNames()` in its `lib/config/app-strings.ts`, called without a platform), before the `renovate` key of `package.json`. */
|
|
8
|
-
const RENOVATE_CONFIGS = [
|
|
9
|
-
RENOVATE_PATH,
|
|
10
|
-
"renovate.jsonc",
|
|
11
|
-
"renovate.json5",
|
|
12
|
-
".github/renovate.json",
|
|
13
|
-
".github/renovate.jsonc",
|
|
14
|
-
".github/renovate.json5",
|
|
15
|
-
".gitlab/renovate.json",
|
|
16
|
-
".gitlab/renovate.jsonc",
|
|
17
|
-
".gitlab/renovate.json5",
|
|
18
|
-
".renovaterc",
|
|
19
|
-
".renovaterc.json",
|
|
20
|
-
".renovaterc.jsonc",
|
|
21
|
-
".renovaterc.json5"
|
|
22
|
-
];
|
|
23
|
-
const PRESET = "github>AntelopeJS/.github:renovate.json5";
|
|
24
|
-
/** Matches a config that extends the AntelopeJS shared Renovate preset. */
|
|
25
|
-
const RENOVATE_PRESET = /github>AntelopeJS\/\.github(?::|\/)/;
|
|
26
|
-
const RENOVATE_JSON = `{
|
|
27
|
-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
28
|
-
"extends": ["${PRESET}"]
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
/**
|
|
32
|
-
* Writes `renovate.json` when the repository has no Renovate config, keeps an existing one byte for byte,
|
|
33
|
-
* and fails one that does not extend the AntelopeJS preset, since rewriting it would drop the repository's settings.
|
|
34
|
-
* `managed` is false for a project scaffolded from a template, whose Renovate setup is its own.
|
|
35
|
-
*/
|
|
36
|
-
function renovateArtifacts(root, manifest, managed) {
|
|
37
|
-
if (!managed) return [];
|
|
38
|
-
const file = RENOVATE_CONFIGS.find((path) => existsSync(join(root, path)));
|
|
39
|
-
const path = file ?? "package.json";
|
|
40
|
-
const text = file === void 0 ? manifest.renovate ? JSON.stringify(manifest.renovate) : void 0 : readFileSync(join(root, file), "utf8");
|
|
41
|
-
if (text === void 0) return [{
|
|
42
|
-
kind: "write",
|
|
43
|
-
path: RENOVATE_PATH,
|
|
44
|
-
content: RENOVATE_JSON,
|
|
45
|
-
mode: void 0
|
|
46
|
-
}];
|
|
47
|
-
if (RENOVATE_PRESET.test(text)) return [{
|
|
48
|
-
kind: "unchanged",
|
|
49
|
-
path
|
|
50
|
-
}];
|
|
51
|
-
return [{
|
|
52
|
-
kind: "error",
|
|
53
|
-
path,
|
|
54
|
-
message: `${file ?? "package.json \"renovate\""}: extend "${PRESET}" in its extends, then rerun antelopejs-sync.`
|
|
55
|
-
}];
|
|
56
|
-
}
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/guardrails/workflow.ts
|
|
59
|
-
const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
|
|
60
|
-
const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
|
|
61
|
-
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>.";
|
|
62
|
-
function hasChecksWorkflow(root) {
|
|
63
|
-
const directory = join(root, ".github/workflows");
|
|
64
|
-
if (!existsSync(directory)) return false;
|
|
65
|
-
for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
|
|
66
|
-
const document = parseDocument(readFileSync(join(directory, file), "utf8"));
|
|
67
|
-
if (document.errors.length) continue;
|
|
68
|
-
const jobs = document.get("jobs", true);
|
|
69
|
-
if (!isMap(jobs)) continue;
|
|
70
|
-
for (const { value: job } of jobs.items) {
|
|
71
|
-
if (!isMap(job)) continue;
|
|
72
|
-
const uses = job.get("uses", true);
|
|
73
|
-
if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
|
|
74
|
-
const steps = job.get("steps", true);
|
|
75
|
-
if (!isSeq(steps)) continue;
|
|
76
|
-
for (const step of steps.items) {
|
|
77
|
-
if (!isMap(step)) continue;
|
|
78
|
-
const run = step.get("run", true);
|
|
79
|
-
if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
function callers(text, pattern) {
|
|
86
|
-
const document = parseDocument(text);
|
|
87
|
-
const jobs = document.errors.length ? void 0 : document.get("jobs", true);
|
|
88
|
-
if (!isMap(jobs)) return [];
|
|
89
|
-
const found = [];
|
|
90
|
-
for (const { key, value: job } of jobs.items) {
|
|
91
|
-
if (!isMap(job)) continue;
|
|
92
|
-
const uses = job.get("uses", true);
|
|
93
|
-
if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
|
|
94
|
-
id: String(isScalar(key) ? key.value : key),
|
|
95
|
-
uses: String(uses.value),
|
|
96
|
-
named: job.has("name")
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return found;
|
|
100
|
-
}
|
|
101
|
-
/** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
|
|
102
|
-
function ciNodeCallers(text) {
|
|
103
|
-
return callers(text, CI_NODE_PATTERN);
|
|
104
|
-
}
|
|
105
|
-
/** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
|
|
106
|
-
function ciRenovateSyncCallers(text) {
|
|
107
|
-
return callers(text, CI_RENOVATE_SYNC_PATTERN);
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
4
|
//#region src/guardrails/ci-aggregator.ts
|
|
111
5
|
/** The caller-level gate job older callers carry next to the shared workflow, which already reports `ci / checks`. */
|
|
112
6
|
const LEGACY_AGGREGATOR_ID = "checks";
|
|
@@ -621,4 +515,110 @@ function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests =
|
|
|
621
515
|
});
|
|
622
516
|
}
|
|
623
517
|
//#endregion
|
|
624
|
-
|
|
518
|
+
//#region src/guardrails/renovate.ts
|
|
519
|
+
/** The Renovate config file sync writes when a repository has none. */
|
|
520
|
+
const RENOVATE_PATH = "renovate.json";
|
|
521
|
+
/** The config files Renovate's `detectConfigFile` reads, in its lookup order (`getConfigFileNames()` in its `lib/config/app-strings.ts`, called without a platform), before the `renovate` key of `package.json`. */
|
|
522
|
+
const RENOVATE_CONFIGS = [
|
|
523
|
+
RENOVATE_PATH,
|
|
524
|
+
"renovate.jsonc",
|
|
525
|
+
"renovate.json5",
|
|
526
|
+
".github/renovate.json",
|
|
527
|
+
".github/renovate.jsonc",
|
|
528
|
+
".github/renovate.json5",
|
|
529
|
+
".gitlab/renovate.json",
|
|
530
|
+
".gitlab/renovate.jsonc",
|
|
531
|
+
".gitlab/renovate.json5",
|
|
532
|
+
".renovaterc",
|
|
533
|
+
".renovaterc.json",
|
|
534
|
+
".renovaterc.jsonc",
|
|
535
|
+
".renovaterc.json5"
|
|
536
|
+
];
|
|
537
|
+
const PRESET = "github>AntelopeJS/.github:renovate.json5";
|
|
538
|
+
/** Matches a config that extends the AntelopeJS shared Renovate preset. */
|
|
539
|
+
const RENOVATE_PRESET = /github>AntelopeJS\/\.github(?::|\/)/;
|
|
540
|
+
const RENOVATE_JSON = `{
|
|
541
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
542
|
+
"extends": ["${PRESET}"]
|
|
543
|
+
}
|
|
544
|
+
`;
|
|
545
|
+
/**
|
|
546
|
+
* Writes `renovate.json` when the repository has no Renovate config, keeps an existing one byte for byte,
|
|
547
|
+
* and fails one that does not extend the AntelopeJS preset, since rewriting it would drop the repository's settings.
|
|
548
|
+
* `managed` is false for a project scaffolded from a template, whose Renovate setup is its own.
|
|
549
|
+
*/
|
|
550
|
+
function renovateArtifacts(root, manifest, managed) {
|
|
551
|
+
if (!managed) return [];
|
|
552
|
+
const file = RENOVATE_CONFIGS.find((path) => existsSync(join(root, path)));
|
|
553
|
+
const path = file ?? "package.json";
|
|
554
|
+
const text = file === void 0 ? manifest.renovate ? JSON.stringify(manifest.renovate) : void 0 : readFileSync(join(root, file), "utf8");
|
|
555
|
+
if (text === void 0) return [{
|
|
556
|
+
kind: "write",
|
|
557
|
+
path: RENOVATE_PATH,
|
|
558
|
+
content: RENOVATE_JSON,
|
|
559
|
+
mode: void 0
|
|
560
|
+
}];
|
|
561
|
+
if (RENOVATE_PRESET.test(text)) return [{
|
|
562
|
+
kind: "unchanged",
|
|
563
|
+
path
|
|
564
|
+
}];
|
|
565
|
+
return [{
|
|
566
|
+
kind: "error",
|
|
567
|
+
path,
|
|
568
|
+
message: `${file ?? "package.json \"renovate\""}: extend "${PRESET}" in its extends, then rerun antelopejs-sync.`
|
|
569
|
+
}];
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/guardrails/workflow.ts
|
|
573
|
+
const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
|
|
574
|
+
const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
|
|
575
|
+
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>.";
|
|
576
|
+
function hasChecksWorkflow(root) {
|
|
577
|
+
const directory = join(root, ".github/workflows");
|
|
578
|
+
if (!existsSync(directory)) return false;
|
|
579
|
+
for (const file of readdirSync(directory).filter((name) => /\.ya?ml$/.test(name))) {
|
|
580
|
+
const document = parseDocument(readFileSync(join(directory, file), "utf8"));
|
|
581
|
+
if (document.errors.length) continue;
|
|
582
|
+
const jobs = document.get("jobs", true);
|
|
583
|
+
if (!isMap(jobs)) continue;
|
|
584
|
+
for (const { value: job } of jobs.items) {
|
|
585
|
+
if (!isMap(job)) continue;
|
|
586
|
+
const uses = job.get("uses", true);
|
|
587
|
+
if (isScalar(uses) && CI_NODE_PATTERN.test(String(uses.value))) return true;
|
|
588
|
+
const steps = job.get("steps", true);
|
|
589
|
+
if (!isSeq(steps)) continue;
|
|
590
|
+
for (const step of steps.items) {
|
|
591
|
+
if (!isMap(step)) continue;
|
|
592
|
+
const run = step.get("run", true);
|
|
593
|
+
if (isScalar(run) && /(?:^|\n|&&|;)\s*pnpm\s+(?:run\s+)?checks(?=\s*(?:$|\n|&&|;|#))/.test(String(run.value))) return true;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
function callers(text, pattern) {
|
|
600
|
+
const document = parseDocument(text);
|
|
601
|
+
const jobs = document.errors.length ? void 0 : document.get("jobs", true);
|
|
602
|
+
if (!isMap(jobs)) return [];
|
|
603
|
+
const found = [];
|
|
604
|
+
for (const { key, value: job } of jobs.items) {
|
|
605
|
+
if (!isMap(job)) continue;
|
|
606
|
+
const uses = job.get("uses", true);
|
|
607
|
+
if (isScalar(uses) && pattern.test(String(uses.value))) found.push({
|
|
608
|
+
id: String(isScalar(key) ? key.value : key),
|
|
609
|
+
uses: String(uses.value),
|
|
610
|
+
named: job.has("name")
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
return found;
|
|
614
|
+
}
|
|
615
|
+
/** Jobs of a workflow file that call the shared Node CI; empty when the YAML does not parse. */
|
|
616
|
+
function ciNodeCallers(text) {
|
|
617
|
+
return callers(text, CI_NODE_PATTERN);
|
|
618
|
+
}
|
|
619
|
+
/** Jobs of a workflow file that call the shared Renovate sync at any ref; empty when the YAML does not parse. */
|
|
620
|
+
function ciRenovateSyncCallers(text) {
|
|
621
|
+
return callers(text, CI_RENOVATE_SYNC_PATTERN);
|
|
622
|
+
}
|
|
623
|
+
//#endregion
|
|
624
|
+
export { RENOVATE_CONFIGS as a, CI_CONTEXT as c, CI_RENOVATE_SYNC_REF as d, ciWorkflow as f, hasChecksWorkflow as i, CI_NODE_REF as l, ciNodeCallers as n, RENOVATE_PRESET as o, placeholderTestScript as p, ciRenovateSyncCallers as r, renovateArtifacts as s, MISSING_CHECKS_WORKFLOW as t, CI_PATH as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -75,7 +75,8 @@
|
|
|
75
75
|
"suppressions:update": "node src/bin/suppressions.ts --update",
|
|
76
76
|
"docs:generate": "node src/docs/generate.ts",
|
|
77
77
|
"ci:shard": "node src/ci/shard.ts",
|
|
78
|
-
"ci:weights": "node src/ci/refresh-weights.ts"
|
|
78
|
+
"ci:weights": "node src/ci/refresh-weights.ts",
|
|
79
|
+
"ci:weights:check": "node src/ci/check-weights.ts"
|
|
79
80
|
},
|
|
80
81
|
"dependencies": {
|
|
81
82
|
"@oxlint/plugins": "1.81.0",
|