33 lines
883 B
JavaScript
33 lines
883 B
JavaScript
import fs from 'fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { getDatabaseAdapter } from './getDatabaseAdapter.js'
|
|
|
|
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
|
|
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
|
|
|
process.env.PAYLOAD_PUBLIC_CLOUD_STORAGE_ADAPTER = 's3'
|
|
|
|
process.env.NODE_OPTIONS = '--no-deprecation'
|
|
process.env.PAYLOAD_CI_DEPENDENCY_CHECKER = 'true'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
const dbAdapter = process.env.PAYLOAD_DATABASE || 'mongodb'
|
|
|
|
// Generate databaseAdapter.ts
|
|
const databaseAdapter = getDatabaseAdapter(dbAdapter)
|
|
|
|
// Write to databaseAdapter.ts
|
|
fs.writeFileSync(
|
|
path.resolve(dirname, 'databaseAdapter.ts'),
|
|
`
|
|
// DO NOT MODIFY. This file is automatically generated in initDevAndTest.ts
|
|
|
|
${databaseAdapter}
|
|
`,
|
|
)
|
|
|
|
console.log('Wrote', dbAdapter, 'db adapter')
|