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

feat(cli): load .env files before running any command #2320

Merged
merged 1 commit into from Feb 22, 2021

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Feb 21, 2021

Type of change (check at least one)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or update to documentation)
  • Maintenance
  • Other, please describe:

Does this change require a documentation update? (Check one)

  • Yes
  • No

Current behavior

When running CLI commands, any environment variables set in .env-files are not respected. For instance, running sanity graphql deploy, sanity deploy and sanity users list uses the values defined in sanity.json instead of respecting any .env file overrides.

Description

This PR ensures any .env-file is read and used before running any CLI commands.

Fixes #2318

Note for release

  • .env files will now be loaded before running any Sanity CLI command

Checklist

  • I have read the Contributing Guidelines
  • The PR title includes a link to the relevant issue
  • The PR title is appropriately formatted: [some-package] PR title (#123)
  • The code is linted
  • The test suite is passing
  • Corresponding changes to the documentation have been made

@rexxars rexxars requested a review from bjoerge February 21, 2021 00:31
@vercel
Copy link

vercel bot commented Feb 21, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

test-studio – ./

🔍 Inspect: https://vercel.com/sanity-io/test-studio/ELdEHLdDFHMCamXkPGog2pPWdb8j
✅ Preview: https://test-studio-git-feat-cli-load-env-file.sanity.build

perf-studio – ./

🔍 Inspect: https://vercel.com/sanity-io/perf-studio/6T4Y7QDDyfykuEGkDj7umDtYTSRk
✅ Preview: https://perf-studio-git-feat-cli-load-env-file.sanity.build

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Added a comment/question about having multiple .env files as the default. LGTM beyond that 💯

packages/@sanity/cli/src/cli.js Show resolved Hide resolved
@rexxars rexxars merged commit 0598533 into next Feb 22, 2021
@rexxars rexxars deleted the feat/cli-load-env-file branch February 22, 2021 23:20
mariuslundgard added a commit that referenced this pull request Feb 24, 2021
* feat(core): add --mock-browser-env flag to `sanity exec` command (#2319)

* feat(cli): load `.env` files before running any command (#2320)

* feat(base): add z-offset values for `paneHeader` and `paneFooter`

* fix(desk-tool): improve z-offsets

* Make sure the pane header and footer are always on top of pane content

* feat(base): add `fullscreen` to z-offset values

* fix(desk-tool): use `fullscreen` z-offset for InspectDialog

* refactor(base): improve organization of z-offset API

Co-authored-by: Espen Hovlandsdal <espen@hovlandsdal.com>
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.

Allow initial configuration of projectId and dataset from environment variables
2 participants