48 lines
1.5 KiB
Bash
Executable File
48 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
usage() {
|
|
echo "Usage: $0 NEW_OUTPUT_ROOT [--include-json]" >&2
|
|
exit 2
|
|
}
|
|
|
|
output_root=${1:-}
|
|
[[ -n "$output_root" ]] || usage
|
|
shift
|
|
|
|
include_json=false
|
|
while (($#)); do
|
|
case $1 in
|
|
--include-json) include_json=true ;;
|
|
*) usage ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[[ ! -e "$output_root" ]]||{ echo "$output_root: output root already exists" >&2; exit 1; }
|
|
mkdir -p "$output_root/reports" "$output_root/diagnostics"
|
|
|
|
reporter/tools/validate-all.sh reports/reports
|
|
reporter/tools/render-all.sh reports/reports --output-dir "$output_root/reports/pdfs"
|
|
count=0
|
|
while IFS= read -r -d '' source; do
|
|
relative=${source#reports/diagnostics/}
|
|
output="$output_root/diagnostics/${relative%.json}.pdf"
|
|
mkdir -p "$(dirname "$output")"
|
|
scripts/render-capture.sh "$source" "$output"
|
|
((count += 1))
|
|
done < <(find reports/diagnostics -type f -name '*.json' -print0 | sort -z)
|
|
((count > 0)) || { echo 'No diagnostic captures found' >&2; exit 1; }
|
|
echo "Rendered $count diagnostic PDFs into $output_root/diagnostics"
|
|
|
|
if [[ "$include_json" == true ]]; then
|
|
reporter/tools/export-json-all.sh reports/reports --output-dir "$output_root/reports/pdfs"
|
|
while IFS= read -r -d '' source; do
|
|
relative=${source#reports/diagnostics/}
|
|
mkdir -p "$output_root/diagnostics/$(dirname "$relative")"
|
|
cp "$source" "$output_root/diagnostics/$relative"
|
|
done < <(find reports/diagnostics -type f -name '*.json' -print0)
|
|
fi
|
|
|
|
echo "Built publishable reports under $output_root"
|