#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" log() { printf '[validate-all] %s\n' "$1" } run_if_present() { local cmd="$1" if command -v ${cmd%% *} >/dev/null 2>&1; then eval "$cmd" return 0 fi return 1 } log "root: $ROOT_DIR" cd "$ROOT_DIR" log "Step 1/5: frontend dependency check" if [[ ! -d "frontend/node_modules" ]]; then log "frontend/node_modules missing; install with: cd frontend && npm install" fi log "Step 2/5: frontend lint" if [[ -f "frontend/package.json" ]]; then ( cd frontend if npm run -s lint; then log "frontend lint: OK" else log "frontend lint failed" exit 1 fi ) else log "frontend/package.json not found; skipping" fi log "Step 3/5: frontend build" if [[ -f "frontend/package.json" ]]; then ( cd frontend if npm run -s build; then log "frontend build: OK" else log "frontend build failed" exit 1 fi ) fi log "Step 4/5: backend syntax check" PY="" for p in \ "$ROOT_DIR/.venv312/bin/python3.12" \ "$ROOT_DIR/.venv312/bin/python" \ "$ROOT_DIR/.venv/bin/python3" \ "$ROOT_DIR/.venv/bin/python" \ "$ROOT_DIR/venv/bin/python3" \ "$ROOT_DIR/venv/bin/python"; do if [[ -x "$p" ]]; then PY="$p" break fi done if [[ -n "$PY" ]]; then log "using python: $PY" "$PY" -m py_compile "$ROOT_DIR/backend/main.py" "$ROOT_DIR/backend/routers/export.py" log "backend syntax check: OK" else log "no project python found (.venv312/.venv/venv); skipping backend syntax check" fi log "Step 5/5: backend health import smoke" if [[ -n "$PY" ]]; then "$PY" - <<'PYCODE' import importlib mods = [ "backend.main", "backend.routers.export", "backend.services.video_editor", ] for m in mods: importlib.import_module(m) print("backend import smoke: OK") PYCODE fi log "Validation complete"