-
Notifications
You must be signed in to change notification settings - Fork 85
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
[eas-cli] add --with-eas-environment-variables-set
flag to eas update
command
#2628
[eas-cli] add --with-eas-environment-variables-set
flag to eas update
command
#2628
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @szdziedzic and the rest of your teammates on Graphite |
--with-eas-environment-variables-set
flag to eas update
command
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2628 +/- ##
==========================================
- Coverage 53.05% 52.93% -0.11%
==========================================
Files 566 569 +3
Lines 21615 21722 +107
Branches 4236 4259 +23
==========================================
+ Hits 11466 11497 +31
- Misses 10119 10194 +75
- Partials 30 31 +1 ☔ View full report in Codecov by Sentry. |
Size Change: +3.67 kB (+0.01%) Total Size: 53 MB
|
Subscribed to pull request
Generated by CodeMention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if maybe this should live up a level in the contexts to better indicate where this flag might be necessary to apply (which commands it needs to be added to for consistency)? (DynamicPublicProjectConfigContextField
, PrivateProjectConfigContextField
, OptionalPrivateProjectConfigContextField
). As it stands, I think we would at least need to add it to a few other update commands (roll-back-to-embedded, etc) in case the config resolved in those commands also depends on these env variables, which makes me think this might be good to move into the contexts. I might be wrong though. What do you think?
c2dd737
to
029025c
Compare
@wschurman @quinlanj I moved server side env vars fetching to context functions. This way they will be used every time when one class I also added a context option to get a function that will fetch server side env vars for given project and environment. Please let me know what you think about it now 🙏 If it looks OK, I will add the same flag and logic to the rest of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One inline comment. Also I believe we also need to add this to OptionalPrivateProjectConfigContextField
?
For the follow-up PR that adds the argument elsewhere, I think there's a good chance we'll need to add the withServerSideEnvironment
argument to every command that uses any of (DynamicProjectConfig
, ProjectConfig
, OptionalProjectConfig
, ServerSideEnvironmentVariables
) contexts? Maybe there's a clever way we could use typescript to enforce that the argument is supplied when any of those fields is used.
...ges/eas-cli/src/commandUtils/context/contextUtils/loadServerSideEnvironmentVariablesAsync.ts
Outdated
Show resolved
Hide resolved
Added 🫡
@wschurman believe I was able to do so. Can you take a look once again please? |
I made |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome use of types! Made a few small adjustments but overall it's really cool to be able to have the typechecker tell us where this is needed.
Side note: I think we need to add the variable fetching code to PrivateProjectConfigContextField
as well?
I see that if we add it to Looking at the commands though, I see a number of them just get the |
(assuming projectId is not allowed to be altered via a server-side environment variable since that'd be wonky) |
Yeah, it should not be altered, this would be weird because we would load env vars for project X and then evaluate project ID for project Y.
I will add new context, thanks for the advice! |
@wschurman I added a separate PR in which I add new context |
❌ It looks like a changelog entry is missing for this PR. Add it manually to CHANGELOG.md. |
Why
https://exponent-internal.slack.com/archives/C013ZK4SA12/p1725644220583309
We are planning to introduce enhancements to our env vars system soon. Currently, we only allow people to keep secrets on EAS servers. Secrets are not readable outside of EAS servers so of course EAS Update doesn't work with them. In a new system, people can also store readable env vars on our servers, which opens new possibilities about how EAS Update can interact with env vars!
In this PR I'm adding support for the
--with-eas-environment-variables-set production|preview|development
flag. If used, we use the flag's value to fetch readable env vars from our servers and use it in theexpo export
command to produce an update bundle based on these env vars. If the flag is used I'm using theEXPO_NO_DOTENV
flag to disable Expo CLI from loading env vars from.env
files and potentially unwillingly overwriting env vars fetched from our servers for a given environment.Users seem to face big issues with using env vars with EAS Build & Update at the moment, originating from the fact that these 2 handle different, non-compatible ways of using env vars. Env vars in the build profile and server-side secrets vs local env vars +
.env
. With this flag it will be easy to avoid envs mismatch by doingeas update ----with-eas-environment-variables-set environment
andeas build
with `{ ..., environment: environment, ...} in the build profile!How
Add a new hidden (for now) flag
--with-eas-environment-variables-set
that indicates which environment to use. If used fetch env vars from server. Merge and overwriteprocess.env
with newly fetched env vars. Use them to resolve the expo config. Don't use.env
env var loading from Expo CLI if server-side env vars are used.Test Plan
Test manually. Run
eas update
with and without a new flag. Check that the expo config is resolved correctly.