@salesforce/core 3.13.1 → 3.15.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/config/config.d.ts +23 -1
  3. package/lib/config/config.js +24 -16
  4. package/lib/config/configAggregator.d.ts +37 -24
  5. package/lib/config/configAggregator.js +83 -41
  6. package/lib/config/envVars.js +3 -3
  7. package/lib/config/sandboxProcessCache.d.ts +15 -0
  8. package/lib/config/sandboxProcessCache.js +38 -0
  9. package/lib/exported.d.ts +5 -3
  10. package/lib/exported.js +8 -2
  11. package/lib/globalInfo/accessors/sandboxAccessor.d.ts +36 -0
  12. package/lib/globalInfo/accessors/sandboxAccessor.js +63 -0
  13. package/lib/globalInfo/globalInfoConfig.d.ts +2 -0
  14. package/lib/globalInfo/globalInfoConfig.js +5 -0
  15. package/lib/globalInfo/sfdxDataHandler.d.ts +12 -2
  16. package/lib/globalInfo/sfdxDataHandler.js +99 -4
  17. package/lib/globalInfo/types.d.ts +19 -1
  18. package/lib/globalInfo/types.js +1 -0
  19. package/lib/org/authInfo.d.ts +2 -1
  20. package/lib/org/authInfo.js +2 -1
  21. package/lib/org/connection.js +4 -4
  22. package/lib/org/org.d.ts +61 -39
  23. package/lib/org/org.js +261 -159
  24. package/lib/org/scratchOrgCache.d.ts +19 -0
  25. package/lib/org/scratchOrgCache.js +33 -0
  26. package/lib/org/scratchOrgCreate.d.ts +25 -16
  27. package/lib/org/scratchOrgCreate.js +110 -41
  28. package/lib/org/scratchOrgErrorCodes.d.ts +8 -2
  29. package/lib/org/scratchOrgErrorCodes.js +26 -3
  30. package/lib/org/scratchOrgInfoApi.d.ts +19 -8
  31. package/lib/org/scratchOrgInfoApi.js +91 -42
  32. package/lib/org/scratchOrgLifecycleEvents.d.ts +2 -0
  33. package/lib/org/scratchOrgLifecycleEvents.js +20 -1
  34. package/lib/org/scratchOrgSettingsGenerator.d.ts +7 -2
  35. package/lib/org/scratchOrgSettingsGenerator.js +1 -0
  36. package/lib/schema/validator.d.ts +7 -5
  37. package/lib/schema/validator.js +38 -63
  38. package/lib/sfProject.d.ts +2 -2
  39. package/lib/sfProject.js +3 -5
  40. package/lib/status/pollingClient.js +1 -0
  41. package/lib/testSetup.js +0 -2
  42. package/messages/org.md +9 -1
  43. package/messages/scratchOrgCreate.md +20 -0
  44. package/package.json +3 -3
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.1](https://github.com/forcedotcom/sfdx-core/compare/v3.15.0...v3.15.1) (2022-04-28)
6
+
7
+ ### Bug Fixes
8
+
9
+ - replace jsen ([664da58](https://github.com/forcedotcom/sfdx-core/commit/664da58cbe06019465ccf70ed17dfafb2425e06b))
10
+
11
+ ## [3.15.0](https://github.com/forcedotcom/sfdx-core/compare/v3.14.0...v3.15.0) (2022-04-26)
12
+
13
+ ### Features
14
+
15
+ - 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))
16
+
17
+ ## [3.14.0](https://github.com/forcedotcom/sfdx-core/compare/v3.13.1...v3.14.0) (2022-04-25)
18
+
19
+ ### Features
20
+
21
+ - add SfdxConfigAggregator ([#563](https://github.com/forcedotcom/sfdx-core/issues/563)) ([cd4debd](https://github.com/forcedotcom/sfdx-core/commit/cd4debdc99046580090b5d21bbd9da9030822d4a))
22
+
5
23
  ### [3.13.1](https://github.com/forcedotcom/sfdx-core/compare/v3.13.0...v3.13.1) (2022-04-21)
6
24
 
7
25
  ### Bug Fixes
@@ -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
+ }
@@ -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");
@@ -316,6 +316,13 @@ class Config extends configFile_1.ConfigFile {
316
316
  localConfig.clear();
317
317
  await localConfig.write();
318
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
+ }
319
326
  static propertyConfigMap() {
320
327
  return (0, kit_1.keyBy)(Config.allowedProperties, 'key');
321
328
  }
@@ -354,7 +361,7 @@ class Config extends configFile_1.ConfigFile {
354
361
  await this.cryptProperties(true);
355
362
  await super.write();
356
363
  if (global_1.Global.SFDX_INTEROPERABILITY)
357
- await this.sfdxConfig.writeSync();
364
+ await this.sfdxConfig.write();
358
365
  await this.cryptProperties(false);
359
366
  return this.getContents();
360
367
  }
@@ -499,25 +506,25 @@ class SfdxConfig {
499
506
  }
500
507
  return Object.assign(config, sfdxConfig);
501
508
  }
502
- readSync() {
509
+ async write(config = this.config.toObject()) {
503
510
  try {
504
- const contents = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getSfdxPath(), 'utf8'));
505
- return this.normalize(contents, 'toNew');
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));
506
515
  }
507
516
  catch (error) {
508
517
  /* Do nothing */
509
- return {};
510
518
  }
511
519
  }
512
- async writeSync(config = this.config.toObject()) {
520
+ readSync() {
513
521
  try {
514
- const sfdxPath = this.getSfdxPath();
515
- await mkdirp((0, path_1.dirname)(sfdxPath));
516
- const mapped = this.normalize(config, 'toOld');
517
- 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');
518
524
  }
519
525
  catch (error) {
520
526
  /* Do nothing */
527
+ return {};
521
528
  }
522
529
  }
523
530
  getSfdxPath() {
@@ -544,22 +551,23 @@ class SfdxConfig {
544
551
  * If toOld is specified: migrate all deprecated configs back to their original key.
545
552
  * - For example, target-org will be renamed to defaultusername.
546
553
  */
547
- normalize(contents, direction) {
554
+ translate(contents, direction) {
548
555
  var _a;
549
- const mapped = {};
556
+ const translated = {};
550
557
  for (const [key, value] of Object.entries(contents)) {
551
558
  const propConfig = direction === 'toNew'
552
559
  ? this.config.getPropertyConfig(key)
553
560
  : (_a = Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
554
561
  if (propConfig.deprecated && propConfig.newKey) {
555
562
  const normalizedKey = direction === 'toNew' ? propConfig.newKey : propConfig.key;
556
- mapped[normalizedKey] = value;
563
+ translated[normalizedKey] = value;
557
564
  }
558
565
  else {
559
- mapped[key] = value;
566
+ translated[key] = value;
560
567
  }
561
568
  }
562
- return mapped;
569
+ return translated;
563
570
  }
564
571
  }
572
+ exports.SfdxConfig = SfdxConfig;
565
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
- * `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
  *
@@ -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. `$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.
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: '$SFDX_LOG_LEVEL'}
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
- * `sfdx-config.json`. The resolution happens in the following bottom-up order:
19
+ * `config.json`. The resolution happens in the following bottom-up order:
22
20
  *
23
- * 1. Environment variables (`SFDX_LOG_LEVEL`)
24
- * 1. Workspace settings (`<workspace-root>/.sfdx/sfdx-config.json`)
25
- * 1. Global settings (`$HOME/.sfdx/sfdx-config.json`)
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. `$SFDX_LOG_LEVEL` if resolved to an environment variable.
181
- * 1. `./.sfdx/sfdx-config.json` if resolved to the local config.
182
- * 1. `~/.sfdx/sfdx-config.json` if resolved to the global config.
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: '$SFDX_LOG_LEVEL'}
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
@@ -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: null,
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: null,
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: null,
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 { ConfigInfo, ConfigAggregator } from './config/configAggregator';
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.User = exports.REQUIRED_FIELDS = 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.ConfigAggregator = 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.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);
@@ -0,0 +1,36 @@
1
+ import { Nullable } from '@salesforce/ts-types';
2
+ import { GlobalInfo } from '../globalInfoConfig';
3
+ import { SfSandbox, SfSandboxes } from '../types';
4
+ export declare class SandboxAccessor {
5
+ private globalInfo;
6
+ constructor(globalInfo: GlobalInfo);
7
+ /**
8
+ * Returns all the sandboxes (or all the sandboxes for a given prod org)
9
+ *
10
+ * @param entity entity as a string should be a production org username
11
+ * and when entity is a SfSandbox, the prod org entity.prodOrgUsername will
12
+ * used in the filter.
13
+ */
14
+ getAll(entity?: string | SfSandbox): SfSandboxes;
15
+ /**
16
+ * Returns the SfSandbox config entry that corresponds to the given
17
+ * sandbox org id if it exists
18
+ *
19
+ * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
20
+ */
21
+ get(sandboxOrgId?: string): Nullable<SfSandbox>;
22
+ /**
23
+ * Returns true if the given sandbox org id exists
24
+ *
25
+ * @param sandboxOrgId the sandboxOrgId that corresponds to a sandbox
26
+ */
27
+ has(sandboxOrgId?: string): boolean;
28
+ /**
29
+ * Set an sandboxOrgId for the given sandbox entity
30
+ *
31
+ * @param sandboxOrgId the sandboxOrgId you want to set
32
+ * @param entity the sandbox entity
33
+ */
34
+ set(sandboxOrgId: string, entity: SfSandbox): void;
35
+ unset(sandboxOrgId: string): void;
36
+ }