@salesforce/core 3.7.5 → 3.7.6

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/lib/config/configStore.js +2 -1
  3. package/lib/crypto/keyChainImpl.js +0 -1
  4. package/lib/exported.d.ts +3 -1
  5. package/lib/exported.js +3 -1
  6. package/lib/lifecycleEvents.js +1 -1
  7. package/lib/logger.js +0 -1
  8. package/lib/org/authInfo.js +2 -3
  9. package/lib/org/connection.d.ts +6 -1
  10. package/lib/org/connection.js +13 -0
  11. package/lib/org/org.d.ts +12 -2
  12. package/lib/org/org.js +39 -36
  13. package/lib/org/scratchOrgCreate.d.ts +43 -0
  14. package/lib/org/scratchOrgCreate.js +142 -0
  15. package/lib/org/scratchOrgErrorCodes.d.ts +4 -0
  16. package/lib/org/scratchOrgErrorCodes.js +62 -0
  17. package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
  18. package/lib/org/scratchOrgFeatureDeprecation.js +110 -0
  19. package/lib/org/scratchOrgInfoApi.d.ts +94 -0
  20. package/lib/org/scratchOrgInfoApi.js +350 -0
  21. package/lib/org/scratchOrgInfoGenerator.d.ts +63 -0
  22. package/lib/org/scratchOrgInfoGenerator.js +223 -0
  23. package/lib/org/scratchOrgSettingsGenerator.d.ts +56 -0
  24. package/lib/org/scratchOrgSettingsGenerator.js +210 -0
  25. package/lib/org/user.js +4 -3
  26. package/lib/status/pollingClient.d.ts +2 -2
  27. package/lib/status/pollingClient.js +8 -2
  28. package/lib/status/streamingClient.d.ts +1 -1
  29. package/lib/util/jsonXmlTools.d.ts +14 -0
  30. package/lib/util/jsonXmlTools.js +41 -0
  31. package/lib/util/mapKeys.d.ts +14 -0
  32. package/lib/util/mapKeys.js +48 -0
  33. package/lib/util/zipWriter.d.ts +14 -0
  34. package/lib/util/zipWriter.js +68 -0
  35. package/lib/webOAuthServer.js +1 -1
  36. package/messages/org.md +4 -0
  37. package/messages/scratchOrgCreate.md +27 -0
  38. package/messages/scratchOrgErrorCodes.md +99 -0
  39. package/messages/scratchOrgFeatureDeprecation.md +11 -0
  40. package/messages/scratchOrgInfoApi.md +11 -0
  41. package/messages/scratchOrgInfoGenerator.md +19 -0
  42. package/messages/user.md +4 -0
  43. package/package.json +4 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,217 @@
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
+ ### [3.7.6](https://github.com/forcedotcom/sfdx-core/compare/v4.0.0...v3.7.6) (2022-02-28)
6
+
7
+ ## [4.0.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v4.0.0) (2022-02-28)
8
+
9
+ ### Bug Fixes
10
+
11
+ - work through conflicts, UTs, pushing for comparison ([476c6fe](https://github.com/forcedotcom/sfdx-core/commit/476c6fe13514903ac97f7def2aba39b070ee2c33))
12
+
13
+ ### [3.7.5](https://github.com/forcedotcom/sfdx-core/compare/v2.35.1...v3.7.5) (2022-02-14)
14
+
15
+ ### Bug Fixes
16
+
17
+ - add env vars from sfdx-cli init to envvars ([#520](https://github.com/forcedotcom/sfdx-core/issues/520)) ([8ef2785](https://github.com/forcedotcom/sfdx-core/commit/8ef27859d95bfffc5999b14f4792874d04f0504c))
18
+
19
+ ### [3.7.4](https://github.com/forcedotcom/sfdx-core/compare/v2.35.0...v3.7.4) (2022-02-07)
20
+
21
+ ### Bug Fixes
22
+
23
+ - pin ts to 4.4.4 and bump other deps ([#509](https://github.com/forcedotcom/sfdx-core/issues/509)) ([1c0e15c](https://github.com/forcedotcom/sfdx-core/commit/1c0e15cd9a96f03e24476c13d73b62577a535fa3))
24
+
25
+ ### [3.7.3](https://github.com/forcedotcom/sfdx-core/compare/v2.33.1...v3.7.3) (2021-12-16)
26
+
27
+ ### [3.7.2](https://github.com/forcedotcom/sfdx-core/compare/v3.7.1...v3.7.2) (2021-10-28)
28
+
29
+ ### Bug Fixes
30
+
31
+ - make @types/sfdx-faye a dependendcy ([683680b](https://github.com/forcedotcom/sfdx-core/commit/683680b8133048f71d25ef4df7aa24d9700dc5e8))
32
+
33
+ ### [3.7.1](https://github.com/forcedotcom/sfdx-core/compare/v2.28.2...v3.7.1) (2021-10-28)
34
+
35
+ ## [3.7.0](https://github.com/forcedotcom/sfdx-core/compare/v3.6.6...v3.7.0) (2021-10-12)
36
+
37
+ ### Features
38
+
39
+ - use jsforce v2 ([#457](https://github.com/forcedotcom/sfdx-core/issues/457)) ([4a9094e](https://github.com/forcedotcom/sfdx-core/commit/4a9094e958288cdcc6c69f5d87b10a70a437d8e9))
40
+
41
+ ### [3.6.6](https://github.com/forcedotcom/sfdx-core/compare/v2.28.1...v3.6.6) (2021-10-08)
42
+
43
+ ### [3.6.5](https://github.com/forcedotcom/sfdx-core/compare/v3.6.4...v3.6.5) (2021-09-29)
44
+
45
+ ### Bug Fixes
46
+
47
+ - add getValue to AliasAccessor ([c4b69f5](https://github.com/forcedotcom/sfdx-core/commit/c4b69f5ff38547fad640c64833291fe0c6e06a79))
48
+
49
+ ### [3.6.4](https://github.com/forcedotcom/sfdx-core/compare/v3.6.3...v3.6.4) (2021-09-23)
50
+
51
+ ### Bug Fixes
52
+
53
+ - edit the env var blurbs ([#482](https://github.com/forcedotcom/sfdx-core/issues/482)) ([bbbdb6d](https://github.com/forcedotcom/sfdx-core/commit/bbbdb6d0800015e94ce0f0c551eec8ed73dd87c6))
54
+
55
+ ### [3.6.3](https://github.com/forcedotcom/sfdx-core/compare/v3.6.2...v3.6.3) (2021-09-23)
56
+
57
+ ### Bug Fixes
58
+
59
+ - edit the config var blurbs ([#480](https://github.com/forcedotcom/sfdx-core/issues/480)) ([f845512](https://github.com/forcedotcom/sfdx-core/commit/f8455121bfd96f27495bc124dc06570632dfce70))
60
+
61
+ ### [3.6.2](https://github.com/forcedotcom/sfdx-core/compare/v2.28.0...v3.6.2) (2021-09-17)
62
+
63
+ ### Bug Fixes
64
+
65
+ - improve time to build auths for many orgs @W-9914839@ ([#478](https://github.com/forcedotcom/sfdx-core/issues/478)) ([c788541](https://github.com/forcedotcom/sfdx-core/commit/c7885415d59994b28552227f0b84dcee5d3ec7cf))
66
+
67
+ ### [3.6.1](https://github.com/forcedotcom/sfdx-core/compare/v3.6.0...v3.6.1) (2021-09-13)
68
+
69
+ ### Bug Fixes
70
+
71
+ - remove tokens associated with org ([#477](https://github.com/forcedotcom/sfdx-core/issues/477)) ([5034fa2](https://github.com/forcedotcom/sfdx-core/commit/5034fa2d4c52d347c00499e137a71366e4feba7f))
72
+
73
+ ## [3.6.0](https://github.com/forcedotcom/sfdx-core/compare/v3.5.0...v3.6.0) (2021-09-10)
74
+
75
+ ### Features
76
+
77
+ - add help section helper ([#474](https://github.com/forcedotcom/sfdx-core/issues/474)) ([b34c2d7](https://github.com/forcedotcom/sfdx-core/commit/b34c2d7a442aed2cf091fd394a7c3656287d1dbf))
78
+
79
+ ## [3.5.0](https://github.com/forcedotcom/sfdx-core/compare/v3.4.5...v3.5.0) (2021-09-09)
80
+
81
+ ### Features
82
+
83
+ - expose well known env vars as part of core ([#473](https://github.com/forcedotcom/sfdx-core/issues/473)) ([11c3f53](https://github.com/forcedotcom/sfdx-core/commit/11c3f53f964459072826274e6ebb33d4a9ecb990))
84
+
85
+ ### [3.4.5](https://github.com/forcedotcom/sfdx-core/compare/v3.4.4...v3.4.5) (2021-09-03)
86
+
87
+ ### Bug Fixes
88
+
89
+ - provide the correct options to SfdxConfig ([fa2117e](https://github.com/forcedotcom/sfdx-core/commit/fa2117e12d7a903f26067bdcf35d7ec9c142101e))
90
+
91
+ ### [3.4.4](https://github.com/forcedotcom/sfdx-core/compare/v3.4.3...v3.4.4) (2021-09-03)
92
+
93
+ ### [3.4.3](https://github.com/forcedotcom/sfdx-core/compare/v3.4.2...v3.4.3) (2021-08-26)
94
+
95
+ ### [3.4.2](https://github.com/forcedotcom/sfdx-core/compare/v3.4.1...v3.4.2) (2021-08-17)
96
+
97
+ ### Bug Fixes
98
+
99
+ - improve interoperability when unsetting ([#467](https://github.com/forcedotcom/sfdx-core/issues/467)) ([ad781d5](https://github.com/forcedotcom/sfdx-core/commit/ad781d5378652dfd64ccb476c11f418e940b8669))
100
+
101
+ ### [3.4.1](https://github.com/forcedotcom/sfdx-core/compare/v3.4.0...v3.4.1) (2021-08-11)
102
+
103
+ ### Bug Fixes
104
+
105
+ - optionally throw error when reading deprecated config key ([#466](https://github.com/forcedotcom/sfdx-core/issues/466)) ([3118ad8](https://github.com/forcedotcom/sfdx-core/commit/3118ad836db384ac27c2b1db88c4753e6121e4db))
106
+
107
+ ## [3.4.0](https://github.com/forcedotcom/sfdx-core/compare/v3.3.12...v3.4.0) (2021-08-11)
108
+
109
+ ### Features
110
+
111
+ - config interoperability ([#461](https://github.com/forcedotcom/sfdx-core/issues/461)) ([11b60ad](https://github.com/forcedotcom/sfdx-core/commit/11b60adbe54acc8e16a90327c77abbe2613fbaab))
112
+
113
+ ### [3.3.12](https://github.com/forcedotcom/sfdx-core/compare/v2.27.2...v3.3.12) (2021-08-10)
114
+
115
+ ### Bug Fixes
116
+
117
+ - add predicate function to list all auths ([ccdb02c](https://github.com/forcedotcom/sfdx-core/commit/ccdb02c268fae7532b23e0c791bcdd831f77cf98))
118
+
119
+ ### [3.3.11](https://github.com/forcedotcom/sfdx-core/compare/v3.3.10...v3.3.11) (2021-08-04)
120
+
121
+ ### Bug Fixes
122
+
123
+ - allows for message keys of error and errors ([#455](https://github.com/forcedotcom/sfdx-core/issues/455)) ([3bfac58](https://github.com/forcedotcom/sfdx-core/commit/3bfac587c6cf1734af6f2b517439d278591ddd50))
124
+
125
+ ### [3.3.10](https://github.com/forcedotcom/sfdx-core/compare/v3.3.9...v3.3.10) (2021-08-04)
126
+
127
+ ### [3.3.9](https://github.com/forcedotcom/sfdx-core/compare/v3.3.8...v3.3.9) (2021-08-04)
128
+
129
+ ### Bug Fixes
130
+
131
+ - merge main(v2) into v3 ([#452](https://github.com/forcedotcom/sfdx-core/issues/452)) ([3a003b9](https://github.com/forcedotcom/sfdx-core/commit/3a003b9c17962f77344e4a23314bb608e1ae50db))
132
+
133
+ ### [3.3.8](https://github.com/forcedotcom/sfdx-core/compare/v3.3.7...v3.3.8) (2021-08-02)
134
+
135
+ ### Bug Fixes
136
+
137
+ - return all info from AuthInfo.listAllAuthorizations ([#449](https://github.com/forcedotcom/sfdx-core/issues/449)) ([17e60ea](https://github.com/forcedotcom/sfdx-core/commit/17e60eabe87c73a83c26344967076f365ddea81c))
138
+
139
+ ### [3.3.7](https://github.com/forcedotcom/sfdx-core/compare/v2.27.0...v3.3.7) (2021-07-30)
140
+
141
+ ### [3.3.6](https://github.com/forcedotcom/sfdx-core/compare/v3.3.5...v3.3.6) (2021-07-28)
142
+
143
+ ### Bug Fixes
144
+
145
+ - use correct method to get username ([#446](https://github.com/forcedotcom/sfdx-core/issues/446)) ([79a6b2f](https://github.com/forcedotcom/sfdx-core/commit/79a6b2f069f95b0c50a6c03ecbac07cf0d1832b1))
146
+
147
+ ### [3.3.5](https://github.com/forcedotcom/sfdx-core/compare/v3.3.4...v3.3.5) (2021-07-28)
148
+
149
+ ### [3.3.4](https://github.com/forcedotcom/sfdx-core/compare/v3.3.3...v3.3.4) (2021-07-26)
150
+
151
+ ### Bug Fixes
152
+
153
+ - remove bad validator function ([1b97dc6](https://github.com/forcedotcom/sfdx-core/commit/1b97dc6f4d657a5b86489d33c4843ebfd54b3715))
154
+
155
+ ### [3.3.3](https://github.com/forcedotcom/sfdx-core/compare/v3.3.2...v3.3.3) (2021-07-22)
156
+
157
+ ### Bug Fixes
158
+
159
+ - write sf.json contents on init ([c47f649](https://github.com/forcedotcom/sfdx-core/commit/c47f64954118d0d2f7f4a8e992d3450516239084))
160
+
161
+ ### [3.3.2](https://github.com/forcedotcom/sfdx-core/compare/v2.26.1...v3.3.2) (2021-07-21)
162
+
163
+ ### Bug Fixes
164
+
165
+ - correct jsdoc ([a362e94](https://github.com/forcedotcom/sfdx-core/commit/a362e94c4ae7538cbbcd7dae8fcd3244629d845c))
166
+
167
+ ### [3.3.1](https://github.com/forcedotcom/sfdx-core/compare/v3.3.0...v3.3.1) (2021-07-15)
168
+
169
+ ### Bug Fixes
170
+
171
+ - temporarily point Alias back to .sfdx ([#438](https://github.com/forcedotcom/sfdx-core/issues/438)) ([4bffcd8](https://github.com/forcedotcom/sfdx-core/commit/4bffcd84362d5b3049ef428e90dc1b538a435f81))
172
+
173
+ ## [3.3.0](https://github.com/forcedotcom/sfdx-core/compare/v3.2.0-v3.0...v3.3.0) (2021-07-14)
174
+
175
+ ### Features
176
+
177
+ - V3 merge ([#436](https://github.com/forcedotcom/sfdx-core/issues/436)) ([1193449](https://github.com/forcedotcom/sfdx-core/commit/119344969147679088e30bae4c4fc5e941661078)), closes [#413](https://github.com/forcedotcom/sfdx-core/issues/413) [#415](https://github.com/forcedotcom/sfdx-core/issues/415) [#428](https://github.com/forcedotcom/sfdx-core/issues/428) [#429](https://github.com/forcedotcom/sfdx-core/issues/429) [#427](https://github.com/forcedotcom/sfdx-core/issues/427) [#432](https://github.com/forcedotcom/sfdx-core/issues/432)
178
+
179
+ ## [3.2.0-v3.0](https://github.com/forcedotcom/sfdx-core/compare/v2.26.0...v3.2.0-v3.0) (2021-07-14)
180
+
181
+ ### Features
182
+
183
+ - use .sf/config.json @W-9546117@ ([#433](https://github.com/forcedotcom/sfdx-core/issues/433)) ([6c41653](https://github.com/forcedotcom/sfdx-core/commit/6c416531a9bae10e855ded3efc289a99196bc26b))
184
+
185
+ ### [3.1.1-v3.2](https://github.com/forcedotcom/sfdx-core/compare/v2.24.2...v3.1.1-v3.2) (2021-06-29)
186
+
187
+ ### Bug Fixes
188
+
189
+ - do not use function prop ([#426](https://github.com/forcedotcom/sfdx-core/issues/426)) ([39efe0c](https://github.com/forcedotcom/sfdx-core/commit/39efe0ccc84b05bc891e54b24bfcddc62790ae0e))
190
+
191
+ ### [3.1.1-v3.1](https://github.com/forcedotcom/sfdx-core/compare/v2.24.0...v3.1.1-v3.1) (2021-06-14)
192
+
193
+ ### Bug Fixes
194
+
195
+ - keep track of auth changes ([210be6c](https://github.com/forcedotcom/sfdx-core/commit/210be6cb408bd9ecc861989570df0e14f6a3a566))
196
+
197
+ ### [3.1.1-v3.0](https://github.com/forcedotcom/sfdx-core/compare/v2.23.3...v3.1.1-v3.0) (2021-06-03)
198
+
199
+ ### ⚠ BREAKING CHANGES
200
+
201
+ - default to reading files from cache
202
+
203
+ ### Features
204
+
205
+ - add GlobalInfo config file ([#397](https://github.com/forcedotcom/sfdx-core/issues/397)) ([889425c](https://github.com/forcedotcom/sfdx-core/commit/889425c06e8ed6a364d9a2bc3dd5ef0a38a66046))
206
+ - add message support for markdown files ([0f235a2](https://github.com/forcedotcom/sfdx-core/commit/0f235a23d5dddbd7b3f07544d8c7e380875c6c55))
207
+ - default to reading files from cache ([558319d](https://github.com/forcedotcom/sfdx-core/commit/558319dfdc81e2bae549d58be75a701162801994))
208
+ - move crypto to config file @W-9225317@ ([#406](https://github.com/forcedotcom/sfdx-core/issues/406)) ([bac83c3](https://github.com/forcedotcom/sfdx-core/commit/bac83c3a52b15c9b462dfb68be9d080e710493cd))
209
+
210
+ ### Bug Fixes
211
+
212
+ - compilation errors ([33a9876](https://github.com/forcedotcom/sfdx-core/commit/33a9876575eff7944bb287d428f52413831725d9))
213
+ - unit test failures ([4507575](https://github.com/forcedotcom/sfdx-core/commit/45075754175d411b6cb71eb809096e6eb3e23d95))
214
+ - unsetAuthorization ([#399](https://github.com/forcedotcom/sfdx-core/issues/399)) ([dd57438](https://github.com/forcedotcom/sfdx-core/commit/dd57438a95b49515f560d3b915cdf916a4b8643b))
215
+
5
216
  ### [3.7.5](https://github.com/forcedotcom/sfdx-core/compare/v3.7.4...v3.7.5) (2022-02-14)
6
217
 
7
218
  ### Bug Fixes
@@ -206,7 +206,8 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
206
206
  });
207
207
  }
208
208
  getEncryptedKeys() {
209
- return [...(this.options.encryptedKeys || []), ...(this.statics.encryptedKeys || [])];
209
+ var _a, _b;
210
+ return [...(((_a = this.options) === null || _a === void 0 ? void 0 : _a.encryptedKeys) || []), ...(((_b = this.statics) === null || _b === void 0 ? void 0 : _b.encryptedKeys) || [])];
210
211
  }
211
212
  /**
212
213
  * This config file has encrypted keys and it should attempt to encrypt them.
@@ -216,7 +216,6 @@ const _linuxImpl = {
216
216
  // This is a workaround for linux.
217
217
  // Calling secret-tool too fast can cause it to return an unexpected error. (below)
218
218
  if (stderr != null && stderr.includes('invalid or unencryptable secret')) {
219
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
220
219
  // @ts-ignore TODO: make an error subclass with this field
221
220
  error.retry = true;
222
221
  // Throwing here allows us to perform a retry in KeychainAccess
package/lib/exported.d.ts CHANGED
@@ -17,7 +17,7 @@ export { SfdcUrl } from './util/sfdcUrl';
17
17
  export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
18
18
  export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
19
19
  export { Messages } from './messages';
20
- export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, } from './org';
20
+ export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
21
21
  export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
22
22
  export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './sfdxProject';
23
23
  export { SchemaPrinter } from './schema/printer';
@@ -28,6 +28,8 @@ export { CometClient, CometSubscription, StreamingClient, StatusResult } from '.
28
28
  export { MyDomainResolver } from './status/myDomainResolver';
29
29
  export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
30
30
  export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
31
+ export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate } from './org/scratchOrgCreate';
32
+ export { ScratchOrgInfo } from './org/scratchOrgInfoApi';
31
33
  export * from './util/fs';
32
34
  export * from './util/sfdc';
33
35
  export * from './util/sfdcUrl';
package/lib/exported.js CHANGED
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
19
+ exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
20
20
  const messages_1 = require("./messages");
21
21
  messages_1.Messages.importMessagesDirectory(__dirname);
22
22
  var configFile_1 = require("./config/configFile");
@@ -93,6 +93,8 @@ Object.defineProperty(exports, "REQUIRED_FIELDS", { enumerable: true, get: funct
93
93
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
94
94
  var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
95
95
  Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, get: function () { return permissionSetAssignment_1.PermissionSetAssignment; } });
96
+ var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
97
+ Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
96
98
  // Utility sub-modules
97
99
  __exportStar(require("./util/fs"), exports);
98
100
  __exportStar(require("./util/sfdc"), exports);
@@ -170,7 +170,7 @@ class Lifecycle {
170
170
  */
171
171
  async emit(eventName, data) {
172
172
  const listeners = this.getListeners(eventName);
173
- if (listeners.length === 0) {
173
+ if (listeners.length === 0 && eventName !== Lifecycle.warningEventName) {
174
174
  this.debug(`A lifecycle event with the name ${eventName} does not exist. An event must be registered before it can be emitted.`);
175
175
  }
176
176
  else {
package/lib/logger.js CHANGED
@@ -11,7 +11,6 @@ const events_1 = require("events");
11
11
  const os = require("os");
12
12
  const path = require("path");
13
13
  const stream_1 = require("stream");
14
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
14
  // @ts-ignore
16
15
  const Bunyan = require("@salesforce/bunyan");
17
16
  const kit_1 = require("@salesforce/kit");
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
2
4
  /*
3
5
  * Copyright (c) 2020, salesforce.com, inc.
4
6
  * All rights reserved.
5
7
  * Licensed under the BSD 3-Clause license.
6
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
10
- /* eslint-disable @typescript-eslint/ban-ts-comment */
11
10
  const crypto_1 = require("crypto");
12
11
  const path_1 = require("path");
13
12
  const os = require("os");
@@ -4,8 +4,8 @@ import { JsonCollection, JsonMap, Optional } from '@salesforce/ts-types';
4
4
  import { Connection as JSForceConnection, ConnectionConfig, HttpRequest, QueryOptions, QueryResult, Record, Schema } from 'jsforce';
5
5
  import { Tooling as JSForceTooling } from 'jsforce/lib/api/tooling';
6
6
  import { StreamPromise } from 'jsforce/lib/util/promise';
7
- import { AuthFields, AuthInfo } from '../org/authInfo';
8
7
  import { ConfigAggregator } from '../config/configAggregator';
8
+ import { AuthFields, AuthInfo } from './authInfo';
9
9
  export declare const SFDX_HTTP_HEADERS: {
10
10
  'content-type': string;
11
11
  'user-agent': string;
@@ -171,6 +171,11 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
171
171
  * @param options The query options.
172
172
  */
173
173
  singleRecordQuery<T extends Record>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
174
+ /**
175
+ * Executes a get request on the baseUrl to force an auth refresh
176
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
177
+ */
178
+ refreshAuth(): Promise<void>;
174
179
  private loadInstanceApiVersion;
175
180
  }
176
181
  export declare const SingleRecordQueryErrors: {
@@ -138,6 +138,7 @@ class Connection extends jsforce_1.Connection {
138
138
  delete options.rest;
139
139
  if (rest) {
140
140
  this.logger.debug('deploy with REST');
141
+ await this.refreshAuth();
141
142
  const headers = {
142
143
  Authorization: this && `OAuth ${this.accessToken}`,
143
144
  'Sforce-Call-Options': 'client=sfdx-core',
@@ -365,6 +366,18 @@ class Connection extends jsforce_1.Connection {
365
366
  }
366
367
  return result.records[0];
367
368
  }
369
+ /**
370
+ * Executes a get request on the baseUrl to force an auth refresh
371
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
372
+ */
373
+ async refreshAuth() {
374
+ this.logger.debug('Refreshing auth for org.');
375
+ const requestInfo = {
376
+ url: this.baseUrl(),
377
+ method: 'GET',
378
+ };
379
+ await this.request(requestInfo);
380
+ }
368
381
  async loadInstanceApiVersion() {
369
382
  const authFileFields = this.options.authInfo.getFields();
370
383
  const lastCheckedDateString = authFileFields.instanceApiVersionLastRetrieved;
package/lib/org/org.d.ts CHANGED
@@ -5,6 +5,7 @@ import { OrgUsersConfig } from '../config/orgUsersConfig';
5
5
  import { SandboxOrgConfig } from '../config/sandboxOrgConfig';
6
6
  import { Connection } from './connection';
7
7
  import { AuthFields, AuthInfo } from './authInfo';
8
+ import { ScratchOrgCreateOptions, ScratchOrgCreateResult } from './scratchOrgCreate';
8
9
  export declare type OrganizationInformation = {
9
10
  Name: string;
10
11
  InstanceName: string;
@@ -63,6 +64,7 @@ export declare type SandboxRequest = {
63
64
  SourceId?: string;
64
65
  Description?: string;
65
66
  };
67
+ export declare type ScratchOrgRequest = Pick<ScratchOrgCreateOptions, 'connectedAppConsumerKey' | 'durationDays' | 'nonamespace' | 'noancestors' | 'wait' | 'retry' | 'apiversion' | 'definitionjson' | 'definitionfile' | 'orgConfig' | 'clientSecret'>;
66
68
  /**
67
69
  * Provides a way to manage a locally authenticated Org.
68
70
  *
@@ -111,6 +113,14 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
111
113
  wait?: Duration;
112
114
  interval?: Duration;
113
115
  }): Promise<SandboxProcessObject>;
116
+ /**
117
+ * Creates a scratchOrg
118
+ * 'this' needs to be a valid dev-hub
119
+ *
120
+ * @param {options} ScratchOrgCreateOptions
121
+ * @returns {ScratchOrgCreateResult}
122
+ */
123
+ scratchOrgCreate(options: ScratchOrgRequest): Promise<ScratchOrgCreateResult>;
114
124
  /**
115
125
  * Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
116
126
  *
@@ -299,8 +309,8 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
299
309
  */
300
310
  protected getDefaultOptions(): Org.Options;
301
311
  private queryProduction;
302
- private destorySandbox;
303
- private destoryScratchOrg;
312
+ private destroySandbox;
313
+ private destroyScratchOrg;
304
314
  /**
305
315
  * this method will delete the sandbox org from the production org and clean up any local files
306
316
  *
package/lib/org/org.js CHANGED
@@ -15,16 +15,17 @@ const configAggregator_1 = require("../config/configAggregator");
15
15
  const orgUsersConfig_1 = require("../config/orgUsersConfig");
16
16
  const sandboxOrgConfig_1 = require("../config/sandboxOrgConfig");
17
17
  const global_1 = require("../global");
18
+ const lifecycleEvents_1 = require("../lifecycleEvents");
18
19
  const logger_1 = require("../logger");
19
20
  const sfdxError_1 = require("../sfdxError");
20
21
  const fs_1 = require("../util/fs");
21
22
  const sfdc_1 = require("../util/sfdc");
22
- const globalInfo_1 = require("../globalInfo");
23
- const messages_1 = require("../messages");
24
- const lifecycleEvents_1 = require("../lifecycleEvents");
25
23
  const webOAuthServer_1 = require("../webOAuthServer");
24
+ const messages_1 = require("../messages");
25
+ const globalInfo_1 = require("../globalInfo");
26
26
  const connection_1 = require("./connection");
27
27
  const authInfo_1 = require("./authInfo");
28
+ const scratchOrgCreate_1 = require("./scratchOrgCreate");
28
29
  const orgConfigProperties_1 = require("./orgConfigProperties");
29
30
  messages_1.Messages.importMessagesDirectory(__dirname);
30
31
  const messages = messages_1.Messages.load('@salesforce/core', 'org', [
@@ -114,6 +115,16 @@ class Org extends kit_1.AsyncOptionalCreatable {
114
115
  pollInterval,
115
116
  });
116
117
  }
118
+ /**
119
+ * Creates a scratchOrg
120
+ * 'this' needs to be a valid dev-hub
121
+ *
122
+ * @param {options} ScratchOrgCreateOptions
123
+ * @returns {ScratchOrgCreateResult}
124
+ */
125
+ async scratchOrgCreate(options) {
126
+ return (0, scratchOrgCreate_1.scratchOrgCreate)({ ...options, hubOrg: this });
127
+ }
117
128
  /**
118
129
  * Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
119
130
  *
@@ -593,10 +604,10 @@ class Org extends kit_1.AsyncOptionalCreatable {
593
604
  async queryProduction(org, field, value) {
594
605
  return org.connection.singleRecordQuery(`SELECT SandboxInfoId FROM SandboxProcess WHERE ${field} ='${value}' AND Status NOT IN ('D', 'E')`, { tooling: true });
595
606
  }
596
- async destorySandbox(org, id) {
607
+ async destroySandbox(org, id) {
597
608
  return org.getConnection().tooling.delete('SandboxInfo', id);
598
609
  }
599
- async destoryScratchOrg(org, id) {
610
+ async destroyScratchOrg(org, id) {
600
611
  return org.getConnection().delete('ActiveScratchOrg', id);
601
612
  }
602
613
  /**
@@ -641,7 +652,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
641
652
  }
642
653
  }
643
654
  // const deleteResult = await prodOrg.connection.tooling.delete('SandboxInfo', result.SandboxInfoId);
644
- const deleteResult = await this.destorySandbox(prodOrg, result.SandboxInfoId);
655
+ const deleteResult = await this.destroySandbox(prodOrg, result.SandboxInfoId);
645
656
  this.logger.debug('Return from calling tooling.delete: %o ', deleteResult);
646
657
  await this.remove();
647
658
  if (Array.isArray(deleteResult) || !deleteResult.success) {
@@ -669,7 +680,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
669
680
  const username = this.getUsername();
670
681
  const activeScratchOrgRecordId = (await devHubConn.singleRecordQuery(`SELECT Id FROM ActiveScratchOrg WHERE SignupUsername='${username}'`)).Id;
671
682
  this.logger.trace(`found matching ActiveScratchOrg with SignupUsername: ${username}. Deleting...`);
672
- await this.destoryScratchOrg(devHub, activeScratchOrgRecordId);
683
+ await this.destroyScratchOrg(devHub, activeScratchOrgRecordId);
673
684
  await this.remove();
674
685
  }
675
686
  catch (err) {
@@ -703,7 +714,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
703
714
  this.logger.debug(`Clearing auth cache for user: ${username}`);
704
715
  config.orgs.unset(username);
705
716
  }
706
- await config.write();
707
717
  }
708
718
  /**
709
719
  * Deletes the users config file
@@ -743,34 +753,27 @@ class Org extends kit_1.AsyncOptionalCreatable {
743
753
  this.logger.debug(`Removing users associate with org: ${this.getOrgId()}`);
744
754
  const config = await this.retrieveOrgUsersConfig();
745
755
  this.logger.debug(`using path for org users: ${config.getPath()}`);
746
- if (await config.exists()) {
747
- const authInfos = await this.readUserAuthFiles();
748
- this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
749
- for (const auth of authInfos) {
750
- const username = auth.getFields().username;
751
- const aliases = (username && globalInfo.aliases.getAll(username)) || [];
752
- globalInfo.aliases.unsetAll(username);
753
- let orgForUser;
754
- if (username === this.getUsername()) {
755
- orgForUser = this;
756
- }
757
- else {
758
- const info = await authInfo_1.AuthInfo.create({ username });
759
- const connection = await connection_1.Connection.create({ authInfo: info });
760
- orgForUser = await Org.create({ connection });
761
- }
762
- const removeConfig = async (configInfo) => {
763
- if ((configInfo.value === username || aliases.includes(configInfo.value)) &&
764
- (configInfo.isGlobal() || configInfo.isLocal())) {
765
- await config_1.Config.update(configInfo.isGlobal(), configInfo.key, undefined);
766
- }
767
- };
768
- await removeConfig(this.configAggregator.getInfo(orgConfigProperties_1.OrgConfigProperties.TARGET_DEV_HUB));
769
- await removeConfig(this.configAggregator.getInfo(orgConfigProperties_1.OrgConfigProperties.TARGET_ORG));
770
- await orgForUser.removeAuth();
771
- }
772
- await globalInfo.write();
773
- }
756
+ const authInfos = await this.readUserAuthFiles();
757
+ await Promise.all(authInfos
758
+ .map((auth) => auth.getFields().username)
759
+ .map(async (username) => {
760
+ const aliasKeys = (username && globalInfo.aliases.getAll(username)) || [];
761
+ globalInfo.aliases.unsetAll(username);
762
+ const orgForUser = username === this.getUsername()
763
+ ? this
764
+ : await Org.create({
765
+ connection: await connection_1.Connection.create({ authInfo: await authInfo_1.AuthInfo.create({ username }) }),
766
+ });
767
+ const orgType = this.isDevHubOrg() ? orgConfigProperties_1.OrgConfigProperties.TARGET_DEV_HUB : orgConfigProperties_1.OrgConfigProperties.TARGET_ORG;
768
+ const configInfo = orgForUser.configAggregator.getInfo(orgType);
769
+ const needsConfigUpdate = (configInfo.isGlobal() || configInfo.isLocal()) &&
770
+ (configInfo.value === username || aliasKeys.includes(configInfo.value));
771
+ return [
772
+ orgForUser.removeAuth(),
773
+ needsConfigUpdate ? config_1.Config.update(configInfo.isGlobal(), orgType, undefined) : undefined,
774
+ ].filter(Boolean);
775
+ }));
776
+ await globalInfo.write();
774
777
  }
775
778
  /**
776
779
  * Remove an associate sandbox config.
@@ -0,0 +1,43 @@
1
+ import { Duration } from '@salesforce/kit';
2
+ import { Org } from './org';
3
+ import { ScratchOrgInfo } from './scratchOrgInfoApi';
4
+ import { AuthFields, AuthInfo } from './authInfo';
5
+ export declare const DEFAULT_STREAM_TIMEOUT_MINUTES = 6;
6
+ export interface ScratchOrgCreateResult {
7
+ username?: string;
8
+ scratchOrgInfo?: ScratchOrgInfo;
9
+ authInfo?: AuthInfo;
10
+ authFields?: AuthFields;
11
+ warnings: string[];
12
+ }
13
+ /**
14
+ * interface ScratchOrgCreateOptions
15
+ *
16
+ * @param hubOrg the environment hub org
17
+ * @param connectedAppConsumerKey The connected app consumer key.
18
+ * @param durationDays duration of the scratch org (in days) (default:1, min:1, max:30)
19
+ * @param nonamespace create the scratch org with no namespace
20
+ * @param noancestors do not include second-generation package ancestors in the scratch org
21
+ * @param wait the streaming client socket timeout (in minutes) must be an instance of the Duration utility class (default:6, min:2)
22
+ * @param retry number of scratch org auth retries after scratch org is successfully signed up (default:0, min:0, max:10)
23
+ * @param apiversion target server instance API version
24
+ * @param definitionjson org definition in JSON format
25
+ * @param definitionfile path to an org definition file
26
+ * @param orgConfig overrides definitionjson
27
+ * @param clientSecret OAuth client secret of personal connected app
28
+ */
29
+ export interface ScratchOrgCreateOptions {
30
+ hubOrg: Org;
31
+ connectedAppConsumerKey?: string;
32
+ durationDays?: number;
33
+ nonamespace?: boolean;
34
+ noancestors?: boolean;
35
+ wait?: Duration;
36
+ retry?: number;
37
+ apiversion?: string;
38
+ definitionjson?: string;
39
+ definitionfile?: string;
40
+ orgConfig?: Record<string, unknown>;
41
+ clientSecret?: string;
42
+ }
43
+ export declare const scratchOrgCreate: (options: ScratchOrgCreateOptions) => Promise<ScratchOrgCreateResult>;