#!/usr/bin/env bash # Validate every vuln-notif lexicon JSON document with jq. set -euo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) REPO_DIR=$(cd "$SCRIPT_DIR/.." && pwd) LEXICONS_DIR=${LEXICONS_DIR:-$REPO_DIR/lexicons} log() { printf '%s\n' "$*" >&2; } die() { printf 'error: %s\n' "$*" >&2; exit 1; } command -v jq >/dev/null 2>&1 || die "jq is required" [ -d "$LEXICONS_DIR" ] || die "lexicon directory not found: $LEXICONS_DIR" count=0 while IFS= read -r -d '' file; do jq empty "$file" || die "invalid lexicon JSON: $file" id=$(jq -r '.id // empty' "$file") if [ -z "$id" ]; then log "warning: $file has no .id" fi printf 'ok %s\n' "$file" count=$((count + 1)) done < <(find "$LEXICONS_DIR" -type f -name '*.json' -print0) [ "$count" -gt 0 ] || die "no lexicon JSON files found under $LEXICONS_DIR" printf '\nvalidated %s lexicon(s)\n' "$count" printf '\nTo serve these lexicons from the local PDS, start it with:\n' printf ' PDS_LEXICON_DIR=%q %s start\n' "$LEXICONS_DIR" "$SCRIPT_DIR/local_atproto_pds.sh" printf 'Production lexicon publishing remains an external goat/atpxrpc procedure.\n'