Files
websitedev/proto/scripts/export-content-snapshot.ts
T
Do SikiandClaude Sonnet 5 12b2711168
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
chore: retire legacy custom CMS (content-editor.js) (MITHOME-93)
Removes the standalone, git-push-based content editor that predates
Payload CMS: content-editor.js, its scripts/cms-*.js modules, its
scripts/test-content-editor-*.js + scripts/test-cms-publish.js test
suite, scripts/markdown-render.js (only used by the editor's guide
renderer), the proto-side test doubles (cms-editor-client.test.ts,
cms-editor-shortcuts.test.ts), and the editor's own user guide
(docs/felhasznaloi-utmutato.md).

Kept: proto/src/content/*.json (still the source for
migrate-content-to-payload.ts and test fixtures for Header/Footer,
per MITHOME-96), proto/src/content/schema.js + scripts/test-content-schema.js
(still validate those JSON files), and docs/content-editor-recovery.md
(historical incident record, not user-facing tool docs).

Safety net before deletion (per user request): added
proto/scripts/export-content-snapshot.ts, a reusable Payload Local API
exporter, and ran it to produce docs/backups/payload-content-snapshot-*.json
— a full hu/en snapshot of every Global + LegalPages + Partners document
at the moment of retirement. Also confirmed no data-loss risk otherwise:
.content-backups/ (the editor's own gitignored backup dir) tops out at
2026-08-23, well before today's fresh migration run, and every JSON
edit ever made through the editor already exists as its own git commit
("content: frissítve a CMS-ből").

Updated dangling references: pre-deploy-tests.sh and
.agent/steering/testing.md (dropped the CMS test block),
.agent/workflows/deploy.md (publish flow is now Payload draft/publish,
not git push), CLAUDE.md + .agent/AGENTS.md (dropped the /cms-feature
workflow, deleted alongside it), README.md (stack description),
.agent/steering/development-rules.md (the guide-maintenance rule no
longer has a guide to maintain).

Verified: tsc, lint, proto unit tests (51 passed), root
test-content-schema.js, plane-sync unit tests, production build all
green after the deletion.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-11 21:48:50 +02:00

71 lines
2.6 KiB
TypeScript

/**
* MITHOME-93 biztonsági lépés: a régi egyedi CMS (content-editor.js +
* scripts/cms-*.js) eltávolítása előtt exportálja a Payload jelenlegi
* (publikált) szöveges tartalmát egy olvasható JSON fájlba — mindkét
* locale-lal (hu, en) —, hogy git-committolt, ember által is átnézhető
* biztonsági mentés maradjon a leépítés pillanatáról.
*
* NEM helyettesíti a git history-t (a src/content/*.json fájlok minden
* korábbi szerkesztése megvan commit-onként), és nem helyettesíti a
* MongoDB-t (az az élő forrás) — ez egy plusz, könnyen olvasható
* pillanatkép a "mielőtt törlünk, mentsünk" elv jegyében.
*
* Futtatás (proto/ mappából, futó MongoDB-vel és beállított env-ekkel):
* node --env-file=.env.local --import tsx scripts/export-content-snapshot.ts
*/
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { getPayload, type Payload } from 'payload'
import config from '../src/payload.config'
const scriptDir = path.dirname(fileURLToPath(import.meta.url))
const outDir = path.resolve(scriptDir, '../../docs/backups')
const GLOBAL_SLUGS = ['home', 'about', 'services', 'contact', 'common'] as const
const LOCALES = ['hu', 'en'] as const
async function exportGlobals(payload: Payload) {
const result: Record<string, Record<string, unknown>> = {}
for (const slug of GLOBAL_SLUGS) {
result[slug] = {}
for (const locale of LOCALES) {
result[slug][locale] = await payload.findGlobal({ slug, locale })
}
}
return result
}
async function exportCollection(payload: Payload, collection: 'legal-pages' | 'partners') {
const result: Record<string, unknown> = {}
for (const locale of LOCALES) {
const { docs } = await payload.find({ collection, locale, limit: 1000 })
result[locale] = docs
}
return result
}
async function run() {
const payload = await getPayload({ config })
const snapshot = {
exportedAt: new Date().toISOString(),
reason: 'MITHOME-93 — régi CMS (content-editor.js) leépítése előtti biztonsági mentés',
globals: await exportGlobals(payload),
collections: {
legalPages: await exportCollection(payload, 'legal-pages'),
partners: await exportCollection(payload, 'partners'),
},
}
fs.mkdirSync(outDir, { recursive: true })
const filename = `payload-content-snapshot-${snapshot.exportedAt.replace(/[:.]/g, '-')}.json`
const outPath = path.join(outDir, filename)
fs.writeFileSync(outPath, JSON.stringify(snapshot, null, 2), 'utf8')
payload.logger.info(`Snapshot kiírva: ${outPath}`)
process.exit(0)
}
run()