@salesforce/core 3.19.0 → 3.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.19.1](https://github.com/forcedotcom/sfdx-core/compare/v3.19.0...v3.19.1) (2022-05-27)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- env var resolution in ConfigAggregator ([#590](https://github.com/forcedotcom/sfdx-core/issues/590)) ([a65cfbd](https://github.com/forcedotcom/sfdx-core/commit/a65cfbdd0e2a6c3806aa4da3270b237f68b37133))
|
|
10
|
+
|
|
5
11
|
## [3.19.0](https://github.com/forcedotcom/sfdx-core/compare/v3.18.3...v3.19.0) (2022-05-20)
|
|
6
12
|
|
|
7
13
|
### Features
|
|
@@ -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.
|
|
@@ -161,7 +161,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<ConfigAggre
|
|
|
161
161
|
/**
|
|
162
162
|
* Get the config properties that are environment variables.
|
|
163
163
|
*/
|
|
164
|
-
getEnvVars():
|
|
164
|
+
getEnvVars(): Dictionary<string>;
|
|
165
165
|
/**
|
|
166
166
|
* Re-read all property configurations from disk.
|
|
167
167
|
*/
|
|
@@ -37,6 +37,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
37
37
|
*/
|
|
38
38
|
constructor(options) {
|
|
39
39
|
super(options || {});
|
|
40
|
+
this.envVars = {};
|
|
40
41
|
// Don't throw an project error with the aggregator, since it should resolve to global if
|
|
41
42
|
// there is no project.
|
|
42
43
|
try {
|
|
@@ -107,7 +108,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
107
108
|
*/
|
|
108
109
|
getPropertyValue(key) {
|
|
109
110
|
if (this.getAllowedProperties().some((element) => key === element.key)) {
|
|
110
|
-
return this.getConfig()[key]
|
|
111
|
+
return this.getConfig()[key];
|
|
111
112
|
}
|
|
112
113
|
else {
|
|
113
114
|
throw messages.createError('unknownConfigKey', [key]);
|
|
@@ -164,7 +165,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
164
165
|
* @param key The key of the property.
|
|
165
166
|
*/
|
|
166
167
|
getLocation(key) {
|
|
167
|
-
if (this.
|
|
168
|
+
if (this.envVars[key] != null) {
|
|
168
169
|
return "Environment" /* ENVIRONMENT */;
|
|
169
170
|
}
|
|
170
171
|
if (this.localConfig && this.localConfig.get(key)) {
|
|
@@ -189,8 +190,8 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
189
190
|
* @param key The key of the property.
|
|
190
191
|
*/
|
|
191
192
|
getPath(key) {
|
|
192
|
-
if (this.envVars
|
|
193
|
-
return `$${
|
|
193
|
+
if (this.envVars[key] != null) {
|
|
194
|
+
return `$${envVars_1.EnvVars.propertyToEnvName(key)}`;
|
|
194
195
|
}
|
|
195
196
|
if (this.localConfig && this.localConfig.getContents()[key] != null) {
|
|
196
197
|
return this.localConfig.getPath();
|
|
@@ -239,7 +240,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
239
240
|
* Get the config properties that are environment variables.
|
|
240
241
|
*/
|
|
241
242
|
getEnvVars() {
|
|
242
|
-
return this.envVars
|
|
243
|
+
return this.envVars;
|
|
243
244
|
}
|
|
244
245
|
/**
|
|
245
246
|
* Re-read all property configurations from disk.
|
|
@@ -287,9 +288,12 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
287
288
|
this.resolveProperties(this.globalConfig.readSync(), this.localConfig && this.localConfig.readSync());
|
|
288
289
|
}
|
|
289
290
|
resolveProperties(globalConfig, localConfig) {
|
|
290
|
-
|
|
291
|
+
const envVars = new envVars_1.EnvVars();
|
|
291
292
|
for (const property of this.getAllowedProperties()) {
|
|
292
|
-
|
|
293
|
+
const key = property.newKey ? property.newKey : property.key;
|
|
294
|
+
const value = envVars.getPropertyFromEnv(property.key);
|
|
295
|
+
if (value)
|
|
296
|
+
this.envVars[key] = value;
|
|
293
297
|
}
|
|
294
298
|
// Global config must be read first so it is on the left hand of the
|
|
295
299
|
// object assign and is overwritten by the local config.
|
|
@@ -298,7 +302,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
298
302
|
if (localConfig) {
|
|
299
303
|
configs.push(localConfig);
|
|
300
304
|
}
|
|
301
|
-
configs.push(this.envVars
|
|
305
|
+
configs.push(this.envVars);
|
|
302
306
|
const json = {};
|
|
303
307
|
const reduced = configs.filter(ts_types_1.isJsonMap).reduce((acc, el) => (0, kit_1.merge)(acc, el), json);
|
|
304
308
|
return reduced;
|
package/lib/config/envVars.d.ts
CHANGED
|
@@ -87,10 +87,9 @@ declare type EnvType = {
|
|
|
87
87
|
export declare const SUPPORTED_ENV_VARS: EnvType;
|
|
88
88
|
export declare class EnvVars extends Env {
|
|
89
89
|
constructor(env?: NodeJS.ProcessEnv);
|
|
90
|
+
static propertyToEnvName(property: string, prefix?: string): string;
|
|
90
91
|
private static defaultPrefix;
|
|
91
|
-
|
|
92
|
-
setPropertyFromEnv(property: string, prefix?: string | undefined): void;
|
|
93
|
-
getPropertyFromEnv<T>(property: string, prefix?: string | undefined): T | undefined;
|
|
92
|
+
getPropertyFromEnv<T>(property: string, prefix?: string): Nullable<T>;
|
|
94
93
|
asDictionary(): Dictionary<unknown>;
|
|
95
94
|
asMap(): Map<string, string>;
|
|
96
95
|
private resolve;
|
package/lib/config/envVars.js
CHANGED
|
@@ -337,7 +337,7 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
337
337
|
},
|
|
338
338
|
[EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT]: {
|
|
339
339
|
description: getMessage(EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT),
|
|
340
|
-
synonymOf:
|
|
340
|
+
synonymOf: EnvironmentVariable.SFDX_MAX_QUERY_LIMIT,
|
|
341
341
|
},
|
|
342
342
|
[EnvironmentVariable.SF_MDAPI_TEMP_DIR]: {
|
|
343
343
|
description: getMessage(EnvironmentVariable.SF_MDAPI_TEMP_DIR),
|
|
@@ -397,6 +397,9 @@ class EnvVars extends kit_1.Env {
|
|
|
397
397
|
super(env);
|
|
398
398
|
this.resolve();
|
|
399
399
|
}
|
|
400
|
+
static propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
|
|
401
|
+
return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
|
|
402
|
+
}
|
|
400
403
|
static defaultPrefix() {
|
|
401
404
|
if (process.argv[0].startsWith('sfdx'))
|
|
402
405
|
return 'SFDX_';
|
|
@@ -404,19 +407,11 @@ class EnvVars extends kit_1.Env {
|
|
|
404
407
|
return 'SF_';
|
|
405
408
|
return 'SFDX_';
|
|
406
409
|
}
|
|
407
|
-
propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
|
|
408
|
-
return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
|
|
409
|
-
}
|
|
410
|
-
setPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
|
|
411
|
-
const envName = this.propertyToEnvName(property, prefix);
|
|
412
|
-
const value = this.getString(envName);
|
|
413
|
-
if (value) {
|
|
414
|
-
this.setString(property, value);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
410
|
getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
|
|
418
|
-
|
|
419
|
-
|
|
411
|
+
var _a;
|
|
412
|
+
const envName = EnvVars.propertyToEnvName(property, prefix);
|
|
413
|
+
const synonym = (_a = exports.SUPPORTED_ENV_VARS[envName]) === null || _a === void 0 ? void 0 : _a.synonymOf;
|
|
414
|
+
return this.get(envName) || this.get(synonym);
|
|
420
415
|
}
|
|
421
416
|
asDictionary() {
|
|
422
417
|
return this.entries().reduce((accumulator, [key, value]) => {
|
package/lib/org/connection.js
CHANGED
|
@@ -21,6 +21,7 @@ const sfError_1 = require("../sfError");
|
|
|
21
21
|
const sfdc_1 = require("../util/sfdc");
|
|
22
22
|
const messages_1 = require("../messages");
|
|
23
23
|
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
24
|
+
const orgConfigProperties_1 = require("./orgConfigProperties");
|
|
24
25
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
25
26
|
const messages = messages_1.Messages.load('@salesforce/core', 'connection', [
|
|
26
27
|
'incorrectAPIVersionError',
|
|
@@ -332,7 +333,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
332
333
|
async autoFetchQuery(soql, queryOptions = {}) {
|
|
333
334
|
const config = await configAggregator_1.ConfigAggregator.create();
|
|
334
335
|
// take the limit from the calling function, then the config, then default 10,000
|
|
335
|
-
const maxFetch = config.getInfo(
|
|
336
|
+
const maxFetch = config.getInfo(orgConfigProperties_1.OrgConfigProperties.ORG_MAX_QUERY_LIMIT).value || queryOptions.maxFetch || 10000;
|
|
336
337
|
const options = Object.assign(queryOptions, {
|
|
337
338
|
autoFetch: true,
|
|
338
339
|
maxFetch,
|