Files
Benjamin Admin 306886a42b Phase 8: CSV + ICS export, print view, MkDocs docs, SBOM + dev-mode auth
Auth (Test-Mode):
  - middleware.AuthMiddleware now takes a devMode flag. In dev,
    requests without Authorization fall back to a deterministic dev
    UUID (00000000-...-001) and role=teacher. ENVIRONMENT=production
    re-enables the strict 401 path.
  - main.go wires devMode = cfg.Environment != "production".
  - page.tsx replaces the red 'Anmeldung noch nicht integriert' banner
    with a softer Testumgebung notice; the manual-token form moves
    behind a nested details block.

Export endpoints (school-service):
  - LoadExportLessons joins tt_lesson with tt_period for wall-clock
    times; one query feeds both CSV and ICS.
  - WriteCSV streams 10 columns including pinned flag.
  - WriteICS emits one VEVENT per lesson anchored to a Monday — caller
    overridable via ?start=YYYY-MM-DD. RFC 5545 escapes for ',', ';',
    '\n' in icsEscape().
  - NextMonday helper for the default anchor.
  - GET /timetable/solutions/:id/export.{csv,ics} handlers attach
    Content-Disposition: attachment so browsers download instead of
    rendering.

Frontend:
  - lib/stundenplan/api.ts downloadSolutionExport() fetches as blob,
    triggers a synthetic <a download> click, and forwards the JWT when
    present.
  - PlanView gains CSV / ICS / Drucken buttons next to the perspective
    selector. The toolbar carries class 'no-print' so window.print()
    yields only the grid.
  - globals.css @media print rule hides chrome, forces white
    background, gives the table proper borders for A4.

Docs:
  - docs-src/services/stundenplan/{index,architecture,constraints,
    solver-tuning,export}.md with nav entry in mkdocs.yml under
    Services → Stundenplaner.
  - sbom/stundenplan/README.md lists manually-verified key dependencies
    and the policy reference. scripts/stundenplan-sbom.sh generates
    full machine-readable inventories via go-licenses + pip-licenses
    + license-checker when those tools are available.

Tests:
  - internal/services/timetable_exports_test.go: 4 unit tests covering
    CSV column layout + quoting, ICS structure + DTSTART formatting,
    icsEscape special chars, NextMonday weekday math.
  - studio-v2/e2e/stundenplan-export.spec.ts split out of the main spec
    file (LOC budget) — 3 tests for button render, CSV download,
    ICS download.
  - mockSchoolApi extended with export.csv + export.ics routes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 08:57:07 +02:00

61 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Generate a Software Bill of Materials for the Stundenplan stack.
#
# Per Open-Source-Policy (.claude/rules/open-source-policy.md) we need a
# license inventory for every shipped artifact. This script collects all
# three flavours into sbom/stundenplan/ as JSON/CSV/Markdown.
#
# Usage: bash scripts/stundenplan-sbom.sh
#
# Tools required (skipped with warning if missing):
# - go-licenses (Go) go install github.com/google/go-licenses@latest
# - pip-licenses (Python) pip install pip-licenses
# - license-checker (Node) already in studio-v2/node_modules
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="$ROOT/sbom/stundenplan"
mkdir -p "$OUT"
# --------- Go: school-service ---------
echo "==> school-service (Go)"
if command -v go-licenses >/dev/null 2>&1; then
( cd "$ROOT/school-service" \
&& go-licenses csv ./... > "$OUT/school-service-licenses.csv" 2> "$OUT/school-service-warnings.log" \
|| echo " go-licenses returned non-zero (see warnings.log)" )
else
echo " skipped — install with: go install github.com/google/go-licenses@latest"
fi
# --------- Python: timetable-solver-service ---------
echo "==> timetable-solver-service (Python)"
if [[ -d "$ROOT/timetable-solver-service" ]]; then
if command -v pip-licenses >/dev/null 2>&1; then
# Resolve against the requirements.txt the Dockerfile installs.
pip install --quiet --no-deps -r "$ROOT/timetable-solver-service/requirements.txt" \
--target "$OUT/.python-tmp" 2>/dev/null || true
PYTHONPATH="$OUT/.python-tmp" pip-licenses --format=json \
> "$OUT/timetable-solver-licenses.json" 2> "$OUT/timetable-solver-warnings.log" \
|| echo " pip-licenses returned non-zero"
rm -rf "$OUT/.python-tmp"
else
echo " skipped — install with: pip install pip-licenses"
fi
fi
# --------- Node: studio-v2 (subset that ships in the bundle) ---------
echo "==> studio-v2 (Node)"
if [[ -d "$ROOT/studio-v2/node_modules" ]]; then
( cd "$ROOT/studio-v2" \
&& ./node_modules/.bin/license-checker --json --production \
> "$OUT/studio-v2-licenses.json" 2> "$OUT/studio-v2-warnings.log" \
|| echo " license-checker returned non-zero" )
else
echo " studio-v2/node_modules missing — run npm install first"
fi
# --------- Summary ---------
echo
echo "SBOM written to $OUT"
ls -la "$OUT"