#!/usr/bin/env sh
set -eu
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
cd "$ROOT"

find app bootstrap config database routes tests -name '*.php' -print0 \
  | xargs -0 -n1 php -l >/tmp/digital-dossier-php-lint.txt
node --check public/js/pdf-region-editor.js
sh -n scripts/vendor-pdfjs.sh

test -f database/migrations/2026_08_06_000600_create_pdf_forms_editor_tables.php
test -f resources/views/pdf-forms/edit.blade.php
test -f public/css/pdf-region-editor.css
test -f public/js/pdf-region-editor.js

grep -q "module:pdf_forms" routes/web.php
grep -q "lockForUpdate" app/Http/Controllers/PdfTemplateEditorController.php
grep -q "PDFJS_VERSION" public/js/pdf-region-editor.js

printf 'Validação estática concluída: %s ficheiros PHP e JavaScript válido.\n' "$(find app bootstrap config database routes tests -name '*.php' | wc -l | tr -d ' ')"
