chore: gitignore test/databaseAdapter (#8235)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -313,3 +313,4 @@ test/admin-root/app/(payload)/admin/importMap.js
|
||||
test/app/(payload)/admin/importMap.js
|
||||
/test/app/(payload)/admin/importMap.js
|
||||
test/pnpm-lock.yaml
|
||||
test/databaseAdapter.js
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// DO NOT MODIFY. This file is automatically generated in initDevAndTest.ts
|
||||
|
||||
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
||||
|
||||
export const databaseAdapter = mongooseAdapter({
|
||||
url:
|
||||
process.env.MONGODB_MEMORY_SERVER_URI ||
|
||||
process.env.DATABASE_URI ||
|
||||
'mongodb://127.0.0.1/payloadtests',
|
||||
collation: {
|
||||
strength: 1,
|
||||
},
|
||||
})
|
||||
@@ -1,3 +1,10 @@
|
||||
import fs from 'fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
|
||||
export const allDatabaseAdapters = {
|
||||
mongodb: `
|
||||
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
||||
@@ -56,6 +63,23 @@ export const allDatabaseAdapters = {
|
||||
})`,
|
||||
}
|
||||
|
||||
export function getDatabaseAdapter(dbAdapter) {
|
||||
return allDatabaseAdapters[dbAdapter]
|
||||
/**
|
||||
* Write to databaseAdapter.ts
|
||||
*/
|
||||
export function generateDatabaseAdapter(dbAdapter) {
|
||||
const databaseAdapter = allDatabaseAdapters[dbAdapter]
|
||||
if (!databaseAdapter) {
|
||||
throw new Error(`Unknown database adapter: ${dbAdapter}`)
|
||||
}
|
||||
fs.writeFileSync(
|
||||
path.resolve(dirname, 'databaseAdapter.js'),
|
||||
`
|
||||
// DO NOT MODIFY. This file is automatically generated by the test suite.
|
||||
|
||||
${databaseAdapter}
|
||||
`,
|
||||
)
|
||||
|
||||
console.log('Wrote', dbAdapter, 'db adapter')
|
||||
return databaseAdapter
|
||||
}
|
||||
@@ -11,12 +11,20 @@ import type { SanitizedConfig } from 'payload'
|
||||
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
|
||||
let testDir: string
|
||||
|
||||
const writeDBAdapter = process.env.WRITE_DB_ADAPTER !== 'false'
|
||||
async function run() {
|
||||
if (writeDBAdapter) {
|
||||
generateDatabaseAdapter(process.env.PAYLOAD_DATABASE || 'mongodb')
|
||||
process.env.WRITE_DB_ADAPTER = 'false'
|
||||
}
|
||||
|
||||
if (testConfigDir) {
|
||||
testDir = path.resolve(dirname, testConfigDir)
|
||||
|
||||
@@ -45,6 +53,7 @@ async function run() {
|
||||
for (const suiteDir of foundDirs) {
|
||||
i++
|
||||
const pathWithConfig = path.resolve(suiteDir, 'config.ts')
|
||||
|
||||
console.log(`Generating types for config ${i} / ${foundDirs.length}:`, pathWithConfig)
|
||||
|
||||
// start a new node process which runs test/generateTypes with pathWithConfig as argument. Can't run it in this process, as there could otherwise be
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
type Query {
|
||||
Collection1(id: String!, draft: Boolean): Collection1
|
||||
Collection1s(
|
||||
draft: Boolean
|
||||
where: Collection1_where
|
||||
limit: Int
|
||||
page: Int
|
||||
sort: String
|
||||
): Collection1s
|
||||
Collection1s(draft: Boolean, where: Collection1_where, limit: Int, page: Int, sort: String): Collection1s
|
||||
countCollection1s(draft: Boolean, where: Collection1_where): countCollection1s
|
||||
docAccessCollection1(id: String!): collection1DocAccess
|
||||
Collection2(id: String!, draft: Boolean): Collection2
|
||||
Collection2s(
|
||||
draft: Boolean
|
||||
where: Collection2_where
|
||||
limit: Int
|
||||
page: Int
|
||||
sort: String
|
||||
): Collection2s
|
||||
Collection2s(draft: Boolean, where: Collection2_where, limit: Int, page: Int, sort: String): Collection2s
|
||||
countCollection2s(draft: Boolean, where: Collection2_where): countCollection2s
|
||||
docAccessCollection2(id: String!): collection2DocAccess
|
||||
User(id: String!, draft: Boolean): User
|
||||
@@ -26,20 +14,14 @@ type Query {
|
||||
meUser: usersMe
|
||||
initializedUser: Boolean
|
||||
PayloadPreference(id: String!, draft: Boolean): PayloadPreference
|
||||
PayloadPreferences(
|
||||
draft: Boolean
|
||||
where: PayloadPreference_where
|
||||
limit: Int
|
||||
page: Int
|
||||
sort: String
|
||||
): PayloadPreferences
|
||||
PayloadPreferences(draft: Boolean, where: PayloadPreference_where, limit: Int, page: Int, sort: String): PayloadPreferences
|
||||
countPayloadPreferences(draft: Boolean, where: PayloadPreference_where): countPayloadPreferences
|
||||
docAccessPayloadPreference(id: String!): payload_preferencesDocAccess
|
||||
Access: Access
|
||||
}
|
||||
|
||||
type Collection1 {
|
||||
id: String
|
||||
id: String!
|
||||
testing: String!
|
||||
title: String!
|
||||
meta: [SharedMetaArray!]
|
||||
@@ -459,8 +441,7 @@ type Collection1CreateDocAccess {
|
||||
"""
|
||||
The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
|
||||
"""
|
||||
scalar JSONObject
|
||||
@specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||
scalar JSONObject @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||
|
||||
type Collection1ReadDocAccess {
|
||||
permission: Boolean!
|
||||
@@ -478,7 +459,7 @@ type Collection1DeleteDocAccess {
|
||||
}
|
||||
|
||||
type Collection2 {
|
||||
id: String
|
||||
id: String!
|
||||
metaArray: [SharedMetaArray!]
|
||||
metaGroup: SharedMeta
|
||||
nestedGroup: Collection2_NestedGroup
|
||||
@@ -1028,7 +1009,7 @@ type Collection2DeleteDocAccess {
|
||||
}
|
||||
|
||||
type User {
|
||||
id: String
|
||||
id: String!
|
||||
updatedAt: DateTime
|
||||
createdAt: DateTime
|
||||
email: EmailAddress!
|
||||
@@ -1044,8 +1025,7 @@ type User {
|
||||
"""
|
||||
A field whose value conforms to the standard internet email address format as specified in HTML Spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address.
|
||||
"""
|
||||
scalar EmailAddress
|
||||
@specifiedBy(url: "https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address")
|
||||
scalar EmailAddress @specifiedBy(url: "https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address")
|
||||
|
||||
type Users {
|
||||
docs: [User]
|
||||
@@ -1271,12 +1251,13 @@ type UsersUnlockDocAccess {
|
||||
type usersMe {
|
||||
collection: String
|
||||
exp: Int
|
||||
strategy: String
|
||||
token: String
|
||||
user: User
|
||||
}
|
||||
|
||||
type PayloadPreference {
|
||||
id: String
|
||||
id: String!
|
||||
user: PayloadPreference_User_Relationship!
|
||||
key: String
|
||||
value: JSON
|
||||
@@ -1298,8 +1279,7 @@ union PayloadPreference_User = User
|
||||
"""
|
||||
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
|
||||
"""
|
||||
scalar JSON
|
||||
@specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||
scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||
|
||||
type PayloadPreferences {
|
||||
docs: [PayloadPreference]
|
||||
@@ -2470,40 +2450,25 @@ type PayloadPreferencesDeleteAccess {
|
||||
|
||||
type Mutation {
|
||||
createCollection1(data: mutationCollection1Input!, draft: Boolean): Collection1
|
||||
updateCollection1(
|
||||
id: String!
|
||||
autosave: Boolean
|
||||
data: mutationCollection1UpdateInput!
|
||||
draft: Boolean
|
||||
): Collection1
|
||||
updateCollection1(id: String!, autosave: Boolean, data: mutationCollection1UpdateInput!, draft: Boolean): Collection1
|
||||
deleteCollection1(id: String!): Collection1
|
||||
duplicateCollection1(id: String!): Collection1
|
||||
createCollection2(data: mutationCollection2Input!, draft: Boolean): Collection2
|
||||
updateCollection2(
|
||||
id: String!
|
||||
autosave: Boolean
|
||||
data: mutationCollection2UpdateInput!
|
||||
draft: Boolean
|
||||
): Collection2
|
||||
updateCollection2(id: String!, autosave: Boolean, data: mutationCollection2UpdateInput!, draft: Boolean): Collection2
|
||||
deleteCollection2(id: String!): Collection2
|
||||
duplicateCollection2(id: String!): Collection2
|
||||
createUser(data: mutationUserInput!, draft: Boolean): User
|
||||
updateUser(id: String!, autosave: Boolean, data: mutationUserUpdateInput!, draft: Boolean): User
|
||||
deleteUser(id: String!): User
|
||||
refreshTokenUser(token: String): usersRefreshedUser
|
||||
refreshTokenUser: usersRefreshedUser
|
||||
logoutUser: String
|
||||
unlockUser(email: String!): Boolean!
|
||||
loginUser(email: String, password: String): usersLoginResult
|
||||
forgotPasswordUser(disableEmail: Boolean, email: String!, expiration: Int): Boolean!
|
||||
loginUser(email: String!, password: String): usersLoginResult
|
||||
forgotPasswordUser(disableEmail: Boolean, expiration: Int, email: String!): Boolean!
|
||||
resetPasswordUser(password: String, token: String): usersResetPassword
|
||||
verifyEmailUser(token: String): Boolean
|
||||
createPayloadPreference(data: mutationPayloadPreferenceInput!, draft: Boolean): PayloadPreference
|
||||
updatePayloadPreference(
|
||||
id: String!
|
||||
autosave: Boolean
|
||||
data: mutationPayloadPreferenceUpdateInput!
|
||||
draft: Boolean
|
||||
): PayloadPreference
|
||||
updatePayloadPreference(id: String!, autosave: Boolean, data: mutationPayloadPreferenceUpdateInput!, draft: Boolean): PayloadPreference
|
||||
deletePayloadPreference(id: String!): PayloadPreference
|
||||
duplicatePayloadPreference(id: String!): PayloadPreference
|
||||
}
|
||||
@@ -2623,6 +2588,7 @@ input mutationUserUpdateInput {
|
||||
type usersRefreshedUser {
|
||||
exp: Int
|
||||
refreshedToken: String
|
||||
strategy: String
|
||||
user: usersJWT
|
||||
}
|
||||
|
||||
@@ -2674,4 +2640,4 @@ input PayloadPreferenceUpdate_UserRelationshipInput {
|
||||
|
||||
enum PayloadPreferenceUpdate_UserRelationshipInputRelationTo {
|
||||
users
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import fs from 'fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
import { type SanitizedConfig, generateImportMap } from 'payload'
|
||||
import { generateImportMap, type SanitizedConfig } from 'payload'
|
||||
|
||||
import type { allDatabaseAdapters } from './getDatabaseAdapter.js'
|
||||
import type { allDatabaseAdapters } from './generateDatabaseAdapter.js'
|
||||
|
||||
import { getDatabaseAdapter } from './getDatabaseAdapter.js'
|
||||
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||
import { getNextRootDir } from './helpers/getNextRootDir.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
@@ -32,21 +32,7 @@ export async function initDevAndTest(
|
||||
if (writeDBAdapter === 'true') {
|
||||
const dbAdapter: keyof typeof allDatabaseAdapters =
|
||||
(process.env.PAYLOAD_DATABASE as keyof typeof allDatabaseAdapters) || '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')
|
||||
generateDatabaseAdapter(dbAdapter)
|
||||
}
|
||||
|
||||
if (skipGenImportMap === 'true') {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import fs from 'fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { getDatabaseAdapter } from './getDatabaseAdapter.js'
|
||||
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||
|
||||
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
@@ -11,22 +8,6 @@ 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')
|
||||
generateDatabaseAdapter(dbAdapter)
|
||||
|
||||
Reference in New Issue
Block a user