Files
dwroller/scripts/copy-bestiary-to-public.js
Alex caf8a03553 feat: Add scripts for upserting and validating bestiary data
- Implemented `upsert-allewis-from-5001.js` to fetch and update Allewis data from API.
- Created `upsert-missing-movement-from-5001.js` to fill missing movement and wounds data from API.
- Developed `upsert-missing-movement-from-pdfs.js` to extract movement and wounds from PDF text.
- Added `upsert-missing-profiles-from-pdfs.js` to fill missing profiles from PDF data.
- Introduced `upsert-missing-wounds-from-pdfs.js` to update wounds data from PDF sources.
- Created `validate-bestiary.js` to validate the structure of the bestiary JSON.
- Updated `BestiaryTab.jsx` component to display bestiary data with improved structure and search functionality.
- Added tests for `BestiaryTab` to ensure proper rendering and functionality.
2025-08-17 16:21:00 +02:00

28 lines
843 B
JavaScript

const fs = require('fs');
const path = require('path');
const repoRoot = path.resolve(__dirname, '..');
const src = path.join(repoRoot, 'database', 'deathwatch-bestiary-extracted.json');
const dst = path.join(repoRoot, 'public', 'deathwatch-bestiary-extracted.json');
if (!fs.existsSync(src)) {
console.error('Source not found:', src);
process.exit(1);
}
const data = JSON.parse(fs.readFileSync(src, 'utf8'));
if (!Array.isArray(data.results)) {
console.error('Source appears invalid, missing results array');
process.exit(1);
}
// backup dst if exists
if (fs.existsSync(dst)) {
const bak = dst + `.backup.${Date.now()}.json`;
fs.copyFileSync(dst, bak);
console.log('Backed up existing public file to', bak);
}
fs.writeFileSync(dst, JSON.stringify(data, null, 2), 'utf8');
console.log('Copied normalized bestiary to', dst);