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/app/(payload)/admin/importMap.js
|
/test/app/(payload)/admin/importMap.js
|
||||||
test/pnpm-lock.yaml
|
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 = {
|
export const allDatabaseAdapters = {
|
||||||
mongodb: `
|
mongodb: `
|
||||||
import { mongooseAdapter } from '@payloadcms/db-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 { fileURLToPath } from 'url'
|
||||||
|
|
||||||
|
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
let testDir: string
|
let testDir: string
|
||||||
|
|
||||||
|
const writeDBAdapter = process.env.WRITE_DB_ADAPTER !== 'false'
|
||||||
async function run() {
|
async function run() {
|
||||||
|
if (writeDBAdapter) {
|
||||||
|
generateDatabaseAdapter(process.env.PAYLOAD_DATABASE || 'mongodb')
|
||||||
|
process.env.WRITE_DB_ADAPTER = 'false'
|
||||||
|
}
|
||||||
|
|
||||||
if (testConfigDir) {
|
if (testConfigDir) {
|
||||||
testDir = path.resolve(dirname, testConfigDir)
|
testDir = path.resolve(dirname, testConfigDir)
|
||||||
|
|
||||||
@@ -45,6 +53,7 @@ async function run() {
|
|||||||
for (const suiteDir of foundDirs) {
|
for (const suiteDir of foundDirs) {
|
||||||
i++
|
i++
|
||||||
const pathWithConfig = path.resolve(suiteDir, 'config.ts')
|
const pathWithConfig = path.resolve(suiteDir, 'config.ts')
|
||||||
|
|
||||||
console.log(`Generating types for config ${i} / ${foundDirs.length}:`, pathWithConfig)
|
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
|
// 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 {
|
type Query {
|
||||||
Collection1(id: String!, draft: Boolean): Collection1
|
Collection1(id: String!, draft: Boolean): Collection1
|
||||||
Collection1s(
|
Collection1s(draft: Boolean, where: Collection1_where, limit: Int, page: Int, sort: String): Collection1s
|
||||||
draft: Boolean
|
|
||||||
where: Collection1_where
|
|
||||||
limit: Int
|
|
||||||
page: Int
|
|
||||||
sort: String
|
|
||||||
): Collection1s
|
|
||||||
countCollection1s(draft: Boolean, where: Collection1_where): countCollection1s
|
countCollection1s(draft: Boolean, where: Collection1_where): countCollection1s
|
||||||
docAccessCollection1(id: String!): collection1DocAccess
|
docAccessCollection1(id: String!): collection1DocAccess
|
||||||
Collection2(id: String!, draft: Boolean): Collection2
|
Collection2(id: String!, draft: Boolean): Collection2
|
||||||
Collection2s(
|
Collection2s(draft: Boolean, where: Collection2_where, limit: Int, page: Int, sort: String): Collection2s
|
||||||
draft: Boolean
|
|
||||||
where: Collection2_where
|
|
||||||
limit: Int
|
|
||||||
page: Int
|
|
||||||
sort: String
|
|
||||||
): Collection2s
|
|
||||||
countCollection2s(draft: Boolean, where: Collection2_where): countCollection2s
|
countCollection2s(draft: Boolean, where: Collection2_where): countCollection2s
|
||||||
docAccessCollection2(id: String!): collection2DocAccess
|
docAccessCollection2(id: String!): collection2DocAccess
|
||||||
User(id: String!, draft: Boolean): User
|
User(id: String!, draft: Boolean): User
|
||||||
@@ -26,20 +14,14 @@ type Query {
|
|||||||
meUser: usersMe
|
meUser: usersMe
|
||||||
initializedUser: Boolean
|
initializedUser: Boolean
|
||||||
PayloadPreference(id: String!, draft: Boolean): PayloadPreference
|
PayloadPreference(id: String!, draft: Boolean): PayloadPreference
|
||||||
PayloadPreferences(
|
PayloadPreferences(draft: Boolean, where: PayloadPreference_where, limit: Int, page: Int, sort: String): PayloadPreferences
|
||||||
draft: Boolean
|
|
||||||
where: PayloadPreference_where
|
|
||||||
limit: Int
|
|
||||||
page: Int
|
|
||||||
sort: String
|
|
||||||
): PayloadPreferences
|
|
||||||
countPayloadPreferences(draft: Boolean, where: PayloadPreference_where): countPayloadPreferences
|
countPayloadPreferences(draft: Boolean, where: PayloadPreference_where): countPayloadPreferences
|
||||||
docAccessPayloadPreference(id: String!): payload_preferencesDocAccess
|
docAccessPayloadPreference(id: String!): payload_preferencesDocAccess
|
||||||
Access: Access
|
Access: Access
|
||||||
}
|
}
|
||||||
|
|
||||||
type Collection1 {
|
type Collection1 {
|
||||||
id: String
|
id: String!
|
||||||
testing: String!
|
testing: String!
|
||||||
title: String!
|
title: String!
|
||||||
meta: [SharedMetaArray!]
|
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).
|
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
|
scalar JSONObject @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||||
@specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
|
||||||
|
|
||||||
type Collection1ReadDocAccess {
|
type Collection1ReadDocAccess {
|
||||||
permission: Boolean!
|
permission: Boolean!
|
||||||
@@ -478,7 +459,7 @@ type Collection1DeleteDocAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Collection2 {
|
type Collection2 {
|
||||||
id: String
|
id: String!
|
||||||
metaArray: [SharedMetaArray!]
|
metaArray: [SharedMetaArray!]
|
||||||
metaGroup: SharedMeta
|
metaGroup: SharedMeta
|
||||||
nestedGroup: Collection2_NestedGroup
|
nestedGroup: Collection2_NestedGroup
|
||||||
@@ -1028,7 +1009,7 @@ type Collection2DeleteDocAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
id: String
|
id: String!
|
||||||
updatedAt: DateTime
|
updatedAt: DateTime
|
||||||
createdAt: DateTime
|
createdAt: DateTime
|
||||||
email: EmailAddress!
|
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.
|
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
|
scalar EmailAddress @specifiedBy(url: "https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address")
|
||||||
@specifiedBy(url: "https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address")
|
|
||||||
|
|
||||||
type Users {
|
type Users {
|
||||||
docs: [User]
|
docs: [User]
|
||||||
@@ -1271,12 +1251,13 @@ type UsersUnlockDocAccess {
|
|||||||
type usersMe {
|
type usersMe {
|
||||||
collection: String
|
collection: String
|
||||||
exp: Int
|
exp: Int
|
||||||
|
strategy: String
|
||||||
token: String
|
token: String
|
||||||
user: User
|
user: User
|
||||||
}
|
}
|
||||||
|
|
||||||
type PayloadPreference {
|
type PayloadPreference {
|
||||||
id: String
|
id: String!
|
||||||
user: PayloadPreference_User_Relationship!
|
user: PayloadPreference_User_Relationship!
|
||||||
key: String
|
key: String
|
||||||
value: JSON
|
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).
|
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
|
scalar JSON @specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
||||||
@specifiedBy(url: "http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")
|
|
||||||
|
|
||||||
type PayloadPreferences {
|
type PayloadPreferences {
|
||||||
docs: [PayloadPreference]
|
docs: [PayloadPreference]
|
||||||
@@ -2470,40 +2450,25 @@ type PayloadPreferencesDeleteAccess {
|
|||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
createCollection1(data: mutationCollection1Input!, draft: Boolean): Collection1
|
createCollection1(data: mutationCollection1Input!, draft: Boolean): Collection1
|
||||||
updateCollection1(
|
updateCollection1(id: String!, autosave: Boolean, data: mutationCollection1UpdateInput!, draft: Boolean): Collection1
|
||||||
id: String!
|
|
||||||
autosave: Boolean
|
|
||||||
data: mutationCollection1UpdateInput!
|
|
||||||
draft: Boolean
|
|
||||||
): Collection1
|
|
||||||
deleteCollection1(id: String!): Collection1
|
deleteCollection1(id: String!): Collection1
|
||||||
duplicateCollection1(id: String!): Collection1
|
duplicateCollection1(id: String!): Collection1
|
||||||
createCollection2(data: mutationCollection2Input!, draft: Boolean): Collection2
|
createCollection2(data: mutationCollection2Input!, draft: Boolean): Collection2
|
||||||
updateCollection2(
|
updateCollection2(id: String!, autosave: Boolean, data: mutationCollection2UpdateInput!, draft: Boolean): Collection2
|
||||||
id: String!
|
|
||||||
autosave: Boolean
|
|
||||||
data: mutationCollection2UpdateInput!
|
|
||||||
draft: Boolean
|
|
||||||
): Collection2
|
|
||||||
deleteCollection2(id: String!): Collection2
|
deleteCollection2(id: String!): Collection2
|
||||||
duplicateCollection2(id: String!): Collection2
|
duplicateCollection2(id: String!): Collection2
|
||||||
createUser(data: mutationUserInput!, draft: Boolean): User
|
createUser(data: mutationUserInput!, draft: Boolean): User
|
||||||
updateUser(id: String!, autosave: Boolean, data: mutationUserUpdateInput!, draft: Boolean): User
|
updateUser(id: String!, autosave: Boolean, data: mutationUserUpdateInput!, draft: Boolean): User
|
||||||
deleteUser(id: String!): User
|
deleteUser(id: String!): User
|
||||||
refreshTokenUser(token: String): usersRefreshedUser
|
refreshTokenUser: usersRefreshedUser
|
||||||
logoutUser: String
|
logoutUser: String
|
||||||
unlockUser(email: String!): Boolean!
|
unlockUser(email: String!): Boolean!
|
||||||
loginUser(email: String, password: String): usersLoginResult
|
loginUser(email: String!, password: String): usersLoginResult
|
||||||
forgotPasswordUser(disableEmail: Boolean, email: String!, expiration: Int): Boolean!
|
forgotPasswordUser(disableEmail: Boolean, expiration: Int, email: String!): Boolean!
|
||||||
resetPasswordUser(password: String, token: String): usersResetPassword
|
resetPasswordUser(password: String, token: String): usersResetPassword
|
||||||
verifyEmailUser(token: String): Boolean
|
verifyEmailUser(token: String): Boolean
|
||||||
createPayloadPreference(data: mutationPayloadPreferenceInput!, draft: Boolean): PayloadPreference
|
createPayloadPreference(data: mutationPayloadPreferenceInput!, draft: Boolean): PayloadPreference
|
||||||
updatePayloadPreference(
|
updatePayloadPreference(id: String!, autosave: Boolean, data: mutationPayloadPreferenceUpdateInput!, draft: Boolean): PayloadPreference
|
||||||
id: String!
|
|
||||||
autosave: Boolean
|
|
||||||
data: mutationPayloadPreferenceUpdateInput!
|
|
||||||
draft: Boolean
|
|
||||||
): PayloadPreference
|
|
||||||
deletePayloadPreference(id: String!): PayloadPreference
|
deletePayloadPreference(id: String!): PayloadPreference
|
||||||
duplicatePayloadPreference(id: String!): PayloadPreference
|
duplicatePayloadPreference(id: String!): PayloadPreference
|
||||||
}
|
}
|
||||||
@@ -2623,6 +2588,7 @@ input mutationUserUpdateInput {
|
|||||||
type usersRefreshedUser {
|
type usersRefreshedUser {
|
||||||
exp: Int
|
exp: Int
|
||||||
refreshedToken: String
|
refreshedToken: String
|
||||||
|
strategy: String
|
||||||
user: usersJWT
|
user: usersJWT
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2674,4 +2640,4 @@ input PayloadPreferenceUpdate_UserRelationshipInput {
|
|||||||
|
|
||||||
enum PayloadPreferenceUpdate_UserRelationshipInputRelationTo {
|
enum PayloadPreferenceUpdate_UserRelationshipInputRelationTo {
|
||||||
users
|
users
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
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'
|
import { getNextRootDir } from './helpers/getNextRootDir.js'
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
@@ -32,21 +32,7 @@ export async function initDevAndTest(
|
|||||||
if (writeDBAdapter === 'true') {
|
if (writeDBAdapter === 'true') {
|
||||||
const dbAdapter: keyof typeof allDatabaseAdapters =
|
const dbAdapter: keyof typeof allDatabaseAdapters =
|
||||||
(process.env.PAYLOAD_DATABASE as keyof typeof allDatabaseAdapters) || 'mongodb'
|
(process.env.PAYLOAD_DATABASE as keyof typeof allDatabaseAdapters) || 'mongodb'
|
||||||
|
generateDatabaseAdapter(dbAdapter)
|
||||||
// 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')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipGenImportMap === 'true') {
|
if (skipGenImportMap === 'true') {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import fs from 'fs'
|
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||||
import path from 'node:path'
|
|
||||||
import { fileURLToPath } from 'node:url'
|
|
||||||
import { getDatabaseAdapter } from './getDatabaseAdapter.js'
|
|
||||||
|
|
||||||
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
|
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
|
||||||
process.env.PAYLOAD_DROP_DATABASE = '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.NODE_OPTIONS = '--no-deprecation'
|
||||||
process.env.PAYLOAD_CI_DEPENDENCY_CHECKER = 'true'
|
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'
|
const dbAdapter = process.env.PAYLOAD_DATABASE || 'mongodb'
|
||||||
|
|
||||||
// Generate databaseAdapter.ts
|
generateDatabaseAdapter(dbAdapter)
|
||||||
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')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user