@salesforce/core 3.7.4 → 4.0.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/lib/config/configStore.js +2 -1
  3. package/lib/config/envVars.d.ts +20 -5
  4. package/lib/config/envVars.js +70 -5
  5. package/lib/crypto/keyChainImpl.js +0 -1
  6. package/lib/exported.d.ts +4 -2
  7. package/lib/exported.js +5 -1
  8. package/lib/lifecycleEvents.js +1 -1
  9. package/lib/logger.js +0 -1
  10. package/lib/org/authInfo.js +2 -3
  11. package/lib/org/connection.d.ts +6 -1
  12. package/lib/org/connection.js +13 -0
  13. package/lib/org/org.d.ts +12 -2
  14. package/lib/org/org.js +39 -36
  15. package/lib/org/scratchOrgCreate.d.ts +43 -0
  16. package/lib/org/scratchOrgCreate.js +142 -0
  17. package/lib/org/scratchOrgErrorCodes.d.ts +4 -0
  18. package/lib/org/scratchOrgErrorCodes.js +62 -0
  19. package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
  20. package/lib/org/scratchOrgFeatureDeprecation.js +110 -0
  21. package/lib/org/scratchOrgInfoApi.d.ts +94 -0
  22. package/lib/org/scratchOrgInfoApi.js +350 -0
  23. package/lib/org/scratchOrgInfoGenerator.d.ts +63 -0
  24. package/lib/org/scratchOrgInfoGenerator.js +223 -0
  25. package/lib/org/scratchOrgSettingsGenerator.d.ts +56 -0
  26. package/lib/org/scratchOrgSettingsGenerator.js +210 -0
  27. package/lib/org/user.js +4 -3
  28. package/lib/status/pollingClient.d.ts +2 -2
  29. package/lib/status/pollingClient.js +8 -2
  30. package/lib/status/streamingClient.d.ts +1 -1
  31. package/lib/util/jsonXmlTools.d.ts +14 -0
  32. package/lib/util/jsonXmlTools.js +41 -0
  33. package/lib/util/mapKeys.d.ts +14 -0
  34. package/lib/util/mapKeys.js +48 -0
  35. package/lib/util/zipWriter.d.ts +14 -0
  36. package/lib/util/zipWriter.js +68 -0
  37. package/lib/webOAuthServer.js +1 -1
  38. package/messages/envVars.md +53 -13
  39. package/messages/org.md +4 -0
  40. package/messages/scratchOrgCreate.md +27 -0
  41. package/messages/scratchOrgErrorCodes.md +99 -0
  42. package/messages/scratchOrgFeatureDeprecation.md +11 -0
  43. package/messages/scratchOrgInfoApi.md +11 -0
  44. package/messages/scratchOrgInfoGenerator.md +19 -0
  45. package/messages/user.md +4 -0
  46. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,221 @@
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
+ ## [4.0.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v4.0.0) (2022-02-28)
6
+
7
+ ### Bug Fixes
8
+
9
+ - work through conflicts, UTs, pushing for comparison ([476c6fe](https://github.com/forcedotcom/sfdx-core/commit/476c6fe13514903ac97f7def2aba39b070ee2c33))
10
+
11
+ ### [3.7.5](https://github.com/forcedotcom/sfdx-core/compare/v2.35.1...v3.7.5) (2022-02-14)
12
+
13
+ ### Bug Fixes
14
+
15
+ - 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))
16
+
17
+ ### [3.7.4](https://github.com/forcedotcom/sfdx-core/compare/v2.35.0...v3.7.4) (2022-02-07)
18
+
19
+ ### Bug Fixes
20
+
21
+ - 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))
22
+
23
+ ### [3.7.3](https://github.com/forcedotcom/sfdx-core/compare/v2.33.1...v3.7.3) (2021-12-16)
24
+
25
+ ### [3.7.2](https://github.com/forcedotcom/sfdx-core/compare/v3.7.1...v3.7.2) (2021-10-28)
26
+
27
+ ### Bug Fixes
28
+
29
+ - make @types/sfdx-faye a dependendcy ([683680b](https://github.com/forcedotcom/sfdx-core/commit/683680b8133048f71d25ef4df7aa24d9700dc5e8))
30
+
31
+ ### [3.7.1](https://github.com/forcedotcom/sfdx-core/compare/v2.28.2...v3.7.1) (2021-10-28)
32
+
33
+ ## [3.7.0](https://github.com/forcedotcom/sfdx-core/compare/v3.6.6...v3.7.0) (2021-10-12)
34
+
35
+ ### Features
36
+
37
+ - use jsforce v2 ([#457](https://github.com/forcedotcom/sfdx-core/issues/457)) ([4a9094e](https://github.com/forcedotcom/sfdx-core/commit/4a9094e958288cdcc6c69f5d87b10a70a437d8e9))
38
+
39
+ ### [3.6.6](https://github.com/forcedotcom/sfdx-core/compare/v2.28.1...v3.6.6) (2021-10-08)
40
+
41
+ ### [3.6.5](https://github.com/forcedotcom/sfdx-core/compare/v3.6.4...v3.6.5) (2021-09-29)
42
+
43
+ ### Bug Fixes
44
+
45
+ - add getValue to AliasAccessor ([c4b69f5](https://github.com/forcedotcom/sfdx-core/commit/c4b69f5ff38547fad640c64833291fe0c6e06a79))
46
+
47
+ ### [3.6.4](https://github.com/forcedotcom/sfdx-core/compare/v3.6.3...v3.6.4) (2021-09-23)
48
+
49
+ ### Bug Fixes
50
+
51
+ - edit the env var blurbs ([#482](https://github.com/forcedotcom/sfdx-core/issues/482)) ([bbbdb6d](https://github.com/forcedotcom/sfdx-core/commit/bbbdb6d0800015e94ce0f0c551eec8ed73dd87c6))
52
+
53
+ ### [3.6.3](https://github.com/forcedotcom/sfdx-core/compare/v3.6.2...v3.6.3) (2021-09-23)
54
+
55
+ ### Bug Fixes
56
+
57
+ - edit the config var blurbs ([#480](https://github.com/forcedotcom/sfdx-core/issues/480)) ([f845512](https://github.com/forcedotcom/sfdx-core/commit/f8455121bfd96f27495bc124dc06570632dfce70))
58
+
59
+ ### [3.6.2](https://github.com/forcedotcom/sfdx-core/compare/v2.28.0...v3.6.2) (2021-09-17)
60
+
61
+ ### Bug Fixes
62
+
63
+ - 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))
64
+
65
+ ### [3.6.1](https://github.com/forcedotcom/sfdx-core/compare/v3.6.0...v3.6.1) (2021-09-13)
66
+
67
+ ### Bug Fixes
68
+
69
+ - remove tokens associated with org ([#477](https://github.com/forcedotcom/sfdx-core/issues/477)) ([5034fa2](https://github.com/forcedotcom/sfdx-core/commit/5034fa2d4c52d347c00499e137a71366e4feba7f))
70
+
71
+ ## [3.6.0](https://github.com/forcedotcom/sfdx-core/compare/v3.5.0...v3.6.0) (2021-09-10)
72
+
73
+ ### Features
74
+
75
+ - add help section helper ([#474](https://github.com/forcedotcom/sfdx-core/issues/474)) ([b34c2d7](https://github.com/forcedotcom/sfdx-core/commit/b34c2d7a442aed2cf091fd394a7c3656287d1dbf))
76
+
77
+ ## [3.5.0](https://github.com/forcedotcom/sfdx-core/compare/v3.4.5...v3.5.0) (2021-09-09)
78
+
79
+ ### Features
80
+
81
+ - 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))
82
+
83
+ ### [3.4.5](https://github.com/forcedotcom/sfdx-core/compare/v3.4.4...v3.4.5) (2021-09-03)
84
+
85
+ ### Bug Fixes
86
+
87
+ - provide the correct options to SfdxConfig ([fa2117e](https://github.com/forcedotcom/sfdx-core/commit/fa2117e12d7a903f26067bdcf35d7ec9c142101e))
88
+
89
+ ### [3.4.4](https://github.com/forcedotcom/sfdx-core/compare/v3.4.3...v3.4.4) (2021-09-03)
90
+
91
+ ### [3.4.3](https://github.com/forcedotcom/sfdx-core/compare/v3.4.2...v3.4.3) (2021-08-26)
92
+
93
+ ### [3.4.2](https://github.com/forcedotcom/sfdx-core/compare/v3.4.1...v3.4.2) (2021-08-17)
94
+
95
+ ### Bug Fixes
96
+
97
+ - improve interoperability when unsetting ([#467](https://github.com/forcedotcom/sfdx-core/issues/467)) ([ad781d5](https://github.com/forcedotcom/sfdx-core/commit/ad781d5378652dfd64ccb476c11f418e940b8669))
98
+
99
+ ### [3.4.1](https://github.com/forcedotcom/sfdx-core/compare/v3.4.0...v3.4.1) (2021-08-11)
100
+
101
+ ### Bug Fixes
102
+
103
+ - 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))
104
+
105
+ ## [3.4.0](https://github.com/forcedotcom/sfdx-core/compare/v3.3.12...v3.4.0) (2021-08-11)
106
+
107
+ ### Features
108
+
109
+ - config interoperability ([#461](https://github.com/forcedotcom/sfdx-core/issues/461)) ([11b60ad](https://github.com/forcedotcom/sfdx-core/commit/11b60adbe54acc8e16a90327c77abbe2613fbaab))
110
+
111
+ ### [3.3.12](https://github.com/forcedotcom/sfdx-core/compare/v2.27.2...v3.3.12) (2021-08-10)
112
+
113
+ ### Bug Fixes
114
+
115
+ - add predicate function to list all auths ([ccdb02c](https://github.com/forcedotcom/sfdx-core/commit/ccdb02c268fae7532b23e0c791bcdd831f77cf98))
116
+
117
+ ### [3.3.11](https://github.com/forcedotcom/sfdx-core/compare/v3.3.10...v3.3.11) (2021-08-04)
118
+
119
+ ### Bug Fixes
120
+
121
+ - 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))
122
+
123
+ ### [3.3.10](https://github.com/forcedotcom/sfdx-core/compare/v3.3.9...v3.3.10) (2021-08-04)
124
+
125
+ ### [3.3.9](https://github.com/forcedotcom/sfdx-core/compare/v3.3.8...v3.3.9) (2021-08-04)
126
+
127
+ ### Bug Fixes
128
+
129
+ - merge main(v2) into v3 ([#452](https://github.com/forcedotcom/sfdx-core/issues/452)) ([3a003b9](https://github.com/forcedotcom/sfdx-core/commit/3a003b9c17962f77344e4a23314bb608e1ae50db))
130
+
131
+ ### [3.3.8](https://github.com/forcedotcom/sfdx-core/compare/v3.3.7...v3.3.8) (2021-08-02)
132
+
133
+ ### Bug Fixes
134
+
135
+ - return all info from AuthInfo.listAllAuthorizations ([#449](https://github.com/forcedotcom/sfdx-core/issues/449)) ([17e60ea](https://github.com/forcedotcom/sfdx-core/commit/17e60eabe87c73a83c26344967076f365ddea81c))
136
+
137
+ ### [3.3.7](https://github.com/forcedotcom/sfdx-core/compare/v2.27.0...v3.3.7) (2021-07-30)
138
+
139
+ ### [3.3.6](https://github.com/forcedotcom/sfdx-core/compare/v3.3.5...v3.3.6) (2021-07-28)
140
+
141
+ ### Bug Fixes
142
+
143
+ - use correct method to get username ([#446](https://github.com/forcedotcom/sfdx-core/issues/446)) ([79a6b2f](https://github.com/forcedotcom/sfdx-core/commit/79a6b2f069f95b0c50a6c03ecbac07cf0d1832b1))
144
+
145
+ ### [3.3.5](https://github.com/forcedotcom/sfdx-core/compare/v3.3.4...v3.3.5) (2021-07-28)
146
+
147
+ ### [3.3.4](https://github.com/forcedotcom/sfdx-core/compare/v3.3.3...v3.3.4) (2021-07-26)
148
+
149
+ ### Bug Fixes
150
+
151
+ - remove bad validator function ([1b97dc6](https://github.com/forcedotcom/sfdx-core/commit/1b97dc6f4d657a5b86489d33c4843ebfd54b3715))
152
+
153
+ ### [3.3.3](https://github.com/forcedotcom/sfdx-core/compare/v3.3.2...v3.3.3) (2021-07-22)
154
+
155
+ ### Bug Fixes
156
+
157
+ - write sf.json contents on init ([c47f649](https://github.com/forcedotcom/sfdx-core/commit/c47f64954118d0d2f7f4a8e992d3450516239084))
158
+
159
+ ### [3.3.2](https://github.com/forcedotcom/sfdx-core/compare/v2.26.1...v3.3.2) (2021-07-21)
160
+
161
+ ### Bug Fixes
162
+
163
+ - correct jsdoc ([a362e94](https://github.com/forcedotcom/sfdx-core/commit/a362e94c4ae7538cbbcd7dae8fcd3244629d845c))
164
+
165
+ ### [3.3.1](https://github.com/forcedotcom/sfdx-core/compare/v3.3.0...v3.3.1) (2021-07-15)
166
+
167
+ ### Bug Fixes
168
+
169
+ - temporarily point Alias back to .sfdx ([#438](https://github.com/forcedotcom/sfdx-core/issues/438)) ([4bffcd8](https://github.com/forcedotcom/sfdx-core/commit/4bffcd84362d5b3049ef428e90dc1b538a435f81))
170
+
171
+ ## [3.3.0](https://github.com/forcedotcom/sfdx-core/compare/v3.2.0-v3.0...v3.3.0) (2021-07-14)
172
+
173
+ ### Features
174
+
175
+ - 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)
176
+
177
+ ## [3.2.0-v3.0](https://github.com/forcedotcom/sfdx-core/compare/v2.26.0...v3.2.0-v3.0) (2021-07-14)
178
+
179
+ ### Features
180
+
181
+ - use .sf/config.json @W-9546117@ ([#433](https://github.com/forcedotcom/sfdx-core/issues/433)) ([6c41653](https://github.com/forcedotcom/sfdx-core/commit/6c416531a9bae10e855ded3efc289a99196bc26b))
182
+
183
+ ### [3.1.1-v3.2](https://github.com/forcedotcom/sfdx-core/compare/v2.24.2...v3.1.1-v3.2) (2021-06-29)
184
+
185
+ ### Bug Fixes
186
+
187
+ - do not use function prop ([#426](https://github.com/forcedotcom/sfdx-core/issues/426)) ([39efe0c](https://github.com/forcedotcom/sfdx-core/commit/39efe0ccc84b05bc891e54b24bfcddc62790ae0e))
188
+
189
+ ### [3.1.1-v3.1](https://github.com/forcedotcom/sfdx-core/compare/v2.24.0...v3.1.1-v3.1) (2021-06-14)
190
+
191
+ ### Bug Fixes
192
+
193
+ - keep track of auth changes ([210be6c](https://github.com/forcedotcom/sfdx-core/commit/210be6cb408bd9ecc861989570df0e14f6a3a566))
194
+
195
+ ### [3.1.1-v3.0](https://github.com/forcedotcom/sfdx-core/compare/v2.23.3...v3.1.1-v3.0) (2021-06-03)
196
+
197
+ ### ⚠ BREAKING CHANGES
198
+
199
+ - default to reading files from cache
200
+
201
+ ### Features
202
+
203
+ - add GlobalInfo config file ([#397](https://github.com/forcedotcom/sfdx-core/issues/397)) ([889425c](https://github.com/forcedotcom/sfdx-core/commit/889425c06e8ed6a364d9a2bc3dd5ef0a38a66046))
204
+ - add message support for markdown files ([0f235a2](https://github.com/forcedotcom/sfdx-core/commit/0f235a23d5dddbd7b3f07544d8c7e380875c6c55))
205
+ - default to reading files from cache ([558319d](https://github.com/forcedotcom/sfdx-core/commit/558319dfdc81e2bae549d58be75a701162801994))
206
+ - 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))
207
+
208
+ ### Bug Fixes
209
+
210
+ - compilation errors ([33a9876](https://github.com/forcedotcom/sfdx-core/commit/33a9876575eff7944bb287d428f52413831725d9))
211
+ - unit test failures ([4507575](https://github.com/forcedotcom/sfdx-core/commit/45075754175d411b6cb71eb809096e6eb3e23d95))
212
+ - unsetAuthorization ([#399](https://github.com/forcedotcom/sfdx-core/issues/399)) ([dd57438](https://github.com/forcedotcom/sfdx-core/commit/dd57438a95b49515f560d3b915cdf916a4b8643b))
213
+
214
+ ### [3.7.5](https://github.com/forcedotcom/sfdx-core/compare/v3.7.4...v3.7.5) (2022-02-14)
215
+
216
+ ### Bug Fixes
217
+
218
+ - 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))
219
+
5
220
  ### [3.7.4](https://github.com/forcedotcom/sfdx-core/compare/v3.7.3...v3.7.4) (2022-02-07)
6
221
 
7
222
  ### 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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Dictionary, Nullable } from '@salesforce/ts-types';
2
3
  import { Env } from '@salesforce/kit';
3
4
  export declare enum EnvironmentVariable {
@@ -35,6 +36,11 @@ export declare enum EnvironmentVariable {
35
36
  'SFDX_SOURCE_MEMBER_POLLING_TIMEOUT' = "SFDX_SOURCE_MEMBER_POLLING_TIMEOUT",
36
37
  'SFDX_USE_GENERIC_UNIX_KEYCHAIN' = "SFDX_USE_GENERIC_UNIX_KEYCHAIN",
37
38
  'SFDX_USE_PROGRESS_BAR' = "SFDX_USE_PROGRESS_BAR",
39
+ 'SFDX_LAZY_LOAD_MODULES' = "SFDX_LAZY_LOAD_MODULES",
40
+ 'SFDX_S3_HOST' = "SFDX_S3_HOST",
41
+ 'SFDX_UPDATE_INSTRUCTIONS' = "SFDX_UPDATE_INSTRUCTIONS",
42
+ 'SFDX_INSTALLER' = "SFDX_INSTALLER",
43
+ 'SFDX_ENV' = "SFDX_ENV",
38
44
  'SF_TARGET_ORG' = "SF_TARGET_ORG",
39
45
  'SF_TARGET_DEV_HUB' = "SF_TARGET_DEV_HUB",
40
46
  'SF_ACCESS_TOKEN' = "SF_ACCESS_TOKEN",
@@ -60,7 +66,12 @@ export declare enum EnvironmentVariable {
60
66
  'SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE' = "SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE",
61
67
  'SF_SOURCE_MEMBER_POLLING_TIMEOUT' = "SF_SOURCE_MEMBER_POLLING_TIMEOUT",
62
68
  'SF_USE_GENERIC_UNIX_KEYCHAIN' = "SF_USE_GENERIC_UNIX_KEYCHAIN",
63
- 'SF_USE_PROGRESS_BAR' = "SF_USE_PROGRESS_BAR"
69
+ 'SF_USE_PROGRESS_BAR' = "SF_USE_PROGRESS_BAR",
70
+ 'SF_LAZY_LOAD_MODULES' = "SF_LAZY_LOAD_MODULES",
71
+ 'SF_S3_HOST' = "SF_S3_HOST",
72
+ 'SF_UPDATE_INSTRUCTIONS' = "SF_UPDATE_INSTRUCTIONS",
73
+ 'SF_INSTALLER' = "SF_INSTALLER",
74
+ 'SF_ENV' = "SF_ENV"
64
75
  }
65
76
  declare type EnvMetaData = {
66
77
  description: string;
@@ -71,11 +82,15 @@ declare type EnvType = {
71
82
  };
72
83
  export declare const SUPPORTED_ENV_VARS: EnvType;
73
84
  export declare class EnvVars extends Env {
74
- constructor();
75
- propertyToEnvName(property: string, prefix?: string): string;
76
- setPropertyFromEnv(property: string, prefix?: string): void;
77
- asDictionary(): Dictionary<string>;
85
+ constructor(env?: NodeJS.ProcessEnv);
86
+ private static defaultPrefix;
87
+ propertyToEnvName(property: string, prefix?: string | undefined): string;
88
+ setPropertyFromEnv(property: string, prefix?: string | undefined): void;
89
+ getPropertyFromEnv<T>(property: string, prefix?: string | undefined): T | undefined;
90
+ asDictionary(): Dictionary<unknown>;
78
91
  asMap(): Map<string, string>;
79
92
  private resolve;
93
+ private get;
80
94
  }
95
+ export declare const envVars: EnvVars;
81
96
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = void 0;
3
+ exports.envVars = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = void 0;
4
4
  /*
5
5
  * Copyright (c) 2020, salesforce.com, inc.
6
6
  * All rights reserved.
@@ -50,6 +50,11 @@ var EnvironmentVariable;
50
50
  EnvironmentVariable["SFDX_SOURCE_MEMBER_POLLING_TIMEOUT"] = "SFDX_SOURCE_MEMBER_POLLING_TIMEOUT";
51
51
  EnvironmentVariable["SFDX_USE_GENERIC_UNIX_KEYCHAIN"] = "SFDX_USE_GENERIC_UNIX_KEYCHAIN";
52
52
  EnvironmentVariable["SFDX_USE_PROGRESS_BAR"] = "SFDX_USE_PROGRESS_BAR";
53
+ EnvironmentVariable["SFDX_LAZY_LOAD_MODULES"] = "SFDX_LAZY_LOAD_MODULES";
54
+ EnvironmentVariable["SFDX_S3_HOST"] = "SFDX_S3_HOST";
55
+ EnvironmentVariable["SFDX_UPDATE_INSTRUCTIONS"] = "SFDX_UPDATE_INSTRUCTIONS";
56
+ EnvironmentVariable["SFDX_INSTALLER"] = "SFDX_INSTALLER";
57
+ EnvironmentVariable["SFDX_ENV"] = "SFDX_ENV";
53
58
  EnvironmentVariable["SF_TARGET_ORG"] = "SF_TARGET_ORG";
54
59
  EnvironmentVariable["SF_TARGET_DEV_HUB"] = "SF_TARGET_DEV_HUB";
55
60
  EnvironmentVariable["SF_ACCESS_TOKEN"] = "SF_ACCESS_TOKEN";
@@ -76,6 +81,11 @@ var EnvironmentVariable;
76
81
  EnvironmentVariable["SF_SOURCE_MEMBER_POLLING_TIMEOUT"] = "SF_SOURCE_MEMBER_POLLING_TIMEOUT";
77
82
  EnvironmentVariable["SF_USE_GENERIC_UNIX_KEYCHAIN"] = "SF_USE_GENERIC_UNIX_KEYCHAIN";
78
83
  EnvironmentVariable["SF_USE_PROGRESS_BAR"] = "SF_USE_PROGRESS_BAR";
84
+ EnvironmentVariable["SF_LAZY_LOAD_MODULES"] = "SF_LAZY_LOAD_MODULES";
85
+ EnvironmentVariable["SF_S3_HOST"] = "SF_S3_HOST";
86
+ EnvironmentVariable["SF_UPDATE_INSTRUCTIONS"] = "SF_UPDATE_INSTRUCTIONS";
87
+ EnvironmentVariable["SF_INSTALLER"] = "SF_INSTALLER";
88
+ EnvironmentVariable["SF_ENV"] = "SF_ENV";
79
89
  })(EnvironmentVariable = exports.EnvironmentVariable || (exports.EnvironmentVariable = {}));
80
90
  const getMessage = (environmentVariable) => messages.getMessage((0, change_case_1.camelCase)(environmentVariable));
81
91
  exports.SUPPORTED_ENV_VARS = {
@@ -216,6 +226,26 @@ exports.SUPPORTED_ENV_VARS = {
216
226
  description: getMessage(EnvironmentVariable.SFDX_USE_PROGRESS_BAR),
217
227
  synonymOf: EnvironmentVariable.SF_USE_PROGRESS_BAR,
218
228
  },
229
+ [EnvironmentVariable.SFDX_LAZY_LOAD_MODULES]: {
230
+ description: getMessage(EnvironmentVariable.SFDX_USE_PROGRESS_BAR),
231
+ synonymOf: EnvironmentVariable.SF_LAZY_LOAD_MODULES,
232
+ },
233
+ [EnvironmentVariable.SFDX_S3_HOST]: {
234
+ description: getMessage(EnvironmentVariable.SFDX_S3_HOST),
235
+ synonymOf: EnvironmentVariable.SF_S3_HOST,
236
+ },
237
+ [EnvironmentVariable.SFDX_UPDATE_INSTRUCTIONS]: {
238
+ description: getMessage(EnvironmentVariable.SFDX_UPDATE_INSTRUCTIONS),
239
+ synonymOf: null,
240
+ },
241
+ [EnvironmentVariable.SFDX_INSTALLER]: {
242
+ description: getMessage(EnvironmentVariable.SFDX_INSTALLER),
243
+ synonymOf: null,
244
+ },
245
+ [EnvironmentVariable.SFDX_ENV]: {
246
+ description: getMessage(EnvironmentVariable.SFDX_ENV),
247
+ synonymOf: null,
248
+ },
219
249
  [EnvironmentVariable.SF_TARGET_ORG]: {
220
250
  description: getMessage(EnvironmentVariable.SF_TARGET_ORG),
221
251
  synonymOf: null,
@@ -321,22 +351,53 @@ exports.SUPPORTED_ENV_VARS = {
321
351
  description: getMessage(EnvironmentVariable.SF_USE_PROGRESS_BAR),
322
352
  synonymOf: null,
323
353
  },
354
+ [EnvironmentVariable.SF_LAZY_LOAD_MODULES]: {
355
+ description: getMessage(EnvironmentVariable.SF_LAZY_LOAD_MODULES),
356
+ synonymOf: null,
357
+ },
358
+ [EnvironmentVariable.SF_S3_HOST]: {
359
+ description: getMessage(EnvironmentVariable.SF_S3_HOST),
360
+ synonymOf: null,
361
+ },
362
+ [EnvironmentVariable.SF_UPDATE_INSTRUCTIONS]: {
363
+ description: getMessage(EnvironmentVariable.SF_UPDATE_INSTRUCTIONS),
364
+ synonymOf: null,
365
+ },
366
+ [EnvironmentVariable.SF_INSTALLER]: {
367
+ description: getMessage(EnvironmentVariable.SF_INSTALLER),
368
+ synonymOf: null,
369
+ },
370
+ [EnvironmentVariable.SF_ENV]: {
371
+ description: getMessage(EnvironmentVariable.SF_ENV),
372
+ synonymOf: null,
373
+ },
324
374
  };
325
375
  class EnvVars extends kit_1.Env {
326
- constructor() {
327
- super();
376
+ constructor(env = process.env) {
377
+ super(env);
328
378
  this.resolve();
329
379
  }
330
- propertyToEnvName(property, prefix = 'SFDX_') {
380
+ static defaultPrefix() {
381
+ if (process.argv[0].startsWith('sfdx'))
382
+ return 'SFDX_';
383
+ if (process.argv[0].startsWith('sf'))
384
+ return 'SF_';
385
+ return 'SFDX_';
386
+ }
387
+ propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
331
388
  return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
332
389
  }
333
- setPropertyFromEnv(property, prefix = 'SFDX_') {
390
+ setPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
334
391
  const envName = this.propertyToEnvName(property, prefix);
335
392
  const value = this.getString(envName);
336
393
  if (value) {
337
394
  this.setString(property, value);
338
395
  }
339
396
  }
397
+ getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
398
+ const envName = this.propertyToEnvName(property, prefix);
399
+ return this.get(envName);
400
+ }
340
401
  asDictionary() {
341
402
  return this.entries().reduce((accumulator, [key, value]) => {
342
403
  accumulator[key] = value;
@@ -363,6 +424,10 @@ class EnvVars extends kit_1.Env {
363
424
  }
364
425
  });
365
426
  }
427
+ get(envName) {
428
+ return this.asDictionary()[envName];
429
+ }
366
430
  }
367
431
  exports.EnvVars = EnvVars;
432
+ exports.envVars = new EnvVars();
368
433
  //# sourceMappingURL=envVars.js.map
@@ -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
@@ -1,6 +1,6 @@
1
1
  export { OAuth2Config } from 'jsforce';
2
2
  export { ConfigFile } from './config/configFile';
3
- export { EnvironmentVariable, SUPPORTED_ENV_VARS } from './config/envVars';
3
+ export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
4
4
  export { BaseConfigStore, ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
5
5
  export { GlobalInfo, SfEntry, SfInfo, SfInfoKeys, SfOrg, SfOrgs, SfToken, SfTokens } from './globalInfo';
6
6
  export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } from './deviceOauthService';
@@ -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,14 +16,16 @@ 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.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = 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");
23
23
  Object.defineProperty(exports, "ConfigFile", { enumerable: true, get: function () { return configFile_1.ConfigFile; } });
24
24
  var envVars_1 = require("./config/envVars");
25
+ Object.defineProperty(exports, "envVars", { enumerable: true, get: function () { return envVars_1.envVars; } });
25
26
  Object.defineProperty(exports, "EnvironmentVariable", { enumerable: true, get: function () { return envVars_1.EnvironmentVariable; } });
26
27
  Object.defineProperty(exports, "SUPPORTED_ENV_VARS", { enumerable: true, get: function () { return envVars_1.SUPPORTED_ENV_VARS; } });
28
+ Object.defineProperty(exports, "EnvVars", { enumerable: true, get: function () { return envVars_1.EnvVars; } });
27
29
  var configStore_1 = require("./config/configStore");
28
30
  Object.defineProperty(exports, "BaseConfigStore", { enumerable: true, get: function () { return configStore_1.BaseConfigStore; } });
29
31
  var globalInfo_1 = require("./globalInfo");
@@ -91,6 +93,8 @@ Object.defineProperty(exports, "REQUIRED_FIELDS", { enumerable: true, get: funct
91
93
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
92
94
  var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
93
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; } });
94
98
  // Utility sub-modules
95
99
  __exportStar(require("./util/fs"), exports);
96
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
  *