tractatus/scripts/export-for-production.js
TheFlow 36c8c30108 feat(docs): documentation curation infrastructure (scripts + sidebar)
INFRASTRUCTURE COMPLETE (22 public documents from 129 total):

CATEGORY CONSOLIDATION (12 → 5):
- Eliminated chaotic category proliferation
- Defined 5 canonical categories with icons, descriptions
- Updated frontend sidebar (public/js/docs-app.js)
- Categories: getting-started, research-theory, technical-reference,
  advanced-topics, business-leadership

SCRIPTS CREATED:
- comprehensive-document-audit.js: Systematic audit of all 129 docs
- generate-public-pdfs.js: Puppeteer-based PDF generation (22 PDFs)
- migrate-documents-final.js: DB migration (22 updated, 104 archived)
- export-for-production.js: Export 22 docs for production
- import-from-export.js: Import documents to production DB
- analyze-categories.js: Category analysis tool
- prepare-public-docs.js: Document preparation validator

AUDIT RESULTS:
- docs/DOCUMENT_AUDIT_REPORT.json: Full analysis with recommendations
- 22 documents recommended for public visibility
- 104 documents to archive (internal/obsolete/poor quality)

REMAINING WORK:
- Fix inst_016/017/018 violations in 22 public documents (85 violations)
  • inst_016: Statistics need citations or [NEEDS VERIFICATION]
  • inst_017: Replace absolute assurance terms with evidence-based language
  • inst_018: Remove maturity claims or add documented evidence
- Regenerate PDFs after content fixes
- Regenerate production export file (compliant version)
- Deploy to production

Database migration already executed in dev (22 updated, 104 archived).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 21:36:54 +13:00

121 lines
4.2 KiB
JavaScript

/**
* 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();