mainfast 0.1.3 → 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/LICENSE +105 -21
- package/README.md +8 -2
- package/dist/mainfast.cjs +472 -154
- package/package.json +19 -3
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,9 +14595,23 @@ 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
|
-
|
|
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
|
+
],
|
|
14614
|
+
license: "FSL-1.1-ALv2",
|
|
14601
14615
|
author: "Mainfast authors",
|
|
14602
14616
|
type: "module",
|
|
14603
14617
|
engines: {
|
|
@@ -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",
|
|
@@ -14694,13 +14710,14 @@ var import_yaml = __toESM(require_dist(), 1);
|
|
|
14694
14710
|
|
|
14695
14711
|
// ../brand.json
|
|
14696
14712
|
var brand_default = {
|
|
14697
|
-
_comment: "Single source of every brand string in the Mainfast suite. Edit here, then run `npm run brand:sync` at the suite root: it rewrites each package's action.yml, package.json,
|
|
14713
|
+
_comment: "Single source of every brand string in the Mainfast suite. Edit here, then run `npm run brand:sync` at the suite root: it rewrites each package's action.yml, package.json, LICENSE pointer and example workflows. TypeScript reads this file directly through @mainfast/shared/brand. Prose (README.md, docs/, prompts/) is not rewritten: grep for the old value after a rename. `npm run brand:check` (and test/brand.test.ts) fails when a generated file drifts.",
|
|
14698
14714
|
suite: {
|
|
14699
14715
|
name: "Mainfast",
|
|
14700
14716
|
version: "0.1.0",
|
|
14701
14717
|
author: "Mainfast authors",
|
|
14702
14718
|
copyrightYear: "2026",
|
|
14703
|
-
license: "
|
|
14719
|
+
license: "FSL-1.1-ALv2",
|
|
14720
|
+
licenseUrl: "https://github.com/mainfast/mainfast/blob/main/LICENSE",
|
|
14704
14721
|
githubOrg: "mainfast",
|
|
14705
14722
|
githubRepo: "mainfast",
|
|
14706
14723
|
homepageUrl: "https://github.com/mainfast/mainfast",
|
|
@@ -14713,26 +14730,7 @@ var brand_default = {
|
|
|
14713
14730
|
configFile: ".mainfast.yml",
|
|
14714
14731
|
configFileAlt: ".mainfast.yaml",
|
|
14715
14732
|
schemaUrl: "https://raw.githubusercontent.com/mainfast/mainfast/main/schema/mainfast.schema.json",
|
|
14716
|
-
envPrefix: "MAINFAST"
|
|
14717
|
-
licenseEnv: "MAINFAST_LICENSE",
|
|
14718
|
-
plan: {
|
|
14719
|
-
freeActiveContributors: 5,
|
|
14720
|
-
windowDays: 30,
|
|
14721
|
-
proPricePerContributorMonth: "$4",
|
|
14722
|
-
_benefitIds: "Polar license-key benefit id of each plan: a key whose benefit_id is `pro` is Mainfast Pro; `free` is the optional free key (registered user, not Pro).",
|
|
14723
|
-
benefitIds: {
|
|
14724
|
-
free: "656e762a-ec6e-4e94-b7fd-f7ff879061ca",
|
|
14725
|
-
pro: "ea9b4fcb-3659-404e-bb62-9bec84fb119a"
|
|
14726
|
-
}
|
|
14727
|
-
},
|
|
14728
|
-
polar: {
|
|
14729
|
-
_comment: "License keys are checked with Polar's public customer-portal endpoint POST {api}/v1/customer-portal/license-keys/validate {key, organization_id}: no merchant secret. These are the live Polar values. While organizationId is all zeros no key is sent anywhere. apiEnv / orgEnv override both, e.g. the sandbox.",
|
|
14730
|
-
api: "https://api.polar.sh",
|
|
14731
|
-
organizationId: "3a0d763f-8fac-4df0-898a-a59eb60d3506",
|
|
14732
|
-
apiEnv: "MAINFAST_POLAR_API",
|
|
14733
|
-
orgEnv: "MAINFAST_POLAR_ORG",
|
|
14734
|
-
timeoutMs: 3e3
|
|
14735
|
-
}
|
|
14733
|
+
envPrefix: "MAINFAST"
|
|
14736
14734
|
},
|
|
14737
14735
|
products: {
|
|
14738
14736
|
intact: {
|
|
@@ -14750,7 +14748,7 @@ var brand_default = {
|
|
|
14750
14748
|
migrations: {
|
|
14751
14749
|
productName: "Mainfast Migrations",
|
|
14752
14750
|
tagline: "database migration guard",
|
|
14753
|
-
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.",
|
|
14754
14752
|
npmName: "@mainfast/migrations",
|
|
14755
14753
|
cliName: "mainfast-migrations",
|
|
14756
14754
|
configSection: "migrations",
|
|
@@ -14764,7 +14762,7 @@ var brand_default = {
|
|
|
14764
14762
|
rollcall: {
|
|
14765
14763
|
productName: "Mainfast Rollcall",
|
|
14766
14764
|
tagline: "required-check integrity audit",
|
|
14767
|
-
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.",
|
|
14768
14766
|
npmName: "@mainfast/rollcall",
|
|
14769
14767
|
cliName: "mainfast-rollcall",
|
|
14770
14768
|
configSection: "rollcall",
|
|
@@ -14776,7 +14774,7 @@ var brand_default = {
|
|
|
14776
14774
|
owners: {
|
|
14777
14775
|
productName: "Mainfast Owners",
|
|
14778
14776
|
tagline: "CODEOWNERS drift check",
|
|
14779
|
-
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.",
|
|
14780
14778
|
npmName: "@mainfast/owners",
|
|
14781
14779
|
cliName: "mainfast-owners",
|
|
14782
14780
|
configSection: "owners",
|
|
@@ -14788,7 +14786,7 @@ var brand_default = {
|
|
|
14788
14786
|
evidence: {
|
|
14789
14787
|
productName: "Mainfast Evidence",
|
|
14790
14788
|
tagline: "proof, not review, for pull requests written by coding agents",
|
|
14791
|
-
description: "
|
|
14789
|
+
description: "For pull requests written by coding agents: checks that tests ran and passed on the head commit and were not weakened.",
|
|
14792
14790
|
npmName: "@mainfast/evidence",
|
|
14793
14791
|
cliName: "mainfast-evidence",
|
|
14794
14792
|
configSection: "evidence",
|
|
@@ -15085,7 +15083,7 @@ var package_default2 = {
|
|
|
15085
15083
|
version: "0.1.0",
|
|
15086
15084
|
private: true,
|
|
15087
15085
|
description: "Mainfast Evidence: proof, not review, for pull requests written by coding agents.",
|
|
15088
|
-
license: "
|
|
15086
|
+
license: "FSL-1.1-ALv2",
|
|
15089
15087
|
author: "Mainfast authors",
|
|
15090
15088
|
type: "module",
|
|
15091
15089
|
engines: {
|
|
@@ -15449,9 +15447,9 @@ function rulesetTargetsBranch(r, branch, defaultBranch) {
|
|
|
15449
15447
|
function resolveRequiredChecks(input) {
|
|
15450
15448
|
const byContext = /* @__PURE__ */ new Map();
|
|
15451
15449
|
const add = (context, src) => {
|
|
15452
|
-
const
|
|
15453
|
-
|
|
15454
|
-
byContext.set(context,
|
|
15450
|
+
const list6 = byContext.get(context) ?? [];
|
|
15451
|
+
list6.push(src);
|
|
15452
|
+
byContext.set(context, list6);
|
|
15455
15453
|
};
|
|
15456
15454
|
const names = new Map((input.rulesets ?? []).map((r) => [r.id, r.name]));
|
|
15457
15455
|
let rulesetStrict;
|
|
@@ -15528,8 +15526,8 @@ async function fetchRequiredSources(gh, owner, repo, branch, opts = {}) {
|
|
|
15528
15526
|
const branchRules = await soft(notes, `GET ${base}/rules/branches/${branch}`, () => gh.paginate(`${base}/rules/branches/${b}?per_page=100`), []);
|
|
15529
15527
|
const rulesets = [];
|
|
15530
15528
|
if (opts.rulesets !== false) {
|
|
15531
|
-
const
|
|
15532
|
-
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) {
|
|
15533
15531
|
if (r.target && r.target !== "branch") continue;
|
|
15534
15532
|
rulesets.push(await soft(notes, `GET ${base}/rulesets/${r.id}`, () => gh.get(`${base}/rulesets/${r.id}?includes_parents=true`), r));
|
|
15535
15533
|
}
|
|
@@ -16153,16 +16151,17 @@ var AGENT_CATALOG = [
|
|
|
16153
16151
|
bodyMarkers: [/\b(?:app|preview)\.devin\.ai\/sessions\//i, /\blink to devin run\b/i]
|
|
16154
16152
|
},
|
|
16155
16153
|
{
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16154
|
+
// Dawnfix: its fix job opens draft PRs from `dawnfix/<fingerprint>` branches.
|
|
16155
|
+
id: "dawnfix",
|
|
16156
|
+
name: "Dawnfix",
|
|
16157
|
+
logins: ["dawnfix[bot]"],
|
|
16158
|
+
branchPrefixes: ["dawnfix/"],
|
|
16159
|
+
trailers: [/^co-authored-by:\s*dawnfix\b/im],
|
|
16161
16160
|
emails: [],
|
|
16162
16161
|
bodyMarkers: []
|
|
16163
16162
|
},
|
|
16164
16163
|
{
|
|
16165
|
-
// UNVERIFIED
|
|
16164
|
+
// UNVERIFIED: the aider/ branch prefix and both trailer forms.
|
|
16166
16165
|
id: "aider",
|
|
16167
16166
|
name: "Aider",
|
|
16168
16167
|
logins: [],
|
|
@@ -16510,18 +16509,18 @@ function evaluateTamper(files, policy) {
|
|
|
16510
16509
|
};
|
|
16511
16510
|
const addedTestCases = testStats.reduce((n2, s) => n2 + s.casesAdded, 0);
|
|
16512
16511
|
const findings = [];
|
|
16513
|
-
const
|
|
16512
|
+
const list6 = (xs) => xs.map((x) => `\`${x}\``).join(", ");
|
|
16514
16513
|
if (touched2.workflows.length)
|
|
16515
|
-
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.` });
|
|
16516
16515
|
if (touched2.codeowners.length)
|
|
16517
|
-
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.` });
|
|
16518
16517
|
if (touched2.policy.length)
|
|
16519
|
-
findings.push({ id: "touched_policy", title: "Evidence policy file changed", detail: `${
|
|
16520
|
-
if (touched2.lockfiles.length) findings.push({ id: "touched_lockfiles", title: "Lockfiles changed", detail:
|
|
16521
|
-
if (touched2.tests.length) findings.push({ id: "touched_tests", title: "Existing tests changed (lines removed, renamed or deleted)", detail:
|
|
16522
|
-
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) });
|
|
16523
16522
|
const deleted = tests.filter((f) => f.status === "removed").map((f) => f.path);
|
|
16524
|
-
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) });
|
|
16525
16524
|
const perFile = (pick2) => testStats.filter((s) => pick2(s) < 0).map((s) => `\`${s.path}\` (${pick2(s)})`).join(", ");
|
|
16526
16525
|
if (net.cases < 0)
|
|
16527
16526
|
findings.push({
|
|
@@ -16549,7 +16548,7 @@ function evaluateTamper(files, policy) {
|
|
|
16549
16548
|
findings.push({
|
|
16550
16549
|
id: "diff_unanalyzed",
|
|
16551
16550
|
title: "Some files could not be analyzed",
|
|
16552
|
-
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.`
|
|
16553
16552
|
});
|
|
16554
16553
|
return { touched: touched2, testStats, net, addedTestCases, unanalyzed, findings };
|
|
16555
16554
|
}
|
|
@@ -16632,7 +16631,7 @@ var FLAG_FIXES = {
|
|
|
16632
16631
|
// ../evidence/src/github/api.ts
|
|
16633
16632
|
var enc2 = encodeURIComponent;
|
|
16634
16633
|
var RestClient = class {
|
|
16635
|
-
/** The shared transport, for callers that need plain REST
|
|
16634
|
+
/** The shared transport, for callers that need plain REST. */
|
|
16636
16635
|
gh;
|
|
16637
16636
|
constructor(token, opts = {}) {
|
|
16638
16637
|
this.gh = new GitHub({ token, apiUrl: opts.baseUrl ?? DEFAULT_API_URL, userAgent: USER_AGENT, fetch: opts.fetch });
|
|
@@ -18483,7 +18482,7 @@ var package_default3 = {
|
|
|
18483
18482
|
version: "0.1.0",
|
|
18484
18483
|
private: true,
|
|
18485
18484
|
description: "Mainfast Intact: prove merge commits did not silently drop changes from main.",
|
|
18486
|
-
license: "
|
|
18485
|
+
license: "FSL-1.1-ALv2",
|
|
18487
18486
|
author: "Mainfast authors",
|
|
18488
18487
|
type: "module",
|
|
18489
18488
|
engines: {
|
|
@@ -18879,7 +18878,7 @@ var package_default4 = {
|
|
|
18879
18878
|
version: "0.1.0",
|
|
18880
18879
|
private: true,
|
|
18881
18880
|
description: "Mainfast Migrations: database migration guard.",
|
|
18882
|
-
license: "
|
|
18881
|
+
license: "FSL-1.1-ALv2",
|
|
18883
18882
|
author: "Mainfast authors",
|
|
18884
18883
|
type: "module",
|
|
18885
18884
|
engines: {
|
|
@@ -18937,7 +18936,7 @@ var STATUS_CONTEXT = P3.statusContext;
|
|
|
18937
18936
|
var USER_AGENT2 = `${P3.cliName}/${VERSION5}`;
|
|
18938
18937
|
|
|
18939
18938
|
// ../migrations/src/types.ts
|
|
18940
|
-
var FRAMEWORKS = ["alembic", "django", "prisma", "rails", "flyway", "drizzle"];
|
|
18939
|
+
var FRAMEWORKS = ["alembic", "django", "prisma", "rails", "flyway", "drizzle", "typeorm"];
|
|
18941
18940
|
|
|
18942
18941
|
// ../migrations/src/config.ts
|
|
18943
18942
|
var POLICIES = ["error", "warning", "off"];
|
|
@@ -18947,7 +18946,8 @@ var DEFAULT_OUT_OF_ORDER = {
|
|
|
18947
18946
|
prisma: "error",
|
|
18948
18947
|
rails: "warning",
|
|
18949
18948
|
flyway: "warning",
|
|
18950
|
-
drizzle: "error"
|
|
18949
|
+
drizzle: "error",
|
|
18950
|
+
typeorm: "warning"
|
|
18951
18951
|
};
|
|
18952
18952
|
var KNOWN_KEYS = ["enabled", "frameworks", "paths", "ignore", "outOfOrder", "label"];
|
|
18953
18953
|
var DEFAULT_CONFIG = {
|
|
@@ -18971,10 +18971,10 @@ function parseConfig2(text) {
|
|
|
18971
18971
|
const raw = loadSection(text, CONFIG_SECTION2, { known: KNOWN_KEYS });
|
|
18972
18972
|
const cfg = { ...DEFAULT_CONFIG, paths: {}, outOfOrder: { ...DEFAULT_OUT_OF_ORDER } };
|
|
18973
18973
|
if (raw.frameworks !== void 0 && raw.frameworks !== "auto") {
|
|
18974
|
-
const
|
|
18975
|
-
const bad =
|
|
18974
|
+
const list6 = strList2(raw.frameworks, `${CONFIG_SECTION2}.frameworks`);
|
|
18975
|
+
const bad = list6.filter((f) => !isFramework(f));
|
|
18976
18976
|
if (bad.length) throw new Error(`${CONFIG_SECTION2}.frameworks: unknown ${bad.join(", ")} (known: ${FRAMEWORKS.join(", ")})`);
|
|
18977
|
-
cfg.frameworks =
|
|
18977
|
+
cfg.frameworks = list6;
|
|
18978
18978
|
}
|
|
18979
18979
|
if (raw.paths !== void 0) {
|
|
18980
18980
|
if (typeof raw.paths !== "object" || raw.paths === null || Array.isArray(raw.paths))
|
|
@@ -19024,19 +19024,19 @@ function groupBy(xs, key2) {
|
|
|
19024
19024
|
const m = /* @__PURE__ */ new Map();
|
|
19025
19025
|
for (const x of xs) {
|
|
19026
19026
|
const k = key2(x);
|
|
19027
|
-
const
|
|
19028
|
-
if (
|
|
19027
|
+
const list6 = m.get(k);
|
|
19028
|
+
if (list6) list6.push(x);
|
|
19029
19029
|
else m.set(k, [x]);
|
|
19030
19030
|
}
|
|
19031
19031
|
return m;
|
|
19032
19032
|
}
|
|
19033
|
-
function outOfOrder(framework, ctx,
|
|
19033
|
+
function outOfOrder(framework, ctx, list6, cmp, explain, hint) {
|
|
19034
19034
|
const severity = ctx.outOfOrder;
|
|
19035
19035
|
if (severity === "off") return [];
|
|
19036
|
-
const baseSet = new Set(
|
|
19037
|
-
const mainList =
|
|
19036
|
+
const baseSet = new Set(list6(ctx.base, ctx.root).map((v) => v.path));
|
|
19037
|
+
const mainList = list6(ctx.main, ctx.root);
|
|
19038
19038
|
const mainPaths = new Set(mainList.map((v) => v.path));
|
|
19039
|
-
const branchAdded =
|
|
19039
|
+
const branchAdded = list6(ctx.head, ctx.root).filter((v) => !baseSet.has(v.path) && !mainPaths.has(v.path));
|
|
19040
19040
|
if (!branchAdded.length || !mainList.length) return [];
|
|
19041
19041
|
const latest = mainList.reduce((a, b) => cmp(a.version, b.version) >= 0 ? a : b);
|
|
19042
19042
|
const stale = branchAdded.filter((v) => cmp(v.version, latest.version) <= 0);
|
|
@@ -19103,15 +19103,15 @@ var alembic = {
|
|
|
19103
19103
|
const revs = revisions(tree, root);
|
|
19104
19104
|
const findings = [];
|
|
19105
19105
|
const byId = groupBy(revs, (r) => r.revision);
|
|
19106
|
-
for (const [id,
|
|
19107
|
-
if (
|
|
19106
|
+
for (const [id, list6] of byId) {
|
|
19107
|
+
if (list6.length > 1)
|
|
19108
19108
|
findings.push({
|
|
19109
19109
|
framework: "alembic",
|
|
19110
19110
|
root,
|
|
19111
19111
|
code: "duplicate-revision",
|
|
19112
19112
|
severity: "error",
|
|
19113
|
-
message: `revision id ${id} is declared by ${
|
|
19114
|
-
files:
|
|
19113
|
+
message: `revision id ${id} is declared by ${list6.length} scripts`,
|
|
19114
|
+
files: list6.map((r) => r.path),
|
|
19115
19115
|
hint: "Give one of the scripts a fresh revision id.",
|
|
19116
19116
|
key: `alembic:${root}:dup:${id}`
|
|
19117
19117
|
});
|
|
@@ -19213,17 +19213,17 @@ var django = {
|
|
|
19213
19213
|
const app = migs[0]?.app ?? basename(dirname(root));
|
|
19214
19214
|
const findings = [];
|
|
19215
19215
|
const names = new Set(migs.flatMap((m) => [m.name, ...m.replaces.filter(([a]) => a === app).map(([, n2]) => n2)]));
|
|
19216
|
-
for (const [num2,
|
|
19217
|
-
if (
|
|
19216
|
+
for (const [num2, list6] of groupBy(migs, (m) => m.number)) {
|
|
19217
|
+
if (list6.length > 1 && /^\d{4}$/.test(num2))
|
|
19218
19218
|
findings.push({
|
|
19219
19219
|
framework: "django",
|
|
19220
19220
|
root,
|
|
19221
19221
|
code: "duplicate-number",
|
|
19222
19222
|
severity: "warning",
|
|
19223
|
-
message: `app "${app}" has ${
|
|
19224
|
-
files:
|
|
19223
|
+
message: `app "${app}" has ${list6.length} migrations numbered ${num2}: ${list6.map((m) => m.name).join(", ")}`,
|
|
19224
|
+
files: list6.map((m) => m.path),
|
|
19225
19225
|
hint: "Renumber the branch migration after main's latest and point its dependency at it.",
|
|
19226
|
-
key: `django:${root}:dupnum:${
|
|
19226
|
+
key: `django:${root}:dupnum:${list6.map((m) => m.name).sort().join(",")}`
|
|
19227
19227
|
});
|
|
19228
19228
|
}
|
|
19229
19229
|
for (const m of migs) {
|
|
@@ -19316,17 +19316,17 @@ var drizzle = {
|
|
|
19316
19316
|
return findings;
|
|
19317
19317
|
}
|
|
19318
19318
|
const entries = journal.entries;
|
|
19319
|
-
for (const [idx,
|
|
19320
|
-
if (
|
|
19319
|
+
for (const [idx, list6] of groupBy(entries, (e) => String(e.idx))) {
|
|
19320
|
+
if (list6.length > 1)
|
|
19321
19321
|
findings.push({
|
|
19322
19322
|
framework: "drizzle",
|
|
19323
19323
|
root,
|
|
19324
19324
|
code: "duplicate-idx",
|
|
19325
19325
|
severity: "error",
|
|
19326
|
-
message: `journal idx ${idx} is used by ${
|
|
19326
|
+
message: `journal idx ${idx} is used by ${list6.length} entries: ${list6.map((e) => e.tag).join(", ")}`,
|
|
19327
19327
|
files: [jp],
|
|
19328
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.",
|
|
19329
|
-
key: `drizzle:${root}:dupidx:${
|
|
19329
|
+
key: `drizzle:${root}:dupidx:${list6.map((e) => e.tag).sort().join(",")}`
|
|
19330
19330
|
});
|
|
19331
19331
|
}
|
|
19332
19332
|
const idxs = entries.map((e) => e.idx);
|
|
@@ -19391,17 +19391,17 @@ var drizzle = {
|
|
|
19391
19391
|
}
|
|
19392
19392
|
});
|
|
19393
19393
|
const ids = new Set(snaps.map((s) => s.id).filter(Boolean));
|
|
19394
|
-
for (const [prev,
|
|
19395
|
-
if (
|
|
19394
|
+
for (const [prev, list6] of groupBy(snaps.filter((s) => s.prevId), (s) => s.prevId)) {
|
|
19395
|
+
if (list6.length > 1)
|
|
19396
19396
|
findings.push({
|
|
19397
19397
|
framework: "drizzle",
|
|
19398
19398
|
root,
|
|
19399
19399
|
code: "snapshot-fork",
|
|
19400
19400
|
severity: "error",
|
|
19401
|
-
message: `${
|
|
19402
|
-
files:
|
|
19401
|
+
message: `${list6.length} snapshots claim prevId ${prev}: ${list6.map((s) => basename(s.path)).join(", ")}`,
|
|
19402
|
+
files: list6.map((s) => s.path),
|
|
19403
19403
|
hint: "Point the branch snapshot's prevId at main's latest snapshot id (or regenerate it with drizzle-kit generate after merging main).",
|
|
19404
|
-
key: `drizzle:${root}:fork:${prev}:${
|
|
19404
|
+
key: `drizzle:${root}:fork:${prev}:${list6.length}`
|
|
19405
19405
|
});
|
|
19406
19406
|
}
|
|
19407
19407
|
for (const s of snaps)
|
|
@@ -19594,8 +19594,90 @@ var rails = {
|
|
|
19594
19594
|
}
|
|
19595
19595
|
};
|
|
19596
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
|
+
|
|
19597
19679
|
// ../migrations/src/frameworks/index.ts
|
|
19598
|
-
var frameworks = { alembic, django, prisma, rails, flyway, drizzle };
|
|
19680
|
+
var frameworks = { alembic, django, prisma, rails, flyway, drizzle, typeorm };
|
|
19599
19681
|
|
|
19600
19682
|
// ../migrations/src/git.ts
|
|
19601
19683
|
var import_node_child_process4 = require("node:child_process");
|
|
@@ -19727,6 +19809,21 @@ function discoverRoots(main7, head, config2) {
|
|
|
19727
19809
|
}
|
|
19728
19810
|
return out;
|
|
19729
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
|
+
}
|
|
19730
19827
|
function analyze(opts) {
|
|
19731
19828
|
const mainSha = revParse2(opts.repo, opts.mainRef);
|
|
19732
19829
|
const headSha = revParse2(opts.repo, opts.headRef);
|
|
@@ -19765,6 +19862,8 @@ function analyzeTrees(opts) {
|
|
|
19765
19862
|
head: { ref: opts.headRef, sha: headSha },
|
|
19766
19863
|
mergeBase: baseSha,
|
|
19767
19864
|
roots,
|
|
19865
|
+
checked: roots.length > 0,
|
|
19866
|
+
unsupported: roots.length ? [] : unsupportedTools(head.files()),
|
|
19768
19867
|
findings: unique,
|
|
19769
19868
|
preExisting
|
|
19770
19869
|
};
|
|
@@ -19781,7 +19880,9 @@ function toMarkdown(r, opts = {}) {
|
|
|
19781
19880
|
lines.push(`### ${opts.title ?? PRODUCT}`);
|
|
19782
19881
|
lines.push("");
|
|
19783
19882
|
if (!r.roots.length) {
|
|
19784
|
-
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})`);
|
|
19785
19886
|
return lines.join("\n");
|
|
19786
19887
|
}
|
|
19787
19888
|
lines.push(
|
|
@@ -19814,12 +19915,17 @@ function toText(r) {
|
|
|
19814
19915
|
const out = [];
|
|
19815
19916
|
out.push(`${PRODUCT}: ${r.head.ref} (${short(r.head.sha)}) -> ${r.main.ref} (${short(r.main.sha)}), merge-base ${short(r.mergeBase)}`);
|
|
19816
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
|
+
}
|
|
19817
19923
|
for (const f of r.findings) {
|
|
19818
19924
|
out.push(`${f.severity.toUpperCase()} ${f.framework} ${f.root} [${f.code}] ${f.message}`);
|
|
19819
19925
|
if (f.hint) out.push(` fix: ${f.hint}`);
|
|
19820
19926
|
}
|
|
19821
19927
|
for (const f of r.preExisting) out.push(`note (already on main) ${f.framework} ${f.root} [${f.code}] ${f.message}`);
|
|
19822
|
-
out.push(r.ok ? "ok" : "FAILED");
|
|
19928
|
+
out.push(r.ok ? r.roots.length ? "ok" : "ok (nothing checked)" : "FAILED");
|
|
19823
19929
|
return out.join("\n");
|
|
19824
19930
|
}
|
|
19825
19931
|
|
|
@@ -19866,7 +19972,7 @@ Resolved: migrations are consistent with ${mdCode(report.main.ref)} at ${report.
|
|
|
19866
19972
|
await o.gh.request("POST", `${base}/statuses/${report.head.sha}`, {
|
|
19867
19973
|
state,
|
|
19868
19974
|
context: STATUS_CONTEXT,
|
|
19869
|
-
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),
|
|
19870
19976
|
target_url: o.targetUrl
|
|
19871
19977
|
});
|
|
19872
19978
|
result.status = state;
|
|
@@ -20273,7 +20379,14 @@ var OwnersApi = class {
|
|
|
20273
20379
|
* backoff, and at most `maxSearches` requests are made per run. undefined = not checked.
|
|
20274
20380
|
*/
|
|
20275
20381
|
reviewsSince(login, since) {
|
|
20276
|
-
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 () => {
|
|
20277
20390
|
const s = this.search;
|
|
20278
20391
|
for (let attempt = 0; ; attempt++) {
|
|
20279
20392
|
if (s.stopped || s.made >= this.maxSearches) {
|
|
@@ -20289,7 +20402,7 @@ var OwnersApi = class {
|
|
|
20289
20402
|
if (wait > 0) await this.sleep(wait);
|
|
20290
20403
|
s.made++;
|
|
20291
20404
|
try {
|
|
20292
|
-
const q = `repo:${this.owner}/${this.repo} type:pr
|
|
20405
|
+
const q = `repo:${this.owner}/${this.repo} type:pr ${qualifier}:${login} updated:>=${since}`;
|
|
20293
20406
|
const r = await this.gh.request("GET", `/search/issues?q=${enc3(q)}&per_page=1`);
|
|
20294
20407
|
const remaining = Number(r.headers.get("x-ratelimit-remaining") ?? NaN);
|
|
20295
20408
|
const reset = Number(r.headers.get("x-ratelimit-reset") ?? NaN);
|
|
@@ -20372,7 +20485,7 @@ var package_default5 = {
|
|
|
20372
20485
|
version: "0.1.0",
|
|
20373
20486
|
private: true,
|
|
20374
20487
|
description: "Mainfast Owners: CODEOWNERS drift check.",
|
|
20375
|
-
license: "
|
|
20488
|
+
license: "FSL-1.1-ALv2",
|
|
20376
20489
|
author: "Mainfast authors",
|
|
20377
20490
|
type: "module",
|
|
20378
20491
|
engines: {
|
|
@@ -20483,6 +20596,7 @@ function configFromDoc2(doc) {
|
|
|
20483
20596
|
var plural11 = (n2, noun) => `${n2} ${noun}${n2 === 1 ? "" : "s"}`;
|
|
20484
20597
|
var FIXES = {
|
|
20485
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.",
|
|
20486
20600
|
"unknown-user": "The account was deleted or renamed: put the current login or a team in its place.",
|
|
20487
20601
|
"owner-left-org": "Remove the owner or replace them with a current member or team.",
|
|
20488
20602
|
"owner-no-write": "Give the owner write access (directly or through a team), or replace them; GitHub skips owners without write.",
|
|
@@ -20690,8 +20804,10 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20690
20804
|
const start = candidates.length ? week % candidates.length : 0;
|
|
20691
20805
|
const order = [...candidates.slice(start), ...candidates.slice(0, start)];
|
|
20692
20806
|
for (const st of order) {
|
|
20693
|
-
if (st.kind === "user")
|
|
20694
|
-
|
|
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 {
|
|
20695
20811
|
const members2 = await api.teamMembers(st.owner.split("/")[1].toLowerCase());
|
|
20696
20812
|
let total2 = 0;
|
|
20697
20813
|
let complete = true;
|
|
@@ -20708,7 +20824,7 @@ async function dormancy(statuses, api, cfg, days, now, org) {
|
|
|
20708
20824
|
function dormantFindings(co, statuses, days) {
|
|
20709
20825
|
const out = [];
|
|
20710
20826
|
for (const st of statuses) {
|
|
20711
|
-
if (st.reviews !== 0) continue;
|
|
20827
|
+
if (st.reviews !== 0 || (st.authored ?? 0) > 0) continue;
|
|
20712
20828
|
const lines = co.rules.filter((r) => r.owners.some((o) => key(o) === key(st.owner))).map((r) => r.line);
|
|
20713
20829
|
out.push({
|
|
20714
20830
|
code: st.kind === "team" ? "dormant-team" : "dormant-owner",
|
|
@@ -20716,7 +20832,7 @@ function dormantFindings(co, statuses, days) {
|
|
|
20716
20832
|
scope: "current",
|
|
20717
20833
|
owner: st.owner,
|
|
20718
20834
|
line: lines[0],
|
|
20719
|
-
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`
|
|
20720
20836
|
});
|
|
20721
20837
|
}
|
|
20722
20838
|
return out;
|
|
@@ -20834,13 +20950,28 @@ async function auditOwners(input) {
|
|
|
20834
20950
|
}
|
|
20835
20951
|
findings.push(...pFindings);
|
|
20836
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
|
+
}
|
|
20837
20968
|
}
|
|
20838
20969
|
}
|
|
20839
20970
|
if (checker && api && untrusted) {
|
|
20840
20971
|
report.orgChecks = "untrusted-pr";
|
|
20841
20972
|
if (checker.publicOnly)
|
|
20842
20973
|
notes.push(
|
|
20843
|
-
`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.`
|
|
20844
20975
|
);
|
|
20845
20976
|
report.owners = [...checker.statuses.values()];
|
|
20846
20977
|
} else if (checker && api) {
|
|
@@ -20893,11 +21024,10 @@ async function loadAudit(api, ref) {
|
|
|
20893
21024
|
return { ref, files: tree.paths, truncated: tree.truncated, codeowners: await codeownersAt(api, ref), notes: [] };
|
|
20894
21025
|
}
|
|
20895
21026
|
var touchesCodeowners = (files) => files.some((f) => CODEOWNERS_LOCATIONS.includes(f.filename) || f.previous_filename !== void 0 && CODEOWNERS_LOCATIONS.includes(f.previous_filename));
|
|
20896
|
-
var TRUSTED_ASSOCIATIONS = ["OWNER", "MEMBER", "COLLABORATOR"];
|
|
20897
21027
|
function isTrustedPr(pr) {
|
|
20898
21028
|
const head = pr?.head?.repo?.full_name;
|
|
20899
21029
|
const base = pr?.base?.repo?.full_name;
|
|
20900
|
-
return Boolean(head && base && head.toLowerCase() === base.toLowerCase()
|
|
21030
|
+
return Boolean(head && base && head.toLowerCase() === base.toLowerCase());
|
|
20901
21031
|
}
|
|
20902
21032
|
async function loadPr(api, pr) {
|
|
20903
21033
|
const files = await api.prFiles(pr.number);
|
|
@@ -20990,7 +21120,7 @@ function toMarkdown2(r, o = {}) {
|
|
|
20990
21120
|
);
|
|
20991
21121
|
out.push("");
|
|
20992
21122
|
}
|
|
20993
|
-
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")));
|
|
20994
21124
|
if (current.length) out.push(...table(current), "");
|
|
20995
21125
|
if (r.proposed) {
|
|
20996
21126
|
const proposed = r.findings.filter((f) => f.scope === "proposed");
|
|
@@ -21011,7 +21141,7 @@ function toText2(r) {
|
|
|
21011
21141
|
const out = [t(`${PRODUCT2}: ${r.repository}${r.pr ? ` #${r.pr}` : ""} \u2014 ${headline2(r)}`)];
|
|
21012
21142
|
for (const f of r.findings) {
|
|
21013
21143
|
out.push(t(`${f.severity.toUpperCase()} [${f.code}]${f.scope === "proposed" ? " (this PR)" : ""} ${f.message}${f.preexisting ? " (already on the base branch)" : ""}`));
|
|
21014
|
-
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)}`);
|
|
21015
21145
|
if (f.hint) out.push(t(` fix: ${f.hint}`));
|
|
21016
21146
|
}
|
|
21017
21147
|
for (const n2 of r.notes) out.push(t(`note: ${n2}`));
|
|
@@ -21133,7 +21263,7 @@ var package_default6 = {
|
|
|
21133
21263
|
version: "0.1.0",
|
|
21134
21264
|
private: true,
|
|
21135
21265
|
description: "Mainfast Rollcall: required-check integrity audit.",
|
|
21136
|
-
license: "
|
|
21266
|
+
license: "FSL-1.1-ALv2",
|
|
21137
21267
|
author: "Mainfast authors",
|
|
21138
21268
|
type: "module",
|
|
21139
21269
|
engines: {
|
|
@@ -21193,7 +21323,7 @@ var ISSUE_MARKER = P5.commentMarker;
|
|
|
21193
21323
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
21194
21324
|
var PR_EVENTS = ["pull_request", "pull_request_target", "merge_group"];
|
|
21195
21325
|
var escapeRe3 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21196
|
-
function
|
|
21326
|
+
function list5(v) {
|
|
21197
21327
|
if (v === void 0 || v === null) return void 0;
|
|
21198
21328
|
return (Array.isArray(v) ? v : [v]).map(String);
|
|
21199
21329
|
}
|
|
@@ -21207,11 +21337,11 @@ function triggers(on) {
|
|
|
21207
21337
|
const c = cfg ?? {};
|
|
21208
21338
|
out.push({
|
|
21209
21339
|
event,
|
|
21210
|
-
paths:
|
|
21211
|
-
pathsIgnore:
|
|
21212
|
-
branches:
|
|
21213
|
-
branchesIgnore:
|
|
21214
|
-
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)
|
|
21215
21345
|
});
|
|
21216
21346
|
}
|
|
21217
21347
|
return out;
|
|
@@ -21368,7 +21498,7 @@ function parseWorkflow(file) {
|
|
|
21368
21498
|
reusable,
|
|
21369
21499
|
opaque,
|
|
21370
21500
|
if: j.if === void 0 ? void 0 : String(j.if),
|
|
21371
|
-
needs:
|
|
21501
|
+
needs: list5(j.needs) ?? []
|
|
21372
21502
|
});
|
|
21373
21503
|
}
|
|
21374
21504
|
return { path: file.path, name, prTriggers: triggers(on), events: eventsOf(on), callableOnly: isCallableOnly(on), jobs };
|
|
@@ -21620,9 +21750,9 @@ function audit(s, opts = {}) {
|
|
|
21620
21750
|
}
|
|
21621
21751
|
}
|
|
21622
21752
|
} else if (pulls.length) {
|
|
21623
|
-
const missingStreak = (
|
|
21753
|
+
const missingStreak = (list6) => {
|
|
21624
21754
|
let n2 = 0;
|
|
21625
|
-
for (const x of
|
|
21755
|
+
for (const x of list6) {
|
|
21626
21756
|
if (!missingAt.has(x.p.number)) break;
|
|
21627
21757
|
n2++;
|
|
21628
21758
|
}
|
|
@@ -22107,8 +22237,8 @@ function parseReport(r) {
|
|
|
22107
22237
|
// src/commands.ts
|
|
22108
22238
|
var AUDIT_CHECKS = ["rollcall", "owners", "migrations", "evidence"];
|
|
22109
22239
|
var AUDIT_NEEDS = {
|
|
22110
|
-
rollcall: "A GitHub origin remote. A private repository also needs GITHUB_TOKEN or GH_TOKEN
|
|
22111
|
-
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.",
|
|
22112
22242
|
migrations: "A checkout with the main branch fetched. No token needed.",
|
|
22113
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."
|
|
22114
22244
|
};
|
|
@@ -22163,26 +22293,175 @@ async function runAudit(o) {
|
|
|
22163
22293
|
}
|
|
22164
22294
|
|
|
22165
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
|
|
22166
22300
|
var import_node_fs11 = require("node:fs");
|
|
22167
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}.`;
|
|
22168
22344
|
|
|
22169
22345
|
// raw:../evidence/examples/workflows/evidence.yml
|
|
22170
|
-
var evidence_default =
|
|
22346
|
+
var evidence_default = `# Copy to .github/workflows/mainfast-evidence.yml.
|
|
22347
|
+
#
|
|
22348
|
+
# Two jobs on purpose:
|
|
22349
|
+
# - pr (pull_request, same-repository PRs): re-evaluates on every push, edit and label change.
|
|
22350
|
+
# Runs with the PR's own workflow file and an ordinary token; checks out the PR head only to
|
|
22351
|
+
# diff it locally (nothing from it is run).
|
|
22352
|
+
# - ci (workflow_run): re-evaluates once your CI finishes, so "tests ran on THIS sha" sees the
|
|
22353
|
+
# final result, and gives fork PRs a card. workflow_run always runs THIS file from the default
|
|
22354
|
+
# branch with a write token, so it never checks out or runs PR code: the diff, the policy
|
|
22355
|
+
# (.mainfast.yml at the PR's base commit) and the checks all come from the API. The coverage
|
|
22356
|
+
# artifact is data the PR's CI run produced: parsed, never executed.
|
|
22357
|
+
# Make the "Mainfast Evidence" check required in your ruleset to gate merges on it.
|
|
22358
|
+
# Never put \${{ github.event.* }} text (branch names, titles, commit messages) into a \`run:\` step.
|
|
22359
|
+
name: Mainfast Evidence
|
|
22360
|
+
|
|
22361
|
+
on:
|
|
22362
|
+
pull_request:
|
|
22363
|
+
types: [opened, synchronize, reopened, edited, labeled, unlabeled, ready_for_review]
|
|
22364
|
+
workflow_run:
|
|
22365
|
+
workflows: [CI] # the name of your test workflow
|
|
22366
|
+
types: [completed]
|
|
22367
|
+
|
|
22368
|
+
permissions: {}
|
|
22369
|
+
|
|
22370
|
+
jobs:
|
|
22371
|
+
pr:
|
|
22372
|
+
# Fork PRs get a read-only token here and could not post; the ci job covers them.
|
|
22373
|
+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
22374
|
+
runs-on: ubuntu-latest
|
|
22375
|
+
permissions:
|
|
22376
|
+
contents: read
|
|
22377
|
+
checks: write
|
|
22378
|
+
pull-requests: write
|
|
22379
|
+
statuses: read # commit statuses (e.g. ci/circleci: \u2026) count as checks
|
|
22380
|
+
concurrency:
|
|
22381
|
+
group: evidence-pr-\${{ github.event.pull_request.number }}
|
|
22382
|
+
cancel-in-progress: true
|
|
22383
|
+
steps:
|
|
22384
|
+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
|
|
22385
|
+
with:
|
|
22386
|
+
fetch-depth: 0 # full history: local diff without GitHub's patch truncation, plus git-ai notes
|
|
22387
|
+
ref: \${{ github.event.pull_request.head.sha }}
|
|
22388
|
+
# credentials stay so the Action can fetch refs/notes/ai (git-ai) in a private repo
|
|
22389
|
+
- uses: mainfast/evidence@v0
|
|
22390
|
+
with:
|
|
22391
|
+
# Give CI a few minutes so the first card is not "no tests ran".
|
|
22392
|
+
wait-for-checks: "600"
|
|
22393
|
+
|
|
22394
|
+
ci:
|
|
22395
|
+
if: github.event_name == 'workflow_run'
|
|
22396
|
+
runs-on: ubuntu-latest
|
|
22397
|
+
permissions:
|
|
22398
|
+
contents: read
|
|
22399
|
+
checks: write
|
|
22400
|
+
pull-requests: write
|
|
22401
|
+
statuses: read # commit statuses (e.g. ci/circleci: \u2026) count as checks
|
|
22402
|
+
actions: read # download the coverage artifact from the CI run
|
|
22403
|
+
concurrency:
|
|
22404
|
+
group: evidence-ci-\${{ github.event.workflow_run.head_sha }}
|
|
22405
|
+
cancel-in-progress: true
|
|
22406
|
+
steps:
|
|
22407
|
+
# No actions/checkout: this job holds a write token, so PR code never lands on its disk.
|
|
22408
|
+
# Optional: changed-line coverage from the CI run's artifact (data only).
|
|
22409
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
22410
|
+
continue-on-error: true
|
|
22411
|
+
with:
|
|
22412
|
+
name: coverage
|
|
22413
|
+
path: coverage
|
|
22414
|
+
run-id: \${{ github.event.workflow_run.id }}
|
|
22415
|
+
github-token: \${{ github.token }}
|
|
22416
|
+
|
|
22417
|
+
- uses: mainfast/evidence@v0
|
|
22418
|
+
with:
|
|
22419
|
+
coverage-files: coverage/lcov.info
|
|
22420
|
+
local-diff: "false" # no checkout in this job: the diff comes from the API
|
|
22421
|
+
`;
|
|
22171
22422
|
|
|
22172
22423
|
// raw:../intact/examples/mainfast-intact.yml
|
|
22173
|
-
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';
|
|
22174
22425
|
|
|
22175
22426
|
// raw:../migrations/examples/mainfast-migrations.yml
|
|
22176
|
-
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
|
|
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';
|
|
22177
22428
|
|
|
22178
22429
|
// raw:../owners/examples/owners.yml
|
|
22179
|
-
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';
|
|
22180
22431
|
|
|
22181
22432
|
// raw:../rollcall/examples/rollcall.yml
|
|
22182
|
-
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
|
+
};
|
|
22183
22447
|
|
|
22184
22448
|
// src/templates.ts
|
|
22185
|
-
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
|
+
};
|
|
22186
22465
|
var workflowPath = (slug) => `.github/workflows/${SUITE.githubOrg}-${slug}.yml`;
|
|
22187
22466
|
var STARTER_CONFIG = `# yaml-language-server: $schema=${SUITE.schemaUrl}
|
|
22188
22467
|
# One optional section per check. Defaults apply to any check without one.
|
|
@@ -22196,7 +22475,7 @@ function installedIn(root, slug) {
|
|
|
22196
22475
|
const rel = ".github/workflows";
|
|
22197
22476
|
if (repoPathKind(root, rel) !== "directory") return [];
|
|
22198
22477
|
const action = product(slug).actionRef.split("@")[0];
|
|
22199
|
-
return (0,
|
|
22478
|
+
return (0, import_node_fs12.readdirSync)((0, import_node_path9.join)(root, rel)).filter((f) => /\.ya?ml$/.test(f)).filter((f) => {
|
|
22200
22479
|
try {
|
|
22201
22480
|
return readRepoFile(root, `${rel}/${f}`)?.includes(`uses: ${action}@`) ?? false;
|
|
22202
22481
|
} catch {
|
|
@@ -22204,14 +22483,29 @@ function installedIn(root, slug) {
|
|
|
22204
22483
|
}
|
|
22205
22484
|
}).map((f) => `${rel}/${f}`);
|
|
22206
22485
|
}
|
|
22207
|
-
function nextSteps(slugs) {
|
|
22486
|
+
function nextSteps(root, slugs) {
|
|
22208
22487
|
const steps = ["Review the new files, commit them and open a pull request. Nothing has been pushed."];
|
|
22209
|
-
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}"`);
|
|
22210
22491
|
if (slugs.includes("migrations")) required2.push(`"${product("migrations").statusContext ?? "mainfast/migrations"}"`);
|
|
22211
22492
|
if (required2.length) steps.push(`To block merges on findings, make ${required2.join(", ")} required in branch protection or a ruleset.`);
|
|
22212
|
-
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
|
+
}
|
|
22213
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.");
|
|
22214
|
-
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}).`);
|
|
22215
22509
|
return steps;
|
|
22216
22510
|
}
|
|
22217
22511
|
function runInit(opts) {
|
|
@@ -22225,13 +22519,13 @@ function runInit(opts) {
|
|
|
22225
22519
|
const skipped = [];
|
|
22226
22520
|
const place = (rel, content) => {
|
|
22227
22521
|
const current = readRepoFile(root, rel);
|
|
22228
|
-
const abs = (0,
|
|
22522
|
+
const abs = (0, import_node_path9.join)(root, rel);
|
|
22229
22523
|
const exists = current !== void 0;
|
|
22230
22524
|
if (current === content) return void unchanged.push(rel);
|
|
22231
22525
|
if (exists && !opts.force) return void skipped.push({ path: rel, reason: "exists with different content; use --force to replace it" });
|
|
22232
22526
|
if (!opts.dryRun) {
|
|
22233
|
-
(0,
|
|
22234
|
-
(0,
|
|
22527
|
+
(0, import_node_fs12.mkdirSync)((0, import_node_path9.dirname)(abs), { recursive: true });
|
|
22528
|
+
(0, import_node_fs12.writeFileSync)(abs, content);
|
|
22235
22529
|
}
|
|
22236
22530
|
(exists ? overwritten : written).push(rel);
|
|
22237
22531
|
};
|
|
@@ -22243,8 +22537,9 @@ function runInit(opts) {
|
|
|
22243
22537
|
}
|
|
22244
22538
|
if (repoPathKind(root, SUITE.configFileAlt)) skipped.push({ path: SUITE.configFile, reason: `${SUITE.configFileAlt} already exists` });
|
|
22245
22539
|
else place(SUITE.configFile, STARTER_CONFIG);
|
|
22246
|
-
const steps = nextSteps(slugs);
|
|
22247
|
-
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() };
|
|
22248
22543
|
const verb = opts.dryRun ? "would write" : "wrote";
|
|
22249
22544
|
const lines = [
|
|
22250
22545
|
...written.map((f) => `${verb} ${f}`),
|
|
@@ -22254,12 +22549,30 @@ function runInit(opts) {
|
|
|
22254
22549
|
"",
|
|
22255
22550
|
"Next:",
|
|
22256
22551
|
...steps.map((s) => `- ${s}`),
|
|
22257
|
-
`- Optional: the hosted GitHub App runs these without workflow files: ${
|
|
22552
|
+
`- Optional, for organizations: ${SUITE.name} Enterprise, the hosted GitHub App, runs these without workflow files and adds a dashboard and alerts: ${SUITE.pricingUrl}`
|
|
22258
22553
|
];
|
|
22259
22554
|
return { exitCode: 0, json, text: lines.join("\n") };
|
|
22260
22555
|
}
|
|
22261
22556
|
|
|
22262
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
|
+
}
|
|
22263
22576
|
function runDoctor(dir) {
|
|
22264
22577
|
const root = repoRoot(dir);
|
|
22265
22578
|
const missing = [];
|
|
@@ -22279,18 +22592,21 @@ function runDoctor(dir) {
|
|
|
22279
22592
|
return [s, { installed: files.length > 0, files }];
|
|
22280
22593
|
}));
|
|
22281
22594
|
const installed = PRODUCT_SLUGS.filter((s) => checks[s].installed);
|
|
22282
|
-
const
|
|
22595
|
+
const kindOf2 = (f) => {
|
|
22283
22596
|
try {
|
|
22284
22597
|
return repoPathKind(root, f);
|
|
22285
22598
|
} catch {
|
|
22286
22599
|
return "unsafe";
|
|
22287
22600
|
}
|
|
22288
22601
|
};
|
|
22289
|
-
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) =>
|
|
22602
|
+
const path = [SUITE.configFile, SUITE.configFileAlt].find((f) => kindOf2(f));
|
|
22290
22603
|
let config2 = { path: path ?? null, ok: true };
|
|
22291
22604
|
if (path) {
|
|
22292
22605
|
try {
|
|
22293
|
-
|
|
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("; "));
|
|
22294
22610
|
} catch (e) {
|
|
22295
22611
|
config2 = { path, ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
22296
22612
|
missing.push(`${path} cannot be used: ${config2.error}`);
|
|
@@ -22298,16 +22614,18 @@ function runDoctor(dir) {
|
|
|
22298
22614
|
}
|
|
22299
22615
|
const token = githubToken();
|
|
22300
22616
|
const repo = githubRepo(root) ?? null;
|
|
22301
|
-
const codeowners =
|
|
22617
|
+
const codeowners = codeownersIn(root);
|
|
22618
|
+
const migrations2 = installed.includes("migrations") ? migrationsFacts(root) : void 0;
|
|
22302
22619
|
if (!installed.length && workflowsOk) missing.push("No checks are installed. Run: mainfast init");
|
|
22303
22620
|
if (!repo) missing.push("No GitHub origin remote, so audit cannot read the repository through the GitHub API.");
|
|
22304
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));
|
|
22305
22623
|
if (installed.includes("owners") && !codeowners) missing.push("Owners is installed but there is no CODEOWNERS file. Add .github/CODEOWNERS.");
|
|
22306
22624
|
const ok = config2.ok && workflowsOk && installed.length > 0;
|
|
22307
|
-
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() };
|
|
22308
22626
|
const lines = [
|
|
22309
22627
|
...PRODUCT_SLUGS.map((s) => `${checks[s].installed ? "installed" : "missing "} ${s}${checks[s].installed ? ` (${checks[s].files.join(", ")})` : ""}`),
|
|
22310
|
-
`config ${path ? config2.ok ? `${path} parses` : `${path}
|
|
22628
|
+
`config ${path ? config2.ok ? `${path} parses, every section valid` : `${path} has errors` : "none (defaults apply)"}`,
|
|
22311
22629
|
`token ${token ? `set (${token.name})` : "not set"}`,
|
|
22312
22630
|
...missing.length ? ["", "To do:", ...missing.map((m) => `- ${m}`)] : []
|
|
22313
22631
|
];
|
|
@@ -22315,8 +22633,8 @@ function runDoctor(dir) {
|
|
|
22315
22633
|
}
|
|
22316
22634
|
|
|
22317
22635
|
// src/mcp.ts
|
|
22318
|
-
var
|
|
22319
|
-
var
|
|
22636
|
+
var import_node_fs13 = require("node:fs");
|
|
22637
|
+
var import_node_path10 = require("node:path");
|
|
22320
22638
|
var import_node_url = require("node:url");
|
|
22321
22639
|
|
|
22322
22640
|
// ../node_modules/zod/v4/core/util.js
|
|
@@ -27219,8 +27537,8 @@ var contributors = {
|
|
|
27219
27537
|
function aggregateChecks(schema) {
|
|
27220
27538
|
const agg = {};
|
|
27221
27539
|
const def = schema._zod.def;
|
|
27222
|
-
const
|
|
27223
|
-
for (const ch of
|
|
27540
|
+
const list6 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
27541
|
+
for (const ch of list6)
|
|
27224
27542
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
27225
27543
|
const bag = schema._zod.bag;
|
|
27226
27544
|
if (bag.minimum !== void 0)
|
|
@@ -32163,17 +32481,17 @@ var TOOLS = [
|
|
|
32163
32481
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
32164
32482
|
}
|
|
32165
32483
|
];
|
|
32166
|
-
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);
|
|
32167
32485
|
function allowedBases(cwd, roots) {
|
|
32168
|
-
let own2 = (0,
|
|
32486
|
+
let own2 = (0, import_node_fs13.realpathSync)(cwd);
|
|
32169
32487
|
try {
|
|
32170
|
-
own2 = (0,
|
|
32488
|
+
own2 = (0, import_node_fs13.realpathSync)(repoRoot(cwd));
|
|
32171
32489
|
} catch {
|
|
32172
32490
|
}
|
|
32173
32491
|
const out = [own2];
|
|
32174
32492
|
for (const uri of roots) {
|
|
32175
32493
|
try {
|
|
32176
|
-
out.push((0,
|
|
32494
|
+
out.push((0, import_node_fs13.realpathSync)((0, import_node_url.fileURLToPath)(uri)));
|
|
32177
32495
|
} catch {
|
|
32178
32496
|
}
|
|
32179
32497
|
}
|
|
@@ -32184,11 +32502,11 @@ function checkRepoPath(given, cwd, roots) {
|
|
|
32184
32502
|
const bases = allowedBases(cwd, roots);
|
|
32185
32503
|
let real;
|
|
32186
32504
|
try {
|
|
32187
|
-
real = (0,
|
|
32505
|
+
real = (0, import_node_fs13.realpathSync)((0, import_node_path10.resolve)(cwd, given));
|
|
32188
32506
|
} catch {
|
|
32189
32507
|
throw new CliError(`repo_path does not exist: ${given}`);
|
|
32190
32508
|
}
|
|
32191
|
-
const top = (0,
|
|
32509
|
+
const top = (0, import_node_fs13.realpathSync)(repoRoot(real));
|
|
32192
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}`);
|
|
32193
32511
|
return real;
|
|
32194
32512
|
}
|
|
@@ -32354,7 +32672,7 @@ ${HELP2[""]}`);
|
|
|
32354
32672
|
return 2;
|
|
32355
32673
|
}
|
|
32356
32674
|
} catch (e) {
|
|
32357
|
-
const message = redact(e instanceof Error ? e.message : String(e));
|
|
32675
|
+
const message = redact(e instanceof Error ? e.message : String(e)).replace(/^(?:mainfast: )+/, "");
|
|
32358
32676
|
process.stderr.write(`mainfast: ${message}
|
|
32359
32677
|
`);
|
|
32360
32678
|
if (json) process.stdout.write(`${JSON.stringify({ schema: SCHEMA, command, ok: false, error: message }, null, 2)}
|