sfdx-easy-sources 0.9.0 → 0.9.1-develop.1
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/lib/commands/easysources/allmeta/minify.d.ts +1 -0
- package/lib/commands/easysources/allmeta/minify.js +17 -2
- package/lib/commands/easysources/allmeta/minify.js.map +1 -1
- package/lib/commands/easysources/objecttranslations/merge.d.ts +1 -3
- package/lib/commands/easysources/objecttranslations/merge.js +46 -17
- package/lib/commands/easysources/objecttranslations/merge.js.map +1 -1
- package/lib/commands/easysources/objecttranslations/minify.d.ts +1 -3
- package/lib/commands/easysources/objecttranslations/minify.js +50 -29
- package/lib/commands/easysources/objecttranslations/minify.js.map +1 -1
- package/lib/commands/easysources/objecttranslations/split.js +76 -52
- package/lib/commands/easysources/objecttranslations/split.js.map +1 -1
- package/lib/commands/easysources/objecttranslations/upsert.d.ts +1 -3
- package/lib/commands/easysources/objecttranslations/upsert.js +107 -75
- package/lib/commands/easysources/objecttranslations/upsert.js.map +1 -1
- package/lib/commands/easysources/permissionsets/minify.js +50 -29
- package/lib/commands/easysources/permissionsets/minify.js.map +1 -1
- package/lib/commands/easysources/profiles/minify.js +50 -29
- package/lib/commands/easysources/profiles/minify.js.map +1 -1
- package/lib/commands/easysources/profiles/split.js +1 -2
- package/lib/commands/easysources/profiles/split.js.map +1 -1
- package/lib/commands/easysources/recordtypes/merge.js +24 -9
- package/lib/commands/easysources/recordtypes/merge.js.map +1 -1
- package/lib/commands/easysources/recordtypes/split.js +56 -40
- package/lib/commands/easysources/recordtypes/split.js.map +1 -1
- package/lib/commands/easysources/recordtypes/updatekey.js +36 -20
- package/lib/commands/easysources/recordtypes/updatekey.js.map +1 -1
- package/lib/commands/easysources/recordtypes/upsert.js +88 -65
- package/lib/commands/easysources/recordtypes/upsert.js.map +1 -1
- package/lib/commands/easysources/translations/minify.js +51 -29
- package/lib/commands/easysources/translations/minify.js.map +1 -1
- package/lib/utils/commands/keyupdater.d.ts +5 -1
- package/lib/utils/commands/keyupdater.js +35 -20
- package/lib/utils/commands/keyupdater.js.map +1 -1
- package/lib/utils/commands/merger.d.ts +4 -0
- package/lib/utils/commands/merger.js +11 -5
- package/lib/utils/commands/merger.js.map +1 -1
- package/lib/utils/commands/splitter.d.ts +5 -1
- package/lib/utils/commands/splitter.js +60 -46
- package/lib/utils/commands/splitter.js.map +1 -1
- package/lib/utils/commands/upserter.d.ts +3 -3
- package/lib/utils/commands/upserter.js +126 -103
- package/lib/utils/commands/upserter.js.map +1 -1
- package/lib/utils/commands/utils.d.ts +4 -0
- package/lib/utils/commands/utils.js +9 -1
- package/lib/utils/commands/utils.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ const constants_objecttranslations_1 = require("../../../utils/constants/constan
|
|
|
20
20
|
const utils_objtransl_1 = require("../../../utils/utils_objtransl");
|
|
21
21
|
const utils_2 = require("../../../utils/commands/utils");
|
|
22
22
|
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
23
|
+
const split_1 = require("./split");
|
|
23
24
|
const fs = require('fs-extra');
|
|
24
25
|
const settings = (0, localSettings_1.loadSettings)();
|
|
25
26
|
// Initialize Messages with the current plugin directory
|
|
@@ -66,7 +67,14 @@ async function objectTranslationUpsert(options = {}) {
|
|
|
66
67
|
const baseInputDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH), constants_objecttranslations_1.OBJTRANSL_SUBPATH);
|
|
67
68
|
const baseOutputDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_objecttranslations_1.OBJTRANSL_SUBPATH);
|
|
68
69
|
const inputObject = (options.input);
|
|
69
|
-
|
|
70
|
+
// Initialize result object
|
|
71
|
+
const result = { result: 'OK', items: {} };
|
|
72
|
+
try {
|
|
73
|
+
(0, filesUtils_1.checkDirOrErrorSync)(baseInputDir);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return (0, utils_2.jsonAndPrintError)(error.message);
|
|
77
|
+
}
|
|
70
78
|
var objectTList = [];
|
|
71
79
|
if (inputObject) {
|
|
72
80
|
objectTList = inputObject.split(',');
|
|
@@ -82,92 +90,116 @@ async function objectTranslationUpsert(options = {}) {
|
|
|
82
90
|
const inputFile = (0, path_1.join)(baseInputDir, objTrName, fullFilename);
|
|
83
91
|
if (!fs.existsSync(inputFile)) {
|
|
84
92
|
console.log('Skipping ' + objTrName + '; File ' + inputFile + ' does not exist!');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const outputDir = (0, path_1.join)(baseOutputDir, objTrName, 'csv');
|
|
89
|
-
const inputFilePart = (0, path_1.join)(baseOutputDir, objTrName, 'csv', objTrName + constants_1.XML_PART_EXTENSION);
|
|
90
|
-
// If outputDir or inputFilePart doesn't exist, run split command instead
|
|
91
|
-
if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
|
|
92
|
-
console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for: ' + objTrName);
|
|
93
|
-
// Create flags for split command with just the current object
|
|
94
|
-
const splitFlags = {
|
|
95
|
-
...options,
|
|
96
|
-
input: objTrName
|
|
93
|
+
result.items[objTrName] = {
|
|
94
|
+
result: 'KO',
|
|
95
|
+
error: `File ${inputFile} does not exist`
|
|
97
96
|
};
|
|
98
|
-
await (0, utils_2.executeCommand)(splitFlags, 'split', 'objecttranslations');
|
|
99
97
|
continue;
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
if ((
|
|
99
|
+
console.log('Upserting: ' + objTrName);
|
|
100
|
+
try {
|
|
101
|
+
const outputDir = (0, path_1.join)(baseOutputDir, objTrName, 'csv');
|
|
102
|
+
const inputFilePart = (0, path_1.join)(baseOutputDir, objTrName, 'csv', objTrName + constants_1.XML_PART_EXTENSION);
|
|
103
|
+
// If outputDir or inputFilePart doesn't exist, run split command instead
|
|
104
|
+
if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
|
|
105
|
+
console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for: ' + objTrName);
|
|
106
|
+
// Create flags for split command with just the current object
|
|
107
|
+
const splitFlags = {
|
|
108
|
+
...options,
|
|
109
|
+
input: objTrName
|
|
110
|
+
};
|
|
111
|
+
// Call split function directly and handle its result
|
|
112
|
+
const splitResult = await (0, split_1.objectTranslationSplit)(splitFlags);
|
|
113
|
+
if (splitResult.items && splitResult.items[objTrName]) {
|
|
114
|
+
result.items[objTrName] = splitResult.items[objTrName];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
result.items[objTrName] = { result: 'KO', error: 'Split operation failed' };
|
|
118
|
+
}
|
|
107
119
|
continue;
|
|
108
|
-
// fixes scenarios when the tag is one, since it would be read as object and not array
|
|
109
|
-
if (!Array.isArray(myjson))
|
|
110
|
-
myjson = [myjson];
|
|
111
|
-
if (tag_section === constants_objecttranslations_1.OBJTRANSL_LAYOUT_ROOT) {
|
|
112
|
-
myjson = (0, utils_objtransl_1.transformLayoutXMLtoCSV)(myjson);
|
|
113
120
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
|
|
122
|
+
const objTranslProperties = xmlFileContent[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] ?? {};
|
|
123
|
+
for (const tag_section in constants_objecttranslations_1.OBJTRANSL_ITEMS) {
|
|
124
|
+
var myjson = objTranslProperties[tag_section];
|
|
125
|
+
// skip when tag is not found in the xml
|
|
126
|
+
if ((myjson == undefined || myjson == '') && tag_section !== constants_objecttranslations_1.OBJTRANSL_CFIELDTRANSL_ROOT)
|
|
127
|
+
continue;
|
|
128
|
+
// fixes scenarios when the tag is one, since it would be read as object and not array
|
|
129
|
+
if (!Array.isArray(myjson))
|
|
130
|
+
myjson = [myjson];
|
|
131
|
+
if (tag_section === constants_objecttranslations_1.OBJTRANSL_LAYOUT_ROOT) {
|
|
132
|
+
myjson = (0, utils_objtransl_1.transformLayoutXMLtoCSV)(myjson);
|
|
122
133
|
}
|
|
134
|
+
if (tag_section === constants_objecttranslations_1.OBJTRANSL_CFIELDTRANSL_ROOT) {
|
|
135
|
+
myjson = [];
|
|
136
|
+
var fieldTrList = (0, utils_objtransl_1.getFieldTranslationFiles)((0, path_1.join)(baseInputDir, objTrName));
|
|
137
|
+
for (const fieldTrFilename of fieldTrList) {
|
|
138
|
+
const fieldTrPath = (0, path_1.join)(baseInputDir, objTrName, fieldTrFilename);
|
|
139
|
+
const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(fieldTrPath)) ?? {};
|
|
140
|
+
const fieldTr = xmlFileContent[constants_objecttranslations_1.OBJTRANSL_CFIELDTRANSL_ROOT_TAG] ?? {};
|
|
141
|
+
myjson.push(...(0, utils_objtransl_1.transformFieldXMLtoCSV)(fieldTr));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
(0, utils_1.generateTagId)(myjson, constants_objecttranslations_1.OBJTRANSL_ITEMS[tag_section].key, constants_objecttranslations_1.OBJTRANSL_ITEMS[tag_section].headers);
|
|
145
|
+
const headers = constants_objecttranslations_1.OBJTRANSL_ITEMS[tag_section].headers;
|
|
146
|
+
const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(objTrName, tag_section));
|
|
147
|
+
(0, filesUtils_1.checkDirOrCreateSync)(outputDir);
|
|
148
|
+
if (fs.existsSync(outputFile)) {
|
|
149
|
+
const csvFilePath = (0, path_1.join)(baseOutputDir, objTrName, 'csv', (0, filesUtils_1.calcCsvFilename)(objTrName, tag_section));
|
|
150
|
+
var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(csvFilePath);
|
|
151
|
+
var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(myjson);
|
|
152
|
+
jsonMapNew.forEach((value, key) => {
|
|
153
|
+
jsonMapOld.set(key, value);
|
|
154
|
+
});
|
|
155
|
+
myjson = Array.from(jsonMapOld.values());
|
|
156
|
+
}
|
|
157
|
+
if (options.sort === 'true') {
|
|
158
|
+
myjson = (0, utils_1.sortByKey)(myjson);
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const csvContent = await csvWriter.toCsv(myjson, headers);
|
|
162
|
+
fs.writeFileSync(outputFile, csvContent, { flag: 'w+' });
|
|
163
|
+
// file written successfully
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
console.error(err);
|
|
167
|
+
throw new Error(`Failed to write CSV file ${outputFile}: ${err.message}`);
|
|
168
|
+
}
|
|
169
|
+
// writes the empty tag on the part file
|
|
170
|
+
// avoid writing for fieldTranslations, since they are separated files
|
|
171
|
+
if (tag_section !== constants_objecttranslations_1.OBJTRANSL_CFIELDTRANSL_ROOT)
|
|
172
|
+
xmlFileContent[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG][tag_section] = null;
|
|
123
173
|
}
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
jsonMapOld.set(key, value);
|
|
134
|
-
});
|
|
135
|
-
myjson = Array.from(jsonMapOld.values());
|
|
136
|
-
}
|
|
137
|
-
if (options.sort === 'true') {
|
|
138
|
-
myjson = (0, utils_1.sortByKey)(myjson);
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
const csvContent = await csvWriter.toCsv(myjson, headers);
|
|
142
|
-
fs.writeFileSync(outputFile, csvContent, { flag: 'w+' });
|
|
143
|
-
// file written successfully
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
console.error(err);
|
|
174
|
+
if (fs.existsSync(inputFilePart)) {
|
|
175
|
+
const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
|
|
176
|
+
const objTranslPropertiesPart = xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] ?? {};
|
|
177
|
+
for (var k in objTranslProperties) {
|
|
178
|
+
objTranslPropertiesPart[k] = objTranslProperties[k];
|
|
179
|
+
}
|
|
180
|
+
xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] = objTranslPropertiesPart;
|
|
181
|
+
xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] = (0, utils_2.sortObjectKeys)(xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG]);
|
|
182
|
+
(0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
|
|
147
183
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (fs.existsSync(inputFilePart)) {
|
|
154
|
-
const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
|
|
155
|
-
const objTranslPropertiesPart = xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] ?? {};
|
|
156
|
-
for (var k in objTranslProperties) {
|
|
157
|
-
objTranslPropertiesPart[k] = objTranslProperties[k];
|
|
184
|
+
else {
|
|
185
|
+
if (fs.existsSync((0, path_1.join)(baseInputDir, objTrName, objTrName))) {
|
|
186
|
+
objTranslProperties[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] = (0, utils_2.sortObjectKeys)(objTranslProperties[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG]);
|
|
187
|
+
(0, filesUtils_1.writeXmlToFile)(inputFilePart, objTranslProperties);
|
|
188
|
+
}
|
|
158
189
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
(0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
|
|
190
|
+
// Object processed successfully
|
|
191
|
+
result.items[objTrName] = { result: 'OK' };
|
|
162
192
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
193
|
+
catch (error) {
|
|
194
|
+
// Object processing failed
|
|
195
|
+
console.error(`Error processing object ${objTrName}:`, error);
|
|
196
|
+
result.items[objTrName] = {
|
|
197
|
+
result: 'KO',
|
|
198
|
+
error: error.message || 'Unknown error occurred'
|
|
199
|
+
};
|
|
168
200
|
}
|
|
169
201
|
}
|
|
170
|
-
return
|
|
202
|
+
return result;
|
|
171
203
|
}
|
|
172
204
|
exports.objectTranslationUpsert = objectTranslationUpsert;
|
|
173
205
|
//# sourceMappingURL=upsert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../src/commands/easysources/objecttranslations/upsert.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,0DAA4K;AAC5K,gDAA+D;AAC/D,kEAAgH;AAChH,4DAAqD;AACrD,+BAA4B;AAC5B,gEAA4D;AAC5D,wGAAyO;AACzO,oEAA2H;AAC3H,
|
|
1
|
+
{"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../src/commands/easysources/objecttranslations/upsert.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,0DAA4K;AAC5K,gDAA+D;AAC/D,kEAAgH;AAChH,4DAAqD;AACrD,+BAA4B;AAC5B,gEAA4D;AAC5D,wGAAyO;AACzO,oEAA2H;AAC3H,yDAAkF;AAClF,wDAAiD;AACjD,mCAAiD;AACjD,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAEhC,wDAAwD;AACxD,eAAQ,CAAC,uBAA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gBACH,IAAI,EAAE,CAAC,UAAU,CAAC,IAAA,WAAI,EAAC,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE;oBACzD,mBAAmB,CAAC,iDAAkB,CAAC,GAAG,IAAA,sBAAc,EAAC,mBAAmB,CAAC,iDAAkB,CAAC,CAAC,CAAC;oBAClG,IAAA,2BAAc,EAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;iBACtD;aACJ;YAED,gCAAgC;YAChC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAE9C;QAAC,OAAO,KAAK,EAAE;YACZ,2BAA2B;YAC3B,OAAO,CAAC,KAAK,CAAC,2BAA2B,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC;YAC9D,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG;gBACtB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KAEJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAtKD,0DAsKC"}
|
|
@@ -18,6 +18,7 @@ const utils_1 = require("../../../utils/utils");
|
|
|
18
18
|
const constants_1 = require("../../../utils/constants/constants");
|
|
19
19
|
const localSettings_1 = require("../../../utils/localSettings");
|
|
20
20
|
const constants_permissionsets_1 = require("../../../utils/constants/constants_permissionsets");
|
|
21
|
+
const utils_2 = require("../../../utils/commands/utils");
|
|
21
22
|
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
22
23
|
const settings = (0, localSettings_1.loadSettings)();
|
|
23
24
|
// Initialize Messages with the current plugin directory
|
|
@@ -70,8 +71,15 @@ async function permissionsetMinify(options) {
|
|
|
70
71
|
const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_permissionsets_1.PERMSETS_SUBPATH);
|
|
71
72
|
const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
|
|
72
73
|
const inputProfile = options.input;
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// Initialize result object
|
|
75
|
+
const result = { result: 'OK', items: {} };
|
|
76
|
+
try {
|
|
77
|
+
(0, filesUtils_1.checkDirOrErrorSync)(csvDir);
|
|
78
|
+
(0, filesUtils_1.checkDirOrErrorSync)(xmlDir);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return (0, utils_2.jsonAndPrintError)(error.message);
|
|
82
|
+
}
|
|
75
83
|
var profileList = [];
|
|
76
84
|
if (inputProfile) {
|
|
77
85
|
profileList = inputProfile.split(',');
|
|
@@ -84,39 +92,52 @@ async function permissionsetMinify(options) {
|
|
|
84
92
|
// profileName is the profile name without the extension
|
|
85
93
|
for (const profileName of profileList) {
|
|
86
94
|
console.log('Minifying on: ' + profileName);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
for (const boolName of (0, utils_1.toArray)(constants_permissionsets_1.PERMSET_TAG_BOOL[tag_section])) {
|
|
98
|
-
if (res[boolName] === 'true' || res[boolName] === 'FALSE')
|
|
95
|
+
try {
|
|
96
|
+
for (const tag_section in constants_permissionsets_1.PERMSET_ITEMS) {
|
|
97
|
+
// tag_section is a profile section (applicationVisibilities, classAccess ecc)
|
|
98
|
+
const csvFilePath = (0, path_1.join)(csvDir, profileName, (0, filesUtils_1.calcCsvFilename)(profileName, tag_section));
|
|
99
|
+
if (fs.existsSync(csvFilePath)) {
|
|
100
|
+
// get the list of resources on the csv. eg. the list of apex classes
|
|
101
|
+
var resListCsv = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
|
|
102
|
+
resListCsv = resListCsv.filter(function (res) {
|
|
103
|
+
// return true to persist, false to delete
|
|
104
|
+
if (constants_permissionsets_1.PERMSET_TAG_BOOL[tag_section] == null)
|
|
99
105
|
return true;
|
|
106
|
+
for (const boolName of (0, utils_1.toArray)(constants_permissionsets_1.PERMSET_TAG_BOOL[tag_section])) {
|
|
107
|
+
if (res[boolName] === 'true' || res[boolName] === 'FALSE')
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
});
|
|
112
|
+
// write the cleaned csv
|
|
113
|
+
const headers = constants_permissionsets_1.PERMSET_ITEMS[tag_section].headers;
|
|
114
|
+
if (options.sort === 'true') {
|
|
115
|
+
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
119
|
+
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
120
|
+
// file written successfully
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error(err);
|
|
124
|
+
throw new Error(`Failed to write CSV file ${csvFilePath}: ${err.message}`);
|
|
100
125
|
}
|
|
101
|
-
return false;
|
|
102
|
-
});
|
|
103
|
-
// write the cleaned csv
|
|
104
|
-
const headers = constants_permissionsets_1.PERMSET_ITEMS[tag_section].headers;
|
|
105
|
-
if (options.sort === 'true') {
|
|
106
|
-
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
110
|
-
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
111
|
-
// file written successfully
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
console.error(err);
|
|
115
126
|
}
|
|
127
|
+
// Permission set processed successfully
|
|
128
|
+
result.items[profileName] = { result: 'OK' };
|
|
116
129
|
}
|
|
117
130
|
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
// Permission set processing failed
|
|
133
|
+
console.error(`Error minifying permission set ${profileName}:`, error);
|
|
134
|
+
result.items[profileName] = {
|
|
135
|
+
result: 'KO',
|
|
136
|
+
error: error.message || 'Unknown error occurred'
|
|
137
|
+
};
|
|
138
|
+
}
|
|
118
139
|
}
|
|
119
|
-
return
|
|
140
|
+
return result;
|
|
120
141
|
}
|
|
121
142
|
exports.permissionsetMinify = permissionsetMinify;
|
|
122
143
|
//# sourceMappingURL=minify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minify.js","sourceRoot":"","sources":["../../../../src/commands/easysources/permissionsets/minify.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,4DAAqD;AACrD,0DAAoG;AACpG,gDAAyD;AACzD,kEAA4F;AAC5F,gEAA4D;AAC5D,gGAAsH;AACtH,wDAAiD;AAEjD,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAEhC,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;AAE/E,MAAqB,KAAM,SAAQ,qBAAW;IA6BnC,KAAK,CAAC,GAAG;QACZ,qBAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;QAElC,IAAI,MAAM,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnD,qBAAW,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC;QAEhC,OAAO,MAAM,CAAC;IAClB,CAAC;;AArCL,wBAsCC;AArCiB,iBAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAExD,cAAQ,GAAG,QAAQ,CAAC,U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wB;aACnD,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAvFD,kDAuFC"}
|
|
@@ -18,6 +18,7 @@ const filesUtils_1 = require("../../../utils/filesUtils");
|
|
|
18
18
|
const utils_1 = require("../../../utils/utils");
|
|
19
19
|
const constants_1 = require("../../../utils/constants/constants");
|
|
20
20
|
const localSettings_1 = require("../../../utils/localSettings");
|
|
21
|
+
const utils_2 = require("../../../utils/commands/utils");
|
|
21
22
|
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
22
23
|
const settings = (0, localSettings_1.loadSettings)();
|
|
23
24
|
// Initialize Messages with the current plugin directory
|
|
@@ -64,8 +65,15 @@ async function profileMinify(options) {
|
|
|
64
65
|
const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_profiles_1.PROFILES_SUBPATH);
|
|
65
66
|
const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
|
|
66
67
|
const inputProfile = options.input;
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
// Initialize result object
|
|
69
|
+
const result = { result: 'OK', items: {} };
|
|
70
|
+
try {
|
|
71
|
+
(0, filesUtils_1.checkDirOrErrorSync)(csvDir);
|
|
72
|
+
(0, filesUtils_1.checkDirOrErrorSync)(xmlDir);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return (0, utils_2.jsonAndPrintError)(error.message);
|
|
76
|
+
}
|
|
69
77
|
var profileList = [];
|
|
70
78
|
if (inputProfile) {
|
|
71
79
|
profileList = inputProfile.split(',');
|
|
@@ -78,39 +86,52 @@ async function profileMinify(options) {
|
|
|
78
86
|
// profileName is the profile name without the extension
|
|
79
87
|
for (const profileName of profileList) {
|
|
80
88
|
console.log('Minifying on: ' + profileName);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for (const boolName of (0, utils_1.toArray)(constants_profiles_1.PROFILE_TAG_BOOL[tag_section])) {
|
|
92
|
-
if (res[boolName] === 'true' || res[boolName] === 'FALSE')
|
|
89
|
+
try {
|
|
90
|
+
for (const tag_section in constants_profiles_1.PROFILE_ITEMS) {
|
|
91
|
+
// tag_section is a profile section (applicationVisibilities, classAccess ecc)
|
|
92
|
+
const csvFilePath = (0, path_1.join)(csvDir, profileName, (0, filesUtils_1.calcCsvFilename)(profileName, tag_section));
|
|
93
|
+
if (fs.existsSync(csvFilePath)) {
|
|
94
|
+
// get the list of resources on the csv. eg. the list of apex classes
|
|
95
|
+
var resListCsv = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
|
|
96
|
+
resListCsv = resListCsv.filter(function (res) {
|
|
97
|
+
// return true to persist, false to delete
|
|
98
|
+
if (constants_profiles_1.PROFILE_TAG_BOOL[tag_section] == null)
|
|
93
99
|
return true;
|
|
100
|
+
for (const boolName of (0, utils_1.toArray)(constants_profiles_1.PROFILE_TAG_BOOL[tag_section])) {
|
|
101
|
+
if (res[boolName] === 'true' || res[boolName] === 'FALSE')
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
});
|
|
106
|
+
// write the cleaned csv
|
|
107
|
+
// write the cleaned csv
|
|
108
|
+
const headers = constants_profiles_1.PROFILE_ITEMS[tag_section].headers;
|
|
109
|
+
if (options.sort === 'true') {
|
|
110
|
+
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
114
|
+
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
115
|
+
// file written successfully
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
console.error(err);
|
|
94
119
|
}
|
|
95
|
-
return false;
|
|
96
|
-
});
|
|
97
|
-
// write the cleaned csv
|
|
98
|
-
const headers = constants_profiles_1.PROFILE_ITEMS[tag_section].headers;
|
|
99
|
-
if (options.sort === 'true') {
|
|
100
|
-
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
104
|
-
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
105
|
-
// file written successfully
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
console.error(err);
|
|
109
120
|
}
|
|
121
|
+
// Profile processed successfully
|
|
122
|
+
result.items[profileName] = { result: 'OK' };
|
|
110
123
|
}
|
|
111
124
|
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
// Profile processing failed
|
|
127
|
+
console.error(`Error processing profile ${profileName}:`, error);
|
|
128
|
+
result.items[profileName] = {
|
|
129
|
+
result: 'KO',
|
|
130
|
+
error: error.message || 'Unknown error occurred'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
112
133
|
}
|
|
113
|
-
return
|
|
134
|
+
return result;
|
|
114
135
|
}
|
|
115
136
|
exports.profileMinify = profileMinify;
|
|
116
137
|
//# sourceMappingURL=minify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minify.js","sourceRoot":"","sources":["../../../../src/commands/easysources/profiles/minify.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,4DAAqD;AACrD,oFAAgH;AAChH,0DAAoG;AACpG,gDAAyD;AACzD,kEAA4F;AAC5F,gEAA4D;AAC5D,wDAAiD;AAEjD,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAEhC,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SA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AC/B;oBAAC,OAAO,GAAG,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;qBACtB;iBAEJ;gBACG,iCAAiC;gBACjC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;aAChD;SACJ;QAAC,OAAO,KAAK,EAAE;YACZ,4BAA4B;YAC5B,OAAO,CAAC,KAAK,CAAC,4BAA4B,WAAW,GAAG,EAAE,KAAK,CAAC,CAAC;YACjE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG;gBACxB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AApFD,sCAoFC"}
|
|
@@ -12,9 +12,8 @@ const command_1 = require("@salesforce/command");
|
|
|
12
12
|
const core_1 = require("@salesforce/core");
|
|
13
13
|
const constants_profiles_1 = require("../../../utils/constants/constants_profiles");
|
|
14
14
|
const performance_1 = require("../../../utils/performance");
|
|
15
|
-
//import { split } from '../../../utils/commands/splitter';
|
|
16
|
-
const constants_1 = require("../../../utils/constants/constants");
|
|
17
15
|
const splitter_1 = require("../../../utils/commands/splitter");
|
|
16
|
+
const constants_1 = require("../../../utils/constants/constants");
|
|
18
17
|
// Initialize Messages with the current plugin directory
|
|
19
18
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
20
19
|
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../../src/commands/easysources/profiles/split.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,oFAAqI;AACrI,4DAAqD;AACrD
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../../src/commands/easysources/profiles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AAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;KAC3D,CAAC;IACF,IAAI,EAAE,eAAK,CAAC,IAAI,CAAC;QACb,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC;QACjE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,OAAO,EAAE,MAAM;KAClB,CAAC;IACF,cAAc,EAAE,eAAK,CAAC,IAAI,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;QAC5E,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,OAAO,EAAE,OAAO;KACnB,CAAC;CACL,CAAC;AAaN;;;;;;GAMG;AACI,KAAK,UAAU,YAAY,CAAC,OAAY;IAC3C,OAAO,MAAM,IAAA,gBAAK,EAAC,OAAO,EAAE,qCAAgB,EAAE,uCAAkB,EAAE,sCAAiB,EAAE,kCAAa,CAAC,CAAC;AACxG,CAAC;AAFD,oCAEC"}
|
|
@@ -19,6 +19,7 @@ const filesUtils_1 = require("../../../utils/filesUtils");
|
|
|
19
19
|
const utils_1 = require("../../../utils/utils");
|
|
20
20
|
const utils_recordtypes_1 = require("../../../utils/utils_recordtypes");
|
|
21
21
|
const localSettings_1 = require("../../../utils/localSettings");
|
|
22
|
+
const utils_2 = require("../../../utils/commands/utils");
|
|
22
23
|
const settings = (0, localSettings_1.loadSettings)();
|
|
23
24
|
// Initialize Messages with the current plugin directory
|
|
24
25
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -68,9 +69,10 @@ async function recordTypeMerge(options = {}) {
|
|
|
68
69
|
const baseOutputDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
|
|
69
70
|
const inputObject = (options.object);
|
|
70
71
|
const inputRecordType = (options.recordtype);
|
|
72
|
+
// Initialize result object
|
|
73
|
+
const result = { result: 'OK', items: {} };
|
|
71
74
|
if (!fs.existsSync(baseInputDir)) {
|
|
72
|
-
|
|
73
|
-
return { outputString: 'ERROR: Input folder does not exist' };
|
|
75
|
+
return (0, utils_2.jsonAndPrintError)('Input folder ' + baseInputDir + ' does not exist!');
|
|
74
76
|
}
|
|
75
77
|
var objectList = [];
|
|
76
78
|
if (inputObject) {
|
|
@@ -94,17 +96,30 @@ async function recordTypeMerge(options = {}) {
|
|
|
94
96
|
.map(item => item.name);
|
|
95
97
|
}
|
|
96
98
|
for (const dir of recordTypeList) {
|
|
99
|
+
const fileKey = `${obj}/${dir}`;
|
|
97
100
|
console.log('Merging: ' + (0, path_1.join)(obj, dir));
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
fs.
|
|
101
|
+
try {
|
|
102
|
+
const mergedXml = await mergeRecordTypeFromCsv(dir, (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir), options);
|
|
103
|
+
const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes');
|
|
104
|
+
const outputFile = (0, path_1.join)(outputDir, dir + constants_recordtypes_1.RECORDTYPES_EXTENSION);
|
|
105
|
+
if (!fs.existsSync(outputDir)) {
|
|
106
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
107
|
+
}
|
|
108
|
+
(0, filesUtils_1.writeXmlToFile)(outputFile, mergedXml);
|
|
109
|
+
// Record type processed successfully
|
|
110
|
+
result.items[fileKey] = { result: 'OK' };
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
// Record type processing failed
|
|
114
|
+
console.error(`Error merging record type ${dir}:`, error);
|
|
115
|
+
result.items[fileKey] = {
|
|
116
|
+
result: 'KO',
|
|
117
|
+
error: error.message || 'Unknown error occurred'
|
|
118
|
+
};
|
|
103
119
|
}
|
|
104
|
-
(0, filesUtils_1.writeXmlToFile)(outputFile, mergedXml);
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
|
-
return
|
|
122
|
+
return result;
|
|
108
123
|
}
|
|
109
124
|
exports.recordTypeMerge = recordTypeMerge;
|
|
110
125
|
/**
|