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 templateName = process.argv[2]
|
||||
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({
|
||||
templatePath,
|
||||
|
||||
@@ -251,7 +251,7 @@ async function main() {
|
||||
...process.env,
|
||||
PAYLOAD_SECRET: 'asecretsolongnotevensantacouldguessit',
|
||||
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
|
||||
.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) => {
|
||||
if (l.startsWith('DATABASE_URI')) {
|
||||
if (dbType === 'mongodb') {
|
||||
l = 'MONGODB_URI=mongodb://127.0.0.1/your-database-name'
|
||||
}
|
||||
// Use db-appropriate connection string
|
||||
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
|
||||
@@ -330,6 +343,7 @@ async function writeEnvExample({
|
||||
}
|
||||
return l
|
||||
})
|
||||
.filter((l) => l.trim() !== '')
|
||||
.join('\n')
|
||||
|
||||
console.log(`Writing to ${envExamplePath}`)
|
||||
|
||||
Reference in New Issue
Block a user