From 9da650662208e767221468d44f306394b063d2ff Mon Sep 17 00:00:00 2001 From: James Date: Thu, 5 Oct 2023 10:34:56 -0400 Subject: [PATCH] chore: initializes payload before build --- docs/admin/bundlers.mdx | 0 docs/configuration/database.mdx | 0 docs/database/mongodb.mdx | 19 +++++++++++++++++++ docs/database/postgres.mdx | 7 +++++++ packages/bundler-vite/src/config.ts | 3 ++- packages/payload/src/bin/build.ts | 8 ++++++++ .../payload/src/bin/generateGraphQLSchema.ts | 2 +- 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 docs/admin/bundlers.mdx create mode 100644 docs/configuration/database.mdx create mode 100644 docs/database/mongodb.mdx create mode 100644 docs/database/postgres.mdx diff --git a/docs/admin/bundlers.mdx b/docs/admin/bundlers.mdx new file mode 100644 index 000000000..e69de29bb diff --git a/docs/configuration/database.mdx b/docs/configuration/database.mdx new file mode 100644 index 000000000..e69de29bb diff --git a/docs/database/mongodb.mdx b/docs/database/mongodb.mdx new file mode 100644 index 000000000..59f8bbe6a --- /dev/null +++ b/docs/database/mongodb.mdx @@ -0,0 +1,19 @@ +--- +title: MongoDB +label: MongoDB +order: 20 +desc: Payload has supported MongoDB natively since alpha. The flexible nature of MongoDB lends itself well to Payload's powerful fields. +keywords: MongoDB, documentation, typescript, Content Management System, cms, headless, javascript, node, react, express +--- + +##### `mongoURL` + +**Required**. This is a fully qualified MongoDB connection string that points to your MongoDB database. If you don't have MongoDB installed locally, you can [follow these steps for Mac OSX](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) and [these steps](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/) for Windows 10. If you want to use a local database and you know you have MongoDB installed locally, a typical connection string will look like this: + +`mongodb://127.0.0.1/payload` + +In contrast to running MongoDB locally, a popular option is to sign up for a free [MongoDB Atlas account](https://www.mongodb.com/cloud/atlas), which is a fully hosted and cloud-based installation of MongoDB that you don't need to ever worry about. + +##### `mongoOptions` + +Customize MongoDB connection options. Payload will connect to your MongoDB database using default options which you can override and extend to include all the [options](https://mongoosejs.com/docs/connections.html#options) available to mongoose. \ No newline at end of file diff --git a/docs/database/postgres.mdx b/docs/database/postgres.mdx new file mode 100644 index 000000000..0c4bca759 --- /dev/null +++ b/docs/database/postgres.mdx @@ -0,0 +1,7 @@ +--- +title: Postgres +label: Postgres +order: 30 +desc: Payload supports Postgres through an officially supported Drizzle database adapter. +keywords: Postgres, documentation, typescript, Content Management System, cms, headless, javascript, node, react, express +--- \ No newline at end of file diff --git a/packages/bundler-vite/src/config.ts b/packages/bundler-vite/src/config.ts index 3e207d4cf..541b22379 100644 --- a/packages/bundler-vite/src/config.ts +++ b/packages/bundler-vite/src/config.ts @@ -62,8 +62,9 @@ export const getViteConfig = async (payloadConfig: SanitizedConfig): Promise ""', + 'process.cwd': 'function () { return "/" }', 'process.env': '{}', + 'process?.cwd': 'function () { return "/" }', } Object.entries(process.env).forEach(([key, val]) => { diff --git a/packages/payload/src/bin/build.ts b/packages/payload/src/bin/build.ts index 362390986..d93383047 100755 --- a/packages/payload/src/bin/build.ts +++ b/packages/payload/src/bin/build.ts @@ -1,8 +1,16 @@ +import payload from '..' import loadConfig from '../config/load' export const build = async (): Promise => { const config = await loadConfig() // Will throw its own error if it fails + await payload.init({ + disableDBConnect: true, + disableOnInit: true, + local: true, + secret: '--unused--', + }) + await config.admin.bundler.build(config) } diff --git a/packages/payload/src/bin/generateGraphQLSchema.ts b/packages/payload/src/bin/generateGraphQLSchema.ts index ce32b7e97..17e2e69a3 100644 --- a/packages/payload/src/bin/generateGraphQLSchema.ts +++ b/packages/payload/src/bin/generateGraphQLSchema.ts @@ -13,8 +13,8 @@ export async function generateGraphQLSchema(): Promise { config.db = null await payload.init({ - disableOnInit: true, disableDBConnect: true, + disableOnInit: true, local: true, secret: '--unused--', })