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

Implement env:init, env:load and env:unload commands #2504

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

khamilowicz
Copy link
Contributor

Why

Commands streamlining usage of environment variables

  • eas env:init - install direnv, set up .envrc file and .gitignore
  • eas env:load --environment production - pulls envvars from given environment and loads them
  • eas env:unload - unloads envvars

Test Plan

Tested manually

Copy link

linear bot commented Aug 20, 2024

@khamilowicz khamilowicz added the no changelog PR that doesn't require a changelog entry label Aug 20, 2024
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from c012511 to 5e4f171 Compare August 20, 2024 11:36
Copy link

github-actions bot commented Aug 20, 2024

Size Change: +10.4 kB (+0.02%)

Total Size: 51.8 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 51.8 MB +10.4 kB (+0.02%)

compressed-size-action

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 20.20202% with 158 lines in your changes missing coverage. Please review.

Project coverage is 52.28%. Comparing base (fbc3924) to head (dacdfdd).

Files with missing lines Patch % Lines
packages/eas-cli/src/commands/env/init.ts 10.38% 113 Missing and 8 partials ⚠️
packages/eas-cli/src/commands/env/load.ts 34.89% 26 Missing and 2 partials ⚠️
packages/eas-cli/src/commands/env/unload.ts 55.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2504      +/-   ##
==========================================
- Coverage   52.59%   52.28%   -0.31%     
==========================================
  Files         548      551       +3     
  Lines       20409    20607     +198     
  Branches     4163     4198      +35     
==========================================
+ Hits        10732    10772      +40     
- Misses       8837     8985     +148     
- Partials      840      850      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from 5e4f171 to 1ffba14 Compare August 20, 2024 14:53
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envpush-command branch from be58276 to e021f93 Compare August 21, 2024 16:29
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch 2 times, most recently from e1229ba to 580d36e Compare August 22, 2024 07:59
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envpush-command branch from a229442 to e17b83a Compare August 22, 2024 15:00
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from 580d36e to e37124b Compare August 22, 2024 15:00
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envpush-command branch from e17b83a to ed27075 Compare August 26, 2024 09:32
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from e37124b to 5a70a4d Compare August 26, 2024 09:32
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envpush-command branch from ed27075 to 546e27b Compare August 26, 2024 09:39
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from 5a70a4d to 09f1e9e Compare August 26, 2024 09:39
Base automatically changed from piotrekszeremeta/eng-11920-add-eas-envpush-command to main August 26, 2024 09:46
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from 09f1e9e to 703ba1f Compare August 26, 2024 09:54
@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-11920-add-eas-envinit branch from 703ba1f to dacdfdd Compare September 3, 2024 09:45
Copy link

github-actions bot commented Sep 3, 2024

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

Copy link
Member

@szdziedzic szdziedzic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed during the meeting this looks like a really cool idea and we definitely want to play with it more behind the hidden flag. Awesome! 🚀

Few comments:

Comment on lines +32 to +34
if (nonInteractive) {
throw new Error("Non-interactive mode is not supported for 'eas env:init'");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just remove this flag from the command

Comment on lines +19 to +21
static override flags = {
...EASNonInteractiveFlag,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static override flags = {
...EASNonInteractiveFlag,
};

Log.log('Skipping adding the direnv hook to the shell config');
Log.log('You may need to add the direnv hook to your shell config manually.');
Log.log('Learn more: https://direnv.net/docs/hook.html');
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return;
throw new Error

to make it exit with non-zero code in such case

Comment on lines +68 to +69
Log.log('The direnv hook is already present in the shell config');
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would throw error here as well

Comment on lines +75 to +79
} else {
Log.log("Unable to determine the user's shell");
Log.log('You may need to add the direnv hook to your shell config manually.');
Log.log('Learn more: https://direnv.net/docs/hook.html');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we also need to throw an error here

throw new Error('Your Linux distribution is not supported by this script.');
}
} else {
Log.log(`Your platform (${platform}) is not supported by this script.`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Log.log(`Your platform (${platform}) is not supported by this script.`);
throw new Error(`Your platform (${platform}) is not supported by this script.`);

Comment on lines +66 to +68
.filter((variable: EnvironmentVariableFragment) => variable.value !== null)
.map((variable: EnvironmentVariableFragment) => {
return `${variable.name}=${variable.value}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.filter((variable: EnvironmentVariableFragment) => variable.value !== null)
.map((variable: EnvironmentVariableFragment) => {
return `${variable.name}=${variable.value}`;
.filter((variable => variable.value !== null)
.map((variable) => {
return `${variable.name}=${variable.value}`;

@@ -24,7 +24,7 @@ export default class EnvironmentValuePull extends EasCommand {
...EASNonInteractiveFlag,
path: Flags.string({
description: 'Path to the result `.env` file',
default: '.env.local',
default: '.env.eas.local',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I would stick with .env.local as default, I believe that's what the average person expects, and .env.local works as well with Expo SDK by default but .env.eas.local doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog PR that doesn't require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants