Compare commits
22 Commits
v0.5.0-bet
...
v0.5.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1d1a00d4a | ||
|
|
ae68093f35 | ||
|
|
0f2f355a01 | ||
|
|
0101aa60d9 | ||
|
|
c823ee07cd | ||
|
|
1f12f9b480 | ||
|
|
ec31ab3a2c | ||
|
|
a7bea35d69 | ||
|
|
64a4f19539 | ||
|
|
c35661e16e | ||
|
|
69b6179521 | ||
|
|
3d2e167e78 | ||
|
|
aa1955221c | ||
|
|
7a9b11e2c4 | ||
|
|
a82c0d0e50 | ||
|
|
35a6daa10d | ||
|
|
bf5db4e44a | ||
|
|
a87e8aa82b | ||
|
|
e00d87a791 | ||
|
|
b61babca73 | ||
|
|
e403a0492e | ||
|
|
54a76e1401 |
@@ -37,7 +37,7 @@
|
||||
"prompts": "^2.4.2",
|
||||
"terminal-link": "^2.1.1"
|
||||
},
|
||||
"version": "0.5.0-beta.0",
|
||||
"version": "0.5.0-beta.5",
|
||||
"devDependencies": {
|
||||
"@types/command-exists": "^1.2.0",
|
||||
"@types/degit": "^2.8.3",
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from 'path'
|
||||
|
||||
import type { DbDetails } from '../types'
|
||||
import { warning } from '../utils/log'
|
||||
import { bundlerPackages, dbPackages } from './packages'
|
||||
import { bundlerPackages, dbPackages, editorPackages } from './packages'
|
||||
|
||||
/** Update payload config with necessary imports and adapters */
|
||||
export async function configurePayloadConfig(args: {
|
||||
@@ -19,11 +19,16 @@ export async function configurePayloadConfig(args: {
|
||||
try {
|
||||
const packageObj = await fse.readJson(packageJsonPath)
|
||||
|
||||
// TODO: Likely revert this once we go to latest
|
||||
packageObj.dependencies['payload'] = 'beta'
|
||||
|
||||
const dbPackage = dbPackages[args.dbDetails.type]
|
||||
const bundlerPackage = bundlerPackages['webpack']
|
||||
const editorPackage = editorPackages['lexical']
|
||||
|
||||
packageObj.dependencies[dbPackage.packageName] = 'latest'
|
||||
packageObj.dependencies[bundlerPackage.packageName] = 'latest'
|
||||
packageObj.dependencies[dbPackage.packageName] = 'beta'
|
||||
packageObj.dependencies[bundlerPackage.packageName] = 'beta'
|
||||
packageObj.dependencies[editorPackage.packageName] = 'beta'
|
||||
|
||||
await fse.writeJson(packageJsonPath, packageObj, { spaces: 2 })
|
||||
} catch (err: unknown) {
|
||||
@@ -54,6 +59,7 @@ export async function configurePayloadConfig(args: {
|
||||
|
||||
const dbReplacement = dbPackages[args.dbDetails.type]
|
||||
const bundlerReplacement = bundlerPackages['webpack']
|
||||
const editorReplacement = editorPackages['lexical']
|
||||
|
||||
let dbConfigStartLineIndex: number | undefined
|
||||
let dbConfigEndLineIndex: number | undefined
|
||||
@@ -70,6 +76,14 @@ export async function configurePayloadConfig(args: {
|
||||
configLines[i] = bundlerReplacement.configReplacement
|
||||
}
|
||||
|
||||
if (l.includes('// editor-import')) {
|
||||
configLines[i] = editorReplacement.importReplacement
|
||||
}
|
||||
|
||||
if (l.includes('// editor-config')) {
|
||||
configLines[i] = editorReplacement.configReplacement
|
||||
}
|
||||
|
||||
if (l.includes('// database-adapter-config-start')) {
|
||||
dbConfigStartLineIndex = i
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BundlerType, DbType } from '../types'
|
||||
import type { BundlerType, DbType, EditorType } from '../types'
|
||||
|
||||
type DbAdapterReplacement = {
|
||||
packageName: string
|
||||
@@ -12,6 +12,12 @@ type BundlerReplacement = {
|
||||
configReplacement: string
|
||||
}
|
||||
|
||||
type EditorReplacement = {
|
||||
packageName: string
|
||||
importReplacement: string
|
||||
configReplacement: string
|
||||
}
|
||||
|
||||
const mongodbReplacement: DbAdapterReplacement = {
|
||||
packageName: '@payloadcms/db-mongodb',
|
||||
importReplacement: "import { mongooseAdapter } from '@payloadcms/db-mongodb'",
|
||||
@@ -23,12 +29,12 @@ const mongodbReplacement: DbAdapterReplacement = {
|
||||
],
|
||||
}
|
||||
|
||||
const postgresqlReplacement: DbAdapterReplacement = {
|
||||
packageName: '@payloadcms/db-postgresql',
|
||||
importReplacement: "import { postgresqlAdapter } from '@payloadcms/db-postgresql'",
|
||||
const postgresReplacement: DbAdapterReplacement = {
|
||||
packageName: '@payloadcms/db-postgres',
|
||||
importReplacement: "import { postgresAdapter } from '@payloadcms/db-postgres'",
|
||||
configReplacement: [
|
||||
' db: postgresqlAdapter({',
|
||||
' client: {',
|
||||
' db: postgresAdapter({',
|
||||
' pool: {',
|
||||
' connectionString: process.env.DATABASE_URI,',
|
||||
' },',
|
||||
' }),',
|
||||
@@ -37,7 +43,7 @@ const postgresqlReplacement: DbAdapterReplacement = {
|
||||
|
||||
export const dbPackages: Record<DbType, DbAdapterReplacement> = {
|
||||
mongodb: mongodbReplacement,
|
||||
postgres: postgresqlReplacement,
|
||||
postgres: postgresReplacement,
|
||||
}
|
||||
|
||||
const webpackReplacement: BundlerReplacement = {
|
||||
@@ -57,3 +63,17 @@ export const bundlerPackages: Record<BundlerType, BundlerReplacement> = {
|
||||
webpack: webpackReplacement,
|
||||
vite: viteReplacement,
|
||||
}
|
||||
|
||||
export const editorPackages: Record<EditorType, EditorReplacement> = {
|
||||
slate: {
|
||||
packageName: '@payloadcms/richtext-slate',
|
||||
importReplacement: "import { slateEditor } from '@payloadcms/richtext-slate'",
|
||||
configReplacement: ' editor: slateEditor({}),',
|
||||
},
|
||||
lexical: {
|
||||
packageName: '@payloadcms/richtext-lexical',
|
||||
importReplacement:
|
||||
"import { lexicalEditor } from '@payloadcms/richtext-lexical'",
|
||||
configReplacement: ' editor: lexicalEditor({}),',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const dbChoiceRecord: Record<DbType, DbChoice> = {
|
||||
},
|
||||
postgres: {
|
||||
value: 'postgres',
|
||||
title: 'PostgreSQL',
|
||||
title: 'PostgreSQL (beta)',
|
||||
dbConnectionPrefix: 'postgres://127.0.0.1:5432/',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -55,3 +55,4 @@ export type DbDetails = {
|
||||
}
|
||||
|
||||
export type BundlerType = 'webpack' | 'vite'
|
||||
export type EditorType = 'lexical' | 'slate'
|
||||
|
||||
Reference in New Issue
Block a user