sfdx-easy-sources 0.9.0 → 0.9.1-develop.2

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.
Files changed (53) hide show
  1. package/lib/commands/easysources/allmeta/minify.d.ts +1 -0
  2. package/lib/commands/easysources/allmeta/minify.js +17 -2
  3. package/lib/commands/easysources/allmeta/minify.js.map +1 -1
  4. package/lib/commands/easysources/objecttranslations/merge.d.ts +1 -3
  5. package/lib/commands/easysources/objecttranslations/merge.js +46 -17
  6. package/lib/commands/easysources/objecttranslations/merge.js.map +1 -1
  7. package/lib/commands/easysources/objecttranslations/minify.d.ts +1 -3
  8. package/lib/commands/easysources/objecttranslations/minify.js +50 -29
  9. package/lib/commands/easysources/objecttranslations/minify.js.map +1 -1
  10. package/lib/commands/easysources/objecttranslations/split.js +76 -52
  11. package/lib/commands/easysources/objecttranslations/split.js.map +1 -1
  12. package/lib/commands/easysources/objecttranslations/upsert.d.ts +1 -3
  13. package/lib/commands/easysources/objecttranslations/upsert.js +107 -75
  14. package/lib/commands/easysources/objecttranslations/upsert.js.map +1 -1
  15. package/lib/commands/easysources/permissionsets/delete.js +41 -24
  16. package/lib/commands/easysources/permissionsets/delete.js.map +1 -1
  17. package/lib/commands/easysources/permissionsets/minify.js +50 -29
  18. package/lib/commands/easysources/permissionsets/minify.js.map +1 -1
  19. package/lib/commands/easysources/profiles/delete.js +41 -23
  20. package/lib/commands/easysources/profiles/delete.js.map +1 -1
  21. package/lib/commands/easysources/profiles/minify.js +50 -29
  22. package/lib/commands/easysources/profiles/minify.js.map +1 -1
  23. package/lib/commands/easysources/profiles/split.js +1 -2
  24. package/lib/commands/easysources/profiles/split.js.map +1 -1
  25. package/lib/commands/easysources/recordtypes/delete.js +45 -30
  26. package/lib/commands/easysources/recordtypes/delete.js.map +1 -1
  27. package/lib/commands/easysources/recordtypes/merge.js +24 -9
  28. package/lib/commands/easysources/recordtypes/merge.js.map +1 -1
  29. package/lib/commands/easysources/recordtypes/split.js +56 -40
  30. package/lib/commands/easysources/recordtypes/split.js.map +1 -1
  31. package/lib/commands/easysources/recordtypes/updatekey.js +36 -20
  32. package/lib/commands/easysources/recordtypes/updatekey.js.map +1 -1
  33. package/lib/commands/easysources/recordtypes/upsert.js +88 -65
  34. package/lib/commands/easysources/recordtypes/upsert.js.map +1 -1
  35. package/lib/commands/easysources/translations/minify.js +51 -29
  36. package/lib/commands/easysources/translations/minify.js.map +1 -1
  37. package/lib/utils/commands/keyupdater.d.ts +5 -1
  38. package/lib/utils/commands/keyupdater.js +35 -20
  39. package/lib/utils/commands/keyupdater.js.map +1 -1
  40. package/lib/utils/commands/merger.d.ts +4 -0
  41. package/lib/utils/commands/merger.js +11 -5
  42. package/lib/utils/commands/merger.js.map +1 -1
  43. package/lib/utils/commands/splitter.d.ts +5 -1
  44. package/lib/utils/commands/splitter.js +60 -46
  45. package/lib/utils/commands/splitter.js.map +1 -1
  46. package/lib/utils/commands/upserter.d.ts +3 -3
  47. package/lib/utils/commands/upserter.js +126 -103
  48. package/lib/utils/commands/upserter.js.map +1 -1
  49. package/lib/utils/commands/utils.d.ts +4 -0
  50. package/lib/utils/commands/utils.js +9 -1
  51. package/lib/utils/commands/utils.js.map +1 -1
  52. package/oclif.manifest.json +1 -1
  53. package/package.json +1 -1
@@ -17,6 +17,7 @@ const performance_1 = require("../../../utils/performance");
17
17
  const path_1 = require("path");
18
18
  const constants_recordtypes_1 = require("../../../utils/constants/constants_recordtypes");
19
19
  const localSettings_1 = require("../../../utils/localSettings");
20
+ const utils_2 = require("../../../utils/commands/utils");
20
21
  const csvWriter_1 = require("../../../utils/csvWriter");
21
22
  const fs = require('fs-extra');
22
23
  const settings = (0, localSettings_1.loadSettings)();
@@ -63,9 +64,10 @@ async function recordTypeUpdateKey(options = {}) {
63
64
  const baseInputDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
64
65
  const inputObject = (options.object);
65
66
  const inputRecordType = (options.recordtype);
67
+ // Initialize result object
68
+ const result = { result: 'OK', items: {} };
66
69
  if (!fs.existsSync(baseInputDir)) {
67
- console.log('Input folder ' + baseInputDir + ' does not exist!');
68
- return { outputString: 'ERROR: Input folder does not exist' };
70
+ return (0, utils_2.jsonAndPrintError)('Input folder ' + baseInputDir + ' does not exist!');
69
71
  }
70
72
  var objectList = [];
71
73
  if (inputObject) {
@@ -90,30 +92,44 @@ async function recordTypeUpdateKey(options = {}) {
90
92
  }
91
93
  // dir is the record type name without the extension
92
94
  for (const dir of recordTypeList) {
95
+ const fileKey = `${obj}/${dir}`;
93
96
  console.log('UpdateKey: ' + dir);
94
- // key is each profile section (applicationVisibilities, classAccess ecc)
95
- for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
96
- const csvFilePath = (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
97
- if (fs.existsSync(csvFilePath)) {
98
- var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
99
- (0, utils_1.generateTagId)(jsonArray, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
100
- if (options.sort === 'true' || options.sort === true || options.sort === undefined) {
101
- jsonArray = (0, utils_1.sortByKey)(jsonArray);
102
- }
103
- const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
104
- try {
105
- const csvContent = await csvWriter.toCsv(jsonArray, headers);
106
- fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
107
- // file written successfully
108
- }
109
- catch (err) {
110
- console.error(err);
97
+ try {
98
+ // key is each profile section (applicationVisibilities, classAccess ecc)
99
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
100
+ const csvFilePath = (0, path_1.join)(baseInputDir, obj, 'recordTypes', dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
101
+ if (fs.existsSync(csvFilePath)) {
102
+ var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
103
+ (0, utils_1.generateTagId)(jsonArray, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
104
+ if (options.sort === 'true' || options.sort === true || options.sort === undefined) {
105
+ jsonArray = (0, utils_1.sortByKey)(jsonArray);
106
+ }
107
+ const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
108
+ try {
109
+ const csvContent = await csvWriter.toCsv(jsonArray, headers);
110
+ fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
111
+ // file written successfully
112
+ }
113
+ catch (err) {
114
+ console.error(err);
115
+ throw new Error(`Failed to write CSV file ${csvFilePath}: ${err.message}`);
116
+ }
111
117
  }
112
118
  }
119
+ // Record type processed successfully
120
+ result.items[fileKey] = { result: 'OK' };
121
+ }
122
+ catch (error) {
123
+ // Record type processing failed
124
+ console.error(`Error updating key for record type ${dir}:`, error);
125
+ result.items[fileKey] = {
126
+ result: 'KO',
127
+ error: error.message || 'Unknown error occurred'
128
+ };
113
129
  }
114
130
  }
115
131
  }
116
- return { outputString: 'OK' };
132
+ return result;
117
133
  }
118
134
  exports.recordTypeUpdateKey = recordTypeUpdateKey;
119
135
  //# sourceMappingURL=updatekey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"updatekey.js","sourceRoot":"","sources":["../../../../src/commands/easysources/recordtypes/updatekey.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,0DAA+E;AAC/E,gDAA+D;AAC/D,kEAAwE;AACxE,4DAAqD;AACrD,+BAA4B;AAC5B,0FAAuG;AACvG,gEAA4D;AAC5D,wDAAiD;AACjD,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,QAAQ,GAAG,IAA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4B;yBAC/B;wBAAC,OAAO,GAAG,EAAE;4BACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,WAAW,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;yBAC9E;qBACJ;iBACJ;gBAED,qCAAqC;gBACrC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;aAE5C;YAAC,OAAO,KAAK,EAAE;gBACZ,gCAAgC;gBAChC,OAAO,CAAC,KAAK,CAAC,sCAAsC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;gBACnE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG;oBACpB,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;iBACnD,CAAC;aACL;SACJ;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAlFD,kDAkFC"}
@@ -20,6 +20,7 @@ const utils_recordtypes_1 = require("../../../utils/utils_recordtypes");
20
20
  const localSettings_1 = require("../../../utils/localSettings");
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
@@ -71,9 +72,10 @@ async function recordTypeUpsert(options = {}) {
71
72
  const baseOutputDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_recordtypes_1.RECORDTYPES_SUBPATH);
72
73
  const inputObject = (options.object);
73
74
  const inputRecordType = (options.recordtype);
75
+ // Initialize result object
76
+ const result = { result: 'OK', items: {} };
74
77
  if (!fs.existsSync(baseInputDir)) {
75
- console.log('Input folder ' + baseInputDir + ' does not exist!');
76
- return;
78
+ return (0, utils_2.jsonAndPrintError)('Input folder ' + baseInputDir + ' does not exist!');
77
79
  }
78
80
  var objectList = [];
79
81
  if (inputObject) {
@@ -98,79 +100,100 @@ async function recordTypeUpsert(options = {}) {
98
100
  }
99
101
  for (const filename of recordTypeList) {
100
102
  const fullFilename = filename.endsWith(constants_recordtypes_1.RECORDTYPES_EXTENSION) ? filename : filename + constants_recordtypes_1.RECORDTYPES_EXTENSION;
101
- console.log('Upserting: ' + filename);
102
- const inputFile = (0, path_1.join)(baseInputDir, obj, 'recordTypes', fullFilename);
103
103
  const recordtypeName = (0, filesUtils_1.removeExtension)(fullFilename);
104
- const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName);
105
- const inputFilePart = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName, recordtypeName + constants_1.XML_PART_EXTENSION);
106
- // If outputDir or inputFilePart doesn't exist, run split command instead
107
- if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
108
- console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for object: ' + obj + ', recordtype: ' + filename);
109
- // Create flags for split command with just the current object and recordtype
110
- const splitFlags = {
111
- ...options,
112
- object: obj,
113
- recordtype: filename
114
- };
115
- await (0, utils_2.executeCommand)(splitFlags, 'split', 'recordtypes');
116
- continue;
117
- }
118
- const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
119
- const recordtypeProperties = xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
120
- for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
121
- var jsonArray = recordtypeProperties[tag_section];
122
- if (jsonArray == undefined)
104
+ const fileKey = `${obj}/${recordtypeName}`;
105
+ console.log('Upserting: ' + filename);
106
+ try {
107
+ const inputFile = (0, path_1.join)(baseInputDir, obj, 'recordTypes', fullFilename);
108
+ const outputDir = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName);
109
+ const inputFilePart = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName, recordtypeName + constants_1.XML_PART_EXTENSION);
110
+ // If outputDir or inputFilePart doesn't exist, run split command instead
111
+ if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
112
+ console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for object: ' + obj + ', recordtype: ' + filename);
113
+ // Create flags for split command with just the current object and recordtype
114
+ const splitFlags = {
115
+ ...options,
116
+ object: obj,
117
+ recordtype: filename
118
+ };
119
+ // Call split function and handle its result
120
+ const splitResult = await (0, split_1.recordTypeSplit)(splitFlags);
121
+ if (splitResult.items && splitResult.items[fileKey]) {
122
+ result.items[fileKey] = splitResult.items[fileKey];
123
+ }
124
+ else {
125
+ result.items[fileKey] = { result: 'KO', error: 'Split operation failed' };
126
+ }
123
127
  continue;
124
- if (!Array.isArray(jsonArray))
125
- jsonArray = [jsonArray];
126
- var jsonArrayNew = (0, utils_recordtypes_1.transformXMLtoCSV)(jsonArray);
127
- (0, utils_1.generateTagId)(jsonArrayNew, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
128
- const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
129
- const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
130
- if (!fs.existsSync(outputDir)) {
131
- fs.mkdirSync(outputDir);
132
128
  }
133
- if (fs.existsSync(outputFile)) {
134
- const csvFilePath = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
135
- var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(csvFilePath);
136
- var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(jsonArrayNew);
137
- jsonMapNew.forEach((value, key) => {
138
- jsonMapOld.set(key, value);
139
- });
140
- jsonArrayNew = Array.from(jsonMapOld.values());
129
+ const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
130
+ const recordtypeProperties = xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
131
+ for (const tag_section in constants_recordtypes_1.RECORDTYPE_ITEMS) {
132
+ var jsonArray = recordtypeProperties[tag_section];
133
+ if (jsonArray == undefined)
134
+ continue;
135
+ if (!Array.isArray(jsonArray))
136
+ jsonArray = [jsonArray];
137
+ var jsonArrayNew = (0, utils_recordtypes_1.transformXMLtoCSV)(jsonArray);
138
+ (0, utils_1.generateTagId)(jsonArrayNew, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].key, constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers);
139
+ const headers = constants_recordtypes_1.RECORDTYPE_ITEMS[tag_section].headers;
140
+ const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
141
+ if (!fs.existsSync(outputDir)) {
142
+ fs.mkdirSync(outputDir);
143
+ }
144
+ if (fs.existsSync(outputFile)) {
145
+ const csvFilePath = (0, path_1.join)(baseOutputDir, obj, 'recordTypes', recordtypeName, (0, filesUtils_1.calcCsvFilename)(recordtypeName, tag_section));
146
+ var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(csvFilePath);
147
+ var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(jsonArrayNew);
148
+ jsonMapNew.forEach((value, key) => {
149
+ jsonMapOld.set(key, value);
150
+ });
151
+ jsonArrayNew = Array.from(jsonMapOld.values());
152
+ }
153
+ if (options.sort === 'true') {
154
+ jsonArrayNew = (0, utils_1.sortByKey)(jsonArrayNew);
155
+ }
156
+ try {
157
+ const csvContent = await csvWriter.toCsv(jsonArrayNew, headers);
158
+ fs.writeFileSync(outputFile, csvContent, { flag: 'w+' });
159
+ // file written successfully
160
+ }
161
+ catch (err) {
162
+ console.error(err);
163
+ throw new Error(`Failed to write CSV file ${outputFile}: ${err.message}`);
164
+ }
165
+ xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG][tag_section] = null;
141
166
  }
142
- if (options.sort === 'true') {
143
- jsonArrayNew = (0, utils_1.sortByKey)(jsonArrayNew);
167
+ if (fs.existsSync(inputFilePart)) {
168
+ const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
169
+ const recordtypePropertiesPart = xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
170
+ for (var k in recordtypeProperties) {
171
+ recordtypePropertiesPart[k] = recordtypeProperties[k];
172
+ }
173
+ xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = recordtypePropertiesPart;
174
+ xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = (0, utils_2.sortObjectKeys)(xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG]);
175
+ (0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
144
176
  }
145
- try {
146
- const csvContent = await csvWriter.toCsv(jsonArrayNew, headers);
147
- fs.writeFileSync(outputFile, csvContent, { flag: 'w+' });
148
- // file written successfully
177
+ else {
178
+ if (fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes', recordtypeName))) {
179
+ recordtypeProperties[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = (0, utils_2.sortObjectKeys)(recordtypeProperties[constants_recordtypes_1.RECORDTYPES_ROOT_TAG]);
180
+ (0, filesUtils_1.writeXmlToFile)(inputFilePart, recordtypeProperties);
181
+ }
149
182
  }
150
- catch (err) {
151
- console.error(err);
152
- }
153
- xmlFileContent[constants_recordtypes_1.RECORDTYPES_ROOT_TAG][tag_section] = null;
154
- }
155
- if (fs.existsSync(inputFilePart)) {
156
- const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
157
- const recordtypePropertiesPart = xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] ?? {};
158
- for (var k in recordtypeProperties) {
159
- recordtypePropertiesPart[k] = recordtypeProperties[k];
160
- }
161
- xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = recordtypePropertiesPart;
162
- xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = (0, utils_2.sortObjectKeys)(xmlFileContentPart[constants_recordtypes_1.RECORDTYPES_ROOT_TAG]);
163
- (0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
183
+ // File processed successfully
184
+ result.items[fileKey] = { result: 'OK' };
164
185
  }
165
- else {
166
- if (fs.existsSync((0, path_1.join)(baseInputDir, obj, 'recordTypes', recordtypeName))) {
167
- recordtypeProperties[constants_recordtypes_1.RECORDTYPES_ROOT_TAG] = (0, utils_2.sortObjectKeys)(recordtypeProperties[constants_recordtypes_1.RECORDTYPES_ROOT_TAG]);
168
- (0, filesUtils_1.writeXmlToFile)(inputFilePart, recordtypeProperties);
169
- }
186
+ catch (error) {
187
+ // File processing failed
188
+ console.error(`Error processing file ${fullFilename}:`, error);
189
+ result.items[fileKey] = {
190
+ result: 'KO',
191
+ error: error.message || 'Unknown error occurred'
192
+ };
170
193
  }
171
194
  }
172
195
  }
173
- return { outputString: 'OK' };
196
+ return result;
174
197
  }
175
198
  exports.recordTypeUpsert = recordTypeUpsert;
176
199
  //# sourceMappingURL=upsert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../src/commands/easysources/recordtypes/upsert.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,yBAAyB;AACzB,iDAAyD;AACzD,2CAA4C;AAE5C,0DAAkJ;AAClJ,gDAA+D;AAC/D,kEAAgH;AAChH,4DAAqD;AACrD,+BAA4B;AAC5B,0FAAoJ;AACpJ,wEAAqE;AACrE,gEAA4D;AAC5D,yDAA+E;AAC/E,wDAAiD;AACjD,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,QAAQ,GAA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 = 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
@@ -65,8 +66,16 @@ async function translationMinify(options = {}) {
65
66
  const csvDir = (0, path_1.join)((options["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), constants_translations_1.TRANSLATIONS_SUBPATH);
66
67
  const xmlDir = (0, path_1.join)((options["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH));
67
68
  const inputTranslation = (options.input);
68
- (0, filesUtils_1.checkDirOrErrorSync)(csvDir);
69
- (0, filesUtils_1.checkDirOrErrorSync)(xmlDir);
69
+ // Initialize result object
70
+ const result = { result: 'OK', items: {} };
71
+ try {
72
+ (0, filesUtils_1.checkDirOrErrorSync)(csvDir);
73
+ (0, filesUtils_1.checkDirOrErrorSync)(xmlDir);
74
+ }
75
+ catch (error) {
76
+ performance_1.default.getInstance().end();
77
+ return (0, utils_2.jsonAndPrintError)(error.message);
78
+ }
70
79
  var transationList = [];
71
80
  if (inputTranslation) {
72
81
  transationList = inputTranslation.split(',');
@@ -79,40 +88,53 @@ async function translationMinify(options = {}) {
79
88
  // translationName is the profile name without the extension
80
89
  for (const translationName of transationList) {
81
90
  console.log('Minifying on: ' + translationName);
82
- for (const tag_section in constants_translations_1.TRANSLATION_ITEMS) {
83
- // tag_section is a profile section (applicationVisibilities, classAccess ecc)
84
- const csvFilePath = (0, path_1.join)(csvDir, translationName, (0, filesUtils_1.calcCsvFilename)(translationName, tag_section));
85
- if (fs.existsSync(csvFilePath)) {
86
- // get the list of resources on the csv. eg. the list of apex classes
87
- var resListCsv = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
88
- resListCsv = resListCsv.filter(function (res) {
89
- // return true to persist, false to delete
90
- if (constants_translations_1.TRANSLAT_TAG_BOOL[tag_section] == null)
91
- return true;
92
- for (const boolName of (0, utils_1.toArray)(constants_translations_1.TRANSLAT_TAG_BOOL[tag_section])) {
93
- if (!(0, utils_1.isBlank)(res[boolName]))
91
+ try {
92
+ for (const tag_section in constants_translations_1.TRANSLATION_ITEMS) {
93
+ // tag_section is a profile section (applicationVisibilities, classAccess ecc)
94
+ const csvFilePath = (0, path_1.join)(csvDir, translationName, (0, filesUtils_1.calcCsvFilename)(translationName, tag_section));
95
+ if (fs.existsSync(csvFilePath)) {
96
+ // get the list of resources on the csv. eg. the list of apex classes
97
+ var resListCsv = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
98
+ resListCsv = resListCsv.filter(function (res) {
99
+ // return true to persist, false to delete
100
+ if (constants_translations_1.TRANSLAT_TAG_BOOL[tag_section] == null)
94
101
  return true;
102
+ for (const boolName of (0, utils_1.toArray)(constants_translations_1.TRANSLAT_TAG_BOOL[tag_section])) {
103
+ if (!(0, utils_1.isBlank)(res[boolName]))
104
+ return true;
105
+ }
106
+ return false;
107
+ });
108
+ // write the cleaned csv
109
+ const headers = constants_translations_1.TRANSLATION_ITEMS[tag_section].headers;
110
+ if (options.sort === 'true') {
111
+ resListCsv = (0, utils_1.sortByKey)(resListCsv);
112
+ }
113
+ try {
114
+ const csvContent = await csvWriter.toCsv(resListCsv, headers);
115
+ fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
116
+ // file written successfully
117
+ }
118
+ catch (err) {
119
+ console.error(err);
120
+ throw new Error(`Failed to write CSV file ${csvFilePath}: ${err.message}`);
95
121
  }
96
- return false;
97
- });
98
- // write the cleaned csv
99
- const headers = constants_translations_1.TRANSLATION_ITEMS[tag_section].headers;
100
- if (options.sort === 'true') {
101
- resListCsv = (0, utils_1.sortByKey)(resListCsv);
102
- }
103
- try {
104
- const csvContent = await csvWriter.toCsv(resListCsv, headers);
105
- fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
106
- // file written successfully
107
- }
108
- catch (err) {
109
- console.error(err);
110
122
  }
123
+ // Translation processed successfully
124
+ result.items[translationName] = { result: 'OK' };
111
125
  }
112
126
  }
127
+ catch (error) {
128
+ // Translation processing failed
129
+ console.error(`Error minifying translation ${translationName}:`, error);
130
+ result.items[translationName] = {
131
+ result: 'KO',
132
+ error: error.message || 'Unknown error occurred'
133
+ };
134
+ }
113
135
  }
114
136
  performance_1.default.getInstance().end();
115
- return { outputString: 'OK' };
137
+ return result;
116
138
  }
117
139
  exports.translationMinify = translationMinify;
118
140
  //# sourceMappingURL=minify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minify.js","sourceRoot":"","sources":["../../../../src/commands/easysources/translations/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,4FAA6H;AAC7H,0DAAoG;AACpG,gDAAkE;AAClE,kEAA4F;AAC5F,gEAA4D;AAC5D,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,qBAAqB,CAAC,CAAC;AAEnF,MAAqB,KAAM,SAAQ,qBAAW;IA6BnC,KAAK,CAAC,GAAG;QACZ,qBAAW,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;QAElC,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnD,qBAAW,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC;QAEhC,OAAO,MAAM,CAAC;IAClB,CAAC;;AAr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BACjB,CAAC,CAAC,CAAC;oBAEC,wBAAwB;oBAC5B,MAAM,OAAO,GAAG,0CAAiB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;oBAEvD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;wBACzB,UAAU,GAAG,IAAA,iBAAS,EAAC,UAAU,CAAC,CAAC;qBACtC;oBAED,IAAI;wBACA,MAAM,UAAU,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;iBACJ;gBAED,qCAAqC;gBACrC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;aACpD;SAEJ;QAAC,OAAO,KAAK,EAAE;YACZ,gCAAgC;YAChC,OAAO,CAAC,KAAK,CAAC,+BAA+B,eAAe,GAAG,EAAE,KAAK,CAAC,CAAC;YACxE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG;gBAC5B,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KACJ;IAED,qBAAW,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC;IAGhC,OAAO,MAAM,CAAC;AAClB,CAAC;AAvFD,8CAuFC"}
@@ -1,3 +1,7 @@
1
1
  export declare function updatekey(flags: any, file_subpath: any, file_items: any): Promise<{
2
- outputString: string;
2
+ error: string;
3
+ result: string;
4
+ } | {
5
+ result: string;
6
+ items: {};
3
7
  }>;
@@ -7,6 +7,7 @@ const utils_2 = require("../utils");
7
7
  const path_1 = require("path");
8
8
  const constants_1 = require("../constants/constants");
9
9
  const localSettings_1 = require("../localSettings");
10
+ const utils_3 = require("./utils");
10
11
  const csvWriter_1 = require("../csvWriter");
11
12
  const fs = require('fs-extra');
12
13
  const settings = (0, localSettings_1.loadSettings)();
@@ -15,9 +16,10 @@ async function updatekey(flags, file_subpath, file_items) {
15
16
  const baseInputDir = (0, path_1.join)((flags["es-csv"] || settings['easysources-csv-path'] || constants_1.DEFAULT_ESCSV_PATH), file_subpath);
16
17
  const inputFiles = (flags.input);
17
18
  if (!fs.existsSync(baseInputDir)) {
18
- console.log('Input folder ' + baseInputDir + ' does not exist!');
19
- return;
19
+ return (0, utils_3.jsonAndPrintError)(`Input folder ${baseInputDir} does not exist`);
20
20
  }
21
+ // Initialize result object
22
+ const result = { result: 'OK', items: {} };
21
23
  var dirList = [];
22
24
  if (inputFiles) {
23
25
  dirList = inputFiles.split(',');
@@ -30,28 +32,41 @@ async function updatekey(flags, file_subpath, file_items) {
30
32
  // dir is the file name without the extension
31
33
  for (const dir of dirList) {
32
34
  console.log('UpdateKey: ' + dir);
33
- // tag_Section is each file section (applicationVisibilities, classAccess ecc)
34
- for (const tag_section in file_items) {
35
- const csvFilePath = (0, path_1.join)(baseInputDir, dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
36
- if (fs.existsSync(csvFilePath)) {
37
- var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
38
- (0, utils_2.generateTagId)(jsonArray, file_items[tag_section].key, file_items[tag_section].headers);
39
- if (flags.sort === 'true') {
40
- jsonArray = (0, utils_1.sortByKey)(jsonArray);
41
- }
42
- const headers = file_items[tag_section].headers;
43
- try {
44
- const csvContent = await csvWriter.toCsv(jsonArray, headers);
45
- fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
46
- // file written successfully
47
- }
48
- catch (err) {
49
- console.error(err);
35
+ try {
36
+ // tag_Section is each file section (applicationVisibilities, classAccess ecc)
37
+ for (const tag_section in file_items) {
38
+ const csvFilePath = (0, path_1.join)(baseInputDir, dir, (0, filesUtils_1.calcCsvFilename)(dir, tag_section));
39
+ if (fs.existsSync(csvFilePath)) {
40
+ var jsonArray = await (0, filesUtils_1.readCsvToJsonArray)(csvFilePath);
41
+ (0, utils_2.generateTagId)(jsonArray, file_items[tag_section].key, file_items[tag_section].headers);
42
+ if (flags.sort === 'true') {
43
+ jsonArray = (0, utils_1.sortByKey)(jsonArray);
44
+ }
45
+ const headers = file_items[tag_section].headers;
46
+ try {
47
+ const csvContent = await csvWriter.toCsv(jsonArray, headers);
48
+ fs.writeFileSync(csvFilePath, csvContent, { flag: 'w+' });
49
+ // file written successfully
50
+ }
51
+ catch (err) {
52
+ console.error(err);
53
+ throw new Error(`Failed to write CSV file ${csvFilePath}: ${err.message}`);
54
+ }
50
55
  }
51
56
  }
57
+ // Directory processed successfully
58
+ result.items[dir] = { result: 'OK' };
59
+ }
60
+ catch (error) {
61
+ // Directory processing failed
62
+ console.error(`Error processing directory ${dir}:`, error);
63
+ result.items[dir] = {
64
+ result: 'KO',
65
+ error: error.message || 'Unknown error occurred'
66
+ };
52
67
  }
53
68
  }
54
- return { outputString: 'OK' };
69
+ return result;
55
70
  }
56
71
  exports.updatekey = updatekey;
57
72
  //# sourceMappingURL=keyupdater.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyupdater.js","sourceRoot":"","sources":["../../../src/utils/commands/keyupdater.ts"],"names":[],"mappings":";;;AAAA,8CAAmE;AACnE,oCAAoC;AACpC,oCAAwC;AACxC,+BAA4B;AAC5B,sDAA4D;AAC5D,oDAAgD;AAChD,4CAAqC;AACrC,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAEzB,KAAK,UAAU,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU;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,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;oBAEvF,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;wBACvB,SAAS,GAAG,IAAA,iBAAS,EAAC,SAAS,CAAC,CAAC;qBACpC;oBAED,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;oBAEhD,IAAI;wBACA,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;wBAC7D,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;qBAE9E;iBACJ;aACJ;YAED,mCAAmC;YACnC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAExC;QAAC,OAAO,KAAK,EAAE;YACZ,8BAA8B;YAC9B,OAAO,CAAC,KAAK,CAAC,8BAA8B,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;gBAChB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AApED,8BAoEC"}
@@ -9,5 +9,9 @@
9
9
  */
10
10
  export declare function mergeItemFromCsv(itemName: string, csvDirPath: string, file_root_tag: string, file_items: any, flags: any): Promise<any>;
11
11
  export declare function merge(flags: any, file_subpath: any, file_extension: any, file_root_tag: any, file_items: any): Promise<{
12
+ error: string;
12
13
  result: string;
14
+ } | {
15
+ result: string;
16
+ items: {};
13
17
  }>;