astro:env
.env.template generation
#957
Replies: 4 comments 3 replies
-
This would be great, would it be able to do full comment blocks(multi-line)? The example shown is already very similar to how i create the example files used for most of my integrations 😅 Merge option would be the best IMO if there is a way to check for existing values? in my example below the Authentication env variables come from one integration while the Cloudinary one comes from another... For example, StudioCMS playground
|
Beta Was this translation helpful? Give feedback.
-
I like the idea, but I don't think we should limit this to .env files. We should think of an modular API, which allows adapters to generate different files, e.g. wrangler.toml and .dev.vars for Cloudflare projects 🤔 |
Beta Was this translation helpful? Give feedback.
-
My thoughts on this from the last discussion is that it would be simpler if users authored the
We also wouldn't have to worry about this. If someone added additional documentation to |
Beta Was this translation helpful? Give feedback.
-
Closing as this can be an integration |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
Generate
.env.template
based on theastro:env
schema.Background & Motivation
The
.env.template
file is used as template for.env
. It contains all the necessary keys (and sometimes default values). It should not contain sensitive data. Developers can then copy it to.env
and filling the environment variables.While it's simple to keep in sync the env schema with a custom
.env.template
, it gets harder:It's also common to want to group variable keys by purpose (eg. stripe).
Goals
.env.template
from the env schemaExample
Enabling
I think this feature should be opt-in, under a flag:
Configuration
Each field would have a new
template
property:undefined
(default): use the default sorting method (more below)string
: used to groupfalse
: exclude from the generation (eg. for inlined system env vars by adapters)Creating the file
The
.env.template
generation would happen each time a sync occurs, that is whenastro sync
orsyncInternal
is called.As for its content, it would follow these rules for sorting:
Example
Questions
.env.template
? Should we override it? Merge it? I'm a bit concerned about the complexity if we have to diff etcBeta Was this translation helpful? Give feedback.
All reactions