@salesforce/core 3.7.6 → 3.7.9

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 (58) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -4
  3. package/lib/config/config.d.ts +7 -5
  4. package/lib/config/config.js +14 -9
  5. package/lib/config/configAggregator.d.ts +2 -2
  6. package/lib/config/configAggregator.js +2 -2
  7. package/lib/config/configFile.d.ts +2 -2
  8. package/lib/config/configFile.js +22 -20
  9. package/lib/config/configStore.js +5 -5
  10. package/lib/config/keychainConfig.js +4 -3
  11. package/lib/crypto/keyChainImpl.js +12 -10
  12. package/lib/deviceOauthService.js +2 -2
  13. package/lib/exported.d.ts +3 -4
  14. package/lib/exported.js +9 -7
  15. package/lib/global.js +2 -2
  16. package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
  17. package/lib/globalInfo/sfdxDataHandler.d.ts +1 -1
  18. package/lib/globalInfo/sfdxDataHandler.js +5 -4
  19. package/lib/logger.d.ts +3 -3
  20. package/lib/logger.js +21 -19
  21. package/lib/messages.d.ts +42 -3
  22. package/lib/messages.js +55 -12
  23. package/lib/org/authInfo.d.ts +1 -1
  24. package/lib/org/authInfo.js +6 -6
  25. package/lib/org/authRemover.d.ts +2 -2
  26. package/lib/org/authRemover.js +2 -2
  27. package/lib/org/connection.d.ts +1 -1
  28. package/lib/org/connection.js +4 -4
  29. package/lib/org/org.d.ts +4 -4
  30. package/lib/org/org.js +16 -16
  31. package/lib/org/permissionSetAssignment.js +2 -2
  32. package/lib/org/scratchOrgCreate.js +4 -4
  33. package/lib/org/scratchOrgErrorCodes.js +6 -6
  34. package/lib/org/scratchOrgInfoApi.js +16 -16
  35. package/lib/org/scratchOrgInfoGenerator.d.ts +3 -3
  36. package/lib/org/scratchOrgInfoGenerator.js +17 -17
  37. package/lib/org/scratchOrgSettingsGenerator.js +2 -2
  38. package/lib/org/user.js +4 -4
  39. package/lib/schema/printer.js +2 -2
  40. package/lib/schema/validator.d.ts +4 -4
  41. package/lib/schema/validator.js +13 -13
  42. package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -14
  43. package/lib/{sfdxError.js → sfError.js} +20 -21
  44. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
  45. package/lib/{sfdxProject.js → sfProject.js} +77 -65
  46. package/lib/status/pollingClient.js +3 -3
  47. package/lib/status/streamingClient.d.ts +2 -2
  48. package/lib/status/streamingClient.js +6 -6
  49. package/lib/testSetup.d.ts +4 -4
  50. package/lib/testSetup.js +8 -8
  51. package/lib/util/internal.d.ts +28 -2
  52. package/lib/util/internal.js +64 -6
  53. package/lib/util/sfdcUrl.d.ts +2 -2
  54. package/lib/util/sfdcUrl.js +2 -2
  55. package/lib/webOAuthServer.js +10 -10
  56. package/package.json +5 -5
  57. package/lib/util/fs.d.ts +0 -201
  58. package/lib/util/fs.js +0 -378
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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.7.9](https://github.com/forcedotcom/sfdx-core/compare/v3.7.8...v3.7.9) (2022-03-04)
6
+
7
+ ### Bug Fixes
8
+
9
+ - error literal to match the error thrown ([#533](https://github.com/forcedotcom/sfdx-core/issues/533)) ([b91ce5c](https://github.com/forcedotcom/sfdx-core/commit/b91ce5c329c9b2b88fb4b0ad028aee5f6d5b6e77))
10
+
11
+ ### [3.7.8](https://github.com/forcedotcom/sfdx-core/compare/v3.7.7...v3.7.8) (2022-03-03)
12
+
13
+ ### Bug Fixes
14
+
15
+ - add create warning and info convenience functions ([#526](https://github.com/forcedotcom/sfdx-core/issues/526)) ([e3428b3](https://github.com/forcedotcom/sfdx-core/commit/e3428b35e00b9cee3c90153ed6ce08b352535ff7))
16
+
17
+ ### [3.7.7](https://github.com/forcedotcom/sfdx-core/compare/v3.7.6...v3.7.7) (2022-03-01)
18
+
5
19
  ### [3.7.6](https://github.com/forcedotcom/sfdx-core/compare/v4.0.0...v3.7.6) (2022-02-28)
6
20
 
7
21
  ## [4.0.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v4.0.0) (2022-02-28)
package/README.md CHANGED
@@ -52,7 +52,7 @@ describe('Mocking Auth data', () => {
52
52
  After having a valid AuthInfo object you can then create fake connections to a Salesforce.com scratch org. This allows for writing tests that can validate result responses for SOQL queries and REST endpoints.
53
53
 
54
54
  ```typescript
55
- import { AuthInfo, Connection, SfdxError } from '@salesforce/core';
55
+ import { AuthInfo, Connection, SfError } from '@salesforce/core';
56
56
  import { MockTestOrgData, testSetup } from '@salesforce/core/lib/testSetup';
57
57
  import { AnyJson, ensureJsonMap, JsonMap } from '@salesforce/ts-types';
58
58
  import { ensureString } from '@salesforce/ts-types';
@@ -77,7 +77,7 @@ describe('Mocking a force server call', () => {
77
77
  if (request && ensureString(_request.url).includes('Account')) {
78
78
  return Promise.resolve(records);
79
79
  } else {
80
- return Promise.reject(new SfdxError(`Unexpected request: ${_request.url}`));
80
+ return Promise.reject(new SfError(`Unexpected request: ${_request.url}`));
81
81
  }
82
82
  };
83
83
  const connection: Connection = await Connection.create({
@@ -117,13 +117,13 @@ describe('Using the built in Sinon sandbox.', () => {
117
117
  It's important to have negative tests that ensure proper error handling. With `shouldThrow` it's easy to test for expected async rejections.
118
118
 
119
119
  ```typescript
120
- import { SfdxError } from '@salesforce/core';
120
+ import { SfError } from '@salesforce/core';
121
121
  import { shouldThrow } from '@salesforce/core/lib/testSetup';
122
122
  import { strictEqual } from 'assert';
123
123
 
124
124
  class TestObject {
125
125
  public static async method() {
126
- throw new SfdxError('Error', 'ExpectedError');
126
+ throw new SfError('Error', 'ExpectedError');
127
127
  }
128
128
  }
129
129
 
@@ -56,12 +56,14 @@ export declare enum SfdxPropertyKeys {
56
56
  * Username associated with the default dev hub org.
57
57
  *
58
58
  * @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
59
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
59
60
  */
60
61
  DEFAULT_DEV_HUB_USERNAME = "defaultdevhubusername",
61
62
  /**
62
63
  * Username associate with the default org.
63
64
  *
64
65
  * @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
66
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
65
67
  */
66
68
  DEFAULT_USERNAME = "defaultusername",
67
69
  /**
@@ -202,7 +204,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
202
204
  * DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
203
205
  * Call {@link SfdxConfig.write} instead.
204
206
  *
205
- * **Throws** *{@link SfdxError}{ name: 'InvalidWriteError' }* Always.
207
+ * **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
206
208
  *
207
209
  * @param newContents Contents to write
208
210
  */
@@ -210,8 +212,8 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
210
212
  /**
211
213
  * Sets a value for a property.
212
214
  *
213
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
214
- * **Throws** *{@link SfdxError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
215
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
216
+ * **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
215
217
  *
216
218
  * @param key The property to set.
217
219
  * @param value The value of the property.
@@ -220,7 +222,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
220
222
  /**
221
223
  * Unsets a value for a property.
222
224
  *
223
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
225
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
224
226
  *
225
227
  * @param key The property to unset.
226
228
  */
@@ -228,7 +230,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
228
230
  /**
229
231
  * Get an individual property config.
230
232
  *
231
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
233
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
232
234
  *
233
235
  * @param propertyName The name of the property.
234
236
  */
@@ -8,13 +8,14 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Config = exports.SfProperty = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = void 0;
10
10
  const path_1 = require("path");
11
+ const fs = require("fs");
11
12
  const kit_1 = require("@salesforce/kit");
12
13
  const ts_types_1 = require("@salesforce/ts-types");
14
+ const mkdirp = require("mkdirp");
13
15
  const global_1 = require("../global");
14
16
  const logger_1 = require("../logger");
15
17
  const messages_1 = require("../messages");
16
18
  const sfdc_1 = require("../util/sfdc");
17
- const fs_1 = require("../util/fs");
18
19
  const sfdcUrl_1 = require("../util/sfdcUrl");
19
20
  const orgConfigProperties_1 = require("../org/orgConfigProperties");
20
21
  const configFile_1 = require("./configFile");
@@ -49,12 +50,14 @@ var SfdxPropertyKeys;
49
50
  * Username associated with the default dev hub org.
50
51
  *
51
52
  * @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
53
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
52
54
  */
53
55
  SfdxPropertyKeys["DEFAULT_DEV_HUB_USERNAME"] = "defaultdevhubusername";
54
56
  /**
55
57
  * Username associate with the default org.
56
58
  *
57
59
  * @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
60
+ * will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
58
61
  */
59
62
  SfdxPropertyKeys["DEFAULT_USERNAME"] = "defaultusername";
60
63
  /**
@@ -115,12 +118,14 @@ exports.SFDX_ALLOWED_PROPERTIES = [
115
118
  },
116
119
  },
117
120
  {
121
+ // will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
118
122
  key: SfdxPropertyKeys.DEFAULT_DEV_HUB_USERNAME,
119
123
  newKey: orgConfigProperties_1.OrgConfigProperties.TARGET_DEV_HUB,
120
124
  deprecated: true,
121
125
  description: messages.getMessage('defaultDevHubUsername'),
122
126
  },
123
127
  {
128
+ // will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
124
129
  key: SfdxPropertyKeys.DEFAULT_USERNAME,
125
130
  newKey: orgConfigProperties_1.OrgConfigProperties.TARGET_ORG,
126
131
  deprecated: true,
@@ -308,7 +313,7 @@ class Config extends configFile_1.ConfigFile {
308
313
  * DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
309
314
  * Call {@link SfdxConfig.write} instead.
310
315
  *
311
- * **Throws** *{@link SfdxError}{ name: 'InvalidWriteError' }* Always.
316
+ * **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
312
317
  *
313
318
  * @param newContents Contents to write
314
319
  */
@@ -319,8 +324,8 @@ class Config extends configFile_1.ConfigFile {
319
324
  /**
320
325
  * Sets a value for a property.
321
326
  *
322
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
323
- * **Throws** *{@link SfdxError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
327
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
328
+ * **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
324
329
  *
325
330
  * @param key The property to set.
326
331
  * @param value The value of the property.
@@ -355,7 +360,7 @@ class Config extends configFile_1.ConfigFile {
355
360
  /**
356
361
  * Unsets a value for a property.
357
362
  *
358
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
363
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
359
364
  *
360
365
  * @param key The property to unset.
361
366
  */
@@ -372,7 +377,7 @@ class Config extends configFile_1.ConfigFile {
372
377
  /**
373
378
  * Get an individual property config.
374
379
  *
375
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
380
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
376
381
  *
377
382
  * @param propertyName The name of the property.
378
383
  */
@@ -446,7 +451,7 @@ class SfdxConfig {
446
451
  }
447
452
  readSync() {
448
453
  try {
449
- const contents = fs_1.fs.readJsonMapSync(this.getSfdxPath());
454
+ const contents = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getSfdxPath(), 'utf8'));
450
455
  return this.normalize(contents, 'toNew');
451
456
  }
452
457
  catch (error) {
@@ -457,9 +462,9 @@ class SfdxConfig {
457
462
  async writeSync(config = this.config.toObject()) {
458
463
  try {
459
464
  const sfdxPath = this.getSfdxPath();
460
- await fs_1.fs.mkdirp((0, path_1.dirname)(sfdxPath));
465
+ await mkdirp((0, path_1.dirname)(sfdxPath));
461
466
  const mapped = this.normalize(config, 'toOld');
462
- await fs_1.fs.writeJson(sfdxPath, mapped);
467
+ await fs.promises.writeFile(sfdxPath, JSON.stringify(mapped, null, 2));
463
468
  }
464
469
  catch (error) {
465
470
  /* Do nothing */
@@ -88,7 +88,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
88
88
  /**
89
89
  * Get a resolved config property.
90
90
  *
91
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
91
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
92
92
  *
93
93
  * @param key The key of the property.
94
94
  */
@@ -96,7 +96,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
96
96
  /**
97
97
  * Get a resolved config property meta.
98
98
  *
99
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
99
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
100
100
  *
101
101
  * @param key The key of the property.
102
102
  */
@@ -100,7 +100,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
100
100
  /**
101
101
  * Get a resolved config property.
102
102
  *
103
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
103
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
104
104
  *
105
105
  * @param key The key of the property.
106
106
  */
@@ -115,7 +115,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
115
115
  /**
116
116
  * Get a resolved config property meta.
117
117
  *
118
- * **Throws** *{@link SfdxError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
118
+ * **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
119
119
  *
120
120
  * @param key The key of the property.
121
121
  */
@@ -78,7 +78,7 @@ export declare class ConfigFile<T extends ConfigFile.Options = ConfigFile.Option
78
78
  * Read the config file and set the config contents. Returns the config contents of the config file. As an
79
79
  * optimization, files are only read once per process and updated in memory and via `write()`. To force
80
80
  * a read from the filesystem pass `force=true`.
81
- * **Throws** *{@link SfdxError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
81
+ * **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
82
82
  *
83
83
  * @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
84
84
  * @param [force = false] Optionally force the file to be read from disk even when already read within the process.
@@ -88,7 +88,7 @@ export declare class ConfigFile<T extends ConfigFile.Options = ConfigFile.Option
88
88
  * Read the config file and set the config contents. Returns the config contents of the config file. As an
89
89
  * optimization, files are only read once per process and updated in memory and via `write()`. To force
90
90
  * a read from the filesystem pass `force=true`.
91
- * **Throws** *{@link SfdxError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
91
+ * **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
92
92
  *
93
93
  * @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
94
94
  * @param [force = false] Optionally force the file to be read from disk even when already read within the process.
@@ -7,14 +7,16 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ConfigFile = void 0;
10
+ const fs = require("fs");
10
11
  const fs_1 = require("fs");
11
12
  const os_1 = require("os");
12
13
  const path_1 = require("path");
13
14
  const ts_types_1 = require("@salesforce/ts-types");
15
+ const kit_1 = require("@salesforce/kit");
16
+ const mkdirp = require("mkdirp");
14
17
  const global_1 = require("../global");
15
18
  const logger_1 = require("../logger");
16
- const sfdxError_1 = require("../sfdxError");
17
- const fs_2 = require("../util/fs");
19
+ const sfError_1 = require("../sfError");
18
20
  const internal_1 = require("../util/internal");
19
21
  const configStore_1 = require("./configStore");
20
22
  /**
@@ -65,7 +67,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
65
67
  */
66
68
  static getFileName() {
67
69
  // Can not have abstract static methods, so throw a runtime error.
68
- throw new sfdxError_1.SfdxError('Unknown filename for config file.');
70
+ throw new sfError_1.SfError('Unknown filename for config file.');
69
71
  }
70
72
  /**
71
73
  * Returns the default options for the config file.
@@ -107,7 +109,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
107
109
  */
108
110
  async access(perm) {
109
111
  try {
110
- await fs_2.fs.access(this.getPath(), perm);
112
+ await fs.promises.access(this.getPath(), perm);
111
113
  return true;
112
114
  }
113
115
  catch (err) {
@@ -124,7 +126,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
124
126
  */
125
127
  accessSync(perm) {
126
128
  try {
127
- fs_2.fs.accessSync(this.getPath(), perm);
129
+ fs.accessSync(this.getPath(), perm);
128
130
  return true;
129
131
  }
130
132
  catch (err) {
@@ -135,7 +137,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
135
137
  * Read the config file and set the config contents. Returns the config contents of the config file. As an
136
138
  * optimization, files are only read once per process and updated in memory and via `write()`. To force
137
139
  * a read from the filesystem pass `force=true`.
138
- * **Throws** *{@link SfdxError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
140
+ * **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
139
141
  *
140
142
  * @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
141
143
  * @param [force = false] Optionally force the file to be read from disk even when already read within the process.
@@ -146,7 +148,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
146
148
  // internally and updated persistently via write().
147
149
  if (!this.hasRead || force) {
148
150
  this.logger.info(`Reading config file: ${this.getPath()}`);
149
- const obj = await fs_2.fs.readJsonMap(this.getPath());
151
+ const obj = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.getPath(), 'utf8'));
150
152
  this.setContentsFromObject(obj);
151
153
  }
152
154
  return this.getContents();
@@ -170,7 +172,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
170
172
  * Read the config file and set the config contents. Returns the config contents of the config file. As an
171
173
  * optimization, files are only read once per process and updated in memory and via `write()`. To force
172
174
  * a read from the filesystem pass `force=true`.
173
- * **Throws** *{@link SfdxError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
175
+ * **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
174
176
  *
175
177
  * @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
176
178
  * @param [force = false] Optionally force the file to be read from disk even when already read within the process.
@@ -181,7 +183,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
181
183
  // internally and updated persistently via write().
182
184
  if (!this.hasRead || force) {
183
185
  this.logger.info(`Reading config file: ${this.getPath()}`);
184
- const obj = fs_2.fs.readJsonMapSync(this.getPath());
186
+ const obj = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getPath(), 'utf8'));
185
187
  this.setContentsFromObject(obj);
186
188
  }
187
189
  return this.getContents();
@@ -211,9 +213,9 @@ class ConfigFile extends configStore_1.BaseConfigStore {
211
213
  if (newContents) {
212
214
  this.setContents(newContents);
213
215
  }
214
- await fs_2.fs.mkdirp((0, path_1.dirname)(this.getPath()));
216
+ await mkdirp((0, path_1.dirname)(this.getPath()));
215
217
  this.logger.info(`Writing to config file: ${this.getPath()}`);
216
- await fs_2.fs.writeJson(this.getPath(), this.toObject());
218
+ await fs.promises.writeFile(this.getPath(), JSON.stringify(this.toObject(), null, 2));
217
219
  return this.getContents();
218
220
  }
219
221
  /**
@@ -226,9 +228,9 @@ class ConfigFile extends configStore_1.BaseConfigStore {
226
228
  if ((0, ts_types_1.isPlainObject)(newContents)) {
227
229
  this.setContents(newContents);
228
230
  }
229
- fs_2.fs.mkdirpSync((0, path_1.dirname)(this.getPath()));
231
+ mkdirp.sync((0, path_1.dirname)(this.getPath()));
230
232
  this.logger.info(`Writing to config file: ${this.getPath()}`);
231
- fs_2.fs.writeJsonSync(this.getPath(), this.toObject());
233
+ fs.writeFileSync(this.getPath(), JSON.stringify(this.toObject(), null, 2));
232
234
  return this.getContents();
233
235
  }
234
236
  /**
@@ -249,7 +251,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
249
251
  * {@link fs.stat}
250
252
  */
251
253
  async stat() {
252
- return fs_2.fs.stat(this.getPath());
254
+ return fs.promises.stat(this.getPath());
253
255
  }
254
256
  /**
255
257
  * Get the stats of the file. Returns the stats of the file.
@@ -257,7 +259,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
257
259
  * {@link fs.stat}
258
260
  */
259
261
  statSync() {
260
- return fs_2.fs.statSync(this.getPath());
262
+ return fs.statSync(this.getPath());
261
263
  }
262
264
  /**
263
265
  * Delete the config file if it exists.
@@ -268,9 +270,9 @@ class ConfigFile extends configStore_1.BaseConfigStore {
268
270
  async unlink() {
269
271
  const exists = await this.exists();
270
272
  if (exists) {
271
- return await fs_2.fs.unlink(this.getPath());
273
+ return await fs.promises.unlink(this.getPath());
272
274
  }
273
- throw new sfdxError_1.SfdxError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
275
+ throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
274
276
  }
275
277
  /**
276
278
  * Delete the config file if it exists.
@@ -281,9 +283,9 @@ class ConfigFile extends configStore_1.BaseConfigStore {
281
283
  unlinkSync() {
282
284
  const exists = this.existsSync();
283
285
  if (exists) {
284
- return fs_2.fs.unlinkSync(this.getPath());
286
+ return fs.unlinkSync(this.getPath());
285
287
  }
286
- throw new sfdxError_1.SfdxError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
288
+ throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
287
289
  }
288
290
  /**
289
291
  * Returns the absolute path to the config file.
@@ -295,7 +297,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
295
297
  getPath() {
296
298
  if (!this.path) {
297
299
  if (!this.options.filename) {
298
- throw new sfdxError_1.SfdxError('The ConfigOptions filename parameter is invalid.', 'InvalidParameter');
300
+ throw new sfError_1.SfError('The ConfigOptions filename parameter is invalid.', 'InvalidParameter');
299
301
  }
300
302
  const _isGlobal = (0, ts_types_1.isBoolean)(this.options.isGlobal) && this.options.isGlobal;
301
303
  const _isState = (0, ts_types_1.isBoolean)(this.options.isState) && this.options.isState;
@@ -11,7 +11,7 @@ const kit_1 = require("@salesforce/kit");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
12
  const ts_types_2 = require("@salesforce/ts-types");
13
13
  const crypto_1 = require("../crypto/crypto");
14
- const sfdxError_1 = require("../sfdxError");
14
+ const sfError_1 = require("../sfError");
15
15
  /**
16
16
  * An abstract class that implements all the config management functions but
17
17
  * none of the storage functions.
@@ -287,18 +287,18 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
287
287
  if (!value)
288
288
  return;
289
289
  if (!this.crypto)
290
- throw new sfdxError_1.SfdxError('crypto is not initialized', 'CryptoNotInitializedError');
290
+ throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
291
291
  if (!(0, ts_types_2.isString)(value))
292
- throw new sfdxError_1.SfdxError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
292
+ throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
293
293
  return this.crypto.isEncrypted(value) ? value : this.crypto.encrypt(value);
294
294
  }
295
295
  decrypt(value) {
296
296
  if (!value)
297
297
  return;
298
298
  if (!this.crypto)
299
- throw new sfdxError_1.SfdxError('crypto is not initialized', 'CryptoNotInitializedError');
299
+ throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
300
300
  if (!(0, ts_types_2.isString)(value))
301
- throw new sfdxError_1.SfdxError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
301
+ throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
302
302
  return this.crypto.isEncrypted(value) ? this.crypto.decrypt(value) : value;
303
303
  }
304
304
  /**
@@ -8,7 +8,8 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.KeychainConfig = void 0;
10
10
  const path_1 = require("path");
11
- const fs_1 = require("../util/fs");
11
+ const fs = require("fs");
12
+ const mkdirp = require("mkdirp");
12
13
  const configFile_1 = require("./configFile");
13
14
  /**
14
15
  * Represent a key chain config backed by a json file.
@@ -34,8 +35,8 @@ class KeychainConfig extends configFile_1.ConfigFile {
34
35
  if (newContents != null) {
35
36
  this.setContents(newContents);
36
37
  }
37
- await fs_1.fs.mkdirp((0, path_1.dirname)(this.getPath()));
38
- await fs_1.fs.writeFile(this.getPath(), JSON.stringify(this.getContents(), null, 4), { mode: '600' });
38
+ await mkdirp((0, path_1.dirname)(this.getPath()));
39
+ await fs.promises.writeFile(this.getPath(), JSON.stringify(this.getContents(), null, 4), { mode: '600' });
39
40
  return this.getContents();
40
41
  }
41
42
  }
@@ -9,12 +9,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.keyChainImpl = exports.GenericWindowsKeychainAccess = exports.GenericUnixKeychainAccess = exports.GenericKeychainAccess = exports.KeychainAccess = void 0;
10
10
  const childProcess = require("child_process");
11
11
  const nodeFs = require("fs");
12
+ const fs = require("fs");
12
13
  const os = require("os");
13
- const path = require("path");
14
14
  const os_1 = require("os");
15
+ const path = require("path");
15
16
  const ts_types_1 = require("@salesforce/ts-types");
17
+ const kit_1 = require("@salesforce/kit");
18
+ const mkdirp = require("mkdirp");
16
19
  const global_1 = require("../global");
17
- const fs_1 = require("../util/fs");
18
20
  const messages_1 = require("../messages");
19
21
  messages_1.Messages.importMessagesDirectory(__dirname);
20
22
  const messages = messages_1.Messages.load('@salesforce/core', 'encryption', [
@@ -58,9 +60,9 @@ const _isExe = (mode, gid, uid) => {
58
60
  /**
59
61
  * Private helper to validate that a program exists on the file system and is executable.
60
62
  *
61
- * **Throws** *{@link SfdxError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
63
+ * **Throws** *{@link SfError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
62
64
  *
63
- * **Throws** *{@link SfdxError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
65
+ * **Throws** *{@link SfError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
64
66
  *
65
67
  * @param programPath The absolute path of the program.
66
68
  * @param fsIfc The file system interface.
@@ -329,8 +331,8 @@ async function _writeFile(opts, fn) {
329
331
  [SecretField.KEY]: opts.password,
330
332
  [SecretField.SERVICE]: opts.service,
331
333
  };
332
- await fs_1.fs.mkdirp(path.dirname(secretFile));
333
- await fs_1.fs.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
334
+ await mkdirp(path.dirname(secretFile));
335
+ await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
334
336
  fn(null, contents);
335
337
  }
336
338
  catch (err) {
@@ -339,7 +341,7 @@ async function _writeFile(opts, fn) {
339
341
  }
340
342
  async function _readFile() {
341
343
  // The file and access is validated before this method is called
342
- const fileContents = await fs_1.fs.readJsonMap(secretFile);
344
+ const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(secretFile, 'utf8'));
343
345
  return {
344
346
  account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
345
347
  password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
@@ -406,7 +408,7 @@ class GenericKeychainAccess {
406
408
  async isValidFileAccess(cb) {
407
409
  try {
408
410
  const root = (0, os_1.homedir)();
409
- await fs_1.fs.access(path.join(root, global_1.Global.SFDX_STATE_FOLDER), fs_1.fs.constants.R_OK | fs_1.fs.constants.X_OK | fs_1.fs.constants.W_OK);
411
+ await fs.promises.access(path.join(root, global_1.Global.SFDX_STATE_FOLDER), fs.constants.R_OK | fs.constants.X_OK | fs.constants.W_OK);
410
412
  await cb(null);
411
413
  }
412
414
  catch (err) {
@@ -426,7 +428,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
426
428
  await cb(err);
427
429
  }
428
430
  else {
429
- const stats = await fs_1.fs.stat(secretFile);
431
+ const stats = await fs.promises.stat(secretFile);
430
432
  const octalModeStr = (stats.mode & 0o777).toString(8);
431
433
  const EXPECTED_OCTAL_PERM_VALUE = '600';
432
434
  if (octalModeStr === EXPECTED_OCTAL_PERM_VALUE) {
@@ -451,7 +453,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
451
453
  }
452
454
  else {
453
455
  try {
454
- await fs_1.fs.access(secretFile, fs_1.fs.constants.R_OK | fs_1.fs.constants.W_OK);
456
+ await fs.promises.access(secretFile, fs.constants.R_OK | fs.constants.W_OK);
455
457
  await cb(null);
456
458
  }
457
459
  catch (e) {
@@ -15,7 +15,7 @@ const kit_1 = require("@salesforce/kit");
15
15
  const ts_types_1 = require("@salesforce/ts-types");
16
16
  const logger_1 = require("./logger");
17
17
  const authInfo_1 = require("./org/authInfo");
18
- const sfdxError_1 = require("./sfdxError");
18
+ const sfError_1 = require("./sfError");
19
19
  const connection_1 = require("./org/connection");
20
20
  const messages_1 = require("./messages");
21
21
  messages_1.Messages.importMessagesDirectory(__dirname);
@@ -29,7 +29,7 @@ async function makeRequest(options) {
29
29
  const rawResponse = await new transport_1.default().httpRequest(options);
30
30
  const response = (0, kit_1.parseJsonMap)(rawResponse.body);
31
31
  if (response.error) {
32
- const err = new sfdxError_1.SfdxError('Request Failed.');
32
+ const err = new sfError_1.SfError('Request Failed.');
33
33
  err.data = Object.assign(response, { status: rawResponse.statusCode });
34
34
  throw err;
35
35
  }
package/lib/exported.d.ts CHANGED
@@ -16,13 +16,13 @@ export { WebOAuthServer } from './webOAuthServer';
16
16
  export { SfdcUrl } from './util/sfdcUrl';
17
17
  export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
18
18
  export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
19
- export { Messages } from './messages';
19
+ export { Messages, StructuredMessage } from './messages';
20
20
  export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
21
21
  export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
22
- export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './sfdxProject';
22
+ export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson, SfdxProject, SfdxProjectJson, } from './sfProject';
23
23
  export { SchemaPrinter } from './schema/printer';
24
24
  export { SchemaValidator } from './schema/validator';
25
- export { SfdxError } from './sfdxError';
25
+ export { SfError, SfdxError } from './sfError';
26
26
  export { PollingClient } from './status/pollingClient';
27
27
  export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
28
28
  export { MyDomainResolver } from './status/myDomainResolver';
@@ -30,6 +30,5 @@ export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user
30
30
  export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
31
31
  export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate } from './org/scratchOrgCreate';
32
32
  export { ScratchOrgInfo } from './org/scratchOrgInfoApi';
33
- export * from './util/fs';
34
33
  export * from './util/sfdc';
35
34
  export * from './util/sfdcUrl';
package/lib/exported.js CHANGED
@@ -16,7 +16,7 @@ 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.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = 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.SFDX_ALLOWED_PROPERTIES = 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.ConfigFile = void 0;
19
+ exports.scratchOrgCreate = exports.PermissionSetAssignment = 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.SFDX_ALLOWED_PROPERTIES = 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.ConfigFile = void 0;
20
20
  const messages_1 = require("./messages");
21
21
  messages_1.Messages.importMessagesDirectory(__dirname);
22
22
  var configFile_1 = require("./config/configFile");
@@ -71,15 +71,18 @@ Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function ()
71
71
  var orgConfigProperties_1 = require("./org/orgConfigProperties");
72
72
  Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
73
73
  Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
74
- var sfdxProject_1 = require("./sfdxProject");
75
- Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfdxProject_1.SfdxProject; } });
76
- Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfdxProject_1.SfdxProjectJson; } });
74
+ var sfProject_1 = require("./sfProject");
75
+ Object.defineProperty(exports, "SfProject", { enumerable: true, get: function () { return sfProject_1.SfProject; } });
76
+ Object.defineProperty(exports, "SfProjectJson", { enumerable: true, get: function () { return sfProject_1.SfProjectJson; } });
77
+ Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfProject_1.SfdxProject; } });
78
+ Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfProject_1.SfdxProjectJson; } });
77
79
  var printer_1 = require("./schema/printer");
78
80
  Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
79
81
  var validator_1 = require("./schema/validator");
80
82
  Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return validator_1.SchemaValidator; } });
81
- var sfdxError_1 = require("./sfdxError");
82
- Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfdxError_1.SfdxError; } });
83
+ var sfError_1 = require("./sfError");
84
+ Object.defineProperty(exports, "SfError", { enumerable: true, get: function () { return sfError_1.SfError; } });
85
+ Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfError_1.SfdxError; } });
83
86
  var pollingClient_1 = require("./status/pollingClient");
84
87
  Object.defineProperty(exports, "PollingClient", { enumerable: true, get: function () { return pollingClient_1.PollingClient; } });
85
88
  var streamingClient_1 = require("./status/streamingClient");
@@ -96,7 +99,6 @@ Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, ge
96
99
  var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
97
100
  Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
98
101
  // Utility sub-modules
99
- __exportStar(require("./util/fs"), exports);
100
102
  __exportStar(require("./util/sfdc"), exports);
101
103
  __exportStar(require("./util/sfdcUrl"), exports);
102
104
  //# sourceMappingURL=exported.js.map