#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

find web/app web/public -name '*.php' -print0 | xargs -0 -n1 php -l >/dev/null
find web/public/assets/js -name '*.js' -print0 | xargs -0 -n1 node --check
find orchestrator/src orchestrator/test -name '*.js' -print0 | xargs -0 -n1 node --check
python3 -m py_compile scripts/generate_assets.py
php scripts/smoke_test.php
if [ -f web/vendor/autoload.php ]; then
  (
    cd web
    php spark routes >/dev/null
  )
fi
(
  cd orchestrator
  node --test test/*.test.js
)

if command -v shellcheck >/dev/null 2>&1; then
  shellcheck scripts/*.sh
fi

echo '기본 소스 구문 검사와 독립 스모크 테스트가 완료되었습니다.'
