Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically load .env files #15

Open
angeloashmore opened this issue Jun 21, 2022 · 0 comments
Open

Automatically load .env files #15

angeloashmore opened this issue Jun 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@angeloashmore
Copy link
Member

Is your feature request related to a problem? Please describe.

Private tokens, like a Prismic repository's access token or Custom Types API token, should generally not be committed to a Git repository. Using .env files is a common practice to exclude private data from committed code.

Currently, prismic-ts-codegen requires an access token and/or Custom Types API token for certain configurations, but does not provide a straightforward way to do so securely.

Describe the solution you'd like

prismic-ts-codegen could automatically load .env files from the working directory. Loading a .env file populates the global process.env object with arbitrary data, which could be used to load private tokens.

The dotenv package is the most commonly used package to load .env files. While that exact package does not need to be used, its .env loading practices are industry-standard.

Something to consider: some frameworks have .env naming conventions. For example, .env.local (as seen in Next.js) and .env.development are common conventions. Which .env file is loaded can be a prismic-ts-codegen configuration property, but good defaults results in a smoother experience.

Describe alternatives you've considered

Because prismic-ts-codegen's config is written in a TypeScript or JavaScript file (prismicCodegen.config.{ts|js}), the dotenv package could be used manually. It is easy to set up, but ultimately is more friction than having that functionality built in to the tool.

Additional context

Thanks to @a-trost for prompting this feature request. 🐴

@angeloashmore angeloashmore added the enhancement New feature or request label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant