@warlock.js/grimoire 5.63.1 → 5.65.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/CHANGELOG.md +61 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +24 -2
- package/esm/book/build.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +11 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/api-snapshot.mjs +39 -0
- package/esm/check/rules/api-snapshot.mjs.map +1 -0
- package/esm/check/rules/code-rules.mjs +45 -0
- package/esm/check/rules/code-rules.mjs.map +1 -0
- package/esm/check/rules/drift.mjs +54 -0
- package/esm/check/rules/drift.mjs.map +1 -0
- package/esm/check/rules/focused-tests.mjs +39 -0
- package/esm/check/rules/focused-tests.mjs.map +1 -0
- package/esm/check/rules/shows.mjs +52 -0
- package/esm/check/rules/shows.mjs.map +1 -0
- package/esm/codes/codes.d.mts +48 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +26 -1
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/guard.d.mts +104 -0
- package/esm/contracts/guard.d.mts.map +1 -0
- package/esm/contracts/index.mjs +5 -0
- package/esm/contracts/matrix.d.mts +75 -0
- package/esm/contracts/matrix.d.mts.map +1 -0
- package/esm/contracts/scry.d.mts +42 -0
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/settings.d.mts +71 -0
- package/esm/contracts/settings.d.mts.map +1 -0
- package/esm/contracts/settings.mjs +67 -0
- package/esm/contracts/settings.mjs.map +1 -0
- package/esm/contracts/shots.d.mts +146 -0
- package/esm/contracts/shots.d.mts.map +1 -0
- package/esm/contracts/snapshot.d.mts +10 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +13 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs +7 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/approvals.mjs +59 -0
- package/esm/devtools/approvals.mjs.map +1 -0
- package/esm/devtools/data.mjs +2 -0
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/graphs.mjs +13 -3
- package/esm/devtools/graphs.mjs.map +1 -1
- package/esm/devtools/index.d.mts +7 -0
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +33 -3
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/matrix.mjs +207 -0
- package/esm/devtools/matrix.mjs.map +1 -0
- package/esm/devtools/product-map.d.mts.map +1 -1
- package/esm/devtools/product-map.mjs +87 -1
- package/esm/devtools/product-map.mjs.map +1 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +12 -3
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +13 -3
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/git/index.d.mts +20 -0
- package/esm/git/index.d.mts.map +1 -0
- package/esm/git/index.mjs +280 -0
- package/esm/git/index.mjs.map +1 -0
- package/esm/guard/api.mjs +70 -0
- package/esm/guard/api.mjs.map +1 -0
- package/esm/guard/assertions.mjs +18 -0
- package/esm/guard/assertions.mjs.map +1 -0
- package/esm/guard/collect.mjs +139 -0
- package/esm/guard/collect.mjs.map +1 -0
- package/esm/guard/format.mjs +27 -0
- package/esm/guard/format.mjs.map +1 -0
- package/esm/guard/glob.mjs +79 -0
- package/esm/guard/glob.mjs.map +1 -0
- package/esm/guard/index.mjs +9 -0
- package/esm/guard/rules.mjs +310 -0
- package/esm/guard/rules.mjs.map +1 -0
- package/esm/guard/scope.mjs +95 -0
- package/esm/guard/scope.mjs.map +1 -0
- package/esm/index.d.mts +10 -3
- package/esm/index.mjs +6 -2
- package/esm/paths/index.d.mts +15 -1
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +27 -3
- package/esm/paths/index.mjs.map +1 -1
- package/esm/proves/index.mjs +2 -1
- package/esm/proves/scan-proofs.mjs +1 -1
- package/esm/proves/scan-proofs.mjs.map +1 -1
- package/esm/proves/scan-shows.d.mts +21 -0
- package/esm/proves/scan-shows.d.mts.map +1 -0
- package/esm/proves/scan-shows.mjs +168 -0
- package/esm/proves/scan-shows.mjs.map +1 -0
- package/esm/releases/index.d.mts.map +1 -1
- package/esm/releases/index.mjs +5 -3
- package/esm/releases/index.mjs.map +1 -1
- package/esm/releases/stamp.mjs +121 -0
- package/esm/releases/stamp.mjs.map +1 -0
- package/esm/rules/focused.mjs +26 -0
- package/esm/rules/focused.mjs.map +1 -0
- package/esm/rules/index.mjs +88 -0
- package/esm/rules/index.mjs.map +1 -0
- package/esm/rules/logical-css.mjs +112 -0
- package/esm/rules/logical-css.mjs.map +1 -0
- package/esm/rules/no-js-imports.mjs +22 -0
- package/esm/rules/no-js-imports.mjs.map +1 -0
- package/esm/rules/scan.mjs +196 -0
- package/esm/rules/scan.mjs.map +1 -0
- package/esm/rules/specific-errors.mjs +51 -0
- package/esm/rules/specific-errors.mjs.map +1 -0
- package/esm/rules/type-discriminator.mjs +27 -0
- package/esm/rules/type-discriminator.mjs.map +1 -0
- package/esm/scry/also-changes.mjs +107 -0
- package/esm/scry/also-changes.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +35 -0
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +40 -2
- package/esm/scry/query.mjs.map +1 -1
- package/esm/scry/search.d.mts.map +1 -1
- package/esm/scry/search.mjs +43 -11
- package/esm/scry/search.mjs.map +1 -1
- package/esm/shots/approve.mjs +195 -0
- package/esm/shots/approve.mjs.map +1 -0
- package/esm/shots/drift.mjs +174 -0
- package/esm/shots/drift.mjs.map +1 -0
- package/esm/shots/png.mjs +166 -0
- package/esm/shots/png.mjs.map +1 -0
- package/esm/shots/state.mjs +43 -0
- package/esm/shots/state.mjs.map +1 -0
- package/esm/shots/store.mjs +66 -0
- package/esm/shots/store.mjs.map +1 -0
- package/esm/shots/touched.mjs +38 -0
- package/esm/shots/touched.mjs.map +1 -0
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +22 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/api-command.mjs +41 -0
- package/esm/warlock/api-command.mjs.map +1 -0
- package/esm/warlock/approve-command.mjs +80 -0
- package/esm/warlock/approve-command.mjs.map +1 -0
- package/esm/warlock/collect-off-thread.mjs +66 -0
- package/esm/warlock/collect-off-thread.mjs.map +1 -0
- package/esm/warlock/commands.d.mts +1 -1
- package/esm/warlock/commands.d.mts.map +1 -1
- package/esm/warlock/commands.mjs +61 -8
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/guard-command.mjs +116 -0
- package/esm/warlock/guard-command.mjs.map +1 -0
- package/esm/warlock/index.d.mts +2 -1
- package/esm/warlock/index.mjs +2 -1
- package/esm/warlock/languages.mjs +75 -0
- package/esm/warlock/languages.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +2 -2
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/warlock/release-command.mjs +65 -0
- package/esm/warlock/release-command.mjs.map +1 -0
- package/esm/warlock/shows.d.mts +35 -0
- package/esm/warlock/shows.d.mts.map +1 -0
- package/esm/warlock/shows.mjs +195 -0
- package/esm/warlock/shows.mjs.map +1 -0
- package/esm/workspace/cache.mjs +4 -1
- package/esm/workspace/cache.mjs.map +1 -1
- package/esm/workspace/derived.mjs +11 -6
- package/esm/workspace/derived.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +8 -1
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/workspace/stored.mjs +4 -1
- package/esm/workspace/stored.mjs.map +1 -1
- package/esm/written/features.mjs +21 -5
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/index.mjs +2 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +16 -3
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/esm/written/settings.d.mts +11 -0
- package/esm/written/settings.d.mts.map +1 -0
- package/esm/written/settings.mjs +88 -0
- package/esm/written/settings.mjs.map +1 -0
- package/llms-full.txt +282 -39
- package/llms.txt +2 -0
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +4 -0
- package/skills/describe-an-app/SKILL.md +4 -1
- package/skills/guard-a-change/SKILL.md +85 -0
- package/skills/index.md +7 -3
- package/skills/record-a-change/SKILL.md +52 -16
- package/skills/review-a-change/SKILL.md +53 -0
- package/skills/use-the-grimoire/SKILL.md +27 -18
- package/skills/write-a-feature/SKILL.md +42 -1
- package/ui/grimoire-view.js +756 -40
- package/ui/grimoire.css +303 -28
- package/ui/product-map.css +43 -7
- package/ui/product-map.js +212 -37
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { CODE_RULES } from "../contracts/settings.mjs";
|
|
2
|
+
import { createFinding } from "../codes/index.mjs";
|
|
3
|
+
import { scanProofsInText } from "../proves/scan-proofs.mjs";
|
|
4
|
+
import "../proves/index.mjs";
|
|
5
|
+
import { describeRouteDiff, diffRoutes } from "./api.mjs";
|
|
6
|
+
import { runCodeRules } from "../rules/index.mjs";
|
|
7
|
+
import { findFocusedTests } from "../rules/focused.mjs";
|
|
8
|
+
import { countAssertions } from "./assertions.mjs";
|
|
9
|
+
import { matchesAny } from "./glob.mjs";
|
|
10
|
+
import { scopeFeatures, scopeFlows } from "./scope.mjs";
|
|
11
|
+
|
|
12
|
+
//#region ../../packages/grimoire/src/guard/rules.ts
|
|
13
|
+
/**
|
|
14
|
+
* The guard's rules: a pure function over a {@link GuardInput}. No git and
|
|
15
|
+
* no file is read here, so every rule is tested with plain data.
|
|
16
|
+
*/
|
|
17
|
+
const TEST_FILE = /(?:\.(?:test|spec|e2e)\.[cm]?[jt]sx?$|(?:^|\/)(?:tests?|e2e|__tests__)\/)/;
|
|
18
|
+
const DEPENDENCY_SECTIONS = [
|
|
19
|
+
"dependencies",
|
|
20
|
+
"devDependencies",
|
|
21
|
+
"peerDependencies",
|
|
22
|
+
"optionalDependencies"
|
|
23
|
+
];
|
|
24
|
+
/** Whether a path is a test file by name or folder. */
|
|
25
|
+
function isTestPath(file) {
|
|
26
|
+
return TEST_FILE.test(file);
|
|
27
|
+
}
|
|
28
|
+
function at(file, line) {
|
|
29
|
+
return {
|
|
30
|
+
file,
|
|
31
|
+
line: line ?? 1,
|
|
32
|
+
column: null
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The paths of a change: each file, and the old path of a rename. */
|
|
36
|
+
function pathsOf(input) {
|
|
37
|
+
return input.changed.flatMap((change) => change.from === null ? [change.file] : [change.file, change.from]);
|
|
38
|
+
}
|
|
39
|
+
/** Whether `removes` names this feature, flow, criterion or case (a wider entry covers what is inside it). */
|
|
40
|
+
function isRemoved(scope, feature, flow, criterion, caseQuestion) {
|
|
41
|
+
return scope.removes.some((entry) => {
|
|
42
|
+
if (entry.feature !== feature) return false;
|
|
43
|
+
if (entry.flow === null) return true;
|
|
44
|
+
if (flow === void 0 || entry.flow !== flow) return false;
|
|
45
|
+
if (entry.criterion === null && entry.case === null) return true;
|
|
46
|
+
return criterion !== void 0 && entry.criterion === criterion.toUpperCase() || caseQuestion !== void 0 && entry.case === caseQuestion.toLowerCase();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** The files a task allows (everything else that changes is GR7006). */
|
|
50
|
+
function allowedFiles(input, scope) {
|
|
51
|
+
const allowed = /* @__PURE__ */ new Set([scope.file]);
|
|
52
|
+
const features = scopeFeatures(scope);
|
|
53
|
+
const flows = scopeFlows(scope);
|
|
54
|
+
for (const feature of features) for (const file of input.ownership.features[feature]?.own ?? []) allowed.add(file);
|
|
55
|
+
for (const [file, owner] of Object.entries(input.ownership.files)) if (owner.owner !== null && features.includes(owner.owner)) allowed.add(file);
|
|
56
|
+
for (const ref of flows) for (const file of input.flowFiles[ref] ?? []) allowed.add(file);
|
|
57
|
+
for (const proof of input.proofs) if (flows.length > 0 ? flows.includes(proof.ref) : features.includes(proof.feature)) allowed.add(proof.at.file);
|
|
58
|
+
for (const [file, text] of Object.entries(input.texts)) {
|
|
59
|
+
if (text.base === null || !text.base.includes("@proves")) continue;
|
|
60
|
+
for (const proof of scanProofsInText(text.base, file).proofs) if (flows.length > 0 ? flows.includes(proof.ref) : features.includes(proof.feature)) allowed.add(file);
|
|
61
|
+
}
|
|
62
|
+
return allowed;
|
|
63
|
+
}
|
|
64
|
+
function inScope(file, scope, allowed) {
|
|
65
|
+
return allowed.has(file) || file.startsWith("grimoire/tasks/") || file.startsWith("grimoire/releases/") || file.startsWith("grimoire/approved/") || file.startsWith("grimoire/screenshots/approved/") || scopeFeatures(scope).some((feature) => file.startsWith(`grimoire/features/${feature}/`)) || matchesAny(file, scope.files);
|
|
66
|
+
}
|
|
67
|
+
function scopeFindings(input, scope) {
|
|
68
|
+
const allowed = allowedFiles(input, scope);
|
|
69
|
+
const findings = [];
|
|
70
|
+
for (const change of input.changed) {
|
|
71
|
+
const outside = [change.file, ...change.from === null ? [] : [change.from]].filter((file) => !inScope(file, scope, allowed));
|
|
72
|
+
if (outside.length === 0) continue;
|
|
73
|
+
findings.push(createFinding({
|
|
74
|
+
code: "GR7006",
|
|
75
|
+
message: `${change.status} ${JSON.stringify(outside[0])} is outside ${scope.id}${scope.feature === null ? "" : ` (${scope.flow ?? scope.feature})`}`,
|
|
76
|
+
at: at(change.file, null),
|
|
77
|
+
task: scope.id
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
return findings;
|
|
81
|
+
}
|
|
82
|
+
function removalFindings(input, scope) {
|
|
83
|
+
const base = input.baseWritten;
|
|
84
|
+
const findings = [];
|
|
85
|
+
if (base === null) return findings;
|
|
86
|
+
const report = (message, file, line, feature, flow) => {
|
|
87
|
+
findings.push(createFinding({
|
|
88
|
+
code: "GR7007",
|
|
89
|
+
message,
|
|
90
|
+
at: at(file, line),
|
|
91
|
+
task: scope.id,
|
|
92
|
+
feature,
|
|
93
|
+
flow
|
|
94
|
+
}));
|
|
95
|
+
};
|
|
96
|
+
for (const feature of base.features) {
|
|
97
|
+
const current = input.written.features.find((item) => item.id === feature.id);
|
|
98
|
+
if (current === void 0) {
|
|
99
|
+
if (!isRemoved(scope, feature.id)) report(`the change removes the feature ${JSON.stringify(feature.id)} (${feature.flows.length} flows)`, feature.readme?.file ?? `grimoire/features/${feature.id}/README.md`, 1, feature.id, null);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
for (const flow of feature.flows) {
|
|
103
|
+
const next = current.flows.find((item) => item.id.value === flow.id.value);
|
|
104
|
+
if (next === void 0) {
|
|
105
|
+
if (!isRemoved(scope, feature.id, flow.id.value)) report(`the change removes the flow ${JSON.stringify(flow.ref)}`, flow.file, 1, feature.id, flow.ref);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
for (const criterion of flow.criteria) {
|
|
109
|
+
if (next.criteria.some((item) => item.id === criterion.id)) continue;
|
|
110
|
+
if (!isRemoved(scope, feature.id, flow.id.value, criterion.id)) report(`the change removes ${criterion.id} of ${flow.ref}: ${JSON.stringify(criterion.text)}`, next.file, 1, feature.id, flow.ref);
|
|
111
|
+
}
|
|
112
|
+
for (const item of flow.cases) {
|
|
113
|
+
if (next.cases.some((other) => other.question === item.question)) continue;
|
|
114
|
+
if (!isRemoved(scope, feature.id, flow.id.value, void 0, item.question)) report(`the change removes the case ${JSON.stringify(item.question)} of ${flow.ref}`, next.file, 1, feature.id, flow.ref);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return findings;
|
|
119
|
+
}
|
|
120
|
+
function proofFindings(input, scope) {
|
|
121
|
+
const touched = new Set(pathsOf(input));
|
|
122
|
+
const current = /* @__PURE__ */ new Set();
|
|
123
|
+
const findings = [];
|
|
124
|
+
for (const proof of input.proofs) if (!touched.has(proof.at.file)) current.add(`${proof.ref} ${proof.criterion}`);
|
|
125
|
+
for (const [file, text] of Object.entries(input.texts)) {
|
|
126
|
+
if (text.current === null) continue;
|
|
127
|
+
for (const proof of scanProofsInText(text.current, file).proofs) current.add(`${proof.ref} ${proof.criterion}`);
|
|
128
|
+
}
|
|
129
|
+
const reported = /* @__PURE__ */ new Set();
|
|
130
|
+
for (const [file, text] of Object.entries(input.texts)) {
|
|
131
|
+
if (text.base === null || !text.base.includes("@proves")) continue;
|
|
132
|
+
for (const proof of scanProofsInText(text.base, file).proofs) {
|
|
133
|
+
const key = `${proof.ref} ${proof.criterion}`;
|
|
134
|
+
if (current.has(key) || reported.has(key)) continue;
|
|
135
|
+
if (isRemoved(scope, proof.feature, proof.flow, proof.criterion)) continue;
|
|
136
|
+
reported.add(key);
|
|
137
|
+
findings.push(createFinding({
|
|
138
|
+
code: "GR7008",
|
|
139
|
+
message: `no test proves ${proof.criterion} of ${proof.ref} any more${proof.test?.name ? ` (was ${JSON.stringify(proof.test.name)})` : ""}`,
|
|
140
|
+
at: at(file, proof.at.line),
|
|
141
|
+
task: scope.id,
|
|
142
|
+
feature: proof.feature,
|
|
143
|
+
flow: proof.ref
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return findings;
|
|
148
|
+
}
|
|
149
|
+
function lockedFindings(input, scope) {
|
|
150
|
+
if (scope.locked.length === 0) return [];
|
|
151
|
+
return input.changed.flatMap((change) => {
|
|
152
|
+
const locked = [change.file, ...change.from === null ? [] : [change.from]].find((file) => matchesAny(file, scope.locked));
|
|
153
|
+
return locked === void 0 ? [] : [createFinding({
|
|
154
|
+
code: "GR7009",
|
|
155
|
+
message: `${JSON.stringify(locked)} is a locked test of ${scope.id} and was ${change.status}`,
|
|
156
|
+
at: at(change.file, null),
|
|
157
|
+
task: scope.id
|
|
158
|
+
})];
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function assertionFindings(input, scope) {
|
|
162
|
+
const tests = new Set(input.testFiles);
|
|
163
|
+
const findings = [];
|
|
164
|
+
for (const [file, text] of Object.entries(input.texts)) {
|
|
165
|
+
if (text.base === null || text.current === null || !(tests.has(file) || isTestPath(file))) continue;
|
|
166
|
+
const before = countAssertions(text.base);
|
|
167
|
+
const after = countAssertions(text.current);
|
|
168
|
+
if (after < before) findings.push(createFinding({
|
|
169
|
+
code: "GR7010",
|
|
170
|
+
message: `the test file has ${after} assertions, it had ${before}`,
|
|
171
|
+
at: at(file, null),
|
|
172
|
+
task: scope?.id ?? null
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
return findings;
|
|
176
|
+
}
|
|
177
|
+
function dependencyChanges(before, after) {
|
|
178
|
+
if (after === null) return [];
|
|
179
|
+
let next;
|
|
180
|
+
let previous = {};
|
|
181
|
+
try {
|
|
182
|
+
next = JSON.parse(after);
|
|
183
|
+
if (before !== null) previous = JSON.parse(before);
|
|
184
|
+
} catch {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
const changes = [];
|
|
188
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
189
|
+
const now = next[section];
|
|
190
|
+
const was = previous[section];
|
|
191
|
+
if (typeof now !== "object" || now === null) continue;
|
|
192
|
+
for (const [name, version] of Object.entries(now)) if ((typeof was === "object" && was !== null ? was[name] : void 0) !== version) changes.push(`${name}@${String(version)}`);
|
|
193
|
+
}
|
|
194
|
+
return changes;
|
|
195
|
+
}
|
|
196
|
+
function protectedFindings(input, scope) {
|
|
197
|
+
const findings = [];
|
|
198
|
+
for (const area of input.settings.protected) {
|
|
199
|
+
const name = area.name.toLowerCase();
|
|
200
|
+
if (scope.touches.includes(name)) continue;
|
|
201
|
+
if (name === "public-api") {
|
|
202
|
+
const { approved, routes } = input.api;
|
|
203
|
+
if (approved === null || routes === null) continue;
|
|
204
|
+
const diff = diffRoutes(approved.routes, routes);
|
|
205
|
+
if (diff.added.length + diff.removed.length > 0) findings.push(createFinding({
|
|
206
|
+
code: "GR7011",
|
|
207
|
+
message: `the public API changed (${describeRouteDiff(diff)}) and ${scope.id} does not name public-api in Touches`,
|
|
208
|
+
at: at("grimoire/approved/api.json", null),
|
|
209
|
+
task: scope.id
|
|
210
|
+
}));
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
for (const change of input.changed) {
|
|
214
|
+
const file = [change.file, change.from ?? ""].find((candidate) => candidate !== "" && matchesAny(candidate, area.globs));
|
|
215
|
+
if (file === void 0) continue;
|
|
216
|
+
if (name === "dependencies") {
|
|
217
|
+
const text = input.texts[change.file];
|
|
218
|
+
const added = dependencyChanges(text?.base ?? null, text?.current ?? null);
|
|
219
|
+
if (added.length === 0) continue;
|
|
220
|
+
findings.push(createFinding({
|
|
221
|
+
code: "GR7011",
|
|
222
|
+
message: `${JSON.stringify(file)} adds or changes ${added.slice(0, 5).join(", ")}${added.length > 5 ? ` and ${added.length - 5} more` : ""}, and ${scope.id} does not name dependencies in Touches`,
|
|
223
|
+
at: at(change.file, null),
|
|
224
|
+
task: scope.id
|
|
225
|
+
}));
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
findings.push(createFinding({
|
|
229
|
+
code: "GR7011",
|
|
230
|
+
message: `${JSON.stringify(file)} is in the protected area ${JSON.stringify(area.name)} and ${scope.id} does not name it in Touches`,
|
|
231
|
+
at: at(change.file, null),
|
|
232
|
+
task: scope.id
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return findings;
|
|
237
|
+
}
|
|
238
|
+
function addedLineFindings(input, scope) {
|
|
239
|
+
const findings = [];
|
|
240
|
+
const rules = input.settings.rules ?? CODE_RULES;
|
|
241
|
+
const tests = new Set(input.testFiles);
|
|
242
|
+
for (const change of input.changed) {
|
|
243
|
+
const text = input.texts[change.file]?.current;
|
|
244
|
+
if (change.status === "deleted" || text === void 0 || text === null) continue;
|
|
245
|
+
const added = new Set(change.addedLines);
|
|
246
|
+
if (rules.length > 0) for (const hit of runCodeRules(change.file, text, rules)) {
|
|
247
|
+
if (!added.has(hit.line)) continue;
|
|
248
|
+
findings.push(createFinding({
|
|
249
|
+
code: hit.code,
|
|
250
|
+
message: hit.message,
|
|
251
|
+
at: {
|
|
252
|
+
file: change.file,
|
|
253
|
+
line: hit.line,
|
|
254
|
+
column: hit.column
|
|
255
|
+
},
|
|
256
|
+
task: scope?.id ?? null
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
if (tests.has(change.file) || isTestPath(change.file)) for (const hit of findFocusedTests(text)) {
|
|
260
|
+
if (!added.has(hit.line)) continue;
|
|
261
|
+
findings.push(createFinding({
|
|
262
|
+
code: hit.type === "only" ? "GR4011" : "GR4012",
|
|
263
|
+
severity: "error",
|
|
264
|
+
message: `${hit.call} was added`,
|
|
265
|
+
at: {
|
|
266
|
+
file: change.file,
|
|
267
|
+
line: hit.line,
|
|
268
|
+
column: null
|
|
269
|
+
},
|
|
270
|
+
task: scope?.id ?? null
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return findings;
|
|
275
|
+
}
|
|
276
|
+
function commitFindings(input) {
|
|
277
|
+
if (input.commits === null) return [];
|
|
278
|
+
const known = new Set(input.taskIds.map((id) => Number(id.replace(/\D/g, ""))));
|
|
279
|
+
const findings = [];
|
|
280
|
+
for (const commit of input.commits) {
|
|
281
|
+
if (/^Merge (?:pull request|branch|remote-tracking branch)\b/.test(commit.subject)) continue;
|
|
282
|
+
const ids = [...new Set([...`${commit.subject}\n${commit.body}`.matchAll(/\bT-(\d+)\b/g)].map((match) => Number(match[1])))];
|
|
283
|
+
const label = `commit ${commit.sha.slice(0, 7)} ${JSON.stringify(commit.subject)}`;
|
|
284
|
+
if (ids.length === 0) findings.push(createFinding({
|
|
285
|
+
code: "GR7012",
|
|
286
|
+
message: `${label} names no task`
|
|
287
|
+
}));
|
|
288
|
+
else if (!ids.some((id) => known.has(id))) findings.push(createFinding({
|
|
289
|
+
code: "GR7012",
|
|
290
|
+
message: `${label} names ${ids.map((id) => `T-${id}`).join(", ")}, which has no task file`
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
return findings;
|
|
294
|
+
}
|
|
295
|
+
/** Every finding of the guard for a change. Pure. */
|
|
296
|
+
function runGuardChecks(input) {
|
|
297
|
+
const { scope } = input;
|
|
298
|
+
const findings = [];
|
|
299
|
+
if (scope === null) findings.push(createFinding({
|
|
300
|
+
code: "GR9008",
|
|
301
|
+
message: "no task was found: none was passed, the commits name none, and not exactly one task is in progress"
|
|
302
|
+
}));
|
|
303
|
+
else findings.push(...scopeFindings(input, scope), ...removalFindings(input, scope), ...proofFindings(input, scope), ...lockedFindings(input, scope), ...protectedFindings(input, scope));
|
|
304
|
+
findings.push(...assertionFindings(input, scope), ...addedLineFindings(input, scope), ...commitFindings(input));
|
|
305
|
+
return findings;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
export { isTestPath, runGuardChecks };
|
|
310
|
+
//# sourceMappingURL=rules.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/guard/rules.ts"],"sourcesContent":["/**\n * The guard's rules: a pure function over a {@link GuardInput}. No git and\n * no file is read here, so every rule is tested with plain data.\n */\nimport { createFinding } from \"../codes\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type { GuardInput, TaskScope } from \"../contracts/guard\";\nimport { CODE_RULES } from \"../contracts/settings\";\nimport { scanProofsInText } from \"../proves\";\nimport { findFocusedTests } from \"../rules/focused\";\nimport { runCodeRules } from \"../rules\";\nimport { countAssertions } from \"./assertions\";\nimport { describeRouteDiff, diffRoutes } from \"./api\";\nimport { matchesAny } from \"./glob\";\nimport { scopeFeatures, scopeFlows } from \"./scope\";\n\nconst TEST_FILE = /(?:\\.(?:test|spec|e2e)\\.[cm]?[jt]sx?$|(?:^|\\/)(?:tests?|e2e|__tests__)\\/)/;\nconst DEPENDENCY_SECTIONS = [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n];\n\n/** Whether a path is a test file by name or folder. */\nexport function isTestPath(file: string): boolean {\n return TEST_FILE.test(file);\n}\n\nfunction at(file: string, line: number | null): { file: string; line: number; column: null } {\n return { file, line: line ?? 1, column: null };\n}\n\n/** The paths of a change: each file, and the old path of a rename. */\nfunction pathsOf(input: GuardInput): string[] {\n return input.changed.flatMap((change) =>\n change.from === null ? [change.file] : [change.file, change.from],\n );\n}\n\n/** Whether `removes` names this feature, flow, criterion or case (a wider entry covers what is inside it). */\nfunction isRemoved(\n scope: TaskScope,\n feature: string,\n flow?: string,\n criterion?: string,\n caseQuestion?: string,\n): boolean {\n return scope.removes.some((entry) => {\n if (entry.feature !== feature) return false;\n\n if (entry.flow === null) return true;\n\n if (flow === undefined || entry.flow !== flow) return false;\n\n if (entry.criterion === null && entry.case === null) return true;\n\n return (\n (criterion !== undefined && entry.criterion === criterion.toUpperCase()) ||\n (caseQuestion !== undefined && entry.case === caseQuestion.toLowerCase())\n );\n });\n}\n\n/** The files a task allows (everything else that changes is GR7006). */\nfunction allowedFiles(input: GuardInput, scope: TaskScope): Set<string> {\n const allowed = new Set<string>([scope.file]);\n const features = scopeFeatures(scope);\n const flows = scopeFlows(scope);\n\n for (const feature of features) {\n for (const file of input.ownership.features[feature]?.own ?? []) allowed.add(file);\n }\n\n for (const [file, owner] of Object.entries(input.ownership.files)) {\n if (owner.owner !== null && features.includes(owner.owner)) allowed.add(file);\n }\n\n for (const ref of flows) {\n for (const file of input.flowFiles[ref] ?? []) allowed.add(file);\n }\n\n // Tests that prove the task's criteria: those of its flows, or of its features when it names no flow.\n for (const proof of input.proofs) {\n if (flows.length > 0 ? flows.includes(proof.ref) : features.includes(proof.feature)) {\n allowed.add(proof.at.file);\n }\n }\n\n // A deleted or rewritten test proved the task's criteria at the base.\n for (const [file, text] of Object.entries(input.texts)) {\n if (text.base === null || !text.base.includes(\"@proves\")) continue;\n\n for (const proof of scanProofsInText(text.base, file).proofs) {\n if (flows.length > 0 ? flows.includes(proof.ref) : features.includes(proof.feature))\n allowed.add(file);\n }\n }\n\n return allowed;\n}\n\nfunction inScope(file: string, scope: TaskScope, allowed: ReadonlySet<string>): boolean {\n return (\n allowed.has(file) ||\n file.startsWith(\"grimoire/tasks/\") ||\n file.startsWith(\"grimoire/releases/\") ||\n // Written only by approve and reject, which the guard reports on its own (the changes not approved).\n file.startsWith(\"grimoire/approved/\") ||\n file.startsWith(\"grimoire/screenshots/approved/\") ||\n scopeFeatures(scope).some((feature) => file.startsWith(`grimoire/features/${feature}/`)) ||\n matchesAny(file, scope.files)\n );\n}\n\nfunction scopeFindings(input: GuardInput, scope: TaskScope): GrimoireFinding[] {\n const allowed = allowedFiles(input, scope);\n const findings: GrimoireFinding[] = [];\n\n for (const change of input.changed) {\n // A change is in scope when both sides of a rename are.\n const outside = [change.file, ...(change.from === null ? [] : [change.from])].filter(\n (file) => !inScope(file, scope, allowed),\n );\n\n if (outside.length === 0) continue;\n\n findings.push(\n createFinding({\n code: \"GR7006\",\n message: `${change.status} ${JSON.stringify(outside[0])} is outside ${scope.id}${scope.feature === null ? \"\" : ` (${scope.flow ?? scope.feature})`}`,\n at: at(change.file, null),\n task: scope.id,\n }),\n );\n }\n\n return findings;\n}\n\nfunction removalFindings(input: GuardInput, scope: TaskScope): GrimoireFinding[] {\n const base = input.baseWritten;\n const findings: GrimoireFinding[] = [];\n\n if (base === null) return findings;\n\n const report = (\n message: string,\n file: string,\n line: number,\n feature: string,\n flow: string | null,\n ): void => {\n findings.push(\n createFinding({ code: \"GR7007\", message, at: at(file, line), task: scope.id, feature, flow }),\n );\n };\n\n for (const feature of base.features) {\n const current = input.written.features.find((item) => item.id === feature.id);\n\n if (current === undefined) {\n if (!isRemoved(scope, feature.id)) {\n report(\n `the change removes the feature ${JSON.stringify(feature.id)} (${feature.flows.length} flows)`,\n feature.readme?.file ?? `grimoire/features/${feature.id}/README.md`,\n 1,\n feature.id,\n null,\n );\n }\n\n continue;\n }\n\n for (const flow of feature.flows) {\n const next = current.flows.find((item) => item.id.value === flow.id.value);\n\n if (next === undefined) {\n if (!isRemoved(scope, feature.id, flow.id.value)) {\n report(\n `the change removes the flow ${JSON.stringify(flow.ref)}`,\n flow.file,\n 1,\n feature.id,\n flow.ref,\n );\n }\n\n continue;\n }\n\n for (const criterion of flow.criteria) {\n if (next.criteria.some((item) => item.id === criterion.id)) continue;\n\n if (!isRemoved(scope, feature.id, flow.id.value, criterion.id)) {\n report(\n `the change removes ${criterion.id} of ${flow.ref}: ${JSON.stringify(criterion.text)}`,\n next.file,\n 1,\n feature.id,\n flow.ref,\n );\n }\n }\n\n for (const item of flow.cases) {\n if (next.cases.some((other) => other.question === item.question)) continue;\n\n if (!isRemoved(scope, feature.id, flow.id.value, undefined, item.question)) {\n report(\n `the change removes the case ${JSON.stringify(item.question)} of ${flow.ref}`,\n next.file,\n 1,\n feature.id,\n flow.ref,\n );\n }\n }\n }\n }\n\n return findings;\n}\n\nfunction proofFindings(input: GuardInput, scope: TaskScope): GrimoireFinding[] {\n const touched = new Set(pathsOf(input));\n const current = new Set<string>();\n const findings: GrimoireFinding[] = [];\n\n for (const proof of input.proofs) {\n if (!touched.has(proof.at.file)) current.add(`${proof.ref} ${proof.criterion}`);\n }\n\n for (const [file, text] of Object.entries(input.texts)) {\n if (text.current === null) continue;\n\n for (const proof of scanProofsInText(text.current, file).proofs) {\n current.add(`${proof.ref} ${proof.criterion}`);\n }\n }\n\n const reported = new Set<string>();\n\n for (const [file, text] of Object.entries(input.texts)) {\n if (text.base === null || !text.base.includes(\"@proves\")) continue;\n\n for (const proof of scanProofsInText(text.base, file).proofs) {\n const key = `${proof.ref} ${proof.criterion}`;\n\n if (current.has(key) || reported.has(key)) continue;\n\n if (isRemoved(scope, proof.feature, proof.flow, proof.criterion)) continue;\n\n reported.add(key);\n findings.push(\n createFinding({\n code: \"GR7008\",\n message: `no test proves ${proof.criterion} of ${proof.ref} any more${proof.test?.name ? ` (was ${JSON.stringify(proof.test.name)})` : \"\"}`,\n at: at(file, proof.at.line),\n task: scope.id,\n feature: proof.feature,\n flow: proof.ref,\n }),\n );\n }\n }\n\n return findings;\n}\n\nfunction lockedFindings(input: GuardInput, scope: TaskScope): GrimoireFinding[] {\n if (scope.locked.length === 0) return [];\n\n return input.changed.flatMap((change) => {\n const locked = [change.file, ...(change.from === null ? [] : [change.from])].find((file) =>\n matchesAny(file, scope.locked),\n );\n\n return locked === undefined\n ? []\n : [\n createFinding({\n code: \"GR7009\",\n message: `${JSON.stringify(locked)} is a locked test of ${scope.id} and was ${change.status}`,\n at: at(change.file, null),\n task: scope.id,\n }),\n ];\n });\n}\n\nfunction assertionFindings(input: GuardInput, scope: TaskScope | null): GrimoireFinding[] {\n const tests = new Set(input.testFiles);\n const findings: GrimoireFinding[] = [];\n\n for (const [file, text] of Object.entries(input.texts)) {\n if (text.base === null || text.current === null || !(tests.has(file) || isTestPath(file)))\n continue;\n\n const before = countAssertions(text.base);\n const after = countAssertions(text.current);\n\n if (after < before) {\n findings.push(\n createFinding({\n code: \"GR7010\",\n message: `the test file has ${after} assertions, it had ${before}`,\n at: at(file, null),\n task: scope?.id ?? null,\n }),\n );\n }\n }\n\n return findings;\n}\n\nfunction dependencyChanges(before: string | null, after: string | null): string[] {\n if (after === null) return [];\n\n let next: Record<string, unknown>;\n let previous: Record<string, unknown> = {};\n\n try {\n next = JSON.parse(after) as Record<string, unknown>;\n\n if (before !== null) previous = JSON.parse(before) as Record<string, unknown>;\n } catch {\n return [];\n }\n\n const changes: string[] = [];\n\n for (const section of DEPENDENCY_SECTIONS) {\n const now = next[section];\n const was = previous[section];\n\n if (typeof now !== \"object\" || now === null) continue;\n\n for (const [name, version] of Object.entries(now as Record<string, unknown>)) {\n const old =\n typeof was === \"object\" && was !== null\n ? (was as Record<string, unknown>)[name]\n : undefined;\n\n if (old !== version) changes.push(`${name}@${String(version)}`);\n }\n }\n\n return changes;\n}\n\nfunction protectedFindings(input: GuardInput, scope: TaskScope): GrimoireFinding[] {\n const findings: GrimoireFinding[] = [];\n\n for (const area of input.settings.protected) {\n const name = area.name.toLowerCase();\n\n if (scope.touches.includes(name)) continue;\n\n if (name === \"public-api\") {\n const { approved, routes } = input.api;\n\n if (approved === null || routes === null) continue;\n\n const diff = diffRoutes(approved.routes, routes);\n\n if (diff.added.length + diff.removed.length > 0) {\n findings.push(\n createFinding({\n code: \"GR7011\",\n message: `the public API changed (${describeRouteDiff(diff)}) and ${scope.id} does not name public-api in Touches`,\n at: at(\"grimoire/approved/api.json\", null),\n task: scope.id,\n }),\n );\n }\n\n continue;\n }\n\n for (const change of input.changed) {\n const file = [change.file, change.from ?? \"\"].find(\n (candidate) => candidate !== \"\" && matchesAny(candidate, area.globs),\n );\n\n if (file === undefined) continue;\n\n if (name === \"dependencies\") {\n const text = input.texts[change.file];\n const added = dependencyChanges(text?.base ?? null, text?.current ?? null);\n\n if (added.length === 0) continue;\n\n findings.push(\n createFinding({\n code: \"GR7011\",\n message: `${JSON.stringify(file)} adds or changes ${added.slice(0, 5).join(\", \")}${added.length > 5 ? ` and ${added.length - 5} more` : \"\"}, and ${scope.id} does not name dependencies in Touches`,\n at: at(change.file, null),\n task: scope.id,\n }),\n );\n continue;\n }\n\n findings.push(\n createFinding({\n code: \"GR7011\",\n message: `${JSON.stringify(file)} is in the protected area ${JSON.stringify(area.name)} and ${scope.id} does not name it in Touches`,\n at: at(change.file, null),\n task: scope.id,\n }),\n );\n }\n }\n\n return findings;\n}\n\nfunction addedLineFindings(input: GuardInput, scope: TaskScope | null): GrimoireFinding[] {\n const findings: GrimoireFinding[] = [];\n const rules = input.settings.rules ?? CODE_RULES;\n const tests = new Set(input.testFiles);\n\n for (const change of input.changed) {\n const text = input.texts[change.file]?.current;\n\n if (change.status === \"deleted\" || text === undefined || text === null) continue;\n\n const added = new Set(change.addedLines);\n\n if (rules.length > 0) {\n for (const hit of runCodeRules(change.file, text, rules)) {\n if (!added.has(hit.line)) continue;\n\n findings.push(\n createFinding({\n code: hit.code,\n message: hit.message,\n at: { file: change.file, line: hit.line, column: hit.column },\n task: scope?.id ?? null,\n }),\n );\n }\n }\n\n if (tests.has(change.file) || isTestPath(change.file)) {\n for (const hit of findFocusedTests(text)) {\n if (!added.has(hit.line)) continue;\n\n findings.push(\n createFinding({\n code: hit.type === \"only\" ? \"GR4011\" : \"GR4012\",\n // `.skip` is a warning in a check; a change that adds one is an error.\n severity: \"error\",\n message: `${hit.call} was added`,\n at: { file: change.file, line: hit.line, column: null },\n task: scope?.id ?? null,\n }),\n );\n }\n }\n }\n\n return findings;\n}\n\nfunction commitFindings(input: GuardInput): GrimoireFinding[] {\n if (input.commits === null) return [];\n\n const known = new Set(input.taskIds.map((id) => Number(id.replace(/\\D/g, \"\"))));\n const findings: GrimoireFinding[] = [];\n\n for (const commit of input.commits) {\n if (/^Merge (?:pull request|branch|remote-tracking branch)\\b/.test(commit.subject)) continue;\n\n const ids = [\n ...new Set(\n [...`${commit.subject}\\n${commit.body}`.matchAll(/\\bT-(\\d+)\\b/g)].map((match) =>\n Number(match[1]),\n ),\n ),\n ];\n const label = `commit ${commit.sha.slice(0, 7)} ${JSON.stringify(commit.subject)}`;\n\n if (ids.length === 0) {\n findings.push(createFinding({ code: \"GR7012\", message: `${label} names no task` }));\n } else if (!ids.some((id) => known.has(id))) {\n findings.push(\n createFinding({\n code: \"GR7012\",\n message: `${label} names ${ids.map((id) => `T-${id}`).join(\", \")}, which has no task file`,\n }),\n );\n }\n }\n\n return findings;\n}\n\n/** Every finding of the guard for a change. Pure. */\nexport function runGuardChecks(input: GuardInput): GrimoireFinding[] {\n const { scope } = input;\n const findings: GrimoireFinding[] = [];\n\n if (scope === null) {\n findings.push(\n createFinding({\n code: \"GR9008\",\n message:\n \"no task was found: none was passed, the commits name none, and not exactly one task is in progress\",\n }),\n );\n } else {\n findings.push(\n ...scopeFindings(input, scope),\n ...removalFindings(input, scope),\n ...proofFindings(input, scope),\n ...lockedFindings(input, scope),\n ...protectedFindings(input, scope),\n );\n }\n\n findings.push(\n ...assertionFindings(input, scope),\n ...addedLineFindings(input, scope),\n ...commitFindings(input),\n );\n\n return findings;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,YAAY;AAClB,MAAM,sBAAsB;CAC1B;CACA;CACA;CACA;AACF;;AAGA,SAAgB,WAAW,MAAuB;CAChD,OAAO,UAAU,KAAK,IAAI;AAC5B;AAEA,SAAS,GAAG,MAAc,MAAmE;CAC3F,OAAO;EAAE;EAAM,MAAM,QAAQ;EAAG,QAAQ;CAAK;AAC/C;;AAGA,SAAS,QAAQ,OAA6B;CAC5C,OAAO,MAAM,QAAQ,SAAS,WAC5B,OAAO,SAAS,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,MAAM,OAAO,IAAI,CAClE;AACF;;AAGA,SAAS,UACP,OACA,SACA,MACA,WACA,cACS;CACT,OAAO,MAAM,QAAQ,MAAM,UAAU;EACnC,IAAI,MAAM,YAAY,SAAS,OAAO;EAEtC,IAAI,MAAM,SAAS,MAAM,OAAO;EAEhC,IAAI,SAAS,UAAa,MAAM,SAAS,MAAM,OAAO;EAEtD,IAAI,MAAM,cAAc,QAAQ,MAAM,SAAS,MAAM,OAAO;EAE5D,OACG,cAAc,UAAa,MAAM,cAAc,UAAU,YAAY,KACrE,iBAAiB,UAAa,MAAM,SAAS,aAAa,YAAY;CAE3E,CAAC;AACH;;AAGA,SAAS,aAAa,OAAmB,OAA+B;CACtE,MAAM,0BAAU,IAAI,IAAY,CAAC,MAAM,IAAI,CAAC;CAC5C,MAAM,WAAW,cAAc,KAAK;CACpC,MAAM,QAAQ,WAAW,KAAK;CAE9B,KAAK,MAAM,WAAW,UACpB,KAAK,MAAM,QAAQ,MAAM,UAAU,SAAS,QAAQ,EAAE,OAAO,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,95 @@
|
|
|
1
|
+
import { splitList } from "./glob.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/grimoire/src/guard/scope.ts
|
|
4
|
+
const keyOf = (key) => key.trim().replace(/\s+/g, " ").toLowerCase();
|
|
5
|
+
/** The numeric part of a task id (`T-12`, `12`, `T-012`), or `null`. */
|
|
6
|
+
function taskNumber(text) {
|
|
7
|
+
const match = /^(?:T-)?0*(\d+)$/i.exec(text.trim());
|
|
8
|
+
return match ? Number(match[1]) : null;
|
|
9
|
+
}
|
|
10
|
+
/** The task files that match `text` by number (`T-12`, `12`, `T-012`). */
|
|
11
|
+
function findTask(written, text) {
|
|
12
|
+
const wanted = taskNumber(text);
|
|
13
|
+
if (wanted === null) return null;
|
|
14
|
+
return written.tasks.find((task) => taskNumber(task.id.value) === wanted) ?? null;
|
|
15
|
+
}
|
|
16
|
+
/** One `Removes:` entry. Entries that do not read as `<feature>[/<flow>[ AC-n | case <question>]]` are kept as a feature name. */
|
|
17
|
+
function parseRemoveEntry(text) {
|
|
18
|
+
const match = /^([a-z0-9][a-z0-9-]*)(?:\/([a-z0-9][a-z0-9-]*))?(?:\s+(?:(AC-\d+)|case\s+(.+)))?$/i.exec(text.trim());
|
|
19
|
+
if (!match) return {
|
|
20
|
+
feature: text.trim(),
|
|
21
|
+
flow: null,
|
|
22
|
+
criterion: null,
|
|
23
|
+
case: null,
|
|
24
|
+
text: text.trim()
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
feature: (match[1] ?? "").toLowerCase(),
|
|
28
|
+
flow: match[2] === void 0 ? null : match[2].toLowerCase(),
|
|
29
|
+
criterion: match[3] === void 0 ? null : match[3].toUpperCase(),
|
|
30
|
+
case: match[4] === void 0 ? null : match[4].trim().toLowerCase(),
|
|
31
|
+
text: text.trim()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function fieldValues(task, name) {
|
|
35
|
+
return task.fields.filter((field) => keyOf(field.key) === name).flatMap((field) => splitList(field.value));
|
|
36
|
+
}
|
|
37
|
+
/** The flow ref a task names: `flow` is a flow id of `feature`, or a full `<feature>/<flow>`. */
|
|
38
|
+
function flowRefOf(task) {
|
|
39
|
+
const value = task.flow?.value;
|
|
40
|
+
if (value === void 0) return null;
|
|
41
|
+
if (value.includes("/")) return value;
|
|
42
|
+
return task.feature ? `${task.feature.value}/${value}` : null;
|
|
43
|
+
}
|
|
44
|
+
/** What one task allows. */
|
|
45
|
+
function readTaskScope(task) {
|
|
46
|
+
const feature = task.feature?.value ?? null;
|
|
47
|
+
const flow = flowRefOf(task);
|
|
48
|
+
const features = /* @__PURE__ */ new Set();
|
|
49
|
+
if (feature !== null) features.add(feature);
|
|
50
|
+
else if (flow !== null) features.add(flow.split("/")[0] ?? "");
|
|
51
|
+
for (const entry of fieldValues(task, "features")) features.add(entry);
|
|
52
|
+
return {
|
|
53
|
+
id: task.id.value,
|
|
54
|
+
file: task.file,
|
|
55
|
+
feature: feature ?? (flow === null ? null : flow.split("/")[0] ?? null),
|
|
56
|
+
flow,
|
|
57
|
+
features: [...features],
|
|
58
|
+
files: fieldValues(task, "files"),
|
|
59
|
+
locked: fieldValues(task, "locked"),
|
|
60
|
+
touches: fieldValues(task, "touches").map((name) => name.toLowerCase()),
|
|
61
|
+
removes: fieldValues(task, "removes").map(parseRemoveEntry)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Several tasks as one scope (the union of what each allows). */
|
|
65
|
+
function mergeScopes(scopes) {
|
|
66
|
+
const [first, ...rest] = scopes;
|
|
67
|
+
if (first === void 0) return null;
|
|
68
|
+
if (rest.length === 0) return first;
|
|
69
|
+
const union = (pick) => [...new Set(scopes.flatMap(pick))];
|
|
70
|
+
return {
|
|
71
|
+
id: scopes.map((scope) => scope.id).join(", "),
|
|
72
|
+
file: first.file,
|
|
73
|
+
feature: first.feature,
|
|
74
|
+
flow: first.flow,
|
|
75
|
+
features: union((scope) => scope.features),
|
|
76
|
+
files: union((scope) => [...scope.files, scope.file]),
|
|
77
|
+
locked: union((scope) => scope.locked),
|
|
78
|
+
touches: union((scope) => scope.touches),
|
|
79
|
+
removes: scopes.flatMap((scope) => scope.removes)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** The flow refs of a scope: its own flow and every `Features:` entry written as `<feature>/<flow>`. */
|
|
83
|
+
function scopeFlows(scope) {
|
|
84
|
+
const flows = scope.features.filter((entry) => entry.includes("/"));
|
|
85
|
+
if (scope.flow !== null) flows.push(scope.flow);
|
|
86
|
+
return [...new Set(flows)];
|
|
87
|
+
}
|
|
88
|
+
/** The feature ids of a scope (a `<feature>/<flow>` entry gives its feature). */
|
|
89
|
+
function scopeFeatures(scope) {
|
|
90
|
+
return [...new Set(scope.features.map((entry) => entry.split("/")[0] ?? entry))];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { findTask, mergeScopes, parseRemoveEntry, readTaskScope, scopeFeatures, scopeFlows, taskNumber };
|
|
95
|
+
//# sourceMappingURL=scope.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/guard/scope.ts"],"sourcesContent":["/**\n * Reading a task for the guard: which features, files, locked tests,\n * protected areas and removals its body allows.\n *\n * ```md\n * - Files: src/app/shared/utils/money.ts, src/config/catalog.ts\n * - Features: orders, catalog/wishlist\n * - Locked: src/app/catalog/tests/new-arrivals.test.ts\n * - Touches: migrations, dependencies\n * - Removes: catalog/new-arrivals AC-3, catalog/wishlist case duplicate\n * ```\n */\nimport type { RemoveEntry, TaskScope } from \"../contracts/guard\";\nimport type { WrittenGrimoire, WrittenTask } from \"../contracts/written\";\nimport { splitList } from \"./glob\";\n\nconst keyOf = (key: string): string => key.trim().replace(/\\s+/g, \" \").toLowerCase();\n\n/** The numeric part of a task id (`T-12`, `12`, `T-012`), or `null`. */\nexport function taskNumber(text: string): number | null {\n const match = /^(?:T-)?0*(\\d+)$/i.exec(text.trim());\n\n return match ? Number(match[1]) : null;\n}\n\n/** The task files that match `text` by number (`T-12`, `12`, `T-012`). */\nexport function findTask(written: WrittenGrimoire, text: string): WrittenTask | null {\n const wanted = taskNumber(text);\n\n if (wanted === null) return null;\n\n return written.tasks.find((task) => taskNumber(task.id.value) === wanted) ?? null;\n}\n\n/** One `Removes:` entry. Entries that do not read as `<feature>[/<flow>[ AC-n | case <question>]]` are kept as a feature name. */\nexport function parseRemoveEntry(text: string): RemoveEntry {\n const match =\n /^([a-z0-9][a-z0-9-]*)(?:\\/([a-z0-9][a-z0-9-]*))?(?:\\s+(?:(AC-\\d+)|case\\s+(.+)))?$/i.exec(\n text.trim(),\n );\n\n if (!match)\n return { feature: text.trim(), flow: null, criterion: null, case: null, text: text.trim() };\n\n return {\n feature: (match[1] ?? \"\").toLowerCase(),\n flow: match[2] === undefined ? null : match[2].toLowerCase(),\n criterion: match[3] === undefined ? null : match[3].toUpperCase(),\n case: match[4] === undefined ? null : match[4].trim().toLowerCase(),\n text: text.trim(),\n };\n}\n\nfunction fieldValues(task: WrittenTask, name: string): string[] {\n return task.fields\n .filter((field) => keyOf(field.key) === name)\n .flatMap((field) => splitList(field.value));\n}\n\n/** The flow ref a task names: `flow` is a flow id of `feature`, or a full `<feature>/<flow>`. */\nfunction flowRefOf(task: WrittenTask): string | null {\n const value = task.flow?.value;\n\n if (value === undefined) return null;\n\n if (value.includes(\"/\")) return value;\n\n return task.feature ? `${task.feature.value}/${value}` : null;\n}\n\n/** What one task allows. */\nexport function readTaskScope(task: WrittenTask): TaskScope {\n const feature = task.feature?.value ?? null;\n const flow = flowRefOf(task);\n const features = new Set<string>();\n\n if (feature !== null) features.add(feature);\n else if (flow !== null) features.add(flow.split(\"/\")[0] ?? \"\");\n\n for (const entry of fieldValues(task, \"features\")) features.add(entry);\n\n return {\n id: task.id.value,\n file: task.file,\n feature: feature ?? (flow === null ? null : (flow.split(\"/\")[0] ?? null)),\n flow,\n features: [...features],\n files: fieldValues(task, \"files\"),\n locked: fieldValues(task, \"locked\"),\n touches: fieldValues(task, \"touches\").map((name) => name.toLowerCase()),\n removes: fieldValues(task, \"removes\").map(parseRemoveEntry),\n };\n}\n\n/** Several tasks as one scope (the union of what each allows). */\nexport function mergeScopes(scopes: readonly TaskScope[]): TaskScope | null {\n const [first, ...rest] = scopes;\n\n if (first === undefined) return null;\n\n if (rest.length === 0) return first;\n\n const union = <T>(pick: (scope: TaskScope) => T[]): T[] => [...new Set(scopes.flatMap(pick))];\n\n return {\n id: scopes.map((scope) => scope.id).join(\", \"),\n file: first.file,\n feature: first.feature,\n flow: first.flow,\n features: union((scope) => scope.features),\n files: union((scope) => [...scope.files, scope.file]),\n locked: union((scope) => scope.locked),\n touches: union((scope) => scope.touches),\n removes: scopes.flatMap((scope) => scope.removes),\n };\n}\n\n/** The flow refs of a scope: its own flow and every `Features:` entry written as `<feature>/<flow>`. */\nexport function scopeFlows(scope: TaskScope): string[] {\n const flows = scope.features.filter((entry) => entry.includes(\"/\"));\n\n if (scope.flow !== null) flows.push(scope.flow);\n\n return [...new Set(flows)];\n}\n\n/** The feature ids of a scope (a `<feature>/<flow>` entry gives its feature). */\nexport function scopeFeatures(scope: TaskScope): string[] {\n return [...new Set(scope.features.map((entry) => entry.split(\"/\")[0] ?? entry))];\n}\n"],"mappings":";;;AAgBA,MAAM,SAAS,QAAwB,IAAI,KAAK,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,YAAY;;AAGnF,SAAgB,WAAW,MAA6B;CACtD,MAAM,QAAQ,oBAAoB,KAAK,KAAK,KAAK,CAAC;CAElD,OAAO,QAAQ,OAAO,MAAM,EAAE,IAAI;AACpC;;AAGA,SAAgB,SAAS,SAA0B,MAAkC;CACnF,MAAM,SAAS,WAAW,IAAI;CAE9B,IAAI,WAAW,MAAM,OAAO;CAE5B,OAAO,QAAQ,MAAM,MAAM,SAAS,WAAW,KAAK,GAAG,KAAK,MAAM,MAAM,KAAK;AAC/E;;AAGA,SA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index.d.mts
CHANGED
|
@@ -2,11 +2,16 @@ import { BookAdapter, BookExport, BookFacts, BookFile, BookFileType, BookHost, B
|
|
|
2
2
|
import { Located, SourceLocation } from "./contracts/location.mjs";
|
|
3
3
|
import { GrimoireCheckReport, GrimoireCodeArea, GrimoireCodeDefinition, GrimoireFinding, GrimoireFindingInput, GrimoireSeverity, RouteFreshness } from "./contracts/findings.mjs";
|
|
4
4
|
import { BOOK_SCHEMA_VERSION, BookAnnotations, BookEntry, BookFactsCache, BookManifest, BookManifestFile, BookMobileScreensFile, BookModuleSummary, BookRouteRef, BookRoutesFile, BookSitePagesFile, BuildBookOptions, BuildBookResult, LoadedBook, WriteBookResult } from "./contracts/book.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { CODE_RULES, CodeRuleName, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, GrimoireSettings, ProtectedArea, SCREENSHOT_MODES, ScreenshotMode, WrittenSettings } from "./contracts/settings.mjs";
|
|
6
|
+
import { CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, CriterionId, FeatureVersion, FlowRef, StepType, TaskStatus, TaskType, UI_CASE_QUESTIONS, UiCaseQuestion, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, WrittenStatus, WrittenStep, WrittenStoryStep, WrittenTask, WrittenVersionBrief, WrittenWho } from "./contracts/written.mjs";
|
|
6
7
|
import { CriterionStatus, ProofLine, ProofResult, TestOutcome, TestResultsInfo, TestResultsStore, UnmatchedProof } from "./contracts/test-results.mjs";
|
|
7
8
|
import { CollectedFiles, FeatureBookmap, FeaturesIndex, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, Ownership, TaskSummary, TasksIndex } from "./contracts/bookmap.mjs";
|
|
9
|
+
import { ApprovedBaseline, ApprovedFlow, ApprovedProof, ApprovedShot, DriftItem, DriftType, RejectedChange, ShotCapture, ShotCaptureIndex, ShotOutcome, ShotsState, ShowsLine } from "./contracts/shots.mjs";
|
|
8
10
|
import { AppMatch, GrimoireRule, GrimoireSnapshot, OpenGrimoireOptions } from "./contracts/snapshot.mjs";
|
|
9
|
-
import { ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult } from "./contracts/scry.mjs";
|
|
11
|
+
import { ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchImpact, ScrySearchResult } from "./contracts/scry.mjs";
|
|
12
|
+
import { ChangedFile, ChangedFileStatus, CommitInfo } from "./git/index.mjs";
|
|
13
|
+
import { ApiSnapshot, GuardFileText, GuardInput, GuardReport, RemoveEntry, TaskScope } from "./contracts/guard.mjs";
|
|
14
|
+
import { GrimoireMatrix, MatrixCell, MatrixCellState, MatrixCriterionRow, MatrixFeatureRow, MatrixFlowRow } from "./contracts/matrix.mjs";
|
|
10
15
|
import { CollectedListText, ReleaseCollection, ReleaseEntry, WriteReleaseResult } from "./contracts/releases.mjs";
|
|
11
16
|
import { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, GrimoireCode } from "./codes/codes.mjs";
|
|
12
17
|
import { GRIMOIRE_CODES_DOCS_URL, GrimoireError, createFinding, explainGrimoireCode, grimoireCodeDocsUrl, isGrimoireCode } from "./codes/index.mjs";
|
|
@@ -14,6 +19,7 @@ import { BookPathInput, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, boo
|
|
|
14
19
|
import { FrontMatterField, FrontMatterResult, FrontMatterValue, readFrontMatter } from "./front-matter/index.mjs";
|
|
15
20
|
import { FileGraph, fileGraph, importClosure, importerClosure } from "./graph/index.mjs";
|
|
16
21
|
import { ParseGrimoireResult, parseGrimoire } from "./written/parse-grimoire.mjs";
|
|
22
|
+
import { resolveSettings } from "./written/settings.mjs";
|
|
17
23
|
import { BookCheck, buildBook, checkBook, loadBook } from "./book/build.mjs";
|
|
18
24
|
import { writeBook } from "./book/write.mjs";
|
|
19
25
|
import { resolveOwnership } from "./ownership/index.mjs";
|
|
@@ -23,6 +29,7 @@ import { writeCollectedFiles } from "./bookmap/write.mjs";
|
|
|
23
29
|
import { openGrimoire } from "./workspace/index.mjs";
|
|
24
30
|
import { openStoredGrimoire } from "./workspace/stored.mjs";
|
|
25
31
|
import { ScanProofsResult, scanProofs, scanProofsInText } from "./proves/scan-proofs.mjs";
|
|
32
|
+
import { ScanShowsResult, scanShows } from "./proves/scan-shows.mjs";
|
|
26
33
|
import { checkGrimoire } from "./check/check-grimoire.mjs";
|
|
27
34
|
import { formatCheckReport } from "./check/format-check-report.mjs";
|
|
28
35
|
import { collectRelease, renderCollectedList, writeRelease } from "./releases/index.mjs";
|
|
@@ -32,4 +39,4 @@ import { formatScryResult } from "./scry/format.mjs";
|
|
|
32
39
|
import { parseScryQuery } from "./scry/parse.mjs";
|
|
33
40
|
import { scry } from "./scry/query.mjs";
|
|
34
41
|
import { SCRY_STOP_WORDS } from "./scry/search.mjs";
|
|
35
|
-
export { AppMatch, BOOK_SCHEMA_VERSION, BookAdapter, BookAnnotations, type BookCheck, BookEntry, BookExport, BookFacts, BookFactsCache, BookFile, BookFileType, BookHost, BookImport, BookManifest, BookManifestFile, BookMobileApp, BookMobileScreensFile, BookModuleSummary, BookNamedThing, BookNamedType, BookPage, BookPageLink, type BookPathInput, BookRoute, BookRouteRef, BookRoutesFile, BookScreen, BookSite, BookSitePagesFile, BuildBookOptions, BuildBookResult, CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, CollectedFiles, type CollectedInput, CollectedListText, CriterionId, CriterionStatus, type CriterionTestResult, FeatureBookmap, FeatureVersion, FeaturesIndex, type FileGraph, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, FlowRef, type FrontMatterField, type FrontMatterResult, type FrontMatterValue, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireCheckReport, type GrimoireCode, GrimoireCodeArea, GrimoireCodeDefinition, GrimoireError, GrimoireFinding, GrimoireFindingInput, GrimoireRule, GrimoireSeverity, GrimoireSnapshot, LoadedBook, Located, OpenGrimoireOptions, Ownership, type ParseGrimoireResult, ProofLine, ProofResult, ReleaseCollection, ReleaseEntry, RouteFreshness, SCRY_STOP_WORDS, type ScanProofsResult, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult, SourceLocation, StepType, TaskStatus, TaskSummary, TaskType, TasksIndex, TestOutcome, TestResultsInfo, TestResultsStore, UnmatchedProof, WriteBookResult, WriteReleaseResult, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, WrittenStatus, WrittenStep, WrittenStoryStep, WrittenTask, WrittenVersionBrief, WrittenWho, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, scanProofs, scanProofsInText, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
42
|
+
export { ApiSnapshot, AppMatch, ApprovedBaseline, ApprovedFlow, ApprovedProof, ApprovedShot, BOOK_SCHEMA_VERSION, BookAdapter, BookAnnotations, type BookCheck, BookEntry, BookExport, BookFacts, BookFactsCache, BookFile, BookFileType, BookHost, BookImport, BookManifest, BookManifestFile, BookMobileApp, BookMobileScreensFile, BookModuleSummary, BookNamedThing, BookNamedType, BookPage, BookPageLink, type BookPathInput, BookRoute, BookRouteRef, BookRoutesFile, BookScreen, BookSite, BookSitePagesFile, BuildBookOptions, BuildBookResult, CASE_QUESTIONS, CODE_RULES, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, type ChangedFile, type ChangedFileStatus, CodeRuleName, CollectedFiles, type CollectedInput, CollectedListText, type CommitInfo, CriterionId, CriterionStatus, type CriterionTestResult, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, DriftItem, DriftType, FeatureBookmap, FeatureVersion, FeaturesIndex, type FileGraph, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, FlowRef, type FrontMatterField, type FrontMatterResult, type FrontMatterValue, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireCheckReport, type GrimoireCode, GrimoireCodeArea, GrimoireCodeDefinition, GrimoireError, GrimoireFinding, GrimoireFindingInput, GrimoireMatrix, GrimoireRule, GrimoireSettings, GrimoireSeverity, GrimoireSnapshot, GuardFileText, GuardInput, GuardReport, LoadedBook, Located, MatrixCell, MatrixCellState, MatrixCriterionRow, MatrixFeatureRow, MatrixFlowRow, OpenGrimoireOptions, Ownership, type ParseGrimoireResult, ProofLine, ProofResult, ProtectedArea, RejectedChange, ReleaseCollection, ReleaseEntry, RemoveEntry, RouteFreshness, SCREENSHOT_MODES, SCRY_STOP_WORDS, type ScanProofsResult, type ScanShowsResult, ScreenshotMode, ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchImpact, ScrySearchResult, ShotCapture, ShotCaptureIndex, ShotOutcome, ShotsState, ShowsLine, SourceLocation, StepType, TaskScope, TaskStatus, TaskSummary, TaskType, TasksIndex, TestOutcome, TestResultsInfo, TestResultsStore, UI_CASE_QUESTIONS, UiCaseQuestion, UnmatchedProof, WriteBookResult, WriteReleaseResult, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, WrittenSettings, WrittenStatus, WrittenStep, WrittenStoryStep, WrittenTask, WrittenVersionBrief, WrittenWho, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, resolveSettings, scanProofs, scanProofsInText, scanShows, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
package/esm/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { BOOK_SCHEMA_VERSION } from "./contracts/book.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { CODE_RULES, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, SCREENSHOT_MODES } from "./contracts/settings.mjs";
|
|
3
|
+
import { CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, UI_CASE_QUESTIONS } from "./contracts/written.mjs";
|
|
4
|
+
import "./contracts/index.mjs";
|
|
3
5
|
import { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST } from "./codes/codes.mjs";
|
|
4
6
|
import { GRIMOIRE_CODES_DOCS_URL, GrimoireError, createFinding, explainGrimoireCode, grimoireCodeDocsUrl, isGrimoireCode } from "./codes/index.mjs";
|
|
5
7
|
import { GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, bookEntryPath, bookEntryPaths, toPosixPath } from "./paths/index.mjs";
|
|
6
8
|
import { readFrontMatter } from "./front-matter/index.mjs";
|
|
7
9
|
import { fileGraph, importClosure, importerClosure } from "./graph/index.mjs";
|
|
10
|
+
import { resolveSettings } from "./written/settings.mjs";
|
|
8
11
|
import { parseGrimoire } from "./written/parse-grimoire.mjs";
|
|
9
12
|
import "./written/index.mjs";
|
|
10
13
|
import { buildBook, checkBook, loadBook } from "./book/build.mjs";
|
|
@@ -19,6 +22,7 @@ import { buildCollectedFiles } from "./bookmap/build.mjs";
|
|
|
19
22
|
import { writeCollectedFiles } from "./bookmap/write.mjs";
|
|
20
23
|
import "./bookmap/index.mjs";
|
|
21
24
|
import { scanProofs, scanProofsInText } from "./proves/scan-proofs.mjs";
|
|
25
|
+
import { scanShows } from "./proves/scan-shows.mjs";
|
|
22
26
|
import "./proves/index.mjs";
|
|
23
27
|
import { openGrimoire } from "./workspace/index.mjs";
|
|
24
28
|
import { openStoredGrimoire } from "./workspace/stored.mjs";
|
|
@@ -32,4 +36,4 @@ import { SCRY_STOP_WORDS } from "./scry/search.mjs";
|
|
|
32
36
|
import { scry } from "./scry/query.mjs";
|
|
33
37
|
import "./scry/index.mjs";
|
|
34
38
|
|
|
35
|
-
export { BOOK_SCHEMA_VERSION, CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireError, SCRY_STOP_WORDS, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, scanProofs, scanProofsInText, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
39
|
+
export { BOOK_SCHEMA_VERSION, CASE_QUESTIONS, CODE_RULES, COLLECTED_END_MARKER, COLLECTED_START_MARKER, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireError, SCREENSHOT_MODES, SCRY_STOP_WORDS, UI_CASE_QUESTIONS, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, resolveSettings, scanProofs, scanProofsInText, scanShows, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
package/esm/paths/index.d.mts
CHANGED
|
@@ -27,9 +27,23 @@ export declare const GRIMOIRE_PATHS: {
|
|
|
27
27
|
readonly releases: "grimoire/releases";
|
|
28
28
|
/** Images that written files show (`` lines point inside this folder). */
|
|
29
29
|
readonly screenshots: "grimoire/screenshots";
|
|
30
|
+
/** Project settings (languages, screenshot mode, code rules, protected areas). Optional. */
|
|
31
|
+
readonly settings: "grimoire/settings.md";
|
|
32
|
+
/** Approved state, written only by `warlock grimoire approve` / `reject` and the tab's buttons (in git). */
|
|
33
|
+
readonly approved: "grimoire/approved";
|
|
34
|
+
/** The approved flows, criteria, cases, proving tests and images. */
|
|
35
|
+
readonly baseline: "grimoire/approved/baseline.json";
|
|
36
|
+
/** The approved public API (the routes). */
|
|
37
|
+
readonly apiSnapshot: "grimoire/approved/api.json";
|
|
38
|
+
/** Approved images of `@shows` scenes (in git). */
|
|
39
|
+
readonly approvedShots: "grimoire/screenshots/approved";
|
|
40
|
+
/** Warlock. The last capture of every `@shows` scene (ignored by git). */
|
|
41
|
+
readonly capturedShots: "grimoire/screenshots/captured";
|
|
42
|
+
/** Warlock. What the last captures were (ignored by git). */
|
|
43
|
+
readonly captureIndex: "grimoire/screenshots/captured/index.json";
|
|
30
44
|
};
|
|
31
45
|
/** Lines a project's `.gitignore` needs so Warlock's files stay out of git. */
|
|
32
|
-
export declare const GRIMOIRE_IGNORE_RULES: readonly ["/grimoire/book/", "/grimoire/features/index.json", "/grimoire/features/**/bookmap.json", "/grimoire/features/**/*.bookmap.json", "/grimoire/tasks/index.json"];
|
|
46
|
+
export declare const GRIMOIRE_IGNORE_RULES: readonly ["/grimoire/book/", "/grimoire/features/index.json", "/grimoire/features/**/bookmap.json", "/grimoire/features/**/*.bookmap.json", "/grimoire/tasks/index.json", "/grimoire/screenshots/captured/"];
|
|
33
47
|
/** A path with `\` turned into `/`. */
|
|
34
48
|
export declare function toPosixPath(file: string): string;
|
|
35
49
|
/** One file to place in the book. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/paths/index.ts"],"mappings":";;qBAOa;;qBAGA;;WAEX;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;WACA;WACA;WACA;WACA;;WAEA;WACA;;WAEA;;;qBAIW;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/paths/index.ts"],"mappings":";;qBAOa;;qBAGA;;WAEX;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;WAEA;WACA;WACA;WACA;WACA;;WAEA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;qBAIW;;wBAYG,YAAY;;YAkDhB;EACV;;EAEA;IAAc;IAAY;;;;;;;;;;;;;;;wBAeZ,eAAe,gBAAgB,kBAAkB;;wBAiCjD,cAAc,OAAO"}
|