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
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
// Installs the git hooks CLAUDE.md §5.2 relies on. Runs from `pnpm install` via
|
|
// the root `prepare` script, so a fresh clone is guarded before its first commit.
|
|
// Adapted from Ludus, including its worktree fix: in a worktree `.git` is a FILE
|
|
// pointing at the real gitdir, and hooks resolve per worktree.
|
|
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, statSync } from 'node:fs';
|
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const gitPath = join(root, '.git');
|
|
|
|
if (!existsSync(gitPath)) {
|
|
console.log('[hooks] no .git — skipping hook install.');
|
|
process.exit(0);
|
|
}
|
|
|
|
function resolveGitDir(path) {
|
|
if (statSync(path).isDirectory()) return path;
|
|
const target = /^gitdir:\s*(.+)$/.exec(readFileSync(path, 'utf8').trim())?.[1]?.trim();
|
|
if (target === undefined) {
|
|
console.log(`[hooks] ${path} is a file but not a gitdir pointer — skipping hook install.`);
|
|
process.exit(0);
|
|
}
|
|
return isAbsolute(target) ? target : resolve(root, target);
|
|
}
|
|
|
|
const hooksDir = join(resolveGitDir(gitPath), 'hooks');
|
|
mkdirSync(hooksDir, { recursive: true });
|
|
|
|
for (const hook of ['pre-commit', 'commit-msg']) {
|
|
const dest = join(hooksDir, hook);
|
|
copyFileSync(join(root, 'scripts', hook), dest);
|
|
chmodSync(dest, 0o755);
|
|
console.log(`[hooks] installed ${hook}`);
|
|
}
|