#!/bin/bash # Regenerates everything the site reads from the analysis directory. # # The site used to hold hand-copied snapshots of books.json and friends, which drifted: # the catalogue grew to 163 books while the site still rendered 112. Nothing under # site/src/data or site/src/content/studies is authored by hand — it is all generated here, # and this runs as part of `npm run build`. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd)" python3 "$ROOT/scripts/sync_studies.py" # Articles are written for a reader, not for the record, and carry their own front matter — # so they are copied verbatim rather than normalised the way the analyses are. ART_SRC="$ROOT/analysis/articles" ART_DST="$ROOT/site/src/content/articles" mkdir -p "$ART_DST"; rm -f "$ART_DST"/*.md if [ -d "$ART_SRC" ]; then for f in "$ART_SRC"/*.md; do [ -e "$f" ] || continue rev=$(date -r "$f" +%Y-%m-%d) awk -v rev="$rev" 'NR==1&&/^---$/{print;print "revised: \"" rev "\"";next}1' "$f" > "$ART_DST/$(basename "$f")" done echo " articles: $(ls "$ART_DST" | wc -l | tr -d ' ')" fi for f in books comparisons findings summaries library hosting; do if [ -f "$ROOT/analysis/$f.json" ]; then cp "$ROOT/analysis/$f.json" "$ROOT/site/src/data/$f.json" n=$(python3 -c "import json,sys;d=json.load(open(sys.argv[1]));print(len(d) if isinstance(d,list) else len(d.get('books',d)))" "$ROOT/analysis/$f.json") echo " data/$f.json ($n records)" else echo " ! analysis/$f.json missing — site keeps its previous copy" fi done # Ship the pipeline itself. The method page describes these scripts; a reproducibility # claim with nothing attached is a claim, not an artefact. ART="$ROOT/site/public/artefacts" mkdir -p "$ART" for f in "$ROOT"/scripts/*.sh "$ROOT"/scripts/*.py; do [ -e "$f" ] || continue cp "$f" "$ART/$(basename "$f").txt" done cp "$ROOT/README.md" "$ART/README.md.txt" 2>/dev/null || true cp "$ROOT/URL-POLICY.md" "$ART/URL-POLICY.md.txt" 2>/dev/null || true cp "$ROOT/EDITORIAL-GUIDELINE.md" "$ART/EDITORIAL-GUIDELINE.md.txt" 2>/dev/null || true echo " artefacts: $(ls "$ART" | wc -l | tr -d ' ') files" echo "site data synced"