#!/bin/bash # Pre-commit hook to run code quality tools and ensure generated types are up-to-date set -e # Get the root of the repository REPO_ROOT="$(git rev-parse --show-toplevel)" cd "$REPO_ROOT" echo "🔧 Running code quality checks (ruff, mypy, bandit, eslint, prettier)..." echo "" # Run pre-commit framework hooks on staged files cd backend && uv run pre-commit run cd "$REPO_ROOT" echo "" echo "🔍 Checking if generated types are fresh..." # Check if api.ts is staged if git diff --cached --name-only | grep -q "frontend/app/generated/api.ts"; then echo "✓ Generated types are staged" else # Check if backend schema files have changed if git diff --cached --name-only | grep -qE "backend/(schemas|models|routes)"; then # Check if api.ts has unstaged changes (meaning types need to be staged) if git diff --name-only | grep -q "frontend/app/generated/api.ts"; then echo "⚠️ Backend schema files changed and generated types have unstaged changes." echo " Run 'git add frontend/app/generated/api.ts' to stage the changes." echo "" echo " To skip this check (not recommended): git commit --no-verify" exit 1 else echo "✓ Generated types are up to date (no changes needed)" fi fi fi echo "" echo "🔍 Validating translation files..." # Check if any translation files are staged if git diff --cached --name-only | grep -q "frontend/locales/"; then # Run translation validation if ! node scripts/validate-translations.js; then exit 1 fi else echo "✓ No translation files staged, skipping validation" fi echo "" echo "✅ All pre-commit checks passed"