CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Waiting to run
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Blocked by required conditions
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Blocked by required conditions
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Waiting to run
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Blocked by required conditions
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Blocked by required conditions
Slug-based collection mirroring LegalPageContent (proto/src/content/ types.ts) for the two legal pages (adatvedelem, hasznalati-feltetelek). - src/collections/LegalPages.ts: slug (unique), title, lastUpdated, sections[] (id/title/content). `content` stays a plain textarea, not lexical richText — the current frontend (src/app/(frontend)/adatvedelem/page.tsx) renders it through a hand-rolled "•"/"**bold**" regex converter, not a real Markdown/ richText parser, matching the same bootstrap-scope call made for Contact.gdpr.label in MITHOME-87. - Registered in payload.config.ts. - migrate-content-to-payload.ts: added an idempotent upsertLegalPage helper (find-by-slug, then update or create — Collections don't have Globals' fixed-slug updateGlobal) and seeded both legal pages from their existing JSON. Verified: migration run twice against the real dev MongoDB produced exactly 2 documents (no duplicates) — confirmed via mongosh. Real browser: logged into /admin, Legal Pages list shows both entries with correct titles/slugs, opened the adatvedelem document and the slug/ title/body fields all show the migrated content correctly. build/lint/ tsc/test (58 passed) all clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
144 lines
4.4 KiB
TypeScript
144 lines
4.4 KiB
TypeScript
/**
|
|
* MITHOME-87/88: egyszeri migrációs script — a proto/src/content/pages/*.json
|
|
* + common.json tartalmát átemeli a Payload Globals-ekbe (Home, About,
|
|
* Services, Contact, Common) és a LegalPages collection-be a Local API-n
|
|
* keresztül.
|
|
*
|
|
* Futtatás (proto/ mappából, futó MongoDB-vel és beállított env-ekkel):
|
|
* node --env-file=.env.local --import tsx scripts/migrate-content-to-payload.ts
|
|
*
|
|
* Idempotens: updateGlobal-t / slug-alapú upsert-et hív, tetszőlegesen
|
|
* többször futtatható — mindig a JSON az aktuális "forrás igazság", felül-
|
|
* írja a Payload-ban lévő korábbi állapotot. NEM törli/nem érinti a JSON
|
|
* fájlokat.
|
|
*/
|
|
import { getPayload, type Payload } from 'payload'
|
|
import config from '../src/payload.config'
|
|
|
|
import homeJson from '../src/content/pages/home.json'
|
|
import aboutJson from '../src/content/pages/about.json'
|
|
import servicesJson from '../src/content/pages/services.json'
|
|
import contactJson from '../src/content/pages/contact.json'
|
|
import commonJson from '../src/content/common.json'
|
|
import adatvedelemJson from '../src/content/pages/adatvedelem.json'
|
|
import hasznalatiFeltetelekJson from '../src/content/pages/hasznalati-feltetelek.json'
|
|
|
|
/** string[] -> [{ value: string }] — lásd src/globals/fields/stringArray.ts */
|
|
function toStringArray(items: readonly string[]): { value: string }[] {
|
|
return items.map((value) => ({ value }))
|
|
}
|
|
|
|
function buildHomeData(json: typeof homeJson) {
|
|
const { hero, about, services, cta, serviceFeatures } = json
|
|
return {
|
|
hero: {
|
|
...hero,
|
|
trustBullets: toStringArray(hero.trustBullets),
|
|
},
|
|
about,
|
|
services: {
|
|
...services,
|
|
items: services.items.map((item) => ({
|
|
...item,
|
|
features: toStringArray(item.features),
|
|
})),
|
|
},
|
|
cta,
|
|
serviceFeatures,
|
|
}
|
|
}
|
|
|
|
function buildAboutData(json: typeof aboutJson) {
|
|
const { meta, hero, story, mission, team, cta } = json
|
|
return {
|
|
meta,
|
|
hero,
|
|
story: { ...story, paragraphs: toStringArray(story.paragraphs) },
|
|
mission,
|
|
team: { ...team, paragraphs: toStringArray(team.paragraphs) },
|
|
cta,
|
|
}
|
|
}
|
|
|
|
function buildServicesData(json: typeof servicesJson) {
|
|
const { meta, hero, details, support, cta } = json
|
|
return {
|
|
meta,
|
|
hero,
|
|
details: {
|
|
...details,
|
|
services: details.services.map((service) => ({
|
|
...service,
|
|
specs: {
|
|
...service.specs,
|
|
items: toStringArray(service.specs.items),
|
|
},
|
|
})),
|
|
},
|
|
support,
|
|
cta,
|
|
}
|
|
}
|
|
|
|
type LegalPageJson = {
|
|
title: string
|
|
lastUpdated: string
|
|
sections: { id: string; title: string; content: string }[]
|
|
}
|
|
|
|
/** Collections have no per-document "known slug" API like Globals do —
|
|
* find-by-slug, then update or create. Idempotent across re-runs. */
|
|
async function upsertLegalPage(payload: Payload, slug: string, json: LegalPageJson) {
|
|
const existing = await payload.find({
|
|
collection: 'legal-pages',
|
|
where: { slug: { equals: slug } },
|
|
limit: 1,
|
|
})
|
|
|
|
if (existing.docs.length > 0) {
|
|
await payload.update({
|
|
collection: 'legal-pages',
|
|
id: existing.docs[0].id,
|
|
data: { slug, ...json },
|
|
})
|
|
} else {
|
|
await payload.create({
|
|
collection: 'legal-pages',
|
|
data: { slug, ...json },
|
|
})
|
|
}
|
|
}
|
|
|
|
async function run() {
|
|
const payload = await getPayload({ config })
|
|
|
|
await payload.updateGlobal({ slug: 'home', data: buildHomeData(homeJson) })
|
|
payload.logger.info('Home global migrálva')
|
|
|
|
await payload.updateGlobal({ slug: 'about', data: buildAboutData(aboutJson) })
|
|
payload.logger.info('About global migrálva')
|
|
|
|
await payload.updateGlobal({ slug: 'services', data: buildServicesData(servicesJson) })
|
|
payload.logger.info('Services global migrálva')
|
|
|
|
await payload.updateGlobal({ slug: 'contact', data: contactJson })
|
|
payload.logger.info('Contact global migrálva')
|
|
|
|
await payload.updateGlobal({ slug: 'common', data: commonJson })
|
|
payload.logger.info('Common global migrálva')
|
|
|
|
await upsertLegalPage(payload, 'adatvedelem', adatvedelemJson)
|
|
payload.logger.info('LegalPages/adatvedelem migrálva')
|
|
|
|
await upsertLegalPage(payload, 'hasznalati-feltetelek', hasznalatiFeltetelekJson)
|
|
payload.logger.info('LegalPages/hasznalati-feltetelek migrálva')
|
|
|
|
payload.logger.info('MITHOME-87/88 migráció kész.')
|
|
process.exit(0)
|
|
}
|
|
|
|
run().catch((error) => {
|
|
console.error('Migráció sikertelen:', error)
|
|
process.exit(1)
|
|
})
|