Feature request - env var related hooks #10691
theoephraim
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Background
https://varlock.dev is a tool that loads and manages environment variables. It allows users to embed schema info in .env files using
@decorator
style comments, and then load and validate those env vars. This means you always have a full schema of all of the env vars your application may interact with. These vars may be set by being passed in when you run your CLI command, from the schema itself, or being fetched using instructions within the schema.In a monorepo, we may want to set some vars at the root level, and then have child repos load more vars specific to that service. Currently turbo would only care about the vars that have been set when passed into the parent turbo command.
It's also very easy to forget that env vars get swallowed (not passed through) by turbo unless they are explicitly listed in
turbo.json
.It would be great if turbo exposed some hooks so that it could reach out to varlock (or a similar tool) to get the resolved env vars, along with metadata that indicates how those vars should affect caching, rather than having to duplicate lists of vars in turbo config files.
Proposal
I haven't thought it all through yet, but I could imagine turbo config having a field where one could specify a command to run that will fetch env vars. These could be returned with additional metadata about caching - ie keys to pass through and whether they should affect caching. Turbo could then run this command, potentially within each child project, while deciding which tasks to run and how to pass through env vars.
I would be happy to help spec this out further, and implement it if there is some willingness to implement such a feature.
We've already got a fairly compelling Next.js integration, so having this all play nicely with turborepo too would be great.
Beta Was this translation helpful? Give feedback.
All reactions