cli icon indicating copy to clipboard operation
cli copied to clipboard

feat: read scopes and contexts in `env:get`, `env:list`, and `dev`

Open jasonbarry opened this issue 1 year ago โ€ข 3 comments

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:

  • [x] 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.
  • [x] Read the contribution guidelines ๐Ÿ“–. This ensures your code follows our style guide and passes our tests.
  • [x] Update or add tests (if any source code was changed or added) ๐Ÿงช
  • [x] Update or add documentation (if features were changed or added) ๐Ÿ“
  • [x] 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

jasonbarry avatar Jul 21 '22 01:07 jasonbarry

๐Ÿ“Š Benchmark results

Comparing with 7317269130ac4017d7d4771ae955f6424ce59e40

Package size: 228 MB

โฌ‡๏ธ 0.00% decrease vs. 7317269130ac4017d7d4771ae955f6424ce59e40

^  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
  • T-30 (dad8d9a57dee3c1e0bd2ed417e1dcee18866ecdb): 224 MB
  • T-29 (a04bc102c4485037ee5845ebe01a1fe8d3e55a5a): 224 MB
  • T-28 (20fa2b286b5cb5eb134630827c6fbee02b69aa1a): 224 MB
  • T-27 (f83a930add5b1ada8ae79ad8f494841556d1567d): 230 MB
  • T-26 (64789d0c133a55b48f74e95b845ced2d07e1a864): 230 MB
  • T-25 (8933bfb2b0b53d14a6d5532a1ad6c851842e64d8): 230 MB
  • T-24 (b98a4de807a2fa23addb9a7a32c35672eaecd16e): 230 MB
  • T-23 (61ba1ef4f263fe40b6c2b4bc186f55738e344be0): 230 MB
  • T-22 (7203fe5a13bad715863af2119f8488a10681c2ec): 230 MB
  • T-21 (22ac96087bb5ae39c1280b7c317a1ca78cafef31): 230 MB
  • T-20 (ca1c17fea2e8c98e4fe1fda5c6c2fb663fe46ed7): 230 MB
  • T-19 (b3dc89711e736d581b58ec55bae7d843894a6dfd): 230 MB
  • T-18 (ad84a4651f3da2c805e738dbafd4c9a869d59d77): 230 MB
  • T-17 (73d9a6e9c00ba5b056ee27406b0f4e107c192622): 230 MB
  • T-16 (c38d2de4d4a1d81db5052897f8d907d1deee4b1d): 230 MB
  • T-15 (490333a1ab09ae701566815ded1b30c3c1195f78): 230 MB
  • T-14 (08652bb3b74e9419ed6bb62a9627cb7c5cd88428): 230 MB
  • T-13 (4a6cb0e6f1aec54b74c1b70678ba0ceaf1b5c08a): 228 MB
  • T-12 (f02d08e2f86064322547b416dec51ea1d16987fa): 228 MB
  • T-11 (64e48dcd3440e137fb9d6d88f4bc1473878af304): 228 MB
  • T-10 (7c209cbd0bb6480a0f09444ce49c64eb6711f5da): 228 MB
  • T-9 (f362ec752e805323ae26c3c633d7f5920b88498b): 228 MB
  • T-8 (585d91e597420bd40d6240f2f02c9623ba6bd99c): 228 MB
  • T-7 (91f4ab26087319c1df411cabf108dcee712153d5): 228 MB
  • T-6 (868ec26799bc1ae506c4421a579e30cab37266a8): 228 MB
  • T-5 (df0c767dc9e97b765f21aa26836b028a784c0d46): 228 MB
  • T-4 (0290c4590c1dfb8a7ac485137ab8dacfa0c62927): 228 MB
  • T-3 (7337755f16fcd8b8cfa2eff362f2a81d21b484b7): 228 MB
  • T-2 (fb72d92c9ba23a5f41ddf7cd9850efd94fecee9d): 228 MB
  • T-1 (7317269130ac4017d7d4771ae955f6424ce59e40): 228 MB
  • T (current commit): 228 MB

github-actions[bot] avatar Jul 21 '22 01:07 github-actions[bot]

@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.

jasonbarry avatar Jul 28 '22 15:07 jasonbarry

@netlify/netlify-dev this is ready for a code review now, if one of y'all can spare a moment! โค๏ธ

jasonbarry avatar Aug 02 '22 00:08 jasonbarry

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 avatar Aug 11 '22 02:08 jasonbarry