@salesforce/core 3.19.5 → 3.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
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.20.1](https://github.com/forcedotcom/sfdx-core/compare/v3.19.5...v3.20.1) (2022-06-08)
6
+
7
+ ### Features
8
+
9
+ - cause a publish from previous skip ([069c366](https://github.com/forcedotcom/sfdx-core/commit/069c36646f5dc10a4172868ef7b5f9cd82ef7503))
10
+ - safer caching for nuts ([fa0af41](https://github.com/forcedotcom/sfdx-core/commit/fa0af41451a4363c84e9713685c8ece439acf3bc))
11
+
12
+ ## [3.20.0](https://github.com/forcedotcom/sfdx-core/compare/v3.19.6-dev.0...v3.20.0) (2022-06-08)
13
+
14
+ ### Features
15
+
16
+ - cache crypto keys by homedir ([dcd493e](https://github.com/forcedotcom/sfdx-core/commit/dcd493e7745bb2717da3a4ed9aff528a51391be6))
17
+
18
+ ### [3.19.6-dev.0](https://github.com/forcedotcom/sfdx-core/compare/v3.19.5...v3.19.6-dev.0) (2022-06-07)
19
+
20
+ ### Features
21
+
22
+ - stateAggregator by homedir ([6219b41](https://github.com/forcedotcom/sfdx-core/commit/6219b41a4d7bac5759a62663e71e16f4722fdeac))
23
+
5
24
  ### [3.19.5](https://github.com/forcedotcom/sfdx-core/compare/v3.19.4...v3.19.5) (2022-06-06)
6
25
 
7
26
  ### Bug Fixes
@@ -16,6 +16,7 @@ const kit_1 = require("@salesforce/kit");
16
16
  const logger_1 = require("../logger");
17
17
  const messages_1 = require("../messages");
18
18
  const cache_1 = require("../util/cache");
19
+ const global_1 = require("../global");
19
20
  const keyChain_1 = require("./keyChain");
20
21
  const secureBuffer_1 = require("./secureBuffer");
21
22
  const TAG_DELIMITER = ':';
@@ -49,20 +50,21 @@ const keychainPromises = {
49
50
  * @param account The keychain account name.
50
51
  */
51
52
  getPassword(_keychain, service, account) {
52
- const sb = cache_1.Cache.get(`${service}:${account}`);
53
+ const cacheKey = `${global_1.Global.DIR}:${service}:${account}`;
54
+ const sb = cache_1.Cache.get(cacheKey);
53
55
  if (!sb) {
54
56
  return new Promise((resolve, reject) => {
55
57
  return _keychain.getPassword({ service, account }, (err, password) => {
56
58
  if (err)
57
59
  return reject(err);
58
- cache_1.Cache.set(`${service}:${account}`, makeSecureBuffer(password));
60
+ cache_1.Cache.set(cacheKey, makeSecureBuffer(password));
59
61
  return resolve({ username: account, password: (0, ts_types_1.ensure)(password) });
60
62
  });
61
63
  });
62
64
  }
63
65
  else {
64
66
  const pw = sb.value((buffer) => buffer.toString('utf8'));
65
- cache_1.Cache.set(`${service}:${account}`, makeSecureBuffer(pw));
67
+ cache_1.Cache.set(cacheKey, makeSecureBuffer(pw));
66
68
  return new Promise((resolve) => {
67
69
  return resolve({ username: account, password: (0, ts_types_1.ensure)(pw) });
68
70
  });
package/lib/global.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare class Global {
29
29
  */
30
30
  static readonly SF_STATE_FOLDER = ".sf";
31
31
  /**
32
- * The peferred global folder in which state is stored.
32
+ * The preferred global folder in which state is stored.
33
33
  */
34
34
  static readonly STATE_FOLDER = ".sfdx";
35
35
  /**
@@ -41,11 +41,11 @@ export declare class Global {
41
41
  /**
42
42
  * The full system path to the global sf state folder.
43
43
  *
44
- * **See** {@link Global.SF_STATE_FOLDER}
44
+ * **See** {@link Global.SF_STATE_FOLDER}
45
45
  */
46
46
  static get SF_DIR(): string;
47
47
  /**
48
- * The full system path to the peferred global state folder
48
+ * The full system path to the preferred global state folder
49
49
  */
50
50
  static get DIR(): string;
51
51
  /**
package/lib/global.js CHANGED
@@ -39,13 +39,13 @@ class Global {
39
39
  /**
40
40
  * The full system path to the global sf state folder.
41
41
  *
42
- * **See** {@link Global.SF_STATE_FOLDER}
42
+ * **See** {@link Global.SF_STATE_FOLDER}
43
43
  */
44
44
  static get SF_DIR() {
45
45
  return path.join(os.homedir(), Global.SF_STATE_FOLDER);
46
46
  }
47
47
  /**
48
- * The full system path to the peferred global state folder
48
+ * The full system path to the preferred global state folder
49
49
  */
50
50
  static get DIR() {
51
51
  return path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
@@ -87,7 +87,7 @@ Global.SFDX_STATE_FOLDER = '.sfdx';
87
87
  */
88
88
  Global.SF_STATE_FOLDER = '.sf';
89
89
  /**
90
- * The peferred global folder in which state is stored.
90
+ * The preferred global folder in which state is stored.
91
91
  */
92
92
  Global.STATE_FOLDER = Global.SFDX_STATE_FOLDER;
93
93
  /**
@@ -4,17 +4,22 @@ import { OrgAccessor } from './accessors/orgAccessor';
4
4
  import { SandboxAccessor } from './accessors/sandboxAccessor';
5
5
  import { TokenAccessor } from './accessors/tokenAccessor';
6
6
  export declare class StateAggregator extends AsyncOptionalCreatable {
7
- private static instance;
7
+ private static instanceMap;
8
8
  aliases: AliasAccessor;
9
9
  orgs: OrgAccessor;
10
10
  sandboxes: SandboxAccessor;
11
11
  tokens: TokenAccessor;
12
+ /**
13
+ * Reuse a StateAggregator if one was already created for the current global state directory
14
+ * Otherwise, create one and adds it to map for future reuse.
15
+ * HomeDir might be stubbed in tests
16
+ */
12
17
  static getInstance(): Promise<StateAggregator>;
13
18
  /**
14
19
  * Clear the cache to force reading from disk.
15
20
  *
16
21
  * *NOTE: Only call this method if you must and you know what you are doing.*
17
22
  */
18
- static clearInstance(): void;
23
+ static clearInstance(path?: string): void;
19
24
  protected init(): Promise<void>;
20
25
  }
@@ -8,24 +8,31 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.StateAggregator = void 0;
10
10
  const kit_1 = require("@salesforce/kit");
11
+ const global_1 = require("../global");
11
12
  const aliasAccessor_1 = require("./accessors/aliasAccessor");
12
13
  const orgAccessor_1 = require("./accessors/orgAccessor");
13
14
  const sandboxAccessor_1 = require("./accessors/sandboxAccessor");
14
15
  const tokenAccessor_1 = require("./accessors/tokenAccessor");
15
16
  class StateAggregator extends kit_1.AsyncOptionalCreatable {
17
+ /**
18
+ * Reuse a StateAggregator if one was already created for the current global state directory
19
+ * Otherwise, create one and adds it to map for future reuse.
20
+ * HomeDir might be stubbed in tests
21
+ */
16
22
  static async getInstance() {
17
- if (!StateAggregator.instance) {
18
- StateAggregator.instance = await StateAggregator.create();
23
+ if (!StateAggregator.instanceMap.has(global_1.Global.DIR)) {
24
+ StateAggregator.instanceMap.set(global_1.Global.DIR, await StateAggregator.create());
19
25
  }
20
- return StateAggregator.instance;
26
+ // TS assertion is valid because there either was one OR it was just now instantiated
27
+ return StateAggregator.instanceMap.get(global_1.Global.DIR);
21
28
  }
22
29
  /**
23
30
  * Clear the cache to force reading from disk.
24
31
  *
25
32
  * *NOTE: Only call this method if you must and you know what you are doing.*
26
33
  */
27
- static clearInstance() {
28
- delete StateAggregator.instance;
34
+ static clearInstance(path = global_1.Global.DIR) {
35
+ StateAggregator.instanceMap.delete(path);
29
36
  }
30
37
  async init() {
31
38
  this.orgs = await orgAccessor_1.OrgAccessor.create();
@@ -35,4 +42,5 @@ class StateAggregator extends kit_1.AsyncOptionalCreatable {
35
42
  }
36
43
  }
37
44
  exports.StateAggregator = StateAggregator;
45
+ StateAggregator.instanceMap = new Map();
38
46
  //# sourceMappingURL=stateAggregator.js.map
@@ -48,7 +48,7 @@ export declare class SfdcUrl extends URL {
48
48
  */
49
49
  checkLightningDomain(): Promise<true | never>;
50
50
  /**
51
- * Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again untill timeout
51
+ * Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
52
52
  * If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
53
53
  *
54
54
  * @returns the resolved ip address.
@@ -155,7 +155,7 @@ class SfdcUrl extends url_1.URL {
155
155
  return true;
156
156
  }
157
157
  /**
158
- * Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again untill timeout
158
+ * Method that performs the dns lookup of the host. If the lookup fails the internal polling (1 second), client will try again until timeout
159
159
  * If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
160
160
  *
161
161
  * @returns the resolved ip address.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.19.5",
3
+ "version": "3.20.1",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",