@salesforce/core 3.13.0 → 3.15.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.
- package/CHANGELOG.md +18 -0
- package/lib/config/config.d.ts +23 -1
- package/lib/config/config.js +28 -18
- package/lib/config/configAggregator.d.ts +37 -24
- package/lib/config/configAggregator.js +83 -41
- package/lib/config/envVars.js +3 -3
- package/lib/config/sandboxProcessCache.d.ts +15 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/exported.d.ts +5 -3
- package/lib/exported.js +8 -2
- package/lib/globalInfo/accessors/sandboxAccessor.d.ts +36 -0
- package/lib/globalInfo/accessors/sandboxAccessor.js +63 -0
- package/lib/globalInfo/globalInfoConfig.d.ts +2 -0
- package/lib/globalInfo/globalInfoConfig.js +5 -0
- package/lib/globalInfo/sfdxDataHandler.d.ts +12 -2
- package/lib/globalInfo/sfdxDataHandler.js +116 -25
- package/lib/globalInfo/types.d.ts +19 -1
- package/lib/globalInfo/types.js +1 -0
- package/lib/org/authInfo.d.ts +2 -1
- package/lib/org/authInfo.js +2 -1
- package/lib/org/connection.js +4 -4
- package/lib/org/org.d.ts +61 -39
- package/lib/org/org.js +261 -159
- package/lib/org/scratchOrgCache.d.ts +19 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +25 -16
- package/lib/org/scratchOrgCreate.js +110 -41
- package/lib/org/scratchOrgErrorCodes.d.ts +8 -2
- package/lib/org/scratchOrgErrorCodes.js +26 -3
- package/lib/org/scratchOrgInfoApi.d.ts +19 -8
- package/lib/org/scratchOrgInfoApi.js +91 -42
- package/lib/org/scratchOrgLifecycleEvents.d.ts +2 -0
- package/lib/org/scratchOrgLifecycleEvents.js +20 -1
- package/lib/org/scratchOrgSettingsGenerator.d.ts +7 -2
- package/lib/org/scratchOrgSettingsGenerator.js +1 -0
- package/lib/sfProject.js +1 -1
- package/lib/status/pollingClient.js +1 -0
- package/lib/testSetup.js +0 -2
- package/messages/org.md +9 -1
- package/messages/scratchOrgCreate.md +20 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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.15.0](https://github.com/forcedotcom/sfdx-core/compare/v3.14.0...v3.15.0) (2022-04-26)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- core changes to support create scratch and sandboxes ([#570](https://github.com/forcedotcom/sfdx-core/issues/570)) ([916eeb1](https://github.com/forcedotcom/sfdx-core/commit/916eeb1f96bebd5dce255f13c838ac0b10bf5b96))
|
|
10
|
+
|
|
11
|
+
## [3.14.0](https://github.com/forcedotcom/sfdx-core/compare/v3.13.1...v3.14.0) (2022-04-25)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- add SfdxConfigAggregator ([#563](https://github.com/forcedotcom/sfdx-core/issues/563)) ([cd4debd](https://github.com/forcedotcom/sfdx-core/commit/cd4debdc99046580090b5d21bbd9da9030822d4a))
|
|
16
|
+
|
|
17
|
+
### [3.13.1](https://github.com/forcedotcom/sfdx-core/compare/v3.13.0...v3.13.1) (2022-04-21)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- log rotation errors ([#564](https://github.com/forcedotcom/sfdx-core/issues/564)) ([8a4c9de](https://github.com/forcedotcom/sfdx-core/commit/8a4c9de85840ae0efa0ee8a27494d63a61545da5))
|
|
22
|
+
|
|
5
23
|
## [3.13.0](https://github.com/forcedotcom/sfdx-core/compare/v3.12.2...v3.13.0) (2022-04-20)
|
|
6
24
|
|
|
7
25
|
### Features
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonPrimitive } from '@salesforce/ts-types';
|
|
1
|
+
import { JsonPrimitive, Nullable } from '@salesforce/ts-types';
|
|
2
2
|
import { OrgConfigProperties } from '../org/orgConfigProperties';
|
|
3
3
|
import { ConfigFile } from './configFile';
|
|
4
4
|
import { ConfigContents, ConfigValue } from './configStore';
|
|
@@ -240,6 +240,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
240
240
|
* Clear all the configured properties both local and global.
|
|
241
241
|
*/
|
|
242
242
|
static clear(): Promise<void>;
|
|
243
|
+
static getPropertyConfigMeta(propertyName: string): Nullable<ConfigPropertyMeta>;
|
|
243
244
|
private static propertyConfigMap;
|
|
244
245
|
/**
|
|
245
246
|
* Read, assign, and return the config contents.
|
|
@@ -298,3 +299,24 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
298
299
|
*/
|
|
299
300
|
private cryptProperties;
|
|
300
301
|
}
|
|
302
|
+
export declare class SfdxConfig {
|
|
303
|
+
private options;
|
|
304
|
+
private config;
|
|
305
|
+
private sfdxPath;
|
|
306
|
+
constructor(options: ConfigFile.Options, config: Config);
|
|
307
|
+
/**
|
|
308
|
+
* If Global.SFDX_INTEROPERABILITY is enabled, merge the sfdx config into the sf config
|
|
309
|
+
*/
|
|
310
|
+
merge(config: ConfigProperties): ConfigProperties | undefined;
|
|
311
|
+
write(config?: import("@salesforce/ts-types").JsonMap): Promise<void>;
|
|
312
|
+
private readSync;
|
|
313
|
+
private getSfdxPath;
|
|
314
|
+
/**
|
|
315
|
+
* If toNew is specified: migrate all deprecated configs with a newKey to the newKey.
|
|
316
|
+
* - For example, defaultusername will be renamed to target-org.
|
|
317
|
+
*
|
|
318
|
+
* If toOld is specified: migrate all deprecated configs back to their original key.
|
|
319
|
+
* - For example, target-org will be renamed to defaultusername.
|
|
320
|
+
*/
|
|
321
|
+
private translate;
|
|
322
|
+
}
|
package/lib/config/config.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
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 = exports.SF_ALLOWED_PROPERTIES = exports.SfConfigProperties = 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
11
|
const fs = require("fs");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
@@ -42,7 +42,6 @@ const messages = messages_1.Messages.load('@salesforce/core', 'config', [
|
|
|
42
42
|
'instanceUrl',
|
|
43
43
|
'disable-telemetry',
|
|
44
44
|
]);
|
|
45
|
-
const log = logger_1.Logger.childFromRoot('core:config');
|
|
46
45
|
const SFDX_CONFIG_FILE_NAME = 'sfdx-config.json';
|
|
47
46
|
const CONFIG_FILE_NAME = 'config.json';
|
|
48
47
|
var SfConfigProperties;
|
|
@@ -277,9 +276,12 @@ class Config extends configFile_1.ConfigFile {
|
|
|
277
276
|
*/
|
|
278
277
|
static addAllowedProperties(metas) {
|
|
279
278
|
const currentMetaKeys = Object.keys(Config.propertyConfigMap());
|
|
279
|
+
// If logger is needed elsewhere in this file, do not move this outside of the Config class.
|
|
280
|
+
// It was causing issues with Bunyan log rotation. See https://github.com/forcedotcom/sfdx-core/pull/562
|
|
281
|
+
const logger = logger_1.Logger.childFromRoot('core:config');
|
|
280
282
|
metas.forEach((meta) => {
|
|
281
283
|
if (currentMetaKeys.includes(meta.key)) {
|
|
282
|
-
|
|
284
|
+
logger.info(`Key ${meta.key} already exists in allowedProperties, skipping.`);
|
|
283
285
|
return;
|
|
284
286
|
}
|
|
285
287
|
Config.allowedProperties.push(meta);
|
|
@@ -314,6 +316,13 @@ class Config extends configFile_1.ConfigFile {
|
|
|
314
316
|
localConfig.clear();
|
|
315
317
|
await localConfig.write();
|
|
316
318
|
}
|
|
319
|
+
static getPropertyConfigMeta(propertyName) {
|
|
320
|
+
const prop = Config.propertyConfigMap()[propertyName];
|
|
321
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.deprecated) && (prop === null || prop === void 0 ? void 0 : prop.newKey)) {
|
|
322
|
+
return Config.propertyConfigMap()[prop.newKey];
|
|
323
|
+
}
|
|
324
|
+
return prop;
|
|
325
|
+
}
|
|
317
326
|
static propertyConfigMap() {
|
|
318
327
|
return (0, kit_1.keyBy)(Config.allowedProperties, 'key');
|
|
319
328
|
}
|
|
@@ -352,7 +361,7 @@ class Config extends configFile_1.ConfigFile {
|
|
|
352
361
|
await this.cryptProperties(true);
|
|
353
362
|
await super.write();
|
|
354
363
|
if (global_1.Global.SFDX_INTEROPERABILITY)
|
|
355
|
-
await this.sfdxConfig.
|
|
364
|
+
await this.sfdxConfig.write();
|
|
356
365
|
await this.cryptProperties(false);
|
|
357
366
|
return this.getContents();
|
|
358
367
|
}
|
|
@@ -497,25 +506,25 @@ class SfdxConfig {
|
|
|
497
506
|
}
|
|
498
507
|
return Object.assign(config, sfdxConfig);
|
|
499
508
|
}
|
|
500
|
-
|
|
509
|
+
async write(config = this.config.toObject()) {
|
|
501
510
|
try {
|
|
502
|
-
const
|
|
503
|
-
|
|
511
|
+
const translated = this.translate(config, 'toOld');
|
|
512
|
+
const sfdxPath = this.getSfdxPath();
|
|
513
|
+
await mkdirp((0, path_1.dirname)(sfdxPath));
|
|
514
|
+
await fs.promises.writeFile(sfdxPath, JSON.stringify(translated, null, 2));
|
|
504
515
|
}
|
|
505
516
|
catch (error) {
|
|
506
517
|
/* Do nothing */
|
|
507
|
-
return {};
|
|
508
518
|
}
|
|
509
519
|
}
|
|
510
|
-
|
|
520
|
+
readSync() {
|
|
511
521
|
try {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
const mapped = this.normalize(config, 'toOld');
|
|
515
|
-
await fs.promises.writeFile(sfdxPath, JSON.stringify(mapped, null, 2));
|
|
522
|
+
const contents = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getSfdxPath(), 'utf8'));
|
|
523
|
+
return this.translate(contents, 'toNew');
|
|
516
524
|
}
|
|
517
525
|
catch (error) {
|
|
518
526
|
/* Do nothing */
|
|
527
|
+
return {};
|
|
519
528
|
}
|
|
520
529
|
}
|
|
521
530
|
getSfdxPath() {
|
|
@@ -542,22 +551,23 @@ class SfdxConfig {
|
|
|
542
551
|
* If toOld is specified: migrate all deprecated configs back to their original key.
|
|
543
552
|
* - For example, target-org will be renamed to defaultusername.
|
|
544
553
|
*/
|
|
545
|
-
|
|
554
|
+
translate(contents, direction) {
|
|
546
555
|
var _a;
|
|
547
|
-
const
|
|
556
|
+
const translated = {};
|
|
548
557
|
for (const [key, value] of Object.entries(contents)) {
|
|
549
558
|
const propConfig = direction === 'toNew'
|
|
550
559
|
? this.config.getPropertyConfig(key)
|
|
551
560
|
: (_a = Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
|
|
552
561
|
if (propConfig.deprecated && propConfig.newKey) {
|
|
553
562
|
const normalizedKey = direction === 'toNew' ? propConfig.newKey : propConfig.key;
|
|
554
|
-
|
|
563
|
+
translated[normalizedKey] = value;
|
|
555
564
|
}
|
|
556
565
|
else {
|
|
557
|
-
|
|
566
|
+
translated[key] = value;
|
|
558
567
|
}
|
|
559
568
|
}
|
|
560
|
-
return
|
|
569
|
+
return translated;
|
|
561
570
|
}
|
|
562
571
|
}
|
|
572
|
+
exports.SfdxConfig = SfdxConfig;
|
|
563
573
|
//# sourceMappingURL=config.js.map
|
|
@@ -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
|
-
* `
|
|
43
|
+
* `config.json`. The resolution happens in the following bottom-up order:
|
|
44
44
|
*
|
|
45
|
-
* 1. Environment variables (`
|
|
46
|
-
* 1. Workspace settings (`<workspace-root>/.
|
|
47
|
-
* 1. Global settings (`$HOME/.
|
|
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
|
*
|
|
@@ -67,12 +67,6 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
67
67
|
* @ignore
|
|
68
68
|
*/
|
|
69
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
70
|
static create<P, 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
|
|
@@ -81,6 +75,12 @@ 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
|
*/
|
|
@@ -123,9 +123,9 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
123
123
|
* Get a resolved file path or environment variable name of the property.
|
|
124
124
|
*
|
|
125
125
|
* For example, `getPath('logLevel')` will return:
|
|
126
|
-
* 1. `$
|
|
127
|
-
* 1. `./.
|
|
128
|
-
* 1. `~/.
|
|
126
|
+
* 1. `$SF_LOG_LEVEL` if resolved to an environment variable.
|
|
127
|
+
* 1. `./.sf/config.json` if resolved to the local config.
|
|
128
|
+
* 1. `~/.sf/config.json` if resolved to the global config.
|
|
129
129
|
* 1. `undefined`, if not resolved.
|
|
130
130
|
*
|
|
131
131
|
* **Note:** that the path returned may be the absolute path instead of
|
|
@@ -140,7 +140,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
140
140
|
* ```
|
|
141
141
|
* > console.log(aggregator.getConfigInfo());
|
|
142
142
|
* [
|
|
143
|
-
* { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$
|
|
143
|
+
* { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$SF_LOG_LEVEL'}
|
|
144
144
|
* { key: 'target-org', val: '<username>', location: 'Local', path: './.sf/config.json'}
|
|
145
145
|
* ]
|
|
146
146
|
* ```
|
|
@@ -170,6 +170,16 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
170
170
|
* Add an allowed config property.
|
|
171
171
|
*/
|
|
172
172
|
addAllowedProperties(configMetas: ConfigPropertyMeta | ConfigPropertyMeta[]): void;
|
|
173
|
+
/**
|
|
174
|
+
* Set the allowed properties.
|
|
175
|
+
*
|
|
176
|
+
* @param properties The properties to set.
|
|
177
|
+
*/
|
|
178
|
+
protected setAllowedProperties(properties: ConfigPropertyMeta[]): void;
|
|
179
|
+
/**
|
|
180
|
+
* Get the allowed properties.
|
|
181
|
+
*/
|
|
182
|
+
protected getAllowedProperties(): ConfigPropertyMeta[];
|
|
173
183
|
/**
|
|
174
184
|
* Loads all the properties and aggregates them according to location.
|
|
175
185
|
*/
|
|
@@ -179,16 +189,6 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
179
189
|
*/
|
|
180
190
|
private loadPropertiesSync;
|
|
181
191
|
private resolveProperties;
|
|
182
|
-
/**
|
|
183
|
-
* Get the allowed properties.
|
|
184
|
-
*/
|
|
185
|
-
private getAllowedProperties;
|
|
186
|
-
/**
|
|
187
|
-
* Set the allowed properties.
|
|
188
|
-
*
|
|
189
|
-
* @param properties The properties to set.
|
|
190
|
-
*/
|
|
191
|
-
private setAllowedProperties;
|
|
192
192
|
}
|
|
193
193
|
export declare namespace ConfigAggregator {
|
|
194
194
|
/**
|
|
@@ -209,3 +209,16 @@ export declare namespace ConfigAggregator {
|
|
|
209
209
|
ENVIRONMENT = "Environment"
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* A ConfigAggregator that will work with deprecated config vars (e.g. defaultusername, apiVersion).
|
|
214
|
+
* We do NOT recommend using this class unless you absolutelty have to.
|
|
215
|
+
*/
|
|
216
|
+
export declare class SfdxConfigAggregator extends ConfigAggregator {
|
|
217
|
+
getPropertyMeta(key: string): ConfigPropertyMeta;
|
|
218
|
+
getPropertyValue<T extends AnyJson>(key: string): Optional<T>;
|
|
219
|
+
getInfo(key: string): ConfigInfo;
|
|
220
|
+
getLocation(key: string): Optional<ConfigAggregator.Location>;
|
|
221
|
+
getPath(key: string): Optional<string>;
|
|
222
|
+
getConfigInfo(): ConfigInfo[];
|
|
223
|
+
private translate;
|
|
224
|
+
}
|
|
@@ -6,23 +6,21 @@
|
|
|
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.ConfigAggregator = void 0;
|
|
9
|
+
exports.SfdxConfigAggregator = exports.ConfigAggregator = void 0;
|
|
10
10
|
const kit_1 = require("@salesforce/kit");
|
|
11
11
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
-
const change_case_1 = require("change-case");
|
|
13
12
|
const messages_1 = require("../messages");
|
|
14
13
|
const envVars_1 = require("./envVars");
|
|
15
14
|
const config_1 = require("./config");
|
|
16
15
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
17
16
|
const messages = messages_1.Messages.load('@salesforce/core', 'config', ['unknownConfigKey', 'deprecatedConfigKey']);
|
|
18
|
-
const propertyToEnvName = (property, prefix = 'SFDX_') => `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
|
|
19
17
|
/**
|
|
20
18
|
* Aggregate global and local project config files, as well as environment variables for
|
|
21
|
-
* `
|
|
19
|
+
* `config.json`. The resolution happens in the following bottom-up order:
|
|
22
20
|
*
|
|
23
|
-
* 1. Environment variables (`
|
|
24
|
-
* 1. Workspace settings (`<workspace-root>/.
|
|
25
|
-
* 1. Global settings (`$HOME/.
|
|
21
|
+
* 1. Environment variables (`SF_LOG_LEVEL`)
|
|
22
|
+
* 1. Workspace settings (`<workspace-root>/.sf/config.json`)
|
|
23
|
+
* 1. Global settings (`$HOME/.sf/config.json`)
|
|
26
24
|
*
|
|
27
25
|
* Use {@link ConfigAggregator.create} to instantiate the aggregator.
|
|
28
26
|
*
|
|
@@ -55,20 +53,6 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
55
53
|
get config() {
|
|
56
54
|
return this.resolveProperties(this.globalConfig.getContents(), this.localConfig && this.localConfig.getContents());
|
|
57
55
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Get the static ConfigAggregator instance. If one doesn't exist, one will be created with
|
|
60
|
-
* the **encrypted** config values. Encrypted config values need to be resolved
|
|
61
|
-
* asynchronously by calling {@link ConfigAggregator.reload}
|
|
62
|
-
*/
|
|
63
|
-
// Use typing from AsyncOptionalCreatable to support extending ConfigAggregator.
|
|
64
|
-
// We really don't want ConfigAggregator extended but typescript doesn't support a final.
|
|
65
|
-
static getInstance() {
|
|
66
|
-
if (!ConfigAggregator.instance) {
|
|
67
|
-
ConfigAggregator.instance = new this();
|
|
68
|
-
ConfigAggregator.instance.loadPropertiesSync();
|
|
69
|
-
}
|
|
70
|
-
return ConfigAggregator.instance;
|
|
71
|
-
}
|
|
72
56
|
// Use typing from AsyncOptionalCreatable to support extending ConfigAggregator.
|
|
73
57
|
// We really don't want ConfigAggregator extended but typescript doesn't support a final.
|
|
74
58
|
static async create(options) {
|
|
@@ -91,6 +75,20 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
91
75
|
static getValue(key) {
|
|
92
76
|
return this.getInstance().getInfo(key);
|
|
93
77
|
}
|
|
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
|
+
// Use typing from AsyncOptionalCreatable to support extending ConfigAggregator.
|
|
84
|
+
// We really don't want ConfigAggregator extended but typescript doesn't support a final.
|
|
85
|
+
static getInstance() {
|
|
86
|
+
if (!ConfigAggregator.instance) {
|
|
87
|
+
ConfigAggregator.instance = new this();
|
|
88
|
+
ConfigAggregator.instance.loadPropertiesSync();
|
|
89
|
+
}
|
|
90
|
+
return ConfigAggregator.instance;
|
|
91
|
+
}
|
|
94
92
|
/**
|
|
95
93
|
* Initialize this instances async dependencies.
|
|
96
94
|
*/
|
|
@@ -106,7 +104,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
106
104
|
*/
|
|
107
105
|
getPropertyValue(key) {
|
|
108
106
|
if (this.getAllowedProperties().some((element) => key === element.key)) {
|
|
109
|
-
return this.getConfig()[key];
|
|
107
|
+
return this.getConfig()[key] || this.getEnvVars().get(key);
|
|
110
108
|
}
|
|
111
109
|
else {
|
|
112
110
|
throw messages.createError('unknownConfigKey', [key]);
|
|
@@ -177,9 +175,9 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
177
175
|
* Get a resolved file path or environment variable name of the property.
|
|
178
176
|
*
|
|
179
177
|
* For example, `getPath('logLevel')` will return:
|
|
180
|
-
* 1. `$
|
|
181
|
-
* 1. `./.
|
|
182
|
-
* 1. `~/.
|
|
178
|
+
* 1. `$SF_LOG_LEVEL` if resolved to an environment variable.
|
|
179
|
+
* 1. `./.sf/config.json` if resolved to the local config.
|
|
180
|
+
* 1. `~/.sf/config.json` if resolved to the global config.
|
|
183
181
|
* 1. `undefined`, if not resolved.
|
|
184
182
|
*
|
|
185
183
|
* **Note:** that the path returned may be the absolute path instead of
|
|
@@ -189,7 +187,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
189
187
|
*/
|
|
190
188
|
getPath(key) {
|
|
191
189
|
if (this.envVars.getString(key) != null) {
|
|
192
|
-
return `$${propertyToEnvName(key)}`;
|
|
190
|
+
return `$${this.envVars.propertyToEnvName(key)}`;
|
|
193
191
|
}
|
|
194
192
|
if (this.localConfig && this.localConfig.getContents()[key] != null) {
|
|
195
193
|
return this.localConfig.getPath();
|
|
@@ -204,7 +202,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
204
202
|
* ```
|
|
205
203
|
* > console.log(aggregator.getConfigInfo());
|
|
206
204
|
* [
|
|
207
|
-
* { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$
|
|
205
|
+
* { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$SF_LOG_LEVEL'}
|
|
208
206
|
* { key: 'target-org', val: '<username>', location: 'Local', path: './.sf/config.json'}
|
|
209
207
|
* ]
|
|
210
208
|
* ```
|
|
@@ -258,6 +256,20 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
258
256
|
this.allowedProperties.push(configMetas);
|
|
259
257
|
}
|
|
260
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Set the allowed properties.
|
|
261
|
+
*
|
|
262
|
+
* @param properties The properties to set.
|
|
263
|
+
*/
|
|
264
|
+
setAllowedProperties(properties) {
|
|
265
|
+
this.allowedProperties = properties;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Get the allowed properties.
|
|
269
|
+
*/
|
|
270
|
+
getAllowedProperties() {
|
|
271
|
+
return this.allowedProperties;
|
|
272
|
+
}
|
|
261
273
|
/**
|
|
262
274
|
* Loads all the properties and aggregates them according to location.
|
|
263
275
|
*/
|
|
@@ -288,21 +300,51 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
288
300
|
const reduced = configs.filter(ts_types_1.isJsonMap).reduce((acc, el) => (0, kit_1.merge)(acc, el), json);
|
|
289
301
|
return reduced;
|
|
290
302
|
}
|
|
291
|
-
/**
|
|
292
|
-
* Get the allowed properties.
|
|
293
|
-
*/
|
|
294
|
-
getAllowedProperties() {
|
|
295
|
-
return this.allowedProperties;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Set the allowed properties.
|
|
299
|
-
*
|
|
300
|
-
* @param properties The properties to set.
|
|
301
|
-
*/
|
|
302
|
-
setAllowedProperties(properties) {
|
|
303
|
-
this.allowedProperties = properties;
|
|
304
|
-
}
|
|
305
303
|
}
|
|
306
304
|
exports.ConfigAggregator = ConfigAggregator;
|
|
307
305
|
ConfigAggregator.encrypted = true;
|
|
306
|
+
/**
|
|
307
|
+
* A ConfigAggregator that will work with deprecated config vars (e.g. defaultusername, apiVersion).
|
|
308
|
+
* We do NOT recommend using this class unless you absolutelty have to.
|
|
309
|
+
*/
|
|
310
|
+
class SfdxConfigAggregator extends ConfigAggregator {
|
|
311
|
+
getPropertyMeta(key) {
|
|
312
|
+
const match = this.getAllowedProperties().find((element) => key === element.key);
|
|
313
|
+
if ((match === null || match === void 0 ? void 0 : match.deprecated) && (match === null || match === void 0 ? void 0 : match.newKey)) {
|
|
314
|
+
return this.getPropertyMeta(match.newKey);
|
|
315
|
+
}
|
|
316
|
+
else if (match) {
|
|
317
|
+
return match;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
throw messages.createError('unknownConfigKey', [key]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
getPropertyValue(key) {
|
|
324
|
+
return super.getPropertyValue(this.translate(key));
|
|
325
|
+
}
|
|
326
|
+
getInfo(key) {
|
|
327
|
+
return super.getInfo(this.translate(key));
|
|
328
|
+
}
|
|
329
|
+
getLocation(key) {
|
|
330
|
+
return super.getLocation(this.translate(key));
|
|
331
|
+
}
|
|
332
|
+
getPath(key) {
|
|
333
|
+
return super.getPath(this.translate(key));
|
|
334
|
+
}
|
|
335
|
+
getConfigInfo() {
|
|
336
|
+
return super.getConfigInfo().map((c) => {
|
|
337
|
+
c.key = this.translate(c.key, 'toOld');
|
|
338
|
+
return c;
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
translate(key, direction = 'toNew') {
|
|
342
|
+
var _a;
|
|
343
|
+
const propConfig = direction === 'toNew'
|
|
344
|
+
? this.getPropertyMeta(key)
|
|
345
|
+
: (_a = config_1.Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
|
|
346
|
+
return propConfig.key || key;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
exports.SfdxConfigAggregator = SfdxConfigAggregator;
|
|
308
350
|
//# sourceMappingURL=configAggregator.js.map
|
package/lib/config/envVars.js
CHANGED
|
@@ -260,11 +260,11 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
260
260
|
},
|
|
261
261
|
[EnvironmentVariable.SF_TARGET_ORG]: {
|
|
262
262
|
description: getMessage(EnvironmentVariable.SF_TARGET_ORG),
|
|
263
|
-
synonymOf:
|
|
263
|
+
synonymOf: EnvironmentVariable.SFDX_DEFAULTUSERNAME,
|
|
264
264
|
},
|
|
265
265
|
[EnvironmentVariable.SF_TARGET_DEV_HUB]: {
|
|
266
266
|
description: getMessage(EnvironmentVariable.SF_TARGET_DEV_HUB),
|
|
267
|
-
synonymOf:
|
|
267
|
+
synonymOf: EnvironmentVariable.SFDX_DEFAULTDEVHUBUSERNAME,
|
|
268
268
|
},
|
|
269
269
|
// sf vars
|
|
270
270
|
[EnvironmentVariable.SF_ACCESS_TOKEN]: {
|
|
@@ -273,7 +273,7 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
273
273
|
},
|
|
274
274
|
[EnvironmentVariable.SF_ORG_API_VERSION]: {
|
|
275
275
|
description: getMessage(EnvironmentVariable.SF_ORG_API_VERSION),
|
|
276
|
-
synonymOf:
|
|
276
|
+
synonymOf: EnvironmentVariable.SFDX_API_VERSION,
|
|
277
277
|
},
|
|
278
278
|
[EnvironmentVariable.SF_AUDIENCE_URL]: {
|
|
279
279
|
description: getMessage(EnvironmentVariable.SF_AUDIENCE_URL),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SandboxProcessObject, SandboxRequest } from '../org';
|
|
2
|
+
import { TTLConfig } from './ttlConfig';
|
|
3
|
+
export declare type SandboxRequestCacheEntry = {
|
|
4
|
+
alias?: string;
|
|
5
|
+
setDefault: boolean;
|
|
6
|
+
prodOrgUsername: string;
|
|
7
|
+
sandboxProcessObject: Partial<SandboxProcessObject>;
|
|
8
|
+
sandboxRequest: Partial<SandboxRequest>;
|
|
9
|
+
};
|
|
10
|
+
export declare class SandboxRequestCache extends TTLConfig<TTLConfig.Options, SandboxRequestCacheEntry> {
|
|
11
|
+
static getDefaultOptions(): TTLConfig.Options;
|
|
12
|
+
static unset(key: string): Promise<void>;
|
|
13
|
+
static set(key: string, sandboxProcessObject: SandboxRequestCacheEntry): Promise<void>;
|
|
14
|
+
static getFileName(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxRequestCache = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const kit_1 = require("@salesforce/kit");
|
|
11
|
+
const global_1 = require("../global");
|
|
12
|
+
const ttlConfig_1 = require("./ttlConfig");
|
|
13
|
+
class SandboxRequestCache extends ttlConfig_1.TTLConfig {
|
|
14
|
+
static getDefaultOptions() {
|
|
15
|
+
return {
|
|
16
|
+
isGlobal: true,
|
|
17
|
+
isState: true,
|
|
18
|
+
filename: SandboxRequestCache.getFileName(),
|
|
19
|
+
stateFolder: global_1.Global.SF_STATE_FOLDER,
|
|
20
|
+
ttl: kit_1.Duration.days(14),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static async unset(key) {
|
|
24
|
+
const cache = await SandboxRequestCache.create();
|
|
25
|
+
cache.unset(key);
|
|
26
|
+
await cache.write();
|
|
27
|
+
}
|
|
28
|
+
static async set(key, sandboxProcessObject) {
|
|
29
|
+
const cache = await SandboxRequestCache.create();
|
|
30
|
+
cache.set(key, sandboxProcessObject);
|
|
31
|
+
await cache.write();
|
|
32
|
+
}
|
|
33
|
+
static getFileName() {
|
|
34
|
+
return 'sandbox-create-cache.json';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SandboxRequestCache = SandboxRequestCache;
|
|
38
|
+
//# sourceMappingURL=sandboxProcessCache.js.map
|
package/lib/exported.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export { GlobalInfo, SfEntry, SfInfo, SfInfoKeys, SfOrg, SfOrgs, SfToken, SfToke
|
|
|
7
7
|
export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } from './deviceOauthService';
|
|
8
8
|
export { OrgUsersConfig } from './config/orgUsersConfig';
|
|
9
9
|
export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config, SfdxPropertyKeys, SfConfigProperties, SFDX_ALLOWED_PROPERTIES, SF_ALLOWED_PROPERTIES, } from './config/config';
|
|
10
|
-
export {
|
|
10
|
+
export { SandboxRequestCacheEntry, SandboxRequestCache } from './config/sandboxProcessCache';
|
|
11
|
+
export { ConfigInfo, ConfigAggregator, SfdxConfigAggregator } from './config/configAggregator';
|
|
11
12
|
export { AuthFields, AuthInfo, AuthSideEffects, OrgAuthorization } from './org/authInfo';
|
|
12
13
|
export { AuthRemover } from './org/authRemover';
|
|
13
14
|
export { Connection, SFDX_HTTP_HEADERS } from './org/connection';
|
|
@@ -18,7 +19,7 @@ export { SfdcUrl } from './util/sfdcUrl';
|
|
|
18
19
|
export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
|
|
19
20
|
export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
|
|
20
21
|
export { Messages, StructuredMessage } from './messages';
|
|
21
|
-
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
|
|
22
|
+
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, ResumeSandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
|
|
22
23
|
export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
|
|
23
24
|
export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson, SfdxProject, SfdxProjectJson, } from './sfProject';
|
|
24
25
|
export { SchemaPrinter } from './schema/printer';
|
|
@@ -29,8 +30,9 @@ export { CometClient, CometSubscription, StreamingClient, StatusResult } from '.
|
|
|
29
30
|
export { MyDomainResolver } from './status/myDomainResolver';
|
|
30
31
|
export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
|
|
31
32
|
export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
|
|
32
|
-
export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate } from './org/scratchOrgCreate';
|
|
33
|
+
export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate, scratchOrgResume, } from './org/scratchOrgCreate';
|
|
33
34
|
export { ScratchOrgInfo } from './org/scratchOrgTypes';
|
|
34
35
|
export { ScratchOrgLifecycleEvent, scratchOrgLifecycleEventName, scratchOrgLifecycleStages, } from './org/scratchOrgLifecycleEvents';
|
|
36
|
+
export { ScratchOrgCache } from './org/scratchOrgCache';
|
|
35
37
|
export * from './util/sfdc';
|
|
36
38
|
export * from './util/sfdcUrl';
|
package/lib/exported.js
CHANGED
|
@@ -16,8 +16,8 @@ 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.
|
|
20
|
-
exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = exports.scratchOrgCreate = exports.PermissionSetAssignment = void 0;
|
|
19
|
+
exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = 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.SfdxConfigAggregator = exports.ConfigAggregator = exports.SandboxRequestCache = exports.SF_ALLOWED_PROPERTIES = exports.SFDX_ALLOWED_PROPERTIES = exports.SfConfigProperties = 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.TTLConfig = exports.ConfigFile = void 0;
|
|
20
|
+
exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = exports.scratchOrgResume = exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = void 0;
|
|
21
21
|
const messages_1 = require("./messages");
|
|
22
22
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
23
23
|
var configFile_1 = require("./config/configFile");
|
|
@@ -44,8 +44,11 @@ Object.defineProperty(exports, "SfdxPropertyKeys", { enumerable: true, get: func
|
|
|
44
44
|
Object.defineProperty(exports, "SfConfigProperties", { enumerable: true, get: function () { return config_1.SfConfigProperties; } });
|
|
45
45
|
Object.defineProperty(exports, "SFDX_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return config_1.SFDX_ALLOWED_PROPERTIES; } });
|
|
46
46
|
Object.defineProperty(exports, "SF_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return config_1.SF_ALLOWED_PROPERTIES; } });
|
|
47
|
+
var sandboxProcessCache_1 = require("./config/sandboxProcessCache");
|
|
48
|
+
Object.defineProperty(exports, "SandboxRequestCache", { enumerable: true, get: function () { return sandboxProcessCache_1.SandboxRequestCache; } });
|
|
47
49
|
var configAggregator_1 = require("./config/configAggregator");
|
|
48
50
|
Object.defineProperty(exports, "ConfigAggregator", { enumerable: true, get: function () { return configAggregator_1.ConfigAggregator; } });
|
|
51
|
+
Object.defineProperty(exports, "SfdxConfigAggregator", { enumerable: true, get: function () { return configAggregator_1.SfdxConfigAggregator; } });
|
|
49
52
|
var authInfo_1 = require("./org/authInfo");
|
|
50
53
|
Object.defineProperty(exports, "AuthInfo", { enumerable: true, get: function () { return authInfo_1.AuthInfo; } });
|
|
51
54
|
var authRemover_1 = require("./org/authRemover");
|
|
@@ -103,9 +106,12 @@ var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
|
|
|
103
106
|
Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, get: function () { return permissionSetAssignment_1.PermissionSetAssignment; } });
|
|
104
107
|
var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
|
|
105
108
|
Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
|
|
109
|
+
Object.defineProperty(exports, "scratchOrgResume", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgResume; } });
|
|
106
110
|
var scratchOrgLifecycleEvents_1 = require("./org/scratchOrgLifecycleEvents");
|
|
107
111
|
Object.defineProperty(exports, "scratchOrgLifecycleEventName", { enumerable: true, get: function () { return scratchOrgLifecycleEvents_1.scratchOrgLifecycleEventName; } });
|
|
108
112
|
Object.defineProperty(exports, "scratchOrgLifecycleStages", { enumerable: true, get: function () { return scratchOrgLifecycleEvents_1.scratchOrgLifecycleStages; } });
|
|
113
|
+
var scratchOrgCache_1 = require("./org/scratchOrgCache");
|
|
114
|
+
Object.defineProperty(exports, "ScratchOrgCache", { enumerable: true, get: function () { return scratchOrgCache_1.ScratchOrgCache; } });
|
|
109
115
|
// Utility sub-modules
|
|
110
116
|
__exportStar(require("./util/sfdc"), exports);
|
|
111
117
|
__exportStar(require("./util/sfdcUrl"), exports);
|