mainfast 0.2.0 → 0.3.1
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 +2 -1
- package/dist/mainfast.cjs +474 -136
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -32,4 +32,5 @@ other clients:
|
|
|
32
32
|
VS Code, Codex and tokens: [docs/mcp.md](https://github.com/mainfast/mainfast/blob/main/docs/mcp.md).
|
|
33
33
|
Copy-paste prompts for coding agents: [prompts/](https://github.com/mainfast/mainfast/tree/main/prompts).
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Free and source available under [FSL-1.1-ALv2](https://github.com/mainfast/mainfast/blob/main/LICENSE), with no key
|
|
36
|
+
and no account. Report problems in [GitHub issues](https://github.com/mainfast/mainfast/issues).
|
package/dist/mainfast.cjs
CHANGED
|
@@ -6348,15 +6348,15 @@ var require_parser = __commonJS({
|
|
|
6348
6348
|
var node_process = require("process");
|
|
6349
6349
|
var cst = require_cst();
|
|
6350
6350
|
var lexer = require_lexer();
|
|
6351
|
-
function includesToken(
|
|
6352
|
-
for (let i = 0; i <
|
|
6353
|
-
if (
|
|
6351
|
+
function includesToken(list6, type) {
|
|
6352
|
+
for (let i = 0; i < list6.length; ++i)
|
|
6353
|
+
if (list6[i].type === type)
|
|
6354
6354
|
return true;
|
|
6355
6355
|
return false;
|
|
6356
6356
|
}
|
|
6357
|
-
function findNonEmptyIndex(
|
|
6358
|
-
for (let i = 0; i <
|
|
6359
|
-
switch (
|
|
6357
|
+
function findNonEmptyIndex(list6) {
|
|
6358
|
+
for (let i = 0; i < list6.length; ++i) {
|
|
6359
|
+
switch (list6[i].type) {
|
|
6360
6360
|
case "space":
|
|
6361
6361
|
case "comment":
|
|
6362
6362
|
case "newline":
|
|
@@ -14560,8 +14560,8 @@ var require_dist2 = __commonJS({
|
|
|
14560
14560
|
return ajv;
|
|
14561
14561
|
}
|
|
14562
14562
|
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
|
14563
|
-
const
|
|
14564
|
-
addFormats(ajv,
|
|
14563
|
+
const list6 = opts.formats || formats_1.formatNames;
|
|
14564
|
+
addFormats(ajv, list6, formats, exportName);
|
|
14565
14565
|
if (opts.keywords)
|
|
14566
14566
|
(0, limit_1.default)(ajv);
|
|
14567
14567
|
return ajv;
|
|
@@ -14573,11 +14573,11 @@ var require_dist2 = __commonJS({
|
|
|
14573
14573
|
throw new Error(`Unknown format "${name}"`);
|
|
14574
14574
|
return f;
|
|
14575
14575
|
};
|
|
14576
|
-
function addFormats(ajv,
|
|
14576
|
+
function addFormats(ajv, list6, fs, exportName) {
|
|
14577
14577
|
var _a3;
|
|
14578
14578
|
var _b;
|
|
14579
14579
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
14580
|
-
for (const f of
|
|
14580
|
+
for (const f of list6)
|
|
14581
14581
|
ajv.addFormat(f, fs[f]);
|
|
14582
14582
|
}
|
|
14583
14583
|
module2.exports = exports2 = formatsPlugin;
|
|
@@ -14595,8 +14595,22 @@ var import_node_child_process = require("node:child_process");
|
|
|
14595
14595
|
// package.json
|
|
14596
14596
|
var package_default = {
|
|
14597
14597
|
name: "mainfast",
|
|
14598
|
-
version: "0.
|
|
14598
|
+
version: "0.3.1",
|
|
14599
14599
|
description: "Set up and run Mainfast, GitHub checks that stop merges from silently breaking main. CLI and MCP server.",
|
|
14600
|
+
keywords: [
|
|
14601
|
+
"github-actions",
|
|
14602
|
+
"merge",
|
|
14603
|
+
"merge-commit",
|
|
14604
|
+
"migrations",
|
|
14605
|
+
"codeowners",
|
|
14606
|
+
"required-checks",
|
|
14607
|
+
"branch-protection",
|
|
14608
|
+
"ci",
|
|
14609
|
+
"code-review",
|
|
14610
|
+
"coding-agents",
|
|
14611
|
+
"mcp",
|
|
14612
|
+
"cli"
|
|
14613
|
+
],
|
|
14600
14614
|
license: "FSL-1.1-ALv2",
|
|
14601
14615
|
author: "Mainfast authors",
|
|
14602
14616
|
type: "module",
|
|
@@ -14615,7 +14629,9 @@ var package_default = {
|
|
|
14615
14629
|
typecheck: "tsc --noEmit -p .",
|
|
14616
14630
|
test: "vitest run",
|
|
14617
14631
|
build: "node build.mjs",
|
|
14618
|
-
all: "npm run typecheck && npm test && npm run build"
|
|
14632
|
+
all: "npm run typecheck && npm test && npm run build",
|
|
14633
|
+
prepack: "node scripts/pack-license.mjs full",
|
|
14634
|
+
postpack: "node scripts/pack-license.mjs restore"
|
|
14619
14635
|
},
|
|
14620
14636
|
devDependencies: {
|
|
14621
14637
|
"@mainfast/shared": "0.1.0",
|
|
@@ -14732,7 +14748,7 @@ var brand_default = {
|
|
|
14732
14748
|
migrations: {
|
|
14733
14749
|
productName: "Mainfast Migrations",
|
|
14734
14750
|
tagline: "database migration guard",
|
|
14735
|
-
description: "Fails a PR whose database migrations would fork the migration history once merged
|
|
14751
|
+
description: "Fails a PR whose database migrations would fork the migration history once merged, and re-checks open PRs when main moves.",
|
|
14736
14752
|
npmName: "@mainfast/migrations",
|
|
14737
14753
|
cliName: "mainfast-migrations",
|
|
14738
14754
|
configSection: "migrations",
|
|
@@ -14746,7 +14762,7 @@ var brand_default = {
|
|
|
14746
14762
|
rollcall: {
|
|
14747
14763
|
productName: "Mainfast Rollcall",
|
|
14748
14764
|
tagline: "required-check integrity audit",
|
|
14749
|
-
description: "Finds required status checks that
|
|
14765
|
+
description: "Finds required status checks that protect nothing: never ran, skipped but counted as passing, renamed or path-filtered.",
|
|
14750
14766
|
npmName: "@mainfast/rollcall",
|
|
14751
14767
|
cliName: "mainfast-rollcall",
|
|
14752
14768
|
configSection: "rollcall",
|
|
@@ -14758,7 +14774,7 @@ var brand_default = {
|
|
|
14758
14774
|
owners: {
|
|
14759
14775
|
productName: "Mainfast Owners",
|
|
14760
14776
|
tagline: "CODEOWNERS drift check",
|
|
14761
|
-
description: "Finds CODEOWNERS drift: unowned files a PR touches, owners who left
|
|
14777
|
+
description: "Finds CODEOWNERS drift: unowned files a PR touches, owners who left or lost write access, missing teams and dead patterns.",
|
|
14762
14778
|
npmName: "@mainfast/owners",
|
|
14763
14779
|
cliName: "mainfast-owners",
|
|
14764
14780
|
configSection: "owners",
|
|
@@ -14770,7 +14786,7 @@ var brand_default = {
|
|
|
14770
14786
|
evidence: {
|
|
14771
14787
|
productName: "Mainfast Evidence",
|
|
14772
14788
|
tagline: "proof, not review, for pull requests written by coding agents",
|
|
14773
|
-
description: "
|
|
14789
|
+
description: "For pull requests written by coding agents: checks that tests ran and passed on the head commit and were not weakened.",
|
|
14774
14790
|
npmName: "@mainfast/evidence",
|
|
14775
14791
|
cliName: "mainfast-evidence",
|
|
14776
14792
|
configSection: "evidence",
|
|
@@ -15431,9 +15447,9 @@ function rulesetTargetsBranch(r, branch, defaultBranch) {
|
|
|
15431
15447
|
function resolveRequiredChecks(input) {
|
|
15432
15448
|
const byContext = /* @__PURE__ */ new Map();
|
|
15433
15449
|
const add = (context, src) => {
|
|
15434
|
-
const
|
|
15435
|
-
|
|
15436
|
-
byContext.set(context,
|
|
15450
|
+
const list6 = byContext.get(context) ?? [];
|
|
15451
|
+
list6.push(src);
|
|
15452
|
+
byContext.set(context, list6);
|
|
15437
15453
|
};
|
|
15438
15454
|
const names = new Map((input.rulesets ?? []).map((r) => [r.id, r.name]));
|
|
15439
15455
|
let rulesetStrict;
|
|
@@ -15510,8 +15526,8 @@ async function fetchRequiredSources(gh, owner, repo, branch, opts = {}) {
|
|
|
15510
15526
|
const branchRules = await soft(notes, `GET ${base}/rules/branches/${branch}`, () => gh.paginate(`${base}/rules/branches/${b}?per_page=100`), []);
|
|
15511
15527
|
const rulesets = [];
|
|
15512
15528
|
if (opts.rulesets !== false) {
|
|
15513
|
-
const
|
|
15514
|
-
for (const r of
|
|
15529
|
+
const list6 = await soft(notes, `GET ${base}/rulesets`, () => gh.paginate(`${base}/rulesets?includes_parents=true&per_page=100`), []);
|
|
15530
|
+
for (const r of list6) {
|
|
15515
15531
|
if (r.target && r.target !== "branch") continue;
|
|
15516
15532
|
rulesets.push(await soft(notes, `GET ${base}/rulesets/${r.id}`, () => gh.get(`${base}/rulesets/${r.id}?includes_parents=true`), r));
|
|
15517
15533
|
}
|
|
@@ -16135,17 +16151,17 @@ var AGENT_CATALOG = [
|
|
|
16135
16151
|
bodyMarkers: [/\b(?:app|preview)\.devin\.ai\/sessions\//i, /\blink to devin run\b/i]
|
|
16136
16152
|
},
|
|
16137
16153
|
{
|
|
16138
|
-
// Dawnfix
|
|
16154
|
+
// Dawnfix: its fix job opens draft PRs from `dawnfix/<fingerprint>` branches.
|
|
16139
16155
|
id: "dawnfix",
|
|
16140
16156
|
name: "Dawnfix",
|
|
16141
|
-
logins: ["dawnfix[bot]"
|
|
16142
|
-
branchPrefixes: ["dawnfix/"
|
|
16143
|
-
trailers: [/^co-authored-by:\s*
|
|
16157
|
+
logins: ["dawnfix[bot]"],
|
|
16158
|
+
branchPrefixes: ["dawnfix/"],
|
|
16159
|
+
trailers: [/^co-authored-by:\s*dawnfix\b/im],
|
|
16144
16160
|
emails: [],
|
|
16145
16161
|
bodyMarkers: []
|
|
16146
16162
|
},
|
|
16147
16163
|
{
|
|
16148
|
-
// UNVERIFIED
|
|
16164
|
+
// UNVERIFIED: the aider/ branch prefix and both trailer forms.
|
|
16149
16165
|
id: "aider",
|
|
16150
16166
|
name: "Aider",
|
|
16151
16167
|
logins: [],
|
|
@@ -16493,18 +16509,18 @@ function evaluateTamper(files, policy) {
|
|
|
16493
16509
|
};
|
|
16494
16510
|
const addedTestCases = testStats.reduce((n2, s) => n2 + s.casesAdded, 0);
|
|
16495
16511
|
const findings = [];
|
|
16496
|
-
const
|
|
16512
|
+
const list6 = (xs) => xs.map((x) => `\`${x}\``).join(", ");
|
|
16497
16513
|
if (touched2.workflows.length)
|
|
16498
|
-
findings.push({ id: "touched_workflows", title: "CI workflow files changed", detail: `${
|
|
16514
|
+
findings.push({ id: "touched_workflows", title: "CI workflow files changed", detail: `${list6(touched2.workflows)} \u2014 a PR that edits its own CI can change what "passing" means.` });
|
|
16499
16515
|
if (touched2.codeowners.length)
|
|
16500
|
-
findings.push({ id: "touched_codeowners", title: "CODEOWNERS changed", detail: `${
|
|
16516
|
+
findings.push({ id: "touched_codeowners", title: "CODEOWNERS changed", detail: `${list6(touched2.codeowners)} \u2014 changes who must review.` });
|
|
16501
16517
|
if (touched2.policy.length)
|
|
16502
|
-
findings.push({ id: "touched_policy", title: "Evidence policy file changed", detail: `${
|
|
16503
|
-
if (touched2.lockfiles.length) findings.push({ id: "touched_lockfiles", title: "Lockfiles changed", detail:
|
|
16504
|
-
if (touched2.tests.length) findings.push({ id: "touched_tests", title: "Existing tests changed (lines removed, renamed or deleted)", detail:
|
|
16505
|
-
if (touched2.testConfig.length) findings.push({ id: "touched_test_config", title: "Test or coverage config changed", detail:
|
|
16518
|
+
findings.push({ id: "touched_policy", title: "Evidence policy file changed", detail: `${list6(touched2.policy)} \u2014 this run used the base branch policy, not the PR's.` });
|
|
16519
|
+
if (touched2.lockfiles.length) findings.push({ id: "touched_lockfiles", title: "Lockfiles changed", detail: list6(touched2.lockfiles) });
|
|
16520
|
+
if (touched2.tests.length) findings.push({ id: "touched_tests", title: "Existing tests changed (lines removed, renamed or deleted)", detail: list6(touched2.tests) });
|
|
16521
|
+
if (touched2.testConfig.length) findings.push({ id: "touched_test_config", title: "Test or coverage config changed", detail: list6(touched2.testConfig) });
|
|
16506
16522
|
const deleted = tests.filter((f) => f.status === "removed").map((f) => f.path);
|
|
16507
|
-
if (deleted.length) findings.push({ id: "tests_deleted", title: "Test files deleted", detail:
|
|
16523
|
+
if (deleted.length) findings.push({ id: "tests_deleted", title: "Test files deleted", detail: list6(deleted) });
|
|
16508
16524
|
const perFile = (pick2) => testStats.filter((s) => pick2(s) < 0).map((s) => `\`${s.path}\` (${pick2(s)})`).join(", ");
|
|
16509
16525
|
if (net.cases < 0)
|
|
16510
16526
|
findings.push({
|
|
@@ -16532,7 +16548,7 @@ function evaluateTamper(files, policy) {
|
|
|
16532
16548
|
findings.push({
|
|
16533
16549
|
id: "diff_unanalyzed",
|
|
16534
16550
|
title: "Some files could not be analyzed",
|
|
16535
|
-
detail: `GitHub returned no patch for ${
|
|
16551
|
+
detail: `GitHub returned no patch for ${list6(unanalyzed)} (diff too large). Run with a full checkout (\`fetch-depth: 0\`) to analyze them locally.`
|
|
16536
16552
|
});
|
|
16537
16553
|
return { touched: touched2, testStats, net, addedTestCases, unanalyzed, findings };
|
|
16538
16554
|
}
|
|
@@ -18920,7 +18936,7 @@ var STATUS_CONTEXT = P3.statusContext;
|
|
|
18920
18936
|
var USER_AGENT2 = `${P3.cliName}/${VERSION5}`;
|
|
18921
18937
|
|
|
18922
18938
|
// ../migrations/src/types.ts
|
|
18923
|
-
var FRAMEWORKS = ["alembic", "django", "prisma", "rails", "flyway", "drizzle"];
|
|
18939
|
+
var FRAMEWORKS = ["alembic", "django", "prisma", "rails", "flyway", "drizzle", "typeorm"];
|
|
18924
18940
|
|
|
18925
18941
|
// ../migrations/src/config.ts
|
|
18926
18942
|
var POLICIES = ["error", "warning", "off"];
|
|
@@ -18930,7 +18946,8 @@ var DEFAULT_OUT_OF_ORDER = {
|
|
|
18930
18946
|
prisma: "error",
|
|
18931
18947
|
rails: "warning",
|
|
18932
18948
|
flyway: "warning",
|
|
18933
|
-
drizzle: "error"
|
|
18949
|
+
drizzle: "error",
|
|
18950
|
+
typeorm: "warning"
|
|
18934
18951
|
};
|
|
18935
18952
|
var KNOWN_KEYS = ["enabled", "frameworks", "paths", "ignore", "outOfOrder", "label"];
|
|
18936
18953
|
var DEFAULT_CONFIG = {
|
|
@@ -18954,10 +18971,10 @@ function parseConfig2(text) {
|
|
|
18954
18971
|
const raw = loadSection(text, CONFIG_SECTION2, { known: KNOWN_KEYS });
|
|
18955
18972
|
const cfg = { ...DEFAULT_CONFIG, paths: {}, outOfOrder: { ...DEFAULT_OUT_OF_ORDER } };
|
|
18956
18973
|
if (raw.frameworks !== void 0 && raw.frameworks !== "auto") {
|
|
18957
|
-
const
|
|
18958
|
-
const bad =
|
|
18974
|
+
const list6 = strList2(raw.frameworks, `${CONFIG_SECTION2}.frameworks`);
|
|
18975
|
+
const bad = list6.filter((f) => !isFramework(f));
|
|
18959
18976
|
if (bad.length) throw new Error(`${CONFIG_SECTION2}.frameworks: unknown ${bad.join(", ")} (known: ${FRAMEWORKS.join(", ")})`);
|
|
18960
|
-
cfg.frameworks =
|
|
18977
|
+
cfg.frameworks = list6;
|
|
18961
18978
|
}
|
|
18962
18979
|
if (raw.paths !== void 0) {
|
|
18963
18980
|
if (typeof raw.paths !== "object" || raw.paths === null || Array.isArray(raw.paths))
|
|
@@ -19007,19 +19024,19 @@ function groupBy(xs, key2) {
|
|
|
19007
19024
|
const m = /* @__PURE__ */ new Map();
|
|
19008
19025
|
for (const x of xs) {
|
|
19009
19026
|
const k = key2(x);
|
|
19010
|
-
const
|
|
19011
|
-
if (
|
|
19027
|
+
const list6 = m.get(k);
|
|
19028
|
+
if (list6) list6.push(x);
|
|
19012
19029
|
else m.set(k, [x]);
|
|
19013
19030
|
}
|
|
19014
19031
|
return m;
|
|
19015
19032
|
}
|
|
19016
|
-
function outOfOrder(framework, ctx,
|
|
19033
|
+
function outOfOrder(framework, ctx, list6, cmp, explain, hint) {
|
|
19017
19034
|
const severity = ctx.outOfOrder;
|
|
19018
19035
|
if (severity === "off") return [];
|
|
19019
|
-
const baseSet = new Set(
|
|
19020
|
-
const mainList =
|
|
19036
|
+
const baseSet = new Set(list6(ctx.base, ctx.root).map((v) => v.path));
|
|
19037
|
+
const mainList = list6(ctx.main, ctx.root);
|
|
19021
19038
|
const mainPaths = new Set(mainList.map((v) => v.path));
|
|
19022
|
-
const branchAdded =
|
|
19039
|
+
const branchAdded = list6(ctx.head, ctx.root).filter((v) => !baseSet.has(v.path) && !mainPaths.has(v.path));
|
|
19023
19040
|
if (!branchAdded.length || !mainList.length) return [];
|
|
19024
19041
|
const latest = mainList.reduce((a, b) => cmp(a.version, b.version) >= 0 ? a : b);
|
|
19025
19042
|
const stale = branchAdded.filter((v) => cmp(v.version, latest.version) <= 0);
|
|
@@ -19086,15 +19103,15 @@ var alembic = {
|
|
|
19086
19103
|
const revs = revisions(tree, root);
|
|
19087
19104
|
const findings = [];
|
|
19088
19105
|
const byId = groupBy(revs, (r) => r.revision);
|
|
19089
|
-
for (const [id,
|
|
19090
|
-
if (
|
|
19106
|
+
for (const [id, list6] of byId) {
|
|
19107
|
+
if (list6.length > 1)
|
|
19091
19108
|
findings.push({
|
|
19092
19109
|
framework: "alembic",
|
|
19093
19110
|
root,
|
|
19094
19111
|
code: "duplicate-revision",
|
|
19095
19112
|
severity: "error",
|
|
19096
|
-
message: `revision id ${id} is declared by ${
|
|
19097
|
-
files:
|
|
19113
|
+
message: `revision id ${id} is declared by ${list6.length} scripts`,
|
|
19114
|
+
files: list6.map((r) => r.path),
|
|
19098
19115
|
hint: "Give one of the scripts a fresh revision id.",
|
|
19099
19116
|
key: `alembic:${root}:dup:${id}`
|
|
19100
19117
|
});
|
|
@@ -19196,17 +19213,17 @@ var django = {
|
|
|
19196
19213
|
const app = migs[0]?.app ?? basename(dirname(root));
|
|
19197
19214
|
const findings = [];
|
|
19198
19215
|
const names = new Set(migs.flatMap((m) => [m.name, ...m.replaces.filter(([a]) => a === app).map(([, n2]) => n2)]));
|
|
19199
|
-
for (const [num2,
|
|
19200
|
-
if (
|
|
19216
|
+
for (const [num2, list6] of groupBy(migs, (m) => m.number)) {
|
|
19217
|
+
if (list6.length > 1 && /^\d{4}$/.test(num2))
|
|
19201
19218
|
findings.push({
|
|
19202
19219
|
framework: "django",
|
|
19203
19220
|
root,
|
|
19204
19221
|
code: "duplicate-number",
|
|
19205
19222
|
severity: "warning",
|
|
19206
|
-
message: `app "${app}" has ${
|
|
19207
|
-
files:
|
|
19223
|
+
message: `app "${app}" has ${list6.length} migrations numbered ${num2}: ${list6.map((m) => m.name).join(", ")}`,
|
|
19224
|
+
files: list6.map((m) => m.path),
|
|
19208
19225
|
hint: "Renumber the branch migration after main's latest and point its dependency at it.",
|
|
19209
|
-
key: `django:${root}:dupnum:${
|
|
19226
|
+
key: `django:${root}:dupnum:${list6.map((m) => m.name).sort().join(",")}`
|
|
19210
19227
|
});
|
|
19211
19228
|
}
|
|
19212
19229
|
for (const m of migs) {
|
|
@@ -19299,17 +19316,17 @@ var drizzle = {
|
|
|
19299
19316
|
return findings;
|
|
19300
19317
|
}
|
|
19301
19318
|
const entries = journal.entries;
|
|
19302
|
-
for (const [idx,
|
|
19303
|
-
if (
|
|
19319
|
+
for (const [idx, list6] of groupBy(entries, (e) => String(e.idx))) {
|
|
19320
|
+
if (list6.length > 1)
|
|
19304
19321
|
findings.push({
|
|
19305
19322
|
framework: "drizzle",
|
|
19306
19323
|
root,
|
|
19307
19324
|
code: "duplicate-idx",
|
|
19308
19325
|
severity: "error",
|
|
19309
|
-
message: `journal idx ${idx} is used by ${
|
|
19326
|
+
message: `journal idx ${idx} is used by ${list6.length} entries: ${list6.map((e) => e.tag).join(", ")}`,
|
|
19310
19327
|
files: [jp],
|
|
19311
19328
|
hint: "Union the entries by tag, re-index idx 0..n-1 in `when` order, and regenerate the branch snapshot so its prevId is main's latest id.",
|
|
19312
|
-
key: `drizzle:${root}:dupidx:${
|
|
19329
|
+
key: `drizzle:${root}:dupidx:${list6.map((e) => e.tag).sort().join(",")}`
|
|
19313
19330
|
});
|
|
19314
19331
|
}
|
|
19315
19332
|
const idxs = entries.map((e) => e.idx);
|
|
@@ -19374,17 +19391,17 @@ var drizzle = {
|
|
|
19374
19391
|
}
|
|
19375
19392
|
});
|
|
19376
19393
|
const ids = new Set(snaps.map((s) => s.id).filter(Boolean));
|
|
19377
|
-
for (const [prev,
|
|
19378
|
-
if (
|
|
19394
|
+
for (const [prev, list6] of groupBy(snaps.filter((s) => s.prevId), (s) => s.prevId)) {
|
|
19395
|
+
if (list6.length > 1)
|
|
19379
19396
|
findings.push({
|
|
19380
19397
|
framework: "drizzle",
|
|
19381
19398
|
root,
|
|
19382
19399
|
code: "snapshot-fork",
|
|
19383
19400
|
severity: "error",
|
|
19384
|
-
message: `${
|
|
19385
|
-
files:
|
|
19401
|
+
message: `${list6.length} snapshots claim prevId ${prev}: ${list6.map((s) => basename(s.path)).join(", ")}`,
|
|
19402
|
+
files: list6.map((s) => s.path),
|
|
19386
19403
|
hint: "Point the branch snapshot's prevId at main's latest snapshot id (or regenerate it with drizzle-kit generate after merging main).",
|
|
19387
|
-
key: `drizzle:${root}:fork:${prev}:${
|
|
19404
|
+
key: `drizzle:${root}:fork:${prev}:${list6.length}`
|
|
19388
19405
|
});
|
|
19389
19406
|
}
|
|
19390
19407
|
for (const s of snaps)
|
|
@@ -19577,8 +19594,168 @@ var rails = {
|
|
|
19577
19594
|
}
|
|
19578
19595
|
};
|
|
19579
19596
|
|
|
19597
|
+
// ../migrations/src/frameworks/typeorm.ts
|
|
19598
|
+
var FILE3 = /(^|\/)\d{13}-[^/]+\.[cm]?[jt]s$/;
|
|
19599
|
+
var isMigrationFile = (f) => FILE3.test(f) && !/\.d\.[cm]?ts$/.test(f);
|
|
19600
|
+
var isTypeorm = (text) => text !== void 0 && /\bMigrationInterface\b/.test(text);
|
|
19601
|
+
function mask(text) {
|
|
19602
|
+
const strings = [];
|
|
19603
|
+
const n2 = text.length;
|
|
19604
|
+
const regexBefore = /(?:^|[(,=:[!&|?{};+\-*%<>~^]|(?:^|[^\w$])(?:return|typeof|case|do|else|in|of|new|delete|void|throw|yield|await))$/;
|
|
19605
|
+
const put = (v) => {
|
|
19606
|
+
strings.push(v);
|
|
19607
|
+
return `\0${strings.length - 1}\0`;
|
|
19608
|
+
};
|
|
19609
|
+
const scan2 = (i, untilBrace) => {
|
|
19610
|
+
let code = "";
|
|
19611
|
+
let depth = 0;
|
|
19612
|
+
while (i < n2) {
|
|
19613
|
+
const c = text[i];
|
|
19614
|
+
const d = text[i + 1];
|
|
19615
|
+
if (c === "/" && d === "/") {
|
|
19616
|
+
while (i < n2 && text[i] !== "\n") i++;
|
|
19617
|
+
code += " ";
|
|
19618
|
+
} else if (c === "/" && d === "*") {
|
|
19619
|
+
const end = text.indexOf("*/", i + 2);
|
|
19620
|
+
i = end < 0 ? n2 : end + 2;
|
|
19621
|
+
code += " ";
|
|
19622
|
+
} else if (c === "'" || c === '"') {
|
|
19623
|
+
let v = "";
|
|
19624
|
+
for (i++; i < n2 && text[i] !== c && text[i] !== "\n"; i++) {
|
|
19625
|
+
if (text[i] === "\\") i++;
|
|
19626
|
+
v += text[i] ?? "";
|
|
19627
|
+
}
|
|
19628
|
+
i++;
|
|
19629
|
+
code += put(v);
|
|
19630
|
+
} else if (c === "`") {
|
|
19631
|
+
let v = "";
|
|
19632
|
+
let plain = true;
|
|
19633
|
+
for (i++; i < n2 && text[i] !== "`"; ) {
|
|
19634
|
+
if (text[i] === "\\") {
|
|
19635
|
+
v += text[i + 1] ?? "";
|
|
19636
|
+
i += 2;
|
|
19637
|
+
} else if (text[i] === "$" && text[i + 1] === "{") {
|
|
19638
|
+
plain = false;
|
|
19639
|
+
i = scan2(i + 2, true)[1];
|
|
19640
|
+
} else v += text[i++];
|
|
19641
|
+
}
|
|
19642
|
+
i++;
|
|
19643
|
+
code += put(plain ? v : null);
|
|
19644
|
+
} else if (c === "/" && regexBefore.test(code.trimEnd())) {
|
|
19645
|
+
let inClass = false;
|
|
19646
|
+
for (i++; i < n2 && text[i] !== "\n"; i++) {
|
|
19647
|
+
if (text[i] === "\\") i++;
|
|
19648
|
+
else if (text[i] === "[") inClass = true;
|
|
19649
|
+
else if (text[i] === "]") inClass = false;
|
|
19650
|
+
else if (text[i] === "/" && !inClass) break;
|
|
19651
|
+
}
|
|
19652
|
+
i++;
|
|
19653
|
+
while (i < n2 && /[a-z]/i.test(text[i])) i++;
|
|
19654
|
+
code += put(null);
|
|
19655
|
+
} else {
|
|
19656
|
+
if (untilBrace && c === "{") depth++;
|
|
19657
|
+
if (untilBrace && c === "}" && depth-- === 0) return [code, i + 1];
|
|
19658
|
+
code += c;
|
|
19659
|
+
i++;
|
|
19660
|
+
}
|
|
19661
|
+
}
|
|
19662
|
+
return [code, i];
|
|
19663
|
+
};
|
|
19664
|
+
return { code: scan2(0, false)[0], strings };
|
|
19665
|
+
}
|
|
19666
|
+
function migrationName(text, file) {
|
|
19667
|
+
const { code, strings } = mask(text);
|
|
19668
|
+
const classes = [...code.matchAll(/\bclass\s+([A-Za-z_$][\w$]*)([^{]*)\{/g)];
|
|
19669
|
+
const cls = classes.find((m) => /\bimplements\b[^{]*\bMigrationInterface\b/.test(m[2])) ?? classes.find((m) => /\bexport\s+(?:default\s+)?$/.test(code.slice(0, m.index))) ?? classes[0];
|
|
19670
|
+
if (!cls) return basename(file).replace(/\.[^.]+$/, "");
|
|
19671
|
+
let top = "";
|
|
19672
|
+
let depth = 1;
|
|
19673
|
+
for (let j = cls.index + cls[0].length; j < code.length && depth > 0; j++) {
|
|
19674
|
+
const ch = code[j];
|
|
19675
|
+
if (ch === "{" || ch === "(" || ch === "[") depth++;
|
|
19676
|
+
else if (ch === "}" || ch === ")" || ch === "]") depth--;
|
|
19677
|
+
top += depth === 1 && ch !== "}" && ch !== ")" && ch !== "]" ? ch : " ";
|
|
19678
|
+
}
|
|
19679
|
+
const field = top.match(
|
|
19680
|
+
/(?:^|[;\s])(?:(?:public|readonly|override|declare|static)\s+)*name\s*[?!]?\s*(?::\s*string\s*)?=\s*\u0000(\d+)\u0000/
|
|
19681
|
+
);
|
|
19682
|
+
const prop = field ? strings[Number(field[1])] : void 0;
|
|
19683
|
+
return prop || cls[1];
|
|
19684
|
+
}
|
|
19685
|
+
function list4(tree, root) {
|
|
19686
|
+
const out = [];
|
|
19687
|
+
for (const f of tree.under(root)) {
|
|
19688
|
+
if (dirname(f) !== root || !isMigrationFile(f)) continue;
|
|
19689
|
+
const text = tree.read(f);
|
|
19690
|
+
if (!isTypeorm(text)) continue;
|
|
19691
|
+
const name = migrationName(text, f);
|
|
19692
|
+
out.push({ name, version: name.match(/(\d{13})$/)?.[1] ?? basename(f).slice(0, 13), path: f });
|
|
19693
|
+
}
|
|
19694
|
+
return out;
|
|
19695
|
+
}
|
|
19696
|
+
var typeorm = {
|
|
19697
|
+
id: "typeorm",
|
|
19698
|
+
detect(files, read) {
|
|
19699
|
+
return uniq(files.filter((f) => isMigrationFile(f) && isTypeorm(read(f))).map(dirname));
|
|
19700
|
+
},
|
|
19701
|
+
inspect(tree, root) {
|
|
19702
|
+
const findings = [];
|
|
19703
|
+
const migs = list4(tree, root);
|
|
19704
|
+
for (const [n2, l] of groupBy(migs, (m) => m.name)) {
|
|
19705
|
+
if (l.length > 1)
|
|
19706
|
+
findings.push({
|
|
19707
|
+
framework: "typeorm",
|
|
19708
|
+
root,
|
|
19709
|
+
code: "duplicate-name",
|
|
19710
|
+
severity: "error",
|
|
19711
|
+
message: `${l.length} migrations are named ${n2} (${l.map((m) => basename(m.path)).join(", ")}); TypeORM throws "Duplicate migrations"`,
|
|
19712
|
+
files: l.map((m) => m.path),
|
|
19713
|
+
hint: "Regenerate the branch migration on top of main (typeorm migration:generate gives it a fresh timestamp and class name).",
|
|
19714
|
+
key: `typeorm:${root}:dupname:${n2}`
|
|
19715
|
+
});
|
|
19716
|
+
}
|
|
19717
|
+
for (const [v, l] of groupBy(migs, (m) => m.version)) {
|
|
19718
|
+
if (l.length > 1 && new Set(l.map((m) => m.name)).size === l.length)
|
|
19719
|
+
findings.push({
|
|
19720
|
+
framework: "typeorm",
|
|
19721
|
+
root,
|
|
19722
|
+
code: "duplicate-timestamp",
|
|
19723
|
+
severity: "warning",
|
|
19724
|
+
message: `${l.length} migrations share timestamp ${v} (${l.map((m) => basename(m.path)).join(", ")}); the order TypeORM runs them in is not defined`,
|
|
19725
|
+
files: l.map((m) => m.path),
|
|
19726
|
+
hint: "Give the branch migration a newer timestamp, in its file name and its class name.",
|
|
19727
|
+
key: `typeorm:${root}:dupts:${v}`
|
|
19728
|
+
});
|
|
19729
|
+
}
|
|
19730
|
+
for (const m of migs) {
|
|
19731
|
+
if (!/\d{13}$/.test(m.name))
|
|
19732
|
+
findings.push({
|
|
19733
|
+
framework: "typeorm",
|
|
19734
|
+
root,
|
|
19735
|
+
code: "name-without-timestamp",
|
|
19736
|
+
severity: "error",
|
|
19737
|
+
message: `${basename(m.path)}: the migration name ${m.name} does not end in a 13-digit timestamp; TypeORM refuses to load it`,
|
|
19738
|
+
files: [m.path],
|
|
19739
|
+
hint: "End the class name (and the `name` property, if set) with the timestamp from the file name.",
|
|
19740
|
+
key: `typeorm:${root}:nots:${m.path}`
|
|
19741
|
+
});
|
|
19742
|
+
}
|
|
19743
|
+
return findings;
|
|
19744
|
+
},
|
|
19745
|
+
compare(ctx) {
|
|
19746
|
+
return outOfOrder(
|
|
19747
|
+
"typeorm",
|
|
19748
|
+
ctx,
|
|
19749
|
+
list4,
|
|
19750
|
+
compareDigits,
|
|
19751
|
+
"TypeORM still runs it on databases that already ran the newer one, so environments apply migrations in different orders.",
|
|
19752
|
+
"Regenerate the branch migration on top of main so its timestamp is newer."
|
|
19753
|
+
);
|
|
19754
|
+
}
|
|
19755
|
+
};
|
|
19756
|
+
|
|
19580
19757
|
// ../migrations/src/frameworks/index.ts
|
|
19581
|
-
var frameworks = { alembic, django, prisma, rails, flyway, drizzle };
|
|
19758
|
+
var frameworks = { alembic, django, prisma, rails, flyway, drizzle, typeorm };
|
|
19582
19759
|
|
|
19583
19760
|
// ../migrations/src/git.ts
|
|
19584
19761
|
var import_node_child_process4 = require("node:child_process");
|
|
@@ -19710,6 +19887,21 @@ function discoverRoots(main7, head, config2) {
|
|
|
19710
19887
|
}
|
|
19711
19888
|
return out;
|
|
19712
19889
|
}
|
|
19890
|
+
var UNSUPPORTED = [
|
|
19891
|
+
{ tool: "knex", test: /(^|\/)knexfile\.[cm]?[jt]s$/ },
|
|
19892
|
+
{ tool: "sequelize", test: /(^|\/)\.sequelizerc$/ },
|
|
19893
|
+
{ tool: "liquibase", test: /(^|\/)(db\.)?changelog(-master)?\.(xml|ya?ml|json|sql)$/ },
|
|
19894
|
+
{ tool: "ecto", test: /(^|\/)priv\/repo\/migrations\/\d+_[^/]+\.exs$/ },
|
|
19895
|
+
{ tool: "golang-migrate or dbmate", test: /(^|\/)\d+_[^/]+\.up\.sql$/ }
|
|
19896
|
+
];
|
|
19897
|
+
function unsupportedTools(files) {
|
|
19898
|
+
const out = [];
|
|
19899
|
+
for (const { tool, test } of UNSUPPORTED) {
|
|
19900
|
+
const hit = files.find((f) => test.test(f) && !f.includes("node_modules/"));
|
|
19901
|
+
if (hit) out.push(`${tool} (${hit})`);
|
|
19902
|
+
}
|
|
19903
|
+
return out;
|
|
19904
|
+
}
|
|
19713
19905
|
function analyze(opts) {
|
|
19714
19906
|
const mainSha = revParse2(opts.repo, opts.mainRef);
|
|
19715
19907
|
const headSha = revParse2(opts.repo, opts.headRef);
|
|
@@ -19748,6 +19940,8 @@ function analyzeTrees(opts) {
|
|
|
19748
19940
|
head: { ref: opts.headRef, sha: headSha },
|
|
19749
19941
|
mergeBase: baseSha,
|
|
19750
19942
|
roots,
|
|
19943
|
+
checked: roots.length > 0,
|
|
19944
|
+
unsupported: roots.length ? [] : unsupportedTools(head.files()),
|
|
19751
19945
|
findings: unique,
|
|
19752
19946
|
preExisting
|
|
19753
19947
|
};
|
|
@@ -19764,7 +19958,9 @@ function toMarkdown(r, opts = {}) {
|
|
|
19764
19958
|
lines.push(`### ${opts.title ?? PRODUCT}`);
|
|
19765
19959
|
lines.push("");
|
|
19766
19960
|
if (!r.roots.length) {
|
|
19767
|
-
lines.push(
|
|
19961
|
+
lines.push(`**Nothing was checked:** no migrations found for a supported framework (${FRAMEWORKS.join(", ")}).`);
|
|
19962
|
+
if (r.unsupported?.length) lines.push("", `Found ${r.unsupported.map((u) => mdInline(u, 200)).join(", ")}, which ${PRODUCT} does not read yet.`);
|
|
19963
|
+
lines.push("", `If your migrations live elsewhere, set \`migrations.paths\` in \`.mainfast.yml\`. [docs](${DOCS_URL2})`);
|
|
19768
19964
|
return lines.join("\n");
|
|
19769
19965
|
}
|
|
19770
19966
|
lines.push(
|
|
@@ -19797,12 +19993,17 @@ function toText(r) {
|
|
|
19797
19993
|
const out = [];
|
|
19798
19994
|
out.push(`${PRODUCT}: ${r.head.ref} (${short(r.head.sha)}) -> ${r.main.ref} (${short(r.main.sha)}), merge-base ${short(r.mergeBase)}`);
|
|
19799
19995
|
for (const x of r.roots) out.push(` checked ${x.framework} ${x.root}${x.touched ? " (changed)" : ""}`);
|
|
19996
|
+
if (!r.roots.length) {
|
|
19997
|
+
out.push(` nothing checked: no migrations found for a supported framework (${FRAMEWORKS.join(", ")})`);
|
|
19998
|
+
for (const u of r.unsupported ?? []) out.push(` found ${u}, which ${PRODUCT} does not read yet`);
|
|
19999
|
+
out.push(" if your migrations live elsewhere, set migrations.paths in .mainfast.yml");
|
|
20000
|
+
}
|
|
19800
20001
|
for (const f of r.findings) {
|
|
19801
20002
|
out.push(`${f.severity.toUpperCase()} ${f.framework} ${f.root} [${f.code}] ${f.message}`);
|
|
19802
20003
|
if (f.hint) out.push(` fix: ${f.hint}`);
|
|
19803
20004
|
}
|
|
19804
20005
|
for (const f of r.preExisting) out.push(`note (already on main) ${f.framework} ${f.root} [${f.code}] ${f.message}`);
|
|
19805
|
-
out.push(r.ok ? "ok" : "FAILED");
|
|
20006
|
+
out.push(r.ok ? r.roots.length ? "ok" : "ok (nothing checked)" : "FAILED");
|
|
19806
20007
|
return out.join("\n");
|
|
19807
20008
|
}
|
|
19808
20009
|
|
|
@@ -19849,7 +20050,7 @@ Resolved: migrations are consistent with ${mdCode(report.main.ref)} at ${report.
|
|
|
19849
20050
|
await o.gh.request("POST", `${base}/statuses/${report.head.sha}`, {
|
|
19850
20051
|
state,
|
|
19851
20052
|
context: STATUS_CONTEXT,
|
|
19852
|
-
description: (stale ? `${plural9(errors2, "migration error")} against ${report.main.ref}` : `Migrations consistent with ${report.main.ref}`).slice(0, 140),
|
|
20053
|
+
description: (stale ? `${plural9(errors2, "migration error")} against ${report.main.ref}` : report.roots.length ? `Migrations consistent with ${report.main.ref}` : "No migrations found for a supported framework: nothing checked").slice(0, 140),
|
|
19853
20054
|
target_url: o.targetUrl
|
|
19854
20055
|
});
|
|
19855
20056
|
result.status = state;
|
|
@@ -20256,7 +20457,14 @@ var OwnersApi = class {
|
|
|
20256
20457
|
* backoff, and at most `maxSearches` requests are made per run. undefined = not checked.
|
|
20257
20458
|
*/
|
|
20258
20459
|
reviewsSince(login, since) {
|
|
20259
|
-
return this.
|
|
20460
|
+
return this.searchCount("reviewed-by", login, since);
|
|
20461
|
+
}
|
|
20462
|
+
/** PRs in this repo the user opened that were updated since `since` (same search budget as reviewsSince). */
|
|
20463
|
+
authoredSince(login, since) {
|
|
20464
|
+
return this.searchCount("author", login, since);
|
|
20465
|
+
}
|
|
20466
|
+
searchCount(qualifier, login, since) {
|
|
20467
|
+
return this.memo(`${qualifier}:${login.toLowerCase()}:${since}`, async () => {
|
|
20260
20468
|
const s = this.search;
|
|
20261
20469
|
for (let attempt = 0; ; attempt++) {
|
|
20262
20470
|
if (s.stopped || s.made >= this.maxSearches) {
|
|
@@ -20272,7 +20480,7 @@ var OwnersApi = class {
|
|
|
20272
20480
|
if (wait > 0) await this.sleep(wait);
|
|
20273
20481
|
s.made++;
|
|
20274
20482
|
try {
|
|
20275
|
-
const q = `repo:${this.owner}/${this.repo} type:pr
|
|
20483
|
+
const q = `repo:${this.owner}/${this.repo} type:pr ${qualifier}:${login} updated:>=${since}`;
|
|
20276
20484
|
const r = await this.gh.request("GET", `/search/issues?q=${enc3(q)}&per_page=1`);
|
|
20277
20485
|
const remaining = Number(r.headers.get("x-ratelimit-remaining") ?? NaN);
|
|
20278
20486
|
const reset = Number(r.headers.get("x-ratelimit-reset") ?? NaN);
|
|
@@ -20466,6 +20674,7 @@ function configFromDoc2(doc) {
|
|
|
20466
20674
|
var plural11 = (n2, noun) => `${n2} ${noun}${n2 === 1 ? "" : "s"}`;
|
|
20467
20675
|
var FIXES = {
|
|
20468
20676
|
"unowned-files": "Add a CODEOWNERS line for these paths (see the suggested lines), or list them under `owners.ignore`.",
|
|
20677
|
+
"owned-after-merge": "Nothing to do: the CODEOWNERS line in this PR covers these paths once merged. Until then GitHub requests no code owner review for them.",
|
|
20469
20678
|
"unknown-user": "The account was deleted or renamed: put the current login or a team in its place.",
|
|
20470
20679
|
"owner-left-org": "Remove the owner or replace them with a current member or team.",
|
|
20471
20680
|
"owner-no-write": "Give the owner write access (directly or through a team), or replace them; GitHub skips owners without write.",
|
|
@@ -20673,8 +20882,10 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20673
20882
|
const start = candidates.length ? week % candidates.length : 0;
|
|
20674
20883
|
const order = [...candidates.slice(start), ...candidates.slice(0, start)];
|
|
20675
20884
|
for (const st of order) {
|
|
20676
|
-
if (st.kind === "user")
|
|
20677
|
-
|
|
20885
|
+
if (st.kind === "user") {
|
|
20886
|
+
st.reviews = await api.reviewsSince(st.owner.slice(1), since);
|
|
20887
|
+
if (st.reviews === 0) st.authored = await api.authoredSince(st.owner.slice(1), since);
|
|
20888
|
+
} else {
|
|
20678
20889
|
const members2 = await api.teamMembers(st.owner.split("/")[1].toLowerCase());
|
|
20679
20890
|
let total2 = 0;
|
|
20680
20891
|
let complete = true;
|
|
@@ -20691,7 +20902,7 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20691
20902
|
function dormantFindings(co, statuses, days) {
|
|
20692
20903
|
const out = [];
|
|
20693
20904
|
for (const st of statuses) {
|
|
20694
|
-
if (st.reviews !== 0) continue;
|
|
20905
|
+
if (st.reviews !== 0 || (st.authored ?? 0) > 0) continue;
|
|
20695
20906
|
const lines = co.rules.filter((r) => r.owners.some((o) => key(o) === key(st.owner))).map((r) => r.line);
|
|
20696
20907
|
out.push({
|
|
20697
20908
|
code: st.kind === "team" ? "dormant-team" : "dormant-owner",
|
|
@@ -20699,7 +20910,7 @@ function dormantFindings(co, statuses, days) {
|
|
|
20699
20910
|
scope: "current",
|
|
20700
20911
|
owner: st.owner,
|
|
20701
20912
|
line: lines[0],
|
|
20702
|
-
message: `\`${st.owner}\` (${co.path} line${lines.length > 1 ? "s" : ""} ${lines.join(", ")}) has not reviewed a PR in this repository in ${days} days`
|
|
20913
|
+
message: `\`${st.owner}\` (${co.path} line${lines.length > 1 ? "s" : ""} ${lines.join(", ")}) has not ${st.kind === "user" ? "reviewed or opened" : "reviewed"} a PR in this repository in ${days} days`
|
|
20703
20914
|
});
|
|
20704
20915
|
}
|
|
20705
20916
|
return out;
|
|
@@ -20817,13 +21028,28 @@ async function auditOwners(input) {
|
|
|
20817
21028
|
}
|
|
20818
21029
|
findings.push(...pFindings);
|
|
20819
21030
|
report.ownedAfterMerge = report.unowned.filter((f) => (ruleFor(pco, f)?.owners ?? []).some(effective));
|
|
21031
|
+
const unownedFinding = findings.find((f) => f.code === "unowned-files" && f.scope === "current");
|
|
21032
|
+
if (unownedFinding && unownedFinding.severity === "error" && report.ownedAfterMerge.length) {
|
|
21033
|
+
const after = new Set(report.ownedAfterMerge);
|
|
21034
|
+
const still = report.unowned.filter((f) => !after.has(f));
|
|
21035
|
+
const ownedLater = report.unowned.filter((f) => after.has(f));
|
|
21036
|
+
findings.splice(findings.indexOf(unownedFinding), 1);
|
|
21037
|
+
if (still.length) findings.push({ ...unownedFinding, message: unownedFinding.message.replace(/^\d+ changed files? (has|have)/, `${plural11(still.length, "changed file")} ${still.length === 1 ? "has" : "have"}`), paths: still });
|
|
21038
|
+
findings.push({
|
|
21039
|
+
code: "owned-after-merge",
|
|
21040
|
+
severity: "warning",
|
|
21041
|
+
scope: "current",
|
|
21042
|
+
message: `${plural11(ownedLater.length, "changed file")} ${ownedLater.length === 1 ? "has" : "have"} no code owner on \`${input.ref ?? "the base branch"}\` yet, but this PR's \`${pco.path}\` owns ${ownedLater.length === 1 ? "it" : "them"} once merged (GitHub requests no code owner review for ${ownedLater.length === 1 ? "it" : "them"} on this PR)`,
|
|
21043
|
+
paths: ownedLater
|
|
21044
|
+
});
|
|
21045
|
+
}
|
|
20820
21046
|
}
|
|
20821
21047
|
}
|
|
20822
21048
|
if (checker && api && untrusted) {
|
|
20823
21049
|
report.orgChecks = "untrusted-pr";
|
|
20824
21050
|
if (checker.publicOnly)
|
|
20825
21051
|
notes.push(
|
|
20826
|
-
`This PR comes from a fork
|
|
21052
|
+
`This PR comes from a fork, so owners were checked for public account existence only: team, org membership and repository access checks (and GitHub's own CODEOWNERS errors) would show private org data to the PR author. ${plural11(checker.publicOnly, "owner")} count as valid here; the scheduled audit checks them in full.`
|
|
20827
21053
|
);
|
|
20828
21054
|
report.owners = [...checker.statuses.values()];
|
|
20829
21055
|
} else if (checker && api) {
|
|
@@ -20876,11 +21102,10 @@ async function loadAudit(api, ref) {
|
|
|
20876
21102
|
return { ref, files: tree.paths, truncated: tree.truncated, codeowners: await codeownersAt(api, ref), notes: [] };
|
|
20877
21103
|
}
|
|
20878
21104
|
var touchesCodeowners = (files) => files.some((f) => CODEOWNERS_LOCATIONS.includes(f.filename) || f.previous_filename !== void 0 && CODEOWNERS_LOCATIONS.includes(f.previous_filename));
|
|
20879
|
-
var TRUSTED_ASSOCIATIONS = ["OWNER", "MEMBER", "COLLABORATOR"];
|
|
20880
21105
|
function isTrustedPr(pr) {
|
|
20881
21106
|
const head = pr?.head?.repo?.full_name;
|
|
20882
21107
|
const base = pr?.base?.repo?.full_name;
|
|
20883
|
-
return Boolean(head && base && head.toLowerCase() === base.toLowerCase()
|
|
21108
|
+
return Boolean(head && base && head.toLowerCase() === base.toLowerCase());
|
|
20884
21109
|
}
|
|
20885
21110
|
async function loadPr(api, pr) {
|
|
20886
21111
|
const files = await api.prFiles(pr.number);
|
|
@@ -20973,7 +21198,7 @@ function toMarkdown2(r, o = {}) {
|
|
|
20973
21198
|
);
|
|
20974
21199
|
out.push("");
|
|
20975
21200
|
}
|
|
20976
|
-
const current = r.findings.filter((f) => f.scope === "current" && !(r.mode === "pr" && f.code === "unowned-files"));
|
|
21201
|
+
const current = r.findings.filter((f) => f.scope === "current" && !(r.mode === "pr" && (f.code === "unowned-files" || f.code === "owned-after-merge")));
|
|
20977
21202
|
if (current.length) out.push(...table(current), "");
|
|
20978
21203
|
if (r.proposed) {
|
|
20979
21204
|
const proposed = r.findings.filter((f) => f.scope === "proposed");
|
|
@@ -20994,7 +21219,7 @@ function toText2(r) {
|
|
|
20994
21219
|
const out = [t(`${PRODUCT2}: ${r.repository}${r.pr ? ` #${r.pr}` : ""} \u2014 ${headline2(r)}`)];
|
|
20995
21220
|
for (const f of r.findings) {
|
|
20996
21221
|
out.push(t(`${f.severity.toUpperCase()} [${f.code}]${f.scope === "proposed" ? " (this PR)" : ""} ${f.message}${f.preexisting ? " (already on the base branch)" : ""}`));
|
|
20997
|
-
if (f.code === "unowned-files" && f.paths) for (const p of f.paths.slice(0, MAX_PATHS)) out.push(` ${t(p)}`);
|
|
21222
|
+
if ((f.code === "unowned-files" || f.code === "owned-after-merge") && f.paths) for (const p of f.paths.slice(0, MAX_PATHS)) out.push(` ${t(p)}`);
|
|
20998
21223
|
if (f.hint) out.push(t(` fix: ${f.hint}`));
|
|
20999
21224
|
}
|
|
21000
21225
|
for (const n2 of r.notes) out.push(t(`note: ${n2}`));
|
|
@@ -21176,7 +21401,7 @@ var ISSUE_MARKER = P5.commentMarker;
|
|
|
21176
21401
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
21177
21402
|
var PR_EVENTS = ["pull_request", "pull_request_target", "merge_group"];
|
|
21178
21403
|
var escapeRe3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21179
|
-
function
|
|
21404
|
+
function list5(v) {
|
|
21180
21405
|
if (v === void 0 || v === null) return void 0;
|
|
21181
21406
|
return (Array.isArray(v) ? v : [v]).map(String);
|
|
21182
21407
|
}
|
|
@@ -21190,11 +21415,11 @@ function triggers(on) {
|
|
|
21190
21415
|
const c = cfg ?? {};
|
|
21191
21416
|
out.push({
|
|
21192
21417
|
event,
|
|
21193
|
-
paths:
|
|
21194
|
-
pathsIgnore:
|
|
21195
|
-
branches:
|
|
21196
|
-
branchesIgnore:
|
|
21197
|
-
types:
|
|
21418
|
+
paths: list5(c.paths),
|
|
21419
|
+
pathsIgnore: list5(c["paths-ignore"]),
|
|
21420
|
+
branches: list5(c.branches),
|
|
21421
|
+
branchesIgnore: list5(c["branches-ignore"]),
|
|
21422
|
+
types: list5(c.types)
|
|
21198
21423
|
});
|
|
21199
21424
|
}
|
|
21200
21425
|
return out;
|
|
@@ -21351,7 +21576,7 @@ function parseWorkflow(file) {
|
|
|
21351
21576
|
reusable,
|
|
21352
21577
|
opaque,
|
|
21353
21578
|
if: j.if === void 0 ? void 0 : String(j.if),
|
|
21354
|
-
needs:
|
|
21579
|
+
needs: list5(j.needs) ?? []
|
|
21355
21580
|
});
|
|
21356
21581
|
}
|
|
21357
21582
|
return { path: file.path, name, prTriggers: triggers(on), events: eventsOf(on), callableOnly: isCallableOnly(on), jobs };
|
|
@@ -21603,9 +21828,9 @@ function audit(s, opts = {}) {
|
|
|
21603
21828
|
}
|
|
21604
21829
|
}
|
|
21605
21830
|
} else if (pulls.length) {
|
|
21606
|
-
const missingStreak = (
|
|
21831
|
+
const missingStreak = (list6) => {
|
|
21607
21832
|
let n2 = 0;
|
|
21608
|
-
for (const x of
|
|
21833
|
+
for (const x of list6) {
|
|
21609
21834
|
if (!missingAt.has(x.p.number)) break;
|
|
21610
21835
|
n2++;
|
|
21611
21836
|
}
|
|
@@ -22090,8 +22315,8 @@ function parseReport(r) {
|
|
|
22090
22315
|
// src/commands.ts
|
|
22091
22316
|
var AUDIT_CHECKS = ["rollcall", "owners", "migrations", "evidence"];
|
|
22092
22317
|
var AUDIT_NEEDS = {
|
|
22093
|
-
rollcall: "A GitHub origin remote. A private repository also needs GITHUB_TOKEN or GH_TOKEN
|
|
22094
|
-
owners: "Nothing for the offline lint. With a GitHub origin remote and a token it runs the full audit, which also checks that each owner exists and has write access.",
|
|
22318
|
+
rollcall: "A GitHub origin remote. A private repository also needs GITHUB_TOKEN or GH_TOKEN. No checkout and no administration permission needed.",
|
|
22319
|
+
owners: "Nothing for the offline lint. With a GitHub origin remote and a token it runs the full audit of the default branch's CODEOWNERS on GitHub (not the working tree), which also checks that each owner exists and has write access. --offline lints the working tree.",
|
|
22095
22320
|
migrations: "A checkout with the main branch fetched. No token needed.",
|
|
22096
22321
|
evidence: "A checkout with the main branch fetched; this local run skips the evidence that comes from CI checks. To evaluate a pull request: a GitHub origin remote and a token."
|
|
22097
22322
|
};
|
|
@@ -22146,8 +22371,54 @@ async function runAudit(o) {
|
|
|
22146
22371
|
}
|
|
22147
22372
|
|
|
22148
22373
|
// src/init.ts
|
|
22374
|
+
var import_node_fs12 = require("node:fs");
|
|
22375
|
+
var import_node_path9 = require("node:path");
|
|
22376
|
+
|
|
22377
|
+
// src/facts.ts
|
|
22149
22378
|
var import_node_fs11 = require("node:fs");
|
|
22150
22379
|
var import_node_path8 = require("node:path");
|
|
22380
|
+
var kindOf = (root, f) => {
|
|
22381
|
+
try {
|
|
22382
|
+
return repoPathKind(root, f);
|
|
22383
|
+
} catch {
|
|
22384
|
+
return "unsafe";
|
|
22385
|
+
}
|
|
22386
|
+
};
|
|
22387
|
+
var codeownersIn = (root) => [".github/CODEOWNERS", "CODEOWNERS", "docs/CODEOWNERS"].find((f) => kindOf(root, f) === "file") ?? null;
|
|
22388
|
+
function otherWorkflowNames(root) {
|
|
22389
|
+
const rel = ".github/workflows";
|
|
22390
|
+
if (kindOf(root, rel) !== "directory") return [];
|
|
22391
|
+
const names = [];
|
|
22392
|
+
for (const f of (0, import_node_fs11.readdirSync)((0, import_node_path8.join)(root, rel)).sort()) {
|
|
22393
|
+
if (!/\.ya?ml$/.test(f) || f.startsWith(`${SUITE.githubOrg}-`)) continue;
|
|
22394
|
+
let text;
|
|
22395
|
+
try {
|
|
22396
|
+
text = readRepoFile(root, `${rel}/${f}`);
|
|
22397
|
+
} catch {
|
|
22398
|
+
continue;
|
|
22399
|
+
}
|
|
22400
|
+
const name = text?.match(/^name:[ \t]*(['"]?)([^'"\n#]+?)\1[ \t]*(#.*)?$/m)?.[2]?.trim();
|
|
22401
|
+
names.push(name || f.replace(/\.ya?ml$/, ""));
|
|
22402
|
+
}
|
|
22403
|
+
return names;
|
|
22404
|
+
}
|
|
22405
|
+
function migrationsFacts(root) {
|
|
22406
|
+
let tree;
|
|
22407
|
+
try {
|
|
22408
|
+
tree = Tree.atRef(root, "HEAD");
|
|
22409
|
+
} catch {
|
|
22410
|
+
return void 0;
|
|
22411
|
+
}
|
|
22412
|
+
let config2 = parseConfig2(void 0);
|
|
22413
|
+
try {
|
|
22414
|
+
const text = readRepoFile(root, SUITE.configFile) ?? readRepoFile(root, SUITE.configFileAlt);
|
|
22415
|
+
config2 = parseConfig2(text);
|
|
22416
|
+
} catch {
|
|
22417
|
+
}
|
|
22418
|
+
const roots = discoverRoots(tree, tree, config2);
|
|
22419
|
+
return { roots, unsupported: roots.length ? [] : unsupportedTools(tree.files()) };
|
|
22420
|
+
}
|
|
22421
|
+
var nothingToMigrate = (m) => `Migrations found no migrations for a supported framework (${FRAMEWORKS.join(", ")}), so it checks nothing and its status says so` + (m.unsupported.length ? `. It does not read ${m.unsupported.join(", ")}` : "") + `. If your migrations live elsewhere, set migrations.paths in ${SUITE.configFile}.`;
|
|
22151
22422
|
|
|
22152
22423
|
// raw:../evidence/examples/workflows/evidence.yml
|
|
22153
22424
|
var evidence_default = `# Copy to .github/workflows/mainfast-evidence.yml.
|
|
@@ -22163,7 +22434,7 @@ var evidence_default = `# Copy to .github/workflows/mainfast-evidence.yml.
|
|
|
22163
22434
|
# artifact is data the PR's CI run produced: parsed, never executed.
|
|
22164
22435
|
# Make the "Mainfast Evidence" check required in your ruleset to gate merges on it.
|
|
22165
22436
|
# Never put \${{ github.event.* }} text (branch names, titles, commit messages) into a \`run:\` step.
|
|
22166
|
-
name: Evidence
|
|
22437
|
+
name: Mainfast Evidence
|
|
22167
22438
|
|
|
22168
22439
|
on:
|
|
22169
22440
|
pull_request:
|
|
@@ -22228,19 +22499,47 @@ jobs:
|
|
|
22228
22499
|
`;
|
|
22229
22500
|
|
|
22230
22501
|
// raw:../intact/examples/mainfast-intact.yml
|
|
22231
|
-
var mainfast_intact_default =
|
|
22502
|
+
var mainfast_intact_default = '# Copy to .github/workflows/mainfast-intact.yml\nname: Mainfast Intact\n\non:\n pull_request: # posts the "Mainfast Intact" check run on every PR, with or without merge commits\n # To also check branches that have no pull request, add a push trigger. On a branch with an open\n # PR it runs the check a second time for the same commit.\n # push:\n # branches-ignore: [main] # your default branch: PR merges into it are clean by construction\n\npermissions:\n contents: read\n checks: write # optional: without it the action reports via job summary + annotations\n\njobs:\n intact:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0\n with:\n fetch-depth: 0 # the check needs both parents and the merge base\n ref: ${{ github.event.pull_request.head.sha || github.sha }}\n - uses: mainfast/intact@v0\n # Report-only by default: findings show as annotations and a neutral check run, which\n # GitHub counts as passing, so requiring "Mainfast Intact" blocks nothing yet. To block,\n # uncomment `with:` and `fail-on:` (error fails on dropped changes; warning also fails on\n # evil merges and partial drops), then make "Mainfast Intact" required.\n # with:\n # fail-on: error\n';
|
|
22232
22503
|
|
|
22233
22504
|
// raw:../migrations/examples/mainfast-migrations.yml
|
|
22234
22505
|
var mainfast_migrations_default = '# Copy to .github/workflows/mainfast-migrations.yml.\n#\n# pull_request: checks this PR\'s migrations against the current main.\n# push to main: re-checks every open PR, because main moving can make a clean PR stale.\n# Both set the commit status `mainfast/migrations` on the PR head (failure = stale, success = clean).\n# Only that status blocks a merge, and only once branch protection (or a ruleset) requires it:\n# Settings > Branches > main > Require status checks > add "mainfast/migrations".\nname: Mainfast Migrations\non:\n pull_request:\n push:\n branches: [main]\n\npermissions:\n contents: read\n pull-requests: write # sticky comment + stale label on PRs\n statuses: write # the blocking mainfast/migrations commit status\n\nconcurrency:\n group: mainfast-migrations-${{ github.event.pull_request.number || github.ref }}\n cancel-in-progress: true\n\njobs:\n migrations:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0\n with:\n fetch-depth: 0 # the merge-base must be reachable\n - uses: mainfast/migrations@v0\n # with:\n # status: false # no commit status: comment + label only (then nothing blocks the merge)\n';
|
|
22235
22506
|
|
|
22236
22507
|
// raw:../owners/examples/owners.yml
|
|
22237
|
-
var owners_default =
|
|
22508
|
+
var owners_default = '# Copy to .github/workflows/mainfast-owners.yml.\n# No checkout step: Owners reads CODEOWNERS, .mainfast.yml and the tree through the API at the\n# right refs (the PR\'s base branch, the PR\'s head when it edits CODEOWNERS, the default branch\n# for the weekly audit), never from a checkout.\nname: Mainfast Owners\non:\n pull_request: # changed files judged with the base CODEOWNERS; a CODEOWNERS edit is linted on its own\n schedule:\n - cron: "23 6 * * 1" # weekly full audit, with dormant owners (180 days by default)\n workflow_dispatch:\n\npermissions:\n contents: read # CODEOWNERS, .mainfast.yml, git tree\n pull-requests: write # PR files + the one sticky comment\n checks: write # the "Mainfast Owners" check run on each PR\n\nconcurrency:\n group: mainfast-owners-${{ github.event.pull_request.number || github.ref }}\n cancel-in-progress: true\n\njobs:\n owners:\n runs-on: ubuntu-latest\n steps:\n - uses: mainfast/owners@v0\n with:\n # Optional: org membership, team existence and team access. GITHUB_TOKEN cannot read\n # them; a fine-grained token (or GitHub App token) with Organization > Members: read\n # can. Without it those checks are skipped with one note. Never used on fork PRs.\n org-token: ${{ secrets.MAINFAST_OWNERS_ORG_TOKEN }}\n';
|
|
22238
22509
|
|
|
22239
22510
|
// raw:../rollcall/examples/rollcall.yml
|
|
22240
|
-
var rollcall_default = '# Copy to .github/workflows/mainfast-rollcall.yml.\n# No checkout step: Rollcall reads .mainfast.yml (default branch) and .github/workflows (audited\n# branch) through the API, so a manual run from any branch audits exactly what the schedule does.\nname:
|
|
22511
|
+
var rollcall_default = '# Copy to .github/workflows/mainfast-rollcall.yml.\n# No checkout step: Rollcall reads .mainfast.yml (default branch) and .github/workflows (audited\n# branch) through the API, so a manual run from any branch audits exactly what the schedule does.\nname: Mainfast Rollcall\non:\n schedule:\n - cron: "17 6 * * 1" # Mondays: also catches ruleset changes, which trigger no workflow event\n workflow_dispatch: # run it by hand after editing a ruleset\n branch_protection_rule: # classic branch protection created / edited / deleted\n push:\n branches: [main]\n paths: [".github/workflows/**", ".mainfast.yml"]\n\npermissions:\n contents: read # .mainfast.yml, workflow files, "Get a branch" (classic required checks)\n pull-requests: read # the merged and open PRs to sample\n statuses: read # commit statuses on each sampled PR head\n checks: write # read check runs, post the Rollcall check run\n issues: write # the one tracking issue\n\nconcurrency:\n group: mainfast-rollcall\n cancel-in-progress: true\n\njobs:\n rollcall:\n runs-on: ubuntu-latest\n steps:\n - uses: mainfast/rollcall@v0\n with:\n pulls: 30\n';
|
|
22512
|
+
|
|
22513
|
+
// src/pins.json
|
|
22514
|
+
var pins_default = {
|
|
22515
|
+
_comment: "The release commit of each action repository, written into the workflows `init` installs. Updated at each release once the action repositories are tagged (see RELEASING.md).",
|
|
22516
|
+
version: "0.3.1",
|
|
22517
|
+
actions: {
|
|
22518
|
+
intact: "1dbf7a47069256a308403f6a9174f20763e8cd1b",
|
|
22519
|
+
migrations: "30e4eb27f5ec4a1fcb5409d0833c1a7cb61a8cef",
|
|
22520
|
+
rollcall: "e2fc735bb4319a09a9e1ab1b626aba887e9a773e",
|
|
22521
|
+
owners: "c292e89c2febe1d35746d1c0410d0e0887ef7548",
|
|
22522
|
+
evidence: "7e1487a5b915eb6d06197c16f5390ccd412d14a6"
|
|
22523
|
+
}
|
|
22524
|
+
};
|
|
22241
22525
|
|
|
22242
22526
|
// src/templates.ts
|
|
22243
|
-
var
|
|
22527
|
+
var PINS = pins_default;
|
|
22528
|
+
function pinWorkflow(slug, text, pin = { version: PINS.version, sha: PINS.actions[slug] }) {
|
|
22529
|
+
const action = product(slug).actionRef.split("@")[0];
|
|
22530
|
+
if (!/^[0-9a-f]{40}$/.test(pin.sha)) throw new Error(`pins.json: ${slug} is not a full commit SHA`);
|
|
22531
|
+
const re = new RegExp(`^([ \\t]*)(- )?uses: ${action.replace(/[/.]/g, "\\$&")}@v\\d+[ \\t]*$`, "gm");
|
|
22532
|
+
return text.replace(re, (_all, indent, dash = "") => `${indent}# Pinned to the v${pin.version} release commit. To follow every v0 release instead, use ${action}@v0.
|
|
22533
|
+
${indent}${dash}uses: ${action}@${pin.sha} # v${pin.version}`);
|
|
22534
|
+
}
|
|
22535
|
+
var prepare = (slug, text) => pinWorkflow(slug, text.replace(/^# Copy to [^\n]*\n/, ""));
|
|
22536
|
+
var WORKFLOWS = {
|
|
22537
|
+
intact: prepare("intact", mainfast_intact_default),
|
|
22538
|
+
migrations: prepare("migrations", mainfast_migrations_default),
|
|
22539
|
+
rollcall: prepare("rollcall", rollcall_default),
|
|
22540
|
+
owners: prepare("owners", owners_default),
|
|
22541
|
+
evidence: prepare("evidence", evidence_default)
|
|
22542
|
+
};
|
|
22244
22543
|
var workflowPath = (slug) => `.github/workflows/${SUITE.githubOrg}-${slug}.yml`;
|
|
22245
22544
|
var STARTER_CONFIG = `# yaml-language-server: $schema=${SUITE.schemaUrl}
|
|
22246
22545
|
# One optional section per check. Defaults apply to any check without one.
|
|
@@ -22254,7 +22553,7 @@ function installedIn(root, slug) {
|
|
|
22254
22553
|
const rel = ".github/workflows";
|
|
22255
22554
|
if (repoPathKind(root, rel) !== "directory") return [];
|
|
22256
22555
|
const action = product(slug).actionRef.split("@")[0];
|
|
22257
|
-
return (0,
|
|
22556
|
+
return (0, import_node_fs12.readdirSync)((0, import_node_path9.join)(root, rel)).filter((f) => /\.ya?ml$/.test(f)).filter((f) => {
|
|
22258
22557
|
try {
|
|
22259
22558
|
return readRepoFile(root, `${rel}/${f}`)?.includes(`uses: ${action}@`) ?? false;
|
|
22260
22559
|
} catch {
|
|
@@ -22262,14 +22561,29 @@ function installedIn(root, slug) {
|
|
|
22262
22561
|
}
|
|
22263
22562
|
}).map((f) => `${rel}/${f}`);
|
|
22264
22563
|
}
|
|
22265
|
-
function nextSteps(slugs) {
|
|
22564
|
+
function nextSteps(root, slugs) {
|
|
22266
22565
|
const steps = ["Review the new files, commit them and open a pull request. Nothing has been pushed."];
|
|
22267
|
-
const required2 =
|
|
22566
|
+
const required2 = [];
|
|
22567
|
+
if (slugs.includes("owners")) required2.push(`"${product("owners").checkName}" (or the job "owners")`);
|
|
22568
|
+
if (slugs.includes("evidence")) required2.push(`"${product("evidence").checkName}"`);
|
|
22268
22569
|
if (slugs.includes("migrations")) required2.push(`"${product("migrations").statusContext ?? "mainfast/migrations"}"`);
|
|
22269
22570
|
if (required2.length) steps.push(`To block merges on findings, make ${required2.join(", ")} required in branch protection or a ruleset.`);
|
|
22270
|
-
if (slugs.includes("
|
|
22571
|
+
if (slugs.includes("intact"))
|
|
22572
|
+
steps.push(
|
|
22573
|
+
`Intact is report-only as installed: on a finding its check run is neutral, which GitHub counts as passing. To block on dropped changes, set fail-on: error in ${workflowPath("intact")}, then make "${product("intact").checkName}" required too (it is posted on every pull request).`
|
|
22574
|
+
);
|
|
22575
|
+
if (slugs.includes("evidence")) {
|
|
22576
|
+
const names = otherWorkflowNames(root);
|
|
22577
|
+
if (!names.includes("CI"))
|
|
22578
|
+
steps.push(`Evidence: set workflows: [CI] in ${workflowPath("evidence")} to the name of your test workflow${names.length ? ` (this repository has ${names.map((n2) => `"${n2}"`).join(", ")})` : ""}.`);
|
|
22579
|
+
}
|
|
22271
22580
|
if (slugs.includes("rollcall")) steps.push("Rollcall runs weekly and keeps one tracking issue open while it finds problems. After you change a ruleset, run it by hand from the Actions tab.");
|
|
22272
|
-
if (slugs.includes("owners")) steps.push("Owners needs a CODEOWNERS file; until you add one, every run reports it as missing.");
|
|
22581
|
+
if (slugs.includes("owners") && !codeownersIn(root)) steps.push("Owners needs a CODEOWNERS file; until you add one, every run reports it as missing.");
|
|
22582
|
+
if (slugs.includes("migrations")) {
|
|
22583
|
+
const m = migrationsFacts(root);
|
|
22584
|
+
if (m && !m.roots.length) steps.push(nothingToMigrate(m));
|
|
22585
|
+
}
|
|
22586
|
+
steps.push(`Each workflow pins its ${SUITE.name} action to the commit of the v${PINS.version} release. To follow every v0 release instead, change that ref to v0 (for example ${product("intact").actionRef}).`);
|
|
22273
22587
|
return steps;
|
|
22274
22588
|
}
|
|
22275
22589
|
function runInit(opts) {
|
|
@@ -22283,13 +22597,13 @@ function runInit(opts) {
|
|
|
22283
22597
|
const skipped = [];
|
|
22284
22598
|
const place = (rel, content) => {
|
|
22285
22599
|
const current = readRepoFile(root, rel);
|
|
22286
|
-
const abs = (0,
|
|
22600
|
+
const abs = (0, import_node_path9.join)(root, rel);
|
|
22287
22601
|
const exists = current !== void 0;
|
|
22288
22602
|
if (current === content) return void unchanged.push(rel);
|
|
22289
22603
|
if (exists && !opts.force) return void skipped.push({ path: rel, reason: "exists with different content; use --force to replace it" });
|
|
22290
22604
|
if (!opts.dryRun) {
|
|
22291
|
-
(0,
|
|
22292
|
-
(0,
|
|
22605
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path9.dirname)(abs), { recursive: true });
|
|
22606
|
+
(0, import_node_fs12.writeFileSync)(abs, content);
|
|
22293
22607
|
}
|
|
22294
22608
|
(exists ? overwritten : written).push(rel);
|
|
22295
22609
|
};
|
|
@@ -22301,8 +22615,9 @@ function runInit(opts) {
|
|
|
22301
22615
|
}
|
|
22302
22616
|
if (repoPathKind(root, SUITE.configFileAlt)) skipped.push({ path: SUITE.configFile, reason: `${SUITE.configFileAlt} already exists` });
|
|
22303
22617
|
else place(SUITE.configFile, STARTER_CONFIG);
|
|
22304
|
-
const steps = nextSteps(slugs);
|
|
22305
|
-
const
|
|
22618
|
+
const steps = nextSteps(root, slugs);
|
|
22619
|
+
const files = opts.dryRun ? { written: [], overwritten: [], would_write: written, would_overwrite: overwritten } : { written, overwritten };
|
|
22620
|
+
const json = { schema: SCHEMA, command: "init", ok: true, repo: root, dry_run: Boolean(opts.dryRun), checks: slugs, ...files, unchanged, skipped, next_steps: steps, pinned: { version: PINS.version, actions: Object.fromEntries(slugs.map((s) => [s, PINS.actions[s]])) }, hosted_app: hostedAppUrl() };
|
|
22306
22621
|
const verb = opts.dryRun ? "would write" : "wrote";
|
|
22307
22622
|
const lines = [
|
|
22308
22623
|
...written.map((f) => `${verb} ${f}`),
|
|
@@ -22318,6 +22633,24 @@ function runInit(opts) {
|
|
|
22318
22633
|
}
|
|
22319
22634
|
|
|
22320
22635
|
// src/doctor.ts
|
|
22636
|
+
function sectionProblems(text, path) {
|
|
22637
|
+
const out = [];
|
|
22638
|
+
const parsers = [
|
|
22639
|
+
["intact", (t) => parseConfig(t, path)],
|
|
22640
|
+
["migrations", parseConfig2],
|
|
22641
|
+
["rollcall", parseConfig4],
|
|
22642
|
+
["owners", parseConfig3]
|
|
22643
|
+
];
|
|
22644
|
+
for (const [slug, parse4] of parsers) {
|
|
22645
|
+
try {
|
|
22646
|
+
parse4(text);
|
|
22647
|
+
} catch (e) {
|
|
22648
|
+
out.push(`${slug}: ${e instanceof Error ? e.message : String(e)}`);
|
|
22649
|
+
}
|
|
22650
|
+
}
|
|
22651
|
+
out.push(...parsePolicy(text).warnings.map((w) => `evidence: ${w}`));
|
|
22652
|
+
return out;
|
|
22653
|
+
}
|
|
22321
22654
|
function runDoctor(dir) {
|
|
22322
22655
|
const root = repoRoot(dir);
|
|
22323
22656
|
const missing = [];
|
|
@@ -22337,18 +22670,21 @@ function runDoctor(dir) {
|
|
|
22337
22670
|
return [s, { installed: files.length > 0, files }];
|
|
22338
22671
|
}));
|
|
22339
22672
|
const installed = PRODUCT_SLUGS.filter((s) => checks[s].installed);
|
|
22340
|
-
const
|
|
22673
|
+
const kindOf2 = (f) => {
|
|
22341
22674
|
try {
|
|
22342
22675
|
return repoPathKind(root, f);
|
|
22343
22676
|
} catch {
|
|
22344
22677
|
return "unsafe";
|
|
22345
22678
|
}
|
|
22346
22679
|
};
|
|
22347
|
-
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) =>
|
|
22680
|
+
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) => kindOf2(f));
|
|
22348
22681
|
let config2 = { path: path ?? null, ok: true };
|
|
22349
22682
|
if (path) {
|
|
22350
22683
|
try {
|
|
22351
|
-
|
|
22684
|
+
const text = readRepoFile(root, path);
|
|
22685
|
+
parseConfigDoc(text, path);
|
|
22686
|
+
const problems = text ? sectionProblems(text, path) : [];
|
|
22687
|
+
if (problems.length) throw new Error(problems.join("; "));
|
|
22352
22688
|
} catch (e) {
|
|
22353
22689
|
config2 = { path, ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
22354
22690
|
missing.push(`${path} cannot be used: ${config2.error}`);
|
|
@@ -22356,16 +22692,18 @@ function runDoctor(dir) {
|
|
|
22356
22692
|
}
|
|
22357
22693
|
const token = githubToken();
|
|
22358
22694
|
const repo = githubRepo(root) ?? null;
|
|
22359
|
-
const codeowners =
|
|
22695
|
+
const codeowners = codeownersIn(root);
|
|
22696
|
+
const migrations2 = installed.includes("migrations") ? migrationsFacts(root) : void 0;
|
|
22360
22697
|
if (!installed.length && workflowsOk) missing.push("No checks are installed. Run: mainfast init");
|
|
22361
22698
|
if (!repo) missing.push("No GitHub origin remote, so audit cannot read the repository through the GitHub API.");
|
|
22362
22699
|
if (!token) missing.push("No GITHUB_TOKEN or GH_TOKEN: audit rollcall needs one for a private repository, and audit owners runs only the offline lint.");
|
|
22700
|
+
if (migrations2 && !migrations2.roots.length) missing.push(nothingToMigrate(migrations2));
|
|
22363
22701
|
if (installed.includes("owners") && !codeowners) missing.push("Owners is installed but there is no CODEOWNERS file. Add .github/CODEOWNERS.");
|
|
22364
22702
|
const ok = config2.ok && workflowsOk && installed.length > 0;
|
|
22365
|
-
const json = { schema: SCHEMA, command: "doctor", ok, repo: root, github_repo: repo, checks, config: config2, codeowners, token: { present: Boolean(token), source: token?.name ?? null }, missing, hosted_app: hostedAppUrl() };
|
|
22703
|
+
const json = { schema: SCHEMA, command: "doctor", ok, repo: root, github_repo: repo, checks, config: config2, codeowners, migrations: migrations2 ? { checked: migrations2.roots.length > 0, roots: migrations2.roots, unsupported: migrations2.unsupported } : null, token: { present: Boolean(token), source: token?.name ?? null }, missing, hosted_app: hostedAppUrl() };
|
|
22366
22704
|
const lines = [
|
|
22367
22705
|
...PRODUCT_SLUGS.map((s) => `${checks[s].installed ? "installed" : "missing "} ${s}${checks[s].installed ? ` (${checks[s].files.join(", ")})` : ""}`),
|
|
22368
|
-
`config ${path ? config2.ok ? `${path} parses` : `${path}
|
|
22706
|
+
`config ${path ? config2.ok ? `${path} parses, every section valid` : `${path} has errors` : "none (defaults apply)"}`,
|
|
22369
22707
|
`token ${token ? `set (${token.name})` : "not set"}`,
|
|
22370
22708
|
...missing.length ? ["", "To do:", ...missing.map((m) => `- ${m}`)] : []
|
|
22371
22709
|
];
|
|
@@ -22373,8 +22711,8 @@ function runDoctor(dir) {
|
|
|
22373
22711
|
}
|
|
22374
22712
|
|
|
22375
22713
|
// src/mcp.ts
|
|
22376
|
-
var
|
|
22377
|
-
var
|
|
22714
|
+
var import_node_fs13 = require("node:fs");
|
|
22715
|
+
var import_node_path10 = require("node:path");
|
|
22378
22716
|
var import_node_url = require("node:url");
|
|
22379
22717
|
|
|
22380
22718
|
// ../node_modules/zod/v4/core/util.js
|
|
@@ -22834,7 +23172,7 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
22834
23172
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
22835
23173
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
22836
23174
|
};
|
|
22837
|
-
function pick(schema,
|
|
23175
|
+
function pick(schema, mask2) {
|
|
22838
23176
|
const currDef = schema._zod.def;
|
|
22839
23177
|
const checks = currDef.checks;
|
|
22840
23178
|
const hasChecks = checks && checks.length > 0;
|
|
@@ -22842,29 +23180,29 @@ function pick(schema, mask) {
|
|
|
22842
23180
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
22843
23181
|
}
|
|
22844
23182
|
const newShape = {};
|
|
22845
|
-
mirrorShape(newShape, schema, maskedKeys(schema,
|
|
23183
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask2));
|
|
22846
23184
|
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
22847
23185
|
}
|
|
22848
|
-
function maskedKeys(schema,
|
|
23186
|
+
function maskedKeys(schema, mask2) {
|
|
22849
23187
|
const raw = sourceShape(schema);
|
|
22850
23188
|
const keys = [];
|
|
22851
|
-
for (const key2 of Reflect.ownKeys(
|
|
23189
|
+
for (const key2 of Reflect.ownKeys(mask2)) {
|
|
22852
23190
|
if (!Object.getOwnPropertyDescriptor(raw, key2)?.enumerable) {
|
|
22853
23191
|
throw new Error(`Unrecognized key: "${String(key2)}"`);
|
|
22854
23192
|
}
|
|
22855
|
-
if (
|
|
23193
|
+
if (mask2[key2])
|
|
22856
23194
|
keys.push(key2);
|
|
22857
23195
|
}
|
|
22858
23196
|
return keys;
|
|
22859
23197
|
}
|
|
22860
|
-
function omit(schema,
|
|
23198
|
+
function omit(schema, mask2) {
|
|
22861
23199
|
const currDef = schema._zod.def;
|
|
22862
23200
|
const checks = currDef.checks;
|
|
22863
23201
|
const hasChecks = checks && checks.length > 0;
|
|
22864
23202
|
if (hasChecks) {
|
|
22865
23203
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
22866
23204
|
}
|
|
22867
|
-
const omitted = new Set(maskedKeys(schema,
|
|
23205
|
+
const omitted = new Set(maskedKeys(schema, mask2));
|
|
22868
23206
|
const newShape = {};
|
|
22869
23207
|
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key2) => !omitted.has(key2)));
|
|
22870
23208
|
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
@@ -22916,20 +23254,20 @@ function merge(a, b) {
|
|
|
22916
23254
|
});
|
|
22917
23255
|
return clone(a, def);
|
|
22918
23256
|
}
|
|
22919
|
-
function partial(Class2, schema,
|
|
23257
|
+
function partial(Class2, schema, mask2, name = "partial") {
|
|
22920
23258
|
const currDef = schema._zod.def;
|
|
22921
23259
|
const checks = currDef.checks;
|
|
22922
23260
|
const hasChecks = checks && checks.length > 0;
|
|
22923
23261
|
if (hasChecks) {
|
|
22924
23262
|
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
22925
23263
|
}
|
|
22926
|
-
const selected =
|
|
23264
|
+
const selected = mask2 ? new Set(maskedKeys(schema, mask2)) : void 0;
|
|
22927
23265
|
const newShape = {};
|
|
22928
23266
|
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key2) => selected && !selected.has(key2) ? value : new Class2({ type: "optional", innerType: value })));
|
|
22929
23267
|
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
22930
23268
|
}
|
|
22931
|
-
function required(Class2, schema,
|
|
22932
|
-
const selected =
|
|
23269
|
+
function required(Class2, schema, mask2) {
|
|
23270
|
+
const selected = mask2 ? new Set(maskedKeys(schema, mask2)) : void 0;
|
|
22933
23271
|
const newShape = {};
|
|
22934
23272
|
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key2) => (
|
|
22935
23273
|
// overwrite with non-optional
|
|
@@ -27277,8 +27615,8 @@ var contributors = {
|
|
|
27277
27615
|
function aggregateChecks(schema) {
|
|
27278
27616
|
const agg = {};
|
|
27279
27617
|
const def = schema._zod.def;
|
|
27280
|
-
const
|
|
27281
|
-
for (const ch of
|
|
27618
|
+
const list6 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
27619
|
+
for (const ch of list6)
|
|
27282
27620
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
27283
27621
|
const bag = schema._zod.bag;
|
|
27284
27622
|
if (bag.minimum !== void 0)
|
|
@@ -28470,11 +28808,11 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
28470
28808
|
merge(other) {
|
|
28471
28809
|
return util_exports.merge(this, other);
|
|
28472
28810
|
},
|
|
28473
|
-
pick(
|
|
28474
|
-
return util_exports.pick(this,
|
|
28811
|
+
pick(mask2) {
|
|
28812
|
+
return util_exports.pick(this, mask2);
|
|
28475
28813
|
},
|
|
28476
|
-
omit(
|
|
28477
|
-
return util_exports.omit(this,
|
|
28814
|
+
omit(mask2) {
|
|
28815
|
+
return util_exports.omit(this, mask2);
|
|
28478
28816
|
},
|
|
28479
28817
|
partial(...args) {
|
|
28480
28818
|
return util_exports.partial(ZodOptional, this, args[0]);
|
|
@@ -32221,17 +32559,17 @@ var TOOLS = [
|
|
|
32221
32559
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
32222
32560
|
}
|
|
32223
32561
|
];
|
|
32224
|
-
var inside = (base, path) => path === base || path.startsWith(base.endsWith(
|
|
32562
|
+
var inside = (base, path) => path === base || path.startsWith(base.endsWith(import_node_path10.sep) ? base : base + import_node_path10.sep);
|
|
32225
32563
|
function allowedBases(cwd, roots) {
|
|
32226
|
-
let own2 = (0,
|
|
32564
|
+
let own2 = (0, import_node_fs13.realpathSync)(cwd);
|
|
32227
32565
|
try {
|
|
32228
|
-
own2 = (0,
|
|
32566
|
+
own2 = (0, import_node_fs13.realpathSync)(repoRoot(cwd));
|
|
32229
32567
|
} catch {
|
|
32230
32568
|
}
|
|
32231
32569
|
const out = [own2];
|
|
32232
32570
|
for (const uri of roots) {
|
|
32233
32571
|
try {
|
|
32234
|
-
out.push((0,
|
|
32572
|
+
out.push((0, import_node_fs13.realpathSync)((0, import_node_url.fileURLToPath)(uri)));
|
|
32235
32573
|
} catch {
|
|
32236
32574
|
}
|
|
32237
32575
|
}
|
|
@@ -32242,11 +32580,11 @@ function checkRepoPath(given, cwd, roots) {
|
|
|
32242
32580
|
const bases = allowedBases(cwd, roots);
|
|
32243
32581
|
let real;
|
|
32244
32582
|
try {
|
|
32245
|
-
real = (0,
|
|
32583
|
+
real = (0, import_node_fs13.realpathSync)((0, import_node_path10.resolve)(cwd, given));
|
|
32246
32584
|
} catch {
|
|
32247
32585
|
throw new CliError(`repo_path does not exist: ${given}`);
|
|
32248
32586
|
}
|
|
32249
|
-
const top = (0,
|
|
32587
|
+
const top = (0, import_node_fs13.realpathSync)(repoRoot(real));
|
|
32250
32588
|
if (!bases.some((b) => inside(b, real)) || !bases.some((b) => inside(b, top))) throw new CliError(`repo_path is outside the working directory and the client's roots: ${given}`);
|
|
32251
32589
|
return real;
|
|
32252
32590
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mainfast",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Set up and run Mainfast, GitHub checks that stop merges from silently breaking main. CLI and MCP server.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"github-actions",
|
|
7
|
+
"merge",
|
|
8
|
+
"merge-commit",
|
|
9
|
+
"migrations",
|
|
10
|
+
"codeowners",
|
|
11
|
+
"required-checks",
|
|
12
|
+
"branch-protection",
|
|
13
|
+
"ci",
|
|
14
|
+
"code-review",
|
|
15
|
+
"coding-agents",
|
|
16
|
+
"mcp",
|
|
17
|
+
"cli"
|
|
18
|
+
],
|
|
5
19
|
"license": "FSL-1.1-ALv2",
|
|
6
20
|
"author": "Mainfast authors",
|
|
7
21
|
"type": "module",
|
|
@@ -20,7 +34,9 @@
|
|
|
20
34
|
"typecheck": "tsc --noEmit -p .",
|
|
21
35
|
"test": "vitest run",
|
|
22
36
|
"build": "node build.mjs",
|
|
23
|
-
"all": "npm run typecheck && npm test && npm run build"
|
|
37
|
+
"all": "npm run typecheck && npm test && npm run build",
|
|
38
|
+
"prepack": "node scripts/pack-license.mjs full",
|
|
39
|
+
"postpack": "node scripts/pack-license.mjs restore"
|
|
24
40
|
},
|
|
25
41
|
"devDependencies": {
|
|
26
42
|
"@mainfast/shared": "0.1.0",
|