@salesforce/core 3.23.4 → 3.23.7
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/org/scratchOrgInfoApi.js +14 -4
- package/lib/org/scratchOrgSettingsGenerator.d.ts +35 -15
- package/lib/org/scratchOrgSettingsGenerator.js +153 -90
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +21 -1
- package/lib/stateAggregator/accessors/aliasAccessor.js +28 -1
- package/lib/util/directoryWriter.d.ts +11 -0
- package/lib/util/directoryWriter.js +52 -0
- package/lib/util/structuredWriter.d.ts +8 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +6 -5
- package/lib/util/zipWriter.js +8 -4
- package/package.json +3 -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.23.7](https://github.com/forcedotcom/sfdx-core/compare/v3.23.6...v3.23.7) (2022-07-08)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- add structure writer interface and refactor ([daef19c](https://github.com/forcedotcom/sfdx-core/commit/daef19cb3a4d145ebb22c4f721a1bd47ffddce40))
|
|
10
|
+
|
|
11
|
+
### [3.23.6](https://github.com/forcedotcom/sfdx-core/compare/v3.23.5...v3.23.6) (2022-07-06)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- workaround for jsforce update bug ([1776f50](https://github.com/forcedotcom/sfdx-core/commit/1776f505671a5a764c4e966736c2981df2b178a4))
|
|
16
|
+
|
|
17
|
+
### [3.23.5](https://github.com/forcedotcom/sfdx-core/compare/v3.23.4...v3.23.5) (2022-07-06)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- add resolveAlias ([#605](https://github.com/forcedotcom/sfdx-core/issues/605)) ([ffa9ed6](https://github.com/forcedotcom/sfdx-core/commit/ffa9ed63ea583baa327071db4030ea5346d1128f))
|
|
22
|
+
|
|
5
23
|
### [3.23.4](https://github.com/forcedotcom/sfdx-core/compare/v3.23.3...v3.23.4) (2022-07-05)
|
|
6
24
|
|
|
7
25
|
### Bug Fixes
|
|
@@ -392,12 +392,22 @@ const updateRevisionCounterToZero = async (scratchOrg) => {
|
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
try {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
395
|
+
// jsforce has a bug in its `update` code such that tooling#update doesn't work right
|
|
396
|
+
// https://github.com/jsforce/jsforce/blob/265eba5c734439dd7b77610c05b63bde7d4b1e83/src/connection.ts#L1082
|
|
397
|
+
// will result in `this._ensureVersion is not a function`
|
|
398
|
+
// so until that is resolved, we hit the API with singular records
|
|
399
|
+
// once that's fixed, you can use the following code for a single API call
|
|
400
|
+
// await conn.tooling
|
|
401
|
+
// .sobject('SourceMember')
|
|
402
|
+
// .update(queryResult.map((record) => ({ Id: record.Id, RevisionCounter: 0 })));
|
|
403
|
+
await Promise.all(queryResult.map((record) => conn.tooling.sobject('SourceMember').update({ Id: record.Id, RevisionCounter: 0 })));
|
|
398
404
|
}
|
|
399
405
|
catch (err) {
|
|
400
|
-
await lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('SourceStatusResetFailureError', [
|
|
406
|
+
await lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('SourceStatusResetFailureError', [
|
|
407
|
+
scratchOrg.getOrgId(),
|
|
408
|
+
scratchOrg.getUsername(),
|
|
409
|
+
err instanceof Error ? err.message : '',
|
|
410
|
+
]));
|
|
401
411
|
}
|
|
402
412
|
};
|
|
403
413
|
exports.updateRevisionCounterToZero = updateRevisionCounterToZero;
|
|
@@ -10,16 +10,27 @@ export declare enum RequestStatus {
|
|
|
10
10
|
Canceling = "Canceling",
|
|
11
11
|
Canceled = "Canceled"
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
values: [
|
|
17
|
-
{
|
|
18
|
-
fullName: string;
|
|
19
|
-
default?: boolean;
|
|
20
|
-
}
|
|
21
|
-
];
|
|
13
|
+
export interface SettingType {
|
|
14
|
+
members: string[];
|
|
15
|
+
name: 'CustomObject' | 'RecordType' | 'BusinessProcess' | 'Settings';
|
|
22
16
|
}
|
|
17
|
+
export interface PackageFile {
|
|
18
|
+
'@': {
|
|
19
|
+
xmlns: string;
|
|
20
|
+
};
|
|
21
|
+
types: SettingType[];
|
|
22
|
+
version: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const createObjectFileContent: ({ allRecordTypes, allBusinessProcesses, apiVersion, settingData, objectSettingsData, }: {
|
|
25
|
+
allRecordTypes?: string[] | undefined;
|
|
26
|
+
allBusinessProcesses?: string[] | undefined;
|
|
27
|
+
apiVersion: string;
|
|
28
|
+
settingData?: Record<string, unknown> | undefined;
|
|
29
|
+
objectSettingsData?: {
|
|
30
|
+
[objectName: string]: ObjectSetting;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}) => PackageFile;
|
|
33
|
+
export declare const createRecordTypeAndBusinessProcessFileContent: (objectName: string, json: Record<string, unknown>, allRecordTypes: string[], allBusinessProcesses: string[]) => JsonMap;
|
|
23
34
|
/**
|
|
24
35
|
* Helper class for dealing with the settings that are defined in a scratch definition file. This class knows how to extract the
|
|
25
36
|
* settings from the definition, how to expand them into a MD directory and how to generate a package.xml.
|
|
@@ -29,8 +40,15 @@ export default class SettingsGenerator {
|
|
|
29
40
|
private objectSettingsData?;
|
|
30
41
|
private logger;
|
|
31
42
|
private writer;
|
|
32
|
-
private
|
|
33
|
-
|
|
43
|
+
private allRecordTypes;
|
|
44
|
+
private allBusinessProcesses;
|
|
45
|
+
private readonly shapeDirName;
|
|
46
|
+
private readonly packageFilePath;
|
|
47
|
+
constructor(options?: {
|
|
48
|
+
mdApiTmpDir?: string;
|
|
49
|
+
shapeDirName?: string;
|
|
50
|
+
asDirectory?: boolean;
|
|
51
|
+
});
|
|
34
52
|
/** extract the settings from the scratch def file, if they are present. */
|
|
35
53
|
extract(scratchDef: ScratchOrgInfo): Promise<{
|
|
36
54
|
settings: Record<string, unknown> | undefined;
|
|
@@ -48,11 +66,13 @@ export default class SettingsGenerator {
|
|
|
48
66
|
* Deploys the settings to the org.
|
|
49
67
|
*/
|
|
50
68
|
deploySettingsViaFolder(scratchOrg: Org, apiVersion: string): Promise<void>;
|
|
69
|
+
createDeployPackageContents(apiVersion: string): Promise<void>;
|
|
51
70
|
getShapeDirName(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the destination where the writer placed the settings content.
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
getDestinationPath(): string | undefined;
|
|
52
76
|
private writeObjectSettingsIfNeeded;
|
|
53
77
|
private writeSettingsIfNeeded;
|
|
54
|
-
private createPackageXml;
|
|
55
|
-
private createObjectFileContent;
|
|
56
|
-
private createRecordTypeFileContent;
|
|
57
|
-
private createBusinessProcessFileContent;
|
|
58
78
|
}
|
|
@@ -6,16 +6,16 @@
|
|
|
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.RequestStatus = void 0;
|
|
9
|
+
exports.createRecordTypeAndBusinessProcessFileContent = exports.createObjectFileContent = exports.RequestStatus = void 0;
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const kit_1 = require("@salesforce/kit");
|
|
12
12
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
13
|
const js2xmlparser = require("js2xmlparser");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
15
|
const sfError_1 = require("../sfError");
|
|
16
|
-
const jsonXmlTools_1 = require("../util/jsonXmlTools");
|
|
17
|
-
const zipWriter_1 = require("../util/zipWriter");
|
|
18
16
|
const pollingClient_1 = require("../status/pollingClient");
|
|
17
|
+
const zipWriter_1 = require("../util/zipWriter");
|
|
18
|
+
const directoryWriter_1 = require("../util/directoryWriter");
|
|
19
19
|
var RequestStatus;
|
|
20
20
|
(function (RequestStatus) {
|
|
21
21
|
RequestStatus["Pending"] = "Pending";
|
|
@@ -27,17 +27,132 @@ var RequestStatus;
|
|
|
27
27
|
RequestStatus["Canceled"] = "Canceled";
|
|
28
28
|
})(RequestStatus = exports.RequestStatus || (exports.RequestStatus = {}));
|
|
29
29
|
const breakPolling = ['Succeeded', 'SucceededPartial', 'Failed', 'Canceled'];
|
|
30
|
+
const createObjectFileContent = ({ allRecordTypes = [], allBusinessProcesses = [], apiVersion, settingData, objectSettingsData, }) => {
|
|
31
|
+
const output = {
|
|
32
|
+
'@': {
|
|
33
|
+
xmlns: 'http://soap.sforce.com/2006/04/metadata',
|
|
34
|
+
},
|
|
35
|
+
types: [],
|
|
36
|
+
};
|
|
37
|
+
if (settingData) {
|
|
38
|
+
const strings = Object.keys(settingData).map((item) => (0, kit_1.upperFirst)(item).replace('Settings', ''));
|
|
39
|
+
output.types.push({ members: strings, name: 'Settings' });
|
|
40
|
+
}
|
|
41
|
+
if (objectSettingsData) {
|
|
42
|
+
const strings = Object.keys(objectSettingsData).map((item) => (0, kit_1.upperFirst)(item));
|
|
43
|
+
output.types.push({ members: strings, name: 'CustomObject' });
|
|
44
|
+
if (allRecordTypes.length > 0) {
|
|
45
|
+
output.types.push({ members: allRecordTypes, name: 'RecordType' });
|
|
46
|
+
}
|
|
47
|
+
if (allBusinessProcesses.length > 0) {
|
|
48
|
+
output.types.push({ members: allBusinessProcesses, name: 'BusinessProcess' });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { ...output, ...{ version: apiVersion } };
|
|
52
|
+
};
|
|
53
|
+
exports.createObjectFileContent = createObjectFileContent;
|
|
54
|
+
const calculateBusinessProcess = (objectName, defaultRecordType) => {
|
|
55
|
+
let businessProcessName = null;
|
|
56
|
+
let businessProcessPicklistVal = null;
|
|
57
|
+
// These four objects require any record type to specify a "business process"--
|
|
58
|
+
// a restricted set of items from a standard picklist on the object.
|
|
59
|
+
if (['Case', 'Lead', 'Opportunity', 'Solution'].includes(objectName)) {
|
|
60
|
+
businessProcessName = (0, kit_1.upperFirst)(defaultRecordType) + 'Process';
|
|
61
|
+
switch (objectName) {
|
|
62
|
+
case 'Case':
|
|
63
|
+
businessProcessPicklistVal = 'New';
|
|
64
|
+
break;
|
|
65
|
+
case 'Lead':
|
|
66
|
+
businessProcessPicklistVal = 'New - Not Contacted';
|
|
67
|
+
break;
|
|
68
|
+
case 'Opportunity':
|
|
69
|
+
businessProcessPicklistVal = 'Prospecting';
|
|
70
|
+
break;
|
|
71
|
+
case 'Solution':
|
|
72
|
+
businessProcessPicklistVal = 'Draft';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [businessProcessName, businessProcessPicklistVal];
|
|
76
|
+
};
|
|
77
|
+
const createRecordTypeAndBusinessProcessFileContent = (objectName, json, allRecordTypes, allBusinessProcesses) => {
|
|
78
|
+
let output = {
|
|
79
|
+
'@': {
|
|
80
|
+
xmlns: 'http://soap.sforce.com/2006/04/metadata',
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const name = (0, kit_1.upperFirst)(objectName);
|
|
84
|
+
const sharingModel = json.sharingModel;
|
|
85
|
+
if (sharingModel) {
|
|
86
|
+
output = {
|
|
87
|
+
...output,
|
|
88
|
+
sharingModel: (0, kit_1.upperFirst)(sharingModel),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const defaultRecordType = json.defaultRecordType;
|
|
92
|
+
if (typeof defaultRecordType === 'string') {
|
|
93
|
+
// We need to keep track of these globally for when we generate the package XML.
|
|
94
|
+
allRecordTypes.push(`${name}.${(0, kit_1.upperFirst)(defaultRecordType)}`);
|
|
95
|
+
const [businessProcessName, businessProcessPicklistVal] = calculateBusinessProcess(name, defaultRecordType);
|
|
96
|
+
// Create the record type
|
|
97
|
+
const recordTypes = {
|
|
98
|
+
fullName: (0, kit_1.upperFirst)(defaultRecordType),
|
|
99
|
+
label: (0, kit_1.upperFirst)(defaultRecordType),
|
|
100
|
+
active: true,
|
|
101
|
+
};
|
|
102
|
+
output = {
|
|
103
|
+
...output,
|
|
104
|
+
recordTypes: {
|
|
105
|
+
...recordTypes,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
if (businessProcessName) {
|
|
109
|
+
// We need to keep track of these globally for the package.xml
|
|
110
|
+
const values = {
|
|
111
|
+
fullName: businessProcessPicklistVal,
|
|
112
|
+
};
|
|
113
|
+
if (name !== 'Opportunity') {
|
|
114
|
+
values.default = true;
|
|
115
|
+
}
|
|
116
|
+
allBusinessProcesses.push(`${name}.${businessProcessName}`);
|
|
117
|
+
output = {
|
|
118
|
+
...output,
|
|
119
|
+
recordTypes: {
|
|
120
|
+
...recordTypes,
|
|
121
|
+
businessProcess: businessProcessName,
|
|
122
|
+
},
|
|
123
|
+
businessProcesses: {
|
|
124
|
+
fullName: businessProcessName,
|
|
125
|
+
isActive: true,
|
|
126
|
+
values,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return output;
|
|
132
|
+
};
|
|
133
|
+
exports.createRecordTypeAndBusinessProcessFileContent = createRecordTypeAndBusinessProcessFileContent;
|
|
30
134
|
/**
|
|
31
135
|
* Helper class for dealing with the settings that are defined in a scratch definition file. This class knows how to extract the
|
|
32
136
|
* settings from the definition, how to expand them into a MD directory and how to generate a package.xml.
|
|
33
137
|
*/
|
|
34
138
|
class SettingsGenerator {
|
|
35
|
-
constructor() {
|
|
36
|
-
this.
|
|
139
|
+
constructor(options) {
|
|
140
|
+
this.allRecordTypes = [];
|
|
141
|
+
this.allBusinessProcesses = [];
|
|
37
142
|
this.logger = logger_1.Logger.childFromRoot('SettingsGenerator');
|
|
38
143
|
// If SFDX_MDAPI_TEMP_DIR is set, copy settings to that dir for people to inspect.
|
|
39
|
-
const
|
|
40
|
-
this.
|
|
144
|
+
const mdApiTmpDir = (options === null || options === void 0 ? void 0 : options.mdApiTmpDir) || kit_1.env.getString('SFDX_MDAPI_TEMP_DIR');
|
|
145
|
+
this.shapeDirName = (options === null || options === void 0 ? void 0 : options.shapeDirName) || `shape_${Date.now()}`;
|
|
146
|
+
this.packageFilePath = path.join(this.shapeDirName, 'package.xml');
|
|
147
|
+
let storePath;
|
|
148
|
+
if (!(options === null || options === void 0 ? void 0 : options.asDirectory)) {
|
|
149
|
+
storePath = mdApiTmpDir ? path.join(mdApiTmpDir, `${this.shapeDirName}.zip`) : undefined;
|
|
150
|
+
this.writer = new zipWriter_1.ZipWriter(storePath);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
storePath = mdApiTmpDir ? path.join(mdApiTmpDir, this.shapeDirName) : undefined;
|
|
154
|
+
this.writer = new directoryWriter_1.DirectoryWriter(storePath);
|
|
155
|
+
}
|
|
41
156
|
}
|
|
42
157
|
/** extract the settings from the scratch def file, if they are present. */
|
|
43
158
|
async extract(scratchDef) {
|
|
@@ -57,7 +172,10 @@ class SettingsGenerator {
|
|
|
57
172
|
async createDeploy() {
|
|
58
173
|
const settingsDir = path.join(this.shapeDirName, 'settings');
|
|
59
174
|
const objectsDir = path.join(this.shapeDirName, 'objects');
|
|
60
|
-
await Promise.all([
|
|
175
|
+
await Promise.all([
|
|
176
|
+
this.writeSettingsIfNeeded(settingsDir),
|
|
177
|
+
this.writeObjectSettingsIfNeeded(objectsDir, this.allRecordTypes, this.allBusinessProcesses),
|
|
178
|
+
]);
|
|
61
179
|
}
|
|
62
180
|
/**
|
|
63
181
|
* Deploys the settings to the org.
|
|
@@ -65,8 +183,7 @@ class SettingsGenerator {
|
|
|
65
183
|
async deploySettingsViaFolder(scratchOrg, apiVersion) {
|
|
66
184
|
const username = scratchOrg.getUsername();
|
|
67
185
|
const logger = await logger_1.Logger.child('deploySettingsViaFolder');
|
|
68
|
-
this.
|
|
69
|
-
await this.writer.finalize();
|
|
186
|
+
await this.createDeployPackageContents(apiVersion);
|
|
70
187
|
const connection = scratchOrg.getConnection();
|
|
71
188
|
logger.debug(`deploying to apiVersion: ${apiVersion}`);
|
|
72
189
|
connection.setApiVersion(apiVersion);
|
|
@@ -113,40 +230,34 @@ class SettingsGenerator {
|
|
|
113
230
|
throw error;
|
|
114
231
|
}
|
|
115
232
|
}
|
|
233
|
+
async createDeployPackageContents(apiVersion) {
|
|
234
|
+
const packageObjectProps = (0, exports.createObjectFileContent)({
|
|
235
|
+
allRecordTypes: this.allRecordTypes,
|
|
236
|
+
allBusinessProcesses: this.allBusinessProcesses,
|
|
237
|
+
apiVersion,
|
|
238
|
+
settingData: this.settingData,
|
|
239
|
+
objectSettingsData: this.objectSettingsData,
|
|
240
|
+
});
|
|
241
|
+
const xml = js2xmlparser.parse('Package', packageObjectProps);
|
|
242
|
+
await this.writer.addToStore(xml, this.packageFilePath);
|
|
243
|
+
await this.writer.finalize();
|
|
244
|
+
}
|
|
116
245
|
getShapeDirName() {
|
|
117
246
|
return this.shapeDirName;
|
|
118
247
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.writer.addToZip(customObjectXml, customObjectDir);
|
|
133
|
-
if (value.defaultRecordType) {
|
|
134
|
-
const recordTypesDir = path.join(objectDir, 'recordTypes', `${(0, kit_1.upperFirst)(value.defaultRecordType)}.recordType`);
|
|
135
|
-
const recordTypesFileContent = this.createRecordTypeFileContent(objectName, value);
|
|
136
|
-
const recordTypesXml = (0, jsonXmlTools_1.JsonAsXml)({
|
|
137
|
-
json: recordTypesFileContent,
|
|
138
|
-
type: 'RecordType',
|
|
139
|
-
});
|
|
140
|
-
this.writer.addToZip(recordTypesXml, recordTypesDir);
|
|
141
|
-
// for things that required a businessProcess
|
|
142
|
-
if (recordTypesFileContent.businessProcess) {
|
|
143
|
-
const businessProcessesDir = path.join(objectDir, 'businessProcesses', `${recordTypesFileContent.businessProcess}.businessProcess`);
|
|
144
|
-
const businessProcessesXml = (0, jsonXmlTools_1.JsonAsXml)({
|
|
145
|
-
json: this.createBusinessProcessFileContent(objectName, recordTypesFileContent.businessProcess),
|
|
146
|
-
type: 'BusinessProcess',
|
|
147
|
-
});
|
|
148
|
-
this.writer.addToZip(businessProcessesXml, businessProcessesDir);
|
|
149
|
-
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns the destination where the writer placed the settings content.
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
getDestinationPath() {
|
|
253
|
+
return this.writer.getDestinationPath();
|
|
254
|
+
}
|
|
255
|
+
async writeObjectSettingsIfNeeded(objectsDir, allRecordTypes, allbusinessProcesses) {
|
|
256
|
+
if (this.objectSettingsData) {
|
|
257
|
+
for (const [item, value] of Object.entries(this.objectSettingsData)) {
|
|
258
|
+
const fileContent = (0, exports.createRecordTypeAndBusinessProcessFileContent)(item, value, allRecordTypes, allbusinessProcesses);
|
|
259
|
+
const xml = js2xmlparser.parse('CustomObject', fileContent);
|
|
260
|
+
await this.writer.addToStore(xml, path.join(objectsDir, (0, kit_1.upperFirst)(item) + '.object'));
|
|
150
261
|
}
|
|
151
262
|
}
|
|
152
263
|
}
|
|
@@ -157,58 +268,10 @@ class SettingsGenerator {
|
|
|
157
268
|
const typeName = (0, kit_1.upperFirst)(item);
|
|
158
269
|
const fname = typeName.replace('Settings', '');
|
|
159
270
|
const fileContent = js2xmlparser.parse(typeName, value);
|
|
160
|
-
this.writer.
|
|
271
|
+
await this.writer.addToStore(fileContent, path.join(settingsDir, fname + '.settings'));
|
|
161
272
|
}
|
|
162
273
|
}
|
|
163
274
|
}
|
|
164
|
-
createPackageXml(apiVersion) {
|
|
165
|
-
const pkg = `<?xml version="1.0" encoding="UTF-8"?>
|
|
166
|
-
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
167
|
-
<types>
|
|
168
|
-
<members>*</members>
|
|
169
|
-
<name>Settings</name>
|
|
170
|
-
</types>
|
|
171
|
-
<types>
|
|
172
|
-
<members>*</members>
|
|
173
|
-
<name>CustomObject</name>
|
|
174
|
-
</types>
|
|
175
|
-
<version>${apiVersion}</version>
|
|
176
|
-
</Package>`;
|
|
177
|
-
this.writer.addToZip(pkg, path.join(this.shapeDirName, 'package.xml'));
|
|
178
|
-
}
|
|
179
|
-
createObjectFileContent(json) {
|
|
180
|
-
const output = {};
|
|
181
|
-
if (json.sharingModel) {
|
|
182
|
-
output.sharingModel = (0, kit_1.upperFirst)(json.sharingModel);
|
|
183
|
-
}
|
|
184
|
-
return output;
|
|
185
|
-
}
|
|
186
|
-
createRecordTypeFileContent(objectName, setting) {
|
|
187
|
-
const defaultRecordType = (0, kit_1.upperFirst)(setting.defaultRecordType);
|
|
188
|
-
const output = {
|
|
189
|
-
fullName: defaultRecordType,
|
|
190
|
-
label: defaultRecordType,
|
|
191
|
-
active: true,
|
|
192
|
-
};
|
|
193
|
-
// all the edge cases
|
|
194
|
-
if (['Case', 'Lead', 'Opportunity', 'Solution'].includes((0, kit_1.upperFirst)(objectName))) {
|
|
195
|
-
return { ...output, businessProcess: `${defaultRecordType}Process` };
|
|
196
|
-
}
|
|
197
|
-
return output;
|
|
198
|
-
}
|
|
199
|
-
createBusinessProcessFileContent(objectName, businessProcessName) {
|
|
200
|
-
const objectToBusinessProcessPicklist = {
|
|
201
|
-
Opportunity: { fullName: 'Prospecting' },
|
|
202
|
-
Case: { fullName: 'New', default: true },
|
|
203
|
-
Lead: { fullName: 'New - Not Contacted', default: true },
|
|
204
|
-
Solution: { fullName: 'Draft', default: true },
|
|
205
|
-
};
|
|
206
|
-
return {
|
|
207
|
-
fullName: businessProcessName,
|
|
208
|
-
isActive: true,
|
|
209
|
-
values: [objectToBusinessProcessPicklist[(0, kit_1.upperFirst)(objectName)]],
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
275
|
}
|
|
213
276
|
exports.default = SettingsGenerator;
|
|
214
277
|
//# sourceMappingURL=scratchOrgSettingsGenerator.js.map
|
|
@@ -138,6 +138,16 @@ export declare class AliasAccessor extends AsyncOptionalCreatable {
|
|
|
138
138
|
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
139
139
|
*/
|
|
140
140
|
resolveUsername(usernameOrAlias: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* If the provided string is an alias, return it.
|
|
143
|
+
* If the provided string is not an alias, return the username of the provided alias
|
|
144
|
+
*
|
|
145
|
+
* This method is helpful when you don't know if the string you have is a username
|
|
146
|
+
* or an alias.
|
|
147
|
+
*
|
|
148
|
+
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
149
|
+
*/
|
|
150
|
+
resolveAlias(usernameOrAlias: string): Nullable<string>;
|
|
141
151
|
/**
|
|
142
152
|
* Set an alias for the given aliasable entity
|
|
143
153
|
*
|
|
@@ -145,14 +155,24 @@ export declare class AliasAccessor extends AsyncOptionalCreatable {
|
|
|
145
155
|
* @param entity the aliasable entity that's being aliased
|
|
146
156
|
*/
|
|
147
157
|
set(alias: string, entity: Aliasable): void;
|
|
158
|
+
/**
|
|
159
|
+
* Unset the given alias.
|
|
160
|
+
*
|
|
161
|
+
*/
|
|
148
162
|
unset(alias: string): void;
|
|
149
163
|
/**
|
|
150
|
-
*
|
|
164
|
+
* Unsets all the aliases for the given entity.
|
|
151
165
|
*
|
|
152
166
|
* @param entity the aliasable entity for which you want to unset all aliases
|
|
153
167
|
*/
|
|
154
168
|
unsetAll(entity: Aliasable): void;
|
|
155
169
|
write(): Promise<ConfigContents>;
|
|
170
|
+
/**
|
|
171
|
+
* Returns true if the provided alias exists
|
|
172
|
+
*
|
|
173
|
+
* @param alias the alias you want to check
|
|
174
|
+
*/
|
|
175
|
+
has(alias: string): boolean;
|
|
156
176
|
protected init(): Promise<void>;
|
|
157
177
|
/**
|
|
158
178
|
* Returns the username of given aliasable entity
|
|
@@ -202,6 +202,21 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
202
202
|
var _a;
|
|
203
203
|
return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* If the provided string is an alias, return it.
|
|
207
|
+
* If the provided string is not an alias, return the username of the provided alias
|
|
208
|
+
*
|
|
209
|
+
* This method is helpful when you don't know if the string you have is a username
|
|
210
|
+
* or an alias.
|
|
211
|
+
*
|
|
212
|
+
* @param usernameOrAlias a string that might be a username or might be an alias
|
|
213
|
+
*/
|
|
214
|
+
resolveAlias(usernameOrAlias) {
|
|
215
|
+
var _a;
|
|
216
|
+
if (this.has(usernameOrAlias))
|
|
217
|
+
return usernameOrAlias;
|
|
218
|
+
return (_a = Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)) === null || _a === void 0 ? void 0 : _a[0];
|
|
219
|
+
}
|
|
205
220
|
/**
|
|
206
221
|
* Set an alias for the given aliasable entity
|
|
207
222
|
*
|
|
@@ -211,11 +226,15 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
211
226
|
set(alias, entity) {
|
|
212
227
|
this.config.set(alias, this.getNameOf(entity));
|
|
213
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Unset the given alias.
|
|
231
|
+
*
|
|
232
|
+
*/
|
|
214
233
|
unset(alias) {
|
|
215
234
|
this.config.unset(alias);
|
|
216
235
|
}
|
|
217
236
|
/**
|
|
218
|
-
*
|
|
237
|
+
* Unsets all the aliases for the given entity.
|
|
219
238
|
*
|
|
220
239
|
* @param entity the aliasable entity for which you want to unset all aliases
|
|
221
240
|
*/
|
|
@@ -226,6 +245,14 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
|
|
|
226
245
|
async write() {
|
|
227
246
|
return this.config.write();
|
|
228
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns true if the provided alias exists
|
|
250
|
+
*
|
|
251
|
+
* @param alias the alias you want to check
|
|
252
|
+
*/
|
|
253
|
+
has(alias) {
|
|
254
|
+
return this.config.has(alias);
|
|
255
|
+
}
|
|
229
256
|
async init() {
|
|
230
257
|
this.config = await aliasesConfig_1.AliasesConfig.create(aliasesConfig_1.AliasesConfig.getDefaultOptions());
|
|
231
258
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { StructuredWriter } from './structuredWriter';
|
|
4
|
+
export declare class DirectoryWriter implements StructuredWriter {
|
|
5
|
+
private readonly rootDestination?;
|
|
6
|
+
constructor(rootDestination?: string | undefined);
|
|
7
|
+
addToStore(contents: string | Readable | Buffer, targetPath: string): Promise<void>;
|
|
8
|
+
finalize(): Promise<void>;
|
|
9
|
+
getDestinationPath(): string | undefined;
|
|
10
|
+
get buffer(): Buffer;
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.DirectoryWriter = void 0;
|
|
10
|
+
const stream_1 = require("stream");
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const os = require("os");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const util_1 = require("util");
|
|
15
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
16
|
+
class DirectoryWriter {
|
|
17
|
+
constructor(rootDestination) {
|
|
18
|
+
this.rootDestination = rootDestination;
|
|
19
|
+
if (!this.rootDestination) {
|
|
20
|
+
this.rootDestination = fs.mkdtempSync(`${os.tmpdir()}${path.sep}`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
fs.mkdirSync(this.rootDestination, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async addToStore(contents, targetPath) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
28
|
+
const destPath = path.join(this.rootDestination, targetPath);
|
|
29
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
30
|
+
if (contents instanceof stream_1.Readable) {
|
|
31
|
+
const writeStream = fs.createWriteStream(destPath);
|
|
32
|
+
await pipeline(contents, writeStream);
|
|
33
|
+
}
|
|
34
|
+
else if (typeof contents === 'string') {
|
|
35
|
+
fs.writeFileSync(destPath, contents);
|
|
36
|
+
}
|
|
37
|
+
else if (contents instanceof Buffer) {
|
|
38
|
+
fs.writeFileSync(destPath, contents);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
finalize() {
|
|
42
|
+
return Promise.resolve(undefined);
|
|
43
|
+
}
|
|
44
|
+
getDestinationPath() {
|
|
45
|
+
return this.rootDestination;
|
|
46
|
+
}
|
|
47
|
+
get buffer() {
|
|
48
|
+
throw new Error('Not implemented');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.DirectoryWriter = DirectoryWriter;
|
|
52
|
+
//# sourceMappingURL=directoryWriter.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
export interface StructuredWriter {
|
|
4
|
+
addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
|
|
5
|
+
finalize(): Promise<void>;
|
|
6
|
+
getDestinationPath(): string | undefined;
|
|
7
|
+
get buffer(): Buffer;
|
|
8
|
+
}
|
package/lib/util/zipWriter.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare class ZipWriter extends Writable {
|
|
5
|
-
private rootDestination?;
|
|
2
|
+
import { Readable, Writable } from 'stream';
|
|
3
|
+
import { StructuredWriter } from './structuredWriter';
|
|
4
|
+
export declare class ZipWriter extends Writable implements StructuredWriter {
|
|
5
|
+
private readonly rootDestination?;
|
|
6
6
|
private zip;
|
|
7
7
|
private buffers;
|
|
8
8
|
constructor(rootDestination?: string | undefined);
|
|
9
|
-
|
|
9
|
+
addToStore(contents: string | Readable | Buffer, path: string): Promise<void>;
|
|
10
10
|
finalize(): Promise<void>;
|
|
11
|
+
getDestinationPath(): string | undefined;
|
|
11
12
|
private getOutputStream;
|
|
12
13
|
private getInputBuffer;
|
|
13
14
|
get buffer(): Buffer;
|
package/lib/util/zipWriter.js
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
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.ZipWriter =
|
|
9
|
+
exports.ZipWriter = void 0;
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
const stream_1 = require("stream");
|
|
12
12
|
const util_1 = require("util");
|
|
13
13
|
const archiver_1 = require("archiver");
|
|
14
|
-
|
|
14
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
15
15
|
class ZipWriter extends stream_1.Writable {
|
|
16
16
|
constructor(rootDestination) {
|
|
17
17
|
super({ objectMode: true });
|
|
@@ -21,15 +21,19 @@ class ZipWriter extends stream_1.Writable {
|
|
|
21
21
|
// higher values = diminishing returns on compression and made conversion slower
|
|
22
22
|
this.zip = (0, archiver_1.create)('zip', { zlib: { level: 3 } });
|
|
23
23
|
this.buffers = [];
|
|
24
|
-
void
|
|
24
|
+
void pipeline(this.zip, this.getOutputStream());
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
async addToStore(contents, path) {
|
|
27
27
|
this.zip.append(contents, { name: path });
|
|
28
|
+
return Promise.resolve();
|
|
28
29
|
}
|
|
29
30
|
async finalize() {
|
|
30
31
|
await this.zip.finalize();
|
|
31
32
|
await this.getInputBuffer();
|
|
32
33
|
}
|
|
34
|
+
getDestinationPath() {
|
|
35
|
+
return this.rootDestination;
|
|
36
|
+
}
|
|
33
37
|
getOutputStream() {
|
|
34
38
|
if (this.rootDestination) {
|
|
35
39
|
return (0, fs_1.createWriteStream)(this.rootDestination);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.23.
|
|
3
|
+
"version": "3.23.7",
|
|
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",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@salesforce/prettier-config": "^0.0.2",
|
|
61
61
|
"@salesforce/ts-sinon": "^1.3.21",
|
|
62
62
|
"@types/archiver": "^5.3.1",
|
|
63
|
+
"@types/chai-string": "^1.4.2",
|
|
63
64
|
"@types/debug": "0.0.31",
|
|
64
65
|
"@types/jsen": "0.0.21",
|
|
65
66
|
"@types/jsonwebtoken": "8.5.7",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
69
70
|
"@typescript-eslint/parser": "4.33.0",
|
|
70
71
|
"chai": "^4.3.4",
|
|
72
|
+
"chai-string": "^1.5.0",
|
|
71
73
|
"commitizen": "^3.1.2",
|
|
72
74
|
"eslint": "^7.27.0",
|
|
73
75
|
"eslint-config-prettier": "^6.15.0",
|