#!/bin/bash set -e echo "๐Ÿ” Running pre-commit checks..." # Check if pnpm-lock.yaml is in sync (CRITICAL - must pass) echo "๐Ÿ“ฆ Checking pnpm-lock.yaml sync..." if ! pnpm install --frozen-lockfile --dry-run > /dev/null 2>&1; then echo "โŒ CRITICAL ERROR: pnpm-lock.yaml is out of sync with package.json" echo " This will cause CI to fail!" echo " Run: pnpm install" echo " Then commit the updated pnpm-lock.yaml" exit 1 fi # Run lint check (TypeScript type check + Prettier format check) (must pass) echo "๐Ÿ” Running lint check (TypeScript + Prettier)..." pnpm run lint || { echo "โŒ Lint check failed" echo " Run 'pnpm lint:fix' to auto-fix formatting issues" echo " Fix any TypeScript errors manually" exit 1 } # Run tests echo "๐Ÿงช Running tests..." pnpm test:run || { echo "โŒ Tests failed" exit 1 } # Check build echo "๐Ÿ—๏ธ Checking build..." pnpm build || { echo "โŒ Build failed" exit 1 } # Security audit echo "๐Ÿ”’ Running security audit..." pnpm audit --audit-level=moderate || { echo "โš ๏ธ Security vulnerabilities found (moderate or higher)" echo " Review with: pnpm audit" exit 1 } echo "โœ… All checks passed!"