sfdx-easy-sources 0.8.3 → 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 +52 -32
- package/lib/commands/easysources/objecttranslations/minify.js.map +1 -1
- package/lib/commands/easysources/objecttranslations/split.js +79 -55
- 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 +109 -75
- package/lib/commands/easysources/objecttranslations/upsert.js.map +1 -1
- package/lib/commands/easysources/permissionsets/clean.js +4 -5
- package/lib/commands/easysources/permissionsets/clean.js.map +1 -1
- package/lib/commands/easysources/permissionsets/delete.js +4 -5
- package/lib/commands/easysources/permissionsets/delete.js.map +1 -1
- package/lib/commands/easysources/permissionsets/minify.js +52 -32
- package/lib/commands/easysources/permissionsets/minify.js.map +1 -1
- package/lib/commands/easysources/profiles/clean.js +4 -5
- package/lib/commands/easysources/profiles/clean.js.map +1 -1
- package/lib/commands/easysources/profiles/delete.js +4 -5
- package/lib/commands/easysources/profiles/delete.js.map +1 -1
- package/lib/commands/easysources/profiles/minify.js +52 -32
- package/lib/commands/easysources/profiles/minify.js.map +1 -1
- package/lib/commands/easysources/profiles/split.js +1 -1
- package/lib/commands/easysources/recordtypes/clean.js +5 -5
- package/lib/commands/easysources/recordtypes/clean.js.map +1 -1
- package/lib/commands/easysources/recordtypes/delete.js +5 -5
- package/lib/commands/easysources/recordtypes/delete.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 +58 -40
- package/lib/commands/easysources/recordtypes/split.js.map +1 -1
- package/lib/commands/easysources/recordtypes/updatekey.js +38 -22
- package/lib/commands/easysources/recordtypes/updatekey.js.map +1 -1
- package/lib/commands/easysources/recordtypes/upsert.js +90 -64
- package/lib/commands/easysources/recordtypes/upsert.js.map +1 -1
- package/lib/commands/easysources/translations/minify.js +53 -31
- 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 +37 -23
- 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 +62 -48
- package/lib/utils/commands/splitter.js.map +1 -1
- package/lib/utils/commands/upserter.d.ts +3 -3
- package/lib/utils/commands/upserter.js +128 -102
- package/lib/utils/commands/upserter.js.map +1 -1
- package/lib/utils/commands/utils.d.ts +11 -0
- package/lib/utils/commands/utils.js +35 -1
- package/lib/utils/commands/utils.js.map +1 -1
- package/lib/utils/constants/constants_applications.d.ts +2 -8
- package/lib/utils/constants/constants_globalvaluesets.d.ts +2 -8
- package/lib/utils/constants/constants_globalvaluesettranslations.d.ts +2 -8
- package/lib/utils/constants/constants_labels.d.ts +2 -8
- package/lib/utils/constants/constants_objecttranslations.d.ts +14 -56
- package/lib/utils/constants/constants_permissionsets.d.ts +2 -8
- package/lib/utils/constants/constants_profiles.d.ts +4 -16
- package/lib/utils/constants/constants_translations.d.ts +12 -48
- package/lib/utils/csvWriter.d.ts +9 -0
- package/lib/utils/csvWriter.js +53 -0
- package/lib/utils/csvWriter.js.map +1 -0
- package/lib/utils/utils.d.ts +1 -4
- package/lib/utils/utils.js +8 -1
- package/lib/utils/utils.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
|
@@ -12,7 +12,6 @@ const command_1 = require("@salesforce/command");
|
|
|
12
12
|
const core_1 = require("@salesforce/core");
|
|
13
13
|
const filesUtils_1 = require("../../../utils/filesUtils");
|
|
14
14
|
const utils_1 = require("../../../utils/utils");
|
|
15
|
-
const { Parser, transforms: { unwind } } = require('json2csv');
|
|
16
15
|
const constants_1 = require("../../../utils/constants/constants");
|
|
17
16
|
const performance_1 = require("../../../utils/performance");
|
|
18
17
|
const path_1 = require("path");
|
|
@@ -20,6 +19,8 @@ const localSettings_1 = require("../../../utils/localSettings");
|
|
|
20
19
|
const constants_objecttranslations_1 = require("../../../utils/constants/constants_objecttranslations");
|
|
21
20
|
const utils_objtransl_1 = require("../../../utils/utils_objtransl");
|
|
22
21
|
const utils_2 = require("../../../utils/commands/utils");
|
|
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
|
|
@@ -62,10 +63,18 @@ Upsert.flagsConfig = {
|
|
|
62
63
|
};
|
|
63
64
|
// Export object translation-specific upsert function for programmatic API
|
|
64
65
|
async function objectTranslationUpsert(options = {}) {
|
|
66
|
+
const csvWriter = new csvWriter_1.default();
|
|
65
67
|
const baseInputDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH), constants_objecttranslations_1.OBJTRANSL_SUBPATH);
|
|
66
68
|
const baseOutputDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_objecttranslations_1.OBJTRANSL_SUBPATH);
|
|
67
69
|
const inputObject = (options.input);
|
|
68
|
-
|
|
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
|
+
}
|
|
69
78
|
var objectTList = [];
|
|
70
79
|
if (inputObject) {
|
|
71
80
|
objectTList = inputObject.split(',');
|
|
@@ -81,91 +90,116 @@ async function objectTranslationUpsert(options = {}) {
|
|
|
81
90
|
const inputFile = (0, path_1.join)(baseInputDir, objTrName, fullFilename);
|
|
82
91
|
if (!fs.existsSync(inputFile)) {
|
|
83
92
|
console.log('Skipping ' + objTrName + '; File ' + inputFile + ' does not exist!');
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const outputDir = (0, path_1.join)(baseOutputDir, objTrName, 'csv');
|
|
88
|
-
const inputFilePart = (0, path_1.join)(baseOutputDir, objTrName, 'csv', objTrName + constants_1.XML_PART_EXTENSION);
|
|
89
|
-
// If outputDir or inputFilePart doesn't exist, run split command instead
|
|
90
|
-
if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
|
|
91
|
-
console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for: ' + objTrName);
|
|
92
|
-
// Create flags for split command with just the current object
|
|
93
|
-
const splitFlags = {
|
|
94
|
-
...options,
|
|
95
|
-
input: objTrName
|
|
93
|
+
result.items[objTrName] = {
|
|
94
|
+
result: 'KO',
|
|
95
|
+
error: `File ${inputFile} does not exist`
|
|
96
96
|
};
|
|
97
|
-
await (0, utils_2.executeCommand)(splitFlags, 'split', 'objecttranslations');
|
|
98
97
|
continue;
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
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
|
+
}
|
|
106
119
|
continue;
|
|
107
|
-
// fixes scenarios when the tag is one, since it would be read as object and not array
|
|
108
|
-
if (!Array.isArray(myjson))
|
|
109
|
-
myjson = [myjson];
|
|
110
|
-
if (tag_section === constants_objecttranslations_1.OBJTRANSL_LAYOUT_ROOT) {
|
|
111
|
-
myjson = (0, utils_objtransl_1.transformLayoutXMLtoCSV)(myjson);
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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);
|
|
121
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;
|
|
122
173
|
}
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(myjson);
|
|
133
|
-
jsonMapNew.forEach((value, key) => {
|
|
134
|
-
jsonMapOld.set(key, value);
|
|
135
|
-
});
|
|
136
|
-
myjson = Array.from(jsonMapOld.values());
|
|
137
|
-
}
|
|
138
|
-
if (options.sort === 'true') {
|
|
139
|
-
myjson = (0, utils_1.sortByKey)(myjson);
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
const csv = parser.parse(myjson);
|
|
143
|
-
fs.writeFileSync(outputFile, csv, { flag: 'w+' });
|
|
144
|
-
// file written successfully
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
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);
|
|
148
183
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (fs.existsSync(inputFilePart)) {
|
|
155
|
-
const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
|
|
156
|
-
const objTranslPropertiesPart = xmlFileContentPart[constants_objecttranslations_1.OBJTRANSL_ROOT_TAG] ?? {};
|
|
157
|
-
for (var k in objTranslProperties) {
|
|
158
|
-
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
|
+
}
|
|
159
189
|
}
|
|
160
|
-
|
|
190
|
+
// Object processed successfully
|
|
191
|
+
result.items[objTrName] = { result: 'OK' };
|
|
161
192
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
+
};
|
|
166
200
|
}
|
|
167
201
|
}
|
|
168
|
-
return
|
|
202
|
+
return result;
|
|
169
203
|
}
|
|
170
204
|
exports.objectTranslationUpsert = objectTranslationUpsert;
|
|
171
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,
|
|
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,uBAAuB,CAAC,SAAS,CAAC,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C,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"}
|
|
@@ -13,7 +13,6 @@ const core_1 = require("@salesforce/core");
|
|
|
13
13
|
const fs = require('fs-extra');
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const performance_1 = require("../../../utils/performance");
|
|
16
|
-
const { Parser, transforms: { unwind } } = require('json2csv');
|
|
17
16
|
const filesUtils_1 = require("../../../utils/filesUtils");
|
|
18
17
|
const utils_1 = require("../../../utils/utils");
|
|
19
18
|
const constants_1 = require("../../../utils/constants/constants");
|
|
@@ -21,6 +20,7 @@ const localSettings_1 = require("../../../utils/localSettings");
|
|
|
21
20
|
const utils_2 = require("../../../utils/commands/utils");
|
|
22
21
|
const constants_sourcesdownload_1 = require("../../../utils/constants/constants_sourcesdownload");
|
|
23
22
|
const constants_permissionsets_1 = require("../../../utils/constants/constants_permissionsets");
|
|
23
|
+
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
24
24
|
const _ = require('lodash');
|
|
25
25
|
const settings = (0, localSettings_1.loadSettings)();
|
|
26
26
|
// Initialize Messages with the current plugin directory
|
|
@@ -115,6 +115,7 @@ Clean.flagsConfig = {
|
|
|
115
115
|
* @returns Promise with clean operation result
|
|
116
116
|
*/
|
|
117
117
|
async function permissionsetClean(options) {
|
|
118
|
+
const csvWriter = new csvWriter_1.default();
|
|
118
119
|
const logdir = options['log-dir'] || settings['easysources-log-path'] || constants_1.DEFAULT_LOG_PATH;
|
|
119
120
|
const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_permissionsets_1.PERMSETS_SUBPATH);
|
|
120
121
|
const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
|
|
@@ -222,14 +223,12 @@ async function permissionsetClean(options) {
|
|
|
222
223
|
if (mode !== "log") {
|
|
223
224
|
// write the cleaned csv
|
|
224
225
|
const headers = constants_permissionsets_1.PERMSET_ITEMS[tag_section].headers;
|
|
225
|
-
const transforms = [unwind({ paths: headers })];
|
|
226
|
-
const parser = new Parser({ fields: [...headers, '_tagid'], transforms });
|
|
227
226
|
if (options.sort === 'true') {
|
|
228
227
|
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
229
228
|
}
|
|
230
|
-
const csv = parser.parse(resListCsv);
|
|
231
229
|
try {
|
|
232
|
-
|
|
230
|
+
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
231
|
+
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
233
232
|
// file written successfully
|
|
234
233
|
}
|
|
235
234
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../../src/commands/easysources/permissionsets/clean.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,MAAM,EAAE,GA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AAC;KAC9C;IACD,IAAG,QAAQ,KAAK,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC;QACtD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;KAC7C;IACD,IAAG,QAAQ,KAAK,YAAY,IAAI,IAAI,KAAK,kCAAkC,EAAC;QACxE,IAAI,GAAG,IAAI,CAAC;KACf;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAZD,wCAYC;AAEM,KAAK,UAAU,gBAAgB,CAAC,WAAW,EAAE,WAAW;IAC3D,MAAM,SAAS,GAAE,IAAA,WAAI,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,CAAC,MAAM,IAAA,4BAAe,EAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,MAAM,eAAe,GAAG,cAAc,CAAC,0CAAc,CAAC,IAAI,EAAE,CAAC;IAC7D,MAAM,aAAa,GAAG,eAAe,CAAC,8CAAkB,CAAC,CAAC;IAE1D,IAAI,YAAY,GAAG,IAAA,kCAAqB,EAAC,aAAa,CAAC,CAAC;IACxD,OAAO,YAAY,CAAC;AACxB,CAAC;AARD,4CAQC"}
|
|
@@ -13,12 +13,12 @@ const core_1 = require("@salesforce/core");
|
|
|
13
13
|
const fs = require('fs-extra');
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const performance_1 = require("../../../utils/performance");
|
|
16
|
-
const { Parser, transforms: { unwind } } = require('json2csv');
|
|
17
16
|
const constants_permissionsets_1 = require("../../../utils/constants/constants_permissionsets");
|
|
18
17
|
const filesUtils_1 = require("../../../utils/filesUtils");
|
|
19
18
|
const utils_1 = require("../../../utils/utils");
|
|
20
19
|
const constants_1 = require("../../../utils/constants/constants");
|
|
21
20
|
const localSettings_1 = require("../../../utils/localSettings");
|
|
21
|
+
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
22
22
|
const settings = (0, localSettings_1.loadSettings)();
|
|
23
23
|
// Initialize Messages with the current plugin directory
|
|
24
24
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -70,6 +70,7 @@ Delete.flagsConfig = {
|
|
|
70
70
|
* @returns Promise with delete operation result
|
|
71
71
|
*/
|
|
72
72
|
async function permissionsetDelete(options) {
|
|
73
|
+
const csvWriter = new csvWriter_1.default();
|
|
73
74
|
const type = options.type;
|
|
74
75
|
const tagid = options.tagid;
|
|
75
76
|
if (!type)
|
|
@@ -105,14 +106,12 @@ async function permissionsetDelete(options) {
|
|
|
105
106
|
}
|
|
106
107
|
var jsonArray = Array.from(jsonMap.values());
|
|
107
108
|
const headers = constants_permissionsets_1.PERMSET_ITEMS[type].headers;
|
|
108
|
-
const transforms = [unwind({ paths: headers })];
|
|
109
|
-
const parser = new Parser({ fields: [...headers, '_tagid'], transforms });
|
|
110
109
|
if (options.sort === 'true') {
|
|
111
110
|
jsonArray = (0, utils_1.sortByKey)(jsonArray);
|
|
112
111
|
}
|
|
113
|
-
const csv = parser.parse(jsonArray);
|
|
114
112
|
try {
|
|
115
|
-
|
|
113
|
+
const csvContent = await csvWriter.toCsv(jsonArray, headers);
|
|
114
|
+
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
116
115
|
// file written successfully
|
|
117
116
|
}
|
|
118
117
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/easysources/permissionsets/delete.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAAqD;AAErD,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,4DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/easysources/permissionsets/delete.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;A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AC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAE7C,MAAM,OAAO,GAAG,wCAAa,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YAE5C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;gBACzB,SAAS,GAAG,IAAA,iBAAS,EAAC,SAAS,CAAC,CAAC;aACpC;YAED,IAAI;gBACA,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAC7D,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1D,4BAA4B;aAC/B;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACtB;SACJ;KACJ;IAED,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC;AAzDD,kDAyDC"}
|
|
@@ -13,12 +13,13 @@ const core_1 = require("@salesforce/core");
|
|
|
13
13
|
const fs = require('fs-extra');
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const performance_1 = require("../../../utils/performance");
|
|
16
|
-
const { Parser, transforms: { unwind } } = require('json2csv');
|
|
17
16
|
const filesUtils_1 = require("../../../utils/filesUtils");
|
|
18
17
|
const utils_1 = require("../../../utils/utils");
|
|
19
18
|
const constants_1 = require("../../../utils/constants/constants");
|
|
20
19
|
const localSettings_1 = require("../../../utils/localSettings");
|
|
21
20
|
const constants_permissionsets_1 = require("../../../utils/constants/constants_permissionsets");
|
|
21
|
+
const utils_2 = require("../../../utils/commands/utils");
|
|
22
|
+
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
22
23
|
const settings = (0, localSettings_1.loadSettings)();
|
|
23
24
|
// Initialize Messages with the current plugin directory
|
|
24
25
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -66,11 +67,19 @@ Clean.flagsConfig = {
|
|
|
66
67
|
* @returns Promise with minify operation result
|
|
67
68
|
*/
|
|
68
69
|
async function permissionsetMinify(options) {
|
|
70
|
+
const csvWriter = new csvWriter_1.default();
|
|
69
71
|
const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_permissionsets_1.PERMSETS_SUBPATH);
|
|
70
72
|
const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
|
|
71
73
|
const inputProfile = options.input;
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
83
|
var profileList = [];
|
|
75
84
|
if (inputProfile) {
|
|
76
85
|
profileList = inputProfile.split(',');
|
|
@@ -83,41 +92,52 @@ async function permissionsetMinify(options) {
|
|
|
83
92
|
// profileName is the profile name without the extension
|
|
84
93
|
for (const profileName of profileList) {
|
|
85
94
|
console.log('Minifying on: ' + profileName);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (const boolName of (0, utils_1.toArray)(constants_permissionsets_1.PERMSET_TAG_BOOL[tag_section])) {
|
|
97
|
-
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)
|
|
98
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}`);
|
|
99
125
|
}
|
|
100
|
-
return false;
|
|
101
|
-
});
|
|
102
|
-
// write the cleaned csv
|
|
103
|
-
const headers = constants_permissionsets_1.PERMSET_ITEMS[tag_section].headers;
|
|
104
|
-
const transforms = [unwind({ paths: headers })];
|
|
105
|
-
const parser = new Parser({ fields: [...headers, '_tagid'], transforms });
|
|
106
|
-
if (options.sort === 'true') {
|
|
107
|
-
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
108
|
-
}
|
|
109
|
-
const csv = parser.parse(resListCsv);
|
|
110
|
-
try {
|
|
111
|
-
fs.writeFileSync(csvFilePath, csv, { flag: 'w+' });
|
|
112
|
-
// file written successfully
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
console.error(err);
|
|
116
126
|
}
|
|
127
|
+
// Permission set processed successfully
|
|
128
|
+
result.items[profileName] = { result: 'OK' };
|
|
117
129
|
}
|
|
118
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
|
+
}
|
|
119
139
|
}
|
|
120
|
-
return
|
|
140
|
+
return result;
|
|
121
141
|
}
|
|
122
142
|
exports.permissionsetMinify = permissionsetMinify;
|
|
123
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,
|
|
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,yDAAkE;AAClE,wDAAiD;AAEjD,MAAM,QAAQ,GAAG,IAAA,4BAA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GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;wBAC9D,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC1D,4BAA4B;qBAC/B;oBAAC,OAAO,GAAG,EAAE;wBACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,WAAW,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;qBAC9E;iBAEJ;gBAED,wCAAwC;gBACxC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;aAChD;SAEJ;QAAC,OAAO,KAAK,EAAE;YACZ,mCAAmC;YACnC,OAAO,CAAC,KAAK,CAAC,kCAAkC,WAAW,GAAG,EAAE,KAAK,CAAC,CAAC;YACvE,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;AAvFD,kDAuFC"}
|
|
@@ -13,7 +13,6 @@ const core_1 = require("@salesforce/core");
|
|
|
13
13
|
const fs = require('fs-extra');
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
const performance_1 = require("../../../utils/performance");
|
|
16
|
-
const { Parser, transforms: { unwind } } = require('json2csv');
|
|
17
16
|
const constants_profiles_1 = require("../../../utils/constants/constants_profiles");
|
|
18
17
|
const filesUtils_1 = require("../../../utils/filesUtils");
|
|
19
18
|
const utils_1 = require("../../../utils/utils");
|
|
@@ -22,6 +21,7 @@ const localSettings_1 = require("../../../utils/localSettings");
|
|
|
22
21
|
const utils_2 = require("../../../utils/commands/utils");
|
|
23
22
|
const constants_sourcesdownload_1 = require("../../../utils/constants/constants_sourcesdownload");
|
|
24
23
|
const constants_profiles_2 = require("../../../utils/constants/constants_profiles");
|
|
24
|
+
const csvWriter_1 = require("../../../utils/csvWriter");
|
|
25
25
|
const _ = require('lodash');
|
|
26
26
|
const settings = (0, localSettings_1.loadSettings)();
|
|
27
27
|
// Initialize Messages with the current plugin directory
|
|
@@ -110,6 +110,7 @@ Clean.flagsConfig = {
|
|
|
110
110
|
};
|
|
111
111
|
// Export a profile-specific clean function that encapsulates profile constants
|
|
112
112
|
async function profileClean(options) {
|
|
113
|
+
const csvWriter = new csvWriter_1.default();
|
|
113
114
|
const logdir = options['log-dir'] || settings['easysources-log-path'] || constants_1.DEFAULT_LOG_PATH;
|
|
114
115
|
const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_profiles_1.PROFILES_SUBPATH);
|
|
115
116
|
const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
|
|
@@ -217,14 +218,12 @@ async function profileClean(options) {
|
|
|
217
218
|
if (mode !== "log") {
|
|
218
219
|
// write the cleaned csv
|
|
219
220
|
const headers = constants_profiles_1.PROFILE_ITEMS[tag_section].headers;
|
|
220
|
-
const transforms = [unwind({ paths: headers })];
|
|
221
|
-
const parser = new Parser({ fields: [...headers, '_tagid'], transforms });
|
|
222
221
|
if (options.sort === 'true') {
|
|
223
222
|
resListCsv = (0, utils_1.sortByKey)(resListCsv);
|
|
224
223
|
}
|
|
225
|
-
const csv = parser.parse(resListCsv);
|
|
226
224
|
try {
|
|
227
|
-
|
|
225
|
+
const csvContent = await csvWriter.toCsv(resListCsv, headers);
|
|
226
|
+
fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
|
|
228
227
|
// file written successfully
|
|
229
228
|
}
|
|
230
229
|
catch (err) {
|