@kubb/core 1.15.0-canary.20231020T203214 → 1.15.0-canary.20231021T230927
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/README.md +16 -17
- package/dist/index.cjs +506 -494
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -217
- package/dist/index.d.ts +202 -217
- package/dist/index.js +508 -493
- package/dist/index.js.map +1 -1
- package/globals.d.ts +4 -4
- package/package.json +3 -3
- package/schema.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,21 +4,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var pc3 = require('picocolors');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
|
+
var fs2 = require('fs-extra');
|
|
8
|
+
var changeCase = require('change-case');
|
|
9
|
+
var naturalOrderby = require('natural-orderby');
|
|
10
|
+
var perf_hooks = require('perf_hooks');
|
|
11
|
+
var seedrandom = require('seedrandom');
|
|
7
12
|
var path2 = require('path');
|
|
8
|
-
var fs = require('fs-extra');
|
|
9
13
|
var jsRuntime = require('js-runtime');
|
|
10
|
-
var perf_hooks = require('perf_hooks');
|
|
11
14
|
var dirTree = require('directory-tree');
|
|
12
|
-
var mod = require('module');
|
|
13
|
-
var os = require('os');
|
|
14
|
-
var url = require('url');
|
|
15
|
-
var seedrandom = require('seedrandom');
|
|
16
|
-
var changeCase = require('change-case');
|
|
17
|
-
var naturalOrderby = require('natural-orderby');
|
|
18
15
|
var parser = require('@kubb/parser');
|
|
19
16
|
var isEqual = require('lodash.isequal');
|
|
20
17
|
var events = require('events');
|
|
21
|
-
var
|
|
18
|
+
var mod = require('module');
|
|
19
|
+
var os = require('os');
|
|
20
|
+
var url = require('url');
|
|
21
|
+
var process = require('process');
|
|
22
22
|
var fs3 = require('fs');
|
|
23
23
|
var semver = require('semver');
|
|
24
24
|
|
|
@@ -26,14 +26,14 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
26
26
|
|
|
27
27
|
var pc3__default = /*#__PURE__*/_interopDefault(pc3);
|
|
28
28
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
29
|
+
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
30
|
+
var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
|
|
29
31
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
30
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
31
32
|
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
|
|
33
|
+
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
32
34
|
var mod__default = /*#__PURE__*/_interopDefault(mod);
|
|
33
35
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
34
|
-
var
|
|
35
|
-
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
36
|
-
var process2__default = /*#__PURE__*/_interopDefault(process2);
|
|
36
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
37
37
|
var fs3__default = /*#__PURE__*/_interopDefault(fs3);
|
|
38
38
|
|
|
39
39
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -44,49 +44,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
44
44
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
// src/utils/isPromise.ts
|
|
48
|
-
function isPromise(result) {
|
|
49
|
-
return typeof result?.then === "function";
|
|
50
|
-
}
|
|
51
|
-
function isPromiseFulfilledResult(result) {
|
|
52
|
-
return result.status === "fulfilled";
|
|
53
|
-
}
|
|
54
|
-
function isPromiseRejectedResult(result) {
|
|
55
|
-
return result.status === "rejected";
|
|
56
|
-
}
|
|
57
|
-
async function saveCreateDirectory(path3) {
|
|
58
|
-
const passedPath = path2__default.default.dirname(path2__default.default.resolve(path3));
|
|
59
|
-
await fs__default.default.mkdir(passedPath, { recursive: true });
|
|
60
|
-
}
|
|
61
|
-
var writer = jsRuntime.switcher(
|
|
62
|
-
{
|
|
63
|
-
node: async (path3, data) => {
|
|
64
|
-
try {
|
|
65
|
-
await fs__default.default.stat(path3);
|
|
66
|
-
const oldContent = await fs__default.default.readFile(path3, { encoding: "utf-8" });
|
|
67
|
-
if (oldContent?.toString() === data) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
} catch (_err) {
|
|
71
|
-
}
|
|
72
|
-
await saveCreateDirectory(path3);
|
|
73
|
-
return fs__default.default.writeFile(path2__default.default.resolve(path3), data, { encoding: "utf-8" });
|
|
74
|
-
},
|
|
75
|
-
bun: async (path3, data) => {
|
|
76
|
-
try {
|
|
77
|
-
await saveCreateDirectory(path3);
|
|
78
|
-
await Bun.write(path2__default.default.resolve(path3), data);
|
|
79
|
-
} catch (e) {
|
|
80
|
-
console.log(e, path2__default.default.resolve(path3));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"node"
|
|
85
|
-
);
|
|
86
|
-
async function write(data, path3) {
|
|
87
|
-
return writer(path3, data);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
47
|
// src/utils/cache.ts
|
|
91
48
|
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
92
49
|
return {
|
|
@@ -114,6 +71,211 @@ function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
|
114
71
|
}
|
|
115
72
|
};
|
|
116
73
|
}
|
|
74
|
+
async function clean(path3) {
|
|
75
|
+
return fs2.remove(path3);
|
|
76
|
+
}
|
|
77
|
+
var FunctionParams = class {
|
|
78
|
+
type;
|
|
79
|
+
items = [];
|
|
80
|
+
constructor(type) {
|
|
81
|
+
this.type = type;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
add(item) {
|
|
85
|
+
if (!item) {
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
if (Array.isArray(item)) {
|
|
89
|
+
item.filter(Boolean).forEach((it) => this.items.push(it));
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
this.items.push(item);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
toString() {
|
|
96
|
+
const sortedData = naturalOrderby.orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
97
|
+
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
98
|
+
if (!name) {
|
|
99
|
+
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
100
|
+
return acc;
|
|
101
|
+
}
|
|
102
|
+
const parameterName = name.startsWith("{") ? name : changeCase.camelCase(name, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
103
|
+
if (type) {
|
|
104
|
+
if (required) {
|
|
105
|
+
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
106
|
+
} else {
|
|
107
|
+
acc.push(`${parameterName}?: ${type}`);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
acc.push(`${parameterName}`);
|
|
111
|
+
}
|
|
112
|
+
return acc;
|
|
113
|
+
}, []).join(", ");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/utils/getUniqueName.ts
|
|
118
|
+
function getUniqueName(originalName, data) {
|
|
119
|
+
let used = data[originalName] || 0;
|
|
120
|
+
if (used) {
|
|
121
|
+
data[originalName] = ++used;
|
|
122
|
+
originalName += used;
|
|
123
|
+
}
|
|
124
|
+
data[originalName] = 1;
|
|
125
|
+
return originalName;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/utils/isPromise.ts
|
|
129
|
+
function isPromise(result) {
|
|
130
|
+
return typeof result?.then === "function";
|
|
131
|
+
}
|
|
132
|
+
function isPromiseFulfilledResult(result) {
|
|
133
|
+
return result.status === "fulfilled";
|
|
134
|
+
}
|
|
135
|
+
function isPromiseRejectedResult(result) {
|
|
136
|
+
return result.status === "rejected";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/utils/jsdoc.ts
|
|
140
|
+
function createJSDocBlockText({ comments }) {
|
|
141
|
+
const filteredComments = comments.filter(Boolean);
|
|
142
|
+
if (!filteredComments.length) {
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
return `/**
|
|
146
|
+
* ${filteredComments.join("\n * ")}
|
|
147
|
+
*/`;
|
|
148
|
+
}
|
|
149
|
+
function createLogger(spinner) {
|
|
150
|
+
const logs = [];
|
|
151
|
+
const log = (message) => {
|
|
152
|
+
if (message && spinner) {
|
|
153
|
+
spinner.text = message;
|
|
154
|
+
logs.push(message);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const error = (message) => {
|
|
158
|
+
if (message) {
|
|
159
|
+
throw new Error(message || "Something went wrong");
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const warn = (message) => {
|
|
163
|
+
if (message && spinner) {
|
|
164
|
+
spinner.warn(pc3__default.default.yellow(message));
|
|
165
|
+
logs.push(message);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const info = (message) => {
|
|
169
|
+
if (message && spinner) {
|
|
170
|
+
spinner.info(message);
|
|
171
|
+
logs.push(message);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const logger = {
|
|
175
|
+
log,
|
|
176
|
+
error,
|
|
177
|
+
warn,
|
|
178
|
+
info,
|
|
179
|
+
spinner,
|
|
180
|
+
logs
|
|
181
|
+
};
|
|
182
|
+
return logger;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/utils/nameSorter.ts
|
|
186
|
+
function nameSorter(a, b) {
|
|
187
|
+
if (a.name < b.name) {
|
|
188
|
+
return -1;
|
|
189
|
+
}
|
|
190
|
+
if (a.name > b.name) {
|
|
191
|
+
return 1;
|
|
192
|
+
}
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
var Queue = class {
|
|
196
|
+
#queue = [];
|
|
197
|
+
#workerCount = 0;
|
|
198
|
+
#maxParallel;
|
|
199
|
+
#debug = false;
|
|
200
|
+
constructor(maxParallel, debug = false) {
|
|
201
|
+
this.#maxParallel = maxParallel;
|
|
202
|
+
this.#debug = debug;
|
|
203
|
+
}
|
|
204
|
+
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
205
|
+
return new Promise((resolve, reject) => {
|
|
206
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
207
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
208
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
209
|
+
reject("Aborted");
|
|
210
|
+
});
|
|
211
|
+
this.#queue.push(item);
|
|
212
|
+
this.#work();
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
216
|
+
new Promise((resolve, reject) => {
|
|
217
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
218
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
219
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
220
|
+
});
|
|
221
|
+
this.#queue.push(item);
|
|
222
|
+
this.#work();
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
get hasJobs() {
|
|
226
|
+
return this.#workerCount > 0 || this.#queue.length > 0;
|
|
227
|
+
}
|
|
228
|
+
get count() {
|
|
229
|
+
return this.#workerCount;
|
|
230
|
+
}
|
|
231
|
+
#work() {
|
|
232
|
+
if (this.#workerCount >= this.#maxParallel) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.#workerCount++;
|
|
236
|
+
let entry;
|
|
237
|
+
while (entry = this.#queue.shift()) {
|
|
238
|
+
const { reject, resolve, job, name, description } = entry;
|
|
239
|
+
if (this.#debug) {
|
|
240
|
+
perf_hooks.performance.mark(name + "_start");
|
|
241
|
+
}
|
|
242
|
+
job().then((result) => {
|
|
243
|
+
resolve(result);
|
|
244
|
+
if (this.#debug) {
|
|
245
|
+
perf_hooks.performance.mark(name + "_stop");
|
|
246
|
+
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
247
|
+
}
|
|
248
|
+
}).catch((err) => reject(err));
|
|
249
|
+
}
|
|
250
|
+
this.#workerCount--;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
254
|
+
function randomColour(text, colours = defaultColours) {
|
|
255
|
+
if (!text) {
|
|
256
|
+
return "white";
|
|
257
|
+
}
|
|
258
|
+
const random = seedrandom__default.default(text);
|
|
259
|
+
const colour = colours.at(Math.floor(random() * colours.length)) || "white";
|
|
260
|
+
return colour;
|
|
261
|
+
}
|
|
262
|
+
function randomPicoColour(text, colors = defaultColours) {
|
|
263
|
+
const colours = pc3__default.default.createColors(true);
|
|
264
|
+
if (!text) {
|
|
265
|
+
return colours.white(text);
|
|
266
|
+
}
|
|
267
|
+
const colour = randomColour(text, colors);
|
|
268
|
+
const isDark = colour.includes("dark");
|
|
269
|
+
const key = colour.replace("dark", "").toLowerCase();
|
|
270
|
+
const formatter = colours[key];
|
|
271
|
+
if (isDark) {
|
|
272
|
+
return pc3__default.default.bold(formatter(text));
|
|
273
|
+
}
|
|
274
|
+
if (typeof formatter !== "function") {
|
|
275
|
+
throw new Error("Formatter for picoColor is not of type function/Formatter");
|
|
276
|
+
}
|
|
277
|
+
return formatter(text);
|
|
278
|
+
}
|
|
117
279
|
function slash(path3, platform = "linux") {
|
|
118
280
|
const isWindowsPath = /^\\\\\?\\/.test(path3);
|
|
119
281
|
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
@@ -141,7 +303,7 @@ function getPathMode(path3) {
|
|
|
141
303
|
var reader = jsRuntime.switcher(
|
|
142
304
|
{
|
|
143
305
|
node: async (path3) => {
|
|
144
|
-
return
|
|
306
|
+
return fs2__default.default.readFile(path3, { encoding: "utf8" });
|
|
145
307
|
},
|
|
146
308
|
bun: async (path3) => {
|
|
147
309
|
const file = Bun.file(path3);
|
|
@@ -153,7 +315,7 @@ var reader = jsRuntime.switcher(
|
|
|
153
315
|
var syncReader = jsRuntime.switcher(
|
|
154
316
|
{
|
|
155
317
|
node: (path3) => {
|
|
156
|
-
return
|
|
318
|
+
return fs2__default.default.readFileSync(path3, { encoding: "utf8" });
|
|
157
319
|
},
|
|
158
320
|
bun: () => {
|
|
159
321
|
throw new Error("Bun cannot read sync");
|
|
@@ -168,38 +330,66 @@ function readSync(path3) {
|
|
|
168
330
|
return syncReader(path3);
|
|
169
331
|
}
|
|
170
332
|
|
|
171
|
-
// src/utils/
|
|
172
|
-
function
|
|
173
|
-
if (
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
if (a.name > b.name) {
|
|
177
|
-
return 1;
|
|
333
|
+
// src/utils/renderTemplate.ts
|
|
334
|
+
function renderTemplate(template, data = void 0) {
|
|
335
|
+
if (!data || !Object.keys(data).length) {
|
|
336
|
+
return template.replace(/{{(.*?)}}/g, "");
|
|
178
337
|
}
|
|
179
|
-
|
|
338
|
+
const matches = template.match(/{{(.*?)}}/g);
|
|
339
|
+
return matches?.reduce((prev, curr) => {
|
|
340
|
+
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
341
|
+
if (index === void 0) {
|
|
342
|
+
return prev;
|
|
343
|
+
}
|
|
344
|
+
const value = data[index];
|
|
345
|
+
if (value === void 0) {
|
|
346
|
+
return prev;
|
|
347
|
+
}
|
|
348
|
+
return prev.replace(curr, () => {
|
|
349
|
+
if (typeof value === "boolean") {
|
|
350
|
+
return `${value.toString()}` || "false";
|
|
351
|
+
}
|
|
352
|
+
return value || "";
|
|
353
|
+
}).trim();
|
|
354
|
+
}, template) || "";
|
|
180
355
|
}
|
|
181
356
|
|
|
182
|
-
// src/utils/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
357
|
+
// src/utils/SummaryError.ts
|
|
358
|
+
var SummaryError = class extends Error {
|
|
359
|
+
summary;
|
|
360
|
+
constructor(message, options) {
|
|
361
|
+
super(message, { cause: options.cause });
|
|
362
|
+
this.name = "SummaryError";
|
|
363
|
+
this.summary = options.summary || [];
|
|
187
364
|
}
|
|
188
|
-
|
|
189
|
-
* ${filteredComments.join("\n * ")}
|
|
190
|
-
*/`;
|
|
191
|
-
}
|
|
365
|
+
};
|
|
192
366
|
|
|
193
|
-
// src/utils/
|
|
194
|
-
|
|
195
|
-
let
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
367
|
+
// src/utils/throttle.ts
|
|
368
|
+
var throttle = (fn, delay) => {
|
|
369
|
+
let wait = false;
|
|
370
|
+
let timeout2;
|
|
371
|
+
let cancelled = false;
|
|
372
|
+
return [
|
|
373
|
+
(...args) => {
|
|
374
|
+
if (cancelled) {
|
|
375
|
+
return void 0;
|
|
376
|
+
}
|
|
377
|
+
if (wait) {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
const val = fn(...args);
|
|
381
|
+
wait = true;
|
|
382
|
+
timeout2 = setTimeout(() => {
|
|
383
|
+
wait = false;
|
|
384
|
+
}, delay);
|
|
385
|
+
return val;
|
|
386
|
+
},
|
|
387
|
+
() => {
|
|
388
|
+
cancelled = true;
|
|
389
|
+
clearTimeout(timeout2);
|
|
390
|
+
}
|
|
391
|
+
];
|
|
392
|
+
};
|
|
203
393
|
|
|
204
394
|
// src/utils/timeout.ts
|
|
205
395
|
async function timeout(ms) {
|
|
@@ -209,64 +399,11 @@ async function timeout(ms) {
|
|
|
209
399
|
}, ms);
|
|
210
400
|
});
|
|
211
401
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
constructor(maxParallel, debug = false) {
|
|
218
|
-
this.#maxParallel = maxParallel;
|
|
219
|
-
this.#debug = debug;
|
|
220
|
-
}
|
|
221
|
-
run(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
222
|
-
return new Promise((resolve, reject) => {
|
|
223
|
-
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
224
|
-
options.controller?.signal.addEventListener("abort", () => {
|
|
225
|
-
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
226
|
-
reject("Aborted");
|
|
227
|
-
});
|
|
228
|
-
this.#queue.push(item);
|
|
229
|
-
this.#work();
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
runSync(job, options = { controller: new AbortController(), name: crypto__default.default.randomUUID(), description: "" }) {
|
|
233
|
-
new Promise((resolve, reject) => {
|
|
234
|
-
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
235
|
-
options.controller?.signal.addEventListener("abort", () => {
|
|
236
|
-
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
237
|
-
});
|
|
238
|
-
this.#queue.push(item);
|
|
239
|
-
this.#work();
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
get hasJobs() {
|
|
243
|
-
return this.#workerCount > 0 || this.#queue.length > 0;
|
|
244
|
-
}
|
|
245
|
-
get count() {
|
|
246
|
-
return this.#workerCount;
|
|
247
|
-
}
|
|
248
|
-
#work() {
|
|
249
|
-
if (this.#workerCount >= this.#maxParallel) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
this.#workerCount++;
|
|
253
|
-
let entry;
|
|
254
|
-
while (entry = this.#queue.shift()) {
|
|
255
|
-
const { reject, resolve, job, name, description } = entry;
|
|
256
|
-
if (this.#debug) {
|
|
257
|
-
perf_hooks.performance.mark(name + "_start");
|
|
258
|
-
}
|
|
259
|
-
job().then((result) => {
|
|
260
|
-
resolve(result);
|
|
261
|
-
if (this.#debug) {
|
|
262
|
-
perf_hooks.performance.mark(name + "_stop");
|
|
263
|
-
perf_hooks.performance.measure(description, name + "_start", name + "_stop");
|
|
264
|
-
}
|
|
265
|
-
}).catch((err) => reject(err));
|
|
266
|
-
}
|
|
267
|
-
this.#workerCount--;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
402
|
+
|
|
403
|
+
// src/utils/transformers/combineCodes.ts
|
|
404
|
+
function combineCodes(codes) {
|
|
405
|
+
return codes.join("\n");
|
|
406
|
+
}
|
|
270
407
|
|
|
271
408
|
// src/utils/transformers/escape.ts
|
|
272
409
|
function escape(text) {
|
|
@@ -385,38 +522,6 @@ function transformReservedWord(word) {
|
|
|
385
522
|
}
|
|
386
523
|
return word;
|
|
387
524
|
}
|
|
388
|
-
|
|
389
|
-
// src/utils/transformers/combineCodes.ts
|
|
390
|
-
function combineCodes(codes) {
|
|
391
|
-
return codes.join("\n");
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// src/utils/renderTemplate.ts
|
|
395
|
-
function renderTemplate(template, data = void 0) {
|
|
396
|
-
if (!data || !Object.keys(data).length) {
|
|
397
|
-
return template.replace(/{{(.*?)}}/g, "");
|
|
398
|
-
}
|
|
399
|
-
const matches = template.match(/{{(.*?)}}/g);
|
|
400
|
-
return matches?.reduce((prev, curr) => {
|
|
401
|
-
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
402
|
-
if (index === void 0) {
|
|
403
|
-
return prev;
|
|
404
|
-
}
|
|
405
|
-
const value = data[index];
|
|
406
|
-
if (value === void 0) {
|
|
407
|
-
return prev;
|
|
408
|
-
}
|
|
409
|
-
return prev.replace(curr, () => {
|
|
410
|
-
if (typeof value === "boolean") {
|
|
411
|
-
return `${value.toString()}` || "false";
|
|
412
|
-
}
|
|
413
|
-
return value || "";
|
|
414
|
-
}).trim();
|
|
415
|
-
}, template) || "";
|
|
416
|
-
}
|
|
417
|
-
async function clean(path3) {
|
|
418
|
-
return fs.remove(path3);
|
|
419
|
-
}
|
|
420
525
|
var TreeNode = class _TreeNode {
|
|
421
526
|
data;
|
|
422
527
|
parent;
|
|
@@ -507,144 +612,11 @@ var TreeNode = class _TreeNode {
|
|
|
507
612
|
|
|
508
613
|
// src/utils/uniqueIdFactory.ts
|
|
509
614
|
var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
|
|
510
|
-
var
|
|
511
|
-
function normalizeDirectory(directory) {
|
|
512
|
-
if (!SLASHES.has(directory[directory.length - 1])) {
|
|
513
|
-
return `${directory}/`;
|
|
514
|
-
}
|
|
515
|
-
return directory;
|
|
516
|
-
}
|
|
517
|
-
function getLocation(path3, cwd) {
|
|
518
|
-
let location = path3;
|
|
519
|
-
if (cwd) {
|
|
520
|
-
const require2 = mod__default.default.createRequire(normalizeDirectory(cwd));
|
|
521
|
-
location = require2.resolve(path3);
|
|
522
|
-
}
|
|
523
|
-
return location;
|
|
524
|
-
}
|
|
525
|
-
async function importModule(path3, cwd) {
|
|
526
|
-
try {
|
|
527
|
-
let location = getLocation(path3, cwd);
|
|
528
|
-
if (os__default.default.platform() == "win32") {
|
|
529
|
-
location = url.pathToFileURL(location).href;
|
|
530
|
-
}
|
|
531
|
-
const module = await import(location);
|
|
532
|
-
return module?.default ?? module;
|
|
533
|
-
} catch (e) {
|
|
534
|
-
console.log(e);
|
|
535
|
-
return void 0;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// src/utils/throttle.ts
|
|
540
|
-
var throttle = (fn, delay) => {
|
|
541
|
-
let wait = false;
|
|
542
|
-
let timeout2;
|
|
543
|
-
let cancelled = false;
|
|
544
|
-
return [
|
|
545
|
-
(...args) => {
|
|
546
|
-
if (cancelled) {
|
|
547
|
-
return void 0;
|
|
548
|
-
}
|
|
549
|
-
if (wait) {
|
|
550
|
-
return void 0;
|
|
551
|
-
}
|
|
552
|
-
const val = fn(...args);
|
|
553
|
-
wait = true;
|
|
554
|
-
timeout2 = setTimeout(() => {
|
|
555
|
-
wait = false;
|
|
556
|
-
}, delay);
|
|
557
|
-
return val;
|
|
558
|
-
},
|
|
559
|
-
() => {
|
|
560
|
-
cancelled = true;
|
|
561
|
-
clearTimeout(timeout2);
|
|
562
|
-
}
|
|
563
|
-
];
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// src/utils/SummaryError.ts
|
|
567
|
-
var SummaryError = class extends Error {
|
|
568
|
-
summary;
|
|
569
|
-
constructor(message, options) {
|
|
570
|
-
super(message, { cause: options.cause });
|
|
571
|
-
this.name = "SummaryError";
|
|
572
|
-
this.summary = options.summary || [];
|
|
573
|
-
}
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
// src/utils/Warning.ts
|
|
577
|
-
var Warning = class extends Error {
|
|
578
|
-
constructor(message, options) {
|
|
579
|
-
super(message, { cause: options?.cause });
|
|
580
|
-
this.name = "Warning";
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
function createLogger(spinner) {
|
|
584
|
-
const logs = [];
|
|
585
|
-
const log = (message) => {
|
|
586
|
-
if (message && spinner) {
|
|
587
|
-
spinner.text = message;
|
|
588
|
-
logs.push(message);
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
const error = (message) => {
|
|
592
|
-
if (message) {
|
|
593
|
-
throw new Error(message || "Something went wrong");
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
const warn = (message) => {
|
|
597
|
-
if (message && spinner) {
|
|
598
|
-
spinner.warn(pc3__default.default.yellow(message));
|
|
599
|
-
logs.push(message);
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
const info = (message) => {
|
|
603
|
-
if (message && spinner) {
|
|
604
|
-
spinner.info(message);
|
|
605
|
-
logs.push(message);
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
const logger = {
|
|
609
|
-
log,
|
|
610
|
-
error,
|
|
611
|
-
warn,
|
|
612
|
-
info,
|
|
613
|
-
spinner,
|
|
614
|
-
logs
|
|
615
|
-
};
|
|
616
|
-
return logger;
|
|
617
|
-
}
|
|
618
|
-
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
619
|
-
function randomColour(text, colours = defaultColours) {
|
|
620
|
-
if (!text) {
|
|
621
|
-
return "white";
|
|
622
|
-
}
|
|
623
|
-
const random = seedrandom__default.default(text);
|
|
624
|
-
const colour = colours.at(Math.floor(random() * colours.length)) || "white";
|
|
625
|
-
return colour;
|
|
626
|
-
}
|
|
627
|
-
function randomPicoColour(text, colors = defaultColours) {
|
|
628
|
-
const colours = pc3__default.default.createColors(true);
|
|
629
|
-
if (!text) {
|
|
630
|
-
return colours.white(text);
|
|
631
|
-
}
|
|
632
|
-
const colour = randomColour(text, colors);
|
|
633
|
-
const isDark = colour.includes("dark");
|
|
634
|
-
const key = colour.replace("dark", "").toLowerCase();
|
|
635
|
-
const formatter = colours[key];
|
|
636
|
-
if (isDark) {
|
|
637
|
-
return pc3__default.default.bold(formatter(text));
|
|
638
|
-
}
|
|
639
|
-
if (typeof formatter !== "function") {
|
|
640
|
-
throw new Error("Formatter for picoColor is not of type function/Formatter");
|
|
641
|
-
}
|
|
642
|
-
return formatter(text);
|
|
643
|
-
}
|
|
644
|
-
var URLPath = class _URLPath {
|
|
615
|
+
var URLPath = class {
|
|
645
616
|
path;
|
|
646
617
|
constructor(path3) {
|
|
647
618
|
this.path = path3;
|
|
619
|
+
return this;
|
|
648
620
|
}
|
|
649
621
|
/**
|
|
650
622
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
@@ -653,8 +625,16 @@ var URLPath = class _URLPath {
|
|
|
653
625
|
get URL() {
|
|
654
626
|
return this.toURLPath();
|
|
655
627
|
}
|
|
656
|
-
get
|
|
657
|
-
|
|
628
|
+
get isURL() {
|
|
629
|
+
try {
|
|
630
|
+
const url = new URL(this.path);
|
|
631
|
+
if (url?.href) {
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
} catch (error) {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
return false;
|
|
658
638
|
}
|
|
659
639
|
/**
|
|
660
640
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
@@ -671,17 +651,18 @@ var URLPath = class _URLPath {
|
|
|
671
651
|
get params() {
|
|
672
652
|
return this.getParams();
|
|
673
653
|
}
|
|
674
|
-
toObject(
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
654
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
655
|
+
const object = {
|
|
656
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
657
|
+
params: this.getParams()
|
|
658
|
+
};
|
|
659
|
+
if (stringify) {
|
|
660
|
+
if (type !== "template") {
|
|
661
|
+
throw new Error("Type should be `template` when using stringiyf");
|
|
662
|
+
}
|
|
663
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
664
|
+
}
|
|
665
|
+
return object;
|
|
685
666
|
}
|
|
686
667
|
/**
|
|
687
668
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
@@ -689,25 +670,22 @@ var URLPath = class _URLPath {
|
|
|
689
670
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
690
671
|
* @example /account/userID => `/account/${userId}`
|
|
691
672
|
*/
|
|
692
|
-
|
|
673
|
+
toTemplateString(replacer) {
|
|
693
674
|
const regex = /{(\w|-)*}/g;
|
|
694
|
-
const found =
|
|
695
|
-
let newPath =
|
|
675
|
+
const found = this.path.match(regex);
|
|
676
|
+
let newPath = this.path.replaceAll("{", "${");
|
|
696
677
|
if (found) {
|
|
697
678
|
newPath = found.reduce((prev, curr) => {
|
|
698
679
|
const pathParam = replacer ? replacer(changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
699
680
|
const replacement = `\${${pathParam}}`;
|
|
700
681
|
return prev.replace(curr, replacement);
|
|
701
|
-
},
|
|
682
|
+
}, this.path);
|
|
702
683
|
}
|
|
703
684
|
return `\`${newPath}\``;
|
|
704
685
|
}
|
|
705
686
|
getParams(replacer) {
|
|
706
|
-
return _URLPath.getParams(this.path, replacer);
|
|
707
|
-
}
|
|
708
|
-
static getParams(path3, replacer) {
|
|
709
687
|
const regex = /{(\w|-)*}/g;
|
|
710
|
-
const found =
|
|
688
|
+
const found = this.path.match(regex);
|
|
711
689
|
if (!found) {
|
|
712
690
|
return void 0;
|
|
713
691
|
}
|
|
@@ -716,7 +694,7 @@ var URLPath = class _URLPath {
|
|
|
716
694
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
717
695
|
const pathParam = replacer ? replacer(changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
718
696
|
params[pathParam] = pathParam;
|
|
719
|
-
},
|
|
697
|
+
}, this.path);
|
|
720
698
|
return params;
|
|
721
699
|
}
|
|
722
700
|
/**
|
|
@@ -724,77 +702,61 @@ var URLPath = class _URLPath {
|
|
|
724
702
|
* @example /pet/{petId} => /pet/:petId
|
|
725
703
|
*/
|
|
726
704
|
toURLPath() {
|
|
727
|
-
return
|
|
705
|
+
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
728
706
|
}
|
|
729
|
-
|
|
730
|
-
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// src/utils/Warning.ts
|
|
710
|
+
var Warning = class extends Error {
|
|
711
|
+
constructor(message, options) {
|
|
712
|
+
super(message, { cause: options?.cause });
|
|
713
|
+
this.name = "Warning";
|
|
731
714
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
715
|
+
};
|
|
716
|
+
async function saveCreateDirectory(path3) {
|
|
717
|
+
const passedPath = path2__default.default.dirname(path2__default.default.resolve(path3));
|
|
718
|
+
await fs2__default.default.mkdir(passedPath, { recursive: true });
|
|
719
|
+
}
|
|
720
|
+
var writer = jsRuntime.switcher(
|
|
721
|
+
{
|
|
722
|
+
node: async (path3, data) => {
|
|
723
|
+
try {
|
|
724
|
+
await fs2__default.default.stat(path3);
|
|
725
|
+
const oldContent = await fs2__default.default.readFile(path3, { encoding: "utf-8" });
|
|
726
|
+
if (oldContent?.toString() === data) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
} catch (_err) {
|
|
740
730
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
731
|
+
await saveCreateDirectory(path3);
|
|
732
|
+
return fs2__default.default.writeFile(path2__default.default.resolve(path3), data, { encoding: "utf-8" });
|
|
733
|
+
},
|
|
734
|
+
bun: async (path3, data) => {
|
|
735
|
+
try {
|
|
736
|
+
await saveCreateDirectory(path3);
|
|
737
|
+
await Bun.write(path2__default.default.resolve(path3), data);
|
|
738
|
+
} catch (e) {
|
|
739
|
+
console.log(e, path2__default.default.resolve(path3));
|
|
750
740
|
}
|
|
751
|
-
} catch (error) {
|
|
752
|
-
return false;
|
|
753
|
-
}
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
var FunctionParams = class {
|
|
758
|
-
type;
|
|
759
|
-
items = [];
|
|
760
|
-
constructor(type) {
|
|
761
|
-
this.type = type;
|
|
762
|
-
return this;
|
|
763
|
-
}
|
|
764
|
-
add(item) {
|
|
765
|
-
if (!item) {
|
|
766
|
-
return this;
|
|
767
741
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
742
|
+
},
|
|
743
|
+
"node"
|
|
744
|
+
);
|
|
745
|
+
async function write(data, path3) {
|
|
746
|
+
return writer(path3, data);
|
|
747
|
+
}
|
|
748
|
+
function getIndexes(root, extName, options = {}) {
|
|
749
|
+
const extMapper = {
|
|
750
|
+
".ts": {
|
|
751
|
+
extensions: /\.ts/,
|
|
752
|
+
exclude: [/schemas/, /json/]
|
|
753
|
+
},
|
|
754
|
+
".json": {
|
|
755
|
+
extensions: /\.json/,
|
|
756
|
+
exclude: []
|
|
771
757
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
toString() {
|
|
776
|
-
const sortedData = naturalOrderby.orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
777
|
-
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
778
|
-
if (!name) {
|
|
779
|
-
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
780
|
-
return acc;
|
|
781
|
-
}
|
|
782
|
-
const parameterName = name.startsWith("{") ? name : changeCase.camelCase(name, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
783
|
-
if (type) {
|
|
784
|
-
if (required) {
|
|
785
|
-
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
786
|
-
} else {
|
|
787
|
-
acc.push(`${parameterName}?: ${type}`);
|
|
788
|
-
}
|
|
789
|
-
} else {
|
|
790
|
-
acc.push(`${parameterName}`);
|
|
791
|
-
}
|
|
792
|
-
return acc;
|
|
793
|
-
}, []).join(", ");
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
function getIndexes(root, options = {}) {
|
|
797
|
-
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
758
|
+
};
|
|
759
|
+
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...options });
|
|
798
760
|
if (!tree) {
|
|
799
761
|
return null;
|
|
800
762
|
}
|
|
@@ -995,6 +957,7 @@ var FileManager = class {
|
|
|
995
957
|
this.#task = options.task;
|
|
996
958
|
this.#queue = options.queue;
|
|
997
959
|
}
|
|
960
|
+
return this;
|
|
998
961
|
}
|
|
999
962
|
get extensions() {
|
|
1000
963
|
return extensions;
|
|
@@ -1027,7 +990,7 @@ var FileManager = class {
|
|
|
1027
990
|
}
|
|
1028
991
|
return resolvedFile;
|
|
1029
992
|
}
|
|
1030
|
-
addOrAppend(file) {
|
|
993
|
+
async addOrAppend(file) {
|
|
1031
994
|
const previousCaches = this.#cache.get(file.path);
|
|
1032
995
|
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
1033
996
|
if (previousCache) {
|
|
@@ -1043,6 +1006,20 @@ ${file.source}` : "",
|
|
|
1043
1006
|
}
|
|
1044
1007
|
return this.add(file);
|
|
1045
1008
|
}
|
|
1009
|
+
async addIndexes(root, extName = ".ts", options = {}) {
|
|
1010
|
+
const files = await getIndexes(root, extName, options);
|
|
1011
|
+
if (!files) {
|
|
1012
|
+
return void 0;
|
|
1013
|
+
}
|
|
1014
|
+
return Promise.all(
|
|
1015
|
+
files.map((file) => {
|
|
1016
|
+
if (file.override) {
|
|
1017
|
+
return this.add(file);
|
|
1018
|
+
}
|
|
1019
|
+
return this.addOrAppend(file);
|
|
1020
|
+
})
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1046
1023
|
#append(path3, file) {
|
|
1047
1024
|
const previousFiles = this.#cache.get(path3) || [];
|
|
1048
1025
|
this.#cache.set(path3, [...previousFiles, file]);
|
|
@@ -1081,6 +1058,44 @@ ${file.source}` : "",
|
|
|
1081
1058
|
return read(...params);
|
|
1082
1059
|
}
|
|
1083
1060
|
};
|
|
1061
|
+
|
|
1062
|
+
// src/managers/pluginManager/ParallelPluginError.ts
|
|
1063
|
+
var ParallelPluginError = class extends Error {
|
|
1064
|
+
errors = [];
|
|
1065
|
+
pluginManager;
|
|
1066
|
+
constructor(message, options) {
|
|
1067
|
+
super(message, { cause: options.cause });
|
|
1068
|
+
this.name = "ParallelPluginError";
|
|
1069
|
+
this.errors = options.errors;
|
|
1070
|
+
this.pluginManager = options.pluginManager;
|
|
1071
|
+
}
|
|
1072
|
+
findError(searchError) {
|
|
1073
|
+
if (!searchError) {
|
|
1074
|
+
return void 0;
|
|
1075
|
+
}
|
|
1076
|
+
return this.errors.find((error) => {
|
|
1077
|
+
if (error.cause) {
|
|
1078
|
+
if (error.cause.name == searchError.name) {
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
return !!this.findError(error.cause);
|
|
1082
|
+
}
|
|
1083
|
+
return error.name === searchError.name;
|
|
1084
|
+
})?.cause;
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// src/managers/pluginManager/PluginError.ts
|
|
1089
|
+
var PluginError = class extends Error {
|
|
1090
|
+
pluginManager;
|
|
1091
|
+
cause;
|
|
1092
|
+
constructor(message, options) {
|
|
1093
|
+
super(message, { cause: options.cause });
|
|
1094
|
+
this.name = "PluginError";
|
|
1095
|
+
this.cause = options.cause;
|
|
1096
|
+
this.pluginManager = options.pluginManager;
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1084
1099
|
function createPlugin(factory) {
|
|
1085
1100
|
return (options) => {
|
|
1086
1101
|
const plugin = factory(options);
|
|
@@ -1155,54 +1170,22 @@ var EventEmitter = class {
|
|
|
1155
1170
|
}
|
|
1156
1171
|
};
|
|
1157
1172
|
|
|
1158
|
-
// src/managers/pluginManager/ParallelPluginError.ts
|
|
1159
|
-
var ParallelPluginError = class extends Error {
|
|
1160
|
-
errors = [];
|
|
1161
|
-
pluginManager;
|
|
1162
|
-
constructor(message, options) {
|
|
1163
|
-
super(message, { cause: options.cause });
|
|
1164
|
-
this.name = "ParallelPluginError";
|
|
1165
|
-
this.errors = options.errors;
|
|
1166
|
-
this.pluginManager = options.pluginManager;
|
|
1167
|
-
}
|
|
1168
|
-
findError(searchError) {
|
|
1169
|
-
if (!searchError) {
|
|
1170
|
-
return void 0;
|
|
1171
|
-
}
|
|
1172
|
-
return this.errors.find((error) => {
|
|
1173
|
-
if (error.cause) {
|
|
1174
|
-
if (error.cause.name == searchError.name) {
|
|
1175
|
-
return true;
|
|
1176
|
-
}
|
|
1177
|
-
return !!this.findError(error.cause);
|
|
1178
|
-
}
|
|
1179
|
-
return error.name === searchError.name;
|
|
1180
|
-
})?.cause;
|
|
1181
|
-
}
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
// src/managers/pluginManager/PluginError.ts
|
|
1185
|
-
var PluginError = class extends Error {
|
|
1186
|
-
pluginManager;
|
|
1187
|
-
cause;
|
|
1188
|
-
constructor(message, options) {
|
|
1189
|
-
super(message, { cause: options.cause });
|
|
1190
|
-
this.name = "PluginError";
|
|
1191
|
-
this.cause = options.cause;
|
|
1192
|
-
this.pluginManager = options.pluginManager;
|
|
1193
|
-
}
|
|
1194
|
-
};
|
|
1195
|
-
|
|
1196
1173
|
// src/managers/pluginManager/pluginParser.ts
|
|
1174
|
+
var usedPluginNames = {};
|
|
1197
1175
|
function pluginParser(plugin, context) {
|
|
1176
|
+
const key = [plugin.kind, plugin.name, getUniqueName(plugin.name, usedPluginNames).split(plugin.name).at(1)];
|
|
1198
1177
|
if (plugin.api && typeof plugin.api === "function") {
|
|
1199
1178
|
const api = plugin.api.call(context);
|
|
1200
1179
|
return {
|
|
1201
1180
|
...plugin,
|
|
1181
|
+
key,
|
|
1202
1182
|
api
|
|
1203
1183
|
};
|
|
1204
1184
|
}
|
|
1205
|
-
return
|
|
1185
|
+
return {
|
|
1186
|
+
...plugin,
|
|
1187
|
+
key
|
|
1188
|
+
};
|
|
1206
1189
|
}
|
|
1207
1190
|
|
|
1208
1191
|
// src/managers/pluginManager/PluginManager.ts
|
|
@@ -1236,16 +1219,15 @@ var PluginManager = class {
|
|
|
1236
1219
|
fileManager: this.fileManager,
|
|
1237
1220
|
resolvePath: this.resolvePath.bind(this),
|
|
1238
1221
|
resolveName: this.resolveName.bind(this),
|
|
1239
|
-
getPlugins: this.#getSortedPlugins.bind(this)
|
|
1222
|
+
getPlugins: this.#getSortedPlugins.bind(this),
|
|
1223
|
+
plugin: void 0
|
|
1240
1224
|
});
|
|
1241
1225
|
this.#core = pluginParser(core, core.api.call(null));
|
|
1242
1226
|
this.plugins = [this.#core, ...config.plugins || []].reduce((prev, plugin) => {
|
|
1243
1227
|
const convertedApi = pluginParser(plugin, this.#core?.api);
|
|
1244
|
-
|
|
1245
|
-
return [...prev, convertedApi];
|
|
1246
|
-
}
|
|
1247
|
-
return [...prev, plugin];
|
|
1228
|
+
return [...prev, convertedApi];
|
|
1248
1229
|
}, []);
|
|
1230
|
+
return this;
|
|
1249
1231
|
}
|
|
1250
1232
|
resolvePath = (params) => {
|
|
1251
1233
|
if (params.pluginName) {
|
|
@@ -1266,8 +1248,8 @@ var PluginManager = class {
|
|
|
1266
1248
|
pluginName: params.pluginName,
|
|
1267
1249
|
hookName: "resolveName",
|
|
1268
1250
|
parameters: [params.name, params.type]
|
|
1269
|
-
})
|
|
1270
|
-
return transformReservedWord(name2);
|
|
1251
|
+
});
|
|
1252
|
+
return transformReservedWord(name2 || params.name);
|
|
1271
1253
|
}
|
|
1272
1254
|
const name = this.hookFirstSync({
|
|
1273
1255
|
hookName: "resolveName",
|
|
@@ -1279,7 +1261,6 @@ var PluginManager = class {
|
|
|
1279
1261
|
this.eventEmitter.on(eventName, handler);
|
|
1280
1262
|
}
|
|
1281
1263
|
/**
|
|
1282
|
-
*
|
|
1283
1264
|
* Run only hook for a specific plugin name
|
|
1284
1265
|
*/
|
|
1285
1266
|
hookForPlugin({
|
|
@@ -1309,7 +1290,6 @@ var PluginManager = class {
|
|
|
1309
1290
|
});
|
|
1310
1291
|
}
|
|
1311
1292
|
/**
|
|
1312
|
-
*
|
|
1313
1293
|
* Chains, first non-null result stops and returns
|
|
1314
1294
|
*/
|
|
1315
1295
|
hookFirst({
|
|
@@ -1332,16 +1312,17 @@ var PluginManager = class {
|
|
|
1332
1312
|
parameters,
|
|
1333
1313
|
plugin
|
|
1334
1314
|
});
|
|
1335
|
-
return Promise.resolve(
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1315
|
+
return Promise.resolve(
|
|
1316
|
+
{
|
|
1317
|
+
plugin,
|
|
1318
|
+
result: value
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1339
1321
|
});
|
|
1340
1322
|
}
|
|
1341
1323
|
return promise;
|
|
1342
1324
|
}
|
|
1343
1325
|
/**
|
|
1344
|
-
*
|
|
1345
1326
|
* Chains, first non-null result stops and returns
|
|
1346
1327
|
*/
|
|
1347
1328
|
hookFirstSync({
|
|
@@ -1370,7 +1351,6 @@ var PluginManager = class {
|
|
|
1370
1351
|
return parseResult;
|
|
1371
1352
|
}
|
|
1372
1353
|
/**
|
|
1373
|
-
*
|
|
1374
1354
|
* Parallel, runs all plugins
|
|
1375
1355
|
*/
|
|
1376
1356
|
async hookParallel({
|
|
@@ -1397,7 +1377,6 @@ var PluginManager = class {
|
|
|
1397
1377
|
return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
1398
1378
|
}
|
|
1399
1379
|
/**
|
|
1400
|
-
*
|
|
1401
1380
|
* Chains, reduces returned value, handling the reduced value as the first hook argument
|
|
1402
1381
|
*/
|
|
1403
1382
|
hookReduceArg0({
|
|
@@ -1426,14 +1405,14 @@ var PluginManager = class {
|
|
|
1426
1405
|
hookSeq({ hookName, parameters }) {
|
|
1427
1406
|
let promise = Promise.resolve();
|
|
1428
1407
|
for (const plugin of this.#getSortedPlugins()) {
|
|
1429
|
-
promise = promise.then(
|
|
1430
|
-
|
|
1408
|
+
promise = promise.then(() => {
|
|
1409
|
+
this.#execute({
|
|
1431
1410
|
strategy: "hookSeq",
|
|
1432
1411
|
hookName,
|
|
1433
1412
|
parameters,
|
|
1434
1413
|
plugin
|
|
1435
|
-
})
|
|
1436
|
-
);
|
|
1414
|
+
});
|
|
1415
|
+
});
|
|
1437
1416
|
}
|
|
1438
1417
|
return promise.then(noReturn);
|
|
1439
1418
|
}
|
|
@@ -1479,7 +1458,7 @@ var PluginManager = class {
|
|
|
1479
1458
|
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1480
1459
|
const task = Promise.resolve().then(() => {
|
|
1481
1460
|
if (typeof hook === "function") {
|
|
1482
|
-
const possiblePromiseResult = hook.apply(this.#core.api, parameters);
|
|
1461
|
+
const possiblePromiseResult = hook.apply({ ...this.#core.api, plugin }, parameters);
|
|
1483
1462
|
if (isPromise(possiblePromiseResult)) {
|
|
1484
1463
|
return Promise.resolve(possiblePromiseResult);
|
|
1485
1464
|
}
|
|
@@ -1587,7 +1566,7 @@ async function transformReducer(_previousCode, result, _plugin) {
|
|
|
1587
1566
|
async function build(options) {
|
|
1588
1567
|
const { config, logLevel, logger = createLogger() } = options;
|
|
1589
1568
|
try {
|
|
1590
|
-
if ("path" in config.input && !URLPath
|
|
1569
|
+
if ("path" in config.input && !new URLPath(config.input.path).isURL) {
|
|
1591
1570
|
await read(config.input.path);
|
|
1592
1571
|
}
|
|
1593
1572
|
} catch (e) {
|
|
@@ -1668,6 +1647,34 @@ function defineConfig(options) {
|
|
|
1668
1647
|
return options;
|
|
1669
1648
|
}
|
|
1670
1649
|
|
|
1650
|
+
// src/generators/Generator.ts
|
|
1651
|
+
var Generator = class {
|
|
1652
|
+
#options = {};
|
|
1653
|
+
#context = {};
|
|
1654
|
+
constructor(options, context) {
|
|
1655
|
+
if (context) {
|
|
1656
|
+
this.#context = context;
|
|
1657
|
+
}
|
|
1658
|
+
if (options) {
|
|
1659
|
+
this.#options = options;
|
|
1660
|
+
}
|
|
1661
|
+
return this;
|
|
1662
|
+
}
|
|
1663
|
+
get options() {
|
|
1664
|
+
return this.#options;
|
|
1665
|
+
}
|
|
1666
|
+
get context() {
|
|
1667
|
+
return this.#context;
|
|
1668
|
+
}
|
|
1669
|
+
set options(options) {
|
|
1670
|
+
this.#options = { ...this.#options, ...options };
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
// src/generators/SchemaGenerator.ts
|
|
1675
|
+
var SchemaGenerator = class extends Generator {
|
|
1676
|
+
};
|
|
1677
|
+
|
|
1671
1678
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
1672
1679
|
var Node = class {
|
|
1673
1680
|
value;
|
|
@@ -1817,7 +1824,7 @@ function checkType(type) {
|
|
|
1817
1824
|
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
1818
1825
|
var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
|
|
1819
1826
|
async function locatePath(paths, {
|
|
1820
|
-
cwd =
|
|
1827
|
+
cwd = process__default.default.cwd(),
|
|
1821
1828
|
type = "file",
|
|
1822
1829
|
allowSymlinks = true,
|
|
1823
1830
|
concurrency,
|
|
@@ -1836,7 +1843,7 @@ async function locatePath(paths, {
|
|
|
1836
1843
|
}, { concurrency, preserveOrder });
|
|
1837
1844
|
}
|
|
1838
1845
|
function locatePathSync(paths, {
|
|
1839
|
-
cwd =
|
|
1846
|
+
cwd = process__default.default.cwd(),
|
|
1840
1847
|
type = "file",
|
|
1841
1848
|
allowSymlinks = true
|
|
1842
1849
|
} = {}) {
|
|
@@ -1936,10 +1943,46 @@ function findUpSync(name, options = {}) {
|
|
|
1936
1943
|
}
|
|
1937
1944
|
var PackageManager = class {
|
|
1938
1945
|
#cwd;
|
|
1939
|
-
|
|
1940
|
-
|
|
1946
|
+
#SLASHES = /* @__PURE__ */ new Set(["/", "\\"]);
|
|
1947
|
+
constructor(workspace) {
|
|
1948
|
+
if (workspace) {
|
|
1949
|
+
this.#cwd = workspace;
|
|
1950
|
+
}
|
|
1941
1951
|
return this;
|
|
1942
1952
|
}
|
|
1953
|
+
set workspace(workspace) {
|
|
1954
|
+
this.#cwd = workspace;
|
|
1955
|
+
}
|
|
1956
|
+
get workspace() {
|
|
1957
|
+
return this.#cwd;
|
|
1958
|
+
}
|
|
1959
|
+
normalizeDirectory(directory) {
|
|
1960
|
+
if (!this.#SLASHES.has(directory[directory.length - 1])) {
|
|
1961
|
+
return `${directory}/`;
|
|
1962
|
+
}
|
|
1963
|
+
return directory;
|
|
1964
|
+
}
|
|
1965
|
+
getLocation(path3) {
|
|
1966
|
+
let location = path3;
|
|
1967
|
+
if (this.#cwd) {
|
|
1968
|
+
const require2 = mod__default.default.createRequire(this.normalizeDirectory(this.#cwd));
|
|
1969
|
+
location = require2.resolve(path3);
|
|
1970
|
+
}
|
|
1971
|
+
return location;
|
|
1972
|
+
}
|
|
1973
|
+
async import(path3) {
|
|
1974
|
+
try {
|
|
1975
|
+
let location = this.getLocation(path3);
|
|
1976
|
+
if (os__default.default.platform() == "win32") {
|
|
1977
|
+
location = url.pathToFileURL(location).href;
|
|
1978
|
+
}
|
|
1979
|
+
const module = await import(location);
|
|
1980
|
+
return module?.default ?? module;
|
|
1981
|
+
} catch (e) {
|
|
1982
|
+
console.log(e);
|
|
1983
|
+
return void 0;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1943
1986
|
async getPackageJSON() {
|
|
1944
1987
|
const pkgPath = await findUp(["package.json"], {
|
|
1945
1988
|
cwd: this.#cwd
|
|
@@ -1996,34 +2039,6 @@ var PackageManager = class {
|
|
|
1996
2039
|
}
|
|
1997
2040
|
};
|
|
1998
2041
|
|
|
1999
|
-
// src/generators/Generator.ts
|
|
2000
|
-
var Generator = class {
|
|
2001
|
-
#options = {};
|
|
2002
|
-
#context = {};
|
|
2003
|
-
constructor(options, context) {
|
|
2004
|
-
if (context) {
|
|
2005
|
-
this.#context = context;
|
|
2006
|
-
}
|
|
2007
|
-
if (options) {
|
|
2008
|
-
this.#options = options;
|
|
2009
|
-
}
|
|
2010
|
-
return this;
|
|
2011
|
-
}
|
|
2012
|
-
get options() {
|
|
2013
|
-
return this.#options;
|
|
2014
|
-
}
|
|
2015
|
-
get context() {
|
|
2016
|
-
return this.#context;
|
|
2017
|
-
}
|
|
2018
|
-
set options(options) {
|
|
2019
|
-
this.#options = { ...this.#options, ...options };
|
|
2020
|
-
}
|
|
2021
|
-
};
|
|
2022
|
-
|
|
2023
|
-
// src/generators/SchemaGenerator.ts
|
|
2024
|
-
var SchemaGenerator = class extends Generator {
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
2042
|
// src/index.ts
|
|
2028
2043
|
var src_default = build;
|
|
2029
2044
|
|
|
@@ -2064,12 +2079,10 @@ exports.escape = escape;
|
|
|
2064
2079
|
exports.extensions = extensions;
|
|
2065
2080
|
exports.getDependedPlugins = getDependedPlugins;
|
|
2066
2081
|
exports.getIndexes = getIndexes;
|
|
2067
|
-
exports.getLocation = getLocation;
|
|
2068
2082
|
exports.getPathMode = getPathMode;
|
|
2069
2083
|
exports.getRelativePath = getRelativePath;
|
|
2070
2084
|
exports.getUniqueName = getUniqueName;
|
|
2071
2085
|
exports.hooks = hooks;
|
|
2072
|
-
exports.importModule = importModule;
|
|
2073
2086
|
exports.isExtensionAllowed = isExtensionAllowed;
|
|
2074
2087
|
exports.isPromise = isPromise;
|
|
2075
2088
|
exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
|
|
@@ -2077,7 +2090,6 @@ exports.isPromiseRejectedResult = isPromiseRejectedResult;
|
|
|
2077
2090
|
exports.jsStringEscape = jsStringEscape;
|
|
2078
2091
|
exports.name = pluginName;
|
|
2079
2092
|
exports.nameSorter = nameSorter;
|
|
2080
|
-
exports.normalizeDirectory = normalizeDirectory;
|
|
2081
2093
|
exports.pluginName = pluginName;
|
|
2082
2094
|
exports.randomColour = randomColour;
|
|
2083
2095
|
exports.randomPicoColour = randomPicoColour;
|