@kubb/core 3.0.0-alpha.4 → 3.0.0-alpha.6
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/dist/{FileManager-CaejIVBd.d.ts → FileManager-Ceski1W9.d.ts} +47 -47
- package/dist/{FileManager--scIq4y4.d.cts → FileManager-wyXRkgIk.d.cts} +47 -47
- package/dist/chunk-2EU7DMPM.js +97 -0
- package/dist/chunk-2EU7DMPM.js.map +1 -0
- package/dist/chunk-5HN4LW3R.cjs +102 -0
- package/dist/chunk-5HN4LW3R.cjs.map +1 -0
- package/dist/{chunk-EFQPHF4E.js → chunk-76UEJFFE.js} +1 -4
- package/dist/chunk-76UEJFFE.js.map +1 -0
- package/dist/{chunk-5JZNFPUP.js → chunk-AWAZR3D5.js} +61 -10
- package/dist/chunk-AWAZR3D5.js.map +1 -0
- package/dist/{chunk-V5THHXXQ.cjs → chunk-DCZQYCCO.cjs} +218 -299
- package/dist/chunk-DCZQYCCO.cjs.map +1 -0
- package/dist/{chunk-YTSNYMHW.cjs → chunk-L3JJLZ5Q.cjs} +62 -11
- package/dist/chunk-L3JJLZ5Q.cjs.map +1 -0
- package/dist/{chunk-QRIDQ4RG.cjs → chunk-LOLEBOMW.cjs} +1 -4
- package/dist/chunk-LOLEBOMW.cjs.map +1 -0
- package/dist/chunk-RIEGCND2.js +525 -0
- package/dist/chunk-RIEGCND2.js.map +1 -0
- package/dist/index.cjs +81 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +68 -64
- package/dist/index.js.map +1 -1
- package/dist/{logger-dzAcLeAA.d.cts → logger-BWFeedRk.d.cts} +17 -2
- package/dist/{logger-dzAcLeAA.d.ts → logger-BWFeedRk.d.ts} +17 -2
- package/dist/logger.cjs +2 -2
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/mocks.cjs +4 -6
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +3 -5
- package/dist/mocks.d.ts +3 -5
- package/dist/mocks.js +5 -7
- package/dist/mocks.js.map +1 -1
- package/dist/transformers.cjs +189 -33
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.d.cts +1 -3
- package/dist/transformers.d.ts +1 -3
- package/dist/transformers.js +156 -14
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +6 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +30 -3
- package/dist/utils.d.ts +30 -3
- package/dist/utils.js +7 -3
- package/package.json +9 -8
- package/src/BarrelManager.ts +27 -93
- package/src/FileManager.ts +165 -266
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +89 -57
- package/src/build.ts +7 -26
- package/src/logger.ts +6 -7
- package/src/transformers/index.ts +2 -3
- package/src/transformers/trim.ts +0 -4
- package/src/types.ts +1 -1
- package/src/utils/TreeNode.ts +91 -26
- package/src/utils/executeStrategies.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/parser.ts +96 -0
- package/dist/chunk-5JZNFPUP.js.map +0 -1
- package/dist/chunk-EFQPHF4E.js.map +0 -1
- package/dist/chunk-JKZG2IJR.js +0 -283
- package/dist/chunk-JKZG2IJR.js.map +0 -1
- package/dist/chunk-PZT4CTBV.cjs +0 -299
- package/dist/chunk-PZT4CTBV.cjs.map +0 -1
- package/dist/chunk-QRIDQ4RG.cjs.map +0 -1
- package/dist/chunk-UUBPTMRW.js +0 -608
- package/dist/chunk-UUBPTMRW.js.map +0 -1
- package/dist/chunk-V5THHXXQ.cjs.map +0 -1
- package/dist/chunk-YTSNYMHW.cjs.map +0 -1
- package/src/utils/getParser.ts +0 -17
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFile,
|
|
3
|
+
getFileParser
|
|
4
|
+
} from "./chunk-AWAZR3D5.js";
|
|
5
|
+
import {
|
|
6
|
+
orderBy
|
|
7
|
+
} from "./chunk-4X5FFJPJ.js";
|
|
8
|
+
import {
|
|
9
|
+
__privateAdd,
|
|
10
|
+
__privateGet,
|
|
11
|
+
__privateMethod,
|
|
12
|
+
__privateSet
|
|
13
|
+
} from "./chunk-HMLY7DHA.js";
|
|
14
|
+
|
|
15
|
+
// src/FileManager.ts
|
|
16
|
+
import { extname, relative, resolve } from "path";
|
|
17
|
+
import { isDeepEqual } from "remeda";
|
|
18
|
+
import { getRelativePath, read, write } from "@kubb/fs";
|
|
19
|
+
|
|
20
|
+
// src/BarrelManager.ts
|
|
21
|
+
import path from "path";
|
|
22
|
+
|
|
23
|
+
// src/utils/TreeNode.ts
|
|
24
|
+
var TreeNode = class _TreeNode {
|
|
25
|
+
constructor(data, parent) {
|
|
26
|
+
this.children = [];
|
|
27
|
+
this.data = data;
|
|
28
|
+
this.parent = parent;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
addChild(data) {
|
|
32
|
+
const child = new _TreeNode(data, this);
|
|
33
|
+
if (!this.children) {
|
|
34
|
+
this.children = [];
|
|
35
|
+
}
|
|
36
|
+
this.children.push(child);
|
|
37
|
+
return child;
|
|
38
|
+
}
|
|
39
|
+
find(data) {
|
|
40
|
+
if (!data) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (data === this.data) {
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
if (this.children?.length) {
|
|
47
|
+
for (let i = 0, { length } = this.children, target = null; i < length; i++) {
|
|
48
|
+
target = this.children[i].find(data);
|
|
49
|
+
if (target) {
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
get leaves() {
|
|
57
|
+
if (!this.children || this.children.length === 0) {
|
|
58
|
+
return [this];
|
|
59
|
+
}
|
|
60
|
+
const leaves = [];
|
|
61
|
+
if (this.children) {
|
|
62
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
63
|
+
leaves.push.apply(leaves, this.children[i].leaves);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return leaves;
|
|
67
|
+
}
|
|
68
|
+
get root() {
|
|
69
|
+
if (!this.parent) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
return this.parent.root;
|
|
73
|
+
}
|
|
74
|
+
forEach(callback) {
|
|
75
|
+
if (typeof callback !== "function") {
|
|
76
|
+
throw new TypeError("forEach() callback must be a function");
|
|
77
|
+
}
|
|
78
|
+
callback(this);
|
|
79
|
+
if (this.children) {
|
|
80
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
81
|
+
this.children[i]?.forEach(callback);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
static build(files, root) {
|
|
87
|
+
try {
|
|
88
|
+
const filteredTree = buildDirectoryTree(files, root);
|
|
89
|
+
if (!filteredTree) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const treeNode = new _TreeNode({
|
|
93
|
+
name: filteredTree.name,
|
|
94
|
+
path: filteredTree.path,
|
|
95
|
+
file: filteredTree.file,
|
|
96
|
+
type: FileManager.getMode(filteredTree.path)
|
|
97
|
+
});
|
|
98
|
+
const recurse = (node, item) => {
|
|
99
|
+
const subNode = node.addChild({
|
|
100
|
+
name: item.name,
|
|
101
|
+
path: item.path,
|
|
102
|
+
file: item.file,
|
|
103
|
+
type: FileManager.getMode(item.path)
|
|
104
|
+
});
|
|
105
|
+
if (item.children?.length) {
|
|
106
|
+
item.children?.forEach((child) => {
|
|
107
|
+
recurse(subNode, child);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
112
|
+
return treeNode;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function buildDirectoryTree(files, rootFolder = "") {
|
|
119
|
+
const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
|
|
120
|
+
const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
|
|
121
|
+
if (filteredFiles.length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const root = {
|
|
125
|
+
name: rootFolder || "",
|
|
126
|
+
path: rootFolder || "",
|
|
127
|
+
children: []
|
|
128
|
+
};
|
|
129
|
+
filteredFiles.forEach((file) => {
|
|
130
|
+
const path2 = file.path.slice(rootFolder.length);
|
|
131
|
+
const parts = path2.split("/");
|
|
132
|
+
let currentLevel = root.children;
|
|
133
|
+
let currentPath = rootFolder;
|
|
134
|
+
parts.forEach((part, index) => {
|
|
135
|
+
if (index !== 0) {
|
|
136
|
+
currentPath += `/${part}`;
|
|
137
|
+
} else {
|
|
138
|
+
currentPath += `${part}`;
|
|
139
|
+
}
|
|
140
|
+
let existingNode = currentLevel.find((node) => node.name === part);
|
|
141
|
+
if (!existingNode) {
|
|
142
|
+
if (index === parts.length - 1) {
|
|
143
|
+
existingNode = {
|
|
144
|
+
name: part,
|
|
145
|
+
file,
|
|
146
|
+
path: currentPath
|
|
147
|
+
};
|
|
148
|
+
} else {
|
|
149
|
+
existingNode = {
|
|
150
|
+
name: part,
|
|
151
|
+
path: currentPath,
|
|
152
|
+
children: []
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
currentLevel.push(existingNode);
|
|
156
|
+
}
|
|
157
|
+
if (!existingNode.file) {
|
|
158
|
+
currentLevel = existingNode.children;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return root;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/BarrelManager.ts
|
|
166
|
+
import { trimExtName } from "@kubb/fs";
|
|
167
|
+
var _options;
|
|
168
|
+
var BarrelManager = class {
|
|
169
|
+
constructor(options = {}) {
|
|
170
|
+
__privateAdd(this, _options);
|
|
171
|
+
__privateSet(this, _options, options);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
getIndexes(generatedFiles, root) {
|
|
175
|
+
const { isTypeOnly, extName } = __privateGet(this, _options);
|
|
176
|
+
const tree = TreeNode.build(generatedFiles, root);
|
|
177
|
+
if (!tree) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
const fileReducer = (files, treeNode) => {
|
|
181
|
+
if (!treeNode.children) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
const indexPath = path.resolve(treeNode.data.path, "index.ts");
|
|
185
|
+
const exports = treeNode.children.filter((item) => !!item.data.name).map((treeNode2) => {
|
|
186
|
+
const importPath = treeNode2.data.file ? `./${trimExtName(treeNode2.data.name)}` : `./${treeNode2.data.name}/index`;
|
|
187
|
+
if (importPath.endsWith("index") && treeNode2.data.file) {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
path: extName ? `${importPath}${extName}` : importPath,
|
|
192
|
+
isTypeOnly
|
|
193
|
+
};
|
|
194
|
+
}).filter(Boolean);
|
|
195
|
+
files.push({
|
|
196
|
+
path: indexPath,
|
|
197
|
+
baseName: "index.ts",
|
|
198
|
+
exports,
|
|
199
|
+
sources: []
|
|
200
|
+
});
|
|
201
|
+
treeNode.children.forEach((childItem) => {
|
|
202
|
+
fileReducer(files, childItem);
|
|
203
|
+
});
|
|
204
|
+
return files;
|
|
205
|
+
};
|
|
206
|
+
return fileReducer([], tree).reverse();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
_options = new WeakMap();
|
|
210
|
+
|
|
211
|
+
// src/FileManager.ts
|
|
212
|
+
import { trimExtName as trimExtName2 } from "@kubb/fs";
|
|
213
|
+
import PQueue from "p-queue";
|
|
214
|
+
var _filesByPath, _files, _FileManager_instances, add_fn, addOrAppend_fn;
|
|
215
|
+
var _FileManager = class _FileManager {
|
|
216
|
+
constructor() {
|
|
217
|
+
__privateAdd(this, _FileManager_instances);
|
|
218
|
+
__privateAdd(this, _filesByPath, /* @__PURE__ */ new Map());
|
|
219
|
+
__privateAdd(this, _files, /* @__PURE__ */ new Set());
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
get files() {
|
|
223
|
+
return Array.from(__privateGet(this, _files));
|
|
224
|
+
}
|
|
225
|
+
get orderedFiles() {
|
|
226
|
+
return orderBy(Array.from(__privateGet(this, _files)), [
|
|
227
|
+
(v) => v.path.length,
|
|
228
|
+
(v) => trimExtName2(v.path).endsWith("index"),
|
|
229
|
+
(v) => trimExtName2(v.baseName),
|
|
230
|
+
(v) => v.path.split(".").pop()
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
get groupedFiles() {
|
|
234
|
+
return buildDirectoryTree(Array.from(__privateGet(this, _files)));
|
|
235
|
+
}
|
|
236
|
+
get treeNode() {
|
|
237
|
+
return TreeNode.build(Array.from(__privateGet(this, _files)));
|
|
238
|
+
}
|
|
239
|
+
async add(...files) {
|
|
240
|
+
const promises = files.map((file) => {
|
|
241
|
+
if (file.override) {
|
|
242
|
+
return __privateMethod(this, _FileManager_instances, add_fn).call(this, file);
|
|
243
|
+
}
|
|
244
|
+
return __privateMethod(this, _FileManager_instances, addOrAppend_fn).call(this, file);
|
|
245
|
+
});
|
|
246
|
+
const resolvedFiles = await Promise.all(promises);
|
|
247
|
+
if (files.length > 1) {
|
|
248
|
+
return resolvedFiles;
|
|
249
|
+
}
|
|
250
|
+
return resolvedFiles[0];
|
|
251
|
+
}
|
|
252
|
+
getCacheById(id) {
|
|
253
|
+
let cache;
|
|
254
|
+
__privateGet(this, _files).forEach((file) => {
|
|
255
|
+
if (file.id === id) {
|
|
256
|
+
cache = file;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return cache;
|
|
260
|
+
}
|
|
261
|
+
getByPath(path2) {
|
|
262
|
+
return __privateGet(this, _filesByPath).get(path2);
|
|
263
|
+
}
|
|
264
|
+
deleteByPath(path2) {
|
|
265
|
+
const cacheItem = this.getByPath(path2);
|
|
266
|
+
if (!cacheItem) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
__privateGet(this, _filesByPath).delete(path2);
|
|
270
|
+
__privateGet(this, _files).delete(cacheItem);
|
|
271
|
+
}
|
|
272
|
+
async getIndexFiles({ files, plugin, root, output, logger, options = {} }) {
|
|
273
|
+
const { exportType = "barrel" } = output;
|
|
274
|
+
if (exportType === false) {
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
const pathToBuildFrom = resolve(root, output.path);
|
|
278
|
+
if (trimExtName2(pathToBuildFrom).endsWith("index")) {
|
|
279
|
+
logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
const exportPath = output.path.startsWith("./") ? output.path : `./${output.path}`;
|
|
283
|
+
const mode = _FileManager.getMode(output.path);
|
|
284
|
+
const barrelManager = new BarrelManager({ ...options, extName: output.extName });
|
|
285
|
+
let indexFiles = barrelManager.getIndexes(files, pathToBuildFrom);
|
|
286
|
+
if (!indexFiles) {
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
289
|
+
const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
|
|
290
|
+
const rootFile = {
|
|
291
|
+
path: resolve(root, "index.ts"),
|
|
292
|
+
baseName: "index.ts",
|
|
293
|
+
exports: [
|
|
294
|
+
output.exportAs ? {
|
|
295
|
+
name: output.exportAs,
|
|
296
|
+
asAlias: true,
|
|
297
|
+
path: rootPath,
|
|
298
|
+
isTypeOnly: options.isTypeOnly
|
|
299
|
+
} : {
|
|
300
|
+
path: rootPath,
|
|
301
|
+
isTypeOnly: options.isTypeOnly
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
sources: [],
|
|
305
|
+
meta: {
|
|
306
|
+
pluginKey: plugin.key
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
if (exportType === "barrel") {
|
|
310
|
+
indexFiles = indexFiles.map((file) => {
|
|
311
|
+
return {
|
|
312
|
+
...file,
|
|
313
|
+
exports: file.exports?.map((exportItem) => {
|
|
314
|
+
return {
|
|
315
|
+
...exportItem,
|
|
316
|
+
name: void 0
|
|
317
|
+
};
|
|
318
|
+
})
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
rootFile.exports = rootFile.exports?.map((item) => {
|
|
322
|
+
return {
|
|
323
|
+
...item,
|
|
324
|
+
name: void 0
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return [
|
|
329
|
+
...indexFiles.map((indexFile) => {
|
|
330
|
+
return {
|
|
331
|
+
...indexFile,
|
|
332
|
+
meta: {
|
|
333
|
+
pluginKey: plugin.key
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}),
|
|
337
|
+
rootFile
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
async write(...params) {
|
|
341
|
+
return write(...params);
|
|
342
|
+
}
|
|
343
|
+
async read(...params) {
|
|
344
|
+
return read(...params);
|
|
345
|
+
}
|
|
346
|
+
// statics
|
|
347
|
+
static getMode(path2) {
|
|
348
|
+
if (!path2) {
|
|
349
|
+
return "split";
|
|
350
|
+
}
|
|
351
|
+
return extname(path2) ? "single" : "split";
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
_filesByPath = new WeakMap();
|
|
355
|
+
_files = new WeakMap();
|
|
356
|
+
_FileManager_instances = new WeakSet();
|
|
357
|
+
add_fn = async function(file) {
|
|
358
|
+
const resolvedFile = createFile(file);
|
|
359
|
+
__privateGet(this, _filesByPath).set(resolvedFile.path, resolvedFile);
|
|
360
|
+
__privateGet(this, _files).add(resolvedFile);
|
|
361
|
+
return resolvedFile;
|
|
362
|
+
};
|
|
363
|
+
addOrAppend_fn = async function(file) {
|
|
364
|
+
const previousFile = __privateGet(this, _filesByPath).get(file.path);
|
|
365
|
+
if (previousFile) {
|
|
366
|
+
__privateGet(this, _filesByPath).delete(previousFile.path);
|
|
367
|
+
__privateGet(this, _files).delete(previousFile);
|
|
368
|
+
return __privateMethod(this, _FileManager_instances, add_fn).call(this, {
|
|
369
|
+
...file,
|
|
370
|
+
sources: [...previousFile.sources || [], ...file.sources || []],
|
|
371
|
+
imports: [...previousFile.imports || [], ...file.imports || []],
|
|
372
|
+
exports: [...previousFile.exports || [], ...file.exports || []]
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return __privateMethod(this, _FileManager_instances, add_fn).call(this, file);
|
|
376
|
+
};
|
|
377
|
+
var FileManager = _FileManager;
|
|
378
|
+
async function getSource(file) {
|
|
379
|
+
const parser = await getFileParser(file.extName);
|
|
380
|
+
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
381
|
+
const exports = file.exports ? combineExports(file.exports) : [];
|
|
382
|
+
const imports = file.imports && source ? combineImports(file.imports, exports, source) : [];
|
|
383
|
+
const importNodes = imports.filter((item) => {
|
|
384
|
+
const path2 = item.root ? getRelativePath(item.root, item.path) : item.path;
|
|
385
|
+
return path2 !== trimExtName2(file.path);
|
|
386
|
+
}).map((item) => {
|
|
387
|
+
const path2 = item.root ? getRelativePath(item.root, item.path) : item.path;
|
|
388
|
+
return parser.createImport({
|
|
389
|
+
name: item.name,
|
|
390
|
+
path: item.extName ? `${path2}${item.extName}` : path2,
|
|
391
|
+
isTypeOnly: item.isTypeOnly
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
const exportNodes = exports.map((item) => {
|
|
395
|
+
if (item.path) {
|
|
396
|
+
return parser.createExport({
|
|
397
|
+
name: item.name,
|
|
398
|
+
path: item.extName ? `${item.path}${item.extName}` : item.path,
|
|
399
|
+
isTypeOnly: item.isTypeOnly,
|
|
400
|
+
asAlias: item.asAlias
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}).filter(Boolean);
|
|
404
|
+
return parser.print({
|
|
405
|
+
imports: importNodes,
|
|
406
|
+
exports: exportNodes,
|
|
407
|
+
source
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
function combineExports(exports) {
|
|
411
|
+
const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
412
|
+
(prev, curr) => {
|
|
413
|
+
const name = curr.name;
|
|
414
|
+
const prevByPath = prev.findLast((imp) => imp.path === curr.path);
|
|
415
|
+
const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly);
|
|
416
|
+
if (prevByPathAndIsTypeOnly) {
|
|
417
|
+
return prev;
|
|
418
|
+
}
|
|
419
|
+
const uniquePrev = prev.findLast(
|
|
420
|
+
(imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
421
|
+
);
|
|
422
|
+
if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
|
|
423
|
+
return prev;
|
|
424
|
+
}
|
|
425
|
+
if (!prevByPath) {
|
|
426
|
+
return [
|
|
427
|
+
...prev,
|
|
428
|
+
{
|
|
429
|
+
...curr,
|
|
430
|
+
name: Array.isArray(name) ? [...new Set(name)] : name
|
|
431
|
+
}
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
435
|
+
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
|
|
436
|
+
return prev;
|
|
437
|
+
}
|
|
438
|
+
return [...prev, curr];
|
|
439
|
+
},
|
|
440
|
+
[]
|
|
441
|
+
);
|
|
442
|
+
return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias]);
|
|
443
|
+
}
|
|
444
|
+
function combineImports(imports, exports, source) {
|
|
445
|
+
const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
|
|
446
|
+
(prev, curr) => {
|
|
447
|
+
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
448
|
+
const hasImportInSource = (importName) => {
|
|
449
|
+
if (!source) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
const checker = (name2) => name2 && !!source.includes(name2);
|
|
453
|
+
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
454
|
+
};
|
|
455
|
+
if (curr.path === curr.root) {
|
|
456
|
+
return prev;
|
|
457
|
+
}
|
|
458
|
+
if (Array.isArray(name)) {
|
|
459
|
+
name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
|
|
460
|
+
}
|
|
461
|
+
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
462
|
+
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
463
|
+
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly);
|
|
464
|
+
if (prevByPathNameAndIsTypeOnly) {
|
|
465
|
+
return prev;
|
|
466
|
+
}
|
|
467
|
+
if (uniquePrev || Array.isArray(name) && !name.length) {
|
|
468
|
+
return prev;
|
|
469
|
+
}
|
|
470
|
+
if (!prevByPath) {
|
|
471
|
+
return [
|
|
472
|
+
...prev,
|
|
473
|
+
{
|
|
474
|
+
...curr,
|
|
475
|
+
name
|
|
476
|
+
}
|
|
477
|
+
];
|
|
478
|
+
}
|
|
479
|
+
if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
|
|
480
|
+
prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
|
|
481
|
+
return prev;
|
|
482
|
+
}
|
|
483
|
+
if (!Array.isArray(name) && name && !hasImportInSource(name)) {
|
|
484
|
+
return prev;
|
|
485
|
+
}
|
|
486
|
+
return [...prev, curr];
|
|
487
|
+
},
|
|
488
|
+
[]
|
|
489
|
+
);
|
|
490
|
+
return orderBy(combinedImports, [(v) => !v.isTypeOnly]);
|
|
491
|
+
}
|
|
492
|
+
var queue = new PQueue({ concurrency: 100 });
|
|
493
|
+
async function processFiles({ dryRun, config, logger, files }) {
|
|
494
|
+
const orderedFiles = orderBy(files, [
|
|
495
|
+
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
496
|
+
(v) => v.path.length,
|
|
497
|
+
(v) => trimExtName2(v.path).endsWith("index")
|
|
498
|
+
]);
|
|
499
|
+
logger.emit("debug", {
|
|
500
|
+
logs: [JSON.stringify({ files: orderedFiles }, null, 2)],
|
|
501
|
+
fileName: "kubb-files.json",
|
|
502
|
+
override: true
|
|
503
|
+
});
|
|
504
|
+
if (!dryRun) {
|
|
505
|
+
const size = orderedFiles.length;
|
|
506
|
+
logger.emit("progress_start", { id: "files", size });
|
|
507
|
+
const promises = orderedFiles.map(async (file) => {
|
|
508
|
+
await queue.add(async () => {
|
|
509
|
+
const source = await getSource(file);
|
|
510
|
+
await write(file.path, source, { sanity: false });
|
|
511
|
+
logger.emit("progress", { id: "files", data: file ? relative(config.root, file.path) : "" });
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
await Promise.all(promises);
|
|
515
|
+
logger.emit("progress_stop", { id: "files" });
|
|
516
|
+
}
|
|
517
|
+
return files;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export {
|
|
521
|
+
FileManager,
|
|
522
|
+
getSource,
|
|
523
|
+
processFiles
|
|
524
|
+
};
|
|
525
|
+
//# sourceMappingURL=chunk-RIEGCND2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FileManager.ts","../src/BarrelManager.ts","../src/utils/TreeNode.ts"],"sourcesContent":["import { extname, relative, resolve } from 'node:path'\n\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual } from 'remeda'\n\nimport { getRelativePath, read, write } from '@kubb/fs'\nimport { BarrelManager } from './BarrelManager.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\n\nimport { trimExtName } from '@kubb/fs'\nimport type { ResolvedFile } from '@kubb/fs/types'\nimport type { GreaterThan } from '@kubb/types'\nimport PQueue from 'p-queue'\nimport type { BarrelManagerOptions } from './BarrelManager.ts'\nimport type { Logger } from './logger.ts'\nimport type { Config, Plugin } from './types.ts'\nimport { createFile, getFileParser } from './utils'\nimport { type DirectoryTree, TreeNode, buildDirectoryTree } from './utils/TreeNode.ts'\n\nexport type FileMetaBase = {\n pluginKey?: Plugin['key']\n}\n\ntype AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>\n\ntype AddIndexesProps = {\n /**\n * Root based on root and output.path specified in the config\n */\n root: string\n /**\n * Output for plugin\n */\n output: {\n path: string\n exportAs?: string\n extName?: string\n exportType?: 'barrel' | 'barrelNamed' | false\n }\n group?: {\n output: string\n exportAs: string\n }\n logger: Logger\n files: KubbFile.File[]\n options?: BarrelManagerOptions\n plugin: Plugin\n}\n\nexport class FileManager {\n #filesByPath: Map<KubbFile.Path, KubbFile.ResolvedFile> = new Map()\n #files: Set<KubbFile.ResolvedFile> = new Set()\n constructor() {\n return this\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n return Array.from(this.#files)\n }\n\n get orderedFiles(): Array<KubbFile.ResolvedFile> {\n return orderBy(Array.from(this.#files), [\n (v) => v.path.length,\n (v) => trimExtName(v.path).endsWith('index'),\n (v) => trimExtName(v.baseName),\n (v) => v.path.split('.').pop(),\n ])\n }\n\n get groupedFiles(): DirectoryTree | null {\n return buildDirectoryTree(Array.from(this.#files))\n }\n\n get treeNode(): TreeNode | null {\n return TreeNode.build(Array.from(this.#files))\n }\n\n async add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T> {\n const promises = files.map((file) => {\n if (file.override) {\n return this.#add(file)\n }\n\n return this.#addOrAppend(file)\n })\n\n const resolvedFiles = await Promise.all(promises)\n\n if (files.length > 1) {\n return resolvedFiles as unknown as AddResult<T>\n }\n\n return resolvedFiles[0] as unknown as AddResult<T>\n }\n\n async #add(file: KubbFile.File): Promise<ResolvedFile> {\n const resolvedFile = createFile(file)\n\n this.#filesByPath.set(resolvedFile.path, resolvedFile)\n this.#files.add(resolvedFile)\n\n return resolvedFile\n }\n\n async #addOrAppend(file: KubbFile.File): Promise<ResolvedFile> {\n const previousFile = this.#filesByPath.get(file.path)\n\n if (previousFile) {\n this.#filesByPath.delete(previousFile.path)\n this.#files.delete(previousFile)\n\n return this.#add({\n ...file,\n sources: [...(previousFile.sources || []), ...(file.sources || [])],\n imports: [...(previousFile.imports || []), ...(file.imports || [])],\n exports: [...(previousFile.exports || []), ...(file.exports || [])],\n })\n }\n return this.#add(file)\n }\n\n getCacheById(id: string): KubbFile.File | undefined {\n let cache: KubbFile.File | undefined\n\n this.#files.forEach((file) => {\n if (file.id === id) {\n cache = file\n }\n })\n return cache\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined {\n return this.#filesByPath.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n const cacheItem = this.getByPath(path)\n if (!cacheItem) {\n return\n }\n\n this.#filesByPath.delete(path)\n this.#files.delete(cacheItem)\n }\n\n async getIndexFiles({ files, plugin, root, output, logger, options = {} }: AddIndexesProps): Promise<KubbFile.File[]> {\n const { exportType = 'barrel' } = output\n if (exportType === false) {\n return []\n }\n\n const pathToBuildFrom = resolve(root, output.path)\n\n if (trimExtName(pathToBuildFrom).endsWith('index')) {\n logger.emit('warning', 'Output has the same fileName as the barrelFiles, please disable barrel generation')\n return []\n }\n\n const exportPath = output.path.startsWith('./') ? output.path : `./${output.path}`\n const mode = FileManager.getMode(output.path)\n const barrelManager = new BarrelManager({ ...options, extName: output.extName })\n\n let indexFiles = barrelManager.getIndexes(files, pathToBuildFrom)\n\n if (!indexFiles) {\n return []\n }\n\n const rootPath = mode === 'split' ? `${exportPath}/index${output.extName || ''}` : `${exportPath}${output.extName || ''}`\n const rootFile: KubbFile.File = {\n path: resolve(root, 'index.ts'),\n baseName: 'index.ts',\n exports: [\n output.exportAs\n ? {\n name: output.exportAs,\n asAlias: true,\n path: rootPath,\n isTypeOnly: options.isTypeOnly,\n }\n : {\n path: rootPath,\n isTypeOnly: options.isTypeOnly,\n },\n ],\n sources: [],\n meta: {\n pluginKey: plugin.key,\n },\n }\n\n if (exportType === 'barrel') {\n indexFiles = indexFiles.map((file) => {\n return {\n ...file,\n exports: file.exports?.map((exportItem) => {\n return {\n ...exportItem,\n name: undefined,\n }\n }),\n }\n })\n\n rootFile.exports = rootFile.exports?.map((item) => {\n return {\n ...item,\n name: undefined,\n }\n })\n }\n\n return [\n ...indexFiles.map((indexFile) => {\n return {\n ...indexFile,\n meta: {\n pluginKey: plugin.key,\n },\n }\n }),\n rootFile,\n ]\n }\n\n async write(...params: Parameters<typeof write>): ReturnType<typeof write> {\n return write(...params)\n }\n\n async read(...params: Parameters<typeof read>): ReturnType<typeof read> {\n return read(...params)\n }\n\n // statics\n static getMode(path: string | undefined | null): KubbFile.Mode {\n if (!path) {\n return 'split'\n }\n return extname(path) ? 'single' : 'split'\n }\n}\n\nexport async function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: KubbFile.File<TMeta> | ResolvedFile<TMeta>): Promise<string> {\n const parser = await getFileParser(file.extName)\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports ? combineExports(file.exports) : []\n // imports should be defined and source should contain code or we have imports without them being used\n const imports = file.imports && source ? combineImports(file.imports, exports, source) : []\n\n const importNodes = imports\n .filter((item) => {\n const path = item.root ? getRelativePath(item.root, item.path) : item.path\n // trim extName\n return path !== trimExtName(file.path)\n })\n .map((item) => {\n const path = item.root ? getRelativePath(item.root, item.path) : item.path\n\n return parser.createImport({\n name: item.name,\n path: item.extName ? `${path}${item.extName}` : path,\n isTypeOnly: item.isTypeOnly,\n })\n })\n const exportNodes = exports\n .map((item) => {\n if (item.path) {\n return parser.createExport({\n name: item.name,\n path: item.extName ? `${item.path}${item.extName}` : item.path,\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n }\n })\n .filter(Boolean)\n\n return parser.print({\n imports: importNodes,\n exports: exportNodes,\n source,\n })\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ['asc']).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n\n return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias])\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ['asc']).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => name && !!source.includes(name)\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n\n return orderBy(combinedImports, [(v) => !v.isTypeOnly])\n}\n\ntype WriteFilesProps = {\n config: Config\n files: Array<KubbFile.ResolvedFile>\n logger: Logger\n dryRun?: boolean\n}\n/**\n * Global queue\n */\nconst queue = new PQueue({ concurrency: 100 })\n\nexport async function processFiles({ dryRun, config, logger, files }: WriteFilesProps) {\n const orderedFiles = orderBy(files, [\n (v) => v?.meta && 'pluginKey' in v.meta && !v.meta.pluginKey,\n (v) => v.path.length,\n (v) => trimExtName(v.path).endsWith('index'),\n ])\n\n logger.emit('debug', {\n logs: [JSON.stringify({ files: orderedFiles }, null, 2)],\n fileName: 'kubb-files.json',\n override: true,\n })\n\n if (!dryRun) {\n const size = orderedFiles.length\n\n logger.emit('progress_start', { id: 'files', size })\n const promises = orderedFiles.map(async (file) => {\n await queue.add(async () => {\n const source = await getSource(file)\n\n await write(file.path, source, { sanity: false })\n\n logger.emit('progress', { id: 'files', data: file ? relative(config.root, file.path) : '' })\n })\n })\n\n await Promise.all(promises)\n\n logger.emit('progress_stop', { id: 'files' })\n }\n\n return files\n}\n","import path from 'node:path'\n\nimport { TreeNode } from './utils/TreeNode.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport { trimExtName } from '@kubb/fs'\n\nexport type BarrelManagerOptions = {\n isTypeOnly?: boolean\n /**\n * Add .ts or .js\n */\n extName?: string\n}\n\n/**\n * Replace with the use of the FileManager exports/imports\n */\nexport class BarrelManager {\n #options: BarrelManagerOptions\n\n constructor(options: BarrelManagerOptions = {}) {\n this.#options = options\n\n return this\n }\n\n getIndexes(generatedFiles: KubbFile.File[], root: string): Array<KubbFile.File> | null {\n const { isTypeOnly, extName } = this.#options\n const tree = TreeNode.build(generatedFiles, root)\n\n if (!tree) {\n return null\n }\n\n const fileReducer = (files: Array<KubbFile.File>, treeNode: TreeNode) => {\n if (!treeNode.children) {\n return []\n }\n\n const indexPath: KubbFile.Path = path.resolve(treeNode.data.path, 'index.ts')\n\n const exports: Array<KubbFile.Export> = treeNode.children\n .filter((item) => !!item.data.name)\n .map((treeNode) => {\n const importPath: string = treeNode.data.file ? `./${trimExtName(treeNode.data.name)}` : `./${treeNode.data.name}/index`\n\n if (importPath.endsWith('index') && treeNode.data.file) {\n return undefined\n }\n\n return {\n path: extName ? `${importPath}${extName}` : importPath,\n isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n\n files.push({\n path: indexPath,\n baseName: 'index.ts',\n exports,\n sources: [],\n })\n\n treeNode.children.forEach((childItem) => {\n fileReducer(files, childItem)\n })\n\n return files\n }\n\n return fileReducer([], tree).reverse()\n }\n}\n","import type * as KubbFile from '@kubb/fs/types'\nimport { FileManager } from '../FileManager.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n /**\n * @deprecated use file instead\n */\n type: KubbFile.Mode\n path: string\n name: string\n}\n\nexport class TreeNode {\n public data: BarrelData\n\n public parent?: TreeNode\n\n public children: Array<TreeNode> = []\n\n constructor(data: BarrelData, parent?: TreeNode) {\n this.data = data\n this.parent = parent\n return this\n }\n\n addChild(data: BarrelData): TreeNode {\n const child = new TreeNode(data, this)\n if (!this.children) {\n this.children = []\n }\n this.children.push(child)\n return child\n }\n\n find(data?: BarrelData): TreeNode | null {\n if (!data) {\n return null\n }\n\n if (data === this.data) {\n return this\n }\n\n if (this.children?.length) {\n for (let i = 0, { length } = this.children, target: TreeNode | null = null; i < length; i++) {\n target = this.children[i]!.find(data)\n if (target) {\n return target\n }\n }\n }\n\n return null\n }\n\n get leaves(): Array<TreeNode> {\n if (!this.children || this.children.length === 0) {\n // this is a leaf\n return [this]\n }\n\n // if not a leaf, return all children's leaves recursively\n const leaves: TreeNode[] = []\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n leaves.push.apply(leaves, this.children[i]!.leaves)\n }\n }\n return leaves\n }\n\n get root(): TreeNode {\n if (!this.parent) {\n return this\n }\n return this.parent.root\n }\n\n forEach(callback: (treeNode: TreeNode) => void): this {\n if (typeof callback !== 'function') {\n throw new TypeError('forEach() callback must be a function')\n }\n\n // run this node through function\n callback(this)\n\n // do the same for all children\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n this.children[i]?.forEach(callback)\n }\n }\n\n return this\n }\n\n public static build(files: KubbFile.File[], root?: string): TreeNode | null {\n try {\n const filteredTree = buildDirectoryTree(files, root)\n\n if (!filteredTree) {\n return null\n }\n\n const treeNode = new TreeNode({\n name: filteredTree.name,\n path: filteredTree.path,\n file: filteredTree.file,\n type: FileManager.getMode(filteredTree.path),\n })\n\n const recurse = (node: typeof treeNode, item: DirectoryTree) => {\n const subNode = node.addChild({\n name: item.name,\n path: item.path,\n file: item.file,\n type: FileManager.getMode(item.path),\n })\n\n if (item.children?.length) {\n item.children?.forEach((child) => {\n recurse(subNode, child)\n })\n }\n }\n\n filteredTree.children?.forEach((child) => recurse(treeNode, child))\n\n return treeNode\n } catch (e) {\n throw new Error('Something went wrong with creating index files with the TreehNode class', { cause: e })\n }\n }\n}\n\nexport type DirectoryTree = {\n name: string\n path: string\n file?: KubbFile.File\n children: Array<DirectoryTree>\n}\n\nexport function buildDirectoryTree(files: Array<KubbFile.File>, rootFolder = ''): DirectoryTree | null {\n const rootPrefix = rootFolder.endsWith('/') ? rootFolder : `${rootFolder}/`\n const filteredFiles = files.filter((file) => (rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith('.json') : !file.path.endsWith('.json')))\n\n if (filteredFiles.length === 0) {\n return null // No files match the root folder\n }\n\n const root: DirectoryTree = {\n name: rootFolder || '',\n path: rootFolder || '',\n children: [],\n }\n\n filteredFiles.forEach((file) => {\n const path = file.path.slice(rootFolder.length)\n const parts = path.split('/')\n let currentLevel: DirectoryTree[] = root.children\n let currentPath = rootFolder\n\n parts.forEach((part, index) => {\n if (index !== 0) {\n currentPath += `/${part}`\n } else {\n currentPath += `${part}`\n }\n\n let existingNode = currentLevel.find((node) => node.name === part)\n\n if (!existingNode) {\n if (index === parts.length - 1) {\n // If it's the last part, it's a file\n existingNode = {\n name: part,\n file,\n path: currentPath,\n } as DirectoryTree\n } else {\n // Otherwise, it's a folder\n existingNode = {\n name: part,\n path: currentPath,\n children: [],\n } as DirectoryTree\n }\n currentLevel.push(existingNode)\n }\n\n // Move to the next level if it's a folder\n if (!existingNode.file)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