Introduce EnvVarInputs to resolve the env vars given to apps - #4595
Open
cprecioso wants to merge 1 commit into
Open
Introduce EnvVarInputs to resolve the env vars given to apps#4595cprecioso wants to merge 1 commit into
cprecioso wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extracts the resolution of the env vars we give to the client and server apps into a new
Wasp.Cli.Util.EnvVarInputsmodule, and refactors the existingwasp build startenv var handling on top of it. No functional changes intended.EnvVarInputnames a place an app's env vars can come from: the environment Wasp itself runs in (Inherit), a CLI option like--server-env(FromFlag), a dotenv file passed via--server-env-file(FromFileArgument), or a project dotenv file like.env.server(FromProjectFile).resolveEnvVarInputsreads all the inputs and merges them with the wasp-owned env vars, failing if any source tries to override a wasp-owned var. Because every input carries a user-facing label, the error now points at the offending source (e.g.PORT (set in .env.server)).wasp build startparses its--{client,server}-env/--{client,server}-env-fileoptions directly intoEnvVarInputs and resolves them through the new module. This replacesWasp.Env.overrideEnvVarsand the ad-hoc merging helpers inBuildStart.Config.The
InheritandFromProjectFileinputs are exercised only by unit tests for now; the next PR in the stack uses them to share this same resolution betweenwasp startandwasp build start.The only user-visible difference is the wording of the error when a user sets a wasp-owned env var, which now includes where they set it.
Part of the dev-server ports stack (4/7): hints system → AppSpec from compiler →
Appsdatatype → EnvVarInputs refactor → Wasp-owned ports → port flags → port auto-selection.Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
🧪 Tests and apps:
examples/kitchen-sink/e2e-tests.waspc/data/Cli/templates, as needed.examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
web/docs/.🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.