import { sqliteAdapter } from '@payloadcms/db-sqlite' import { lexicalEditor } from '@payloadcms/richtext-lexical' import path from 'path' import { buildConfig } from 'payload' import { billingPlugin } from '../dist/index.js' import sharp from 'sharp' import { fileURLToPath } from 'url' import { testEmailAdapter } from './helpers/testEmailAdapter' import { seed } from './seed' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) if (!process.env.ROOT_DIR) { process.env.ROOT_DIR = dirname } const buildConfigWithSQLite = () => { return buildConfig({ admin: { importMap: { baseDir: path.resolve(dirname), }, }, collections: [ { slug: 'posts', fields: [], }, { slug: 'media', fields: [], upload: { staticDir: path.resolve(dirname, 'media'), }, }, ], db: sqliteAdapter({ client: { url: `file:${path.resolve(dirname, 'payload.sqlite')}`, }, }), editor: lexicalEditor(), email: testEmailAdapter, onInit: async (payload) => { await seed(payload) }, plugins: [ billingPlugin({ providers: { test: { enabled: true, autoComplete: true, } }, collections: { payments: 'payments', customers: 'customers', invoices: 'invoices', refunds: 'refunds', // customerRelation: false, // Set to false to disable customer relationship in invoices // customerRelation: 'clients', // Or set to a custom collection slug } }), ], secret: process.env.PAYLOAD_SECRET || 'test-secret_key', sharp, typescript: { outputFile: path.resolve(dirname, 'payload-types.ts'), }, }) } export default buildConfigWithSQLite()