xml-disassembler 1.10.6 → 1.10.8
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/CHANGELOG.md +14 -0
- package/README.md +64 -71
- package/disassemble.log +453 -506
- package/dist/index.cjs +130 -141
- 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 +130 -141
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +129 -141
- package/dist/index.umd.js.map +1 -1
- package/dist/typings/builders/buildLeafFile.d.ts +1 -1
- package/dist/typings/builders/mergeXmlElements.d.ts +2 -0
- package/dist/typings/builders/strategies/grouped-by-tag/buildGroupNestedFile.d.ts +1 -1
- package/dist/typings/builders/strategies/uid/buildNestedFiles.d.ts +1 -1
- package/dist/typings/constants/constants.d.ts +0 -1
- package/dist/typings/handlers/reassembleXMLFileHandler.d.ts +0 -1
- package/dist/typings/parsers/parseToXmlObject.d.ts +1 -0
- package/dist/typings/transformers/getTransformer.d.ts +2 -1
- package/dist/typings/transformers/transformers.d.ts +6 -5
- package/dist/typings/types/types.d.ts +1 -1
- package/package.json +1 -1
- package/samples/attributes/notes.xml +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## [1.10.8](https://github.com/mcarvin8/xml-disassembler/compare/v1.10.7...v1.10.8) (2025-05-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* assert non-null on root element and remove default declaration ([9bd9fbd](https://github.com/mcarvin8/xml-disassembler/commit/9bd9fbd2b4d9afa94bab3c851c9555cecaab9726))
|
|
14
|
+
|
|
15
|
+
## [1.10.7](https://github.com/mcarvin8/xml-disassembler/compare/v1.10.6...v1.10.7) (2025-05-14)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* write other formats directly without creating a temp xml ([9717caf](https://github.com/mcarvin8/xml-disassembler/commit/9717caf1db486474f8b3b0e967102798c4844536))
|
|
21
|
+
|
|
8
22
|
## [1.10.6](https://github.com/mcarvin8/xml-disassembler/compare/v1.10.5...v1.10.6) (2025-05-13)
|
|
9
23
|
|
|
10
24
|
|
package/README.md
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/xml-disassembler) [](https://npmjs.org/package/xml-disassembler)
|
|
4
4
|
|
|
5
|
-
Disassemble XML files into smaller,
|
|
5
|
+
Disassemble large XML files into smaller, modular files in formats like XML, INI, JSON, JSON5, TOML, or YAML—then reassemble them as needed.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Designed for improved version control, cleaner diffs, and easier team collaboration when dealing with complex XML structures.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Features
|
|
12
12
|
|
|
13
|
-
- **Disassemble XML Files** – Break down XML
|
|
14
|
-
- **Reassemble XML
|
|
15
|
-
|
|
16
|
-
- **
|
|
17
|
-
- **Ignore
|
|
18
|
-
- **Logging** –
|
|
19
|
-
- **
|
|
20
|
-
|
|
13
|
+
- **Disassemble XML Files** – Break down XML into smaller components.
|
|
14
|
+
- **Reassemble XML** – Rebuild the original XML from disassembled parts.
|
|
15
|
+
- **Multiple Output Formats** – Choose XML, INI, JSON, JSON5, TOML, or YAML.
|
|
16
|
+
- **Two Disassembly Strategies** – Choose between `unique-id` (default) or `grouped-by-tag`.
|
|
17
|
+
- **Ignore Rules** – Exclude files from processing using an ignore file.
|
|
18
|
+
- **Logging** – Log errors and debug information using `log4js`.
|
|
19
|
+
- **Salesforce Integration** – Supports use cases like Salesforce metadata processing.
|
|
20
|
+
|
|
21
|
+
> **Note**: Reassembly guarantees element-level fidelity, but element order may vary—especially when using TOML.
|
|
21
22
|
|
|
22
23
|
<!-- TABLE OF CONTENTS -->
|
|
23
24
|
<details>
|
|
@@ -38,12 +39,15 @@ This tool simplifies version control, improves diff readability, and streamlines
|
|
|
38
39
|
- [Template](#template)
|
|
39
40
|
</details>
|
|
40
41
|
|
|
42
|
+
---
|
|
43
|
+
|
|
41
44
|
## Background
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
`xml-disassembler` helps by breaking down these files into smaller, more digestible chunks, making it easier to track changes and collaborate.
|
|
46
|
+
Managing large XML files—especially those generated by tools—can be painful. `xml-disassembler` solves this by splitting them into digestible pieces, optimized for Git diffs and team workflows.
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
No need for complex diffing tools—just structured directories with format-flexible files.
|
|
49
|
+
|
|
50
|
+
---
|
|
47
51
|
|
|
48
52
|
## Install
|
|
49
53
|
|
|
@@ -53,25 +57,11 @@ Install the package using NPM:
|
|
|
53
57
|
npm install xml-disassembler
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
---
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
## Disassembling Files
|
|
59
63
|
|
|
60
64
|
```typescript
|
|
61
|
-
/*
|
|
62
|
-
FLAGS
|
|
63
|
-
- filePath: Relative path to the XML file or directory to disassemble.
|
|
64
|
-
- uniqueIdElements: Comma-separated list of UID elements for naming disassembled files (nested elements).
|
|
65
|
-
Defaults to SHA-256 hash if UID is undefined or not found.
|
|
66
|
-
- prePurge: Delete pre-existing disassembled files prior to disassembling the file.
|
|
67
|
-
- postPurge: Delete the XML file after disassembling it.
|
|
68
|
-
|
|
69
|
-
- ignorePath: Path to an XML disassembly ignore file.
|
|
70
|
-
- format: File format for the disassembled files ("xml", "ini", "json", "json5", "toml", "yaml")
|
|
71
|
-
Defaults to "xml" if the format isn't supported or provided.
|
|
72
|
-
- strategy: Disassemble strategy ("unique-id" or "grouped-by-tag")
|
|
73
|
-
Defaults to "unique-id" if strategy isn't supported or provided.
|
|
74
|
-
*/
|
|
75
65
|
import { DisassembleXMLFileHandler } from "xml-disassembler";
|
|
76
66
|
|
|
77
67
|
const handler = new DisassembleXMLFileHandler();
|
|
@@ -87,25 +77,31 @@ await handler.disassemble({
|
|
|
87
77
|
});
|
|
88
78
|
```
|
|
89
79
|
|
|
90
|
-
|
|
80
|
+
| Option | Description |
|
|
81
|
+
|--------------------|--------------------------------------------------------------------------|
|
|
82
|
+
| `filePath` | Path to the XML file or directory |
|
|
83
|
+
| `uniqueIdElements` | Comma-separated list of UID elements for naming nested files |
|
|
84
|
+
| `prePurge` | Delete previous disassembly output before running |
|
|
85
|
+
| `postPurge` | Delete the original XML after disassembly |
|
|
86
|
+
| `ignorePath` | Path to the ignore file |
|
|
87
|
+
| `format` | Output format: `xml`, `ini`, `json`, `json5`, `toml`, `yaml` |
|
|
88
|
+
| `strategy` | Disassembly strategy: `unique-id` or `grouped-by-tag` |
|
|
91
89
|
|
|
92
|
-
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Disassembly Strategies
|
|
93
93
|
|
|
94
94
|
### unique-id (default)
|
|
95
95
|
|
|
96
96
|
> This is the strategy all previous versions of the `xml-disassembler` follow.
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
File names are generated using one or more unique identifier elements (uniqueIdElements) or fallback to a SHA-256 hash.
|
|
101
|
-
|
|
102
|
-
Leaf elements remain grouped in a file named after the original XML.
|
|
98
|
+
Each nested element is written to a separate file based on its unique identifier—or a SHA-256 hash fallback. Leaf elements remain grouped in a file named after the original XML.
|
|
103
99
|
|
|
104
|
-
Best for
|
|
100
|
+
> Best for detailed diffs and granular version control.
|
|
105
101
|
|
|
106
|
-
**
|
|
102
|
+
**Example Outputs**
|
|
107
103
|
|
|
108
|
-
| Format |
|
|
104
|
+
| Format | UID Example | Hash Example |
|
|
109
105
|
| --------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
110
106
|
| **XML** | <br> | <br> |
|
|
111
107
|
| **YAML** | <br> | <br> |
|
|
@@ -116,15 +112,13 @@ Best for maximum diff granularity and precision in version control.
|
|
|
116
112
|
|
|
117
113
|
### grouped-by-tag
|
|
118
114
|
|
|
119
|
-
Groups all nested elements by tag
|
|
115
|
+
Groups all nested elements by tag into a single file. Leaf elements still go into a base file named after the original XML.
|
|
120
116
|
|
|
121
|
-
|
|
117
|
+
> Best for fewer files and easier manual inspection.
|
|
122
118
|
|
|
123
|
-
|
|
119
|
+
**Example Outputs**
|
|
124
120
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
| Format | Sample Directory |
|
|
121
|
+
| Format | Grouped by Tag Example |
|
|
128
122
|
| --------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
129
123
|
| **XML** | <br> |
|
|
130
124
|
| **YAML** | <br> |
|
|
@@ -133,18 +127,11 @@ Useful for simplifying diff views and reducing file count in large projects.
|
|
|
133
127
|
| **TOML** | <br> |
|
|
134
128
|
| **INI** | <br> |
|
|
135
129
|
|
|
136
|
-
|
|
130
|
+
---
|
|
137
131
|
|
|
138
|
-
|
|
132
|
+
## Reassembling Files
|
|
139
133
|
|
|
140
134
|
```typescript
|
|
141
|
-
/*
|
|
142
|
-
FLAGS
|
|
143
|
-
- filePath: Relative path to the disassembled directory to reassemble.
|
|
144
|
-
- fileExtension: File extension for the reassembled XML.
|
|
145
|
-
[default: `.xml`]
|
|
146
|
-
- postPurge: Delete the disassembled files after reassembly.
|
|
147
|
-
*/
|
|
148
135
|
import { ReassembleXMLFileHandler } from "xml-disassembler";
|
|
149
136
|
|
|
150
137
|
const handler = new ReassembleXMLFileHandler();
|
|
@@ -155,15 +142,27 @@ await handler.reassemble({
|
|
|
155
142
|
});
|
|
156
143
|
```
|
|
157
144
|
|
|
145
|
+
| Option | Description |
|
|
146
|
+
|------------------|----------------------------------------------------------|
|
|
147
|
+
| `filePath` | Directory containing disassembled files to reassemble |
|
|
148
|
+
| `fileExtension` | Extension for the output XML file (default: `.xml`) |
|
|
149
|
+
| `postPurge` | Delete disassembled files after successful reassembly |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
158
153
|
## Use Case
|
|
159
154
|
|
|
160
155
|
See [`sf-decomposer`](https://github.com/mcarvin8/sf-decomposer) for a Salesforce CLI use case.
|
|
161
156
|
|
|
157
|
+
---
|
|
158
|
+
|
|
162
159
|
## Ignore File
|
|
163
160
|
|
|
164
161
|
Create an ignore file (`.xmldisassemblerignore` by default) to exclude XMLs from disassembly.
|
|
165
162
|
|
|
166
|
-
|
|
163
|
+
> uses [`node-ignore`](https://github.com/kaelzhang/node-ignore) (follows [.gitignore spec 2.22.1](https://git-scm.com/docs/gitignore))
|
|
164
|
+
|
|
165
|
+
---
|
|
167
166
|
|
|
168
167
|
## XML Parser
|
|
169
168
|
|
|
@@ -173,32 +172,26 @@ Uses [`fast-xml-parser`](https://github.com/NaturalIntelligence/fast-xml-parser)
|
|
|
173
172
|
- Comments: `"!---"`
|
|
174
173
|
- Attributes: `"@__**"`
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
Instead of printing to the terminal, the disassembler uses [`log4js`](https://github.com/log4js-node/log4js-node) to create a logging file. Logs are stored in `disassemble.log`.
|
|
179
|
-
|
|
180
|
-
By default, only errors are logged.
|
|
175
|
+
---
|
|
181
176
|
|
|
182
|
-
|
|
183
|
-
[2024-03-30T14:28:37.950] [ERROR] default - The XML file HR_Admin.no-nested-elements.xml only has leaf elements. This file will not be disassembled.
|
|
184
|
-
```
|
|
177
|
+
## Logging
|
|
185
178
|
|
|
186
|
-
|
|
179
|
+
Logging uses [`log4js`](https://github.com/log4js-node/log4js-node). Logs are written to `disassemble.log`.
|
|
187
180
|
|
|
188
181
|
```typescript
|
|
189
|
-
import {
|
|
190
|
-
DisassembleXMLFileHandler,
|
|
191
|
-
ReassembleXMLFileHandler,
|
|
192
|
-
setLogLevel,
|
|
193
|
-
} from "xml-disassembler";
|
|
182
|
+
import { setLogLevel } from "xml-disassembler";
|
|
194
183
|
|
|
195
|
-
setLogLevel("debug");
|
|
184
|
+
setLogLevel("debug"); // Enables verbose logging
|
|
196
185
|
```
|
|
197
186
|
|
|
187
|
+
---
|
|
188
|
+
|
|
198
189
|
## Contributing
|
|
199
190
|
|
|
200
191
|
Contributions are welcome! See [Contributing](https://github.com/mcarvin8/xml-disassembler/blob/main/CONTRIBUTING.md).
|
|
201
192
|
|
|
193
|
+
---
|
|
194
|
+
|
|
202
195
|
## Template
|
|
203
196
|
|
|
204
197
|
This project was created from a template by [Allan Oricil](https://github.com/AllanOricil).
|