Skip to main content
Glama
pre-pushβ€’4 kB
echo "πŸš€ Running pre-push validations..." current_branch=$(git rev-parse --abbrev-ref HEAD) # Check for sensitive files in staged changes echo "πŸ” Checking for sensitive files..." if git diff --name-only HEAD~1..HEAD 2>/dev/null | grep -E "\.(key|pem|p12|pfx)$|\.env$|\.env\.(local|development|test|production)$" > /dev/null; then echo "❌ Attempting to push sensitive files. Please remove them from the commit." git diff --name-only HEAD~1..HEAD | grep -E "\.(key|pem|p12|pfx)$|\.env$|\.env\.(local|development|test|production)$" exit 1 fi # Check for alternative file versions (forbidden) echo "πŸ” Checking for forbidden file patterns..." ALT_FILES=$(find src -name "*-v2.ts" -o -name "*-new.ts" -o -name "*-old.ts" -o -name "*-temp.ts" -o -name "*-backup.ts" -o -name "*-enhanced.ts" -o -name "*-improved.ts" 2>/dev/null) if [ -n "$ALT_FILES" ]; then echo "❌ Forbidden alternative file versions found:" echo "$ALT_FILES" exit 1 fi # NEW: Comprehensive untracked file check (REQ-3) echo "πŸ” Checking for untracked source files..." UNTRACKED_SRC=$(find src -name "*.ts" -type f 2>/dev/null | while read -r file; do if ! git ls-files --error-unmatch "$file" >/dev/null 2>&1; then echo "$file" fi done) if [ -n "$UNTRACKED_SRC" ]; then echo "❌ Found untracked source files that WILL cause CI failures:" echo "$UNTRACKED_SRC" echo "" echo "πŸ’‘ These files exist locally but are not in git." echo " CI will fail because it only sees tracked files." echo " To fix:" echo " 1. git add <files>" echo " 2. git commit --amend (to add to current commit)" echo " Or create a new commit:" echo " 1. git add <files>" echo " 2. git commit -m 'fix: add missing source files'" exit 1 fi # NEW: Validate no source files are gitignored (REQ-3, REQ-7) echo "πŸ” Validating .gitignore doesn't ignore source code..." IGNORED_SRC=$(git check-ignore src/**/*.ts 2>/dev/null || true) if [ -n "$IGNORED_SRC" ]; then echo "❌ Source files are being ignored by .gitignore:" echo "$IGNORED_SRC" echo "" echo "πŸ’‘ This WILL cause CI failures. The .gitignore patterns are" echo " preventing these source files from being committed." echo "" echo " To fix .gitignore patterns:" echo " 1. Use leading '/' to anchor patterns to repository root" echo " 2. Example: Change 'memory/' to '/memory/'" echo " 3. This ensures only root-level directories are ignored," echo " not src/memory/ or other nested directories." exit 1 fi # NEW: Validate TypeScript imports resolve correctly (REQ-7) echo "πŸ” Validating TypeScript import resolution..." timeout 60s npm run typecheck >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "⚠️ TypeScript import resolution issues detected." echo " Running full typecheck for details..." npm run typecheck echo "" echo "πŸ’‘ Import resolution failures often indicate:" echo " - Missing source files (not tracked by git)" echo " - Incorrect import paths" echo " - Missing type definitions" exit 1 fi # Run full validation with strict linting (same as CI) echo "πŸ—οΈ Running CI validation..." timeout 220s npm run validate:ci if [ $? -ne 0 ]; then echo "❌ CI validation failed. Please fix the issues above." echo "πŸ’‘ CI validation includes: security audit, format check, strict lint (zero warnings), typecheck, tests with coverage." exit 1 fi # Build the project echo "πŸ“¦ Building project..." timeout 120s npm run build:quick if [ $? -ne 0 ]; then echo "❌ Build failed. Please fix the issues above." exit 1 fi # Additional checks for protected branches if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ]; then echo "πŸ”’ Protected branch: $current_branch" if git log --oneline -5 | grep -E "(bump|version|release|v[0-9])" > /dev/null; then echo "βœ… Version update detected." else echo "⚠️ No version update detected. Consider bumping version." fi fi echo "βœ… Pre-push validations passed!"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keyurgolani/ThoughtMcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server