@warlock.js/grimoire 5.58.0 → 5.59.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 +24 -0
- package/esm/apps/check-apps.mjs +11 -5
- package/esm/apps/check-apps.mjs.map +1 -1
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +5 -3
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +34 -3
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +22 -1
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/scry.d.mts +26 -6
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +3 -1
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/devtools/data.mjs +23 -3
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/feature-map.mjs +149 -0
- package/esm/devtools/feature-map.mjs.map +1 -0
- package/esm/devtools/index.d.mts +2 -2
- package/esm/devtools/index.mjs +30 -9
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts.map +1 -1
- package/esm/devtools/product-map.mjs +82 -7
- package/esm/devtools/product-map.mjs.map +1 -1
- package/esm/devtools/site.d.mts +43 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +111 -15
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +15 -2
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/index.d.mts +3 -3
- package/esm/ownership/index.d.mts.map +1 -1
- package/esm/ownership/index.mjs +60 -1
- package/esm/ownership/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +2 -1
- package/esm/scry/compact.mjs.map +1 -1
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +12 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +147 -23
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/warlock/actions.mjs +15 -7
- package/esm/warlock/actions.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +36 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/commands.mjs +7 -2
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/logo.mjs +12 -0
- package/esm/warlock/logo.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +6 -6
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/cache.mjs +194 -0
- package/esm/workspace/cache.mjs.map +1 -0
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +3 -1
- package/esm/workspace/index.mjs.map +1 -1
- package/llms-full.txt +32 -9
- package/package.json +3 -3
- package/skills/record-a-change/SKILL.md +2 -0
- package/skills/use-the-grimoire/SKILL.md +30 -9
- package/ui/grimoire-static.js +57 -6
- package/ui/grimoire-view.js +1289 -310
- package/ui/grimoire.css +583 -2
- package/ui/product-map.css +157 -8
- package/ui/product-map.js +507 -59
|
@@ -61,8 +61,20 @@ function contextOf(snapshot, options) {
|
|
|
61
61
|
const report = reportOf(snapshot);
|
|
62
62
|
const featureErrors = /* @__PURE__ */ new Map();
|
|
63
63
|
const flowErrors = /* @__PURE__ */ new Map();
|
|
64
|
+
const featureFindings = /* @__PURE__ */ new Map();
|
|
64
65
|
for (const finding of report.findings) {
|
|
65
|
-
if (finding.expected
|
|
66
|
+
if (finding.expected) continue;
|
|
67
|
+
const owner = finding.subject.feature ?? finding.subject.flow?.split("/")[0] ?? null;
|
|
68
|
+
if (owner !== null) {
|
|
69
|
+
const known = featureFindings.get(owner) ?? {
|
|
70
|
+
errors: 0,
|
|
71
|
+
warnings: 0
|
|
72
|
+
};
|
|
73
|
+
if (finding.severity === "error") known.errors += 1;
|
|
74
|
+
else known.warnings += 1;
|
|
75
|
+
featureFindings.set(owner, known);
|
|
76
|
+
}
|
|
77
|
+
if (finding.severity !== "error") continue;
|
|
66
78
|
const flow = finding.subject.flow;
|
|
67
79
|
const feature = finding.subject.feature ?? flow?.split("/")[0] ?? null;
|
|
68
80
|
if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);
|
|
@@ -74,6 +86,7 @@ function contextOf(snapshot, options) {
|
|
|
74
86
|
report,
|
|
75
87
|
featureErrors,
|
|
76
88
|
flowErrors,
|
|
89
|
+
featureFindings,
|
|
77
90
|
captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),
|
|
78
91
|
resultsMissing: snapshot.results === null && snapshot.proofs.length > 0
|
|
79
92
|
};
|
|
@@ -112,8 +125,13 @@ function healthOf(context, criteria, checkErrors, captured) {
|
|
|
112
125
|
level = "attention";
|
|
113
126
|
reason = `${counts.noTest} of ${total} checks have no test`;
|
|
114
127
|
} else if (context.resultsMissing && total > 0) {
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
if (context.options.shared) {
|
|
129
|
+
level = "unknown";
|
|
130
|
+
reason = "Test results are not measured";
|
|
131
|
+
} else {
|
|
132
|
+
level = "attention";
|
|
133
|
+
reason = "No test results recorded";
|
|
134
|
+
}
|
|
117
135
|
} else if (counts.stale > 0 || counts.notRun > 0) {
|
|
118
136
|
level = "attention";
|
|
119
137
|
reason = "Tests have not run since they changed";
|
|
@@ -151,10 +169,59 @@ function audienceOf(feature) {
|
|
|
151
169
|
if (listed.length > 0) return listed;
|
|
152
170
|
return [...new Set(feature.flows.map((flow) => flow.who.value))];
|
|
153
171
|
}
|
|
172
|
+
/** The health strip numbers of a feature card. */
|
|
173
|
+
function stripOf(context, feature, health) {
|
|
174
|
+
const bookmaps = feature.flows.flatMap((flow) => {
|
|
175
|
+
const found = context.snapshot.collected.flows[flow.ref];
|
|
176
|
+
return found === void 0 ? [] : [found];
|
|
177
|
+
});
|
|
178
|
+
const places = appearancesOf(context.snapshot, bookmaps);
|
|
179
|
+
return {
|
|
180
|
+
flows: {
|
|
181
|
+
total: feature.flows.length,
|
|
182
|
+
shipped: feature.flows.filter((flow) => flow.status.value === "shipped").length
|
|
183
|
+
},
|
|
184
|
+
criteria: {
|
|
185
|
+
total: health.criteria.total,
|
|
186
|
+
proven: health.criteria.pass,
|
|
187
|
+
failing: health.criteria.fail,
|
|
188
|
+
measured: !context.resultsMissing && (health.criteria.total === 0 || health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 || health.criteria.notRun === 0)
|
|
189
|
+
},
|
|
190
|
+
screenshots: {
|
|
191
|
+
places: places.length,
|
|
192
|
+
present: places.filter((place) => place.screenshots.length > 0).length
|
|
193
|
+
},
|
|
194
|
+
findings: context.featureFindings.get(feature.id) ?? {
|
|
195
|
+
errors: 0,
|
|
196
|
+
warnings: 0
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
201
|
+
/** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */
|
|
202
|
+
const isDay = (value) => DAY.test(value) && !Number.isNaN((/* @__PURE__ */ new Date(`${value}T00:00:00Z`)).getTime());
|
|
203
|
+
/** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */
|
|
204
|
+
function compareReleases(left, right) {
|
|
205
|
+
const parts = (value) => value.split(/[.\-+]/).map((part) => part);
|
|
206
|
+
const a = parts(left);
|
|
207
|
+
const b = parts(right);
|
|
208
|
+
for (let index = 0; index < Math.max(a.length, b.length); index += 1) {
|
|
209
|
+
const x = a[index] ?? "0";
|
|
210
|
+
const y = b[index] ?? "0";
|
|
211
|
+
const diff = /^\d+$/.test(x) && /^\d+$/.test(y) ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;
|
|
212
|
+
if (diff !== 0) return diff;
|
|
213
|
+
}
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
154
216
|
function card(context, feature) {
|
|
155
217
|
const readme = feature.readme;
|
|
156
218
|
if (readme === null) throw new Error("A feature card needs a README.");
|
|
219
|
+
const health = featureHealth(context, feature);
|
|
220
|
+
const entries = feature.changelog?.entries ?? [];
|
|
157
221
|
return {
|
|
222
|
+
changedAt: [readme.updated.value, ...entries.flatMap((entry) => entry.date === null ? [] : [entry.date])].filter(isDay).reduce((newest, date) => date > newest ? date : newest, ""),
|
|
223
|
+
changedIn: [...new Set(entries.flatMap((entry) => entry.release === null ? [] : [entry.release]))],
|
|
224
|
+
unreleased: entries.some((entry) => entry.release === null),
|
|
158
225
|
id: feature.id,
|
|
159
226
|
title: readme.title.value,
|
|
160
227
|
summary: readme.summary,
|
|
@@ -163,7 +230,8 @@ function card(context, feature) {
|
|
|
163
230
|
status: readme.status.value,
|
|
164
231
|
version: readme.version.value,
|
|
165
232
|
flows: feature.flows.length,
|
|
166
|
-
health
|
|
233
|
+
health,
|
|
234
|
+
strip: stripOf(context, feature, health)
|
|
167
235
|
};
|
|
168
236
|
}
|
|
169
237
|
/** `GET /product`: the feature map. */
|
|
@@ -177,7 +245,12 @@ function productMap(snapshot, options) {
|
|
|
177
245
|
type: app.type.value,
|
|
178
246
|
title: app.heading?.value ?? null
|
|
179
247
|
})),
|
|
180
|
-
|
|
248
|
+
releases: snapshot.written.releases.map((item) => ({
|
|
249
|
+
release: item.release.value,
|
|
250
|
+
date: item.date.value
|
|
251
|
+
})).sort((left, right) => left.date.localeCompare(right.date) || compareReleases(left.release, right.release)),
|
|
252
|
+
developer: !options.shared,
|
|
253
|
+
host: snapshot.host ?? null
|
|
181
254
|
};
|
|
182
255
|
}
|
|
183
256
|
const slugOf = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -300,6 +373,7 @@ function productFeature(snapshot, id, options) {
|
|
|
300
373
|
releases: releasesOf(snapshot, feature),
|
|
301
374
|
planned: plannedOf(snapshot, feature.id),
|
|
302
375
|
health: featureHealth(context, feature),
|
|
376
|
+
host: snapshot.host ?? null,
|
|
303
377
|
developer: options.shared ? null : {
|
|
304
378
|
folders: readme.folders.map((folder) => folder.value),
|
|
305
379
|
routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),
|
|
@@ -376,10 +450,11 @@ function productFlow(snapshot, featureId, flowId, options) {
|
|
|
376
450
|
previous,
|
|
377
451
|
next,
|
|
378
452
|
health: flowHealthOf(context, flow),
|
|
379
|
-
developer: options.shared ? null : { steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)) }
|
|
453
|
+
developer: options.shared ? null : { steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)) },
|
|
454
|
+
host: snapshot.host ?? null
|
|
380
455
|
};
|
|
381
456
|
}
|
|
382
457
|
|
|
383
458
|
//#endregion
|
|
384
|
-
export { productFeature, productFlow, productMap };
|
|
459
|
+
export { compareReleases, productFeature, productFlow, productMap };
|
|
385
460
|
//# sourceMappingURL=product-map.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-map.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"sourcesContent":["/**\n * The product map answers: the Grimoire in plain words for readers who do\n * not read code. Built from the written files, the book maps, the test\n * results, the open tasks, the changelogs and (when the devtools monitor\n * reports them) the captured errors. A shared answer (`options.shared`)\n * carries no file paths, code or test names.\n */\nimport { checkGrimoire } from \"../check\";\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmap, FlowBookmapCriterion } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport } from \"../contracts/findings\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n WrittenApp,\n WrittenFeature,\n WrittenFlow,\n WrittenScreenshot,\n WrittenStep,\n} from \"../contracts/written\";\nimport { compactStep, flowOrder, neighboursOf } from \"../scry/compact\";\nimport type {\n ProductAppearance,\n ProductFeatureAnswer,\n ProductFeatureCard,\n ProductFlowAnswer,\n ProductFlowCard,\n ProductHealth,\n ProductMapAnswer,\n ProductPlannedItem,\n ProductRelease,\n ProductScreenshot,\n ProductStoryStep,\n} from \"./answers\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** One captured error group as devtools hands it to a panel: counts only. */\nexport type ProductErrorSummary = {\n /** The route pattern (`/products/:id`), or `null` outside a request. */\n route: string | null;\n status: number | null;\n name: string | null;\n source: \"request\" | \"log\";\n count: number;\n firstSeen: number;\n lastSeen: number;\n};\n\n/** How the product map answers are built. */\nexport type ProductMapOptions = {\n /** `true` for a read-only share link: no developer detail. */\n shared: boolean;\n /** Captured error groups, or `null` when the monitor reports none. */\n errors: readonly ProductErrorSummary[] | null;\n};\n\n/** How far back captured errors count (one hour). */\nconst ERROR_WINDOW_MS = 3_600_000;\n\ntype ErrorCount = { count: number; lastSeen: number };\n\n/** Everything the answers share, computed once per request. */\ntype Context = {\n snapshot: GrimoireSnapshot;\n options: ProductMapOptions;\n report: GrimoireCheckReport;\n featureErrors: Map<string, number>;\n flowErrors: Map<string, number>;\n captured: { features: Map<string, ErrorCount>; flows: Map<string, ErrorCount> } | null;\n resultsMissing: boolean;\n};\n\nfunction addCount(map: Map<string, ErrorCount>, key: string, group: ProductErrorSummary): void {\n const known = map.get(key);\n\n map.set(key, {\n count: (known?.count ?? 0) + group.count,\n lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen),\n });\n}\n\n/** Map the last hour's error groups to the features and flows that use their route. */\nfunction captureErrors(\n snapshot: GrimoireSnapshot,\n errors: readonly ProductErrorSummary[],\n now: number,\n): NonNullable<Context[\"captured\"]> {\n const features = new Map<string, ErrorCount>();\n const flows = new Map<string, ErrorCount>();\n const routes = snapshot.book.facts.routes ?? [];\n\n for (const group of errors) {\n if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;\n\n const path = normalizeRoutePath(group.route);\n\n for (const route of routes) {\n if (normalizeRoutePath(route.path) !== path) continue;\n\n const file = route.handlerFile ?? route.sourceFile;\n const owner = file === null ? null : (snapshot.ownership.files[file]?.owner ?? null);\n\n if (owner !== null) addCount(features, owner, group);\n }\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) {\n const hit = flow.steps.some(\n (step) =>\n (step.type === \"route\" &&\n step.route !== null &&\n normalizeRoutePath(step.route.path) === path) ||\n (step.type === \"page\" && normalizeRoutePath(step.target) === path),\n );\n\n if (hit) addCount(flows, flow.ref, group);\n }\n }\n }\n\n return { features, flows };\n}\n\n/**\n * The check report of a snapshot, run once per snapshot. A share link reaches\n * these answers without an account, so a page view must not run the whole\n * check again; a changed book opens a new snapshot and a new report.\n */\nconst reports = new WeakMap<GrimoireSnapshot, GrimoireCheckReport>();\n\nfunction reportOf(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n let report = reports.get(snapshot);\n\n if (report === undefined) {\n report = checkGrimoire(snapshot);\n reports.set(snapshot, report);\n }\n\n return report;\n}\n\nfunction contextOf(snapshot: GrimoireSnapshot, options: ProductMapOptions): Context {\n const report = reportOf(snapshot);\n const featureErrors = new Map<string, number>();\n const flowErrors = new Map<string, number>();\n\n for (const finding of report.findings) {\n if (finding.expected || finding.severity !== \"error\") continue;\n\n const flow = finding.subject.flow;\n const feature = finding.subject.feature ?? flow?.split(\"/\")[0] ?? null;\n\n if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);\n if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);\n }\n\n return {\n snapshot,\n options,\n report,\n featureErrors,\n flowErrors,\n captured:\n options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),\n resultsMissing: snapshot.results === null && snapshot.proofs.length > 0,\n };\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** The traffic light and its sentence (the rules of the product map). */\nfunction healthOf(\n context: Context,\n criteria: readonly Pick<FlowBookmapCriterion, \"status\">[],\n checkErrors: number,\n captured: ErrorCount | undefined,\n): ProductHealth {\n const counts = { total: criteria.length, pass: 0, fail: 0, stale: 0, notRun: 0, noTest: 0 };\n\n for (const criterion of criteria) {\n if (criterion.status === \"pass\") counts.pass += 1;\n else if (criterion.status === \"fail\") counts.fail += 1;\n else if (criterion.status === \"stale\") counts.stale += 1;\n else if (criterion.status === \"not-run\") counts.notRun += 1;\n else counts.noTest += 1;\n }\n\n const errors =\n context.captured === null ? null : { count: captured?.count ?? 0, lastSeen: captured?.lastSeen ?? null };\n const recent = errors?.count ?? 0;\n const total = counts.total;\n let level: ProductHealth[\"level\"];\n let reason: string;\n\n if (counts.fail > 0) {\n level = \"problem\";\n reason = `${counts.fail} of ${total} checks fail`;\n } else if (checkErrors > 0) {\n level = \"problem\";\n reason = `The check found ${plural(checkErrors, \"error\")}`;\n } else if (counts.noTest > 0) {\n level = \"attention\";\n reason = `${counts.noTest} of ${total} checks have no test`;\n } else if (context.resultsMissing && total > 0) {\n level = \"attention\";\n reason = \"No test results recorded\";\n } else if (counts.stale > 0 || counts.notRun > 0) {\n level = \"attention\";\n reason = \"Tests have not run since they changed\";\n } else if (recent > 0) {\n level = \"attention\";\n reason = `${plural(recent, \"error\")} in the last hour`;\n } else if (total > 0) {\n level = \"good\";\n reason = `All ${total} checks pass`;\n } else {\n level = \"unknown\";\n reason = \"No checks written yet\";\n }\n\n return { level, reason, criteria: counts, errors };\n}\n\nfunction featureHealth(context: Context, feature: WrittenFeature): ProductHealth {\n const criteria = feature.flows.flatMap(\n (flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n );\n\n return healthOf(\n context,\n criteria,\n context.featureErrors.get(feature.id) ?? 0,\n context.captured?.features.get(feature.id),\n );\n}\n\nfunction flowHealthOf(context: Context, flow: WrittenFlow): ProductHealth {\n return healthOf(\n context,\n context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n context.flowErrors.get(flow.ref) ?? 0,\n context.captured?.flows.get(flow.ref),\n );\n}\n\nfunction findFeature(snapshot: GrimoireSnapshot, id: string | undefined): WrittenFeature {\n if (id === undefined || id === \"\") throw new GrimoirePanelError(400, 'Missing \"feature\".');\n\n const feature = snapshot.written.features.find((item) => item.id === id);\n\n if (feature === undefined || feature.readme === null) {\n throw new GrimoirePanelError(404, `No feature \"${id}\" is written in grimoire/features.`);\n }\n\n return feature;\n}\n\nfunction audienceOf(feature: WrittenFeature): string[] {\n const listed = (feature.readme?.audience ?? []).map((item) => item.value);\n\n if (listed.length > 0) return listed;\n\n return [...new Set(feature.flows.map((flow) => flow.who.value))];\n}\n\nfunction card(context: Context, feature: WrittenFeature): ProductFeatureCard {\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"A feature card needs a README.\");\n\n return {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n flows: feature.flows.length,\n health: featureHealth(context, feature),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(snapshot: GrimoireSnapshot, options: ProductMapOptions): ProductMapAnswer {\n const context = contextOf(snapshot, options);\n\n return {\n builtAt: snapshot.book.manifest.builtAt,\n features: snapshot.written.features\n .filter((feature) => feature.readme !== null)\n .map((feature) => card(context, feature)),\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n title: app.heading?.value ?? null,\n })),\n developer: !options.shared,\n };\n}\n\nconst slugOf = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\nfunction screenshotsOf(items: readonly WrittenScreenshot[]): ProductScreenshot[] {\n return items.flatMap((item) => (item.path === null ? [] : [{ src: item.path, alt: item.alt }]));\n}\n\n/** Where the flows are shown, with the screenshots of the block (else of the page). */\nfunction appearancesOf(snapshot: GrimoireSnapshot, bookmaps: readonly FlowBookmap[]): ProductAppearance[] {\n const seen = new Set<string>();\n const list: ProductAppearance[] = [];\n const apps = new Map<string, WrittenApp>(snapshot.written.apps.map((app) => [app.id.value, app]));\n\n for (const bookmap of bookmaps) {\n for (const shown of bookmap.shownBy) {\n const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n\n const app = apps.get(shown.app);\n let title: string | null = null;\n let route: string | null = null;\n let screenshots: ProductScreenshot[] = [];\n\n if (app !== undefined && shown.type === \"layout\") {\n title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;\n } else if (app !== undefined) {\n const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);\n\n if (page !== undefined) {\n title = page.heading?.value ?? null;\n route = page.route?.value ?? page.screen?.value ?? null;\n\n const block =\n page.blockFiles.find((item) => item.id === slugOf(shown.block)) ??\n page.blockFiles.find((item) => item.flow?.value === bookmap.ref);\n\n screenshots = screenshotsOf(block?.screenshots ?? []);\n\n if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);\n }\n }\n\n list.push({\n app: shown.app,\n type: shown.type,\n id: shown.id,\n title,\n route,\n block: shown.block,\n flow: bookmap.ref,\n screenshots,\n });\n }\n }\n\n return list;\n}\n\nfunction releasesOf(snapshot: GrimoireSnapshot, feature: WrittenFeature): ProductRelease[] {\n const dates = new Map(snapshot.written.releases.map((item) => [item.release.value, item.date.value]));\n const entries = feature.changelog?.entries ?? [];\n // Unreleased entries first, then the stamped ones in file order (newest first).\n const ordered = [\n ...entries.filter((entry) => entry.release === null),\n ...entries.filter((entry) => entry.release !== null),\n ];\n const groups = new Map<string, ProductRelease>();\n\n for (const entry of ordered) {\n const key = `${entry.version.value}|${entry.release ?? \"\"}`;\n let group = groups.get(key);\n\n if (group === undefined) {\n group = {\n version: entry.version.value,\n release: entry.release,\n date: entry.date ?? (entry.release === null ? null : (dates.get(entry.release) ?? null)),\n changes: [],\n };\n groups.set(key, group);\n }\n\n group.changes.push({ word: entry.word, flow: entry.flow, text: entry.text });\n }\n\n return [...groups.values()];\n}\n\nfunction plannedOf(snapshot: GrimoireSnapshot, feature: string): ProductPlannedItem[] {\n return snapshot.collected.tasksIndex.open\n .filter((task) => task.feature === feature)\n .map((task) => ({\n id: task.id,\n title: task.title,\n type: task.type,\n status: task.status,\n flow: task.flow === null ? null : task.flow.replace(`${feature}/`, \"\"),\n }));\n}\n\nfunction flowCard(context: Context, flow: WrittenFlow): ProductFlowCard {\n return {\n id: flow.id.value,\n ref: flow.ref,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n health: flowHealthOf(context, flow),\n };\n}\n\n/** `GET /product/features/:feature`. */\nexport function productFeature(\n snapshot: GrimoireSnapshot,\n id: string | undefined,\n options: ProductMapOptions,\n): ProductFeatureAnswer {\n const feature = findFeature(snapshot, id);\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"unreachable\");\n\n const context = contextOf(snapshot, options);\n const bookmaps = feature.flows.flatMap((flow) => {\n const bookmap = snapshot.collected.flows[flow.ref];\n\n return bookmap === undefined ? [] : [bookmap];\n });\n const own = snapshot.collected.features[feature.id];\n const unexpected = context.report.findings.filter(\n (finding) =>\n (finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0]) === feature.id,\n );\n const unexpectedNow = unexpected.filter((finding) => !finding.expected);\n const errors = unexpectedNow.filter((finding) => finding.severity === \"error\").length;\n\n return {\n feature: {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n why: readme.why,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n updated: readme.updated.value,\n origin: readme.origin?.value ?? null,\n },\n flows: flowOrder(feature).map((flow) => flowCard(context, flow)),\n appearances: appearancesOf(snapshot, bookmaps),\n releases: releasesOf(snapshot, feature),\n planned: plannedOf(snapshot, feature.id),\n health: featureHealth(context, feature),\n developer: options.shared\n ? null\n : {\n folders: readme.folders.map((folder) => folder.value),\n routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),\n files: own?.own.length ?? 0,\n findings: {\n errors,\n warnings: unexpectedNow.length - errors,\n expected: unexpected.length - unexpectedNow.length,\n },\n },\n };\n}\n\nconst STEP_WORDS: Record<WrittenStep[\"type\"], (target: string) => string> = {\n page: (target) => `Open ${target}`,\n route: () => \"The server takes the request\",\n mail: (target) => `An email \"${target}\" is sent`,\n notification: (target) => `A notification \"${target}\" is sent`,\n job: (target) => `The job \"${target}\" runs in the background`,\n event: (target) => `The event \"${target}\" happens`,\n \"outside service\": (target) => `The outside service \"${target}\" is used`,\n affects: (target) => `This also affects ${target}`,\n};\n\nfunction storyOf(flow: WrittenFlow): ProductStoryStep[] {\n if (flow.story.length > 0) {\n return flow.story.map((step) => ({\n index: step.index,\n text: step.text,\n screenshots: screenshotsOf(step.screenshots),\n derived: false,\n }));\n }\n\n return flow.steps.map((step) => ({\n index: step.index,\n text: step.note ?? STEP_WORDS[step.type](step.target),\n screenshots: [],\n derived: true,\n }));\n}\n\nconst DOES_NOT_APPLY = /^does not apply\\b[:\\s—-]*/i;\n\n/** `GET /product/flows/:feature/:flow`. */\nexport function productFlow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n options: ProductMapOptions,\n): ProductFlowAnswer {\n const feature = findFeature(snapshot, featureId);\n const flow = feature.flows.find((item) => item.id.value === flowId);\n\n if (flow === undefined) {\n throw new GrimoirePanelError(404, `No flow \"${flowId ?? \"\"}\" in feature \"${feature.id}\".`);\n }\n\n const context = contextOf(snapshot, options);\n const bookmap = snapshot.collected.flows[flow.ref];\n const { previous, next } = neighboursOf(feature, flow.id.value);\n\n return {\n flow: {\n ref: flow.ref,\n feature: feature.id,\n featureTitle: feature.readme?.title.value ?? feature.id,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n since: flow.since.value,\n },\n story: storyOf(flow),\n proof: (bookmap?.criteria ?? []).map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n status: criterion.status,\n tests: options.shared ? null : criterion.tests,\n })),\n cases: flow.cases.map((item) => {\n const answer = item.doesNotApply ? item.answer.replace(DOES_NOT_APPLY, \"\").trim() : item.answer;\n\n return {\n question: item.question,\n answer: answer === \"\" ? \"Does not apply\" : answer,\n handled: !item.doesNotApply,\n criteria: item.criteria,\n };\n }),\n appearances: bookmap === undefined ? [] : appearancesOf(snapshot, [bookmap]),\n previous,\n next,\n health: flowHealthOf(context, flow),\n developer: options.shared\n ? null\n : {\n steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,MAAM,kBAAkB;AAexB,SAAS,SAAS,KAA8B,KAAa,OAAkC;CAC7F,MAAM,QAAQ,IAAI,IAAI,GAAG;CAEzB,IAAI,IAAI,KAAK;EACX,QAAQ,OAAO,SAAS,KAAK,MAAM;EACnC,UAAU,KAAK,IAAI,OAAO,YAAY,GAAG,MAAM,QAAQ;CACzD,CAAC;AACH;;AAGA,SAAS,cACP,UACA,QACA,KACkC;CAClC,MAAM,2BAAW,IAAI,IAAwB;CAC7C,MAAM,wBAAQ,IAAI,IAAwB;CAC1C,MAAM,SAAS,SAAS,KAAK,MAAM,UAAU,CAAC;CAE9C,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,MAAM,UAAU,QAAQ,MAAM,WAAW,MAAM,iBAAiB;EAEpE,MAAM,OAAO,mBAAmB,MAAM,KAAK;EAE3C,KAAK,MAAM,SAAS,QAAQ;GAC1B,IAAI,mBAAmB,MAAM,IAAI,MAAM,MAAM;GAE7C,MAAM,OAAO,MAAM,eAAe,MAAM;GACxC,MAAM,QAAQ,SAAS,OAAO,OAAQ,SAAS,UAAU,MAAM,KAAK,EAAE,SAAS;GAE/E,IAAI,UAAU,MAAM,SAAS,UAAU,OAAO,KAAK;EACrD;EAEA,KAAK,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AU;GACd,MAAM,UAAU;GAChB,QAAQ,UAAU;GAClB,OAAO,QAAQ,SAAS,OAAO,UAAU;EAC3C,EAAE;EACF,OAAO,KAAK,MAAM,KAAK,SAAS;GAC9B,MAAM,SAAS,KAAK,eAAe,KAAK,OAAO,QAAQ,gBAAgB,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK;GAEzF,OAAO;IACL,UAAU,KAAK;IACf,QAAQ,WAAW,KAAK,mBAAmB;IAC3C,SAAS,CAAC,KAAK;IACf,UAAU,KAAK;GACjB;EACF,CAAC;EACD,aAAa,YAAY,SAAY,CAAC,IAAI,cAAc,UAAU,CAAC,OAAO,CAAC;EAC3E;EACA;EACA,QAAQ,aAAa,SAAS,IAAI;EAClC,WAAW,QAAQ,SACf,OACA,EACE,QAAQ,SAAS,SAAS,CAAC,EAAC,CAAE,KAAK,SAAS,YAAY,UAAU,SAAS,MAAM,IAAI,CAAC,EACxF;CACN;AACF"}
|
|
1
|
+
{"version":3,"file":"product-map.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"sourcesContent":["/**\n * The product map answers: the Grimoire in plain words for readers who do\n * not read code. Built from the written files, the book maps, the test\n * results, the open tasks, the changelogs and (when the devtools monitor\n * reports them) the captured errors. A shared answer (`options.shared`)\n * carries no file paths, code or test names.\n */\nimport { checkGrimoire } from \"../check\";\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmap, FlowBookmapCriterion } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport } from \"../contracts/findings\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n WrittenApp,\n WrittenFeature,\n WrittenFlow,\n WrittenScreenshot,\n WrittenStep,\n} from \"../contracts/written\";\nimport { compactStep, flowOrder, neighboursOf } from \"../scry/compact\";\nimport type {\n ProductAppearance,\n ProductFeatureAnswer,\n ProductFeatureCard,\n ProductFlowAnswer,\n ProductFlowCard,\n ProductHealth,\n ProductMapAnswer,\n ProductPlannedItem,\n ProductRelease,\n ProductScreenshot,\n ProductStrip,\n ProductStoryStep,\n} from \"./answers\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** One captured error group as devtools hands it to a panel: counts only. */\nexport type ProductErrorSummary = {\n /** The route pattern (`/products/:id`), or `null` outside a request. */\n route: string | null;\n status: number | null;\n name: string | null;\n source: \"request\" | \"log\";\n count: number;\n firstSeen: number;\n lastSeen: number;\n};\n\n/** How the product map answers are built. */\nexport type ProductMapOptions = {\n /** `true` for a read-only share link: no developer detail. */\n shared: boolean;\n /** Captured error groups, or `null` when the monitor reports none. */\n errors: readonly ProductErrorSummary[] | null;\n};\n\n/** How far back captured errors count (one hour). */\nconst ERROR_WINDOW_MS = 3_600_000;\n\ntype ErrorCount = { count: number; lastSeen: number };\n\n/** Everything the answers share, computed once per request. */\ntype Context = {\n snapshot: GrimoireSnapshot;\n options: ProductMapOptions;\n report: GrimoireCheckReport;\n featureErrors: Map<string, number>;\n flowErrors: Map<string, number>;\n /** Unexpected findings by feature id. */\n featureFindings: Map<string, { errors: number; warnings: number }>;\n captured: { features: Map<string, ErrorCount>; flows: Map<string, ErrorCount> } | null;\n resultsMissing: boolean;\n};\n\nfunction addCount(map: Map<string, ErrorCount>, key: string, group: ProductErrorSummary): void {\n const known = map.get(key);\n\n map.set(key, {\n count: (known?.count ?? 0) + group.count,\n lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen),\n });\n}\n\n/** Map the last hour's error groups to the features and flows that use their route. */\nfunction captureErrors(\n snapshot: GrimoireSnapshot,\n errors: readonly ProductErrorSummary[],\n now: number,\n): NonNullable<Context[\"captured\"]> {\n const features = new Map<string, ErrorCount>();\n const flows = new Map<string, ErrorCount>();\n const routes = snapshot.book.facts.routes ?? [];\n\n for (const group of errors) {\n if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;\n\n const path = normalizeRoutePath(group.route);\n\n for (const route of routes) {\n if (normalizeRoutePath(route.path) !== path) continue;\n\n const file = route.handlerFile ?? route.sourceFile;\n const owner = file === null ? null : (snapshot.ownership.files[file]?.owner ?? null);\n\n if (owner !== null) addCount(features, owner, group);\n }\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) {\n const hit = flow.steps.some(\n (step) =>\n (step.type === \"route\" &&\n step.route !== null &&\n normalizeRoutePath(step.route.path) === path) ||\n (step.type === \"page\" && normalizeRoutePath(step.target) === path),\n );\n\n if (hit) addCount(flows, flow.ref, group);\n }\n }\n }\n\n return { features, flows };\n}\n\n/**\n * The check report of a snapshot, run once per snapshot. A share link reaches\n * these answers without an account, so a page view must not run the whole\n * check again; a changed book opens a new snapshot and a new report.\n */\nconst reports = new WeakMap<GrimoireSnapshot, GrimoireCheckReport>();\n\nfunction reportOf(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n let report = reports.get(snapshot);\n\n if (report === undefined) {\n report = checkGrimoire(snapshot);\n reports.set(snapshot, report);\n }\n\n return report;\n}\n\nfunction contextOf(snapshot: GrimoireSnapshot, options: ProductMapOptions): Context {\n const report = reportOf(snapshot);\n const featureErrors = new Map<string, number>();\n const flowErrors = new Map<string, number>();\n const featureFindings = new Map<string, { errors: number; warnings: number }>();\n\n for (const finding of report.findings) {\n if (finding.expected) continue;\n\n const owner = finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? null;\n\n if (owner !== null) {\n const known = featureFindings.get(owner) ?? { errors: 0, warnings: 0 };\n\n if (finding.severity === \"error\") known.errors += 1;\n else known.warnings += 1;\n\n featureFindings.set(owner, known);\n }\n\n if (finding.severity !== \"error\") continue;\n\n const flow = finding.subject.flow;\n const feature = finding.subject.feature ?? flow?.split(\"/\")[0] ?? null;\n\n if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);\n if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);\n }\n\n return {\n snapshot,\n options,\n report,\n featureErrors,\n flowErrors,\n featureFindings,\n captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),\n resultsMissing: snapshot.results === null && snapshot.proofs.length > 0,\n };\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** The traffic light and its sentence (the rules of the product map). */\nfunction healthOf(\n context: Context,\n criteria: readonly Pick<FlowBookmapCriterion, \"status\">[],\n checkErrors: number,\n captured: ErrorCount | undefined,\n): ProductHealth {\n const counts = { total: criteria.length, pass: 0, fail: 0, stale: 0, notRun: 0, noTest: 0 };\n\n for (const criterion of criteria) {\n if (criterion.status === \"pass\") counts.pass += 1;\n else if (criterion.status === \"fail\") counts.fail += 1;\n else if (criterion.status === \"stale\") counts.stale += 1;\n else if (criterion.status === \"not-run\") counts.notRun += 1;\n else counts.noTest += 1;\n }\n\n const errors =\n context.captured === null\n ? null\n : { count: captured?.count ?? 0, lastSeen: captured?.lastSeen ?? null };\n const recent = errors?.count ?? 0;\n const total = counts.total;\n let level: ProductHealth[\"level\"];\n let reason: string;\n\n if (counts.fail > 0) {\n level = \"problem\";\n reason = `${counts.fail} of ${total} checks fail`;\n } else if (checkErrors > 0) {\n level = \"problem\";\n reason = `The check found ${plural(checkErrors, \"error\")}`;\n } else if (counts.noTest > 0) {\n level = \"attention\";\n reason = `${counts.noTest} of ${total} checks have no test`;\n } else if (context.resultsMissing && total > 0) {\n // A missing results file is a missing measurement, not a product problem: a shared (business) view shows it neutral.\n if (context.options.shared) {\n level = \"unknown\";\n reason = \"Test results are not measured\";\n } else {\n level = \"attention\";\n reason = \"No test results recorded\";\n }\n } else if (counts.stale > 0 || counts.notRun > 0) {\n level = \"attention\";\n reason = \"Tests have not run since they changed\";\n } else if (recent > 0) {\n level = \"attention\";\n reason = `${plural(recent, \"error\")} in the last hour`;\n } else if (total > 0) {\n level = \"good\";\n reason = `All ${total} checks pass`;\n } else {\n level = \"unknown\";\n reason = \"No checks written yet\";\n }\n\n return { level, reason, criteria: counts, errors };\n}\n\nfunction featureHealth(context: Context, feature: WrittenFeature): ProductHealth {\n const criteria = feature.flows.flatMap(\n (flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n );\n\n return healthOf(\n context,\n criteria,\n context.featureErrors.get(feature.id) ?? 0,\n context.captured?.features.get(feature.id),\n );\n}\n\nfunction flowHealthOf(context: Context, flow: WrittenFlow): ProductHealth {\n return healthOf(\n context,\n context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n context.flowErrors.get(flow.ref) ?? 0,\n context.captured?.flows.get(flow.ref),\n );\n}\n\nfunction findFeature(snapshot: GrimoireSnapshot, id: string | undefined): WrittenFeature {\n if (id === undefined || id === \"\") throw new GrimoirePanelError(400, 'Missing \"feature\".');\n\n const feature = snapshot.written.features.find((item) => item.id === id);\n\n if (feature === undefined || feature.readme === null) {\n throw new GrimoirePanelError(404, `No feature \"${id}\" is written in grimoire/features.`);\n }\n\n return feature;\n}\n\nfunction audienceOf(feature: WrittenFeature): string[] {\n const listed = (feature.readme?.audience ?? []).map((item) => item.value);\n\n if (listed.length > 0) return listed;\n\n return [...new Set(feature.flows.map((flow) => flow.who.value))];\n}\n\n/** The health strip numbers of a feature card. */\nfunction stripOf(context: Context, feature: WrittenFeature, health: ProductHealth): ProductStrip {\n const bookmaps = feature.flows.flatMap((flow) => {\n const found = context.snapshot.collected.flows[flow.ref];\n\n return found === undefined ? [] : [found];\n });\n const places = appearancesOf(context.snapshot, bookmaps);\n\n return {\n flows: {\n total: feature.flows.length,\n shipped: feature.flows.filter((flow) => flow.status.value === \"shipped\").length,\n },\n criteria: {\n total: health.criteria.total,\n proven: health.criteria.pass,\n failing: health.criteria.fail,\n // Nothing is measured when no result was recorded, or none of the criteria has a result yet.\n measured:\n !context.resultsMissing &&\n (health.criteria.total === 0 ||\n health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 ||\n health.criteria.notRun === 0),\n },\n screenshots: {\n places: places.length,\n present: places.filter((place) => place.screenshots.length > 0).length,\n },\n findings: context.featureFindings.get(feature.id) ?? { errors: 0, warnings: 0 },\n };\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */\nconst isDay = (value: string): boolean =>\n DAY.test(value) && !Number.isNaN(new Date(`${value}T00:00:00Z`).getTime());\n\n/** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */\nexport function compareReleases(left: string, right: string): number {\n const parts = (value: string) => value.split(/[.\\-+]/).map((part) => part);\n const a = parts(left);\n const b = parts(right);\n\n for (let index = 0; index < Math.max(a.length, b.length); index += 1) {\n const x = a[index] ?? \"0\";\n const y = b[index] ?? \"0\";\n const numeric = /^\\d+$/.test(x) && /^\\d+$/.test(y);\n const diff = numeric ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;\n\n if (diff !== 0) return diff;\n }\n\n return 0;\n}\n\nfunction card(context: Context, feature: WrittenFeature): ProductFeatureCard {\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"A feature card needs a README.\");\n\n const health = featureHealth(context, feature);\n const entries = feature.changelog?.entries ?? [];\n const dates = [\n readme.updated.value,\n ...entries.flatMap((entry) => (entry.date === null ? [] : [entry.date])),\n ].filter(isDay);\n\n return {\n changedAt: dates.reduce((newest, date) => (date > newest ? date : newest), \"\"),\n changedIn: [\n ...new Set(entries.flatMap((entry) => (entry.release === null ? [] : [entry.release]))),\n ],\n unreleased: entries.some((entry) => entry.release === null),\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n flows: feature.flows.length,\n health,\n strip: stripOf(context, feature, health),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductMapAnswer {\n const context = contextOf(snapshot, options);\n\n return {\n builtAt: snapshot.book.manifest.builtAt,\n features: snapshot.written.features\n .filter((feature) => feature.readme !== null)\n .map((feature) => card(context, feature)),\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n title: app.heading?.value ?? null,\n })),\n releases: snapshot.written.releases\n .map((item) => ({ release: item.release.value, date: item.date.value }))\n .sort(\n (left, right) =>\n left.date.localeCompare(right.date) || compareReleases(left.release, right.release),\n ),\n developer: !options.shared,\n host: snapshot.host ?? null,\n };\n}\n\nconst slugOf = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\nfunction screenshotsOf(items: readonly WrittenScreenshot[]): ProductScreenshot[] {\n return items.flatMap((item) => (item.path === null ? [] : [{ src: item.path, alt: item.alt }]));\n}\n\n/** Where the flows are shown, with the screenshots of the block (else of the page). */\nfunction appearancesOf(\n snapshot: GrimoireSnapshot,\n bookmaps: readonly FlowBookmap[],\n): ProductAppearance[] {\n const seen = new Set<string>();\n const list: ProductAppearance[] = [];\n const apps = new Map<string, WrittenApp>(snapshot.written.apps.map((app) => [app.id.value, app]));\n\n for (const bookmap of bookmaps) {\n for (const shown of bookmap.shownBy) {\n const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n\n const app = apps.get(shown.app);\n let title: string | null = null;\n let route: string | null = null;\n let screenshots: ProductScreenshot[] = [];\n\n if (app !== undefined && shown.type === \"layout\") {\n title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;\n } else if (app !== undefined) {\n const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);\n\n if (page !== undefined) {\n title = page.heading?.value ?? null;\n route = page.route?.value ?? page.screen?.value ?? null;\n\n const block =\n page.blockFiles.find((item) => item.id === slugOf(shown.block)) ??\n page.blockFiles.find((item) => item.flow?.value === bookmap.ref);\n\n screenshots = screenshotsOf(block?.screenshots ?? []);\n\n if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);\n }\n }\n\n list.push({\n app: shown.app,\n type: shown.type,\n id: shown.id,\n title,\n route,\n block: shown.block,\n flow: bookmap.ref,\n screenshots,\n });\n }\n }\n\n return list;\n}\n\nfunction releasesOf(snapshot: GrimoireSnapshot, feature: WrittenFeature): ProductRelease[] {\n const dates = new Map(\n snapshot.written.releases.map((item) => [item.release.value, item.date.value]),\n );\n const entries = feature.changelog?.entries ?? [];\n // Unreleased entries first, then the stamped ones in file order (newest first).\n const ordered = [\n ...entries.filter((entry) => entry.release === null),\n ...entries.filter((entry) => entry.release !== null),\n ];\n const groups = new Map<string, ProductRelease>();\n\n for (const entry of ordered) {\n const key = `${entry.version.value}|${entry.release ?? \"\"}`;\n let group = groups.get(key);\n\n if (group === undefined) {\n group = {\n version: entry.version.value,\n release: entry.release,\n date: entry.date ?? (entry.release === null ? null : (dates.get(entry.release) ?? null)),\n changes: [],\n };\n groups.set(key, group);\n }\n\n group.changes.push({ word: entry.word, flow: entry.flow, text: entry.text });\n }\n\n return [...groups.values()];\n}\n\nfunction plannedOf(snapshot: GrimoireSnapshot, feature: string): ProductPlannedItem[] {\n return snapshot.collected.tasksIndex.open\n .filter((task) => task.feature === feature)\n .map((task) => ({\n id: task.id,\n title: task.title,\n type: task.type,\n status: task.status,\n flow: task.flow === null ? null : task.flow.replace(`${feature}/`, \"\"),\n }));\n}\n\nfunction flowCard(context: Context, flow: WrittenFlow): ProductFlowCard {\n return {\n id: flow.id.value,\n ref: flow.ref,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n health: flowHealthOf(context, flow),\n };\n}\n\n/** `GET /product/features/:feature`. */\nexport function productFeature(\n snapshot: GrimoireSnapshot,\n id: string | undefined,\n options: ProductMapOptions,\n): ProductFeatureAnswer {\n const feature = findFeature(snapshot, id);\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"unreachable\");\n\n const context = contextOf(snapshot, options);\n const bookmaps = feature.flows.flatMap((flow) => {\n const bookmap = snapshot.collected.flows[flow.ref];\n\n return bookmap === undefined ? [] : [bookmap];\n });\n const own = snapshot.collected.features[feature.id];\n const unexpected = context.report.findings.filter(\n (finding) => (finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0]) === feature.id,\n );\n const unexpectedNow = unexpected.filter((finding) => !finding.expected);\n const errors = unexpectedNow.filter((finding) => finding.severity === \"error\").length;\n\n return {\n feature: {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n why: readme.why,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n updated: readme.updated.value,\n origin: readme.origin?.value ?? null,\n },\n flows: flowOrder(feature).map((flow) => flowCard(context, flow)),\n appearances: appearancesOf(snapshot, bookmaps),\n releases: releasesOf(snapshot, feature),\n planned: plannedOf(snapshot, feature.id),\n health: featureHealth(context, feature),\n host: snapshot.host ?? null,\n developer: options.shared\n ? null\n : {\n folders: readme.folders.map((folder) => folder.value),\n routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),\n files: own?.own.length ?? 0,\n findings: {\n errors,\n warnings: unexpectedNow.length - errors,\n expected: unexpected.length - unexpectedNow.length,\n },\n },\n };\n}\n\nconst STEP_WORDS: Record<WrittenStep[\"type\"], (target: string) => string> = {\n page: (target) => `Open ${target}`,\n route: () => \"The server takes the request\",\n mail: (target) => `An email \"${target}\" is sent`,\n notification: (target) => `A notification \"${target}\" is sent`,\n job: (target) => `The job \"${target}\" runs in the background`,\n event: (target) => `The event \"${target}\" happens`,\n \"outside service\": (target) => `The outside service \"${target}\" is used`,\n affects: (target) => `This also affects ${target}`,\n};\n\nfunction storyOf(flow: WrittenFlow): ProductStoryStep[] {\n if (flow.story.length > 0) {\n return flow.story.map((step) => ({\n index: step.index,\n text: step.text,\n screenshots: screenshotsOf(step.screenshots),\n derived: false,\n }));\n }\n\n return flow.steps.map((step) => ({\n index: step.index,\n text: step.note ?? STEP_WORDS[step.type](step.target),\n screenshots: [],\n derived: true,\n }));\n}\n\nconst DOES_NOT_APPLY = /^does not apply\\b[:\\s—-]*/i;\n\n/** `GET /product/flows/:feature/:flow`. */\nexport function productFlow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n options: ProductMapOptions,\n): ProductFlowAnswer {\n const feature = findFeature(snapshot, featureId);\n const flow = feature.flows.find((item) => item.id.value === flowId);\n\n if (flow === undefined) {\n throw new GrimoirePanelError(404, `No flow \"${flowId ?? \"\"}\" in feature \"${feature.id}\".`);\n }\n\n const context = contextOf(snapshot, options);\n const bookmap = snapshot.collected.flows[flow.ref];\n const { previous, next } = neighboursOf(feature, flow.id.value);\n\n return {\n flow: {\n ref: flow.ref,\n feature: feature.id,\n featureTitle: feature.readme?.title.value ?? feature.id,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n since: flow.since.value,\n },\n story: storyOf(flow),\n proof: (bookmap?.criteria ?? []).map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n status: criterion.status,\n tests: options.shared ? null : criterion.tests,\n })),\n cases: flow.cases.map((item) => {\n const answer = item.doesNotApply\n ? item.answer.replace(DOES_NOT_APPLY, \"\").trim()\n : item.answer;\n\n return {\n question: item.question,\n answer: answer === \"\" ? \"Does not apply\" : answer,\n handled: !item.doesNotApply,\n criteria: item.criteria,\n };\n }),\n appearances: bookmap === undefined ? [] : appearancesOf(snapshot, [bookmap]),\n previous,\n next,\n health: flowHealthOf(context, flow),\n developer: options.shared\n ? null\n : {\n steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)),\n },\n host: snapshot.host ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,MAAM,kBAAkB;AAiBxB,SAAS,SAAS,KAA8B,KAAa,OAAkC;CAC7F,MAAM,QAAQ,IAAI,IAAI,GAAG;CAEzB,IAAI,IAAI,KAAK;EACX,QAAQ,OAAO,SAAS,KAAK,MAAM;EACnC,UAAU,KAAK,IAAI,OAAO,YAAY,GAAG,MAAM,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Y,UAAU,SAAS,MAAM,IAAI,CAAC,EACxF;EACJ,MAAM,SAAS,QAAQ;CACzB;AACF"}
|
package/esm/devtools/site.d.mts
CHANGED
|
@@ -9,6 +9,38 @@ export type ExportGrimoireSiteOptions = {
|
|
|
9
9
|
adapter?: BookAdapter | (() => Promise<BookAdapter>);
|
|
10
10
|
/** An already opened snapshot; skips opening one. */
|
|
11
11
|
snapshot?: GrimoireSnapshot;
|
|
12
|
+
/**
|
|
13
|
+
* Export the business view only: the share-safe Product map (no file paths, test
|
|
14
|
+
* names or export names, no per-file answers, no check or search of code). The
|
|
15
|
+
* page opens on the Product map.
|
|
16
|
+
*/
|
|
17
|
+
product?: boolean;
|
|
18
|
+
/** Write the page even when the folder already holds one built from the same book. Default `false`. */
|
|
19
|
+
force?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** What `exportGrimoireSite()` did. */
|
|
22
|
+
export type GrimoireSiteExport = {
|
|
23
|
+
/** The output folder, project-relative. */
|
|
24
|
+
outDir: string;
|
|
25
|
+
/** `true` when the folder already held a page built from the same book and nothing was written. */
|
|
26
|
+
upToDate: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** One entry of the exported search list. `text` is written content (a flow's summary, story, cases and criteria) the search also reads. */
|
|
29
|
+
type SearchItem = {
|
|
30
|
+
type: string;
|
|
31
|
+
id: string;
|
|
32
|
+
detail: string | null;
|
|
33
|
+
text?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The business-only data of the static export: the share-safe Product map, its feature
|
|
37
|
+
* and flow pages, and nothing else. No file paths, test names, export names, check
|
|
38
|
+
* findings or per-file answers; the search list is empty.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildProductSiteData(snapshot: GrimoireSnapshot): {
|
|
41
|
+
routes: Record<string, unknown>;
|
|
42
|
+
files: {};
|
|
43
|
+
search: SearchItem[];
|
|
12
44
|
};
|
|
13
45
|
/**
|
|
14
46
|
* Write the tab as a static folder for people without the app running.
|
|
@@ -18,9 +50,19 @@ export type ExportGrimoireSiteOptions = {
|
|
|
18
50
|
* page and use `#grimoire/...` links; the answers that need the running app
|
|
19
51
|
* (impact of a file) say so in place.
|
|
20
52
|
*
|
|
53
|
+
* With `product: true` the page is the business export: the share-safe
|
|
54
|
+
* Product map only, no file paths, test names or per-file answers.
|
|
55
|
+
*
|
|
56
|
+
* The page carries a freshness stamp (the files of the book, the written
|
|
57
|
+
* folders and the test results). When the folder already holds a page with
|
|
58
|
+
* the same stamp and the same mode, nothing is rebuilt or written (`force`
|
|
59
|
+
* writes it anyway).
|
|
60
|
+
*
|
|
21
61
|
* @param root Absolute project root.
|
|
22
|
-
* @returns The output folder, project-relative.
|
|
23
62
|
*/
|
|
63
|
+
export declare function exportGrimoireSiteDetailed(root: string, options?: ExportGrimoireSiteOptions): Promise<GrimoireSiteExport>;
|
|
64
|
+
/** `exportGrimoireSiteDetailed()` that returns only the output folder, project-relative. */
|
|
24
65
|
export declare function exportGrimoireSite(root: string, options?: ExportGrimoireSiteOptions): Promise<string>;
|
|
25
66
|
//#endregion
|
|
67
|
+
export {};
|
|
26
68
|
//# sourceMappingURL=site.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;YAoBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;EAMX;;EAEA;;;YAIU;;EAEV;;EAEA;;;KAOG;EAAe;EAAc;EAAY;EAAuB;;;;;;;wBAuJrD,qBAAqB,UAAU;;;EAmBH,QAAA;;;;;;;;;;;;;;;;;;;;wBAsPtB,2BACpB,cACA,UAAS,4BACR,QAAQ;;wBAiDW,mBACpB,cACA,UAAS,4BACR"}
|
package/esm/devtools/site.mjs
CHANGED
|
@@ -3,8 +3,10 @@ import { featureGraph, fileGraph, pageGraph } from "./graphs.mjs";
|
|
|
3
3
|
import { apps, check, checkGroups, feature, features, file, flowAnswer, graphOfModules, page, releases, summary, tasks } from "./data.mjs";
|
|
4
4
|
import { productFeature, productFlow, productMap } from "./product-map.mjs";
|
|
5
5
|
import { createSnapshotSource } from "./snapshot-source.mjs";
|
|
6
|
+
import { stampOf } from "../workspace/cache.mjs";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import {
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { copyFile, mkdir, open, readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
8
10
|
import { fileURLToPath } from "node:url";
|
|
9
11
|
|
|
10
12
|
//#region ../../packages/grimoire/src/devtools/site.ts
|
|
@@ -15,6 +17,15 @@ import { fileURLToPath } from "node:url";
|
|
|
15
17
|
*/
|
|
16
18
|
/** The most files the export keeps per-file answers for (the most imported first). */
|
|
17
19
|
const SITE_FILE_LIMIT = 3e3;
|
|
20
|
+
/** The written text of a flow the exported search reads, with criteria ids so `AC-5` is findable. */
|
|
21
|
+
function flowSearchText(flow) {
|
|
22
|
+
return [
|
|
23
|
+
flow.summary ?? "",
|
|
24
|
+
...flow.story.map((step) => step.text),
|
|
25
|
+
...flow.cases.map((item) => `${item.question} ${item.answer} ${item.criteria.join(" ")}`),
|
|
26
|
+
...flow.criteria.map((item) => `${item.id} ${item.text}`)
|
|
27
|
+
].filter((part) => part !== "").join(" | ");
|
|
28
|
+
}
|
|
18
29
|
const uiFolder = fileURLToPath(new URL("../../ui/", import.meta.url));
|
|
19
30
|
/** Every answer the static page can give, keyed by the data route it replaces. */
|
|
20
31
|
function buildSiteData(snapshot) {
|
|
@@ -45,7 +56,8 @@ function buildSiteData(snapshot) {
|
|
|
45
56
|
search.push({
|
|
46
57
|
type: "feature",
|
|
47
58
|
id: feature$1.id,
|
|
48
|
-
detail: readme?.title.value ?? null
|
|
59
|
+
detail: readme?.title.value ?? null,
|
|
60
|
+
text: [readme?.summary ?? "", readme?.why ?? ""].filter((part) => part !== "").join(" | ")
|
|
49
61
|
});
|
|
50
62
|
const answered = attempt(() => feature(snapshot, feature$1.id));
|
|
51
63
|
if (answered !== void 0) routes[`features/${feature$1.id}`] = answered;
|
|
@@ -57,7 +69,8 @@ function buildSiteData(snapshot) {
|
|
|
57
69
|
search.push({
|
|
58
70
|
type: "flow",
|
|
59
71
|
id: flow.ref,
|
|
60
|
-
detail: flow.heading?.value ?? null
|
|
72
|
+
detail: flow.heading?.value ?? null,
|
|
73
|
+
text: flowSearchText(flow)
|
|
61
74
|
});
|
|
62
75
|
const flowAnswer$1 = attempt(() => flowAnswer(snapshot, feature$1.id, flow.id.value));
|
|
63
76
|
const productFlowAnswer = attempt(() => productFlow(snapshot, feature$1.id, flow.id.value, productOptions));
|
|
@@ -118,6 +131,33 @@ function buildSiteData(snapshot) {
|
|
|
118
131
|
search
|
|
119
132
|
};
|
|
120
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The business-only data of the static export: the share-safe Product map, its feature
|
|
136
|
+
* and flow pages, and nothing else. No file paths, test names, export names, check
|
|
137
|
+
* findings or per-file answers; the search list is empty.
|
|
138
|
+
*/
|
|
139
|
+
function buildProductSiteData(snapshot) {
|
|
140
|
+
const options = {
|
|
141
|
+
shared: true,
|
|
142
|
+
errors: null
|
|
143
|
+
};
|
|
144
|
+
const routes = {};
|
|
145
|
+
const map = attempt(() => productMap(snapshot, options));
|
|
146
|
+
if (map !== void 0) routes.product = map;
|
|
147
|
+
for (const feature of snapshot.written.features) {
|
|
148
|
+
const answer = attempt(() => productFeature(snapshot, feature.id, options));
|
|
149
|
+
if (answer !== void 0) routes[`product/features/${feature.id}`] = answer;
|
|
150
|
+
for (const flow of feature.flows) {
|
|
151
|
+
const flowAnswer = attempt(() => productFlow(snapshot, feature.id, flow.id.value, options));
|
|
152
|
+
if (flowAnswer !== void 0) routes[`product/flows/${flow.ref}`] = flowAnswer;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
routes,
|
|
157
|
+
files: {},
|
|
158
|
+
search: []
|
|
159
|
+
};
|
|
160
|
+
}
|
|
121
161
|
/** JSON for an inline `<script>`: every `<` is escaped, so no `<\/script` or `<!--` can appear. */
|
|
122
162
|
function inlineJson(value) {
|
|
123
163
|
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
@@ -200,8 +240,8 @@ function inlineProductMap(source) {
|
|
|
200
240
|
* The values keep text AA on `--background` and `--card`.
|
|
201
241
|
*/
|
|
202
242
|
const PAGE_STYLE = `
|
|
203
|
-
:root{color-scheme:light dark;--background:#
|
|
204
|
-
@media (prefers-color-scheme:dark){:root{--background:#
|
|
243
|
+
:root{color-scheme:light dark;--background:#faf8f2;--foreground:#1a1814;--card:#fff;--card-foreground:#1a1814;--popover:#fff;--popover-foreground:#1a1814;--primary:#1a1814;--primary-foreground:#faf8f2;--secondary:#f0ece0;--secondary-foreground:#1a1814;--muted:#f0ece0;--muted-foreground:#5c574b;--accent:#f3ecd6;--accent-foreground:#1a1814;--destructive:#b42318;--border:#e0d9c6;--input:#d2cab3;--ring:#8a5a00;--radius:10px;--brand:#8a5a00;--brand-foreground:#fff;--success:#13693b;--warning:#8a5300;--info:#0b66a3;--chart-1:#8a5a00;--chart-2:#13693b;--chart-3:#0b66a3;--chart-4:#6d3ac7;--chart-5:#b4306b;font-family:system-ui,-apple-system,"Segoe UI",sans-serif}
|
|
244
|
+
@media (prefers-color-scheme:dark){:root{--background:#0b0b0c;--foreground:#f2f2ee;--card:#141416;--card-foreground:#f2f2ee;--popover:#141416;--popover-foreground:#f2f2ee;--primary:#ffc61a;--primary-foreground:#1a1300;--secondary:#1f1f22;--secondary-foreground:#f2f2ee;--muted:#1f1f22;--muted-foreground:#a9a9b0;--accent:#26262a;--accent-foreground:#f2f2ee;--destructive:#ff8f86;--border:#2a2a2e;--input:#34343a;--ring:#ffc61a;--radius:10px;--brand:#ffc61a;--brand-foreground:#1a1300;--success:#5fd391;--warning:#f3a24a;--info:#6cc0f5;--chart-1:#ffc61a;--chart-2:#5fd391;--chart-3:#6cc0f5;--chart-4:#b79cff;--chart-5:#ff8fbd}}
|
|
205
245
|
*{box-sizing:border-box}body{margin:0;background:var(--background);color:var(--foreground);font-size:14px;line-height:1.5}
|
|
206
246
|
main{max-width:1180px;margin:0 auto;padding:16px}
|
|
207
247
|
.empty{padding:12px;color:var(--muted-foreground)}.error{padding:12px;color:var(--destructive)}
|
|
@@ -209,14 +249,17 @@ main{max-width:1180px;margin:0 auto;padding:16px}
|
|
|
209
249
|
/** The `index.html` text. */
|
|
210
250
|
function renderSiteHtml(siteData, sources) {
|
|
211
251
|
const json = inlineJson(siteData);
|
|
212
|
-
|
|
252
|
+
if (sources.product === true && sources.productMap === void 0) throw new Error("A product export needs product-map.js.");
|
|
253
|
+
const mounted = sources.product === true ? "renderProductMap" : "renderGrimoire";
|
|
254
|
+
const script = inlineCode(`${sources.productMap === void 0 ? "" : inlineProductMap(sources.productMap)}${sources.product === true ? "" : inlineView(sources.view)}\n${sources.loader}\ngrimoireStaticMount(JSON.parse(document.getElementById("grimoire-data").textContent), document.getElementById("grimoire-root"), ${mounted});\n`);
|
|
255
|
+
const styles = sources.product === true ? "" : sources.css;
|
|
213
256
|
return `<!doctype html>
|
|
214
257
|
<html lang="en">
|
|
215
258
|
<head>
|
|
216
259
|
<meta charset="utf-8">
|
|
217
260
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
218
|
-
<title
|
|
219
|
-
<style>${PAGE_STYLE}${
|
|
261
|
+
${sources.stamp === void 0 ? "" : `<meta name="grimoire-stamp" content="${sources.stamp}">\n`}<title>${sources.product === true ? "Product map" : "Grimoire"}</title>
|
|
262
|
+
<style>${PAGE_STYLE}${styles}${sources.productCss ?? ""}</style>
|
|
220
263
|
</head>
|
|
221
264
|
<body>
|
|
222
265
|
<main id="grimoire-root"><p class="empty">Opening the book…</p></main>
|
|
@@ -226,6 +269,37 @@ function renderSiteHtml(siteData, sources) {
|
|
|
226
269
|
</html>
|
|
227
270
|
`;
|
|
228
271
|
}
|
|
272
|
+
/** The stamp is written near the top of the page; this much of the file is enough to find it. */
|
|
273
|
+
const STAMP_HEAD_BYTES = 2048;
|
|
274
|
+
/** The stamp of the page that is already in `index.html`, or `null` (no page, or one without a stamp). */
|
|
275
|
+
async function writtenStamp(file) {
|
|
276
|
+
let handle;
|
|
277
|
+
try {
|
|
278
|
+
handle = await open(file, "r");
|
|
279
|
+
const { buffer, bytesRead } = await handle.read(Buffer.alloc(STAMP_HEAD_BYTES), 0, STAMP_HEAD_BYTES, 0);
|
|
280
|
+
return /<meta name="grimoire-stamp" content="([0-9a-f]+)">/.exec(buffer.toString("utf8", 0, bytesRead))?.[1] ?? null;
|
|
281
|
+
} catch {
|
|
282
|
+
return null;
|
|
283
|
+
} finally {
|
|
284
|
+
await handle?.close();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** Modified times of the files the page is built from, so a new framework version rebuilds the page. */
|
|
288
|
+
async function uiStamp() {
|
|
289
|
+
return (await Promise.all([
|
|
290
|
+
"grimoire-view.js",
|
|
291
|
+
"grimoire-static.js",
|
|
292
|
+
"grimoire.css",
|
|
293
|
+
"product-map.js",
|
|
294
|
+
"product-map.css"
|
|
295
|
+
].map(async (name) => {
|
|
296
|
+
try {
|
|
297
|
+
return (await stat(path.join(uiFolder, name))).mtimeMs;
|
|
298
|
+
} catch {
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
}))).join(",");
|
|
302
|
+
}
|
|
229
303
|
/**
|
|
230
304
|
* Write the tab as a static folder for people without the app running.
|
|
231
305
|
*
|
|
@@ -234,12 +308,26 @@ function renderSiteHtml(siteData, sources) {
|
|
|
234
308
|
* page and use `#grimoire/...` links; the answers that need the running app
|
|
235
309
|
* (impact of a file) say so in place.
|
|
236
310
|
*
|
|
311
|
+
* With `product: true` the page is the business export: the share-safe
|
|
312
|
+
* Product map only, no file paths, test names or per-file answers.
|
|
313
|
+
*
|
|
314
|
+
* The page carries a freshness stamp (the files of the book, the written
|
|
315
|
+
* folders and the test results). When the folder already holds a page with
|
|
316
|
+
* the same stamp and the same mode, nothing is rebuilt or written (`force`
|
|
317
|
+
* writes it anyway).
|
|
318
|
+
*
|
|
237
319
|
* @param root Absolute project root.
|
|
238
|
-
* @returns The output folder, project-relative.
|
|
239
320
|
*/
|
|
240
|
-
async function
|
|
321
|
+
async function exportGrimoireSiteDetailed(root, options = {}) {
|
|
241
322
|
const outDir = projectPath(root, toPosixPath(options.outDir ?? GRIMOIRE_PATHS.staticSite)).replace(/\/+$/, "");
|
|
242
323
|
const snapshot = options.snapshot ?? await createSnapshotSource(root, options.adapter === void 0 ? {} : { adapter: options.adapter }).get();
|
|
324
|
+
const absolute = path.resolve(root, outDir);
|
|
325
|
+
const product = options.product === true;
|
|
326
|
+
const stamp = createHash("sha1").update(`${product ? "product" : "full"}|${await stampOf(root, snapshot)}|${await uiStamp()}`).digest("hex");
|
|
327
|
+
if (options.force !== true && await writtenStamp(path.join(absolute, "index.html")) === stamp) return {
|
|
328
|
+
outDir,
|
|
329
|
+
upToDate: true
|
|
330
|
+
};
|
|
243
331
|
const [view, loader, css, productMapSource, productCss] = await Promise.all([
|
|
244
332
|
"grimoire-view.js",
|
|
245
333
|
"grimoire-static.js",
|
|
@@ -247,20 +335,28 @@ async function exportGrimoireSite(root, options = {}) {
|
|
|
247
335
|
"product-map.js",
|
|
248
336
|
"product-map.css"
|
|
249
337
|
].map((name) => readFile(path.join(uiFolder, name), "utf8")));
|
|
250
|
-
const html = renderSiteHtml(buildSiteData(snapshot), {
|
|
338
|
+
const html = renderSiteHtml(product ? buildProductSiteData(snapshot) : buildSiteData(snapshot), {
|
|
251
339
|
view: view ?? "",
|
|
252
340
|
loader: loader ?? "",
|
|
253
341
|
css: css ?? "",
|
|
254
342
|
productMap: productMapSource ?? "",
|
|
255
|
-
productCss: productCss ?? ""
|
|
343
|
+
productCss: productCss ?? "",
|
|
344
|
+
product,
|
|
345
|
+
stamp
|
|
256
346
|
});
|
|
257
|
-
const absolute = path.resolve(root, outDir);
|
|
258
347
|
await mkdir(absolute, { recursive: true });
|
|
259
348
|
await writeFile(path.join(absolute, "index.html"), html);
|
|
260
349
|
await copyScreenshots(root, absolute, collectScreenshotPaths(snapshot.written));
|
|
261
|
-
return
|
|
350
|
+
return {
|
|
351
|
+
outDir,
|
|
352
|
+
upToDate: false
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/** `exportGrimoireSiteDetailed()` that returns only the output folder, project-relative. */
|
|
356
|
+
async function exportGrimoireSite(root, options = {}) {
|
|
357
|
+
return (await exportGrimoireSiteDetailed(root, options)).outDir;
|
|
262
358
|
}
|
|
263
359
|
|
|
264
360
|
//#endregion
|
|
265
|
-
export { PAGE_STYLE, SITE_FILE_LIMIT, buildSiteData, collectScreenshotPaths, copyScreenshots, exportGrimoireSite, inlineProductMap, inlineView, renderSiteHtml };
|
|
361
|
+
export { PAGE_STYLE, SITE_FILE_LIMIT, buildProductSiteData, buildSiteData, collectScreenshotPaths, copyScreenshots, exportGrimoireSite, exportGrimoireSiteDetailed, inlineProductMap, inlineView, renderSiteHtml };
|
|
266
362
|
//# sourceMappingURL=site.mjs.map
|