mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-23 06:00:24 +00:00
fix(with-lingui): run vp staged from app roots in pre-commit
Git core.hooksPath points at this app while commits use the repo root cwd, so plain vp staged could not find vite.config.ts. Dispatch into apps/with-lingui and apps/basic by staged path; run packages/create check-types for matching TS sources. Document behavior in AGENTS.md. Made-with: Cursor
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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.
|
||||
See `.github/instructions/README.md` for usage and authoring rules.
|
||||
|
||||
Reference in New Issue
Block a user