File size: 2,020 Bytes
6a7089a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/bin/bash
set -e
# check-dashboard.sh — Dashboard quality checks (matches CI: dashboard.yml)
# Runs: typecheck → eslint → prettier
cd "$(dirname "$0")/.."
BOLD=$'\033[1m'
ACCENT=$'\033[38;2;251;191;36m'
SUCCESS=$'\033[38;2;0;229;204m'
ERROR=$'\033[38;2;230;57;70m'
MUTED=$'\033[38;2;90;100;128m'
NC=$'\033[0m'
ok() { echo -e " ${SUCCESS}✓${NC} $1"; }
fail() { echo -e " ${ERROR}✗${NC} $1"; [ -n "${2:-}" ] && echo -e " ${MUTED}$2${NC}"; }
section() {
echo ""
echo -e " ${ACCENT}${BOLD}$1${NC}"
}
if [ ! -d "dashboard" ]; then
fail "Dashboard directory not found"
exit 1
fi
cd dashboard
# Detect runner
RUN="bun"
if ! command -v bun &>/dev/null; then
if command -v npx &>/dev/null; then
RUN="npx"
else
fail "Neither bun nor npx found"
exit 1
fi
fi
# Install deps if needed
if [ ! -d "node_modules" ]; then
section "Dependencies"
echo -e " ${MUTED}Installing...${NC}"
$RUN install 2>&1 | tail -1
fi
# Check tygo types are in sync (if tygo is installed)
TYGO="${GOPATH:-$HOME/go}/bin/tygo"
if [ -x "$TYGO" ] || command -v tygo &>/dev/null; then
section "Types (tygo)"
TYGO_CMD="${TYGO:-tygo}"
if [ -x "$TYGO" ]; then TYGO_CMD="$TYGO"; fi
$TYGO_CMD generate 2>/dev/null
npx prettier --write src/generated/types.ts 2>/dev/null || true
if git diff --quiet -- src/generated/types.ts 2>/dev/null; then
ok "Types in sync"
else
fail "Types out of sync" "Run: cd dashboard && tygo generate && npx prettier --write src/generated/types.ts"
exit 1
fi
fi
section "TypeScript"
if $RUN run typecheck 2>&1; then
ok "Type check"
else
fail "Type errors"
exit 1
fi
section "ESLint"
if $RUN run lint 2>&1; then
ok "ESLint"
else
fail "Lint errors"
exit 1
fi
section "Prettier"
if $RUN run format:check 2>&1; then
ok "Formatting"
else
fail "Files not formatted"
echo -e " ${MUTED}Run: cd dashboard && $RUN run format${NC}"
exit 1
fi
section "Summary"
echo ""
echo -e " ${SUCCESS}${BOLD}Dashboard checks passed!${NC}"
echo ""
|