#!/usr/bin/env bash # Palette audit: fails when a color literal outside the BEARER palette appears # in the app source. Alpha (rgba) variants of palette tokens are allowed. # SVG luminance masks (#fff/#000 in GlyphField) are exempt by design. set -uo pipefail cd "$(dirname "$0")/.." # hex tokens, lowercase ALLOWED_HEX="080808|111111|161616|1c1c1c|2a2a2a|3d3d3d|f2f2f2|919191|5c5c5c|c8ff00|8fb000|e9ffb3|5200ff|8a5cff|ff3b00" # rgba bases: mint 200,255,0 · volt 82,0,255 · lime 233,255,179 · snow 242,242,242 ALLOWED_RGBA="^rgba?\((200, ?255, ?0|82, ?0, ?255|233, ?255, ?179|242, ?242, ?242)(, ?[0-9.]+)?\)$" FAIL=0 # --- hex literals ----------------------------------------------------------- while IFS=: read -r file line hex; do low=$(printf "%s" "$hex" | tr 'A-F' 'a-f') norm=${low#\#} [[ "$norm" =~ ^($ALLOWED_HEX)$ ]] && continue # exempt: luminance mask stops in GlyphField if [[ "$file" == *"GlyphField"* && ( "$norm" == "fff" || "$norm" == "000" ) ]]; then continue fi echo "STRAY HEX $file:$line $hex" FAIL=1 done < <(grep -rnoE "#[0-9a-fA-F]{3,8}\b" src/ index.html | grep -v "^\s*//" ) # --- rgb/rgba literals ------------------------------------------------------ while IFS=: read -r file line rgba; do [[ "$rgba" =~ $ALLOWED_RGBA ]] && continue echo "STRAY RGBA $file:$line $rgba" FAIL=1 done < <(grep -rnoE "rgba?\([0-9, .]+\)" src/) if [[ $FAIL -eq 0 ]]; then echo "palette audit clean: every literal maps to a BEARER token" fi exit $FAIL