@ploaness/cli 1.1.0 → 1.2.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/dist/checks/assets.d.ts +12 -0
- package/dist/checks/assets.d.ts.map +1 -1
- package/dist/checks/assets.js +27 -4
- package/dist/checks/assets.js.map +1 -1
- package/dist/checks/blocklist.d.ts +8 -0
- package/dist/checks/blocklist.d.ts.map +1 -0
- package/dist/checks/blocklist.js +106 -0
- package/dist/checks/blocklist.js.map +1 -0
- package/dist/checks/dependencies.d.ts.map +1 -1
- package/dist/checks/dependencies.js +75 -52
- package/dist/checks/dependencies.js.map +1 -1
- package/dist/checks/editorconfig.js +6 -5
- package/dist/checks/editorconfig.js.map +1 -1
- package/dist/checks/environment.d.ts.map +1 -1
- package/dist/checks/environment.js +4 -10
- package/dist/checks/environment.js.map +1 -1
- package/dist/checks/install.d.ts +2 -0
- package/dist/checks/install.d.ts.map +1 -1
- package/dist/checks/install.js +10 -1
- package/dist/checks/install.js.map +1 -1
- package/dist/checks/oxlint.d.ts +5 -0
- package/dist/checks/oxlint.d.ts.map +1 -0
- package/dist/checks/oxlint.js +85 -0
- package/dist/checks/oxlint.js.map +1 -0
- package/dist/checks/payload.d.ts +11 -0
- package/dist/checks/payload.d.ts.map +1 -1
- package/dist/checks/payload.js +104 -7
- package/dist/checks/payload.js.map +1 -1
- package/dist/checks/suppressions.d.ts +2 -2
- package/dist/checks/suppressions.d.ts.map +1 -1
- package/dist/checks/suppressions.js +31 -11
- package/dist/checks/suppressions.js.map +1 -1
- package/dist/checks/tree.d.ts +1 -1
- package/dist/checks/tree.d.ts.map +1 -1
- package/dist/checks/tree.js +6 -26
- package/dist/checks/tree.js.map +1 -1
- package/dist/checks/wiring.d.ts +10 -0
- package/dist/checks/wiring.d.ts.map +1 -1
- package/dist/checks/wiring.js +16 -4
- package/dist/checks/wiring.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/context.d.ts +1 -23
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +9 -34
- package/dist/context.js.map +1 -1
- package/dist/gates.d.ts.map +1 -1
- package/dist/gates.js +37 -12
- package/dist/gates.js.map +1 -1
- package/dist/probes/payload-defaults.probe.d.ts +2 -0
- package/dist/probes/payload-defaults.probe.d.ts.map +1 -0
- package/dist/probes/payload-defaults.probe.js +116 -0
- package/dist/probes/payload-defaults.probe.js.map +1 -0
- package/dist/source-comments.d.ts +9 -0
- package/dist/source-comments.d.ts.map +1 -0
- package/dist/source-comments.js +54 -0
- package/dist/source-comments.js.map +1 -0
- package/dist/working-tree.d.ts +5 -0
- package/dist/working-tree.d.ts.map +1 -0
- package/dist/working-tree.js +36 -0
- package/dist/working-tree.js.map +1 -0
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/checks/environment.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,mEAAmE;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAEL,iBAAiB,EACjB,yBAAyB,EAEzB,yBAAyB,EACzB,4BAA4B,
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/checks/environment.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,mEAAmE;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAEL,iBAAiB,EACjB,yBAAyB,EAEzB,yBAAyB,EACzB,4BAA4B,EAE5B,WAAW,GACZ,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAwC,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACtF,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM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AAsB;AACtB,MAAM,SAAS,GAAG,CAAC,UAAgB,EAA2B,EAAE,CAC9D,WAAW,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAChD,CAAC,IAAY,EAAgB,EAAE,CAAC,CAAC;IAC/B,IAAI;IACJ,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC;CAChE,CAAC,CACH,CAAA;AAEH,MAAM,QAAQ,GAAG,CAAC,SAA+B,EAAU,EAAE,CAC3D,GAAG,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,EAAE,CAAA;AAE1C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAgB,EAAc,EAAE;IAC1D,MAAM,UAAU,GAAoC,yBAAyB,CAAC;QAC5E,kBAAkB,EAAE,UAAU,CAAC,UAAU,CAAC;QAC1C,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC;QAChC,cAAc,EAAE,cAAc,CAAC,UAAU,CAAC;QAC1C,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC;KACjC,CAAC,CAAA;IACF,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC;QAC1B,CAAC,CAAC,MAAM,CACJ,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,6EAA6E,EACzG,UAAU,CAAC,GAAG,CAAC,CAAC,SAA+B,EAAU,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CACjF;QACH,CAAC,CAAC,MAAM,CAAC,qEAAqE,CAAC,CAAA;AACnF,CAAC,CAAA"}
|
package/dist/checks/install.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ import type { Repository as Repo } from '../context.js';
|
|
|
2
2
|
import { type GateResult } from '../exec.js';
|
|
3
3
|
/** The repository must name the dependencies permitted to run an install script. */
|
|
4
4
|
export declare const installScripts: (repo: Repo) => GateResult;
|
|
5
|
+
/** The repository must keep pnpm's release-age floor strict, and may exempt only the harness from it. */
|
|
6
|
+
export declare const releaseAge: (repo: Repo) => GateResult;
|
|
5
7
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/checks/install.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,IAAI,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;AAQ5D,oFAAoF;AACpF,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,KAAG,UAMpC,CAAA"}
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/checks/install.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,IAAI,IAAI,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;AAQ5D,oFAAoF;AACpF,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,KAAG,UAMpC,CAAA;AAIR,yGAAyG;AACzG,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,KAAG,UAQvC,CAAA"}
|
package/dist/checks/install.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// `pnpm install` - the broadest surface a project has for executing code it never called. The gate
|
|
5
5
|
// requires the allowlist to exist and says nothing about what is on it: which packages a project trusts
|
|
6
6
|
// with an install script is a decision for the project to record, not one the harness can make for it.
|
|
7
|
-
import { declaresInstallScriptAllowlist } from '@ploaness/governance';
|
|
7
|
+
import { declaresInstallScriptAllowlist, findReleaseAgeViolations } from '@ploaness/governance';
|
|
8
8
|
import { failed, passed } from '../exec.js';
|
|
9
9
|
const WORKSPACE_FILE = 'pnpm-workspace.yaml';
|
|
10
10
|
// The workspace file arrives already read, from the repository root. It used to be read relative to
|
|
@@ -18,4 +18,13 @@ export const installScripts = (repo) => declaresInstallScriptAllowlist(repo.work
|
|
|
18
18
|
`declare onlyBuiltDependencies in ${WORKSPACE_FILE}, or under the "pnpm" key of package.json`,
|
|
19
19
|
'an empty list is a valid answer: it permits no dependency to run an install script',
|
|
20
20
|
]);
|
|
21
|
+
// The same file, read the same way, for the other half of install policy: what pnpm may install at all.
|
|
22
|
+
// The decisions are in `install-policy.ts`; this hands over the file and names the gate.
|
|
23
|
+
/** The repository must keep pnpm's release-age floor strict, and may exempt only the harness from it. */
|
|
24
|
+
export const releaseAge = (repo) => {
|
|
25
|
+
const findings = findReleaseAgeViolations(repo.workspaceFile);
|
|
26
|
+
return findings.length > 0
|
|
27
|
+
? failed(`${String(findings.length)} release-age setting(s) weaken the floor pnpm enforces`, findings)
|
|
28
|
+
: passed('the release-age floor is strict, and only the harness is excluded from it');
|
|
29
|
+
};
|
|
21
30
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/checks/install.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,wGAAwG;AACxG,uGAAuG;AACvG,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/checks/install.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,wGAAwG;AACxG,uGAAuG;AACvG,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAE/F,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,cAAc,GAAW,qBAAqB,CAAA;AAEpD,oGAAoG;AACpG,uGAAuG;AACvG,kGAAkG;AAClG,uDAAuD;AACvD,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAU,EAAc,EAAE,CACvD,8BAA8B,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;IAClE,CAAC,CAAC,MAAM,CAAC,kEAAkE,CAAC;IAC5E,CAAC,CAAC,MAAM,CAAC,yCAAyC,EAAE;QAChD,oCAAoC,cAAc,2CAA2C;QAC7F,oFAAoF;KACrF,CAAC,CAAA;AAER,wGAAwG;AACxG,yFAAyF;AACzF,yGAAyG;AACzG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAc,EAAE;IACnD,MAAM,QAAQ,GAAsB,wBAAwB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAChF,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC;QACxB,CAAC,CAAC,MAAM,CACJ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,wDAAwD,EAClF,QAAQ,CACT;QACH,CAAC,CAAC,MAAM,CAAC,2EAA2E,CAAC,CAAA;AACzF,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Member } from '../context.js';
|
|
2
|
+
import { type GateResult } from '../exec.js';
|
|
3
|
+
/** Native core checks for every member, with accessibility only in the existing application scope. */
|
|
4
|
+
export declare const oxlint: (member: Member) => GateResult;
|
|
5
|
+
//# sourceMappingURL=oxlint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.d.ts","sourceRoot":"","sources":["../../src/checks/oxlint.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,MAAM,EAKZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAU,KAAK,UAAU,EAA+C,MAAM,YAAY,CAAA;AAsGjG,sGAAsG;AACtG,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,KAAG,UAmBvC,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { asRecord, asText, isEslintOwnedSuppression, isOxlintConfig, oxlintArguments, oxlintConfig, oxlintGroups, oxlintReportProblems, oxlintRuleNames, oxlintSourceFiles, oxlintSuppressionProblems, } from '@ploaness/governance';
|
|
5
|
+
import { cliDirectory, hasOwnRuntime, readJson, resolveTool, shippedDirectory, workingTreeFiles, } from '../context.js';
|
|
6
|
+
import { failed, passed, runNode, withOutput } from '../exec.js';
|
|
7
|
+
import { sourceComments } from '../source-comments.js';
|
|
8
|
+
const JSON_INDENT = 2;
|
|
9
|
+
const manifestIn = (directory) => asRecord(readJson(path.join(directory, 'package.json')));
|
|
10
|
+
const versionProblems = () => {
|
|
11
|
+
const cli = manifestIn(cliDirectory());
|
|
12
|
+
const expected = asText(asRecord(cli['dependencies'])['oxlint']);
|
|
13
|
+
const manifest = manifestIn(shippedDirectory('oxlint'));
|
|
14
|
+
return expected.length > 0 && manifest['version'] === expected
|
|
15
|
+
? []
|
|
16
|
+
: [`Oxlint must resolve to the harness-owned version ${expected}`];
|
|
17
|
+
};
|
|
18
|
+
const eligibleFiles = (member, inventory) => oxlintSourceFiles(inventory, member.settings.generatedArtefacts, member.siblingPaths).filter((file) => {
|
|
19
|
+
const absolute = path.join(member.root, file);
|
|
20
|
+
return existsSync(absolute) && statSync(absolute).isFile();
|
|
21
|
+
});
|
|
22
|
+
const suppressionProblems = (member, group) => group.files.flatMap((file) => {
|
|
23
|
+
const text = readFileSync(path.join(member.root, file), 'utf8');
|
|
24
|
+
const problems = oxlintSuppressionProblems(sourceComments(text, file), oxlintRuleNames(group.rules));
|
|
25
|
+
return problems.map((problem) => `${file}: ${problem}`);
|
|
26
|
+
});
|
|
27
|
+
const legacySitesIn = (member, files) => files.flatMap((file) => {
|
|
28
|
+
const text = readFileSync(path.join(member.root, file), 'utf8');
|
|
29
|
+
return sourceComments(text, file)
|
|
30
|
+
.filter(isEslintOwnedSuppression)
|
|
31
|
+
.map((comment) => ({ file, line: comment.line }));
|
|
32
|
+
});
|
|
33
|
+
const nativeVerdict = (result, group, legacy) => {
|
|
34
|
+
const findings = oxlintReportProblems(result.stdout, group.files.length, group.rules.length, { exitCode: result.code, output: result.output, legacy });
|
|
35
|
+
return withOutput(findings.length === 0
|
|
36
|
+
? passed(`${String(group.files.length)} source file(s) pass ${String(group.rules.length)} native rules`)
|
|
37
|
+
: failed('Oxlint did not establish conformance', [
|
|
38
|
+
...findings,
|
|
39
|
+
...(result.code === 0 ? [] : [result.output]),
|
|
40
|
+
]), result.output);
|
|
41
|
+
};
|
|
42
|
+
const analyze = (member, group) => {
|
|
43
|
+
const directory = mkdtempSync(path.join(tmpdir(), 'ploaness-oxlint-'));
|
|
44
|
+
try {
|
|
45
|
+
const config = path.join(directory, 'oxlint.json');
|
|
46
|
+
writeFileSync(config, `${JSON.stringify(oxlintConfig(group.rules), null, JSON_INDENT)}\n`);
|
|
47
|
+
const legacy = legacySitesIn(member, group.files);
|
|
48
|
+
return nativeVerdict(runNode(resolveTool('oxlint'), [...oxlintArguments(config, group.files)], {
|
|
49
|
+
cwd: member.root,
|
|
50
|
+
}), group, legacy);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
rmSync(directory, { recursive: true, force: true });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/** Run disjoint groups sequentially, preserving each invocation's measured coverage. */
|
|
57
|
+
const analyzeGroups = (member, groups) => {
|
|
58
|
+
const [first, ...rest] = groups;
|
|
59
|
+
if (first === undefined) {
|
|
60
|
+
return passed('no eligible source remains to analyze');
|
|
61
|
+
}
|
|
62
|
+
const result = analyze(member, first);
|
|
63
|
+
if (!result.ok || rest.length === 0) {
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
const remaining = analyzeGroups(member, rest);
|
|
67
|
+
return withOutput({ ...remaining, summary: `${result.summary}; ${remaining.summary}` }, [result.output, remaining.output].filter(Boolean).join('\n'));
|
|
68
|
+
};
|
|
69
|
+
/** Native core checks for every member, with accessibility only in the existing application scope. */
|
|
70
|
+
export const oxlint = (member) => {
|
|
71
|
+
const inventory = workingTreeFiles(member.root);
|
|
72
|
+
const groups = oxlintGroups(eligibleFiles(member, inventory), hasOwnRuntime(member));
|
|
73
|
+
const problems = [
|
|
74
|
+
...versionProblems(),
|
|
75
|
+
...inventory
|
|
76
|
+
.filter(isOxlintConfig)
|
|
77
|
+
.map((file) => `${file}: Oxlint configuration is owned by ploaness`),
|
|
78
|
+
...groups.flatMap((group) => suppressionProblems(member, group)),
|
|
79
|
+
];
|
|
80
|
+
if (problems.length > 0) {
|
|
81
|
+
return failed('Oxlint wiring or suppression policy is violated', problems);
|
|
82
|
+
}
|
|
83
|
+
return analyzeGroups(member, groups);
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=oxlint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../../src/checks/oxlint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EACL,QAAQ,EACR,MAAM,EACN,wBAAwB,EACxB,cAAc,EAGd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,GAE1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,YAAY,EACZ,aAAa,EAEb,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAkB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACj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CAA6C,CAAC;QACtF,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAkB,EAAqB,EAAE,CAC1D,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CACnC;KACF,CAAA;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,iDAAiD,EAAE,QAAQ,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
package/dist/checks/payload.d.ts
CHANGED
|
@@ -2,6 +2,17 @@ import { type Context, type Member } from '../context.js';
|
|
|
2
2
|
import { type GateResult } from '../exec.js';
|
|
3
3
|
/** Regenerate the Payload types and admin import map, then fail on any drift. */
|
|
4
4
|
export declare const payloadGenerated: (context: Context) => GateResult;
|
|
5
|
+
/**
|
|
6
|
+
* Every collection and global in the BUILT configuration decides its access.
|
|
7
|
+
*
|
|
8
|
+
* The static rule reads the access blocks a project wrote; this one imports the configuration Payload
|
|
9
|
+
* actually boots, so the collections the framework builds for the project - the folder tree, the job
|
|
10
|
+
* queue, a plugin's own - are judged too. Each of those arrives with Payload's default, which admits
|
|
11
|
+
* every signed-in user, and the anonymous sweep cannot see that because a signed-in user is not
|
|
12
|
+
* anonymous. The harness's own tsx loads the configuration against the project's tsconfig, with the
|
|
13
|
+
* project root as the working directory so `payload` resolves from the project.
|
|
14
|
+
*/
|
|
15
|
+
export declare const payloadDefaults: (context: Member) => GateResult;
|
|
5
16
|
/** Apply the source rules to every TypeScript file under the declared source roots. */
|
|
6
17
|
export declare const payloadRules: (context: Member) => GateResult;
|
|
7
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/checks/payload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/checks/payload.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,KAAK,UAAU,EAKhB,MAAM,YAAY,CAAA;AA2BnB,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,UAgDnD,CAAA;AAuDD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,UA6CjD,CAAA;AAuCD,uFAAuF;AACvF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,UAmB9C,CAAA;AAOD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,KAAG,UAmC5C,CAAA"}
|
package/dist/checks/payload.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// and the Local API must be used in a way that neither over-fetches nor skips access control.
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { findDeclaredAdminViews, findGeneratedDrift, findPayloadViolations, findSourceViolations, findUnguardedRelationships, findUnscannedAdminViews, } from '@ploaness/governance';
|
|
6
|
-
import { git, resolveProjectTool, runEnvironment, workingTreeFiles, } from '../context.js';
|
|
7
|
-
import { asFindings, failed, passed, runNode } from '../exec.js';
|
|
5
|
+
import { findDeclaredAdminViews, findEndpointViolations, findGeneratedDrift, findInheritedAccess, findPayloadViolations, findSourceViolations, findUnconstrainedDraftReads, findUnguardedRelationships, findUnscannedAdminViews, parseInheritedAccessReport, payloadConfigPathOf, } from '@ploaness/governance';
|
|
6
|
+
import { cliDirectory, git, manifestPathFrom, readJson, resolveProjectTool, resolveTool, runEnvironment, workingTreeFiles, } from '../context.js';
|
|
7
|
+
import { asFindings, failed, passed, runNode, withOutput, } from '../exec.js';
|
|
8
8
|
// Resolution failure is an answer rather than an exception the caller must catch.
|
|
9
9
|
const resolveProjectToolOrUndefined = (context, tool) => {
|
|
10
10
|
try {
|
|
@@ -75,14 +75,111 @@ export const payloadGenerated = (context) => {
|
|
|
75
75
|
])
|
|
76
76
|
: passed('the generated Payload artefacts match the configuration');
|
|
77
77
|
};
|
|
78
|
+
// Where Payload keeps the function it fills an undeclared operation with. Named by path because the
|
|
79
|
+
// package's exports map does not expose it; ploaness pins `payload` exactly, so a layout change arrives
|
|
80
|
+
// with a ploaness release rather than silently, and an absent file fails closed below.
|
|
81
|
+
const DEFAULT_ACCESS_MODULE = ['dist', 'auth', 'defaultAccess.js'];
|
|
82
|
+
const PROBE_FILE = ['dist', 'probes', 'payload-defaults.probe.js'];
|
|
83
|
+
// Building a configuration opens no socket, but a plugin might, and a hung import must end as a verdict.
|
|
84
|
+
const PROBE_TIMEOUT_MS = 120_000;
|
|
85
|
+
const defaultAccessFileOf = (context) => {
|
|
86
|
+
const manifest = manifestPathFrom('payload', path.join(context.root, 'package.json'));
|
|
87
|
+
return manifest === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: path.join(path.dirname(manifest), ...DEFAULT_ACCESS_MODULE);
|
|
90
|
+
};
|
|
91
|
+
// The two defects the report can carry, named separately so the summary says which one was found
|
|
92
|
+
// rather than counting them together under whichever wording came first.
|
|
93
|
+
const summariseAccessFindings = (inherited, draftReads) => {
|
|
94
|
+
const parts = [
|
|
95
|
+
...(inherited > 0
|
|
96
|
+
? [`${String(inherited)} collection(s) or global(s) inherit Payload's default access`]
|
|
97
|
+
: []),
|
|
98
|
+
...(draftReads > 0
|
|
99
|
+
? [`${String(draftReads)} drafts read(s) serve an unapproved document to a stranger`]
|
|
100
|
+
: []),
|
|
101
|
+
];
|
|
102
|
+
return parts.join('; ');
|
|
103
|
+
};
|
|
104
|
+
// The probe's outcome, once it ran: a report that was not printed, or not readable, is a failure of its
|
|
105
|
+
// own rather than an empty finding list, because nothing else stands between a crashed probe and a pass.
|
|
106
|
+
const judgeProbe = (result) => {
|
|
107
|
+
if (result.code !== 0) {
|
|
108
|
+
return failed('the Payload configuration could not be built', asFindings(result.output));
|
|
109
|
+
}
|
|
110
|
+
const report = parseInheritedAccessReport(result.stdout);
|
|
111
|
+
if (report === undefined) {
|
|
112
|
+
return failed('the access probe printed no readable report', asFindings(result.output));
|
|
113
|
+
}
|
|
114
|
+
const inherited = findInheritedAccess(report);
|
|
115
|
+
const draftReads = findUnconstrainedDraftReads(report);
|
|
116
|
+
const findings = [...inherited, ...draftReads];
|
|
117
|
+
return findings.length > 0
|
|
118
|
+
? failed(summariseAccessFindings(inherited.length, draftReads.length), findings)
|
|
119
|
+
: passed('every collection and global decides its access, framework-built ones included, and no ' +
|
|
120
|
+
'drafts read serves an unapproved document to a stranger');
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Every collection and global in the BUILT configuration decides its access.
|
|
124
|
+
*
|
|
125
|
+
* The static rule reads the access blocks a project wrote; this one imports the configuration Payload
|
|
126
|
+
* actually boots, so the collections the framework builds for the project - the folder tree, the job
|
|
127
|
+
* queue, a plugin's own - are judged too. Each of those arrives with Payload's default, which admits
|
|
128
|
+
* every signed-in user, and the anonymous sweep cannot see that because a signed-in user is not
|
|
129
|
+
* anonymous. The harness's own tsx loads the configuration against the project's tsconfig, with the
|
|
130
|
+
* project root as the working directory so `payload` resolves from the project.
|
|
131
|
+
*/
|
|
132
|
+
export const payloadDefaults = (context) => {
|
|
133
|
+
const tsconfig = path.join(context.root, 'tsconfig.json');
|
|
134
|
+
const configPath = payloadConfigPathOf(readJson(tsconfig));
|
|
135
|
+
const configFile = path.join(context.root, configPath);
|
|
136
|
+
if (!existsSync(configFile)) {
|
|
137
|
+
return failed('the Payload configuration could not be found', [
|
|
138
|
+
`${configPath} does not exist; a Payload member names its configuration under ` +
|
|
139
|
+
'compilerOptions.paths["@payload-config"] in tsconfig.json, which `ploaness init` writes',
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
const defaultAccessFile = defaultAccessFileOf(context);
|
|
143
|
+
if (defaultAccessFile === undefined) {
|
|
144
|
+
return failed('payload could not be resolved from the project', [
|
|
145
|
+
'ploaness governs Payload projects, so "payload" must be installed in the project itself',
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
if (!existsSync(defaultAccessFile)) {
|
|
149
|
+
return failed("Payload's default access could not be located", [
|
|
150
|
+
`${defaultAccessFile} is missing; ploaness knows the layout of the Payload version it pins, ` +
|
|
151
|
+
'and this installation differs',
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
const result = runNode(resolveTool('tsx'), [
|
|
155
|
+
'--tsconfig',
|
|
156
|
+
tsconfig,
|
|
157
|
+
path.join(cliDirectory(), ...PROBE_FILE),
|
|
158
|
+
configFile,
|
|
159
|
+
defaultAccessFile,
|
|
160
|
+
], {
|
|
161
|
+
cwd: context.root,
|
|
162
|
+
// The placeholders every analyzer that imports the project receives, then the project's own
|
|
163
|
+
// environment, then the one option ploaness owns: the same layering the knip and generated gates
|
|
164
|
+
// use, so a configuration that validates `process.env` on import survives here as it does there.
|
|
165
|
+
env: {
|
|
166
|
+
...context.settings.analysisEnv,
|
|
167
|
+
...runEnvironment(context),
|
|
168
|
+
NODE_OPTIONS: '--no-deprecation',
|
|
169
|
+
},
|
|
170
|
+
timeoutMs: PROBE_TIMEOUT_MS,
|
|
171
|
+
});
|
|
172
|
+
return withOutput(judgeProbe(result), result.output);
|
|
173
|
+
};
|
|
78
174
|
const SOURCE_EXTENSIONS = ['.ts', '.tsx'];
|
|
79
175
|
// The language rules apply to every package; the Payload ones only to a package that has Payload to
|
|
80
176
|
// misuse. Held together, the import rule ran only where Payload did - so a frontend beside the CMS, the
|
|
81
177
|
// place a parent-relative import is MOST likely because it has no Payload config to anchor on, was the
|
|
82
178
|
// one package never checked for it.
|
|
83
|
-
const violationsIn = (
|
|
84
|
-
...findSourceViolations(source),
|
|
85
|
-
...(isPayload ? findPayloadViolations(source) : []),
|
|
179
|
+
const violationsIn = (file, isPayload) => [
|
|
180
|
+
...findSourceViolations(file.source),
|
|
181
|
+
...(isPayload ? findPayloadViolations(file.source) : []),
|
|
182
|
+
...(isPayload ? findEndpointViolations(file.path, file.source) : []),
|
|
86
183
|
];
|
|
87
184
|
const sourceCandidates = (context) => {
|
|
88
185
|
const roots = context.settings.sourceRoots;
|
|
@@ -107,7 +204,7 @@ export const payloadRules = (context) => {
|
|
|
107
204
|
source: readFileSync(path.join(context.root, file), 'utf8'),
|
|
108
205
|
}));
|
|
109
206
|
const findings = [
|
|
110
|
-
...files.flatMap((file) => violationsIn(file
|
|
207
|
+
...files.flatMap((file) => violationsIn(file, context.isPayload).map((violation) => reported(file.path, violation))),
|
|
111
208
|
...crossFileFindings(context, files),
|
|
112
209
|
];
|
|
113
210
|
return findings.length > 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.js","sourceRoot":"","sources":["../../src/checks/payload.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,8FAA8F;AAC9F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"payload.js","sourceRoot":"","sources":["../../src/checks/payload.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,8FAA8F;AAC9F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAEL,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EAIvB,0BAA0B,EAC1B,mBAAmB,GAGpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAEL,YAAY,EACZ,GAAG,EAEH,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EA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CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,uCAAuC,EAAE,QAAQ,CAAC,CAAA;IAC5F,CAAC;IACD,MAAM,KAAK,GAAW,QAAQ,CAAC,MAAM,CACnC,CAAC,KAAa,EAAE,CAAC,EAAE,KAAK,CAAsD,EAAU,EAAE,CACxF,KAAK,GAAG,KAAK,CAAC,MAAM,EACtB,CAAC,CACF,CAAA;IACD,OAAO,MAAM,CACX,KAAK,KAAK,CAAC;QACT,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,qDAAqD,CAC1E,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Member } from '../context.js';
|
|
2
2
|
import { type GateResult } from '../exec.js';
|
|
3
3
|
/** Count suppressions and source lines across the project's own code. */
|
|
4
|
-
export declare const suppressions: (context:
|
|
4
|
+
export declare const suppressions: (context: Member) => GateResult;
|
|
5
5
|
//# sourceMappingURL=suppressions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suppressions.d.ts","sourceRoot":"","sources":["../../src/checks/suppressions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"suppressions.d.ts","sourceRoot":"","sources":["../../src/checks/suppressions.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,MAAM,EAAoB,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;AAgD5D,yEAAyE;AACzE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,UA4C9C,CAAA"}
|
|
@@ -7,33 +7,53 @@
|
|
|
7
7
|
// a separate informational report such as dependency freshness.
|
|
8
8
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import { countSourceLines, findSuppressions, isGovernedCode, judgeSuppressions, } from '@ploaness/governance';
|
|
10
|
+
import { countSourceLines, findSuppressions, hasExtension, isGovernedCode, isOxlintSuppression, judgeSuppressions, OXLINT_EXTENSIONS, oxlintSourceFiles, } from '@ploaness/governance';
|
|
11
11
|
import { workingTreeFiles } from '../context.js';
|
|
12
12
|
import { failed, passed } from '../exec.js';
|
|
13
|
+
import { sourceComments } from '../source-comments.js';
|
|
13
14
|
import { managedPaths } from './assets.js';
|
|
14
15
|
const isUnderSourceRoots = (file, sourceRoots) => sourceRoots.some((sourceRoot) => file.startsWith(`${sourceRoot}/`));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const sitesOf = (scanned) => [
|
|
17
|
+
...findSuppressions(scanned.file, scanned.content),
|
|
18
|
+
...(hasExtension(scanned.file, OXLINT_EXTENSIONS)
|
|
19
|
+
? sourceComments(scanned.content, scanned.file)
|
|
20
|
+
.filter(isOxlintSuppression)
|
|
21
|
+
.map((comment) => ({
|
|
22
|
+
file: scanned.file,
|
|
23
|
+
line: comment.line,
|
|
24
|
+
token: 'oxlint-disable',
|
|
25
|
+
}))
|
|
26
|
+
: []),
|
|
27
|
+
];
|
|
28
|
+
const eligibleFiles = (context, inventory, native) => {
|
|
21
29
|
const managed = managedPaths(context);
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
const excluded = context.settings.typographyExclusions;
|
|
31
|
+
return inventory.filter((file) => {
|
|
24
32
|
const full = path.join(context.root, file);
|
|
25
|
-
return (
|
|
33
|
+
return ((hasExtension(file, OXLINT_EXTENSIONS)
|
|
34
|
+
? native.has(file)
|
|
35
|
+
: isUnderSourceRoots(file, context.settings.sourceRoots)) &&
|
|
26
36
|
!managed.has(file) &&
|
|
27
37
|
isGovernedCode(file, excluded) &&
|
|
28
38
|
existsSync(full) &&
|
|
29
39
|
statSync(full).isFile());
|
|
30
40
|
});
|
|
41
|
+
};
|
|
42
|
+
/** Count suppressions and source lines across the project's own code. */
|
|
43
|
+
export const suppressions = (context) => {
|
|
44
|
+
// A managed file is ploaness's, byte for byte, and the project can neither remove a suppression
|
|
45
|
+
// inside it nor be asked to justify one. Its lines are left out of the denominator for the same
|
|
46
|
+
// reason: a ceiling earned by code the project did not write would be an allowance, not a measure.
|
|
47
|
+
// An enumerated path is not always a regular file: a symlink and a submodule gitlink both appear here.
|
|
48
|
+
const inventory = workingTreeFiles(context.root);
|
|
49
|
+
const native = new Set(oxlintSourceFiles(inventory, context.settings.generatedArtefacts, context.siblingPaths));
|
|
50
|
+
const files = eligibleFiles(context, inventory, native);
|
|
31
51
|
// Read once, then derive both figures from the same contents rather than accumulating as we go.
|
|
32
52
|
const contents = files.map((file) => ({
|
|
33
53
|
file,
|
|
34
54
|
content: readFileSync(path.join(context.root, file), 'utf8'),
|
|
35
55
|
}));
|
|
36
|
-
const sites = contents.flatMap((scanned) =>
|
|
56
|
+
const sites = contents.flatMap((scanned) => sitesOf(scanned));
|
|
37
57
|
const sourceLines = contents.reduce((total, scanned) => total + countSourceLines(scanned.content), 0);
|
|
38
58
|
const report = judgeSuppressions(sites, sourceLines, context.settings.maxSuppressions);
|
|
39
59
|
const summary = `${String(report.count)} of ${String(report.ceiling)} permitted, ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suppressions.js","sourceRoot":"","sources":["../../src/checks/suppressions.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,EAAE;AACF,uGAAuG;AACvG,wGAAwG;AACxG,kGAAkG;AAClG,wGAAwG;AACxG,gEAAgE;AAChE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,
|
|
1
|
+
{"version":3,"file":"suppressions.js","sourceRoot":"","sources":["../../src/checks/suppressions.ts"],"names":[],"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I,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CACrF;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/dist/checks/tree.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/checks/tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/checks/tree.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;AAY5D,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,UAK/C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,UAe7C,CAAA"}
|
package/dist/checks/tree.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
// Working-tree integrity: a fingerprint taken before the gates, and checked again after. Verification must
|
|
2
|
-
// judge the tree the project committed, not one a gate quietly rewrote as a side effect. A formatter or
|
|
3
|
-
// a code generator that edits during `verify` would otherwise let a build pass on content that is not in
|
|
4
|
-
// the repository, and the next clean checkout would fail.
|
|
5
|
-
import { createHash } from 'node:crypto';
|
|
6
|
-
import { readFileSync, statSync } from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { workingTreeFiles } from '../context.js';
|
|
9
1
|
import { failed, passed } from '../exec.js';
|
|
10
|
-
|
|
11
|
-
const hash = createHash('sha256');
|
|
12
|
-
for (const file of workingTreeFiles(context.root)) {
|
|
13
|
-
const full = path.join(context.root, file);
|
|
14
|
-
hash.update(file);
|
|
15
|
-
try {
|
|
16
|
-
hash.update(statSync(full).isFile() ? readFileSync(full) : Buffer.alloc(0));
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
// An indexed-but-deleted path contributes its name only, so deleting one still changes the digest.
|
|
20
|
-
hash.update('<absent>');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return hash.digest('hex');
|
|
24
|
-
};
|
|
2
|
+
import { workingTreeFingerprint } from '../working-tree.js';
|
|
25
3
|
// The fingerprint is taken by one gate and compared by another, so it must outlive both calls, and
|
|
26
4
|
// there is no channel between gates to carry it as a value.
|
|
27
5
|
// eslint-disable-next-line functional/no-let -- must outlive two separate gate invocations
|
|
@@ -32,7 +10,7 @@ const FINGERPRINT_PREVIEW = 12;
|
|
|
32
10
|
export const treeSnapshot = (context) => {
|
|
33
11
|
// Recording state the later tree-verify gate reads is this gate's whole purpose.
|
|
34
12
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- see the binding above
|
|
35
|
-
snapshot =
|
|
13
|
+
snapshot = workingTreeFingerprint(context.root);
|
|
36
14
|
return passed(`tree fingerprint recorded (${snapshot.slice(0, FINGERPRINT_PREVIEW)})`);
|
|
37
15
|
};
|
|
38
16
|
/**
|
|
@@ -45,9 +23,11 @@ export const treeSnapshot = (context) => {
|
|
|
45
23
|
*/
|
|
46
24
|
export const treeVerify = (context) => {
|
|
47
25
|
if (snapshot === undefined) {
|
|
48
|
-
return
|
|
26
|
+
return failed('no tree snapshot was taken', [
|
|
27
|
+
'run complete verification to establish tree integrity',
|
|
28
|
+
]);
|
|
49
29
|
}
|
|
50
|
-
const current =
|
|
30
|
+
const current = workingTreeFingerprint(context.root);
|
|
51
31
|
return current === snapshot
|
|
52
32
|
? passed('the working tree is unchanged since verification began')
|
|
53
33
|
: failed('the working tree changed during verification', [
|
package/dist/checks/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/checks/tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/checks/tree.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAmB,MAA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
/**
|
|
4
|
+
* Every version ploaness decides for a project that declares the name: the analyzers read from the
|
|
5
|
+
* harness's own manifests, the framework pins from `pins.json`, and the runtime package at the release.
|
|
6
|
+
*
|
|
7
|
+
* Exported because the `deps` gate sorts its report by whose repair a finding is, and "a version the
|
|
8
|
+
* project declares but may not change" is precisely this map's key set. Read here rather than rebuilt
|
|
9
|
+
* there, so the report and the wiring gate cannot disagree about whose version a name is.
|
|
10
|
+
* @returns the pinned names, each mapped to the exact version the project must declare.
|
|
11
|
+
*/
|
|
12
|
+
export declare const harnessDecidedVersions: () => Readonly<Record<string, string>>;
|
|
3
13
|
/** Verify the repository and each of its members have installed ploaness exactly as ploaness dictates. */
|
|
4
14
|
export declare const wiring: (repository: Repository) => GateResult;
|
|
5
15
|
//# sourceMappingURL=wiring.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../src/checks/wiring.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,UAAU,EAKhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../src/checks/wiring.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,UAAU,EAKhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAU,KAAK,UAAU,EAAU,MAAM,YAAY,CAAA;AAgH5D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBxE,CAAA;AA6GD,0GAA0G;AAC1G,eAAO,MAAM,MAAM,GAAI,YAAY,UAAU,KAAG,UAyB/C,CAAA"}
|
package/dist/checks/wiring.js
CHANGED
|
@@ -85,11 +85,23 @@ const declaredBy = (packageName) => {
|
|
|
85
85
|
const requiredPackages = (kind) => new Set(pinGroups()
|
|
86
86
|
.filter((group) => group.requiredFor.includes(kind))
|
|
87
87
|
.flatMap((group) => Object.keys(group.versions)));
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Every version ploaness decides for a project that declares the name: the analyzers read from the
|
|
90
|
+
* harness's own manifests, the framework pins from `pins.json`, and the runtime package at the release.
|
|
91
|
+
*
|
|
92
|
+
* Exported because the `deps` gate sorts its report by whose repair a finding is, and "a version the
|
|
93
|
+
* project declares but may not change" is precisely this map's key set. Read here rather than rebuilt
|
|
94
|
+
* there, so the report and the wiring gate cannot disagree about whose version a name is.
|
|
95
|
+
* @returns the pinned names, each mapped to the exact version the project must declare.
|
|
96
|
+
*/
|
|
97
|
+
export const harnessDecidedVersions = () => {
|
|
89
98
|
// Built from one flat list of entries rather than by folding an object into itself: a later source
|
|
90
99
|
// still wins, because `fromEntries` keeps the last entry for a repeated key.
|
|
91
100
|
const declared = Object.fromEntries(VERSION_SOURCES.flatMap((source) => Object.entries(declaredBy(source))));
|
|
92
|
-
const fromDependencies = asStringRecord(Object.fromEntries(TEST_LIBRARY_NAMES.map((name) => [
|
|
101
|
+
const fromDependencies = asStringRecord(Object.fromEntries([...TEST_LIBRARY_NAMES, 'oxlint'].map((name) => [
|
|
102
|
+
name,
|
|
103
|
+
declared[name],
|
|
104
|
+
])));
|
|
93
105
|
return { ...fromDependencies, ...ownedVersions(), ...harnessRuntimeVersion() };
|
|
94
106
|
};
|
|
95
107
|
/**
|
|
@@ -148,7 +160,7 @@ const memberViolations = (member) => {
|
|
|
148
160
|
declaredExclusions: member.settings.declaredExclusions,
|
|
149
161
|
biomeConfig: readText(path.join(member.root, 'biome.json')),
|
|
150
162
|
tsconfig: readText(path.join(member.root, 'tsconfig.json')),
|
|
151
|
-
expectedTestLibraries:
|
|
163
|
+
expectedTestLibraries: harnessDecidedVersions(),
|
|
152
164
|
requiredTestLibraries: requiredFor(kind),
|
|
153
165
|
payloadVersion: ownedVersions()['payload'],
|
|
154
166
|
});
|
|
@@ -181,7 +193,7 @@ export const wiring = (repository) => {
|
|
|
181
193
|
packageJson: repository.packageJson,
|
|
182
194
|
workspaceFile: repository.workspaceFile,
|
|
183
195
|
declaredExclusions: repository.settings.declaredExclusions,
|
|
184
|
-
expectedTestLibraries:
|
|
196
|
+
expectedTestLibraries: harnessDecidedVersions(),
|
|
185
197
|
requiredPackageManager: asOptionalText(readPins()['packageManager']),
|
|
186
198
|
requiredEngines: asStringRecord(readPins()['engines']),
|
|
187
199
|
declaredAcrossMembers: declaredEverywhere(repository),
|