@salesforce/core 3.19.3 → 3.19.6-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/crypto/keyChainImpl.js +5 -6
- package/lib/global.d.ts +4 -4
- package/lib/global.js +4 -4
- package/lib/org/scratchOrgInfoApi.js +1 -1
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +3 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +4 -0
- package/lib/stateAggregator/stateAggregator.d.ts +7 -2
- package/lib/stateAggregator/stateAggregator.js +13 -5
- package/lib/util/sfdcUrl.d.ts +1 -1
- package/lib/util/sfdcUrl.js +1 -1
- package/package.json +1 -1
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.19.6-dev.0](https://github.com/forcedotcom/sfdx-core/compare/v3.19.5...v3.19.6-dev.0) (2022-06-07)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- stateAggregator by homedir ([6219b41](https://github.com/forcedotcom/sfdx-core/commit/6219b41a4d7bac5759a62663e71e16f4722fdeac))
|
|
10
|
+
|
|
11
|
+
### [3.19.5](https://github.com/forcedotcom/sfdx-core/compare/v3.19.4...v3.19.5) (2022-06-06)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- update `NamedOrgNotFound` err name ([6a6a627](https://github.com/forcedotcom/sfdx-core/commit/6a6a62782046858c062ecb24a1d28631ea1f3bbe))
|
|
16
|
+
|
|
17
|
+
### [3.19.4](https://github.com/forcedotcom/sfdx-core/compare/v3.19.3...v3.19.4) (2022-06-06)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- add stat method to OrgAccessor ([f4e297c](https://github.com/forcedotcom/sfdx-core/commit/f4e297c576647b32be62621377d6e3fc5c8dc5f1))
|
|
22
|
+
|
|
5
23
|
### [3.19.3](https://github.com/forcedotcom/sfdx-core/compare/v3.19.2...v3.19.3) (2022-06-06)
|
|
6
24
|
|
|
7
25
|
### [3.19.2](https://github.com/forcedotcom/sfdx-core/compare/v3.19.1...v3.19.2) (2022-06-02)
|
|
@@ -317,7 +317,6 @@ const _darwinImpl = {
|
|
|
317
317
|
}
|
|
318
318
|
},
|
|
319
319
|
};
|
|
320
|
-
const getSecretFile = () => path.join(global_1.Global.DIR, 'key.json');
|
|
321
320
|
var SecretField;
|
|
322
321
|
(function (SecretField) {
|
|
323
322
|
SecretField["SERVICE"] = "service";
|
|
@@ -331,7 +330,7 @@ async function _writeFile(opts, fn) {
|
|
|
331
330
|
[SecretField.KEY]: opts.password,
|
|
332
331
|
[SecretField.SERVICE]: opts.service,
|
|
333
332
|
};
|
|
334
|
-
const secretFile =
|
|
333
|
+
const secretFile = path.join(global_1.Global.DIR, 'key.json');
|
|
335
334
|
await mkdirp(path.dirname(secretFile));
|
|
336
335
|
await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
|
|
337
336
|
fn(null, contents);
|
|
@@ -342,7 +341,7 @@ async function _writeFile(opts, fn) {
|
|
|
342
341
|
}
|
|
343
342
|
async function _readFile() {
|
|
344
343
|
// The file and access is validated before this method is called
|
|
345
|
-
const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(
|
|
344
|
+
const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(path.join(global_1.Global.DIR, 'key.json'), 'utf8'));
|
|
346
345
|
return {
|
|
347
346
|
account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
|
|
348
347
|
password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
|
|
@@ -369,7 +368,7 @@ class GenericKeychainAccess {
|
|
|
369
368
|
else {
|
|
370
369
|
// if the service and account names don't match then maybe someone or something is editing
|
|
371
370
|
// that file. #donotallow
|
|
372
|
-
fn(messages.createError('genericKeychainServiceError', [
|
|
371
|
+
fn(messages.createError('genericKeychainServiceError', [path.join(global_1.Global.DIR, 'key.json')]));
|
|
373
372
|
}
|
|
374
373
|
}
|
|
375
374
|
catch (readJsonErr) {
|
|
@@ -429,7 +428,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
|
|
|
429
428
|
await cb(err);
|
|
430
429
|
}
|
|
431
430
|
else {
|
|
432
|
-
const secretFile =
|
|
431
|
+
const secretFile = path.join(global_1.Global.DIR, 'key.json');
|
|
433
432
|
const stats = await fs.promises.stat(secretFile);
|
|
434
433
|
const octalModeStr = (stats.mode & 0o777).toString(8);
|
|
435
434
|
const EXPECTED_OCTAL_PERM_VALUE = '600';
|
|
@@ -455,7 +454,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
|
|
|
455
454
|
}
|
|
456
455
|
else {
|
|
457
456
|
try {
|
|
458
|
-
await fs.promises.access(
|
|
457
|
+
await fs.promises.access(path.join(global_1.Global.DIR, 'key.json'), fs.constants.R_OK | fs.constants.W_OK);
|
|
459
458
|
await cb(null);
|
|
460
459
|
}
|
|
461
460
|
catch (e) {
|
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
|
|
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**
|
|
44
|
+
* **See** {@link Global.SF_STATE_FOLDER}
|
|
45
45
|
*/
|
|
46
46
|
static get SF_DIR(): string;
|
|
47
47
|
/**
|
|
48
|
-
* The
|
|
48
|
+
* The full system path to the preferred global state folder
|
|
49
49
|
*/
|
|
50
50
|
static get DIR(): string;
|
|
51
51
|
/**
|
|
@@ -53,7 +53,7 @@ export declare class Global {
|
|
|
53
53
|
*/
|
|
54
54
|
static readonly LOG_FILE_PATH: string;
|
|
55
55
|
/**
|
|
56
|
-
* Gets the
|
|
56
|
+
* Gets the curr ent mode environment variable as a {@link Mode} instance.
|
|
57
57
|
*
|
|
58
58
|
* ```
|
|
59
59
|
* console.log(Global.getEnvironmentMode() === Mode.PRODUCTION);
|
package/lib/global.js
CHANGED
|
@@ -39,19 +39,19 @@ class Global {
|
|
|
39
39
|
/**
|
|
40
40
|
* The full system path to the global sf state folder.
|
|
41
41
|
*
|
|
42
|
-
* **See**
|
|
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
|
|
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);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Gets the
|
|
54
|
+
* Gets the curr ent mode environment variable as a {@link Mode} instance.
|
|
55
55
|
*
|
|
56
56
|
* ```
|
|
57
57
|
* console.log(Global.getEnvironmentMode() === Mode.PRODUCTION);
|
|
@@ -87,7 +87,7 @@ Global.SFDX_STATE_FOLDER = '.sfdx';
|
|
|
87
87
|
*/
|
|
88
88
|
Global.SF_STATE_FOLDER = '.sf';
|
|
89
89
|
/**
|
|
90
|
-
* The
|
|
90
|
+
* The preferred global folder in which state is stored.
|
|
91
91
|
*/
|
|
92
92
|
Global.STATE_FOLDER = Global.SFDX_STATE_FOLDER;
|
|
93
93
|
/**
|
|
@@ -203,7 +203,7 @@ const checkOrgDoesntExist = async (scratchOrgInfo) => {
|
|
|
203
203
|
catch (error) {
|
|
204
204
|
const sfError = sfError_1.SfError.wrap(error);
|
|
205
205
|
// if an AuthInfo couldn't be created that means no AuthFile exists.
|
|
206
|
-
if (sfError.name === '
|
|
206
|
+
if (sfError.name === 'NamedOrgNotFoundError') {
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
// Something unexpected
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as fs from 'fs';
|
|
1
3
|
import { JsonMap, Nullable, Optional } from '@salesforce/ts-types';
|
|
2
4
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
3
5
|
import { AuthInfoConfig } from '../../config/authInfoConfig';
|
|
@@ -29,6 +31,7 @@ export declare abstract class BaseOrgAccessor<T extends ConfigFile, P extends Co
|
|
|
29
31
|
getAll(decrypt?: boolean): P[];
|
|
30
32
|
has(username: string): boolean;
|
|
31
33
|
exists(username: string): Promise<boolean>;
|
|
34
|
+
stat(username: string): Promise<Nullable<fs.Stats>>;
|
|
32
35
|
hasFile(username: string): Promise<boolean>;
|
|
33
36
|
list(): Promise<string[]>;
|
|
34
37
|
set(username: string, org: P): void;
|
|
@@ -105,6 +105,10 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
105
105
|
const config = this.configs.get(username);
|
|
106
106
|
return config ? await config.exists() : false;
|
|
107
107
|
}
|
|
108
|
+
async stat(username) {
|
|
109
|
+
const config = this.configs.get(username);
|
|
110
|
+
return config ? await config.stat() : null;
|
|
111
|
+
}
|
|
108
112
|
async hasFile(username) {
|
|
109
113
|
try {
|
|
110
114
|
await fs.promises.access(this.parseFilename(username));
|
|
@@ -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
|
|
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.
|
|
18
|
-
StateAggregator.
|
|
23
|
+
if (!StateAggregator.instanceMap.has(global_1.Global.DIR)) {
|
|
24
|
+
StateAggregator.instanceMap.set(global_1.Global.DIR, await StateAggregator.create());
|
|
19
25
|
}
|
|
20
|
-
|
|
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
|
-
|
|
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
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -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
|
|
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.
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -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
|
|
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.
|