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

fix(cli): add support for import.meta.env #5617

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

ricokahler
Copy link
Contributor

Description

The following adds minimal support for import.meta.env inside of the mock browser environment used in the CLI.

What to review

Does it work?

Testing

I added an import.meta.env usage in the test-studio and ran the command.

Notes for release

  • Fixes a bug that caused uses of import.meta.env to break the mock browser environment used in the CLI.

@ricokahler ricokahler requested a review from a team as a code owner January 30, 2024 20:31
@ricokahler ricokahler requested review from bjoerge and removed request for a team January 30, 2024 20:31
Copy link

vercel bot commented Jan 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Jan 30, 2024 9:12pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2024 9:12pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Jan 30, 2024 9:12pm

Copy link
Contributor

Package Documentation Change
sanity -3%
Full Report
@sanity/migrate
This branch Next branch
14 documented 14 documented
79 not documented 62 not documented
@sanity/diff
This branch Next branch
13 documented 13 documented
16 not documented 16 not documented
@sanity/block-tools
This branch Next branch
4 documented 4 documented
9 not documented 9 not documented
@sanity/types
This branch Next branch
55 documented 55 documented
233 not documented 239 not documented
sanity/desk
This branch Next branch
84 documented 84 documented
64 not documented 64 not documented
@sanity/portable-text-editor
This branch Next branch
21 documented 21 documented
44 not documented 44 not documented
@sanity/mutator
This branch Next branch
7 documented 7 documented
3 not documented 4 not documented
@sanity/cli
This branch Next branch
1 documented 1 documented
31 not documented 31 not documented
@sanity/util/legacyDateFormat
This branch Next branch
0 documented 0 documented
4 not documented 5 not documented
@sanity/schema/_internal
This branch Next branch
0 documented 0 documented
12 not documented 12 not documented
@sanity/util/paths
This branch Next branch
1 documented 1 documented
15 not documented 15 not documented
sanity/router
This branch Next branch
17 documented 17 documented
26 not documented 26 not documented
@sanity/schema
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
sanity/structure
This branch Next branch
2 documented 2 documented
6 not documented 6 not documented
sanity/cli
This branch Next branch
2 documented 2 documented
0 not documented 0 not documented
@sanity/vision
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/fs
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
sanity/_internal
This branch Next branch
0 documented 0 documented
1 not documented 1 not documented
@sanity/util/createSafeJsonParser
This branch Next branch
1 documented 1 documented
0 not documented 0 not documented
sanity/_internalBrowser
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/util/content
This branch Next branch
1 documented 1 documented
5 not documented 5 not documented
sanity
This branch Next branch
177 documented 183 documented
835 not documented 847 not documented

Copy link
Contributor

github-actions bot commented Jan 30, 2024

Component Testing Report Updated Jan 30, 2024 9:14 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 13s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 18s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ❌ Failed (Inspect) 1m 5s 17 0 1
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 7s 3 0 0

@ricokahler ricokahler closed this Jan 30, 2024
@ricokahler
Copy link
Contributor Author

Eh may not be the best idea to release this without properly populating process.env/import.meta.env

@ricokahler ricokahler reopened this Jan 30, 2024
@binoy14 binoy14 requested a review from rexxars January 30, 2024 21:07
@ricokahler ricokahler removed the request for review from binoy14 January 30, 2024 21:09
@ricokahler ricokahler changed the title fix(cli): add minimal support for import.meta.env fix(cli): add support for import.meta.env Jan 30, 2024
Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

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

I think that should work, yeah?

Comment on lines +39 to +40
// define the `process.env` global
...getStudioEnvironmentVariables({prefix: 'process.env.', jsonEncode: true}),
Copy link
Member

Choose a reason for hiding this comment

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

Not actually sure if this one is needed, given we're already in an environment with process.env defined - maybe if the .env files and such is not already loaded?

Copy link
Contributor

Choose a reason for hiding this comment

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

added as a safety mechanism, since process.env is not a browser thing right?

@ricokahler ricokahler added this pull request to the merge queue Jan 30, 2024
Merged via the queue into next with commit 083ff16 Jan 30, 2024
69 of 70 checks passed
@ricokahler ricokahler deleted the fix/minimal-import-meta-env-support branch January 30, 2024 21:54
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.

3 participants