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: warn users about frontdoor url #149

Merged
merged 3 commits into from
Sep 29, 2021
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
4 changes: 2 additions & 2 deletions messages/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ Browser in which to open the environment.

# flags.browser.description

You can specify that the environment open in one of the following browsers: Firefox, Safari, Google Chrome, or Windows Edge. If you don’t specify --browser, the environment opens in your default browser. The exact names of the browser applications differ depending on the operating system you're on; check your documentation for details.
You can specify that the environment open in one of the following browsers: Firefox, Safari, Google Chrome, or Windows Edge. If you don’t specify --browser, the environment opens in your default browser. The exact names of the browser applications differ depending on the operating system you're on; check your documentation for details.

# error.NoDefaultEnv

No default environment found. Use -e or --target-env to specify an environment to open.
No default environment found. Use -e or --target-env to specify an environment to open.

# error.NoEnvFound

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"author": "Salesforce",
"bugs": "https://github.com/salesforcecli/cli/issues",
"dependencies": {
"@oclif/core": "^0.5.39",
"@oclif/core": "^0.5.41",
"@salesforce/core": "3.6.2",
"@salesforce/sf-plugins-core": "^0.0.25",
"@salesforce/sf-plugins-core": "^0.0.27",
"change-case": "^4.1.2",
"cli-ux": "^5.6.3",
"open": "^8.2.0",
Expand Down
21 changes: 3 additions & 18 deletions src/commands/env/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { SfCommand } from '@salesforce/sf-plugins-core';
import { Logger, Messages, Org, SfdxError } from '@salesforce/core';
import * as open from 'open';
import type { Options } from 'open';
import { isArray } from '@salesforce/ts-types';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/plugin-env', 'open');

type Environment = { name: string; openUrl: string };

export type OpenResult = { url: string };

export default class EnvOpen extends SfCommand<OpenResult> {
Expand Down Expand Up @@ -69,19 +66,7 @@ export default class EnvOpen extends SfCommand<OpenResult> {
}

if (!url) {
let foundEnvs: Environment[] = [];
const push = (envs: Environment | Environment[]): void => {
foundEnvs = [...foundEnvs, ...(isArray(envs) ? envs : [envs])];
};
await this.config.runHook('environments-request', { push });

const foundEnv = foundEnvs.find((env) => env.name === nameOrAlias);

if (!foundEnv) {
throw messages.createError('error.NoEnvFound', [nameOrAlias]);
}

url = foundEnv.openUrl;
throw messages.createError('error.NoEnvFound', [nameOrAlias]);
}

if (url) {
Expand All @@ -91,7 +76,7 @@ export default class EnvOpen extends SfCommand<OpenResult> {
url = frontDoorUrl.toString();
}
if (flags['url-only']) {
this.log(url);
this.logSensitive(url);
} else {
const browser = flags.browser;
const browserName = browser ? browser : 'the default browser';
Expand Down Expand Up @@ -130,7 +115,7 @@ export default class EnvOpen extends SfCommand<OpenResult> {
return new Promise((resolve, reject) => {
process.stderr.on('data', (chunk) => chunks.push(Buffer.from(chunk)));

const resolveOrReject = (code): void => {
const resolveOrReject = (code: number): void => {
// stderr could contain warnings or random data, so we will only error if we know there is a valid error.
const validErrors = [
'Unable to find application named',
Expand Down
35 changes: 29 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@
is-wsl "^2.1.1"
tslib "^2.0.0"

"@oclif/[email protected]", "@oclif/core@^0.5.38", "@oclif/core@^0.5.39":
"@oclif/[email protected]", "@oclif/core@^0.5.38":
version "0.5.39"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-0.5.39.tgz#d00705f31c5e6617145e84bb9dd50156cf3b01c5"
integrity sha512-4XusxLX8PnHDQxtRP25PImlkIj1Mlx6wt0NWb1FxQGvTJOAgXGJZl3YB02ZeXZLYbeKA2A3AqqxFTTKbADnZng==
Expand Down Expand Up @@ -721,6 +721,29 @@
widest-line "^3.1.0"
wrap-ansi "^7.0.0"

"@oclif/core@^0.5.41":
version "0.5.41"
resolved "https://registry.npmjs.org/@oclif/core/-/core-0.5.41.tgz#54ab600b1b6017f3849e629401eafd4f4e3a5c2e"
integrity sha512-zEYbpxSQr80t7MkLMHOmZr8QCrCIbVrI7fLSZWlsvD2AEM0vvzuhWymjo9/kHy2/kNfxwu7NTI4i2a0zoHu11w==
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"
Expand Down Expand Up @@ -1191,12 +1214,12 @@
cli-ux "^5.6.3"
inquirer "^8.1.1"

"@salesforce/sf-plugins-core@^0.0.25":
version "0.0.25"
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-0.0.25.tgz#bb8012cae2911c8965d959595006a570ab5c6405"
integrity sha512-2mxQvEldZYG5BSvFNReeu/MIZ0h2+6KYfGC8i1lWan8YYsUbrzdWS6JK3pVw/IOMTuBXuxs05vOVVmzsR6vyCA==
"@salesforce/sf-plugins-core@^0.0.27":
version "0.0.27"
resolved "https://registry.npmjs.org/@salesforce/sf-plugins-core/-/sf-plugins-core-0.0.27.tgz#41a2d8d6c0f6ba1c46d6c23ff546b1ae0c2404e7"
integrity sha512-FpIyIDB46WWWAEVo+y4uGrKfugtLXq6+Gmli21l40f+J166rCvE8yszF+0nvD8V9xGw3By0XEkwMC6fTseYqKw==
dependencies:
"@oclif/core" "^0.5.39"
"@oclif/core" "^0.5.41"
"@salesforce/core" "^3.6.2"
"@salesforce/kit" "^1.5.17"
"@salesforce/ts-types" "^1.5.20"
Expand Down