diff --git a/packages/create-payload-app/src/lib/create-project.ts b/packages/create-payload-app/src/lib/create-project.ts index 54b24179f53..36041509d61 100644 --- a/packages/create-payload-app/src/lib/create-project.ts +++ b/packages/create-payload-app/src/lib/create-project.ts @@ -19,6 +19,8 @@ import { configurePayloadConfig } from './configure-payload-config.js' import { configurePluginProject } from './configure-plugin-project.js' import { downloadExample } from './download-example.js' import { downloadTemplate } from './download-template.js' +import { generateSecret } from './generate-secret.js' +import { manageEnvFiles } from './manage-env-files.js' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -142,6 +144,18 @@ export async function createProject( } } + // Call manageEnvFiles before initializing Git + if (dbDetails) { + await manageEnvFiles({ + cliArgs, + databaseType: dbDetails.type, + databaseUri: dbDetails.dbUri, + payloadSecret: generateSecret(), + projectDir, + template: 'template' in args ? args.template : undefined, + }) + } + // Remove yarn.lock file. This is only desired in Payload Cloud. const lockPath = path.resolve(projectDir, 'pnpm-lock.yaml') if (fse.existsSync(lockPath)) { diff --git a/packages/create-payload-app/src/main.ts b/packages/create-payload-app/src/main.ts index c3411d35c03..38f7c7df186 100644 --- a/packages/create-payload-app/src/main.ts +++ b/packages/create-payload-app/src/main.ts @@ -255,7 +255,6 @@ export class Main { } case 'starter': { const dbDetails = await selectDb(this.args, projectName) - const payloadSecret = generateSecret() await createProject({ cliArgs: this.args, @@ -266,15 +265,6 @@ export class Main { template, }) - await manageEnvFiles({ - cliArgs: this.args, - databaseType: dbDetails.type, - databaseUri: dbDetails.dbUri, - payloadSecret, - projectDir, - template, - }) - break } } diff --git a/templates/_template/.env.example b/templates/_template/.env.example index 441b33e686e..566f44738d4 100644 --- a/templates/_template/.env.example +++ b/templates/_template/.env.example @@ -1,2 +1,2 @@ -DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0 +DATABASE_URI=mongodb://127.0.0.1/your-database-name PAYLOAD_SECRET=YOUR_SECRET_HERE diff --git a/templates/blank/.env.example b/templates/blank/.env.example index 441b33e686e..566f44738d4 100644 --- a/templates/blank/.env.example +++ b/templates/blank/.env.example @@ -1,2 +1,2 @@ -DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0 +DATABASE_URI=mongodb://127.0.0.1/your-database-name PAYLOAD_SECRET=YOUR_SECRET_HERE diff --git a/templates/website/.env.example b/templates/website/.env.example index 210d1ca4ba5..87499e5283a 100644 --- a/templates/website/.env.example +++ b/templates/website/.env.example @@ -1,8 +1,8 @@ # Database connection string -DATABASE_URI=mongodb://127.0.0.1/payload-template-website +DATABASE_URI=mongodb://127.0.0.1/your-database-name # Or use a PG connection string -#DATABASE_URI=postgresql://127.0.0.1:5432/payload-template-website +#DATABASE_URI=postgresql://127.0.0.1:5432/your-database-name # Used to encrypt JWT tokens PAYLOAD_SECRET=YOUR_SECRET_HERE diff --git a/templates/with-payload-cloud/.env.example b/templates/with-payload-cloud/.env.example index 0cb45aaa666..566f44738d4 100644 --- a/templates/with-payload-cloud/.env.example +++ b/templates/with-payload-cloud/.env.example @@ -1,2 +1,2 @@ -DATABASE_URI=mongodb://127.0.0.1/payload-template-blank-3-0 -PAYLOAD_SECRET=YOUR_SECRET_HERE \ No newline at end of file +DATABASE_URI=mongodb://127.0.0.1/your-database-name +PAYLOAD_SECRET=YOUR_SECRET_HERE