xml-disassembler 1.10.7 → 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 CHANGED
@@ -5,6 +5,13 @@
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
+
8
15
  ## [1.10.7](https://github.com/mcarvin8/xml-disassembler/compare/v1.10.6...v1.10.7) (2025-05-14)
9
16
 
10
17
 
package/README.md CHANGED
@@ -2,22 +2,23 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/xml-disassembler.svg?label=xml-disassembler)](https://www.npmjs.com/package/xml-disassembler) [![Downloads/week](https://img.shields.io/npm/dw/xml-disassembler.svg)](https://npmjs.org/package/xml-disassembler)
4
4
 
5
- Disassemble XML files into smaller, more manageable files (XML/INI/JSON/JSON5/TOML/YAML) and reassemble the XML when needed.
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
- This tool simplifies version control, improves diff readability, and streamlines collaboration when dealing with large XML files.
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
- ## 🚀 Features
11
+ ## Features
12
12
 
13
- - **Disassemble XML Files** – Break down XML files into structured directories.
14
- - **Reassemble XML Files** – Recreate the original XML structure from disassembled parts.
15
- > **NOTE**: The `xml-disassembler` aims to reassemble the original XML 100% element-wise, however, the element sorting will vary. The reassembler will sort elements based on how they are sorted in the disassembled directories. "toml" format sorting varies compared to the other formats.
16
- - **Multiple Disassembly Strategies** – Provides 2 strategies to disassemble an XML file.
17
- - **Ignore Files** – Specify XML files to exclude from disassembly.
18
- - **Logging** – Enable detailed debugging logs.
19
- - **Integrations** – Works with tools like Salesforce CLI
20
- - **Multiple Formats** - The disassembled file format can be XML, INI, JSON, JSON5, TOML, or YAML based on preference. The reassembler will reassemble the original XML structure from these formats.
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
- Large XML files, especially those generated by external tools, can be challenging to review and manage.
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 filesespecially those generated by toolscan be painful. `xml-disassembler` solves this by splitting them into digestible pieces, optimized for Git diffs and team workflows.
45
47
 
46
- Instead of relying on complex XML diff algorithms, `xml-disassembler` provides a simple and accessible solution by splitting XML files into structured directories.
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
- ## Disassembling Files
60
+ ---
57
61
 
58
- Disassemble a single XML file or multiple XML files within a directory into smaller files (XML/INI/JSON/JSON5/TOML/YAML).
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
- ## Disassembly Strategies
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
- `xml-disassembler` supports two disassembly strategies to suit different use cases for nested elements. You can choose a strategy by setting the strategy option when calling disassemble().
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
- Disassembles each nested element into its own file under sub-directories.
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 maximum diff granularity and precision in version control.
100
+ > Best for detailed diffs and granular version control.
105
101
 
106
- **Disassembled Directory Samples for Unique IDs**
102
+ **Example Outputs**
107
103
 
108
- | Format | Sample Directory - UIDs | Sample Directory - SHA-256 Hashes |
104
+ | Format | UID Example | Hash Example |
109
105
  | --------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
110
106
  | **XML** | ![XML UID](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled.png)<br> | ![XML Hash](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-hashes.png)<br> |
111
107
  | **YAML** | ![YAML UID](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-yaml.png)<br> | ![YAML Hash](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-hashes-yaml.png)<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 name into a single file (e.g., all `<fieldPermissions>` into `fieldPermissions.xml`).
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
- Leaf elements remain grouped in a file named after the original XML.
117
+ > Best for fewer files and easier manual inspection.
122
118
 
123
- Useful for simplifying diff views and reducing file count in large projects.
119
+ **Example Outputs**
124
120
 
125
- **Disassembled Directory Samples for Grouped by Tag**
126
-
127
- | Format | Sample Directory |
121
+ | Format | Grouped by Tag Example |
128
122
  | --------- | ----------------------------------------------------------------------------------------------------------------------------- |
129
123
  | **XML** | ![XML tag](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-tags.png)<br> |
130
124
  | **YAML** | ![YAML tag](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-tags-yaml.png)<br> |
@@ -133,18 +127,11 @@ Useful for simplifying diff views and reducing file count in large projects.
133
127
  | **TOML** | ![TOML tag](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-tags-toml.png)<br> |
134
128
  | **INI** | ![INI tag](https://raw.githubusercontent.com/mcarvin8/xml-disassembler/main/.github/images/disassembled-tags-ini.png)<br> |
135
129
 
136
- ## Reassembling Files
130
+ ---
137
131
 
138
- Reassemble a directory of disassembled files (XML/INI/JSON/JSON5/TOML/YAML) into a single XML file.
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
- - uses [`node-ignore`](https://github.com/kaelzhang/node-ignore) (follows [.gitignore spec 2.22.1](https://git-scm.com/docs/gitignore))
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
- ## Logging
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
- Enable debug logs using the `setLogLevel` function:
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).