#!/usr/bin/env bash # Fails the build if any source file exceeds the 1,500-line budget. # Warns for files over the 1,100-line soft threshold so splits happen # before they hurt. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" HARD_LIMIT=1500 SOFT_LIMIT=1100 STATUS=0 # Source extensions under budget. Generated/vendored paths are excluded. while IFS= read -r f; do [ -z "$f" ] && continue lines=$(wc -l <"$f" | tr -d ' ') if [ "$lines" -gt "$HARD_LIMIT" ]; then echo "FAIL: $f has $lines lines (limit $HARD_LIMIT)" STATUS=1 elif [ "$lines" -gt "$SOFT_LIMIT" ]; then echo "WARN: $f has $lines lines (soft limit $SOFT_LIMIT)" fi done < <( find "$ROOT/crates" "$ROOT/frontend/src" "$ROOT/tools" "$ROOT/tests" \ -type f \( -name '*.rs' -o -name '*.ts' -o -name '*.tsx' -o -name '*.css' \) \ -not -path '*/node_modules/*' -not -path '*/target/*' 2>/dev/null ) exit "$STATUS"