#!/bin/bash

echo "🔍 Running pre-commit checks..."

# Run security check
echo "🔐 Checking for credential leaks..."
npm run security:check
if [ $? -ne 0 ]; then
    echo "❌ Security check failed!"
    exit 1
fi

# Run build test
echo "🏗️  Testing build..."
node scripts/test-build.js
if [ $? -ne 0 ]; then
    echo "❌ Build test failed!"
    exit 1
fi

# Run tests
echo "🧪 Running tests..."
npm test -- --passWithNoTests
if [ $? -ne 0 ]; then
    echo "❌ Tests failed!"
    exit 1
fi

echo "✅ All pre-commit checks passed!"