crosscode.church-export/1 with its app part, in plain terms with refs made for the export: members as people with every role, the wall's rules, commitments as rules (with skips), "I prayed" marks, campaigns, testimonies, prayer requests with their updates and moderation (who and why; the whole export is encrypted by the agent), the emergency numbers, announcements, the church's own devotionals (not Cross Code's) and simple events; uploaded images listed under uploads/. scripts/export-church.ts writes export.json for the crosscode script (app.sh comes with slice 7). A test checks the schema and that no internal id is in it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
/**
|
|
* The App's part of a church's export (`crosscode export` / uninstall, APP-1.0-PLAN §11):
|
|
* `export.json` in --out-dir (src/export/churchExport.ts). The crosscode script adds the uploaded
|
|
* images next to it (backend/uploads → uploads/), and the server agent encrypts the whole export.
|
|
*
|
|
* npx tsx scripts/export-church.ts --out-dir <dir>
|
|
*/
|
|
import 'dotenv/config';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
import { PrismaClient } from '../src/generated/prisma/client.js';
|
|
import { createCtx } from '../src/context.js';
|
|
import { buildExport } from '../src/export/churchExport.js';
|
|
import { loadConfig } from '../src/lib/config.js';
|
|
|
|
const i = process.argv.indexOf('--out-dir');
|
|
const out = i > 0 ? process.argv[i + 1] : null;
|
|
if (!out) {
|
|
console.error('Usage: export-church.ts --out-dir <dir>');
|
|
process.exit(2);
|
|
}
|
|
|
|
const db = new PrismaClient({ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }) });
|
|
const data = await buildExport(createCtx(loadConfig(), db));
|
|
fs.mkdirSync(out, { recursive: true });
|
|
fs.writeFileSync(path.join(out, 'export.json'), JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
const a = data.app!;
|
|
console.log(` export.json: ${data.people.length} people, ${a.commitments.length} commitments, ${a.prayerRequests.length} prayer requests, ${a.announcements.length} announcements, ${data.files.length} files`);
|
|
await db.$disconnect();
|