Skip to content

Commit a27774b

Browse files
authored
fix: enforce docs snapshots and track SPA analytics (#34)
1 parent 6b3b744 commit a27774b

33 files changed

Lines changed: 771 additions & 1002 deletions

‎README.md‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@ CI therefore validate the same package boundary used by GitHub Pages.
1010

1111
- `npm run dev` starts the Vite development server.
1212
- `npm run build` builds the client and runs `askr ssg` into `dist/`.
13-
- `npm run docs:api` refreshes the published declaration snapshot.
14-
- `npm run docs:cli` refreshes the installed CLI command snapshot.
15-
- `npm run verify:static` validates the generated route, markup, and assets.
1613
- `npm run fmt:check` checks formatting without changing files.
17-
- `npm test` verifies the generated static output after a build.
14+
- `npm test` runs the unit and generated-output contract tests after a build.
1815
- `npm run preview` serves `dist/` with `vp preview --outDir dist`.
19-
- `npm run check` runs lint, typecheck, build, and static verification.
16+
- `npm run check` runs formatting, lint, typecheck, tests, and the production
17+
build.
2018

2119
## Architecture
2220

2321
- `src/pages/marketing/_layout.tsx` owns the marketing shell and shared Askr
2422
branding.
25-
- `src/pages/_routes.tsx` owns the complete docs and SSG route registry, while
26-
`src/pages/marketing/_routes.tsx` owns the smaller browser registry used by
27-
marketing pages.
23+
- `src/pages/_routes.tsx` owns the complete browser and SSG route registry plus
24+
the persistent route-analytics layout, while
25+
`src/pages/marketing/_routes.tsx` registers the marketing leaves.
2826
- `src/pages/marketing/home.tsx` renders the `/` page.
2927
- `src/pages/docs/catalog.ts` is the typed source of truth for docs routes,
3028
metadata, grouped navigation, breadcrumbs, page ordering, search, and SSG.
@@ -46,24 +44,17 @@ SSG. This package does not expose a public API.
4644
1. `npm run build:client` builds the browser entry and stylesheet into
4745
`.askr/client/` with hashed asset names.
4846
2. `npm run build:ssg` renders the marketing routes, authored docs catalog, and
49-
generated API reference routes,
50-
injects them into the built Vite document, and publishes the result to
51-
`dist/`.
52-
3. `npm run verify:static` checks `dist/metadata.json`, pre-rendered content,
53-
and every referenced asset.
47+
API reference routes, injects them into the built Vite document, and
48+
publishes the result to `dist/`.
5449

55-
The build fails when the checked-in API or CLI snapshot drifts from the exact
56-
package versions in `package-lock.json`. Reference-only packages are kept as
50+
The API and CLI snapshots are checked-in documentation data. The unit suite
51+
derives installed package entrypoints, versions, exported signatures, peer
52+
metadata, and CLI help directly from `node_modules` and fails on drift before
53+
the production build starts. Package versions remain internal contract metadata
54+
and are not rendered on the site. Reference-only packages are kept as
5755
development dependencies; packages used by live browser examples remain
5856
runtime dependencies.
5957

60-
`docs:api` also generates `src/pages/docs/package-versions.ts` from the
61-
installed package manifests. Guide badges and package references read from that
62-
map instead of repeating version literals. To refresh the site after releases,
63-
upgrade the relevant `@askrjs/*` dependencies, run `npm install`, then run
64-
`npm run docs:api` and `npm run docs:cli`. The aggregate check verifies that the
65-
catalog, CLI snapshot, and every generated API entrypoint agree on versions.
66-
6758
`.github/workflows/ci.yml` runs format, lint/typecheck, build, and test on pull
6859
requests. Pushes to `main` and manual dispatches use
6960
`.github/workflows/deploy.yml` to run the aggregate check, upload `dist/`, and

‎index.html‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
<title data-askr-head>Askr</title>
77
<link rel="icon" type="image/png" href="/assets/askr-logo-64.png" />
88
<link rel="apple-touch-icon" href="/assets/askr-logo-180.png" />
9+
<!-- Google tag (gtag.js) -->
10+
<script
11+
async
12+
src="https://www.googletagmanager.com/gtag/js?id=G-TXZTWQFV59"
13+
></script>
14+
<script>
15+
window.dataLayer = window.dataLayer || [];
16+
function gtag() {
17+
dataLayer.push(arguments);
18+
}
19+
gtag('js', new Date());
20+
gtag('config', 'G-TXZTWQFV59', { send_page_view: false });
21+
</script>
922
</head>
1023

1124
<body>

‎package-lock.json‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@
66
"type": "module",
77
"scripts": {
88
"dev": "vp dev",
9-
"build": "npm run docs:drift && npm run build:client && npm run build:ssg",
9+
"build": "npm run build:client && npm run build:ssg",
1010
"build:client": "vp build --outDir .askr/client",
1111
"build:ssg": "askr ssg --config ./ssg.config.ts --output ./dist && cp ./dist/404/index.html ./dist/404.html",
12-
"verify:static": "tsx ./scripts/verify-static-output.ts",
13-
"docs:api": "tsx ./scripts/generate-api-snapshot.ts",
14-
"docs:api:check": "tsx ./scripts/generate-api-snapshot.ts --check",
15-
"docs:cli": "tsx ./scripts/generate-cli-reference.ts",
16-
"docs:cli:check": "tsx ./scripts/generate-cli-reference.ts --check",
17-
"docs:drift": "npm run docs:api:check && npm run docs:cli:check",
1812
"analyze": "askr analyze --check",
19-
"lint": "vp lint src scripts ssg.config.ts vite.config.ts",
13+
"lint": "vp lint src tests ssg.config.ts vite.config.ts",
2014
"fmt": "vp fmt .",
2115
"fmt:check": "vp fmt . --check",
22-
"test:unit": "vp test run",
23-
"test": "npm run test:unit && npm run verify:static",
16+
"test:unit": "vp test run --exclude tests/generated-output-contract.test.ts",
17+
"test:static": "vp test run tests/generated-output-contract.test.ts",
18+
"test": "npm run test:unit && npm run test:static",
2419
"typecheck": "tsc --noEmit",
25-
"check": "npm run fmt:check && npm run lint && npm run typecheck && npm run docs:drift && npm run test:unit && npm run build && npm run verify:static",
20+
"check": "npm run fmt:check && npm run lint && npm run typecheck && npm run test:unit && npm run build && npm run test:static",
2621
"preview": "vp preview --outDir dist"
2722
},
2823
"dependencies": {
@@ -47,7 +42,6 @@
4742
"@askrjs/testing": "0.0.3",
4843
"@askrjs/vite": "0.0.10",
4944
"@types/node": "^26.1.2",
50-
"tsx": "4.23.1",
5145
"typescript": "^6.0.3",
5246
"vite-plus": "^0.2.6"
5347
},

‎scripts/format-generated.ts‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)