#!/usr/bin/env bash
set -euo pipefail

# Run from the repository root.
mkdir -p reports/client-sprint/evidence

npm ci
npm run test:coverage | tee reports/client-sprint/evidence/test_coverage.log

# Local SonarQube. If already running, this is harmless.
npm run sonar:up

# If your SonarQube requires auth, set SONAR_TOKEN before this command.
export SONAR_HOST_URL="${SONAR_HOST_URL:-http://localhost:9000}"
npm run sonar:scan | tee reports/client-sprint/evidence/sonar_scan.md

# Optional when SONAR_TOKEN is available:
# npm run sonar:export

node quality/client-sprint-report.mjs
