templates: removes DATABASE_URI env var from with-vercel-website template .env.example (#10098)
### What? Previously, the `with-vercel-website` template included a `DATABASE_URI` env var in the `.env.example` file - which was unneeded. ### Why? The `with-vercel-website` template uses a `POSTGRES_URL` env var for the db connection string env var instead. ### How? Removes the `DATABASE_URI` env var from the .env.example file. Also, updates the `DATABASE_URI` db string names in the following templates from `payloadtests` to `your-database-name` for a more generic / clear name: - with-postgres - with-vercel-mongodb - with-vercel-postgres - with-vercel-website
This commit is contained in:
@@ -16,7 +16,7 @@ async function main() {
|
|||||||
const templateDir = path.resolve(dirname, '../templates')
|
const templateDir = path.resolve(dirname, '../templates')
|
||||||
const templateName = process.argv[2]
|
const templateName = process.argv[2]
|
||||||
const templatePath = path.join(templateDir, templateName)
|
const templatePath = path.join(templateDir, templateName)
|
||||||
const databaseConnection = process.argv[3] || 'mongodb://127.0.0.1/payloadtests'
|
const databaseConnection = process.argv[3] || 'mongodb://127.0.0.1/your-database-name'
|
||||||
|
|
||||||
console.log({
|
console.log({
|
||||||
templatePath,
|
templatePath,
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ async function main() {
|
|||||||
...process.env,
|
...process.env,
|
||||||
PAYLOAD_SECRET: 'asecretsolongnotevensantacouldguessit',
|
PAYLOAD_SECRET: 'asecretsolongnotevensantacouldguessit',
|
||||||
BLOB_READ_WRITE_TOKEN: 'vercel_blob_rw_TEST_asdf',
|
BLOB_READ_WRITE_TOKEN: 'vercel_blob_rw_TEST_asdf',
|
||||||
DATABASE_URI: process.env.POSTGRES_URL || 'postgres://localhost:5432/payloadtests',
|
DATABASE_URI: process.env.POSTGRES_URL || 'postgres://localhost:5432/your-database-name',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -315,12 +315,25 @@ async function writeEnvExample({
|
|||||||
|
|
||||||
const fileContents = envFileContents
|
const fileContents = envFileContents
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((e) => e)
|
.filter((l) => {
|
||||||
|
// Remove the unwanted PostgreSQL connection comment for "with-vercel-website"
|
||||||
|
if (
|
||||||
|
dbType === 'vercel-postgres' &&
|
||||||
|
(l.startsWith('# Or use a PG connection string') ||
|
||||||
|
l.startsWith('#DATABASE_URI=postgresql://'))
|
||||||
|
) {
|
||||||
|
return false // Skip this line
|
||||||
|
}
|
||||||
|
return true // Keep other lines
|
||||||
|
})
|
||||||
.map((l) => {
|
.map((l) => {
|
||||||
if (l.startsWith('DATABASE_URI')) {
|
if (l.startsWith('DATABASE_URI')) {
|
||||||
|
if (dbType === 'mongodb') {
|
||||||
|
l = 'MONGODB_URI=mongodb://127.0.0.1/your-database-name'
|
||||||
|
}
|
||||||
// Use db-appropriate connection string
|
// Use db-appropriate connection string
|
||||||
if (dbType.includes('postgres')) {
|
if (dbType.includes('postgres')) {
|
||||||
l = 'DATABASE_URI=postgresql://127.0.0.1:5432/payloadtests'
|
l = 'DATABASE_URI=postgresql://127.0.0.1:5432/your-database-name'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace DATABASE_URI with the correct env name if set
|
// Replace DATABASE_URI with the correct env name if set
|
||||||
@@ -330,6 +343,7 @@ async function writeEnvExample({
|
|||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
})
|
})
|
||||||
|
.filter((l) => l.trim() !== '')
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
console.log(`Writing to ${envExamplePath}`)
|
console.log(`Writing to ${envExamplePath}`)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
DATABASE_URI=postgresql://127.0.0.1:5432/payloadtests
|
DATABASE_URI=postgresql://127.0.0.1:5432/your-database-name
|
||||||
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
MONGODB_URI=mongodb://127.0.0.1/payload-template-blank-3-0
|
MONGODB_URI=mongodb://127.0.0.1/your-database-name
|
||||||
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
POSTGRES_URL=postgresql://127.0.0.1:5432/payloadtests
|
POSTGRES_URL=postgresql://127.0.0.1:5432/your-database-name
|
||||||
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
# Database connection string
|
# Database connection string
|
||||||
POSTGRES_URL=postgresql://127.0.0.1:5432/payloadtests
|
POSTGRES_URL=postgresql://127.0.0.1:5432/your-database-name
|
||||||
# Or use a PG connection string
|
|
||||||
#DATABASE_URI=postgresql://127.0.0.1:5432/payload-template-website
|
|
||||||
# Used to encrypt JWT tokens
|
# Used to encrypt JWT tokens
|
||||||
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
||||||
# Used to configure CORS, format links and more. No trailing slash
|
# Used to configure CORS, format links and more. No trailing slash
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
- '54320:5432'
|
- '54320:5432'
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_DB: payloadtests # THIS MUST MATCH YOUR DB NAME IN .env
|
POSTGRES_DB: your-database-name # THIS MUST MATCH YOUR DB NAME IN .env
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
POSTGRES_HOST_AUTH_METHOD: trust
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|||||||
Reference in New Issue
Block a user