@kubb/core 1.15.0-canary.20231026T131818 → 1.15.0-canary.20231026T165002
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 +841 -899
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +313 -255
- package/dist/index.d.ts +313 -255
- package/dist/index.js +784 -861
- package/dist/index.js.map +1 -1
- package/globals.d.ts +16 -33
- package/package.json +3 -8
- package/dist/utils.cjs +0 -1208
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -235
- package/dist/utils.d.ts +0 -235
- package/dist/utils.js +0 -1156
- package/dist/utils.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import mod, { createRequire } from 'module';
|
|
2
2
|
import pc3 from 'picocolors';
|
|
3
|
+
export { default as pc } from 'picocolors';
|
|
4
|
+
import crypto from 'crypto';
|
|
3
5
|
import fs2, { remove } from 'fs-extra';
|
|
4
|
-
import seedrandom from 'seedrandom';
|
|
5
|
-
import { switcher } from 'js-runtime';
|
|
6
6
|
import { camelCase, camelCaseTransformMerge } from 'change-case';
|
|
7
|
-
import crypto2 from 'crypto';
|
|
8
|
-
import path, { resolve, dirname, extname } from 'path';
|
|
9
|
-
import { print } from '@kubb/parser';
|
|
10
|
-
import * as factory from '@kubb/parser/factory';
|
|
11
|
-
import isEqual from 'lodash.isequal';
|
|
12
7
|
import { orderBy } from 'natural-orderby';
|
|
8
|
+
import { performance } from 'perf_hooks';
|
|
9
|
+
import seedrandom from 'seedrandom';
|
|
10
|
+
import pathParser from 'path';
|
|
11
|
+
import { switcher } from 'js-runtime';
|
|
13
12
|
import dirTree from 'directory-tree';
|
|
13
|
+
import { createImportDeclaration, print, createExportDeclaration } from '@kubb/parser';
|
|
14
|
+
import isEqual from 'lodash.isequal';
|
|
14
15
|
import { EventEmitter as EventEmitter$1 } from 'events';
|
|
15
|
-
import { performance } from 'perf_hooks';
|
|
16
16
|
import os from 'os';
|
|
17
17
|
import { pathToFileURL } from 'url';
|
|
18
18
|
import { findUp, findUpSync } from 'find-up';
|
|
@@ -27,15 +27,110 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
27
27
|
return require.apply(this, arguments);
|
|
28
28
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
// src/utils/cache.ts
|
|
32
|
+
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
33
|
+
return {
|
|
34
|
+
set(id, value) {
|
|
35
|
+
Store[id] = [0, value];
|
|
36
|
+
},
|
|
37
|
+
get(id) {
|
|
38
|
+
const item = Store[id];
|
|
39
|
+
if (!item) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
item[0] = 0;
|
|
43
|
+
return item[1];
|
|
44
|
+
},
|
|
45
|
+
has(id) {
|
|
46
|
+
const item = Store[id];
|
|
47
|
+
if (!item) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
item[0] = 0;
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
delete(id) {
|
|
54
|
+
return delete Store[id];
|
|
55
|
+
}
|
|
56
|
+
};
|
|
32
57
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
async function clean(path) {
|
|
59
|
+
return remove(path);
|
|
60
|
+
}
|
|
61
|
+
var FunctionParams = class {
|
|
62
|
+
type;
|
|
63
|
+
items = [];
|
|
64
|
+
constructor(type) {
|
|
65
|
+
this.type = type;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
add(item) {
|
|
69
|
+
if (!item) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(item)) {
|
|
73
|
+
item.filter(Boolean).forEach((it) => this.items.push(it));
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
this.items.push(item);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
toString() {
|
|
80
|
+
const sortedData = orderBy(this.items.filter(Boolean), [(v) => !v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
81
|
+
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
82
|
+
if (!name) {
|
|
83
|
+
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
84
|
+
return acc;
|
|
85
|
+
}
|
|
86
|
+
const parameterName = name.startsWith("{") ? name : camelCase(name, { delimiter: "", transform: camelCaseTransformMerge });
|
|
87
|
+
if (type) {
|
|
88
|
+
if (required) {
|
|
89
|
+
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
90
|
+
} else {
|
|
91
|
+
acc.push(`${parameterName}?: ${type}`);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
acc.push(`${parameterName}`);
|
|
95
|
+
}
|
|
96
|
+
return acc;
|
|
97
|
+
}, []).join(", ");
|
|
98
|
+
}
|
|
37
99
|
};
|
|
38
|
-
|
|
100
|
+
|
|
101
|
+
// src/utils/getUniqueName.ts
|
|
102
|
+
function getUniqueName(originalName, data) {
|
|
103
|
+
let used = data[originalName] || 0;
|
|
104
|
+
if (used) {
|
|
105
|
+
data[originalName] = ++used;
|
|
106
|
+
originalName += used;
|
|
107
|
+
}
|
|
108
|
+
data[originalName] = 1;
|
|
109
|
+
return originalName;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/utils/isPromise.ts
|
|
113
|
+
function isPromise(result) {
|
|
114
|
+
return typeof result?.then === "function";
|
|
115
|
+
}
|
|
116
|
+
function isPromiseFulfilledResult(result) {
|
|
117
|
+
return result.status === "fulfilled";
|
|
118
|
+
}
|
|
119
|
+
function isPromiseRejectedResult(result) {
|
|
120
|
+
return result.status === "rejected";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/utils/jsdoc.ts
|
|
124
|
+
function createJSDocBlockText({ comments }) {
|
|
125
|
+
const filteredComments = comments.filter(Boolean);
|
|
126
|
+
if (!filteredComments.length) {
|
|
127
|
+
return "";
|
|
128
|
+
}
|
|
129
|
+
return `/**
|
|
130
|
+
* ${filteredComments.join("\n * ")}
|
|
131
|
+
*/`;
|
|
132
|
+
}
|
|
133
|
+
function createLogger(spinner) {
|
|
39
134
|
const logs = [];
|
|
40
135
|
const log = (message) => {
|
|
41
136
|
if (message && spinner) {
|
|
@@ -61,8 +156,6 @@ function createLogger({ logLevel, name, spinner }) {
|
|
|
61
156
|
}
|
|
62
157
|
};
|
|
63
158
|
const logger = {
|
|
64
|
-
name,
|
|
65
|
-
logLevel,
|
|
66
159
|
log,
|
|
67
160
|
error,
|
|
68
161
|
warn,
|
|
@@ -72,6 +165,75 @@ function createLogger({ logLevel, name, spinner }) {
|
|
|
72
165
|
};
|
|
73
166
|
return logger;
|
|
74
167
|
}
|
|
168
|
+
|
|
169
|
+
// src/utils/nameSorter.ts
|
|
170
|
+
function nameSorter(a, b) {
|
|
171
|
+
if (a.name < b.name) {
|
|
172
|
+
return -1;
|
|
173
|
+
}
|
|
174
|
+
if (a.name > b.name) {
|
|
175
|
+
return 1;
|
|
176
|
+
}
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
var Queue = class {
|
|
180
|
+
#queue = [];
|
|
181
|
+
#workerCount = 0;
|
|
182
|
+
#maxParallel;
|
|
183
|
+
#debug = false;
|
|
184
|
+
constructor(maxParallel, debug = false) {
|
|
185
|
+
this.#maxParallel = maxParallel;
|
|
186
|
+
this.#debug = debug;
|
|
187
|
+
}
|
|
188
|
+
run(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
191
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
192
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
193
|
+
reject("Aborted");
|
|
194
|
+
});
|
|
195
|
+
this.#queue.push(item);
|
|
196
|
+
this.#work();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
runSync(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
|
|
200
|
+
new Promise((resolve, reject) => {
|
|
201
|
+
const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
|
|
202
|
+
options.controller?.signal.addEventListener("abort", () => {
|
|
203
|
+
this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name);
|
|
204
|
+
});
|
|
205
|
+
this.#queue.push(item);
|
|
206
|
+
this.#work();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
get hasJobs() {
|
|
210
|
+
return this.#workerCount > 0 || this.#queue.length > 0;
|
|
211
|
+
}
|
|
212
|
+
get count() {
|
|
213
|
+
return this.#workerCount;
|
|
214
|
+
}
|
|
215
|
+
#work() {
|
|
216
|
+
if (this.#workerCount >= this.#maxParallel) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.#workerCount++;
|
|
220
|
+
let entry;
|
|
221
|
+
while (entry = this.#queue.shift()) {
|
|
222
|
+
const { reject, resolve, job, name, description } = entry;
|
|
223
|
+
if (this.#debug) {
|
|
224
|
+
performance.mark(name + "_start");
|
|
225
|
+
}
|
|
226
|
+
job().then((result) => {
|
|
227
|
+
resolve(result);
|
|
228
|
+
if (this.#debug) {
|
|
229
|
+
performance.mark(name + "_stop");
|
|
230
|
+
performance.measure(description, name + "_start", name + "_stop");
|
|
231
|
+
}
|
|
232
|
+
}).catch((err) => reject(err));
|
|
233
|
+
}
|
|
234
|
+
this.#workerCount--;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
75
237
|
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
76
238
|
function randomColour(text, colours = defaultColours) {
|
|
77
239
|
if (!text) {
|
|
@@ -98,22 +260,46 @@ function randomPicoColour(text, colors = defaultColours) {
|
|
|
98
260
|
}
|
|
99
261
|
return formatter(text);
|
|
100
262
|
}
|
|
263
|
+
function slash(path, platform = "linux") {
|
|
264
|
+
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
265
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
266
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
267
|
+
}
|
|
268
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
269
|
+
}
|
|
270
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
271
|
+
if (!rootDir || !filePath) {
|
|
272
|
+
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
273
|
+
}
|
|
274
|
+
const relativePath = pathParser.relative(rootDir, filePath);
|
|
275
|
+
const path = slash(relativePath, platform);
|
|
276
|
+
if (path.startsWith("../")) {
|
|
277
|
+
return path.replace(pathParser.basename(path), pathParser.basename(path, pathParser.extname(filePath)));
|
|
278
|
+
}
|
|
279
|
+
return `./${path.replace(pathParser.basename(path), pathParser.basename(path, pathParser.extname(filePath)))}`;
|
|
280
|
+
}
|
|
281
|
+
function getPathMode(path) {
|
|
282
|
+
if (!path) {
|
|
283
|
+
return "directory";
|
|
284
|
+
}
|
|
285
|
+
return pathParser.extname(path) ? "file" : "directory";
|
|
286
|
+
}
|
|
101
287
|
var reader = switcher(
|
|
102
288
|
{
|
|
103
|
-
node: async (
|
|
104
|
-
return fs2.readFile(
|
|
289
|
+
node: async (path) => {
|
|
290
|
+
return fs2.readFile(path, { encoding: "utf8" });
|
|
105
291
|
},
|
|
106
|
-
bun: async (
|
|
107
|
-
const file = Bun.file(
|
|
292
|
+
bun: async (path) => {
|
|
293
|
+
const file = Bun.file(path);
|
|
108
294
|
return file.text();
|
|
109
295
|
}
|
|
110
296
|
},
|
|
111
297
|
"node"
|
|
112
298
|
);
|
|
113
|
-
switcher(
|
|
299
|
+
var syncReader = switcher(
|
|
114
300
|
{
|
|
115
|
-
node: (
|
|
116
|
-
return fs2.readFileSync(
|
|
301
|
+
node: (path) => {
|
|
302
|
+
return fs2.readFileSync(path, { encoding: "utf8" });
|
|
117
303
|
},
|
|
118
304
|
bun: () => {
|
|
119
305
|
throw new Error("Bun cannot read sync");
|
|
@@ -121,116 +307,79 @@ switcher(
|
|
|
121
307
|
},
|
|
122
308
|
"node"
|
|
123
309
|
);
|
|
124
|
-
async function read(
|
|
125
|
-
return reader(
|
|
310
|
+
async function read(path) {
|
|
311
|
+
return reader(path);
|
|
126
312
|
}
|
|
127
|
-
|
|
128
|
-
path;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
const url = new URL(this.path);
|
|
143
|
-
if (url?.href) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
153
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
154
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
155
|
-
* @example /account/userID => `/account/${userId}`
|
|
156
|
-
*/
|
|
157
|
-
get template() {
|
|
158
|
-
return this.toTemplateString();
|
|
159
|
-
}
|
|
160
|
-
get object() {
|
|
161
|
-
return this.toObject();
|
|
162
|
-
}
|
|
163
|
-
get params() {
|
|
164
|
-
return this.getParams();
|
|
165
|
-
}
|
|
166
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
167
|
-
const object = {
|
|
168
|
-
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
169
|
-
params: this.getParams()
|
|
170
|
-
};
|
|
171
|
-
if (stringify) {
|
|
172
|
-
if (type !== "template") {
|
|
173
|
-
throw new Error("Type should be `template` when using stringiyf");
|
|
174
|
-
}
|
|
175
|
-
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
176
|
-
}
|
|
177
|
-
return object;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
181
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
182
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
183
|
-
* @example /account/userID => `/account/${userId}`
|
|
184
|
-
*/
|
|
185
|
-
toTemplateString(replacer) {
|
|
186
|
-
const regex = /{(\w|-)*}/g;
|
|
187
|
-
const found = this.path.match(regex);
|
|
188
|
-
let newPath = this.path.replaceAll("{", "${");
|
|
189
|
-
if (found) {
|
|
190
|
-
newPath = found.reduce((prev, curr) => {
|
|
191
|
-
const pathParam = replacer ? replacer(camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge });
|
|
192
|
-
const replacement = `\${${pathParam}}`;
|
|
193
|
-
return prev.replace(curr, replacement);
|
|
194
|
-
}, this.path);
|
|
313
|
+
function readSync(path) {
|
|
314
|
+
return syncReader(path);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/utils/renderTemplate.ts
|
|
318
|
+
function renderTemplate(template, data = void 0) {
|
|
319
|
+
if (!data || !Object.keys(data).length) {
|
|
320
|
+
return template.replace(/{{(.*?)}}/g, "");
|
|
321
|
+
}
|
|
322
|
+
const matches = template.match(/{{(.*?)}}/g);
|
|
323
|
+
return matches?.reduce((prev, curr) => {
|
|
324
|
+
const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
|
|
325
|
+
if (index === void 0) {
|
|
326
|
+
return prev;
|
|
195
327
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const regex = /{(\w|-)*}/g;
|
|
200
|
-
const found = this.path.match(regex);
|
|
201
|
-
if (!found) {
|
|
202
|
-
return void 0;
|
|
328
|
+
const value = data[index];
|
|
329
|
+
if (value === void 0) {
|
|
330
|
+
return prev;
|
|
203
331
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
332
|
+
return prev.replace(curr, () => {
|
|
333
|
+
if (typeof value === "boolean") {
|
|
334
|
+
return `${value.toString()}` || "false";
|
|
335
|
+
}
|
|
336
|
+
return value || "";
|
|
337
|
+
}).trim();
|
|
338
|
+
}, template) || "";
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/utils/SummaryError.ts
|
|
342
|
+
var SummaryError = class extends Error {
|
|
343
|
+
summary;
|
|
344
|
+
constructor(message, options) {
|
|
345
|
+
super(message, { cause: options.cause });
|
|
346
|
+
this.name = "SummaryError";
|
|
347
|
+
this.summary = options.summary || [];
|
|
218
348
|
}
|
|
219
349
|
};
|
|
220
350
|
|
|
221
|
-
// src/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return
|
|
227
|
-
|
|
351
|
+
// src/utils/throttle.ts
|
|
352
|
+
var throttle = (fn, delay) => {
|
|
353
|
+
let wait = false;
|
|
354
|
+
let timeout2;
|
|
355
|
+
let cancelled = false;
|
|
356
|
+
return [
|
|
357
|
+
(...args) => {
|
|
358
|
+
if (cancelled) {
|
|
359
|
+
return void 0;
|
|
360
|
+
}
|
|
361
|
+
if (wait) {
|
|
362
|
+
return void 0;
|
|
363
|
+
}
|
|
364
|
+
const val = fn(...args);
|
|
365
|
+
wait = true;
|
|
366
|
+
timeout2 = setTimeout(() => {
|
|
367
|
+
wait = false;
|
|
368
|
+
}, delay);
|
|
369
|
+
return val;
|
|
370
|
+
},
|
|
371
|
+
() => {
|
|
372
|
+
cancelled = true;
|
|
373
|
+
clearTimeout(timeout2);
|
|
374
|
+
}
|
|
375
|
+
];
|
|
376
|
+
};
|
|
228
377
|
|
|
229
378
|
// src/utils/timeout.ts
|
|
230
379
|
async function timeout(ms) {
|
|
231
|
-
return new Promise((
|
|
380
|
+
return new Promise((resolve) => {
|
|
232
381
|
setTimeout(() => {
|
|
233
|
-
|
|
382
|
+
resolve(true);
|
|
234
383
|
}, ms);
|
|
235
384
|
});
|
|
236
385
|
}
|
|
@@ -240,17 +389,6 @@ function combineCodes(codes) {
|
|
|
240
389
|
return codes.join("\n");
|
|
241
390
|
}
|
|
242
391
|
|
|
243
|
-
// src/utils/transformers/createJSDocBlockText.ts
|
|
244
|
-
function createJSDocBlockText({ comments }) {
|
|
245
|
-
const filteredComments = comments.filter(Boolean);
|
|
246
|
-
if (!filteredComments.length) {
|
|
247
|
-
return "";
|
|
248
|
-
}
|
|
249
|
-
return `/**
|
|
250
|
-
* ${filteredComments.join("\n * ")}
|
|
251
|
-
*/`;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
392
|
// src/utils/transformers/escape.ts
|
|
255
393
|
function escape(text) {
|
|
256
394
|
return text ? text.replaceAll("`", "\\`") : "";
|
|
@@ -276,39 +414,6 @@ function jsStringEscape(input) {
|
|
|
276
414
|
});
|
|
277
415
|
}
|
|
278
416
|
|
|
279
|
-
// src/utils/transformers/indent.ts
|
|
280
|
-
function createIndent(size) {
|
|
281
|
-
return Array.from({ length: size + 1 }).join(" ");
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/utils/transformers/nameSorter.ts
|
|
285
|
-
function nameSorter(a, b) {
|
|
286
|
-
if (a.name < b.name) {
|
|
287
|
-
return -1;
|
|
288
|
-
}
|
|
289
|
-
if (a.name > b.name) {
|
|
290
|
-
return 1;
|
|
291
|
-
}
|
|
292
|
-
return 0;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// src/utils/transformers/searchAndReplace.ts
|
|
296
|
-
function searchAndReplace(options) {
|
|
297
|
-
const { text, replaceBy, prefix = "", key } = options;
|
|
298
|
-
const searchValues = options.searchValues?.(prefix, key) || [
|
|
299
|
-
`${prefix}["${key}"]`,
|
|
300
|
-
`${prefix}['${key}']`,
|
|
301
|
-
`${prefix}[\`${key}\`]`,
|
|
302
|
-
`${prefix}"${key}"`,
|
|
303
|
-
`${prefix}'${key}'`,
|
|
304
|
-
`${prefix}\`${key}\``,
|
|
305
|
-
new RegExp(`${prefix}${key}`, "g")
|
|
306
|
-
];
|
|
307
|
-
return searchValues.reduce((prev, searchValue) => {
|
|
308
|
-
return prev.toString().replaceAll(searchValue, replaceBy);
|
|
309
|
-
}, text);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
417
|
// src/utils/transformers/transformReservedWord.ts
|
|
313
418
|
var reservedWords = [
|
|
314
419
|
"abstract",
|
|
@@ -401,80 +506,6 @@ function transformReservedWord(word) {
|
|
|
401
506
|
}
|
|
402
507
|
return word;
|
|
403
508
|
}
|
|
404
|
-
|
|
405
|
-
// src/utils/transformers/index.ts
|
|
406
|
-
var transformers = {
|
|
407
|
-
combineCodes,
|
|
408
|
-
escape,
|
|
409
|
-
jsStringEscape,
|
|
410
|
-
createIndent,
|
|
411
|
-
transformReservedWord,
|
|
412
|
-
nameSorter,
|
|
413
|
-
searchAndReplace,
|
|
414
|
-
JSDoc: {
|
|
415
|
-
createJSDocBlockText
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
async function saveCreateDirectory(path3) {
|
|
419
|
-
const passedPath = dirname(resolve(path3));
|
|
420
|
-
await fs2.mkdir(passedPath, { recursive: true });
|
|
421
|
-
}
|
|
422
|
-
var writer = switcher(
|
|
423
|
-
{
|
|
424
|
-
node: async (path3, data) => {
|
|
425
|
-
try {
|
|
426
|
-
await fs2.stat(resolve(path3));
|
|
427
|
-
const oldContent = await fs2.readFile(resolve(path3), { encoding: "utf-8" });
|
|
428
|
-
if (oldContent?.toString() === data?.toString()) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
} catch (_err) {
|
|
432
|
-
}
|
|
433
|
-
await saveCreateDirectory(path3);
|
|
434
|
-
await fs2.writeFile(resolve(path3), data, { encoding: "utf-8" });
|
|
435
|
-
const savedData = await fs2.readFile(resolve(path3), { encoding: "utf-8" });
|
|
436
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
437
|
-
throw new Error(`Sanity check failed for ${path3}
|
|
438
|
-
|
|
439
|
-
Data[${data.length}]:
|
|
440
|
-
${data}
|
|
441
|
-
|
|
442
|
-
Saved[${savedData.length}]:
|
|
443
|
-
${savedData}
|
|
444
|
-
`);
|
|
445
|
-
}
|
|
446
|
-
return savedData;
|
|
447
|
-
},
|
|
448
|
-
bun: async (path3, data) => {
|
|
449
|
-
try {
|
|
450
|
-
await saveCreateDirectory(path3);
|
|
451
|
-
await Bun.write(resolve(path3), data);
|
|
452
|
-
const file = Bun.file(resolve(path3));
|
|
453
|
-
const savedData = await file.text();
|
|
454
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
455
|
-
throw new Error(`Sanity check failed for ${path3}
|
|
456
|
-
|
|
457
|
-
Data[${data.length}]:
|
|
458
|
-
${data}
|
|
459
|
-
|
|
460
|
-
Saved[${savedData.length}]:
|
|
461
|
-
${savedData}
|
|
462
|
-
`);
|
|
463
|
-
}
|
|
464
|
-
return savedData;
|
|
465
|
-
} catch (e) {
|
|
466
|
-
console.log(e, resolve(path3));
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
"node"
|
|
471
|
-
);
|
|
472
|
-
async function write(data, path3) {
|
|
473
|
-
if (data.trim() === "") {
|
|
474
|
-
return void 0;
|
|
475
|
-
}
|
|
476
|
-
return writer(path3, data.trim());
|
|
477
|
-
}
|
|
478
509
|
var TreeNode = class _TreeNode {
|
|
479
510
|
data;
|
|
480
511
|
parent;
|
|
@@ -539,16 +570,16 @@ var TreeNode = class _TreeNode {
|
|
|
539
570
|
}
|
|
540
571
|
return this;
|
|
541
572
|
}
|
|
542
|
-
static build(
|
|
573
|
+
static build(path, options = {}) {
|
|
543
574
|
try {
|
|
544
575
|
const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
|
|
545
|
-
const filteredTree = dirTree(
|
|
576
|
+
const filteredTree = dirTree(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
|
|
546
577
|
if (!filteredTree) {
|
|
547
578
|
return null;
|
|
548
579
|
}
|
|
549
|
-
const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type ||
|
|
580
|
+
const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || getPathMode(filteredTree.path) });
|
|
550
581
|
const recurse = (node, item) => {
|
|
551
|
-
const subNode = node.addChild({ name: item.name, path: item.path, type: item.type ||
|
|
582
|
+
const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || getPathMode(item.path) });
|
|
552
583
|
if (item.children?.length) {
|
|
553
584
|
item.children?.forEach((child) => {
|
|
554
585
|
recurse(subNode, child);
|
|
@@ -563,271 +594,227 @@ var TreeNode = class _TreeNode {
|
|
|
563
594
|
}
|
|
564
595
|
};
|
|
565
596
|
|
|
566
|
-
// src/
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
597
|
+
// src/utils/uniqueIdFactory.ts
|
|
598
|
+
var uniqueIdFactory = (counter) => (str = "") => `${str}${++counter}`;
|
|
599
|
+
var URLPath = class {
|
|
600
|
+
path;
|
|
601
|
+
constructor(path) {
|
|
602
|
+
this.path = path;
|
|
571
603
|
return this;
|
|
572
604
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...treeNode });
|
|
586
|
-
if (!tree) {
|
|
587
|
-
return null;
|
|
588
|
-
}
|
|
589
|
-
const fileReducer = (files2, currentTree) => {
|
|
590
|
-
if (!currentTree.children) {
|
|
591
|
-
return [];
|
|
592
|
-
}
|
|
593
|
-
if (currentTree.children?.length > 1) {
|
|
594
|
-
const indexPath = path.resolve(currentTree.data.path, "index.ts");
|
|
595
|
-
const exports = currentTree.children.filter(Boolean).map((file) => {
|
|
596
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
597
|
-
if (importPath.includes("index") && indexPath.includes("index")) {
|
|
598
|
-
return void 0;
|
|
599
|
-
}
|
|
600
|
-
return {
|
|
601
|
-
path: includeExt ? file.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
|
|
602
|
-
isTypeOnly
|
|
603
|
-
};
|
|
604
|
-
}).filter(Boolean);
|
|
605
|
-
files2.push({
|
|
606
|
-
path: indexPath,
|
|
607
|
-
baseName: "index.ts",
|
|
608
|
-
source: "",
|
|
609
|
-
exports: output ? exports?.filter((item) => {
|
|
610
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
611
|
-
}) : exports
|
|
612
|
-
});
|
|
613
|
-
} else {
|
|
614
|
-
currentTree.children?.forEach((child) => {
|
|
615
|
-
const indexPath = path.resolve(currentTree.data.path, "index.ts");
|
|
616
|
-
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
617
|
-
const exports = [
|
|
618
|
-
{
|
|
619
|
-
path: includeExt ? child.data.type === "directory" ? `${importPath}/index${extName}` : `${importPath}${extName}` : importPath,
|
|
620
|
-
isTypeOnly
|
|
621
|
-
}
|
|
622
|
-
];
|
|
623
|
-
files2.push({
|
|
624
|
-
path: indexPath,
|
|
625
|
-
baseName: "index.ts",
|
|
626
|
-
source: "",
|
|
627
|
-
exports: output ? exports?.filter((item) => {
|
|
628
|
-
return item.path.endsWith(output.replace(/\.[^.]*$/, ""));
|
|
629
|
-
}) : exports
|
|
630
|
-
});
|
|
631
|
-
});
|
|
605
|
+
/**
|
|
606
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
607
|
+
* @example /pet/{petId} => /pet/:petId
|
|
608
|
+
*/
|
|
609
|
+
get URL() {
|
|
610
|
+
return this.toURLPath();
|
|
611
|
+
}
|
|
612
|
+
get isURL() {
|
|
613
|
+
try {
|
|
614
|
+
const url = new URL(this.path);
|
|
615
|
+
if (url?.href) {
|
|
616
|
+
return true;
|
|
632
617
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
};
|
|
638
|
-
const files = fileReducer([], tree).reverse();
|
|
639
|
-
const filteredFiles = filter ? files.filter(filter) : files;
|
|
640
|
-
return map ? filteredFiles.map(map) : filteredFiles;
|
|
618
|
+
} catch (error) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
return false;
|
|
641
622
|
}
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
// src/FileManager.ts
|
|
645
|
-
var FileManager = class _FileManager {
|
|
646
|
-
#cache = /* @__PURE__ */ new Map();
|
|
647
|
-
#task;
|
|
648
|
-
#isWriting = false;
|
|
649
623
|
/**
|
|
650
|
-
*
|
|
624
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
625
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
626
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
627
|
+
* @example /account/userID => `/account/${userId}`
|
|
651
628
|
*/
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
constructor(options) {
|
|
655
|
-
if (options) {
|
|
656
|
-
this.#task = options.task;
|
|
657
|
-
this.#queue = options.queue;
|
|
658
|
-
this.#timeout = options.timeout || 0;
|
|
659
|
-
}
|
|
660
|
-
return this;
|
|
661
|
-
}
|
|
662
|
-
get files() {
|
|
663
|
-
const files = [];
|
|
664
|
-
this.#cache.forEach((item) => {
|
|
665
|
-
files.push(...item.flat(1));
|
|
666
|
-
});
|
|
667
|
-
return files;
|
|
629
|
+
get template() {
|
|
630
|
+
return this.toTemplateString();
|
|
668
631
|
}
|
|
669
|
-
get
|
|
670
|
-
return this
|
|
632
|
+
get object() {
|
|
633
|
+
return this.toObject();
|
|
671
634
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
|
|
677
|
-
throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
|
|
678
|
-
}
|
|
635
|
+
get params() {
|
|
636
|
+
return this.getParams();
|
|
679
637
|
}
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
this
|
|
683
|
-
|
|
684
|
-
|
|
638
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
639
|
+
const object = {
|
|
640
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
641
|
+
params: this.getParams()
|
|
642
|
+
};
|
|
643
|
+
if (stringify) {
|
|
644
|
+
if (type !== "template") {
|
|
645
|
+
throw new Error("Type should be `template` when using stringiyf");
|
|
685
646
|
}
|
|
686
|
-
return
|
|
687
|
-
});
|
|
688
|
-
const resolvedFiles = await Promise.all(promises);
|
|
689
|
-
if (files.length > 1) {
|
|
690
|
-
return resolvedFiles;
|
|
691
|
-
}
|
|
692
|
-
return resolvedFiles[0];
|
|
693
|
-
}
|
|
694
|
-
async #add(file) {
|
|
695
|
-
const controller = new AbortController();
|
|
696
|
-
const resolvedFile = { id: crypto2.randomUUID(), ...file };
|
|
697
|
-
this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
698
|
-
if (this.#queue) {
|
|
699
|
-
await this.#queue.run(
|
|
700
|
-
async () => {
|
|
701
|
-
return this.#task?.(resolvedFile);
|
|
702
|
-
},
|
|
703
|
-
{ controller }
|
|
704
|
-
);
|
|
647
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
705
648
|
}
|
|
706
|
-
return
|
|
649
|
+
return object;
|
|
707
650
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
651
|
+
/**
|
|
652
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
653
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
654
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
655
|
+
* @example /account/userID => `/account/${userId}`
|
|
656
|
+
*/
|
|
657
|
+
toTemplateString(replacer) {
|
|
658
|
+
const regex = /{(\w|-)*}/g;
|
|
659
|
+
const found = this.path.match(regex);
|
|
660
|
+
let newPath = this.path.replaceAll("{", "${");
|
|
661
|
+
if (found) {
|
|
662
|
+
newPath = found.reduce((prev, curr) => {
|
|
663
|
+
const pathParam = replacer ? replacer(camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge });
|
|
664
|
+
const replacement = `\${${pathParam}}`;
|
|
665
|
+
return prev.replace(curr, replacement);
|
|
666
|
+
}, this.path);
|
|
721
667
|
}
|
|
722
|
-
return
|
|
668
|
+
return `\`${newPath}\``;
|
|
723
669
|
}
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
const
|
|
727
|
-
if (!
|
|
670
|
+
getParams(replacer) {
|
|
671
|
+
const regex = /{(\w|-)*}/g;
|
|
672
|
+
const found = this.path.match(regex);
|
|
673
|
+
if (!found) {
|
|
728
674
|
return void 0;
|
|
729
675
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
);
|
|
676
|
+
const params = {};
|
|
677
|
+
found.forEach((item) => {
|
|
678
|
+
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
679
|
+
const pathParam = replacer ? replacer(camelCase(item, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(item, { delimiter: "", transform: camelCaseTransformMerge });
|
|
680
|
+
params[pathParam] = pathParam;
|
|
681
|
+
}, this.path);
|
|
682
|
+
return params;
|
|
738
683
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
return
|
|
684
|
+
/**
|
|
685
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
686
|
+
* @example /pet/{petId} => /pet/:petId
|
|
687
|
+
*/
|
|
688
|
+
toURLPath() {
|
|
689
|
+
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
745
690
|
}
|
|
746
|
-
|
|
747
|
-
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
// src/utils/Warning.ts
|
|
694
|
+
var Warning = class extends Error {
|
|
695
|
+
constructor(message, options) {
|
|
696
|
+
super(message, { cause: options?.cause });
|
|
697
|
+
this.name = "Warning";
|
|
748
698
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
699
|
+
};
|
|
700
|
+
async function saveCreateDirectory(path) {
|
|
701
|
+
const passedPath = pathParser.dirname(pathParser.resolve(path));
|
|
702
|
+
await fs2.mkdir(passedPath, { recursive: true });
|
|
703
|
+
}
|
|
704
|
+
var writer = switcher(
|
|
705
|
+
{
|
|
706
|
+
node: async (path, data) => {
|
|
707
|
+
try {
|
|
708
|
+
await fs2.stat(path);
|
|
709
|
+
const oldContent = await fs2.readFile(path, { encoding: "utf-8" });
|
|
710
|
+
if (oldContent?.toString() === data) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
} catch (_err) {
|
|
714
|
+
}
|
|
715
|
+
await saveCreateDirectory(path);
|
|
716
|
+
return fs2.writeFile(pathParser.resolve(path), data, { encoding: "utf-8" });
|
|
717
|
+
},
|
|
718
|
+
bun: async (path, data) => {
|
|
719
|
+
try {
|
|
720
|
+
await saveCreateDirectory(path);
|
|
721
|
+
await Bun.write(pathParser.resolve(path), data);
|
|
722
|
+
} catch (e) {
|
|
723
|
+
console.log(e, pathParser.resolve(path));
|
|
724
|
+
}
|
|
753
725
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
726
|
+
},
|
|
727
|
+
"node"
|
|
728
|
+
);
|
|
729
|
+
async function write(data, path) {
|
|
730
|
+
return writer(path, data);
|
|
731
|
+
}
|
|
732
|
+
function getIndexes(root, extName, options = {}) {
|
|
733
|
+
const extMapper = {
|
|
734
|
+
".ts": {
|
|
735
|
+
extensions: /\.ts/,
|
|
736
|
+
exclude: [/schemas/, /json/]
|
|
737
|
+
},
|
|
738
|
+
".json": {
|
|
739
|
+
extensions: /\.json/,
|
|
740
|
+
exclude: []
|
|
762
741
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
return read(...params);
|
|
742
|
+
};
|
|
743
|
+
const tree = TreeNode.build(root, { ...extMapper[extName] || {}, ...options });
|
|
744
|
+
if (!tree) {
|
|
745
|
+
return null;
|
|
768
746
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
return file.source;
|
|
747
|
+
const fileReducer = (files2, currentTree) => {
|
|
748
|
+
if (!currentTree.children) {
|
|
749
|
+
return [];
|
|
773
750
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
751
|
+
if (currentTree.children?.length > 1) {
|
|
752
|
+
const path = pathParser.resolve(currentTree.data.path, "index.ts");
|
|
753
|
+
const exports = currentTree.children.map((file) => {
|
|
754
|
+
if (!file) {
|
|
755
|
+
return void 0;
|
|
756
|
+
}
|
|
757
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
758
|
+
if (importPath.includes("index") && path.includes("index")) {
|
|
759
|
+
return void 0;
|
|
760
|
+
}
|
|
761
|
+
return { path: importPath };
|
|
762
|
+
}).filter(Boolean);
|
|
763
|
+
files2.push({
|
|
764
|
+
path,
|
|
765
|
+
baseName: "index.ts",
|
|
766
|
+
source: "",
|
|
767
|
+
exports
|
|
768
|
+
});
|
|
769
|
+
} else {
|
|
770
|
+
currentTree.children?.forEach((child) => {
|
|
771
|
+
const path = pathParser.resolve(currentTree.data.path, "index.ts");
|
|
772
|
+
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
773
|
+
files2.push({
|
|
774
|
+
path,
|
|
775
|
+
baseName: "index.ts",
|
|
776
|
+
source: "",
|
|
777
|
+
exports: [{ path: importPath }]
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
currentTree.children.forEach((childItem) => {
|
|
782
|
+
fileReducer(files2, childItem);
|
|
783
|
+
});
|
|
784
|
+
return files2;
|
|
785
|
+
};
|
|
786
|
+
const files = fileReducer([], tree);
|
|
787
|
+
return files;
|
|
788
|
+
}
|
|
789
|
+
function combineFiles(files) {
|
|
790
|
+
return files.filter(Boolean).reduce((acc, curr) => {
|
|
791
|
+
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
792
|
+
if (prevIndex !== -1) {
|
|
788
793
|
const prev = acc[prevIndex];
|
|
789
|
-
if (prev && file.override) {
|
|
790
|
-
acc[prevIndex] = {
|
|
791
|
-
imports: [],
|
|
792
|
-
exports: [],
|
|
793
|
-
...file
|
|
794
|
-
};
|
|
795
|
-
return acc;
|
|
796
|
-
}
|
|
797
794
|
if (prev) {
|
|
798
795
|
acc[prevIndex] = {
|
|
799
|
-
...
|
|
800
|
-
source: prev.source &&
|
|
801
|
-
${
|
|
802
|
-
imports: [...prev.imports || [], ...
|
|
803
|
-
exports: [...prev.exports || [], ...
|
|
804
|
-
env: { ...prev.env || {}, ...
|
|
796
|
+
...curr,
|
|
797
|
+
source: prev.source && curr.source ? `${prev.source}
|
|
798
|
+
${curr.source}` : "",
|
|
799
|
+
imports: [...prev.imports || [], ...curr.imports || []],
|
|
800
|
+
exports: [...prev.exports || [], ...curr.exports || []],
|
|
801
|
+
env: { ...prev.env || {}, ...curr.env || {} }
|
|
805
802
|
};
|
|
806
803
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
static getMode(path3) {
|
|
811
|
-
if (!path3) {
|
|
812
|
-
return "directory";
|
|
804
|
+
} else {
|
|
805
|
+
acc.push(curr);
|
|
813
806
|
}
|
|
814
|
-
return
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
822
|
-
};
|
|
807
|
+
return acc;
|
|
808
|
+
}, []);
|
|
809
|
+
}
|
|
810
|
+
var extensions = [".js", ".ts", ".tsx"];
|
|
811
|
+
function isExtensionAllowed(baseName) {
|
|
812
|
+
return extensions.some((extension) => baseName.endsWith(extension));
|
|
813
|
+
}
|
|
823
814
|
function combineExports(exports) {
|
|
824
|
-
|
|
815
|
+
return exports.reduce((prev, curr) => {
|
|
825
816
|
const name = curr.name;
|
|
826
817
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path);
|
|
827
|
-
const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly);
|
|
828
|
-
if (prevByPathAndIsTypeOnly) {
|
|
829
|
-
return prev;
|
|
830
|
-
}
|
|
831
818
|
const uniquePrev = prev.findLast(
|
|
832
819
|
(imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
|
|
833
820
|
);
|
|
@@ -849,16 +836,12 @@ function combineExports(exports) {
|
|
|
849
836
|
}
|
|
850
837
|
return [...prev, curr];
|
|
851
838
|
}, []);
|
|
852
|
-
return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
|
|
853
839
|
}
|
|
854
840
|
function combineImports(imports, exports, source) {
|
|
855
|
-
|
|
841
|
+
return imports.reduce((prev, curr) => {
|
|
856
842
|
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
857
843
|
const hasImportInSource = (importName) => {
|
|
858
|
-
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
const checker = (name2) => name2 && !!source.includes(name2);
|
|
844
|
+
const checker = (name2) => name2 && !!source.includes(`${name2}`);
|
|
862
845
|
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
863
846
|
};
|
|
864
847
|
if (Array.isArray(name)) {
|
|
@@ -866,10 +849,6 @@ function combineImports(imports, exports, source) {
|
|
|
866
849
|
}
|
|
867
850
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
868
851
|
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
869
|
-
const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(imp.name, name) && imp.isTypeOnly);
|
|
870
|
-
if (prevByPathNameAndIsTypeOnly) {
|
|
871
|
-
return prev;
|
|
872
|
-
}
|
|
873
852
|
if (uniquePrev || Array.isArray(name) && !name.length) {
|
|
874
853
|
return prev;
|
|
875
854
|
}
|
|
@@ -891,7 +870,43 @@ function combineImports(imports, exports, source) {
|
|
|
891
870
|
}
|
|
892
871
|
return [...prev, curr];
|
|
893
872
|
}, []);
|
|
894
|
-
|
|
873
|
+
}
|
|
874
|
+
function createFileSource(file) {
|
|
875
|
+
let { source } = file;
|
|
876
|
+
if (!isExtensionAllowed(file.baseName)) {
|
|
877
|
+
return file.source;
|
|
878
|
+
}
|
|
879
|
+
const exports = file.exports ? combineExports(file.exports) : [];
|
|
880
|
+
const imports = file.imports ? combineImports(file.imports, exports, source) : [];
|
|
881
|
+
const importNodes = imports.map((item) => createImportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly }));
|
|
882
|
+
const importSource = print(importNodes);
|
|
883
|
+
const exportNodes = exports.map((item) => createExportDeclaration({ name: item.name, path: item.path, isTypeOnly: item.isTypeOnly, asAlias: item.asAlias }));
|
|
884
|
+
const exportSource = print(exportNodes);
|
|
885
|
+
source = getEnvSource(file.source, file.env);
|
|
886
|
+
if (importSource) {
|
|
887
|
+
source = `${importSource}
|
|
888
|
+
${source}`;
|
|
889
|
+
}
|
|
890
|
+
if (exportSource) {
|
|
891
|
+
source = `${exportSource}
|
|
892
|
+
${source}`;
|
|
893
|
+
}
|
|
894
|
+
return source;
|
|
895
|
+
}
|
|
896
|
+
function searchAndReplace(options) {
|
|
897
|
+
const { text, replaceBy, prefix = "", key } = options;
|
|
898
|
+
const searchValues = options.searchValues?.(prefix, key) || [
|
|
899
|
+
`${prefix}["${key}"]`,
|
|
900
|
+
`${prefix}['${key}']`,
|
|
901
|
+
`${prefix}[\`${key}\`]`,
|
|
902
|
+
`${prefix}"${key}"`,
|
|
903
|
+
`${prefix}'${key}'`,
|
|
904
|
+
`${prefix}\`${key}\``,
|
|
905
|
+
new RegExp(`${prefix}${key}`, "g")
|
|
906
|
+
];
|
|
907
|
+
return searchValues.reduce((prev, searchValue) => {
|
|
908
|
+
return prev.toString().replaceAll(searchValue, replaceBy);
|
|
909
|
+
}, text);
|
|
895
910
|
}
|
|
896
911
|
function getEnvSource(source, env) {
|
|
897
912
|
if (!env) {
|
|
@@ -908,117 +923,127 @@ function getEnvSource(source, env) {
|
|
|
908
923
|
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
909
924
|
}
|
|
910
925
|
if (typeof replaceBy === "string") {
|
|
911
|
-
prev =
|
|
912
|
-
prev =
|
|
926
|
+
prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
927
|
+
prev = searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
913
928
|
`, "ig"), ""), replaceBy, key });
|
|
914
929
|
}
|
|
915
930
|
return prev;
|
|
916
931
|
}, source);
|
|
917
932
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
#
|
|
923
|
-
|
|
924
|
-
|
|
933
|
+
|
|
934
|
+
// src/managers/fileManager/FileManager.ts
|
|
935
|
+
var FileManager = class {
|
|
936
|
+
#cache = /* @__PURE__ */ new Map();
|
|
937
|
+
#task;
|
|
938
|
+
#queue;
|
|
939
|
+
constructor(options) {
|
|
940
|
+
if (options) {
|
|
941
|
+
this.#task = options.task;
|
|
942
|
+
this.#queue = options.queue;
|
|
943
|
+
}
|
|
944
|
+
return this;
|
|
925
945
|
}
|
|
926
|
-
|
|
927
|
-
|
|
946
|
+
get extensions() {
|
|
947
|
+
return extensions;
|
|
928
948
|
}
|
|
929
|
-
|
|
930
|
-
|
|
949
|
+
get files() {
|
|
950
|
+
const files = [];
|
|
951
|
+
this.#cache.forEach((item) => {
|
|
952
|
+
files.push(...item.flat(1));
|
|
953
|
+
});
|
|
954
|
+
return files;
|
|
931
955
|
}
|
|
932
|
-
|
|
933
|
-
this.#
|
|
956
|
+
get isExecuting() {
|
|
957
|
+
return this.#queue?.hasJobs ?? false;
|
|
934
958
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
959
|
+
async add(file) {
|
|
960
|
+
const controller = new AbortController();
|
|
961
|
+
const resolvedFile = { id: crypto.randomUUID(), ...file };
|
|
962
|
+
this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
963
|
+
if (this.#queue) {
|
|
964
|
+
try {
|
|
965
|
+
await this.#queue.run(
|
|
966
|
+
async () => {
|
|
967
|
+
return this.#task?.(resolvedFile);
|
|
968
|
+
},
|
|
969
|
+
{ controller }
|
|
970
|
+
);
|
|
971
|
+
} catch {
|
|
972
|
+
return resolvedFile;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return resolvedFile;
|
|
945
976
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
977
|
+
async addOrAppend(file) {
|
|
978
|
+
const previousCaches = this.#cache.get(file.path);
|
|
979
|
+
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
980
|
+
if (previousCache) {
|
|
981
|
+
this.#cache.delete(previousCache.path);
|
|
982
|
+
return this.add({
|
|
983
|
+
...file,
|
|
984
|
+
source: previousCache.source && file.source ? `${previousCache.source}
|
|
985
|
+
${file.source}` : "",
|
|
986
|
+
imports: [...previousCache.imports || [], ...file.imports || []],
|
|
987
|
+
exports: [...previousCache.exports || [], ...file.exports || []],
|
|
988
|
+
env: { ...previousCache.env || {}, ...file.env || {} }
|
|
952
989
|
});
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
});
|
|
990
|
+
}
|
|
991
|
+
return this.add(file);
|
|
956
992
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
993
|
+
async addIndexes(root, extName = ".ts", options = {}) {
|
|
994
|
+
const files = await getIndexes(root, extName, options);
|
|
995
|
+
if (!files) {
|
|
996
|
+
return void 0;
|
|
997
|
+
}
|
|
998
|
+
return Promise.all(
|
|
999
|
+
files.map((file) => {
|
|
1000
|
+
if (file.override) {
|
|
1001
|
+
return this.add(file);
|
|
1002
|
+
}
|
|
1003
|
+
return this.addOrAppend(file);
|
|
1004
|
+
})
|
|
1005
|
+
);
|
|
966
1006
|
}
|
|
967
|
-
|
|
968
|
-
|
|
1007
|
+
#append(path, file) {
|
|
1008
|
+
const previousFiles = this.#cache.get(path) || [];
|
|
1009
|
+
this.#cache.set(path, [...previousFiles, file]);
|
|
969
1010
|
}
|
|
970
|
-
|
|
971
|
-
|
|
1011
|
+
getCacheByUUID(UUID) {
|
|
1012
|
+
let cache;
|
|
1013
|
+
this.#cache.forEach((files) => {
|
|
1014
|
+
cache = files.find((item) => item.id === UUID);
|
|
1015
|
+
});
|
|
1016
|
+
return cache;
|
|
972
1017
|
}
|
|
973
|
-
|
|
974
|
-
|
|
1018
|
+
get(path) {
|
|
1019
|
+
return this.#cache.get(path);
|
|
1020
|
+
}
|
|
1021
|
+
remove(path) {
|
|
1022
|
+
const cacheItem = this.get(path);
|
|
1023
|
+
if (!cacheItem) {
|
|
975
1024
|
return;
|
|
976
1025
|
}
|
|
977
|
-
this.#
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
job().then((result) => {
|
|
985
|
-
this.eventEmitter.emit("jobDone", result);
|
|
986
|
-
resolve2(result);
|
|
987
|
-
if (this.#debug) {
|
|
988
|
-
performance.mark(name + "_stop");
|
|
989
|
-
performance.measure(description, name + "_start", name + "_stop");
|
|
990
|
-
}
|
|
991
|
-
}).catch((err) => {
|
|
992
|
-
this.eventEmitter.emit("jobFailed", err);
|
|
993
|
-
reject(err);
|
|
1026
|
+
this.#cache.delete(path);
|
|
1027
|
+
}
|
|
1028
|
+
async write(...params) {
|
|
1029
|
+
if (this.#queue) {
|
|
1030
|
+
return this.#queue.run(async () => {
|
|
1031
|
+
return write(...params);
|
|
994
1032
|
});
|
|
995
1033
|
}
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
// src/utils/uniqueName.ts
|
|
1001
|
-
function setUniqueName(originalName, data) {
|
|
1002
|
-
let used = data[originalName] || 0;
|
|
1003
|
-
if (used) {
|
|
1004
|
-
data[originalName] = ++used;
|
|
1005
|
-
return originalName;
|
|
1034
|
+
return write(...params);
|
|
1006
1035
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
cause;
|
|
1015
|
-
constructor(message, options) {
|
|
1016
|
-
super(message, { cause: options.cause });
|
|
1017
|
-
this.name = "PluginError";
|
|
1018
|
-
this.cause = options.cause;
|
|
1019
|
-
this.pluginManager = options.pluginManager;
|
|
1036
|
+
async read(...params) {
|
|
1037
|
+
if (this.#queue) {
|
|
1038
|
+
return this.#queue.run(async () => {
|
|
1039
|
+
return read(...params);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
return read(...params);
|
|
1020
1043
|
}
|
|
1021
1044
|
};
|
|
1045
|
+
|
|
1046
|
+
// src/managers/pluginManager/ParallelPluginError.ts
|
|
1022
1047
|
var ParallelPluginError = class extends Error {
|
|
1023
1048
|
errors = [];
|
|
1024
1049
|
pluginManager;
|
|
@@ -1043,55 +1068,30 @@ var ParallelPluginError = class extends Error {
|
|
|
1043
1068
|
})?.cause;
|
|
1044
1069
|
}
|
|
1045
1070
|
};
|
|
1046
|
-
|
|
1047
|
-
|
|
1071
|
+
|
|
1072
|
+
// src/managers/pluginManager/PluginError.ts
|
|
1073
|
+
var PluginError = class extends Error {
|
|
1074
|
+
pluginManager;
|
|
1075
|
+
cause;
|
|
1048
1076
|
constructor(message, options) {
|
|
1049
1077
|
super(message, { cause: options.cause });
|
|
1050
|
-
this.name = "
|
|
1051
|
-
this.
|
|
1052
|
-
|
|
1053
|
-
};
|
|
1054
|
-
var Warning = class extends Error {
|
|
1055
|
-
constructor(message, options) {
|
|
1056
|
-
super(message, { cause: options?.cause });
|
|
1057
|
-
this.name = "Warning";
|
|
1078
|
+
this.name = "PluginError";
|
|
1079
|
+
this.cause = options.cause;
|
|
1080
|
+
this.pluginManager = options.pluginManager;
|
|
1058
1081
|
}
|
|
1059
1082
|
};
|
|
1060
|
-
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
// src/utils/cache.ts
|
|
1064
|
-
function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
|
|
1065
|
-
return {
|
|
1066
|
-
set(id, value) {
|
|
1067
|
-
Store[id] = [0, value];
|
|
1068
|
-
},
|
|
1069
|
-
get(id) {
|
|
1070
|
-
const item = Store[id];
|
|
1071
|
-
if (!item) {
|
|
1072
|
-
return null;
|
|
1073
|
-
}
|
|
1074
|
-
item[0] = 0;
|
|
1075
|
-
return item[1];
|
|
1076
|
-
},
|
|
1077
|
-
has(id) {
|
|
1078
|
-
const item = Store[id];
|
|
1079
|
-
if (!item) {
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
item[0] = 0;
|
|
1083
|
-
return true;
|
|
1084
|
-
},
|
|
1085
|
-
delete(id) {
|
|
1086
|
-
return delete Store[id];
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// src/plugin.ts
|
|
1092
|
-
function createPlugin(factory2) {
|
|
1083
|
+
function createPlugin(factory) {
|
|
1093
1084
|
return (options) => {
|
|
1094
|
-
|
|
1085
|
+
const plugin = factory(options);
|
|
1086
|
+
if (Array.isArray(plugin)) {
|
|
1087
|
+
throw new Error("Not implemented");
|
|
1088
|
+
}
|
|
1089
|
+
if (!plugin.transform) {
|
|
1090
|
+
plugin.transform = function transform(code) {
|
|
1091
|
+
return code;
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
return plugin;
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
1097
1097
|
var pluginName = "core";
|
|
@@ -1100,8 +1100,6 @@ var definePlugin = createPlugin((options) => {
|
|
|
1100
1100
|
return {
|
|
1101
1101
|
name: pluginName,
|
|
1102
1102
|
options,
|
|
1103
|
-
key: ["controller", "core"],
|
|
1104
|
-
kind: "controller",
|
|
1105
1103
|
api() {
|
|
1106
1104
|
return {
|
|
1107
1105
|
get config() {
|
|
@@ -1110,18 +1108,18 @@ var definePlugin = createPlugin((options) => {
|
|
|
1110
1108
|
get plugins() {
|
|
1111
1109
|
return options.getPlugins();
|
|
1112
1110
|
},
|
|
1113
|
-
get plugin() {
|
|
1114
|
-
return options.plugin;
|
|
1115
|
-
},
|
|
1116
1111
|
logger,
|
|
1117
1112
|
fileManager,
|
|
1118
1113
|
pluginManager,
|
|
1119
1114
|
async addFile(...files) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1115
|
+
return Promise.all(
|
|
1116
|
+
files.map((file) => {
|
|
1117
|
+
if (file.override) {
|
|
1118
|
+
return fileManager.add(file);
|
|
1119
|
+
}
|
|
1120
|
+
return fileManager.addOrAppend(file);
|
|
1121
|
+
})
|
|
1122
|
+
);
|
|
1125
1123
|
},
|
|
1126
1124
|
resolvePath,
|
|
1127
1125
|
resolveName,
|
|
@@ -1129,55 +1127,63 @@ var definePlugin = createPlugin((options) => {
|
|
|
1129
1127
|
};
|
|
1130
1128
|
},
|
|
1131
1129
|
resolvePath(baseName) {
|
|
1132
|
-
const root =
|
|
1133
|
-
return
|
|
1130
|
+
const root = pathParser.resolve(this.config.root, this.config.output.path);
|
|
1131
|
+
return pathParser.resolve(root, baseName);
|
|
1134
1132
|
},
|
|
1135
1133
|
resolveName(name) {
|
|
1136
1134
|
return name;
|
|
1137
1135
|
}
|
|
1138
1136
|
};
|
|
1139
1137
|
});
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
return promises.reduce(
|
|
1144
|
-
(promise, func) => {
|
|
1145
|
-
if (!func || typeof func !== "function") {
|
|
1146
|
-
throw new Error("HookSeq needs a function that returns a promise `() => Promise<unknown>`");
|
|
1147
|
-
}
|
|
1148
|
-
return promise.then((result) => {
|
|
1149
|
-
const calledFunc = func();
|
|
1150
|
-
if (calledFunc) {
|
|
1151
|
-
return calledFunc.then(Array.prototype.concat.bind(result));
|
|
1152
|
-
}
|
|
1153
|
-
});
|
|
1154
|
-
},
|
|
1155
|
-
Promise.resolve([])
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
// src/PromiseManager.ts
|
|
1160
|
-
var PromiseManager = class {
|
|
1161
|
-
#options = {};
|
|
1162
|
-
constructor(options = {}) {
|
|
1163
|
-
this.#options = options;
|
|
1164
|
-
return this;
|
|
1138
|
+
var EventEmitter = class {
|
|
1139
|
+
constructor() {
|
|
1140
|
+
this.#emitter.setMaxListeners(100);
|
|
1165
1141
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1142
|
+
#emitter = new EventEmitter$1();
|
|
1143
|
+
emit(eventName, ...eventArg) {
|
|
1144
|
+
this.#emitter.emit(eventName, ...eventArg);
|
|
1145
|
+
}
|
|
1146
|
+
on(eventName, handler) {
|
|
1147
|
+
this.#emitter.on(eventName, handler);
|
|
1148
|
+
}
|
|
1149
|
+
off(eventName, handler) {
|
|
1150
|
+
this.#emitter.off(eventName, handler);
|
|
1151
|
+
}
|
|
1152
|
+
removeAll() {
|
|
1153
|
+
this.#emitter.removeAllListeners();
|
|
1171
1154
|
}
|
|
1172
1155
|
};
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1156
|
+
|
|
1157
|
+
// src/managers/pluginManager/pluginParser.ts
|
|
1158
|
+
var usedPluginNames = {};
|
|
1159
|
+
function pluginParser(plugin, context) {
|
|
1160
|
+
const key = [plugin.kind, plugin.name, getUniqueName(plugin.name, usedPluginNames).split(plugin.name).at(1)];
|
|
1161
|
+
if (plugin.api && typeof plugin.api === "function") {
|
|
1162
|
+
const api = plugin.api.call(context);
|
|
1163
|
+
return {
|
|
1164
|
+
...plugin,
|
|
1165
|
+
key,
|
|
1166
|
+
api
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
...plugin,
|
|
1171
|
+
key
|
|
1172
|
+
};
|
|
1178
1173
|
}
|
|
1179
1174
|
|
|
1180
|
-
// src/PluginManager.ts
|
|
1175
|
+
// src/managers/pluginManager/PluginManager.ts
|
|
1176
|
+
var hookNames = {
|
|
1177
|
+
validate: 1,
|
|
1178
|
+
buildStart: 1,
|
|
1179
|
+
resolvePath: 1,
|
|
1180
|
+
resolveName: 1,
|
|
1181
|
+
load: 1,
|
|
1182
|
+
transform: 1,
|
|
1183
|
+
writeFile: 1,
|
|
1184
|
+
buildEnd: 1
|
|
1185
|
+
};
|
|
1186
|
+
var hooks = Object.keys(hookNames);
|
|
1181
1187
|
var PluginManager = class {
|
|
1182
1188
|
plugins;
|
|
1183
1189
|
fileManager;
|
|
@@ -1186,14 +1192,10 @@ var PluginManager = class {
|
|
|
1186
1192
|
executed = [];
|
|
1187
1193
|
logger;
|
|
1188
1194
|
#core;
|
|
1189
|
-
#usedPluginNames = {};
|
|
1190
|
-
#promiseManager;
|
|
1191
1195
|
constructor(config, options) {
|
|
1192
1196
|
this.logger = options.logger;
|
|
1193
|
-
this.queue = new Queue(100,
|
|
1194
|
-
this.fileManager = new FileManager({ task: options.task, queue: this.queue
|
|
1195
|
-
this.#promiseManager = new PromiseManager();
|
|
1196
|
-
const plugins = config.plugins || [];
|
|
1197
|
+
this.queue = new Queue(100, options.debug);
|
|
1198
|
+
this.fileManager = new FileManager({ task: options.task, queue: this.queue });
|
|
1197
1199
|
const core = definePlugin({
|
|
1198
1200
|
config,
|
|
1199
1201
|
logger: this.logger,
|
|
@@ -1201,29 +1203,23 @@ var PluginManager = class {
|
|
|
1201
1203
|
fileManager: this.fileManager,
|
|
1202
1204
|
resolvePath: this.resolvePath.bind(this),
|
|
1203
1205
|
resolveName: this.resolveName.bind(this),
|
|
1204
|
-
getPlugins: this.#getSortedPlugins.bind(this)
|
|
1205
|
-
|
|
1206
|
-
this.#core = this.#parse(core, this, core.api.call(null));
|
|
1207
|
-
this.plugins = [this.#core, ...plugins].map((plugin) => {
|
|
1208
|
-
return this.#parse(plugin, this, this.#core.api);
|
|
1206
|
+
getPlugins: this.#getSortedPlugins.bind(this),
|
|
1207
|
+
plugin: void 0
|
|
1209
1208
|
});
|
|
1209
|
+
this.#core = pluginParser(core, core.api.call(null));
|
|
1210
|
+
this.plugins = [this.#core, ...config.plugins || []].reduce((prev, plugin) => {
|
|
1211
|
+
const convertedApi = pluginParser(plugin, this.#core?.api);
|
|
1212
|
+
return [...prev, convertedApi];
|
|
1213
|
+
}, []);
|
|
1210
1214
|
return this;
|
|
1211
1215
|
}
|
|
1212
1216
|
resolvePath = (params) => {
|
|
1213
|
-
if (params.
|
|
1214
|
-
|
|
1215
|
-
|
|
1217
|
+
if (params.pluginName) {
|
|
1218
|
+
return this.hookForPluginSync({
|
|
1219
|
+
pluginName: params.pluginName,
|
|
1216
1220
|
hookName: "resolvePath",
|
|
1217
1221
|
parameters: [params.baseName, params.directory, params.options]
|
|
1218
1222
|
});
|
|
1219
|
-
if (paths && paths?.length > 1) {
|
|
1220
|
-
throw new Error(
|
|
1221
|
-
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1222
|
-
|
|
1223
|
-
Paths: ${JSON.stringify(paths, void 0, 2)}`
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
return paths?.at(0);
|
|
1227
1223
|
}
|
|
1228
1224
|
return this.hookFirstSync({
|
|
1229
1225
|
hookName: "resolvePath",
|
|
@@ -1231,20 +1227,13 @@ Paths: ${JSON.stringify(paths, void 0, 2)}`
|
|
|
1231
1227
|
}).result;
|
|
1232
1228
|
};
|
|
1233
1229
|
resolveName = (params) => {
|
|
1234
|
-
if (params.
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1230
|
+
if (params.pluginName) {
|
|
1231
|
+
const name2 = this.hookForPluginSync({
|
|
1232
|
+
pluginName: params.pluginName,
|
|
1237
1233
|
hookName: "resolveName",
|
|
1238
1234
|
parameters: [params.name, params.type]
|
|
1239
1235
|
});
|
|
1240
|
-
|
|
1241
|
-
throw new Error(
|
|
1242
|
-
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1243
|
-
|
|
1244
|
-
Names: ${JSON.stringify(names, void 0, 2)}`
|
|
1245
|
-
);
|
|
1246
|
-
}
|
|
1247
|
-
return transformReservedWord(names?.at(0) || params.name);
|
|
1236
|
+
return transformReservedWord(name2 || params.name);
|
|
1248
1237
|
}
|
|
1249
1238
|
const name = this.hookFirstSync({
|
|
1250
1239
|
hookName: "resolveName",
|
|
@@ -1259,35 +1248,30 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1259
1248
|
* Run only hook for a specific plugin name
|
|
1260
1249
|
*/
|
|
1261
1250
|
hookForPlugin({
|
|
1262
|
-
|
|
1251
|
+
pluginName: pluginName2,
|
|
1263
1252
|
hookName,
|
|
1264
1253
|
parameters
|
|
1265
1254
|
}) {
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
});
|
|
1274
|
-
}).filter(Boolean);
|
|
1275
|
-
return Promise.all(promises);
|
|
1255
|
+
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1256
|
+
return this.#execute({
|
|
1257
|
+
strategy: "hookFirst",
|
|
1258
|
+
hookName,
|
|
1259
|
+
parameters,
|
|
1260
|
+
plugin
|
|
1261
|
+
});
|
|
1276
1262
|
}
|
|
1277
1263
|
hookForPluginSync({
|
|
1278
|
-
|
|
1264
|
+
pluginName: pluginName2,
|
|
1279
1265
|
hookName,
|
|
1280
1266
|
parameters
|
|
1281
1267
|
}) {
|
|
1282
|
-
const
|
|
1283
|
-
return
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
});
|
|
1290
|
-
}).filter(Boolean);
|
|
1268
|
+
const plugin = this.getPlugin(hookName, pluginName2);
|
|
1269
|
+
return this.#executeSync({
|
|
1270
|
+
strategy: "hookFirst",
|
|
1271
|
+
hookName,
|
|
1272
|
+
parameters,
|
|
1273
|
+
plugin
|
|
1274
|
+
});
|
|
1291
1275
|
}
|
|
1292
1276
|
/**
|
|
1293
1277
|
* Chains, first non-null result stops and returns
|
|
@@ -1403,58 +1387,37 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1403
1387
|
* Chains plugins
|
|
1404
1388
|
*/
|
|
1405
1389
|
hookSeq({ hookName, parameters }) {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1390
|
+
let promise = Promise.resolve();
|
|
1391
|
+
for (const plugin of this.#getSortedPlugins()) {
|
|
1392
|
+
promise = promise.then(() => {
|
|
1393
|
+
this.#execute({
|
|
1394
|
+
strategy: "hookSeq",
|
|
1395
|
+
hookName,
|
|
1396
|
+
parameters,
|
|
1397
|
+
plugin
|
|
1398
|
+
});
|
|
1412
1399
|
});
|
|
1413
|
-
}
|
|
1414
|
-
return
|
|
1400
|
+
}
|
|
1401
|
+
return promise.then(noReturn);
|
|
1415
1402
|
}
|
|
1416
1403
|
#getSortedPlugins(hookName) {
|
|
1417
1404
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1418
1405
|
if (hookName) {
|
|
1419
|
-
if (this.logger.logLevel === "info") {
|
|
1420
|
-
const containsHookName = plugins.some((item) => item[hookName]);
|
|
1421
|
-
if (!containsHookName) {
|
|
1422
|
-
this.logger.warn(`No hook ${hookName} found`);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
1406
|
return plugins.filter((item) => item[hookName]);
|
|
1426
1407
|
}
|
|
1427
1408
|
return plugins;
|
|
1428
1409
|
}
|
|
1429
|
-
|
|
1410
|
+
getPlugin(hookName, pluginName2) {
|
|
1430
1411
|
const plugins = [...this.plugins];
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
1435
|
-
const kindCheck = kind === searchKind;
|
|
1436
|
-
const nameCheck = name === searchPluginName;
|
|
1437
|
-
if (searchIdentifier) {
|
|
1438
|
-
return identifierCheck && kindCheck && nameCheck;
|
|
1439
|
-
}
|
|
1440
|
-
return kindCheck && nameCheck;
|
|
1441
|
-
});
|
|
1442
|
-
if (!pluginByPluginName?.length) {
|
|
1443
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
1444
|
-
if (this.logger.logLevel === "info") {
|
|
1445
|
-
if (corePlugin) {
|
|
1446
|
-
this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
|
|
1447
|
-
} else {
|
|
1448
|
-
this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
return corePlugin ? [corePlugin] : [];
|
|
1412
|
+
const pluginByPluginName = plugins.find((item) => item.name === pluginName2 && item[hookName]);
|
|
1413
|
+
if (!pluginByPluginName) {
|
|
1414
|
+
return this.#core;
|
|
1452
1415
|
}
|
|
1453
1416
|
return pluginByPluginName;
|
|
1454
1417
|
}
|
|
1455
1418
|
#addExecutedToCallStack(executer) {
|
|
1456
1419
|
if (executer) {
|
|
1457
|
-
this.eventEmitter.emit("
|
|
1420
|
+
this.eventEmitter.emit("execute", executer);
|
|
1458
1421
|
this.executed.push(executer);
|
|
1459
1422
|
}
|
|
1460
1423
|
}
|
|
@@ -1524,7 +1487,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1524
1487
|
this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1525
1488
|
try {
|
|
1526
1489
|
if (typeof hook === "function") {
|
|
1527
|
-
const fn = hook.apply(
|
|
1490
|
+
const fn = hook.apply(this.#core.api, parameters);
|
|
1528
1491
|
output = fn;
|
|
1529
1492
|
return fn;
|
|
1530
1493
|
}
|
|
@@ -1550,50 +1513,34 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1550
1513
|
this.eventEmitter.emit("error", pluginError);
|
|
1551
1514
|
throw pluginError;
|
|
1552
1515
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
pluginNames = [dependedPluginNames];
|
|
1582
|
-
} else {
|
|
1583
|
-
pluginNames = dependedPluginNames;
|
|
1584
|
-
}
|
|
1585
|
-
return pluginNames.map((pluginName2) => {
|
|
1586
|
-
const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
|
|
1587
|
-
if (!plugin) {
|
|
1588
|
-
throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
|
|
1589
|
-
}
|
|
1590
|
-
return plugin;
|
|
1591
|
-
});
|
|
1592
|
-
}
|
|
1593
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1594
|
-
static get hooks() {
|
|
1595
|
-
return ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
1596
|
-
}
|
|
1516
|
+
};
|
|
1517
|
+
function noReturn() {
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// src/managers/pluginManager/validate.ts
|
|
1521
|
+
var ValidationPluginError = class extends Error {
|
|
1522
|
+
};
|
|
1523
|
+
function getDependedPlugins(plugins, dependedPluginNames) {
|
|
1524
|
+
let pluginNames = [];
|
|
1525
|
+
if (typeof dependedPluginNames === "string") {
|
|
1526
|
+
pluginNames = [dependedPluginNames];
|
|
1527
|
+
} else {
|
|
1528
|
+
pluginNames = dependedPluginNames;
|
|
1529
|
+
}
|
|
1530
|
+
return pluginNames.map((pluginName2) => {
|
|
1531
|
+
const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
|
|
1532
|
+
if (!plugin) {
|
|
1533
|
+
throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
|
|
1534
|
+
}
|
|
1535
|
+
return plugin;
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
// src/types.ts
|
|
1540
|
+
var LogLevel = {
|
|
1541
|
+
silent: "silent",
|
|
1542
|
+
info: "info",
|
|
1543
|
+
debug: "debug"
|
|
1597
1544
|
};
|
|
1598
1545
|
|
|
1599
1546
|
// src/build.ts
|
|
@@ -1601,13 +1548,13 @@ async function transformReducer(_previousCode, result, _plugin) {
|
|
|
1601
1548
|
return result;
|
|
1602
1549
|
}
|
|
1603
1550
|
async function build(options) {
|
|
1604
|
-
const { config, logger = createLogger(
|
|
1551
|
+
const { config, logLevel, logger = createLogger() } = options;
|
|
1605
1552
|
try {
|
|
1606
|
-
if (
|
|
1553
|
+
if ("path" in config.input && !new URLPath(config.input.path).isURL) {
|
|
1607
1554
|
await read(config.input.path);
|
|
1608
1555
|
}
|
|
1609
1556
|
} catch (e) {
|
|
1610
|
-
if (
|
|
1557
|
+
if ("path" in config.input) {
|
|
1611
1558
|
throw new Error(
|
|
1612
1559
|
"Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config " + pc3.dim(config.input.path),
|
|
1613
1560
|
{
|
|
@@ -1620,11 +1567,11 @@ async function build(options) {
|
|
|
1620
1567
|
await clean(config.output.path);
|
|
1621
1568
|
}
|
|
1622
1569
|
const queueTask = async (file) => {
|
|
1623
|
-
const { path
|
|
1624
|
-
let code =
|
|
1570
|
+
const { path } = file;
|
|
1571
|
+
let code = createFileSource(file);
|
|
1625
1572
|
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
1626
1573
|
hookName: "load",
|
|
1627
|
-
parameters: [
|
|
1574
|
+
parameters: [path]
|
|
1628
1575
|
});
|
|
1629
1576
|
if (loadedResult && isPromise(loadedResult)) {
|
|
1630
1577
|
code = await loadedResult;
|
|
@@ -1635,53 +1582,28 @@ async function build(options) {
|
|
|
1635
1582
|
if (code) {
|
|
1636
1583
|
const transformedCode = await pluginManager.hookReduceArg0({
|
|
1637
1584
|
hookName: "transform",
|
|
1638
|
-
parameters: [code,
|
|
1585
|
+
parameters: [code, path],
|
|
1639
1586
|
reduce: transformReducer
|
|
1640
1587
|
});
|
|
1641
1588
|
if (config.output.write || config.output.write === void 0) {
|
|
1642
|
-
|
|
1643
|
-
return pluginManager.hookForPlugin({
|
|
1644
|
-
pluginKey: file.meta?.pluginKey,
|
|
1645
|
-
hookName: "writeFile",
|
|
1646
|
-
parameters: [transformedCode, path3]
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
return pluginManager.hookFirst({
|
|
1589
|
+
await pluginManager.hookParallel({
|
|
1650
1590
|
hookName: "writeFile",
|
|
1651
|
-
parameters: [transformedCode,
|
|
1591
|
+
parameters: [transformedCode, path]
|
|
1652
1592
|
});
|
|
1653
1593
|
}
|
|
1654
1594
|
}
|
|
1655
1595
|
};
|
|
1656
|
-
const pluginManager = new PluginManager(config, { logger, task: queueTask
|
|
1596
|
+
const pluginManager = new PluginManager(config, { debug: logLevel === LogLevel.debug, logger, task: queueTask });
|
|
1657
1597
|
const { plugins, fileManager } = pluginManager;
|
|
1658
1598
|
pluginManager.on("execute", (executer) => {
|
|
1659
|
-
const { hookName, parameters, plugin } = executer;
|
|
1660
|
-
if (hookName === "writeFile" && logger.spinner) {
|
|
1661
|
-
const [code] = parameters;
|
|
1662
|
-
if (logger.logLevel === LogLevel.info) {
|
|
1663
|
-
logger.spinner.start(`\u{1F4BE} Writing`);
|
|
1664
|
-
}
|
|
1665
|
-
if (logger.logLevel === "debug") {
|
|
1666
|
-
logger.info(`PluginKey ${pc3.dim(JSON.stringify(plugin.key))}
|
|
1667
|
-
with source
|
|
1668
|
-
|
|
1669
|
-
${code}`);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
});
|
|
1673
|
-
pluginManager.on("executed", (executer) => {
|
|
1674
1599
|
const { hookName, plugin, output, parameters } = executer;
|
|
1675
1600
|
const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`;
|
|
1676
|
-
if (
|
|
1677
|
-
if (
|
|
1678
|
-
const [_code, path3] = parameters;
|
|
1679
|
-
logger.spinner.suffixText = pc3.dim(path3);
|
|
1680
|
-
} else {
|
|
1601
|
+
if (logLevel === LogLevel.info) {
|
|
1602
|
+
if (logger.spinner) {
|
|
1681
1603
|
logger.spinner.suffixText = messsage;
|
|
1682
1604
|
}
|
|
1683
1605
|
}
|
|
1684
|
-
if (
|
|
1606
|
+
if (logLevel === LogLevel.debug) {
|
|
1685
1607
|
logger.info(messsage);
|
|
1686
1608
|
const logs = [
|
|
1687
1609
|
parameters && `${pc3.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
|
|
@@ -1701,14 +1623,15 @@ ${code}`);
|
|
|
1701
1623
|
parameters: [config]
|
|
1702
1624
|
});
|
|
1703
1625
|
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1626
|
+
return { files: fileManager.files.map((file) => ({ ...file, source: createFileSource(file) })), pluginManager };
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// src/config.ts
|
|
1630
|
+
function defineConfig(options) {
|
|
1631
|
+
return options;
|
|
1709
1632
|
}
|
|
1710
1633
|
|
|
1711
|
-
// src/Generator.ts
|
|
1634
|
+
// src/generators/Generator.ts
|
|
1712
1635
|
var Generator = class {
|
|
1713
1636
|
#options = {};
|
|
1714
1637
|
#context = {};
|
|
@@ -1731,6 +1654,10 @@ var Generator = class {
|
|
|
1731
1654
|
this.#options = { ...this.#options, ...options };
|
|
1732
1655
|
}
|
|
1733
1656
|
};
|
|
1657
|
+
|
|
1658
|
+
// src/generators/SchemaGenerator.ts
|
|
1659
|
+
var SchemaGenerator = class extends Generator {
|
|
1660
|
+
};
|
|
1734
1661
|
var PackageManager = class _PackageManager {
|
|
1735
1662
|
static #cache = {};
|
|
1736
1663
|
#cwd;
|
|
@@ -1753,17 +1680,17 @@ var PackageManager = class _PackageManager {
|
|
|
1753
1680
|
}
|
|
1754
1681
|
return directory;
|
|
1755
1682
|
}
|
|
1756
|
-
getLocation(
|
|
1757
|
-
let location =
|
|
1683
|
+
getLocation(path) {
|
|
1684
|
+
let location = path;
|
|
1758
1685
|
if (this.#cwd) {
|
|
1759
1686
|
const require2 = mod.createRequire(this.normalizeDirectory(this.#cwd));
|
|
1760
|
-
location = require2.resolve(
|
|
1687
|
+
location = require2.resolve(path);
|
|
1761
1688
|
}
|
|
1762
1689
|
return location;
|
|
1763
1690
|
}
|
|
1764
|
-
async import(
|
|
1691
|
+
async import(path) {
|
|
1765
1692
|
try {
|
|
1766
|
-
let location = this.getLocation(
|
|
1693
|
+
let location = this.getLocation(path);
|
|
1767
1694
|
if (os.platform() == "win32") {
|
|
1768
1695
|
location = pathToFileURL(location).href;
|
|
1769
1696
|
}
|
|
@@ -1839,13 +1766,9 @@ var PackageManager = class _PackageManager {
|
|
|
1839
1766
|
}
|
|
1840
1767
|
};
|
|
1841
1768
|
|
|
1842
|
-
// src/SchemaGenerator.ts
|
|
1843
|
-
var SchemaGenerator = class extends Generator {
|
|
1844
|
-
};
|
|
1845
|
-
|
|
1846
1769
|
// src/index.ts
|
|
1847
1770
|
var src_default = build;
|
|
1848
1771
|
|
|
1849
|
-
export { FileManager, Generator, PackageManager, ParallelPluginError, PluginError, PluginManager,
|
|
1772
|
+
export { FileManager, FunctionParams, Generator, LogLevel, PackageManager, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, clean, combineCodes, combineExports, combineFiles, combineImports, createFileSource, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, escape, extensions, getDependedPlugins, getIndexes, getPathMode, getRelativePath, getUniqueName, hooks, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, jsStringEscape, pluginName as name, nameSorter, pluginName, randomColour, randomPicoColour, read, readSync, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
|
|
1850
1773
|
//# sourceMappingURL=out.js.map
|
|
1851
1774
|
//# sourceMappingURL=index.js.map
|