@salesforce/core 2.35.2 → 2.36.1
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 +23 -0
- package/lib/logger.d.ts +11 -0
- package/lib/logger.js +19 -8
- package/lib/org.js +26 -28
- package/lib/util/sfdcUrl.d.ts +1 -1
- package/lib/util/sfdcUrl.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.36.1](https://github.com/forcedotcom/sfdx-core/compare/v2.36.0...v2.36.1) (2022-04-14)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- sandbox cname recognition ([#555](https://github.com/forcedotcom/sfdx-core/issues/555)) ([105bc9a](https://github.com/forcedotcom/sfdx-core/commit/105bc9a043b3c984846e060e5176b290fe49b5bc))
|
|
10
|
+
|
|
11
|
+
## [2.36.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.3...v2.36.0) (2022-03-23)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- rotating log file ([d185e00](https://github.com/forcedotcom/sfdx-core/commit/d185e00aa66fc558f3c0d710cb2fafa0655a9fbc))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- bump jsforce types ([ddacb98](https://github.com/forcedotcom/sfdx-core/commit/ddacb987068d00aec2147130f3464232a6bdccdf))
|
|
20
|
+
- check env before resetting ([abf6ea1](https://github.com/forcedotcom/sfdx-core/commit/abf6ea1bd721f773c09f346ff9ae8d01a915e5cd))
|
|
21
|
+
|
|
22
|
+
### [2.35.3](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v2.35.3) (2022-02-23)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- always try to clean up aliases and configs ([cd0adc4](https://github.com/forcedotcom/sfdx-core/commit/cd0adc456978f27fc2d44cbcb61632925edcccd9))
|
|
27
|
+
|
|
5
28
|
### [2.35.2](https://github.com/forcedotcom/sfdx-core/compare/v2.35.1...v2.35.2) (2022-02-16)
|
|
6
29
|
|
|
7
30
|
### Bug Fixes
|
package/lib/logger.d.ts
CHANGED
|
@@ -163,6 +163,17 @@ export declare class Logger {
|
|
|
163
163
|
static readonly LEVEL_NAMES: string[];
|
|
164
164
|
private static readonly lifecycle;
|
|
165
165
|
private static rootLogger?;
|
|
166
|
+
/**
|
|
167
|
+
* The default rotation period for logs. Example '1d' will rotate logs daily (at midnight).
|
|
168
|
+
* See 'period' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
|
|
169
|
+
*/
|
|
170
|
+
readonly logRotationPeriod: string;
|
|
171
|
+
/**
|
|
172
|
+
* The number of backup rotated log files to keep.
|
|
173
|
+
* Example: '3' will have the base sfdx.log file, and the past 3 (period) log files.
|
|
174
|
+
* See 'count' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
|
|
175
|
+
*/
|
|
176
|
+
readonly logRotationCount: number;
|
|
166
177
|
/**
|
|
167
178
|
* Whether debug is enabled for this Logger.
|
|
168
179
|
*/
|
package/lib/logger.js
CHANGED
|
@@ -72,6 +72,17 @@ class Logger {
|
|
|
72
72
|
* `Logger`.
|
|
73
73
|
*/
|
|
74
74
|
constructor(optionsOrName) {
|
|
75
|
+
/**
|
|
76
|
+
* The default rotation period for logs. Example '1d' will rotate logs daily (at midnight).
|
|
77
|
+
* See 'period' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
|
|
78
|
+
*/
|
|
79
|
+
this.logRotationPeriod = new kit_1.Env().getString('SFDX_LOG_ROTATION_PERIOD') || '1d';
|
|
80
|
+
/**
|
|
81
|
+
* The number of backup rotated log files to keep.
|
|
82
|
+
* Example: '3' will have the base sfdx.log file, and the past 3 (period) log files.
|
|
83
|
+
* See 'count' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
|
|
84
|
+
*/
|
|
85
|
+
this.logRotationCount = new kit_1.Env().getNumber('SFDX_LOG_ROTATION_COUNT') || 2;
|
|
75
86
|
/**
|
|
76
87
|
* Whether debug is enabled for this Logger.
|
|
77
88
|
*/
|
|
@@ -250,12 +261,12 @@ class Logger {
|
|
|
250
261
|
if (!this.bunyan.streams.find(
|
|
251
262
|
// No bunyan typings
|
|
252
263
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
-
(stream) => stream.type === 'file' && stream.path === logFile)) {
|
|
254
|
-
// TODO: rotating-file
|
|
255
|
-
// https://github.com/trentm/node-bunyan#stream-type-rotating-file
|
|
264
|
+
(stream) => stream.type === 'rotating-file' && stream.path === logFile)) {
|
|
256
265
|
this.addStream({
|
|
257
|
-
type: 'file',
|
|
266
|
+
type: 'rotating-file',
|
|
258
267
|
path: logFile,
|
|
268
|
+
period: this.logRotationPeriod,
|
|
269
|
+
count: this.logRotationCount,
|
|
259
270
|
level: this.bunyan.level(),
|
|
260
271
|
});
|
|
261
272
|
}
|
|
@@ -290,12 +301,12 @@ class Logger {
|
|
|
290
301
|
if (!this.bunyan.streams.find(
|
|
291
302
|
// No bunyan typings
|
|
292
303
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
293
|
-
(stream) => stream.type === 'file' && stream.path === logFile)) {
|
|
294
|
-
// TODO: rotating-file
|
|
295
|
-
// https://github.com/trentm/node-bunyan#stream-type-rotating-file
|
|
304
|
+
(stream) => stream.type === 'rotating-file' && stream.path === logFile)) {
|
|
296
305
|
this.addStream({
|
|
297
|
-
type: 'file',
|
|
306
|
+
type: 'rotating-file',
|
|
298
307
|
path: logFile,
|
|
308
|
+
period: this.logRotationPeriod,
|
|
309
|
+
count: this.logRotationCount,
|
|
299
310
|
level: this.bunyan.level(),
|
|
300
311
|
});
|
|
301
312
|
}
|
package/lib/org.js
CHANGED
|
@@ -644,35 +644,33 @@ class Org extends kit_1.AsyncCreatable {
|
|
|
644
644
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
645
645
|
async removeUsers(throwWhenRemoveFails) {
|
|
646
646
|
this.logger.debug(`Removing users associate with org: ${this.getOrgId()}`);
|
|
647
|
-
const config = await
|
|
647
|
+
const [config, authInfos, aliases] = await Promise.all([
|
|
648
|
+
this.retrieveOrgUsersConfig(),
|
|
649
|
+
this.readUserAuthFiles(),
|
|
650
|
+
aliases_1.Aliases.create(aliases_1.Aliases.getDefaultOptions()),
|
|
651
|
+
]);
|
|
648
652
|
this.logger.debug(`using path for org users: ${config.getPath()}`);
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
await config_1.Config.update(configInfo.isGlobal(), orgType, undefined);
|
|
671
|
-
}
|
|
672
|
-
await orgForUser.removeAuth();
|
|
673
|
-
}
|
|
674
|
-
await aliases.write();
|
|
675
|
-
}
|
|
653
|
+
this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
|
|
654
|
+
await Promise.all(authInfos
|
|
655
|
+
.map((auth) => auth.getFields().username)
|
|
656
|
+
.map(async (username) => {
|
|
657
|
+
const aliasKeys = (username && aliases.getKeysByValue(username)) || [];
|
|
658
|
+
aliases.unsetAll(aliasKeys);
|
|
659
|
+
const orgForUser = username === this.getUsername()
|
|
660
|
+
? this
|
|
661
|
+
: await Org.create({
|
|
662
|
+
connection: await connection_1.Connection.create({ authInfo: await authInfo_1.AuthInfo.create({ username }) }),
|
|
663
|
+
});
|
|
664
|
+
const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
|
|
665
|
+
const configInfo = orgForUser.configAggregator.getInfo(orgType);
|
|
666
|
+
const needsConfigUpdate = (configInfo.isGlobal() || configInfo.isLocal()) &&
|
|
667
|
+
(configInfo.value === username || aliasKeys.includes(configInfo.value));
|
|
668
|
+
return [
|
|
669
|
+
orgForUser.removeAuth(),
|
|
670
|
+
needsConfigUpdate ? config_1.Config.update(configInfo.isGlobal(), orgType, undefined) : undefined,
|
|
671
|
+
].filter(Boolean);
|
|
672
|
+
}));
|
|
673
|
+
await aliases.write();
|
|
676
674
|
}
|
|
677
675
|
/**
|
|
678
676
|
* Remove an associate sandbox config.
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare class SfdcUrl extends URL {
|
|
|
62
62
|
isSandboxUrl(createdOrgInstance?: string): boolean;
|
|
63
63
|
/**
|
|
64
64
|
* Tests whether this url is a sandbox url
|
|
65
|
-
* otherwise
|
|
65
|
+
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
66
66
|
*
|
|
67
67
|
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
68
68
|
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -156,13 +156,15 @@ class SfdcUrl extends url_1.URL {
|
|
|
156
156
|
this.origin.endsWith('sandbox.my.salesforce.mil') ||
|
|
157
157
|
/sandbox\.my\.salesforce\.com/gi.test(this.origin) || // enhanced domains >= 230
|
|
158
158
|
/(cs[0-9]+(\.my|)\.salesforce\.com)/gi.test(this.origin) || // my domains on CS instance OR CS instance without my domain
|
|
159
|
+
/(cs[0-9]+\.force\.com)/gi.test(this.origin) || // sandboxes have cnames like cs123.force.com
|
|
160
|
+
/(\w+--\w+\.my\.salesforce\.com)/gi.test(this.origin) || // sandboxes myDomain like foo--bar.my.salesforce.com
|
|
159
161
|
/([a-z]{3}[0-9]+s\.sfdc-.+\.salesforce\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.salesforce.com
|
|
160
162
|
/([a-z]{3}[0-9]+s\.sfdc-.+\.force\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.force.com
|
|
161
163
|
this.hostname === 'test.salesforce.com');
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
164
166
|
* Tests whether this url is a sandbox url
|
|
165
|
-
* otherwise
|
|
167
|
+
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
166
168
|
*
|
|
167
169
|
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
168
170
|
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.1",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@salesforce/schemas": "^1.0.1",
|
|
40
40
|
"@salesforce/ts-types": "^1.5.20",
|
|
41
41
|
"@types/graceful-fs": "^4.1.5",
|
|
42
|
-
"@types/jsforce": "^1.9.
|
|
42
|
+
"@types/jsforce": "^1.9.41",
|
|
43
43
|
"@types/mkdirp": "^1.0.1",
|
|
44
44
|
"archiver": "^5.3.0",
|
|
45
45
|
"debug": "^3.1.0",
|