feat(backend): update collections, config and migration tools
Update Payload CMS configuration, collections (Audit, Posts), and add migration scripts/reports.
This commit is contained in:
40
apps/backend/scripts/migration/compare-posts.ts
Normal file
40
apps/backend/scripts/migration/compare-posts.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env tsx
|
||||
import { config as dotenvConfig } from 'dotenv'
|
||||
dotenvConfig({ path: '.env' })
|
||||
|
||||
import { parseWebflowCSV } from './csvParser'
|
||||
import { htmlToLexical } from './lexicalConverter'
|
||||
|
||||
async function main() {
|
||||
const data = await parseWebflowCSV('/Users/pukpuk/Dev/website-enchun-mgr/恩群數位行銷 - 行銷放大鏡集.csv')
|
||||
|
||||
const successPost = data.posts.find((p: any) => p.title === '正確的 hashtag 帶你上天堂')
|
||||
const failPost = data.posts.find((p: any) => p.title.includes('一點都不難'))
|
||||
|
||||
console.log('=== SUCCESSFUL POST ===')
|
||||
console.log('Title:', successPost.title)
|
||||
console.log('Content length:', successPost.content?.length)
|
||||
|
||||
const successLexical = htmlToLexical(successPost.content || '')
|
||||
const successParsed = JSON.parse(successLexical)
|
||||
console.log('Has root:', successParsed.root !== undefined)
|
||||
console.log('Root type:', successParsed.root?.type)
|
||||
console.log('Root children count:', successParsed.root?.children?.length)
|
||||
|
||||
console.log('\n=== FAILED POST ===')
|
||||
console.log('Title:', failPost.title)
|
||||
console.log('Content length:', failPost.content?.length)
|
||||
|
||||
const failLexical = htmlToLexical(failPost.content || '')
|
||||
const failParsed = JSON.parse(failLexical)
|
||||
console.log('Has root:', failParsed.root !== undefined)
|
||||
console.log('Root type:', failParsed.root?.type)
|
||||
console.log('Root children count:', failParsed.root?.children?.length)
|
||||
|
||||
// Check for any differences in structure
|
||||
console.log('\n=== STRUCTURE COMPARISON ===')
|
||||
console.log('Success first child type:', successParsed.root?.children?.[0]?.type)
|
||||
console.log('Fail first child type:', failParsed.root?.children?.[0]?.type)
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
Reference in New Issue
Block a user