xml-disassembler 1.2.9 → 1.3.0
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/.xmldisassemblerignore +1 -0
- package/CHANGELOG.md +12 -0
- package/README.md +17 -13
- package/disassemble.log +95 -93
- package/dist/index.cjs +68 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.min.umd.js +1 -1
- package/dist/index.min.umd.js.map +1 -1
- package/dist/index.mjs +69 -45
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +71 -48
- package/dist/index.umd.js.map +1 -1
- package/dist/typings/helpers/types.d.ts +1 -1
- package/dist/typings/service/buildDisassembledFiles.d.ts +1 -1
- package/dist/typings/service/buildLeafFile.d.ts +1 -1
- package/dist/typings/service/buildNestedFiles.d.ts +1 -1
- package/dist/typings/service/buildReassembledFiles.d.ts +1 -1
- package/dist/typings/service/disassembleXMLFileHandler.d.ts +5 -2
- package/dist/typings/service/reassembleXMLFileHandler.d.ts +1 -1
- package/package.json +2 -1
- package/CONTRIBUTING.md +0 -48
|
@@ -0,0 +1 @@
|
|
|
1
|
+
**/ignore/*
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/mcarvin8/xml-disassembler/compare/v1.2.10...v1.3.0) (2024-05-22)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- add support for an ignore file during disassembly ([553a90a](https://github.com/mcarvin8/xml-disassembler/commit/553a90a2a6b5a712aa61c795489f286e9e3ef16a))
|
|
6
|
+
|
|
7
|
+
## [1.2.10](https://github.com/mcarvin8/xml-disassembler/compare/v1.2.9...v1.2.10) (2024-04-24)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- remove extra space in leaf file, normalize variable names, change `xmlPath` to `filePath` in classes ([61a204c](https://github.com/mcarvin8/xml-disassembler/commit/61a204cac95a831e6543f54acb70451c07b824a6))
|
|
12
|
+
|
|
1
13
|
## [1.2.9](https://github.com/mcarvin8/xml-disassembler/compare/v1.2.8...v1.2.9) (2024-04-24)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ Import the `DisassembleXMLFileHandler` class from the package.
|
|
|
100
100
|
```typescript
|
|
101
101
|
/*
|
|
102
102
|
FLAGS
|
|
103
|
-
-
|
|
103
|
+
- filePath: Path to 1 XML file or a directory of XML files to disassemble. If the path provided is a directory, only the files in the immediate directory will be disassembled.
|
|
104
104
|
- uniqueIdElements: (Optional) Comma-separated list of unique and required ID elements used to name disassembled files for nested elements.
|
|
105
105
|
Defaults to SHA-256 hash if unique ID elements are undefined or not found.
|
|
106
106
|
- prePurge: (Optional) Boolean value. If set to true, purge pre-existing disassembled directories prior to disassembling the file.
|
|
@@ -112,7 +112,7 @@ import { DisassembleXMLFileHandler } from "xml-disassembler";
|
|
|
112
112
|
|
|
113
113
|
const handler = new DisassembleXMLFileHandler();
|
|
114
114
|
await handler.disassemble({
|
|
115
|
-
|
|
115
|
+
filePath: "test/baselines/general",
|
|
116
116
|
uniqueIdElements:
|
|
117
117
|
"application,apexClass,name,externalDataSource,flow,object,apexPage,recordType,tab,field",
|
|
118
118
|
prePurge: true,
|
|
@@ -122,25 +122,25 @@ await handler.disassemble({
|
|
|
122
122
|
|
|
123
123
|
## Reassembling Files
|
|
124
124
|
|
|
125
|
-
Reassemble 1 XML directory (`
|
|
125
|
+
Reassemble 1 XML directory (`filePath`) containing disassembled files back into 1 XML file.
|
|
126
126
|
|
|
127
|
-
**NOTE**: You should be reassembling files created by this package's `DisassembleXMLFileHandler` class for intended results. This class will assume all disassembled files in `
|
|
127
|
+
**NOTE**: You should be reassembling files created by this package's `DisassembleXMLFileHandler` class for intended results. This class will assume all disassembled files in `filePath` have the same XML Root Element. The reassembled XML file will be created in the parent directory of `filePath` and will overwrite the original file used to create the original disassembled directories, if it still exists and the `fileExtension` flag matches the original file extension.
|
|
128
128
|
|
|
129
129
|
Import the `ReassembleXMLFileHandler` class from the package.
|
|
130
130
|
|
|
131
131
|
```typescript
|
|
132
132
|
/*
|
|
133
133
|
FLAGS
|
|
134
|
-
-
|
|
134
|
+
- filePath: Path to the disassembled XML files to reassemble (must be a directory)
|
|
135
135
|
- fileExtension: (Optional) Desired file extension for the final XML (default: `.xml`)
|
|
136
|
-
- postPurge: (Optional) Boolean value. If set to true, purge the disassembled file directory (
|
|
136
|
+
- postPurge: (Optional) Boolean value. If set to true, purge the disassembled file directory (filePath) after reassembly.
|
|
137
137
|
Defaults to false.
|
|
138
138
|
*/
|
|
139
139
|
import { ReassembleXMLFileHandler } from "xml-disassembler";
|
|
140
140
|
|
|
141
141
|
const handler = new ReassembleXMLFileHandler();
|
|
142
142
|
await handler.reassemble({
|
|
143
|
-
|
|
143
|
+
filePath: "test/baselines/general/HR_Admin",
|
|
144
144
|
fileExtension: "permissionset-meta.xml",
|
|
145
145
|
postPurge: true,
|
|
146
146
|
});
|
|
@@ -153,6 +153,14 @@ Refer to the Salesforce plugin, [SFDX Decomposer](https://github.com/mcarvin8/sf
|
|
|
153
153
|
- [Disassemble Use Case](https://github.com/mcarvin8/sfdx-decomposer-plugin/blob/main/src/service/decomposeFileHandler.ts)
|
|
154
154
|
- [Reassemble Use Case](https://github.com/mcarvin8/sfdx-decomposer-plugin/blob/main/src/service/recomposeFileHandler.ts)
|
|
155
155
|
|
|
156
|
+
## Ignore File
|
|
157
|
+
|
|
158
|
+
If you wish, you can create an ignore file named `.xmldisassemblerignore` to have the disassembler ignore specific XMLs similar to a `.gitignore` file.
|
|
159
|
+
|
|
160
|
+
The disassembler uses the [node-ignore](https://github.com/kaelzhang/node-ignore) package to parse ignore files that follow [.gitignore spec 2.22.1](https://git-scm.com/docs/gitignore).
|
|
161
|
+
|
|
162
|
+
Ensure your `.xmldisassemblerignore` exists in the same directory you are running the disassembler in. If you are using this package in a git repository, this ignore file should be in the root folder of the repository preferably.
|
|
163
|
+
|
|
156
164
|
## XML Parser
|
|
157
165
|
|
|
158
166
|
The XML parser, which uses the `fast-xml-parser` package, is configured to retain any Character Data (CDATA) values (`<![CDATA[some stuff]]>`) and comments (`<translation><!-- Four --></translation>`) in the original XML file.
|
|
@@ -204,7 +212,7 @@ if (debug) {
|
|
|
204
212
|
|
|
205
213
|
const disassembleHandler = new DisassembleXMLFileHandler();
|
|
206
214
|
await disassembleHandler.disassemble({
|
|
207
|
-
|
|
215
|
+
filePath: "test/baselines/general",
|
|
208
216
|
uniqueIdElements:
|
|
209
217
|
"application,apexClass,name,externalDataSource,flow,object,apexPage,recordType,tab,field",
|
|
210
218
|
prePurge: true,
|
|
@@ -213,7 +221,7 @@ await disassembleHandler.disassemble({
|
|
|
213
221
|
|
|
214
222
|
const reassembleHandler = new ReassembleXMLFileHandler();
|
|
215
223
|
await reassembleHandler.reassemble({
|
|
216
|
-
|
|
224
|
+
filePath: "test/baselines/general/HR_Admin",
|
|
217
225
|
fileExtension: "permissionset-meta.xml",
|
|
218
226
|
});
|
|
219
227
|
```
|
|
@@ -223,7 +231,3 @@ await reassembleHandler.reassemble({
|
|
|
223
231
|
This project was created from a template provided by [Allan Oricil](https://github.com/AllanOricil). Thank you Allan!
|
|
224
232
|
|
|
225
233
|
His original [license](https://github.com/AllanOricil/js-template/blob/main/LICENSE) remains in this project.
|
|
226
|
-
|
|
227
|
-
## Contributing
|
|
228
|
-
|
|
229
|
-
Any contributions you would like to make are appreciated. Please see [CONTRIBUTING](https://github.com/mcarvin8/xml-disassembler/blob/main/CONTRIBUTING.md).
|
package/disassemble.log
CHANGED
|
@@ -1,93 +1,95 @@
|
|
|
1
|
-
[2024-
|
|
2
|
-
[2024-
|
|
3
|
-
[2024-
|
|
4
|
-
[2024-
|
|
5
|
-
[2024-
|
|
6
|
-
[2024-
|
|
7
|
-
[2024-
|
|
8
|
-
[2024-
|
|
9
|
-
[2024-
|
|
10
|
-
[2024-
|
|
11
|
-
[2024-
|
|
12
|
-
[2024-
|
|
13
|
-
[2024-
|
|
14
|
-
[2024-
|
|
15
|
-
[2024-
|
|
16
|
-
[2024-
|
|
17
|
-
[2024-
|
|
18
|
-
[2024-
|
|
19
|
-
[2024-
|
|
20
|
-
[2024-
|
|
21
|
-
[2024-
|
|
22
|
-
[2024-
|
|
23
|
-
[2024-
|
|
24
|
-
[2024-
|
|
25
|
-
[2024-
|
|
26
|
-
[2024-
|
|
27
|
-
[2024-
|
|
28
|
-
[2024-
|
|
29
|
-
[2024-
|
|
30
|
-
[2024-
|
|
31
|
-
[2024-
|
|
32
|
-
[2024-
|
|
33
|
-
[2024-
|
|
34
|
-
[2024-
|
|
35
|
-
[2024-
|
|
36
|
-
[2024-
|
|
37
|
-
[2024-
|
|
38
|
-
[2024-
|
|
39
|
-
[2024-
|
|
40
|
-
[2024-
|
|
41
|
-
[2024-
|
|
42
|
-
[2024-
|
|
43
|
-
[2024-
|
|
44
|
-
[2024-
|
|
45
|
-
[2024-
|
|
46
|
-
[2024-
|
|
47
|
-
[2024-
|
|
48
|
-
[2024-
|
|
49
|
-
[2024-
|
|
50
|
-
[2024-
|
|
51
|
-
[2024-
|
|
52
|
-
[2024-
|
|
53
|
-
[2024-
|
|
54
|
-
[2024-
|
|
55
|
-
[2024-
|
|
56
|
-
[2024-
|
|
57
|
-
[2024-
|
|
58
|
-
[2024-
|
|
59
|
-
[2024-
|
|
60
|
-
[2024-
|
|
61
|
-
[2024-
|
|
62
|
-
[2024-
|
|
63
|
-
[2024-
|
|
64
|
-
[2024-
|
|
65
|
-
[2024-
|
|
66
|
-
[2024-
|
|
67
|
-
[2024-
|
|
68
|
-
[2024-
|
|
69
|
-
[2024-
|
|
70
|
-
[2024-
|
|
71
|
-
[2024-
|
|
72
|
-
[2024-
|
|
73
|
-
[2024-
|
|
74
|
-
[2024-
|
|
75
|
-
[2024-
|
|
76
|
-
[2024-
|
|
77
|
-
[2024-
|
|
78
|
-
[2024-
|
|
79
|
-
[2024-
|
|
80
|
-
[2024-
|
|
81
|
-
[2024-
|
|
82
|
-
[2024-
|
|
83
|
-
[2024-
|
|
84
|
-
[2024-
|
|
85
|
-
[2024-
|
|
86
|
-
[2024-
|
|
87
|
-
[2024-
|
|
88
|
-
[2024-
|
|
89
|
-
[2024-
|
|
90
|
-
[2024-
|
|
91
|
-
[2024-
|
|
92
|
-
[2024-
|
|
93
|
-
[2024-
|
|
1
|
+
[2024-05-22T00:13:30.557] [DEBUG] default - Parsing file to disassemble: mock/general/HR_Admin.permissionset-meta.xml
|
|
2
|
+
[2024-05-22T00:13:30.566] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/applicationVisibilities/JobApps__Recruiting.applicationVisibilities-meta.xml
|
|
3
|
+
[2024-05-22T00:13:30.566] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/classAccesses/Send_Email_Confirmation.classAccesses-meta.xml
|
|
4
|
+
[2024-05-22T00:13:30.567] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/fieldPermissions/Job_Request__c.Salary__c.fieldPermissions-meta.xml
|
|
5
|
+
[2024-05-22T00:13:30.567] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/objectPermissions/Job_Request__c.objectPermissions-meta.xml
|
|
6
|
+
[2024-05-22T00:13:30.568] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/pageAccesses/Job_Request_Web_Form.pageAccesses-meta.xml
|
|
7
|
+
[2024-05-22T00:13:30.568] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/recordTypeVisibilities/Recruiting.DevManager.recordTypeVisibilities-meta.xml
|
|
8
|
+
[2024-05-22T00:13:30.569] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/tabSettings/Job_Request__c.tabSettings-meta.xml
|
|
9
|
+
[2024-05-22T00:13:30.569] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/userPermissions/APIEnabled.userPermissions-meta.xml
|
|
10
|
+
[2024-05-22T00:13:30.570] [DEBUG] default - Created disassembled file: mock/general/HR_Admin/HR_Admin.permissionset-meta.xml
|
|
11
|
+
[2024-05-22T00:13:30.573] [DEBUG] default - Parsing directory to reassemble: mock/general/HR_Admin
|
|
12
|
+
[2024-05-22T00:13:30.588] [DEBUG] default - Created reassembled file: mock/general/HR_Admin.permissionset-meta.xml
|
|
13
|
+
[2024-05-22T00:13:30.589] [DEBUG] default - Parsing file to disassemble: mock/attributes/notes.xml
|
|
14
|
+
[2024-05-22T00:13:30.590] [DEBUG] default - Created disassembled file: mock/attributes/notes/nest/103c6c8b.nest-meta.xml
|
|
15
|
+
[2024-05-22T00:13:30.591] [DEBUG] default - Created disassembled file: mock/attributes/notes/nest/f876f2be.nest-meta.xml
|
|
16
|
+
[2024-05-22T00:13:30.592] [DEBUG] default - Parsing directory to reassemble: mock/attributes/notes
|
|
17
|
+
[2024-05-22T00:13:30.593] [DEBUG] default - Created reassembled file: mock/attributes/notes.xml
|
|
18
|
+
[2024-05-22T00:13:30.594] [DEBUG] default - Parsing file to disassemble: mock/cdata/VidLand_US.marketingappextension-meta.xml
|
|
19
|
+
[2024-05-22T00:13:30.596] [DEBUG] default - Created disassembled file: mock/cdata/VidLand_US/marketingAppExtActions/register_user.marketingAppExtActions-meta.xml
|
|
20
|
+
[2024-05-22T00:13:30.596] [DEBUG] default - Created disassembled file: mock/cdata/VidLand_US/VidLand_US.marketingappextension-meta.xml
|
|
21
|
+
[2024-05-22T00:13:30.597] [DEBUG] default - Parsing directory to reassemble: mock/cdata/VidLand_US
|
|
22
|
+
[2024-05-22T00:13:30.599] [DEBUG] default - Created reassembled file: mock/cdata/VidLand_US.xml
|
|
23
|
+
[2024-05-22T00:13:30.600] [DEBUG] default - Parsing file to disassemble: mock/comments/Numbers-fr.globalValueSetTranslation-meta.xml
|
|
24
|
+
[2024-05-22T00:13:30.601] [DEBUG] default - Created disassembled file: mock/comments/Numbers-fr/valueTranslation/30e8b6d2.valueTranslation-meta.xml
|
|
25
|
+
[2024-05-22T00:13:30.601] [DEBUG] default - Created disassembled file: mock/comments/Numbers-fr/valueTranslation/d7dd1420.valueTranslation-meta.xml
|
|
26
|
+
[2024-05-22T00:13:30.602] [DEBUG] default - Created disassembled file: mock/comments/Numbers-fr/valueTranslation/d8852ede.valueTranslation-meta.xml
|
|
27
|
+
[2024-05-22T00:13:30.603] [DEBUG] default - Parsing directory to reassemble: mock/comments/Numbers-fr
|
|
28
|
+
[2024-05-22T00:13:30.604] [DEBUG] default - Created reassembled file: mock/comments/Numbers-fr.globalValueSetTranslation-meta.xml
|
|
29
|
+
[2024-05-22T00:13:30.605] [DEBUG] default - Parsing file to disassemble: mock/deeply-nested-unique-id-element/Get_Info.flow-meta.xml
|
|
30
|
+
[2024-05-22T00:13:30.610] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/actionCalls/Get_Info.actionCalls-meta.xml
|
|
31
|
+
[2024-05-22T00:13:30.610] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/actionCalls/Post_to_Contact_s_Feed.actionCalls-meta.xml
|
|
32
|
+
[2024-05-22T00:13:30.611] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/assignments/Set_Contact_ID.assignments-meta.xml
|
|
33
|
+
[2024-05-22T00:13:30.611] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/decisions/Update_If_Existing.decisions-meta.xml
|
|
34
|
+
[2024-05-22T00:13:30.612] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/decisions/Update_or_Create.decisions-meta.xml
|
|
35
|
+
[2024-05-22T00:13:30.612] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/dynamicChoiceSets/accounts.dynamicChoiceSets-meta.xml
|
|
36
|
+
[2024-05-22T00:13:30.613] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/formulas/created_or_updated.formulas-meta.xml
|
|
37
|
+
[2024-05-22T00:13:30.613] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/processMetadataValues/BuilderType.processMetadataValues-meta.xml
|
|
38
|
+
[2024-05-22T00:13:30.614] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/processMetadataValues/CanvasMode.processMetadataValues-meta.xml
|
|
39
|
+
[2024-05-22T00:13:30.614] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/processMetadataValues/OriginBuilderType.processMetadataValues-meta.xml
|
|
40
|
+
[2024-05-22T00:13:30.615] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/recordCreates/Create_Contact.recordCreates-meta.xml
|
|
41
|
+
[2024-05-22T00:13:30.615] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/recordLookups/Find_a_Match.recordLookups-meta.xml
|
|
42
|
+
[2024-05-22T00:13:30.615] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/recordUpdates/Update_Contact.recordUpdates-meta.xml
|
|
43
|
+
[2024-05-22T00:13:30.616] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/screens/Confirm.screens-meta.xml
|
|
44
|
+
[2024-05-22T00:13:30.616] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/screens/Contact_Info.screens-meta.xml
|
|
45
|
+
[2024-05-22T00:13:30.616] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/start/Contact_Info.start-meta.xml
|
|
46
|
+
[2024-05-22T00:13:30.617] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/textTemplates/chatterMessage.textTemplates-meta.xml
|
|
47
|
+
[2024-05-22T00:13:30.617] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/variables/ComplexObjectExample.variables-meta.xml
|
|
48
|
+
[2024-05-22T00:13:30.618] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/variables/contact.variables-meta.xml
|
|
49
|
+
[2024-05-22T00:13:30.618] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/variables/existingId.variables-meta.xml
|
|
50
|
+
[2024-05-22T00:13:30.618] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/variables/updateExisting.variables-meta.xml
|
|
51
|
+
[2024-05-22T00:13:30.618] [DEBUG] default - Created disassembled file: mock/deeply-nested-unique-id-element/Get_Info/Get_Info.flow-meta.xml
|
|
52
|
+
[2024-05-22T00:13:30.619] [DEBUG] default - Parsing directory to reassemble: mock/deeply-nested-unique-id-element/Get_Info
|
|
53
|
+
[2024-05-22T00:13:30.640] [DEBUG] default - Created reassembled file: mock/deeply-nested-unique-id-element/Get_Info.flow-meta.xml
|
|
54
|
+
[2024-05-22T00:13:30.641] [DEBUG] default - Parsing file to disassemble: mock/array-of-leafs/Dreamhouse.app-meta.xml
|
|
55
|
+
[2024-05-22T00:13:30.644] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/39049d21.actionOverrides-meta.xml
|
|
56
|
+
[2024-05-22T00:13:30.644] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/735c1659.actionOverrides-meta.xml
|
|
57
|
+
[2024-05-22T00:13:30.645] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/b04e9f9b.actionOverrides-meta.xml
|
|
58
|
+
[2024-05-22T00:13:30.645] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/c8cc7a99.actionOverrides-meta.xml
|
|
59
|
+
[2024-05-22T00:13:30.645] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/brand/c9db422b.brand-meta.xml
|
|
60
|
+
[2024-05-22T00:13:30.646] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/Dreamhouse.app-meta.xml
|
|
61
|
+
[2024-05-22T00:13:30.647] [DEBUG] default - Parsing directory to reassemble: mock/array-of-leafs/Dreamhouse
|
|
62
|
+
[2024-05-22T00:13:30.651] [DEBUG] default - Created reassembled file: mock/array-of-leafs/Dreamhouse.app-meta.xml
|
|
63
|
+
[2024-05-22T00:13:30.652] [DEBUG] default - Parsing file to disassemble: mock/array-of-leafs/Dreamhouse.app-meta.xml
|
|
64
|
+
[2024-05-22T00:13:30.656] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/39049d21.actionOverrides-meta.xml
|
|
65
|
+
[2024-05-22T00:13:30.656] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/735c1659.actionOverrides-meta.xml
|
|
66
|
+
[2024-05-22T00:13:30.657] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/b04e9f9b.actionOverrides-meta.xml
|
|
67
|
+
[2024-05-22T00:13:30.657] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/actionOverrides/c8cc7a99.actionOverrides-meta.xml
|
|
68
|
+
[2024-05-22T00:13:30.657] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/brand/c9db422b.brand-meta.xml
|
|
69
|
+
[2024-05-22T00:13:30.658] [DEBUG] default - Created disassembled file: mock/array-of-leafs/Dreamhouse/Dreamhouse.app-meta.xml
|
|
70
|
+
[2024-05-22T00:13:30.659] [DEBUG] default - Parsing directory to reassemble: mock/array-of-leafs/Dreamhouse
|
|
71
|
+
[2024-05-22T00:13:30.661] [DEBUG] default - Created reassembled file: mock/array-of-leafs/Dreamhouse.app-meta.xml
|
|
72
|
+
[2024-05-22T00:13:30.663] [DEBUG] default - Parsing file to disassemble: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin.permissionset-meta.xml
|
|
73
|
+
[2024-05-22T00:13:30.664] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/applicationVisibilities/JobApps__Recruiting.applicationVisibilities-meta.xml
|
|
74
|
+
[2024-05-22T00:13:30.664] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/classAccesses/Send_Email_Confirmation.classAccesses-meta.xml
|
|
75
|
+
[2024-05-22T00:13:30.664] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/fieldPermissions/Job_Request__c.Salary__c.fieldPermissions-meta.xml
|
|
76
|
+
[2024-05-22T00:13:30.665] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/objectPermissions/Job_Request__c.objectPermissions-meta.xml
|
|
77
|
+
[2024-05-22T00:13:30.665] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/pageAccesses/Job_Request_Web_Form.pageAccesses-meta.xml
|
|
78
|
+
[2024-05-22T00:13:30.665] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/recordTypeVisibilities/Recruiting.DevManager.recordTypeVisibilities-meta.xml
|
|
79
|
+
[2024-05-22T00:13:30.666] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/tabSettings/Job_Request__c.tabSettings-meta.xml
|
|
80
|
+
[2024-05-22T00:13:30.666] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/userPermissions/APIEnabled.userPermissions-meta.xml
|
|
81
|
+
[2024-05-22T00:13:30.666] [DEBUG] default - Created disassembled file: /home/runner/work/xml-disassembler/xml-disassembler/mock/no-namespace/HR_Admin/HR_Admin.permissionset-meta.xml
|
|
82
|
+
[2024-05-22T00:13:30.667] [DEBUG] default - Parsing directory to reassemble: mock/no-namespace/HR_Admin
|
|
83
|
+
[2024-05-22T00:13:30.671] [DEBUG] default - Created reassembled file: mock/no-namespace/HR_Admin.permissionset-meta.xml
|
|
84
|
+
[2024-05-22T00:13:30.672] [ERROR] default - The file path provided is not an XML file: /home/runner/work/xml-disassembler/xml-disassembler/mock/not-an-xml.txt
|
|
85
|
+
[2024-05-22T00:13:30.672] [ERROR] default - The provided path to reassemble is not a directory: mock/no-namespace/HR_Admin/HR_Admin.permissionset-meta.xml
|
|
86
|
+
[2024-05-22T00:13:30.673] [DEBUG] default - Parsing file to disassemble: mock/no-root-element/Assessment_Bot.bot-meta.xml
|
|
87
|
+
[2024-05-22T00:13:30.674] [ERROR] default - mock/no-root-element/Assessment_Bot.bot-meta.xml was unabled to be parsed and will not be processed. Confirm formatting and try again.
|
|
88
|
+
[2024-05-22T00:13:30.674] [DEBUG] default - Parsing directory to reassemble: mock/no-root-element/Assessment_Bot
|
|
89
|
+
[2024-05-22T00:13:30.675] [ERROR] default - mock/no-root-element/Assessment_Bot/Assessment_Bot.bot-meta.xml was unabled to be parsed and will not be processed. Confirm formatting and try again.
|
|
90
|
+
[2024-05-22T00:13:30.675] [ERROR] default - mock/no-root-element/Assessment_Bot/botMlDomain/419e0199.botMlDomain-meta.xml was unabled to be parsed and will not be processed. Confirm formatting and try again.
|
|
91
|
+
[2024-05-22T00:13:30.675] [ERROR] default - No files under mock/no-root-element/Assessment_Bot were parsed successfully. A reassembled XML file was not created.
|
|
92
|
+
[2024-05-22T00:13:30.676] [DEBUG] default - Parsing file to disassemble: mock/no-nested-elements/HR_Admin.xml
|
|
93
|
+
[2024-05-22T00:13:30.676] [ERROR] default - The XML file mock/no-nested-elements/HR_Admin.xml only has leaf elements. This file will not be disassembled.
|
|
94
|
+
[2024-05-22T00:13:30.677] [WARN] default - File ignored by .xmldisassemblerignore: mock/ignore/HR_Admin.permissionset-meta.xml
|
|
95
|
+
[2024-05-22T00:13:30.678] [WARN] default - File ignored by .xmldisassemblerignore: /home/runner/work/xml-disassembler/xml-disassembler/mock/ignore/HR_Admin.permissionset-meta.xml
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var log4js = require('log4js');
|
|
|
4
4
|
var promises = require('node:fs/promises');
|
|
5
5
|
var node_path = require('node:path');
|
|
6
6
|
var node_fs = require('node:fs');
|
|
7
|
+
var ignore = require('ignore');
|
|
7
8
|
var node_crypto = require('node:crypto');
|
|
8
9
|
var fastXmlParser = require('fast-xml-parser');
|
|
9
10
|
|
|
@@ -42,7 +43,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
42
43
|
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
43
44
|
const INDENT = " ";
|
|
44
45
|
|
|
45
|
-
function buildReassembledFile(combinedXmlContents,
|
|
46
|
+
function buildReassembledFile(combinedXmlContents, reassembledPath, xmlElement, xmlRootElementHeader) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
let finalXmlContent = combinedXmlContents.join("\n");
|
|
48
49
|
finalXmlContent = finalXmlContent.replace(/<\?xml version="1.0" encoding="UTF-8"\?>/g, "");
|
|
@@ -58,8 +59,8 @@ function buildReassembledFile(combinedXmlContents, filePath, xmlElement, xmlRoot
|
|
|
58
59
|
});
|
|
59
60
|
finalXmlContent = finalXmlContent.replace(/(\n\s*){2,}/g, `\n${INDENT}`);
|
|
60
61
|
const closeTag = `</${xmlElement}>`;
|
|
61
|
-
yield promises.writeFile(
|
|
62
|
-
logger.debug(`Created reassembled file: ${
|
|
62
|
+
yield promises.writeFile(reassembledPath, `${XML_HEADER}\n${xmlRootElementHeader}${finalXmlContent}${closeTag}`);
|
|
63
|
+
logger.debug(`Created reassembled file: ${reassembledPath}`);
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -158,30 +159,30 @@ class ReassembleXMLFileHandler {
|
|
|
158
159
|
}
|
|
159
160
|
reassemble(xmlAttributes) {
|
|
160
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const {
|
|
162
|
+
const { filePath, fileExtension, postPurge = false } = xmlAttributes;
|
|
162
163
|
let combinedXmlContents = [];
|
|
163
|
-
const fileStat = yield promises.stat(
|
|
164
|
+
const fileStat = yield promises.stat(filePath);
|
|
164
165
|
if (!fileStat.isDirectory()) {
|
|
165
|
-
logger.error(`The provided
|
|
166
|
+
logger.error(`The provided path to reassemble is not a directory: ${filePath}`);
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
|
-
logger.debug(`Parsing directory to reassemble: ${
|
|
169
|
-
const [subCombinedXmlContents, rootResult] = yield this.processFilesInDirectory(
|
|
169
|
+
logger.debug(`Parsing directory to reassemble: ${filePath}`);
|
|
170
|
+
const [subCombinedXmlContents, rootResult] = yield this.processFilesInDirectory(filePath);
|
|
170
171
|
combinedXmlContents = subCombinedXmlContents;
|
|
171
|
-
const parentDirectory = node_path.dirname(
|
|
172
|
-
const subdirectoryBasename = node_path.basename(
|
|
172
|
+
const parentDirectory = node_path.dirname(filePath);
|
|
173
|
+
const subdirectoryBasename = node_path.basename(filePath);
|
|
173
174
|
const fileName = fileExtension
|
|
174
175
|
? `${subdirectoryBasename}.${fileExtension}`
|
|
175
176
|
: `${subdirectoryBasename}.xml`;
|
|
176
|
-
const
|
|
177
|
+
const outputPath = node_path.join(parentDirectory, fileName);
|
|
177
178
|
if (rootResult !== undefined) {
|
|
178
179
|
const [rootElementName, rootElementHeader] = rootResult;
|
|
179
|
-
yield buildReassembledFile(combinedXmlContents,
|
|
180
|
+
yield buildReassembledFile(combinedXmlContents, outputPath, rootElementName, rootElementHeader);
|
|
180
181
|
if (postPurge)
|
|
181
|
-
yield promises.rm(
|
|
182
|
+
yield promises.rm(filePath, { recursive: true });
|
|
182
183
|
}
|
|
183
184
|
else {
|
|
184
|
-
logger.error(`No files under ${
|
|
185
|
+
logger.error(`No files under ${filePath} were parsed successfully. A reassembled XML file was not created.`);
|
|
185
186
|
}
|
|
186
187
|
});
|
|
187
188
|
}
|
|
@@ -216,11 +217,11 @@ function getShortHash(element) {
|
|
|
216
217
|
return fullHash.slice(0, 8);
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
function buildNestedFile(element,
|
|
220
|
+
function buildNestedFile(element, disassembledPath, uniqueIdElements, rootElementName, rootElementHeader, parentKey, indent) {
|
|
220
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
222
|
let elementContent = "";
|
|
222
223
|
const fieldName = findUniqueIdElement(element, uniqueIdElements);
|
|
223
|
-
const outputDirectory = node_path.join(
|
|
224
|
+
const outputDirectory = node_path.join(disassembledPath, parentKey);
|
|
224
225
|
const outputFileName = `${fieldName}.${parentKey}-meta.xml`;
|
|
225
226
|
const outputPath = node_path.join(outputDirectory, outputFileName);
|
|
226
227
|
yield promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -239,9 +240,9 @@ function buildNestedFile(element, metadataPath, uniqueIdElements, rootElementNam
|
|
|
239
240
|
|
|
240
241
|
function processElement(params) {
|
|
241
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
const { element,
|
|
243
|
+
const { element, disassembledPath, uniqueIdElements, rootElementName, rootElementHeader, key, indent, leafContent, leafCount, hasNestedElements, } = params;
|
|
243
244
|
if (typeof element === "object") {
|
|
244
|
-
yield buildNestedFile(element,
|
|
245
|
+
yield buildNestedFile(element, disassembledPath, uniqueIdElements, rootElementName, rootElementHeader, key, indent);
|
|
245
246
|
return [leafContent, leafCount, true];
|
|
246
247
|
}
|
|
247
248
|
else {
|
|
@@ -251,21 +252,21 @@ function processElement(params) {
|
|
|
251
252
|
});
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
function buildLeafFile(leafContent,
|
|
255
|
+
function buildLeafFile(leafContent, disassembledPath, baseName, rootElementName, rootElementHeader) {
|
|
255
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
257
|
let leafFile = `${XML_HEADER}\n`;
|
|
257
258
|
leafFile += `${rootElementHeader}\n`;
|
|
258
259
|
leafFile += leafContent;
|
|
259
|
-
leafFile +=
|
|
260
|
-
const leafOutputPath = node_path.join(
|
|
260
|
+
leafFile += `</${rootElementName}>`;
|
|
261
|
+
const leafOutputPath = node_path.join(disassembledPath, `${baseName}.xml`);
|
|
261
262
|
yield promises.writeFile(leafOutputPath, leafFile);
|
|
262
263
|
logger.debug(`Created disassembled file: ${leafOutputPath}`);
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
266
|
|
|
266
|
-
function buildDisassembledFiles(
|
|
267
|
+
function buildDisassembledFiles(filePath, disassembledPath, uniqueIdElements, baseName, indent, postPurge) {
|
|
267
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
-
const parsedXml = yield parseXML(
|
|
269
|
+
const parsedXml = yield parseXML(filePath);
|
|
269
270
|
if (parsedXml === undefined)
|
|
270
271
|
return;
|
|
271
272
|
const rootElementName = Object.keys(parsedXml)[1];
|
|
@@ -279,7 +280,7 @@ function buildDisassembledFiles(xmlPath, metadataPath, uniqueIdElements, baseNam
|
|
|
279
280
|
for (const element of rootElement[key]) {
|
|
280
281
|
const [updatedLeafContent, updatedLeafCount, updatedHasNestedElements] = yield processElement({
|
|
281
282
|
element,
|
|
282
|
-
|
|
283
|
+
disassembledPath,
|
|
283
284
|
uniqueIdElements,
|
|
284
285
|
rootElementName,
|
|
285
286
|
rootElementHeader,
|
|
@@ -297,7 +298,7 @@ function buildDisassembledFiles(xmlPath, metadataPath, uniqueIdElements, baseNam
|
|
|
297
298
|
else {
|
|
298
299
|
const [updatedLeafContent, updatedLeafCount, updatedHasNestedElements] = yield processElement({
|
|
299
300
|
element: rootElement[key],
|
|
300
|
-
|
|
301
|
+
disassembledPath,
|
|
301
302
|
uniqueIdElements,
|
|
302
303
|
rootElementName,
|
|
303
304
|
rootElementHeader,
|
|
@@ -313,63 +314,86 @@ function buildDisassembledFiles(xmlPath, metadataPath, uniqueIdElements, baseNam
|
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
if (!hasNestedElements) {
|
|
316
|
-
logger.error(`The XML file ${
|
|
317
|
+
logger.error(`The XML file ${filePath} only has leaf elements. This file will not be disassembled.`);
|
|
317
318
|
return;
|
|
318
319
|
}
|
|
319
320
|
if (leafCount > 0) {
|
|
320
|
-
yield buildLeafFile(leafContent,
|
|
321
|
+
yield buildLeafFile(leafContent, disassembledPath, baseName, rootElementName, rootElementHeader);
|
|
321
322
|
}
|
|
322
323
|
if (postPurge) {
|
|
323
|
-
promises.unlink(
|
|
324
|
+
promises.unlink(filePath);
|
|
324
325
|
}
|
|
325
326
|
});
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
class DisassembleXMLFileHandler {
|
|
330
|
+
constructor() {
|
|
331
|
+
this.ign = ignore();
|
|
332
|
+
this.loadIgnoreFile();
|
|
333
|
+
}
|
|
334
|
+
loadIgnoreFile() {
|
|
335
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
336
|
+
const ignorePath = node_path.resolve(".xmldisassemblerignore");
|
|
337
|
+
if (node_fs.existsSync(ignorePath)) {
|
|
338
|
+
const content = yield promises.readFile(ignorePath);
|
|
339
|
+
this.ign.add(content.toString());
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
329
343
|
disassemble(xmlAttributes) {
|
|
330
344
|
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
-
const {
|
|
332
|
-
const fileStat = yield promises.stat(
|
|
345
|
+
const { filePath, uniqueIdElements, prePurge = false, postPurge = false, } = xmlAttributes;
|
|
346
|
+
const fileStat = yield promises.stat(filePath);
|
|
347
|
+
const relativePath = node_path.relative(process.cwd(), filePath);
|
|
333
348
|
if (fileStat.isFile()) {
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
336
|
-
logger.error(`The file path
|
|
349
|
+
const resolvedPath = node_path.resolve(filePath);
|
|
350
|
+
if (!resolvedPath.endsWith(".xml")) {
|
|
351
|
+
logger.error(`The file path provided is not an XML file: ${resolvedPath}`);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (this.ign.ignores(relativePath)) {
|
|
355
|
+
logger.warn(`File ignored by .xmldisassemblerignore: ${resolvedPath}`);
|
|
337
356
|
return;
|
|
338
357
|
}
|
|
339
|
-
const
|
|
358
|
+
const dirPath = node_path.dirname(resolvedPath);
|
|
340
359
|
yield this.processFile({
|
|
341
|
-
|
|
342
|
-
filePath,
|
|
360
|
+
dirPath,
|
|
361
|
+
filePath: resolvedPath,
|
|
343
362
|
uniqueIdElements,
|
|
344
363
|
prePurge,
|
|
345
364
|
postPurge,
|
|
346
365
|
});
|
|
347
366
|
}
|
|
348
367
|
else if (fileStat.isDirectory()) {
|
|
349
|
-
const
|
|
350
|
-
for (const
|
|
351
|
-
const
|
|
352
|
-
|
|
368
|
+
const subFiles = yield promises.readdir(filePath);
|
|
369
|
+
for (const subFile of subFiles) {
|
|
370
|
+
const subFilePath = node_path.join(filePath, subFile);
|
|
371
|
+
const relativeSubFilePath = node_path.relative(process.cwd(), subFilePath);
|
|
372
|
+
if (subFilePath.endsWith(".xml") &&
|
|
373
|
+
!this.ign.ignores(relativeSubFilePath)) {
|
|
353
374
|
yield this.processFile({
|
|
354
|
-
|
|
355
|
-
filePath,
|
|
375
|
+
dirPath: filePath,
|
|
376
|
+
filePath: subFilePath,
|
|
356
377
|
uniqueIdElements,
|
|
357
378
|
prePurge,
|
|
358
379
|
postPurge,
|
|
359
380
|
});
|
|
360
381
|
}
|
|
382
|
+
else if (this.ign.ignores(relativeSubFilePath)) {
|
|
383
|
+
logger.warn(`File ignored by .xmldisassemblerignore: ${subFilePath}`);
|
|
384
|
+
}
|
|
361
385
|
}
|
|
362
386
|
}
|
|
363
387
|
});
|
|
364
388
|
}
|
|
365
389
|
processFile(xmlAttributes) {
|
|
366
390
|
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
const {
|
|
391
|
+
const { dirPath, filePath, uniqueIdElements, prePurge, postPurge } = xmlAttributes;
|
|
368
392
|
logger.debug(`Parsing file to disassemble: ${filePath}`);
|
|
369
393
|
const fullName = node_path.basename(filePath, node_path.extname(filePath));
|
|
370
394
|
const baseName = fullName.split(".")[0];
|
|
371
395
|
let outputPath;
|
|
372
|
-
outputPath = node_path.join(
|
|
396
|
+
outputPath = node_path.join(dirPath, baseName);
|
|
373
397
|
if (prePurge && node_fs.existsSync(outputPath))
|
|
374
398
|
yield promises.rm(outputPath, { recursive: true });
|
|
375
399
|
yield buildDisassembledFiles(filePath, outputPath, uniqueIdElements, fullName, INDENT, postPurge);
|