@forwardimpact/libwiki 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/package.json +1 -1
- package/src/audit/engine.js +1 -2
- package/src/audit/format.js +2 -4
- package/src/audit/rules.js +0 -3
- package/src/audit/scopes.js +1 -3
- package/src/commands/audit.js +2 -3
package/README.md
CHANGED
|
@@ -94,8 +94,7 @@ on any failure. Text output: `WARN ...` and `FAIL ...` lines plus a
|
|
|
94
94
|
`RESULT: ...` trailer. JSON output:
|
|
95
95
|
|
|
96
96
|
```json
|
|
97
|
-
{ "result": "pass|fail", "failures": [...], "warnings": [...]
|
|
98
|
-
"grace_active": false, "grace_until": null }
|
|
97
|
+
{ "result": "pass|fail", "failures": [...], "warnings": [...] }
|
|
99
98
|
```
|
|
100
99
|
|
|
101
100
|
Each finding carries a stable `id` for filtering. The catalogue lives in
|
package/package.json
CHANGED
package/src/audit/engine.js
CHANGED
|
@@ -13,11 +13,10 @@ function applyRule(rule, subject, ctx) {
|
|
|
13
13
|
if (rule.when && !rule.when(subject, ctx)) return [];
|
|
14
14
|
const result = rule.check(subject, ctx);
|
|
15
15
|
if (result == null) return [];
|
|
16
|
-
const level = rule.graceDowngrade && ctx.grace ? "warn" : rule.severity;
|
|
17
16
|
const items = Array.isArray(result) ? result : [result];
|
|
18
17
|
return items.map((item) => ({
|
|
19
18
|
id: rule.id,
|
|
20
|
-
level,
|
|
19
|
+
level: rule.severity,
|
|
21
20
|
path: subject.path ?? null,
|
|
22
21
|
message: rule.message(subject, item, ctx),
|
|
23
22
|
}));
|
package/src/audit/format.js
CHANGED
|
@@ -22,8 +22,8 @@ export function emitText(findings) {
|
|
|
22
22
|
return lines.join("\n") + "\n";
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** Render findings as a JSON document
|
|
26
|
-
export function emitJson(findings
|
|
25
|
+
/** Render findings as a JSON document. */
|
|
26
|
+
export function emitJson(findings) {
|
|
27
27
|
const { failures, warnings } = partition(findings);
|
|
28
28
|
return (
|
|
29
29
|
JSON.stringify(
|
|
@@ -31,8 +31,6 @@ export function emitJson(findings, ctx) {
|
|
|
31
31
|
result: failures.length === 0 ? "pass" : "fail",
|
|
32
32
|
failures,
|
|
33
33
|
warnings,
|
|
34
|
-
grace_active: ctx.grace,
|
|
35
|
-
grace_until: ctx.graceUntil,
|
|
36
34
|
},
|
|
37
35
|
null,
|
|
38
36
|
2,
|
package/src/audit/rules.js
CHANGED
|
@@ -212,7 +212,6 @@ export const RULES = [
|
|
|
212
212
|
id: "summary.line-budget",
|
|
213
213
|
scope: "summary",
|
|
214
214
|
severity: "fail",
|
|
215
|
-
graceDowngrade: true,
|
|
216
215
|
check: lineBudget(SUMMARY_LINE_BUDGET),
|
|
217
216
|
message: (s, r) =>
|
|
218
217
|
`budget: ${s.path} has ${r.value} lines (limit ${SUMMARY_LINE_BUDGET})`,
|
|
@@ -221,7 +220,6 @@ export const RULES = [
|
|
|
221
220
|
id: "summary.word-budget",
|
|
222
221
|
scope: "summary",
|
|
223
222
|
severity: "fail",
|
|
224
|
-
graceDowngrade: true,
|
|
225
223
|
check: wordBudget(SUMMARY_WORD_BUDGET),
|
|
226
224
|
message: (s, r) =>
|
|
227
225
|
`budget: ${s.path} has ${r.value} words (limit ${SUMMARY_WORD_BUDGET})`,
|
|
@@ -272,7 +270,6 @@ export const RULES = [
|
|
|
272
270
|
id: "decision-block.heading-within-5",
|
|
273
271
|
scope: "weekly-log-main",
|
|
274
272
|
severity: "fail",
|
|
275
|
-
graceDowngrade: true,
|
|
276
273
|
check: decisionWithin5({
|
|
277
274
|
entryRe: /^## \d{4}-\d{2}-\d{2}(?:[\s(].*)?$/,
|
|
278
275
|
requiredLine: DECISION_HEADING,
|
package/src/audit/scopes.js
CHANGED
|
@@ -173,7 +173,7 @@ export function resolveScope(scopeKey, ctx) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/** Build the audit context: classifies and loads every wiki file once. */
|
|
176
|
-
export function buildContext({ wikiRoot, today
|
|
176
|
+
export function buildContext({ wikiRoot, today }) {
|
|
177
177
|
const subjects = {
|
|
178
178
|
summary: [],
|
|
179
179
|
"weekly-log-main": [],
|
|
@@ -187,8 +187,6 @@ export function buildContext({ wikiRoot, today, graceUntil }) {
|
|
|
187
187
|
return {
|
|
188
188
|
wikiRoot,
|
|
189
189
|
today,
|
|
190
|
-
grace: Boolean(graceUntil && graceUntil >= today),
|
|
191
|
-
graceUntil: graceUntil ?? null,
|
|
192
190
|
subjects,
|
|
193
191
|
memory: loadMemory(wikiRoot),
|
|
194
192
|
storyboard: loadStoryboard(wikiRoot, today),
|
package/src/commands/audit.js
CHANGED
|
@@ -12,13 +12,12 @@ export function runAuditCommand(values, _args, _cli) {
|
|
|
12
12
|
const projectRoot = finder.findProjectRoot(process.cwd());
|
|
13
13
|
const wikiRoot = values["wiki-root"] || path.join(projectRoot, "wiki");
|
|
14
14
|
const today = values.today || new Date().toISOString().slice(0, 10);
|
|
15
|
-
const graceUntil = process.env.FIT_WIKI_AUDIT_GRACE_UNTIL || null;
|
|
16
15
|
|
|
17
|
-
const ctx = buildContext({ wikiRoot, today
|
|
16
|
+
const ctx = buildContext({ wikiRoot, today });
|
|
18
17
|
const findings = runAudit(RULES, ctx);
|
|
19
18
|
|
|
20
19
|
process.stdout.write(
|
|
21
|
-
values.format === "json" ? emitJson(findings
|
|
20
|
+
values.format === "json" ? emitJson(findings) : emitText(findings),
|
|
22
21
|
);
|
|
23
22
|
|
|
24
23
|
if (findings.some((f) => f.level === "fail")) process.exit(1);
|