Skip to content

Commit fc445bf

Browse files
authored
fix: env vars (#1140)
1 parent ab0790e commit fc445bf

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

Diff for: .changeset/rich-seas-speak.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-t3-app": patch
3+
---
4+
5+
chore: add descriptive comments and format .env prettier

Diff for: cli/src/installers/envVars.ts

+27-17
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,52 @@ export const envVariablesInstaller: Installer = ({ projectDir, packages }) => {
3636
};
3737

3838
const getEnvContent = (usingAuth: boolean, usingPrisma: boolean) => {
39-
let content =
40-
"# When adding additional env variables, the schema in /env/schema.mjs should be updated accordingly";
39+
let content = `
40+
# When adding additional environment variables, the schema in "/env/schema.mjs"
41+
# should be updated accordingly.
42+
`
43+
.trim()
44+
.concat("\n");
4145

4246
if (usingPrisma)
4347
content += `
4448
# Prisma
45-
DATABASE_URL=file:./db.sqlite
49+
# https://www.prisma.io/docs/reference/database-reference/connection-urls#env
50+
DATABASE_URL="file:./db.sqlite"
4651
`;
4752

4853
if (usingAuth)
4954
content += `
5055
# Next Auth
51-
# You can generate the secret via 'openssl rand -base64 32' on Linux
52-
# More info: https://next-auth.js.org/configuration/options#secret
53-
# NEXTAUTH_SECRET=
54-
NEXTAUTH_URL=http://localhost:3000
56+
# You can generate a new secret on the command line with:
57+
# openssl rand -base64 32
58+
# https://next-auth.js.org/configuration/options#secret
59+
#NEXTAUTH_SECRET=""
60+
NEXTAUTH_URL="http://localhost:3000"
5561
5662
# Next Auth Discord Provider
57-
DISCORD_CLIENT_ID=
58-
DISCORD_CLIENT_SECRET=
63+
DISCORD_CLIENT_ID=""
64+
DISCORD_CLIENT_SECRET=""
5965
`;
6066

6167
if (!usingAuth && !usingPrisma)
6268
content += `
6369
# Example:
64-
# SERVERVAR=foo
65-
# NEXT_PUBLIC_CLIENTVAR=bar
70+
# SERVERVAR="foo"
71+
# NEXT_PUBLIC_CLIENTVAR="bar"
6672
`;
6773

6874
return content;
6975
};
7076

71-
const exampleEnvContent = `# Since .env is gitignored, you can use .env.example to build a new \`.env\` file when you clone the repo.
72-
# Keep this file up-to-date when you add new variables to \`.env\`.
77+
const exampleEnvContent = `
78+
# Since the ".env" file is gitignored, you can use the ".env.example" file to
79+
# build a new ".env" file when you clone the repo. Keep this file up-to-date
80+
# when you add new variables to \`.env\`.
7381
74-
# This file will be committed to version control, so make sure not to have any secrets in it.
75-
# If you are cloning this repo, create a copy of this file named \`.env\` and populate it with your secrets.
76-
77-
`;
82+
# This file will be committed to version control, so make sure not to have any
83+
# secrets in it. If you are cloning this repo, create a copy of this file named
84+
# ".env" and populate it with your secrets.
85+
`
86+
.trim()
87+
.concat("\n\n");

0 commit comments

Comments
 (0)