@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
package/lib/testSetup.js
CHANGED
|
@@ -21,8 +21,8 @@ const connection_1 = require("./org/connection");
|
|
|
21
21
|
const crypto_2 = require("./crypto/crypto");
|
|
22
22
|
const logger_1 = require("./logger");
|
|
23
23
|
const messages_1 = require("./messages");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const sfError_1 = require("./sfError");
|
|
25
|
+
const sfProject_1 = require("./sfProject");
|
|
26
26
|
const streamingClient_1 = require("./status/streamingClient");
|
|
27
27
|
const globalInfo_1 = require("./globalInfo");
|
|
28
28
|
const global_1 = require("./global");
|
|
@@ -126,12 +126,12 @@ const instantiateContext = (sinon) => {
|
|
|
126
126
|
inProject(inProject = true) {
|
|
127
127
|
testContext.SANDBOXES.PROJECT.restore();
|
|
128
128
|
if (inProject) {
|
|
129
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
130
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
129
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPath').callsFake(() => testContext.localPathRetriever(testContext.id));
|
|
130
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPathSync').callsFake(() => testContext.localPathRetrieverSync(testContext.id));
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
134
|
-
testContext.SANDBOXES.PROJECT.stub(
|
|
133
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPath').rejects(new sfError_1.SfError('', 'InvalidProjectWorkspaceError'));
|
|
134
|
+
testContext.SANDBOXES.PROJECT.stub(sfProject_1.SfProject, 'resolveProjectPathSync').throws(new sfError_1.SfError('', 'InvalidProjectWorkspaceError'));
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
};
|
|
@@ -174,7 +174,7 @@ const stubContext = (testContext) => {
|
|
|
174
174
|
testContext.inProject(true);
|
|
175
175
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolder').callsFake((isGlobal) => testContext.rootPathRetriever(isGlobal, testContext.id));
|
|
176
176
|
testContext.SANDBOXES.CONFIG.stub(configFile_1.ConfigFile, 'resolveRootFolderSync').callsFake((isGlobal) => testContext.rootPathRetrieverSync(isGlobal, testContext.id));
|
|
177
|
-
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.PROJECT,
|
|
177
|
+
(0, ts_sinon_1.stubMethod)(testContext.SANDBOXES.PROJECT, sfProject_1.SfProjectJson.prototype, 'doesPackageExist').callsFake(() => true);
|
|
178
178
|
const initStubForRead = (configFile) => {
|
|
179
179
|
const stub = testContext.configStubs[configFile.constructor.name] || {};
|
|
180
180
|
// init calls read calls getPath which sets the path on the config file the first time.
|
|
@@ -324,7 +324,7 @@ exports.testSetup = (0, kit_1.once)(_testSetup);
|
|
|
324
324
|
*
|
|
325
325
|
* **See** {@link shouldThrow}
|
|
326
326
|
*/
|
|
327
|
-
exports.unexpectedResult = new
|
|
327
|
+
exports.unexpectedResult = new sfError_1.SfError('This code was expected to fail', 'UnexpectedResult');
|
|
328
328
|
/**
|
|
329
329
|
* Use for this testing pattern:
|
|
330
330
|
* ```
|
package/lib/util/internal.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Optional } from '@salesforce/ts-types';
|
|
1
2
|
/**
|
|
2
3
|
* The name of the project config file.
|
|
3
4
|
*
|
|
@@ -11,7 +12,7 @@ export declare const SFDX_PROJECT_JSON = "sfdx-project.json";
|
|
|
11
12
|
*
|
|
12
13
|
* **See** {@link traverseForFile}
|
|
13
14
|
*
|
|
14
|
-
* **Throws** *{@link
|
|
15
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
15
16
|
*
|
|
16
17
|
* @param dir The directory path to start traversing from.
|
|
17
18
|
* @ignore
|
|
@@ -24,9 +25,34 @@ export declare function resolveProjectPath(dir?: string): Promise<string>;
|
|
|
24
25
|
*
|
|
25
26
|
* **See** {@link traverseForFile}
|
|
26
27
|
*
|
|
27
|
-
* **Throws** *{@link
|
|
28
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
28
29
|
*
|
|
29
30
|
* @param dir The directory path to start traversing from.
|
|
30
31
|
* @ignore
|
|
31
32
|
*/
|
|
32
33
|
export declare function resolveProjectPathSync(dir?: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* These methods were moved from the deprecated 'fs' module in v2 and are only used in sfdx-core above
|
|
36
|
+
*
|
|
37
|
+
* They were migrated into the 'traverse' constant in order to stub them in unit tests
|
|
38
|
+
*/
|
|
39
|
+
export declare const traverse: {
|
|
40
|
+
/**
|
|
41
|
+
* Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
42
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
43
|
+
* not found.
|
|
44
|
+
*
|
|
45
|
+
* @param dir The directory path in which to start the upward search.
|
|
46
|
+
* @param file The file name to look for.
|
|
47
|
+
*/
|
|
48
|
+
forFile: (dir: string, file: string) => Promise<Optional<string>>;
|
|
49
|
+
/**
|
|
50
|
+
* Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
51
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
52
|
+
* not found.
|
|
53
|
+
*
|
|
54
|
+
* @param dir The directory path in which to start the upward search.
|
|
55
|
+
* @param file The file name to look for.
|
|
56
|
+
*/
|
|
57
|
+
forFileSync: (dir: string, file: string) => Optional<string>;
|
|
58
|
+
};
|
package/lib/util/internal.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0;
|
|
9
|
+
exports.traverse = exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0;
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
10
12
|
const messages_1 = require("../messages");
|
|
11
|
-
const fs_1 = require("./fs");
|
|
12
13
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
13
14
|
const messages = messages_1.Messages.load('@salesforce/core', 'config', ['invalidProjectWorkspace']);
|
|
14
15
|
/**
|
|
@@ -25,13 +26,13 @@ exports.SFDX_PROJECT_JSON = 'sfdx-project.json';
|
|
|
25
26
|
*
|
|
26
27
|
* **See** {@link traverseForFile}
|
|
27
28
|
*
|
|
28
|
-
* **Throws** *{@link
|
|
29
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
29
30
|
*
|
|
30
31
|
* @param dir The directory path to start traversing from.
|
|
31
32
|
* @ignore
|
|
32
33
|
*/
|
|
33
34
|
async function resolveProjectPath(dir = process.cwd()) {
|
|
34
|
-
const projectPath = await
|
|
35
|
+
const projectPath = await exports.traverse.forFile(dir, exports.SFDX_PROJECT_JSON);
|
|
35
36
|
if (!projectPath) {
|
|
36
37
|
throw messages.createError('invalidProjectWorkspace');
|
|
37
38
|
}
|
|
@@ -45,17 +46,74 @@ exports.resolveProjectPath = resolveProjectPath;
|
|
|
45
46
|
*
|
|
46
47
|
* **See** {@link traverseForFile}
|
|
47
48
|
*
|
|
48
|
-
* **Throws** *{@link
|
|
49
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
49
50
|
*
|
|
50
51
|
* @param dir The directory path to start traversing from.
|
|
51
52
|
* @ignore
|
|
52
53
|
*/
|
|
53
54
|
function resolveProjectPathSync(dir = process.cwd()) {
|
|
54
|
-
const projectPath =
|
|
55
|
+
const projectPath = exports.traverse.forFileSync(dir, exports.SFDX_PROJECT_JSON);
|
|
55
56
|
if (!projectPath) {
|
|
56
57
|
throw messages.createError('invalidProjectWorkspace');
|
|
57
58
|
}
|
|
58
59
|
return projectPath;
|
|
59
60
|
}
|
|
60
61
|
exports.resolveProjectPathSync = resolveProjectPathSync;
|
|
62
|
+
/**
|
|
63
|
+
* These methods were moved from the deprecated 'fs' module in v2 and are only used in sfdx-core above
|
|
64
|
+
*
|
|
65
|
+
* They were migrated into the 'traverse' constant in order to stub them in unit tests
|
|
66
|
+
*/
|
|
67
|
+
exports.traverse = {
|
|
68
|
+
/**
|
|
69
|
+
* Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
70
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
71
|
+
* not found.
|
|
72
|
+
*
|
|
73
|
+
* @param dir The directory path in which to start the upward search.
|
|
74
|
+
* @param file The file name to look for.
|
|
75
|
+
*/
|
|
76
|
+
forFile: async (dir, file) => {
|
|
77
|
+
let foundProjectDir;
|
|
78
|
+
try {
|
|
79
|
+
fs.statSync((0, path_1.join)(dir, file));
|
|
80
|
+
foundProjectDir = dir;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err && err.code === 'ENOENT') {
|
|
84
|
+
const nextDir = (0, path_1.resolve)(dir, '..');
|
|
85
|
+
if (nextDir !== dir) {
|
|
86
|
+
// stop at root
|
|
87
|
+
foundProjectDir = await exports.traverse.forFile(nextDir, file);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return foundProjectDir;
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
95
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
96
|
+
* not found.
|
|
97
|
+
*
|
|
98
|
+
* @param dir The directory path in which to start the upward search.
|
|
99
|
+
* @param file The file name to look for.
|
|
100
|
+
*/
|
|
101
|
+
forFileSync: (dir, file) => {
|
|
102
|
+
let foundProjectDir;
|
|
103
|
+
try {
|
|
104
|
+
fs.statSync((0, path_1.join)(dir, file));
|
|
105
|
+
foundProjectDir = dir;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err && err.code === 'ENOENT') {
|
|
109
|
+
const nextDir = (0, path_1.resolve)(dir, '..');
|
|
110
|
+
if (nextDir !== dir) {
|
|
111
|
+
// stop at root
|
|
112
|
+
foundProjectDir = exports.traverse.forFileSync(nextDir, file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return foundProjectDir;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
61
119
|
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonMap } from '@salesforce/ts-types';
|
|
2
|
+
import { IOptions } from 'js2xmlparser/lib/options';
|
|
3
|
+
export interface JSONasXML {
|
|
4
|
+
json: JsonMap;
|
|
5
|
+
type: string;
|
|
6
|
+
options?: IOptions;
|
|
7
|
+
}
|
|
8
|
+
export interface WriteJSONasXMLInputs extends JSONasXML {
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const standardOptions: IOptions;
|
|
12
|
+
export declare const writeJSONasXML: ({ path, json, type, options, }: WriteJSONasXMLInputs) => Promise<void>;
|
|
13
|
+
export declare const JsonAsXml: ({ json, type, options }: JSONasXML) => string;
|
|
14
|
+
export declare const fixExistingDollarSign: (existing: WriteJSONasXMLInputs['json']) => Record<string, unknown>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.fixExistingDollarSign = exports.JsonAsXml = exports.writeJSONasXML = exports.standardOptions = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const jsToXml = require("js2xmlparser");
|
|
12
|
+
exports.standardOptions = {
|
|
13
|
+
declaration: {
|
|
14
|
+
include: true,
|
|
15
|
+
encoding: 'UTF-8',
|
|
16
|
+
version: '1.0',
|
|
17
|
+
},
|
|
18
|
+
format: {
|
|
19
|
+
doubleQuotes: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const writeJSONasXML = async ({ path, json, type, options = exports.standardOptions, }) => {
|
|
23
|
+
const xml = jsToXml.parse(type, (0, exports.fixExistingDollarSign)(json), options);
|
|
24
|
+
return await fs_1.promises.writeFile(path, xml);
|
|
25
|
+
};
|
|
26
|
+
exports.writeJSONasXML = writeJSONasXML;
|
|
27
|
+
const JsonAsXml = ({ json, type, options = exports.standardOptions }) => {
|
|
28
|
+
return jsToXml.parse(type, (0, exports.fixExistingDollarSign)(json), options);
|
|
29
|
+
};
|
|
30
|
+
exports.JsonAsXml = JsonAsXml;
|
|
31
|
+
const fixExistingDollarSign = (existing) => {
|
|
32
|
+
const existingCopy = { ...existing };
|
|
33
|
+
if (existingCopy.$) {
|
|
34
|
+
const temp = existingCopy.$;
|
|
35
|
+
delete existingCopy.$;
|
|
36
|
+
existingCopy['@'] = temp;
|
|
37
|
+
}
|
|
38
|
+
return existingCopy;
|
|
39
|
+
};
|
|
40
|
+
exports.fixExistingDollarSign = fixExistingDollarSign;
|
|
41
|
+
//# sourceMappingURL=jsonXmlTools.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use mapKeys to convert object keys to another format using the specified conversion function.
|
|
3
|
+
*
|
|
4
|
+
* E.g., to deep convert all object keys to camelCase: mapKeys(myObj, _.camelCase, true)
|
|
5
|
+
* to shallow convert object keys to lower case: mapKeys(myObj, _.toLower)
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This mutates the object passed in for conversion.
|
|
8
|
+
*
|
|
9
|
+
* @param target - {Object} The object to convert the keys
|
|
10
|
+
* @param converter - {Function} The function that converts the object key
|
|
11
|
+
* @param deep - {boolean} Whether to do a deep object key conversion
|
|
12
|
+
* @return {Object} - the object with the converted keys
|
|
13
|
+
*/
|
|
14
|
+
export default function mapKeys(obj: any, converter: (key: string) => string, deep?: boolean): Record<string, unknown>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
10
|
+
/**
|
|
11
|
+
* Use mapKeys to convert object keys to another format using the specified conversion function.
|
|
12
|
+
*
|
|
13
|
+
* E.g., to deep convert all object keys to camelCase: mapKeys(myObj, _.camelCase, true)
|
|
14
|
+
* to shallow convert object keys to lower case: mapKeys(myObj, _.toLower)
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This mutates the object passed in for conversion.
|
|
17
|
+
*
|
|
18
|
+
* @param target - {Object} The object to convert the keys
|
|
19
|
+
* @param converter - {Function} The function that converts the object key
|
|
20
|
+
* @param deep - {boolean} Whether to do a deep object key conversion
|
|
21
|
+
* @return {Object} - the object with the converted keys
|
|
22
|
+
*/
|
|
23
|
+
function mapKeys(
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
25
|
+
obj, converter, deep) {
|
|
26
|
+
const target = Object.assign({}, obj);
|
|
27
|
+
return Object.fromEntries(Object.entries(target).map(([key, value]) => {
|
|
28
|
+
const k = converter.call(null, key);
|
|
29
|
+
if (deep) {
|
|
30
|
+
let v = value;
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
v = value.map((v1) => {
|
|
33
|
+
if ((0, ts_types_1.isPlainObject)(v1)) {
|
|
34
|
+
return mapKeys(v1, converter, deep);
|
|
35
|
+
}
|
|
36
|
+
return v1;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if ((0, ts_types_1.isPlainObject)(value)) {
|
|
40
|
+
v = mapKeys(value, converter, deep);
|
|
41
|
+
}
|
|
42
|
+
return [k, v];
|
|
43
|
+
}
|
|
44
|
+
return [k, value];
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
exports.default = mapKeys;
|
|
48
|
+
//# sourceMappingURL=mapKeys.js.map
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare class SfdcUrl extends URL {
|
|
|
43
43
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
44
44
|
*
|
|
45
45
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
46
|
-
* @throws {@link
|
|
46
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
47
47
|
*/
|
|
48
48
|
checkLightningDomain(): Promise<true | never>;
|
|
49
49
|
/**
|
|
@@ -51,7 +51,7 @@ export declare class SfdcUrl extends URL {
|
|
|
51
51
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
52
52
|
*
|
|
53
53
|
* @returns the resolved ip address.
|
|
54
|
-
* @throws {@link
|
|
54
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
55
55
|
*/
|
|
56
56
|
lookup(): Promise<string>;
|
|
57
57
|
/**
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -121,7 +121,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
121
121
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
122
122
|
*
|
|
123
123
|
* @returns {Promise<true | never>} The resolved ip address or never
|
|
124
|
-
* @throws {@link
|
|
124
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
125
125
|
*/
|
|
126
126
|
async checkLightningDomain() {
|
|
127
127
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
@@ -142,7 +142,7 @@ class SfdcUrl extends url_1.URL {
|
|
|
142
142
|
* If SFDX_DOMAIN_RETRY environment variable is set (number) it overrides the default timeout duration (240 seconds)
|
|
143
143
|
*
|
|
144
144
|
* @returns the resolved ip address.
|
|
145
|
-
* @throws {@link
|
|
145
|
+
* @throws {@link SfError} If can't resolve DNS.
|
|
146
146
|
*/
|
|
147
147
|
async lookup() {
|
|
148
148
|
const quantity = (0, ts_types_1.ensureNumber)(new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { pipeline as cbPipeline, Readable, Writable } from 'stream';
|
|
3
|
+
export declare const pipeline: typeof cbPipeline.__promisify__;
|
|
4
|
+
export declare class ZipWriter extends Writable {
|
|
5
|
+
private rootDestination?;
|
|
6
|
+
private zip;
|
|
7
|
+
private buffers;
|
|
8
|
+
constructor(rootDestination?: string | undefined);
|
|
9
|
+
addToZip(contents: string | Readable | Buffer, path: string): void;
|
|
10
|
+
finalize(): Promise<void>;
|
|
11
|
+
private getOutputStream;
|
|
12
|
+
private getInputBuffer;
|
|
13
|
+
get buffer(): Buffer;
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ZipWriter = exports.pipeline = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const stream_1 = require("stream");
|
|
12
|
+
const util_1 = require("util");
|
|
13
|
+
const archiver_1 = require("archiver");
|
|
14
|
+
exports.pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
15
|
+
class ZipWriter extends stream_1.Writable {
|
|
16
|
+
constructor(rootDestination) {
|
|
17
|
+
super({ objectMode: true });
|
|
18
|
+
this.rootDestination = rootDestination;
|
|
19
|
+
// compression-/speed+ (0)<---(3)---------->(9) compression+/speed-
|
|
20
|
+
// 3 appears to be a decent balance of compression and speed. It felt like
|
|
21
|
+
// higher values = diminishing returns on compression and made conversion slower
|
|
22
|
+
this.zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
|
|
23
|
+
this.buffers = [];
|
|
24
|
+
void (0, exports.pipeline)(this.zip, this.getOutputStream());
|
|
25
|
+
}
|
|
26
|
+
addToZip(contents, path) {
|
|
27
|
+
this.zip.append(contents, { name: path });
|
|
28
|
+
}
|
|
29
|
+
async finalize() {
|
|
30
|
+
await this.zip.finalize();
|
|
31
|
+
await this.getInputBuffer();
|
|
32
|
+
}
|
|
33
|
+
getOutputStream() {
|
|
34
|
+
if (this.rootDestination) {
|
|
35
|
+
return (0, fs_1.createWriteStream)(this.rootDestination);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const bufferWritable = new stream_1.Writable();
|
|
39
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
40
|
+
bufferWritable._write = (chunk, encoding, cb) => {
|
|
41
|
+
this.buffers.push(chunk);
|
|
42
|
+
cb();
|
|
43
|
+
};
|
|
44
|
+
return bufferWritable;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async getInputBuffer() {
|
|
48
|
+
if (this.rootDestination) {
|
|
49
|
+
const inputStream = (0, fs_1.createReadStream)(this.rootDestination);
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
inputStream.on('data', (chunk) => {
|
|
52
|
+
this.buffers.push(chunk);
|
|
53
|
+
});
|
|
54
|
+
inputStream.once('end', () => {
|
|
55
|
+
return resolve();
|
|
56
|
+
});
|
|
57
|
+
inputStream.once('error', (error) => {
|
|
58
|
+
return reject(error);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
get buffer() {
|
|
64
|
+
return Buffer.concat(this.buffers);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ZipWriter = ZipWriter;
|
|
68
|
+
//# sourceMappingURL=zipWriter.js.map
|
package/lib/webOAuthServer.js
CHANGED
|
@@ -16,9 +16,9 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
16
16
|
const jsforce_1 = require("jsforce");
|
|
17
17
|
const logger_1 = require("./logger");
|
|
18
18
|
const authInfo_1 = require("./org/authInfo");
|
|
19
|
-
const
|
|
19
|
+
const sfError_1 = require("./sfError");
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
|
-
const
|
|
21
|
+
const sfProject_1 = require("./sfProject");
|
|
22
22
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
23
23
|
const messages = messages_1.Messages.load('@salesforce/core', 'auth', [
|
|
24
24
|
'invalidRequestUri',
|
|
@@ -56,8 +56,8 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
56
56
|
*/
|
|
57
57
|
static async determineOauthPort() {
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
59
|
+
const sfProject = await sfProject_1.SfProjectJson.create();
|
|
60
|
+
return sfProject.get('oauthLocalPort') || WebOAuthServer.DEFAULT_PORT;
|
|
61
61
|
}
|
|
62
62
|
catch {
|
|
63
63
|
return WebOAuthServer.DEFAULT_PORT;
|
|
@@ -144,7 +144,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
144
144
|
async executeOauthRequest() {
|
|
145
145
|
return new Promise((resolve, reject) => {
|
|
146
146
|
this.logger.debug('Starting web auth flow');
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises, @typescript-eslint/no-explicit-any
|
|
148
148
|
this.webServer.server.on('request', async (request, response) => {
|
|
149
149
|
const url = (0, url_1.parse)(request.url);
|
|
150
150
|
this.logger.debug(`processing request for uri: ${url.pathname}`);
|
|
@@ -152,7 +152,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
152
152
|
if (url.pathname && url.pathname.startsWith('/OauthRedirect')) {
|
|
153
153
|
request.query = (0, querystring_1.parse)(url.query);
|
|
154
154
|
if (request.query.error) {
|
|
155
|
-
const err = new
|
|
155
|
+
const err = new sfError_1.SfError(request.query.error_description || request.query.error, request.query.error);
|
|
156
156
|
this.webServer.reportError(err, response);
|
|
157
157
|
return reject(err);
|
|
158
158
|
}
|
|
@@ -169,14 +169,14 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
169
169
|
this.webServer.sendError(404, 'Resource not found', response);
|
|
170
170
|
const errName = 'invalidRequestUri';
|
|
171
171
|
const errMessage = messages.getMessage(errName, [url.pathname]);
|
|
172
|
-
reject(new
|
|
172
|
+
reject(new sfError_1.SfError(errMessage, errName));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
else {
|
|
176
176
|
this.webServer.sendError(405, 'Unsupported http methods', response);
|
|
177
177
|
const errName = 'invalidRequestMethod';
|
|
178
178
|
const errMessage = messages.getMessage(errName, [request.method]);
|
|
179
|
-
reject(new
|
|
179
|
+
reject(new sfError_1.SfError(errMessage, errName));
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
});
|
|
@@ -190,7 +190,7 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
|
|
|
190
190
|
*/
|
|
191
191
|
parseAuthCodeFromRequest(response, request) {
|
|
192
192
|
if (!this.validateState(request)) {
|
|
193
|
-
const error = new
|
|
193
|
+
const error = new sfError_1.SfError('urlStateMismatch');
|
|
194
194
|
this.webServer.sendError(400, `${error.message}\n`, response);
|
|
195
195
|
this.closeRequest(request);
|
|
196
196
|
this.logger.warn('urlStateMismatchAttempt detected.');
|
|
@@ -343,13 +343,13 @@ class WebServer extends kit_1.AsyncCreatable {
|
|
|
343
343
|
const socket = new net_1.Socket();
|
|
344
344
|
socket.setTimeout(this.getSocketTimeout(), () => {
|
|
345
345
|
socket.destroy();
|
|
346
|
-
const error = new
|
|
346
|
+
const error = new sfError_1.SfError('timeout', 'SOCKET_TIMEOUT');
|
|
347
347
|
reject(error);
|
|
348
348
|
});
|
|
349
349
|
// An existing connection, means that the port is occupied
|
|
350
350
|
socket.connect(clientConfig, () => {
|
|
351
351
|
socket.destroy();
|
|
352
|
-
const error = new
|
|
352
|
+
const error = new sfError_1.SfError('Address in use', 'EADDRINUSE');
|
|
353
353
|
error.data = {
|
|
354
354
|
port: clientConfig.port,
|
|
355
355
|
address: clientConfig.host,
|
package/messages/org.md
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# UnsupportedSnapshotOrgCreateOptionsError
|
|
2
|
+
|
|
3
|
+
Org snapshots don’t support one or more options you specified: %s.
|
|
4
|
+
|
|
5
|
+
# SourceStatusResetFailureError
|
|
6
|
+
|
|
7
|
+
Successfully created org with ID: %s and name: %s. Unfortunately, source tracking isn’t working as expected. If you run force:source:status, the results may be incorrect. Try again by creating another scratch org.
|
|
8
|
+
|
|
9
|
+
# DurationDaysValidationMinError
|
|
10
|
+
|
|
11
|
+
Expected 'durationDays' greater than or equal to %s but received %s.
|
|
12
|
+
|
|
13
|
+
# DurationDaysValidationMaxError
|
|
14
|
+
|
|
15
|
+
Expected 'durationDays' less than or equal to %s but received %s.
|
|
16
|
+
|
|
17
|
+
# DurationDaysNotIntError
|
|
18
|
+
|
|
19
|
+
Expected 'durationDays' to be an integer number.
|
|
20
|
+
|
|
21
|
+
# RetryNotIntError
|
|
22
|
+
|
|
23
|
+
Expected 'retry' to be an integer number.
|
|
24
|
+
|
|
25
|
+
# WaitValidationMaxError
|
|
26
|
+
|
|
27
|
+
Expected 'wait' greater than or equal to %s but received %s.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# SignupFailedError
|
|
2
|
+
|
|
3
|
+
The request to create a scratch org failed with error code: %s.
|
|
4
|
+
|
|
5
|
+
# SignupFailedUnknownError
|
|
6
|
+
|
|
7
|
+
An unknown server error occurred. Please try again. If you still see this error, contact Salesforce support for assistance. Include the information from 'sfdx force:data:record:get -s ScratchOrgInfo -i %s -u %s'.
|
|
8
|
+
|
|
9
|
+
# SignupFailedActionError
|
|
10
|
+
|
|
11
|
+
See https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_signuprequest.htm for information on error code %s.
|
|
12
|
+
|
|
13
|
+
# SignupUnexpectedError
|
|
14
|
+
|
|
15
|
+
The request to create a scratch org returned an unexpected status
|
|
16
|
+
|
|
17
|
+
# INVALID_ID_FIELD
|
|
18
|
+
|
|
19
|
+
Provide a valid template ID, in the format 0TTxxxxxxxxxxxx.
|
|
20
|
+
|
|
21
|
+
# T-0002
|
|
22
|
+
|
|
23
|
+
We couldn’t find a template or snapshot with the ID or name specified in the scratch org definition. If you’re sure the ID is correct, contact Salesforce Support.
|
|
24
|
+
|
|
25
|
+
# T-0003
|
|
26
|
+
|
|
27
|
+
The template specified in the scratch org definition is unapproved. Contact Salesforce Support to request template approval.
|
|
28
|
+
|
|
29
|
+
# T-0004
|
|
30
|
+
|
|
31
|
+
The Trialforce Source Organization (TSO) for the template doesn’t exist or has expired.
|
|
32
|
+
|
|
33
|
+
# S-1006
|
|
34
|
+
|
|
35
|
+
Provide a valid email address in your scratch org definition or your %s file.
|
|
36
|
+
|
|
37
|
+
# S-2006
|
|
38
|
+
|
|
39
|
+
Provide a valid country code in your scratch org definition or your %s file.
|
|
40
|
+
|
|
41
|
+
# S-1017
|
|
42
|
+
|
|
43
|
+
Specify a namespace that’s used by a release org associated with your Dev Hub org.
|
|
44
|
+
|
|
45
|
+
# S-1018
|
|
46
|
+
|
|
47
|
+
Provide a valid My Domain value. This value can’t include double hyphens, end in a hyphen, include restricted words, or be more than 40 characters long.
|
|
48
|
+
|
|
49
|
+
# S-1019
|
|
50
|
+
|
|
51
|
+
The My Domain value you chose is already in use.
|
|
52
|
+
|
|
53
|
+
# S-1026
|
|
54
|
+
|
|
55
|
+
Provide a valid namespace value. This value must begin with a letter. It can’t include consecutive underscores, end in an underscore, be more than 15 characters long, or be a restricted or reserved namespace. Only alphanumeric characters and underscores are allowed.
|
|
56
|
+
|
|
57
|
+
# S-9999
|
|
58
|
+
|
|
59
|
+
A fatal signup error occurred. Please try again. If you still see this error, contact Salesforce Support for assistance.
|
|
60
|
+
|
|
61
|
+
# SH-0001
|
|
62
|
+
|
|
63
|
+
Can’t create scratch org. Contact the source org admin to add your Dev Hub org ID to Setup > Org Shape. Then try again.
|
|
64
|
+
|
|
65
|
+
# SH-0002
|
|
66
|
+
|
|
67
|
+
Can’t create scratch org. No org shape exists for the specified sourceOrg. Create an org shape and try again.
|
|
68
|
+
|
|
69
|
+
# SH-0003
|
|
70
|
+
|
|
71
|
+
Can’t create scratch org from org shape. The org shape version is outdated. Recreate the org shape and try again.
|
|
72
|
+
|
|
73
|
+
# C-1007
|
|
74
|
+
|
|
75
|
+
The username provided to the org:create command is already in use. Run 'force:org:list --clean' to remove stale org authentications or create the org with a different username.
|
|
76
|
+
|
|
77
|
+
# C-1015
|
|
78
|
+
|
|
79
|
+
We encountered a problem while registering your My Domain value with the DNS provider. Please try again.
|
|
80
|
+
|
|
81
|
+
# C-1016
|
|
82
|
+
|
|
83
|
+
We encountered a problem while attempting to configure and approve the Connected App for your org. Verify the Connected App configuration with your Salesforce admin.
|
|
84
|
+
|
|
85
|
+
# C-1017
|
|
86
|
+
|
|
87
|
+
Provide a valid namespace prefix. This value must begin with a letter. It can’t include consecutive underscores, end in an underscore, be more than 15 characters long, or be a restricted or reserved namespace. Only alphanumeric characters and underscores are allowed.
|
|
88
|
+
|
|
89
|
+
# C-1020
|
|
90
|
+
|
|
91
|
+
We couldn't find a template with the ID specified in the scratch org definition. If you’re sure the ID is correct, contact Salesforce Support.
|
|
92
|
+
|
|
93
|
+
# C-1027
|
|
94
|
+
|
|
95
|
+
The template specified in the Scratch Definition isn’t supported. Specify a generic edition (such as Developer or Enterprise), or specify a template ID.
|
|
96
|
+
|
|
97
|
+
# C-9999
|
|
98
|
+
|
|
99
|
+
A fatal signup error occurred. Please try again. If you still see this error, contact Salesforce Support for assistance
|