-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathlefthook.yml
More file actions
78 lines (74 loc) · 2.76 KB
/
lefthook.yml
File metadata and controls
78 lines (74 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
prepare-commit-msg:
scripts:
'generate-commit-msg.sh':
runner: bash
output:
- meta
- summary
- error
pre-commit:
commands:
'prevent-commit-on-main':
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch" = "main" ]; then
echo "ERROR: Direct commits to main branch are not allowed!"
exit 1
fi
'validate-json-files':
glob: '*.{json,jsonc}'
run: |
./scripts/validate-json-files.sh
post-checkout:
commands:
'pnpm-install-on-deps-change':
run: |
# Only run if pnpm is available
if ! command -v pnpm &> /dev/null; then
echo "\033[33mWarning: pnpm not available, skipping dependency installation.\033[0m"
exit 0
fi
# Only run for branch checkouts (not file checkouts)
if [ "{3}" = "1" ]; then
# Always install if node_modules doesn't exist (new worktree case)
if [ ! -d "node_modules" ]; then
echo "📦 node_modules not found, running pnpm install --frozen-lockfile..."
pnpm install --frozen-lockfile
# Otherwise, only install if dependencies changed
elif git diff --name-only {1} {2} | grep -qE '^(package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml)$'; then
echo "📦 Dependencies changed, running pnpm install --frozen-lockfile..."
pnpm install --frozen-lockfile
fi
fi
'claude-symlink':
run: |
# Only run for branch checkouts (not file checkouts)
if [ "{3}" = "1" ]; then
if [ -n "$CLAUDE_SYMLINK_SCRIPT" ] && [ -f "$CLAUDE_SYMLINK_SCRIPT" ]; then
"$CLAUDE_SYMLINK_SCRIPT" --yes "$PWD"
elif [ -z "$CLAUDE_SYMLINK_SCRIPT" ]; then
echo "\033[33mWarning: CLAUDE_SYMLINK_SCRIPT not set. See LOCAL_DEV.md for setup instructions.\033[0m"
fi
fi
pre-push:
scripts:
'prevent-push-to-main.sh':
runner: bash
skip_output:
- meta
commands:
'validate-changesets':
run: |
if find .changeset -name "*.md" -not -name "README.md" 2>/dev/null | grep -q .; then
echo "🔍 Validating changesets..."
VERSION=$(jq -r '.devDependencies["@changesets/cli"]' package.json | tr -d '^~')
if ! pnpm dlx @changesets/cli@$VERSION status; then
echo ""
echo "❌ Changeset validation failed!"
echo "Check that package names in .changeset/*.md files match 'name' field in package.json files."
exit 1
fi
echo "✅ Changesets are valid"
fi
'nx-affected-checks':
run: CI=true NX_DAEMON=false pnpm nx affected --target=prepush --base=origin/main --head=HEAD --output-style=static --verbose --nx-bail