diff --git a/command-snapshot.json b/command-snapshot.json index 9309e24b..ff82d63e 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -7,7 +7,7 @@ { "command": "env:list", "plugin": "@salesforce/plugin-env", - "flags": ["columns", "csv", "extended", "filter", "json", "no-header", "no-truncate", "output", "sort"] + "flags": ["all", "columns", "csv", "extended", "filter", "json", "no-header", "no-truncate", "output", "sort"] }, { "command": "env:open", diff --git a/messages/list.md b/messages/list.md index 7f9cc1e2..e778abc8 100644 --- a/messages/list.md +++ b/messages/list.md @@ -4,13 +4,13 @@ List the environments you’ve created or logged into. # description -The command displays only active environments. For orgs, active means unexpired scratch orgs and orgs you’re currently logged into. +The command displays only active environments. For orgs, active means unexpired scratch orgs and orgs you’re currently logged into. Output is displayed in multiple tables, one for each environment type. For example, the Salesforce Orgs table lists the non-scratch orgs you’re logged into, such as sandboxes, Dev Hubs, production orgs, and so on. Scratch orgs get their own table. For non-scratch orgs, the Username column refers to the user you logged into the org with. For scratch orgs it refers to the username that was generated for you when you created the scratch org. The table also displays the default environment for each type, the instance URL, and how you authorized (logged into) the org, either using a web browser or JWT. -Use the table-manipulation flags, such as --filter and --sort, to change how the data is displayed. +Use the table-manipulation flags, such as --filter and --sort, to change how the data is displayed. Run "sf env display" to view details about a specific environment. @@ -20,6 +20,10 @@ Run "sf env display" to view details about a specific environment. <%= config.bin %> <%= command.id %> +- List all environments: + + <%= config.bin %> <%= command.id %> --all + - Filter the output to list only orgs you authorized using a web browser; "OAuth Method" is the name of a column: <%= config.bin %> <%= command.id %> --filter "OAuth Method=web" @@ -31,11 +35,15 @@ Run "sf env display" to view details about a specific environment. - Don't truncate the displayed output: <%= config.bin %> <%= command.id %> --no-truncate - + - Display only the table data, not the headers, in comma-separated value (csv) format: <%= config.bin %> <%= command.id %> --csv --no-header +# flags.all.summary + +Show all envs regardless of status. + # flags.extended.summary Show extra columns. @@ -62,7 +70,7 @@ Don't truncate output to fit screen. # flags.output.summary -Format in which to display the output. +Format in which to display the output. # flags.sort.summary diff --git a/package.json b/package.json index f314f6aa..3c440d2d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Salesforce", "bugs": "https://github.com/forcedotcom/cli/issues", "dependencies": { - "@oclif/core": "^0.5.26", + "@oclif/core": "^0.5.29", "@salesforce/core": "3.3.11", "cli-ux": "^5.6.3", "open": "^8.2.0", diff --git a/schemas/env-display.json b/schemas/env-display.json index b1918303..0c56e3fd 100644 --- a/schemas/env-display.json +++ b/schemas/env-display.json @@ -13,12 +13,7 @@ }, "oauthMethod": { "type": "string", - "enum": [ - "jwt", - "web", - "token", - "unknown" - ] + "enum": ["jwt", "web", "token", "unknown"] }, "aliases": { "anyOf": [ @@ -49,6 +44,9 @@ "isScratchOrg": { "type": "boolean" }, + "isDevHub": { + "type": "boolean" + }, "instanceUrl": { "type": "string" }, @@ -57,14 +55,21 @@ }, "error": { "type": "string" + }, + "isExpired": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "string", + "const": "unknown" + } + ] } }, - "required": [ - "orgId", - "username", - "oauthMethod" - ], + "required": ["orgId", "username", "oauthMethod", "isExpired"], "additionalProperties": false } } -} \ No newline at end of file +} diff --git a/schemas/env-list.json b/schemas/env-list.json index ad977790..8ba1e2f4 100644 --- a/schemas/env-list.json +++ b/schemas/env-list.json @@ -19,12 +19,7 @@ }, "oauthMethod": { "type": "string", - "enum": [ - "jwt", - "web", - "token", - "unknown" - ] + "enum": ["jwt", "web", "token", "unknown"] }, "aliases": { "anyOf": [ @@ -55,6 +50,9 @@ "isScratchOrg": { "type": "boolean" }, + "isDevHub": { + "type": "boolean" + }, "instanceUrl": { "type": "string" }, @@ -63,14 +61,21 @@ }, "error": { "type": "string" + }, + "isExpired": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "string", + "const": "unknown" + } + ] } }, - "required": [ - "orgId", - "username", - "oauthMethod" - ], + "required": ["orgId", "username", "oauthMethod", "isExpired"], "additionalProperties": false } } -} \ No newline at end of file +} diff --git a/src/commands/env/list.ts b/src/commands/env/list.ts index 7357474a..693cb2a0 100644 --- a/src/commands/env/list.ts +++ b/src/commands/env/list.ts @@ -19,10 +19,9 @@ export default class EnvList extends Command { public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); public static flags = { - extended: Flags.boolean({ - char: 'x', - summary: messages.getMessage('flags.extended.summary'), - hidden: true, + all: Flags.boolean({ + summary: messages.getMessage('flags.all.summary'), + char: 'a', }), columns: Flags.string({ summary: messages.getMessage('flags.columns.summary'), @@ -31,6 +30,11 @@ export default class EnvList extends Command { csv: Flags.boolean({ summary: messages.getMessage('flags.csv.summary'), }), + extended: Flags.boolean({ + char: 'x', + summary: messages.getMessage('flags.extended.summary'), + hidden: true, + }), filter: Flags.string({ summary: messages.getMessage('flags.filter.summary'), }), @@ -49,11 +53,12 @@ export default class EnvList extends Command { }), }; private flags!: { - json: boolean; - extended: boolean; + all: boolean; columns: string[]; csv: boolean; + extended: boolean; filter: string; + json: boolean; 'no-header': boolean; 'no-truncate': boolean; output: string; @@ -78,7 +83,14 @@ export default class EnvList extends Command { } private async handleSfOrgs(): Promise { - const auths = await AuthInfo.listAllAuthorizations(); + let auths: OrgAuthorization[]; + + if (this.flags.all) { + auths = await AuthInfo.listAllAuthorizations(); + } else { + // Only get active auths + auths = await AuthInfo.listAllAuthorizations((auth) => auth.isExpired !== false); + } const grouped = { nonScratchOrgs: [] as OrgAuthorization[], diff --git a/yarn.lock b/yarn.lock index 224a6d60..e17beae1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -491,6 +491,29 @@ widest-line "^3.1.0" wrap-ansi "^7.0.0" +"@oclif/core@^0.5.29": + version "0.5.29" + resolved "https://registry.yarnpkg.com/@oclif/core/-/core-0.5.29.tgz#97d02f6f06d94f457d494d6cb526d6bbcb37f7ec" + integrity sha512-v5MMxeTgEKbVcEl7D3jsTVL8Wy3lLTDj0KHX7cOmI751yfjdAOqy9frHQ6IXssxubDkBW6sXzbYN9Bw12zsBqg== + dependencies: + "@oclif/linewrap" "^1.0.0" + chalk "^4.1.0" + clean-stack "^3.0.0" + cli-ux "^5.1.0" + debug "^4.1.1" + fs-extra "^9.0.1" + get-package-type "^0.1.0" + globby "^11.0.1" + indent-string "^4.0.0" + is-wsl "^2.1.1" + lodash.template "^4.4.0" + semver "^7.3.2" + string-width "^4.2.0" + strip-ansi "^6.0.0" + tslib "^2.0.0" + widest-line "^3.1.0" + wrap-ansi "^7.0.0" + "@oclif/dev-cli@^1": version "1.26.0" resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.26.0.tgz#e3ec294b362c010ffc8948003d3770955c7951fd"