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: allow CONTENT_TYPE env to work for all oclif cmds #753

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

mshanemc
Copy link
Member

@mshanemc mshanemc commented Jul 31, 2023

read CONTENT_TYPE=json from the env

forcedotcom/cli#2331
@W-13848014@

before/after
Screenshot 2023-07-31 at 1 10 53 PM

QA:
compile this
yarn link into oclif/plugin-version
sf plugins link . (inside oclif/plugin-version). This is needed to get the SF into the scopedEnvVars. Otherwise (bin/dev), you've got to do it with the plugin, but note that the @ | /| - are transformed by oclif config/scopedEnvVars
SF_CONTENT_TYPE=json sf version


// mock a scopedEnvVar being set to JSON
const cmd = new CMD([], {
bin: 'FOO', scopedEnvVar: (foo: string) => foo.includes('CONTENT_TYPE') ? 'json' : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

there's an .env() on fancy-test that lets you set env vars if you prefer

Copy link
Member Author

Choose a reason for hiding this comment

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

that didn't work when I tried it

mdonnalley
mdonnalley previously approved these changes Jul 31, 2023
WillieRuemmele
WillieRuemmele previously approved these changes Jul 31, 2023
@mshanemc mshanemc dismissed stale reviews from WillieRuemmele and mdonnalley via 378a4f7 July 31, 2023 19:38
@WillieRuemmele
Copy link
Contributor

QA Notes


Following the QA instructions above, confirmed working

 ➜  SF_CONTENT_TYPE=json sf version
{
  "cliVersion": "@salesforce/cli/2.1.7",
  "architecture": "darwin-arm64",
  "nodeVersion": "node-v18.16.0"
}

✅ : jqable results

➜  plugin-version git:(main) 🔗1
 ➜  SF_CONTENT_TYPE=json sf version | jq .cliVersion
"@salesforce/cli/2.1.7"

✅ : confirmed NOT working in plugin-commands before linking

 ➜  SF_CONTENT_TYPE=json sf commands                
 Command                               Summary                                                                                                                             
 ───────────────────────────────────── ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
 alias list                            List all aliases currently set on your local computer.  

✅ : working after linking

 ➜  SF_CONTENT_TYPE=json sf commands
[
  {
    "id": "alias:list",

✅ : jqable

 ➜  SF_CONTENT_TYPE=json sf commands|jq '.[0].id'
"alias:list"

✅ : doesn't override flag

 ➜  SF_CONTENT_TYPE=notjson sf commands --json|jq '.[0].id'
"alias:list"

@WillieRuemmele WillieRuemmele merged commit b25ed8d into main Aug 3, 2023
23 checks passed
@WillieRuemmele WillieRuemmele deleted the sm/scoped-env-var-CONTENT_TYPE branch August 3, 2023 18:00
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