Files
site/scripts/modules.test.ts
zeekayandGitHub ea43c5a975 Type lib, scripts, v2, home and app under strict (#8)
* Type scripts under strict

Playwright's API the checks use is declared in host.ts (the package is
the app repo's); caught errors read through why(). tabs-tree.test waits
for the typed tabsTree.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type the shared components under strict

Window globals (__lenis, __hzHold, google) and the two react-dom calls
are declared in components/*.d.ts, since @types/react-dom is not a
dependency and the lockfile is frozen.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type components/v2 under strict

Props, state, refs and DOM events in the 93 v2 files. A2Motion's easing
tuples are as const. Two real bugs: x-archimedes/MaskLines imported a
NoJs that does not exist, and x-hypatia/PinChapters returned the element
from a ref callback, which React 19 reads as a cleanup. AppSheet no
longer sets aria-label to a JSX label.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type components/home under strict

The race, cost and frontier figures, the plan cards, the repository card
and the product stories take Run, Models and Plan types from lib.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type the hero devices and the app routes under strict

HeroScene and its parts describe hero-scenes.json; the [slug] pages take
params as a Promise, and metadata and viewport carry Next's types.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Give the integrations previews their Preview type

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Use the bench Card type for the closing cards

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
2026-11-14 01:34:34 -08:00

29 lines
1.6 KiB
TypeScript

// After `pnpm build` (the postbuild step runs it): every Go module hanzo-inc/app publishes under hanzo.ai answers
// ?go-get=1 with its tag in the static HTML of out/, naming the repository the app names. modules.json is that list as
// hanzo-inc/app lib/go-modules.ts evaluates it (name -> repository), 74 modules, nested paths (lz4/v4) included.
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
const OUT = path.resolve(import.meta.dirname, '..', 'out');
const MODULES = JSON.parse(fs.readFileSync(path.join(import.meta.dirname, 'modules.json'), 'utf8'));
// the Sites plane serves <route>/index.html, then <route>.html (next.config.mjs writes the second)
const page = (name: string) => [`${name}/index.html`, `${name}.html`].map((f) => path.join(OUT, f)).find((f) => fs.existsSync(f));
const meta = (html: string, name: string) => [...html.matchAll(new RegExp(`<meta name="${name}" content="([^"]*)"`, 'g'))].map((m) => m[1]);
test('out/ has been built', () => {
assert.ok(fs.existsSync(path.join(OUT, 'index.html')), 'run pnpm build first');
});
for (const [name, repo] of Object.entries(MODULES)) {
test(`hanzo.ai/${name} carries its go-import tag`, () => {
const file = page(name);
assert.ok(file, `no page at /${name} in out/`);
const html = fs.readFileSync(file, 'utf8');
const path_ = `hanzo.ai/${name}`;
assert.deepEqual(meta(html, 'go-import'), [`${path_} git ${repo}`]);
assert.deepEqual(meta(html, 'go-source'), [`${path_} ${repo} ${repo}/tree/main{/dir} ${repo}/blob/main{/dir}/{file}#L{line}`]);
});
}