@warlock.js/grimoire 5.63.1 → 5.64.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 +44 -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 +21 -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.map +1 -1
- package/esm/devtools/index.mjs +32 -2
- 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 +5 -1
- 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 +106 -0
- package/esm/scry/also-changes.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +22 -0
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +7 -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 +15 -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/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 +276 -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 +21 -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 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/matrix.ts"],"sourcesContent":["/**\n * `GET /matrix`: the bird-view. Every feature, flow and acceptance criterion\n * against the app's languages, built from the snapshot. Without `@shows`\n * scenes or an approved baseline it carries the test status only.\n */\nimport type { CriterionStatus } from \"../contracts/test-results\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n GrimoireMatrix,\n MatrixCell,\n MatrixCellState,\n MatrixCriterionRow,\n MatrixFeatureRow,\n MatrixFlowRow,\n} from \"../contracts/matrix\";\nimport { DEFAULT_GRIMOIRE_SETTINGS } from \"../contracts/settings\";\nimport type { ApprovedFlow, DriftItem, ShotsState } from \"../contracts/shots\";\nimport type { WrittenFeature, WrittenFlow } from \"../contracts/written\";\n\n/** The feature that is listed first: the project's design rules. */\nconst DESIGN_SYSTEM = \"design-system\";\n\n/** Worst first: the state of a cell is the first of these that applies. */\nconst STATE_ORDER: readonly MatrixCellState[] = [\n \"rejected\",\n \"fail\",\n \"changed\",\n \"stale\",\n \"not-run\",\n \"no-test\",\n \"pass\",\n];\n\n/** What the route answers: the matrix, and whether this panel may write approvals. */\nexport type GrimoireMatrixAnswer = GrimoireMatrix & {\n /** `true` in development, where Approve and Reject work; `false` in production and in a static export. */\n development: boolean;\n};\n\ntype Inputs = {\n languages: string[];\n shots: ShotsState | null;\n captured: Map<string, NonNullable<ShotsState[\"captures\"]>[\"captures\"][number]>;\n approved: Map<string, string>;\n /** The screenshot mode of this run (`changed`, `all` or `off`). */\n mode: string;\n driftOf: (ref: string, criterion: string | null, language: string | null) => DriftItem[];\n};\n\nconst cellKey = (ref: string, criterion: string, language: string): string =>\n `${ref}\\n${criterion}\\n${language}`;\n\nfunction inputsOf(snapshot: GrimoireSnapshot): Inputs {\n const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;\n const shots = snapshot.shots ?? null;\n const captured = new Map<string, NonNullable<ShotsState[\"captures\"]>[\"captures\"][number]>();\n const approved = new Map<string, string>();\n const drift = shots?.drift ?? [];\n\n for (const capture of shots?.captures?.captures ?? []) {\n captured.set(cellKey(capture.ref, capture.criterion, capture.language), capture);\n }\n\n for (const shot of shots?.baseline?.shots ?? []) {\n approved.set(cellKey(shot.ref, shot.criterion, shot.language), shot.file);\n }\n\n return {\n languages: settings.languages.length > 0 ? [...settings.languages] : [\"\"],\n shots,\n captured,\n approved,\n mode: shots?.mode ?? settings.screenshots,\n // A drift item without a language (a changed criterion text, a removed proof) concerns every language of the criterion.\n driftOf: (ref, criterion, language) =>\n drift.filter(\n (item) =>\n item.ref === ref &&\n item.criterion === criterion &&\n (criterion === null ||\n language === null ||\n item.language === null ||\n item.language === language),\n ),\n };\n}\n\nfunction worst(states: readonly MatrixCellState[]): MatrixCellState {\n return STATE_ORDER.find((state) => states.includes(state)) ?? \"pass\";\n}\n\ntype CellInput = {\n ref: string;\n criterion: string;\n language: string;\n test: CriterionStatus;\n /** `true` when a `@shows` scene names the criterion. */\n shows: boolean;\n /** `true` for a criterion that is no longer written. */\n removed: boolean;\n};\n\nfunction cellOf(inputs: Inputs, input: CellInput): MatrixCell {\n const { ref, criterion, language } = input;\n const key = cellKey(ref, criterion, language);\n const capture = inputs.captured.get(key) ?? null;\n const approvedFile = inputs.approved.get(key) ?? null;\n const items = inputs.driftOf(ref, criterion, language);\n const baseline = inputs.shots?.baseline ?? null;\n // In `changed` mode only touched flows are captured: with no capture, an approved image still stands.\n const standing = capture === null && approvedFile !== null && inputs.mode !== \"all\";\n const shown: MatrixCell[\"shown\"] =\n input.shows || (input.removed && approvedFile !== null)\n ? {\n outcome: capture?.outcome ?? (standing && !input.removed ? \"pass\" : \"not-run\"),\n shot: capture?.file ?? null,\n approved: approvedFile,\n ranAt: capture?.ranAt ?? null,\n }\n : null;\n const approval: MatrixCell[\"approval\"] =\n baseline === null\n ? null\n : items.some((item) => item.rejected !== null)\n ? \"rejected\"\n : items.length > 0 || input.removed\n ? \"changed\"\n : \"approved\";\n const states: MatrixCellState[] = [];\n\n if (approval === \"rejected\") states.push(\"rejected\");\n\n if (input.test === \"fail\" || shown?.outcome === \"fail\") states.push(\"fail\");\n\n if (approval === \"changed\") states.push(\"changed\");\n\n // A removed criterion has no test to speak of: it is a change until approved.\n if (!input.removed) {\n if (input.test === \"stale\") states.push(\"stale\");\n\n if (input.test === \"not-run\" || shown?.outcome === \"not-run\") states.push(\"not-run\");\n\n if (input.test === \"no-test\") states.push(\"no-test\");\n }\n\n return {\n language,\n test: input.test,\n shown,\n approval,\n drift: items.map((item) => item.id),\n state: worst(states),\n };\n}\n\nfunction removedCriteria(\n inputs: Inputs,\n ref: string,\n approvedFlow: ApprovedFlow,\n written: ReadonlySet<string>,\n): MatrixCriterionRow[] {\n return approvedFlow.criteria\n .filter((criterion) => !written.has(criterion.id))\n .map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n app: null,\n removed: true,\n cells: inputs.languages.map((language) =>\n cellOf(inputs, {\n ref,\n criterion: criterion.id,\n language,\n test: \"no-test\",\n shows: false,\n removed: true,\n }),\n ),\n }));\n}\n\nfunction flowRow(snapshot: GrimoireSnapshot, inputs: Inputs, flow: WrittenFlow): MatrixFlowRow {\n const bookmap = snapshot.collected.flows[flow.ref];\n const status = new Map((bookmap?.criteria ?? []).map((item) => [item.id, item.status]));\n const shows = new Set(\n (inputs.shots?.shows ?? [])\n .filter((line) => line.ref === flow.ref)\n .map((line) => line.criterion),\n );\n const approvedFlow = inputs.shots?.baseline?.flows.find((item) => item.ref === flow.ref);\n const writtenIds = new Set(flow.criteria.map((criterion) => criterion.id));\n const optedOut =\n flow.screenshots?.value === false || (inputs.shots?.optedOut ?? []).includes(flow.ref);\n\n return {\n ref: flow.ref,\n id: flow.id.value,\n title: flow.heading?.value ?? flow.id.value,\n status: flow.status.value,\n differsIn: flow.differs.map((line) => line.name),\n screenshots: !optedOut,\n removed: false,\n criteria: [\n ...flow.criteria.map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n app: criterion.app,\n removed: false,\n cells: inputs.languages.map((language) =>\n cellOf(inputs, {\n ref: flow.ref,\n criterion: criterion.id,\n language,\n test: status.get(criterion.id) ?? \"no-test\",\n // A flow with no screenshots (opted out, or the mode is off) never waits for a capture.\n shows: !optedOut && inputs.mode !== \"off\" && shows.has(criterion.id),\n removed: false,\n }),\n ),\n })),\n ...(approvedFlow === undefined\n ? []\n : removedCriteria(inputs, flow.ref, approvedFlow, writtenIds)),\n ],\n drift: inputs.driftOf(flow.ref, null, null).map((item) => item.id),\n };\n}\n\nfunction featureRow(\n snapshot: GrimoireSnapshot,\n inputs: Inputs,\n feature: WrittenFeature,\n): MatrixFeatureRow {\n return {\n id: feature.id,\n title: feature.readme?.title.value ?? feature.id,\n designSystem: feature.id === DESIGN_SYSTEM,\n flows: feature.flows.map((flow) => flowRow(snapshot, inputs, flow)),\n };\n}\n\n/** Rows of the baseline that are no longer written: whole flows, and the features only they belonged to. */\nfunction removedFlows(\n inputs: Inputs,\n features: MatrixFeatureRow[],\n snapshot: GrimoireSnapshot,\n): void {\n const written = new Set(\n snapshot.written.features.flatMap((feature) => feature.flows.map((flow) => flow.ref)),\n );\n\n for (const approved of inputs.shots?.baseline?.flows ?? []) {\n if (written.has(approved.ref)) continue;\n\n const [featureId = \"\", flowId = \"\"] = approved.ref.split(\"/\");\n let feature = features.find((item) => item.id === featureId);\n\n if (feature === undefined) {\n feature = {\n id: featureId,\n title: featureId,\n designSystem: featureId === DESIGN_SYSTEM,\n flows: [],\n };\n features.push(feature);\n }\n\n const flowDrift = inputs.driftOf(approved.ref, null, null).map((item) => item.id);\n // The flow's removal is the change each of its cells stands for: approving a cell approves the removal.\n const criteria = removedCriteria(inputs, approved.ref, approved, new Set()).map((row) => ({\n ...row,\n cells: row.cells.map((cell) => ({\n ...cell,\n drift: [...new Set([...flowDrift, ...cell.drift])],\n })),\n }));\n\n feature.flows.push({\n ref: approved.ref,\n id: flowId,\n title: flowId,\n status: null,\n differsIn: [],\n screenshots: true,\n removed: true,\n criteria,\n drift: flowDrift,\n });\n }\n}\n\n/** `GET /matrix`. */\nexport function matrix(snapshot: GrimoireSnapshot): GrimoireMatrix {\n const inputs = inputsOf(snapshot);\n const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;\n const features = snapshot.written.features.map((feature) =>\n featureRow(snapshot, inputs, feature),\n );\n\n removedFlows(inputs, features, snapshot);\n\n // The design system first; the rest keep their order.\n features.sort((left, right) => Number(right.designSystem) - Number(left.designSystem));\n\n const counts: GrimoireMatrix[\"counts\"] = {\n rejected: 0,\n fail: 0,\n changed: 0,\n stale: 0,\n \"not-run\": 0,\n \"no-test\": 0,\n pass: 0,\n };\n\n for (const feature of features)\n for (const flow of feature.flows)\n for (const criterion of flow.criteria)\n for (const cell of criterion.cells) counts[cell.state] += 1;\n\n const baseline = inputs.shots?.baseline ?? null;\n\n return {\n languages: inputs.languages,\n mode: inputs.shots?.mode ?? settings.screenshots,\n baseline: baseline === null ? null : { approvedAt: baseline.approvedAt },\n features,\n drift: inputs.shots?.drift ?? [],\n counts,\n };\n}\n\n/** What needs a look in the bird-view: cells that failed, changed or were rejected, and the changes to whole flows. */\nexport function attentionOf(answer: GrimoireMatrix): number {\n const flows = answer.features.reduce(\n (total, feature) => total + feature.flows.reduce((sum, flow) => sum + flow.drift.length, 0),\n 0,\n );\n\n return answer.counts.fail + answer.counts.changed + answer.counts.rejected + flows;\n}\n\n/** Every image the matrix shows (captured and approved), as paths under `grimoire/screenshots/`, once each. */\nexport function matrixImagePaths(answer: GrimoireMatrix): string[] {\n const found = new Set<string>();\n\n for (const feature of answer.features)\n for (const flow of feature.flows)\n for (const criterion of flow.criteria)\n for (const cell of criterion.cells) {\n if (cell.shown?.shot) found.add(cell.shown.shot);\n\n if (cell.shown?.approved) found.add(cell.shown.approved);\n }\n\n return [...found].sort();\n}\n"],"mappings":";;;;AAoBA,MAAM,gBAAgB;;AAGtB,MAAM,cAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAkBA,MAAM,WAAW,KAAa,WAAmB,aAC/C,GAAG,IAAI,IAAI,UAAU,IAAI;AAE3B,SAAS,SAAS,UAAoC;CACpD,MAAM,WAAW,SAAS,YAAY;CACtC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,2BAAW,IAAI,IAAqE;CAC1F,MAAM,2BAAW,IAAI,IAAoB;CACzC,MAAM,QAAQ,OAAO,SAAS,CAAC;CAE/B,KAAK,MAAM,WAAW,OAAO,UAAU,YAAY,CAAC,GAClD,SAAS,IAAI,QAAQ,QAAQ,KAAK,QAAQ,WAAW,QAAQ,QAAQ,GAAG,OAAO;CAGjF,KAAK,MAAM,QAAQ,OAAO,UAAU,SAAS,CAAC,GAC5C,SAAS,IAAI,QAAQ,KAAK,KAAK,KAAK,WAAW,KAAK,QAAQ,GAAG,KAAK,IAAI;CAG1E,OAAO;EACL,WAAW,SAAS,UAAU,SAAS,IAAI,CAAC,GAAG,SAAS,SAAS,IAAI,CAAC,EAAE;EACxE;EACA;EACA;EACA,MAAM,OAAO,QAAQ,SAA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Aa,OAAO,OAAO,EAAE,YAAY,SAAS,WAAW;EACvE;EACA,OAAO,OAAO,OAAO,SAAS,CAAC;EAC/B;CACF;AACF;;AAGA,SAAgB,YAAY,QAAgC;CAC1D,MAAM,QAAQ,OAAO,SAAS,QAC3B,OAAO,YAAY,QAAQ,QAAQ,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,MAAM,QAAQ,CAAC,GAC1F,CACF;CAEA,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,UAAU,OAAO,OAAO,WAAW;AAC/E;;AAGA,SAAgB,iBAAiB,QAAkC;CACjE,MAAM,wBAAQ,IAAI,IAAY;CAE9B,KAAK,MAAM,WAAW,OAAO,UAC3B,KAAK,MAAM,QAAQ,QAAQ,OACzB,KAAK,MAAM,aAAa,KAAK,UAC3B,KAAK,MAAM,QAAQ,UAAU,OAAO;EAClC,IAAI,KAAK,OAAO,MAAM,MAAM,IAAI,KAAK,MAAM,IAAI;EAE/C,IAAI,KAAK,OAAO,UAAU,MAAM,IAAI,KAAK,MAAM,QAAQ;CACzD;CAEN,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;YAuCY;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA"}
|
|
@@ -285,6 +285,7 @@ function appearancesOf(snapshot, bookmaps) {
|
|
|
285
285
|
}
|
|
286
286
|
list.push({
|
|
287
287
|
app: shown.app,
|
|
288
|
+
appTitle: app?.heading?.value ?? null,
|
|
288
289
|
type: shown.type,
|
|
289
290
|
id: shown.id,
|
|
290
291
|
title,
|
|
@@ -454,7 +455,92 @@ function productFlow(snapshot, featureId, flowId, options) {
|
|
|
454
455
|
host: snapshot.host ?? null
|
|
455
456
|
};
|
|
456
457
|
}
|
|
458
|
+
/** A reference id: `AC-6`, `T-12`, `QA 1.5.6`. */
|
|
459
|
+
const REFERENCE = /^(?:[A-Z]{1,5}-\d+|QA\s+\d[\w.-]*)$/;
|
|
460
|
+
/** A trailing parenthesised group (optionally followed by one end mark) at the end of a sentence. */
|
|
461
|
+
const TRAILING_GROUP = /\s*\(([^()]*)\)\s*([.!?]?)\s*$/;
|
|
462
|
+
/** A sentence without the reference ids written in trailing parentheses: `"Fixed the total (AC-6, T-12)."` gives `"Fixed the total."`. */
|
|
463
|
+
function withoutReferences(sentence) {
|
|
464
|
+
let text = sentence;
|
|
465
|
+
for (;;) {
|
|
466
|
+
const match = TRAILING_GROUP.exec(text);
|
|
467
|
+
if (match === null) break;
|
|
468
|
+
const parts = (match[1] ?? "").split(/[,;]/).map((part) => part.trim()).filter((part) => part !== "");
|
|
469
|
+
if (parts.length === 0 || !parts.every((part) => REFERENCE.test(part))) break;
|
|
470
|
+
text = `${text.slice(0, match.index)}${match[2] ?? ""}`;
|
|
471
|
+
}
|
|
472
|
+
return text.trim();
|
|
473
|
+
}
|
|
474
|
+
/** The first paragraph of a release brief as one plain line, or `null`. */
|
|
475
|
+
function firstParagraph(brief) {
|
|
476
|
+
const paragraph = brief.split(/\n\s*\n/).map((part) => part.trim()).find((part) => part !== "" && !part.startsWith("#"));
|
|
477
|
+
if (paragraph === void 0) return null;
|
|
478
|
+
const text = withoutReferences(paragraph.replace(/\s+/g, " ").replaceAll("`", ""));
|
|
479
|
+
return text === "" ? null : text;
|
|
480
|
+
}
|
|
481
|
+
/** The newest release first; the changes without a release lead. */
|
|
482
|
+
function newestFirst(left, right) {
|
|
483
|
+
if (left.release === null || right.release === null) return Number(right.release === null) - Number(left.release === null);
|
|
484
|
+
return (right.date ?? "").localeCompare(left.date ?? "") || compareReleases(right.release, left.release);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* `GET /product/whats-new`: the changelog entries of every feature, grouped by
|
|
488
|
+
* release and then by feature, in plain words (no criterion or task ids, no
|
|
489
|
+
* paths). A release is one a changelog names or a file in `grimoire/releases`;
|
|
490
|
+
* the changes that are in no release yet only appear in the signed-in view.
|
|
491
|
+
*/
|
|
492
|
+
function productWhatsNew(snapshot, options) {
|
|
493
|
+
const written = new Map(snapshot.written.releases.map((item) => [item.release.value, item]));
|
|
494
|
+
const releases = /* @__PURE__ */ new Map();
|
|
495
|
+
const releaseOf = (name, date) => {
|
|
496
|
+
const key = name ?? "";
|
|
497
|
+
let found = releases.get(key);
|
|
498
|
+
if (found === void 0) {
|
|
499
|
+
const file = name === null ? void 0 : written.get(name);
|
|
500
|
+
found = {
|
|
501
|
+
release: name,
|
|
502
|
+
date: file?.date.value ?? date,
|
|
503
|
+
brief: file === void 0 ? null : firstParagraph(file.brief),
|
|
504
|
+
features: []
|
|
505
|
+
};
|
|
506
|
+
releases.set(key, found);
|
|
507
|
+
}
|
|
508
|
+
return found;
|
|
509
|
+
};
|
|
510
|
+
for (const item of snapshot.written.releases) releaseOf(item.release.value, item.date.value);
|
|
511
|
+
for (const feature of snapshot.written.features) {
|
|
512
|
+
if (feature.readme === null) continue;
|
|
513
|
+
const title = feature.readme.title.value;
|
|
514
|
+
const flowTitles = new Map(feature.flows.map((flow) => [flow.id.value, flow.heading?.value ?? flow.id.value]));
|
|
515
|
+
for (const entry of feature.changelog?.entries ?? []) {
|
|
516
|
+
if (entry.release === null && options.shared) continue;
|
|
517
|
+
const release = releaseOf(entry.release, entry.date);
|
|
518
|
+
let group = release.features.find((item) => item.id === feature.id);
|
|
519
|
+
if (group === void 0) {
|
|
520
|
+
group = {
|
|
521
|
+
id: feature.id,
|
|
522
|
+
title,
|
|
523
|
+
changes: []
|
|
524
|
+
};
|
|
525
|
+
release.features.push(group);
|
|
526
|
+
}
|
|
527
|
+
group.changes.push({
|
|
528
|
+
word: entry.word,
|
|
529
|
+
flow: entry.flow === null ? null : flowTitles.get(entry.flow) ?? entry.flow,
|
|
530
|
+
text: withoutReferences(entry.text)
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
releases: [...releases.values()].filter((release) => release.release !== null || release.features.length > 0).map((release) => ({
|
|
536
|
+
...release,
|
|
537
|
+
features: [...release.features].sort((left, right) => left.title.localeCompare(right.title))
|
|
538
|
+
})).sort(newestFirst),
|
|
539
|
+
developer: !options.shared,
|
|
540
|
+
host: snapshot.host ?? null
|
|
541
|
+
};
|
|
542
|
+
}
|
|
457
543
|
|
|
458
544
|
//#endregion
|
|
459
|
-
export { compareReleases, productFeature, productFlow, productMap };
|
|
545
|
+
export { compareReleases, productFeature, productFlow, productMap, productWhatsNew };
|
|
460
546
|
//# 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 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,QAAQ;CACzD,CAAC;AACH;;AAGA,SAAS,cACP,UACA,QACA,KACkC;CAClC,MAAM,2BAAW,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|
|
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 ProductWhatsNewAnswer,\n ProductWhatsNewRelease,\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 appTitle: app?.heading?.value ?? null,\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\n/** A reference id: `AC-6`, `T-12`, `QA 1.5.6`. */\nconst REFERENCE = /^(?:[A-Z]{1,5}-\\d+|QA\\s+\\d[\\w.-]*)$/;\n/** A trailing parenthesised group (optionally followed by one end mark) at the end of a sentence. */\nconst TRAILING_GROUP = /\\s*\\(([^()]*)\\)\\s*([.!?]?)\\s*$/;\n\n/** A sentence without the reference ids written in trailing parentheses: `\"Fixed the total (AC-6, T-12).\"` gives `\"Fixed the total.\"`. */\nfunction withoutReferences(sentence: string): string {\n let text = sentence;\n\n for (;;) {\n const match = TRAILING_GROUP.exec(text);\n\n if (match === null) break;\n\n const parts = (match[1] ?? \"\")\n .split(/[,;]/)\n .map((part) => part.trim())\n .filter((part) => part !== \"\");\n\n if (parts.length === 0 || !parts.every((part) => REFERENCE.test(part))) break;\n\n text = `${text.slice(0, match.index)}${match[2] ?? \"\"}`;\n }\n\n return text.trim();\n}\n\n/** The first paragraph of a release brief as one plain line, or `null`. */\nfunction firstParagraph(brief: string): string | null {\n const paragraph = brief\n .split(/\\n\\s*\\n/)\n .map((part) => part.trim())\n .find((part) => part !== \"\" && !part.startsWith(\"#\"));\n\n if (paragraph === undefined) return null;\n\n const text = withoutReferences(paragraph.replace(/\\s+/g, \" \").replaceAll(\"`\", \"\"));\n\n return text === \"\" ? null : text;\n}\n\n/** The newest release first; the changes without a release lead. */\nfunction newestFirst(left: ProductWhatsNewRelease, right: ProductWhatsNewRelease): number {\n if (left.release === null || right.release === null)\n return Number(right.release === null) - Number(left.release === null);\n\n return (\n (right.date ?? \"\").localeCompare(left.date ?? \"\") ||\n compareReleases(right.release, left.release)\n );\n}\n\n/**\n * `GET /product/whats-new`: the changelog entries of every feature, grouped by\n * release and then by feature, in plain words (no criterion or task ids, no\n * paths). A release is one a changelog names or a file in `grimoire/releases`;\n * the changes that are in no release yet only appear in the signed-in view.\n */\nexport function productWhatsNew(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductWhatsNewAnswer {\n const written = new Map(snapshot.written.releases.map((item) => [item.release.value, item]));\n const releases = new Map<string, ProductWhatsNewRelease>();\n\n const releaseOf = (name: string | null, date: string | null): ProductWhatsNewRelease => {\n const key = name ?? \"\";\n let found = releases.get(key);\n\n if (found === undefined) {\n const file = name === null ? undefined : written.get(name);\n\n found = {\n release: name,\n date: file?.date.value ?? date,\n brief: file === undefined ? null : firstParagraph(file.brief),\n features: [],\n };\n releases.set(key, found);\n }\n\n return found;\n };\n\n for (const item of snapshot.written.releases) releaseOf(item.release.value, item.date.value);\n\n for (const feature of snapshot.written.features) {\n if (feature.readme === null) continue;\n\n const title = feature.readme.title.value;\n const flowTitles = new Map(\n feature.flows.map((flow) => [flow.id.value, flow.heading?.value ?? flow.id.value]),\n );\n\n for (const entry of feature.changelog?.entries ?? []) {\n if (entry.release === null && options.shared) continue;\n\n const release = releaseOf(entry.release, entry.date);\n let group = release.features.find((item) => item.id === feature.id);\n\n if (group === undefined) {\n group = { id: feature.id, title, changes: [] };\n release.features.push(group);\n }\n\n group.changes.push({\n word: entry.word,\n flow: entry.flow === null ? null : (flowTitles.get(entry.flow) ?? entry.flow),\n text: withoutReferences(entry.text),\n });\n }\n }\n\n return {\n releases: [...releases.values()]\n .filter((release) => release.release !== null || release.features.length > 0)\n .map((release) => ({\n ...release,\n features: [...release.features].sort((left, right) =>\n left.title.localeCompare(right.title),\n ),\n }))\n .sort(newestFirst),\n developer: !options.shared,\n host: snapshot.host ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2DA,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,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,MAAM,WAAW,SAAS,QAAQ,UACrC,KAAK,MAAM,QAAQ,QAAQ,OASzB,IARY,KAAK,MAAM,MACpB,SACE,KAAK,SAAS,WACb,KAAK,UAAU,QACf,mBAAmB,KAAK,MAAM,IAAI,MAAM,QACzC,KAAK,SAAS,UAAU,mBAAmB,KAAK,MAAM,MAAM,IAG3D,GAAG,SAAS,OAAO,KAAK,KAAK,KAAK;CAG9C;CAEA,OAAO;EAAE;EAAU;CAAM;AAC3B;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G;GACpD,IAAI,MAAM,YAAY,QAAQ,QAAQ,QAAQ;GAE9C,MAAM,UAAU,UAAU,MAAM,SAAS,MAAM,IAAI;GACnD,IAAI,QAAQ,QAAQ,SAAS,MAAM,SAAS,KAAK,OAAO,QAAQ,EAAE;GAElE,IAAI,UAAU,QAAW;IACvB,QAAQ;KAAE,IAAI,QAAQ;KAAI;KAAO,SAAS,CAAC;IAAE;IAC7C,QAAQ,SAAS,KAAK,KAAK;GAC7B;GAEA,MAAM,QAAQ,KAAK;IACjB,MAAM,MAAM;IACZ,MAAM,MAAM,SAAS,OAAO,OAAQ,WAAW,IAAI,MAAM,IAAI,KAAK,MAAM;IACxE,MAAM,kBAAkB,MAAM,IAAI;GACpC,CAAC;EACH;CACF;CAEA,OAAO;EACL,UAAU,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAC7B,QAAQ,YAAY,QAAQ,YAAY,QAAQ,QAAQ,SAAS,SAAS,CAAC,CAAC,CAC5E,KAAK,aAAa;GACjB,GAAG;GACH,UAAU,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC,MAAM,MAAM,UAC1C,KAAK,MAAM,cAAc,MAAM,KAAK,CACtC;EACF,EAAE,CAAC,CACF,KAAK,WAAW;EACnB,WAAW,CAAC,QAAQ;EACpB,MAAM,SAAS,QAAQ;CACzB;AACF"}
|
|
@@ -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":";;;;YAqBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;EAMX;;EAEA;;;YAIU;;EAEV;;EAEA;;;KAOG;EAAe;EAAc;EAAY;EAAuB;;;;;;;wBA6JrD,qBAAqB,UAAU;;;EAuBH,QAAA;;;;;;;;;;;;;;;;;;;;wBAsPtB,2BACpB,cACA,UAAS,4BACR,QAAQ;;wBAqDW,mBACpB,cACA,UAAS,4BACR"}
|
package/esm/devtools/site.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { GRIMOIRE_PATHS, projectPath, toPosixPath } from "../paths/index.mjs";
|
|
2
|
+
import { matrix, matrixImagePaths } from "./matrix.mjs";
|
|
2
3
|
import { featureGraph, fileGraph, pageGraph } from "./graphs.mjs";
|
|
3
4
|
import { apps, check, checkGroups, feature, features, file, flowAnswer, graphOfModules, page, releases, summary, tasks } from "./data.mjs";
|
|
4
|
-
import { productFeature, productFlow, productMap } from "./product-map.mjs";
|
|
5
|
+
import { productFeature, productFlow, productMap, productWhatsNew } from "./product-map.mjs";
|
|
5
6
|
import { createSnapshotSource } from "./snapshot-source.mjs";
|
|
6
7
|
import { stampOf } from "../workspace/cache.mjs";
|
|
7
8
|
import path from "node:path";
|
|
@@ -39,7 +40,11 @@ function buildSiteData(snapshot) {
|
|
|
39
40
|
...check(snapshot),
|
|
40
41
|
root: "."
|
|
41
42
|
},
|
|
42
|
-
"graph/modules": graphOfModules(snapshot)
|
|
43
|
+
"graph/modules": graphOfModules(snapshot),
|
|
44
|
+
matrix: {
|
|
45
|
+
...matrix(snapshot),
|
|
46
|
+
development: false
|
|
47
|
+
}
|
|
43
48
|
};
|
|
44
49
|
const productOptions = {
|
|
45
50
|
shared: false,
|
|
@@ -48,6 +53,8 @@ function buildSiteData(snapshot) {
|
|
|
48
53
|
const productAnswer = attempt(() => productMap(snapshot, productOptions));
|
|
49
54
|
const groups = attempt(() => checkGroups(snapshot));
|
|
50
55
|
if (productAnswer !== void 0) routes.product = productAnswer;
|
|
56
|
+
const whatsNew = attempt(() => productWhatsNew(snapshot, productOptions));
|
|
57
|
+
if (whatsNew !== void 0) routes["product/whats-new"] = whatsNew;
|
|
51
58
|
if (groups !== void 0) routes["check/groups"] = groups;
|
|
52
59
|
const search = [];
|
|
53
60
|
for (const release of snapshot.written.releases) routes[`releases/${release.release.value}`] = release;
|
|
@@ -144,6 +151,8 @@ function buildProductSiteData(snapshot) {
|
|
|
144
151
|
const routes = {};
|
|
145
152
|
const map = attempt(() => productMap(snapshot, options));
|
|
146
153
|
if (map !== void 0) routes.product = map;
|
|
154
|
+
const whatsNew = attempt(() => productWhatsNew(snapshot, options));
|
|
155
|
+
if (whatsNew !== void 0) routes["product/whats-new"] = whatsNew;
|
|
147
156
|
for (const feature of snapshot.written.features) {
|
|
148
157
|
const answer = attempt(() => productFeature(snapshot, feature.id, options));
|
|
149
158
|
if (answer !== void 0) routes[`product/features/${feature.id}`] = answer;
|
|
@@ -346,7 +355,7 @@ async function exportGrimoireSiteDetailed(root, options = {}) {
|
|
|
346
355
|
});
|
|
347
356
|
await mkdir(absolute, { recursive: true });
|
|
348
357
|
await writeFile(path.join(absolute, "index.html"), html);
|
|
349
|
-
await copyScreenshots(root, absolute, collectScreenshotPaths(snapshot.written));
|
|
358
|
+
await copyScreenshots(root, absolute, [...collectScreenshotPaths(snapshot.written), ...product ? [] : matrixImagePaths(matrix(snapshot))]);
|
|
350
359
|
return {
|
|
351
360
|
outDir,
|
|
352
361
|
upToDate: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.mjs","names":["data.summary","data.features","data.apps","data.tasks","data.releases","data.check","data.graphOfModules","data.checkGroups","feature","data.feature","flowAnswer","data.flowAnswer","page","data.page","file","data.file"],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"sourcesContent":["/**\n * The static export: one folder with an `index.html` that holds the view, the\n * loader, the styles and the data as JSON. It opens from disk (`file://`) or\n * any static host and needs no running app.\n */\nimport { createHash } from \"node:crypto\";\nimport { copyFile, mkdir, open, readFile, realpath, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenFlow } from \"../contracts/written\";\nimport { GRIMOIRE_PATHS, projectPath, toPosixPath } from \"../paths\";\nimport { stampOf } from \"../workspace/cache\";\nimport * as data from \"./data\";\nimport { featureGraph, fileGraph, pageGraph } from \"./graphs\";\nimport { productFeature, productFlow, productMap } from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\n/** Options of `exportGrimoireSite()`. */\nexport type ExportGrimoireSiteOptions = {\n /** Output folder, project-relative or absolute. Default `grimoire/book/site` (the book writer leaves it alone and git ignores it). */\n outDir?: string;\n /** The adapter to open the book with. Default: the Warlock adapter. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /** An already opened snapshot; skips opening one. */\n snapshot?: GrimoireSnapshot;\n /**\n * Export the business view only: the share-safe Product map (no file paths, test\n * names or export names, no per-file answers, no check or search of code). The\n * page opens on the Product map.\n */\n product?: boolean;\n /** Write the page even when the folder already holds one built from the same book. Default `false`. */\n force?: boolean;\n};\n\n/** What `exportGrimoireSite()` did. */\nexport type GrimoireSiteExport = {\n /** The output folder, project-relative. */\n outDir: string;\n /** `true` when the folder already held a page built from the same book and nothing was written. */\n upToDate: boolean;\n};\n\n/** The most files the export keeps per-file answers for (the most imported first). */\nexport const SITE_FILE_LIMIT = 3000;\n\n/** One entry of the exported search list. `text` is written content (a flow's summary, story, cases and criteria) the search also reads. */\ntype SearchItem = { type: string; id: string; detail: string | null; text?: string };\n\n/** The written text of a flow the exported search reads, with criteria ids so `AC-5` is findable. */\nfunction flowSearchText(flow: WrittenFlow): string {\n return [\n flow.summary ?? \"\",\n ...flow.story.map((step) => step.text),\n ...flow.cases.map((item) => `${item.question} ${item.answer} ${item.criteria.join(\" \")}`),\n ...flow.criteria.map((item) => `${item.id} ${item.text}`),\n ]\n .filter((part) => part !== \"\")\n .join(\" | \");\n}\n\nconst uiFolder = fileURLToPath(new URL(\"../../ui/\", import.meta.url));\n\n/** Every answer the static page can give, keyed by the data route it replaces. */\nexport function buildSiteData(snapshot: GrimoireSnapshot) {\n const routes: Record<string, unknown> = {\n summary: data.summary(snapshot),\n features: data.features(snapshot),\n apps: data.apps(snapshot),\n tasks: data.tasks(snapshot),\n releases: data.releases(snapshot),\n // The page is meant to be shared: it does not name where the project sits on this machine.\n check: { ...data.check(snapshot), root: \".\" },\n \"graph/modules\": data.graphOfModules(snapshot),\n };\n // The static page is the signed-in view: developer detail stays, and no monitor reports errors.\n const productOptions = { shared: false, errors: null } as const;\n const productAnswer = attempt(() => productMap(snapshot, productOptions));\n const groups = attempt(() => data.checkGroups(snapshot));\n\n if (productAnswer !== undefined) routes.product = productAnswer;\n\n if (groups !== undefined) routes[\"check/groups\"] = groups;\n\n const search: SearchItem[] = [];\n\n for (const release of snapshot.written.releases) {\n routes[`releases/${release.release.value}`] = release;\n }\n\n for (const feature of snapshot.written.features) {\n const readme = feature.readme;\n\n search.push({\n type: \"feature\",\n id: feature.id,\n detail: readme?.title.value ?? null,\n text: [readme?.summary ?? \"\", readme?.why ?? \"\"].filter((part) => part !== \"\").join(\" | \"),\n });\n const answered = attempt(() => data.feature(snapshot, feature.id));\n\n if (answered !== undefined) routes[`features/${feature.id}`] = answered;\n\n const graph = featureGraph(snapshot, feature.id);\n\n if (graph !== null) routes[`graph/feature/${feature.id}`] = graph;\n\n const product = attempt(() => productFeature(snapshot, feature.id, productOptions));\n\n if (product !== undefined) routes[`product/features/${feature.id}`] = product;\n\n for (const flow of feature.flows) {\n search.push({\n type: \"flow\",\n id: flow.ref,\n detail: flow.heading?.value ?? null,\n text: flowSearchText(flow),\n });\n const flowAnswer = attempt(() => data.flowAnswer(snapshot, feature.id, flow.id.value));\n const productFlowAnswer = attempt(() =>\n productFlow(snapshot, feature.id, flow.id.value, productOptions),\n );\n\n if (flowAnswer !== undefined) routes[`flows/${flow.ref}`] = flowAnswer;\n\n if (productFlowAnswer !== undefined) routes[`product/flows/${flow.ref}`] = productFlowAnswer;\n }\n }\n\n for (const app of snapshot.written.apps) {\n const appId = app.id.value;\n\n for (const page of [...app.pages, ...app.screens]) {\n const route = page.route?.value ?? page.screen?.value ?? null;\n const answer = attempt(() => data.page(snapshot, appId, page.id));\n const graph = pageGraph(snapshot, appId, page.id);\n\n for (const key of new Set([page.id, ...(route === null ? [] : [route])])) {\n if (answer !== undefined) routes[`apps/${appId}/pages/${key}`] = answer;\n\n if (graph !== null) routes[`graph/page/${appId}/${key}`] = graph;\n }\n\n if (route !== null)\n search.push({\n type: page.type,\n id: `${appId} ${route}`,\n detail: page.heading?.value ?? null,\n });\n\n for (const block of page.blockFiles) {\n search.push({\n type: \"block\",\n id: `${appId}/${page.id}/${block.id}`,\n detail: block.flow?.value ?? null,\n });\n }\n }\n }\n\n for (const found of snapshot.book.facts.routes ?? []) {\n search.push({\n type: \"route\",\n id: `${found.method} ${found.path}`,\n detail: found.description ?? found.handler,\n });\n }\n\n for (const task of snapshot.collected.tasksIndex.open.concat(\n snapshot.collected.tasksIndex.done,\n )) {\n search.push({ type: \"task\", id: task.id, detail: task.title });\n }\n\n const files: Record<string, { result: unknown; graph: unknown }> = {};\n const ranked = [...snapshot.book.facts.files].sort(\n (left, right) =>\n right.importedBy.length - left.importedBy.length || left.file.localeCompare(right.file),\n );\n\n for (const [index, file] of ranked.entries()) {\n search.push({ type: \"file\", id: file.file, detail: file.about });\n\n if (index >= SITE_FILE_LIMIT) continue;\n\n const result = attempt(() => data.file(snapshot, file.file));\n\n if (result !== undefined) files[file.file] = { result, graph: fileGraph(snapshot, file.file) };\n }\n\n return { routes, files, search };\n}\n\n/**\n * The business-only data of the static export: the share-safe Product map, its feature\n * and flow pages, and nothing else. No file paths, test names, export names, check\n * findings or per-file answers; the search list is empty.\n */\nexport function buildProductSiteData(snapshot: GrimoireSnapshot) {\n const options = { shared: true, errors: null } as const;\n const routes: Record<string, unknown> = {};\n const map = attempt(() => productMap(snapshot, options));\n\n if (map !== undefined) routes.product = map;\n\n for (const feature of snapshot.written.features) {\n const answer = attempt(() => productFeature(snapshot, feature.id, options));\n\n if (answer !== undefined) routes[`product/features/${feature.id}`] = answer;\n\n for (const flow of feature.flows) {\n const flowAnswer = attempt(() => productFlow(snapshot, feature.id, flow.id.value, options));\n\n if (flowAnswer !== undefined) routes[`product/flows/${flow.ref}`] = flowAnswer;\n }\n }\n\n return { routes, files: {}, search: [] as SearchItem[] };\n}\n\n/** JSON for an inline `<script>`: every `<` is escaped, so no `</script` or `<!--` can appear. */\nfunction inlineJson(value: unknown): string {\n return JSON.stringify(value).replaceAll(\"<\", \"\\\\u003c\");\n}\n\n/** Code for an inline `<script>`: `</script` (in any case) and `<!--` (only possible in strings and comments) are broken up. */\nfunction inlineCode(code: string): string {\n return code.replace(/<\\/(script)/gi, \"<\\\\/$1\").replaceAll(\"<!--\", \"<\\\\!--\");\n}\n\n/** The image types the export copies (the same list the devtools panel serves). */\nconst SCREENSHOT_EXTENSIONS = new Set([\".png\", \".jpg\", \".jpeg\", \".webp\", \".gif\"]);\n\n/** Every `WrittenScreenshot.path` in the written files, once each. */\nexport function collectScreenshotPaths(written: unknown): string[] {\n const found = new Set<string>();\n const walk = (value: unknown): void => {\n if (Array.isArray(value)) {\n for (const item of value) walk(item);\n } else if (value !== null && typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n\n if (\n typeof record.path === \"string\" &&\n typeof record.written === \"string\" &&\n typeof record.alt === \"string\"\n )\n found.add(record.path);\n\n for (const item of Object.values(record)) walk(item);\n }\n };\n\n walk(written);\n\n return [...found].sort();\n}\n\n/**\n * Copy the screenshots the written files use into `<out>/screenshots/`. A path that leaves\n * `grimoire/screenshots/`, has another extension or does not exist is skipped.\n *\n * @returns The paths that were copied.\n */\nexport async function copyScreenshots(\n root: string,\n outFolder: string,\n paths: readonly string[],\n): Promise<string[]> {\n const folder = await realpath(path.join(root, GRIMOIRE_PATHS.screenshots)).catch(() => null);\n const copied: string[] = [];\n\n if (folder === null) return copied;\n\n for (const written of paths) {\n const segments = written.split(\"/\");\n\n if (\n written === \"\" ||\n written.includes(\"\\\\\") ||\n written.includes(\"\\0\") ||\n path.isAbsolute(written) ||\n segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\") ||\n !SCREENSHOT_EXTENSIONS.has(path.extname(written).toLowerCase())\n )\n continue;\n\n const source = await realpath(path.join(folder, ...segments)).catch(() => null);\n\n if (source === null || !source.startsWith(folder + path.sep)) continue;\n\n if (!(await stat(source)).isFile()) continue;\n\n const target = path.join(outFolder, \"screenshots\", ...segments);\n\n await mkdir(path.dirname(target), { recursive: true });\n await copyFile(source, target);\n copied.push(written);\n }\n\n return copied;\n}\n\n/** The answer, or `undefined` when the item cannot be answered (the export skips it). */\nfunction attempt<Value>(answer: () => Value): Value | undefined {\n try {\n return answer();\n } catch {\n return undefined;\n }\n}\n\n/** Everything before the page's `export default`, so the view can sit in an inline module. */\nexport function inlineView(source: string): string {\n const marker = \"export default renderGrimoire;\";\n\n if (!source.includes(marker))\n throw new Error(\"grimoire-view.js must end with `export default renderGrimoire;`.\");\n\n return source.replace(marker, \"\");\n}\n\n/**\n * The product map module as inline code: its `export` keywords are removed and the Grimoire view\n * finds it as `globalThis.grimoireProductMap`.\n */\nexport function inlineProductMap(source: string): string {\n const marker = \"export default renderProductMap;\";\n\n if (!source.includes(marker))\n throw new Error(\"product-map.js must end with `export default renderProductMap;`.\");\n\n return `${source.replace(marker, \"\").replace(/^export (async )?function /gm, \"$1function \")}\\nglobalThis.grimoireProductMap = { productMapView };\\n`;\n}\n\n/**\n * The page's own styles: it defines every devtools panel token (light, then dark under\n * `prefers-color-scheme`), so `grimoire.css` renders the same here as in the dashboard.\n * The values keep text AA on `--background` and `--card`.\n */\nexport const PAGE_STYLE = `\n: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}\n@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}}\n*{box-sizing:border-box}body{margin:0;background:var(--background);color:var(--foreground);font-size:14px;line-height:1.5}\nmain{max-width:1180px;margin:0 auto;padding:16px}\n.empty{padding:12px;color:var(--muted-foreground)}.error{padding:12px;color:var(--destructive)}\n`;\n\n/** The `index.html` text. */\nexport function renderSiteHtml(\n siteData: unknown,\n sources: {\n view: string;\n loader: string;\n css: string;\n productMap?: string;\n productCss?: string;\n /** Mount the share-safe Product map alone (the business export): `view` and `css` are not inlined. */\n product?: boolean;\n /** A freshness stamp written into the page, so the next export can tell it is current. */\n stamp?: string;\n },\n): string {\n const json = inlineJson(siteData);\n\n if (sources.product === true && sources.productMap === undefined) {\n throw new Error(\"A product export needs product-map.js.\");\n }\n\n const mounted = sources.product === true ? \"renderProductMap\" : \"renderGrimoire\";\n const script = inlineCode(\n `${sources.productMap === undefined ? \"\" : 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`,\n );\n const styles = sources.product === true ? \"\" : sources.css;\n const stamp =\n sources.stamp === undefined ? \"\" : `<meta name=\"grimoire-stamp\" content=\"${sources.stamp}\">\\n`;\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n${stamp}<title>${sources.product === true ? \"Product map\" : \"Grimoire\"}</title>\n<style>${PAGE_STYLE}${styles}${sources.productCss ?? \"\"}</style>\n</head>\n<body>\n<main id=\"grimoire-root\"><p class=\"empty\">Opening the book…</p></main>\n<script type=\"application/json\" id=\"grimoire-data\">${json}</script>\n<script type=\"module\">${script}</script>\n</body>\n</html>\n`;\n}\n\n/** The stamp is written near the top of the page; this much of the file is enough to find it. */\nconst STAMP_HEAD_BYTES = 2048;\n\n/** The stamp of the page that is already in `index.html`, or `null` (no page, or one without a stamp). */\nasync function writtenStamp(file: string): Promise<string | null> {\n let handle;\n\n try {\n handle = await open(file, \"r\");\n\n const { buffer, bytesRead } = await handle.read(\n Buffer.alloc(STAMP_HEAD_BYTES),\n 0,\n STAMP_HEAD_BYTES,\n 0,\n );\n\n return (\n /<meta name=\"grimoire-stamp\" content=\"([0-9a-f]+)\">/.exec(\n buffer.toString(\"utf8\", 0, bytesRead),\n )?.[1] ?? null\n );\n } catch {\n return null;\n } finally {\n await handle?.close();\n }\n}\n\n/** Modified times of the files the page is built from, so a new framework version rebuilds the page. */\nasync function uiStamp(): Promise<string> {\n const names = [\n \"grimoire-view.js\",\n \"grimoire-static.js\",\n \"grimoire.css\",\n \"product-map.js\",\n \"product-map.css\",\n ];\n const times = await Promise.all(\n names.map(async (name) => {\n try {\n return (await stat(path.join(uiFolder, name))).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\n/**\n * Write the tab as a static folder for people without the app running.\n *\n * The folder holds `index.html` only: the view, the loader, the styles and\n * the data (as JSON) are inside it, so it opens straight from disk. Open the\n * page and use `#grimoire/...` links; the answers that need the running app\n * (impact of a file) say so in place.\n *\n * With `product: true` the page is the business export: the share-safe\n * Product map only, no file paths, test names or per-file answers.\n *\n * The page carries a freshness stamp (the files of the book, the written\n * folders and the test results). When the folder already holds a page with\n * the same stamp and the same mode, nothing is rebuilt or written (`force`\n * writes it anyway).\n *\n * @param root Absolute project root.\n */\nexport async function exportGrimoireSiteDetailed(\n root: string,\n options: ExportGrimoireSiteOptions = {},\n): Promise<GrimoireSiteExport> {\n // Project-relative from here on; an absolute folder is kept where it is.\n const outDir = projectPath(\n root,\n toPosixPath(options.outDir ?? GRIMOIRE_PATHS.staticSite),\n ).replace(/\\/+$/, \"\");\n const snapshot =\n options.snapshot ??\n (await createSnapshotSource(\n root,\n options.adapter === undefined ? {} : { adapter: options.adapter },\n ).get());\n const absolute = path.resolve(root, outDir);\n const product = options.product === true;\n const stamp = createHash(\"sha1\")\n .update(`${product ? \"product\" : \"full\"}|${await stampOf(root, snapshot)}|${await uiStamp()}`)\n .digest(\"hex\");\n\n if (options.force !== true && (await writtenStamp(path.join(absolute, \"index.html\"))) === stamp) {\n return { outDir, upToDate: true };\n }\n\n const [view, loader, css, productMapSource, productCss] = await Promise.all(\n [\n \"grimoire-view.js\",\n \"grimoire-static.js\",\n \"grimoire.css\",\n \"product-map.js\",\n \"product-map.css\",\n ].map((name) => readFile(path.join(uiFolder, name), \"utf8\")),\n );\n const html = renderSiteHtml(product ? buildProductSiteData(snapshot) : buildSiteData(snapshot), {\n view: view ?? \"\",\n loader: loader ?? \"\",\n css: css ?? \"\",\n productMap: productMapSource ?? \"\",\n productCss: productCss ?? \"\",\n product,\n stamp,\n });\n\n await mkdir(absolute, { recursive: true });\n await writeFile(path.join(absolute, \"index.html\"), html);\n await copyScreenshots(root, absolute, collectScreenshotPaths(snapshot.written));\n\n return { outDir, upToDate: false };\n}\n\n/** `exportGrimoireSiteDetailed()` that returns only the output folder, project-relative. */\nexport async function exportGrimoireSite(\n root: string,\n options: ExportGrimoireSiteOptions = {},\n): Promise<string> {\n return (await exportGrimoireSiteDetailed(root, options)).outDir;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8CA,MAAa,kBAAkB;;AAM/B,SAAS,eAAe,MAA2B;CACjD,OAAO;EACL,KAAK,WAAW;EAChB,GAAG,KAAK,MAAM,KAAK,SAAS,KAAK,IAAI;EACrC,GAAG,KAAK,MAAM,KAAK,SAAS,GAAG,KAAK,SAAS,GAAG,KAAK,OAAO,GAAG,KAAK,SAAS,KAAK,GAAG,GAAG;EACxF,GAAG,KAAK,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG,GAAG,KAAK,MAAM;CAC1D,CAAC,CACE,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7B,KAAK,KAAK;AACf;AAEA,MAAM,WAAW,cAAc,IAAI,IAAI,aAAa,YAAY,GAAG,CAAC;;AAGpE,SAAgB,cAAc,UAA4B;CACxD,MAAM,SAAkC;EACtC,SAASA,QAAa,QAAQ;EAC9B,UAAUC,SAAc,QAAQ;EAChC,MAAMC,KAAU,QAAQ;EACxB,OAAOC,MAAW,QAAQ;EAC1B,UAAUC,SAAc,QAAQ;EAEhC,OAAO;GAAE,GAAGC,MAAW,QAAQ;GAAG,MAAM;EAAI;EAC5C,iBAAiBC,eAAoB,QAAQ;CAC/C;CAEA,MAAM,iBAAiB;EAAE,QAAQ;EAAO,QAAQ;CAAK;CACrD,MAAM,gBAAgB,cAAc,WAAW,UAAU,cAAc,CAAC;CACxE,MAAM,SAAS,cAAcC,YAAiB,QAAQ,CAAC;CAEvD,IAAI,kBAAkB,QAAW,OAAO,UAAU;CAElD,IAAI,WAAW,QAAW,OAAO,kBAAkB;CAEnD,MAAM,SAAuB,CAAC;CAE9B,KAAK,MAAM,WAAW,SAAS,QAAQ,UACrC,OAAO,YAAY,QAAQ,QAAQ,WAAW;CA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ACxF,OAAO;EAAE;EAAQ,UAAU;CAAK;CAGlC,MAAM,CAAC,MAAM,QAAQ,KAAK,kBAAkB,cAAc,MAAM,QAAQ,IACtE;EACE;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,SAAS,SAAS,KAAK,KAAK,UAAU,IAAI,GAAG,MAAM,CAAC,CAC7D;CACA,MAAM,OAAO,eAAe,UAAU,qBAAqB,QAAQ,IAAI,cAAc,QAAQ,GAAG;EAC9F,MAAM,QAAQ;EACd,QAAQ,UAAU;EAClB,KAAK,OAAO;EACZ,YAAY,oBAAoB;EAChC,YAAY,cAAc;EAC1B;EACA;CACF,CAAC;CAED,MAAM,MAAM,UAAU,EAAE,WAAW,KAAK,CAAC;CACzC,MAAM,UAAU,KAAK,KAAK,UAAU,YAAY,GAAG,IAAI;CACvD,MAAM,gBAAgB,MAAM,UAAU,uBAAuB,SAAS,OAAO,CAAC;CAE9E,OAAO;EAAE;EAAQ,UAAU;CAAM;AACnC;;AAGA,eAAsB,mBACpB,MACA,UAAqC,CAAC,GACrB;CACjB,QAAQ,MAAM,2BAA2B,MAAM,OAAO,EAAC,CAAE;AAC3D"}
|
|
1
|
+
{"version":3,"file":"site.mjs","names":["data.summary","data.features","data.apps","data.tasks","data.releases","data.check","data.graphOfModules","data.checkGroups","feature","data.feature","flowAnswer","data.flowAnswer","page","data.page","file","data.file"],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"sourcesContent":["/**\n * The static export: one folder with an `index.html` that holds the view, the\n * loader, the styles and the data as JSON. It opens from disk (`file://`) or\n * any static host and needs no running app.\n */\nimport { createHash } from \"node:crypto\";\nimport { copyFile, mkdir, open, readFile, realpath, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenFlow } from \"../contracts/written\";\nimport { GRIMOIRE_PATHS, projectPath, toPosixPath } from \"../paths\";\nimport { stampOf } from \"../workspace/cache\";\nimport * as data from \"./data\";\nimport { matrix, matrixImagePaths } from \"./matrix\";\nimport { featureGraph, fileGraph, pageGraph } from \"./graphs\";\nimport { productFeature, productFlow, productMap, productWhatsNew } from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\n/** Options of `exportGrimoireSite()`. */\nexport type ExportGrimoireSiteOptions = {\n /** Output folder, project-relative or absolute. Default `grimoire/book/site` (the book writer leaves it alone and git ignores it). */\n outDir?: string;\n /** The adapter to open the book with. Default: the Warlock adapter. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /** An already opened snapshot; skips opening one. */\n snapshot?: GrimoireSnapshot;\n /**\n * Export the business view only: the share-safe Product map (no file paths, test\n * names or export names, no per-file answers, no check or search of code). The\n * page opens on the Product map.\n */\n product?: boolean;\n /** Write the page even when the folder already holds one built from the same book. Default `false`. */\n force?: boolean;\n};\n\n/** What `exportGrimoireSite()` did. */\nexport type GrimoireSiteExport = {\n /** The output folder, project-relative. */\n outDir: string;\n /** `true` when the folder already held a page built from the same book and nothing was written. */\n upToDate: boolean;\n};\n\n/** The most files the export keeps per-file answers for (the most imported first). */\nexport const SITE_FILE_LIMIT = 3000;\n\n/** One entry of the exported search list. `text` is written content (a flow's summary, story, cases and criteria) the search also reads. */\ntype SearchItem = { type: string; id: string; detail: string | null; text?: string };\n\n/** The written text of a flow the exported search reads, with criteria ids so `AC-5` is findable. */\nfunction flowSearchText(flow: WrittenFlow): string {\n return [\n flow.summary ?? \"\",\n ...flow.story.map((step) => step.text),\n ...flow.cases.map((item) => `${item.question} ${item.answer} ${item.criteria.join(\" \")}`),\n ...flow.criteria.map((item) => `${item.id} ${item.text}`),\n ]\n .filter((part) => part !== \"\")\n .join(\" | \");\n}\n\nconst uiFolder = fileURLToPath(new URL(\"../../ui/\", import.meta.url));\n\n/** Every answer the static page can give, keyed by the data route it replaces. */\nexport function buildSiteData(snapshot: GrimoireSnapshot) {\n const routes: Record<string, unknown> = {\n summary: data.summary(snapshot),\n features: data.features(snapshot),\n apps: data.apps(snapshot),\n tasks: data.tasks(snapshot),\n releases: data.releases(snapshot),\n // The page is meant to be shared: it does not name where the project sits on this machine.\n check: { ...data.check(snapshot), root: \".\" },\n \"graph/modules\": data.graphOfModules(snapshot),\n // The page is read-only: no Approve or Reject buttons.\n matrix: { ...matrix(snapshot), development: false },\n };\n // The static page is the signed-in view: developer detail stays, and no monitor reports errors.\n const productOptions = { shared: false, errors: null } as const;\n const productAnswer = attempt(() => productMap(snapshot, productOptions));\n const groups = attempt(() => data.checkGroups(snapshot));\n\n if (productAnswer !== undefined) routes.product = productAnswer;\n\n const whatsNew = attempt(() => productWhatsNew(snapshot, productOptions));\n\n if (whatsNew !== undefined) routes[\"product/whats-new\"] = whatsNew;\n\n if (groups !== undefined) routes[\"check/groups\"] = groups;\n\n const search: SearchItem[] = [];\n\n for (const release of snapshot.written.releases) {\n routes[`releases/${release.release.value}`] = release;\n }\n\n for (const feature of snapshot.written.features) {\n const readme = feature.readme;\n\n search.push({\n type: \"feature\",\n id: feature.id,\n detail: readme?.title.value ?? null,\n text: [readme?.summary ?? \"\", readme?.why ?? \"\"].filter((part) => part !== \"\").join(\" | \"),\n });\n const answered = attempt(() => data.feature(snapshot, feature.id));\n\n if (answered !== undefined) routes[`features/${feature.id}`] = answered;\n\n const graph = featureGraph(snapshot, feature.id);\n\n if (graph !== null) routes[`graph/feature/${feature.id}`] = graph;\n\n const product = attempt(() => productFeature(snapshot, feature.id, productOptions));\n\n if (product !== undefined) routes[`product/features/${feature.id}`] = product;\n\n for (const flow of feature.flows) {\n search.push({\n type: \"flow\",\n id: flow.ref,\n detail: flow.heading?.value ?? null,\n text: flowSearchText(flow),\n });\n const flowAnswer = attempt(() => data.flowAnswer(snapshot, feature.id, flow.id.value));\n const productFlowAnswer = attempt(() =>\n productFlow(snapshot, feature.id, flow.id.value, productOptions),\n );\n\n if (flowAnswer !== undefined) routes[`flows/${flow.ref}`] = flowAnswer;\n\n if (productFlowAnswer !== undefined) routes[`product/flows/${flow.ref}`] = productFlowAnswer;\n }\n }\n\n for (const app of snapshot.written.apps) {\n const appId = app.id.value;\n\n for (const page of [...app.pages, ...app.screens]) {\n const route = page.route?.value ?? page.screen?.value ?? null;\n const answer = attempt(() => data.page(snapshot, appId, page.id));\n const graph = pageGraph(snapshot, appId, page.id);\n\n for (const key of new Set([page.id, ...(route === null ? [] : [route])])) {\n if (answer !== undefined) routes[`apps/${appId}/pages/${key}`] = answer;\n\n if (graph !== null) routes[`graph/page/${appId}/${key}`] = graph;\n }\n\n if (route !== null)\n search.push({\n type: page.type,\n id: `${appId} ${route}`,\n detail: page.heading?.value ?? null,\n });\n\n for (const block of page.blockFiles) {\n search.push({\n type: \"block\",\n id: `${appId}/${page.id}/${block.id}`,\n detail: block.flow?.value ?? null,\n });\n }\n }\n }\n\n for (const found of snapshot.book.facts.routes ?? []) {\n search.push({\n type: \"route\",\n id: `${found.method} ${found.path}`,\n detail: found.description ?? found.handler,\n });\n }\n\n for (const task of snapshot.collected.tasksIndex.open.concat(\n snapshot.collected.tasksIndex.done,\n )) {\n search.push({ type: \"task\", id: task.id, detail: task.title });\n }\n\n const files: Record<string, { result: unknown; graph: unknown }> = {};\n const ranked = [...snapshot.book.facts.files].sort(\n (left, right) =>\n right.importedBy.length - left.importedBy.length || left.file.localeCompare(right.file),\n );\n\n for (const [index, file] of ranked.entries()) {\n search.push({ type: \"file\", id: file.file, detail: file.about });\n\n if (index >= SITE_FILE_LIMIT) continue;\n\n const result = attempt(() => data.file(snapshot, file.file));\n\n if (result !== undefined) files[file.file] = { result, graph: fileGraph(snapshot, file.file) };\n }\n\n return { routes, files, search };\n}\n\n/**\n * The business-only data of the static export: the share-safe Product map, its feature\n * and flow pages, and nothing else. No file paths, test names, export names, check\n * findings or per-file answers; the search list is empty.\n */\nexport function buildProductSiteData(snapshot: GrimoireSnapshot) {\n const options = { shared: true, errors: null } as const;\n const routes: Record<string, unknown> = {};\n const map = attempt(() => productMap(snapshot, options));\n\n if (map !== undefined) routes.product = map;\n\n const whatsNew = attempt(() => productWhatsNew(snapshot, options));\n\n if (whatsNew !== undefined) routes[\"product/whats-new\"] = whatsNew;\n\n for (const feature of snapshot.written.features) {\n const answer = attempt(() => productFeature(snapshot, feature.id, options));\n\n if (answer !== undefined) routes[`product/features/${feature.id}`] = answer;\n\n for (const flow of feature.flows) {\n const flowAnswer = attempt(() => productFlow(snapshot, feature.id, flow.id.value, options));\n\n if (flowAnswer !== undefined) routes[`product/flows/${flow.ref}`] = flowAnswer;\n }\n }\n\n return { routes, files: {}, search: [] as SearchItem[] };\n}\n\n/** JSON for an inline `<script>`: every `<` is escaped, so no `</script` or `<!--` can appear. */\nfunction inlineJson(value: unknown): string {\n return JSON.stringify(value).replaceAll(\"<\", \"\\\\u003c\");\n}\n\n/** Code for an inline `<script>`: `</script` (in any case) and `<!--` (only possible in strings and comments) are broken up. */\nfunction inlineCode(code: string): string {\n return code.replace(/<\\/(script)/gi, \"<\\\\/$1\").replaceAll(\"<!--\", \"<\\\\!--\");\n}\n\n/** The image types the export copies (the same list the devtools panel serves). */\nconst SCREENSHOT_EXTENSIONS = new Set([\".png\", \".jpg\", \".jpeg\", \".webp\", \".gif\"]);\n\n/** Every `WrittenScreenshot.path` in the written files, once each. */\nexport function collectScreenshotPaths(written: unknown): string[] {\n const found = new Set<string>();\n const walk = (value: unknown): void => {\n if (Array.isArray(value)) {\n for (const item of value) walk(item);\n } else if (value !== null && typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n\n if (\n typeof record.path === \"string\" &&\n typeof record.written === \"string\" &&\n typeof record.alt === \"string\"\n )\n found.add(record.path);\n\n for (const item of Object.values(record)) walk(item);\n }\n };\n\n walk(written);\n\n return [...found].sort();\n}\n\n/**\n * Copy the screenshots the written files use into `<out>/screenshots/`. A path that leaves\n * `grimoire/screenshots/`, has another extension or does not exist is skipped.\n *\n * @returns The paths that were copied.\n */\nexport async function copyScreenshots(\n root: string,\n outFolder: string,\n paths: readonly string[],\n): Promise<string[]> {\n const folder = await realpath(path.join(root, GRIMOIRE_PATHS.screenshots)).catch(() => null);\n const copied: string[] = [];\n\n if (folder === null) return copied;\n\n for (const written of paths) {\n const segments = written.split(\"/\");\n\n if (\n written === \"\" ||\n written.includes(\"\\\\\") ||\n written.includes(\"\\0\") ||\n path.isAbsolute(written) ||\n segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\") ||\n !SCREENSHOT_EXTENSIONS.has(path.extname(written).toLowerCase())\n )\n continue;\n\n const source = await realpath(path.join(folder, ...segments)).catch(() => null);\n\n if (source === null || !source.startsWith(folder + path.sep)) continue;\n\n if (!(await stat(source)).isFile()) continue;\n\n const target = path.join(outFolder, \"screenshots\", ...segments);\n\n await mkdir(path.dirname(target), { recursive: true });\n await copyFile(source, target);\n copied.push(written);\n }\n\n return copied;\n}\n\n/** The answer, or `undefined` when the item cannot be answered (the export skips it). */\nfunction attempt<Value>(answer: () => Value): Value | undefined {\n try {\n return answer();\n } catch {\n return undefined;\n }\n}\n\n/** Everything before the page's `export default`, so the view can sit in an inline module. */\nexport function inlineView(source: string): string {\n const marker = \"export default renderGrimoire;\";\n\n if (!source.includes(marker))\n throw new Error(\"grimoire-view.js must end with `export default renderGrimoire;`.\");\n\n return source.replace(marker, \"\");\n}\n\n/**\n * The product map module as inline code: its `export` keywords are removed and the Grimoire view\n * finds it as `globalThis.grimoireProductMap`.\n */\nexport function inlineProductMap(source: string): string {\n const marker = \"export default renderProductMap;\";\n\n if (!source.includes(marker))\n throw new Error(\"product-map.js must end with `export default renderProductMap;`.\");\n\n return `${source.replace(marker, \"\").replace(/^export (async )?function /gm, \"$1function \")}\\nglobalThis.grimoireProductMap = { productMapView };\\n`;\n}\n\n/**\n * The page's own styles: it defines every devtools panel token (light, then dark under\n * `prefers-color-scheme`), so `grimoire.css` renders the same here as in the dashboard.\n * The values keep text AA on `--background` and `--card`.\n */\nexport const PAGE_STYLE = `\n: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}\n@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}}\n*{box-sizing:border-box}body{margin:0;background:var(--background);color:var(--foreground);font-size:14px;line-height:1.5}\nmain{max-width:1180px;margin:0 auto;padding:16px}\n.empty{padding:12px;color:var(--muted-foreground)}.error{padding:12px;color:var(--destructive)}\n`;\n\n/** The `index.html` text. */\nexport function renderSiteHtml(\n siteData: unknown,\n sources: {\n view: string;\n loader: string;\n css: string;\n productMap?: string;\n productCss?: string;\n /** Mount the share-safe Product map alone (the business export): `view` and `css` are not inlined. */\n product?: boolean;\n /** A freshness stamp written into the page, so the next export can tell it is current. */\n stamp?: string;\n },\n): string {\n const json = inlineJson(siteData);\n\n if (sources.product === true && sources.productMap === undefined) {\n throw new Error(\"A product export needs product-map.js.\");\n }\n\n const mounted = sources.product === true ? \"renderProductMap\" : \"renderGrimoire\";\n const script = inlineCode(\n `${sources.productMap === undefined ? \"\" : 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`,\n );\n const styles = sources.product === true ? \"\" : sources.css;\n const stamp =\n sources.stamp === undefined ? \"\" : `<meta name=\"grimoire-stamp\" content=\"${sources.stamp}\">\\n`;\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n${stamp}<title>${sources.product === true ? \"Product map\" : \"Grimoire\"}</title>\n<style>${PAGE_STYLE}${styles}${sources.productCss ?? \"\"}</style>\n</head>\n<body>\n<main id=\"grimoire-root\"><p class=\"empty\">Opening the book…</p></main>\n<script type=\"application/json\" id=\"grimoire-data\">${json}</script>\n<script type=\"module\">${script}</script>\n</body>\n</html>\n`;\n}\n\n/** The stamp is written near the top of the page; this much of the file is enough to find it. */\nconst STAMP_HEAD_BYTES = 2048;\n\n/** The stamp of the page that is already in `index.html`, or `null` (no page, or one without a stamp). */\nasync function writtenStamp(file: string): Promise<string | null> {\n let handle;\n\n try {\n handle = await open(file, \"r\");\n\n const { buffer, bytesRead } = await handle.read(\n Buffer.alloc(STAMP_HEAD_BYTES),\n 0,\n STAMP_HEAD_BYTES,\n 0,\n );\n\n return (\n /<meta name=\"grimoire-stamp\" content=\"([0-9a-f]+)\">/.exec(\n buffer.toString(\"utf8\", 0, bytesRead),\n )?.[1] ?? null\n );\n } catch {\n return null;\n } finally {\n await handle?.close();\n }\n}\n\n/** Modified times of the files the page is built from, so a new framework version rebuilds the page. */\nasync function uiStamp(): Promise<string> {\n const names = [\n \"grimoire-view.js\",\n \"grimoire-static.js\",\n \"grimoire.css\",\n \"product-map.js\",\n \"product-map.css\",\n ];\n const times = await Promise.all(\n names.map(async (name) => {\n try {\n return (await stat(path.join(uiFolder, name))).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\n/**\n * Write the tab as a static folder for people without the app running.\n *\n * The folder holds `index.html` only: the view, the loader, the styles and\n * the data (as JSON) are inside it, so it opens straight from disk. Open the\n * page and use `#grimoire/...` links; the answers that need the running app\n * (impact of a file) say so in place.\n *\n * With `product: true` the page is the business export: the share-safe\n * Product map only, no file paths, test names or per-file answers.\n *\n * The page carries a freshness stamp (the files of the book, the written\n * folders and the test results). When the folder already holds a page with\n * the same stamp and the same mode, nothing is rebuilt or written (`force`\n * writes it anyway).\n *\n * @param root Absolute project root.\n */\nexport async function exportGrimoireSiteDetailed(\n root: string,\n options: ExportGrimoireSiteOptions = {},\n): Promise<GrimoireSiteExport> {\n // Project-relative from here on; an absolute folder is kept where it is.\n const outDir = projectPath(\n root,\n toPosixPath(options.outDir ?? GRIMOIRE_PATHS.staticSite),\n ).replace(/\\/+$/, \"\");\n const snapshot =\n options.snapshot ??\n (await createSnapshotSource(\n root,\n options.adapter === undefined ? {} : { adapter: options.adapter },\n ).get());\n const absolute = path.resolve(root, outDir);\n const product = options.product === true;\n const stamp = createHash(\"sha1\")\n .update(`${product ? \"product\" : \"full\"}|${await stampOf(root, snapshot)}|${await uiStamp()}`)\n .digest(\"hex\");\n\n if (options.force !== true && (await writtenStamp(path.join(absolute, \"index.html\"))) === stamp) {\n return { outDir, upToDate: true };\n }\n\n const [view, loader, css, productMapSource, productCss] = await Promise.all(\n [\n \"grimoire-view.js\",\n \"grimoire-static.js\",\n \"grimoire.css\",\n \"product-map.js\",\n \"product-map.css\",\n ].map((name) => readFile(path.join(uiFolder, name), \"utf8\")),\n );\n const html = renderSiteHtml(product ? buildProductSiteData(snapshot) : buildSiteData(snapshot), {\n view: view ?? \"\",\n loader: loader ?? \"\",\n css: css ?? \"\",\n productMap: productMapSource ?? \"\",\n productCss: productCss ?? \"\",\n product,\n stamp,\n });\n\n await mkdir(absolute, { recursive: true });\n await writeFile(path.join(absolute, \"index.html\"), html);\n // The business export carries no bird-view, so it does not carry the captured and approved images either.\n await copyScreenshots(root, absolute, [\n ...collectScreenshotPaths(snapshot.written),\n ...(product ? [] : matrixImagePaths(matrix(snapshot))),\n ]);\n\n return { outDir, upToDate: false };\n}\n\n/** `exportGrimoireSiteDetailed()` that returns only the output folder, project-relative. */\nexport async function exportGrimoireSite(\n root: string,\n options: ExportGrimoireSiteOptions = {},\n): Promise<string> {\n return (await exportGrimoireSiteDetailed(root, options)).outDir;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,MAAa,kBAAkB;;AAM/B,SAAS,eAAe,MAA2B;CACjD,OAAO;EACL,KAAK,WAAW;EAChB,GAAG,KAAK,MAAM,KAAK,SAAS,KAAK,IAAI;EACrC,GAAG,KAAK,MAAM,KAAK,SAAS,GAAG,KAAK,SAAS,GAAG,KAAK,OAAO,GAAG,KAAK,SAAS,KAAK,GAAG,GAAG;EACxF,GAAG,KAAK,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG,GAAG,KAAK,MAAM;CAC1D,CAAC,CACE,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7B,KAAK,KAAK;AACf;AAEA,MAAM,WAAW,cAAc,IAAI,IAAI,aAAa,YAAY,GAAG,CAAC;;AAGpE,SAAgB,cAAc,UAA4B;CACxD,MAAM,SAAkC;EACtC,SAASA,QAAa,QAAQ;EAC9B,UAAUC,SAAc,QAAQ;EAChC,MAAMC,KAAU,QAAQ;EACxB,OAAOC,MAAW,QAAQ;EAC1B,UAAUC,SAAc,QAAQ;EAEhC,OAAO;GAAE,GAAGC,MAAW,QAAQ;GAAG,MAAM;EAAI;EAC5C,iBAAiBC,eAAoB,QAAQ;EAE7C,QAAQ;GAAE,GAAG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AACnC;;AAGA,eAAsB,mBACpB,MACA,UAAqC,CAAC,GACrB;CACjB,QAAQ,MAAM,2BAA2B,MAAM,OAAO,EAAC,CAAE;AAC3D"}
|
|
@@ -41,7 +41,11 @@ const STAMPED = [
|
|
|
41
41
|
GRIMOIRE_PATHS.apps,
|
|
42
42
|
GRIMOIRE_PATHS.openTasks,
|
|
43
43
|
GRIMOIRE_PATHS.doneTasks,
|
|
44
|
-
GRIMOIRE_PATHS.releases
|
|
44
|
+
GRIMOIRE_PATHS.releases,
|
|
45
|
+
GRIMOIRE_PATHS.settings,
|
|
46
|
+
GRIMOIRE_PATHS.approved,
|
|
47
|
+
GRIMOIRE_PATHS.baseline,
|
|
48
|
+
GRIMOIRE_PATHS.captureIndex
|
|
45
49
|
];
|
|
46
50
|
/** The modified times of `files`, joined (`0` for a missing file). */
|
|
47
51
|
async function timesOf(files) {
|