mainfast 0.2.0 → 0.3.0
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 +381 -121
- 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.0",
|
|
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,90 @@ 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 migrationName(text, file) {
|
|
19602
|
+
const head = text.split(/\bup\s*\(/)[0];
|
|
19603
|
+
const prop = head.match(/\bname\s*=\s*(['"`])([^'"`]+)\1/)?.[2];
|
|
19604
|
+
const cls = text.match(/\bclass\s+([A-Za-z_$][\w$]*)/)?.[1];
|
|
19605
|
+
return prop ?? cls ?? basename(file).replace(/\.[^.]+$/, "");
|
|
19606
|
+
}
|
|
19607
|
+
function list4(tree, root) {
|
|
19608
|
+
const out = [];
|
|
19609
|
+
for (const f of tree.under(root)) {
|
|
19610
|
+
if (dirname(f) !== root || !isMigrationFile(f)) continue;
|
|
19611
|
+
const text = tree.read(f);
|
|
19612
|
+
if (!isTypeorm(text)) continue;
|
|
19613
|
+
const name = migrationName(text, f);
|
|
19614
|
+
out.push({ name, version: name.match(/(\d{13})$/)?.[1] ?? basename(f).slice(0, 13), path: f });
|
|
19615
|
+
}
|
|
19616
|
+
return out;
|
|
19617
|
+
}
|
|
19618
|
+
var typeorm = {
|
|
19619
|
+
id: "typeorm",
|
|
19620
|
+
detect(files, read) {
|
|
19621
|
+
return uniq(files.filter((f) => isMigrationFile(f) && isTypeorm(read(f))).map(dirname));
|
|
19622
|
+
},
|
|
19623
|
+
inspect(tree, root) {
|
|
19624
|
+
const findings = [];
|
|
19625
|
+
const migs = list4(tree, root);
|
|
19626
|
+
for (const [n2, l] of groupBy(migs, (m) => m.name)) {
|
|
19627
|
+
if (l.length > 1)
|
|
19628
|
+
findings.push({
|
|
19629
|
+
framework: "typeorm",
|
|
19630
|
+
root,
|
|
19631
|
+
code: "duplicate-name",
|
|
19632
|
+
severity: "error",
|
|
19633
|
+
message: `${l.length} migrations are named ${n2} (${l.map((m) => basename(m.path)).join(", ")}); TypeORM throws "Duplicate migrations"`,
|
|
19634
|
+
files: l.map((m) => m.path),
|
|
19635
|
+
hint: "Regenerate the branch migration on top of main (typeorm migration:generate gives it a fresh timestamp and class name).",
|
|
19636
|
+
key: `typeorm:${root}:dupname:${n2}`
|
|
19637
|
+
});
|
|
19638
|
+
}
|
|
19639
|
+
for (const [v, l] of groupBy(migs, (m) => m.version)) {
|
|
19640
|
+
if (l.length > 1 && new Set(l.map((m) => m.name)).size === l.length)
|
|
19641
|
+
findings.push({
|
|
19642
|
+
framework: "typeorm",
|
|
19643
|
+
root,
|
|
19644
|
+
code: "duplicate-timestamp",
|
|
19645
|
+
severity: "warning",
|
|
19646
|
+
message: `${l.length} migrations share timestamp ${v} (${l.map((m) => basename(m.path)).join(", ")}); the order TypeORM runs them in is not defined`,
|
|
19647
|
+
files: l.map((m) => m.path),
|
|
19648
|
+
hint: "Give the branch migration a newer timestamp, in its file name and its class name.",
|
|
19649
|
+
key: `typeorm:${root}:dupts:${v}`
|
|
19650
|
+
});
|
|
19651
|
+
}
|
|
19652
|
+
for (const m of migs) {
|
|
19653
|
+
if (!/\d{13}$/.test(m.name))
|
|
19654
|
+
findings.push({
|
|
19655
|
+
framework: "typeorm",
|
|
19656
|
+
root,
|
|
19657
|
+
code: "name-without-timestamp",
|
|
19658
|
+
severity: "error",
|
|
19659
|
+
message: `${basename(m.path)}: the migration name ${m.name} does not end in a 13-digit timestamp; TypeORM refuses to load it`,
|
|
19660
|
+
files: [m.path],
|
|
19661
|
+
hint: "End the class name (and the `name` property, if set) with the timestamp from the file name.",
|
|
19662
|
+
key: `typeorm:${root}:nots:${m.path}`
|
|
19663
|
+
});
|
|
19664
|
+
}
|
|
19665
|
+
return findings;
|
|
19666
|
+
},
|
|
19667
|
+
compare(ctx) {
|
|
19668
|
+
return outOfOrder(
|
|
19669
|
+
"typeorm",
|
|
19670
|
+
ctx,
|
|
19671
|
+
list4,
|
|
19672
|
+
compareDigits,
|
|
19673
|
+
"TypeORM still runs it on databases that already ran the newer one, so environments apply migrations in different orders.",
|
|
19674
|
+
"Regenerate the branch migration on top of main so its timestamp is newer."
|
|
19675
|
+
);
|
|
19676
|
+
}
|
|
19677
|
+
};
|
|
19678
|
+
|
|
19580
19679
|
// ../migrations/src/frameworks/index.ts
|
|
19581
|
-
var frameworks = { alembic, django, prisma, rails, flyway, drizzle };
|
|
19680
|
+
var frameworks = { alembic, django, prisma, rails, flyway, drizzle, typeorm };
|
|
19582
19681
|
|
|
19583
19682
|
// ../migrations/src/git.ts
|
|
19584
19683
|
var import_node_child_process4 = require("node:child_process");
|
|
@@ -19710,6 +19809,21 @@ function discoverRoots(main7, head, config2) {
|
|
|
19710
19809
|
}
|
|
19711
19810
|
return out;
|
|
19712
19811
|
}
|
|
19812
|
+
var UNSUPPORTED = [
|
|
19813
|
+
{ tool: "knex", test: /(^|\/)knexfile\.[cm]?[jt]s$/ },
|
|
19814
|
+
{ tool: "sequelize", test: /(^|\/)\.sequelizerc$/ },
|
|
19815
|
+
{ tool: "liquibase", test: /(^|\/)(db\.)?changelog(-master)?\.(xml|ya?ml|json|sql)$/ },
|
|
19816
|
+
{ tool: "ecto", test: /(^|\/)priv\/repo\/migrations\/\d+_[^/]+\.exs$/ },
|
|
19817
|
+
{ tool: "golang-migrate or dbmate", test: /(^|\/)\d+_[^/]+\.up\.sql$/ }
|
|
19818
|
+
];
|
|
19819
|
+
function unsupportedTools(files) {
|
|
19820
|
+
const out = [];
|
|
19821
|
+
for (const { tool, test } of UNSUPPORTED) {
|
|
19822
|
+
const hit = files.find((f) => test.test(f) && !f.includes("node_modules/"));
|
|
19823
|
+
if (hit) out.push(`${tool} (${hit})`);
|
|
19824
|
+
}
|
|
19825
|
+
return out;
|
|
19826
|
+
}
|
|
19713
19827
|
function analyze(opts) {
|
|
19714
19828
|
const mainSha = revParse2(opts.repo, opts.mainRef);
|
|
19715
19829
|
const headSha = revParse2(opts.repo, opts.headRef);
|
|
@@ -19748,6 +19862,8 @@ function analyzeTrees(opts) {
|
|
|
19748
19862
|
head: { ref: opts.headRef, sha: headSha },
|
|
19749
19863
|
mergeBase: baseSha,
|
|
19750
19864
|
roots,
|
|
19865
|
+
checked: roots.length > 0,
|
|
19866
|
+
unsupported: roots.length ? [] : unsupportedTools(head.files()),
|
|
19751
19867
|
findings: unique,
|
|
19752
19868
|
preExisting
|
|
19753
19869
|
};
|
|
@@ -19764,7 +19880,9 @@ function toMarkdown(r, opts = {}) {
|
|
|
19764
19880
|
lines.push(`### ${opts.title ?? PRODUCT}`);
|
|
19765
19881
|
lines.push("");
|
|
19766
19882
|
if (!r.roots.length) {
|
|
19767
|
-
lines.push(
|
|
19883
|
+
lines.push(`**Nothing was checked:** no migrations found for a supported framework (${FRAMEWORKS.join(", ")}).`);
|
|
19884
|
+
if (r.unsupported?.length) lines.push("", `Found ${r.unsupported.map((u) => mdInline(u, 200)).join(", ")}, which ${PRODUCT} does not read yet.`);
|
|
19885
|
+
lines.push("", `If your migrations live elsewhere, set \`migrations.paths\` in \`.mainfast.yml\`. [docs](${DOCS_URL2})`);
|
|
19768
19886
|
return lines.join("\n");
|
|
19769
19887
|
}
|
|
19770
19888
|
lines.push(
|
|
@@ -19797,12 +19915,17 @@ function toText(r) {
|
|
|
19797
19915
|
const out = [];
|
|
19798
19916
|
out.push(`${PRODUCT}: ${r.head.ref} (${short(r.head.sha)}) -> ${r.main.ref} (${short(r.main.sha)}), merge-base ${short(r.mergeBase)}`);
|
|
19799
19917
|
for (const x of r.roots) out.push(` checked ${x.framework} ${x.root}${x.touched ? " (changed)" : ""}`);
|
|
19918
|
+
if (!r.roots.length) {
|
|
19919
|
+
out.push(` nothing checked: no migrations found for a supported framework (${FRAMEWORKS.join(", ")})`);
|
|
19920
|
+
for (const u of r.unsupported ?? []) out.push(` found ${u}, which ${PRODUCT} does not read yet`);
|
|
19921
|
+
out.push(" if your migrations live elsewhere, set migrations.paths in .mainfast.yml");
|
|
19922
|
+
}
|
|
19800
19923
|
for (const f of r.findings) {
|
|
19801
19924
|
out.push(`${f.severity.toUpperCase()} ${f.framework} ${f.root} [${f.code}] ${f.message}`);
|
|
19802
19925
|
if (f.hint) out.push(` fix: ${f.hint}`);
|
|
19803
19926
|
}
|
|
19804
19927
|
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");
|
|
19928
|
+
out.push(r.ok ? r.roots.length ? "ok" : "ok (nothing checked)" : "FAILED");
|
|
19806
19929
|
return out.join("\n");
|
|
19807
19930
|
}
|
|
19808
19931
|
|
|
@@ -19849,7 +19972,7 @@ Resolved: migrations are consistent with ${mdCode(report.main.ref)} at ${report.
|
|
|
19849
19972
|
await o.gh.request("POST", `${base}/statuses/${report.head.sha}`, {
|
|
19850
19973
|
state,
|
|
19851
19974
|
context: STATUS_CONTEXT,
|
|
19852
|
-
description: (stale ? `${plural9(errors2, "migration error")} against ${report.main.ref}` : `Migrations consistent with ${report.main.ref}`).slice(0, 140),
|
|
19975
|
+
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
19976
|
target_url: o.targetUrl
|
|
19854
19977
|
});
|
|
19855
19978
|
result.status = state;
|
|
@@ -20256,7 +20379,14 @@ var OwnersApi = class {
|
|
|
20256
20379
|
* backoff, and at most `maxSearches` requests are made per run. undefined = not checked.
|
|
20257
20380
|
*/
|
|
20258
20381
|
reviewsSince(login, since) {
|
|
20259
|
-
return this.
|
|
20382
|
+
return this.searchCount("reviewed-by", login, since);
|
|
20383
|
+
}
|
|
20384
|
+
/** PRs in this repo the user opened that were updated since `since` (same search budget as reviewsSince). */
|
|
20385
|
+
authoredSince(login, since) {
|
|
20386
|
+
return this.searchCount("author", login, since);
|
|
20387
|
+
}
|
|
20388
|
+
searchCount(qualifier, login, since) {
|
|
20389
|
+
return this.memo(`${qualifier}:${login.toLowerCase()}:${since}`, async () => {
|
|
20260
20390
|
const s = this.search;
|
|
20261
20391
|
for (let attempt = 0; ; attempt++) {
|
|
20262
20392
|
if (s.stopped || s.made >= this.maxSearches) {
|
|
@@ -20272,7 +20402,7 @@ var OwnersApi = class {
|
|
|
20272
20402
|
if (wait > 0) await this.sleep(wait);
|
|
20273
20403
|
s.made++;
|
|
20274
20404
|
try {
|
|
20275
|
-
const q = `repo:${this.owner}/${this.repo} type:pr
|
|
20405
|
+
const q = `repo:${this.owner}/${this.repo} type:pr ${qualifier}:${login} updated:>=${since}`;
|
|
20276
20406
|
const r = await this.gh.request("GET", `/search/issues?q=${enc3(q)}&per_page=1`);
|
|
20277
20407
|
const remaining = Number(r.headers.get("x-ratelimit-remaining") ?? NaN);
|
|
20278
20408
|
const reset = Number(r.headers.get("x-ratelimit-reset") ?? NaN);
|
|
@@ -20466,6 +20596,7 @@ function configFromDoc2(doc) {
|
|
|
20466
20596
|
var plural11 = (n2, noun) => `${n2} ${noun}${n2 === 1 ? "" : "s"}`;
|
|
20467
20597
|
var FIXES = {
|
|
20468
20598
|
"unowned-files": "Add a CODEOWNERS line for these paths (see the suggested lines), or list them under `owners.ignore`.",
|
|
20599
|
+
"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
20600
|
"unknown-user": "The account was deleted or renamed: put the current login or a team in its place.",
|
|
20470
20601
|
"owner-left-org": "Remove the owner or replace them with a current member or team.",
|
|
20471
20602
|
"owner-no-write": "Give the owner write access (directly or through a team), or replace them; GitHub skips owners without write.",
|
|
@@ -20673,8 +20804,10 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20673
20804
|
const start = candidates.length ? week % candidates.length : 0;
|
|
20674
20805
|
const order = [...candidates.slice(start), ...candidates.slice(0, start)];
|
|
20675
20806
|
for (const st of order) {
|
|
20676
|
-
if (st.kind === "user")
|
|
20677
|
-
|
|
20807
|
+
if (st.kind === "user") {
|
|
20808
|
+
st.reviews = await api.reviewsSince(st.owner.slice(1), since);
|
|
20809
|
+
if (st.reviews === 0) st.authored = await api.authoredSince(st.owner.slice(1), since);
|
|
20810
|
+
} else {
|
|
20678
20811
|
const members2 = await api.teamMembers(st.owner.split("/")[1].toLowerCase());
|
|
20679
20812
|
let total2 = 0;
|
|
20680
20813
|
let complete = true;
|
|
@@ -20691,7 +20824,7 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20691
20824
|
function dormantFindings(co, statuses, days) {
|
|
20692
20825
|
const out = [];
|
|
20693
20826
|
for (const st of statuses) {
|
|
20694
|
-
if (st.reviews !== 0) continue;
|
|
20827
|
+
if (st.reviews !== 0 || (st.authored ?? 0) > 0) continue;
|
|
20695
20828
|
const lines = co.rules.filter((r) => r.owners.some((o) => key(o) === key(st.owner))).map((r) => r.line);
|
|
20696
20829
|
out.push({
|
|
20697
20830
|
code: st.kind === "team" ? "dormant-team" : "dormant-owner",
|
|
@@ -20699,7 +20832,7 @@ function dormantFindings(co, statuses, days) {
|
|
|
20699
20832
|
scope: "current",
|
|
20700
20833
|
owner: st.owner,
|
|
20701
20834
|
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`
|
|
20835
|
+
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
20836
|
});
|
|
20704
20837
|
}
|
|
20705
20838
|
return out;
|
|
@@ -20817,13 +20950,28 @@ async function auditOwners(input) {
|
|
|
20817
20950
|
}
|
|
20818
20951
|
findings.push(...pFindings);
|
|
20819
20952
|
report.ownedAfterMerge = report.unowned.filter((f) => (ruleFor(pco, f)?.owners ?? []).some(effective));
|
|
20953
|
+
const unownedFinding = findings.find((f) => f.code === "unowned-files" && f.scope === "current");
|
|
20954
|
+
if (unownedFinding && unownedFinding.severity === "error" && report.ownedAfterMerge.length) {
|
|
20955
|
+
const after = new Set(report.ownedAfterMerge);
|
|
20956
|
+
const still = report.unowned.filter((f) => !after.has(f));
|
|
20957
|
+
const ownedLater = report.unowned.filter((f) => after.has(f));
|
|
20958
|
+
findings.splice(findings.indexOf(unownedFinding), 1);
|
|
20959
|
+
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 });
|
|
20960
|
+
findings.push({
|
|
20961
|
+
code: "owned-after-merge",
|
|
20962
|
+
severity: "warning",
|
|
20963
|
+
scope: "current",
|
|
20964
|
+
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)`,
|
|
20965
|
+
paths: ownedLater
|
|
20966
|
+
});
|
|
20967
|
+
}
|
|
20820
20968
|
}
|
|
20821
20969
|
}
|
|
20822
20970
|
if (checker && api && untrusted) {
|
|
20823
20971
|
report.orgChecks = "untrusted-pr";
|
|
20824
20972
|
if (checker.publicOnly)
|
|
20825
20973
|
notes.push(
|
|
20826
|
-
`This PR comes from a fork
|
|
20974
|
+
`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
20975
|
);
|
|
20828
20976
|
report.owners = [...checker.statuses.values()];
|
|
20829
20977
|
} else if (checker && api) {
|
|
@@ -20876,11 +21024,10 @@ async function loadAudit(api, ref) {
|
|
|
20876
21024
|
return { ref, files: tree.paths, truncated: tree.truncated, codeowners: await codeownersAt(api, ref), notes: [] };
|
|
20877
21025
|
}
|
|
20878
21026
|
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
21027
|
function isTrustedPr(pr) {
|
|
20881
21028
|
const head = pr?.head?.repo?.full_name;
|
|
20882
21029
|
const base = pr?.base?.repo?.full_name;
|
|
20883
|
-
return Boolean(head && base && head.toLowerCase() === base.toLowerCase()
|
|
21030
|
+
return Boolean(head && base && head.toLowerCase() === base.toLowerCase());
|
|
20884
21031
|
}
|
|
20885
21032
|
async function loadPr(api, pr) {
|
|
20886
21033
|
const files = await api.prFiles(pr.number);
|
|
@@ -20973,7 +21120,7 @@ function toMarkdown2(r, o = {}) {
|
|
|
20973
21120
|
);
|
|
20974
21121
|
out.push("");
|
|
20975
21122
|
}
|
|
20976
|
-
const current = r.findings.filter((f) => f.scope === "current" && !(r.mode === "pr" && f.code === "unowned-files"));
|
|
21123
|
+
const current = r.findings.filter((f) => f.scope === "current" && !(r.mode === "pr" && (f.code === "unowned-files" || f.code === "owned-after-merge")));
|
|
20977
21124
|
if (current.length) out.push(...table(current), "");
|
|
20978
21125
|
if (r.proposed) {
|
|
20979
21126
|
const proposed = r.findings.filter((f) => f.scope === "proposed");
|
|
@@ -20994,7 +21141,7 @@ function toText2(r) {
|
|
|
20994
21141
|
const out = [t(`${PRODUCT2}: ${r.repository}${r.pr ? ` #${r.pr}` : ""} \u2014 ${headline2(r)}`)];
|
|
20995
21142
|
for (const f of r.findings) {
|
|
20996
21143
|
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)}`);
|
|
21144
|
+
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
21145
|
if (f.hint) out.push(t(` fix: ${f.hint}`));
|
|
20999
21146
|
}
|
|
21000
21147
|
for (const n2 of r.notes) out.push(t(`note: ${n2}`));
|
|
@@ -21176,7 +21323,7 @@ var ISSUE_MARKER = P5.commentMarker;
|
|
|
21176
21323
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
21177
21324
|
var PR_EVENTS = ["pull_request", "pull_request_target", "merge_group"];
|
|
21178
21325
|
var escapeRe3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21179
|
-
function
|
|
21326
|
+
function list5(v) {
|
|
21180
21327
|
if (v === void 0 || v === null) return void 0;
|
|
21181
21328
|
return (Array.isArray(v) ? v : [v]).map(String);
|
|
21182
21329
|
}
|
|
@@ -21190,11 +21337,11 @@ function triggers(on) {
|
|
|
21190
21337
|
const c = cfg ?? {};
|
|
21191
21338
|
out.push({
|
|
21192
21339
|
event,
|
|
21193
|
-
paths:
|
|
21194
|
-
pathsIgnore:
|
|
21195
|
-
branches:
|
|
21196
|
-
branchesIgnore:
|
|
21197
|
-
types:
|
|
21340
|
+
paths: list5(c.paths),
|
|
21341
|
+
pathsIgnore: list5(c["paths-ignore"]),
|
|
21342
|
+
branches: list5(c.branches),
|
|
21343
|
+
branchesIgnore: list5(c["branches-ignore"]),
|
|
21344
|
+
types: list5(c.types)
|
|
21198
21345
|
});
|
|
21199
21346
|
}
|
|
21200
21347
|
return out;
|
|
@@ -21351,7 +21498,7 @@ function parseWorkflow(file) {
|
|
|
21351
21498
|
reusable,
|
|
21352
21499
|
opaque,
|
|
21353
21500
|
if: j.if === void 0 ? void 0 : String(j.if),
|
|
21354
|
-
needs:
|
|
21501
|
+
needs: list5(j.needs) ?? []
|
|
21355
21502
|
});
|
|
21356
21503
|
}
|
|
21357
21504
|
return { path: file.path, name, prTriggers: triggers(on), events: eventsOf(on), callableOnly: isCallableOnly(on), jobs };
|
|
@@ -21603,9 +21750,9 @@ function audit(s, opts = {}) {
|
|
|
21603
21750
|
}
|
|
21604
21751
|
}
|
|
21605
21752
|
} else if (pulls.length) {
|
|
21606
|
-
const missingStreak = (
|
|
21753
|
+
const missingStreak = (list6) => {
|
|
21607
21754
|
let n2 = 0;
|
|
21608
|
-
for (const x of
|
|
21755
|
+
for (const x of list6) {
|
|
21609
21756
|
if (!missingAt.has(x.p.number)) break;
|
|
21610
21757
|
n2++;
|
|
21611
21758
|
}
|
|
@@ -22090,8 +22237,8 @@ function parseReport(r) {
|
|
|
22090
22237
|
// src/commands.ts
|
|
22091
22238
|
var AUDIT_CHECKS = ["rollcall", "owners", "migrations", "evidence"];
|
|
22092
22239
|
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.",
|
|
22240
|
+
rollcall: "A GitHub origin remote. A private repository also needs GITHUB_TOKEN or GH_TOKEN. No checkout and no administration permission needed.",
|
|
22241
|
+
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
22242
|
migrations: "A checkout with the main branch fetched. No token needed.",
|
|
22096
22243
|
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
22244
|
};
|
|
@@ -22146,8 +22293,54 @@ async function runAudit(o) {
|
|
|
22146
22293
|
}
|
|
22147
22294
|
|
|
22148
22295
|
// src/init.ts
|
|
22296
|
+
var import_node_fs12 = require("node:fs");
|
|
22297
|
+
var import_node_path9 = require("node:path");
|
|
22298
|
+
|
|
22299
|
+
// src/facts.ts
|
|
22149
22300
|
var import_node_fs11 = require("node:fs");
|
|
22150
22301
|
var import_node_path8 = require("node:path");
|
|
22302
|
+
var kindOf = (root, f) => {
|
|
22303
|
+
try {
|
|
22304
|
+
return repoPathKind(root, f);
|
|
22305
|
+
} catch {
|
|
22306
|
+
return "unsafe";
|
|
22307
|
+
}
|
|
22308
|
+
};
|
|
22309
|
+
var codeownersIn = (root) => [".github/CODEOWNERS", "CODEOWNERS", "docs/CODEOWNERS"].find((f) => kindOf(root, f) === "file") ?? null;
|
|
22310
|
+
function otherWorkflowNames(root) {
|
|
22311
|
+
const rel = ".github/workflows";
|
|
22312
|
+
if (kindOf(root, rel) !== "directory") return [];
|
|
22313
|
+
const names = [];
|
|
22314
|
+
for (const f of (0, import_node_fs11.readdirSync)((0, import_node_path8.join)(root, rel)).sort()) {
|
|
22315
|
+
if (!/\.ya?ml$/.test(f) || f.startsWith(`${SUITE.githubOrg}-`)) continue;
|
|
22316
|
+
let text;
|
|
22317
|
+
try {
|
|
22318
|
+
text = readRepoFile(root, `${rel}/${f}`);
|
|
22319
|
+
} catch {
|
|
22320
|
+
continue;
|
|
22321
|
+
}
|
|
22322
|
+
const name = text?.match(/^name:[ \t]*(['"]?)([^'"\n#]+?)\1[ \t]*(#.*)?$/m)?.[2]?.trim();
|
|
22323
|
+
names.push(name || f.replace(/\.ya?ml$/, ""));
|
|
22324
|
+
}
|
|
22325
|
+
return names;
|
|
22326
|
+
}
|
|
22327
|
+
function migrationsFacts(root) {
|
|
22328
|
+
let tree;
|
|
22329
|
+
try {
|
|
22330
|
+
tree = Tree.atRef(root, "HEAD");
|
|
22331
|
+
} catch {
|
|
22332
|
+
return void 0;
|
|
22333
|
+
}
|
|
22334
|
+
let config2 = parseConfig2(void 0);
|
|
22335
|
+
try {
|
|
22336
|
+
const text = readRepoFile(root, SUITE.configFile) ?? readRepoFile(root, SUITE.configFileAlt);
|
|
22337
|
+
config2 = parseConfig2(text);
|
|
22338
|
+
} catch {
|
|
22339
|
+
}
|
|
22340
|
+
const roots = discoverRoots(tree, tree, config2);
|
|
22341
|
+
return { roots, unsupported: roots.length ? [] : unsupportedTools(tree.files()) };
|
|
22342
|
+
}
|
|
22343
|
+
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
22344
|
|
|
22152
22345
|
// raw:../evidence/examples/workflows/evidence.yml
|
|
22153
22346
|
var evidence_default = `# Copy to .github/workflows/mainfast-evidence.yml.
|
|
@@ -22163,7 +22356,7 @@ var evidence_default = `# Copy to .github/workflows/mainfast-evidence.yml.
|
|
|
22163
22356
|
# artifact is data the PR's CI run produced: parsed, never executed.
|
|
22164
22357
|
# Make the "Mainfast Evidence" check required in your ruleset to gate merges on it.
|
|
22165
22358
|
# Never put \${{ github.event.* }} text (branch names, titles, commit messages) into a \`run:\` step.
|
|
22166
|
-
name: Evidence
|
|
22359
|
+
name: Mainfast Evidence
|
|
22167
22360
|
|
|
22168
22361
|
on:
|
|
22169
22362
|
pull_request:
|
|
@@ -22228,19 +22421,47 @@ jobs:
|
|
|
22228
22421
|
`;
|
|
22229
22422
|
|
|
22230
22423
|
// raw:../intact/examples/mainfast-intact.yml
|
|
22231
|
-
var mainfast_intact_default =
|
|
22424
|
+
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
22425
|
|
|
22233
22426
|
// raw:../migrations/examples/mainfast-migrations.yml
|
|
22234
22427
|
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
22428
|
|
|
22236
22429
|
// raw:../owners/examples/owners.yml
|
|
22237
|
-
var owners_default =
|
|
22430
|
+
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
22431
|
|
|
22239
22432
|
// 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:
|
|
22433
|
+
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';
|
|
22434
|
+
|
|
22435
|
+
// src/pins.json
|
|
22436
|
+
var pins_default = {
|
|
22437
|
+
_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).",
|
|
22438
|
+
version: "0.3.0",
|
|
22439
|
+
actions: {
|
|
22440
|
+
intact: "1dbf7a47069256a308403f6a9174f20763e8cd1b",
|
|
22441
|
+
migrations: "8a4e8ffb5618166d0fc501ce2ef1522e8975df02",
|
|
22442
|
+
rollcall: "e2fc735bb4319a09a9e1ab1b626aba887e9a773e",
|
|
22443
|
+
owners: "c292e89c2febe1d35746d1c0410d0e0887ef7548",
|
|
22444
|
+
evidence: "7e1487a5b915eb6d06197c16f5390ccd412d14a6"
|
|
22445
|
+
}
|
|
22446
|
+
};
|
|
22241
22447
|
|
|
22242
22448
|
// src/templates.ts
|
|
22243
|
-
var
|
|
22449
|
+
var PINS = pins_default;
|
|
22450
|
+
function pinWorkflow(slug, text, pin = { version: PINS.version, sha: PINS.actions[slug] }) {
|
|
22451
|
+
const action = product(slug).actionRef.split("@")[0];
|
|
22452
|
+
if (!/^[0-9a-f]{40}$/.test(pin.sha)) throw new Error(`pins.json: ${slug} is not a full commit SHA`);
|
|
22453
|
+
const re = new RegExp(`^([ \\t]*)(- )?uses: ${action.replace(/[/.]/g, "\\$&")}@v\\d+[ \\t]*$`, "gm");
|
|
22454
|
+
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.
|
|
22455
|
+
${indent}${dash}uses: ${action}@${pin.sha} # v${pin.version}`);
|
|
22456
|
+
}
|
|
22457
|
+
var prepare = (slug, text) => pinWorkflow(slug, text.replace(/^# Copy to [^\n]*\n/, ""));
|
|
22458
|
+
var WORKFLOWS = {
|
|
22459
|
+
intact: prepare("intact", mainfast_intact_default),
|
|
22460
|
+
migrations: prepare("migrations", mainfast_migrations_default),
|
|
22461
|
+
rollcall: prepare("rollcall", rollcall_default),
|
|
22462
|
+
owners: prepare("owners", owners_default),
|
|
22463
|
+
evidence: prepare("evidence", evidence_default)
|
|
22464
|
+
};
|
|
22244
22465
|
var workflowPath = (slug) => `.github/workflows/${SUITE.githubOrg}-${slug}.yml`;
|
|
22245
22466
|
var STARTER_CONFIG = `# yaml-language-server: $schema=${SUITE.schemaUrl}
|
|
22246
22467
|
# One optional section per check. Defaults apply to any check without one.
|
|
@@ -22254,7 +22475,7 @@ function installedIn(root, slug) {
|
|
|
22254
22475
|
const rel = ".github/workflows";
|
|
22255
22476
|
if (repoPathKind(root, rel) !== "directory") return [];
|
|
22256
22477
|
const action = product(slug).actionRef.split("@")[0];
|
|
22257
|
-
return (0,
|
|
22478
|
+
return (0, import_node_fs12.readdirSync)((0, import_node_path9.join)(root, rel)).filter((f) => /\.ya?ml$/.test(f)).filter((f) => {
|
|
22258
22479
|
try {
|
|
22259
22480
|
return readRepoFile(root, `${rel}/${f}`)?.includes(`uses: ${action}@`) ?? false;
|
|
22260
22481
|
} catch {
|
|
@@ -22262,14 +22483,29 @@ function installedIn(root, slug) {
|
|
|
22262
22483
|
}
|
|
22263
22484
|
}).map((f) => `${rel}/${f}`);
|
|
22264
22485
|
}
|
|
22265
|
-
function nextSteps(slugs) {
|
|
22486
|
+
function nextSteps(root, slugs) {
|
|
22266
22487
|
const steps = ["Review the new files, commit them and open a pull request. Nothing has been pushed."];
|
|
22267
|
-
const required2 =
|
|
22488
|
+
const required2 = [];
|
|
22489
|
+
if (slugs.includes("owners")) required2.push(`"${product("owners").checkName}" (or the job "owners")`);
|
|
22490
|
+
if (slugs.includes("evidence")) required2.push(`"${product("evidence").checkName}"`);
|
|
22268
22491
|
if (slugs.includes("migrations")) required2.push(`"${product("migrations").statusContext ?? "mainfast/migrations"}"`);
|
|
22269
22492
|
if (required2.length) steps.push(`To block merges on findings, make ${required2.join(", ")} required in branch protection or a ruleset.`);
|
|
22270
|
-
if (slugs.includes("
|
|
22493
|
+
if (slugs.includes("intact"))
|
|
22494
|
+
steps.push(
|
|
22495
|
+
`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).`
|
|
22496
|
+
);
|
|
22497
|
+
if (slugs.includes("evidence")) {
|
|
22498
|
+
const names = otherWorkflowNames(root);
|
|
22499
|
+
if (!names.includes("CI"))
|
|
22500
|
+
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(", ")})` : ""}.`);
|
|
22501
|
+
}
|
|
22271
22502
|
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.");
|
|
22503
|
+
if (slugs.includes("owners") && !codeownersIn(root)) steps.push("Owners needs a CODEOWNERS file; until you add one, every run reports it as missing.");
|
|
22504
|
+
if (slugs.includes("migrations")) {
|
|
22505
|
+
const m = migrationsFacts(root);
|
|
22506
|
+
if (m && !m.roots.length) steps.push(nothingToMigrate(m));
|
|
22507
|
+
}
|
|
22508
|
+
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
22509
|
return steps;
|
|
22274
22510
|
}
|
|
22275
22511
|
function runInit(opts) {
|
|
@@ -22283,13 +22519,13 @@ function runInit(opts) {
|
|
|
22283
22519
|
const skipped = [];
|
|
22284
22520
|
const place = (rel, content) => {
|
|
22285
22521
|
const current = readRepoFile(root, rel);
|
|
22286
|
-
const abs = (0,
|
|
22522
|
+
const abs = (0, import_node_path9.join)(root, rel);
|
|
22287
22523
|
const exists = current !== void 0;
|
|
22288
22524
|
if (current === content) return void unchanged.push(rel);
|
|
22289
22525
|
if (exists && !opts.force) return void skipped.push({ path: rel, reason: "exists with different content; use --force to replace it" });
|
|
22290
22526
|
if (!opts.dryRun) {
|
|
22291
|
-
(0,
|
|
22292
|
-
(0,
|
|
22527
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path9.dirname)(abs), { recursive: true });
|
|
22528
|
+
(0, import_node_fs12.writeFileSync)(abs, content);
|
|
22293
22529
|
}
|
|
22294
22530
|
(exists ? overwritten : written).push(rel);
|
|
22295
22531
|
};
|
|
@@ -22301,8 +22537,9 @@ function runInit(opts) {
|
|
|
22301
22537
|
}
|
|
22302
22538
|
if (repoPathKind(root, SUITE.configFileAlt)) skipped.push({ path: SUITE.configFile, reason: `${SUITE.configFileAlt} already exists` });
|
|
22303
22539
|
else place(SUITE.configFile, STARTER_CONFIG);
|
|
22304
|
-
const steps = nextSteps(slugs);
|
|
22305
|
-
const
|
|
22540
|
+
const steps = nextSteps(root, slugs);
|
|
22541
|
+
const files = opts.dryRun ? { written: [], overwritten: [], would_write: written, would_overwrite: overwritten } : { written, overwritten };
|
|
22542
|
+
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
22543
|
const verb = opts.dryRun ? "would write" : "wrote";
|
|
22307
22544
|
const lines = [
|
|
22308
22545
|
...written.map((f) => `${verb} ${f}`),
|
|
@@ -22318,6 +22555,24 @@ function runInit(opts) {
|
|
|
22318
22555
|
}
|
|
22319
22556
|
|
|
22320
22557
|
// src/doctor.ts
|
|
22558
|
+
function sectionProblems(text, path) {
|
|
22559
|
+
const out = [];
|
|
22560
|
+
const parsers = [
|
|
22561
|
+
["intact", (t) => parseConfig(t, path)],
|
|
22562
|
+
["migrations", parseConfig2],
|
|
22563
|
+
["rollcall", parseConfig4],
|
|
22564
|
+
["owners", parseConfig3]
|
|
22565
|
+
];
|
|
22566
|
+
for (const [slug, parse4] of parsers) {
|
|
22567
|
+
try {
|
|
22568
|
+
parse4(text);
|
|
22569
|
+
} catch (e) {
|
|
22570
|
+
out.push(`${slug}: ${e instanceof Error ? e.message : String(e)}`);
|
|
22571
|
+
}
|
|
22572
|
+
}
|
|
22573
|
+
out.push(...parsePolicy(text).warnings.map((w) => `evidence: ${w}`));
|
|
22574
|
+
return out;
|
|
22575
|
+
}
|
|
22321
22576
|
function runDoctor(dir) {
|
|
22322
22577
|
const root = repoRoot(dir);
|
|
22323
22578
|
const missing = [];
|
|
@@ -22337,18 +22592,21 @@ function runDoctor(dir) {
|
|
|
22337
22592
|
return [s, { installed: files.length > 0, files }];
|
|
22338
22593
|
}));
|
|
22339
22594
|
const installed = PRODUCT_SLUGS.filter((s) => checks[s].installed);
|
|
22340
|
-
const
|
|
22595
|
+
const kindOf2 = (f) => {
|
|
22341
22596
|
try {
|
|
22342
22597
|
return repoPathKind(root, f);
|
|
22343
22598
|
} catch {
|
|
22344
22599
|
return "unsafe";
|
|
22345
22600
|
}
|
|
22346
22601
|
};
|
|
22347
|
-
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) =>
|
|
22602
|
+
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) => kindOf2(f));
|
|
22348
22603
|
let config2 = { path: path ?? null, ok: true };
|
|
22349
22604
|
if (path) {
|
|
22350
22605
|
try {
|
|
22351
|
-
|
|
22606
|
+
const text = readRepoFile(root, path);
|
|
22607
|
+
parseConfigDoc(text, path);
|
|
22608
|
+
const problems = text ? sectionProblems(text, path) : [];
|
|
22609
|
+
if (problems.length) throw new Error(problems.join("; "));
|
|
22352
22610
|
} catch (e) {
|
|
22353
22611
|
config2 = { path, ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
22354
22612
|
missing.push(`${path} cannot be used: ${config2.error}`);
|
|
@@ -22356,16 +22614,18 @@ function runDoctor(dir) {
|
|
|
22356
22614
|
}
|
|
22357
22615
|
const token = githubToken();
|
|
22358
22616
|
const repo = githubRepo(root) ?? null;
|
|
22359
|
-
const codeowners =
|
|
22617
|
+
const codeowners = codeownersIn(root);
|
|
22618
|
+
const migrations2 = installed.includes("migrations") ? migrationsFacts(root) : void 0;
|
|
22360
22619
|
if (!installed.length && workflowsOk) missing.push("No checks are installed. Run: mainfast init");
|
|
22361
22620
|
if (!repo) missing.push("No GitHub origin remote, so audit cannot read the repository through the GitHub API.");
|
|
22362
22621
|
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.");
|
|
22622
|
+
if (migrations2 && !migrations2.roots.length) missing.push(nothingToMigrate(migrations2));
|
|
22363
22623
|
if (installed.includes("owners") && !codeowners) missing.push("Owners is installed but there is no CODEOWNERS file. Add .github/CODEOWNERS.");
|
|
22364
22624
|
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() };
|
|
22625
|
+
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
22626
|
const lines = [
|
|
22367
22627
|
...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}
|
|
22628
|
+
`config ${path ? config2.ok ? `${path} parses, every section valid` : `${path} has errors` : "none (defaults apply)"}`,
|
|
22369
22629
|
`token ${token ? `set (${token.name})` : "not set"}`,
|
|
22370
22630
|
...missing.length ? ["", "To do:", ...missing.map((m) => `- ${m}`)] : []
|
|
22371
22631
|
];
|
|
@@ -22373,8 +22633,8 @@ function runDoctor(dir) {
|
|
|
22373
22633
|
}
|
|
22374
22634
|
|
|
22375
22635
|
// src/mcp.ts
|
|
22376
|
-
var
|
|
22377
|
-
var
|
|
22636
|
+
var import_node_fs13 = require("node:fs");
|
|
22637
|
+
var import_node_path10 = require("node:path");
|
|
22378
22638
|
var import_node_url = require("node:url");
|
|
22379
22639
|
|
|
22380
22640
|
// ../node_modules/zod/v4/core/util.js
|
|
@@ -27277,8 +27537,8 @@ var contributors = {
|
|
|
27277
27537
|
function aggregateChecks(schema) {
|
|
27278
27538
|
const agg = {};
|
|
27279
27539
|
const def = schema._zod.def;
|
|
27280
|
-
const
|
|
27281
|
-
for (const ch of
|
|
27540
|
+
const list6 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
27541
|
+
for (const ch of list6)
|
|
27282
27542
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
27283
27543
|
const bag = schema._zod.bag;
|
|
27284
27544
|
if (bag.minimum !== void 0)
|
|
@@ -32221,17 +32481,17 @@ var TOOLS = [
|
|
|
32221
32481
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
32222
32482
|
}
|
|
32223
32483
|
];
|
|
32224
|
-
var inside = (base, path) => path === base || path.startsWith(base.endsWith(
|
|
32484
|
+
var inside = (base, path) => path === base || path.startsWith(base.endsWith(import_node_path10.sep) ? base : base + import_node_path10.sep);
|
|
32225
32485
|
function allowedBases(cwd, roots) {
|
|
32226
|
-
let own2 = (0,
|
|
32486
|
+
let own2 = (0, import_node_fs13.realpathSync)(cwd);
|
|
32227
32487
|
try {
|
|
32228
|
-
own2 = (0,
|
|
32488
|
+
own2 = (0, import_node_fs13.realpathSync)(repoRoot(cwd));
|
|
32229
32489
|
} catch {
|
|
32230
32490
|
}
|
|
32231
32491
|
const out = [own2];
|
|
32232
32492
|
for (const uri of roots) {
|
|
32233
32493
|
try {
|
|
32234
|
-
out.push((0,
|
|
32494
|
+
out.push((0, import_node_fs13.realpathSync)((0, import_node_url.fileURLToPath)(uri)));
|
|
32235
32495
|
} catch {
|
|
32236
32496
|
}
|
|
32237
32497
|
}
|
|
@@ -32242,11 +32502,11 @@ function checkRepoPath(given, cwd, roots) {
|
|
|
32242
32502
|
const bases = allowedBases(cwd, roots);
|
|
32243
32503
|
let real;
|
|
32244
32504
|
try {
|
|
32245
|
-
real = (0,
|
|
32505
|
+
real = (0, import_node_fs13.realpathSync)((0, import_node_path10.resolve)(cwd, given));
|
|
32246
32506
|
} catch {
|
|
32247
32507
|
throw new CliError(`repo_path does not exist: ${given}`);
|
|
32248
32508
|
}
|
|
32249
|
-
const top = (0,
|
|
32509
|
+
const top = (0, import_node_fs13.realpathSync)(repoRoot(real));
|
|
32250
32510
|
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
32511
|
return real;
|
|
32252
32512
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mainfast",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|