@salesforce/core 3.24.5 → 3.25.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
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.25.0](https://github.com/forcedotcom/sfdx-core/compare/v3.24.5...v3.25.0) (2022-07-29)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- orgAccessor.get has throwOnNotFound option ([a2ee821](https://github.com/forcedotcom/sfdx-core/commit/a2ee8219adf692de7de17ba254e05f501ef5814c))
|
|
10
|
+
|
|
5
11
|
### [3.24.5](https://github.com/forcedotcom/sfdx-core/compare/v3.24.4...v3.24.5) (2022-07-28)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
package/lib/org/authRemover.js
CHANGED
|
@@ -14,7 +14,6 @@ const messages_1 = require("../messages");
|
|
|
14
14
|
const stateAggregator_1 = require("../stateAggregator");
|
|
15
15
|
const orgConfigProperties_1 = require("./orgConfigProperties");
|
|
16
16
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
17
|
-
const coreMessages = messages_1.Messages.load('@salesforce/core', 'core', ['namedOrgNotFound']);
|
|
18
17
|
const messages = messages_1.Messages.load('@salesforce/core', 'auth', ['targetOrgNotSet']);
|
|
19
18
|
/**
|
|
20
19
|
* Handles the removing of authorizations, which includes deleting the auth file
|
|
@@ -72,12 +71,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
72
71
|
* @returns {Promise<SfOrg>}
|
|
73
72
|
*/
|
|
74
73
|
async findAuth(usernameOrAlias) {
|
|
75
|
-
const username = await this.resolveUsername(usernameOrAlias
|
|
76
|
-
|
|
77
|
-
if (!auth) {
|
|
78
|
-
throw coreMessages.createError('namedOrgNotFound');
|
|
79
|
-
}
|
|
80
|
-
return auth;
|
|
74
|
+
const username = await this.resolveUsername(usernameOrAlias ?? this.getTargetOrg());
|
|
75
|
+
return this.stateAggregator.orgs.get(username, false, true);
|
|
81
76
|
}
|
|
82
77
|
/**
|
|
83
78
|
* Finds all org authorizations in the global info file (.sf/sf.json)
|
|
@@ -26,7 +26,7 @@ export declare abstract class BaseOrgAccessor<T extends ConfigFile, P extends Co
|
|
|
26
26
|
private contents;
|
|
27
27
|
private logger;
|
|
28
28
|
/**
|
|
29
|
-
* Read the auth file for the given
|
|
29
|
+
* Read the auth file for the given username. Once the file has been read, it can be re-accessed with the `get` method.
|
|
30
30
|
*
|
|
31
31
|
* @param username username to read
|
|
32
32
|
* @param decrypt if true, decrypt encrypted values
|
|
@@ -39,13 +39,7 @@ export declare abstract class BaseOrgAccessor<T extends ConfigFile, P extends Co
|
|
|
39
39
|
* @param decrypt if true, decrypt encrypted values
|
|
40
40
|
*/
|
|
41
41
|
readAll(decrypt?: boolean): Promise<P[]>;
|
|
42
|
-
|
|
43
|
-
* Return the contents of the username's auth file from cache. The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
44
|
-
*
|
|
45
|
-
* @param username username to get
|
|
46
|
-
* @param decrypt if true, decrypt encrypted values
|
|
47
|
-
*/
|
|
48
|
-
get(username: string, decrypt?: boolean): Nullable<P>;
|
|
42
|
+
get(username: string, decrypt?: boolean, throwOnNotFound?: true): P;
|
|
49
43
|
/**
|
|
50
44
|
* Return the contents of all the auth files from cache. The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
51
45
|
*
|
|
@@ -14,6 +14,7 @@ const authInfoConfig_1 = require("../../config/authInfoConfig");
|
|
|
14
14
|
const global_1 = require("../../global");
|
|
15
15
|
const types_1 = require("../types");
|
|
16
16
|
const logger_1 = require("../../logger");
|
|
17
|
+
const messages_1 = require("../../messages");
|
|
17
18
|
/**
|
|
18
19
|
* @deprecated
|
|
19
20
|
*/
|
|
@@ -62,7 +63,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
62
63
|
this.contents = new Map();
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
|
-
* Read the auth file for the given
|
|
66
|
+
* Read the auth file for the given username. Once the file has been read, it can be re-accessed with the `get` method.
|
|
66
67
|
*
|
|
67
68
|
* @param username username to read
|
|
68
69
|
* @param decrypt if true, decrypt encrypted values
|
|
@@ -96,13 +97,21 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
96
97
|
return this.getAll(decrypt);
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
99
|
-
* Return the contents of the username's auth file from cache.
|
|
100
|
+
* Return the contents of the username's auth file from cache.
|
|
101
|
+
* The `read` or `readAll` methods must be called first in order to populate the cache.
|
|
102
|
+
* If throwOnNotFound is not true, an empty object {} is returned if the org is not found.
|
|
100
103
|
*
|
|
101
104
|
* @param username username to get
|
|
102
105
|
* @param decrypt if true, decrypt encrypted values
|
|
106
|
+
* @param throwOnNotFound if true, throw if the auth file does not already exist in the cache
|
|
103
107
|
*/
|
|
104
|
-
get(username, decrypt = false) {
|
|
108
|
+
get(username, decrypt = false, throwOnNotFound = false) {
|
|
105
109
|
const config = this.configs.get(username);
|
|
110
|
+
if (throwOnNotFound && config?.keys().length === 0) {
|
|
111
|
+
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
112
|
+
const messages = messages_1.Messages.load('@salesforce/core', 'core', ['namedOrgNotFound']);
|
|
113
|
+
throw messages.createError('namedOrgNotFound', [username]);
|
|
114
|
+
}
|
|
106
115
|
if (config) {
|
|
107
116
|
this.contents.set(username, config.getContents(decrypt));
|
|
108
117
|
}
|
|
@@ -115,10 +124,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
115
124
|
* @returns
|
|
116
125
|
*/
|
|
117
126
|
getAll(decrypt = false) {
|
|
118
|
-
return [...this.configs.keys()].
|
|
119
|
-
const org = this.get(username, decrypt);
|
|
120
|
-
return org && !(0, kit_1.isEmpty)(org) ? orgs.concat([org]) : orgs;
|
|
121
|
-
}, []);
|
|
127
|
+
return [...this.configs.keys()].map((username) => this.get(username, decrypt)).filter((org) => !(0, kit_1.isEmpty)(org));
|
|
122
128
|
}
|
|
123
129
|
/**
|
|
124
130
|
* Returns true if the username has been cached.
|