@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 28 lines 1.23 KB
Raw
1 // @effect-diagnostics nodeBuiltinImport:off - a plain test that scans the source tree once.
2 import * as NodeFS from "node:fs";
3 import * as NodePath from "node:path";
4
5 import { THEME_CSS_HOOKS } from "@t3tools/shared/themeCss";
6 import { expect, it } from "vite-plus/test";
7
8 const sourceDirectory = import.meta.dirname;
9 const source = NodeFS.readdirSync(sourceDirectory, { recursive: true, encoding: "utf8" })
10 .filter((file) => /\.(tsx?|css)$/.test(file) && !file.includes(".test."))
11 .map((file) => NodeFS.readFileSync(NodePath.join(sourceDirectory, file), "utf8"))
12 .join("\n");
13
14 /** How the selector's hook is written in source: an attribute, a slot value, or a class name. */
15 function sourcePattern(selector: string): RegExp {
16 const slot = /^\[data-slot="([a-z-]+)"\]$/.exec(selector)?.[1];
17 if (slot) return new RegExp(`data-slot["']?\\s*[:=]\\s*["']${slot}["']`);
18 const attribute = /^\[(data-[a-z-]+)/.exec(selector)?.[1];
19 return new RegExp(`\\b${attribute ?? selector.slice(1)}\\b`);
20 }
21
22 // Theme CSS and the agent guide rely on these selectors. Rename one in the guide too.
23 it.each(THEME_CSS_HOOKS.map((hook) => hook.selector))(
24 "%s is still in the web source",
25 (selector) => {
26 expect(source).toMatch(sourcePattern(selector));
27 },
28 );