Skip to content

Commit 93f3cbe

Browse files
authored
feat: normalize config vars for sf (#543)
* feat: add metadata-rest-deploy * feat: replace all sfdx config vars with sf appropriate ones * chore: spelling * chore: correct readme * chore: correct deprecation note * chore: update exports * fix: update envVars too * chore: remove org-metadata-rest-deploy * chore: rebuild
1 parent cc36ad9 commit 93f3cbe

File tree

9 files changed

+251
-50
lines changed

9 files changed

+251
-50
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ workflows:
133133
node_version: [lts]
134134
external_project_git_url:
135135
[
136+
# 'https://github.com/salesforcecli/plugin-config#v2',
137+
'https://github.com/salesforcecli/plugin-config#mdonnalley/update-tests',
136138
'https://github.com/salesforcecli/plugin-alias',
137-
'https://github.com/salesforcecli/plugin-config#v2',
138139
'https://github.com/salesforcecli/plugin-env',
139140
'https://github.com/salesforcecli/plugin-login',
140141
'https://github.com/salesforcecli/plugin-deploy-retrieve',

MIGRATING_V2-V3.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,20 @@ info.aliases.getAll();
6363

6464
- Moved `.sfdx/sfdx-config.json` to `.sf/config.json`
6565
- Removed `Config.<config key name>`
66-
- Deprecated `DEFAULT_USERNAME` and `DEFAULT_DEV_HUB_USERNAME`
66+
- Deprecated the following:
67+
68+
| Deprecated Config Var | New Config Var |
69+
| ------------------------------------------------ | --------------------------------------------------- |
70+
| `SfdxPropertyKeys.API_VERSION` | `OrgConfigProperties.ORG_API_VERSION` |
71+
| `SfdxPropertyKeys.CUSTOM_ORG_METADATA_TEMPLATES` | `OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES` |
72+
| `SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME` | `OrgConfigProperties.TARGET_DEV_HUB` |
73+
| `SfdxPropertyKeys.DEFAULT_USERNAME` | `OrgConfigProperties.TARGET_ORG` |
74+
| `SfdxPropertyKeys.DISABLE_TELEMETRY` | `SfConfigProperties.DISABLE_TELEMETRY` |
75+
| `SfdxPropertyKeys.INSTANCE_URL` | `OrgConfigProperties.ORG_INSTANCE_URL` |
76+
| `SfdxPropertyKeys.ISV_DEBUGGER_SID` | `OrgConfigProperties.ORG_ISV_DEBUGGER_SID` |
77+
| `SfdxPropertyKeys.ISV_DEBUGGER_URL` | `OrgConfigProperties.ORG_ISV_DEBUGGER_URL` |
78+
| `SfdxPropertyKeys.MAX_QUERY_LIMIT` | `OrgConfigProperties.ORG_MAX_QUERY_LIMIT` |
79+
| `SfdxPropertyKeys.REST_DEPLOY` | REMOVED |
6780

6881
### Why
6982

@@ -81,6 +94,12 @@ Config.update(true, Config.API_VERSION, '49.0');
8194
Config.update(true, SfdxPropertyKeys.API_VERSION, '49.0');
8295
```
8396

97+
OR
98+
99+
```typescript
100+
Config.update(true, OrgConfigProperties.ORG_API_VERSION, '49.0');
101+
```
102+
84103
## ConfigStore, ConfigFile, AuthInfo, and Encrypting Values
85104

86105
### What

messages/config.md

+30-6
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ In sfdx-project.json, indicate only one package directory (path) as the default.
7575

7676
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.
7777

78-
# targetOrg
78+
# target-org
7979

8080
Username or alias of the org that all commands run against by default. (sf only)
8181

82-
# targetDevHub
82+
# target-dev-hub
8383

8484
Username or alias of your default Dev Hub org. (sf only)
8585

@@ -93,28 +93,52 @@ Username or alias of your default Dev Hub org. (sfdx only)
9393

9494
# isvDebuggerSid
9595

96-
ISV debugger SID
96+
ISV debugger SID (sfdx only)
9797

9898
# isvDebuggerUrl
9999

100-
ISV debugger URL
100+
ISV debugger URL (sfdx only)
101+
102+
# org-isv-debugger-sid
103+
104+
ISV debugger SID.
105+
106+
# org-isv-debugger-url
107+
108+
ISV debugger URL.
101109

102110
# apiVersion
103111

112+
API version of your project. Default: API version of your Dev Hub org. (sfdx only)
113+
114+
# org-api-version
115+
104116
API version of your project. Default: API version of your Dev Hub org.
105117

106118
# disableTelemetry
107119

108-
Disables the collection of usage and user environment information, etc. Default: true.
120+
Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)
121+
122+
# disable-telemetry
123+
124+
Disables the collection of usage and user environment information, etc. Default: false.
109125

110126
# maxQueryLimit
111127

128+
Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)
129+
130+
# org-max-query-limit
131+
112132
Maximum number of Salesforce records returned by a CLI command. Default: 10,000.
113133

114134
# restDeploy
115135

116-
Whether deployments use the Metadata REST API (true) or SOAP API (false, default value).
136+
Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)
117137

118138
# instanceUrl
119139

140+
URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)
141+
142+
# org-instance-url
143+
120144
URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com.

messages/envVars.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Username or alias of your default Dev Hub org. Overrides the target-dev-hub conf
174174

175175
Specifies an access token when using a login command that uses access tokens.
176176

177-
# sfApiVersion
177+
# sfOrgApiVersion
178178

179179
API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion configuration variable.
180180

@@ -218,7 +218,7 @@ Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom
218218

219219
Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands.
220220

221-
# sfInstanceUrl
221+
# sfOrgInstanceUrl
222222

223223
URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration variable.
224224

@@ -238,7 +238,7 @@ The default rotation period for logs. Example '1d' will rotate logs daily (at mi
238238

239239
The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files.
240240

241-
# sfMaxQueryLimit
241+
# sfOrgMaxQueryLimit
242242

243243
Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration variable.
244244

src/config/config.ts

+52-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const messages = Messages.load('@salesforce/core', 'config', [
4040
'maxQueryLimit',
4141
'restDeploy',
4242
'instanceUrl',
43+
'disable-telemetry',
4344
]);
4445

4546
const log = Logger.childFromRoot('core:config');
@@ -104,6 +105,24 @@ export interface ConfigPropertyMetaInput {
104105
failedMessage: string | ((value: ConfigValue) => string);
105106
}
106107

108+
export enum SfConfigProperties {
109+
/**
110+
* Disables telemetry reporting
111+
*/
112+
DISABLE_TELEMETRY = 'disable-telemetry',
113+
}
114+
115+
export const SF_ALLOWED_PROPERTIES = [
116+
{
117+
key: SfConfigProperties.DISABLE_TELEMETRY,
118+
description: messages.getMessage(SfConfigProperties.DISABLE_TELEMETRY),
119+
input: {
120+
validator: (value: ConfigValue) => value == null || ['true', 'false'].includes(value.toString()),
121+
failedMessage: messages.getMessage('invalidBooleanConfigValue'),
122+
},
123+
},
124+
];
125+
107126
export enum SfdxPropertyKeys {
108127
/**
109128
* Username associated with the default dev hub org.
@@ -123,45 +142,63 @@ export enum SfdxPropertyKeys {
123142

124143
/**
125144
* The sid for the debugger configuration.
145+
*
146+
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_SID in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
126147
*/
127148
ISV_DEBUGGER_SID = 'isvDebuggerSid',
128149

129150
/**
130151
* The url for the debugger configuration.
152+
*
153+
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
131154
*/
132155
ISV_DEBUGGER_URL = 'isvDebuggerUrl',
133156

134157
/**
135158
* The api version
159+
*
160+
* @deprecated Replaced by OrgConfigProperties.ORG_API_VERSION in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
136161
*/
137162
API_VERSION = 'apiVersion',
138163

139164
/**
140165
* Disables telemetry reporting
166+
*
167+
* @deprecated Replaced by SfPropertyKeys.DISABLE_TELEMETRY in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
141168
*/
142169
DISABLE_TELEMETRY = 'disableTelemetry',
143170

144171
/**
145172
* Custom templates repo or local location.
173+
*
174+
* @deprecated Replaced by OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
146175
*/
147176
CUSTOM_ORG_METADATA_TEMPLATES = 'customOrgMetadataTemplates',
148177

149178
/**
150179
* allows users to override the 10,000 result query limit
180+
*
181+
* @deprecated Replaced by OrgConfigProperties.ORG_MAX_QUERY_LIMIT in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
151182
*/
152183
MAX_QUERY_LIMIT = 'maxQueryLimit',
153184

154-
/** */
185+
/**
186+
* @deprecated
187+
*/
155188
REST_DEPLOY = 'restDeploy',
156189

157-
/** */
190+
/**
191+
* @deprecated Replaced by OrgConfigProperties.ORG_INSTANCE_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
192+
*/
158193
INSTANCE_URL = 'instanceUrl',
159194
}
160195

161196
export const SFDX_ALLOWED_PROPERTIES = [
162197
{
163198
key: SfdxPropertyKeys.INSTANCE_URL,
164199
description: messages.getMessage(SfdxPropertyKeys.INSTANCE_URL),
200+
newKey: OrgConfigProperties.ORG_INSTANCE_URL,
201+
deprecated: true,
165202
input: {
166203
// If a value is provided validate it otherwise no value is unset.
167204
validator: (value: ConfigValue) => {
@@ -179,6 +216,8 @@ export const SFDX_ALLOWED_PROPERTIES = [
179216
},
180217
{
181218
key: SfdxPropertyKeys.API_VERSION,
219+
newKey: OrgConfigProperties.ORG_API_VERSION,
220+
deprecated: true,
182221
description: messages.getMessage(SfdxPropertyKeys.API_VERSION),
183222
hidden: true,
184223
input: {
@@ -203,6 +242,8 @@ export const SFDX_ALLOWED_PROPERTIES = [
203242
},
204243
{
205244
key: SfdxPropertyKeys.ISV_DEBUGGER_SID,
245+
newKey: OrgConfigProperties.ORG_ISV_DEBUGGER_SID,
246+
deprecated: true,
206247
description: messages.getMessage(SfdxPropertyKeys.ISV_DEBUGGER_SID),
207248
encrypted: true,
208249
input: {
@@ -213,6 +254,8 @@ export const SFDX_ALLOWED_PROPERTIES = [
213254
},
214255
{
215256
key: SfdxPropertyKeys.ISV_DEBUGGER_URL,
257+
newKey: OrgConfigProperties.ORG_ISV_DEBUGGER_URL,
258+
deprecated: true,
216259
description: messages.getMessage(SfdxPropertyKeys.ISV_DEBUGGER_URL),
217260
input: {
218261
// If a value is provided validate it otherwise no value is unset.
@@ -222,17 +265,20 @@ export const SFDX_ALLOWED_PROPERTIES = [
222265
},
223266
{
224267
key: SfdxPropertyKeys.DISABLE_TELEMETRY,
268+
newKey: SfConfigProperties.DISABLE_TELEMETRY,
269+
deprecated: true,
225270
description: messages.getMessage(SfdxPropertyKeys.DISABLE_TELEMETRY),
226271
input: {
227272
validator: (value: ConfigValue) => value == null || ['true', 'false'].includes(value.toString()),
228273
failedMessage: messages.getMessage('invalidBooleanConfigValue'),
229274
},
230275
},
231-
// This should be brought in by a plugin, but there isn't a way to do that right now.
232276
{
233277
key: SfdxPropertyKeys.REST_DEPLOY,
234278
description: messages.getMessage(SfdxPropertyKeys.REST_DEPLOY),
235279
hidden: true,
280+
newKey: 'org-metadata-rest-deploy',
281+
deprecated: true,
236282
input: {
237283
validator: (value: ConfigValue) => value != null && ['true', 'false'].includes(value.toString()),
238284
failedMessage: messages.getMessage('invalidBooleanConfigValue'),
@@ -241,6 +287,8 @@ export const SFDX_ALLOWED_PROPERTIES = [
241287
{
242288
key: SfdxPropertyKeys.MAX_QUERY_LIMIT,
243289
description: messages.getMessage(SfdxPropertyKeys.MAX_QUERY_LIMIT),
290+
hidden: true,
291+
newKey: OrgConfigProperties.ORG_MAX_QUERY_LIMIT,
244292
input: {
245293
// the bit shift will remove the negative bit, and any decimal numbers
246294
// then the parseFloat will handle converting it to a number from a string
@@ -272,6 +320,7 @@ export type ConfigProperties = { [index: string]: JsonPrimitive };
272320
export class Config extends ConfigFile<ConfigFile.Options, ConfigProperties> {
273321
private static allowedProperties: ConfigPropertyMeta[] = [
274322
...SFDX_ALLOWED_PROPERTIES,
323+
...SF_ALLOWED_PROPERTIES,
275324
...ORG_CONFIG_ALLOWED_PROPERTIES,
276325
];
277326

src/config/envVars.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export enum EnvironmentVariable {
5858
'SF_TARGET_ORG' = 'SF_TARGET_ORG',
5959
'SF_TARGET_DEV_HUB' = 'SF_TARGET_DEV_HUB',
6060
'SF_ACCESS_TOKEN' = 'SF_ACCESS_TOKEN',
61-
'SF_API_VERSION' = 'SF_API_VERSION',
61+
'SF_ORG_API_VERSION' = 'SF_ORG_API_VERSION',
6262
'SF_AUDIENCE_URL' = 'SF_AUDIENCE_URL',
6363
'SF_CODE_COVERAGE_REQUIREMENT' = 'SF_CODE_COVERAGE_REQUIREMENT',
6464
'SF_CONTENT_TYPE' = 'SF_CONTENT_TYPE',
@@ -69,12 +69,12 @@ export enum EnvironmentVariable {
6969
'SF_DNS_TIMEOUT' = 'SF_DNS_TIMEOUT',
7070
'SF_DOMAIN_RETRY' = 'SF_DOMAIN_RETRY',
7171
'SF_IMPROVED_CODE_COVERAGE' = 'SF_IMPROVED_CODE_COVERAGE',
72-
'SF_INSTANCE_URL' = 'SF_INSTANCE_URL',
72+
'SF_ORG_INSTANCE_URL' = 'SF_ORG_INSTANCE_URL',
7373
'SF_JSON_TO_STDOUT' = 'SF_JSON_TO_STDOUT',
7474
'SF_LOG_LEVEL' = 'SF_LOG_LEVEL',
7575
'SF_LOG_ROTATION_COUNT' = 'SF_LOG_ROTATION_COUNT',
7676
'SF_LOG_ROTATION_PERIOD' = 'SF_LOG_ROTATION_PERIOD',
77-
'SF_MAX_QUERY_LIMIT' = 'SF_MAX_QUERY_LIMIT',
77+
'SF_ORG_MAX_QUERY_LIMIT' = 'SF_ORG_MAX_QUERY_LIMIT',
7878
'SF_MDAPI_TEMP_DIR' = 'SF_MDAPI_TEMP_DIR',
7979
'SF_NPM_REGISTRY' = 'SF_NPM_REGISTRY',
8080
'SF_PRECOMPILE_ENABLE' = 'SF_PRECOMPILE_ENABLE',
@@ -137,7 +137,7 @@ export const SUPPORTED_ENV_VARS: EnvType = {
137137
},
138138
[EnvironmentVariable.SFDX_API_VERSION]: {
139139
description: getMessage(EnvironmentVariable.SFDX_API_VERSION),
140-
synonymOf: EnvironmentVariable.SF_API_VERSION,
140+
synonymOf: EnvironmentVariable.SF_ORG_API_VERSION,
141141
},
142142
[EnvironmentVariable.SFDX_AUDIENCE_URL]: {
143143
description: getMessage(EnvironmentVariable.SFDX_AUDIENCE_URL),
@@ -189,7 +189,7 @@ export const SUPPORTED_ENV_VARS: EnvType = {
189189
},
190190
[EnvironmentVariable.SFDX_INSTANCE_URL]: {
191191
description: getMessage(EnvironmentVariable.SFDX_INSTANCE_URL),
192-
synonymOf: EnvironmentVariable.SF_INSTANCE_URL,
192+
synonymOf: EnvironmentVariable.SF_ORG_INSTANCE_URL,
193193
},
194194
[EnvironmentVariable.SFDX_JSON_TO_STDOUT]: {
195195
description: getMessage(EnvironmentVariable.SFDX_JSON_TO_STDOUT),
@@ -209,7 +209,7 @@ export const SUPPORTED_ENV_VARS: EnvType = {
209209
},
210210
[EnvironmentVariable.SFDX_MAX_QUERY_LIMIT]: {
211211
description: getMessage(EnvironmentVariable.SFDX_MAX_QUERY_LIMIT),
212-
synonymOf: EnvironmentVariable.SF_MAX_QUERY_LIMIT,
212+
synonymOf: EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT,
213213
},
214214
[EnvironmentVariable.SFDX_MDAPI_TEMP_DIR]: {
215215
description: getMessage(EnvironmentVariable.SFDX_MDAPI_TEMP_DIR),
@@ -282,8 +282,8 @@ export const SUPPORTED_ENV_VARS: EnvType = {
282282
description: getMessage(EnvironmentVariable.SF_ACCESS_TOKEN),
283283
synonymOf: null,
284284
},
285-
[EnvironmentVariable.SF_API_VERSION]: {
286-
description: getMessage(EnvironmentVariable.SF_API_VERSION),
285+
[EnvironmentVariable.SF_ORG_API_VERSION]: {
286+
description: getMessage(EnvironmentVariable.SF_ORG_API_VERSION),
287287
synonymOf: null,
288288
},
289289
[EnvironmentVariable.SF_AUDIENCE_URL]: {
@@ -326,8 +326,8 @@ export const SUPPORTED_ENV_VARS: EnvType = {
326326
description: getMessage(EnvironmentVariable.SF_IMPROVED_CODE_COVERAGE),
327327
synonymOf: null,
328328
},
329-
[EnvironmentVariable.SF_INSTANCE_URL]: {
330-
description: getMessage(EnvironmentVariable.SF_INSTANCE_URL),
329+
[EnvironmentVariable.SF_ORG_INSTANCE_URL]: {
330+
description: getMessage(EnvironmentVariable.SF_ORG_INSTANCE_URL),
331331
synonymOf: null,
332332
},
333333
[EnvironmentVariable.SF_JSON_TO_STDOUT]: {
@@ -346,8 +346,8 @@ export const SUPPORTED_ENV_VARS: EnvType = {
346346
description: getMessage(EnvironmentVariable.SF_LOG_ROTATION_PERIOD),
347347
synonymOf: null,
348348
},
349-
[EnvironmentVariable.SF_MAX_QUERY_LIMIT]: {
350-
description: getMessage(EnvironmentVariable.SF_MAX_QUERY_LIMIT),
349+
[EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT]: {
350+
description: getMessage(EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT),
351351
synonymOf: null,
352352
},
353353
[EnvironmentVariable.SF_MDAPI_TEMP_DIR]: {

0 commit comments

Comments
 (0)