@salesforce/core 6.7.5 → 6.7.7-qa.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/lib/config/authInfoConfig.js +1 -1
- package/lib/config/config.js +6 -5
- package/lib/config/configAggregator.js +7 -2
- package/lib/config/configFile.js +6 -2
- package/lib/config/configStore.js +17 -14
- package/lib/config/lwwMap.js +12 -19
- package/lib/config/lwwRegister.js +1 -0
- package/lib/crypto/crypto.js +3 -1
- package/lib/crypto/keyChainImpl.js +2 -0
- package/lib/crypto/secureBuffer.js +3 -4
- package/lib/deviceOauthService.d.ts +1 -1
- package/lib/deviceOauthService.js +8 -6
- package/lib/global.js +22 -22
- package/lib/index.d.ts +1 -1
- package/lib/lifecycleEvents.js +5 -2
- package/lib/logger/logger.js +31 -29
- package/lib/logger/memoryLogger.js +1 -1
- package/lib/messages.js +41 -30
- package/lib/org/authInfo.d.ts +1 -1
- package/lib/org/authInfo.js +65 -67
- package/lib/org/authRemover.js +7 -2
- package/lib/org/connection.d.ts +4 -4
- package/lib/org/connection.js +33 -22
- package/lib/org/org.js +30 -23
- package/lib/org/permissionSetAssignment.js +2 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -0
- package/lib/org/scratchOrgInfoApi.d.ts +1 -1
- package/lib/org/scratchOrgInfoApi.js +4 -5
- package/lib/org/scratchOrgInfoGenerator.d.ts +2 -2
- package/lib/org/scratchOrgInfoGenerator.js +13 -15
- package/lib/org/scratchOrgSettingsGenerator.d.ts +4 -4
- package/lib/org/scratchOrgSettingsGenerator.js +9 -2
- package/lib/org/user.js +24 -16
- package/lib/schema/validator.js +4 -0
- package/lib/sfError.d.ts +20 -6
- package/lib/sfError.js +48 -37
- package/lib/sfProject.d.ts +7 -0
- package/lib/sfProject.js +25 -15
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +0 -35
- package/lib/stateAggregator/accessors/aliasAccessor.js +4 -68
- package/lib/stateAggregator/accessors/orgAccessor.js +5 -10
- package/lib/stateAggregator/stateAggregator.js +4 -1
- package/lib/status/myDomainResolver.js +3 -1
- package/lib/status/pollingClient.js +5 -0
- package/lib/status/streamingClient.js +16 -4
- package/lib/testSetup.d.ts +2 -2
- package/lib/testSetup.js +75 -29
- package/lib/util/cache.js +21 -35
- package/lib/util/directoryWriter.js +1 -0
- package/lib/util/getJwtAudienceUrl.d.ts +1 -1
- package/lib/util/sfdc.js +1 -1
- package/lib/util/sfdcUrl.js +7 -6
- package/lib/util/zipWriter.js +4 -1
- package/lib/webOAuthServer.js +20 -9
- package/package.json +62 -4
- package/lib/util/checkLightningDomain.d.ts +0 -2
- package/lib/util/checkLightningDomain.js +0 -30
|
@@ -17,6 +17,7 @@ const configFile_1 = require("./configFile");
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
class AuthInfoConfig extends configFile_1.ConfigFile {
|
|
20
|
+
static encryptedKeys = [/token/i, /password/i, /secret/i];
|
|
20
21
|
/**
|
|
21
22
|
* Gets the config options for a given org ID.
|
|
22
23
|
*
|
|
@@ -31,5 +32,4 @@ class AuthInfoConfig extends configFile_1.ConfigFile {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
exports.AuthInfoConfig = AuthInfoConfig;
|
|
34
|
-
AuthInfoConfig.encryptedKeys = [/token/i, /password/i, /secret/i];
|
|
35
35
|
//# sourceMappingURL=authInfoConfig.js.map
|
package/lib/config/config.js
CHANGED
|
@@ -251,6 +251,12 @@ exports.SfProperty = {};
|
|
|
251
251
|
* https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_config_values.htm
|
|
252
252
|
*/
|
|
253
253
|
class Config extends configFile_1.ConfigFile {
|
|
254
|
+
static allowedProperties = [
|
|
255
|
+
...exports.SFDX_ALLOWED_PROPERTIES,
|
|
256
|
+
...exports.SF_ALLOWED_PROPERTIES,
|
|
257
|
+
...orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES,
|
|
258
|
+
];
|
|
259
|
+
sfdxPath;
|
|
254
260
|
constructor(options) {
|
|
255
261
|
super({
|
|
256
262
|
...{ isGlobal: false },
|
|
@@ -496,11 +502,6 @@ class Config extends configFile_1.ConfigFile {
|
|
|
496
502
|
}
|
|
497
503
|
}
|
|
498
504
|
exports.Config = Config;
|
|
499
|
-
Config.allowedProperties = [
|
|
500
|
-
...exports.SFDX_ALLOWED_PROPERTIES,
|
|
501
|
-
...exports.SF_ALLOWED_PROPERTIES,
|
|
502
|
-
...orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES,
|
|
503
|
-
];
|
|
504
505
|
/**
|
|
505
506
|
* convert from "new" to "old" config names
|
|
506
507
|
* - For example, `target-org` will be renamed to `defaultusername`.
|
|
@@ -31,6 +31,13 @@ const messages = new messages_1.Messages('@salesforce/core', 'config', new Map([
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
34
|
+
static instance;
|
|
35
|
+
static encrypted = true;
|
|
36
|
+
// Initialized in loadProperties
|
|
37
|
+
allowedProperties;
|
|
38
|
+
localConfig;
|
|
39
|
+
globalConfig;
|
|
40
|
+
envVars = {};
|
|
34
41
|
/**
|
|
35
42
|
* **Do not directly construct instances of this class -- use {@link ConfigAggregator.create} instead.**
|
|
36
43
|
*
|
|
@@ -38,7 +45,6 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
38
45
|
*/
|
|
39
46
|
constructor(options) {
|
|
40
47
|
super(options ?? {});
|
|
41
|
-
this.envVars = {};
|
|
42
48
|
// Don't throw an project error with the aggregator, since it should resolve to global if
|
|
43
49
|
// there is no project.
|
|
44
50
|
try {
|
|
@@ -347,5 +353,4 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
355
|
exports.ConfigAggregator = ConfigAggregator;
|
|
350
|
-
ConfigAggregator.encrypted = true;
|
|
351
356
|
//# sourceMappingURL=configAggregator.js.map
|
package/lib/config/configFile.js
CHANGED
|
@@ -62,6 +62,12 @@ const lwwMap_1 = require("./lwwMap");
|
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
class ConfigFile extends configStore_1.BaseConfigStore {
|
|
65
|
+
// whether file contents have been read
|
|
66
|
+
hasRead = false;
|
|
67
|
+
// Initialized in init
|
|
68
|
+
logger;
|
|
69
|
+
// Initialized in create
|
|
70
|
+
path;
|
|
65
71
|
/**
|
|
66
72
|
* Create an instance of a config file without reading the file. Call `read` or `readSync`
|
|
67
73
|
* after creating the ConfigFile OR instantiate with {@link ConfigFile.create} instead.
|
|
@@ -71,8 +77,6 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
71
77
|
*/
|
|
72
78
|
constructor(options) {
|
|
73
79
|
super(options);
|
|
74
|
-
// whether file contents have been read
|
|
75
|
-
this.hasRead = false;
|
|
76
80
|
this.logger = logger_1.Logger.childFromRoot(this.constructor.name);
|
|
77
81
|
const statics = this.constructor;
|
|
78
82
|
let defaultOptions = {};
|
|
@@ -21,6 +21,13 @@ const lwwMap_1 = require("./lwwMap");
|
|
|
21
21
|
* **Note:** To see the interface, look in typescripts autocomplete help or the npm package's ConfigStore.d.ts file.
|
|
22
22
|
*/
|
|
23
23
|
class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
24
|
+
// If encryptedKeys is an array of RegExps, they should not contain the /g (global) or /y (sticky) flags to avoid stateful issues.
|
|
25
|
+
static encryptedKeys = [];
|
|
26
|
+
options;
|
|
27
|
+
crypto;
|
|
28
|
+
// Initialized in setContents
|
|
29
|
+
contents = new lwwMap_1.LWWMap();
|
|
30
|
+
statics = this.constructor;
|
|
24
31
|
/**
|
|
25
32
|
* Constructor.
|
|
26
33
|
*
|
|
@@ -29,9 +36,6 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
29
36
|
*/
|
|
30
37
|
constructor(options) {
|
|
31
38
|
super(options);
|
|
32
|
-
// Initialized in setContents
|
|
33
|
-
this.contents = new lwwMap_1.LWWMap();
|
|
34
|
-
this.statics = this.constructor;
|
|
35
39
|
this.options = options ?? {};
|
|
36
40
|
this.setContents(this.initialContents());
|
|
37
41
|
}
|
|
@@ -86,20 +90,21 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
86
90
|
* @param value The value.
|
|
87
91
|
*/
|
|
88
92
|
set(key, value) {
|
|
93
|
+
let resolvedValue = value;
|
|
89
94
|
if (this.hasEncryption()) {
|
|
90
|
-
if ((0, ts_types_2.isJsonMap)(
|
|
91
|
-
|
|
95
|
+
if ((0, ts_types_2.isJsonMap)(resolvedValue)) {
|
|
96
|
+
resolvedValue = this.recursiveEncrypt(resolvedValue, key);
|
|
92
97
|
}
|
|
93
98
|
else if (this.isCryptoKey(key)) {
|
|
94
|
-
|
|
99
|
+
resolvedValue = this.encrypt(resolvedValue);
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
// set(key, undefined) means unset
|
|
98
|
-
if (
|
|
103
|
+
if (resolvedValue === undefined) {
|
|
99
104
|
this.unset(key);
|
|
100
105
|
}
|
|
101
106
|
else {
|
|
102
|
-
this.contents.set(key,
|
|
107
|
+
this.contents.set(key, resolvedValue);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
/**
|
|
@@ -210,10 +215,8 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
210
215
|
* @param contents The contents.
|
|
211
216
|
*/
|
|
212
217
|
setContents(contents = {}) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
(0, ts_types_1.entriesOf)(contents).map(([key, value]) => {
|
|
218
|
+
const maybeEncryptedContents = this.hasEncryption() ? this.recursiveEncrypt(contents) : contents;
|
|
219
|
+
(0, ts_types_1.entriesOf)(maybeEncryptedContents).map(([key, value]) => {
|
|
217
220
|
this.contents.set(key, value);
|
|
218
221
|
});
|
|
219
222
|
}
|
|
@@ -341,11 +344,11 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
341
344
|
}
|
|
342
345
|
}
|
|
343
346
|
else if (this.isCryptoKey(key)) {
|
|
347
|
+
// I think this side effect is intentional
|
|
348
|
+
// eslint-disable-next-line no-param-reassign
|
|
344
349
|
data[key] = method(value);
|
|
345
350
|
}
|
|
346
351
|
}
|
|
347
352
|
}
|
|
348
353
|
exports.BaseConfigStore = BaseConfigStore;
|
|
349
|
-
// If encryptedKeys is an array of RegExps, they should not contain the /g (global) or /y (sticky) flags to avoid stateful issues.
|
|
350
|
-
BaseConfigStore.encryptedKeys = [];
|
|
351
354
|
//# sourceMappingURL=configStore.js.map
|
package/lib/config/lwwMap.js
CHANGED
|
@@ -5,12 +5,6 @@
|
|
|
5
5
|
* Licensed under the BSD 3-Clause license.
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _LWWMap_data;
|
|
14
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
9
|
exports.LWWMap = exports.stateFromContents = exports.SYMBOL_FOR_DELETED = void 0;
|
|
16
10
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
@@ -31,21 +25,21 @@ const stateFromContents = (contents, timestamp) => Object.fromEntries((0, ts_typ
|
|
|
31
25
|
);
|
|
32
26
|
exports.stateFromContents = stateFromContents;
|
|
33
27
|
class LWWMap {
|
|
28
|
+
/** map of key to LWWRegister. Used for managing conflicts */
|
|
29
|
+
#data = new Map();
|
|
34
30
|
constructor(state) {
|
|
35
|
-
/** map of key to LWWRegister. Used for managing conflicts */
|
|
36
|
-
_LWWMap_data.set(this, new Map());
|
|
37
31
|
// create a new register for each key in the initial state
|
|
38
32
|
for (const [key, register] of (0, ts_types_1.entriesOf)(state ?? {})) {
|
|
39
|
-
|
|
33
|
+
this.#data.set(key, new lwwRegister_1.LWWRegister(register));
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
get value() {
|
|
43
|
-
return Object.fromEntries(Array.from(
|
|
37
|
+
return Object.fromEntries(Array.from(this.#data.entries())
|
|
44
38
|
.filter(([, register]) => register.value !== exports.SYMBOL_FOR_DELETED)
|
|
45
39
|
.map(([key, register]) => [key, register.value]));
|
|
46
40
|
}
|
|
47
41
|
get state() {
|
|
48
|
-
return Object.fromEntries(Array.from(
|
|
42
|
+
return Object.fromEntries(Array.from(this.#data.entries()).map(([key, register]) => [key, register.state]));
|
|
49
43
|
}
|
|
50
44
|
// Merge top-level properties of the incoming state with the current state.
|
|
51
45
|
// The value with the latest timestamp wins.
|
|
@@ -53,44 +47,43 @@ class LWWMap {
|
|
|
53
47
|
// properties that are in the incoming state but not the current state might have been deleted.
|
|
54
48
|
// recursively merge each key's register with the incoming state for that key
|
|
55
49
|
for (const [key, remote] of (0, ts_types_1.entriesOf)(state)) {
|
|
56
|
-
const local =
|
|
50
|
+
const local = this.#data.get(key);
|
|
57
51
|
// if the register already exists, merge it with the incoming state
|
|
58
52
|
if (local)
|
|
59
53
|
local.merge(remote);
|
|
60
54
|
// otherwise, instantiate a new `LWWRegister` with the incoming state
|
|
61
55
|
else
|
|
62
|
-
|
|
56
|
+
this.#data.set(key, new lwwRegister_1.LWWRegister(remote));
|
|
63
57
|
}
|
|
64
58
|
return this.state;
|
|
65
59
|
}
|
|
66
60
|
set(key, value) {
|
|
67
61
|
// get the register at the given key
|
|
68
|
-
const register =
|
|
62
|
+
const register = this.#data.get(key);
|
|
69
63
|
// if the register already exists, set the value
|
|
70
64
|
if (register)
|
|
71
65
|
register.set(value);
|
|
72
66
|
// otherwise, instantiate a new `LWWRegister` with the value
|
|
73
67
|
else
|
|
74
|
-
|
|
68
|
+
this.#data.set(key, new lwwRegister_1.LWWRegister({ timestamp: (0, time_1.nowBigInt)(), value }));
|
|
75
69
|
}
|
|
76
70
|
get(key) {
|
|
77
71
|
// map loses the typing
|
|
78
|
-
const value =
|
|
72
|
+
const value = this.#data.get(key)?.value;
|
|
79
73
|
if (value === exports.SYMBOL_FOR_DELETED)
|
|
80
74
|
return undefined;
|
|
81
75
|
return value;
|
|
82
76
|
}
|
|
83
77
|
delete(key) {
|
|
84
|
-
|
|
78
|
+
this.#data.set(key, new lwwRegister_1.LWWRegister({
|
|
85
79
|
timestamp: (0, time_1.nowBigInt)(),
|
|
86
80
|
value: exports.SYMBOL_FOR_DELETED,
|
|
87
81
|
}));
|
|
88
82
|
}
|
|
89
83
|
has(key) {
|
|
90
84
|
// if a register doesn't exist or its value is null, the map doesn't contain the key
|
|
91
|
-
return
|
|
85
|
+
return this.#data.has(key) && this.#data.get(key)?.value !== exports.SYMBOL_FOR_DELETED;
|
|
92
86
|
}
|
|
93
87
|
}
|
|
94
88
|
exports.LWWMap = LWWMap;
|
|
95
|
-
_LWWMap_data = new WeakMap();
|
|
96
89
|
//# sourceMappingURL=lwwMap.js.map
|
package/lib/crypto/crypto.js
CHANGED
|
@@ -182,6 +182,9 @@ const keychainPromises = {
|
|
|
182
182
|
* Class for managing encrypting and decrypting private auth information.
|
|
183
183
|
*/
|
|
184
184
|
class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
185
|
+
key = new secureBuffer_1.SecureBuffer();
|
|
186
|
+
options;
|
|
187
|
+
noResetOnClose;
|
|
185
188
|
/**
|
|
186
189
|
* Constructor
|
|
187
190
|
* **Do not directly construct instances of this class -- use {@link Crypto.create} instead.**
|
|
@@ -191,7 +194,6 @@ class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
|
191
194
|
*/
|
|
192
195
|
constructor(options) {
|
|
193
196
|
super(options);
|
|
194
|
-
this.key = new secureBuffer_1.SecureBuffer();
|
|
195
197
|
this.options = options ?? {};
|
|
196
198
|
}
|
|
197
199
|
// @ts-expect-error only for test access
|
|
@@ -49,10 +49,9 @@ const cipherSize = 32;
|
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
51
|
class SecureBuffer {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
52
|
+
key = crypto.randomBytes(cipherSize);
|
|
53
|
+
iv = crypto.randomBytes(16);
|
|
54
|
+
secret;
|
|
56
55
|
/**
|
|
57
56
|
* Invokes a callback with a decrypted version of the buffer.
|
|
58
57
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncCreatable } from '@salesforce/kit';
|
|
2
|
-
import { OAuth2Config } from 'jsforce';
|
|
2
|
+
import { OAuth2Config } from '@jsforce/jsforce-node';
|
|
3
3
|
import { JsonMap, Nullable } from '@salesforce/ts-types';
|
|
4
4
|
import { AuthInfo } from './org/authInfo';
|
|
5
5
|
export interface DeviceCodeResponse extends JsonMap {
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.DeviceOauthService = void 0;
|
|
15
|
-
const transport_1 = __importDefault(require("jsforce/lib/transport"));
|
|
15
|
+
const transport_1 = __importDefault(require("@jsforce/jsforce-node/lib/transport"));
|
|
16
16
|
const kit_1 = require("@salesforce/kit");
|
|
17
17
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
18
18
|
const form_data_1 = __importDefault(require("form-data"));
|
|
@@ -59,9 +59,15 @@ async function makeRequest(options) {
|
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
class DeviceOauthService extends kit_1.AsyncCreatable {
|
|
62
|
+
static RESPONSE_TYPE = 'device_code';
|
|
63
|
+
static GRANT_TYPE = 'device';
|
|
64
|
+
static SCOPE = 'refresh_token web api';
|
|
65
|
+
static POLLING_COUNT_MAX = 100;
|
|
66
|
+
logger;
|
|
67
|
+
options;
|
|
68
|
+
pollingCount = 0;
|
|
62
69
|
constructor(options) {
|
|
63
70
|
super(options);
|
|
64
|
-
this.pollingCount = 0;
|
|
65
71
|
this.options = options;
|
|
66
72
|
if (!this.options.clientId)
|
|
67
73
|
this.options.clientId = authInfo_1.DEFAULT_CONNECTED_APP_INFO.clientId;
|
|
@@ -192,8 +198,4 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
|
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
exports.DeviceOauthService = DeviceOauthService;
|
|
195
|
-
DeviceOauthService.RESPONSE_TYPE = 'device_code';
|
|
196
|
-
DeviceOauthService.GRANT_TYPE = 'device';
|
|
197
|
-
DeviceOauthService.SCOPE = 'refresh_token web api';
|
|
198
|
-
DeviceOauthService.POLLING_COUNT_MAX = 100;
|
|
199
201
|
//# sourceMappingURL=deviceOauthService.js.map
|
package/lib/global.js
CHANGED
|
@@ -52,6 +52,24 @@ var Mode;
|
|
|
52
52
|
* Global constants, methods, and configuration.
|
|
53
53
|
*/
|
|
54
54
|
class Global {
|
|
55
|
+
/**
|
|
56
|
+
* Enable interoperability between `.sfdx` and `.sf`.
|
|
57
|
+
*
|
|
58
|
+
* When @salesforce/core@v2 is deprecated and no longer used, this can be removed.
|
|
59
|
+
*/
|
|
60
|
+
static SFDX_INTEROPERABILITY = kit_1.env.getBoolean('SF_SFDX_INTEROPERABILITY', true);
|
|
61
|
+
/**
|
|
62
|
+
* The global folder in which sfdx state is stored.
|
|
63
|
+
*/
|
|
64
|
+
static SFDX_STATE_FOLDER = '.sfdx';
|
|
65
|
+
/**
|
|
66
|
+
* The global folder in which sf state is stored.
|
|
67
|
+
*/
|
|
68
|
+
static SF_STATE_FOLDER = '.sf';
|
|
69
|
+
/**
|
|
70
|
+
* The preferred global folder in which state is stored.
|
|
71
|
+
*/
|
|
72
|
+
static STATE_FOLDER = Global.SFDX_STATE_FOLDER;
|
|
55
73
|
/**
|
|
56
74
|
* The full system path to the global sfdx state folder.
|
|
57
75
|
*
|
|
@@ -94,37 +112,19 @@ class Global {
|
|
|
94
112
|
* @param dirPath The directory path to be created within {@link Global.SFDX_DIR}.
|
|
95
113
|
*/
|
|
96
114
|
static async createDir(dirPath) {
|
|
97
|
-
|
|
115
|
+
const resolvedPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
|
|
98
116
|
try {
|
|
99
117
|
if (process.platform === 'win32') {
|
|
100
|
-
await fs.promises.mkdir(
|
|
118
|
+
await fs.promises.mkdir(resolvedPath, { recursive: true });
|
|
101
119
|
}
|
|
102
120
|
else {
|
|
103
|
-
await fs.promises.mkdir(
|
|
121
|
+
await fs.promises.mkdir(resolvedPath, { recursive: true, mode: 0o700 });
|
|
104
122
|
}
|
|
105
123
|
}
|
|
106
124
|
catch (error) {
|
|
107
|
-
throw new sfError_1.SfError(`Failed to create directory or set permissions for: ${
|
|
125
|
+
throw new sfError_1.SfError(`Failed to create directory or set permissions for: ${resolvedPath}`);
|
|
108
126
|
}
|
|
109
127
|
}
|
|
110
128
|
}
|
|
111
129
|
exports.Global = Global;
|
|
112
|
-
/**
|
|
113
|
-
* Enable interoperability between `.sfdx` and `.sf`.
|
|
114
|
-
*
|
|
115
|
-
* When @salesforce/core@v2 is deprecated and no longer used, this can be removed.
|
|
116
|
-
*/
|
|
117
|
-
Global.SFDX_INTEROPERABILITY = kit_1.env.getBoolean('SF_SFDX_INTEROPERABILITY', true);
|
|
118
|
-
/**
|
|
119
|
-
* The global folder in which sfdx state is stored.
|
|
120
|
-
*/
|
|
121
|
-
Global.SFDX_STATE_FOLDER = '.sfdx';
|
|
122
|
-
/**
|
|
123
|
-
* The global folder in which sf state is stored.
|
|
124
|
-
*/
|
|
125
|
-
Global.SF_STATE_FOLDER = '.sf';
|
|
126
|
-
/**
|
|
127
|
-
* The preferred global folder in which state is stored.
|
|
128
|
-
*/
|
|
129
|
-
Global.STATE_FOLDER = Global.SFDX_STATE_FOLDER;
|
|
130
130
|
//# sourceMappingURL=global.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { OAuth2Config } from 'jsforce';
|
|
1
|
+
export { OAuth2Config } from '@jsforce/jsforce-node';
|
|
2
2
|
export { ConfigFile } from './config/configFile';
|
|
3
3
|
export { TTLConfig } from './config/ttlConfig';
|
|
4
4
|
export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -58,6 +58,11 @@ const logger_1 = require("./logger/logger");
|
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
60
|
class Lifecycle {
|
|
61
|
+
listeners;
|
|
62
|
+
uniqueListeners;
|
|
63
|
+
static telemetryEventName = 'telemetry';
|
|
64
|
+
static warningEventName = 'warning';
|
|
65
|
+
logger;
|
|
61
66
|
constructor(listeners = {}, uniqueListeners = new Map()) {
|
|
62
67
|
this.listeners = listeners;
|
|
63
68
|
this.uniqueListeners = uniqueListeners;
|
|
@@ -227,6 +232,4 @@ class Lifecycle {
|
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
234
|
exports.Lifecycle = Lifecycle;
|
|
230
|
-
Lifecycle.telemetryEventName = 'telemetry';
|
|
231
|
-
Lifecycle.warningEventName = 'warning';
|
|
232
235
|
//# sourceMappingURL=lifecycleEvents.js.map
|
package/lib/logger/logger.js
CHANGED
|
@@ -85,6 +85,26 @@ var LoggerLevel;
|
|
|
85
85
|
* **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_log_messages.htm
|
|
86
86
|
*/
|
|
87
87
|
class Logger {
|
|
88
|
+
/**
|
|
89
|
+
* The name of the root sfdx `Logger`.
|
|
90
|
+
*/
|
|
91
|
+
static ROOT_NAME = 'sf';
|
|
92
|
+
/**
|
|
93
|
+
* The default `LoggerLevel` when constructing new `Logger` instances.
|
|
94
|
+
*/
|
|
95
|
+
static DEFAULT_LEVEL = LoggerLevel.WARN;
|
|
96
|
+
/**
|
|
97
|
+
* A list of all lower case `LoggerLevel` names.
|
|
98
|
+
*
|
|
99
|
+
* **See** {@link LoggerLevel}
|
|
100
|
+
*/
|
|
101
|
+
static LEVEL_NAMES = Object.values(LoggerLevel)
|
|
102
|
+
.filter(ts_types_1.isString)
|
|
103
|
+
.map((v) => v.toLowerCase());
|
|
104
|
+
// The sfdx root logger singleton
|
|
105
|
+
static rootLogger;
|
|
106
|
+
pinoLogger;
|
|
107
|
+
memoryLogger;
|
|
88
108
|
/**
|
|
89
109
|
* Constructs a new `Logger`.
|
|
90
110
|
*
|
|
@@ -194,11 +214,11 @@ class Logger {
|
|
|
194
214
|
* @see {@Link LoggerLevel}
|
|
195
215
|
*/
|
|
196
216
|
static getLevelByName(levelName) {
|
|
197
|
-
|
|
198
|
-
if (!(0, ts_types_1.isKeyOf)(LoggerLevel,
|
|
199
|
-
throw new sfError_1.SfError(`Invalid log level "${
|
|
217
|
+
const upperLevel = levelName.toUpperCase();
|
|
218
|
+
if (!(0, ts_types_1.isKeyOf)(LoggerLevel, upperLevel)) {
|
|
219
|
+
throw new sfError_1.SfError(`Invalid log level "${upperLevel}".`, 'UnrecognizedLoggerLevelNameError');
|
|
200
220
|
}
|
|
201
|
-
return LoggerLevel[
|
|
221
|
+
return LoggerLevel[upperLevel];
|
|
202
222
|
}
|
|
203
223
|
/** get the bare (pino) logger instead of using the class hierarchy */
|
|
204
224
|
static getRawRootLogger() {
|
|
@@ -242,11 +262,8 @@ class Logger {
|
|
|
242
262
|
* ```
|
|
243
263
|
*/
|
|
244
264
|
setLevel(level) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
level = logLevelFromEnvVar ? Logger.getLevelByName(logLevelFromEnvVar) : Logger.DEFAULT_LEVEL;
|
|
248
|
-
}
|
|
249
|
-
this.pinoLogger.level = this.pinoLogger.levels.labels[level] ?? this.pinoLogger.levels.labels[Logger.DEFAULT_LEVEL];
|
|
265
|
+
this.pinoLogger.level =
|
|
266
|
+
this.pinoLogger.levels.labels[level ?? getDefaultLevel()] ?? this.pinoLogger.levels.labels[Logger.DEFAULT_LEVEL];
|
|
250
267
|
return this;
|
|
251
268
|
}
|
|
252
269
|
/**
|
|
@@ -272,10 +289,7 @@ class Logger {
|
|
|
272
289
|
*/
|
|
273
290
|
readLogContentsAsText() {
|
|
274
291
|
if (this.memoryLogger) {
|
|
275
|
-
return this.memoryLogger
|
|
276
|
-
accum += JSON.stringify(line) + os.EOL;
|
|
277
|
-
return accum;
|
|
278
|
-
}, '');
|
|
292
|
+
return this.memoryLogger?.loggedData.map((line) => JSON.stringify(line)).join(os.EOL);
|
|
279
293
|
}
|
|
280
294
|
else {
|
|
281
295
|
this.pinoLogger.warn('readLogContentsAsText is not supported for file streams, only used when useMemoryLogging is true');
|
|
@@ -374,22 +388,6 @@ class Logger {
|
|
|
374
388
|
}
|
|
375
389
|
}
|
|
376
390
|
exports.Logger = Logger;
|
|
377
|
-
/**
|
|
378
|
-
* The name of the root sfdx `Logger`.
|
|
379
|
-
*/
|
|
380
|
-
Logger.ROOT_NAME = 'sf';
|
|
381
|
-
/**
|
|
382
|
-
* The default `LoggerLevel` when constructing new `Logger` instances.
|
|
383
|
-
*/
|
|
384
|
-
Logger.DEFAULT_LEVEL = LoggerLevel.WARN;
|
|
385
|
-
/**
|
|
386
|
-
* A list of all lower case `LoggerLevel` names.
|
|
387
|
-
*
|
|
388
|
-
* **See** {@link LoggerLevel}
|
|
389
|
-
*/
|
|
390
|
-
Logger.LEVEL_NAMES = Object.values(LoggerLevel)
|
|
391
|
-
.filter(ts_types_1.isString)
|
|
392
|
-
.map((v) => v.toLowerCase());
|
|
393
391
|
/** return various streams that the logger could send data to, depending on the options and env */
|
|
394
392
|
const getWriteStream = (level = 'warn') => {
|
|
395
393
|
// used when debug mode, writes to stdout (colorized)
|
|
@@ -441,4 +439,8 @@ const levelFromOption = (value) => {
|
|
|
441
439
|
const numberToLevel = (level) => pino_1.pino.levels.labels[level] ??
|
|
442
440
|
Object.entries(pino_1.pino.levels.labels).find(([value]) => Number(value) > level)?.[1] ??
|
|
443
441
|
'warn';
|
|
442
|
+
const getDefaultLevel = () => {
|
|
443
|
+
const logLevelFromEnvVar = new kit_1.Env().getString('SF_LOG_LEVEL');
|
|
444
|
+
return logLevelFromEnvVar ? Logger.getLevelByName(logLevelFromEnvVar) : Logger.DEFAULT_LEVEL;
|
|
445
|
+
};
|
|
444
446
|
//# sourceMappingURL=logger.js.map
|
|
@@ -14,9 +14,9 @@ const filters_1 = require("./filters");
|
|
|
14
14
|
* Used by test setup to keep UT from writing to disk.
|
|
15
15
|
*/
|
|
16
16
|
class MemoryLogger extends node_stream_1.Writable {
|
|
17
|
+
loggedData = [];
|
|
17
18
|
constructor() {
|
|
18
19
|
super({ objectMode: true });
|
|
19
|
-
this.loggedData = [];
|
|
20
20
|
}
|
|
21
21
|
_write(chunk, encoding, callback) {
|
|
22
22
|
const filteredChunk = (0, unwrapArray_1.unwrapArray)((0, filters_1.filterSecrets)([chunk]));
|