Files
website-enchun-mgr/apps/backend/scripts/migration/deep-compare.ts
pkupuk be7fc902fb feat(backend): update collections, config and migration tools
Update Payload CMS configuration, collections (Audit, Posts), and add migration scripts/reports.
2026-02-11 11:50:23 +08:00

53 lines
2.1 KiB
TypeScript

#!/usr/bin/env tsx
import { config as dotenvConfig } from 'dotenv'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const envPath = resolve(__dirname, '../../.env')
dotenvConfig({ path: envPath })
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('一點都不難'))
const successLexical = htmlToLexical(successPost.content || '')
const failLexical = htmlToLexical(failPost.content || '')
const successParsed = JSON.parse(successLexical)
const failParsed = JSON.parse(failLexical)
// Check the actual content structure
console.log('=== SUCCESSFUL POST FIRST PARAGRAPH ===')
console.log(JSON.stringify(successParsed.root?.children?.[0], null, 2))
console.log('\n=== FAILED POST FIRST PARAGRAPH ===')
console.log(JSON.stringify(failParsed.root?.children?.[0], null, 2))
// Look for differences in text node properties
console.log('\n=== TEXT NODE COMPARISON ===')
const successTextNode = successParsed.root?.children?.[0]?.children?.[0]
const failTextNode = failParsed.root?.children?.[0]?.children?.[0]
console.log('Success text node:', successTextNode)
console.log('Fail text node:', failTextNode)
// Check for format or detail properties
console.log('\n=== PROPERTY CHECK ===')
console.log('Success has format:', successTextNode?.format !== undefined)
console.log('Fail has format:', failTextNode?.format !== undefined)
console.log('Success has detail:', successTextNode?.detail !== undefined)
console.log('Fail has detail:', failTextNode?.detail !== undefined)
console.log('Success has mode:', successTextNode?.mode !== undefined)
console.log('Fail has mode:', failTextNode?.mode !== undefined)
}
main().catch(console.error)