43 lines
1.3 KiB
Bash
43 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
STRICT=0
|
|
if [[ "${1:-}" == "--strict" ]]; then
|
|
STRICT=1
|
|
fi
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
report() {
|
|
local title="$1"
|
|
local pattern="$2"
|
|
shift 2
|
|
local matches
|
|
matches="$(rg -n "$pattern" "$@" --glob '!**/*.test.*' || true)"
|
|
|
|
echo "=== $title ==="
|
|
if [[ -z "$matches" ]]; then
|
|
echo "ok: no matches"
|
|
return 0
|
|
fi
|
|
|
|
echo "$matches"
|
|
echo
|
|
return 1
|
|
}
|
|
|
|
failures=0
|
|
|
|
report "Raw interactive controls" '<button|<input|<textarea|<select' web/src/app web/src/components || failures=$((failures + 1))
|
|
report "Legacy global surface classes" 'className="[^"]*(badge|surface-card|surface-muted|input-shell)' web/src/app web/src/components || failures=$((failures + 1))
|
|
report "Hardcoded color literals" '#[0-9a-fA-F]{3,8}|rgba?\(' web/src/app web/src/components || failures=$((failures + 1))
|
|
report "Direct @bytelyst/ui imports outside adapter" 'from "@bytelyst/ui"|from '\''@bytelyst/ui'\''' web/src/app web/src/components --glob '!web/src/components/ui/Primitives.tsx' || failures=$((failures + 1))
|
|
|
|
if [[ "$STRICT" == "1" && "$failures" -gt 0 ]]; then
|
|
echo "UI drift audit failed in strict mode with $failures category/categories containing matches." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "UI drift audit completed with $failures non-empty category/categories."
|