@salesforce/core 3.16.0 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.16.1](https://github.com/forcedotcom/sfdx-core/compare/v3.16.0...v3.16.1) (2022-05-11)
6
+
7
+ ### Bug Fixes
8
+
9
+ - homedir can change after Core loads ([bb1e4f5](https://github.com/forcedotcom/sfdx-core/commit/bb1e4f5b1f59269f6d48a5389b1d76eeee252db0))
10
+
5
11
  ## [3.16.0](https://github.com/forcedotcom/sfdx-core/compare/v3.15.5...v3.16.0) (2022-05-04)
6
12
 
7
13
  ### Features
@@ -317,7 +317,7 @@ const _darwinImpl = {
317
317
  }
318
318
  },
319
319
  };
320
- const secretFile = path.join((0, os_1.homedir)(), global_1.Global.SFDX_STATE_FOLDER, 'key.json');
320
+ const getSecretFile = () => path.join(global_1.Global.SFDX_DIR, 'key.json');
321
321
  var SecretField;
322
322
  (function (SecretField) {
323
323
  SecretField["SERVICE"] = "service";
@@ -331,6 +331,7 @@ async function _writeFile(opts, fn) {
331
331
  [SecretField.KEY]: opts.password,
332
332
  [SecretField.SERVICE]: opts.service,
333
333
  };
334
+ const secretFile = getSecretFile();
334
335
  await mkdirp(path.dirname(secretFile));
335
336
  await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
336
337
  fn(null, contents);
@@ -341,7 +342,7 @@ async function _writeFile(opts, fn) {
341
342
  }
342
343
  async function _readFile() {
343
344
  // The file and access is validated before this method is called
344
- const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(secretFile, 'utf8'));
345
+ const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(getSecretFile(), 'utf8'));
345
346
  return {
346
347
  account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
347
348
  password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
@@ -368,7 +369,7 @@ class GenericKeychainAccess {
368
369
  else {
369
370
  // if the service and account names don't match then maybe someone or something is editing
370
371
  // that file. #donotallow
371
- fn(messages.createError('genericKeychainServiceError', [secretFile]));
372
+ fn(messages.createError('genericKeychainServiceError', [getSecretFile()]));
372
373
  }
373
374
  }
374
375
  catch (readJsonErr) {
@@ -428,6 +429,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
428
429
  await cb(err);
429
430
  }
430
431
  else {
432
+ const secretFile = getSecretFile();
431
433
  const stats = await fs.promises.stat(secretFile);
432
434
  const octalModeStr = (stats.mode & 0o777).toString(8);
433
435
  const EXPECTED_OCTAL_PERM_VALUE = '600';
@@ -453,7 +455,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
453
455
  }
454
456
  else {
455
457
  try {
456
- await fs.promises.access(secretFile, fs.constants.R_OK | fs.constants.W_OK);
458
+ await fs.promises.access(getSecretFile(), fs.constants.R_OK | fs.constants.W_OK);
457
459
  await cb(null);
458
460
  }
459
461
  catch (e) {
package/lib/global.d.ts CHANGED
@@ -33,13 +33,13 @@ export declare class Global {
33
33
  *
34
34
  * **See** {@link Global.SFDX_STATE_FOLDER}
35
35
  */
36
- static readonly SFDX_DIR: string;
36
+ static get SFDX_DIR(): string;
37
37
  /**
38
38
  * The full system path to the global sf state folder.
39
39
  *
40
40
  * **See** {@link Global.SF_STATE_FOLDER}
41
41
  */
42
- static readonly SF_DIR: string;
42
+ static get SF_DIR(): string;
43
43
  /**
44
44
  * The full system path to the global log file.
45
45
  */
package/lib/global.js CHANGED
@@ -28,6 +28,22 @@ var Mode;
28
28
  * Global constants, methods, and configuration.
29
29
  */
30
30
  class Global {
31
+ /**
32
+ * The full system path to the global sfdx state folder.
33
+ *
34
+ * **See** {@link Global.SFDX_STATE_FOLDER}
35
+ */
36
+ static get SFDX_DIR() {
37
+ return path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
38
+ }
39
+ /**
40
+ * The full system path to the global sf state folder.
41
+ *
42
+ * **See** {@link Global.SF_STATE_FOLDER}
43
+ */
44
+ static get SF_DIR() {
45
+ return path.join(os.homedir(), Global.SF_STATE_FOLDER);
46
+ }
31
47
  /**
32
48
  * Gets the current mode environment variable as a {@link Mode} instance.
33
49
  *
@@ -64,18 +80,6 @@ Global.SFDX_STATE_FOLDER = '.sfdx';
64
80
  * The global folder in which sf state is stored.
65
81
  */
66
82
  Global.SF_STATE_FOLDER = '.sf';
67
- /**
68
- * The full system path to the global sfdx state folder.
69
- *
70
- * **See** {@link Global.SFDX_STATE_FOLDER}
71
- */
72
- Global.SFDX_DIR = path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
73
- /**
74
- * The full system path to the global sf state folder.
75
- *
76
- * **See** {@link Global.SF_STATE_FOLDER}
77
- */
78
- Global.SF_DIR = path.join(os.homedir(), Global.SF_STATE_FOLDER);
79
83
  /**
80
84
  * The full system path to the global log file.
81
85
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.16.0",
3
+ "version": "3.16.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",