@salesforce/core 2.28.4 → 2.29.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/CHANGELOG.md +48 -60
- package/lib/authInfo.d.ts +1 -6
- package/lib/authInfo.js +1 -0
- package/lib/connection.js +2 -1
- package/lib/lifecycleEvents.d.ts +38 -1
- package/lib/lifecycleEvents.js +73 -2
- package/lib/logger.js +1 -0
- package/lib/sfdxError.d.ts +1 -1
- package/lib/sfdxError.js +1 -0
- package/lib/testSetup.js +1 -1
- package/lib/util/sfdcUrl.js +2 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,202 +2,190 @@
|
|
|
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
|
-
|
|
5
|
+
## [2.29.0](https://github.com/forcedotcom/sfdx-core/compare/v2.28.4...v2.29.0) (2021-11-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* cleans up old listeners from upgraded instance ([e3f2d69](https://github.com/forcedotcom/sfdx-core/commit/e3f2d69ccd5c096d37addb1b982e19354175f11a))
|
|
11
|
+
* use warnings instead of process in sfdx-core ([c1f7e98](https://github.com/forcedotcom/sfdx-core/commit/c1f7e98f6b19d57da1a2ee0cdf58e449079f0ee7))
|
|
12
|
+
* warning and telemetry events ([80a8039](https://github.com/forcedotcom/sfdx-core/commit/80a8039e2f686d973ddbc24c9a2980fb93928d13))
|
|
13
|
+
* warning and telemetry events ([a04b293](https://github.com/forcedotcom/sfdx-core/commit/a04b29355c8ca6c7e37e071ccc159aff5e5e9ca0))
|
|
6
14
|
|
|
7
15
|
|
|
8
16
|
### Bug Fixes
|
|
9
17
|
|
|
10
|
-
*
|
|
18
|
+
* transfer listeners when upgrading the global instance to newer version ([0a40831](https://github.com/forcedotcom/sfdx-core/commit/0a408317c132548771ced0fe196178d2e9c76232))
|
|
11
19
|
|
|
12
|
-
### [2.28.
|
|
20
|
+
### [2.28.4](https://github.com/forcedotcom/sfdx-core/compare/v2.28.3...v2.28.4) (2021-11-10)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
13
23
|
|
|
24
|
+
- bump jsforce types and run unit tests on Windows ([#485](https://github.com/forcedotcom/sfdx-core/issues/485)) ([3952c8f](https://github.com/forcedotcom/sfdx-core/commit/3952c8fe248531a0597477ed12240f611048caba))
|
|
25
|
+
|
|
26
|
+
### [2.28.3](https://github.com/forcedotcom/sfdx-core/compare/v2.28.2...v2.28.3) (2021-11-08)
|
|
14
27
|
|
|
15
28
|
### Bug Fixes
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
- fix unit test ([d903c04](https://github.com/forcedotcom/sfdx-core/commit/d903c04e5f3e4f01fccb3f00b91560c443013ddf))
|
|
31
|
+
- force new release ([124bb74](https://github.com/forcedotcom/sfdx-core/commit/124bb744c5ecc28cb8babf285c6d8c3032eb7ef6))
|
|
32
|
+
- improve error message when providing an invalid username ([2ab4bbd](https://github.com/forcedotcom/sfdx-core/commit/2ab4bbdefd962283d88ccb735de88c88fe189d39))
|
|
20
33
|
|
|
21
34
|
### [2.28.2](https://github.com/forcedotcom/sfdx-core/compare/v2.28.1...v2.28.2) (2021-10-13)
|
|
22
35
|
|
|
23
|
-
|
|
24
36
|
### Bug Fixes
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
- support for .mil sandboxes ([9ef35c7](https://github.com/forcedotcom/sfdx-core/commit/9ef35c7b1ef0fe974c3bd3b89b862a436e00f7d9))
|
|
27
39
|
|
|
28
40
|
### [2.28.1](https://github.com/forcedotcom/sfdx-core/compare/v2.28.0...v2.28.1) (2021-10-06)
|
|
29
41
|
|
|
30
|
-
|
|
31
42
|
### Bug Fixes
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
- crmforce.mil ([e263d5d](https://github.com/forcedotcom/sfdx-core/commit/e263d5d74be9c0651e5c2676d6eec1c31fca05e4))
|
|
34
45
|
|
|
35
46
|
## [2.28.0](https://github.com/forcedotcom/sfdx-core/compare/v2.27.2...v2.28.0) (2021-09-16)
|
|
36
47
|
|
|
37
|
-
|
|
38
48
|
### Features
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
- add custom templates config ([3cf8a8c](https://github.com/forcedotcom/sfdx-core/commit/3cf8a8cee1e7196efced989dcca9b545e1283386))
|
|
51
|
+
- add validator for custom templates config ([dd2bcfe](https://github.com/forcedotcom/sfdx-core/commit/dd2bcfe8e7fee5c5c1c6321189ec04288103d5b6))
|
|
52
|
+
- update config name ([72e84bf](https://github.com/forcedotcom/sfdx-core/commit/72e84bfacef48a1c2d00a61ebbae3f632601abbd))
|
|
43
53
|
|
|
44
54
|
### [2.27.2](https://github.com/forcedotcom/sfdx-core/compare/v2.27.1...v2.27.2) (2021-08-05)
|
|
45
55
|
|
|
46
|
-
|
|
47
56
|
### Bug Fixes
|
|
48
57
|
|
|
49
|
-
|
|
58
|
+
- improve error handling while removing config props ([eecf7b0](https://github.com/forcedotcom/sfdx-core/commit/eecf7b0d0cf14e1371dc4c5ef03a413f864b0a8b))
|
|
50
59
|
|
|
51
60
|
### [2.27.1](https://github.com/forcedotcom/sfdx-core/compare/v2.27.0...v2.27.1) (2021-08-05)
|
|
52
61
|
|
|
53
|
-
|
|
54
62
|
### Bug Fixes
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
- dont fail when trying to unset sf config keys ([#456](https://github.com/forcedotcom/sfdx-core/issues/456)) ([8aff9fd](https://github.com/forcedotcom/sfdx-core/commit/8aff9fd4bdb73ec20e58f5a16a8192a8eecba912))
|
|
57
65
|
|
|
58
66
|
## [2.27.0](https://github.com/forcedotcom/sfdx-core/compare/v2.26.1...v2.27.0) (2021-07-29)
|
|
59
67
|
|
|
60
|
-
|
|
61
68
|
### Features
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
- Core URL class SfdcUrl ([#420](https://github.com/forcedotcom/sfdx-core/issues/420)) ([66881ea](https://github.com/forcedotcom/sfdx-core/commit/66881eae2f30215c862ea398bfc1630d9a5898fe))
|
|
64
71
|
|
|
65
72
|
### [2.26.1](https://github.com/forcedotcom/sfdx-core/compare/v2.26.0...v2.26.1) (2021-07-19)
|
|
66
73
|
|
|
67
|
-
|
|
68
74
|
### Bug Fixes
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
- force:org:open force:org:open --urlonly display bug ([#439](https://github.com/forcedotcom/sfdx-core/issues/439)) ([2ea0e74](https://github.com/forcedotcom/sfdx-core/commit/2ea0e74b8bf1bff6de8af70372025cac10fc8c18))
|
|
71
77
|
|
|
72
78
|
## [2.26.0](https://github.com/forcedotcom/sfdx-core/compare/v2.25.1...v2.26.0) (2021-07-13)
|
|
73
79
|
|
|
74
|
-
|
|
75
80
|
### Features
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
- update generate password functionality ([#432](https://github.com/forcedotcom/sfdx-core/issues/432)) ([ed65e83](https://github.com/forcedotcom/sfdx-core/commit/ed65e83da3afe0d101743ee89cc7b2a7a38d5254))
|
|
78
83
|
|
|
79
84
|
### [2.25.1](https://github.com/forcedotcom/sfdx-core/compare/v3.1.1-3.2...v2.25.1) (2021-06-30)
|
|
80
85
|
|
|
81
|
-
|
|
82
86
|
### Bug Fixes
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
- set retries to INFINITELY for polling client ([31539b4](https://github.com/forcedotcom/sfdx-core/commit/31539b4f0edd0cc1c049f70331ed5e40b8af55ea))
|
|
85
89
|
|
|
86
90
|
## [2.25.0](https://github.com/forcedotcom/sfdx-core/compare/v2.24.2...v2.25.0) (2021-06-30)
|
|
87
91
|
|
|
88
|
-
|
|
89
92
|
### Features
|
|
90
93
|
|
|
91
|
-
|
|
94
|
+
- @W-9517449@ Allow signupTargetLoginUrl to be overridden via env var ([#429](https://github.com/forcedotcom/sfdx-core/issues/429)) ([e2b8b36](https://github.com/forcedotcom/sfdx-core/commit/e2b8b36b2836b5277c83ffe22922978dc32e7b11)), closes [#427](https://github.com/forcedotcom/sfdx-core/issues/427)
|
|
92
95
|
|
|
93
96
|
### [2.24.2](https://github.com/forcedotcom/sfdx-core/compare/v3.1.1-3.1...v2.24.2) (2021-06-23)
|
|
94
97
|
|
|
95
|
-
|
|
96
98
|
### Bug Fixes
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
- puts some types back in dependencies ([94bea31](https://github.com/forcedotcom/sfdx-core/commit/94bea31037a41d4377faecb22bce8a2d12e95f4f))
|
|
99
101
|
|
|
100
102
|
### [2.24.1](https://github.com/forcedotcom/sfdx-core/compare/v2.24.0...v2.24.1) (2021-06-23)
|
|
101
103
|
|
|
102
|
-
|
|
103
104
|
### Bug Fixes
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
- rewrite polling client ([8d363d1](https://github.com/forcedotcom/sfdx-core/commit/8d363d13616f5efa944d4bb717a010add3c996b5))
|
|
106
107
|
|
|
107
108
|
## [2.24.0](https://github.com/forcedotcom/sfdx-core/compare/v2.23.5...v2.24.0) (2021-06-08)
|
|
108
109
|
|
|
109
|
-
|
|
110
110
|
### Features
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
- exported function checkLightningDomain() ([#415](https://github.com/forcedotcom/sfdx-core/issues/415)) ([8e75231](https://github.com/forcedotcom/sfdx-core/commit/8e752313abf4a383a6ef18250ffac78b398987dd))
|
|
113
113
|
|
|
114
114
|
### [2.23.5](https://github.com/forcedotcom/sfdx-core/compare/v3.1.1-3.0...v2.23.5) (2021-06-07)
|
|
115
115
|
|
|
116
|
-
|
|
117
116
|
### Bug Fixes
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
- w-9299422 (login url from config) and fs-parallelization ([043bb17](https://github.com/forcedotcom/sfdx-core/commit/043bb179dbf64f9c4522a4c0f0720ae09794227c))
|
|
120
119
|
|
|
121
120
|
### [2.23.4](https://github.com/forcedotcom/sfdx-core/compare/v2.23.3...v2.23.4) (2021-06-03)
|
|
122
121
|
|
|
123
|
-
|
|
124
122
|
### Bug Fixes
|
|
125
123
|
|
|
126
|
-
|
|
124
|
+
- works with TS4+ and jsforce types ([#413](https://github.com/forcedotcom/sfdx-core/issues/413)) ([b77cdad](https://github.com/forcedotcom/sfdx-core/commit/b77cdad56b114290b8e5fd23d968e23e7d4eedf4))
|
|
127
125
|
|
|
128
126
|
### [2.23.3](https://github.com/forcedotcom/sfdx-core/compare/v2.23.2...v2.23.3) (2021-06-03)
|
|
129
127
|
|
|
130
128
|
### [2.23.2](https://github.com/forcedotcom/sfdx-core/compare/v2.23.1...v2.23.2) (2021-06-02)
|
|
131
129
|
|
|
132
|
-
|
|
133
130
|
### Bug Fixes
|
|
134
131
|
|
|
135
|
-
|
|
132
|
+
- authinfo returning only lowercase usernames. ([#411](https://github.com/forcedotcom/sfdx-core/issues/411)) ([243668e](https://github.com/forcedotcom/sfdx-core/commit/243668e61cd8418b6acb2f0d4806da50ccf37b29)), closes [#405](https://github.com/forcedotcom/sfdx-core/issues/405)
|
|
136
133
|
|
|
137
134
|
### [2.23.1](https://github.com/forcedotcom/sfdx-core/compare/v2.23.0...v2.23.1) (2021-05-27)
|
|
138
135
|
|
|
139
136
|
## [2.23.0](https://github.com/forcedotcom/sfdx-core/compare/v2.22.0...v2.23.0) (2021-05-26)
|
|
140
137
|
|
|
141
|
-
|
|
142
138
|
### Features
|
|
143
139
|
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
- export getJwtAudienceUrl ([e7d26d2](https://github.com/forcedotcom/sfdx-core/commit/e7d26d20106d6abb6b424936bdf26c0a9f8cd175))
|
|
146
141
|
|
|
147
142
|
### Bug Fixes
|
|
148
143
|
|
|
149
|
-
|
|
144
|
+
- export library method ([d0016f9](https://github.com/forcedotcom/sfdx-core/commit/d0016f96da1246535049884c1043399239a33c00))
|
|
150
145
|
|
|
151
146
|
## [2.22.0](https://github.com/forcedotcom/sfdx-core/compare/v2.21.0...v2.22.0) (2021-05-24)
|
|
152
147
|
|
|
153
|
-
|
|
154
148
|
### Features
|
|
155
149
|
|
|
156
|
-
|
|
150
|
+
- export getJwtAudienceUrl ([#407](https://github.com/forcedotcom/sfdx-core/issues/407)) ([585bb07](https://github.com/forcedotcom/sfdx-core/commit/585bb073434d73473a855ee52b7ddc6f0228aae1))
|
|
157
151
|
|
|
158
152
|
## [2.21.0](https://github.com/forcedotcom/sfdx-core/compare/v2.20.11...v2.21.0) (2021-05-24)
|
|
159
153
|
|
|
160
|
-
|
|
161
154
|
### Features
|
|
162
155
|
|
|
163
|
-
|
|
156
|
+
- modify authInfo to return username for access token auth ([160b7d2](https://github.com/forcedotcom/sfdx-core/commit/160b7d20e32b80d7a54c8cf679154fcbaa9e8cda))
|
|
164
157
|
|
|
165
158
|
### [2.20.11](https://github.com/forcedotcom/sfdx-core/compare/v3.1.0-3.0...v2.20.11) (2021-05-12)
|
|
166
159
|
|
|
167
|
-
|
|
168
160
|
### Bug Fixes
|
|
169
161
|
|
|
170
|
-
|
|
162
|
+
- force release ([f0b837a](https://github.com/forcedotcom/sfdx-core/commit/f0b837ab7b4d0361c2fa3ba15fe56cd2f7cc1fd0))
|
|
171
163
|
|
|
172
164
|
### [2.20.10](https://github.com/forcedotcom/sfdx-core/compare/v2.20.9...v2.20.10) (2021-04-14)
|
|
173
165
|
|
|
174
|
-
|
|
175
166
|
### Bug Fixes
|
|
176
167
|
|
|
177
|
-
|
|
168
|
+
- add another internal test env domain ([6ea538f](https://github.com/forcedotcom/sfdx-core/commit/6ea538f2ce62daba7262a247472ce821c6e2616f))
|
|
178
169
|
|
|
179
170
|
### [2.20.9](https://github.com/forcedotcom/sfdx-core/compare/v2.20.8...v2.20.9) (2021-04-05)
|
|
180
171
|
|
|
181
|
-
|
|
182
172
|
### Bug Fixes
|
|
183
173
|
|
|
184
|
-
|
|
174
|
+
- allow = in authUrl tokens ([2337fcd](https://github.com/forcedotcom/sfdx-core/commit/2337fcddfb1907a7092cd52f5b3ad73ae963d59e))
|
|
185
175
|
|
|
186
176
|
### [2.20.8](https://github.com/forcedotcom/sfdx-core/compare/v2.20.7...v2.20.8) (2021-04-03)
|
|
187
177
|
|
|
188
|
-
|
|
189
178
|
### Bug Fixes
|
|
190
179
|
|
|
191
|
-
|
|
180
|
+
- debugEnabled should be public ([dbd0124](https://github.com/forcedotcom/sfdx-core/commit/dbd01243003f555b8b4db45c83e81cc08b8cb9a1))
|
|
192
181
|
|
|
193
182
|
### [2.20.7](https://github.com/forcedotcom/sfdx-core/compare/v2.20.6...v2.20.7) (2021-04-02)
|
|
194
183
|
|
|
195
|
-
|
|
196
184
|
### Bug Fixes
|
|
197
185
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
- add deployRecentValidation ([62d367b](https://github.com/forcedotcom/sfdx-core/commit/62d367b217e6b552573bd7176b064e28252348c5))
|
|
187
|
+
- add deployRecentValidation ([a39c329](https://github.com/forcedotcom/sfdx-core/commit/a39c329b3fab603b537ae5ed8cce4773bdf24eb6))
|
|
188
|
+
- add test, clarify comments ([8d5679e](https://github.com/forcedotcom/sfdx-core/commit/8d5679ecbd482af84842f5c1c8908a059d97ef3f))
|
|
201
189
|
|
|
202
190
|
### [2.20.6](https://github.com/forcedotcom/sfdx-core/compare/v2.20.5...v2.20.6) (2021-04-02)
|
|
203
191
|
|
package/lib/authInfo.d.ts
CHANGED
|
@@ -202,12 +202,7 @@ export declare class AuthInfo extends AsyncCreatable<AuthInfo.Options> {
|
|
|
202
202
|
* ```
|
|
203
203
|
* @param sfdxAuthUrl
|
|
204
204
|
*/
|
|
205
|
-
static parseSfdxAuthUrl(sfdxAuthUrl: string):
|
|
206
|
-
clientId: string;
|
|
207
|
-
clientSecret: string;
|
|
208
|
-
refreshToken: string;
|
|
209
|
-
loginUrl: string;
|
|
210
|
-
};
|
|
205
|
+
static parseSfdxAuthUrl(sfdxAuthUrl: string): Pick<AuthFields, 'clientId' | 'clientSecret' | 'refreshToken' | 'loginUrl'>;
|
|
211
206
|
/**
|
|
212
207
|
* Get the username.
|
|
213
208
|
*/
|
package/lib/authInfo.js
CHANGED
|
@@ -87,6 +87,7 @@ class OAuth2WithVerifier extends jsforce_1.OAuth2 {
|
|
|
87
87
|
*
|
|
88
88
|
* See https://github.com/jsforce/jsforce/issues/665
|
|
89
89
|
*/
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
91
|
async _postParams(params, callback) {
|
|
91
92
|
kit_1.set(params, 'code_verifier', this.codeVerifier);
|
|
92
93
|
// @ts-ignore TODO: need better typings for jsforce
|
package/lib/connection.js
CHANGED
|
@@ -19,6 +19,7 @@ const configAggregator_1 = require("./config/configAggregator");
|
|
|
19
19
|
const logger_1 = require("./logger");
|
|
20
20
|
const sfdxError_1 = require("./sfdxError");
|
|
21
21
|
const sfdc_1 = require("./util/sfdc");
|
|
22
|
+
const lifecycleEvents_1 = require("./lifecycleEvents");
|
|
22
23
|
/**
|
|
23
24
|
* The 'async' in our request override replaces the jsforce promise with the node promise, then returns it back to
|
|
24
25
|
* jsforce which expects .thenCall. Add .thenCall to the node promise to prevent breakage.
|
|
@@ -356,7 +357,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
356
357
|
.on('end', () => {
|
|
357
358
|
const totalSize = ts_types_1.getNumber(query, 'totalSize') || 0;
|
|
358
359
|
if (totalSize > records.length) {
|
|
359
|
-
|
|
360
|
+
void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(`The query result is missing ${totalSize - records.length} records due to a ${maxFetch} record limit. Increase the number of records returned by setting the config value "maxQueryLimit" or the environment variable "SFDX_MAX_QUERY_LIMIT" to ${totalSize} or greater than ${maxFetch}.`);
|
|
360
361
|
}
|
|
361
362
|
resolve({
|
|
362
363
|
done: true,
|
package/lib/lifecycleEvents.d.ts
CHANGED
|
@@ -16,16 +16,29 @@ declare type callback = (data: any) => Promise<void>;
|
|
|
16
16
|
*
|
|
17
17
|
* // Deep in the deploy code, fire the event for all libraries and plugins to hear.
|
|
18
18
|
* Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
|
|
19
|
+
*
|
|
20
|
+
* // if you don't need to await anything
|
|
21
|
+
* use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
21
24
|
export declare class Lifecycle {
|
|
22
|
-
private debug;
|
|
23
25
|
private readonly listeners;
|
|
26
|
+
static readonly telemetryEventName = "telemetry";
|
|
27
|
+
static readonly warningEventName = "warning";
|
|
28
|
+
private debug;
|
|
24
29
|
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* return the package.json version of the sfdx-core library.
|
|
32
|
+
*/
|
|
33
|
+
static staticVersion(): string;
|
|
25
34
|
/**
|
|
26
35
|
* Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
|
|
27
36
|
*/
|
|
28
37
|
static getInstance(): Lifecycle;
|
|
38
|
+
/**
|
|
39
|
+
* return the package.json version of the sfdx-core library.
|
|
40
|
+
*/
|
|
41
|
+
version(): string;
|
|
29
42
|
/**
|
|
30
43
|
* Remove all listeners for a given event
|
|
31
44
|
*
|
|
@@ -38,6 +51,18 @@ export declare class Lifecycle {
|
|
|
38
51
|
* @param eventName The name of the event to get listeners of
|
|
39
52
|
*/
|
|
40
53
|
getListeners(eventName: string): callback[];
|
|
54
|
+
/**
|
|
55
|
+
* Create a listener for the `telemetry` event
|
|
56
|
+
*
|
|
57
|
+
* @param cb The callback function to run when the event is emitted
|
|
58
|
+
*/
|
|
59
|
+
onTelemetry(cb: (data: Record<string, unknown>) => Promise<void>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Create a listener for the `warning` event
|
|
62
|
+
*
|
|
63
|
+
* @param cb The callback function to run when the event is emitted
|
|
64
|
+
*/
|
|
65
|
+
onWarning(cb: (warning: string) => Promise<void>): void;
|
|
41
66
|
/**
|
|
42
67
|
* Create a new listener for a given event
|
|
43
68
|
*
|
|
@@ -45,6 +70,18 @@ export declare class Lifecycle {
|
|
|
45
70
|
* @param cb The callback function to run when the event is emitted
|
|
46
71
|
*/
|
|
47
72
|
on<T = AnyJson>(eventName: string, cb: (data: T) => Promise<void>): void;
|
|
73
|
+
/**
|
|
74
|
+
* Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
|
|
75
|
+
*
|
|
76
|
+
* @param data The data to emit
|
|
77
|
+
*/
|
|
78
|
+
emitTelemetry(data: AnyJson): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Emit a `warning` event, causing all callback functions to be run in the order they were registered
|
|
81
|
+
*
|
|
82
|
+
* @param data The warning (string) to emit
|
|
83
|
+
*/
|
|
84
|
+
emitWarning(warning: string): Promise<void>;
|
|
48
85
|
/**
|
|
49
86
|
* Emit a given event, causing all callback functions to be run in the order they were registered
|
|
50
87
|
*
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Lifecycle = void 0;
|
|
10
10
|
const Debug = require("debug");
|
|
11
|
+
const semver_1 = require("semver");
|
|
12
|
+
// needed for TS to not put everything inside /lib/src
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const pjson = require("../package.json");
|
|
11
15
|
/**
|
|
12
16
|
* An asynchronous event listener and emitter that follows the singleton pattern. The singleton pattern allows lifecycle
|
|
13
17
|
* events to be emitted from deep within a library and still be consumed by any other library or tool. It allows other
|
|
@@ -24,12 +28,21 @@ const Debug = require("debug");
|
|
|
24
28
|
*
|
|
25
29
|
* // Deep in the deploy code, fire the event for all libraries and plugins to hear.
|
|
26
30
|
* Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
|
|
31
|
+
*
|
|
32
|
+
* // if you don't need to await anything
|
|
33
|
+
* use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
|
|
27
34
|
* ```
|
|
28
35
|
*/
|
|
29
36
|
class Lifecycle {
|
|
30
|
-
constructor() {
|
|
37
|
+
constructor(listeners = {}) {
|
|
38
|
+
this.listeners = listeners;
|
|
31
39
|
this.debug = Debug(`sfdx:${this.constructor.name}`);
|
|
32
|
-
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* return the package.json version of the sfdx-core library.
|
|
43
|
+
*/
|
|
44
|
+
static staticVersion() {
|
|
45
|
+
return pjson.version;
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
|
|
@@ -52,10 +65,29 @@ class Lifecycle {
|
|
|
52
65
|
//
|
|
53
66
|
// Nothing should EVER be removed, even across major versions.
|
|
54
67
|
if (!global.salesforceCoreLifecycle) {
|
|
68
|
+
// it's not been loaded yet (basic singleton pattern)
|
|
55
69
|
global.salesforceCoreLifecycle = new Lifecycle();
|
|
56
70
|
}
|
|
71
|
+
else if (
|
|
72
|
+
// an older version was loaded that should be replaced
|
|
73
|
+
semver_1.compare(global.salesforceCoreLifecycle.version(), Lifecycle.staticVersion()) === -1) {
|
|
74
|
+
const oldInstance = global.salesforceCoreLifecycle;
|
|
75
|
+
// use the newer version and transfer any listeners from the old version
|
|
76
|
+
// object spread keeps them from being references
|
|
77
|
+
global.salesforceCoreLifecycle = new Lifecycle({ ...oldInstance.listeners });
|
|
78
|
+
// clean up any listeners on the old version
|
|
79
|
+
Object.keys(oldInstance.listeners).map((eventName) => {
|
|
80
|
+
oldInstance.removeAllListeners(eventName);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
57
83
|
return global.salesforceCoreLifecycle;
|
|
58
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* return the package.json version of the sfdx-core library.
|
|
87
|
+
*/
|
|
88
|
+
version() {
|
|
89
|
+
return pjson.version;
|
|
90
|
+
}
|
|
59
91
|
/**
|
|
60
92
|
* Remove all listeners for a given event
|
|
61
93
|
*
|
|
@@ -79,6 +111,22 @@ class Lifecycle {
|
|
|
79
111
|
return [];
|
|
80
112
|
}
|
|
81
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a listener for the `telemetry` event
|
|
116
|
+
*
|
|
117
|
+
* @param cb The callback function to run when the event is emitted
|
|
118
|
+
*/
|
|
119
|
+
onTelemetry(cb) {
|
|
120
|
+
this.on(Lifecycle.telemetryEventName, cb);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a listener for the `warning` event
|
|
124
|
+
*
|
|
125
|
+
* @param cb The callback function to run when the event is emitted
|
|
126
|
+
*/
|
|
127
|
+
onWarning(cb) {
|
|
128
|
+
this.on(Lifecycle.warningEventName, cb);
|
|
129
|
+
}
|
|
82
130
|
/**
|
|
83
131
|
* Create a new listener for a given event
|
|
84
132
|
*
|
|
@@ -93,6 +141,27 @@ class Lifecycle {
|
|
|
93
141
|
listeners.push(cb);
|
|
94
142
|
this.listeners[eventName] = listeners;
|
|
95
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
|
|
146
|
+
*
|
|
147
|
+
* @param data The data to emit
|
|
148
|
+
*/
|
|
149
|
+
async emitTelemetry(data) {
|
|
150
|
+
return this.emit(Lifecycle.telemetryEventName, data);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Emit a `warning` event, causing all callback functions to be run in the order they were registered
|
|
154
|
+
*
|
|
155
|
+
* @param data The warning (string) to emit
|
|
156
|
+
*/
|
|
157
|
+
async emitWarning(warning) {
|
|
158
|
+
// if there are no listeners, warnings should go to the node process so they're not lost
|
|
159
|
+
// this also preserves behavior in UT where there's a spy on process.emitWarning
|
|
160
|
+
if (this.getListeners(Lifecycle.warningEventName).length === 0) {
|
|
161
|
+
process.emitWarning(warning);
|
|
162
|
+
}
|
|
163
|
+
return this.emit(Lifecycle.warningEventName, warning);
|
|
164
|
+
}
|
|
96
165
|
/**
|
|
97
166
|
* Emit a given event, causing all callback functions to be run in the order they were registered
|
|
98
167
|
*
|
|
@@ -112,4 +181,6 @@ class Lifecycle {
|
|
|
112
181
|
}
|
|
113
182
|
}
|
|
114
183
|
exports.Lifecycle = Lifecycle;
|
|
184
|
+
Lifecycle.telemetryEventName = 'telemetry';
|
|
185
|
+
Lifecycle.warningEventName = 'warning';
|
|
115
186
|
//# sourceMappingURL=lifecycleEvents.js.map
|
package/lib/logger.js
CHANGED
package/lib/sfdxError.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare class SfdxError extends NamedError {
|
|
|
149
149
|
* @param err The error to convert.
|
|
150
150
|
*/
|
|
151
151
|
static wrap(err: Error | string): SfdxError;
|
|
152
|
-
get code(): string;
|
|
152
|
+
get code(): string | undefined | any;
|
|
153
153
|
set code(code: string);
|
|
154
154
|
/**
|
|
155
155
|
* Sets the name of the command. For convenience `this` object is returned.
|
package/lib/sfdxError.js
CHANGED
package/lib/testSetup.js
CHANGED
|
@@ -63,7 +63,7 @@ function defaultFakeConnectionRequest() {
|
|
|
63
63
|
* ```
|
|
64
64
|
* @param sinon
|
|
65
65
|
*/
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
67
67
|
const instantiateContext = (sinon) => {
|
|
68
68
|
if (!sinon) {
|
|
69
69
|
try {
|
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
|
/**
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.0",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/exported",
|
|
6
|
+
"types": "lib/exported.d.ts",
|
|
6
7
|
"license": "BSD-3-Clause",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build": "sf-build",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"jsforce": "^1.10.1",
|
|
53
54
|
"jsonwebtoken": "8.5.0",
|
|
54
55
|
"mkdirp": "1.0.4",
|
|
56
|
+
"semver": "^7.3.5",
|
|
55
57
|
"sfdx-faye": "^1.0.9",
|
|
56
58
|
"ts-retry-promise": "^0.6.0"
|
|
57
59
|
},
|
|
@@ -63,6 +65,7 @@
|
|
|
63
65
|
"@types/debug": "0.0.30",
|
|
64
66
|
"@types/jsen": "0.0.19",
|
|
65
67
|
"@types/jsonwebtoken": "8.3.2",
|
|
68
|
+
"@types/semver": "^7.3.9",
|
|
66
69
|
"@types/shelljs": "0.7.8",
|
|
67
70
|
"@types/sinon": "^9.0.8",
|
|
68
71
|
"@typescript-eslint/eslint-plugin": "^4.2.0",
|
|
@@ -88,7 +91,6 @@
|
|
|
88
91
|
"ts-node": "^8.10.2",
|
|
89
92
|
"typescript": "^4.1.3"
|
|
90
93
|
},
|
|
91
|
-
"types": "lib/exported.d.ts",
|
|
92
94
|
"repository": {
|
|
93
95
|
"type": "git",
|
|
94
96
|
"url": "https://github.com/forcedotcom/sfdx-core.git"
|