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: read scopes and contexts in env:get, env:list, and dev #4839

Merged
merged 24 commits into from
Aug 11, 2022

Conversation

jasonbarry
Copy link
Contributor

@jasonbarry jasonbarry commented Jul 21, 2022

Summary

This PR adds support for environment variable scopes and contexts for the env:get, env:list, and dev commands.

env:get and env:list support both the --scope and --context flags if the site has been configured with the new Environment Variables experience:tm:, aka Envelope. If the site is not configured with Envelope and either of those flags are passed, an error message will print. If this site is not configured with Envelope and neither of those flags are passed, it will behave as it normally has.

A new Scope column has been added to env:list if the site is on Envelope:
Screenshot 2022-07-27 at 22 29 27

The --context flag for netlify dev is now supported, which will pull in values from Envelope while respecting the precedence of context values in netlify.toml.

One caveat is that there will be a duplicate GET request sent to Envelope due to this change in netlify/config. Since we're adding context and scope options on the CLI level, I thought it would make sense to move the requests to happen in the CLI. Once all the calls to Envelope land in CLI, it should be safe to remove in netlify/config to remove the redundancy.

Fixes https://github.com/netlify/pillar-workflow/issues/755
Fixes https://github.com/netlify/pillar-workflow/issues/734


Test instructions

  • Checkout this branch and install dependencies
  • Remove your existing global install -- if installed with npm, npm uninstall -g netlify-cli
  • npm link
  • Give env:get, env:list, and dev a whirl. I recommend trying with a site opted-in to the new Env Vars experience in the UI (enable in Labs)

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

Screenshot 2022-07-24 at 21 41 04

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jul 21, 2022
@github-actions
Copy link

github-actions bot commented Jul 21, 2022

📊 Benchmark results

Comparing with 7317269

Package size: 228 MB

⬇️ 0.00% decrease vs. 7317269

^  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB  228 MB 
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@jasonbarry jasonbarry self-assigned this Jul 22, 2022
name: 'build settings',
name: 'site settings',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasonbarry
Copy link
Contributor Author

@codebyuma I would very much appreciate a copy review in this PR for options outputted by the --help flag, and log/error messages 🙏 . In the diff, I suggest clicking the "Show file tree" button and looking at .js files in src/commands/*. The copy in the docs/ directory is auto-generated from the commands.

Copy link
Contributor

@codebyuma codebyuma left a comment

Choose a reason for hiding this comment

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

It's exciting to see this coming together! I haven't finished reviewing/testing but I need to run for an appointment, so I thought I'd submit the comments I have so far. I'll come back to this when I'm back

src/commands/env/env-get.js Outdated Show resolved Hide resolved
src/commands/env/env-get.js Show resolved Hide resolved
src/commands/env/env-list.js Outdated Show resolved Hide resolved
src/commands/env/env-get.js Outdated Show resolved Hide resolved
src/commands/env/env-get.js Show resolved Hide resolved
src/commands/env/env-get.js Show resolved Hide resolved
src/commands/env/env-list.js Show resolved Hide resolved
@jasonbarry
Copy link
Contributor Author

@netlify/netlify-dev this is ready for a code review now, if one of y'all can spare a moment! ❤️

lukasholzer
lukasholzer previously approved these changes Aug 10, 2022
Copy link
Collaborator

@lukasholzer lukasholzer left a comment

Choose a reason for hiding this comment

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

THIS is an outstanding PR 👏 Very nicely documented and well tested! 💯
🐳

@jasonbarry
Copy link
Contributor Author

Why thank you @lukasholzer!! I realized a test was failing due to some capitalization of strings in logging 🤦 here's the change. Would you mind doing a re-review?

@jasonbarry jasonbarry added the automerge Add to Kodiak auto merge queue label Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants