@salesforce/core 4.0.0 → 4.1.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 (151) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +93 -44
  3. package/lib/config/authInfoConfig.d.ts +19 -0
  4. package/lib/config/authInfoConfig.js +35 -0
  5. package/lib/config/config.d.ts +87 -22
  6. package/lib/config/config.js +117 -65
  7. package/lib/config/configAggregator.d.ts +41 -35
  8. package/lib/config/configAggregator.js +102 -73
  9. package/lib/config/configFile.d.ts +2 -2
  10. package/lib/config/configFile.js +38 -29
  11. package/lib/config/configStore.d.ts +9 -9
  12. package/lib/config/configStore.js +17 -15
  13. package/lib/config/envVars.d.ts +15 -9
  14. package/lib/config/envVars.js +71 -47
  15. package/lib/config/orgUsersConfig.js +2 -0
  16. package/lib/config/sandboxOrgConfig.js +2 -0
  17. package/lib/config/sandboxProcessCache.d.ts +16 -0
  18. package/lib/config/sandboxProcessCache.js +38 -0
  19. package/lib/config/tokensConfig.d.ts +10 -0
  20. package/lib/config/tokensConfig.js +29 -0
  21. package/lib/config/ttlConfig.d.ts +34 -0
  22. package/lib/config/ttlConfig.js +50 -0
  23. package/lib/crypto/crypto.js +15 -22
  24. package/lib/crypto/keyChain.js +2 -3
  25. package/lib/crypto/keyChainImpl.d.ts +5 -3
  26. package/lib/crypto/keyChainImpl.js +58 -61
  27. package/lib/crypto/secureBuffer.d.ts +1 -1
  28. package/lib/deviceOauthService.d.ts +3 -3
  29. package/lib/deviceOauthService.js +27 -25
  30. package/lib/exported.d.ts +15 -12
  31. package/lib/exported.js +28 -16
  32. package/lib/global.d.ts +11 -3
  33. package/lib/global.js +39 -12
  34. package/lib/lifecycleEvents.d.ts +1 -1
  35. package/lib/lifecycleEvents.js +3 -0
  36. package/lib/logger.d.ts +19 -9
  37. package/lib/logger.js +112 -86
  38. package/lib/messages.d.ts +53 -36
  39. package/lib/messages.js +81 -91
  40. package/lib/org/authInfo.d.ts +56 -20
  41. package/lib/org/authInfo.js +232 -131
  42. package/lib/org/authRemover.d.ts +8 -7
  43. package/lib/org/authRemover.js +32 -28
  44. package/lib/org/connection.d.ts +13 -37
  45. package/lib/org/connection.js +78 -124
  46. package/lib/org/index.js +5 -1
  47. package/lib/org/org.d.ts +151 -48
  48. package/lib/org/org.js +468 -225
  49. package/lib/org/orgConfigProperties.d.ts +64 -3
  50. package/lib/org/orgConfigProperties.js +96 -4
  51. package/lib/org/permissionSetAssignment.js +4 -13
  52. package/lib/org/scratchOrgCache.d.ts +20 -0
  53. package/lib/org/scratchOrgCache.js +33 -0
  54. package/lib/org/scratchOrgCreate.d.ts +28 -17
  55. package/lib/org/scratchOrgCreate.js +125 -53
  56. package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
  57. package/lib/org/scratchOrgErrorCodes.js +34 -17
  58. package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
  59. package/lib/org/scratchOrgInfoApi.d.ts +21 -47
  60. package/lib/org/scratchOrgInfoApi.js +129 -63
  61. package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
  62. package/lib/org/scratchOrgInfoGenerator.js +76 -62
  63. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
  64. package/lib/org/scratchOrgLifecycleEvents.js +41 -0
  65. package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
  66. package/lib/org/scratchOrgSettingsGenerator.js +165 -98
  67. package/lib/org/scratchOrgTypes.d.ts +43 -0
  68. package/lib/org/scratchOrgTypes.js +9 -0
  69. package/lib/org/user.d.ts +1 -1
  70. package/lib/org/user.js +25 -34
  71. package/lib/schema/printer.d.ts +6 -0
  72. package/lib/schema/printer.js +34 -31
  73. package/lib/schema/validator.d.ts +12 -10
  74. package/lib/schema/validator.js +56 -76
  75. package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
  76. package/lib/{sfdxError.js → sfError.js} +40 -30
  77. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
  78. package/lib/sfProject.js +651 -0
  79. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +129 -0
  80. package/lib/stateAggregator/accessors/aliasAccessor.js +263 -0
  81. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
  82. package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
  83. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
  84. package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
  85. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
  86. package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
  87. package/lib/stateAggregator/index.d.ts +4 -0
  88. package/lib/stateAggregator/index.js +27 -0
  89. package/lib/stateAggregator/stateAggregator.d.ts +25 -0
  90. package/lib/stateAggregator/stateAggregator.js +46 -0
  91. package/lib/status/myDomainResolver.d.ts +1 -1
  92. package/lib/status/myDomainResolver.js +4 -4
  93. package/lib/status/pollingClient.js +4 -4
  94. package/lib/status/streamingClient.d.ts +2 -2
  95. package/lib/status/streamingClient.js +58 -63
  96. package/lib/status/types.d.ts +2 -2
  97. package/lib/testSetup.d.ts +204 -75
  98. package/lib/testSetup.js +468 -164
  99. package/lib/util/cache.d.ts +2 -2
  100. package/lib/util/cache.js +6 -6
  101. package/lib/util/checkLightningDomain.js +3 -4
  102. package/lib/util/directoryWriter.d.ts +12 -0
  103. package/lib/util/directoryWriter.js +54 -0
  104. package/lib/util/getJwtAudienceUrl.js +1 -1
  105. package/lib/util/internal.d.ts +28 -2
  106. package/lib/util/internal.js +65 -8
  107. package/lib/util/jsonXmlTools.js +2 -4
  108. package/lib/util/mapKeys.d.ts +9 -9
  109. package/lib/util/mapKeys.js +13 -9
  110. package/lib/util/sfdc.d.ts +51 -51
  111. package/lib/util/sfdc.js +74 -79
  112. package/lib/util/sfdcUrl.d.ts +5 -19
  113. package/lib/util/sfdcUrl.js +40 -49
  114. package/lib/util/structuredWriter.d.ts +9 -0
  115. package/lib/util/structuredWriter.js +3 -0
  116. package/lib/util/zipWriter.d.ts +8 -6
  117. package/lib/util/zipWriter.js +13 -13
  118. package/lib/webOAuthServer.d.ts +20 -6
  119. package/lib/webOAuthServer.js +102 -56
  120. package/messageTransformer/messageTransformer.ts +93 -0
  121. package/messages/auth.md +9 -1
  122. package/messages/config.md +42 -6
  123. package/messages/connection.md +8 -0
  124. package/messages/core.md +10 -0
  125. package/messages/envVars.md +37 -3
  126. package/messages/org.md +21 -1
  127. package/messages/scratchOrgCreate.md +2 -6
  128. package/messages/scratchOrgErrorCodes.md +17 -1
  129. package/messages/scratchOrgInfoApi.md +9 -0
  130. package/messages/scratchOrgInfoGenerator.md +9 -1
  131. package/package.json +123 -46
  132. package/CHANGELOG.md +0 -1244
  133. package/lib/config/keychainConfig.d.ts +0 -19
  134. package/lib/config/keychainConfig.js +0 -43
  135. package/lib/globalInfo/accessors/aliasAccessor.d.ts +0 -83
  136. package/lib/globalInfo/accessors/aliasAccessor.js +0 -130
  137. package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
  138. package/lib/globalInfo/accessors/orgAccessor.js +0 -45
  139. package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
  140. package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
  141. package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
  142. package/lib/globalInfo/globalInfoConfig.js +0 -105
  143. package/lib/globalInfo/index.d.ts +0 -6
  144. package/lib/globalInfo/index.js +0 -29
  145. package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
  146. package/lib/globalInfo/sfdxDataHandler.js +0 -217
  147. package/lib/globalInfo/types.d.ts +0 -39
  148. package/lib/globalInfo/types.js +0 -10
  149. package/lib/sfdxProject.js +0 -557
  150. package/lib/util/fs.d.ts +0 -201
  151. package/lib/util/fs.js +0 -378
@@ -6,90 +6,106 @@
6
6
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Config = exports.SfProperty = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = void 0;
9
+ exports.SfdxConfig = exports.Config = exports.SfProperty = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.SF_ALLOWED_PROPERTIES = exports.SfConfigProperties = void 0;
10
10
  const path_1 = require("path");
11
+ const fs = require("fs");
11
12
  const kit_1 = require("@salesforce/kit");
12
13
  const ts_types_1 = require("@salesforce/ts-types");
13
14
  const global_1 = require("../global");
14
15
  const logger_1 = require("../logger");
15
16
  const messages_1 = require("../messages");
16
17
  const sfdc_1 = require("../util/sfdc");
17
- const fs_1 = require("../util/fs");
18
18
  const sfdcUrl_1 = require("../util/sfdcUrl");
19
19
  const orgConfigProperties_1 = require("../org/orgConfigProperties");
20
+ const lifecycleEvents_1 = require("../lifecycleEvents");
20
21
  const configFile_1 = require("./configFile");
21
- messages_1.Messages.importMessagesDirectory(__dirname);
22
- const messages = messages_1.Messages.load('@salesforce/core', 'config', [
23
- 'deprecatedConfigKey',
24
- 'invalidApiVersion',
25
- 'invalidBooleanConfigValue',
26
- 'invalidConfigValue',
27
- 'invalidInstanceUrl',
28
- 'invalidIsvDebuggerSid',
29
- 'invalidIsvDebuggerUrl',
30
- 'invalidNumberConfigValue',
31
- 'invalidWrite',
32
- 'unknownConfigKey',
33
- 'defaultUsername',
34
- 'defaultDevHubUsername',
35
- 'isvDebuggerSid',
36
- 'isvDebuggerUrl',
37
- 'apiVersion',
38
- 'disableTelemetry',
39
- 'maxQueryLimit',
40
- 'restDeploy',
41
- 'instanceUrl',
42
- ]);
43
- const log = logger_1.Logger.childFromRoot('core:config');
22
+ const messages = new messages_1.Messages('@salesforce/core', 'config', new Map([["unknownConfigKey", "Unknown config name: %s."], ["deprecatedConfigKey", "Deprecated config name: %s. Please use %s instead."], ["invalidWrite", "The writeSync method is not allowed on SfdxConfig. Use the async write method instead."], ["invalidConfigValue", "Invalid config value: %s."], ["invalidInstanceUrl", "Specify a valid Salesforce instance URL."], ["invalidApiVersion", "Specify a valid Salesforce API version, for example, 42.0."], ["invalidCustomOrgMetadataTemplates", "Specify a valid repository URL or directory for the custom org metadata templates."], ["invalidIsvDebuggerSid", "Specify a valid Debugger SID."], ["invalidIsvDebuggerUrl", "Specify a valid Debugger URL."], ["invalidNumberConfigValue", "Specify a valid positive integer, for example, 150000."], ["invalidBooleanConfigValue", "The config value can only be set to true or false."], ["invalidProjectWorkspace", "This directory does not contain a valid Salesforce DX project."], ["schemaValidationError", "The config file \"%s\" is not schema valid.\nDue to: %s"], ["schemaValidationError.actions", ["Fix the invalid entries at %s."]], ["missingDefaultPath", "In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ \"path\": \"packageDirectory1\", \"default\": true }, { \"path\": \"packageDirectory2\" }]`"], ["missingPackageDirectory", "The path \"%s\", specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root."], ["invalidPackageDirectory", "The path \"%s\", specified in sfdx-project.json, must be indicated as a relative path to the project root."], ["multipleDefaultPaths", "In sfdx-project.json, indicate only one package directory (path) as the default."], ["singleNonDefaultPackage", "The sfdx-project.json file must include one, and only one, default package directory (path). Because your sfdx-project.json file contains only one package directory, it must be the default. Remove the `\"default\": false` key and try again."], ["target-org", "Username or alias of the org that all commands run against by default. (sf only)"], ["target-dev-hub", "Username or alias of your default Dev Hub org. (sf only)"], ["defaultUsername", "Username or alias of the org that all commands run against by default. (sfdx only)"], ["defaultDevHubUsername", "Username or alias of your default Dev Hub org. (sfdx only)"], ["isvDebuggerSid", "ISV debugger SID (sfdx only)"], ["isvDebuggerUrl", "ISV debugger URL (sfdx only)"], ["org-isv-debugger-sid", "ISV debugger SID."], ["org-isv-debugger-url", "ISV debugger URL."], ["apiVersion", "API version of your project. Default: API version of your Dev Hub org. (sfdx only)"], ["org-api-version", "API version of your project. Default: API version of your Dev Hub org."], ["disableTelemetry", "Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)"], ["disable-telemetry", "Disables the collection of usage and user environment information, etc. Default: false."], ["maxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)"], ["org-max-query-limit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000."], ["restDeploy", "Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)"], ["instanceUrl", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)"], ["org-instance-url", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com."], ["customOrgMetadataTemplates", "A valid repository URL or directory for the custom org metadata templates."], ["org-custom-metadata-templates", "A valid repository URL or directory for the custom org metadata templates."], ["invalidId", "The given id %s is not a valid 15 or 18 character Salesforce ID."]]));
44
23
  const SFDX_CONFIG_FILE_NAME = 'sfdx-config.json';
45
24
  const CONFIG_FILE_NAME = 'config.json';
25
+ var SfConfigProperties;
26
+ (function (SfConfigProperties) {
27
+ /**
28
+ * Disables telemetry reporting
29
+ */
30
+ SfConfigProperties["DISABLE_TELEMETRY"] = "disable-telemetry";
31
+ })(SfConfigProperties = exports.SfConfigProperties || (exports.SfConfigProperties = {}));
32
+ exports.SF_ALLOWED_PROPERTIES = [
33
+ {
34
+ key: SfConfigProperties.DISABLE_TELEMETRY,
35
+ description: messages.getMessage(SfConfigProperties.DISABLE_TELEMETRY),
36
+ input: {
37
+ validator: (value) => value == null || ['true', 'false'].includes(value.toString()),
38
+ failedMessage: messages.getMessage('invalidBooleanConfigValue'),
39
+ },
40
+ },
41
+ ];
46
42
  var SfdxPropertyKeys;
47
43
  (function (SfdxPropertyKeys) {
48
44
  /**
49
45
  * Username associated with the default dev hub org.
50
46
  *
51
47
  * @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
48
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
52
49
  */
53
50
  SfdxPropertyKeys["DEFAULT_DEV_HUB_USERNAME"] = "defaultdevhubusername";
54
51
  /**
55
52
  * Username associate with the default org.
56
53
  *
57
54
  * @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
55
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
58
56
  */
59
57
  SfdxPropertyKeys["DEFAULT_USERNAME"] = "defaultusername";
60
58
  /**
61
59
  * The sid for the debugger configuration.
60
+ *
61
+ * @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_SID in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
62
62
  */
63
63
  SfdxPropertyKeys["ISV_DEBUGGER_SID"] = "isvDebuggerSid";
64
64
  /**
65
65
  * The url for the debugger configuration.
66
+ *
67
+ * @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
66
68
  */
67
69
  SfdxPropertyKeys["ISV_DEBUGGER_URL"] = "isvDebuggerUrl";
68
70
  /**
69
71
  * The api version
72
+ *
73
+ * @deprecated Replaced by OrgConfigProperties.ORG_API_VERSION in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
70
74
  */
71
75
  SfdxPropertyKeys["API_VERSION"] = "apiVersion";
72
76
  /**
73
77
  * Disables telemetry reporting
78
+ *
79
+ * @deprecated Replaced by SfPropertyKeys.DISABLE_TELEMETRY in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
74
80
  */
75
81
  SfdxPropertyKeys["DISABLE_TELEMETRY"] = "disableTelemetry";
76
82
  /**
77
83
  * Custom templates repo or local location.
84
+ *
85
+ * @deprecated Replaced by OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
78
86
  */
79
87
  SfdxPropertyKeys["CUSTOM_ORG_METADATA_TEMPLATES"] = "customOrgMetadataTemplates";
80
88
  /**
81
89
  * allows users to override the 10,000 result query limit
90
+ *
91
+ * @deprecated Replaced by OrgConfigProperties.ORG_MAX_QUERY_LIMIT in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
82
92
  */
83
93
  SfdxPropertyKeys["MAX_QUERY_LIMIT"] = "maxQueryLimit";
84
- /** */
94
+ /**
95
+ * @deprecated
96
+ */
85
97
  SfdxPropertyKeys["REST_DEPLOY"] = "restDeploy";
86
- /** */
98
+ /**
99
+ * @deprecated Replaced by OrgConfigProperties.ORG_INSTANCE_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
100
+ */
87
101
  SfdxPropertyKeys["INSTANCE_URL"] = "instanceUrl";
88
102
  })(SfdxPropertyKeys = exports.SfdxPropertyKeys || (exports.SfdxPropertyKeys = {}));
89
103
  exports.SFDX_ALLOWED_PROPERTIES = [
90
104
  {
91
105
  key: SfdxPropertyKeys.INSTANCE_URL,
92
106
  description: messages.getMessage(SfdxPropertyKeys.INSTANCE_URL),
107
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_INSTANCE_URL,
108
+ deprecated: true,
93
109
  input: {
94
110
  // If a value is provided validate it otherwise no value is unset.
95
111
  validator: (value) => {
@@ -106,21 +122,25 @@ exports.SFDX_ALLOWED_PROPERTIES = [
106
122
  },
107
123
  {
108
124
  key: SfdxPropertyKeys.API_VERSION,
125
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_API_VERSION,
126
+ deprecated: true,
109
127
  description: messages.getMessage(SfdxPropertyKeys.API_VERSION),
110
128
  hidden: true,
111
129
  input: {
112
130
  // If a value is provided validate it otherwise no value is unset.
113
- validator: (value) => value == null || ((0, ts_types_1.isString)(value) && sfdc_1.sfdc.validateApiVersion(value)),
131
+ validator: (value) => value == null || ((0, ts_types_1.isString)(value) && (0, sfdc_1.validateApiVersion)(value)),
114
132
  failedMessage: messages.getMessage('invalidApiVersion'),
115
133
  },
116
134
  },
117
135
  {
136
+ // will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
118
137
  key: SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME,
119
138
  newKey: orgConfigProperties_1.OrgConfigProperties.TARGET_DEV_HUB,
120
139
  deprecated: true,
121
140
  description: messages.getMessage('defaultDevHubUsername'),
122
141
  },
123
142
  {
143
+ // will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
124
144
  key: SfdxPropertyKeys.DEFAULT_USERNAME,
125
145
  newKey: orgConfigProperties_1.OrgConfigProperties.TARGET_ORG,
126
146
  deprecated: true,
@@ -128,6 +148,8 @@ exports.SFDX_ALLOWED_PROPERTIES = [
128
148
  },
129
149
  {
130
150
  key: SfdxPropertyKeys.ISV_DEBUGGER_SID,
151
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_ISV_DEBUGGER_SID,
152
+ deprecated: true,
131
153
  description: messages.getMessage(SfdxPropertyKeys.ISV_DEBUGGER_SID),
132
154
  encrypted: true,
133
155
  input: {
@@ -138,6 +160,8 @@ exports.SFDX_ALLOWED_PROPERTIES = [
138
160
  },
139
161
  {
140
162
  key: SfdxPropertyKeys.ISV_DEBUGGER_URL,
163
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_ISV_DEBUGGER_URL,
164
+ deprecated: true,
141
165
  description: messages.getMessage(SfdxPropertyKeys.ISV_DEBUGGER_URL),
142
166
  input: {
143
167
  // If a value is provided validate it otherwise no value is unset.
@@ -147,17 +171,26 @@ exports.SFDX_ALLOWED_PROPERTIES = [
147
171
  },
148
172
  {
149
173
  key: SfdxPropertyKeys.DISABLE_TELEMETRY,
174
+ newKey: SfConfigProperties.DISABLE_TELEMETRY,
175
+ deprecated: true,
150
176
  description: messages.getMessage(SfdxPropertyKeys.DISABLE_TELEMETRY),
151
177
  input: {
152
178
  validator: (value) => value == null || ['true', 'false'].includes(value.toString()),
153
179
  failedMessage: messages.getMessage('invalidBooleanConfigValue'),
154
180
  },
155
181
  },
156
- // This should be brought in by a plugin, but there isn't a way to do that right now.
182
+ {
183
+ key: SfdxPropertyKeys.CUSTOM_ORG_METADATA_TEMPLATES,
184
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES,
185
+ deprecated: true,
186
+ description: messages.getMessage(SfdxPropertyKeys.CUSTOM_ORG_METADATA_TEMPLATES),
187
+ },
157
188
  {
158
189
  key: SfdxPropertyKeys.REST_DEPLOY,
159
190
  description: messages.getMessage(SfdxPropertyKeys.REST_DEPLOY),
160
191
  hidden: true,
192
+ newKey: 'org-metadata-rest-deploy',
193
+ deprecated: true,
161
194
  input: {
162
195
  validator: (value) => value != null && ['true', 'false'].includes(value.toString()),
163
196
  failedMessage: messages.getMessage('invalidBooleanConfigValue'),
@@ -166,6 +199,9 @@ exports.SFDX_ALLOWED_PROPERTIES = [
166
199
  {
167
200
  key: SfdxPropertyKeys.MAX_QUERY_LIMIT,
168
201
  description: messages.getMessage(SfdxPropertyKeys.MAX_QUERY_LIMIT),
202
+ hidden: true,
203
+ newKey: orgConfigProperties_1.OrgConfigProperties.ORG_MAX_QUERY_LIMIT,
204
+ deprecated: true,
169
205
  input: {
170
206
  // the bit shift will remove the negative bit, and any decimal numbers
171
207
  // then the parseFloat will handle converting it to a number from a string
@@ -193,7 +229,7 @@ class Config extends configFile_1.ConfigFile {
193
229
  constructor(options) {
194
230
  super(Object.assign({
195
231
  isGlobal: false,
196
- }, options !== null && options !== void 0 ? options : {}, {
232
+ }, options ?? {}, {
197
233
  // Don't let consumers of config override this. If they really really want to,
198
234
  // they can extend this class.
199
235
  isState: true,
@@ -225,9 +261,12 @@ class Config extends configFile_1.ConfigFile {
225
261
  */
226
262
  static addAllowedProperties(metas) {
227
263
  const currentMetaKeys = Object.keys(Config.propertyConfigMap());
264
+ // If logger is needed elsewhere in this file, do not move this outside of the Config class.
265
+ // It was causing issues with Bunyan log rotation. See https://github.com/forcedotcom/sfdx-core/pull/562
266
+ const logger = logger_1.Logger.childFromRoot('core:config');
228
267
  metas.forEach((meta) => {
229
268
  if (currentMetaKeys.includes(meta.key)) {
230
- log.info(`Key ${meta.key} already exists in allowedProperties, skipping.`);
269
+ logger.info(`Key ${meta.key} already exists in allowedProperties, skipping.`);
231
270
  return;
232
271
  }
233
272
  Config.allowedProperties.push(meta);
@@ -262,6 +301,13 @@ class Config extends configFile_1.ConfigFile {
262
301
  localConfig.clear();
263
302
  await localConfig.write();
264
303
  }
304
+ static getPropertyConfigMeta(propertyName) {
305
+ const prop = Config.propertyConfigMap()[propertyName];
306
+ if (prop?.deprecated && prop?.newKey) {
307
+ return Config.propertyConfigMap()[prop.newKey];
308
+ }
309
+ return prop;
310
+ }
265
311
  static propertyConfigMap() {
266
312
  return (0, kit_1.keyBy)(Config.allowedProperties, 'key');
267
313
  }
@@ -300,7 +346,7 @@ class Config extends configFile_1.ConfigFile {
300
346
  await this.cryptProperties(true);
301
347
  await super.write();
302
348
  if (global_1.Global.SFDX_INTEROPERABILITY)
303
- await this.sfdxConfig.writeSync();
349
+ await this.sfdxConfig.write();
304
350
  await this.cryptProperties(false);
305
351
  return this.getContents();
306
352
  }
@@ -308,19 +354,19 @@ class Config extends configFile_1.ConfigFile {
308
354
  * DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
309
355
  * Call {@link SfdxConfig.write} instead.
310
356
  *
311
- * **Throws** *{@link SfdxError}{ name: 'InvalidWriteError' }* Always.
357
+ * **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
312
358
  *
313
359
  * @param newContents Contents to write
314
360
  */
315
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
361
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
316
362
  writeSync(newContents) {
317
363
  throw messages.createError('invalidWrite');
318
364
  }
319
365
  /**
320
366
  * Sets a value for a property.
321
367
  *
322
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
323
- * **Throws** *{@link SfdxError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
368
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
369
+ * **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
324
370
  *
325
371
  * @param key The property to set.
326
372
  * @param value The value of the property.
@@ -331,14 +377,16 @@ class Config extends configFile_1.ConfigFile {
331
377
  throw messages.createError('unknownConfigKey', [key]);
332
378
  }
333
379
  if (property.deprecated && property.newKey) {
334
- throw messages.createError('deprecatedConfigKey', [key, property.newKey]);
380
+ // you're trying to set a deprecated key, but we'll set the new key instead
381
+ void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedConfigKey', [key, property.newKey]));
382
+ return this.set(property.newKey, value);
335
383
  }
336
384
  if (property.input) {
337
- if (property.input && property.input.validator(value)) {
385
+ if (property.input?.validator(value)) {
338
386
  super.set(property.key, value);
339
387
  }
340
388
  else {
341
- let valueError = (value === null || value === void 0 ? void 0 : value.toString()) || '';
389
+ let valueError = value?.toString() ?? '';
342
390
  if (property.input.failedMessage) {
343
391
  valueError = (0, ts_types_1.isString)(property.input.failedMessage)
344
392
  ? property.input.failedMessage
@@ -355,7 +403,7 @@ class Config extends configFile_1.ConfigFile {
355
403
  /**
356
404
  * Unsets a value for a property.
357
405
  *
358
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
406
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
359
407
  *
360
408
  * @param key The property to unset.
361
409
  */
@@ -365,20 +413,28 @@ class Config extends configFile_1.ConfigFile {
365
413
  throw messages.createError('unknownConfigKey', [key]);
366
414
  }
367
415
  if (property.deprecated && property.newKey) {
368
- throw messages.createError('deprecatedConfigKey', [key, property.newKey]);
416
+ // you're trying to set a deprecated key, so we'll ALSO unset the new key
417
+ void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedConfigKey', [key, property.newKey]));
418
+ super.unset(property.key);
419
+ return this.unset(property.newKey);
369
420
  }
370
421
  return super.unset(property.key);
371
422
  }
372
423
  /**
373
424
  * Get an individual property config.
374
425
  *
375
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
426
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
376
427
  *
377
428
  * @param propertyName The name of the property.
378
429
  */
430
+ // eslint-disable-next-line class-methods-use-this
379
431
  getPropertyConfig(propertyName) {
380
432
  const prop = Config.propertyConfigMap()[propertyName];
381
433
  if (!prop) {
434
+ const newEquivalent = Config.allowedProperties.find((p) => p.newKey);
435
+ if (newEquivalent) {
436
+ return this.getPropertyConfig(newEquivalent.key);
437
+ }
382
438
  throw messages.createError('unknownConfigKey', [propertyName]);
383
439
  }
384
440
  return prop;
@@ -397,10 +453,7 @@ class Config extends configFile_1.ConfigFile {
397
453
  * @param encrypt `true` to encrypt.
398
454
  */
399
455
  async cryptProperties(encrypt) {
400
- const hasEncryptedProperties = this.entries().some(([key]) => {
401
- var _a;
402
- return !!((_a = Config.propertyConfigMap()[key]) === null || _a === void 0 ? void 0 : _a.encrypted);
403
- });
456
+ const hasEncryptedProperties = this.entries().some(([key]) => !!Config.propertyConfigMap()[key]?.encrypted);
404
457
  if (hasEncryptedProperties) {
405
458
  await this.initCrypto();
406
459
  const crypto = (0, ts_types_1.ensure)(this.crypto);
@@ -415,6 +468,7 @@ class Config extends configFile_1.ConfigFile {
415
468
  exports.Config = Config;
416
469
  Config.allowedProperties = [
417
470
  ...exports.SFDX_ALLOWED_PROPERTIES,
471
+ ...exports.SF_ALLOWED_PROPERTIES,
418
472
  ...orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES,
419
473
  ];
420
474
  class SfdxConfig {
@@ -444,38 +498,36 @@ class SfdxConfig {
444
498
  }
445
499
  return Object.assign(config, sfdxConfig);
446
500
  }
447
- readSync() {
501
+ async write(config = this.config.toObject()) {
448
502
  try {
449
- const contents = fs_1.fs.readJsonMapSync(this.getSfdxPath());
450
- return this.normalize(contents, 'toNew');
503
+ const translated = this.translate(config, 'toOld');
504
+ const sfdxPath = this.getSfdxPath();
505
+ await fs.promises.mkdir((0, path_1.dirname)(sfdxPath), { recursive: true });
506
+ await fs.promises.writeFile(sfdxPath, JSON.stringify(translated, null, 2));
451
507
  }
452
508
  catch (error) {
453
509
  /* Do nothing */
454
- return {};
455
510
  }
456
511
  }
457
- async writeSync(config = this.config.toObject()) {
512
+ readSync() {
458
513
  try {
459
- const sfdxPath = this.getSfdxPath();
460
- await fs_1.fs.mkdirp((0, path_1.dirname)(sfdxPath));
461
- const mapped = this.normalize(config, 'toOld');
462
- await fs_1.fs.writeJson(sfdxPath, mapped);
514
+ const contents = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getSfdxPath(), 'utf8'));
515
+ return this.translate(contents, 'toNew');
463
516
  }
464
517
  catch (error) {
465
518
  /* Do nothing */
519
+ return {};
466
520
  }
467
521
  }
468
522
  getSfdxPath() {
469
523
  if (!this.sfdxPath) {
470
524
  const stateFolder = global_1.Global.SFDX_STATE_FOLDER;
471
525
  const fileName = SFDX_CONFIG_FILE_NAME;
472
- const _isGlobal = (0, ts_types_1.isBoolean)(this.options.isGlobal) && this.options.isGlobal;
473
- const _isState = (0, ts_types_1.isBoolean)(this.options.isState) && this.options.isState;
474
526
  // Don't let users store config files in homedir without being in the state folder.
475
527
  let configRootFolder = this.options.rootFolder
476
528
  ? this.options.rootFolder
477
529
  : configFile_1.ConfigFile.resolveRootFolderSync(!!this.options.isGlobal);
478
- if (_isGlobal || _isState) {
530
+ if (this.options.isGlobal === true || this.options.isState === true) {
479
531
  configRootFolder = (0, path_1.join)(configRootFolder, stateFolder);
480
532
  }
481
533
  this.sfdxPath = (0, path_1.join)(configRootFolder, fileName);
@@ -489,22 +541,22 @@ class SfdxConfig {
489
541
  * If toOld is specified: migrate all deprecated configs back to their original key.
490
542
  * - For example, target-org will be renamed to defaultusername.
491
543
  */
492
- normalize(contents, direction) {
493
- var _a;
494
- const mapped = {};
544
+ translate(contents, direction) {
545
+ const translated = {};
495
546
  for (const [key, value] of Object.entries(contents)) {
496
547
  const propConfig = direction === 'toNew'
497
548
  ? this.config.getPropertyConfig(key)
498
- : (_a = Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
549
+ : Config.getAllowedProperties().find((c) => c.newKey === key) ?? {};
499
550
  if (propConfig.deprecated && propConfig.newKey) {
500
551
  const normalizedKey = direction === 'toNew' ? propConfig.newKey : propConfig.key;
501
- mapped[normalizedKey] = value;
552
+ translated[normalizedKey] = value;
502
553
  }
503
554
  else {
504
- mapped[key] = value;
555
+ translated[key] = value;
505
556
  }
506
557
  }
507
- return mapped;
558
+ return translated;
508
559
  }
509
560
  }
561
+ exports.SfdxConfig = SfdxConfig;
510
562
  //# sourceMappingURL=config.js.map
@@ -1,5 +1,5 @@
1
1
  import { AsyncOptionalCreatable } from '@salesforce/kit';
2
- import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
2
+ import { AnyJson, Dictionary, JsonMap, Optional } from '@salesforce/ts-types';
3
3
  import { Config, ConfigPropertyMeta } from './config';
4
4
  /**
5
5
  * Information about a config property.
@@ -40,11 +40,11 @@ export interface ConfigInfo {
40
40
  }
41
41
  /**
42
42
  * Aggregate global and local project config files, as well as environment variables for
43
- * `sfdx-config.json`. The resolution happens in the following bottom-up order:
43
+ * `config.json`. The resolution happens in the following bottom-up order:
44
44
  *
45
- * 1. Environment variables (`SFDX_LOG_LEVEL`)
46
- * 1. Workspace settings (`<workspace-root>/.sfdx/sfdx-config.json`)
47
- * 1. Global settings (`$HOME/.sfdx/sfdx-config.json`)
45
+ * 1. Environment variables (`SF_LOG_LEVEL`)
46
+ * 1. Workspace settings (`<workspace-root>/.sf/config.json`)
47
+ * 1. Global settings (`$HOME/.sf/config.json`)
48
48
  *
49
49
  * Use {@link ConfigAggregator.create} to instantiate the aggregator.
50
50
  *
@@ -53,27 +53,21 @@ export interface ConfigInfo {
53
53
  * console.log(aggregator.getPropertyValue('target-org'));
54
54
  * ```
55
55
  */
56
- export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
57
- private static instance;
58
- private static encrypted;
56
+ export declare class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggregator.Options> {
57
+ protected static instance: AsyncOptionalCreatable;
58
+ protected static encrypted: boolean;
59
59
  private allowedProperties;
60
60
  private localConfig?;
61
61
  private globalConfig;
62
62
  private envVars;
63
- private get config();
64
63
  /**
65
64
  * **Do not directly construct instances of this class -- use {@link ConfigAggregator.create} instead.**
66
65
  *
67
66
  * @ignore
68
67
  */
69
- constructor(options?: JsonMap);
70
- /**
71
- * Get the static ConfigAggregator instance. If one doesn't exist, one will be created with
72
- * the **encrypted** config values. Encrypted config values need to be resolved
73
- * asynchronously by calling {@link ConfigAggregator.reload}
74
- */
75
- static getInstance<P, T extends AsyncOptionalCreatable<P>>(this: new () => T): T;
76
- static create<P, T extends AsyncOptionalCreatable<P>>(this: new (options?: P) => T, options?: P): Promise<T>;
68
+ constructor(options?: ConfigAggregator.Options);
69
+ private get config();
70
+ static create<P extends ConfigAggregator.Options, T extends AsyncOptionalCreatable<P>>(this: new (options?: P) => T, options?: P): Promise<T>;
77
71
  /**
78
72
  * Get the info for a given key. If the ConfigAggregator was not asynchronously created OR
79
73
  * the {@link ConfigAggregator.reload} was not called, the config value may be encrypted.
@@ -81,28 +75,37 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
81
75
  * @param key The config key.
82
76
  */
83
77
  static getValue(key: string): ConfigInfo;
78
+ /**
79
+ * Get the static ConfigAggregator instance. If one doesn't exist, one will be created with
80
+ * the **encrypted** config values. Encrypted config values need to be resolved
81
+ * asynchronously by calling {@link ConfigAggregator.reload}
82
+ */
83
+ private static getInstance;
84
84
  /**
85
85
  * Initialize this instances async dependencies.
86
86
  */
87
87
  init(): Promise<void>;
88
88
  /**
89
89
  * Get a resolved config property.
90
+ * If you use a deprecated property, a warning will be emitted and it will attempt to resolve the new property's value
90
91
  *
91
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
92
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
92
93
  *
93
94
  * @param key The key of the property.
94
95
  */
95
96
  getPropertyValue<T extends AnyJson>(key: string): Optional<T>;
96
97
  /**
97
98
  * Get a resolved config property meta.
99
+ * If the property is deprecated, it will return the new key's meta, if it exists, with a deprecation warning
98
100
  *
99
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
101
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
100
102
  *
101
103
  * @param key The key of the property.
102
104
  */
103
105
  getPropertyMeta(key: string): ConfigPropertyMeta;
104
106
  /**
105
107
  * Get a resolved config property.
108
+ * If a property is deprecated, it will try to use the the new key, if there is a config there.
106
109
  *
107
110
  * @param key The key of the property.
108
111
  * @param throwOnDeprecation True, if you want an error throw when reading a deprecated config
@@ -123,9 +126,9 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
123
126
  * Get a resolved file path or environment variable name of the property.
124
127
  *
125
128
  * For example, `getPath('logLevel')` will return:
126
- * 1. `$SFDX_LOG_LEVEL` if resolved to an environment variable.
127
- * 1. `./.sfdx/sfdx-config.json` if resolved to the local config.
128
- * 1. `~/.sfdx/sfdx-config.json` if resolved to the global config.
129
+ * 1. `$SF_LOG_LEVEL` if resolved to an environment variable.
130
+ * 1. `./.sf/config.json` if resolved to the local config.
131
+ * 1. `~/.sf/config.json` if resolved to the global config.
129
132
  * 1. `undefined`, if not resolved.
130
133
  *
131
134
  * **Note:** that the path returned may be the absolute path instead of
@@ -140,7 +143,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
140
143
  * ```
141
144
  * > console.log(aggregator.getConfigInfo());
142
145
  * [
143
- * { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$SFDX_LOG_LEVEL'}
146
+ * { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$SF_LOG_LEVEL'}
144
147
  * { key: 'target-org', val: '<username>', location: 'Local', path: './.sf/config.json'}
145
148
  * ]
146
149
  * ```
@@ -161,7 +164,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
161
164
  /**
162
165
  * Get the config properties that are environment variables.
163
166
  */
164
- getEnvVars(): Map<string, string>;
167
+ getEnvVars(): Dictionary<string>;
165
168
  /**
166
169
  * Re-read all property configurations from disk.
167
170
  */
@@ -171,24 +174,24 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
171
174
  */
172
175
  addAllowedProperties(configMetas: ConfigPropertyMeta | ConfigPropertyMeta[]): void;
173
176
  /**
174
- * Loads all the properties and aggregates them according to location.
177
+ * Set the allowed properties.
178
+ *
179
+ * @param properties The properties to set.
175
180
  */
176
- private loadProperties;
181
+ protected setAllowedProperties(properties: ConfigPropertyMeta[]): void;
177
182
  /**
178
- * Loads all the properties and aggregates them according to location.
183
+ * Get the allowed properties.
179
184
  */
180
- private loadPropertiesSync;
181
- private resolveProperties;
185
+ protected getAllowedProperties(): ConfigPropertyMeta[];
182
186
  /**
183
- * Get the allowed properties.
187
+ * Loads all the properties and aggregates them according to location.
184
188
  */
185
- private getAllowedProperties;
189
+ protected loadProperties(): Promise<void>;
186
190
  /**
187
- * Set the allowed properties.
188
- *
189
- * @param properties The properties to set.
191
+ * Loads all the properties and aggregates them according to location.
190
192
  */
191
- private setAllowedProperties;
193
+ private loadPropertiesSync;
194
+ private resolveProperties;
192
195
  }
193
196
  export declare namespace ConfigAggregator {
194
197
  /**
@@ -208,4 +211,7 @@ export declare namespace ConfigAggregator {
208
211
  */
209
212
  ENVIRONMENT = "Environment"
210
213
  }
214
+ type Options = {
215
+ customConfigMeta?: ConfigPropertyMeta[];
216
+ };
211
217
  }