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: private browser #923

Closed
wants to merge 12 commits into from
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ FLAG DESCRIPTIONS
sandbox.
```

_See code: [lib/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/create/sandbox.ts)_
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/create/sandbox.ts)_

## `sf org create scratch`

Expand Down Expand Up @@ -369,7 +369,7 @@ FLAG DESCRIPTIONS
Omit this flag to have Salesforce generate a unique username for your org.
```

_See code: [lib/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/create/scratch.ts)_
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/create/scratch.ts)_

## `sf org delete sandbox`

Expand Down Expand Up @@ -413,7 +413,7 @@ EXAMPLES
$ sf org delete sandbox --target-org my-sandbox --no-prompt
```

_See code: [lib/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/delete/sandbox.ts)_
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/delete/sandbox.ts)_

## `sf org delete scratch`

Expand Down Expand Up @@ -455,7 +455,7 @@ EXAMPLES
$ sf org delete scratch --target-org my-scratch-org --no-prompt
```

_See code: [lib/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/delete/scratch.ts)_
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/delete/scratch.ts)_

## `sf org disable tracking`

Expand Down Expand Up @@ -493,7 +493,7 @@ EXAMPLES
$ sf org disable tracking
```

_See code: [lib/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/disable/tracking.ts)_
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/disable/tracking.ts)_

## `sf org display`

Expand Down Expand Up @@ -537,7 +537,7 @@ EXAMPLES
$ sf org display --target-org TestOrg1 --verbose
```

_See code: [lib/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/display.ts)_
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/display.ts)_

## `sf org enable tracking`

Expand Down Expand Up @@ -578,7 +578,7 @@ EXAMPLES
$ sf org enable tracking
```

_See code: [lib/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/enable/tracking.ts)_
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/enable/tracking.ts)_

## `sf org list`

Expand Down Expand Up @@ -616,7 +616,7 @@ EXAMPLES
$ sf org list --clean
```

_See code: [lib/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/list.ts)_
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/list.ts)_

## `sf org list metadata`

Expand Down Expand Up @@ -681,7 +681,7 @@ FLAG DESCRIPTIONS
Examples of metadata types that use folders are Dashboard, Document, EmailTemplate, and Report.
```

_See code: [lib/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/list/metadata.ts)_
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/list/metadata.ts)_

## `sf org list metadata-types`

Expand Down Expand Up @@ -735,7 +735,7 @@ FLAG DESCRIPTIONS
Override the api version used for api requests made by this command
```

_See code: [lib/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/list/metadata-types.ts)_
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/list/metadata-types.ts)_

## `sf org open`

Expand Down Expand Up @@ -801,7 +801,7 @@ EXAMPLES
$ sf org open --source-file force-app/main/default/flows/Hello.flow-meta.xml
```

_See code: [lib/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/open.ts)_
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/open.ts)_

## `sf org resume sandbox`

Expand Down Expand Up @@ -863,7 +863,7 @@ FLAG DESCRIPTIONS
returns the job ID. To resume checking the sandbox creation, rerun this command.
```

_See code: [lib/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/resume/sandbox.ts)_
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/resume/sandbox.ts)_

## `sf org resume scratch`

Expand Down Expand Up @@ -909,6 +909,6 @@ FLAG DESCRIPTIONS
The job ID is valid for 24 hours after you start the scratch org creation.
```

_See code: [lib/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/lib/commands/org/resume/scratch.ts)_
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/3.2.1/src/commands/org/resume/scratch.ts)_

<!-- commandsstop -->
6 changes: 6 additions & 0 deletions messages/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ To generate a URL but not launch it in your browser, specify --url-only.

To open in a specific browser, use the --browser flag. Supported browsers are "chrome", "edge", and "firefox". If you don't specify --browser, the org opens in your default browser.

To open in an incognito window using your default browser, use `--browser browserPrivate`.

# examples

- Open your default org in your default browser:

$ <%= config.bin %> <%= command.id %>

- Open your default org in your default browser using an incognito window:

$ <%= config.bin %> <%= command.id %> --browser browserPrivate

- Open the org with alias MyTestOrg1 in the Firefox browser:

$ <%= config.bin %> <%= command.id %> --target-org MyTestOrg1 --browser firefox
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^3.15.1",
"@oclif/core": "^3.16.0",
"@salesforce/core": "^6.4.4",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^5.0.3",
"@salesforce/sf-plugins-core": "^7.0.0",
"@salesforce/source-deploy-retrieve": "^10.2.5",
"chalk": "^4",
"chalk": "^5.3.0",
"change-case": "^5.3.0",
"open": "^9.1.0"
"open": "^10.0.3"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^5.0.5",
Expand Down
16 changes: 6 additions & 10 deletions src/commands/force/org/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,6 @@ export class Create extends SfCommand<CreateResult> {

this.logger.debug('validation complete');

// If the user supplied a specific client ID, we have no way of knowing if it's
// a certificate-based Connected App or not. Therefore, we have to assume that
// we'll need the client secret, so prompt the user for it.
const { clientSecret } = this.flags.clientid
? await this.prompt<{ clientSecret: string }>([
{ name: 'clientSecret', type: 'mask', message: messages.getMessage('secretPrompt') },
])
: { clientSecret: undefined };

const createCommandOptions: ScratchOrgRequest = {
connectedAppConsumerKey: this.flags.clientid,
durationDays: this.flags.durationdays,
Expand All @@ -282,7 +273,12 @@ export class Create extends SfCommand<CreateResult> {
apiversion: this.flags['api-version'],
definitionfile: this.flags.definitionfile,
orgConfig: this.varArgs,
clientSecret,
// If the user supplied a specific client ID, we have no way of knowing if it's
// a certificate-based Connected App or not. Therefore, we have to assume that
// we'll need the client secret, so prompt the user for it.
clientSecret: this.flags.clientid
? await this.secretPrompt({ message: messages.getMessage('secretPrompt') })
: undefined,
setDefault: this.flags.setdefaultusername === true,
alias: this.flags.setalias,
tracksSource: true,
Expand Down
4 changes: 3 additions & 1 deletion src/commands/force/org/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export class Delete extends SfCommand<DeleteResult> {
// we either need permission to proceed without a prompt OR get the user to confirm
if (
flags['no-prompt'] ||
(await this.confirm(messages.getMessage('confirmDelete', [isSandbox ? 'sandbox' : 'scratch', resolvedUsername])))
(await this.confirm({
message: messages.getMessage('confirmDelete', [isSandbox ? 'sandbox' : 'scratch', resolvedUsername]),
}))
) {
let alreadyDeleted = false;
let successMessageKey = 'commandSandboxSuccess';
Expand Down
20 changes: 6 additions & 14 deletions src/commands/org/create/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/



import { Duration } from '@salesforce/kit';
import { Flags } from '@salesforce/sf-plugins-core';
import { Lifecycle, Messages, SandboxEvents, SandboxProcessObject, SandboxRequest, SfError } from '@salesforce/core';
Expand All @@ -16,7 +14,7 @@ import requestFunctions from '../../../shared/sandboxRequest.js';
import { SandboxCommandBase } from '../../../shared/sandboxCommandBase.js';
import { SandboxLicenseType } from '../../../shared/orgTypes.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'create.sandbox');

const getLicenseTypes = (): string[] => Object.values(SandboxLicenseType);
Expand Down Expand Up @@ -225,17 +223,11 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
this.styledHeader('Config Sandbox Request');
this.table(data, columns, {});

const configurationCorrect = await this.timedPrompt<{ continue: boolean }>(
[
{
name: 'continue',
type: 'confirm',
message: messages.getMessage('isConfigurationOk'),
},
],
10_000
);
if (!configurationCorrect.continue) {
if (
!(await this.confirm({
message: messages.getMessage('isConfigurationOk'),
}))
) {
throw messages.createError('error.UserNotSatisfiedWithSandboxConfig');
}
}
Expand Down
16 changes: 1 addition & 15 deletions src/commands/org/create/scratch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {

const createCommandOptions = await buildScratchOrgRequest(
flags,
flags['client-id'] ? await this.clientSecretPrompt() : undefined
flags['client-id'] ? await this.secretPrompt({ message: messages.getMessage('prompt.secret') }) : undefined
);
let lastStatus: string | undefined;

Expand Down Expand Up @@ -210,18 +210,4 @@ export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
}
}
}

private async clientSecretPrompt(): Promise<string> {
const { secret } = await this.timedPrompt<{ secret: string }>(
[
{
name: 'secret',
message: messages.getMessage('prompt.secret'),
type: 'password',
},
],
secretTimeout
);
return secret;
}
}
5 changes: 2 additions & 3 deletions src/commands/org/delete/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/


import { AuthInfo, AuthRemover, Messages, Org, SfError, StateAggregator } from '@salesforce/core';
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { orgThatMightBeDeleted } from '../../../shared/flags.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'delete_sandbox');

export interface SandboxDeleteResponse {
Expand Down Expand Up @@ -62,7 +61,7 @@ export default class DeleteSandbox extends SfCommand<SandboxDeleteResponse> {
throw messages.createError('error.unknownSandbox', [username]);
}

if (flags['no-prompt'] || (await this.confirm(messages.getMessage('prompt.confirm', [username])))) {
if (flags['no-prompt'] || (await this.confirm({ message: messages.getMessage('prompt.confirm', [username]) }))) {
try {
const org = await Org.create({ aliasOrUsername: username });
await org.delete();
Expand Down
9 changes: 5 additions & 4 deletions src/commands/org/delete/scratch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/



import { AuthInfo, AuthRemover, Messages, Org } from '@salesforce/core';
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { orgThatMightBeDeleted } from '../../../shared/flags.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'delete_scratch');

export interface ScratchDeleteResponse {
Expand Down Expand Up @@ -41,7 +39,10 @@ export default class DeleteScratch extends SfCommand<ScratchDeleteResponse> {
const resolvedUsername = flags['target-org'];
const orgId = (await AuthInfo.create({ username: resolvedUsername })).getFields().orgId as string;

if (flags['no-prompt'] || (await this.confirm(messages.getMessage('prompt.confirm', [resolvedUsername])))) {
if (
flags['no-prompt'] ||
(await this.confirm({ message: messages.getMessage('prompt.confirm', [resolvedUsername]) }))
) {
try {
const org = await Org.create({ aliasOrUsername: resolvedUsername });

Expand Down
10 changes: 4 additions & 6 deletions src/commands/org/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/



import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core';
import { AuthInfo, ConfigAggregator, ConfigInfo, Connection, Org, SfError, Messages, Logger } from '@salesforce/core';
import { Interfaces } from '@oclif/core';
import chalk from 'chalk';
import chalk, { ChalkInstance } from 'chalk';
import { OrgListUtil, identifyActiveOrgByStatus } from '../../shared/orgListUtil.js';
import { getStyledObject } from '../../shared/orgHighlighter.js';
import { ExtendedAuthFields, FullyPopulatedScratchOrgFields } from '../../shared/orgTypes.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'list');

export const defaultOrgEmoji = '🍁';
Expand Down Expand Up @@ -117,7 +115,7 @@ Legend: ${defaultHubEmoji}=Default DevHub, ${defaultOrgEmoji}=Default Org ${
}

protected async cleanScratchOrgs(scratchOrgs: ExtendedAuthFields[], prompt?: boolean): Promise<void> {
if (prompt && (await this.confirm(messages.getMessage('prompt', [scratchOrgs.length]))) === false) {
if (prompt && (await this.confirm({ message: messages.getMessage('prompt', [scratchOrgs.length]) })) === false) {
return;
}

Expand Down Expand Up @@ -259,7 +257,7 @@ const addType =
(val: ExtendedAuthFields): ExtendedAuthFieldsWithType => ({ ...val, type });

const colorEveryFieldButConnectedStatus =
(colorFn: chalk.Chalk) =>
(colorFn: ChalkInstance) =>
(row: ExtendedAuthFieldsWithType): ExtendedAuthFieldsWithType =>
Object.fromEntries(
Object.entries(row).map(([key, val]) => [
Expand Down
Loading
Loading