@kubb/core 1.5.0 → 1.5.1
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/index.cjs +1584 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -24
- package/dist/index.d.ts +11 -24
- package/dist/index.js +1516 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -3
- package/schema.json +0 -9
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1584 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var crypto = require('crypto');
|
|
6
|
+
var fs = require('fs-extra');
|
|
7
|
+
var pathParser2 = require('path');
|
|
8
|
+
var jsRuntime = require('js-runtime');
|
|
9
|
+
var changeCase = require('change-case');
|
|
10
|
+
var perf_hooks = require('perf_hooks');
|
|
11
|
+
var rimraf = require('rimraf');
|
|
12
|
+
var dirTree = require('directory-tree');
|
|
13
|
+
var mod = require('module');
|
|
14
|
+
var url = require('url');
|
|
15
|
+
var os = require('os');
|
|
16
|
+
var pc3 = require('picocolors');
|
|
17
|
+
var seedrandom = require('seedrandom');
|
|
18
|
+
var tsCodegen = require('@kubb/ts-codegen');
|
|
19
|
+
var events = require('events');
|
|
20
|
+
|
|
21
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
|
|
23
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
24
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
25
|
+
var pathParser2__default = /*#__PURE__*/_interopDefault(pathParser2);
|
|
26
|
+
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
|
|
27
|
+
var mod__default = /*#__PURE__*/_interopDefault(mod);
|
|
28
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
29
|
+
var pc3__default = /*#__PURE__*/_interopDefault(pc3);
|
|
30
|
+
var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
|
|
31
|
+
|
|
32
|
+
// src/managers/fileManager/FileManager.ts
|
|
33
|
+
|
|
34
|
+
// src/utils/isPromise.ts
|
|
35
|
+
function isPromise(result) {
|
|
36
|
+
return typeof result?.then === "function";
|
|
37
|
+
}
|
|
38
|
+
function isPromiseFulfilledResult(result) {
|
|
39
|
+
return result.status === "fulfilled";
|
|
40
|
+
}
|
|
41
|
+
function isPromiseRejectedResult(result) {
|
|
42
|
+
return result.status === "rejected";
|
|
43
|
+
}
|
|
44
|
+
async function saveCreateDirectory(path) {
|
|
45
|
+
const passedPath = pathParser2__default.default.dirname(pathParser2__default.default.resolve(path));
|
|
46
|
+
await fs__default.default.mkdir(passedPath, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
var writer = jsRuntime.switcher(
|
|
49
|
+
{
|
|
50
|
+
node: async (path, data) => {
|
|
51
|
+
try {
|
|
52
|
+
await fs__default.default.stat(path);
|
|
53
|
+
const oldContent = await fs__default.default.readFile(path, { encoding: "utf-8" });
|
|
54
|
+
if (oldContent?.toString() === data) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
} catch (_err) {
|
|
58
|
+
}
|
|
59
|
+
await saveCreateDirectory(path);
|
|
60
|
+
return fs__default.default.writeFile(pathParser2__default.default.resolve(path), data, { encoding: "utf-8" });
|
|
61
|
+
},
|
|
62
|
+
bun: async (path, data) => {
|
|
63
|
+
try {
|
|
64
|
+
await saveCreateDirectory(path);
|
|
65
|
+
await Bun.write(pathParser2__default.default.resolve(path), data);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.log(e, pathParser2__default.default.resolve(path));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"node"
|
|
72
|
+
);
|
|
73
|
+
async function write(data, path) {
|
|
74
|
+
return writer(path, data);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/utils/cache.ts
|
|
78
|
+
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
79
|
+
return {
|
|
80
|
+
set(id, value) {
|
|
81
|
+
Store[id] = [0, value];
|
|
82
|
+
},
|
|
83
|
+
get(id) {
|
|
84
|
+
const item = Store[id];
|
|
85
|
+
if (!item) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
item[0] = 0;
|
|
89
|
+
return item[1];
|
|
90
|
+
},
|
|
91
|
+
has(id) {
|
|
92
|
+
const item = Store[id];
|
|
93
|
+
if (!item) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
item[0] = 0;
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
delete(id) {
|
|
100
|
+
return delete Store[id];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function slash(path, platform = "linux") {
|
|
105
|
+
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
106
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
107
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
108
|
+
}
|
|
109
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
110
|
+
}
|
|
111
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
112
|
+
if (!rootDir || !filePath) {
|
|
113
|
+
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
114
|
+
}
|
|
115
|
+
const relativePath = pathParser2__default.default.relative(rootDir, filePath);
|
|
116
|
+
const path = slash(relativePath, platform);
|
|
117
|
+
if (path.startsWith("../")) {
|
|
118
|
+
return path.replace(pathParser2__default.default.basename(path), pathParser2__default.default.basename(path, pathParser2__default.default.extname(filePath)));
|
|
119
|
+
}
|
|
120
|
+
return `./${path.replace(pathParser2__default.default.basename(path), pathParser2__default.default.basename(path, pathParser2__default.default.extname(filePath)))}`;
|
|
121
|
+
}
|
|
122
|
+
function getPathMode(path) {
|
|
123
|
+
if (!path) {
|
|
124
|
+
return "directory";
|
|
125
|
+
}
|
|
126
|
+
return pathParser2__default.default.extname(path) ? "file" : "directory";
|
|
127
|
+
}
|
|
128
|
+
var reader = jsRuntime.switcher(
|
|
129
|
+
{
|
|
130
|
+
node: async (path) => {
|
|
131
|
+
return fs__default.default.readFile(path, { encoding: "utf8" });
|
|
132
|
+
},
|
|
133
|
+
bun: async (path) => {
|
|
134
|
+
const file = Bun.file(path);
|
|
135
|
+
return file.text();
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"node"
|
|
139
|
+
);
|
|
140
|
+
async function read(path) {
|
|
141
|
+
return reader(path);
|
|
142
|
+
}
|
|
143
|
+
function objectToParameters(data, options = {}) {
|
|
144
|
+
const { typed } = options;
|
|
145
|
+
return data.reduce((acc, [key, value]) => {
|
|
146
|
+
const parameterName = changeCase.camelCase(key, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
147
|
+
if (typed) {
|
|
148
|
+
acc.push(`${parameterName}: ${value}["${key}"]`);
|
|
149
|
+
} else {
|
|
150
|
+
acc.push(`${parameterName}`);
|
|
151
|
+
}
|
|
152
|
+
return acc;
|
|
153
|
+
}, []).join(", ");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/utils/nameSorter.ts
|
|
157
|
+
function nameSorter(a, b) {
|
|
158
|
+
if (a.name < b.name) {
|
|
159
|
+
return -1;
|
|
160
|
+
}
|
|
161
|
+
if (a.name > b.name) {
|
|
162
|
+
return 1;
|
|
163
|
+
}
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/utils/jsdoc.ts
|
|
168
|
+
function createJSDocBlockText({ comments }) {
|
|
169
|
+
const filteredComments = comments.filter(Boolean);
|
|
170
|
+
if (!filteredComments.length) {
|
|
171
|
+
return "";
|
|
172
|
+
}
|
|
173
|
+
const text = filteredComments.reduce((acc, comment) => {
|
|
174
|
+
return `${acc}
|
|
175
|
+
* ${comment}`;
|
|
176
|
+
}, "/**");
|
|
177
|
+
return `${text}
|
|
178
|
+
*/`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/utils/getUniqueName.ts
|
|
182
|
+
function getUniqueName(originalName, data) {
|
|
183
|
+
let used = data[originalName] || 0;
|
|
184
|
+
if (used) {
|
|
185
|
+
data[originalName] = ++used;
|
|
186
|
+
originalName += used;
|
|
187
|
+
}
|
|
188
|
+
data[originalName] = 1;
|
|
189
|
+
return originalName;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/utils/timeout.ts
|
|
193
|
+
async function timeout(ms) {
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
setTimeout(() => {
|
|
196
|
+
resolve(true);
|
|
197
|
+
}, ms);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
var Queue = class {
|
|
201
|
+
queue = [];
|
|
202
|
+
workerCount = 0;
|
|
203
|
+
maxParallel;
|
|
204
|
+
debug = false;
|
|
205
|
+
constructor(maxParallel, debug = false) {
|
|
206
|
+
this.maxParallel = maxParallel;
|
|
207
|
+
this.debug = debug;
|
|
208
|
+
}
|
|
209
|
+
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
212
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
213
|
+
this.queue = this.queue.filter((queueItem) => queueItem.name === item.name);
|
|
214
|
+
reject("Aborted");
|
|
215
|
+
});
|
|
216
|
+
this.queue.push(item);
|
|
217
|
+
this.work();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
221
|
+
new Promise((resolve, reject) => {
|
|
222
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
223
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
224
|
+
this.queue = this.queue.filter((queueItem) => queueItem.name === item.name);
|
|
225
|
+
});
|
|
226
|
+
this.queue.push(item);
|
|
227
|
+
this.work();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
get hasJobs() {
|
|
231
|
+
return this.workerCount > 0 || this.queue.length > 0;
|
|
232
|
+
}
|
|
233
|
+
work() {
|
|
234
|
+
if (this.workerCount >= this.maxParallel) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this.workerCount++;
|
|
238
|
+
let entry;
|
|
239
|
+
while (entry = this.queue.shift()) {
|
|
240
|
+
const { reject, resolve, job, name, description } = entry;
|
|
241
|
+
if (this.debug) {
|
|
242
|
+
perf_hooks.performance.mark(name + "_start");
|
|
243
|
+
}
|
|
244
|
+
job().then((result) => {
|
|
245
|
+
resolve(result);
|
|
246
|
+
if (this.debug) {
|
|
247
|
+
perf_hooks.performance.mark(name + "_stop");
|
|
248
|
+
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
249
|
+
}
|
|
250
|
+
}).catch((err) => reject(err));
|
|
251
|
+
}
|
|
252
|
+
this.workerCount--;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/utils/getEncodedText.ts
|
|
257
|
+
function getEncodedText(text) {
|
|
258
|
+
return text ? text.replaceAll("`", "\\`") : "";
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/utils/renderTemplate.ts
|
|
262
|
+
function renderTemplate(template, data = void 0) {
|
|
263
|
+
if (!data || !Object.keys(data).length) {
|
|
264
|
+
return template.replace(/{{(.*?)}}/g, "");
|
|
265
|
+
}
|
|
266
|
+
const matches = template.match(/{{(.*?)}}/g);
|
|
267
|
+
return matches?.reduce((prev, curr) => {
|
|
268
|
+
const value = data[curr.split(/{{|}}/).filter(Boolean)[0].trim()];
|
|
269
|
+
if (value === void 0) {
|
|
270
|
+
return prev;
|
|
271
|
+
}
|
|
272
|
+
return prev.replace(curr, () => {
|
|
273
|
+
if (typeof value === "boolean") {
|
|
274
|
+
return `${value.toString()}` || "false";
|
|
275
|
+
}
|
|
276
|
+
return value || "";
|
|
277
|
+
}).trim();
|
|
278
|
+
}, template) || "";
|
|
279
|
+
}
|
|
280
|
+
async function clean(path) {
|
|
281
|
+
return rimraf.rimraf(path);
|
|
282
|
+
}
|
|
283
|
+
var TreeNode = class _TreeNode {
|
|
284
|
+
data;
|
|
285
|
+
parent;
|
|
286
|
+
children = [];
|
|
287
|
+
constructor(data, parent) {
|
|
288
|
+
this.data = data;
|
|
289
|
+
this.parent = parent;
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
addChild(data) {
|
|
293
|
+
const child = new _TreeNode(data, this);
|
|
294
|
+
if (!this.children) {
|
|
295
|
+
this.children = [];
|
|
296
|
+
}
|
|
297
|
+
this.children.push(child);
|
|
298
|
+
return child;
|
|
299
|
+
}
|
|
300
|
+
find(data) {
|
|
301
|
+
if (!data) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
if (data === this.data) {
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
if (this.children?.length) {
|
|
308
|
+
for (let i = 0, { length } = this.children, target = null; i < length; i++) {
|
|
309
|
+
target = this.children[i].find(data);
|
|
310
|
+
if (target) {
|
|
311
|
+
return target;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
get leaves() {
|
|
318
|
+
if (!this.children || this.children.length === 0) {
|
|
319
|
+
return [this];
|
|
320
|
+
}
|
|
321
|
+
const leaves = [];
|
|
322
|
+
if (this.children) {
|
|
323
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
324
|
+
leaves.push.apply(leaves, this.children[i].leaves);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return leaves;
|
|
328
|
+
}
|
|
329
|
+
get root() {
|
|
330
|
+
if (!this.parent) {
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
return this.parent.root;
|
|
334
|
+
}
|
|
335
|
+
forEach(callback) {
|
|
336
|
+
if (typeof callback !== "function") {
|
|
337
|
+
throw new TypeError("forEach() callback must be a function");
|
|
338
|
+
}
|
|
339
|
+
callback(this);
|
|
340
|
+
if (this.children) {
|
|
341
|
+
for (let i = 0, { length } = this.children; i < length; i++) {
|
|
342
|
+
this.children[i].forEach(callback);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
static build(path, options = {}) {
|
|
348
|
+
try {
|
|
349
|
+
const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
|
|
350
|
+
const filteredTree = dirTree__default.default(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
|
|
351
|
+
if (!filteredTree) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || getPathMode(filteredTree.path) });
|
|
355
|
+
const recurse = (node, item) => {
|
|
356
|
+
const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || getPathMode(item.path) });
|
|
357
|
+
if (item.children?.length) {
|
|
358
|
+
item.children?.forEach((child) => {
|
|
359
|
+
recurse(subNode, child);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
filteredTree.children?.forEach((child) => recurse(treeNode, child));
|
|
364
|
+
return treeNode;
|
|
365
|
+
} catch (e) {
|
|
366
|
+
throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/utils/transformReservedWord.ts
|
|
372
|
+
var reservedWords = [
|
|
373
|
+
"abstract",
|
|
374
|
+
"arguments",
|
|
375
|
+
"boolean",
|
|
376
|
+
"break",
|
|
377
|
+
"byte",
|
|
378
|
+
"case",
|
|
379
|
+
"catch",
|
|
380
|
+
"char",
|
|
381
|
+
"class",
|
|
382
|
+
"const",
|
|
383
|
+
"continue",
|
|
384
|
+
"debugger",
|
|
385
|
+
"default",
|
|
386
|
+
"delete",
|
|
387
|
+
"do",
|
|
388
|
+
"double",
|
|
389
|
+
"else",
|
|
390
|
+
"enum",
|
|
391
|
+
"eval",
|
|
392
|
+
"export",
|
|
393
|
+
"extends",
|
|
394
|
+
"false",
|
|
395
|
+
"final",
|
|
396
|
+
"finally",
|
|
397
|
+
"float",
|
|
398
|
+
"for",
|
|
399
|
+
"function",
|
|
400
|
+
"goto",
|
|
401
|
+
"if",
|
|
402
|
+
"implements",
|
|
403
|
+
"import",
|
|
404
|
+
"in",
|
|
405
|
+
"instanceof",
|
|
406
|
+
"int",
|
|
407
|
+
"interface",
|
|
408
|
+
"let",
|
|
409
|
+
"long",
|
|
410
|
+
"native",
|
|
411
|
+
"new",
|
|
412
|
+
"null",
|
|
413
|
+
"package",
|
|
414
|
+
"private",
|
|
415
|
+
"protected",
|
|
416
|
+
"public",
|
|
417
|
+
"return",
|
|
418
|
+
"short",
|
|
419
|
+
"static",
|
|
420
|
+
"super",
|
|
421
|
+
"switch",
|
|
422
|
+
"synchronized",
|
|
423
|
+
"this",
|
|
424
|
+
"throw",
|
|
425
|
+
"throws",
|
|
426
|
+
"transient",
|
|
427
|
+
"true",
|
|
428
|
+
"try",
|
|
429
|
+
"typeof",
|
|
430
|
+
"var",
|
|
431
|
+
"void",
|
|
432
|
+
"volatile",
|
|
433
|
+
"while",
|
|
434
|
+
"with",
|
|
435
|
+
"yield",
|
|
436
|
+
"Array",
|
|
437
|
+
"Date",
|
|
438
|
+
"eval",
|
|
439
|
+
"function",
|
|
440
|
+
"hasOwnProperty",
|
|
441
|
+
"Infinity",
|
|
442
|
+
"isFinite",
|
|
443
|
+
"isNaN",
|
|
444
|
+
"isPrototypeOf",
|
|
445
|
+
"length",
|
|
446
|
+
"Math",
|
|
447
|
+
"name",
|
|
448
|
+
"NaN",
|
|
449
|
+
"Number",
|
|
450
|
+
"Object",
|
|
451
|
+
"prototype",
|
|
452
|
+
"String",
|
|
453
|
+
"toString",
|
|
454
|
+
"undefined",
|
|
455
|
+
"valueOf"
|
|
456
|
+
];
|
|
457
|
+
function transformReservedWord(word) {
|
|
458
|
+
if (word && reservedWords.includes(word) || word?.match(/^\d/)) {
|
|
459
|
+
return `_${word}`;
|
|
460
|
+
}
|
|
461
|
+
return word;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// src/utils/uniqueIdFactory.ts
|
|
465
|
+
var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
|
|
466
|
+
var SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
|
|
467
|
+
function normalizeDirectory(directory) {
|
|
468
|
+
if (!SLASHES.has(directory[directory.length - 1])) {
|
|
469
|
+
return `${directory}/`;
|
|
470
|
+
}
|
|
471
|
+
return directory;
|
|
472
|
+
}
|
|
473
|
+
function getLocation(path, cwd) {
|
|
474
|
+
let location = path;
|
|
475
|
+
if (cwd) {
|
|
476
|
+
const require2 = mod__default.default.createRequire(normalizeDirectory(cwd));
|
|
477
|
+
location = require2.resolve(path);
|
|
478
|
+
}
|
|
479
|
+
return location;
|
|
480
|
+
}
|
|
481
|
+
async function importModule(path, cwd) {
|
|
482
|
+
try {
|
|
483
|
+
let location = getLocation(path, cwd);
|
|
484
|
+
if (os__default.default.platform() == "win32") {
|
|
485
|
+
location = url.pathToFileURL(location).href;
|
|
486
|
+
}
|
|
487
|
+
const module = await import(location);
|
|
488
|
+
return module?.default ?? module;
|
|
489
|
+
} catch (e) {
|
|
490
|
+
console.log(e);
|
|
491
|
+
return void 0;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// src/utils/throttle.ts
|
|
496
|
+
var throttle = (fn, delay) => {
|
|
497
|
+
let wait = false;
|
|
498
|
+
let timeout2;
|
|
499
|
+
let cancelled = false;
|
|
500
|
+
return [
|
|
501
|
+
(...args) => {
|
|
502
|
+
if (cancelled) {
|
|
503
|
+
return void 0;
|
|
504
|
+
}
|
|
505
|
+
if (wait) {
|
|
506
|
+
return void 0;
|
|
507
|
+
}
|
|
508
|
+
const val = fn(...args);
|
|
509
|
+
wait = true;
|
|
510
|
+
timeout2 = setTimeout(() => {
|
|
511
|
+
wait = false;
|
|
512
|
+
}, delay);
|
|
513
|
+
return val;
|
|
514
|
+
},
|
|
515
|
+
() => {
|
|
516
|
+
cancelled = true;
|
|
517
|
+
clearTimeout(timeout2);
|
|
518
|
+
}
|
|
519
|
+
];
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// src/utils/SummaryError.ts
|
|
523
|
+
var SummaryError = class extends Error {
|
|
524
|
+
summary;
|
|
525
|
+
constructor(message, options) {
|
|
526
|
+
super(message, { cause: options.cause });
|
|
527
|
+
this.name = "SummaryError";
|
|
528
|
+
this.summary = options.summary || [];
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// src/utils/Warning.ts
|
|
533
|
+
var Warning = class extends Error {
|
|
534
|
+
constructor(message, options) {
|
|
535
|
+
super(message, { cause: options?.cause });
|
|
536
|
+
this.name = "Warning";
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function createLogger(spinner) {
|
|
540
|
+
const log = (message) => {
|
|
541
|
+
if (message && spinner) {
|
|
542
|
+
spinner.text = message;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const error = (message) => {
|
|
546
|
+
if (message) {
|
|
547
|
+
throw new Error(message || "Something went wrong");
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
const warn = (message) => {
|
|
551
|
+
if (message && spinner) {
|
|
552
|
+
spinner.warn(pc3__default.default.yellow(message));
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const info = (message) => {
|
|
556
|
+
if (message && spinner) {
|
|
557
|
+
spinner.info(message);
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
const logger = {
|
|
561
|
+
log,
|
|
562
|
+
error,
|
|
563
|
+
warn,
|
|
564
|
+
info,
|
|
565
|
+
spinner
|
|
566
|
+
};
|
|
567
|
+
return logger;
|
|
568
|
+
}
|
|
569
|
+
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
570
|
+
function randomColour(text, colours = defaultColours) {
|
|
571
|
+
if (!text) {
|
|
572
|
+
return "white";
|
|
573
|
+
}
|
|
574
|
+
const random = seedrandom__default.default(text);
|
|
575
|
+
const colour = colours.at(Math.floor(random() * colours.length)) || "white";
|
|
576
|
+
return colour;
|
|
577
|
+
}
|
|
578
|
+
function randomPicoColour(text, colors = defaultColours) {
|
|
579
|
+
const colours = pc3__default.default.createColors(true);
|
|
580
|
+
if (!text) {
|
|
581
|
+
return colours.white(text);
|
|
582
|
+
}
|
|
583
|
+
const colour = randomColour(text, colors);
|
|
584
|
+
const isDark = colour.includes("dark");
|
|
585
|
+
const key = colour.replace("dark", "").toLowerCase();
|
|
586
|
+
const formatter = colours[key];
|
|
587
|
+
if (isDark) {
|
|
588
|
+
return pc3__default.default.bold(formatter(text));
|
|
589
|
+
}
|
|
590
|
+
if (typeof formatter !== "function") {
|
|
591
|
+
throw new Error("Formatter for picoColor is not of type function/Formatter");
|
|
592
|
+
}
|
|
593
|
+
return formatter(text);
|
|
594
|
+
}
|
|
595
|
+
var URLPath = class _URLPath {
|
|
596
|
+
path;
|
|
597
|
+
constructor(path) {
|
|
598
|
+
this.path = path;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
602
|
+
* @example /pet/{petId} => /pet/:petId
|
|
603
|
+
*/
|
|
604
|
+
get URL() {
|
|
605
|
+
return this.toURLPath();
|
|
606
|
+
}
|
|
607
|
+
get isUrl() {
|
|
608
|
+
return _URLPath.isURL(this.path);
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
612
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
613
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
614
|
+
* @example /account/userID => `/account/${userId}`
|
|
615
|
+
*/
|
|
616
|
+
get template() {
|
|
617
|
+
return this.toTemplateString();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
621
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
622
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
623
|
+
* @example /account/userID => `/account/${userId}`
|
|
624
|
+
*/
|
|
625
|
+
toTemplateString() {
|
|
626
|
+
return _URLPath.toTemplateString(this.path);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
630
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
631
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
632
|
+
* @example /account/userID => `/account/${userId}`
|
|
633
|
+
*/
|
|
634
|
+
static toTemplateString(path) {
|
|
635
|
+
const regex = /{(\w|-)*}/g;
|
|
636
|
+
const found = path.match(regex);
|
|
637
|
+
let newPath = path.replaceAll("{", "${");
|
|
638
|
+
if (found) {
|
|
639
|
+
newPath = found.reduce((prev, curr) => {
|
|
640
|
+
const replacement = `\${${changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })}}`;
|
|
641
|
+
return prev.replace(curr, replacement);
|
|
642
|
+
}, path);
|
|
643
|
+
}
|
|
644
|
+
return `\`${newPath}\``;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
648
|
+
* @example /pet/{petId} => /pet/:petId
|
|
649
|
+
*/
|
|
650
|
+
toURLPath() {
|
|
651
|
+
return _URLPath.toURLPath(this.path);
|
|
652
|
+
}
|
|
653
|
+
static toURLPath(path) {
|
|
654
|
+
return path.replaceAll("{", ":").replaceAll("}", "");
|
|
655
|
+
}
|
|
656
|
+
static isURL(path) {
|
|
657
|
+
try {
|
|
658
|
+
const url = new URL(path);
|
|
659
|
+
if (url?.href) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
} catch (error) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
function getIndexes(root, options = {}) {
|
|
669
|
+
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
670
|
+
if (!tree) {
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
const fileReducer = (files2, currentTree) => {
|
|
674
|
+
if (!currentTree.children) {
|
|
675
|
+
return [];
|
|
676
|
+
}
|
|
677
|
+
if (currentTree.children?.length > 1) {
|
|
678
|
+
const path = pathParser2__default.default.resolve(currentTree.data.path, "index.ts");
|
|
679
|
+
const exports = currentTree.children.map((file) => {
|
|
680
|
+
if (!file) {
|
|
681
|
+
return void 0;
|
|
682
|
+
}
|
|
683
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
684
|
+
if (importPath.includes("index") && path.includes("index")) {
|
|
685
|
+
return void 0;
|
|
686
|
+
}
|
|
687
|
+
return { path: importPath };
|
|
688
|
+
}).filter(Boolean);
|
|
689
|
+
files2.push({
|
|
690
|
+
path,
|
|
691
|
+
fileName: "index.ts",
|
|
692
|
+
source: "",
|
|
693
|
+
exports
|
|
694
|
+
});
|
|
695
|
+
} else {
|
|
696
|
+
currentTree.children?.forEach((child) => {
|
|
697
|
+
const path = pathParser2__default.default.resolve(currentTree.data.path, "index.ts");
|
|
698
|
+
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
699
|
+
files2.push({
|
|
700
|
+
path,
|
|
701
|
+
fileName: "index.ts",
|
|
702
|
+
source: "",
|
|
703
|
+
exports: [{ path: importPath }]
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
currentTree.children.forEach((childItem) => {
|
|
708
|
+
fileReducer(files2, childItem);
|
|
709
|
+
});
|
|
710
|
+
return files2;
|
|
711
|
+
};
|
|
712
|
+
const files = fileReducer([], tree);
|
|
713
|
+
return files;
|
|
714
|
+
}
|
|
715
|
+
function combineFiles(files) {
|
|
716
|
+
return files.filter(Boolean).reduce((acc, curr) => {
|
|
717
|
+
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
718
|
+
if (prevIndex !== -1) {
|
|
719
|
+
const prev = acc[prevIndex];
|
|
720
|
+
acc[prevIndex] = {
|
|
721
|
+
...curr,
|
|
722
|
+
source: prev.source && curr.source ? `${prev.source}
|
|
723
|
+
${curr.source}` : "",
|
|
724
|
+
imports: [...prev.imports || [], ...curr.imports || []],
|
|
725
|
+
exports: [...prev.exports || [], ...curr.exports || []],
|
|
726
|
+
env: { ...prev.env || {}, ...curr.env || {} }
|
|
727
|
+
};
|
|
728
|
+
} else {
|
|
729
|
+
acc.push(curr);
|
|
730
|
+
}
|
|
731
|
+
return acc;
|
|
732
|
+
}, []);
|
|
733
|
+
}
|
|
734
|
+
var extensions = [".js", ".ts", ".tsx"];
|
|
735
|
+
function isExtensionAllowed(fileName) {
|
|
736
|
+
return extensions.some((extension) => fileName.endsWith(extension));
|
|
737
|
+
}
|
|
738
|
+
function getFileSource(file) {
|
|
739
|
+
let { source } = file;
|
|
740
|
+
if (!isExtensionAllowed(file.fileName)) {
|
|
741
|
+
return file.source;
|
|
742
|
+
}
|
|
743
|
+
const imports = [];
|
|
744
|
+
const exports = [];
|
|
745
|
+
file.imports?.forEach((curr) => {
|
|
746
|
+
const existingImport = imports.find((imp) => imp.path === curr.path);
|
|
747
|
+
if (!existingImport) {
|
|
748
|
+
imports.push({
|
|
749
|
+
...curr,
|
|
750
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
if (existingImport && !Array.isArray(existingImport.name) && existingImport.name !== curr.name) {
|
|
754
|
+
imports.push(curr);
|
|
755
|
+
}
|
|
756
|
+
if (existingImport && Array.isArray(existingImport.name)) {
|
|
757
|
+
if (Array.isArray(curr.name)) {
|
|
758
|
+
existingImport.name = [.../* @__PURE__ */ new Set([...existingImport.name, ...curr.name])];
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
file.exports?.forEach((curr) => {
|
|
763
|
+
const exists = exports.find((imp) => imp.path === curr.path);
|
|
764
|
+
if (!exists) {
|
|
765
|
+
exports.push({
|
|
766
|
+
...curr,
|
|
767
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
|
|
771
|
+
exports.push(curr);
|
|
772
|
+
}
|
|
773
|
+
if (exists && Array.isArray(exists.name)) {
|
|
774
|
+
if (Array.isArray(curr.name)) {
|
|
775
|
+
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
const importNodes = imports.reduce((prev, curr) => {
|
|
780
|
+
return [...prev, tsCodegen.createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
|
|
781
|
+
}, []);
|
|
782
|
+
const importSource = tsCodegen.print(importNodes);
|
|
783
|
+
const exportNodes = exports.reduce((prev, curr) => {
|
|
784
|
+
return [...prev, tsCodegen.createExportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly, asAlias: curr.asAlias })];
|
|
785
|
+
}, []);
|
|
786
|
+
const exportSource = tsCodegen.print(exportNodes);
|
|
787
|
+
source = getEnvSource(source, file.env);
|
|
788
|
+
if (importSource) {
|
|
789
|
+
source = `${importSource}
|
|
790
|
+
${source}`;
|
|
791
|
+
}
|
|
792
|
+
if (exportSource) {
|
|
793
|
+
source = `${exportSource}
|
|
794
|
+
${source}`;
|
|
795
|
+
}
|
|
796
|
+
return source;
|
|
797
|
+
}
|
|
798
|
+
function searchAndReplace(options) {
|
|
799
|
+
const { text, replaceBy, prefix = "", key } = options;
|
|
800
|
+
const searchValues = options.searchValues?.(prefix, key) || [
|
|
801
|
+
`${prefix}["${key}"]`,
|
|
802
|
+
`${prefix}['${key}']`,
|
|
803
|
+
`${prefix}[\`${key}\`]`,
|
|
804
|
+
`${prefix}"${key}"`,
|
|
805
|
+
`${prefix}'${key}'`,
|
|
806
|
+
`${prefix}\`${key}\``,
|
|
807
|
+
new RegExp(`${prefix}${key}`, "g")
|
|
808
|
+
];
|
|
809
|
+
return searchValues.reduce((prev, searchValue) => {
|
|
810
|
+
return prev.toString().replaceAll(searchValue, replaceBy);
|
|
811
|
+
}, text);
|
|
812
|
+
}
|
|
813
|
+
function getEnvSource(source, env) {
|
|
814
|
+
if (!env) {
|
|
815
|
+
return source;
|
|
816
|
+
}
|
|
817
|
+
const keys = Object.keys(env);
|
|
818
|
+
if (!keys.length) {
|
|
819
|
+
return source;
|
|
820
|
+
}
|
|
821
|
+
return keys.reduce((prev, key) => {
|
|
822
|
+
const environmentValue = env[key];
|
|
823
|
+
const replaceBy = environmentValue ? `'${environmentValue.replaceAll('"', "")?.replaceAll("'", "")}'` : "undefined";
|
|
824
|
+
if (key.toUpperCase() !== key) {
|
|
825
|
+
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
826
|
+
}
|
|
827
|
+
if (typeof replaceBy === "string") {
|
|
828
|
+
prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
829
|
+
prev = searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
830
|
+
`, "ig"), ""), replaceBy, key });
|
|
831
|
+
}
|
|
832
|
+
return prev;
|
|
833
|
+
}, source);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// src/managers/fileManager/FileManager.ts
|
|
837
|
+
var FileManager = class {
|
|
838
|
+
cache = /* @__PURE__ */ new Map();
|
|
839
|
+
task;
|
|
840
|
+
queue;
|
|
841
|
+
constructor(options) {
|
|
842
|
+
if (options) {
|
|
843
|
+
this.task = options.task;
|
|
844
|
+
this.queue = options.queue;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
get extensions() {
|
|
848
|
+
return extensions;
|
|
849
|
+
}
|
|
850
|
+
get files() {
|
|
851
|
+
const files = [];
|
|
852
|
+
this.cache.forEach((item) => {
|
|
853
|
+
files.push(...item.flat(1));
|
|
854
|
+
});
|
|
855
|
+
return files;
|
|
856
|
+
}
|
|
857
|
+
get isExecuting() {
|
|
858
|
+
return this.queue?.hasJobs ?? false;
|
|
859
|
+
}
|
|
860
|
+
async add(file) {
|
|
861
|
+
const controller = new AbortController();
|
|
862
|
+
const resolvedFile = { id: crypto__default.default.randomUUID(), ...file };
|
|
863
|
+
this.cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
864
|
+
if (this.queue) {
|
|
865
|
+
try {
|
|
866
|
+
await this.queue.run(
|
|
867
|
+
async () => {
|
|
868
|
+
return this.task?.(resolvedFile);
|
|
869
|
+
},
|
|
870
|
+
{ controller }
|
|
871
|
+
);
|
|
872
|
+
} catch {
|
|
873
|
+
return resolvedFile;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return resolvedFile;
|
|
877
|
+
}
|
|
878
|
+
addOrAppend(file) {
|
|
879
|
+
const previousCaches = this.cache.get(file.path);
|
|
880
|
+
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
881
|
+
if (previousCache) {
|
|
882
|
+
this.cache.delete(previousCache.path);
|
|
883
|
+
return this.add({
|
|
884
|
+
...file,
|
|
885
|
+
source: previousCache.source && file.source ? `${previousCache.source}
|
|
886
|
+
${file.source}` : "",
|
|
887
|
+
imports: [...previousCache.imports || [], ...file.imports || []],
|
|
888
|
+
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
889
|
+
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
return this.add(file);
|
|
893
|
+
}
|
|
894
|
+
append(path, file) {
|
|
895
|
+
const previousFiles = this.cache.get(path) || [];
|
|
896
|
+
this.cache.set(path, [...previousFiles, file]);
|
|
897
|
+
}
|
|
898
|
+
getCacheByUUID(UUID) {
|
|
899
|
+
let cache;
|
|
900
|
+
this.cache.forEach((files) => {
|
|
901
|
+
cache = files.find((item) => item.id === UUID);
|
|
902
|
+
});
|
|
903
|
+
return cache;
|
|
904
|
+
}
|
|
905
|
+
get(path) {
|
|
906
|
+
return this.cache.get(path);
|
|
907
|
+
}
|
|
908
|
+
remove(path) {
|
|
909
|
+
const cacheItem = this.get(path);
|
|
910
|
+
if (!cacheItem) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
this.cache.delete(path);
|
|
914
|
+
}
|
|
915
|
+
async write(...params) {
|
|
916
|
+
if (this.queue) {
|
|
917
|
+
return this.queue.run(async () => {
|
|
918
|
+
return write(...params);
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
return write(...params);
|
|
922
|
+
}
|
|
923
|
+
async read(...params) {
|
|
924
|
+
if (this.queue) {
|
|
925
|
+
return this.queue.run(async () => {
|
|
926
|
+
return read(...params);
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return read(...params);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
function createPlugin(factory) {
|
|
933
|
+
return (options) => {
|
|
934
|
+
const plugin = factory(options);
|
|
935
|
+
if (Array.isArray(plugin)) {
|
|
936
|
+
throw new Error("Not implemented");
|
|
937
|
+
}
|
|
938
|
+
if (!plugin.transform) {
|
|
939
|
+
plugin.transform = function transform(code) {
|
|
940
|
+
return code;
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
return plugin;
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
var pluginName = "core";
|
|
947
|
+
var definePlugin = createPlugin((options) => {
|
|
948
|
+
const { fileManager, resolvePath, resolveName, logger } = options;
|
|
949
|
+
return {
|
|
950
|
+
name: pluginName,
|
|
951
|
+
options,
|
|
952
|
+
api() {
|
|
953
|
+
return {
|
|
954
|
+
get config() {
|
|
955
|
+
return options.config;
|
|
956
|
+
},
|
|
957
|
+
logger,
|
|
958
|
+
fileManager,
|
|
959
|
+
async addFile(...files) {
|
|
960
|
+
return Promise.all(
|
|
961
|
+
files.map((file) => {
|
|
962
|
+
if (file.override) {
|
|
963
|
+
return fileManager.add(file);
|
|
964
|
+
}
|
|
965
|
+
return fileManager.addOrAppend(file);
|
|
966
|
+
})
|
|
967
|
+
);
|
|
968
|
+
},
|
|
969
|
+
resolvePath,
|
|
970
|
+
resolveName: (params) => {
|
|
971
|
+
const name = resolveName(params);
|
|
972
|
+
return transformReservedWord(name);
|
|
973
|
+
},
|
|
974
|
+
cache: createPluginCache()
|
|
975
|
+
};
|
|
976
|
+
},
|
|
977
|
+
resolvePath(fileName) {
|
|
978
|
+
const root = pathParser2__default.default.resolve(this.config.root, this.config.output.path);
|
|
979
|
+
return pathParser2__default.default.resolve(root, fileName);
|
|
980
|
+
},
|
|
981
|
+
resolveName(name) {
|
|
982
|
+
return name;
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
// src/managers/pluginManager/ParallelPluginError.ts
|
|
988
|
+
var ParallelPluginError = class extends Error {
|
|
989
|
+
errors = [];
|
|
990
|
+
pluginManager;
|
|
991
|
+
constructor(message, options) {
|
|
992
|
+
super(message, { cause: options.cause });
|
|
993
|
+
this.name = "ParallelPluginError";
|
|
994
|
+
this.errors = options.errors;
|
|
995
|
+
this.pluginManager = options.pluginManager;
|
|
996
|
+
}
|
|
997
|
+
findError(searchError) {
|
|
998
|
+
if (!searchError) {
|
|
999
|
+
return void 0;
|
|
1000
|
+
}
|
|
1001
|
+
return this.errors.find((error) => {
|
|
1002
|
+
if (error.cause) {
|
|
1003
|
+
if (error.cause.name == searchError.name) {
|
|
1004
|
+
return true;
|
|
1005
|
+
}
|
|
1006
|
+
return !!this.findError(error.cause);
|
|
1007
|
+
}
|
|
1008
|
+
return error.name === searchError.name;
|
|
1009
|
+
})?.cause;
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// src/managers/pluginManager/PluginError.ts
|
|
1014
|
+
var PluginError = class extends Error {
|
|
1015
|
+
pluginManager;
|
|
1016
|
+
cause;
|
|
1017
|
+
constructor(message, options) {
|
|
1018
|
+
super(message, { cause: options.cause });
|
|
1019
|
+
this.name = "PluginError";
|
|
1020
|
+
this.cause = options.cause;
|
|
1021
|
+
this.pluginManager = options.pluginManager;
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
var EventEmitter = class {
|
|
1025
|
+
emitter = new events.EventEmitter();
|
|
1026
|
+
emit(eventName, ...eventArg) {
|
|
1027
|
+
this.emitter.emit(eventName, ...eventArg);
|
|
1028
|
+
}
|
|
1029
|
+
on(eventName, handler) {
|
|
1030
|
+
this.emitter.on(eventName, handler);
|
|
1031
|
+
}
|
|
1032
|
+
off(eventName, handler) {
|
|
1033
|
+
this.emitter.off(eventName, handler);
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
// src/managers/pluginManager/pluginParser.ts
|
|
1038
|
+
function pluginParser(plugin, context) {
|
|
1039
|
+
if (plugin.api && typeof plugin.api === "function") {
|
|
1040
|
+
const api = plugin.api.call(context);
|
|
1041
|
+
return {
|
|
1042
|
+
...plugin,
|
|
1043
|
+
api
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// src/managers/pluginManager/PluginManager.ts
|
|
1050
|
+
var hookNames = {
|
|
1051
|
+
validate: 1,
|
|
1052
|
+
buildStart: 1,
|
|
1053
|
+
resolvePath: 1,
|
|
1054
|
+
resolveName: 1,
|
|
1055
|
+
load: 1,
|
|
1056
|
+
transform: 1,
|
|
1057
|
+
writeFile: 1,
|
|
1058
|
+
buildEnd: 1
|
|
1059
|
+
};
|
|
1060
|
+
var hooks = Object.keys(hookNames);
|
|
1061
|
+
var PluginManager = class {
|
|
1062
|
+
plugins;
|
|
1063
|
+
fileManager;
|
|
1064
|
+
core;
|
|
1065
|
+
queue;
|
|
1066
|
+
executed = [];
|
|
1067
|
+
logger;
|
|
1068
|
+
eventEmitter = new EventEmitter();
|
|
1069
|
+
constructor(config, options) {
|
|
1070
|
+
this.logger = options.logger;
|
|
1071
|
+
this.queue = new Queue(50, options.debug);
|
|
1072
|
+
this.fileManager = new FileManager({ task: options.task, queue: this.queue });
|
|
1073
|
+
const core = definePlugin({
|
|
1074
|
+
config,
|
|
1075
|
+
logger: this.logger,
|
|
1076
|
+
fileManager: this.fileManager,
|
|
1077
|
+
resolvePath: this.resolvePath,
|
|
1078
|
+
resolveName: this.resolveName
|
|
1079
|
+
});
|
|
1080
|
+
this.core = pluginParser(core, core.api.call(null));
|
|
1081
|
+
this.plugins = [this.core, ...config.plugins || []].reduce((prev, plugin) => {
|
|
1082
|
+
const convertedApi = pluginParser(plugin, this.core?.api);
|
|
1083
|
+
if (convertedApi) {
|
|
1084
|
+
return [...prev, convertedApi];
|
|
1085
|
+
}
|
|
1086
|
+
return [...prev, plugin];
|
|
1087
|
+
}, []);
|
|
1088
|
+
}
|
|
1089
|
+
resolvePath = (params) => {
|
|
1090
|
+
if (params.pluginName) {
|
|
1091
|
+
return this.hookForPluginSync({
|
|
1092
|
+
pluginName: params.pluginName,
|
|
1093
|
+
hookName: "resolvePath",
|
|
1094
|
+
parameters: [params.fileName, params.directory, params.options]
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
return this.hookFirstSync({
|
|
1098
|
+
hookName: "resolvePath",
|
|
1099
|
+
parameters: [params.fileName, params.directory, params.options]
|
|
1100
|
+
}).result;
|
|
1101
|
+
};
|
|
1102
|
+
resolveName = (params) => {
|
|
1103
|
+
if (params.pluginName) {
|
|
1104
|
+
return this.hookForPluginSync({
|
|
1105
|
+
pluginName: params.pluginName,
|
|
1106
|
+
hookName: "resolveName",
|
|
1107
|
+
parameters: [params.name]
|
|
1108
|
+
}) || params.name;
|
|
1109
|
+
}
|
|
1110
|
+
return this.hookFirstSync({
|
|
1111
|
+
hookName: "resolveName",
|
|
1112
|
+
parameters: [params.name]
|
|
1113
|
+
}).result;
|
|
1114
|
+
};
|
|
1115
|
+
on(eventName, handler) {
|
|
1116
|
+
this.eventEmitter.on(eventName, handler);
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
*
|
|
1120
|
+
* Run only hook for a specific plugin name
|
|
1121
|
+
*/
|
|
1122
|
+
hookForPlugin({
|
|
1123
|
+
pluginName: pluginName2,
|
|
1124
|
+
hookName,
|
|
1125
|
+
parameters
|
|
1126
|
+
}) {
|
|
1127
|
+
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1128
|
+
return this.execute({
|
|
1129
|
+
strategy: "hookFirst",
|
|
1130
|
+
hookName,
|
|
1131
|
+
parameters,
|
|
1132
|
+
plugin
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
hookForPluginSync({
|
|
1136
|
+
pluginName: pluginName2,
|
|
1137
|
+
hookName,
|
|
1138
|
+
parameters
|
|
1139
|
+
}) {
|
|
1140
|
+
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1141
|
+
return this.executeSync({
|
|
1142
|
+
strategy: "hookFirst",
|
|
1143
|
+
hookName,
|
|
1144
|
+
parameters,
|
|
1145
|
+
plugin
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
*
|
|
1150
|
+
* Chains, first non-null result stops and returns
|
|
1151
|
+
*/
|
|
1152
|
+
hookFirst({
|
|
1153
|
+
hookName,
|
|
1154
|
+
parameters,
|
|
1155
|
+
skipped
|
|
1156
|
+
}) {
|
|
1157
|
+
let promise = Promise.resolve(null);
|
|
1158
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
1159
|
+
if (skipped && skipped.has(plugin)) {
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
promise = promise.then(async (parseResult) => {
|
|
1163
|
+
if (parseResult?.result != null) {
|
|
1164
|
+
return parseResult;
|
|
1165
|
+
}
|
|
1166
|
+
const value = await this.execute({
|
|
1167
|
+
strategy: "hookFirst",
|
|
1168
|
+
hookName,
|
|
1169
|
+
parameters,
|
|
1170
|
+
plugin
|
|
1171
|
+
});
|
|
1172
|
+
return Promise.resolve({
|
|
1173
|
+
plugin,
|
|
1174
|
+
result: value
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
return promise;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
*
|
|
1182
|
+
* Chains, first non-null result stops and returns
|
|
1183
|
+
*/
|
|
1184
|
+
hookFirstSync({
|
|
1185
|
+
hookName,
|
|
1186
|
+
parameters,
|
|
1187
|
+
skipped
|
|
1188
|
+
}) {
|
|
1189
|
+
let parseResult = null;
|
|
1190
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
1191
|
+
if (skipped && skipped.has(plugin)) {
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
1194
|
+
parseResult = {
|
|
1195
|
+
result: this.executeSync({
|
|
1196
|
+
strategy: "hookFirst",
|
|
1197
|
+
hookName,
|
|
1198
|
+
parameters,
|
|
1199
|
+
plugin
|
|
1200
|
+
}),
|
|
1201
|
+
plugin
|
|
1202
|
+
};
|
|
1203
|
+
if (parseResult?.result != null) {
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return parseResult;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
*
|
|
1211
|
+
* Parallel, runs all plugins
|
|
1212
|
+
*/
|
|
1213
|
+
async hookParallel({
|
|
1214
|
+
hookName,
|
|
1215
|
+
parameters
|
|
1216
|
+
}) {
|
|
1217
|
+
const parallelPromises = [];
|
|
1218
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
1219
|
+
const promise = this.execute({ strategy: "hookParallel", hookName, parameters, plugin });
|
|
1220
|
+
if (promise) {
|
|
1221
|
+
parallelPromises.push(promise);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
const results = await Promise.allSettled(parallelPromises);
|
|
1225
|
+
const errors = results.map((result) => {
|
|
1226
|
+
if (isPromiseRejectedResult(result) && result.reason instanceof PluginError) {
|
|
1227
|
+
return result.reason;
|
|
1228
|
+
}
|
|
1229
|
+
return void 0;
|
|
1230
|
+
}).filter(Boolean);
|
|
1231
|
+
if (errors.length) {
|
|
1232
|
+
throw new ParallelPluginError("Error", { errors, pluginManager: this });
|
|
1233
|
+
}
|
|
1234
|
+
return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
*
|
|
1238
|
+
* Chains, reduces returned value, handling the reduced value as the first hook argument
|
|
1239
|
+
*/
|
|
1240
|
+
hookReduceArg0({
|
|
1241
|
+
hookName,
|
|
1242
|
+
parameters,
|
|
1243
|
+
reduce
|
|
1244
|
+
}) {
|
|
1245
|
+
const [argument0, ...rest] = parameters;
|
|
1246
|
+
let promise = Promise.resolve(argument0);
|
|
1247
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
1248
|
+
promise = promise.then((arg0) => {
|
|
1249
|
+
const value = this.execute({
|
|
1250
|
+
strategy: "hookReduceArg0",
|
|
1251
|
+
hookName,
|
|
1252
|
+
parameters: [arg0, ...rest],
|
|
1253
|
+
plugin
|
|
1254
|
+
});
|
|
1255
|
+
return value;
|
|
1256
|
+
}).then((result) => reduce.call(this.core.api, argument0, result, plugin));
|
|
1257
|
+
}
|
|
1258
|
+
return promise;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Chains plugins
|
|
1262
|
+
*/
|
|
1263
|
+
hookSeq({ hookName, parameters }) {
|
|
1264
|
+
let promise = Promise.resolve();
|
|
1265
|
+
for (const plugin of this.getSortedPlugins(hookName)) {
|
|
1266
|
+
promise = promise.then(
|
|
1267
|
+
() => this.execute({
|
|
1268
|
+
strategy: "hookSeq",
|
|
1269
|
+
hookName,
|
|
1270
|
+
parameters,
|
|
1271
|
+
plugin
|
|
1272
|
+
})
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
return promise.then(noReturn);
|
|
1276
|
+
}
|
|
1277
|
+
getSortedPlugins(_hookName) {
|
|
1278
|
+
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1279
|
+
return plugins;
|
|
1280
|
+
}
|
|
1281
|
+
getPlugin(hookName, pluginName2) {
|
|
1282
|
+
const plugins = [...this.plugins];
|
|
1283
|
+
const pluginByPluginName = plugins.find((item) => item.name === pluginName2 && item[hookName]);
|
|
1284
|
+
if (!pluginByPluginName) {
|
|
1285
|
+
return this.core;
|
|
1286
|
+
}
|
|
1287
|
+
return pluginByPluginName;
|
|
1288
|
+
}
|
|
1289
|
+
addExecutedToCallStack(executer) {
|
|
1290
|
+
if (executer) {
|
|
1291
|
+
this.eventEmitter.emit("execute", executer);
|
|
1292
|
+
this.executed.push(executer);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Run an async plugin hook and return the result.
|
|
1297
|
+
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
1298
|
+
* @param args Arguments passed to the plugin hook.
|
|
1299
|
+
* @param plugin The actual pluginObject to run.
|
|
1300
|
+
*/
|
|
1301
|
+
// Implementation signature
|
|
1302
|
+
execute({
|
|
1303
|
+
strategy,
|
|
1304
|
+
hookName,
|
|
1305
|
+
parameters,
|
|
1306
|
+
plugin
|
|
1307
|
+
}) {
|
|
1308
|
+
const hook = plugin[hookName];
|
|
1309
|
+
let output;
|
|
1310
|
+
if (!hook) {
|
|
1311
|
+
return null;
|
|
1312
|
+
}
|
|
1313
|
+
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1314
|
+
const task = Promise.resolve().then(() => {
|
|
1315
|
+
if (typeof hook === "function") {
|
|
1316
|
+
const possiblePromiseResult = hook.apply(this.core.api, parameters);
|
|
1317
|
+
if (isPromise(possiblePromiseResult)) {
|
|
1318
|
+
return Promise.resolve(possiblePromiseResult);
|
|
1319
|
+
}
|
|
1320
|
+
return possiblePromiseResult;
|
|
1321
|
+
}
|
|
1322
|
+
return hook;
|
|
1323
|
+
}).then((result) => {
|
|
1324
|
+
output = result;
|
|
1325
|
+
return result;
|
|
1326
|
+
}).catch((e) => {
|
|
1327
|
+
this.catcher(e, plugin, hookName);
|
|
1328
|
+
return null;
|
|
1329
|
+
}).finally(() => {
|
|
1330
|
+
this.addExecutedToCallStack({
|
|
1331
|
+
parameters,
|
|
1332
|
+
output,
|
|
1333
|
+
strategy,
|
|
1334
|
+
hookName,
|
|
1335
|
+
plugin
|
|
1336
|
+
});
|
|
1337
|
+
});
|
|
1338
|
+
return task;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Run a sync plugin hook and return the result.
|
|
1342
|
+
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
1343
|
+
* @param args Arguments passed to the plugin hook.
|
|
1344
|
+
* @param plugin The acutal plugin
|
|
1345
|
+
* @param replaceContext When passed, the plugin context can be overridden.
|
|
1346
|
+
*/
|
|
1347
|
+
executeSync({
|
|
1348
|
+
strategy,
|
|
1349
|
+
hookName,
|
|
1350
|
+
parameters,
|
|
1351
|
+
plugin
|
|
1352
|
+
}) {
|
|
1353
|
+
const hook = plugin[hookName];
|
|
1354
|
+
let output;
|
|
1355
|
+
if (!hook) {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1359
|
+
try {
|
|
1360
|
+
if (typeof hook === "function") {
|
|
1361
|
+
const fn = hook.apply(this.core.api, parameters);
|
|
1362
|
+
output = fn;
|
|
1363
|
+
return fn;
|
|
1364
|
+
}
|
|
1365
|
+
output = hook;
|
|
1366
|
+
return hook;
|
|
1367
|
+
} catch (e) {
|
|
1368
|
+
this.catcher(e, plugin, hookName);
|
|
1369
|
+
return null;
|
|
1370
|
+
} finally {
|
|
1371
|
+
this.addExecutedToCallStack({
|
|
1372
|
+
parameters,
|
|
1373
|
+
output,
|
|
1374
|
+
strategy,
|
|
1375
|
+
hookName,
|
|
1376
|
+
plugin
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
catcher(e, plugin, hookName) {
|
|
1381
|
+
const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
|
|
1382
|
+
`;
|
|
1383
|
+
const pluginError = new PluginError(text, { cause: e, pluginManager: this });
|
|
1384
|
+
this.eventEmitter.emit("error", pluginError);
|
|
1385
|
+
throw pluginError;
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
function noReturn() {
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// src/managers/pluginManager/validate.ts
|
|
1392
|
+
var ValidationPluginError = class extends Error {
|
|
1393
|
+
};
|
|
1394
|
+
function validatePlugins(plugins, dependedPluginNames) {
|
|
1395
|
+
let pluginNames = [];
|
|
1396
|
+
if (typeof dependedPluginNames === "string") {
|
|
1397
|
+
pluginNames = [dependedPluginNames];
|
|
1398
|
+
} else {
|
|
1399
|
+
pluginNames = dependedPluginNames;
|
|
1400
|
+
}
|
|
1401
|
+
pluginNames.forEach((pluginName2) => {
|
|
1402
|
+
const exists = plugins.some((plugin) => plugin.name === pluginName2);
|
|
1403
|
+
if (!exists) {
|
|
1404
|
+
throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
return true;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
// src/types.ts
|
|
1411
|
+
var LogLevel = {
|
|
1412
|
+
silent: "silent",
|
|
1413
|
+
info: "info",
|
|
1414
|
+
debug: "debug"
|
|
1415
|
+
};
|
|
1416
|
+
|
|
1417
|
+
// src/build.ts
|
|
1418
|
+
async function transformReducer(_previousCode, result, _plugin) {
|
|
1419
|
+
return result;
|
|
1420
|
+
}
|
|
1421
|
+
async function build(options) {
|
|
1422
|
+
const { config, logLevel, logger = createLogger() } = options;
|
|
1423
|
+
try {
|
|
1424
|
+
if (!URLPath.isURL(config.input.path)) {
|
|
1425
|
+
await read(config.input.path);
|
|
1426
|
+
}
|
|
1427
|
+
} catch (e) {
|
|
1428
|
+
throw new Error(
|
|
1429
|
+
"Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + pc3__default.default.dim(config.input.path),
|
|
1430
|
+
{
|
|
1431
|
+
cause: e
|
|
1432
|
+
}
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
if (config.output.clean) {
|
|
1436
|
+
await clean(config.output.path);
|
|
1437
|
+
}
|
|
1438
|
+
const queueTask = async (file) => {
|
|
1439
|
+
const { path } = file;
|
|
1440
|
+
let code = getFileSource(file);
|
|
1441
|
+
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
1442
|
+
hookName: "load",
|
|
1443
|
+
parameters: [path]
|
|
1444
|
+
});
|
|
1445
|
+
if (loadedResult && isPromise(loadedResult)) {
|
|
1446
|
+
code = await loadedResult;
|
|
1447
|
+
}
|
|
1448
|
+
if (loadedResult && !isPromise(loadedResult)) {
|
|
1449
|
+
code = loadedResult;
|
|
1450
|
+
}
|
|
1451
|
+
if (code) {
|
|
1452
|
+
const transformedCode = await pluginManager.hookReduceArg0({
|
|
1453
|
+
hookName: "transform",
|
|
1454
|
+
parameters: [code, path],
|
|
1455
|
+
reduce: transformReducer
|
|
1456
|
+
});
|
|
1457
|
+
if (config.output.write || config.output.write === void 0) {
|
|
1458
|
+
await pluginManager.hookParallel({
|
|
1459
|
+
hookName: "writeFile",
|
|
1460
|
+
parameters: [transformedCode, path]
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const pluginManager = new PluginManager(config, { debug: logLevel === LogLevel.debug, logger, task: queueTask });
|
|
1466
|
+
const { plugins, fileManager } = pluginManager;
|
|
1467
|
+
pluginManager.on("execute", (executer) => {
|
|
1468
|
+
const { hookName, plugin, output, parameters } = executer;
|
|
1469
|
+
const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`;
|
|
1470
|
+
if (logLevel === LogLevel.info) {
|
|
1471
|
+
if (logger.spinner) {
|
|
1472
|
+
logger.spinner.suffixText = messsage;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
if (logLevel === LogLevel.debug) {
|
|
1476
|
+
logger.info(messsage);
|
|
1477
|
+
const logs = [
|
|
1478
|
+
parameters && `${pc3__default.default.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
|
|
1479
|
+
JSON.stringify(parameters, void 0, 2),
|
|
1480
|
+
output && `${pc3__default.default.bgWhite("Output")} ${randomPicoColour(plugin.name)} ${hookName}`,
|
|
1481
|
+
output
|
|
1482
|
+
].filter(Boolean);
|
|
1483
|
+
console.log(logs.join("\n"));
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
await pluginManager.hookParallel({
|
|
1487
|
+
hookName: "validate",
|
|
1488
|
+
parameters: [plugins]
|
|
1489
|
+
});
|
|
1490
|
+
await pluginManager.hookParallel({
|
|
1491
|
+
hookName: "buildStart",
|
|
1492
|
+
parameters: [config]
|
|
1493
|
+
});
|
|
1494
|
+
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
1495
|
+
return { files: fileManager.files.map((file) => ({ ...file, source: getFileSource(file) })), pluginManager };
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
// src/config.ts
|
|
1499
|
+
function defineConfig(options) {
|
|
1500
|
+
return options;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// src/generators/Generator.ts
|
|
1504
|
+
var Generator = class {
|
|
1505
|
+
_options = {};
|
|
1506
|
+
constructor(options = {}) {
|
|
1507
|
+
if (options) {
|
|
1508
|
+
this._options = {
|
|
1509
|
+
...this._options,
|
|
1510
|
+
...options
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
return this;
|
|
1514
|
+
}
|
|
1515
|
+
get options() {
|
|
1516
|
+
return this._options;
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
// src/generators/SchemaGenerator.ts
|
|
1521
|
+
var SchemaGenerator = class extends Generator {
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
// src/index.ts
|
|
1525
|
+
var src_default = build;
|
|
1526
|
+
|
|
1527
|
+
Object.defineProperty(exports, 'pc', {
|
|
1528
|
+
enumerable: true,
|
|
1529
|
+
get: function () { return pc3__default.default; }
|
|
1530
|
+
});
|
|
1531
|
+
exports.FileManager = FileManager;
|
|
1532
|
+
exports.Generator = Generator;
|
|
1533
|
+
exports.LogLevel = LogLevel;
|
|
1534
|
+
exports.ParallelPluginError = ParallelPluginError;
|
|
1535
|
+
exports.PluginError = PluginError;
|
|
1536
|
+
exports.PluginManager = PluginManager;
|
|
1537
|
+
exports.Queue = Queue;
|
|
1538
|
+
exports.SchemaGenerator = SchemaGenerator;
|
|
1539
|
+
exports.SummaryError = SummaryError;
|
|
1540
|
+
exports.TreeNode = TreeNode;
|
|
1541
|
+
exports.URLPath = URLPath;
|
|
1542
|
+
exports.ValidationPluginError = ValidationPluginError;
|
|
1543
|
+
exports.Warning = Warning;
|
|
1544
|
+
exports.build = build;
|
|
1545
|
+
exports.clean = clean;
|
|
1546
|
+
exports.combineFiles = combineFiles;
|
|
1547
|
+
exports.createJSDocBlockText = createJSDocBlockText;
|
|
1548
|
+
exports.createLogger = createLogger;
|
|
1549
|
+
exports.createPlugin = createPlugin;
|
|
1550
|
+
exports.createPluginCache = createPluginCache;
|
|
1551
|
+
exports.default = src_default;
|
|
1552
|
+
exports.defaultColours = defaultColours;
|
|
1553
|
+
exports.defineConfig = defineConfig;
|
|
1554
|
+
exports.extensions = extensions;
|
|
1555
|
+
exports.getEncodedText = getEncodedText;
|
|
1556
|
+
exports.getFileSource = getFileSource;
|
|
1557
|
+
exports.getIndexes = getIndexes;
|
|
1558
|
+
exports.getLocation = getLocation;
|
|
1559
|
+
exports.getPathMode = getPathMode;
|
|
1560
|
+
exports.getRelativePath = getRelativePath;
|
|
1561
|
+
exports.getUniqueName = getUniqueName;
|
|
1562
|
+
exports.hooks = hooks;
|
|
1563
|
+
exports.importModule = importModule;
|
|
1564
|
+
exports.isExtensionAllowed = isExtensionAllowed;
|
|
1565
|
+
exports.isPromise = isPromise;
|
|
1566
|
+
exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
|
|
1567
|
+
exports.isPromiseRejectedResult = isPromiseRejectedResult;
|
|
1568
|
+
exports.name = pluginName;
|
|
1569
|
+
exports.nameSorter = nameSorter;
|
|
1570
|
+
exports.normalizeDirectory = normalizeDirectory;
|
|
1571
|
+
exports.objectToParameters = objectToParameters;
|
|
1572
|
+
exports.pluginName = pluginName;
|
|
1573
|
+
exports.randomColour = randomColour;
|
|
1574
|
+
exports.randomPicoColour = randomPicoColour;
|
|
1575
|
+
exports.read = read;
|
|
1576
|
+
exports.renderTemplate = renderTemplate;
|
|
1577
|
+
exports.throttle = throttle;
|
|
1578
|
+
exports.timeout = timeout;
|
|
1579
|
+
exports.transformReservedWord = transformReservedWord;
|
|
1580
|
+
exports.uniqueIdFactory = uniqueIdFactory;
|
|
1581
|
+
exports.validatePlugins = validatePlugins;
|
|
1582
|
+
exports.write = write;
|
|
1583
|
+
//# sourceMappingURL=out.js.map
|
|
1584
|
+
//# sourceMappingURL=index.cjs.map
|