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
Show file tree
Hide file tree
Changes from 2 commits
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: 4 additions & 14 deletions messages/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %> [email protected]

- 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

Expand All @@ -34,6 +24,6 @@ No results found.

No environment found for %s.

# error.NoDefaultEnv
# warning.orgsNoLongerSupported

No default environment found. Use -e or --target-env to specify an environment to display.
This command only displays functions environments. Use "%s org display" to display an org.
22 changes: 6 additions & 16 deletions messages/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -74,14 +64,14 @@ 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.

# warning.RequestedColumnsNotPresentInEnvironment

The columns you specified (%s) aren't available in the table for environment "%s".

# warning.orgsNoLongerSupported

This command only lists functions environments. Use "%s org list" to list orgs.
4 changes: 4 additions & 0 deletions messages/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ The environment %s doesn't support being opened.
# error.ApplicationNotFound

Can't find application named %s.

# warning.orgsNoLongerSupported

This command only opens a function's environment. Use "%s org open" to open an org.
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.

10 changes: 3 additions & 7 deletions src/commands/env/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ export default class EnvDisplay extends SfCommand<JsonObject> {
};

public async run(): Promise<JsonObject> {
this.warn(messages.getMessage('warning.orgsNoLongerSupported', [this.config.bin]));
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;
Expand Down
8 changes: 1 addition & 7 deletions src/commands/env/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -82,6 +75,7 @@ export default class EnvList extends SfCommand<Environments> {
private flags!: Interfaces.InferredFlags<typeof EnvList.flags>;

public async run(): Promise<Environments> {
this.warn(messages.getMessage('warning.orgsNoLongerSupported', [this.config.bin]));
this.flags = (await this.parse(EnvList)).flags;
const tableOpts = {
columns: this.flags.columns?.join(','),
Expand Down
2 changes: 2 additions & 0 deletions src/commands/env/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class EnvOpen extends SfCommand<OpenResult> {
};

public async run(): Promise<OpenResult> {
this.warn(messages.getMessage('warning.orgsNoLongerSupported', [this.config.bin]));
const { flags } = await this.parse(EnvOpen);
const nameOrAlias = flags['target-env'];
let url: string;
Expand All @@ -53,6 +54,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();
Expand Down
22 changes: 0 additions & 22 deletions src/hooks/envDisplay.ts

This file was deleted.

Loading