diff --git a/apps/with-lingui/.vite-hooks/pre-commit b/apps/with-lingui/.vite-hooks/pre-commit index 85fb65b..b8cd380 100755 --- a/apps/with-lingui/.vite-hooks/pre-commit +++ b/apps/with-lingui/.vite-hooks/pre-commit @@ -1 +1,26 @@ -vp staged +#!/usr/bin/env sh +# Run vp staged from each Vite+ app root so vite.config.ts (and its staged block) resolves. +# Git's cwd is the repo root while core.hooksPath points here; vp staged otherwise looks for +# vite.config.ts in the wrong directory. + +root=$(git rev-parse --show-toplevel) || exit 1 +cd "$root" || exit 1 + +files=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null || true) +[ -z "$files" ] && exit 0 + +failed=0 + +if echo "$files" | grep -q '^apps/with-lingui/'; then + (cd apps/with-lingui && PATH="$PWD/node_modules/.bin:$PATH" vp staged) || failed=1 +fi + +if echo "$files" | grep -q '^apps/basic/'; then + (cd apps/basic && PATH="$PWD/node_modules/.bin:$PATH" vp staged) || failed=1 +fi + +if echo "$files" | grep -E -q '^packages/create/.*\.(ts|tsx|mts)$'; then + pnpm --dir "$root/packages/create" run check-types || failed=1 +fi + +exit "$failed" diff --git a/apps/with-lingui/AGENTS.md b/apps/with-lingui/AGENTS.md index 5b23aa0..f4a779c 100644 --- a/apps/with-lingui/AGENTS.md +++ b/apps/with-lingui/AGENTS.md @@ -72,6 +72,10 @@ These commands map to their corresponding tools. For example, `vp dev --port 300 - Run `vp install` after pulling remote changes and before getting started. - Run `vp check` and `vp test` to validate changes. +## Monorepo git hooks + +When this app lives under a monorepo, `git config core.hooksPath` may point at `.vite-hooks/_` here while commits run with the **repository root** as cwd. The checked-in `.vite-hooks/pre-commit` script dispatches `vp staged` into `apps/with-lingui` and `apps/basic` based on staged paths (and runs `pnpm --dir packages/create run check-types` for matching `packages/create` sources) so each app’s `vite.config.ts` is found. + ## AI Instruction Files This repository also uses scoped AI instruction files in `.github/instructions/`. @@ -82,4 +86,4 @@ This repository also uses scoped AI instruction files in `.github/instructions/` - `refactor.instructions.md` for behavior-preserving cleanup - `add-resource.instructions.md` for adding a new CRUD resource (checklist; mirror `users` / `orders`) -See `.github/instructions/README.md` for usage and authoring rules. \ No newline at end of file +See `.github/instructions/README.md` for usage and authoring rules.