Security: - Add authentication to /api/documents/archived endpoint (admin-only) - Prevent public exposure of 108 archived/internal documents Documentation UI: - Remove duplicate hardcoded Resources section from docs.html - Add Resources category to docs-app.js for implementation guides - Move 3 implementation guides from Getting Started to Resources - Move Glossary from Technical Reference to Getting Started - Set Research & Theory section to collapsed by default - Update service worker cache version to 0.1.4 Migration Scripts: - Add scripts for document category reorganization - Add scripts for research document migration to production - Add scripts for glossary verification and comparison Files changed: - public/docs.html: Remove duplicate Resources section - public/js/docs-app.js: Add Resources category, collapse Research - public/service-worker.js: Bump cache to v0.1.4 - src/routes/documents.routes.js: Secure /archived endpoint - scripts/*: Add 10 migration/diagnostic scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
75 lines
2.9 KiB
JavaScript
75 lines
2.9 KiB
JavaScript
/**
|
|
* Migrate tractatus-framework-research from dev to production
|
|
*/
|
|
const { MongoClient } = require('mongodb');
|
|
require('dotenv').config({ path: '/var/www/tractatus/.env' });
|
|
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017';
|
|
|
|
async function run() {
|
|
// Connect to dev
|
|
const devClient = new MongoClient('mongodb://localhost:27017');
|
|
await devClient.connect();
|
|
const devDb = devClient.db('tractatus_dev');
|
|
|
|
// Connect to prod
|
|
const prodClient = new MongoClient(MONGODB_URI);
|
|
await prodClient.connect();
|
|
const prodDb = prodClient.db(process.env.MONGODB_DB || 'tractatus_prod');
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(' MIGRATING tractatus-framework-research TO PRODUCTION');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
// Get document from dev
|
|
const devDoc = await devDb.collection('documents').findOne({ slug: 'tractatus-framework-research' });
|
|
|
|
if (!devDoc) {
|
|
console.log('❌ Document not found in dev database');
|
|
await devClient.close();
|
|
await prodClient.close();
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`📄 Found in dev: ${devDoc.title}`);
|
|
console.log(` Sections: ${devDoc.sections?.length || 0}`);
|
|
console.log(` Category: ${devDoc.category}`);
|
|
|
|
// Check if already exists in prod
|
|
const prodDoc = await prodDb.collection('documents').findOne({ slug: 'tractatus-framework-research' });
|
|
|
|
if (prodDoc) {
|
|
console.log('⚠️ Document already exists in production - updating instead...');
|
|
|
|
await prodDb.collection('documents').replaceOne(
|
|
{ slug: 'tractatus-framework-research' },
|
|
devDoc
|
|
);
|
|
|
|
console.log('✅ Document updated in production');
|
|
} else {
|
|
console.log('📝 Inserting new document into production...');
|
|
|
|
// Remove _id to let MongoDB generate a new one
|
|
delete devDoc._id;
|
|
|
|
// Ensure correct metadata
|
|
devDoc.category = 'research-theory';
|
|
devDoc.order = 2;
|
|
devDoc.visibility = 'public';
|
|
devDoc.updated_at = new Date();
|
|
|
|
await prodDb.collection('documents').insertOne(devDoc);
|
|
|
|
console.log('✅ Document inserted into production');
|
|
}
|
|
|
|
await devClient.close();
|
|
await prodClient.close();
|
|
|
|
console.log('\n═══════════════════════════════════════════════════════════');
|
|
console.log(' MIGRATION COMPLETE');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
}
|
|
|
|
run().catch(console.error);
|