@salesforce/core 3.7.5 → 3.7.8
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 +219 -0
- package/README.md +4 -4
- package/lib/config/config.d.ts +7 -5
- package/lib/config/config.js +14 -9
- package/lib/config/configAggregator.d.ts +2 -2
- package/lib/config/configAggregator.js +2 -2
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +22 -20
- package/lib/config/configStore.js +7 -6
- package/lib/config/keychainConfig.js +4 -3
- package/lib/crypto/keyChainImpl.js +12 -11
- package/lib/deviceOauthService.js +2 -2
- package/lib/exported.d.ts +6 -5
- package/lib/exported.js +11 -7
- package/lib/global.js +2 -2
- package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
- package/lib/globalInfo/sfdxDataHandler.d.ts +1 -1
- package/lib/globalInfo/sfdxDataHandler.js +5 -4
- package/lib/lifecycleEvents.js +1 -1
- package/lib/logger.d.ts +3 -3
- package/lib/logger.js +20 -19
- package/lib/messages.d.ts +42 -3
- package/lib/messages.js +55 -12
- package/lib/org/authInfo.d.ts +1 -1
- package/lib/org/authInfo.js +8 -9
- package/lib/org/authRemover.d.ts +2 -2
- package/lib/org/authRemover.js +2 -2
- package/lib/org/connection.d.ts +7 -2
- package/lib/org/connection.js +17 -4
- package/lib/org/org.d.ts +16 -6
- package/lib/org/org.js +54 -51
- package/lib/org/permissionSetAssignment.js +2 -2
- package/lib/org/scratchOrgCreate.d.ts +43 -0
- package/lib/org/scratchOrgCreate.js +142 -0
- package/lib/org/scratchOrgErrorCodes.d.ts +4 -0
- package/lib/org/scratchOrgErrorCodes.js +62 -0
- package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +110 -0
- package/lib/org/scratchOrgInfoApi.d.ts +94 -0
- package/lib/org/scratchOrgInfoApi.js +350 -0
- package/lib/org/scratchOrgInfoGenerator.d.ts +63 -0
- package/lib/org/scratchOrgInfoGenerator.js +223 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +56 -0
- package/lib/org/scratchOrgSettingsGenerator.js +210 -0
- package/lib/org/user.js +8 -7
- package/lib/schema/printer.js +2 -2
- package/lib/schema/validator.d.ts +4 -4
- package/lib/schema/validator.js +13 -13
- package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -14
- package/lib/{sfdxError.js → sfError.js} +20 -21
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
- package/lib/{sfdxProject.js → sfProject.js} +77 -65
- package/lib/status/pollingClient.d.ts +2 -2
- package/lib/status/pollingClient.js +10 -4
- package/lib/status/streamingClient.d.ts +1 -1
- package/lib/status/streamingClient.js +6 -6
- package/lib/testSetup.d.ts +4 -4
- package/lib/testSetup.js +8 -8
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +64 -6
- package/lib/util/jsonXmlTools.d.ts +14 -0
- package/lib/util/jsonXmlTools.js +41 -0
- package/lib/util/mapKeys.d.ts +14 -0
- package/lib/util/mapKeys.js +48 -0
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +2 -2
- package/lib/util/zipWriter.d.ts +14 -0
- package/lib/util/zipWriter.js +68 -0
- package/lib/webOAuthServer.js +11 -11
- package/messages/org.md +4 -0
- package/messages/scratchOrgCreate.md +27 -0
- package/messages/scratchOrgErrorCodes.md +99 -0
- package/messages/scratchOrgFeatureDeprecation.md +11 -0
- package/messages/scratchOrgInfoApi.md +11 -0
- package/messages/scratchOrgInfoGenerator.md +19 -0
- package/messages/user.md +4 -0
- package/package.json +4 -1
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
|
@@ -11,7 +11,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
11
11
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
12
|
const ts_types_2 = require("@salesforce/ts-types");
|
|
13
13
|
const crypto_1 = require("../crypto/crypto");
|
|
14
|
-
const
|
|
14
|
+
const sfError_1 = require("../sfError");
|
|
15
15
|
/**
|
|
16
16
|
* An abstract class that implements all the config management functions but
|
|
17
17
|
* none of the storage functions.
|
|
@@ -206,7 +206,8 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
getEncryptedKeys() {
|
|
209
|
-
|
|
209
|
+
var _a, _b;
|
|
210
|
+
return [...(((_a = this.options) === null || _a === void 0 ? void 0 : _a.encryptedKeys) || []), ...(((_b = this.statics) === null || _b === void 0 ? void 0 : _b.encryptedKeys) || [])];
|
|
210
211
|
}
|
|
211
212
|
/**
|
|
212
213
|
* This config file has encrypted keys and it should attempt to encrypt them.
|
|
@@ -286,18 +287,18 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
286
287
|
if (!value)
|
|
287
288
|
return;
|
|
288
289
|
if (!this.crypto)
|
|
289
|
-
throw new
|
|
290
|
+
throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
|
|
290
291
|
if (!(0, ts_types_2.isString)(value))
|
|
291
|
-
throw new
|
|
292
|
+
throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
|
|
292
293
|
return this.crypto.isEncrypted(value) ? value : this.crypto.encrypt(value);
|
|
293
294
|
}
|
|
294
295
|
decrypt(value) {
|
|
295
296
|
if (!value)
|
|
296
297
|
return;
|
|
297
298
|
if (!this.crypto)
|
|
298
|
-
throw new
|
|
299
|
+
throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
|
|
299
300
|
if (!(0, ts_types_2.isString)(value))
|
|
300
|
-
throw new
|
|
301
|
+
throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
|
|
301
302
|
return this.crypto.isEncrypted(value) ? this.crypto.decrypt(value) : value;
|
|
302
303
|
}
|
|
303
304
|
/**
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.KeychainConfig = void 0;
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const mkdirp = require("mkdirp");
|
|
12
13
|
const configFile_1 = require("./configFile");
|
|
13
14
|
/**
|
|
14
15
|
* Represent a key chain config backed by a json file.
|
|
@@ -34,8 +35,8 @@ class KeychainConfig extends configFile_1.ConfigFile {
|
|
|
34
35
|
if (newContents != null) {
|
|
35
36
|
this.setContents(newContents);
|
|
36
37
|
}
|
|
37
|
-
await
|
|
38
|
-
await
|
|
38
|
+
await mkdirp((0, path_1.dirname)(this.getPath()));
|
|
39
|
+
await fs.promises.writeFile(this.getPath(), JSON.stringify(this.getContents(), null, 4), { mode: '600' });
|
|
39
40
|
return this.getContents();
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -9,12 +9,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.keyChainImpl = exports.GenericWindowsKeychainAccess = exports.GenericUnixKeychainAccess = exports.GenericKeychainAccess = exports.KeychainAccess = void 0;
|
|
10
10
|
const childProcess = require("child_process");
|
|
11
11
|
const nodeFs = require("fs");
|
|
12
|
+
const fs = require("fs");
|
|
12
13
|
const os = require("os");
|
|
13
|
-
const path = require("path");
|
|
14
14
|
const os_1 = require("os");
|
|
15
|
+
const path = require("path");
|
|
15
16
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
17
|
+
const kit_1 = require("@salesforce/kit");
|
|
18
|
+
const mkdirp = require("mkdirp");
|
|
16
19
|
const global_1 = require("../global");
|
|
17
|
-
const fs_1 = require("../util/fs");
|
|
18
20
|
const messages_1 = require("../messages");
|
|
19
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
20
22
|
const messages = messages_1.Messages.load('@salesforce/core', 'encryption', [
|
|
@@ -58,9 +60,9 @@ const _isExe = (mode, gid, uid) => {
|
|
|
58
60
|
/**
|
|
59
61
|
* Private helper to validate that a program exists on the file system and is executable.
|
|
60
62
|
*
|
|
61
|
-
* **Throws** *{@link
|
|
63
|
+
* **Throws** *{@link SfError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
|
|
62
64
|
*
|
|
63
|
-
* **Throws** *{@link
|
|
65
|
+
* **Throws** *{@link SfError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
|
|
64
66
|
*
|
|
65
67
|
* @param programPath The absolute path of the program.
|
|
66
68
|
* @param fsIfc The file system interface.
|
|
@@ -216,7 +218,6 @@ const _linuxImpl = {
|
|
|
216
218
|
// This is a workaround for linux.
|
|
217
219
|
// Calling secret-tool too fast can cause it to return an unexpected error. (below)
|
|
218
220
|
if (stderr != null && stderr.includes('invalid or unencryptable secret')) {
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
220
221
|
// @ts-ignore TODO: make an error subclass with this field
|
|
221
222
|
error.retry = true;
|
|
222
223
|
// Throwing here allows us to perform a retry in KeychainAccess
|
|
@@ -330,8 +331,8 @@ async function _writeFile(opts, fn) {
|
|
|
330
331
|
[SecretField.KEY]: opts.password,
|
|
331
332
|
[SecretField.SERVICE]: opts.service,
|
|
332
333
|
};
|
|
333
|
-
await
|
|
334
|
-
await
|
|
334
|
+
await mkdirp(path.dirname(secretFile));
|
|
335
|
+
await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
|
|
335
336
|
fn(null, contents);
|
|
336
337
|
}
|
|
337
338
|
catch (err) {
|
|
@@ -340,7 +341,7 @@ async function _writeFile(opts, fn) {
|
|
|
340
341
|
}
|
|
341
342
|
async function _readFile() {
|
|
342
343
|
// The file and access is validated before this method is called
|
|
343
|
-
const fileContents = await
|
|
344
|
+
const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(secretFile, 'utf8'));
|
|
344
345
|
return {
|
|
345
346
|
account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
|
|
346
347
|
password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
|
|
@@ -407,7 +408,7 @@ class GenericKeychainAccess {
|
|
|
407
408
|
async isValidFileAccess(cb) {
|
|
408
409
|
try {
|
|
409
410
|
const root = (0, os_1.homedir)();
|
|
410
|
-
await
|
|
411
|
+
await fs.promises.access(path.join(root, global_1.Global.SFDX_STATE_FOLDER), fs.constants.R_OK | fs.constants.X_OK | fs.constants.W_OK);
|
|
411
412
|
await cb(null);
|
|
412
413
|
}
|
|
413
414
|
catch (err) {
|
|
@@ -427,7 +428,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
|
|
|
427
428
|
await cb(err);
|
|
428
429
|
}
|
|
429
430
|
else {
|
|
430
|
-
const stats = await
|
|
431
|
+
const stats = await fs.promises.stat(secretFile);
|
|
431
432
|
const octalModeStr = (stats.mode & 0o777).toString(8);
|
|
432
433
|
const EXPECTED_OCTAL_PERM_VALUE = '600';
|
|
433
434
|
if (octalModeStr === EXPECTED_OCTAL_PERM_VALUE) {
|
|
@@ -452,7 +453,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
|
|
|
452
453
|
}
|
|
453
454
|
else {
|
|
454
455
|
try {
|
|
455
|
-
await
|
|
456
|
+
await fs.promises.access(secretFile, fs.constants.R_OK | fs.constants.W_OK);
|
|
456
457
|
await cb(null);
|
|
457
458
|
}
|
|
458
459
|
catch (e) {
|
|
@@ -15,7 +15,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
15
15
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
17
|
const authInfo_1 = require("./org/authInfo");
|
|
18
|
-
const
|
|
18
|
+
const sfError_1 = require("./sfError");
|
|
19
19
|
const connection_1 = require("./org/connection");
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -29,7 +29,7 @@ async function makeRequest(options) {
|
|
|
29
29
|
const rawResponse = await new transport_1.default().httpRequest(options);
|
|
30
30
|
const response = (0, kit_1.parseJsonMap)(rawResponse.body);
|
|
31
31
|
if (response.error) {
|
|
32
|
-
const err = new
|
|
32
|
+
const err = new sfError_1.SfError('Request Failed.');
|
|
33
33
|
err.data = Object.assign(response, { status: rawResponse.statusCode });
|
|
34
34
|
throw err;
|
|
35
35
|
}
|
package/lib/exported.d.ts
CHANGED
|
@@ -16,18 +16,19 @@ export { WebOAuthServer } from './webOAuthServer';
|
|
|
16
16
|
export { SfdcUrl } from './util/sfdcUrl';
|
|
17
17
|
export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
|
|
18
18
|
export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
|
|
19
|
-
export { Messages } from './messages';
|
|
20
|
-
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, } from './org';
|
|
19
|
+
export { Messages, StructuredMessage } from './messages';
|
|
20
|
+
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
|
|
21
21
|
export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
|
|
22
|
-
export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './
|
|
22
|
+
export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson, SfdxProject, SfdxProjectJson, } from './sfProject';
|
|
23
23
|
export { SchemaPrinter } from './schema/printer';
|
|
24
24
|
export { SchemaValidator } from './schema/validator';
|
|
25
|
-
export { SfdxError } from './
|
|
25
|
+
export { SfError, SfdxError } from './sfError';
|
|
26
26
|
export { PollingClient } from './status/pollingClient';
|
|
27
27
|
export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
|
|
28
28
|
export { MyDomainResolver } from './status/myDomainResolver';
|
|
29
29
|
export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
|
|
30
30
|
export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
|
|
31
|
-
export
|
|
31
|
+
export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate } from './org/scratchOrgCreate';
|
|
32
|
+
export { ScratchOrgInfo } from './org/scratchOrgInfoApi';
|
|
32
33
|
export * from './util/sfdc';
|
|
33
34
|
export * from './util/sfdcUrl';
|
package/lib/exported.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
|
|
19
|
+
exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
22
22
|
var configFile_1 = require("./config/configFile");
|
|
@@ -71,15 +71,18 @@ Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function ()
|
|
|
71
71
|
var orgConfigProperties_1 = require("./org/orgConfigProperties");
|
|
72
72
|
Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
|
|
73
73
|
Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
|
|
74
|
-
var
|
|
75
|
-
Object.defineProperty(exports, "
|
|
76
|
-
Object.defineProperty(exports, "
|
|
74
|
+
var sfProject_1 = require("./sfProject");
|
|
75
|
+
Object.defineProperty(exports, "SfProject", { enumerable: true, get: function () { return sfProject_1.SfProject; } });
|
|
76
|
+
Object.defineProperty(exports, "SfProjectJson", { enumerable: true, get: function () { return sfProject_1.SfProjectJson; } });
|
|
77
|
+
Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfProject_1.SfdxProject; } });
|
|
78
|
+
Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfProject_1.SfdxProjectJson; } });
|
|
77
79
|
var printer_1 = require("./schema/printer");
|
|
78
80
|
Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
|
|
79
81
|
var validator_1 = require("./schema/validator");
|
|
80
82
|
Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return validator_1.SchemaValidator; } });
|
|
81
|
-
var
|
|
82
|
-
Object.defineProperty(exports, "
|
|
83
|
+
var sfError_1 = require("./sfError");
|
|
84
|
+
Object.defineProperty(exports, "SfError", { enumerable: true, get: function () { return sfError_1.SfError; } });
|
|
85
|
+
Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfError_1.SfdxError; } });
|
|
83
86
|
var pollingClient_1 = require("./status/pollingClient");
|
|
84
87
|
Object.defineProperty(exports, "PollingClient", { enumerable: true, get: function () { return pollingClient_1.PollingClient; } });
|
|
85
88
|
var streamingClient_1 = require("./status/streamingClient");
|
|
@@ -93,8 +96,9 @@ Object.defineProperty(exports, "REQUIRED_FIELDS", { enumerable: true, get: funct
|
|
|
93
96
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
|
|
94
97
|
var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
|
|
95
98
|
Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, get: function () { return permissionSetAssignment_1.PermissionSetAssignment; } });
|
|
99
|
+
var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
|
|
100
|
+
Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
|
|
96
101
|
// Utility sub-modules
|
|
97
|
-
__exportStar(require("./util/fs"), exports);
|
|
98
102
|
__exportStar(require("./util/sfdc"), exports);
|
|
99
103
|
__exportStar(require("./util/sfdcUrl"), exports);
|
|
100
104
|
//# sourceMappingURL=exported.js.map
|
package/lib/global.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.Global = exports.Mode = void 0;
|
|
|
10
10
|
const os = require("os");
|
|
11
11
|
const path = require("path");
|
|
12
12
|
const kit_1 = require("@salesforce/kit");
|
|
13
|
-
const
|
|
13
|
+
const mkdirp = require("mkdirp");
|
|
14
14
|
/**
|
|
15
15
|
* Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
|
|
16
16
|
* with the default mode being `production`.
|
|
@@ -46,7 +46,7 @@ class Global {
|
|
|
46
46
|
*/
|
|
47
47
|
static async createDir(dirPath) {
|
|
48
48
|
dirPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
|
|
49
|
-
await
|
|
49
|
+
await mkdirp(dirPath, '700');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
exports.Global = Global;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AliasAccessor = void 0;
|
|
10
|
-
const
|
|
10
|
+
const sfError_1 = require("../../sfError");
|
|
11
11
|
const types_1 = require("../types");
|
|
12
12
|
class AliasAccessor {
|
|
13
13
|
constructor(globalInfo) {
|
|
@@ -121,7 +121,7 @@ class AliasAccessor {
|
|
|
121
121
|
return entity;
|
|
122
122
|
const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
|
|
123
123
|
if (!aliaseeName) {
|
|
124
|
-
throw new
|
|
124
|
+
throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
125
125
|
}
|
|
126
126
|
return aliaseeName;
|
|
127
127
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConfigFile } from '../config/configFile';
|
|
2
|
-
import {
|
|
2
|
+
import { SfInfo, SfInfoKeys, SfOrg, SfOrgs } from './types';
|
|
3
3
|
interface Handler<T extends SfInfoKeys> {
|
|
4
4
|
sfKey: T;
|
|
5
5
|
merge: (sfData: SfInfo) => Promise<Partial<SfInfo>>;
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AliasesHandler = exports.AuthHandler = exports.SfdxDataHandler = void 0;
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
11
12
|
const kit_1 = require("@salesforce/kit");
|
|
12
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
14
|
const global_1 = require("../global");
|
|
14
|
-
const fs_1 = require("../util/fs");
|
|
15
15
|
const configFile_1 = require("../config/configFile");
|
|
16
16
|
const globalInfoConfig_1 = require("./globalInfoConfig");
|
|
17
17
|
const types_1 = require("./types");
|
|
@@ -141,7 +141,7 @@ class AuthHandler extends BaseHandler {
|
|
|
141
141
|
return config;
|
|
142
142
|
}
|
|
143
143
|
async listAllAuthFiles() {
|
|
144
|
-
const globalFiles = await
|
|
144
|
+
const globalFiles = await fs.promises.readdir(global_1.Global.SFDX_DIR);
|
|
145
145
|
return globalFiles.filter((file) => file.match(AuthHandler.authFilenameFilterRegEx));
|
|
146
146
|
}
|
|
147
147
|
async listAllAuthorizations() {
|
|
@@ -169,7 +169,8 @@ class AliasesHandler extends BaseHandler {
|
|
|
169
169
|
async migrate() {
|
|
170
170
|
const aliasesFilePath = (0, path_1.join)(global_1.Global.SFDX_DIR, AliasesHandler.SFDX_ALIASES_FILENAME);
|
|
171
171
|
try {
|
|
172
|
-
const
|
|
172
|
+
const x = await fs.promises.readFile(aliasesFilePath, 'utf8');
|
|
173
|
+
const sfdxAliases = (0, kit_1.parseJson)(x).orgs;
|
|
173
174
|
return { [this.sfKey]: { ...sfdxAliases } };
|
|
174
175
|
}
|
|
175
176
|
catch (e) {
|
|
@@ -209,7 +210,7 @@ class AliasesHandler extends BaseHandler {
|
|
|
209
210
|
}
|
|
210
211
|
async write(latest) {
|
|
211
212
|
const aliasesFilePath = (0, path_1.join)(global_1.Global.SFDX_DIR, AliasesHandler.SFDX_ALIASES_FILENAME);
|
|
212
|
-
|
|
213
|
+
await fs.promises.writeFile(aliasesFilePath, JSON.stringify({ orgs: latest[types_1.SfInfoKeys.ALIASES] }, null, 2));
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
exports.AliasesHandler = AliasesHandler;
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -170,7 +170,7 @@ class Lifecycle {
|
|
|
170
170
|
*/
|
|
171
171
|
async emit(eventName, data) {
|
|
172
172
|
const listeners = this.getListeners(eventName);
|
|
173
|
-
if (listeners.length === 0) {
|
|
173
|
+
if (listeners.length === 0 && eventName !== Lifecycle.warningEventName) {
|
|
174
174
|
this.debug(`A lifecycle event with the name ${eventName} does not exist. An event must be registered before it can be emitted.`);
|
|
175
175
|
}
|
|
176
176
|
else {
|
package/lib/logger.d.ts
CHANGED
|
@@ -174,7 +174,7 @@ export declare class Logger {
|
|
|
174
174
|
*
|
|
175
175
|
* @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
|
|
176
176
|
*
|
|
177
|
-
* **Throws** *{@link
|
|
177
|
+
* **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
|
|
178
178
|
* `Logger`.
|
|
179
179
|
*/
|
|
180
180
|
constructor(optionsOrName: LoggerOptions | string);
|
|
@@ -211,7 +211,7 @@ export declare class Logger {
|
|
|
211
211
|
*
|
|
212
212
|
* @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
|
|
213
213
|
*
|
|
214
|
-
* **Throws** *{@link
|
|
214
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
|
|
215
215
|
* @see {@Link LoggerLevel}
|
|
216
216
|
*/
|
|
217
217
|
static getLevelByName(levelName: string): LoggerLevelValue;
|
|
@@ -249,7 +249,7 @@ export declare class Logger {
|
|
|
249
249
|
*
|
|
250
250
|
* @param {LoggerLevelValue} [level] The logger level.
|
|
251
251
|
*
|
|
252
|
-
* **Throws** *{@link
|
|
252
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
|
|
253
253
|
* was invalid.
|
|
254
254
|
*
|
|
255
255
|
* ```
|
package/lib/logger.js
CHANGED
|
@@ -11,15 +11,16 @@ const events_1 = require("events");
|
|
|
11
11
|
const os = require("os");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const stream_1 = require("stream");
|
|
14
|
+
const fs = require("fs");
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
16
|
// @ts-ignore
|
|
16
17
|
const Bunyan = require("@salesforce/bunyan");
|
|
17
18
|
const kit_1 = require("@salesforce/kit");
|
|
18
19
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
19
20
|
const Debug = require("debug");
|
|
21
|
+
const mkdirp = require("mkdirp");
|
|
20
22
|
const global_1 = require("./global");
|
|
21
|
-
const
|
|
22
|
-
const fs_1 = require("./util/fs");
|
|
23
|
+
const sfError_1 = require("./sfError");
|
|
23
24
|
/**
|
|
24
25
|
* Standard `Logger` levels.
|
|
25
26
|
*
|
|
@@ -69,7 +70,7 @@ class Logger {
|
|
|
69
70
|
*
|
|
70
71
|
* @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
|
|
71
72
|
*
|
|
72
|
-
* **Throws** *{@link
|
|
73
|
+
* **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
|
|
73
74
|
* `Logger`.
|
|
74
75
|
*/
|
|
75
76
|
constructor(optionsOrName) {
|
|
@@ -103,7 +104,7 @@ class Logger {
|
|
|
103
104
|
options = optionsOrName;
|
|
104
105
|
}
|
|
105
106
|
if (Logger.rootLogger && options.name === Logger.ROOT_NAME) {
|
|
106
|
-
throw new
|
|
107
|
+
throw new sfError_1.SfError('Can not create another root logger.', 'RedundantRootLoggerError');
|
|
107
108
|
}
|
|
108
109
|
// Inspect format to know what logging format to use then delete from options to
|
|
109
110
|
// ensure it doesn't conflict with Bunyan.
|
|
@@ -199,13 +200,13 @@ class Logger {
|
|
|
199
200
|
*
|
|
200
201
|
* @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
|
|
201
202
|
*
|
|
202
|
-
* **Throws** *{@link
|
|
203
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
|
|
203
204
|
* @see {@Link LoggerLevel}
|
|
204
205
|
*/
|
|
205
206
|
static getLevelByName(levelName) {
|
|
206
207
|
levelName = levelName.toUpperCase();
|
|
207
208
|
if (!(0, ts_types_1.isKeyOf)(LoggerLevel, levelName)) {
|
|
208
|
-
throw new
|
|
209
|
+
throw new sfError_1.SfError(`Invalid log level "${levelName}".`, 'UnrecognizedLoggerLevelNameError');
|
|
209
210
|
}
|
|
210
211
|
return LoggerLevel[levelName];
|
|
211
212
|
}
|
|
@@ -229,22 +230,22 @@ class Logger {
|
|
|
229
230
|
async addLogFileStream(logFile) {
|
|
230
231
|
try {
|
|
231
232
|
// Check if we have write access to the log file (i.e., we created it already)
|
|
232
|
-
await
|
|
233
|
+
await fs.promises.access(logFile, fs.constants.W_OK);
|
|
233
234
|
}
|
|
234
235
|
catch (err1) {
|
|
235
236
|
try {
|
|
236
|
-
await
|
|
237
|
-
mode:
|
|
237
|
+
await mkdirp(path.dirname(logFile), {
|
|
238
|
+
mode: '700',
|
|
238
239
|
});
|
|
239
240
|
}
|
|
240
241
|
catch (err2) {
|
|
241
242
|
// noop; directory exists already
|
|
242
243
|
}
|
|
243
244
|
try {
|
|
244
|
-
await
|
|
245
|
+
await fs.promises.writeFile(logFile, '', { mode: '600' });
|
|
245
246
|
}
|
|
246
247
|
catch (err3) {
|
|
247
|
-
throw
|
|
248
|
+
throw sfError_1.SfError.wrap(err3);
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
// avoid multiple streams to same log file
|
|
@@ -269,22 +270,22 @@ class Logger {
|
|
|
269
270
|
addLogFileStreamSync(logFile) {
|
|
270
271
|
try {
|
|
271
272
|
// Check if we have write access to the log file (i.e., we created it already)
|
|
272
|
-
|
|
273
|
+
fs.accessSync(logFile, fs.constants.W_OK);
|
|
273
274
|
}
|
|
274
275
|
catch (err1) {
|
|
275
276
|
try {
|
|
276
|
-
|
|
277
|
-
mode:
|
|
277
|
+
mkdirp.sync(path.dirname(logFile), {
|
|
278
|
+
mode: '700',
|
|
278
279
|
});
|
|
279
280
|
}
|
|
280
281
|
catch (err2) {
|
|
281
282
|
// noop; directory exists already
|
|
282
283
|
}
|
|
283
284
|
try {
|
|
284
|
-
|
|
285
|
+
fs.writeFileSync(logFile, '', { mode: '600' });
|
|
285
286
|
}
|
|
286
287
|
catch (err3) {
|
|
287
|
-
throw
|
|
288
|
+
throw sfError_1.SfError.wrap(err3);
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
// avoid multiple streams to same log file
|
|
@@ -320,7 +321,7 @@ class Logger {
|
|
|
320
321
|
*
|
|
321
322
|
* @param {LoggerLevelValue} [level] The logger level.
|
|
322
323
|
*
|
|
323
|
-
* **Throws** *{@link
|
|
324
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
|
|
324
325
|
* was invalid.
|
|
325
326
|
*
|
|
326
327
|
* ```
|
|
@@ -401,7 +402,7 @@ class Logger {
|
|
|
401
402
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
402
403
|
this.bunyan.streams.forEach(async (stream) => {
|
|
403
404
|
if (stream.type === 'file') {
|
|
404
|
-
content += await
|
|
405
|
+
content += await fs.promises.readFile(stream.path, 'utf8');
|
|
405
406
|
}
|
|
406
407
|
});
|
|
407
408
|
return content;
|
|
@@ -453,7 +454,7 @@ class Logger {
|
|
|
453
454
|
*/
|
|
454
455
|
child(name, fields = {}) {
|
|
455
456
|
if (!name) {
|
|
456
|
-
throw new
|
|
457
|
+
throw new sfError_1.SfError('LoggerNameRequired');
|
|
457
458
|
}
|
|
458
459
|
fields.log = name;
|
|
459
460
|
const child = new Logger(name);
|
package/lib/messages.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { AnyJson } from '@salesforce/ts-types';
|
|
2
|
-
import {
|
|
2
|
+
import { SfError } from './sfError';
|
|
3
3
|
export declare type Tokens = Array<string | boolean | number | null | undefined>;
|
|
4
|
+
export declare type StructuredMessage = {
|
|
5
|
+
message: string;
|
|
6
|
+
name: string;
|
|
7
|
+
actions?: string[];
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* A loader function to return messages.
|
|
6
11
|
*
|
|
@@ -244,9 +249,43 @@ export declare class Messages<T extends string> {
|
|
|
244
249
|
* @param key The key of the error message.
|
|
245
250
|
* @param tokens The error message tokens.
|
|
246
251
|
* @param actionTokens The action messages tokens.
|
|
247
|
-
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or
|
|
252
|
+
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
|
|
248
253
|
* @param cause The underlying error that caused this error to be raised.
|
|
249
254
|
*/
|
|
250
|
-
createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error):
|
|
255
|
+
createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
|
|
256
|
+
/**
|
|
257
|
+
* Convenience method to create warning using message labels.
|
|
258
|
+
*
|
|
259
|
+
* `warning.name` will be the upper-cased key, remove prefixed `warning.` and will always end in Warning.
|
|
260
|
+
* `warning.actions` will be loaded using `${key}.actions` if available.
|
|
261
|
+
*
|
|
262
|
+
* @param key The key of the warning message.
|
|
263
|
+
* @param tokens The warning message tokens.
|
|
264
|
+
* @param actionTokens The action messages tokens.
|
|
265
|
+
*/
|
|
266
|
+
createWarning(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
|
|
267
|
+
/**
|
|
268
|
+
* Convenience method to create info using message labels.
|
|
269
|
+
*
|
|
270
|
+
* `info.name` will be the upper-cased key, remove prefixed `info.` and will always end in Info.
|
|
271
|
+
* `info.actions` will be loaded using `${key}.actions` if available.
|
|
272
|
+
*
|
|
273
|
+
* @param key The key of the warning message.
|
|
274
|
+
* @param tokens The warning message tokens.
|
|
275
|
+
* @param actionTokens The action messages tokens.
|
|
276
|
+
*/
|
|
277
|
+
createInfo(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
|
|
278
|
+
/**
|
|
279
|
+
* Formats message contents given a message type, key, tokens and actions tokens
|
|
280
|
+
*
|
|
281
|
+
* `<type>.name` will be the upper-cased key, remove prefixed `<type>.` and will always end in 'Error | Warning | Info.
|
|
282
|
+
* `<type>.actions` will be loaded using `${key}.actions` if available.
|
|
283
|
+
*
|
|
284
|
+
* @param type The type of the message set must 'error' | 'warning' | 'info'.
|
|
285
|
+
* @param key The key of the warning message.
|
|
286
|
+
* @param tokens The warning message tokens.
|
|
287
|
+
* @param actionTokens The action messages tokens.
|
|
288
|
+
*/
|
|
289
|
+
private formatMessageContents;
|
|
251
290
|
private getMessageWithMap;
|
|
252
291
|
}
|