next.js icon indicating copy to clipboard operation
next.js copied to clipboard

cna: create `.env.example` correctly

Open JamBalaya56562 opened this issue 1 year ago • 6 comments

What?

  1. Rename .env.example to env.example in the CNA templates.
  2. Update index.ts to create .env.example correctly.
  3. Add .env.example to integration tests.

Why?

At #56469, .env.example was added to CNA templates. However, create-next-app command doesn't make it due to dotfile.

CC: @samcx

JamBalaya56562 avatar Dec 09 '24 09:12 JamBalaya56562

Allow CI Workflow Run

  • [ ] approve CI run for commit: 861396305912df329ace9721bfb12c4478222071

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

ijjk avatar Dec 09 '24 09:12 ijjk

I don't think we should switch it to env.example since the convention is with the .env.<xyz>.

However, create-next-app command doesn't make it due to dotfile.

Is it possible to fix this? 👀

samcx avatar Apr 06 '25 01:04 samcx

I don't think we should switch it to env.example since the convention is with the .env.<xyz>.

However, create-next-app command doesn't make it due to dotfile.

Is it possible to fix this? 👀

You are right, but .gitignore file has already named gitignore for .gitignore conversion.

https://github.com/vercel/next.js/blob/fd5f588f43360913197f655a7322b37022c51e17/packages/create-next-app/templates/index.ts#L60-L78

Make sure that the output env file name will be .env.example like .gitignore conversion.

JamBalaya56562 avatar Apr 07 '25 00:04 JamBalaya56562

⚠️ No Changeset found

Latest commit: 085a7977263f2fba268814f787caf8a5d058aba8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar May 15 '25 00:05 changeset-bot[bot]

@JamBalaya56562 These are still not using .env.example (starting with a .)

samcx avatar Jun 17 '25 18:06 samcx

@JamBalaya56562 These are still not using .env.example (starting with a .)

I'm sorry but I'm not sure what you mean.

By the way, I will tell you why the dotfiles aren't made by create-next-app.

You can create .env.example correctly in local create-next-app folder. However, you can't do that with dist/index.ts after build because of @vercel/ncc compile. @vercel/ncc doesn't output dotfiles to dist folder.

That's why .gitignore is replaced with gitignore.

JamBalaya56562 avatar Jun 18 '25 01:06 JamBalaya56562