@salesforce/plugin-org 5.1.4 → 5.1.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -14
- package/lib/commands/org/open/agent.d.ts +16 -0
- package/lib/commands/org/open/agent.js +59 -0
- package/lib/commands/org/open/agent.js.map +1 -0
- package/lib/commands/org/open.d.ts +5 -10
- package/lib/commands/org/open.js +10 -110
- package/lib/commands/org/open.js.map +1 -1
- package/lib/shared/orgOpenCommandBase.d.ts +15 -0
- package/lib/shared/orgOpenCommandBase.js +82 -0
- package/lib/shared/orgOpenCommandBase.js.map +1 -0
- package/lib/shared/orgOpenUtils.d.ts +18 -0
- package/lib/shared/orgOpenUtils.js +61 -0
- package/lib/shared/orgOpenUtils.js.map +1 -0
- package/lib/shared/orgTypes.d.ts +5 -0
- package/lib/shared/orgTypes.js.map +1 -1
- package/lib/shared/utils.d.ts +0 -4
- package/lib/shared/utils.js +6 -3
- package/lib/shared/utils.js.map +1 -1
- package/messages/open.agent.md +41 -0
- package/oclif.manifest.json +117 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -110,6 +110,7 @@ the [SandboxNuts](https://github.com/salesforcecli/plugin-org/actions/workflows/
|
|
|
110
110
|
- [`sf org list metadata`](#sf-org-list-metadata)
|
|
111
111
|
- [`sf org list metadata-types`](#sf-org-list-metadata-types)
|
|
112
112
|
- [`sf org open`](#sf-org-open)
|
|
113
|
+
- [`sf org open agent`](#sf-org-open-agent)
|
|
113
114
|
- [`sf org refresh sandbox`](#sf-org-refresh-sandbox)
|
|
114
115
|
- [`sf org resume sandbox`](#sf-org-resume-sandbox)
|
|
115
116
|
- [`sf org resume scratch`](#sf-org-resume-scratch)
|
|
@@ -241,7 +242,7 @@ FLAG DESCRIPTIONS
|
|
|
241
242
|
You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both.
|
|
242
243
|
```
|
|
243
244
|
|
|
244
|
-
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
245
|
+
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/create/sandbox.ts)_
|
|
245
246
|
|
|
246
247
|
## `sf org create scratch`
|
|
247
248
|
|
|
@@ -395,7 +396,7 @@ FLAG DESCRIPTIONS
|
|
|
395
396
|
Omit this flag to have Salesforce generate a unique username for your org.
|
|
396
397
|
```
|
|
397
398
|
|
|
398
|
-
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
399
|
+
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/create/scratch.ts)_
|
|
399
400
|
|
|
400
401
|
## `sf org delete sandbox`
|
|
401
402
|
|
|
@@ -441,7 +442,7 @@ EXAMPLES
|
|
|
441
442
|
$ sf org delete sandbox --target-org my-sandbox --no-prompt
|
|
442
443
|
```
|
|
443
444
|
|
|
444
|
-
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
445
|
+
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/delete/sandbox.ts)_
|
|
445
446
|
|
|
446
447
|
## `sf org delete scratch`
|
|
447
448
|
|
|
@@ -485,7 +486,7 @@ EXAMPLES
|
|
|
485
486
|
$ sf org delete scratch --target-org my-scratch-org --no-prompt
|
|
486
487
|
```
|
|
487
488
|
|
|
488
|
-
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
489
|
+
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/delete/scratch.ts)_
|
|
489
490
|
|
|
490
491
|
## `sf org disable tracking`
|
|
491
492
|
|
|
@@ -524,7 +525,7 @@ EXAMPLES
|
|
|
524
525
|
$ sf org disable tracking
|
|
525
526
|
```
|
|
526
527
|
|
|
527
|
-
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
528
|
+
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/disable/tracking.ts)_
|
|
528
529
|
|
|
529
530
|
## `sf org display`
|
|
530
531
|
|
|
@@ -569,7 +570,7 @@ EXAMPLES
|
|
|
569
570
|
$ sf org display --target-org TestOrg1 --verbose
|
|
570
571
|
```
|
|
571
572
|
|
|
572
|
-
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
573
|
+
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/display.ts)_
|
|
573
574
|
|
|
574
575
|
## `sf org enable tracking`
|
|
575
576
|
|
|
@@ -611,7 +612,7 @@ EXAMPLES
|
|
|
611
612
|
$ sf org enable tracking
|
|
612
613
|
```
|
|
613
614
|
|
|
614
|
-
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
615
|
+
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/enable/tracking.ts)_
|
|
615
616
|
|
|
616
617
|
## `sf org list`
|
|
617
618
|
|
|
@@ -650,7 +651,7 @@ EXAMPLES
|
|
|
650
651
|
$ sf org list --clean
|
|
651
652
|
```
|
|
652
653
|
|
|
653
|
-
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
654
|
+
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list.ts)_
|
|
654
655
|
|
|
655
656
|
## `sf org list metadata`
|
|
656
657
|
|
|
@@ -717,7 +718,7 @@ FLAG DESCRIPTIONS
|
|
|
717
718
|
Examples of metadata types that use folders are Dashboard, Document, EmailTemplate, and Report.
|
|
718
719
|
```
|
|
719
720
|
|
|
720
|
-
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
721
|
+
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list/metadata.ts)_
|
|
721
722
|
|
|
722
723
|
## `sf org list metadata-types`
|
|
723
724
|
|
|
@@ -772,7 +773,7 @@ FLAG DESCRIPTIONS
|
|
|
772
773
|
Override the api version used for api requests made by this command
|
|
773
774
|
```
|
|
774
775
|
|
|
775
|
-
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
776
|
+
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list/metadata-types.ts)_
|
|
776
777
|
|
|
777
778
|
## `sf org open`
|
|
778
779
|
|
|
@@ -848,7 +849,57 @@ EXAMPLES
|
|
|
848
849
|
$ sf org open --source-file force-app/main/default/bots/Coral_Cloud_Agent/Coral_Cloud_Agent.bot-meta.xml
|
|
849
850
|
```
|
|
850
851
|
|
|
851
|
-
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
852
|
+
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/open.ts)_
|
|
853
|
+
|
|
854
|
+
## `sf org open agent`
|
|
855
|
+
|
|
856
|
+
Open an agent in the Agent Builder org UI in a browser.
|
|
857
|
+
|
|
858
|
+
```
|
|
859
|
+
USAGE
|
|
860
|
+
$ sf org open agent -o <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>] [--private | -r |
|
|
861
|
+
-b chrome|edge|firefox]
|
|
862
|
+
|
|
863
|
+
FLAGS
|
|
864
|
+
-b, --browser=<option> Browser where the org opens.
|
|
865
|
+
<options: chrome|edge|firefox>
|
|
866
|
+
-n, --name=<value> (required) The developer name (aka API name) of the agent to open in the Agent Builder org
|
|
867
|
+
UI.
|
|
868
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
869
|
+
configuration variable is already set.
|
|
870
|
+
-r, --url-only Display navigation URL, but don’t launch browser.
|
|
871
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
872
|
+
--private Open the org in the default browser using private (incognito) mode.
|
|
873
|
+
|
|
874
|
+
GLOBAL FLAGS
|
|
875
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
876
|
+
--json Format output as json.
|
|
877
|
+
|
|
878
|
+
DESCRIPTION
|
|
879
|
+
Open an agent in the Agent Builder org UI in a browser.
|
|
880
|
+
|
|
881
|
+
Use the --name flag to open an agent using the developer name (aka API name) in the Agent Builder Org UI.
|
|
882
|
+
|
|
883
|
+
To generate a URL but not launch it in your browser, specify --url-only.
|
|
884
|
+
|
|
885
|
+
To open in a specific browser, use the --browser flag. Supported browsers are "chrome", "edge", and "firefox". If you
|
|
886
|
+
don't specify --browser, the org opens in your default browser.
|
|
887
|
+
|
|
888
|
+
EXAMPLES
|
|
889
|
+
Open the agent with developer name "Coral_Cloud_Agent using the default browser:
|
|
890
|
+
|
|
891
|
+
$ sf org open agent --name Coral_Cloud_Agent
|
|
892
|
+
|
|
893
|
+
Open the agent in an incognito window of your default browser:
|
|
894
|
+
|
|
895
|
+
$ sf org open agent --private --name Coral_Cloud_Agent
|
|
896
|
+
|
|
897
|
+
Open the agent in the org with alias MyTestOrg1 using the Firefox browser:
|
|
898
|
+
|
|
899
|
+
$ sf org open agent --target-org MyTestOrg1 --browser firefox --name Coral_Cloud_Agent
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
_See code: [src/commands/org/open/agent.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/open/agent.ts)_
|
|
852
903
|
|
|
853
904
|
## `sf org refresh sandbox`
|
|
854
905
|
|
|
@@ -925,7 +976,7 @@ FLAG DESCRIPTIONS
|
|
|
925
976
|
By default, a sandbox auto-activates after a refresh. Use this flag to control sandbox activation manually.
|
|
926
977
|
```
|
|
927
978
|
|
|
928
|
-
_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
979
|
+
_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/refresh/sandbox.ts)_
|
|
929
980
|
|
|
930
981
|
## `sf org resume sandbox`
|
|
931
982
|
|
|
@@ -988,7 +1039,7 @@ FLAG DESCRIPTIONS
|
|
|
988
1039
|
returns the job ID. To resume checking the sandbox creation, rerun this command.
|
|
989
1040
|
```
|
|
990
1041
|
|
|
991
|
-
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
1042
|
+
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/resume/sandbox.ts)_
|
|
992
1043
|
|
|
993
1044
|
## `sf org resume scratch`
|
|
994
1045
|
|
|
@@ -1035,6 +1086,6 @@ FLAG DESCRIPTIONS
|
|
|
1035
1086
|
The job ID is valid for 24 hours after you start the scratch org creation.
|
|
1036
1087
|
```
|
|
1037
1088
|
|
|
1038
|
-
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.
|
|
1089
|
+
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/resume/scratch.ts)_
|
|
1039
1090
|
|
|
1040
1091
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OrgOpenCommandBase } from '../../../shared/orgOpenCommandBase.js';
|
|
2
|
+
import { type OrgOpenOutput } from '../../../shared/orgTypes.js';
|
|
3
|
+
export declare class OrgOpenAgent extends OrgOpenCommandBase<OrgOpenOutput> {
|
|
4
|
+
static readonly summary: string;
|
|
5
|
+
static readonly description: string;
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
private: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
browser: import("@oclif/core/interfaces").OptionFlag<"chrome" | "firefox" | "edge" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'url-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<OrgOpenOutput>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { buildFrontdoorUrl } from '../../../shared/orgOpenUtils.js';
|
|
10
|
+
import { OrgOpenCommandBase } from '../../../shared/orgOpenCommandBase.js';
|
|
11
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
12
|
+
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open.agent');
|
|
13
|
+
export class OrgOpenAgent extends OrgOpenCommandBase {
|
|
14
|
+
static summary = messages.getMessage('summary');
|
|
15
|
+
static description = messages.getMessage('description');
|
|
16
|
+
static examples = messages.getMessages('examples');
|
|
17
|
+
static flags = {
|
|
18
|
+
'target-org': Flags.requiredOrg(),
|
|
19
|
+
'api-version': Flags.orgApiVersion(),
|
|
20
|
+
name: Flags.string({
|
|
21
|
+
char: 'n',
|
|
22
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
private: Flags.boolean({
|
|
26
|
+
summary: messages.getMessage('flags.private.summary'),
|
|
27
|
+
exclusive: ['url-only', 'browser'],
|
|
28
|
+
}),
|
|
29
|
+
browser: Flags.option({
|
|
30
|
+
char: 'b',
|
|
31
|
+
summary: messages.getMessage('flags.browser.summary'),
|
|
32
|
+
options: ['chrome', 'edge', 'firefox'], // These are ones supported by "open" package
|
|
33
|
+
exclusive: ['url-only', 'private'],
|
|
34
|
+
})(),
|
|
35
|
+
'url-only': Flags.boolean({
|
|
36
|
+
char: 'r',
|
|
37
|
+
summary: messages.getMessage('flags.url-only.summary'),
|
|
38
|
+
aliases: ['urlonly'],
|
|
39
|
+
deprecateAliases: true,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
async run() {
|
|
43
|
+
const { flags } = await this.parse(OrgOpenAgent);
|
|
44
|
+
this.org = flags['target-org'];
|
|
45
|
+
this.connection = this.org.getConnection(flags['api-version']);
|
|
46
|
+
const [frontDoorUrl, retUrl] = await Promise.all([
|
|
47
|
+
buildFrontdoorUrl(this.org, this.connection),
|
|
48
|
+
buildRetUrl(this.connection, flags.name),
|
|
49
|
+
]);
|
|
50
|
+
return this.openOrgUI(flags, frontDoorUrl, retUrl);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Build the URL part to the Agent Builder given a Bot API name.
|
|
54
|
+
const buildRetUrl = async (conn, botName) => {
|
|
55
|
+
const query = `SELECT id FROM BotDefinition WHERE DeveloperName='${botName}'`;
|
|
56
|
+
const botId = (await conn.singleRecordQuery(query)).Id;
|
|
57
|
+
return `AiCopilot/copilotStudio.app#/copilot/builder?copilotId=${botId}`;
|
|
58
|
+
};
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M,IAAI,CAAC,iBAAiB,CAAiB,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,OAAO,0DAA0D,KAAK,EAAE,CAAC;AAC3E,CAAC,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class OrgOpenCommand extends
|
|
1
|
+
import { OrgOpenCommandBase } from '../../shared/orgOpenCommandBase.js';
|
|
2
|
+
import { type OrgOpenOutput } from '../../shared/orgTypes.js';
|
|
3
|
+
export declare class OrgOpenCommand extends OrgOpenCommandBase<OrgOpenOutput> {
|
|
4
4
|
static readonly summary: string;
|
|
5
5
|
static readonly description: string;
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static readonly aliases: string[];
|
|
8
8
|
static deprecateAliases: boolean;
|
|
9
9
|
static readonly flags: {
|
|
10
|
-
'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
private: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
browser: import("@oclif/core/interfaces").OptionFlag<"chrome" | "
|
|
13
|
+
browser: import("@oclif/core/interfaces").OptionFlag<"chrome" | "firefox" | "edge" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
path: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
'url-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
loglevel: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -18,8 +18,3 @@ export declare class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
|
|
|
18
18
|
};
|
|
19
19
|
run(): Promise<OrgOpenOutput>;
|
|
20
20
|
}
|
|
21
|
-
export type OrgOpenOutput = {
|
|
22
|
-
url: string;
|
|
23
|
-
username: string;
|
|
24
|
-
orgId: string;
|
|
25
|
-
};
|
package/lib/commands/org/open.js
CHANGED
|
@@ -5,19 +5,14 @@
|
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
7
|
import path from 'node:path';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import { execSync } from 'node:child_process';
|
|
11
|
-
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
|
|
12
|
-
import isWsl from 'is-wsl';
|
|
13
|
-
import { Logger, Messages, Org, SfdcUrl, SfError } from '@salesforce/core';
|
|
14
|
-
import { Duration, Env, sleep } from '@salesforce/kit';
|
|
8
|
+
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, } from '@salesforce/sf-plugins-core';
|
|
9
|
+
import { Messages } from '@salesforce/core';
|
|
15
10
|
import { MetadataResolver } from '@salesforce/source-deploy-retrieve';
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
11
|
+
import { buildFrontdoorUrl } from '../../shared/orgOpenUtils.js';
|
|
12
|
+
import { OrgOpenCommandBase } from '../../shared/orgOpenCommandBase.js';
|
|
18
13
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
19
14
|
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open');
|
|
20
|
-
export class OrgOpenCommand extends
|
|
15
|
+
export class OrgOpenCommand extends OrgOpenCommandBase {
|
|
21
16
|
static summary = messages.getMessage('summary');
|
|
22
17
|
static description = messages.getMessage('description');
|
|
23
18
|
static examples = messages.getMessages('examples');
|
|
@@ -60,80 +55,15 @@ export class OrgOpenCommand extends SfCommand {
|
|
|
60
55
|
};
|
|
61
56
|
async run() {
|
|
62
57
|
const { flags } = await this.parse(OrgOpenCommand);
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
this.org = flags['target-org'];
|
|
59
|
+
this.connection = this.org.getConnection(flags['api-version']);
|
|
65
60
|
const [frontDoorUrl, retUrl] = await Promise.all([
|
|
66
|
-
buildFrontdoorUrl(
|
|
67
|
-
flags['source-file'] ? generateFileUrl(flags['source-file'],
|
|
61
|
+
buildFrontdoorUrl(this.org, this.connection),
|
|
62
|
+
flags['source-file'] ? generateFileUrl(flags['source-file'], this.connection) : flags.path,
|
|
68
63
|
]);
|
|
69
|
-
|
|
70
|
-
const orgId = flags['target-org'].getOrgId();
|
|
71
|
-
// TODO: better typings in sfdx-core for orgs read from auth files
|
|
72
|
-
const username = flags['target-org'].getUsername();
|
|
73
|
-
const output = { orgId, url, username };
|
|
74
|
-
// NOTE: Deliberate use of `||` here since getBoolean() defaults to false, and we need to consider both env vars.
|
|
75
|
-
const containerMode = env.getBoolean('SF_CONTAINER_MODE') || env.getBoolean('SFDX_CONTAINER_MODE');
|
|
76
|
-
// security warning only for --json OR --url-only OR containerMode
|
|
77
|
-
if (flags['url-only'] || Boolean(flags.json) || containerMode) {
|
|
78
|
-
const sharedMessages = Messages.loadMessages('@salesforce/plugin-org', 'messages');
|
|
79
|
-
this.warn(sharedMessages.getMessage('SecurityWarning'));
|
|
80
|
-
this.log('');
|
|
81
|
-
}
|
|
82
|
-
if (containerMode) {
|
|
83
|
-
// instruct the user that they need to paste the URL into the browser
|
|
84
|
-
this.styledHeader('Action Required!');
|
|
85
|
-
this.log(messages.getMessage('containerAction', [orgId, url]));
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
if (flags['url-only']) {
|
|
89
|
-
// this includes the URL
|
|
90
|
-
this.logSuccess(messages.getMessage('humanSuccess', [orgId, username, url]));
|
|
91
|
-
return output;
|
|
92
|
-
}
|
|
93
|
-
this.logSuccess(messages.getMessage('humanSuccessNoUrl', [orgId, username]));
|
|
94
|
-
// we actually need to open the org
|
|
95
|
-
try {
|
|
96
|
-
this.spinner.start(messages.getMessage('domainWaiting'));
|
|
97
|
-
await new SfdcUrl(url).checkLightningDomain();
|
|
98
|
-
this.spinner.stop();
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
handleDomainError(err, url, env);
|
|
102
|
-
}
|
|
103
|
-
// create a local html file that contains the POST stuff.
|
|
104
|
-
const tempFilePath = path.join(tmpdir(), `org-open-${new Date().valueOf()}.html`);
|
|
105
|
-
await fs.promises.writeFile(tempFilePath, getFileContents(conn.accessToken, conn.instanceUrl,
|
|
106
|
-
// the path flag is URI-encoded in its `parse` func.
|
|
107
|
-
// For the form redirect to work we need it decoded.
|
|
108
|
-
flags.path ? decodeURIComponent(flags.path) : retUrl));
|
|
109
|
-
const filePathUrl = isWsl
|
|
110
|
-
? 'file:///' + execSync(`wslpath -m ${tempFilePath}`).toString().trim()
|
|
111
|
-
: `file:///${tempFilePath}`;
|
|
112
|
-
const cp = await utils.openUrl(filePathUrl, {
|
|
113
|
-
...(flags.browser ? { app: { name: apps[flags.browser] } } : {}),
|
|
114
|
-
...(flags.private ? { newInstance: platform() === 'darwin', app: { name: apps.browserPrivate } } : {}),
|
|
115
|
-
});
|
|
116
|
-
cp.on('error', (err) => {
|
|
117
|
-
fileCleanup(tempFilePath);
|
|
118
|
-
throw SfError.wrap(err);
|
|
119
|
-
});
|
|
120
|
-
// so we don't delete the file while the browser is still using it
|
|
121
|
-
// open returns when the CP is spawned, but there's not way to know if the browser is still using the file
|
|
122
|
-
await sleep(platform() === 'win32' || isWsl ? 7000 : 5000);
|
|
123
|
-
fileCleanup(tempFilePath);
|
|
124
|
-
return output;
|
|
64
|
+
return this.openOrgUI(flags, frontDoorUrl, retUrl);
|
|
125
65
|
}
|
|
126
66
|
}
|
|
127
|
-
const fileCleanup = (tempFilePath) => fs.rmSync(tempFilePath, { force: true, maxRetries: 3, recursive: true });
|
|
128
|
-
const buildFrontdoorUrl = async (org, conn) => {
|
|
129
|
-
await org.refreshAuth(); // we need a live accessToken for the frontdoor url
|
|
130
|
-
const accessToken = conn.accessToken;
|
|
131
|
-
if (!accessToken) {
|
|
132
|
-
throw new SfError('NoAccessToken', 'NoAccessToken');
|
|
133
|
-
}
|
|
134
|
-
const instanceUrlClean = org.getField(Org.Fields.INSTANCE_URL).replace(/\/$/, '');
|
|
135
|
-
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
|
|
136
|
-
};
|
|
137
67
|
const generateFileUrl = async (file, conn) => {
|
|
138
68
|
try {
|
|
139
69
|
const metadataResolver = new MetadataResolver();
|
|
@@ -172,34 +102,4 @@ const flowFileNameToId = async (conn, filePath) => {
|
|
|
172
102
|
throw messages.createError('FlowIdNotFound', [filePath]);
|
|
173
103
|
}
|
|
174
104
|
};
|
|
175
|
-
/** builds the html file that does an automatic post to the frontdoor url */
|
|
176
|
-
const getFileContents = (authToken, instanceUrl,
|
|
177
|
-
// we have to defalt this to get to Setup only on the POST version. GET goes to Setup automatically
|
|
178
|
-
retUrl = '/lightning/setup/SetupOneHome/home') => `
|
|
179
|
-
<html>
|
|
180
|
-
<body onload="document.body.firstElementChild.submit()">
|
|
181
|
-
<form method="POST" action="${instanceUrl}/secur/frontdoor.jsp">
|
|
182
|
-
<input type="hidden" name="sid" value="${authToken}" />
|
|
183
|
-
<input type="hidden" name="retURL" value="${retUrl}" />
|
|
184
|
-
</form>
|
|
185
|
-
</body>
|
|
186
|
-
</html>`;
|
|
187
|
-
const handleDomainError = (err, url, env) => {
|
|
188
|
-
if (err instanceof Error) {
|
|
189
|
-
if (err.message.includes('timeout')) {
|
|
190
|
-
const host = /https?:\/\/([^.]*)/.exec(url)?.[1];
|
|
191
|
-
if (!host) {
|
|
192
|
-
throw new SfError('InvalidUrl', 'InvalidUrl');
|
|
193
|
-
}
|
|
194
|
-
const domain = `https://${host}.lightning.force.com`;
|
|
195
|
-
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
|
|
196
|
-
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
|
|
197
|
-
const logger = Logger.childFromRoot('org:open');
|
|
198
|
-
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
|
|
199
|
-
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
|
|
200
|
-
}
|
|
201
|
-
throw SfError.wrap(err);
|
|
202
|
-
}
|
|
203
|
-
throw err;
|
|
204
|
-
};
|
|
205
105
|
//# sourceMappingURL=open.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/commands/org/open.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/commands/org/open.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,KAAK,EACL,QAAQ,EACR,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAc,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAGxE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,OAAO,cAAe,SAAQ,kBAAiC;IAC5D,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SA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AClG,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CACF,CAAC,EAAE,CAAC;AAEP,oFAAoF;AACpF,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAgB,EAAE,QAAgB,EAAmB,EAAE;IACrF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,iBAAiB,CACvC,6EAA6E,IAAI,CAAC,QAAQ,CACxF,QAAQ,EACR,gBAAgB,CACjB,uCAAuC,CACzC,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Connection, Org } from '@salesforce/core';
|
|
3
|
+
import { type OrgOpenOutput } from './orgTypes.js';
|
|
4
|
+
type OrgOpenFlags = {
|
|
5
|
+
'url-only': boolean;
|
|
6
|
+
browser?: 'chrome' | 'firefox' | 'edge';
|
|
7
|
+
path?: string;
|
|
8
|
+
private: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare abstract class OrgOpenCommandBase<T> extends SfCommand<T> {
|
|
11
|
+
protected org: Org;
|
|
12
|
+
protected connection: Connection;
|
|
13
|
+
protected openOrgUI(flags: OrgOpenFlags, frontDoorUrl: string, retUrl?: string): Promise<OrgOpenOutput>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import { platform, tmpdir } from 'node:os';
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import isWsl from 'is-wsl';
|
|
12
|
+
import { apps } from 'open';
|
|
13
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
14
|
+
import { Messages, SfdcUrl, SfError } from '@salesforce/core';
|
|
15
|
+
import { env, sleep } from '@salesforce/kit';
|
|
16
|
+
import utils, { fileCleanup, getFileContents, handleDomainError } from './orgOpenUtils.js';
|
|
17
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
18
|
+
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open');
|
|
19
|
+
export class OrgOpenCommandBase extends SfCommand {
|
|
20
|
+
// Set by concrete classes in `run()`
|
|
21
|
+
org;
|
|
22
|
+
connection;
|
|
23
|
+
async openOrgUI(flags, frontDoorUrl, retUrl) {
|
|
24
|
+
const orgId = this.org.getOrgId();
|
|
25
|
+
const url = `${frontDoorUrl}${retUrl ? `&retURL=${retUrl}` : ''}`;
|
|
26
|
+
// TODO: better typings in sfdx-core for orgs read from auth files
|
|
27
|
+
const username = this.org.getUsername();
|
|
28
|
+
const output = { orgId, url, username };
|
|
29
|
+
// NOTE: Deliberate use of `||` here since getBoolean() defaults to false, and we need to consider both env vars.
|
|
30
|
+
const containerMode = env.getBoolean('SF_CONTAINER_MODE') || env.getBoolean('SFDX_CONTAINER_MODE');
|
|
31
|
+
// security warning only for --json OR --url-only OR containerMode
|
|
32
|
+
if (flags['url-only'] || this.jsonEnabled() || containerMode) {
|
|
33
|
+
const sharedMessages = Messages.loadMessages('@salesforce/plugin-org', 'messages');
|
|
34
|
+
this.warn(sharedMessages.getMessage('SecurityWarning'));
|
|
35
|
+
this.log('');
|
|
36
|
+
}
|
|
37
|
+
if (containerMode) {
|
|
38
|
+
// instruct the user that they need to paste the URL into the browser
|
|
39
|
+
this.styledHeader('Action Required!');
|
|
40
|
+
this.log(messages.getMessage('containerAction', [orgId, url]));
|
|
41
|
+
return output;
|
|
42
|
+
}
|
|
43
|
+
if (flags['url-only']) {
|
|
44
|
+
// this includes the URL
|
|
45
|
+
this.logSuccess(messages.getMessage('humanSuccess', [orgId, username, url]));
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
this.logSuccess(messages.getMessage('humanSuccessNoUrl', [orgId, username]));
|
|
49
|
+
// we actually need to open the org
|
|
50
|
+
try {
|
|
51
|
+
this.spinner.start(messages.getMessage('domainWaiting'));
|
|
52
|
+
await new SfdcUrl(url).checkLightningDomain();
|
|
53
|
+
this.spinner.stop();
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
handleDomainError(err, url, env);
|
|
57
|
+
}
|
|
58
|
+
// create a local html file that contains the POST stuff.
|
|
59
|
+
const tempFilePath = path.join(tmpdir(), `org-open-${new Date().valueOf()}.html`);
|
|
60
|
+
await fs.promises.writeFile(tempFilePath, getFileContents(this.connection.accessToken, this.connection.instanceUrl,
|
|
61
|
+
// the path flag is URI-encoded in its `parse` func.
|
|
62
|
+
// For the form redirect to work we need it decoded.
|
|
63
|
+
flags.path ? decodeURIComponent(flags.path) : retUrl));
|
|
64
|
+
const filePathUrl = isWsl
|
|
65
|
+
? 'file:///' + execSync(`wslpath -m ${tempFilePath}`).toString().trim()
|
|
66
|
+
: `file:///${tempFilePath}`;
|
|
67
|
+
const cp = await utils.openUrl(filePathUrl, {
|
|
68
|
+
...(flags.browser ? { app: { name: apps[flags.browser] } } : {}),
|
|
69
|
+
...(flags.private ? { newInstance: platform() === 'darwin', app: { name: apps.browserPrivate } } : {}),
|
|
70
|
+
});
|
|
71
|
+
cp.on('error', (err) => {
|
|
72
|
+
fileCleanup(tempFilePath);
|
|
73
|
+
throw SfError.wrap(err);
|
|
74
|
+
});
|
|
75
|
+
// so we don't delete the file while the browser is still using it
|
|
76
|
+
// open returns when the CP is spawned, but there's not way to know if the browser is still using the file
|
|
77
|
+
await sleep(platform() === 'win32' || isWsl ? 7000 : 5000);
|
|
78
|
+
fileCleanup(tempFilePath);
|
|
79
|
+
return output;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=orgOpenCommandBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orgOpenCommandBase.js","sourceRoot":"","sources":["../../src/shared/orgOpenCommandBase.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAc,QAAQ,EAAO,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3F,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AASzE,MAAM,OAAgB,kBAAsB,SAAQ,SAAY;IAC9D,qCAAqC;IAC3B,GAAG,CAAO;IACV,UAAU,CAAc;IAExB,KAAK,CAAC,SAAS,CAAC,KAAmB,EAAE,YAAoB,EAAE,MAAe;QAClF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAA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AAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvG,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACrB,WAAW,CAAC,YAAY,CAAC,CAAC;YAC1B,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QACH,kEAAkE;QAClE,0GAA0G;QAC1G,MAAM,KAAK,CAAC,QAAQ,EAAE,KAAK,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3D,WAAW,CAAC,YAAY,CAAC,CAAC;QAE1B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
|
+
import { Options } from 'open';
|
|
3
|
+
import { Connection, Org } from '@salesforce/core';
|
|
4
|
+
import { Env } from '@salesforce/kit';
|
|
5
|
+
export declare const openUrl: (url: string, options: Options) => Promise<ChildProcess>;
|
|
6
|
+
export declare const fileCleanup: (tempFilePath: string) => void;
|
|
7
|
+
export declare const buildFrontdoorUrl: (org: Org, conn: Connection) => Promise<string>;
|
|
8
|
+
export declare const handleDomainError: (err: unknown, url: string, env: Env) => string;
|
|
9
|
+
/** builds the html file that does an automatic post to the frontdoor url */
|
|
10
|
+
export declare const getFileContents: (authToken: string, instanceUrl: string, retUrl?: string) => string;
|
|
11
|
+
declare const _default: {
|
|
12
|
+
openUrl: (url: string, options: Options) => Promise<ChildProcess>;
|
|
13
|
+
fileCleanup: (tempFilePath: string) => void;
|
|
14
|
+
buildFrontdoorUrl: (org: Org, conn: Connection) => Promise<string>;
|
|
15
|
+
handleDomainError: (err: unknown, url: string, env: Env) => string;
|
|
16
|
+
getFileContents: (authToken: string, instanceUrl: string, retUrl?: string) => string;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { rmSync } from 'node:fs';
|
|
8
|
+
import open from 'open';
|
|
9
|
+
import { Logger, Messages, Org, SfError } from '@salesforce/core';
|
|
10
|
+
import { Duration } from '@salesforce/kit';
|
|
11
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
12
|
+
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open');
|
|
13
|
+
export const openUrl = async (url, options) => open(url, options);
|
|
14
|
+
export const fileCleanup = (tempFilePath) => rmSync(tempFilePath, { force: true, maxRetries: 3, recursive: true });
|
|
15
|
+
export const buildFrontdoorUrl = async (org, conn) => {
|
|
16
|
+
await org.refreshAuth(); // we need a live accessToken for the frontdoor url
|
|
17
|
+
const accessToken = conn.accessToken;
|
|
18
|
+
if (!accessToken) {
|
|
19
|
+
throw new SfError('NoAccessToken', 'NoAccessToken');
|
|
20
|
+
}
|
|
21
|
+
const instanceUrlClean = org.getField(Org.Fields.INSTANCE_URL).replace(/\/$/, '');
|
|
22
|
+
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
|
|
23
|
+
};
|
|
24
|
+
export const handleDomainError = (err, url, env) => {
|
|
25
|
+
if (err instanceof Error) {
|
|
26
|
+
if (err.message.includes('timeout')) {
|
|
27
|
+
const host = /https?:\/\/([^.]*)/.exec(url)?.[1];
|
|
28
|
+
if (!host) {
|
|
29
|
+
throw new SfError('InvalidUrl', 'InvalidUrl');
|
|
30
|
+
}
|
|
31
|
+
const domain = `https://${host}.lightning.force.com`;
|
|
32
|
+
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
|
|
33
|
+
const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
|
|
34
|
+
const logger = Logger.childFromRoot('org:open');
|
|
35
|
+
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
|
|
36
|
+
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
|
|
37
|
+
}
|
|
38
|
+
throw SfError.wrap(err);
|
|
39
|
+
}
|
|
40
|
+
throw err;
|
|
41
|
+
};
|
|
42
|
+
/** builds the html file that does an automatic post to the frontdoor url */
|
|
43
|
+
export const getFileContents = (authToken, instanceUrl,
|
|
44
|
+
// we have to defalt this to get to Setup only on the POST version. GET goes to Setup automatically
|
|
45
|
+
retUrl = '/lightning/setup/SetupOneHome/home') => `
|
|
46
|
+
<html>
|
|
47
|
+
<body onload="document.body.firstElementChild.submit()">
|
|
48
|
+
<form method="POST" action="${instanceUrl}/secur/frontdoor.jsp">
|
|
49
|
+
<input type="hidden" name="sid" value="${authToken}" />
|
|
50
|
+
<input type="hidden" name="retURL" value="${retUrl}" />
|
|
51
|
+
</form>
|
|
52
|
+
</body>
|
|
53
|
+
</html>`;
|
|
54
|
+
export default {
|
|
55
|
+
openUrl,
|
|
56
|
+
fileCleanup,
|
|
57
|
+
buildFrontdoorUrl,
|
|
58
|
+
handleDomainError,
|
|
59
|
+
getFileContents,
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=orgOpenUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orgOpenUtils.js","sourceRoot":"","sources":["../../src/shared/orgOpenUtils.ts"],"names":[],"mappings":"AAAA;;;;;GA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eAAe;IACb,OAAO;IACP,WAAW;IACX,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;CAChB,CAAC"}
|
package/lib/shared/orgTypes.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export type OrgDisplayReturn = Partial<ScratchOrgFields> & {
|
|
|
11
11
|
connectedStatus?: string;
|
|
12
12
|
sfdxAuthUrl?: string;
|
|
13
13
|
};
|
|
14
|
+
export type OrgOpenOutput = {
|
|
15
|
+
url: string;
|
|
16
|
+
username: string;
|
|
17
|
+
orgId: string;
|
|
18
|
+
};
|
|
14
19
|
/** Convenience type for the fields that are in the auth file
|
|
15
20
|
*
|
|
16
21
|
* core's AuthFields has everything as optional.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orgTypes.js","sourceRoot":"","sources":["../../src/shared/orgTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"orgTypes.js","sourceRoot":"","sources":["../../src/shared/orgTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoGH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,6CAAuB,CAAA;IACvB,oDAA8B,CAAA;IAC9B,yCAAmB,CAAA;IACnB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B"}
|
package/lib/shared/utils.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { ChildProcess } from 'node:child_process';
|
|
2
|
-
import { Options } from 'open';
|
|
3
1
|
export declare const getAliasByUsername: (username: string) => Promise<string | undefined>;
|
|
4
|
-
export declare const openUrl: (url: string, options: Options) => Promise<ChildProcess>;
|
|
5
2
|
export declare const lowerToUpper: (object: Record<string, unknown>) => Record<string, unknown>;
|
|
6
3
|
declare const _default: {
|
|
7
4
|
getAliasByUsername: (username: string) => Promise<string | undefined>;
|
|
8
|
-
openUrl: (url: string, options: Options) => Promise<ChildProcess>;
|
|
9
5
|
lowerToUpper: (object: Record<string, unknown>) => Record<string, unknown>;
|
|
10
6
|
};
|
|
11
7
|
export default _default;
|
package/lib/shared/utils.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
1
7
|
import { upperFirst } from '@salesforce/kit';
|
|
2
8
|
import { StateAggregator } from '@salesforce/core';
|
|
3
|
-
import open from 'open';
|
|
4
9
|
export const getAliasByUsername = async (username) => {
|
|
5
10
|
const stateAggregator = await StateAggregator.getInstance();
|
|
6
11
|
const keys = stateAggregator.aliases.getAll(username);
|
|
7
12
|
// use the most recently added alias for that username
|
|
8
13
|
return keys?.length ? keys[keys.length - 1] : undefined;
|
|
9
14
|
};
|
|
10
|
-
export const openUrl = async (url, options) => open(url, options);
|
|
11
15
|
export const lowerToUpper = (object) =>
|
|
12
16
|
// the API has keys defined in capital camel case, while the definition schema has them as lower camel case
|
|
13
17
|
// we need to convert lower camel case to upper before merging options so they will override properly
|
|
14
18
|
Object.fromEntries(Object.entries(object).map(([key, value]) => [upperFirst(key), value]));
|
|
15
19
|
export default {
|
|
16
20
|
getAliasByUsername,
|
|
17
|
-
openUrl,
|
|
18
21
|
lowerToUpper,
|
|
19
22
|
};
|
|
20
23
|
export const isDefined = (value) => value !== undefined && value !== null;
|
package/lib/shared/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,QAAgB,EAA+B,EAAE;IACxF,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,CAAC;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtD,sDAAsD;IACtD,OAAO,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAA+B,EAA2B,EAAE;AACvF,2GAA2G;AAC3G,qGAAqG;AACrG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAE7F,eAAe;IACb,kBAAkB;IAClB,YAAY;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAA2B,EAAc,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Open an agent in the Agent Builder org UI in a browser.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Use the --name flag to open an agent using the developer name (aka API name) in the Agent Builder Org UI.
|
|
8
|
+
|
|
9
|
+
To generate a URL but not launch it in your browser, specify --url-only.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
# examples
|
|
14
|
+
|
|
15
|
+
- Open the agent with developer name "Coral_Cloud_Agent using the default browser:
|
|
16
|
+
|
|
17
|
+
$ <%= config.bin %> <%= command.id %> --name Coral_Cloud_Agent
|
|
18
|
+
|
|
19
|
+
- Open the agent in an incognito window of your default browser:
|
|
20
|
+
|
|
21
|
+
$ <%= config.bin %> <%= command.id %> --private --name Coral_Cloud_Agent
|
|
22
|
+
|
|
23
|
+
- Open the agent in the org with alias MyTestOrg1 using the Firefox browser:
|
|
24
|
+
|
|
25
|
+
$ <%= config.bin %> <%= command.id %> --target-org MyTestOrg1 --browser firefox --name Coral_Cloud_Agent
|
|
26
|
+
|
|
27
|
+
# flags.name.summary
|
|
28
|
+
|
|
29
|
+
The developer name (aka API name) of the agent to open in the Agent Builder org UI.
|
|
30
|
+
|
|
31
|
+
# flags.private.summary
|
|
32
|
+
|
|
33
|
+
Open the org in the default browser using private (incognito) mode.
|
|
34
|
+
|
|
35
|
+
# flags.browser.summary
|
|
36
|
+
|
|
37
|
+
Browser where the org opens.
|
|
38
|
+
|
|
39
|
+
# flags.url-only.summary
|
|
40
|
+
|
|
41
|
+
Display navigation URL, but don’t launch browser.
|
package/oclif.manifest.json
CHANGED
|
@@ -358,7 +358,6 @@
|
|
|
358
358
|
"pluginType": "core",
|
|
359
359
|
"strict": true,
|
|
360
360
|
"summary": "Open your default scratch org, or another specified org, in a browser.",
|
|
361
|
-
"enableJsonFlag": true,
|
|
362
361
|
"isESM": true,
|
|
363
362
|
"relativePath": [
|
|
364
363
|
"lib",
|
|
@@ -1378,6 +1377,122 @@
|
|
|
1378
1377
|
"metadata:list:org"
|
|
1379
1378
|
]
|
|
1380
1379
|
},
|
|
1380
|
+
"org:open:agent": {
|
|
1381
|
+
"aliases": [],
|
|
1382
|
+
"args": {},
|
|
1383
|
+
"description": "Use the --name flag to open an agent using the developer name (aka API name) in the Agent Builder Org UI.\n\nTo generate a URL but not launch it in your browser, specify --url-only.\n\nTo 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.",
|
|
1384
|
+
"examples": [
|
|
1385
|
+
"Open the agent with developer name \"Coral_Cloud_Agent using the default browser:\n$ <%= config.bin %> <%= command.id %> --name Coral_Cloud_Agent",
|
|
1386
|
+
"Open the agent in an incognito window of your default browser:\n$ <%= config.bin %> <%= command.id %> --private --name Coral_Cloud_Agent",
|
|
1387
|
+
"Open the agent in the org with alias MyTestOrg1 using the Firefox browser:\n$ <%= config.bin %> <%= command.id %> --target-org MyTestOrg1 --browser firefox --name Coral_Cloud_Agent"
|
|
1388
|
+
],
|
|
1389
|
+
"flags": {
|
|
1390
|
+
"json": {
|
|
1391
|
+
"description": "Format output as json.",
|
|
1392
|
+
"helpGroup": "GLOBAL",
|
|
1393
|
+
"name": "json",
|
|
1394
|
+
"allowNo": false,
|
|
1395
|
+
"type": "boolean"
|
|
1396
|
+
},
|
|
1397
|
+
"flags-dir": {
|
|
1398
|
+
"helpGroup": "GLOBAL",
|
|
1399
|
+
"name": "flags-dir",
|
|
1400
|
+
"summary": "Import flag values from a directory.",
|
|
1401
|
+
"hasDynamicHelp": false,
|
|
1402
|
+
"multiple": false,
|
|
1403
|
+
"type": "option"
|
|
1404
|
+
},
|
|
1405
|
+
"target-org": {
|
|
1406
|
+
"char": "o",
|
|
1407
|
+
"name": "target-org",
|
|
1408
|
+
"noCacheDefault": true,
|
|
1409
|
+
"required": true,
|
|
1410
|
+
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
1411
|
+
"hasDynamicHelp": true,
|
|
1412
|
+
"multiple": false,
|
|
1413
|
+
"type": "option"
|
|
1414
|
+
},
|
|
1415
|
+
"api-version": {
|
|
1416
|
+
"description": "Override the api version used for api requests made by this command",
|
|
1417
|
+
"name": "api-version",
|
|
1418
|
+
"hasDynamicHelp": false,
|
|
1419
|
+
"multiple": false,
|
|
1420
|
+
"type": "option"
|
|
1421
|
+
},
|
|
1422
|
+
"name": {
|
|
1423
|
+
"char": "n",
|
|
1424
|
+
"name": "name",
|
|
1425
|
+
"required": true,
|
|
1426
|
+
"summary": "The developer name (aka API name) of the agent to open in the Agent Builder org UI.",
|
|
1427
|
+
"hasDynamicHelp": false,
|
|
1428
|
+
"multiple": false,
|
|
1429
|
+
"type": "option"
|
|
1430
|
+
},
|
|
1431
|
+
"private": {
|
|
1432
|
+
"exclusive": [
|
|
1433
|
+
"url-only",
|
|
1434
|
+
"browser"
|
|
1435
|
+
],
|
|
1436
|
+
"name": "private",
|
|
1437
|
+
"summary": "Open the org in the default browser using private (incognito) mode.",
|
|
1438
|
+
"allowNo": false,
|
|
1439
|
+
"type": "boolean"
|
|
1440
|
+
},
|
|
1441
|
+
"browser": {
|
|
1442
|
+
"char": "b",
|
|
1443
|
+
"exclusive": [
|
|
1444
|
+
"url-only",
|
|
1445
|
+
"private"
|
|
1446
|
+
],
|
|
1447
|
+
"name": "browser",
|
|
1448
|
+
"summary": "Browser where the org opens.",
|
|
1449
|
+
"hasDynamicHelp": false,
|
|
1450
|
+
"multiple": false,
|
|
1451
|
+
"options": [
|
|
1452
|
+
"chrome",
|
|
1453
|
+
"edge",
|
|
1454
|
+
"firefox"
|
|
1455
|
+
],
|
|
1456
|
+
"type": "option"
|
|
1457
|
+
},
|
|
1458
|
+
"url-only": {
|
|
1459
|
+
"aliases": [
|
|
1460
|
+
"urlonly"
|
|
1461
|
+
],
|
|
1462
|
+
"char": "r",
|
|
1463
|
+
"deprecateAliases": true,
|
|
1464
|
+
"name": "url-only",
|
|
1465
|
+
"summary": "Display navigation URL, but don’t launch browser.",
|
|
1466
|
+
"allowNo": false,
|
|
1467
|
+
"type": "boolean"
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
"hasDynamicHelp": true,
|
|
1471
|
+
"hiddenAliases": [],
|
|
1472
|
+
"id": "org:open:agent",
|
|
1473
|
+
"pluginAlias": "@salesforce/plugin-org",
|
|
1474
|
+
"pluginName": "@salesforce/plugin-org",
|
|
1475
|
+
"pluginType": "core",
|
|
1476
|
+
"strict": true,
|
|
1477
|
+
"summary": "Open an agent in the Agent Builder org UI in a browser.",
|
|
1478
|
+
"isESM": true,
|
|
1479
|
+
"relativePath": [
|
|
1480
|
+
"lib",
|
|
1481
|
+
"commands",
|
|
1482
|
+
"org",
|
|
1483
|
+
"open",
|
|
1484
|
+
"agent.js"
|
|
1485
|
+
],
|
|
1486
|
+
"aliasPermutations": [],
|
|
1487
|
+
"permutations": [
|
|
1488
|
+
"org:open:agent",
|
|
1489
|
+
"open:org:agent",
|
|
1490
|
+
"open:agent:org",
|
|
1491
|
+
"org:agent:open",
|
|
1492
|
+
"agent:org:open",
|
|
1493
|
+
"agent:open:org"
|
|
1494
|
+
]
|
|
1495
|
+
},
|
|
1381
1496
|
"org:refresh:sandbox": {
|
|
1382
1497
|
"aliases": [],
|
|
1383
1498
|
"args": {},
|
|
@@ -1698,5 +1813,5 @@
|
|
|
1698
1813
|
]
|
|
1699
1814
|
}
|
|
1700
1815
|
},
|
|
1701
|
-
"version": "5.1.
|
|
1816
|
+
"version": "5.1.5-beta.0"
|
|
1702
1817
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/plugin-org",
|
|
3
3
|
"description": "Commands to interact with Salesforce orgs",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.5-beta.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/forcedotcom/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"@salesforce/cli-plugins-testkit": "^5.3.36",
|
|
23
23
|
"@salesforce/dev-scripts": "^10.2.10",
|
|
24
24
|
"@salesforce/plugin-command-reference": "^3.1.31",
|
|
25
|
-
"@salesforce/ts-sinon": "^1.4.
|
|
25
|
+
"@salesforce/ts-sinon": "^1.4.29",
|
|
26
26
|
"eslint-plugin-sf-plugin": "^1.20.8",
|
|
27
27
|
"moment": "^2.30.1",
|
|
28
|
-
"oclif": "^4.15.
|
|
28
|
+
"oclif": "^4.15.22",
|
|
29
29
|
"ts-node": "^10.9.2",
|
|
30
30
|
"typescript": "^5.6.3"
|
|
31
31
|
},
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
"exports": "./lib/index.js",
|
|
227
227
|
"type": "module",
|
|
228
228
|
"sfdx": {
|
|
229
|
-
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.
|
|
230
|
-
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.
|
|
229
|
+
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5-beta.0.crt",
|
|
230
|
+
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5-beta.0.sig"
|
|
231
231
|
}
|
|
232
232
|
}
|