pre-commit 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Pre-commit hook for registry validation
  3. # Place this file in .git/hooks/pre-commit (or use Husky)
  4. set -e
  5. echo "Running pre-commit registry checks..."
  6. echo ""
  7. # Check if bun is available
  8. if ! command -v bun &> /dev/null; then
  9. echo "⚠️ Warning: bun not found. Skipping registry checks."
  10. exit 0
  11. fi
  12. cd "$(git rev-parse --show-toplevel)"
  13. # Colors
  14. GREEN='\033[0;32m'
  15. RED='\033[0;31m'
  16. YELLOW='\033[1;33m'
  17. NC='\033[0m'
  18. # Track if any check failed
  19. FAILED=0
  20. echo "1. Checking registry paths and JSON validity..."
  21. if bun run scripts/registry/validate-registry.ts > /dev/null 2>&1; then
  22. echo -e "${GREEN}✓${NC} Registry is valid JSON and all paths exist"
  23. else
  24. echo -e "${RED}✗${NC} Registry validation failed"
  25. bun run scripts/registry/validate-registry.ts
  26. FAILED=1
  27. fi
  28. echo ""
  29. echo "2. Checking dependencies and profile consistency..."
  30. if bun run scripts/registry/check-dependencies.ts > /dev/null 2>&1; then
  31. echo -e "${GREEN}✓${NC} All dependencies and profile references are valid"
  32. else
  33. echo -e "${RED}✗${NC} Some dependencies or profile references are invalid"
  34. bun run scripts/registry/check-dependencies.ts
  35. FAILED=1
  36. fi
  37. echo ""
  38. if [ $FAILED -eq 0 ]; then
  39. echo -e "${GREEN}✓ All pre-commit checks passed!${NC}"
  40. exit 0
  41. else
  42. echo -e "${RED}✗ Pre-commit checks failed. Please fix the issues above.${NC}"
  43. echo ""
  44. echo "Quick fixes:"
  45. echo " - Run 'bun run scripts/registry/validate-registry.ts' for path/JSON issues"
  46. echo " - Run 'bun run scripts/registry/check-dependencies.ts' for dependency issues"
  47. exit 1
  48. fi