@salesforce/core 3.7.1 → 3.7.5
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/CHANGELOG.md +96 -2
- package/LICENSE.txt +1 -1
- package/lib/config/config.js +15 -15
- package/lib/config/configAggregator.js +4 -4
- package/lib/config/configFile.js +9 -9
- package/lib/config/configStore.js +12 -13
- package/lib/config/envVars.d.ts +20 -5
- package/lib/config/envVars.js +75 -10
- package/lib/config/keychainConfig.js +1 -1
- package/lib/crypto/crypto.js +6 -6
- package/lib/crypto/keyChainImpl.js +6 -5
- package/lib/crypto/secureBuffer.js +1 -1
- package/lib/deviceOauthService.js +5 -4
- package/lib/exported.d.ts +2 -2
- package/lib/exported.js +6 -2
- package/lib/globalInfo/globalInfoConfig.js +1 -1
- package/lib/globalInfo/sfdxDataHandler.js +11 -11
- package/lib/lifecycleEvents.d.ts +38 -1
- package/lib/lifecycleEvents.js +73 -2
- package/lib/logger.js +13 -12
- package/lib/messages.js +10 -9
- package/lib/org/authInfo.d.ts +2 -6
- package/lib/org/authInfo.js +44 -41
- package/lib/org/connection.js +14 -11
- package/lib/org/org.d.ts +121 -9
- package/lib/org/org.js +373 -36
- package/lib/org/orgConfigProperties.js +1 -1
- package/lib/org/permissionSetAssignment.js +3 -3
- package/lib/org/user.js +20 -20
- package/lib/schema/printer.js +18 -18
- package/lib/schema/validator.js +8 -8
- package/lib/sfdxError.d.ts +1 -1
- package/lib/sfdxError.js +3 -2
- package/lib/sfdxProject.js +15 -13
- package/lib/status/myDomainResolver.js +3 -3
- package/lib/status/pollingClient.d.ts +0 -1
- package/lib/status/pollingClient.js +2 -2
- package/lib/status/streamingClient.d.ts +2 -3
- package/lib/status/streamingClient.js +16 -22
- package/lib/status/types.d.ts +89 -0
- package/lib/status/types.js +18 -0
- package/lib/testSetup.d.ts +3 -2
- package/lib/testSetup.js +25 -25
- package/lib/util/cache.js +3 -3
- package/lib/util/fs.js +12 -12
- package/lib/util/sfdc.js +3 -3
- package/lib/util/sfdcUrl.d.ts +2 -1
- package/lib/util/sfdcUrl.js +16 -8
- package/lib/webOAuthServer.js +7 -7
- package/messages/core.json +3 -3
- package/messages/core.md +1 -1
- package/messages/envVars.md +53 -13
- package/messages/org.md +36 -0
- package/package.json +39 -46
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CometClient = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const events_1 = require("events");
|
|
11
|
+
/**
|
|
12
|
+
* Comet client interface. The is to allow for mocking the inner streaming Cometd implementation.
|
|
13
|
+
* The Faye implementation is used by default but it could be used to adapt another Cometd impl.
|
|
14
|
+
*/
|
|
15
|
+
class CometClient extends events_1.EventEmitter {
|
|
16
|
+
}
|
|
17
|
+
exports.CometClient = CometClient;
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
package/lib/testSetup.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="sfdx-faye" />
|
|
2
1
|
/// <reference types="node" />
|
|
3
2
|
import { EventEmitter } from 'events';
|
|
4
3
|
import * as sinonType from 'sinon';
|
|
@@ -391,7 +390,9 @@ export declare class MockTestOrgData {
|
|
|
391
390
|
refreshToken: string;
|
|
392
391
|
userId: string;
|
|
393
392
|
redirectUri: string;
|
|
394
|
-
constructor(id?: string
|
|
393
|
+
constructor(id?: string, options?: {
|
|
394
|
+
username: string;
|
|
395
|
+
});
|
|
395
396
|
createDevHubUsername(username: string): void;
|
|
396
397
|
makeDevHub(): void;
|
|
397
398
|
createUser(user: string): MockTestOrgData;
|
package/lib/testSetup.js
CHANGED
|
@@ -27,13 +27,13 @@ const streamingClient_1 = require("./status/streamingClient");
|
|
|
27
27
|
const globalInfo_1 = require("./globalInfo");
|
|
28
28
|
const global_1 = require("./global");
|
|
29
29
|
const uniqid = () => {
|
|
30
|
-
return crypto_1.randomBytes(16).toString('hex');
|
|
30
|
+
return (0, crypto_1.randomBytes)(16).toString('hex');
|
|
31
31
|
};
|
|
32
32
|
function getTestLocalPath(uid) {
|
|
33
|
-
return path_1.join(os_1.tmpdir(), uid, 'sfdx_core', 'local');
|
|
33
|
+
return (0, path_1.join)((0, os_1.tmpdir)(), uid, 'sfdx_core', 'local');
|
|
34
34
|
}
|
|
35
35
|
function getTestGlobalPath(uid) {
|
|
36
|
-
return path_1.join(os_1.tmpdir(), uid, 'sfdx_core', 'global');
|
|
36
|
+
return (0, path_1.join)((0, os_1.tmpdir)(), uid, 'sfdx_core', 'global');
|
|
37
37
|
}
|
|
38
38
|
function retrieveRootPathSync(isGlobal, uid = uniqid()) {
|
|
39
39
|
return isGlobal ? getTestGlobalPath(uid) : getTestLocalPath(uid);
|
|
@@ -43,7 +43,7 @@ async function retrieveRootPath(isGlobal, uid = uniqid()) {
|
|
|
43
43
|
return retrieveRootPathSync(isGlobal, uid);
|
|
44
44
|
}
|
|
45
45
|
function defaultFakeConnectionRequest() {
|
|
46
|
-
return Promise.resolve(ts_types_1.ensureAnyJson({ records: [] }));
|
|
46
|
+
return Promise.resolve((0, ts_types_1.ensureAnyJson)({ records: [] }));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Instantiate a @salesforce/core test context. This is automatically created by `const $$ = testSetup()`
|
|
@@ -66,7 +66,7 @@ function defaultFakeConnectionRequest() {
|
|
|
66
66
|
* ```
|
|
67
67
|
* @param sinon
|
|
68
68
|
*/
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
70
70
|
const instantiateContext = (sinon) => {
|
|
71
71
|
if (!sinon) {
|
|
72
72
|
try {
|
|
@@ -78,7 +78,7 @@ const instantiateContext = (sinon) => {
|
|
|
78
78
|
}
|
|
79
79
|
// Import all the messages files in the sfdx-core messages dir.
|
|
80
80
|
// Messages.importMessagesDirectory(pathJoin(__dirname, '..', '..'));
|
|
81
|
-
messages_1.Messages.importMessagesDirectory(path_1.join(__dirname));
|
|
81
|
+
messages_1.Messages.importMessagesDirectory((0, path_1.join)(__dirname));
|
|
82
82
|
// Create a global sinon sandbox and a test logger instance for use within tests.
|
|
83
83
|
const defaultSandbox = sinon.createSandbox();
|
|
84
84
|
const testContext = {
|
|
@@ -110,7 +110,7 @@ const instantiateContext = (sinon) => {
|
|
|
110
110
|
const stub = this.configStubs[name];
|
|
111
111
|
if (stub && stub.contents) {
|
|
112
112
|
if (group && stub.contents[group]) {
|
|
113
|
-
return ts_types_1.ensureJsonMap(stub.contents[group]);
|
|
113
|
+
return (0, ts_types_1.ensureJsonMap)(stub.contents[group]);
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
return stub.contents;
|
|
@@ -119,7 +119,7 @@ const instantiateContext = (sinon) => {
|
|
|
119
119
|
return {};
|
|
120
120
|
},
|
|
121
121
|
setConfigStubContents(name, value) {
|
|
122
|
-
if (ts_types_1.ensureString(name) && ts_types_1.isJsonMap(value)) {
|
|
122
|
+
if ((0, ts_types_1.ensureString)(name) && (0, ts_types_1.isJsonMap)(value)) {
|
|
123
123
|
this.configStubs[name] = value;
|
|
124
124
|
}
|
|
125
125
|
},
|
|
@@ -169,12 +169,12 @@ const stubContext = (testContext) => {
|
|
|
169
169
|
// @ts-ignore
|
|
170
170
|
global_1.Global.SFDX_INTEROPERABILITY = false;
|
|
171
171
|
// Most core files create a child logger so stub this to return our test logger.
|
|
172
|
-
ts_sinon_1.stubMethod(testContext.SANDBOX, logger_1.Logger, 'child').returns(Promise.resolve(testContext.TEST_LOGGER));
|
|
173
|
-
ts_sinon_1.stubMethod(testContext.SANDBOX, logger_1.Logger, 'childFromRoot').returns(testContext.TEST_LOGGER);
|
|
172
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOX, logger_1.Logger, 'child').returns(Promise.resolve(testContext.TEST_LOGGER));
|
|
173
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOX, logger_1.Logger, 'childFromRoot').returns(testContext.TEST_LOGGER);
|
|
174
174
|
testContext.inProject(true);
|
|
175
175
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolder').callsFake((isGlobal) => testContext.rootPathRetriever(isGlobal, testContext.id));
|
|
176
176
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolderSync').callsFake((isGlobal) => testContext.rootPathRetrieverSync(isGlobal, testContext.id));
|
|
177
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.PROJECT, sfdxProject_1.SfdxProjectJson.prototype, 'doesPackageExist').callsFake(() => true);
|
|
177
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.PROJECT, sfdxProject_1.SfdxProjectJson.prototype, 'doesPackageExist').callsFake(() => true);
|
|
178
178
|
const initStubForRead = (configFile) => {
|
|
179
179
|
const stub = testContext.configStubs[configFile.constructor.name] || {};
|
|
180
180
|
// init calls read calls getPath which sets the path on the config file the first time.
|
|
@@ -232,14 +232,14 @@ const stubContext = (testContext) => {
|
|
|
232
232
|
writeSync.call(this);
|
|
233
233
|
}
|
|
234
234
|
};
|
|
235
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.CONFIG, configFile_1.ConfigFile.prototype, 'writeSync').callsFake(writeSync);
|
|
236
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.CONFIG, configFile_1.ConfigFile.prototype, 'write').callsFake(write);
|
|
237
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.CRYPTO, crypto_2.Crypto.prototype, 'getKeyChain').callsFake(() => Promise.resolve({
|
|
235
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.CONFIG, configFile_1.ConfigFile.prototype, 'writeSync').callsFake(writeSync);
|
|
236
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.CONFIG, configFile_1.ConfigFile.prototype, 'write').callsFake(write);
|
|
237
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.CRYPTO, crypto_2.Crypto.prototype, 'getKeyChain').callsFake(() => Promise.resolve({
|
|
238
238
|
setPassword: () => Promise.resolve(),
|
|
239
239
|
getPassword: (data, cb) => cb(undefined, '12345678901234567890123456789012'),
|
|
240
240
|
}));
|
|
241
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.CONNECTION, connection_1.Connection.prototype, 'isResolvable').resolves(true);
|
|
242
|
-
ts_sinon_1.stubMethod(testContext.SANDBOXES.CONNECTION, connection_1.Connection.prototype, 'request').callsFake(function (request, options) {
|
|
241
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.CONNECTION, connection_1.Connection.prototype, 'isResolvable').resolves(true);
|
|
242
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.CONNECTION, connection_1.Connection.prototype, 'request').callsFake(function (request, options) {
|
|
243
243
|
if (request === `${this.instanceUrl}/services/data`) {
|
|
244
244
|
return Promise.resolve([{ version: '42.0' }]);
|
|
245
245
|
}
|
|
@@ -278,15 +278,15 @@ const restoreContext = (testContext) => {
|
|
|
278
278
|
exports.restoreContext = restoreContext;
|
|
279
279
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
280
|
const _testSetup = (sinon) => {
|
|
281
|
-
const testContext = exports.instantiateContext(sinon);
|
|
281
|
+
const testContext = (0, exports.instantiateContext)(sinon);
|
|
282
282
|
beforeEach(() => {
|
|
283
283
|
// Allow each test to have their own config aggregator
|
|
284
284
|
// @ts-ignore clear for testing.
|
|
285
285
|
delete configAggregator_1.ConfigAggregator.instance;
|
|
286
|
-
exports.stubContext(testContext);
|
|
286
|
+
(0, exports.stubContext)(testContext);
|
|
287
287
|
});
|
|
288
288
|
afterEach(() => {
|
|
289
|
-
exports.restoreContext(testContext);
|
|
289
|
+
(0, exports.restoreContext)(testContext);
|
|
290
290
|
});
|
|
291
291
|
return testContext;
|
|
292
292
|
};
|
|
@@ -318,7 +318,7 @@ const _testSetup = (sinon) => {
|
|
|
318
318
|
* });
|
|
319
319
|
* ```
|
|
320
320
|
*/
|
|
321
|
-
exports.testSetup = kit_1.once(_testSetup);
|
|
321
|
+
exports.testSetup = (0, kit_1.once)(_testSetup);
|
|
322
322
|
/**
|
|
323
323
|
* A pre-canned error for try/catch testing.
|
|
324
324
|
*
|
|
@@ -413,7 +413,7 @@ class StreamingMockCometClient extends streamingClient_1.CometClient {
|
|
|
413
413
|
* @param {StreamingMockCometSubscriptionOptions} options Extends the StreamingClient options.
|
|
414
414
|
*/
|
|
415
415
|
constructor(options) {
|
|
416
|
-
super(
|
|
416
|
+
super();
|
|
417
417
|
this.options = options;
|
|
418
418
|
if (!this.options.messagePlaylist) {
|
|
419
419
|
this.options.messagePlaylist = [{ id: this.options.id }];
|
|
@@ -475,11 +475,11 @@ exports.StreamingMockCometClient = StreamingMockCometClient;
|
|
|
475
475
|
* Mock class for OrgData.
|
|
476
476
|
*/
|
|
477
477
|
class MockTestOrgData {
|
|
478
|
-
constructor(id = uniqid()) {
|
|
478
|
+
constructor(id = uniqid(), options) {
|
|
479
479
|
this.testId = id;
|
|
480
480
|
this.userId = `user_id_${this.testId}`;
|
|
481
481
|
this.orgId = `${this.testId}`;
|
|
482
|
-
this.username = `admin_${this.testId}@gb.org`;
|
|
482
|
+
this.username = (options === null || options === void 0 ? void 0 : options.username) || `admin_${this.testId}@gb.org`;
|
|
483
483
|
this.loginUrl = `http://login.${this.testId}.salesforce.com`;
|
|
484
484
|
this.instanceUrl = `http://instance.${this.testId}.salesforce.com`;
|
|
485
485
|
this.clientId = `${this.testId}/client_id`;
|
|
@@ -493,7 +493,7 @@ class MockTestOrgData {
|
|
|
493
493
|
this.devHubUsername = username;
|
|
494
494
|
}
|
|
495
495
|
makeDevHub() {
|
|
496
|
-
kit_1.set(this, 'isDevHub', true);
|
|
496
|
+
(0, kit_1.set)(this, 'isDevHub', true);
|
|
497
497
|
}
|
|
498
498
|
createUser(user) {
|
|
499
499
|
const userMock = new MockTestOrgData();
|
|
@@ -544,7 +544,7 @@ class MockTestOrgData {
|
|
|
544
544
|
if (this.devHubUsername) {
|
|
545
545
|
config.devHubUsername = this.devHubUsername;
|
|
546
546
|
}
|
|
547
|
-
const isDevHub = ts_types_1.getBoolean(this, 'isDevHub');
|
|
547
|
+
const isDevHub = (0, ts_types_1.getBoolean)(this, 'isDevHub');
|
|
548
548
|
if (isDevHub) {
|
|
549
549
|
config.isDevHub = isDevHub;
|
|
550
550
|
}
|
package/lib/util/cache.js
CHANGED
|
@@ -41,12 +41,12 @@ class Cache extends Map {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
static get(key) {
|
|
44
|
-
var _b, _c;
|
|
44
|
+
var _b, _c, _d;
|
|
45
45
|
if (!__classPrivateFieldGet(Cache, _a, "f", _Cache_enabled)) {
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
48
|
-
__classPrivateFieldSet(_b = Cache.instance(), _Cache_lookups,
|
|
49
|
-
__classPrivateFieldSet(
|
|
48
|
+
__classPrivateFieldSet(_b = Cache.instance(), _Cache_lookups, (_c = __classPrivateFieldGet(_b, _Cache_lookups, "f"), _c++, _c), "f");
|
|
49
|
+
__classPrivateFieldSet(_d = Cache.instance(), _Cache_hits, __classPrivateFieldGet(_d, _Cache_hits, "f") + (Cache.instance().has(key) ? 1 : 0), "f");
|
|
50
50
|
return __classPrivateFieldGet(Cache, _a, "f", _Cache_instance).get(key);
|
|
51
51
|
}
|
|
52
52
|
static disable() {
|
package/lib/util/fs.js
CHANGED
|
@@ -34,35 +34,35 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
34
34
|
/**
|
|
35
35
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readfile_path_options_callback|fsLib.readFile}.
|
|
36
36
|
*/
|
|
37
|
-
readFile: util_1.promisify(fsLib.readFile),
|
|
37
|
+
readFile: (0, util_1.promisify)(fsLib.readFile),
|
|
38
38
|
/**
|
|
39
39
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readdir_path_options_callback|fsLib.readdir}.
|
|
40
40
|
*/
|
|
41
|
-
readdir: util_1.promisify(fsLib.readdir),
|
|
41
|
+
readdir: (0, util_1.promisify)(fsLib.readdir),
|
|
42
42
|
/**
|
|
43
43
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_writefile_file_data_options_callback|fsLib.writeFile}.
|
|
44
44
|
*/
|
|
45
|
-
writeFile: util_1.promisify(fsLib.writeFile),
|
|
45
|
+
writeFile: (0, util_1.promisify)(fsLib.writeFile),
|
|
46
46
|
/**
|
|
47
47
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_access_path_mode_callback|fsLib.access}.
|
|
48
48
|
*/
|
|
49
|
-
access: util_1.promisify(fsLib.access),
|
|
49
|
+
access: (0, util_1.promisify)(fsLib.access),
|
|
50
50
|
/**
|
|
51
51
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_open_path_flags_mode_callback|fsLib.open}.
|
|
52
52
|
*/
|
|
53
|
-
open: util_1.promisify(fsLib.open),
|
|
53
|
+
open: (0, util_1.promisify)(fsLib.open),
|
|
54
54
|
/**
|
|
55
55
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_unlink_path_callback|fsLib.unlink}.
|
|
56
56
|
*/
|
|
57
|
-
unlink: util_1.promisify(fsLib.unlink),
|
|
57
|
+
unlink: (0, util_1.promisify)(fsLib.unlink),
|
|
58
58
|
/**
|
|
59
59
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readdir_path_options_callback|fsLib.rmdir}.
|
|
60
60
|
*/
|
|
61
|
-
rmdir: util_1.promisify(fsLib.rmdir),
|
|
61
|
+
rmdir: (0, util_1.promisify)(fsLib.rmdir),
|
|
62
62
|
/**
|
|
63
63
|
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_fstat_fd_callback|fsLib.stat}.
|
|
64
64
|
*/
|
|
65
|
-
stat: util_1.promisify(fsLib.stat),
|
|
65
|
+
stat: (0, util_1.promisify)(fsLib.stat),
|
|
66
66
|
/**
|
|
67
67
|
* Promisified version of {@link https://npmjs.com/package/mkdirp|mkdirp}.
|
|
68
68
|
*/
|
|
@@ -183,7 +183,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
183
183
|
*/
|
|
184
184
|
readJson: async (jsonPath, throwOnEmpty) => {
|
|
185
185
|
const fileData = await exports.fs.readFile(jsonPath, 'utf8');
|
|
186
|
-
return kit_1.parseJson(fileData, jsonPath, throwOnEmpty);
|
|
186
|
+
return (0, kit_1.parseJson)(fileData, jsonPath, throwOnEmpty);
|
|
187
187
|
},
|
|
188
188
|
/**
|
|
189
189
|
* Read a file and convert it to JSON. Returns the contents of the file as a JSON object
|
|
@@ -193,7 +193,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
193
193
|
*/
|
|
194
194
|
readJsonSync: (jsonPath, throwOnEmpty) => {
|
|
195
195
|
const fileData = exports.fs.readFileSync(jsonPath, 'utf8');
|
|
196
|
-
return kit_1.parseJson(fileData, jsonPath, throwOnEmpty);
|
|
196
|
+
return (0, kit_1.parseJson)(fileData, jsonPath, throwOnEmpty);
|
|
197
197
|
},
|
|
198
198
|
/**
|
|
199
199
|
* Read a file and convert it to JSON, throwing an error if the parsed contents are not a `JsonMap`.
|
|
@@ -203,7 +203,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
203
203
|
*/
|
|
204
204
|
readJsonMap: async (jsonPath, throwOnEmpty) => {
|
|
205
205
|
const fileData = await exports.fs.readFile(jsonPath, 'utf8');
|
|
206
|
-
return kit_1.parseJsonMap(fileData, jsonPath, throwOnEmpty);
|
|
206
|
+
return (0, kit_1.parseJsonMap)(fileData, jsonPath, throwOnEmpty);
|
|
207
207
|
},
|
|
208
208
|
/**
|
|
209
209
|
* Read a file and convert it to JSON, throwing an error if the parsed contents are not a `JsonMap`.
|
|
@@ -213,7 +213,7 @@ exports.fs = Object.assign({}, fsLib, {
|
|
|
213
213
|
*/
|
|
214
214
|
readJsonMapSync: (jsonPath, throwOnEmpty) => {
|
|
215
215
|
const fileData = exports.fs.readFileSync(jsonPath, 'utf8');
|
|
216
|
-
return kit_1.parseJsonMap(fileData, jsonPath, throwOnEmpty);
|
|
216
|
+
return (0, kit_1.parseJsonMap)(fileData, jsonPath, throwOnEmpty);
|
|
217
217
|
},
|
|
218
218
|
/**
|
|
219
219
|
* Convert a JSON-compatible object to a `string` and write it to a file.
|
package/lib/util/sfdc.js
CHANGED
|
@@ -63,15 +63,15 @@ exports.sfdc = {
|
|
|
63
63
|
*/
|
|
64
64
|
findUpperCaseKeys: (data, sectionBlocklist = []) => {
|
|
65
65
|
let key;
|
|
66
|
-
kit_1.findKey(data, (val, k) => {
|
|
66
|
+
(0, kit_1.findKey)(data, (val, k) => {
|
|
67
67
|
if (k.substr(0, 1) === k.substr(0, 1).toUpperCase()) {
|
|
68
68
|
key = k;
|
|
69
69
|
}
|
|
70
|
-
else if (ts_types_1.isJsonMap(val)) {
|
|
70
|
+
else if ((0, ts_types_1.isJsonMap)(val)) {
|
|
71
71
|
if (sectionBlocklist.includes(k)) {
|
|
72
72
|
return key;
|
|
73
73
|
}
|
|
74
|
-
key = exports.sfdc.findUpperCaseKeys(ts_types_1.asJsonMap(val));
|
|
74
|
+
key = exports.sfdc.findUpperCaseKeys((0, ts_types_1.asJsonMap)(val));
|
|
75
75
|
}
|
|
76
76
|
return key;
|
|
77
77
|
});
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -36,9 +36,10 @@ export declare class SfdcUrl extends URL {
|
|
|
36
36
|
* @returns {boolean} true if this is a local machine
|
|
37
37
|
*/
|
|
38
38
|
isLocalUrl(): boolean;
|
|
39
|
+
toLightningDomain(): string;
|
|
39
40
|
/**
|
|
40
41
|
* Tests whether this url has the lightning domain extension
|
|
41
|
-
* This method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again
|
|
42
|
+
* This method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
|
|
42
43
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
43
44
|
*
|
|
44
45
|
* @returns {Promise<true | never>} The resolved ip address or never
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -12,12 +12,13 @@ const kit_1 = require("@salesforce/kit");
|
|
|
12
12
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
13
|
const myDomainResolver_1 = require("../status/myDomainResolver");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
|
+
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
15
16
|
class SfdcUrl extends url_1.URL {
|
|
16
17
|
constructor(input, base) {
|
|
17
18
|
super(input.toString(), base);
|
|
18
19
|
if (this.protocol !== 'https:' && !SfdcUrl.cache.has(this.origin)) {
|
|
19
20
|
SfdcUrl.cache.add(this.origin);
|
|
20
|
-
|
|
21
|
+
void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(`Using insecure protocol: ${this.protocol} on url: ${this.origin}`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
static isValidUrl(input) {
|
|
@@ -105,25 +106,31 @@ class SfdcUrl extends url_1.URL {
|
|
|
105
106
|
const LOCAL_PARTS = ['localhost.sfdcdev.', '.internal.'];
|
|
106
107
|
return LOCAL_PARTS.some((part) => this.origin.includes(part));
|
|
107
108
|
}
|
|
109
|
+
toLightningDomain() {
|
|
110
|
+
if (this.origin.endsWith('.my.salesforce.mil')) {
|
|
111
|
+
return this.origin.replace('.my.salesforce.mil', '.lightning.crmforce.mil');
|
|
112
|
+
}
|
|
113
|
+
// all non-mil domains
|
|
114
|
+
return `https://${(0, ts_types_1.ensureArray)(/https?:\/\/([^.]*)/.exec(this.origin))
|
|
115
|
+
.slice(1, 2)
|
|
116
|
+
.pop()}.lightning.force.com`;
|
|
117
|
+
}
|
|
108
118
|
/**
|
|
109
119
|
* Tests whether this url has the lightning domain extension
|
|
110
|
-
* This method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again
|
|
120
|
+
* This method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
|
|
111
121
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
112
122
|
*
|
|
113
123
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
114
124
|
* @throws {@link SfdxError} If can't resolve DNS.
|
|
115
125
|
*/
|
|
116
126
|
async checkLightningDomain() {
|
|
117
|
-
const
|
|
118
|
-
.slice(1, 2)
|
|
119
|
-
.pop()}.lightning.force.com`;
|
|
120
|
-
const quantity = ts_types_1.ensureNumber(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
127
|
+
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
121
128
|
const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
|
|
122
129
|
if (this.isInternalUrl() || timeout.seconds === 0) {
|
|
123
130
|
return true;
|
|
124
131
|
}
|
|
125
132
|
const resolver = await myDomainResolver_1.MyDomainResolver.create({
|
|
126
|
-
url: new url_1.URL(
|
|
133
|
+
url: new url_1.URL(this.toLightningDomain()),
|
|
127
134
|
timeout,
|
|
128
135
|
frequency: new kit_1.Duration(1, kit_1.Duration.Unit.SECONDS),
|
|
129
136
|
});
|
|
@@ -138,7 +145,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
138
145
|
* @throws {@link SfdxError} If can't resolve DNS.
|
|
139
146
|
*/
|
|
140
147
|
async lookup() {
|
|
141
|
-
const quantity = ts_types_1.ensureNumber(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
148
|
+
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
142
149
|
const timeout = new kit_1.Duration(quantity, kit_1.Duration.Unit.SECONDS);
|
|
143
150
|
const resolver = await myDomainResolver_1.MyDomainResolver.create({
|
|
144
151
|
url: new url_1.URL(this.origin),
|
|
@@ -155,6 +162,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
155
162
|
*/
|
|
156
163
|
isSandboxUrl(createdOrgInstance) {
|
|
157
164
|
return ((createdOrgInstance && /^cs|s$/gi.test(createdOrgInstance)) ||
|
|
165
|
+
this.origin.endsWith('sandbox.my.salesforce.mil') ||
|
|
158
166
|
/sandbox\.my\.salesforce\.com/gi.test(this.origin) || // enhanced domains >= 230
|
|
159
167
|
/(cs[0-9]+(\.my|)\.salesforce\.com)/gi.test(this.origin) || // my domains on CS instance OR CS instance without my domain
|
|
160
168
|
/([a-z]{3}[0-9]+s\.sfdc-.+\.salesforce\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.salesforce.com
|
package/lib/webOAuthServer.js
CHANGED
|
@@ -146,11 +146,11 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
146
146
|
this.logger.debug('Starting web auth flow');
|
|
147
147
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
148
148
|
this.webServer.server.on('request', async (request, response) => {
|
|
149
|
-
const url = url_1.parse(request.url);
|
|
149
|
+
const url = (0, url_1.parse)(request.url);
|
|
150
150
|
this.logger.debug(`processing request for uri: ${url.pathname}`);
|
|
151
151
|
if (request.method === 'GET') {
|
|
152
152
|
if (url.pathname && url.pathname.startsWith('/OauthRedirect')) {
|
|
153
|
-
request.query = querystring_1.parse(url.query);
|
|
153
|
+
request.query = (0, querystring_1.parse)(url.query);
|
|
154
154
|
if (request.query.error) {
|
|
155
155
|
const err = new sfdxError_1.SfdxError(request.query.error_description || request.query.error, request.query.error);
|
|
156
156
|
this.webServer.reportError(err, response);
|
|
@@ -158,7 +158,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
158
158
|
}
|
|
159
159
|
this.logger.debug(`request.query.state: ${request.query.state}`);
|
|
160
160
|
try {
|
|
161
|
-
this.oauthConfig.authCode = ts_types_1.asString(this.parseAuthCodeFromRequest(response, request));
|
|
161
|
+
this.oauthConfig.authCode = (0, ts_types_1.asString)(this.parseAuthCodeFromRequest(response, request));
|
|
162
162
|
resolve(response);
|
|
163
163
|
}
|
|
164
164
|
catch (err) {
|
|
@@ -194,9 +194,9 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
194
194
|
this.webServer.sendError(400, `${error.message}\n`, response);
|
|
195
195
|
this.closeRequest(request);
|
|
196
196
|
this.logger.warn('urlStateMismatchAttempt detected.');
|
|
197
|
-
if (!ts_types_1.get(this.webServer.server, 'urlStateMismatchAttempt')) {
|
|
197
|
+
if (!(0, ts_types_1.get)(this.webServer.server, 'urlStateMismatchAttempt')) {
|
|
198
198
|
this.logger.error(error.message);
|
|
199
|
-
kit_1.set(this.webServer.server, 'urlStateMismatchAttempt', true);
|
|
199
|
+
(0, kit_1.set)(this.webServer.server, 'urlStateMismatchAttempt', true);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
else {
|
|
@@ -233,7 +233,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
233
233
|
*/
|
|
234
234
|
validateState(request) {
|
|
235
235
|
const state = request.query.state;
|
|
236
|
-
const query = url_1.parse(this.authUrl, true).query;
|
|
236
|
+
const query = (0, url_1.parse)(this.authUrl, true).query;
|
|
237
237
|
return !!(state && state === query.state);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -372,7 +372,7 @@ class WebServer extends kit_1.AsyncCreatable {
|
|
|
372
372
|
*/
|
|
373
373
|
getSocketTimeout() {
|
|
374
374
|
const env = new kit_1.Env();
|
|
375
|
-
const socketTimeout = kit_1.toNumber(env.getNumber('SFDX_HTTP_SOCKET_TIMEOUT'));
|
|
375
|
+
const socketTimeout = (0, kit_1.toNumber)(env.getNumber('SFDX_HTTP_SOCKET_TIMEOUT'));
|
|
376
376
|
return Number.isInteger(socketTimeout) && socketTimeout > 0
|
|
377
377
|
? socketTimeout
|
|
378
378
|
: WebServer.DEFAULT_CLIENT_SOCKET_TIMEOUT;
|
package/messages/core.json
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"OrgDataNotAvailableErrorAction2": "Use `sfdx force:config:set` to update the defaultusername.",
|
|
13
13
|
"OrgDataNotAvailableErrorAction3": "Use `sfdx force:org:create` to create a new org.",
|
|
14
14
|
"OrgDataNotAvailableErrorAction4": "Use `sfdx force:auth` to authenticate an existing org.",
|
|
15
|
-
"NamedOrgNotFound": "No
|
|
16
|
-
"NoAliasesFound": "Nothing to set",
|
|
17
|
-
"InvalidFormat": "Setting aliases must be in the format <key>=<value> but found: [%s]",
|
|
15
|
+
"NamedOrgNotFound": "No authorization information found for %s %s.",
|
|
16
|
+
"NoAliasesFound": "Nothing to set.",
|
|
17
|
+
"InvalidFormat": "Setting aliases must be in the format <key>=<value> but found: [%s].",
|
|
18
18
|
"NoAuthInfoFound": "No authorization information can be found.",
|
|
19
19
|
"InvalidJsonCasing": "All JSON input must have heads down camelcase keys. E.g., { sfdcLoginUrl: \"https://login.salesforce.com\" }\nFound \"%s\" at %s"
|
|
20
20
|
}
|
package/messages/core.md
CHANGED
package/messages/envVars.md
CHANGED
|
@@ -12,15 +12,15 @@ Speed of the spinner in milliseconds. Default is 60.
|
|
|
12
12
|
|
|
13
13
|
# httpProxy
|
|
14
14
|
|
|
15
|
-
HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy.
|
|
15
|
+
HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy.
|
|
16
16
|
|
|
17
17
|
# httpsProxy
|
|
18
18
|
|
|
19
|
-
HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy.
|
|
19
|
+
HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy.
|
|
20
20
|
|
|
21
21
|
# nodeExtraCaCerts
|
|
22
22
|
|
|
23
|
-
Fully qualified path to your self-signed certificate. Will be installed after you run "sfdx update".
|
|
23
|
+
Fully qualified path to your self-signed certificate. Will be installed after you run "sfdx update".
|
|
24
24
|
|
|
25
25
|
# nodeTlsRejectUnauthorized
|
|
26
26
|
|
|
@@ -36,7 +36,7 @@ The API version for a specific project or all projects. Default value is the API
|
|
|
36
36
|
|
|
37
37
|
# sfdxAudienceUrl
|
|
38
38
|
|
|
39
|
-
URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you’re logging into.
|
|
39
|
+
URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you’re logging into.
|
|
40
40
|
|
|
41
41
|
# sfdxCodeCoverageRequirement
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Code coverage percentages that are displayed in green when you run force:apex:te
|
|
|
44
44
|
|
|
45
45
|
# sfdxContentType
|
|
46
46
|
|
|
47
|
-
Set to JSON so that all CLI commands output results in JSON format.
|
|
47
|
+
Set to JSON so that all CLI commands output results in JSON format.
|
|
48
48
|
|
|
49
49
|
# sfdxDefaultdevhubusername
|
|
50
50
|
|
|
@@ -56,11 +56,11 @@ Username or alias of your default org. Overrides the defaultusername configurati
|
|
|
56
56
|
|
|
57
57
|
# sfdxDisableAutoupdate
|
|
58
58
|
|
|
59
|
-
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
59
|
+
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
60
60
|
|
|
61
61
|
# sfdxAutoupdateDisable
|
|
62
62
|
|
|
63
|
-
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
63
|
+
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
64
64
|
|
|
65
65
|
# sfdxDisableSourceMemberPolling
|
|
66
66
|
|
|
@@ -80,7 +80,7 @@ Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom
|
|
|
80
80
|
|
|
81
81
|
# sfdxImprovedCodeCoverage
|
|
82
82
|
|
|
83
|
-
Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\*.
|
|
83
|
+
Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\*.
|
|
84
84
|
|
|
85
85
|
# sfdxInstanceUrl
|
|
86
86
|
|
|
@@ -134,6 +134,26 @@ Number of seconds you want the force:source:push command to keep polling the Sou
|
|
|
134
134
|
|
|
135
135
|
Set to false to disable the progress bar when running force:mdapi:deploy, force:source:deploy, or force:source:push.
|
|
136
136
|
|
|
137
|
+
# sfdxLazyLoadModules
|
|
138
|
+
|
|
139
|
+
Set to true to enable lazy loading of sfdx modules
|
|
140
|
+
|
|
141
|
+
# sfdxS3Host
|
|
142
|
+
|
|
143
|
+
URL to S3 host
|
|
144
|
+
|
|
145
|
+
# sfdxUpdateInstructions
|
|
146
|
+
|
|
147
|
+
Text that describes how to update sfdx
|
|
148
|
+
|
|
149
|
+
# sfdxInstaller
|
|
150
|
+
|
|
151
|
+
Boolean indicating that the installer is running
|
|
152
|
+
|
|
153
|
+
# sfdxEnv
|
|
154
|
+
|
|
155
|
+
Describes if sfdx is in "demo" mode
|
|
156
|
+
|
|
137
157
|
# sfTargetOrg
|
|
138
158
|
|
|
139
159
|
Username or alias of your default org. Overrides the target-org configuration variable.
|
|
@@ -152,7 +172,7 @@ API version for a specific project or all projects. Default value is the API ver
|
|
|
152
172
|
|
|
153
173
|
# sfAudienceUrl
|
|
154
174
|
|
|
155
|
-
URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you’re logging into.
|
|
175
|
+
URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you’re logging into.
|
|
156
176
|
|
|
157
177
|
# sfCodeCoverageRequirement
|
|
158
178
|
|
|
@@ -160,15 +180,15 @@ Code coverage percentages that are displayed in green when you run the Apex test
|
|
|
160
180
|
|
|
161
181
|
# sfContentType
|
|
162
182
|
|
|
163
|
-
Set to JSON so that all CLI commands output results in JSON format.
|
|
183
|
+
Set to JSON so that all CLI commands output results in JSON format.
|
|
164
184
|
|
|
165
185
|
# sfDisableAutoupdate
|
|
166
186
|
|
|
167
|
-
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
187
|
+
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
168
188
|
|
|
169
189
|
# sfAutoupdateDisable
|
|
170
190
|
|
|
171
|
-
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
191
|
+
Set to true to disable the auto-update feature of Salesforce CLI. Default value is false.
|
|
172
192
|
|
|
173
193
|
# sfDisableSourceMemberPolling
|
|
174
194
|
|
|
@@ -188,7 +208,7 @@ Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom
|
|
|
188
208
|
|
|
189
209
|
# sfImprovedCodeCoverage
|
|
190
210
|
|
|
191
|
-
Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands.
|
|
211
|
+
Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands.
|
|
192
212
|
|
|
193
213
|
# sfInstanceUrl
|
|
194
214
|
|
|
@@ -237,3 +257,23 @@ Number of seconds you want the source push command to keep polling the SourceMem
|
|
|
237
257
|
# sfUseProgressBar
|
|
238
258
|
|
|
239
259
|
Set to false to disable the progress bar when running the metadata deploy command.
|
|
260
|
+
|
|
261
|
+
# sfLazyLoadModules
|
|
262
|
+
|
|
263
|
+
Set to true to enable lazy loading of sf modules
|
|
264
|
+
|
|
265
|
+
# sfS3Host
|
|
266
|
+
|
|
267
|
+
URL to S3 host
|
|
268
|
+
|
|
269
|
+
# sfUpdateInstructions
|
|
270
|
+
|
|
271
|
+
Text that describes how to update sf
|
|
272
|
+
|
|
273
|
+
# sfInstaller
|
|
274
|
+
|
|
275
|
+
Boolean indicating that the installer is running
|
|
276
|
+
|
|
277
|
+
# sfEnv
|
|
278
|
+
|
|
279
|
+
Describes if sf is in "demo" mode
|
package/messages/org.md
CHANGED
|
@@ -5,3 +5,39 @@ The provided dev hub username %s is not a valid dev hub.
|
|
|
5
5
|
# noUsernameFound
|
|
6
6
|
|
|
7
7
|
No username found.
|
|
8
|
+
|
|
9
|
+
# noDevHubFound
|
|
10
|
+
|
|
11
|
+
Unable to associate this scratch org with a DevHub.
|
|
12
|
+
|
|
13
|
+
# deleteOrgHubError
|
|
14
|
+
|
|
15
|
+
The Dev Hub org cannot be deleted.
|
|
16
|
+
|
|
17
|
+
# insufficientAccessToDelete
|
|
18
|
+
|
|
19
|
+
You do not have the appropriate permissions to delete a scratch org. Please contact your Salesforce admin.
|
|
20
|
+
|
|
21
|
+
# scratchOrgNotFound
|
|
22
|
+
|
|
23
|
+
Attempting to delete an expired or deleted org
|
|
24
|
+
|
|
25
|
+
# sandboxDeleteFailed
|
|
26
|
+
|
|
27
|
+
The sandbox org deletion failed with a result of %s.
|
|
28
|
+
|
|
29
|
+
# sandboxNotFound
|
|
30
|
+
|
|
31
|
+
We can't find a SandboxProcess for the sandbox org %s.
|
|
32
|
+
|
|
33
|
+
# sandboxInfoCreateFailed
|
|
34
|
+
|
|
35
|
+
The sandbox org creation failed with a result of %s.
|
|
36
|
+
|
|
37
|
+
# missingAuthUsername
|
|
38
|
+
|
|
39
|
+
The sandbox %s does not have an authorized username.
|
|
40
|
+
|
|
41
|
+
# orgPollingTimeout
|
|
42
|
+
|
|
43
|
+
Sandbox status is %s; timed out waiting for completion.
|