@salesforce/core 3.24.3 → 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 +14 -0
- package/lib/config/config.js +1 -2
- package/lib/config/configFile.js +12 -3
- package/lib/crypto/keyChainImpl.js +1 -2
- package/lib/global.js +13 -2
- package/lib/logger.js +14 -9
- package/lib/org/authRemover.js +2 -7
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +2 -8
- package/lib/stateAggregator/accessors/orgAccessor.js +13 -7
- package/package.json +1 -3
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.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
|
+
|
|
11
|
+
### [3.24.5](https://github.com/forcedotcom/sfdx-core/compare/v3.24.4...v3.24.5) (2022-07-28)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- set correct file mode for log file ([30aa3fc](https://github.com/forcedotcom/sfdx-core/commit/30aa3fc09ba2bf0db600ee6528fde5b0ff97b217))
|
|
16
|
+
|
|
17
|
+
### [3.24.4](https://github.com/forcedotcom/sfdx-core/compare/v3.24.3...v3.24.4) (2022-07-28)
|
|
18
|
+
|
|
5
19
|
### [3.24.3](https://github.com/forcedotcom/sfdx-core/compare/v3.24.2...v3.24.3) (2022-07-28)
|
|
6
20
|
|
|
7
21
|
### Bug Fixes
|
package/lib/config/config.js
CHANGED
|
@@ -11,7 +11,6 @@ const path_1 = require("path");
|
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
13
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
14
|
-
const mkdirp = require("mkdirp");
|
|
15
14
|
const global_1 = require("../global");
|
|
16
15
|
const logger_1 = require("../logger");
|
|
17
16
|
const messages_1 = require("../messages");
|
|
@@ -510,7 +509,7 @@ class SfdxConfig {
|
|
|
510
509
|
try {
|
|
511
510
|
const translated = this.translate(config, 'toOld');
|
|
512
511
|
const sfdxPath = this.getSfdxPath();
|
|
513
|
-
await
|
|
512
|
+
await fs.promises.mkdir((0, path_1.dirname)(sfdxPath), { recursive: true });
|
|
514
513
|
await fs.promises.writeFile(sfdxPath, JSON.stringify(translated, null, 2));
|
|
515
514
|
}
|
|
516
515
|
catch (error) {
|
package/lib/config/configFile.js
CHANGED
|
@@ -13,7 +13,6 @@ const os_1 = require("os");
|
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
15
|
const kit_1 = require("@salesforce/kit");
|
|
16
|
-
const mkdirp = require("mkdirp");
|
|
17
16
|
const global_1 = require("../global");
|
|
18
17
|
const logger_1 = require("../logger");
|
|
19
18
|
const sfError_1 = require("../sfError");
|
|
@@ -213,7 +212,12 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
213
212
|
if (newContents) {
|
|
214
213
|
this.setContents(newContents);
|
|
215
214
|
}
|
|
216
|
-
|
|
215
|
+
try {
|
|
216
|
+
await fs.promises.mkdir((0, path_1.dirname)(this.getPath()), { recursive: true });
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
throw sfError_1.SfError.wrap(err);
|
|
220
|
+
}
|
|
217
221
|
this.logger.info(`Writing to config file: ${this.getPath()}`);
|
|
218
222
|
await fs.promises.writeFile(this.getPath(), JSON.stringify(this.toObject(), null, 2));
|
|
219
223
|
return this.getContents();
|
|
@@ -228,7 +232,12 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
228
232
|
if ((0, ts_types_1.isPlainObject)(newContents)) {
|
|
229
233
|
this.setContents(newContents);
|
|
230
234
|
}
|
|
231
|
-
|
|
235
|
+
try {
|
|
236
|
+
fs.mkdirSync((0, path_1.dirname)(this.getPath()), { recursive: true });
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
throw sfError_1.SfError.wrap(err);
|
|
240
|
+
}
|
|
232
241
|
this.logger.info(`Writing to config file: ${this.getPath()}`);
|
|
233
242
|
fs.writeFileSync(this.getPath(), JSON.stringify(this.toObject(), null, 2));
|
|
234
243
|
return this.getContents();
|
|
@@ -15,7 +15,6 @@ const os_1 = require("os");
|
|
|
15
15
|
const path = require("path");
|
|
16
16
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
17
17
|
const kit_1 = require("@salesforce/kit");
|
|
18
|
-
const mkdirp = require("mkdirp");
|
|
19
18
|
const global_1 = require("../global");
|
|
20
19
|
const messages_1 = require("../messages");
|
|
21
20
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -332,7 +331,7 @@ async function _writeFile(opts, fn) {
|
|
|
332
331
|
[SecretField.SERVICE]: opts.service,
|
|
333
332
|
};
|
|
334
333
|
const secretFile = getSecretFile();
|
|
335
|
-
await
|
|
334
|
+
await fs.promises.mkdir(path.dirname(secretFile), { recursive: true });
|
|
336
335
|
await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
|
|
337
336
|
fn(null, contents);
|
|
338
337
|
}
|
package/lib/global.js
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Global = exports.Mode = void 0;
|
|
10
|
+
const fs = require("fs");
|
|
10
11
|
const os = require("os");
|
|
11
12
|
const path = require("path");
|
|
12
13
|
const kit_1 = require("@salesforce/kit");
|
|
13
|
-
const
|
|
14
|
+
const sfError_1 = require("./sfError");
|
|
14
15
|
/**
|
|
15
16
|
* Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
|
|
16
17
|
* with the default mode being `production`.
|
|
@@ -68,7 +69,17 @@ class Global {
|
|
|
68
69
|
*/
|
|
69
70
|
static async createDir(dirPath) {
|
|
70
71
|
dirPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
|
|
71
|
-
|
|
72
|
+
try {
|
|
73
|
+
if (process.platform === 'win32') {
|
|
74
|
+
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
await fs.promises.mkdir(dirPath, { recursive: true, mode: 0o700 });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
throw new sfError_1.SfError(`Failed to create directory or set permissions for: ${dirPath}`);
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
exports.Global = Global;
|
package/lib/logger.js
CHANGED
|
@@ -18,7 +18,6 @@ const Bunyan = require("@salesforce/bunyan");
|
|
|
18
18
|
const kit_1 = require("@salesforce/kit");
|
|
19
19
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
20
20
|
const Debug = require("debug");
|
|
21
|
-
const mkdirp = require("mkdirp");
|
|
22
21
|
const global_1 = require("./global");
|
|
23
22
|
const sfError_1 = require("./sfError");
|
|
24
23
|
/**
|
|
@@ -245,12 +244,15 @@ class Logger {
|
|
|
245
244
|
}
|
|
246
245
|
catch (err1) {
|
|
247
246
|
try {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
247
|
+
if (process.platform === 'win32') {
|
|
248
|
+
await fs.promises.mkdir(path.dirname(logFile), { recursive: true });
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
await fs.promises.mkdir(path.dirname(logFile), { recursive: true, mode: 0o700 });
|
|
252
|
+
}
|
|
251
253
|
}
|
|
252
254
|
catch (err2) {
|
|
253
|
-
|
|
255
|
+
throw sfError_1.SfError.wrap(err2);
|
|
254
256
|
}
|
|
255
257
|
try {
|
|
256
258
|
await fs.promises.writeFile(logFile, '', { mode: '600' });
|
|
@@ -285,12 +287,15 @@ class Logger {
|
|
|
285
287
|
}
|
|
286
288
|
catch (err1) {
|
|
287
289
|
try {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
290
|
+
if (process.platform === 'win32') {
|
|
291
|
+
fs.mkdirSync(path.dirname(logFile));
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
fs.mkdirSync(path.dirname(logFile), { mode: 0o700 });
|
|
295
|
+
}
|
|
291
296
|
}
|
|
292
297
|
catch (err2) {
|
|
293
|
-
|
|
298
|
+
throw sfError_1.SfError.wrap(err2);
|
|
294
299
|
}
|
|
295
300
|
try {
|
|
296
301
|
fs.writeFileSync(logFile, '', { mode: '600' });
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.0",
|
|
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",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@salesforce/schemas": "^1.1.0",
|
|
40
40
|
"@salesforce/ts-types": "^1.5.20",
|
|
41
41
|
"@types/graceful-fs": "^4.1.5",
|
|
42
|
-
"@types/mkdirp": "^1.0.2",
|
|
43
42
|
"@types/semver": "^7.3.9",
|
|
44
43
|
"ajv": "^8.11.0",
|
|
45
44
|
"archiver": "^5.3.0",
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
"js2xmlparser": "^4.0.1",
|
|
52
51
|
"jsforce": "^2.0.0-beta.16",
|
|
53
52
|
"jsonwebtoken": "8.5.1",
|
|
54
|
-
"mkdirp": "1.0.4",
|
|
55
53
|
"ts-retry-promise": "^0.6.0"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|