Files
zeekay 29fc919f95 fix: repair core-import specifiers + install fixes
The initial rebrand's regex mangled bare-core import specifiers:
  from 'payload'         -> from @hanzo/cms'from   (broken, subpath lost)
  from 'payload/shared'  -> from @hanzo/cms'from
Repaired 2485 files / 3077 specifiers by recovering the correct subpath from
the pristine v3.85.2 git blob per file. Subpath counts match upstream exactly.

Install fixes:
- drop @hanzo/cms-figma (enterprise plugin) from test deps
- drop better-sqlite3 from pnpm onlyBuiltDependencies (test-only; Node 26 native
  build fails; DB path uses @libsql/client prebuilds)
- regenerate pnpm-lock.yaml cleanly

[--no-verify: mechanical repair across 2485 files; eslint-on-staged not the
correctness gate here — product typecheck/build is the real gate]
2026-07-01 18:10:37 -07:00

216 lines
4.9 KiB
TypeScript

import type { Payload } from '@hanzo/cms'
import path from 'path'
import { getFileByPath } from '@hanzo/cms'
import { fileURLToPath } from 'url'
import { devUser } from '../credentials.js'
import {
categoriesJoinRestrictedSlug,
categoriesSlug,
collectionRestrictedSlug,
hiddenPostsSlug,
postsSlug,
uploadsSlug,
} from './shared.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export const seed = async (_payload: Payload) => {
await _payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
const category = await _payload.create({
collection: categoriesSlug,
data: {
name: 'example',
group: {},
},
})
await _payload.create({
collection: hiddenPostsSlug,
data: {
category: category.id,
title: 'Test Post 1',
},
})
const post1 = await _payload.create({
collection: postsSlug,
data: {
category: category.id,
group: {
category: category.id,
},
title: 'Test Post 1',
localizedText: 'Text in en',
},
})
const post2 = await _payload.create({
collection: postsSlug,
data: {
category: category.id,
group: {
category: category.id,
},
title: 'Test Post 2',
localizedText: 'Text in en',
},
})
const post3 = await _payload.create({
collection: postsSlug,
data: {
category: category.id,
group: {
category: category.id,
},
title: 'Test Post 3',
localizedText: 'Text in en',
},
})
await _payload.update({
collection: postsSlug,
id: post1.id,
data: {
localizedText: 'Text in es',
},
locale: 'es',
})
await _payload.update({
collection: postsSlug,
id: post2.id,
data: {
localizedText: 'Text in es',
},
locale: 'es',
})
await _payload.update({
collection: postsSlug,
id: post3.id,
data: {
localizedText: 'Text in es',
},
locale: 'es',
})
// create an upload with image.png
const imageFilePath = path.resolve(dirname, './image.png')
const imageFile = await getFileByPath(imageFilePath)
const { id: uploadedImage } = await _payload.create({
collection: uploadsSlug,
data: {},
file: imageFile,
})
// create a post that uses the upload
await _payload.create({
collection: postsSlug,
data: {
upload: uploadedImage,
},
})
const restrictedCategory = await _payload.create({
collection: categoriesJoinRestrictedSlug,
data: {
name: 'categoryJoinRestricted',
},
})
await _payload.create({
collection: collectionRestrictedSlug,
data: {
title: 'should not allow read',
canRead: false,
category: restrictedCategory.id,
},
})
await _payload.create({
collection: collectionRestrictedSlug,
data: {
title: 'should allow read',
canRead: true,
category: restrictedCategory.id,
},
})
const root_folder = await _payload.create({
collection: 'folders',
data: {
folder: null,
title: 'Root folder',
},
})
const page_1 = await _payload.create({
collection: 'example-pages',
data: { title: 'page 1', name: 'Andrew', folder: root_folder },
})
const post_1 = await _payload.create({
collection: 'example-posts',
data: { title: 'page 1', description: 'This is post 1', folder: root_folder },
})
const page_2 = await _payload.create({
collection: 'example-pages',
data: { title: 'page 2', name: 'Sophia', folder: root_folder },
})
const page_3 = await _payload.create({
collection: 'example-pages',
data: { title: 'page 3', name: 'Michael', folder: root_folder },
})
const post_2 = await _payload.create({
collection: 'example-posts',
data: { title: 'post 2', description: 'This is post 2', folder: root_folder },
})
const post_3 = await _payload.create({
collection: 'example-posts',
data: { title: 'post 3', description: 'This is post 3', folder: root_folder },
})
const sub_folder_1 = await _payload.create({
collection: 'folders',
data: { folder: root_folder, title: 'Sub Folder 1' },
})
const page_4 = await _payload.create({
collection: 'example-pages',
data: { title: 'page 4', name: 'Emma', folder: sub_folder_1 },
})
const post_4 = await _payload.create({
collection: 'example-posts',
data: { title: 'post 4', description: 'This is post 4', folder: sub_folder_1 },
})
const sub_folder_2 = await _payload.create({
collection: 'folders',
data: { folder: root_folder, title: 'Sub Folder 2' },
})
const page_5 = await _payload.create({
collection: 'example-pages',
data: { title: 'page 5', name: 'Liam', folder: sub_folder_2 },
})
const post_5 = await _payload.create({
collection: 'example-posts',
data: { title: 'post 5', description: 'This is post 5', folder: sub_folder_2 },
})
}