@antelopejs/tooling-configs 0.7.3 → 0.7.5-next.356.g0d472b3
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 +63 -80
- package/dist/bin/api-diff.mjs +29 -49
- package/dist/bin/capture.mjs +4 -4
- package/dist/bin/check-size.mjs +12 -3
- package/dist/bin/checks.mjs +2 -2
- package/dist/bin/comment-proof.mjs +3 -4
- package/dist/bin/garden.mjs +45 -170
- package/dist/bin/readme-strip.mjs +2 -2
- package/dist/bin/suppressions.mjs +212 -9
- package/dist/bin/sync.mjs +318 -210
- package/dist/bin/tsc.mjs +24 -0
- package/dist/bin/verify.mjs +91 -671
- package/dist/{checks-CSlWvky1.mjs → checks-C60vMFin.mjs} +155 -310
- package/dist/{docs-compat-BAZiPLZt.mjs → docs-compat-CdgBviGf.mjs} +2 -2
- package/dist/eslint.mjs +1 -1
- package/dist/{files-C-JJhExM.mjs → files-BbzJEk-L.mjs} +5 -4
- package/dist/formal/index.mjs +1 -1
- package/dist/{guardrails-nj7NTglr.mjs → guardrails-Dron1AbR.mjs} +67 -673
- package/dist/{installed-typescript-6MtIWlE4.mjs → installed-typescript-CF_FR9DV.mjs} +17 -17
- package/dist/{map-BYkmnvNw.mjs → map-CbNbypUa.mjs} +2 -2
- package/dist/oxc/anti-slop/index.mjs +22 -964
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +1 -1
- package/dist/oxc/lint.d.mts +2 -14
- package/dist/oxc/lint.mjs +3 -20
- package/dist/{package-DDG3YH7W.mjs → package-7oylgBeT.mjs} +6 -19
- package/dist/{workflow-C-oBwL2H.mjs → renovate-D0su_v9p.mjs} +191 -91
- package/dist/{suppression-budget-CPDSFg4X.mjs → suppression-budget-De9nUzlD.mjs} +33 -13
- package/dist/{suppressions-CxPnh4sC.mjs → suppressions-CfJwL0fN.mjs} +6 -2
- package/dist/{templates-HG0fel2S.mjs → templates-DLW0Ubfk.mjs} +26 -29
- package/dist/typescript-C7eU-cig.mjs +581 -0
- package/dist/typescript-version-CptQKjGz.mjs +18 -0
- package/dist/typescript6-BWqCcXGY.mjs +2 -0
- package/dist/typescript6-HdyOMBv3.mjs +8 -0
- package/dist/verify/index.d.mts +5 -24
- package/package.json +27 -7
- package/dist/bin/body-check.mjs +0 -350
- package/dist/bin/ratchet.d.mts +0 -1
- package/dist/bin/ratchet.mjs +0 -375
- package/dist/ceilings-B7KayYIG.mjs +0 -76
- package/dist/oxlint-CIeonWMB.mjs +0 -133
- package/dist/proof-stamp-BFV7JTZT.mjs +0 -342
- package/dist/ratchet-DLCfeaPY.mjs +0 -453
- package/dist/renames-L2owF5GD.mjs +0 -59
- package/dist/size-CCGLY4Ke.mjs +0 -18
- package/dist/suppression-base-CYaLZAq7.mjs +0 -120
- package/dist/typescript-QfxkJYzd.mjs +0 -292
- /package/dist/bin/{body-check.d.mts → tsc.d.mts} +0 -0
package/dist/bin/check-size.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { l as worktreeSuppressions, o as revisionSuppressions } from "../suppressions-
|
|
5
|
-
import { t as checkSize } from "../size-CCGLY4Ke.mjs";
|
|
3
|
+
import { o as repositoryPath, s as repositoryRoot, t as authoredSizes, u as MAX_FILE_BYTES } from "../files-BbzJEk-L.mjs";
|
|
4
|
+
import { l as worktreeSuppressions, o as revisionSuppressions } from "../suppressions-CfJwL0fN.mjs";
|
|
6
5
|
import { realpathSync } from "node:fs";
|
|
7
6
|
import { resolve } from "node:path";
|
|
8
7
|
import { parseArgs } from "node:util";
|
|
@@ -13,6 +12,16 @@ function checkBlanketDisables(root, files, staged = false) {
|
|
|
13
12
|
return (staged ? revisionSuppressions(root, "", authored) : worktreeSuppressions(root, authored)).flatMap((suppression) => suppression.kind === "rule" && suppression.rule === "*" ? [`${suppression.file}:${suppression.line}: \`${suppression.directive}\` without a rule list disables every rule, the comment ban included. Name the rule(s) and give a reason, for example: oxlint-disable-next-line no-debugger -- debugging this operation.`] : []);
|
|
14
13
|
}
|
|
15
14
|
//#endregion
|
|
15
|
+
//#region src/guardrails/size.ts
|
|
16
|
+
function sizeFailure(file, size) {
|
|
17
|
+
return `${file}: ${size} bytes, ${size - MAX_FILE_BYTES} bytes over the ${MAX_FILE_BYTES}-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.`;
|
|
18
|
+
}
|
|
19
|
+
function checkSize(root, files, staged = false) {
|
|
20
|
+
const failures = [];
|
|
21
|
+
for (const [file, size] of authoredSizes(root, files, staged)) if (size > 2e4) failures.push(sizeFailure(file, size));
|
|
22
|
+
return failures;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
16
25
|
//#region src/bin/check-size.ts
|
|
17
26
|
runCli(() => {
|
|
18
27
|
const root = repositoryRoot();
|
package/dist/bin/checks.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-
|
|
3
|
+
import { s as repositoryRoot } from "../files-BbzJEk-L.mjs";
|
|
4
|
+
import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-C60vMFin.mjs";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
//#region src/bin/checks.ts
|
|
7
7
|
const SIGNAL_EXIT = /* @__PURE__ */ new Map([
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as listsNoFiles, n as extendedConfigs, s as packagesAt, t as emitPackage } from "../typescript-QfxkJYzd.mjs";
|
|
3
|
+
import { s as repositoryRoot } from "../files-BbzJEk-L.mjs";
|
|
4
|
+
import { a as listsNoFiles, d as revisionCounts, n as extendedConfigs, s as packagesAt, t as emitPackage, u as compareRevisions } from "../typescript-C7eU-cig.mjs";
|
|
6
5
|
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
7
6
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
7
|
//#region src/guardrails/comment-proof.ts
|
|
@@ -49,7 +48,7 @@ function commentProof(root, baseRef) {
|
|
|
49
48
|
const skips = [...skipped].sort(([a], [b]) => a.localeCompare(b)).map(([directory, file]) => `Comment proof: skipped ${directory}, its tsconfig extends ${file}, which the commit does not hold.\n`).join("");
|
|
50
49
|
return {
|
|
51
50
|
...result,
|
|
52
|
-
output:
|
|
51
|
+
output: result.output + skips + revisionCounts(root, baseRef)
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
//#endregion
|
package/dist/bin/garden.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as admits } from "../semver-BDxeEcP_.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
4
4
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { _ as ciRenovateSyncCallers, c as CI_CONTEXT, d as CI_RENOVATE_SYNC_REF, g as ciNodeCallers, i as GITATTRIBUTES, l as CI_NODE_REF, n as RENOVATE_PRESET, o as LF_ATTRIBUTES, s as enforcesLf, t as RENOVATE_CONFIGS, u as CI_PATH } from "../renovate-D0su_v9p.mjs";
|
|
6
6
|
import { n as tagVersion, r as tooling, t as TOOLING_PACKAGE } from "../npm-CIIqL5SG.mjs";
|
|
7
7
|
import { i as ghToken, n as createApi, t as ApiError } from "../api-BQLrI_S1.mjs";
|
|
8
|
-
import { parseDocument } from "yaml";
|
|
9
8
|
import { parseArgs } from "node:util";
|
|
10
9
|
import { inflateRawSync } from "node:zlib";
|
|
11
10
|
//#region src/garden/decode.ts
|
|
@@ -30,6 +29,7 @@ function workflowRun(value) {
|
|
|
30
29
|
updatedAt: time(source, "updated_at"),
|
|
31
30
|
url: str(source, "html_url"),
|
|
32
31
|
headSha: optStr(source, "head_sha") ?? "",
|
|
32
|
+
event: optStr(source, "event") ?? "",
|
|
33
33
|
referencedWorkflows: (source.referenced_workflows === null ? [] : children(source, "referenced_workflows")).map((workflow) => ({
|
|
34
34
|
path: str(workflow, "path"),
|
|
35
35
|
sha: optStr(workflow, "sha") ?? ""
|
|
@@ -119,6 +119,7 @@ const PACKS = [
|
|
|
119
119
|
"template",
|
|
120
120
|
"none"
|
|
121
121
|
];
|
|
122
|
+
const INTEGRATION_BRANCHES = ["next", "develop"];
|
|
122
123
|
const TIERS = [
|
|
123
124
|
"N1",
|
|
124
125
|
"N2",
|
|
@@ -187,7 +188,6 @@ var GardenContext = class {
|
|
|
187
188
|
pulls = new Memo();
|
|
188
189
|
alertLists = new Memo();
|
|
189
190
|
packuments = new Memo();
|
|
190
|
-
removals = new Memo();
|
|
191
191
|
searches = new Memo();
|
|
192
192
|
branchLists = new Memo();
|
|
193
193
|
closed = new Memo();
|
|
@@ -222,17 +222,29 @@ var GardenContext = class {
|
|
|
222
222
|
async scope() {
|
|
223
223
|
return (await this.repos()).filter(isInScope);
|
|
224
224
|
}
|
|
225
|
+
/** The branch whose CI judges the repository: `next`, else `develop`, the cloud's integration branch, else the default branch. */
|
|
225
226
|
async targetBranch(repo) {
|
|
226
227
|
return this.branches.get(repo.name, async () => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return "next";
|
|
230
|
-
} catch (error) {
|
|
231
|
-
if (error instanceof Error && isMissing(error)) return repo.defaultBranch;
|
|
232
|
-
throw error;
|
|
233
|
-
}
|
|
228
|
+
for (const branch of INTEGRATION_BRANCHES) if (await this.hasBranch(repo, branch)) return branch;
|
|
229
|
+
return repo.defaultBranch;
|
|
234
230
|
});
|
|
235
231
|
}
|
|
232
|
+
async hasBranch(repo, branch) {
|
|
233
|
+
try {
|
|
234
|
+
await this.api.json(`/repos/${ORG}/${repo.name}/branches/${branch}`);
|
|
235
|
+
return true;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (error instanceof Error && isMissing(error)) return false;
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Completed runs of a workflow that judge a branch, newest first: its pushes, and the nightly schedule, which runs on
|
|
243
|
+
* the default branch since a push there no longer runs CI. Undefined when the workflow does not exist.
|
|
244
|
+
*/
|
|
245
|
+
async branchRuns(repo, workflow, branch) {
|
|
246
|
+
return (await this.workflowRuns(repo, workflow, branch, ""))?.filter(({ event }) => event === "push" || event === "schedule");
|
|
247
|
+
}
|
|
236
248
|
tree(repo) {
|
|
237
249
|
return this.trees.get(repo.name, async () => {
|
|
238
250
|
const body = object(await this.api.json(`/repos/${ORG}/${repo.name}/git/trees/${repo.defaultBranch}?recursive=1`), "tree");
|
|
@@ -330,17 +342,6 @@ var GardenContext = class {
|
|
|
330
342
|
throw error;
|
|
331
343
|
}
|
|
332
344
|
}
|
|
333
|
-
/** Whether a commit of the default branch history removed the file; looks at the 30 newest commits that touched it. */
|
|
334
|
-
removedInHistory(repo, path) {
|
|
335
|
-
return this.removals.get(`${repo.name}:${path}`, async () => {
|
|
336
|
-
const commits = list(await this.api.json(`/repos/${ORG}/${repo.name}/commits?path=${path}&sha=${repo.defaultBranch}&per_page=30`), "commits");
|
|
337
|
-
for (const commit of commits) {
|
|
338
|
-
const detail = object(await this.api.json(`/repos/${ORG}/${repo.name}/commits/${str(object(commit, "commit"), "sha")}`), "commit");
|
|
339
|
-
if (children(detail, "files").some((file) => str(file, "filename") === path && optStr(file, "status") === "removed")) return true;
|
|
340
|
-
}
|
|
341
|
-
return false;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
345
|
packument(name) {
|
|
345
346
|
return this.packuments.get(name, () => this.api.npm(name));
|
|
346
347
|
}
|
|
@@ -482,7 +483,7 @@ function firstZipEntry(archive) {
|
|
|
482
483
|
}
|
|
483
484
|
//#endregion
|
|
484
485
|
//#region src/garden/checks/artifacts.ts
|
|
485
|
-
const WORKFLOWS_REPO
|
|
486
|
+
const WORKFLOWS_REPO = ".github";
|
|
486
487
|
async function latestReport(context, repo, name) {
|
|
487
488
|
const [latest] = await context.artifactsNamed(repo, name);
|
|
488
489
|
if (latest === void 0) return void 0;
|
|
@@ -492,8 +493,8 @@ async function latestReport(context, repo, name) {
|
|
|
492
493
|
const linkRot = {
|
|
493
494
|
id: "link-rot",
|
|
494
495
|
async run(context) {
|
|
495
|
-
if (!await context.exists(WORKFLOWS_REPO
|
|
496
|
-
const report = await latestReport(context, WORKFLOWS_REPO
|
|
496
|
+
if (!await context.exists(WORKFLOWS_REPO, ".github/workflows/link-rot.yml")) return skip("AntelopeJS/.github has no link-rot.yml yet");
|
|
497
|
+
const report = await latestReport(context, WORKFLOWS_REPO, "link-rot");
|
|
497
498
|
if (report === void 0) return skip("no link-rot artifact exists yet");
|
|
498
499
|
const repos = object(report.repos ?? {}, "repos");
|
|
499
500
|
const findings = [];
|
|
@@ -546,8 +547,8 @@ async function perRepo(repos, scan) {
|
|
|
546
547
|
//#endregion
|
|
547
548
|
//#region src/garden/checks/ci-health.ts
|
|
548
549
|
const DAY$4 = 864e5;
|
|
549
|
-
const WORKFLOW
|
|
550
|
-
const CALLER = `.github/workflows/${WORKFLOW
|
|
550
|
+
const WORKFLOW = "ci.yml";
|
|
551
|
+
const CALLER = `.github/workflows/${WORKFLOW}`;
|
|
551
552
|
const RECENT_RUNS = 10;
|
|
552
553
|
const MIN_BASELINE = 5;
|
|
553
554
|
const RELATIVE_LIMIT = 1.2;
|
|
@@ -577,14 +578,14 @@ function redSince(runs) {
|
|
|
577
578
|
}
|
|
578
579
|
async function red(context, repo) {
|
|
579
580
|
const branch = await context.targetBranch(repo);
|
|
580
|
-
const runs = await context.
|
|
581
|
+
const runs = await context.branchRuns(repo, WORKFLOW, branch);
|
|
581
582
|
const since = runs === void 0 ? void 0 : redSince(runs);
|
|
582
583
|
if (since === void 0 || context.api.now().getTime() - since.createdAt <= DAY$4) return [];
|
|
583
584
|
return [finding({
|
|
584
585
|
repo: repo.name,
|
|
585
586
|
check: "red-branch",
|
|
586
587
|
subject: branch
|
|
587
|
-
}, `${WORKFLOW
|
|
588
|
+
}, `${WORKFLOW} has been red on ${branch} since ${new Date(since.createdAt).toISOString()}: ${since.url}`, `${WORKFLOW} is green on ${branch}.`)];
|
|
588
589
|
}
|
|
589
590
|
/** A reusable workflow path without its `@ref`, e.g. `AntelopeJS/.github/.github/workflows/ci-node.yml`. */
|
|
590
591
|
function workflowPath(path) {
|
|
@@ -624,7 +625,7 @@ async function callerChange(context, repo, branch, newest) {
|
|
|
624
625
|
}
|
|
625
626
|
async function slow(context, repo) {
|
|
626
627
|
const branch = await context.targetBranch(repo);
|
|
627
|
-
const runs = await context.
|
|
628
|
+
const runs = await context.branchRuns(repo, WORKFLOW, branch);
|
|
628
629
|
if (runs === void 0) return [];
|
|
629
630
|
const passed = runs.filter((run) => run.conclusion === "success");
|
|
630
631
|
const cutoff = Math.max(context.api.now().getTime() - 30 * DAY$4, await callerChange(context, repo, branch, passed[0]));
|
|
@@ -640,7 +641,7 @@ async function slow(context, repo) {
|
|
|
640
641
|
repo: repo.name,
|
|
641
642
|
check: "ci-duration",
|
|
642
643
|
subject: branch
|
|
643
|
-
}, `The median of the last ${RECENT_RUNS} ${WORKFLOW
|
|
644
|
+
}, `The median of the last ${RECENT_RUNS} ${WORKFLOW} runs on ${branch} is ${Math.round(recent)} s against ${Math.round(usual)} s over the earlier runs since ${since}, the latest of 30 days ago, the last change to ${CALLER} or a workflow file of this repository it calls, and the last change to the shared workflows it calls.`, `The median is within 20% and 60 s of the baseline since the last change to what ${WORKFLOW} runs.`)];
|
|
644
645
|
}
|
|
645
646
|
const redBranch = {
|
|
646
647
|
id: "red-branch",
|
|
@@ -662,7 +663,7 @@ const ciDuration = {
|
|
|
662
663
|
};
|
|
663
664
|
//#endregion
|
|
664
665
|
//#region src/garden/checks/branches.ts
|
|
665
|
-
const CHECK$
|
|
666
|
+
const CHECK$1 = "stale-branches";
|
|
666
667
|
const SUBJECT = "branches";
|
|
667
668
|
const DAY$3 = 864e5;
|
|
668
669
|
const INACTIVE_DAYS = 30;
|
|
@@ -715,13 +716,13 @@ function report(repo, prunes) {
|
|
|
715
716
|
if (!prunes.length) return [];
|
|
716
717
|
return [finding({
|
|
717
718
|
repo: repo.name,
|
|
718
|
-
check: CHECK$
|
|
719
|
+
check: CHECK$1,
|
|
719
720
|
subject: SUBJECT
|
|
720
721
|
}, prunes.map(({ branch, reason }) => `${branch} (${reason})`).join(", "), `No branch other than the default, next and protected ones is the head of a merged or closed PR, or has no open PR and no commit for ${INACTIVE_DAYS} days.`)];
|
|
721
722
|
}
|
|
722
723
|
/** Lists, per repository, the branches `--apply-prunes` would delete. */
|
|
723
724
|
const staleBranches = {
|
|
724
|
-
id: CHECK$
|
|
725
|
+
id: CHECK$1,
|
|
725
726
|
async run(context) {
|
|
726
727
|
return perRepo(await context.scope(), async (repo) => report(repo, await prunable(context, repo)));
|
|
727
728
|
}
|
|
@@ -729,7 +730,7 @@ const staleBranches = {
|
|
|
729
730
|
/** The deletions behind each stale-branches finding, re-read from the API given so a branch that gained an open PR or a commit since the scan is kept; a repository whose read failed is never pruned. */
|
|
730
731
|
async function plannedPrunes(api, findings) {
|
|
731
732
|
const fresh = new GardenContext(api);
|
|
732
|
-
const flagged = new Set(findings.filter((entry) => entry.check === CHECK$
|
|
733
|
+
const flagged = new Set(findings.filter((entry) => entry.check === CHECK$1).map((entry) => entry.repo));
|
|
733
734
|
const prunes = [];
|
|
734
735
|
const failed = [];
|
|
735
736
|
const scope = await fresh.scope().catch((error) => {
|
|
@@ -755,7 +756,7 @@ async function applyPrunes(api, prunes) {
|
|
|
755
756
|
}
|
|
756
757
|
//#endregion
|
|
757
758
|
//#region src/garden/checks/conformance.ts
|
|
758
|
-
const CHECK
|
|
759
|
+
const CHECK = "conformance";
|
|
759
760
|
const DAY$2 = 864e5;
|
|
760
761
|
const MEND_EXEMPT = /* @__PURE__ */ new Set(["k8s-gitops-infra"]);
|
|
761
762
|
/** Repositories whose ci.yml runs its own jobs: tooling-configs shards its tests and checks its docs action at HEAD, which ci-node.yml cannot do. */
|
|
@@ -763,7 +764,7 @@ const CI_CALLER_EXEMPT = /* @__PURE__ */ new Set(["tooling-configs"]);
|
|
|
763
764
|
function problem(repo, subject, evidence, doneMeans) {
|
|
764
765
|
return finding({
|
|
765
766
|
repo: repo.name,
|
|
766
|
-
check: CHECK
|
|
767
|
+
check: CHECK,
|
|
767
768
|
subject
|
|
768
769
|
}, evidence, doneMeans);
|
|
769
770
|
}
|
|
@@ -778,7 +779,7 @@ async function ciCaller(context, repo) {
|
|
|
778
779
|
if (unpinned.length === callers.length) findings.push(problem(repo, "ci-caller", `${CI_PATH} calls ${unpinned[0].uses}.`, `The caller uses ${CI_NODE_REF}.`));
|
|
779
780
|
if (!callers.some(({ id, named }) => id === "ci" && !named)) findings.push(problem(repo, "ci-job-id", `The caller job is ${callers[0].id}${callers[0].named ? " with a name" : ""}, so the check is not reported as ${CI_CONTEXT}.`, `antelopejs-sync has renamed the caller job to ci and removed its name.`));
|
|
780
781
|
const syncCallers = ciRenovateSyncCallers(text);
|
|
781
|
-
if (!syncCallers.some(({ uses }) => uses ===
|
|
782
|
+
if (!syncCallers.some(({ uses }) => uses === CI_RENOVATE_SYNC_REF)) findings.push(problem(repo, "ci-renovate-sync", syncCallers.length ? `${CI_PATH} calls ${syncCallers[0].uses}.` : `${CI_PATH} has no job calling ci-renovate-sync.yml.`, `${CI_PATH} has a job calling ${CI_RENOVATE_SYNC_REF}.`));
|
|
782
783
|
return findings;
|
|
783
784
|
}
|
|
784
785
|
async function renovateConfig(context, repo) {
|
|
@@ -806,17 +807,12 @@ async function toolingVersion(context, repo) {
|
|
|
806
807
|
}
|
|
807
808
|
async function checksStatus(context, repo) {
|
|
808
809
|
const branch = await context.targetBranch(repo);
|
|
809
|
-
const [latest] = await context.
|
|
810
|
+
const [latest] = await context.branchRuns(repo, "ci.yml", branch) ?? [];
|
|
810
811
|
const runs = (await context.checkRuns(repo, latest?.headSha || branch)).filter(({ name }) => name === CI_CONTEXT || name === "checks");
|
|
811
812
|
const reported = runs.find(({ name }) => name === CI_CONTEXT);
|
|
812
813
|
if (reported === void 0) return [problem(repo, "checks-context", `${branch} reports ${runs.length ? runs.map(({ name }) => name).join(", ") : "no checks"} instead of ${CI_CONTEXT}.`, `The latest run on ${branch} reports ${CI_CONTEXT}.`)];
|
|
813
814
|
return reported.conclusion === "success" ? [] : [problem(repo, "checks-red", `${CI_CONTEXT} on ${branch} is ${reported.conclusion ?? "pending"}: ${reported.url}`, `${CI_CONTEXT} is green on ${branch}.`)];
|
|
814
815
|
}
|
|
815
|
-
const GUARDRAILS_RATCHET = "guardrails.ratchet.json";
|
|
816
|
-
async function cleanRatchet(context, repo) {
|
|
817
|
-
if (!(await context.tree(repo)).includes(GUARDRAILS_RATCHET) || !await context.removedInHistory(repo, GUARDRAILS_RATCHET)) return [];
|
|
818
|
-
return [problem(repo, "ratchet", `${GUARDRAILS_RATCHET} is back after the history deleted it.`, `${GUARDRAILS_RATCHET} is deleted again.`)];
|
|
819
|
-
}
|
|
820
816
|
const BRANCH_CLEANUP = "delete-branch-on-merge";
|
|
821
817
|
async function branchCleanup(context, repo) {
|
|
822
818
|
return await context.deletesBranchOnMerge(repo) ? [] : [problem(repo, BRANCH_CLEANUP, "delete_branch_on_merge is off, so merged head branches stay behind.", "delete_branch_on_merge is on; antelopejs-garden --apply turns it on.")];
|
|
@@ -831,7 +827,7 @@ const deleteBranchOnMerge = {
|
|
|
831
827
|
/** Turns `delete_branch_on_merge` on for each repository a finding reports it off on, and writes nothing else; returns the writes that failed. */
|
|
832
828
|
async function applySettings(api, findings) {
|
|
833
829
|
const failed = [];
|
|
834
|
-
for (const entry of findings) if (entry.check === CHECK
|
|
830
|
+
for (const entry of findings) if (entry.check === CHECK && entry.subject === BRANCH_CLEANUP) await api.send("PATCH", `/repos/${ORG}/${entry.repo}`, { delete_branch_on_merge: true }).catch((error) => {
|
|
835
831
|
failed.push(`${entry.repo}: ${error instanceof Error ? error.message : String(error)}`);
|
|
836
832
|
});
|
|
837
833
|
return failed;
|
|
@@ -841,8 +837,7 @@ async function scan(context, repo) {
|
|
|
841
837
|
...await ciCaller(context, repo),
|
|
842
838
|
...await renovateConfig(context, repo),
|
|
843
839
|
...await toolingVersion(context, repo),
|
|
844
|
-
...await checksStatus(context, repo)
|
|
845
|
-
...await cleanRatchet(context, repo)
|
|
840
|
+
...await checksStatus(context, repo)
|
|
846
841
|
];
|
|
847
842
|
}
|
|
848
843
|
async function newRepos(context) {
|
|
@@ -853,7 +848,7 @@ async function mendSelection(context) {
|
|
|
853
848
|
return (await context.repos()).filter((repo) => repo.tier !== "N4" && !MEND_EXEMPT.has(repo.name) && !active.has(repo.name)).map((repo) => problem(repo, "renovate-app", "No issue or pull request from the Renovate app: the repository is not in the app's selection.", "Antony adds the repository to the Mend Renovate app's selected repositories."));
|
|
854
849
|
}
|
|
855
850
|
const conformance = {
|
|
856
|
-
id: CHECK
|
|
851
|
+
id: CHECK,
|
|
857
852
|
async run(context) {
|
|
858
853
|
const scanned = await perRepo(await context.scope(), (repo) => scan(context, repo));
|
|
859
854
|
const extra = [...await newRepos(context), ...await mendSelection(context)];
|
|
@@ -1211,99 +1206,6 @@ const packageSize = {
|
|
|
1211
1206
|
}
|
|
1212
1207
|
};
|
|
1213
1208
|
//#endregion
|
|
1214
|
-
//#region src/garden/workflow-windows.ts
|
|
1215
|
-
const CI_NODE$1 = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@(\S+)$/;
|
|
1216
|
-
const CI_EVENTS = /* @__PURE__ */ new Set([
|
|
1217
|
-
"pull_request",
|
|
1218
|
-
"pull_request_target",
|
|
1219
|
-
"push",
|
|
1220
|
-
"merge_group"
|
|
1221
|
-
]);
|
|
1222
|
-
const WINDOWS = /windows/i;
|
|
1223
|
-
const EXPRESSION = /\$\{\{/;
|
|
1224
|
-
const MATRIX_KEY = /\bmatrix\.([\w-]+)/g;
|
|
1225
|
-
const ALWAYS = /^\s*\$\{\{\s*true\s*\}\}\s*$/;
|
|
1226
|
-
const NEVER = /^\s*\$\{\{\s*false\s*\}\}\s*$/;
|
|
1227
|
-
/** The workflow as JSON, its anchors, aliases and merge keys resolved; undefined when the YAML does not parse. */
|
|
1228
|
-
function workflow(text) {
|
|
1229
|
-
const document = parseDocument(text, { merge: true });
|
|
1230
|
-
if (document.errors.length) return void 0;
|
|
1231
|
-
const value = parseJson(JSON.stringify(document.toJS({ maxAliasCount: 1e3 }) ?? null));
|
|
1232
|
-
return isObject(value) ? value : void 0;
|
|
1233
|
-
}
|
|
1234
|
-
/** Every string in `value`, nested lists and object values included. */
|
|
1235
|
-
function texts(value) {
|
|
1236
|
-
if (value === null) return [];
|
|
1237
|
-
if (isString(value)) return [value];
|
|
1238
|
-
if (Array.isArray(value)) return value.flatMap(texts);
|
|
1239
|
-
if (isObject(value)) return Object.values(value).flatMap(texts);
|
|
1240
|
-
return [];
|
|
1241
|
-
}
|
|
1242
|
-
function own(source, key) {
|
|
1243
|
-
return Object.hasOwn(source, key) ? source[key] : null;
|
|
1244
|
-
}
|
|
1245
|
-
function at(value, keys) {
|
|
1246
|
-
return keys.reduce((node, key) => node !== null && isObject(node) ? own(node, key) : null, value);
|
|
1247
|
-
}
|
|
1248
|
-
function triggers(on) {
|
|
1249
|
-
if (on !== null && isObject(on)) return Object.keys(on);
|
|
1250
|
-
return texts(on);
|
|
1251
|
-
}
|
|
1252
|
-
function entries(value) {
|
|
1253
|
-
return Array.isArray(value) ? value.filter(isObject) : [];
|
|
1254
|
-
}
|
|
1255
|
-
/** The values the matrix gives `key`: its own list and `include` entries, less the values a single-key `exclude` entry drops. */
|
|
1256
|
-
function legs(matrix, key) {
|
|
1257
|
-
const dropped = new Set(entries(own(matrix, "exclude")).filter((entry) => Object.keys(entry).length === 1).flatMap((entry) => texts(own(entry, key))));
|
|
1258
|
-
return [...texts(own(matrix, key)), ...entries(own(matrix, "include")).flatMap((entry) => texts(own(entry, key)))].filter((value) => !dropped.has(value));
|
|
1259
|
-
}
|
|
1260
|
-
function runnerIsWindows(job) {
|
|
1261
|
-
const labels = texts(own(job, "runs-on"));
|
|
1262
|
-
if (labels.some((label) => WINDOWS.test(label))) return true;
|
|
1263
|
-
const strategy = own(job, "strategy");
|
|
1264
|
-
const matrix = strategy !== null && isObject(strategy) ? own(strategy, "matrix") : null;
|
|
1265
|
-
if (matrix === null) return false;
|
|
1266
|
-
if (!isObject(matrix)) return texts(matrix).some((value) => WINDOWS.test(value));
|
|
1267
|
-
return labels.filter((label) => EXPRESSION.test(label)).flatMap((label) => [...label.matchAll(MATRIX_KEY)].map((match) => match[1])).some((key) => legs(matrix, key).some((value) => WINDOWS.test(value)));
|
|
1268
|
-
}
|
|
1269
|
-
async function jobRunsOnWindows(job, windowsDefault) {
|
|
1270
|
-
const condition = own(job, "if");
|
|
1271
|
-
if (condition === false || isString(condition) && NEVER.test(condition)) return false;
|
|
1272
|
-
const uses = own(job, "uses");
|
|
1273
|
-
const ref = isString(uses) ? CI_NODE$1.exec(uses)?.[1] : void 0;
|
|
1274
|
-
if (ref === void 0) return runnerIsWindows(job);
|
|
1275
|
-
const windows = at(job, ["with", "windows"]);
|
|
1276
|
-
if (windows === null) return windowsDefault(ref);
|
|
1277
|
-
return windows === true || isString(windows) && ALWAYS.test(windows);
|
|
1278
|
-
}
|
|
1279
|
-
/** Whether a ci-node.yml, given as its text, defaults its `windows` input to true. False when the YAML does not parse. */
|
|
1280
|
-
function windowsByDefault(ciNode) {
|
|
1281
|
-
const parsed = workflow(ciNode);
|
|
1282
|
-
return parsed !== void 0 && at(parsed, [
|
|
1283
|
-
"on",
|
|
1284
|
-
"workflow_call",
|
|
1285
|
-
"inputs",
|
|
1286
|
-
"windows",
|
|
1287
|
-
"default"
|
|
1288
|
-
]) === true;
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Whether a workflow file runs a job on Windows for pull requests or pushes: a ci-node.yml caller with
|
|
1292
|
-
* `windows: true`, or with no `windows` input when `windowsDefault` says the ci-node.yml at the caller's ref
|
|
1293
|
-
* defaults it to true, or a job whose `runs-on`, or the matrix value it reads, names a Windows runner. A
|
|
1294
|
-
* workflow on other events only, a job whose `if` is false, and matrix values `exclude` drops do not count.
|
|
1295
|
-
* False when the YAML does not parse.
|
|
1296
|
-
*/
|
|
1297
|
-
async function runsOnWindows(text, windowsDefault) {
|
|
1298
|
-
const parsed = workflow(text);
|
|
1299
|
-
if (parsed === void 0) return false;
|
|
1300
|
-
if (!triggers(own(parsed, "on")).some((event) => CI_EVENTS.has(event))) return false;
|
|
1301
|
-
const jobs = own(parsed, "jobs");
|
|
1302
|
-
if (jobs === null || !isObject(jobs)) return false;
|
|
1303
|
-
for (const job of Object.values(jobs)) if (job !== null && isObject(job) && await jobRunsOnWindows(job, windowsDefault)) return true;
|
|
1304
|
-
return false;
|
|
1305
|
-
}
|
|
1306
|
-
//#endregion
|
|
1307
1209
|
//#region src/garden/stack.ts
|
|
1308
1210
|
const FRAMEWORK = /* @__PURE__ */ new Set([
|
|
1309
1211
|
"antelopejs",
|
|
@@ -1336,40 +1238,14 @@ const FAMILIES = [
|
|
|
1336
1238
|
"dms-"
|
|
1337
1239
|
];
|
|
1338
1240
|
const RETIRED = /* @__PURE__ */ new Set(["dms-builder"]);
|
|
1339
|
-
/** Whether a repository belongs to the framework and DMS stack, whose
|
|
1241
|
+
/** Whether a repository belongs to the framework and DMS stack, whose clones must keep LF line endings: the framework, its interfaces, modules and templates, and the DMS repositories. */
|
|
1340
1242
|
function isStackRepo(name) {
|
|
1341
1243
|
if (RETIRED.has(name)) return false;
|
|
1342
1244
|
return FRAMEWORK.has(name) || MODULES.has(name) || FAMILIES.some((prefix) => name.startsWith(prefix));
|
|
1343
1245
|
}
|
|
1344
1246
|
//#endregion
|
|
1345
|
-
//#region src/garden/checks/
|
|
1346
|
-
const CHECK = "windows-ci";
|
|
1247
|
+
//#region src/garden/checks/line-endings.ts
|
|
1347
1248
|
const LINE_ENDINGS = "line-endings";
|
|
1348
|
-
const WORKFLOW = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
1349
|
-
const WORKFLOWS_REPO = ".github";
|
|
1350
|
-
const CI_NODE = ".github/workflows/ci-node.yml";
|
|
1351
|
-
/** Reports every framework and DMS stack repository whose workflows run no job on Windows. */
|
|
1352
|
-
const windowsCi = {
|
|
1353
|
-
id: CHECK,
|
|
1354
|
-
async run(context) {
|
|
1355
|
-
const repos = await context.repos();
|
|
1356
|
-
const workflowsRepo = repos.find(({ name }) => name === WORKFLOWS_REPO);
|
|
1357
|
-
const windowsDefault = async (ref) => {
|
|
1358
|
-
if (workflowsRepo === void 0) return false;
|
|
1359
|
-
const ciNode = await context.file(workflowsRepo, CI_NODE, ref);
|
|
1360
|
-
return ciNode !== void 0 && windowsByDefault(ciNode);
|
|
1361
|
-
};
|
|
1362
|
-
return perRepo(repos.filter(({ name }) => isStackRepo(name)), async (repo) => {
|
|
1363
|
-
const workflows = (await context.tree(repo)).filter((path) => WORKFLOW.test(path));
|
|
1364
|
-
for (const path of workflows) if (await runsOnWindows(await context.file(repo, path) ?? "", windowsDefault)) return [];
|
|
1365
|
-
return [finding({
|
|
1366
|
-
repo: repo.name,
|
|
1367
|
-
check: CHECK,
|
|
1368
|
-
subject: "windows"
|
|
1369
|
-
}, workflows.length ? `No job in ${workflows.join(", ")} runs on Windows.` : "The repository has no workflow.", "The ci-node.yml caller passes windows: true or leaves it at a true default, or a workflow job runs on windows-latest.")];
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
1249
|
/** Reports every framework and DMS stack repository whose `.gitattributes` does not check text files out with LF, so a Windows clone keeps its shell scripts runnable. */
|
|
1374
1250
|
const lineEndings = {
|
|
1375
1251
|
id: LINE_ENDINGS,
|
|
@@ -1534,7 +1410,6 @@ const CHECKS = [
|
|
|
1534
1410
|
webBuild,
|
|
1535
1411
|
linkRot,
|
|
1536
1412
|
captureScenes,
|
|
1537
|
-
windowsCi,
|
|
1538
1413
|
lineEndings,
|
|
1539
1414
|
staleBranches
|
|
1540
1415
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as toolingRoot } from "../package-
|
|
2
|
+
import { d as toolingRoot } from "../package-7oylgBeT.mjs";
|
|
3
3
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { s as repositoryRoot } from "../files-BbzJEk-L.mjs";
|
|
5
5
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { parseArgs } from "node:util";
|