beffroi-reporting/scripts/render-capture.sh

20 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Analyze a raw WinDiagnostics capture, then render its diagnostic JSON via Reportist.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
[[ $# -eq 2 ]] || { echo "Usage: $0 CAPTURE OUTPUT.pdf" >&2; exit 2; }
capture=$(realpath "$1"); output=$2
[[ -f "$capture" ]] || { echo "Missing capture: $capture" >&2; exit 1; }
stage=$(mktemp -d "${TMPDIR:-/tmp}/beffroi-capture.XXXXXXXX")
trap 'rm -rf "$stage"' EXIT
cp -- "$capture" "$stage/capture.json"
cp -- reports/plugins/diagnostics/tools/capture-info.typ "$stage/capture-info.typ"
collected=$(typst eval --root "$stage" --input capture=capture.json --in "$stage/capture-info.typ" 'query(<collected>).first().value')
collected=${collected#\"}; collected=${collected%\"}
reports/plugins/diagnostics/analyse.sh "$capture" --evidence-root "$(dirname "$capture")" \
--output "$stage/diagnostic.json" --reference-time "$collected" \
--producer-version "$(git -C reports rev-parse HEAD)" >/dev/null
reporter/render.sh "$stage/diagnostic.json" --plugin reports/plugins/diagnostics \
--plugin-input "author=${DIAGNOSTICS_AUTHOR:-Beffroi}" \
--plugin-input "theme=${DIAGNOSTICS_THEME:-default}" --output "$output"