config-disassembler 1.0.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 +774 -0
- package/LICENSE.md +9 -0
- package/README.md +358 -0
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.min.cjs +2 -0
- package/dist/index.min.cjs.map +1 -0
- package/dist/index.min.mjs +2 -0
- package/dist/index.min.mjs.map +1 -0
- package/dist/index.min.umd.js +2 -0
- package/dist/index.min.umd.js.map +1 -0
- package/dist/index.mjs +30 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +43 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/native/darwin-arm64/index.node +0 -0
- package/dist/native/darwin-x64/index.node +0 -0
- package/dist/native/linux-arm64/index.node +0 -0
- package/dist/native/linux-ia32/index.node +0 -0
- package/dist/native/linux-x64/index.node +0 -0
- package/dist/native/win32-x64/index.node +0 -0
- package/dist/typings/index.d.ts +41 -0
- package/dist/typings/native-dir.d.ts +1 -0
- package/package.json +88 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Carvin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# config-disassembler-node
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/config-disassembler)
|
|
4
|
+
[](https://raw.githubusercontent.com/mcarvin8/config-disassembler-node/main/LICENSE.md)
|
|
5
|
+
[](https://npmjs.org/package/config-disassembler)
|
|
6
|
+
|
|
7
|
+
Node.js bindings for the Rust [`config-disassembler`](https://crates.io/crates/config-disassembler) crate.
|
|
8
|
+
|
|
9
|
+
Disassemble configuration files (XML, JSON, JSON5, JSONC, YAML, TOON, TOML, INI) into smaller, version-control–friendly pieces — and reassemble them on demand.
|
|
10
|
+
|
|
11
|
+
> **Native Rust:** All work is done in [`config-disassembler`](https://crates.io/crates/config-disassembler); this package provides Node.js bindings via [Neon](https://neon-bindings.com).
|
|
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
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Install
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install config-disassembler
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Supported formats
|
|
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
|
|
108
|
+
|
|
109
|
+
Mirrors the standalone [`xml-disassembler`](https://github.com/mcarvin8/xml-disassembler-rust) crate (now hosted as the `xml` subcommand of `config-disassembler`). The on-disk layout, defaults, and option semantics are identical.
|
|
110
|
+
|
|
111
|
+
### Disassembling XML
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { DisassembleXMLFileHandler } from "config-disassembler";
|
|
115
|
+
|
|
116
|
+
const handler = new DisassembleXMLFileHandler();
|
|
117
|
+
handler.disassemble({
|
|
118
|
+
filePath: "test/baselines/general",
|
|
119
|
+
uniqueIdElements:
|
|
120
|
+
"application,apexClass,name,externalDataSource,flow,object,apexPage,recordType,tab,field",
|
|
121
|
+
prePurge: true,
|
|
122
|
+
postPurge: true,
|
|
123
|
+
ignorePath: ".cdignore",
|
|
124
|
+
format: "json",
|
|
125
|
+
strategy: "unique-id",
|
|
126
|
+
});
|
|
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. Multi-level spec: `file_pattern:root_to_strip:unique_id_elements`. 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
|
+
Best for fine-grained diffs and version control.
|
|
148
|
+
|
|
149
|
+
#### `grouped-by-tag`
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
Best for fewer files and quick inspection.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
handler.disassemble({
|
|
157
|
+
filePath: "my.xml",
|
|
158
|
+
strategy: "grouped-by-tag",
|
|
159
|
+
format: "yaml",
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Split tags (`splitTags`)
|
|
164
|
+
|
|
165
|
+
With `strategy: "grouped-by-tag"`, you can optionally split or group specific nested tags into subdirectories instead of a single file per tag. Useful for permission sets and similar metadata: e.g. one file per `objectPermissions` under `objectPermissions/`, and `fieldPermissions` grouped by object under `fieldPermissions/`.
|
|
166
|
+
|
|
167
|
+
**Spec:** Comma-separated rules. Each rule is `tag:mode:field` or `tag:path:mode:field` (path defaults to tag). `mode` is `split` (one file per array item, filename from `field`) or `group` (group array items by `field`, one file per group).
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
handler.disassemble({
|
|
171
|
+
filePath: "fixtures/split-tags/HR_Admin.permissionset-meta.xml",
|
|
172
|
+
strategy: "grouped-by-tag",
|
|
173
|
+
splitTags: "objectPermissions:split:object,fieldPermissions:group:field",
|
|
174
|
+
format: "xml",
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Multi-level disassembly
|
|
179
|
+
|
|
180
|
+
For XML with nested repeatable blocks (e.g. `programProcesses` inside `LoyaltyProgramSetup`), you can disassemble in one call and reassemble in one call. Pass a **multi-level spec** so the tool further splits matching files and later merges them in the right order.
|
|
181
|
+
|
|
182
|
+
**Spec format:** `file_pattern:root_to_strip:unique_id_elements`
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import {
|
|
186
|
+
DisassembleXMLFileHandler,
|
|
187
|
+
ReassembleXMLFileHandler,
|
|
188
|
+
} from "config-disassembler";
|
|
189
|
+
|
|
190
|
+
const disassemble = new DisassembleXMLFileHandler();
|
|
191
|
+
disassemble.disassemble({
|
|
192
|
+
filePath: "Cloud_Kicks_Inner_Circle.loyaltyProgramSetup-meta.xml",
|
|
193
|
+
uniqueIdElements: "fullName,name,processName",
|
|
194
|
+
multiLevel: "programProcesses:programProcesses:parameterName,ruleName",
|
|
195
|
+
postPurge: true,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const reassemble = new ReassembleXMLFileHandler();
|
|
199
|
+
reassemble.reassemble({
|
|
200
|
+
filePath: "Cloud_Kicks_Inner_Circle",
|
|
201
|
+
fileExtension: "loyaltyProgramSetup-meta.xml",
|
|
202
|
+
postPurge: true,
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
**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.
|
|
209
|
+
|
|
210
|
+
### Reassembling XML
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import { ReassembleXMLFileHandler } from "config-disassembler";
|
|
214
|
+
|
|
215
|
+
const handler = new ReassembleXMLFileHandler();
|
|
216
|
+
handler.reassemble({
|
|
217
|
+
filePath: "test/baselines/general/HR_Admin",
|
|
218
|
+
fileExtension: "permissionset-meta.xml",
|
|
219
|
+
postPurge: true,
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| Option | Description |
|
|
224
|
+
| --------------- | --------------------------------------------------------------------------------- |
|
|
225
|
+
| `filePath` | Directory that contains the disassembled files (e.g. `HR_Admin/`). |
|
|
226
|
+
| `fileExtension` | Suffix for the rebuilt XML file (e.g. `permissionset-meta.xml`). Default: `.xml`. |
|
|
227
|
+
| `postPurge` | Remove disassembled files after a successful reassembly (default: `false`). |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Value-format API
|
|
232
|
+
|
|
233
|
+
Use these classes for JSON, JSON5, JSONC, YAML, TOON, TOML, and INI files. Both methods are synchronous and return the relevant output path.
|
|
234
|
+
|
|
235
|
+
### Disassembling config files
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import { DisassembleConfigFileHandler } from "config-disassembler";
|
|
239
|
+
|
|
240
|
+
const handler = new DisassembleConfigFileHandler();
|
|
241
|
+
|
|
242
|
+
// File input: writes split files into ./config/ next to config.json
|
|
243
|
+
const outDir = handler.disassemble({
|
|
244
|
+
input: "config.json",
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// Cross-format: split JSON into per-key YAML files
|
|
248
|
+
handler.disassemble({
|
|
249
|
+
input: "config.json",
|
|
250
|
+
outputFormat: "yaml",
|
|
251
|
+
outputDir: "config-split",
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Array root: name files by a field on each element
|
|
255
|
+
handler.disassemble({
|
|
256
|
+
input: "users.json",
|
|
257
|
+
uniqueId: "id",
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Directory input: walks the directory and disassembles every matching
|
|
261
|
+
// file in place, using `.cdignore` (or `ignorePath`) to filter the walk.
|
|
262
|
+
handler.disassemble({
|
|
263
|
+
input: "envs/",
|
|
264
|
+
inputFormat: "yaml",
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
| Option | Description |
|
|
269
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
270
|
+
| `input` | Path to a file or directory to disassemble. |
|
|
271
|
+
| `inputFormat` | Override input format. Defaults to detecting from the file extension (or each file's extension when `input` is a directory). |
|
|
272
|
+
| `outputFormat` | Format used for the split files. Defaults to `inputFormat`. Restricted to the input's compatible family. |
|
|
273
|
+
| `outputDir` | Directory to write split files to (single-file input only). Defaults to `<stem>` next to the input. Rejected for directory inputs. |
|
|
274
|
+
| `uniqueId` | For array roots, name files by this field on each element. Falls back to a zero-padded index when missing. |
|
|
275
|
+
| `prePurge` | Remove the output directory before writing (default: `false`). |
|
|
276
|
+
| `postPurge` | Delete the input file (or input directory, when empty after disassembly) after a successful run (default: `false`). |
|
|
277
|
+
| `ignorePath` | `.gitignore`-style ignore file for directory walks. Defaults to `.cdignore` in the input directory. |
|
|
278
|
+
|
|
279
|
+
The handler returns the path of the directory containing the split files (single-file input) or the input directory itself (directory input).
|
|
280
|
+
|
|
281
|
+
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.
|
|
282
|
+
|
|
283
|
+
### Reassembling config files
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { ReassembleConfigFileHandler } from "config-disassembler";
|
|
287
|
+
|
|
288
|
+
const handler = new ReassembleConfigFileHandler();
|
|
289
|
+
|
|
290
|
+
// Default: rebuild using the original source format from the sidecar
|
|
291
|
+
handler.reassemble({
|
|
292
|
+
inputDir: "config",
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Cross-format: rebuild a YAML-split tree as JSON
|
|
296
|
+
handler.reassemble({
|
|
297
|
+
inputDir: "config",
|
|
298
|
+
output: "config.rebuilt.json",
|
|
299
|
+
outputFormat: "json",
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
| Option | Description |
|
|
304
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
305
|
+
| `inputDir` | Directory containing the split files and `.config-disassembler.json` sidecar. |
|
|
306
|
+
| `output` | Output file path. Defaults to the original source filename recorded in the metadata, or `<dirname>.<ext>` next to it. |
|
|
307
|
+
| `outputFormat` | Format to write the rebuilt file in. Defaults to the source format recorded in the metadata. |
|
|
308
|
+
| `postPurge` | Remove the disassembled directory after a successful reassembly (default: `false`). |
|
|
309
|
+
|
|
310
|
+
### TOML and INI isolation
|
|
311
|
+
|
|
312
|
+
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.
|
|
313
|
+
|
|
314
|
+
Trying to mix formats with TOML or INI throws a clear error:
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
TOML can only be converted to and from TOML; got input=json, output=toml
|
|
318
|
+
INI can only be converted to and from INI; got input=json, output=ini
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
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.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Ignore file
|
|
326
|
+
|
|
327
|
+
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).
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
**/secret.json
|
|
331
|
+
**/generated/
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
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.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Logging
|
|
339
|
+
|
|
340
|
+
The Rust crate uses [env_logger](https://docs.rs/env_logger). Set `RUST_LOG` to control verbosity (e.g. `RUST_LOG=debug`).
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Implementation
|
|
345
|
+
|
|
346
|
+
The core logic is implemented in Rust ([config-disassembler](https://crates.io/crates/config-disassembler)) and exposed to Node.js via [Neon](https://neon-bindings.com). Building from source requires Rust and Node.js.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Use case
|
|
351
|
+
|
|
352
|
+
For a Salesforce CLI integration example using the XML API, see [sf-decomposer](https://github.com/mcarvin8/sf-decomposer).
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## License
|
|
357
|
+
|
|
358
|
+
[MIT](LICENSE.md)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
|
|
5
|
+
function resolveNativeDir(baseDir, platform, arch) {
|
|
6
|
+
const isDist = path.basename(baseDir) === "dist";
|
|
7
|
+
return isDist
|
|
8
|
+
? path.join(baseDir, "native", `${platform}-${arch}`)
|
|
9
|
+
: path.join(baseDir, "..", "dist", "native", `${platform}-${arch}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const nativeDir = resolveNativeDir(__dirname, process.platform, process.arch);
|
|
13
|
+
const nativeAddon = require(path.join(nativeDir, "index.node"));
|
|
14
|
+
class DisassembleXMLFileHandler {
|
|
15
|
+
disassemble(opts) {
|
|
16
|
+
nativeAddon.disassemble(opts);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class ReassembleXMLFileHandler {
|
|
20
|
+
reassemble(opts) {
|
|
21
|
+
nativeAddon.reassemble(opts);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class DisassembleConfigFileHandler {
|
|
25
|
+
disassemble(opts) {
|
|
26
|
+
return nativeAddon.disassembleConfig(opts);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class ReassembleConfigFileHandler {
|
|
30
|
+
reassemble(opts) {
|
|
31
|
+
return nativeAddon.reassembleConfig(opts);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.DisassembleConfigFileHandler = DisassembleConfigFileHandler;
|
|
36
|
+
exports.DisassembleXMLFileHandler = DisassembleXMLFileHandler;
|
|
37
|
+
exports.ReassembleConfigFileHandler = ReassembleConfigFileHandler;
|
|
38
|
+
exports.ReassembleXMLFileHandler = ReassembleXMLFileHandler;
|
|
39
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/native-dir.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;SAUgB,gBAAgB,CAC9B,OAAe,EACf,QAAgB,EAChB,IAAY,EAAA;IAEZ,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,MAAM;AAChD,IAAA,OAAO;AACL,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;AACpD,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,IAAI,IAAI,CAAA,CAAE,CAAC;AACvE;;AChBA,MAAM,SAAS,GAAG,gBAAgB,CAChC,SAAS,EACT,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,IAAI,CACb;AACD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;MAsBlD,yBAAyB,CAAA;AACpC,IAAA,WAAW,CAAC,IAUX,EAAA;AACC,QAAA,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B;AACD;MAOY,wBAAwB,CAAA;AACnC,IAAA,UAAU,CAAC,IAIV,EAAA;AACC,QAAA,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B;AACD;MAaY,4BAA4B,CAAA;AACvC,IAAA,WAAW,CAAC,IASX,EAAA;AACC,QAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC;IAC5C;AACD;MAQY,2BAA2B,CAAA;AACtC,IAAA,UAAU,CAAC,IAKV,EAAA;AACC,QAAA,OAAO,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC;IAC3C;AACD;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("path");const s=(a=__dirname,r=process.platform,i=process.arch,"dist"===e.basename(a)?e.join(a,"native",`${r}-${i}`):e.join(a,"..","dist","native",`${r}-${i}`));var a,r,i;const l=require(e.join(s,"index.node"));exports.DisassembleConfigFileHandler=class{disassemble(e){return l.disassembleConfig(e)}},exports.DisassembleXMLFileHandler=class{disassemble(e){l.disassemble(e)}},exports.ReassembleConfigFileHandler=class{reassemble(e){return l.reassembleConfig(e)}},exports.ReassembleXMLFileHandler=class{reassemble(e){l.reassemble(e)}};
|
|
2
|
+
//# sourceMappingURL=index.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.min.cjs","sources":["../src/index.ts","../src/native-dir.ts"],"sourcesContent":[null,null],"names":["nativeDir","baseDir","__dirname","platform","process","arch","path","basename","join","nativeAddon","require","disassemble","opts","disassembleConfig","reassemble","reassembleConfig"],"mappings":"mCAGA,MAAMA,GCQJC,EDPAC,UCQAC,EDPAC,QAAQD,SCQRE,EDPAD,QAAQC,KCSkC,SAA3BC,EAAKC,SAASN,GAEzBK,EAAKE,KAAKP,EAAS,SAAU,GAAGE,KAAYE,KAC5CC,EAAKE,KAAKP,EAAS,KAAM,OAAQ,SAAU,GAAGE,KAAYE,UAP9DJ,EACAE,EACAE,EDLF,MAAMI,EAAcC,QAAQJ,EAAKE,KAAKR,EAAW,0DAiE/C,WAAAW,CAAYC,GAUV,OAAOH,EAAYI,kBAAkBD,EACvC,2CArDA,WAAAD,CAAYC,GAWVH,EAAYE,YAAYC,EAC1B,6CAmDA,UAAAE,CAAWF,GAMT,OAAOH,EAAYM,iBAAiBH,EACtC,0CAjDA,UAAAE,CAAWF,GAKTH,EAAYK,WAAWF,EACzB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import s from"path";import{createRequire as e}from"module";import{fileURLToPath as r}from"url";const m=s.dirname(r(import.meta.url)),a=s.join(m,"native",process.platform+"-"+process.arch),o=e(import.meta.url)(s.join(a,"index.node"));class l{disassemble(s){o.disassemble(s)}}class i{reassemble(s){o.reassemble(s)}}class t{disassemble(s){return o.disassembleConfig(s)}}class n{reassemble(s){return o.reassembleConfig(s)}}export{t as DisassembleConfigFileHandler,l as DisassembleXMLFileHandler,n as ReassembleConfigFileHandler,i as ReassembleXMLFileHandler};
|
|
2
|
+
//# sourceMappingURL=index.min.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.min.mjs","sources":["../src/native-dir.ts","../src/index.ts"],"sourcesContent":[null,null],"names":["fileURLToPath","__dirname","path","dirname","url","nativeDir","join","platform","process","arch","nativeAddon","createRequire","DisassembleXMLFileHandler","disassemble","opts","ReassembleXMLFileHandler","reassemble","DisassembleConfigFileHandler","disassembleConfig","ReassembleConfigFileHandler","reassembleConfig"],"mappings":"mFAUgBA,MACd,MAKA,MAAAC,EAAOC,EAAAC,QAAAH,cAAAI,MACLC,EAAOH,EAAKI,OAAmB,iBAAeC,SAAM,IAAAC,QAAAC,MACpDC,EAAYC,kBAAAA,CAA+BT,EAAKI,KAAAD,EAAgB,eACpE,MAAAO,iBChBMF,EAAYG,YAAAC,EAKlB,EAuBE,MAAAC,EAWE,UAAAC,CAAAF,GACFJ,EAAAM,WAAAF,EACD,EAQC,MAAAG,EAKE,WAAAJ,CAAAC,GACF,OAAAJ,EAAAQ,kBAAAJ,EACD,EAcC,MAAAK,EAUE,UAAAH,CAAOF,GACT,OAAAJ,EAAAU,iBAAAN,EACD,2CAesBF,+BAAsBO,iCAAAJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("path")):"function"==typeof define&&define.amd?define(["exports","path"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).jsTemplate={},e.path)}(this,function(e,s){"use strict";const i=(a=__dirname,n=process.platform,l=process.arch,"dist"===s.basename(a)?s.join(a,"native",`${n}-${l}`):s.join(a,"..","dist","native",`${n}-${l}`));var a,n,l;const o=require(s.join(i,"index.node"));e.DisassembleConfigFileHandler=class{disassemble(e){return o.disassembleConfig(e)}},e.DisassembleXMLFileHandler=class{disassemble(e){o.disassemble(e)}},e.ReassembleConfigFileHandler=class{reassemble(e){return o.reassembleConfig(e)}},e.ReassembleXMLFileHandler=class{reassemble(e){o.reassemble(e)}}});
|
|
2
|
+
//# sourceMappingURL=index.min.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.min.umd.js","sources":["../src/index.ts","../src/native-dir.ts"],"sourcesContent":[null,null],"names":["nativeDir","baseDir","__dirname","platform","process","arch","path","basename","join","nativeAddon","require","disassemble","opts","disassembleConfig","reassemble","reassembleConfig"],"mappings":"iRAGA,MAAMA,GCQJC,EDPAC,UCQAC,EDPAC,QAAQD,SCQRE,EDPAD,QAAQC,KCSkC,SAA3BC,EAAKC,SAASN,GAEzBK,EAAKE,KAAKP,EAAS,SAAU,GAAGE,KAAYE,KAC5CC,EAAKE,KAAKP,EAAS,KAAM,OAAQ,SAAU,GAAGE,KAAYE,UAP9DJ,EACAE,EACAE,EDLF,MAAMI,EAAcC,QAAQJ,EAAKE,KAAKR,EAAW,oDAiE/C,WAAAW,CAAYC,GAUV,OAAOH,EAAYI,kBAAkBD,EACvC,qCArDA,WAAAD,CAAYC,GAWVH,EAAYE,YAAYC,EAC1B,uCAmDA,UAAAE,CAAWF,GAMT,OAAOH,EAAYM,iBAAiBH,EACtC,oCAjDA,UAAAE,CAAWF,GAKTH,EAAYK,WAAWF,EACzB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const nativeDir = path.join(__dirname, 'native', process.platform + '-' + process.arch);
|
|
7
|
+
const nativeAddon = createRequire(import.meta.url)(path.join(nativeDir, 'index.node'));
|
|
8
|
+
class DisassembleXMLFileHandler {
|
|
9
|
+
disassemble(opts) {
|
|
10
|
+
nativeAddon.disassemble(opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class ReassembleXMLFileHandler {
|
|
14
|
+
reassemble(opts) {
|
|
15
|
+
nativeAddon.reassemble(opts);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class DisassembleConfigFileHandler {
|
|
19
|
+
disassemble(opts) {
|
|
20
|
+
return nativeAddon.disassembleConfig(opts);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class ReassembleConfigFileHandler {
|
|
24
|
+
reassemble(opts) {
|
|
25
|
+
return nativeAddon.reassembleConfig(opts);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DisassembleConfigFileHandler, DisassembleXMLFileHandler, ReassembleConfigFileHandler, ReassembleXMLFileHandler };
|
|
30
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/native-dir.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;SAUgB,gBAAgB,CAC9B,OAAe,EACf,QAAgB,EAChB,IAAY,EAAA;IAEZ,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,MAAM;AAChD,IAAA,OAAO;AACL,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;AACpD,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,IAAI,IAAI,CAAA,CAAE,CAAC;AACvE;;AChBA,MAAM,SAAS,GAAG,gBAAgB,CAChC,SAAS,EACT,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,IAAI,CACb;AACD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;MAsBlD,yBAAyB,CAAA;AACpC,IAAA,WAAW,CAAC,IAUX,EAAA;AACC,QAAA,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B;AACD;MAOY,wBAAwB,CAAA;AACnC,IAAA,UAAU,CAAC,IAIV,EAAA;AACC,QAAA,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B;AACD;MAaY,4BAA4B,CAAA;AACvC,IAAA,WAAW,CAAC,IASX,EAAA;AACC,QAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC;IAC5C;AACD;MAQY,2BAA2B,CAAA;AACtC,IAAA,UAAU,CAAC,IAKV,EAAA;AACC,QAAA,OAAO,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC;IAC3C;AACD;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'path'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jsTemplate = {}, global.path));
|
|
5
|
+
})(this, (function (exports, path) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function resolveNativeDir(baseDir, platform, arch) {
|
|
8
|
+
const isDist = path.basename(baseDir) === "dist";
|
|
9
|
+
return isDist
|
|
10
|
+
? path.join(baseDir, "native", `${platform}-${arch}`)
|
|
11
|
+
: path.join(baseDir, "..", "dist", "native", `${platform}-${arch}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const nativeDir = resolveNativeDir(__dirname, process.platform, process.arch);
|
|
15
|
+
const nativeAddon = require(path.join(nativeDir, "index.node"));
|
|
16
|
+
class DisassembleXMLFileHandler {
|
|
17
|
+
disassemble(opts) {
|
|
18
|
+
nativeAddon.disassemble(opts);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class ReassembleXMLFileHandler {
|
|
22
|
+
reassemble(opts) {
|
|
23
|
+
nativeAddon.reassemble(opts);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class DisassembleConfigFileHandler {
|
|
27
|
+
disassemble(opts) {
|
|
28
|
+
return nativeAddon.disassembleConfig(opts);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class ReassembleConfigFileHandler {
|
|
32
|
+
reassemble(opts) {
|
|
33
|
+
return nativeAddon.reassembleConfig(opts);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.DisassembleConfigFileHandler = DisassembleConfigFileHandler;
|
|
38
|
+
exports.DisassembleXMLFileHandler = DisassembleXMLFileHandler;
|
|
39
|
+
exports.ReassembleConfigFileHandler = ReassembleConfigFileHandler;
|
|
40
|
+
exports.ReassembleXMLFileHandler = ReassembleXMLFileHandler;
|
|
41
|
+
|
|
42
|
+
}));
|
|
43
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/native-dir.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;;aAUgB,gBAAgB,CAC9B,OAAe,EACf,QAAgB,EAChB,IAAY,EAAA;QAEZ,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,MAAM;IAChD,IAAA,OAAO;IACL,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,IAAI,EAAE;IACpD,UAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA,EAAG,QAAQ,IAAI,IAAI,CAAA,CAAE,CAAC;IACvE;;IChBA,MAAM,SAAS,GAAG,gBAAgB,CAChC,SAAS,EACT,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,IAAI,CACb;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;UAsBlD,yBAAyB,CAAA;IACpC,IAAA,WAAW,CAAC,IAUX,EAAA;IACC,QAAA,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC;QAC/B;IACD;UAOY,wBAAwB,CAAA;IACnC,IAAA,UAAU,CAAC,IAIV,EAAA;IACC,QAAA,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;QAC9B;IACD;UAaY,4BAA4B,CAAA;IACvC,IAAA,WAAW,CAAC,IASX,EAAA;IACC,QAAA,OAAO,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAC5C;IACD;UAQY,2BAA2B,CAAA;IACtC,IAAA,UAAU,CAAC,IAKV,EAAA;IACC,QAAA,OAAO,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC3C;IACD;;;;;;;;;;;"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type ConfigFormat = "json" | "json5" | "jsonc" | "yaml" | "toon" | "toml" | "ini";
|
|
2
|
+
export declare class DisassembleXMLFileHandler {
|
|
3
|
+
disassemble(opts: {
|
|
4
|
+
filePath: string;
|
|
5
|
+
uniqueIdElements?: string;
|
|
6
|
+
strategy?: string;
|
|
7
|
+
prePurge?: boolean;
|
|
8
|
+
postPurge?: boolean;
|
|
9
|
+
ignorePath?: string;
|
|
10
|
+
format?: string;
|
|
11
|
+
multiLevel?: string;
|
|
12
|
+
splitTags?: string;
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ReassembleXMLFileHandler {
|
|
16
|
+
reassemble(opts: {
|
|
17
|
+
filePath: string;
|
|
18
|
+
fileExtension?: string;
|
|
19
|
+
postPurge?: boolean;
|
|
20
|
+
}): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class DisassembleConfigFileHandler {
|
|
23
|
+
disassemble(opts: {
|
|
24
|
+
input: string;
|
|
25
|
+
inputFormat?: ConfigFormat;
|
|
26
|
+
outputFormat?: ConfigFormat;
|
|
27
|
+
outputDir?: string;
|
|
28
|
+
uniqueId?: string;
|
|
29
|
+
prePurge?: boolean;
|
|
30
|
+
postPurge?: boolean;
|
|
31
|
+
ignorePath?: string;
|
|
32
|
+
}): string;
|
|
33
|
+
}
|
|
34
|
+
export declare class ReassembleConfigFileHandler {
|
|
35
|
+
reassemble(opts: {
|
|
36
|
+
inputDir: string;
|
|
37
|
+
output?: string;
|
|
38
|
+
outputFormat?: ConfigFormat;
|
|
39
|
+
postPurge?: boolean;
|
|
40
|
+
}): string;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveNativeDir(baseDir: string, platform: string, arch: string): string;
|