/** * Export Curated Documents for Production * * Exports the 22 curated public documents (with PDFs and sections) * for import into production database * * Usage: node scripts/export-for-production.js */ const { MongoClient } = require('mongodb'); const fs = require('fs').promises; const path = require('path'); // 22 curated public documents const PUBLIC_SLUGS = [ // Getting Started (6) 'introduction', 'core-concepts', 'executive-summary-tractatus-inflection-point', 'implementation-guide-v1.1', 'implementation-guide', 'implementation-guide-python-examples', // Research & Theory (7) 'tractatus-framework-research', // Working Paper v0.1 - CRITICAL 'pluralistic-values-research-foundations', 'the-27027-incident-a-case-study-in-pattern-recognition-bias', 'real-world-ai-governance-a-case-study-in-framework-failure-and-recovery', 'llm-integration-feasibility-research-scope', 'research-topic-concurrent-session-architecture', 'research-topic-rule-proliferation-transactional-overhead', // Technical Reference (5) 'technical-architecture', 'api-reference-complete', 'api-javascript-examples', 'api-python-examples', 'openapi-specification', // Advanced Topics (3) 'value-pluralism-faq', 'tractatus-ai-safety-framework-core-values-and-principles', 'organizational-theory-foundations', // Business Leadership (1) 'business-case-tractatus-framework' ]; async function run() { const client = new MongoClient('mongodb://localhost:27017'); try { await client.connect(); const db = client.db('tractatus_dev'); const collection = db.collection('documents'); console.log('═══════════════════════════════════════════════════════════'); console.log(' EXPORTING DOCUMENTS FOR PRODUCTION'); console.log('═══════════════════════════════════════════════════════════\n'); console.log(`Target documents: ${PUBLIC_SLUGS.length}\n`); const documents = []; const notFound = []; for (const slug of PUBLIC_SLUGS) { const doc = await collection.findOne({ slug }); if (!doc) { console.log(` ⚠️ NOT FOUND: ${slug}`); notFound.push(slug); continue; } // Remove MongoDB _id for clean import delete doc._id; // Ensure updated_at is set doc.updated_at = new Date(); documents.push(doc); console.log(` ✓ Exported: ${doc.title} (${doc.category}, order ${doc.order})`); } // Save to file const exportPath = path.join(__dirname, '../docs/PRODUCTION_DOCUMENTS_EXPORT.json'); await fs.writeFile(exportPath, JSON.stringify({ exported_at: new Date().toISOString(), total_documents: documents.length, documents }, null, 2)); console.log('\n═══════════════════════════════════════════════════════════'); console.log(' EXPORT SUMMARY'); console.log('═══════════════════════════════════════════════════════════\n'); console.log(` ✅ Exported: ${documents.length}`); console.log(` ⚠️ Not found: ${notFound.length}`); console.log(`\n 📄 File: ${exportPath}\n`); if (notFound.length > 0) { console.log(' Not found:'); notFound.forEach(slug => console.log(` - ${slug}`)); console.log(''); } console.log('\n Next steps:'); console.log(' 1. Review the export file'); console.log(' 2. Copy to production server:'); console.log(' scp -i ~/.ssh/tractatus_deploy docs/PRODUCTION_DOCUMENTS_EXPORT.json ubuntu@vps-93a693da.vps.ovh.net:/tmp/'); console.log(' 3. Import on production:'); console.log(' node scripts/import-from-export.js /tmp/PRODUCTION_DOCUMENTS_EXPORT.json\n'); await client.close(); process.exit(0); } catch (error) { console.error('Export error:', error); await client.close(); process.exit(1); } } run();