Skip to content

Commit 3950df1

Browse files
committed
feat: add pre-commit check script to catch issues before commit
- Add scripts/pre-commit-check.sh for comprehensive pre-commit validation - Add 'check' script (lint, type-check, tests, build) - Add 'pre-commit' script (includes security audit) - Update README with pre-commit instructions - Fix pnpm-lock.yaml formatting
1 parent b7f39d2 commit 3950df1

4 files changed

Lines changed: 69 additions & 2 deletions

File tree

‎README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ See [tests/README.md](tests/README.md) for details.
110110

111111
### Pre-Commit Checklist
112112

113+
**Before committing, run all checks:**
114+
115+
```bash
116+
# Quick check (lint, type-check, tests, build)
117+
pnpm run check
118+
119+
# Full check (includes security audit)
120+
pnpm run pre-commit
121+
```
122+
123+
Or manually:
124+
113125
- ✅ `pnpm lint` passes
114126
- ✅ `pnpm type-check` passes
115127
- ✅ `pnpm test:run` passes
@@ -119,6 +131,8 @@ See [tests/README.md](tests/README.md) for details.
119131
- ✅ Self-reviewed
120132
- ✅ Commit messages in English
121133

134+
**Tip**: Run `pnpm run check` before every commit to catch issues early.
135+
122136
### Commit Convention
123137

124138
Follow [Conventional Commits](https://www.conventionalcommits.org/):

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"test:coverage": "vitest run --coverage",
1818
"test:config-helpers": "vitest run tests/utils/config-helpers",
1919
"test:integration": "vitest run tests/utils/config-helpers.integration.test.ts",
20-
"test:watch": "vitest --watch"
20+
"test:watch": "vitest --watch",
21+
"pre-commit": "bash scripts/pre-commit-check.sh",
22+
"check": "pnpm run lint && pnpm run type-check && pnpm test:run && pnpm build"
2123
},
2224
"dependencies": {
2325
"@aws-sdk/client-s3": "^3.844.0",

‎pnpm-lock.yaml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/pre-commit-check.sh‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🔍 Running pre-commit checks..."
5+
6+
# Check if pnpm-lock.yaml is in sync
7+
echo "📦 Checking pnpm-lock.yaml sync..."
8+
if ! pnpm install --frozen-lockfile --dry-run > /dev/null 2>&1; then
9+
echo "❌ Error: pnpm-lock.yaml is out of sync with package.json"
10+
echo " Run: pnpm install"
11+
exit 1
12+
fi
13+
14+
# Run linting
15+
echo "🔍 Running linter..."
16+
pnpm run lint || {
17+
echo "❌ Linting failed. Run 'pnpm lint:fix' to auto-fix"
18+
exit 1
19+
}
20+
21+
# Run type checking
22+
echo "📘 Running type check..."
23+
pnpm run type-check || {
24+
echo "❌ Type checking failed"
25+
exit 1
26+
}
27+
28+
# Run tests
29+
echo "🧪 Running tests..."
30+
pnpm test:run || {
31+
echo "❌ Tests failed"
32+
exit 1
33+
}
34+
35+
# Check build
36+
echo "🏗️ Checking build..."
37+
pnpm build || {
38+
echo "❌ Build failed"
39+
exit 1
40+
}
41+
42+
# Security audit
43+
echo "🔒 Running security audit..."
44+
pnpm audit --audit-level=moderate || {
45+
echo "⚠️ Security vulnerabilities found (moderate or higher)"
46+
echo " Review with: pnpm audit"
47+
exit 1
48+
}
49+
50+
echo "✅ All checks passed!"
51+

0 commit comments

Comments
 (0)