config-disassembler 2.1.0 → 2.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/CHANGELOG.md +14 -761
- package/README.md +81 -316
- package/index.d.ts +15 -0
- package/index.js +53 -52
- package/package.json +11 -15
package/README.md
CHANGED
|
@@ -1,81 +1,14 @@
|
|
|
1
|
-
# config-disassembler
|
|
1
|
+
# config-disassembler
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/config-disassembler)
|
|
4
4
|
[](https://raw.githubusercontent.com/mcarvin8/config-disassembler-node/main/LICENSE.md)
|
|
5
5
|
[](https://npmjs.org/package/config-disassembler)
|
|
6
6
|
|
|
7
|
-
Node.js bindings for the Rust [`config-disassembler`](https://crates.io/crates/config-disassembler) crate.
|
|
7
|
+
Node.js bindings for the Rust [`config-disassembler`](https://crates.io/crates/config-disassembler) crate via napi-rs.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Use it to disassemble large configuration files into smaller, version-control–friendly files and reassemble them later.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Table of contents
|
|
16
|
-
|
|
17
|
-
- [Quick start](#quick-start)
|
|
18
|
-
- [Install](#install)
|
|
19
|
-
- [Supported formats](#supported-formats)
|
|
20
|
-
- [XML API](#xml-api)
|
|
21
|
-
- [Disassembling XML](#disassembling-xml)
|
|
22
|
-
- [Disassembly strategies](#disassembly-strategies)
|
|
23
|
-
- [Split tags (splitTags)](#split-tags-splittags)
|
|
24
|
-
- [Multi-level disassembly](#multi-level-disassembly)
|
|
25
|
-
- [Reassembling XML](#reassembling-xml)
|
|
26
|
-
- [Value-format API (JSON / JSON5 / JSONC / YAML / TOON / TOML / INI)](#value-format-api)
|
|
27
|
-
- [Disassembling config files](#disassembling-config-files)
|
|
28
|
-
- [Reassembling config files](#reassembling-config-files)
|
|
29
|
-
- [TOML and INI isolation](#toml-and-ini-isolation)
|
|
30
|
-
- [Ignore file](#ignore-file)
|
|
31
|
-
- [Logging](#logging)
|
|
32
|
-
- [Implementation](#implementation)
|
|
33
|
-
- [Use case](#use-case)
|
|
34
|
-
- [License](#license)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Quick start
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import {
|
|
42
|
-
DisassembleXMLFileHandler,
|
|
43
|
-
ReassembleXMLFileHandler,
|
|
44
|
-
DisassembleConfigFileHandler,
|
|
45
|
-
ReassembleConfigFileHandler,
|
|
46
|
-
} from "config-disassembler";
|
|
47
|
-
|
|
48
|
-
// XML: disassemble one XML -> many small files
|
|
49
|
-
const disassembleXml = new DisassembleXMLFileHandler();
|
|
50
|
-
disassembleXml.disassemble({
|
|
51
|
-
filePath: "path/to/YourFile.permissionset-meta.xml",
|
|
52
|
-
uniqueIdElements:
|
|
53
|
-
"application,apexClass,name,flow,object,recordType,tab,field",
|
|
54
|
-
format: "json",
|
|
55
|
-
strategy: "unique-id",
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const reassembleXml = new ReassembleXMLFileHandler();
|
|
59
|
-
reassembleXml.reassemble({
|
|
60
|
-
filePath: "path/to/YourFile",
|
|
61
|
-
fileExtension: "permissionset-meta.xml",
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// JSON / YAML / TOML / INI / etc.
|
|
65
|
-
const disassembleCfg = new DisassembleConfigFileHandler();
|
|
66
|
-
const outDir = disassembleCfg.disassemble({
|
|
67
|
-
input: "config.json",
|
|
68
|
-
outputFormat: "yaml",
|
|
69
|
-
uniqueId: "id",
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const reassembleCfg = new ReassembleConfigFileHandler();
|
|
73
|
-
reassembleCfg.reassemble({
|
|
74
|
-
inputDir: outDir,
|
|
75
|
-
output: "config.rebuilt.json",
|
|
76
|
-
outputFormat: "json",
|
|
77
|
-
});
|
|
78
|
-
```
|
|
11
|
+
The Node bindings closely mirror the Rust crate APIs and behavior. For complete documentation and behavior details, see the Rust crate [documentation](https://github.com/mcarvin8/config-disassembler).
|
|
79
12
|
|
|
80
13
|
---
|
|
81
14
|
|
|
@@ -87,309 +20,141 @@ npm install config-disassembler
|
|
|
87
20
|
|
|
88
21
|
---
|
|
89
22
|
|
|
90
|
-
##
|
|
91
|
-
|
|
92
|
-
| Format | Disassemble | Reassemble | Cross-format conversions |
|
|
93
|
-
| ------ | ----------- | ---------- | --------------------------------------------------------------------------------- |
|
|
94
|
-
| XML | yes | yes | XML ↔ XML / JSON / JSON5 / YAML |
|
|
95
|
-
| JSON | yes | yes | within JSON / JSON5 / JSONC / YAML / TOON |
|
|
96
|
-
| JSON5 | yes | yes | within JSON / JSON5 / JSONC / YAML / TOON |
|
|
97
|
-
| JSONC | yes | yes | within JSON / JSON5 / JSONC / YAML / TOON (comments preserved on JSONC <-> JSONC) |
|
|
98
|
-
| YAML | yes | yes | within JSON / JSON5 / JSONC / YAML / TOON |
|
|
99
|
-
| TOON | yes | yes | within JSON / JSON5 / JSONC / YAML / TOON |
|
|
100
|
-
| TOML | yes | yes | TOML <-> TOML only |
|
|
101
|
-
| INI | yes | yes | INI <-> INI only |
|
|
102
|
-
|
|
103
|
-
See [TOML and INI isolation](#toml-and-ini-isolation) for the rationale on the same-format-only restriction.
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## XML API
|
|
23
|
+
## XML API Examples
|
|
108
24
|
|
|
109
|
-
|
|
25
|
+
> Use this to disassemble a large XML into smaller files (XML, JSON, JSON5, YAML) and reassemble the XML.
|
|
110
26
|
|
|
111
|
-
|
|
27
|
+
```ts
|
|
28
|
+
import {
|
|
29
|
+
DisassembleXMLFileHandler,
|
|
30
|
+
ReassembleXMLFileHandler,
|
|
31
|
+
parseXml,
|
|
32
|
+
} from "config-disassembler";
|
|
112
33
|
|
|
113
|
-
|
|
114
|
-
import { DisassembleXMLFileHandler } from "config-disassembler";
|
|
34
|
+
const disassemble = new DisassembleXMLFileHandler();
|
|
115
35
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
36
|
+
/* Disassemble XML Options
|
|
37
|
+
* filePath = required. Path to the XML file or directory to disassemble.
|
|
38
|
+
* strategy = optional (default: unique-id). Disassembly strategy (unique-id or grouped-by-tag).
|
|
39
|
+
* uniqueIdElements = optional for unique-id strategy. Comma-separated element names used to derive filenames for nested elements.
|
|
40
|
+
* multiLevel = optional for unique-id strategy. One or more multi-level specs: file_pattern:root_to_strip:unique_id_elements. Pass a string (single rule) or a string[] for several rules; semicolon-separated strings are also accepted.
|
|
41
|
+
* splitTags = optional for grouped-by-tag strategy. split or group nested tags.
|
|
42
|
+
* prePurge = optional (default: false). Delete any pre-existing disassembled files before disassembly.
|
|
43
|
+
* postPurge = optional (default: false). Delete the XML file after successfully disassembling it.
|
|
44
|
+
* format = optional (default: xml). Output format: xml, json, json5, yaml.
|
|
45
|
+
* ignorePath = optional (default: .cdignore). Path to a .gitignore-like file to skip files while disassembling.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
// Disassemble using unique-ID strategy
|
|
49
|
+
disassemble.disassemble({
|
|
50
|
+
filePath: "My.permissionset-meta.xml",
|
|
119
51
|
uniqueIdElements:
|
|
120
|
-
"application,apexClass,name,
|
|
52
|
+
"application,apexClass,name,flow,object,recordType,tab,field",
|
|
53
|
+
strategy: "unique-id",
|
|
54
|
+
format: "json",
|
|
121
55
|
prePurge: true,
|
|
122
56
|
postPurge: true,
|
|
123
57
|
ignorePath: ".cdignore",
|
|
124
|
-
format: "json",
|
|
125
|
-
strategy: "unique-id",
|
|
126
58
|
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
| Option | Description |
|
|
130
|
-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
131
|
-
| `filePath` | Path to the XML file or directory to disassemble. |
|
|
132
|
-
| `uniqueIdElements` | Comma-separated element names used to derive filenames for nested elements. |
|
|
133
|
-
| `multiLevel` | Optional. One or more multi-level specs: `file_pattern:root_to_strip:unique_id_elements`. Pass a `string` (single rule) or a `string[]` for several rules; semicolon-separated strings are also accepted. See [Multi-level disassembly](#multi-level-disassembly). |
|
|
134
|
-
| `splitTags` | Optional. With `strategy: "grouped-by-tag"`: split or group nested tags. See [Split tags](#split-tags-splittags). |
|
|
135
|
-
| `prePurge` | Remove existing disassembly output before running (default: `false`). |
|
|
136
|
-
| `postPurge` | Remove the source XML after disassembly (default: `false`). |
|
|
137
|
-
| `ignorePath` | Path to the ignore file (default: `.cdignore`). |
|
|
138
|
-
| `format` | Output format: `xml`, `json`, `json5`, `yaml`. |
|
|
139
|
-
| `strategy` | `unique-id` or `grouped-by-tag`. |
|
|
140
|
-
|
|
141
|
-
### Disassembly strategies
|
|
142
|
-
|
|
143
|
-
#### `unique-id` (default)
|
|
144
|
-
|
|
145
|
-
Each nested element is written to its own file, named by a unique identifier (or an 8-character SHA-256 hash if no UID is available). Leaf content stays in a file named after the original XML.
|
|
146
|
-
|
|
147
|
-
**Compound keys (`+`)** – Each comma-separated *UID candidate* in the list may be a `+`-joined compound (e.g. `actionName+pageOrSobjectType+formFactor+profile`). A compound matches only when every sub-field is present and non-empty at the same level, in which case the resolved values are joined with `__` to form the filename. Useful for metadata whose natural unique key is multi-field, like Salesforce `<profileActionOverrides>` (`actionName + pageOrSobjectType + formFactor + profile [+ recordType]`); without compounds, every sibling sharing an `actionName` would collapse to one filename. List both wide and narrow forms (e.g. `A+B+C+D, A+B+C, A`) for graceful fallback when items only carry some keys.
|
|
148
59
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
#### `grouped-by-tag`
|
|
154
|
-
|
|
155
|
-
All nested elements with the same tag go into one file per tag. Leaf content stays in the base file named after the original XML.
|
|
156
|
-
|
|
157
|
-
Best for fewer files and quick inspection.
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
handler.disassemble({
|
|
161
|
-
filePath: "my.xml",
|
|
60
|
+
// Or, disassemble using grouped-by-tag strategy
|
|
61
|
+
disassemble.disassemble({
|
|
62
|
+
filePath: "My.permissionset-meta.xml",
|
|
162
63
|
strategy: "grouped-by-tag",
|
|
163
|
-
format: "
|
|
64
|
+
format: "json",
|
|
164
65
|
});
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Split tags (`splitTags`)
|
|
168
66
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
handler.disassemble({
|
|
175
|
-
filePath: "fixtures/split-tags/HR_Admin.permissionset-meta.xml",
|
|
67
|
+
// Or, disassemble using grouped-by-tag strategy with split-tags
|
|
68
|
+
disassemble.disassemble({
|
|
69
|
+
filePath: "My.permissionset-meta.xml",
|
|
176
70
|
strategy: "grouped-by-tag",
|
|
177
71
|
splitTags: "objectPermissions:split:object,fieldPermissions:group:field",
|
|
178
|
-
format: "xml",
|
|
179
72
|
});
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Multi-level disassembly
|
|
183
73
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
**Spec format:** `file_pattern:root_to_strip:unique_id_elements`
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
import {
|
|
190
|
-
DisassembleXMLFileHandler,
|
|
191
|
-
ReassembleXMLFileHandler,
|
|
192
|
-
} from "config-disassembler";
|
|
193
|
-
|
|
194
|
-
const disassemble = new DisassembleXMLFileHandler();
|
|
74
|
+
// Or, disassemble an XML over multiple-levels with unique-id strategy
|
|
195
75
|
disassemble.disassemble({
|
|
196
76
|
filePath: "Cloud_Kicks_Inner_Circle.loyaltyProgramSetup-meta.xml",
|
|
77
|
+
strategy: "unique-id",
|
|
197
78
|
uniqueIdElements: "fullName,name,processName",
|
|
198
79
|
multiLevel: "programProcesses:programProcesses:parameterName,ruleName",
|
|
199
80
|
postPurge: true,
|
|
200
81
|
});
|
|
201
82
|
|
|
202
83
|
const reassemble = new ReassembleXMLFileHandler();
|
|
203
|
-
reassemble.reassemble({
|
|
204
|
-
filePath: "Cloud_Kicks_Inner_Circle",
|
|
205
|
-
fileExtension: "loyaltyProgramSetup-meta.xml",
|
|
206
|
-
postPurge: true,
|
|
207
|
-
});
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
A `.multi_level.json` config is written in the disassembly root so reassembly knows how to merge inner levels first, then the top level. No extra options are needed for reassembly.
|
|
211
|
-
|
|
212
|
-
**Caveat:** Multi-level reassembly removes disassembled directories after reassembling each level, even when you do not pass `postPurge`. This is required so the next level can merge the reassembled XML files.
|
|
213
|
-
|
|
214
|
-
#### Multiple multi-level rules
|
|
215
|
-
|
|
216
|
-
If a single XML file has more than one deeply-nested repeatable block, pass several specs in one `disassemble` call. Each rule is applied independently and persisted to `.multi_level.json` so reassembly replays them all in order. Use a `string[]` (preferred for clarity) or a single `;`-separated string:
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
disassemble.disassemble({
|
|
220
|
-
filePath: "MyType.bigFile-meta.xml",
|
|
221
|
-
uniqueIdElements: "fullName,name,id",
|
|
222
|
-
multiLevel: ["sectionA:sectionA:id", "sectionB:sectionB:name"],
|
|
223
|
-
postPurge: true,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
disassemble.disassemble({
|
|
227
|
-
filePath: "MyType.bigFile-meta.xml",
|
|
228
|
-
uniqueIdElements: "fullName,name,id",
|
|
229
|
-
multiLevel: "sectionA:sectionA:id;sectionB:sectionB:name",
|
|
230
|
-
postPurge: true,
|
|
231
|
-
});
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
> Sequential `disassemble` calls (one per rule, with `postPurge: false` to preserve prior output) are **not** equivalent — each call rewrites `.multi_level.json` and reorganises the on-disk wrappers, so only the last rule survives. Always pass every rule for a given file in a single call.
|
|
235
84
|
|
|
236
|
-
|
|
85
|
+
/* Reassemble XML Options
|
|
86
|
+
* filePath = required. Folder containing disassembled files to reassemble into 1 XML.
|
|
87
|
+
* fileExtension = optional (default: `.xml`). Set explicit file extension.
|
|
88
|
+
* postPurge = optional (default: false). Delete disassembled files after reassembly.
|
|
89
|
+
*/
|
|
237
90
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const handler = new ReassembleXMLFileHandler();
|
|
242
|
-
handler.reassemble({
|
|
243
|
-
filePath: "test/baselines/general/HR_Admin",
|
|
91
|
+
reassemble.reassemble({
|
|
92
|
+
filePath: "My",
|
|
244
93
|
fileExtension: "permissionset-meta.xml",
|
|
245
94
|
postPurge: true,
|
|
246
95
|
});
|
|
247
|
-
```
|
|
248
96
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
97
|
+
/* parseXml
|
|
98
|
+
* filePath = required. Path to the XML file to parse.
|
|
99
|
+
* Returns the parsed XML document as a plain JavaScript object, or null
|
|
100
|
+
* if the file cannot be read or is not valid XML.
|
|
101
|
+
*/
|
|
102
|
+
const doc = await parseXml("My.permissionset-meta.xml");
|
|
103
|
+
if (doc) {
|
|
104
|
+
console.log(doc);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
254
107
|
|
|
255
108
|
---
|
|
256
109
|
|
|
257
|
-
## Value-
|
|
110
|
+
## Value-Format API Examples
|
|
258
111
|
|
|
259
|
-
Use
|
|
112
|
+
> Use this for JSON, JSON5, JSONC, YAML, TOML, TOON, and INI configs.
|
|
260
113
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const handler = new DisassembleConfigFileHandler();
|
|
114
|
+
```ts
|
|
115
|
+
import {
|
|
116
|
+
DisassembleConfigFileHandler,
|
|
117
|
+
ReassembleConfigFileHandler,
|
|
118
|
+
} from "config-disassembler";
|
|
267
119
|
|
|
268
|
-
//
|
|
269
|
-
const
|
|
270
|
-
input: "config.json",
|
|
271
|
-
});
|
|
120
|
+
// Disassemble config
|
|
121
|
+
const disassemble = new DisassembleConfigFileHandler();
|
|
272
122
|
|
|
273
|
-
|
|
274
|
-
handler.disassemble({
|
|
123
|
+
const outputDir = disassemble.disassemble({
|
|
275
124
|
input: "config.json",
|
|
276
125
|
outputFormat: "yaml",
|
|
277
|
-
outputDir: "config-split",
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
// Array root: name files by a field on each element
|
|
281
|
-
handler.disassemble({
|
|
282
|
-
input: "users.json",
|
|
283
126
|
uniqueId: "id",
|
|
284
127
|
});
|
|
285
128
|
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
handler.disassemble({
|
|
289
|
-
input: "envs/",
|
|
290
|
-
inputFormat: "yaml",
|
|
291
|
-
});
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
| Option | Description |
|
|
295
|
-
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
296
|
-
| `input` | Path to a file or directory to disassemble. |
|
|
297
|
-
| `inputFormat` | Override input format. Defaults to detecting from the file extension (or each file's extension when `input` is a directory). |
|
|
298
|
-
| `outputFormat` | Format used for the split files. Defaults to `inputFormat`. Restricted to the input's compatible family. |
|
|
299
|
-
| `outputDir` | Directory to write split files to (single-file input only). Defaults to `<stem>` next to the input. Rejected for directory inputs. |
|
|
300
|
-
| `uniqueId` | For array roots, name files by this field on each element. Falls back to a zero-padded index when missing. |
|
|
301
|
-
| `prePurge` | Remove the output directory before writing (default: `false`). |
|
|
302
|
-
| `postPurge` | Delete the input file (or input directory, when empty after disassembly) after a successful run (default: `false`). |
|
|
303
|
-
| `ignorePath` | `.gitignore`-style ignore file for directory walks. Defaults to `.cdignore` in the input directory. |
|
|
304
|
-
|
|
305
|
-
The handler returns the path of the directory containing the split files (single-file input) or the input directory itself (directory input).
|
|
306
|
-
|
|
307
|
-
A `.config-disassembler.json` sidecar is written into the output directory recording the original key order, root type, source format, and the format the split files were written in. Reassembly uses this metadata to rebuild the original document deterministically.
|
|
308
|
-
|
|
309
|
-
### Reassembling config files
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
import { ReassembleConfigFileHandler } from "config-disassembler";
|
|
313
|
-
|
|
314
|
-
const handler = new ReassembleConfigFileHandler();
|
|
129
|
+
// Reassemble config
|
|
130
|
+
const reassemble = new ReassembleConfigFileHandler();
|
|
315
131
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
inputDir: "config",
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// Cross-format: rebuild a YAML-split tree as JSON
|
|
322
|
-
handler.reassemble({
|
|
323
|
-
inputDir: "config",
|
|
132
|
+
reassemble.reassemble({
|
|
133
|
+
inputDir: outputDir,
|
|
324
134
|
output: "config.rebuilt.json",
|
|
325
135
|
outputFormat: "json",
|
|
326
136
|
});
|
|
327
137
|
```
|
|
328
138
|
|
|
329
|
-
| Option | Description |
|
|
330
|
-
| -------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
331
|
-
| `inputDir` | Directory containing the split files and `.config-disassembler.json` sidecar. |
|
|
332
|
-
| `output` | Output file path. Defaults to the original source filename recorded in the metadata, or `<dirname>.<ext>` next to it. |
|
|
333
|
-
| `outputFormat` | Format to write the rebuilt file in. Defaults to the source format recorded in the metadata. |
|
|
334
|
-
| `postPurge` | Remove the disassembled directory after a successful reassembly (default: `false`). |
|
|
335
|
-
|
|
336
|
-
### TOML and INI isolation
|
|
337
|
-
|
|
338
|
-
TOML and INI can only be disassembled and reassembled within the same format. TOML cannot represent `null`, forbids array roots, and forces bare keys to precede tables (which would reorder values on round-trip through other formats). INI is even narrower: section values are strings (or valueless keys) and arrays / nested objects cannot be represented without inventing a custom encoding.
|
|
339
|
-
|
|
340
|
-
Trying to mix formats with TOML or INI throws a clear error:
|
|
341
|
-
|
|
342
|
-
```
|
|
343
|
-
TOML can only be converted to and from TOML; got input=json, output=toml
|
|
344
|
-
INI can only be converted to and from INI; got input=json, output=ini
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
To keep every split file valid for table-style formats, TOML and INI wrap each per-key split file under its parent key (e.g. `dependencies.toml` contains `[dependencies]` headers, `settings.ini` contains `[settings]`). Reassembly unwraps them automatically using the metadata sidecar.
|
|
348
|
-
|
|
349
139
|
---
|
|
350
140
|
|
|
351
|
-
##
|
|
352
|
-
|
|
353
|
-
Exclude files or directories from disassembly using an ignore file (default: `.cdignore` in the input directory). Syntax is the same as [`.gitignore`](https://git-scm.com/docs/gitignore).
|
|
354
|
-
|
|
355
|
-
```
|
|
356
|
-
**/secret.json
|
|
357
|
-
**/generated/
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
For backward compatibility, the XML API still falls back to `.xmldisassemblerignore` if `.cdignore` is missing — rename the file or pass `ignorePath` explicitly to silence the deprecation warning.
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
## Logging
|
|
365
|
-
|
|
366
|
-
The Rust crate uses [env_logger](https://docs.rs/env_logger). Set `RUST_LOG` to control verbosity (e.g. `RUST_LOG=debug`).
|
|
367
|
-
|
|
368
|
-
---
|
|
369
|
-
|
|
370
|
-
## Implementation
|
|
371
|
-
|
|
372
|
-
The core logic is implemented in Rust ([config-disassembler](https://crates.io/crates/config-disassembler)) and exposed to Node.js via [napi-rs](https://napi.rs). Building from source requires Rust and Node.js.
|
|
373
|
-
|
|
374
|
-
Prebuilt native binaries are published as platform-scoped optional dependencies (e.g. `config-disassembler-darwin-arm64`, `config-disassembler-linux-x64-gnu`); npm/yarn/pnpm will install only the one matching the consumer's `os`/`cpu`/`libc`.
|
|
375
|
-
|
|
376
|
-
This package ships with native binaries for these platforms and architectures:
|
|
141
|
+
## Supported Platforms
|
|
377
142
|
|
|
378
|
-
|
|
379
|
-
| ----------- | ---------------------------------------------------------- |
|
|
380
|
-
| **macOS** | x64 (Intel), arm64 (Apple Silicon) |
|
|
381
|
-
| **Linux** | x64 (gnu + musl), arm64 (gnu + musl) |
|
|
382
|
-
| **Windows** | x64, arm64, ia32 |
|
|
143
|
+
This package ships with prebuilt native binaries as platform-specific optional npm packages — your package manager installs only the one matching your `os` / `cpu` / `libc`:
|
|
383
144
|
|
|
384
|
-
|
|
145
|
+
| Platform | Architectures |
|
|
146
|
+
| ----------- | ------------------------------------ |
|
|
147
|
+
| **macOS** | x64 (Intel), arm64 (Apple Silicon) |
|
|
148
|
+
| **Linux** | x64 (gnu + musl), arm64 (gnu + musl) |
|
|
149
|
+
| **Windows** | x64, arm64, ia32 |
|
|
385
150
|
|
|
386
|
-
|
|
151
|
+
If your platform or architecture isn't listed, please open an [issue](https://github.com/mcarvin8/config-disassembler-node/issues).
|
|
387
152
|
|
|
388
153
|
---
|
|
389
154
|
|
|
390
|
-
## Use
|
|
155
|
+
## Use Case
|
|
391
156
|
|
|
392
|
-
For a
|
|
157
|
+
For a use-case using the XML API, see [sf-decomposer](https://github.com/mcarvin8/sf-decomposer).
|
|
393
158
|
|
|
394
159
|
---
|
|
395
160
|
|
package/index.d.ts
CHANGED
|
@@ -79,6 +79,21 @@ export interface DisassembleXmlOptions {
|
|
|
79
79
|
splitTags?: string
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Parse an XML file at `filePath` into a plain JavaScript object.
|
|
84
|
+
*
|
|
85
|
+
* Mirrors `config_disassembler::xml::parse_xml`. Returns the parsed
|
|
86
|
+
* document on success, or `null` when the file cannot be read or is not
|
|
87
|
+
* valid XML (the underlying Rust function logs the error via `env_logger`).
|
|
88
|
+
*
|
|
89
|
+
* ```js
|
|
90
|
+
* const { parseXml } = require('config-disassembler-node');
|
|
91
|
+
* const doc = await parseXml('path/to/file.xml');
|
|
92
|
+
* if (doc) { console.log(doc); }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function parseXml(filePath: string): any
|
|
96
|
+
|
|
82
97
|
/** Options accepted by [`ReassembleConfigFileHandler::reassemble`]. */
|
|
83
98
|
export interface ReassembleConfigOptions {
|
|
84
99
|
inputDir: string
|