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: disconnect orgs from env commands #513

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions messages/display.md
Original file line number Diff line number Diff line change
@@ -6,21 +6,11 @@ Display details about an environment.

Specify an environment with either the username you used when you logged into the environment with "sf login", or the alias you gave the environment when you created it. Run "sf env list" to view all your environments and their aliases.

Output depends on the type of environment. For example, scratch org details include the access token, alias, username of the associated Dev Hub, the creation and expiration date, the generated scratch org username, and more. Compute environment details include the alias, connected orgs, creation date, project name, and more.
Output depends on the type of environment.

# examples

- Display details about a scratch org with alias my-scratch-org:

<%= config.bin %> <%= command.id %> --target-env=my-scratch-org

- Specify a username instead of an alias:

<%= config.bin %> <%= command.id %> --target-env=test-123456-abcdefg@example.com

- Specify JSON format and redirect output into a file:

<%= config.bin %> <%= command.id %> --target-env=my-scratch-org --json > tmp/MyOrdDesc.json
- <%- config.bin %> <%- command.id %> --target-env myEnv

# flags.target-env.summary

@@ -33,7 +23,3 @@ No results found.
# error.NoEnvFound

No environment found for %s.

# error.NoDefaultEnv

No default environment found. Use -e or --target-env to specify an environment to display.
18 changes: 2 additions & 16 deletions messages/list.md
Original file line number Diff line number Diff line change
@@ -4,11 +4,9 @@ List the environments you’ve created or logged into.

# description

By default, the command displays active environments. For orgs, active means unexpired scratch orgs and orgs you’re currently logged into.
By default, the command displays active environments.

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 and compute environments get their own tables.

The two org tables show similar information, such as aliases, information about the org, and how you authorized (logged into) it, such as with a web browser or JWT. The scratch org table also shows the expiration date. 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. Your default scratch org or Dev Hub org is indicated with the "target-org" or "target-dev-hub" configuration variable, respectively, in the Config column.
Output is displayed in multiple tables, one for each environment type.

The compute environment table shows the alias, information about the connected orgs, the project name, and more.

@@ -26,14 +24,6 @@ Run "sf env display" to view details about a specific environment.

<%= config.bin %> <%= command.id %> --all

- Filter the output to list only orgs you authorized using a web browser; "Auth Method" is the name of a column:

<%= config.bin %> <%= command.id %> --filter "Auth Method=web"

- Display only the Aliases column and sort the aliases in descending order:

<%= config.bin %> <%= command.id %> --sort "-Aliases" --columns "Aliases"

- Don't truncate the displayed output and instead wrap text that's wider than your terminal:

<%= config.bin %> <%= command.id %> --no-truncate
@@ -74,10 +64,6 @@ Format in which to display the output.

Column to sort by (prepend '-' for descending).

# error.NoAuthsAvailable

No authenticated environments found. Log in or create an environment, and then try again.

# error.NoResultsFound

No results found.
8 changes: 8 additions & 0 deletions messages/open.md
Original file line number Diff line number Diff line change
@@ -63,3 +63,11 @@ The environment %s doesn't support being opened.
# error.ApplicationNotFound

Can't find application named %s.

# deprecationMessage

This command will be deprecated in a future release.

# deprecatedInFavorOf

<%= config.bin %> org open
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -71,10 +71,6 @@
"commands": "./lib/commands",
"bin": "sf",
"topicSeparator": " ",
"hooks": {
"sf:env:display": "./lib/hooks/envDisplay",
"sf:env:list": "./lib/hooks/envList"
},
"devPlugins": [
"@oclif/plugin-help",
"@oclif/plugin-command-snapshot",
@@ -114,4 +110,4 @@
"access": "public"
},
"main": "lib/index.js"
}
}
88 changes: 0 additions & 88 deletions schemas/hooks/sf-env-display.json

This file was deleted.

47 changes: 0 additions & 47 deletions schemas/hooks/sf-env-list.json

This file was deleted.

9 changes: 2 additions & 7 deletions src/commands/env/display.ts
Original file line number Diff line number Diff line change
@@ -25,19 +25,14 @@ export default class EnvDisplay extends SfCommand<JsonObject> {

public async run(): Promise<JsonObject> {
const { flags } = await this.parse(EnvDisplay);
// TODO: access this from ConfigAggregator once target-env config var is supported.
const targetEnv = flags['target-env'];

if (!targetEnv) throw messages.createError('error.NoDefaultEnv');

let data: JsonObject = {};

try {
const results = await SfHook.run(this.config, 'sf:env:display', { targetEnv });
const results = await SfHook.run(this.config, 'sf:env:display', { targetEnv: flags['target-env'] });
const result = results.successes.find((s) => !!s.result?.data)?.result || null;

if (!result) {
throw messages.createError('error.NoEnvFound', [targetEnv]);
throw messages.createError('error.NoEnvFound', [flags['target-env']]);
}

data = result.data;
7 changes: 0 additions & 7 deletions src/commands/env/list.ts
Original file line number Diff line number Diff line change
@@ -15,13 +15,6 @@ const messages = Messages.loadMessages('@salesforce/plugin-env', 'list');

const envTypeValues = Object.keys(Env.EnvType);
const envOrderBy = (a: Env.Table<JsonObject>, b: Env.Table<JsonObject>): number => {
// both a && b are well known
if (envTypeValues.includes(a.type) && envTypeValues.includes(a.type)) {
if (a.type === Env.EnvType.salesforceOrgs && b.type !== Env.EnvType.salesforceOrgs) return -1;
if (a.type !== Env.EnvType.salesforceOrgs && b.type === Env.EnvType.salesforceOrgs) return 1;
if (a.type === Env.EnvType.scratchOrgs && b.type !== Env.EnvType.scratchOrgs) return -1;
return 1;
}
// both a && b are user defined - use natural sort
if (!envTypeValues.includes(a.type) && !envTypeValues.includes(a.type)) {
return a.type.localeCompare(b.type);
7 changes: 7 additions & 0 deletions src/commands/env/open.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,12 @@ export default class EnvOpen extends SfCommand<OpenResult> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly state = 'deprecated';
public static readonly deprecationOptions = {
to: messages.getMessage('deprecatedInFavorOf'),
message: messages.getMessage('deprecationMessage'),
version: '60.0',
};

public static readonly flags = {
path: Flags.string({
@@ -53,6 +59,7 @@ export default class EnvOpen extends SfCommand<OpenResult> {

try {
const org = await Org.create({ aliasOrUsername: nameOrAlias });
// eslint-disable-next-line sf-plugin/get-connection-with-version
const conn = org.getConnection();
await org.refreshAuth();
const authInfo = conn.getAuthInfo();
22 changes: 0 additions & 22 deletions src/hooks/envDisplay.ts

This file was deleted.

78 changes: 0 additions & 78 deletions src/hooks/envList.ts

This file was deleted.

Loading