49c8def037
pnpm + turbo workspace with the commands from CLAUDE.md §3. The contracts from §6 as JSON Schemas with generated types; localDay as the one place a day is computed; the forbidden-word list shared by lint:copy and the library validator, with 13 negative fixtures; a Svelte 5 PWA shell built under /Rosea/ with a meta CSP. E2E and offline suites run against the built bundle; the offline one closes the server rather than emulating. Analysis: .agents/features/phase0-workspace.md
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
/**
|
|
* `pnpm lint:copy` — every file a player could read text from, checked for
|
|
* forbidden words and names (CLAUDE.md §5.6). The rules live in
|
|
* @rosea/content (copy-lint.ts, forbidden.ts) and are tested there.
|
|
*
|
|
* Not scanned: .agents/ and docs/, where the forbidden words may appear because
|
|
* they are being discussed (§5.6 rule 4).
|
|
*/
|
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
import { extname, join, relative } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { lintCopy } from '@rosea/content';
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
|
|
/** Directories walked, and the extensions read in them. */
|
|
const TARGETS: readonly { dir: string; ext: readonly string[] }[] = [
|
|
{ dir: 'packages/ui/src', ext: ['.ts', '.svelte', '.css'] },
|
|
{ dir: 'apps/rosea/src', ext: ['.ts', '.svelte', '.css'] },
|
|
// Store listings, once they exist, live here and are player-facing too (§8).
|
|
{ dir: 'store', ext: ['.md', '.txt', '.json'] }
|
|
];
|
|
|
|
/** Single files: the page shell and the config that builds the web manifest. */
|
|
const FILES: readonly string[] = ['apps/rosea/index.html', 'apps/rosea/vite.config.ts'];
|
|
|
|
function walk(dir: string, ext: readonly string[]): string[] {
|
|
if (!existsSync(dir)) return [];
|
|
return readdirSync(dir).flatMap((entry) => {
|
|
const full = join(dir, entry);
|
|
if (statSync(full).isDirectory()) return walk(full, ext);
|
|
return ext.includes(extname(entry)) ? [full] : [];
|
|
});
|
|
}
|
|
|
|
const files = [
|
|
...TARGETS.flatMap(({ dir, ext }) => walk(join(root, dir), ext)),
|
|
...FILES.map((f) => join(root, f)).filter((f) => existsSync(f))
|
|
];
|
|
|
|
if (files.length === 0) {
|
|
console.error('lint:copy found no files to check. A check that reads nothing is not a pass.');
|
|
process.exit(1);
|
|
}
|
|
|
|
let problems = 0;
|
|
for (const file of files) {
|
|
for (const p of lintCopy(readFileSync(file, 'utf8'))) {
|
|
problems += 1;
|
|
console.error(`${relative(root, file).replace(/\\/g, '/')}:${p.line} ${p.message}`);
|
|
}
|
|
}
|
|
|
|
console.log(`lint:copy: ${files.length} files checked, ${problems} problem${problems === 1 ? '' : 's'}`);
|
|
process.exit(problems === 0 ? 0 : 1);
|