#!/bin/bash

# script/check: Run linting and type checking tools together
#
# Runs both type-check (Pyright) and lint-check (Ruff) in sequence.
# Recommended before committing changes.
#
# Usage:
#   ./scripts/check
#
# Examples:
#   ./scripts/check

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR/.."

# shellcheck source=scripts/.lib/output.sh
source "$SCRIPT_DIR/.lib/output.sh"

if [[ -z ${VIRTUAL_ENV:-} ]]; then
    # shellcheck source=/dev/null
    source "$HOME/.venv/bin/activate"
fi

"$SCRIPT_DIR/type-check"
echo ""
"$SCRIPT_DIR/lint-check"
echo ""

log_header "Checking sensor reference freshness..."
python3 "$SCRIPT_DIR/docs/generate-sensor-reference" --check

log_success "All checks passed"
