pre-commit 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. # shellcheck disable=SC2034 # YELLOW reserved for future warning messages
  17. YELLOW='\033[1;33m'
  18. NC='\033[0m'
  19. # Track if any check failed
  20. FAILED=0
  21. echo "1. Checking registry paths and JSON validity..."
  22. if bun run scripts/registry/validate-registry.ts > /dev/null 2>&1; then
  23. echo -e "${GREEN}✓${NC} Registry is valid JSON and all paths exist"
  24. else
  25. echo -e "${RED}✗${NC} Registry validation failed"
  26. bun run scripts/registry/validate-registry.ts
  27. FAILED=1
  28. fi
  29. echo ""
  30. echo "2. Checking dependencies and profile consistency..."
  31. if bun run scripts/registry/check-dependencies.ts > /dev/null 2>&1; then
  32. echo -e "${GREEN}✓${NC} All dependencies and profile references are valid"
  33. else
  34. echo -e "${RED}✗${NC} Some dependencies or profile references are invalid"
  35. bun run scripts/registry/check-dependencies.ts
  36. FAILED=1
  37. fi
  38. echo ""
  39. if [ $FAILED -eq 0 ]; then
  40. echo -e "${GREEN}✓ All pre-commit checks passed!${NC}"
  41. exit 0
  42. else
  43. echo -e "${RED}✗ Pre-commit checks failed. Please fix the issues above.${NC}"
  44. echo ""
  45. echo "Quick fixes:"
  46. echo " - Run 'bun run scripts/registry/validate-registry.ts' for path/JSON issues"
  47. echo " - Run 'bun run scripts/registry/check-dependencies.ts' for dependency issues"
  48. exit 1
  49. fi