Skip to content

Add diff log to env:pull command #2984

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khamilowicz
Copy link
Contributor

@khamilowicz khamilowicz commented Apr 10, 2025

Why

ENG-15251: Analyse EnvVar UI feedback from user

Users should be aware of the changes that the command env:pull performs: new, changed, and deleted variables should be clearly visible.

image

How

  • Added diff

Test Plan

  1. Execute eas env:pull --environment ENVIRONMENT - all variables should be displayed in normal text, without prefixes
  2. Add, delete, and change some variables (via website or CLI)
  3. Pull variables again
  • New variables are displayed in green text with a + prefix.
  • Deleted variables are displayed in red text with a - prefix.
  • Changed variables are displayed in yellow text with a ~ prefix.
  • Unchanged variables remain in black text without any prefix.

Verify for plain text, sensitive, secret, text and file variables.

Copy link

linear bot commented Apr 10, 2025

Copy link

Subscribed to pull request

File Patterns Mentions
**/* @sjchmiela, @radoslawkrzemien

Generated by CodeMention

Copy link

github-actions bot commented Apr 10, 2025

Size Change: +706 B (0%)

Total Size: 53.5 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 53.5 MB +706 B (0%)

compressed-size-action

@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-15251-analyze-envvar-ui-feedback-from-user branch 2 times, most recently from dbb4bc6 to cf91e66 Compare April 10, 2025 13:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-15251-analyze-envvar-ui-feedback-from-user branch 2 times, most recently from 35f6856 to 046f6bc Compare April 10, 2025 14:33
@khamilowicz khamilowicz requested a review from Copilot April 10, 2025 14:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

packages/eas-cli/src/commands/env/pull.ts:64

  • Consider adding error handling around the fs.readFile call to gracefully handle scenarios where the file exists but cannot be read.
const fileContent = await fs.readFile(currentEnvValue, 'base64');

Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.

Project coverage is 52.60%. Comparing base (20b4832) to head (16bec66).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/eas-cli/src/commands/env/pull.ts 94.29% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2984      +/-   ##
==========================================
+ Coverage   52.36%   52.60%   +0.24%     
==========================================
  Files         596      596              
  Lines       23698    23733      +35     
  Branches     4714     4726      +12     
==========================================
+ Hits        12407    12482      +75     
+ Misses      11256    11216      -40     
  Partials       35       35              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

newVariable: EnvironmentVariableWithFileContent
): Promise<boolean> {
if (newVariable.visibility === EnvironmentVariableVisibility.Secret) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be undefined? Do we know values of secret variables? Maybe we should never compare them (and tell the user we can't)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Secret variables are a special case: if they are set in the .env var, we keep the current local value (so they are equal), and if it is a new variable, we inform user that they should set it manually (line 185 and 195).

return fileContent === newVariable.valueWithFileContent;
}

return currentEnvValue === newVariable.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can a variable type change? In which case just checking the value would no longer be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you change a variable type, then values would also necessarly change, yes? if you change a string variable to a file, then you need to upload a new value.


const diffLog = [];

for (const variableName of allVariableNames) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we extract this to a testable function and add tests? Shouldn't be too hard.

if (newVariable) {
if (Object.hasOwn(currentEnvLocal, variableName)) {
if (await this.isVariableEqualAsync(currentEnvLocal[variableName], newVariable)) {
diffLog.push(chalk.black(` ${variableName}`));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is black going to be white in dark mode terminals? Should we just do diffLog.push(\ ${variableName}`)`?

@khamilowicz khamilowicz force-pushed the piotrekszeremeta/eng-15251-analyze-envvar-ui-feedback-from-user branch from 046f6bc to 16bec66 Compare April 14, 2025 09:02
Copy link

✅ Thank you for adding the changelog entry!

@khamilowicz khamilowicz requested a review from sjchmiela April 14, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants