@salesforce/plugin-auth 3.2.0 → 3.3.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 +7 -7
- package/lib/commands/org/list/auth.js +2 -4
- package/lib/commands/org/list/auth.js.map +1 -1
- package/lib/commands/org/login/access-token.d.ts +9 -10
- package/lib/commands/org/login/access-token.js +8 -5
- package/lib/commands/org/login/access-token.js.map +1 -1
- package/lib/commands/org/login/device.d.ts +3 -4
- package/lib/commands/org/login/device.js +5 -12
- package/lib/commands/org/login/device.js.map +1 -1
- package/lib/commands/org/login/jwt.d.ts +3 -3
- package/lib/commands/org/login/jwt.js +6 -6
- package/lib/commands/org/login/jwt.js.map +1 -1
- package/lib/commands/org/login/sfdx-url.d.ts +3 -3
- package/lib/commands/org/login/sfdx-url.js +4 -4
- package/lib/commands/org/login/sfdx-url.js.map +1 -1
- package/lib/commands/org/login/web.d.ts +10 -13
- package/lib/commands/org/login/web.js +17 -27
- package/lib/commands/org/login/web.js.map +1 -1
- package/lib/commands/org/logout.d.ts +9 -12
- package/lib/commands/org/logout.js +71 -116
- package/lib/commands/org/logout.js.map +1 -1
- package/lib/common.d.ts +5 -3
- package/lib/common.js +30 -23
- package/lib/common.js.map +1 -1
- package/messages/messages.md +0 -4
- package/oclif.lock +208 -144
- package/oclif.manifest.json +7 -24
- package/package.json +11 -9
- package/lib/authBaseCommand.d.ts +0 -9
- package/lib/authBaseCommand.js +0 -46
- package/lib/authBaseCommand.js.map +0 -1
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AuthBaseCommand } from '../../authBaseCommand.js';
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
2
|
export type AuthLogoutResults = string[];
|
|
4
|
-
export default class Logout extends
|
|
3
|
+
export default class Logout extends SfCommand<AuthLogoutResults> {
|
|
5
4
|
static readonly summary: string;
|
|
6
5
|
static readonly description: string;
|
|
7
6
|
static readonly examples: string[];
|
|
8
7
|
static readonly deprecateAliases = true;
|
|
9
|
-
static aliases: string[];
|
|
8
|
+
static readonly aliases: string[];
|
|
10
9
|
static readonly flags: {
|
|
11
|
-
'target-org':
|
|
12
|
-
all:
|
|
13
|
-
'no-prompt':
|
|
14
|
-
loglevel:
|
|
10
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
all: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
'no-prompt': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
loglevel: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
14
|
};
|
|
16
|
-
private flags;
|
|
17
|
-
private static buildChoices;
|
|
18
15
|
run(): Promise<AuthLogoutResults>;
|
|
19
|
-
|
|
20
|
-
private
|
|
16
|
+
/** Warning about logging out of a scratch org and losing access to it */
|
|
17
|
+
private maybeWarnScratchOrgs;
|
|
21
18
|
}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import os from 'node:os';
|
|
8
8
|
import { AuthInfo, AuthRemover, ConfigAggregator, Global, Messages, Mode, OrgConfigProperties, } from '@salesforce/core';
|
|
9
|
-
import
|
|
9
|
+
import checkbox, { Separator } from '@inquirer/checkbox';
|
|
10
|
+
import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core';
|
|
10
11
|
import chalk from 'chalk';
|
|
11
|
-
import { AuthBaseCommand } from '../../authBaseCommand.js';
|
|
12
12
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
13
|
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'logout');
|
|
14
14
|
const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
15
|
-
export default class Logout extends
|
|
15
|
+
export default class Logout extends SfCommand {
|
|
16
16
|
static summary = messages.getMessage('summary');
|
|
17
17
|
static description = messages.getMessage('description');
|
|
18
18
|
static examples = messages.getMessages('examples');
|
|
@@ -42,46 +42,10 @@ export default class Logout extends AuthBaseCommand {
|
|
|
42
42
|
}),
|
|
43
43
|
loglevel,
|
|
44
44
|
};
|
|
45
|
-
flags;
|
|
46
|
-
static buildChoices(orgAuths, all) {
|
|
47
|
-
const maxUsernameLength = Math.max('Username'.length, ...orgAuths.map((orgAuth) => orgAuth.username.length));
|
|
48
|
-
const maxAliasLength = Math.max('Aliases'.length, ...orgAuths.map((orgAuth) => (orgAuth.aliases ? orgAuth.aliases.join(',') : '').length));
|
|
49
|
-
const maxConfigLength = Math.max('Configs'.length, ...orgAuths.map((orgAuth) => (orgAuth.configs ? orgAuth.configs.join(',') : '').length));
|
|
50
|
-
const maxTypeLength = Math.max('Type'.length, ...orgAuths.map((orgAuth) => {
|
|
51
|
-
if (orgAuth.isScratchOrg) {
|
|
52
|
-
return 'Scratch'.length;
|
|
53
|
-
}
|
|
54
|
-
if (orgAuth.isDevHub) {
|
|
55
|
-
return 'DevHub'.length;
|
|
56
|
-
}
|
|
57
|
-
if (orgAuth.isSandbox) {
|
|
58
|
-
return 'Sandbox'.length;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}));
|
|
62
|
-
const choices = orgAuths
|
|
63
|
-
.map((orgAuth) => {
|
|
64
|
-
const aliasString = (orgAuth.aliases ? orgAuth.aliases.join(',') : '').padEnd(maxAliasLength, ' ');
|
|
65
|
-
const configString = (orgAuth.configs ? orgAuth.configs.join(',') : '').padEnd(maxConfigLength, ' ');
|
|
66
|
-
const typeString = chalk.dim((orgAuth.isScratchOrg ? 'Scratch' : orgAuth.isDevHub ? 'DevHub' : orgAuth.isSandbox ? 'Sandbox' : '').padEnd(maxTypeLength, ' '));
|
|
67
|
-
// username - aliases - configs
|
|
68
|
-
const key = `${chalk.bold(orgAuth.username.padEnd(maxUsernameLength))} | ${typeString} | ${aliasString} | ${chalk.yellowBright(configString)}`;
|
|
69
|
-
return { name: key, value: orgAuth, checked: all, short: `${os.EOL}${orgAuth.username}` };
|
|
70
|
-
})
|
|
71
|
-
.sort((a, b) => a.value.username.localeCompare(b.value.username));
|
|
72
|
-
const userHeader = `${'Username'.padEnd(maxUsernameLength, ' ')}`;
|
|
73
|
-
const aliasHeader = `${'Aliases'.padEnd(maxAliasLength, ' ')}`;
|
|
74
|
-
const configHeader = `${'Configs'.padEnd(maxConfigLength, ' ')}`;
|
|
75
|
-
const typeHeader = `${'Type'.padEnd(maxTypeLength, ' ')}`;
|
|
76
|
-
return [new Separator(` ${userHeader} | ${typeHeader} | ${aliasHeader} | ${configHeader}`), ...choices];
|
|
77
|
-
}
|
|
78
45
|
async run() {
|
|
79
46
|
const { flags } = await this.parse(Logout);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const remover = await AuthRemover.create();
|
|
83
|
-
let orgAuths = [];
|
|
84
|
-
const targetUsername = this.flags['target-org'] ?? this.configAggregator.getInfo(OrgConfigProperties.TARGET_ORG).value;
|
|
47
|
+
const targetUsername = flags['target-org'] ??
|
|
48
|
+
(await ConfigAggregator.create()).getInfo(OrgConfigProperties.TARGET_ORG).value;
|
|
85
49
|
// if no-prompt, there must be a resolved target-org or --all
|
|
86
50
|
if (flags['no-prompt'] && !targetUsername && !flags.all) {
|
|
87
51
|
throw messages.createError('noOrgSpecifiedWithNoPrompt');
|
|
@@ -89,33 +53,29 @@ export default class Logout extends AuthBaseCommand {
|
|
|
89
53
|
if (this.jsonEnabled() && !targetUsername && !flags.all) {
|
|
90
54
|
throw messages.createError('noOrgSpecifiedWithJson');
|
|
91
55
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
orgAuths = [];
|
|
101
|
-
}
|
|
56
|
+
const shouldFindAllAuths = targetUsername && !flags.all
|
|
57
|
+
? false
|
|
58
|
+
: flags.all || Global.getEnvironmentMode() === Mode.DEMO || !flags['no-prompt'];
|
|
59
|
+
const orgAuths = shouldFindAllAuths
|
|
60
|
+
? await AuthInfo.listAllAuthorizations()
|
|
61
|
+
: targetUsername
|
|
62
|
+
? (await AuthInfo.listAllAuthorizations()).filter((orgAuth) => orgAuth.username === targetUsername || !!orgAuth.aliases?.includes(targetUsername))
|
|
63
|
+
: [];
|
|
102
64
|
if (orgAuths.length === 0) {
|
|
103
|
-
if (
|
|
65
|
+
if (flags['target-org']) {
|
|
104
66
|
// user specified a target org but it was not resolved, issue success message and return
|
|
105
|
-
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [
|
|
106
|
-
return [
|
|
67
|
+
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [flags['target-org']]));
|
|
68
|
+
return [flags['target-org']];
|
|
107
69
|
}
|
|
108
70
|
this.info(messages.getMessage('noOrgsFound'));
|
|
109
71
|
return [];
|
|
110
72
|
}
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
const loggedOutUsernames = orgs.map((org) => org.username);
|
|
73
|
+
const skipPrompt = flags['no-prompt'] || this.jsonEnabled();
|
|
74
|
+
const selectedOrgs = this.maybeWarnScratchOrgs(skipPrompt ? orgAuths : await promptForOrgsToRemove(orgAuths, flags.all));
|
|
75
|
+
if (skipPrompt || (await this.confirm({ message: getOrgConfirmationMessage(selectedOrgs, orgAuths.length) }))) {
|
|
76
|
+
const remover = await AuthRemover.create();
|
|
77
|
+
const loggedOutUsernames = selectedOrgs.map((org) => org.username);
|
|
78
|
+
await Promise.all(loggedOutUsernames.map((username) => remover.removeAuth(username)));
|
|
119
79
|
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [loggedOutUsernames.join(os.EOL)]));
|
|
120
80
|
return loggedOutUsernames;
|
|
121
81
|
}
|
|
@@ -124,62 +84,57 @@ export default class Logout extends AuthBaseCommand {
|
|
|
124
84
|
return [];
|
|
125
85
|
}
|
|
126
86
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
87
|
+
/** Warning about logging out of a scratch org and losing access to it */
|
|
88
|
+
maybeWarnScratchOrgs(orgs) {
|
|
89
|
+
if (orgs.some((org) => org.isScratchOrg)) {
|
|
90
|
+
this.warn(messages.getMessage('warning'));
|
|
130
91
|
}
|
|
131
|
-
return
|
|
92
|
+
return orgs;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
94
|
+
}
|
|
95
|
+
const promptForOrgsToRemove = async (orgAuths, all) => orgAuths.length === 1
|
|
96
|
+
? orgAuths
|
|
97
|
+
: checkbox({
|
|
98
|
+
message: messages.getMessage('prompt.select-envs'),
|
|
99
|
+
// pick the orgs to delete - if flags.all - set each org to selected
|
|
100
|
+
// otherwise prompt the user to select the orgs to delete
|
|
101
|
+
choices: buildChoices(orgAuths, all),
|
|
102
|
+
loop: true,
|
|
103
|
+
});
|
|
104
|
+
const getOrgConfirmationMessage = (selectedOrgs, originalOrgCount) => selectedOrgs.length === originalOrgCount
|
|
105
|
+
? messages.getMessage('prompt.confirm-all')
|
|
106
|
+
: messages.getMessage('prompt.confirm', [selectedOrgs.length, selectedOrgs.length > 1 ? 's' : '']);
|
|
107
|
+
/** A whole bunch of custom formatting to make the list look nicer */
|
|
108
|
+
const buildChoices = (orgAuths, all) => {
|
|
109
|
+
const maxUsernameLength = Math.max('Username'.length, ...orgAuths.map((orgAuth) => orgAuth.username.length));
|
|
110
|
+
const maxAliasLength = Math.max('Aliases'.length, ...orgAuths.map((orgAuth) => (orgAuth.aliases ? orgAuth.aliases.join(',') : '').length));
|
|
111
|
+
const maxConfigLength = Math.max('Configs'.length, ...orgAuths.map((orgAuth) => (orgAuth.configs ? orgAuth.configs.join(',') : '').length));
|
|
112
|
+
const maxTypeLength = Math.max('Type'.length, ...orgAuths.map((orgAuth) => {
|
|
113
|
+
if (orgAuth.isScratchOrg) {
|
|
114
|
+
return 'Scratch'.length;
|
|
136
115
|
}
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
this.warn(messages.getMessage('warning'));
|
|
140
|
-
}
|
|
141
|
-
if (await this.confirm(messages.getMessage('prompt.confirm.single', [orgAuths[0].username]), 30000, false)) {
|
|
142
|
-
return { orgs: orgAuths, confirmed: true };
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return { orgs: [], confirmed: false };
|
|
146
|
-
}
|
|
116
|
+
if (orgAuth.isDevHub) {
|
|
117
|
+
return 'DevHub'.length;
|
|
147
118
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return messages.getMessage('prompt.confirm-all');
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return messages.getMessage('prompt.confirm', [names.length, names.length > 1 ? 's' : '']);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
type: 'confirm',
|
|
176
|
-
default: false,
|
|
177
|
-
},
|
|
178
|
-
], 30000);
|
|
179
|
-
return {
|
|
180
|
-
orgs: orgs.map((a) => a),
|
|
181
|
-
confirmed,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
119
|
+
if (orgAuth.isSandbox) {
|
|
120
|
+
return 'Sandbox'.length;
|
|
121
|
+
}
|
|
122
|
+
return 0;
|
|
123
|
+
}));
|
|
124
|
+
const choices = orgAuths
|
|
125
|
+
.map((orgAuth) => {
|
|
126
|
+
const aliasString = (orgAuth.aliases ? orgAuth.aliases.join(',') : '').padEnd(maxAliasLength, ' ');
|
|
127
|
+
const configString = (orgAuth.configs ? orgAuth.configs.join(',') : '').padEnd(maxConfigLength, ' ');
|
|
128
|
+
const typeString = chalk.dim((orgAuth.isScratchOrg ? 'Scratch' : orgAuth.isDevHub ? 'DevHub' : orgAuth.isSandbox ? 'Sandbox' : '').padEnd(maxTypeLength, ' '));
|
|
129
|
+
// username - aliases - configs
|
|
130
|
+
const key = `${chalk.bold(orgAuth.username.padEnd(maxUsernameLength))} | ${typeString} | ${aliasString} | ${chalk.yellowBright(configString)}`;
|
|
131
|
+
return { name: key, value: orgAuth, checked: all, short: `${os.EOL}${orgAuth.username}` };
|
|
132
|
+
})
|
|
133
|
+
.sort((a, b) => a.value.username.localeCompare(b.value.username));
|
|
134
|
+
const userHeader = `${'Username'.padEnd(maxUsernameLength, ' ')}`;
|
|
135
|
+
const aliasHeader = `${'Aliases'.padEnd(maxAliasLength, ' ')}`;
|
|
136
|
+
const configHeader = `${'Configs'.padEnd(maxConfigLength, ' ')}`;
|
|
137
|
+
const typeHeader = `${'Type'.padEnd(maxTypeLength, ' ')}`;
|
|
138
|
+
return [new Separator(` ${userHeader} | ${typeHeader} | ${aliasHeader} | ${configHeader}`), ...choices];
|
|
139
|
+
};
|
|
185
140
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,IAAI,EAEJ,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,QAAQ,EAAE,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO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AAC,EAAE,CAAC;QAC3E,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5F,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC;IAClE,MAAM,WAAW,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC;IAC/D,MAAM,YAAY,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,GAAG,CAAC,EAAE,CAAC;IACjE,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC;IAC1D,OAAO,CAAC,IAAI,SAAS,CAAC,KAAK,UAAU,MAAM,UAAU,MAAM,WAAW,MAAM,YAAY,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;AAC3G,CAAC,CAAC"}
|
package/lib/common.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
shouldExitCommand: (noPrompt?: boolean | undefined) => Promise<boolean>;
|
|
3
|
+
resolveLoginUrl: (instanceUrl?: string | undefined) => Promise<string>;
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
package/lib/common.js
CHANGED
|
@@ -4,33 +4,33 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
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
|
-
import { Logger, SfdcUrl, SfProject, Messages, SfError } from '@salesforce/core';
|
|
7
|
+
import { Logger, SfdcUrl, SfProject, Messages, SfError, Global, Mode } from '@salesforce/core';
|
|
8
8
|
import { getString, isObject } from '@salesforce/ts-types';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import { prompts } from '@salesforce/sf-plugins-core';
|
|
9
11
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
12
|
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return instanceUrl;
|
|
17
|
-
}
|
|
18
|
-
let loginUrl;
|
|
19
|
-
try {
|
|
20
|
-
const project = await SfProject.resolve();
|
|
21
|
-
const projectJson = await project.resolveProjectConfig();
|
|
22
|
-
loginUrl = getString(projectJson, 'sfdcLoginUrl', SfdcUrl.PRODUCTION);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
const message = (isObject(err) ? Reflect.get(err, 'message') ?? err : err);
|
|
26
|
-
logger.debug(`error occurred while trying to determine loginUrl: ${message}`);
|
|
27
|
-
loginUrl = SfdcUrl.PRODUCTION;
|
|
28
|
-
}
|
|
29
|
-
throwIfLightning(loginUrl);
|
|
30
|
-
logger.debug(`loginUrl: ${loginUrl}`);
|
|
31
|
-
return loginUrl;
|
|
13
|
+
const resolveLoginUrl = async (instanceUrl) => {
|
|
14
|
+
const logger = await Logger.child('Common', { tag: 'resolveLoginUrl' });
|
|
15
|
+
if (instanceUrl) {
|
|
16
|
+
throwIfLightning(instanceUrl);
|
|
17
|
+
return instanceUrl;
|
|
32
18
|
}
|
|
33
|
-
|
|
19
|
+
let loginUrl;
|
|
20
|
+
try {
|
|
21
|
+
const project = await SfProject.resolve();
|
|
22
|
+
const projectJson = await project.resolveProjectConfig();
|
|
23
|
+
loginUrl = getString(projectJson, 'sfdcLoginUrl', SfdcUrl.PRODUCTION);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const message = (isObject(err) ? Reflect.get(err, 'message') ?? err : err);
|
|
27
|
+
logger.debug(`error occurred while trying to determine loginUrl: ${message}`);
|
|
28
|
+
loginUrl = SfdcUrl.PRODUCTION;
|
|
29
|
+
}
|
|
30
|
+
throwIfLightning(loginUrl);
|
|
31
|
+
logger.debug(`loginUrl: ${loginUrl}`);
|
|
32
|
+
return loginUrl;
|
|
33
|
+
};
|
|
34
34
|
const throwIfLightning = (urlString) => {
|
|
35
35
|
if (urlString?.match(/\.lightning\..*force\.com/)) {
|
|
36
36
|
throw new SfError(messages.getMessage('lightningInstanceUrl'), 'LightningDomain', [
|
|
@@ -38,4 +38,11 @@ const throwIfLightning = (urlString) => {
|
|
|
38
38
|
]);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
const shouldExitCommand = async (noPrompt) => Boolean(noPrompt) || Global.getEnvironmentMode() !== Mode.DEMO
|
|
42
|
+
? false
|
|
43
|
+
: !(await prompts.confirm({ message: chalk.dim(messages.getMessage('warnAuth', ['sf'])), ms: 60000 }));
|
|
44
|
+
export default {
|
|
45
|
+
shouldExitCommand,
|
|
46
|
+
resolveLoginUrl,
|
|
47
|
+
};
|
|
41
48
|
//# sourceMappingURL=common.js.map
|
package/lib/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,SAAS,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AE,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,SAAkB,EAAQ,EAAE;IACpD,IAAI,SAAS,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,iBAAiB,EAAE;YAChF,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAAkB,EAAoB,EAAE,CACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,KAAK,IAAI,CAAC,IAAI;IAC5D,CAAC,CAAC,KAAK;IACP,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAM,EAAE,CAAC,CAAC,CAAC;AAE5G,eAAe;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC"}
|
package/messages/messages.md
CHANGED
|
@@ -40,10 +40,6 @@ Do you want to authorize this org for use with the Salesforce CLI?
|
|
|
40
40
|
|
|
41
41
|
Don't prompt for confirmation.
|
|
42
42
|
|
|
43
|
-
# flags.disable-masking.summary
|
|
44
|
-
|
|
45
|
-
Disable masking of user input; use with problematic terminals.
|
|
46
|
-
|
|
47
43
|
# clientSecretStdin
|
|
48
44
|
|
|
49
45
|
OAuth client secret of personal connected app? Press Enter if it's not required.
|