check-required-files.sh
1 #!/bin/sh 2 # Pre-commit hook helper: warns if new data/prompts/docs files are staged 3 # but not listed in tests/data/required-files.test.js 4 # 5 # Only checks files that match patterns the pipeline loads at runtime. 6 # Exits 0 always (warning only, never blocks commit). 7 8 MANIFEST="tests/data/required-files.test.js" 9 10 if [ ! -f "$MANIFEST" ]; then 11 exit 0 12 fi 13 14 # Patterns for runtime-critical file types (not code, not html storage) 15 # A = added, C = copied, R = renamed (destination) 16 new_files=$(git diff --cached --name-only --diff-filter=ACR -- \ 17 'data/*.json' \ 18 'data/*.csv' \ 19 'data/*.txt' \ 20 'data/compliance/*.json' \ 21 'data/franchises/*.txt' \ 22 'data/templates/**/*.json' \ 23 'prompts/*.md' \ 24 'prompts/agents/*.md' \ 25 'docs/**/*-best-practices*.md' \ 26 'db/schema.sql' \ 27 2>/dev/null) 28 29 if [ -z "$new_files" ]; then 30 exit 0 31 fi 32 33 missing="" 34 for f in $new_files; do 35 # Skip html storage (generated at runtime, not tracked in manifest) 36 case "$f" in data/html/*) continue ;; esac 37 # Skip search-volume and regions.txt (not loaded at runtime by default) 38 case "$f" in *search-volume*.csv) continue ;; esac 39 case "$f" in data/*/regions.txt) continue ;; esac 40 # Skip pricing-export.json (generated, not a dependency) 41 case "$f" in data/pricing-export.json) continue ;; esac 42 # Skip grammar reports (generated by spintax-grammar-check, not a hard dep) 43 case "$f" in *grammar-report*) continue ;; esac 44 45 if ! grep -qF "'$f'" "$MANIFEST" && ! grep -qF "\"$f\"" "$MANIFEST"; then 46 missing="$missing\n $f" 47 fi 48 done 49 50 if [ -n "$missing" ]; then 51 printf '\n\033[33m⚠ New data/prompt files not in required-files manifest:%s\033[0m\n' "$missing" 52 printf ' Add them to: %s\n\n' "$MANIFEST" 53 fi 54 55 exit 0