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.
- 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/delete.js +41 -24
- package/lib/commands/easysources/permissionsets/delete.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/delete.js +41 -23
- package/lib/commands/easysources/profiles/delete.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/delete.js +45 -30
- 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 +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
|
@@ -8,6 +8,7 @@ const filesUtils_1 = require("../filesUtils");
|
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const localSettings_1 = require("../localSettings");
|
|
10
10
|
const flatArrayUtils_1 = require("../flatArrayUtils");
|
|
11
|
+
const utils_2 = require("./utils");
|
|
11
12
|
const settings = (0, localSettings_1.loadSettings)();
|
|
12
13
|
/**
|
|
13
14
|
* Core merge logic that creates merged XML from CSV files in memory
|
|
@@ -54,9 +55,10 @@ async function merge(flags, file_subpath, file_extension, file_root_tag, file_it
|
|
|
54
55
|
const baseOutputDir = (0, path_1.join)((flags["sf-xml"] || settings['salesforce-xml-path'] || constants_1.DEFAULT_SFXML_PATH), file_subpath);
|
|
55
56
|
const inputProfile = (flags.input);
|
|
56
57
|
if (!fs.existsSync(baseInputDir)) {
|
|
57
|
-
|
|
58
|
-
return;
|
|
58
|
+
return (0, utils_2.jsonAndPrintError)(`Input folder ${baseInputDir} does not exist`);
|
|
59
59
|
}
|
|
60
|
+
// Initialize result object
|
|
61
|
+
const result = { result: 'OK', items: {} };
|
|
60
62
|
var dirList = [];
|
|
61
63
|
if (inputProfile) {
|
|
62
64
|
dirList = inputProfile.split(',');
|
|
@@ -77,14 +79,18 @@ async function merge(flags, file_subpath, file_extension, file_root_tag, file_it
|
|
|
77
79
|
const mergedXml = await mergeItemFromCsv(dir, csvDirPath, file_root_tag, file_items, flags);
|
|
78
80
|
const outputFile = (0, path_1.join)(baseOutputDir, dir + file_extension);
|
|
79
81
|
(0, filesUtils_1.writeXmlToFile)(outputFile, mergedXml);
|
|
82
|
+
// Directory processed successfully
|
|
83
|
+
result.items[dir] = { result: 'OK' };
|
|
80
84
|
}
|
|
81
85
|
catch (error) {
|
|
82
86
|
console.log(`Error merging ${dir}: ${error.message}. Skipping...`);
|
|
83
|
-
|
|
87
|
+
result.items[dir] = {
|
|
88
|
+
result: 'KO',
|
|
89
|
+
error: error.message || 'Unknown error occurred'
|
|
90
|
+
};
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
return { result };
|
|
93
|
+
return result;
|
|
88
94
|
}
|
|
89
95
|
exports.merge = merge;
|
|
90
96
|
//# sourceMappingURL=merger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merger.js","sourceRoot":"","sources":["../../../src/utils/commands/merger.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,sDAAmG;AACnG,8CAAoG;AACpG,oCAAoC;AACpC,oDAAgD;AAChD,sDAAgD;
|
|
1
|
+
{"version":3,"file":"merger.js","sourceRoot":"","sources":["../../../src/utils/commands/merger.ts"],"names":[],"mappings":";;;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,+BAA4B;AAC5B,sDAAmG;AACnG,8CAAoG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CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KAC9B;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QAC/B,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;KAC/B;IAED,6CAA6C;IAC7C,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;QAC/B,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAE3C,IAAI;YACA,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;YAC5F,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,aAAa,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC;YAC7D,IAAA,2BAAc,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YAEtC,mCAAmC;YACnC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACxC;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,KAAK,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;YACnE,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;AA9CD,sBA8CC"}
|
|
@@ -10,8 +10,9 @@ const constants_1 = require("../constants/constants");
|
|
|
10
10
|
const constants_profiles_1 = require("../constants/constants_profiles");
|
|
11
11
|
const localSettings_1 = require("../localSettings");
|
|
12
12
|
const flatArrayUtils_1 = require("../flatArrayUtils");
|
|
13
|
-
const csvWriter_1 = require("../csvWriter");
|
|
14
13
|
const utils_3 = require("./utils");
|
|
14
|
+
const csvWriter_1 = require("../csvWriter");
|
|
15
|
+
const utils_4 = require("./utils");
|
|
15
16
|
const settings = (0, localSettings_1.loadSettings)();
|
|
16
17
|
async function split(flags, file_subpath, file_extension, file_root_tag, file_items) {
|
|
17
18
|
const csvWriter = new csvWriter_1.default();
|
|
@@ -20,9 +21,10 @@ async function split(flags, file_subpath, file_extension, file_root_tag, file_it
|
|
|
20
21
|
const ignoreUserPerm = (file_subpath === constants_profiles_1.PROFILES_SUBPATH && (flags.ignoreuserperm === 'true' || settings['ignore-user-permissions']) || false);
|
|
21
22
|
const inputFiles = (flags.input);
|
|
22
23
|
if (!fs.existsSync(baseInputDir)) {
|
|
23
|
-
|
|
24
|
-
return;
|
|
24
|
+
return (0, utils_3.jsonAndPrintError)(`Input folder ${baseInputDir} does not exist`);
|
|
25
25
|
}
|
|
26
|
+
// Initialize result object
|
|
27
|
+
const result = { result: 'OK', items: {} };
|
|
26
28
|
var fileList = [];
|
|
27
29
|
if (inputFiles) {
|
|
28
30
|
fileList = inputFiles.split(',');
|
|
@@ -35,56 +37,68 @@ async function split(flags, file_subpath, file_extension, file_root_tag, file_it
|
|
|
35
37
|
for (const filename of fileList) {
|
|
36
38
|
const fullFilename = filename.endsWith(file_extension) ? filename : filename + file_extension;
|
|
37
39
|
console.log('Splitting: ' + fullFilename);
|
|
38
|
-
const inputFile = (0, path_1.join)(baseInputDir, fullFilename);
|
|
39
|
-
const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
|
|
40
|
-
const fileProperties = xmlFileContent[file_root_tag] ?? {};
|
|
41
40
|
const fileName = (0, filesUtils_1.removeExtension)(fullFilename);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
continue;
|
|
41
|
+
try {
|
|
42
|
+
const inputFile = (0, path_1.join)(baseInputDir, fullFilename);
|
|
43
|
+
const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
|
|
44
|
+
const fileProperties = xmlFileContent[file_root_tag] ?? {};
|
|
45
|
+
const outputDir = (0, path_1.join)(baseOutputDir, fileName);
|
|
46
|
+
// Delete outputDir if it exists to ensure a clean split
|
|
47
|
+
if (fs.existsSync(outputDir)) {
|
|
48
|
+
fs.removeSync(outputDir);
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
myjson = (0,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
fs.
|
|
74
|
-
|
|
50
|
+
for (const tag_section in file_items) {
|
|
51
|
+
if (ignoreUserPerm && tag_section == constants_profiles_1.PROFILE_USERPERM_ROOT) {
|
|
52
|
+
xmlFileContent[file_root_tag][tag_section] = null;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
var myjson = fileProperties[tag_section];
|
|
56
|
+
// skip when tag is not found in the xml
|
|
57
|
+
if (myjson == undefined)
|
|
58
|
+
continue;
|
|
59
|
+
// fixes scenarios when the tag is one, since it would be read as object and not array
|
|
60
|
+
if (!Array.isArray(myjson))
|
|
61
|
+
myjson = [myjson];
|
|
62
|
+
myjson = (0, flatArrayUtils_1.arrayToFlat)(myjson);
|
|
63
|
+
// generate _tagId column
|
|
64
|
+
(0, utils_1.generateTagId)(myjson, file_items[tag_section].key, file_items[tag_section].headers);
|
|
65
|
+
// sorts array by _tagid. sorting is made as string
|
|
66
|
+
if (flags.sort === 'true') {
|
|
67
|
+
myjson = (0, utils_2.sortByKey)(myjson);
|
|
68
|
+
}
|
|
69
|
+
const headers = file_items[tag_section].headers;
|
|
70
|
+
const outputFileCSV = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(fileName, tag_section));
|
|
71
|
+
if (!fs.existsSync(outputDir)) {
|
|
72
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const csvContent = await csvWriter.toCsv(myjson, headers);
|
|
76
|
+
fs.writeFileSync(outputFileCSV, csvContent, { flag: 'w+' });
|
|
77
|
+
// file written successfully
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
}
|
|
82
|
+
xmlFileContent[file_root_tag][tag_section] = null;
|
|
75
83
|
}
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
if (fs.existsSync(outputDir)) {
|
|
85
|
+
const outputFileXML = (0, path_1.join)(outputDir, fileName + constants_1.XML_PART_EXTENSION);
|
|
86
|
+
xmlFileContent[file_root_tag] = (0, utils_4.sortObjectKeys)(xmlFileContent[file_root_tag]);
|
|
87
|
+
(0, filesUtils_1.writeXmlToFile)(outputFileXML, xmlFileContent);
|
|
78
88
|
}
|
|
79
|
-
|
|
89
|
+
// File processed successfully
|
|
90
|
+
result.items[fileName] = { result: 'OK' };
|
|
80
91
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
catch (error) {
|
|
93
|
+
// File processing failed
|
|
94
|
+
console.error(`Error processing file ${fullFilename}:`, error);
|
|
95
|
+
result.items[fileName] = {
|
|
96
|
+
result: 'KO',
|
|
97
|
+
error: error.message || 'Unknown error occurred'
|
|
98
|
+
};
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
|
-
return
|
|
101
|
+
return result;
|
|
88
102
|
}
|
|
89
103
|
exports.split = split;
|
|
90
104
|
//# sourceMappingURL=splitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitter.js","sourceRoot":"","sources":["../../../src/utils/commands/splitter.ts"],"names":[],"mappings":";;;AAAA,8CAAiG;AACjG,oCAAwC;AACxC,+BAA4B;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,oCAAoC;AACpC,sDAAoG;AACpG,wEAA0F;AAC1F,oDAAgD;AAChD,sDAAgD;AAChD,4CAAqC;AACrC,mCAAyC;AAEzC,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAIzB,KAAK,UAAU,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU;IACtF,MAAM,SAAS,GAAG,IAAI,mBAAS,EAAE,CAAC;IAElC,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,qBAAqB,CAAC,IAAI,8BAAkB,CAAC,EAAE,YAAY,CAAW,CAAC;IAC9H,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,sBAAsB,CAAC,IAAI,8BAAkB,CAAC,EAAE,YAAY,CAAW,CAAC;IAChI,MAAM,cAAc,GAAG,CAAC,YAAY,KAAK,qCAAgB,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,MAAM,IAAI,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,KAAK,CAAY,CAAC;IAC3J,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,KAAK,CAAW,CAAC;IAE3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"splitter.js","sourceRoot":"","sources":["../../../src/utils/commands/splitter.ts"],"names":[],"mappings":";;;AAAA,8CAAiG;AACjG,oCAAwC;AACxC,+BAA4B;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC/B,oCAAoC;AACpC,sDA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,UAAU,CAAC,SAAS,CAAC,EAAE;gBAC1B,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,QAAQ,GAAG,8BAAkB,CAAC,CAAC;gBACrE,cAAc,CAAC,aAAa,CAAC,GAAG,IAAA,sBAAc,EAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC9E,IAAA,2BAAc,EAAC,aAAa,EAAE,cAAc,CAAC,CAAC;aACjD;YAED,8BAA8B;YAC9B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACZ,yBAAyB;YACzB,OAAO,CAAC,KAAK,CAAC,yBAAyB,YAAY,GAAG,EAAE,KAAK,CAAC,CAAC;YAC/D,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG;gBACrB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAnGD,sBAmGC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function upsert(flags: any, file_subpath: any, file_extension: any, file_root_tag: any, file_items: any): Promise<{
|
|
2
2
|
error: string;
|
|
3
|
-
|
|
3
|
+
result: string;
|
|
4
4
|
} | {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
result: string;
|
|
6
|
+
items: {};
|
|
7
7
|
}>;
|
|
@@ -8,8 +8,9 @@ const path_1 = require("path");
|
|
|
8
8
|
const constants_1 = require("../constants/constants");
|
|
9
9
|
const constants_profiles_1 = require("../constants/constants_profiles");
|
|
10
10
|
const localSettings_1 = require("../localSettings");
|
|
11
|
-
const csvWriter_1 = require("../csvWriter");
|
|
12
11
|
const utils_2 = require("./utils");
|
|
12
|
+
const csvWriter_1 = require("../csvWriter");
|
|
13
|
+
const utils_3 = require("./utils");
|
|
13
14
|
const fs = require('fs-extra');
|
|
14
15
|
const settings = (0, localSettings_1.loadSettings)();
|
|
15
16
|
async function upsert(flags, file_subpath, file_extension, file_root_tag, file_items) {
|
|
@@ -22,8 +23,7 @@ async function upsert(flags, file_subpath, file_extension, file_root_tag, file_i
|
|
|
22
23
|
const hasType = flags.type !== undefined;
|
|
23
24
|
const hasTagid = flags.tagid !== undefined;
|
|
24
25
|
if (hasTagid && !hasType) {
|
|
25
|
-
|
|
26
|
-
return { error: `Missing required parameter: type (-t)` };
|
|
26
|
+
return (0, utils_2.jsonAndPrintError)(`tagid (-k) parameter can only be used together with type (-t) parameter`);
|
|
27
27
|
}
|
|
28
28
|
// Validate that specified types exist in file_items configuration
|
|
29
29
|
if (hasType) {
|
|
@@ -31,15 +31,14 @@ async function upsert(flags, file_subpath, file_extension, file_root_tag, file_i
|
|
|
31
31
|
const availableTypes = Object.keys(file_items);
|
|
32
32
|
const invalidTypes = specifiedTypes.filter(type => !availableTypes.includes(type.trim()));
|
|
33
33
|
if (invalidTypes.length > 0) {
|
|
34
|
-
|
|
35
|
-
console.error(`Available types are: ${availableTypes.join(', ')}`);
|
|
36
|
-
return { error: `Invalid type(s): ${invalidTypes.join(', ')}` };
|
|
34
|
+
return (0, utils_2.jsonAndPrintError)(`Invalid type(s) specified: ${invalidTypes.join(', ')}\nAvailable types are: ${availableTypes.join(', ')}`);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
if (!fs.existsSync(baseInputDir)) {
|
|
40
|
-
|
|
41
|
-
return;
|
|
38
|
+
return (0, utils_2.jsonAndPrintError)(`Input folder ${baseInputDir} does not exist`);
|
|
42
39
|
}
|
|
40
|
+
// Initialize result object
|
|
41
|
+
const result = { result: 'OK', items: {} };
|
|
43
42
|
var fileList = [];
|
|
44
43
|
if (inputFiles) {
|
|
45
44
|
fileList = inputFiles.split(',');
|
|
@@ -51,113 +50,137 @@ async function upsert(flags, file_subpath, file_extension, file_root_tag, file_i
|
|
|
51
50
|
}
|
|
52
51
|
for (const filename of fileList) {
|
|
53
52
|
const fullFilename = filename.endsWith(file_extension) ? filename : filename + file_extension;
|
|
54
|
-
console.log('Upserting: ' + fullFilename);
|
|
55
53
|
const fileName = (0, filesUtils_1.removeExtension)(fullFilename);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// If
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (!file_items[tag_section]) {
|
|
82
|
-
console.log(`Warning: Type '${tag_section}' not found in file items configuration`);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (ignoreUserPerm && tag_section == constants_profiles_1.PROFILE_USERPERM_ROOT) {
|
|
86
|
-
xmlFileContent[file_root_tag][tag_section] = null;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
var jsonArrayNew = fileProperties[tag_section];
|
|
90
|
-
if (jsonArrayNew == undefined)
|
|
91
|
-
continue;
|
|
92
|
-
if (!Array.isArray(jsonArrayNew))
|
|
93
|
-
jsonArrayNew = [jsonArrayNew];
|
|
94
|
-
(0, utils_1.generateTagId)(jsonArrayNew, file_items[tag_section].key, file_items[tag_section].headers);
|
|
95
|
-
const headers = file_items[tag_section].headers;
|
|
96
|
-
const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(fileName, tag_section));
|
|
97
|
-
if (!fs.existsSync(outputDir)) {
|
|
98
|
-
fs.mkdirSync(outputDir);
|
|
99
|
-
}
|
|
100
|
-
if (fs.existsSync(outputFile)) {
|
|
101
|
-
var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(outputFile);
|
|
102
|
-
var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(jsonArrayNew);
|
|
103
|
-
// If tagid is specified, only update entries with matching tagid(s)
|
|
104
|
-
if (flags.tagid) {
|
|
105
|
-
const targetTagids = flags.tagid.split(',').map(id => id.trim());
|
|
106
|
-
jsonMapNew.forEach((value, key) => {
|
|
107
|
-
if (targetTagids.includes(value._tagid)) {
|
|
108
|
-
jsonMapOld.set(key, value);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
54
|
+
console.log('Upserting: ' + fullFilename);
|
|
55
|
+
try {
|
|
56
|
+
const outputDir = (0, path_1.join)(baseOutputDir, fileName);
|
|
57
|
+
const inputFilePart = (0, path_1.join)(baseOutputDir, fileName, fileName + constants_1.XML_PART_EXTENSION);
|
|
58
|
+
// If outputDir or inputFilePart doesn't exist, run split command instead
|
|
59
|
+
if (!fs.existsSync(outputDir) || !fs.existsSync(inputFilePart)) {
|
|
60
|
+
// If we're targeting specific types or tagids, skip this file since split would create all types
|
|
61
|
+
if (flags.type || flags.tagid) {
|
|
62
|
+
console.log(`⚠️ Skipping ${fullFilename}: Output csv directory or -part.xml file not found and specific type/tagid filtering is active`);
|
|
63
|
+
result.items[fileName] = {
|
|
64
|
+
result: 'KO',
|
|
65
|
+
error: 'Output csv directory or -part.xml file not found and specific type/tagid filtering is active'
|
|
66
|
+
};
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
console.log('⚠️ Output csv directory or -part.xml file not found. Running split command for: ' + fullFilename);
|
|
70
|
+
// Create flags object with just the current file
|
|
71
|
+
const splitFlags = {
|
|
72
|
+
...flags,
|
|
73
|
+
input: fullFilename
|
|
74
|
+
};
|
|
75
|
+
const splitResult = await (0, splitter_1.split)(splitFlags, file_subpath, file_extension, file_root_tag, file_items);
|
|
76
|
+
if ('items' in splitResult && splitResult.items[fileName]) {
|
|
77
|
+
// result.items[fileName] = { result: splitResult.items[fileName].status, error: splitResult.items[fileName].error };
|
|
78
|
+
result.items[fileName] = splitResult.items[fileName];
|
|
111
79
|
}
|
|
112
80
|
else {
|
|
113
|
-
|
|
114
|
-
jsonMapOld.set(key, value);
|
|
115
|
-
});
|
|
81
|
+
result.items[fileName] = { result: 'KO', error: 'Split operation failed' };
|
|
116
82
|
}
|
|
117
|
-
|
|
83
|
+
continue;
|
|
118
84
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
85
|
+
const inputFile = (0, path_1.join)(baseInputDir, fullFilename);
|
|
86
|
+
const xmlFileContent = (await (0, filesUtils_1.readXmlFromFile)(inputFile)) ?? {};
|
|
87
|
+
const fileProperties = xmlFileContent[file_root_tag] ?? {};
|
|
88
|
+
// Determine which sections to process based on flags.type
|
|
89
|
+
const sectionsToProcess = flags.type ? flags.type.split(',') : Object.keys(file_items);
|
|
90
|
+
for (const tag_section of sectionsToProcess) {
|
|
91
|
+
// Skip if the section doesn't exist in file_items
|
|
92
|
+
if (!file_items[tag_section]) {
|
|
93
|
+
console.log(`Warning: Type '${tag_section}' not found in file items configuration`);
|
|
126
94
|
continue;
|
|
127
95
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
96
|
+
if (ignoreUserPerm && tag_section == constants_profiles_1.PROFILE_USERPERM_ROOT) {
|
|
97
|
+
xmlFileContent[file_root_tag][tag_section] = null;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
var jsonArrayNew = fileProperties[tag_section];
|
|
101
|
+
if (jsonArrayNew == undefined)
|
|
102
|
+
continue;
|
|
103
|
+
if (!Array.isArray(jsonArrayNew))
|
|
104
|
+
jsonArrayNew = [jsonArrayNew];
|
|
105
|
+
(0, utils_1.generateTagId)(jsonArrayNew, file_items[tag_section].key, file_items[tag_section].headers);
|
|
106
|
+
const headers = file_items[tag_section].headers;
|
|
107
|
+
const outputFile = (0, path_1.join)(outputDir, (0, filesUtils_1.calcCsvFilename)(fileName, tag_section));
|
|
108
|
+
if (!fs.existsSync(outputDir)) {
|
|
109
|
+
fs.mkdirSync(outputDir);
|
|
110
|
+
}
|
|
111
|
+
if (fs.existsSync(outputFile)) {
|
|
112
|
+
var jsonMapOld = await (0, filesUtils_1.readCsvToJsonMap)(outputFile);
|
|
113
|
+
var jsonMapNew = (0, filesUtils_1.jsonArrayCsvToMap)(jsonArrayNew);
|
|
114
|
+
// If tagid is specified, only update entries with matching tagid(s)
|
|
115
|
+
if (flags.tagid) {
|
|
116
|
+
const targetTagids = flags.tagid.split(',').map(id => id.trim());
|
|
117
|
+
jsonMapNew.forEach((value, key) => {
|
|
118
|
+
if (targetTagids.includes(value._tagid)) {
|
|
119
|
+
jsonMapOld.set(key, value);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
jsonMapNew.forEach((value, key) => {
|
|
125
|
+
jsonMapOld.set(key, value);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
jsonArrayNew = Array.from(jsonMapOld.values());
|
|
129
|
+
}
|
|
130
|
+
else if (flags.tagid) {
|
|
131
|
+
// If tagid is specified but no existing CSV file, filter the new array
|
|
132
|
+
const targetTagids = flags.tagid.split(',').map(id => id.trim());
|
|
133
|
+
jsonArrayNew = jsonArrayNew.filter(item => targetTagids.includes(item._tagid));
|
|
134
|
+
// If no items match the tagid(s), skip creating the file
|
|
135
|
+
if (jsonArrayNew.length === 0) {
|
|
136
|
+
console.log(`⚠️ No items found with tagid(s) '${flags.tagid}' in section '${tag_section}' for file '${fullFilename}'. Skipping CSV creation.`);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (flags.sort === 'true') {
|
|
141
|
+
jsonArrayNew = (0, utils_1.sortByKey)(jsonArrayNew);
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
const csvContent = await csvWriter.toCsv(jsonArrayNew, headers);
|
|
145
|
+
fs.writeFileSync(outputFile, csvContent, { flag: 'w+' });
|
|
146
|
+
// file written successfully
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.error(err);
|
|
150
|
+
throw new Error(`Failed to write CSV file ${outputFile}: ${err.message}`);
|
|
151
|
+
}
|
|
152
|
+
xmlFileContent[file_root_tag][tag_section] = null;
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
(
|
|
154
|
+
// Only update the -part.xml file if we're not doing targeted upsert
|
|
155
|
+
if (!flags.type && !flags.tagid) {
|
|
156
|
+
if (fs.existsSync(inputFilePart)) {
|
|
157
|
+
const xmlFileContentPart = (await (0, filesUtils_1.readXmlFromFile)(inputFilePart)) ?? {};
|
|
158
|
+
const filePropertiesPart = xmlFileContentPart[file_root_tag] ?? {};
|
|
159
|
+
for (var k in fileProperties) {
|
|
160
|
+
filePropertiesPart[k] = fileProperties[k];
|
|
161
|
+
}
|
|
162
|
+
xmlFileContentPart[file_root_tag] = filePropertiesPart;
|
|
163
|
+
xmlFileContentPart[file_root_tag] = (0, utils_3.sortObjectKeys)(xmlFileContentPart[file_root_tag]);
|
|
164
|
+
(0, filesUtils_1.writeXmlToFile)(inputFilePart, xmlFileContentPart);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
fileProperties[file_root_tag] = (0, utils_3.sortObjectKeys)(fileProperties[file_root_tag]);
|
|
168
|
+
(0, filesUtils_1.writeXmlToFile)(inputFilePart, fileProperties);
|
|
169
|
+
}
|
|
157
170
|
}
|
|
171
|
+
// File processed successfully
|
|
172
|
+
result.items[fileName] = { result: 'OK' };
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
// File processing failed
|
|
176
|
+
console.error(`Error processing file ${fullFilename}:`, error);
|
|
177
|
+
result[fileName] = {
|
|
178
|
+
result: 'KO',
|
|
179
|
+
error: error.message || 'Unknown error occurred'
|
|
180
|
+
};
|
|
158
181
|
}
|
|
159
182
|
}
|
|
160
|
-
return
|
|
183
|
+
return result;
|
|
161
184
|
}
|
|
162
185
|
exports.upsert = upsert;
|
|
163
186
|
//# sourceMappingURL=upserter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upserter.js","sourceRoot":"","sources":["../../../src/utils/commands/upserter.ts"],"names":[],"mappings":";;;AAAA,8CAAsI;AACtI,oCAAmD;AACnD,yCAAkC;AAClC,+BAA4B;AAC5B,sDAAoG;AACpG,wEAA0F;AAC1F,oDAAgD;AAChD,4CAAqC;AACrC,mCAAyC;AACzC,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,QAAQ,GAAG,IAAA,4BAAY,GAAE,CAAC;AAEzB,KAAK,UAAU,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU;IACvF,MAAM,SAAS,GAAG,IAAI,mBAAS,EAAE,CAAC;IAElC,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,qBAAqB,CAAC,IAAI,8BAAkB,CAAC,EAAE,YAAY,CAAW,CAAC;IAC9H,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,sBAAsB,CAAC,IAAI,8BAAkB,CAAC,EAAE,YAAY,CAAW,CAAC;IAChI,MAAM,cAAc,GAAG,CAAC,YAAY,KAAK,qCAAgB,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,MAAM,IAAI,QAAQ,CAAC,yBAAyB,CAAC,CAAC,I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K,CAAC,CAAC;YAC/D,MAAM,CAAC,QAAQ,CAAC,GAAG;gBACf,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;aACnD,CAAC;SACL;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAjMD,wBAiMC"}
|
|
@@ -4,6 +4,10 @@ export declare function retrievePackage(orgname: any, baseDir: any, filename: an
|
|
|
4
4
|
export declare function executeCommand(flags: any, cmd: any, mdt: any): Promise<unknown>;
|
|
5
5
|
export declare function bulkExecuteCommands(flags: any, cmd: any, sequencial: any): Promise<void>;
|
|
6
6
|
export declare function getDefaultOrgName(): Promise<any>;
|
|
7
|
+
export declare function jsonAndPrintError(err: string): {
|
|
8
|
+
error: string;
|
|
9
|
+
result: string;
|
|
10
|
+
};
|
|
7
11
|
/**
|
|
8
12
|
* Sorts the keys of an object in alphabetical order.
|
|
9
13
|
* If 'fullName' key is present, it will be placed first.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortObjectKeys = exports.getDefaultOrgName = exports.bulkExecuteCommands = exports.executeCommand = exports.retrievePackage = exports.retrieveAllMetadataPackageLocal = exports.retrieveAllMetadataPackageOrg = void 0;
|
|
3
|
+
exports.sortObjectKeys = exports.jsonAndPrintError = exports.getDefaultOrgName = exports.bulkExecuteCommands = exports.executeCommand = exports.retrievePackage = exports.retrieveAllMetadataPackageLocal = exports.retrieveAllMetadataPackageOrg = void 0;
|
|
4
4
|
const child = require("child_process");
|
|
5
5
|
const util = require("util");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -139,6 +139,14 @@ async function getDefaultOrgName() {
|
|
|
139
139
|
return JSON.parse(res.stdout).result.alias;
|
|
140
140
|
}
|
|
141
141
|
exports.getDefaultOrgName = getDefaultOrgName;
|
|
142
|
+
function jsonAndPrintError(err) {
|
|
143
|
+
console.error(err);
|
|
144
|
+
return {
|
|
145
|
+
error: err || 'Unknown error',
|
|
146
|
+
result: 'ERROR'
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
exports.jsonAndPrintError = jsonAndPrintError;
|
|
142
150
|
/**
|
|
143
151
|
* Sorts the keys of an object in alphabetical order.
|
|
144
152
|
* If 'fullName' key is present, it will be placed first.
|