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

[cli-kit] Support parsing multiline environment variables in .env file #3494

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

aswamy
Copy link
Contributor

@aswamy aswamy commented Feb 27, 2024

WHY are these changes introduced?

Hydrogen CLI is introducing multiline support in their .env files

  • The current library used in cli-kit does not support it
  • However, we can't fully remove the old library since it still provides the ability to write to .env files (which the new one does not)

WHAT is this pull request doing?

  • Adding dotenv library

How to test your changes?

  • Just ensure exists unit tests are run, and the new one passes as well

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

This comment has been minimized.

@aswamy aswamy force-pushed the add-dot-env-package branch 3 times, most recently from a9f3e00 to 837d70b Compare February 27, 2024 20:59
Copy link
Contributor

github-actions bot commented Feb 27, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.7% (+0.16% 🔼)
6605/8962
🟡 Branches
70.48% (+0.16% 🔼)
3213/4559
🟡 Functions
73.09% (+0.27% 🔼)
1741/2382
🟡 Lines
74.7% (+0.17% 🔼)
6231/8341
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / context.ts
90% (+0.2% 🔼)
86.84% (-0.49% 🔻)
82.86%
90.56% (+0.21% 🔼)
🔴
... / draftable-extension.ts
31.82% (-5.02% 🔻)
16.67% (-8.33% 🔻)
16.67%
35% (-3.89% 🔻)
🟢
... / setup-dev-processes.ts
94.87% (-0.25% 🔻)
68.18% 90%
94.12% (-0.33% 🔻)
🟢
... / push.ts
92.31% (-0.55% 🔻)
75% 100%
92.31% (-0.55% 🔻)
🟢
... / ConcurrentOutput.tsx
97.62% (-2.38% 🔻)
75% (-8.33% 🔻)
100%
97.44% (-2.56% 🔻)

Test suite run success

1580 tests passing in 737 suites.

Report generated by 🧪jest coverage report action from 3affd6b

@aswamy aswamy force-pushed the add-dot-env-package branch 2 times, most recently from 69a1e6d to 6351648 Compare February 29, 2024 05:28
Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for taking care of it!

Have you tested it on Windows? I'm a bit concerned about the new line logic that works differently there.

packages/cli-kit/src/public/node/dot-env.ts Outdated Show resolved Hide resolved
packages/cli-kit/package.json Outdated Show resolved Hide resolved
Copy link
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/dot-env.d.ts
@@ -32,4 +32,5 @@ export declare function writeDotEnv(file: DotEnvFile): Promise<void>;
  */
 export declare function patchEnvFile(envFileContent: string | null, updatedValues: {
     [key: string]: string | undefined;
-}): string;
\ No newline at end of file
+}): string;
+export declare function createDotEnvFileLine(key: string, value?: string, quote?: string): string;
\ No newline at end of file

@aswamy
Copy link
Contributor Author

aswamy commented Feb 29, 2024

Have you tested it on Windows? I'm a bit concerned about the new line logic that works differently there.

@gonzaloriestra

  • The dotenv library supports windows new lines so we don't have to worry about the parse method.
  • For the writeDotEnv method, i looked at how envfile did their stringify method; they didn't specify OS-level newline characters either, so i think we're fine. See here.
  • The patchEnvFile always split the file by \n instead of \r\n so i think we're fine again

@aswamy aswamy enabled auto-merge March 4, 2024 22:34
@aswamy aswamy added this pull request to the merge queue Mar 5, 2024
Merged via the queue into main with commit 543975e Mar 5, 2024
@aswamy aswamy deleted the add-dot-env-package branch March 5, 2024 14: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.

None yet

2 participants