@kubb/core 2.0.0-beta.3 → 2.0.0-beta.5
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 +188 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -13
- package/dist/index.d.ts +9 -13
- package/dist/index.js +191 -158
- package/dist/index.js.map +1 -1
- package/dist/transformers.cjs +222 -0
- package/dist/transformers.cjs.map +1 -0
- package/dist/transformers.d.cts +55 -0
- package/dist/transformers.d.ts +55 -0
- package/dist/transformers.js +207 -0
- package/dist/transformers.js.map +1 -0
- package/dist/utils.cjs +226 -212
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -49
- package/dist/utils.d.ts +1 -49
- package/dist/utils.js +227 -212
- package/dist/utils.js.map +1 -1
- package/package.json +10 -5
- package/src/FileManager.ts +33 -15
- package/src/PluginManager.ts +9 -9
- package/src/build.ts +1 -1
- package/src/index.ts +0 -1
- package/src/transformers/casing.ts +9 -0
- package/src/transformers/createJSDocBlockText.ts +9 -0
- package/src/transformers/index.ts +36 -0
- package/src/transformers/trim.ts +7 -0
- package/src/utils/FunctionParams.ts +3 -2
- package/src/utils/URLPath.ts +5 -5
- package/src/utils/index.ts +0 -1
- package/src/SchemaGenerator.ts +0 -8
- package/src/utils/transformers/createJSDocBlockText.ts +0 -15
- package/src/utils/transformers/index.ts +0 -22
- package/src/utils/transformers/trim.ts +0 -3
- /package/src/{utils/transformers → transformers}/combineCodes.ts +0 -0
- /package/src/{utils/transformers → transformers}/escape.ts +0 -0
- /package/src/{utils/transformers → transformers}/indent.ts +0 -0
- /package/src/{utils/transformers → transformers}/nameSorter.ts +0 -0
- /package/src/{utils/transformers → transformers}/searchAndReplace.ts +0 -0
- /package/src/{utils/transformers → transformers}/transformReservedWord.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -170,6 +170,24 @@ function randomPicoColour(text, colors = defaultColours) {
|
|
|
170
170
|
}
|
|
171
171
|
return formatter(text);
|
|
172
172
|
}
|
|
173
|
+
function slash(path5, platform = "linux") {
|
|
174
|
+
const isWindowsPath = /^\\\\\?\\/.test(path5);
|
|
175
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
176
|
+
return path5.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
177
|
+
}
|
|
178
|
+
return path5.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
179
|
+
}
|
|
180
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
181
|
+
if (!rootDir || !filePath) {
|
|
182
|
+
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
183
|
+
}
|
|
184
|
+
const relativePath = path4.relative(rootDir, filePath);
|
|
185
|
+
const slashedPath = slash(relativePath, platform);
|
|
186
|
+
if (slashedPath.startsWith("../")) {
|
|
187
|
+
return slashedPath.replace(path4.basename(slashedPath), path4.basename(slashedPath, path4.extname(filePath)));
|
|
188
|
+
}
|
|
189
|
+
return `./${slashedPath.replace(path4.basename(slashedPath), path4.basename(slashedPath, path4.extname(filePath)))}`;
|
|
190
|
+
}
|
|
173
191
|
var reader = jsRuntime.switcher(
|
|
174
192
|
{
|
|
175
193
|
node: async (path5) => {
|
|
@@ -196,141 +214,30 @@ jsRuntime.switcher(
|
|
|
196
214
|
async function read(path5) {
|
|
197
215
|
return reader(path5);
|
|
198
216
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.path = path5;
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
206
|
-
* @example /pet/{petId} => /pet/:petId
|
|
207
|
-
*/
|
|
208
|
-
get URL() {
|
|
209
|
-
return this.toURLPath();
|
|
210
|
-
}
|
|
211
|
-
get isURL() {
|
|
212
|
-
try {
|
|
213
|
-
const url = new URL(this.path);
|
|
214
|
-
if (url?.href) {
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
} catch (error) {
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
224
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
225
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
226
|
-
* @example /account/userID => `/account/${userId}`
|
|
227
|
-
*/
|
|
228
|
-
get template() {
|
|
229
|
-
return this.toTemplateString();
|
|
230
|
-
}
|
|
231
|
-
get object() {
|
|
232
|
-
return this.toObject();
|
|
233
|
-
}
|
|
234
|
-
get params() {
|
|
235
|
-
return this.getParams();
|
|
236
|
-
}
|
|
237
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
238
|
-
const object = {
|
|
239
|
-
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
240
|
-
params: this.getParams()
|
|
241
|
-
};
|
|
242
|
-
if (stringify) {
|
|
243
|
-
if (type === "template") {
|
|
244
|
-
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
245
|
-
}
|
|
246
|
-
if (object.params) {
|
|
247
|
-
return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
248
|
-
}
|
|
249
|
-
return `{ url: '${object.url}' }`;
|
|
250
|
-
}
|
|
251
|
-
return object;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
255
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
256
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
257
|
-
* @example /account/userID => `/account/${userId}`
|
|
258
|
-
*/
|
|
259
|
-
toTemplateString(replacer) {
|
|
260
|
-
const regex = /{(\w|-)*}/g;
|
|
261
|
-
const found = this.path.match(regex);
|
|
262
|
-
let newPath = this.path.replaceAll("{", "${");
|
|
263
|
-
if (found) {
|
|
264
|
-
newPath = found.reduce((prev, curr) => {
|
|
265
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(curr, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
266
|
-
const replacement = `\${${pathParam}}`;
|
|
267
|
-
return prev.replace(curr, replacement);
|
|
268
|
-
}, this.path);
|
|
269
|
-
}
|
|
270
|
-
return `\`${newPath}\``;
|
|
271
|
-
}
|
|
272
|
-
getParams(replacer) {
|
|
273
|
-
const regex = /{(\w|-)*}/g;
|
|
274
|
-
const found = this.path.match(regex);
|
|
275
|
-
if (!found) {
|
|
276
|
-
return void 0;
|
|
277
|
-
}
|
|
278
|
-
const params = {};
|
|
279
|
-
found.forEach((item) => {
|
|
280
|
-
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
281
|
-
const pathParam = replacer ? replacer(changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge })) : changeCase.camelCase(item, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
|
|
282
|
-
params[pathParam] = pathParam;
|
|
283
|
-
}, this.path);
|
|
284
|
-
return params;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
288
|
-
* @example /pet/{petId} => /pet/:petId
|
|
289
|
-
*/
|
|
290
|
-
toURLPath() {
|
|
291
|
-
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
// src/config.ts
|
|
296
|
-
function defineConfig(options) {
|
|
297
|
-
return options;
|
|
217
|
+
function camelCase(text) {
|
|
218
|
+
return changeCase.camelCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.camelCaseTransformMerge });
|
|
298
219
|
}
|
|
299
|
-
function
|
|
300
|
-
return
|
|
220
|
+
function pascalCase(text) {
|
|
221
|
+
return changeCase.pascalCase(text, { delimiter: "", stripRegexp: /[^A-Z0-9$]/gi, transform: changeCase.pascalCaseTransformMerge });
|
|
301
222
|
}
|
|
302
223
|
|
|
303
|
-
// src/
|
|
304
|
-
async function timeout(ms) {
|
|
305
|
-
return new Promise((resolve2) => {
|
|
306
|
-
setTimeout(() => {
|
|
307
|
-
resolve2(true);
|
|
308
|
-
}, ms);
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// src/utils/transformers/combineCodes.ts
|
|
224
|
+
// src/transformers/combineCodes.ts
|
|
313
225
|
function combineCodes(codes) {
|
|
314
226
|
return codes.join("\n");
|
|
315
227
|
}
|
|
316
228
|
|
|
317
|
-
// src/
|
|
318
|
-
function createJSDocBlockText({ comments
|
|
229
|
+
// src/transformers/createJSDocBlockText.ts
|
|
230
|
+
function createJSDocBlockText({ comments }) {
|
|
319
231
|
const filteredComments = comments.filter(Boolean);
|
|
320
232
|
if (!filteredComments.length) {
|
|
321
233
|
return "";
|
|
322
234
|
}
|
|
323
|
-
|
|
235
|
+
return `/**
|
|
324
236
|
* ${filteredComments.join("\n * ")}
|
|
325
237
|
*/`;
|
|
326
|
-
if (newLine) {
|
|
327
|
-
return `${source}
|
|
328
|
-
`;
|
|
329
|
-
}
|
|
330
|
-
return source;
|
|
331
238
|
}
|
|
332
239
|
|
|
333
|
-
// src/
|
|
240
|
+
// src/transformers/escape.ts
|
|
334
241
|
function escape(text) {
|
|
335
242
|
return text ? text.replaceAll("`", "\\`") : "";
|
|
336
243
|
}
|
|
@@ -355,12 +262,12 @@ function jsStringEscape(input) {
|
|
|
355
262
|
});
|
|
356
263
|
}
|
|
357
264
|
|
|
358
|
-
// src/
|
|
265
|
+
// src/transformers/indent.ts
|
|
359
266
|
function createIndent(size) {
|
|
360
267
|
return Array.from({ length: size + 1 }).join(" ");
|
|
361
268
|
}
|
|
362
269
|
|
|
363
|
-
// src/
|
|
270
|
+
// src/transformers/nameSorter.ts
|
|
364
271
|
function nameSorter(a, b) {
|
|
365
272
|
if (a.name < b.name) {
|
|
366
273
|
return -1;
|
|
@@ -371,7 +278,7 @@ function nameSorter(a, b) {
|
|
|
371
278
|
return 0;
|
|
372
279
|
}
|
|
373
280
|
|
|
374
|
-
// src/
|
|
281
|
+
// src/transformers/searchAndReplace.ts
|
|
375
282
|
function searchAndReplace(options) {
|
|
376
283
|
const { text, replaceBy, prefix = "", key } = options;
|
|
377
284
|
const searchValues = options.searchValues?.(prefix, key) || [
|
|
@@ -388,7 +295,7 @@ function searchAndReplace(options) {
|
|
|
388
295
|
}, text);
|
|
389
296
|
}
|
|
390
297
|
|
|
391
|
-
// src/
|
|
298
|
+
// src/transformers/transformReservedWord.ts
|
|
392
299
|
var reservedWords = [
|
|
393
300
|
"abstract",
|
|
394
301
|
"arguments",
|
|
@@ -481,13 +388,16 @@ function transformReservedWord(word) {
|
|
|
481
388
|
return word;
|
|
482
389
|
}
|
|
483
390
|
|
|
484
|
-
// src/
|
|
391
|
+
// src/transformers/trim.ts
|
|
485
392
|
function trim(text) {
|
|
486
393
|
return text.replaceAll(/\n/g, "").trim();
|
|
487
394
|
}
|
|
395
|
+
function trimExtName(text) {
|
|
396
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
397
|
+
}
|
|
488
398
|
|
|
489
|
-
// src/
|
|
490
|
-
var
|
|
399
|
+
// src/transformers/index.ts
|
|
400
|
+
var transformers_default = {
|
|
491
401
|
combineCodes,
|
|
492
402
|
escape,
|
|
493
403
|
jsStringEscape,
|
|
@@ -496,10 +406,127 @@ var transformers = {
|
|
|
496
406
|
nameSorter,
|
|
497
407
|
searchAndReplace,
|
|
498
408
|
trim,
|
|
409
|
+
trimExtName,
|
|
499
410
|
JSDoc: {
|
|
500
411
|
createJSDocBlockText
|
|
412
|
+
},
|
|
413
|
+
camelCase,
|
|
414
|
+
pascalCase
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// src/utils/URLPath.ts
|
|
418
|
+
var URLPath = class {
|
|
419
|
+
constructor(path5) {
|
|
420
|
+
this.path = path5;
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
425
|
+
* @example /pet/{petId} => /pet/:petId
|
|
426
|
+
*/
|
|
427
|
+
get URL() {
|
|
428
|
+
return this.toURLPath();
|
|
429
|
+
}
|
|
430
|
+
get isURL() {
|
|
431
|
+
try {
|
|
432
|
+
const url = new URL(this.path);
|
|
433
|
+
if (url?.href) {
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
} catch (error) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
443
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
444
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
445
|
+
* @example /account/userID => `/account/${userId}`
|
|
446
|
+
*/
|
|
447
|
+
get template() {
|
|
448
|
+
return this.toTemplateString();
|
|
449
|
+
}
|
|
450
|
+
get object() {
|
|
451
|
+
return this.toObject();
|
|
452
|
+
}
|
|
453
|
+
get params() {
|
|
454
|
+
return this.getParams();
|
|
455
|
+
}
|
|
456
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
457
|
+
const object = {
|
|
458
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
459
|
+
params: this.getParams()
|
|
460
|
+
};
|
|
461
|
+
if (stringify) {
|
|
462
|
+
if (type === "template") {
|
|
463
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
464
|
+
}
|
|
465
|
+
if (object.params) {
|
|
466
|
+
return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
467
|
+
}
|
|
468
|
+
return `{ url: '${object.url}' }`;
|
|
469
|
+
}
|
|
470
|
+
return object;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
474
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
475
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
476
|
+
* @example /account/userID => `/account/${userId}`
|
|
477
|
+
*/
|
|
478
|
+
toTemplateString(replacer) {
|
|
479
|
+
const regex = /{(\w|-)*}/g;
|
|
480
|
+
const found = this.path.match(regex);
|
|
481
|
+
let newPath = this.path.replaceAll("{", "${");
|
|
482
|
+
if (found) {
|
|
483
|
+
newPath = found.reduce((prev, curr) => {
|
|
484
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(curr)) : transformers_default.camelCase(curr);
|
|
485
|
+
const replacement = `\${${pathParam}}`;
|
|
486
|
+
return prev.replace(curr, replacement);
|
|
487
|
+
}, this.path);
|
|
488
|
+
}
|
|
489
|
+
return `\`${newPath}\``;
|
|
490
|
+
}
|
|
491
|
+
getParams(replacer) {
|
|
492
|
+
const regex = /{(\w|-)*}/g;
|
|
493
|
+
const found = this.path.match(regex);
|
|
494
|
+
if (!found) {
|
|
495
|
+
return void 0;
|
|
496
|
+
}
|
|
497
|
+
const params = {};
|
|
498
|
+
found.forEach((item) => {
|
|
499
|
+
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
500
|
+
const pathParam = replacer ? replacer(transformers_default.camelCase(item)) : transformers_default.camelCase(item);
|
|
501
|
+
params[pathParam] = pathParam;
|
|
502
|
+
}, this.path);
|
|
503
|
+
return params;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
507
|
+
* @example /pet/{petId} => /pet/:petId
|
|
508
|
+
*/
|
|
509
|
+
toURLPath() {
|
|
510
|
+
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
501
511
|
}
|
|
502
512
|
};
|
|
513
|
+
|
|
514
|
+
// src/config.ts
|
|
515
|
+
function defineConfig(options) {
|
|
516
|
+
return options;
|
|
517
|
+
}
|
|
518
|
+
function isInputPath(result) {
|
|
519
|
+
return !!result && "path" in result;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/utils/timeout.ts
|
|
523
|
+
async function timeout(ms) {
|
|
524
|
+
return new Promise((resolve2) => {
|
|
525
|
+
setTimeout(() => {
|
|
526
|
+
resolve2(true);
|
|
527
|
+
}, ms);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
503
530
|
async function saveCreateDirectory(path5) {
|
|
504
531
|
const passedPath = path4.dirname(path4.resolve(path5));
|
|
505
532
|
await fs2__default.default.mkdir(passedPath, { recursive: true });
|
|
@@ -730,7 +757,7 @@ _options = new WeakMap();
|
|
|
730
757
|
exports.KubbFile = void 0;
|
|
731
758
|
((KubbFile2) => {
|
|
732
759
|
})(exports.KubbFile || (exports.KubbFile = {}));
|
|
733
|
-
var _cache, _task, _isWriting, _timeout, _queue, _validate,
|
|
760
|
+
var _cache, _task, _isWriting, _timeout, _queue, _validate, _add, add_fn, _addOrAppend, addOrAppend_fn;
|
|
734
761
|
var _FileManager = class _FileManager {
|
|
735
762
|
constructor(options) {
|
|
736
763
|
__privateAdd(this, _validate);
|
|
@@ -763,7 +790,6 @@ var _FileManager = class _FileManager {
|
|
|
763
790
|
}
|
|
764
791
|
async add(...files) {
|
|
765
792
|
const promises = files.map((file) => {
|
|
766
|
-
__privateMethod(this, _validate, validate_fn).call(this, file);
|
|
767
793
|
if (file.override) {
|
|
768
794
|
return __privateMethod(this, _add, add_fn).call(this, file);
|
|
769
795
|
}
|
|
@@ -827,9 +853,22 @@ var _FileManager = class _FileManager {
|
|
|
827
853
|
}
|
|
828
854
|
const exports = file.exports ? combineExports(file.exports) : [];
|
|
829
855
|
const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
|
|
830
|
-
const importNodes = imports.
|
|
856
|
+
const importNodes = imports.filter((item) => {
|
|
857
|
+
return item.path !== transformers_default.trimExtName(file.path);
|
|
858
|
+
}).map((item) => {
|
|
859
|
+
return factory__namespace.createImportDeclaration({
|
|
860
|
+
name: item.name,
|
|
861
|
+
path: item.root ? getRelativePath(item.root, item.path) : item.path,
|
|
862
|
+
isTypeOnly: item.isTypeOnly
|
|
863
|
+
});
|
|
864
|
+
});
|
|
831
865
|
const exportNodes = exports.map(
|
|
832
|
-
(item) => factory__namespace.createExportDeclaration({
|
|
866
|
+
(item) => factory__namespace.createExportDeclaration({
|
|
867
|
+
name: item.name,
|
|
868
|
+
path: item.path,
|
|
869
|
+
isTypeOnly: item.isTypeOnly,
|
|
870
|
+
asAlias: item.asAlias
|
|
871
|
+
})
|
|
833
872
|
);
|
|
834
873
|
return [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
|
|
835
874
|
}
|
|
@@ -880,14 +919,6 @@ _isWriting = new WeakMap();
|
|
|
880
919
|
_timeout = new WeakMap();
|
|
881
920
|
_queue = new WeakMap();
|
|
882
921
|
_validate = new WeakSet();
|
|
883
|
-
validate_fn = function(file) {
|
|
884
|
-
if (!file.validate) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {
|
|
888
|
-
throw new Error(`${file.path} should end with the baseName ${file.baseName}`);
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
922
|
_add = new WeakSet();
|
|
892
923
|
add_fn = async function(file) {
|
|
893
924
|
const controller = new AbortController();
|
|
@@ -964,7 +995,7 @@ function combineImports(imports, exports, source) {
|
|
|
964
995
|
return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
|
|
965
996
|
};
|
|
966
997
|
if (Array.isArray(name)) {
|
|
967
|
-
name = name.filter((item) => hasImportInSource(item));
|
|
998
|
+
name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
|
|
968
999
|
}
|
|
969
1000
|
const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
|
|
970
1001
|
const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isEqual__default.default(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
|
|
@@ -1010,8 +1041,8 @@ function getEnvSource(source, env) {
|
|
|
1010
1041
|
throw new TypeError(`Environment should be in upperCase for ${key}`);
|
|
1011
1042
|
}
|
|
1012
1043
|
if (typeof replaceBy === "string") {
|
|
1013
|
-
prev =
|
|
1014
|
-
prev =
|
|
1044
|
+
prev = transformers_default.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
|
|
1045
|
+
prev = transformers_default.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
|
|
1015
1046
|
`, "ig"), ""), replaceBy, key });
|
|
1016
1047
|
}
|
|
1017
1048
|
return prev;
|
|
@@ -1305,11 +1336,14 @@ var PluginManager = class {
|
|
|
1305
1336
|
hookName: "resolvePath",
|
|
1306
1337
|
parameters: [params.baseName, params.directory, params.options]
|
|
1307
1338
|
});
|
|
1308
|
-
if (paths && paths?.length > 1) {
|
|
1309
|
-
|
|
1339
|
+
if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {
|
|
1340
|
+
this.logger.warn(
|
|
1310
1341
|
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1311
1342
|
|
|
1312
|
-
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
1343
|
+
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
1344
|
+
|
|
1345
|
+
Falling back on the first item.
|
|
1346
|
+
`
|
|
1313
1347
|
);
|
|
1314
1348
|
}
|
|
1315
1349
|
return paths?.at(0);
|
|
@@ -1326,11 +1360,14 @@ Paths: ${JSON.stringify(paths, void 0, 2)}`
|
|
|
1326
1360
|
hookName: "resolveName",
|
|
1327
1361
|
parameters: [params.name, params.type]
|
|
1328
1362
|
});
|
|
1329
|
-
if (names && names?.length > 1) {
|
|
1330
|
-
|
|
1363
|
+
if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {
|
|
1364
|
+
this.logger.warn(
|
|
1331
1365
|
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1332
1366
|
|
|
1333
|
-
Names: ${JSON.stringify(names, void 0, 2)}
|
|
1367
|
+
Names: ${JSON.stringify(names, void 0, 2)}
|
|
1368
|
+
|
|
1369
|
+
Falling back on the first item.
|
|
1370
|
+
`
|
|
1334
1371
|
);
|
|
1335
1372
|
}
|
|
1336
1373
|
return transformReservedWord(names?.at(0) || params.name);
|
|
@@ -1525,7 +1562,7 @@ Names: ${JSON.stringify(names, void 0, 2)}`
|
|
|
1525
1562
|
});
|
|
1526
1563
|
if (!pluginByPluginName?.length) {
|
|
1527
1564
|
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
1528
|
-
if (this.logger.logLevel ===
|
|
1565
|
+
if (this.logger.logLevel === LogLevel.debug) {
|
|
1529
1566
|
if (corePlugin) {
|
|
1530
1567
|
this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
|
|
1531
1568
|
} else {
|
|
@@ -1563,7 +1600,7 @@ _getSortedPlugins = new WeakSet();
|
|
|
1563
1600
|
getSortedPlugins_fn = function(hookName) {
|
|
1564
1601
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1565
1602
|
if (hookName) {
|
|
1566
|
-
if (this.logger.logLevel ===
|
|
1603
|
+
if (this.logger.logLevel === LogLevel.info) {
|
|
1567
1604
|
const containsHookName = plugins.some((item) => item[hookName]);
|
|
1568
1605
|
if (!containsHookName) {
|
|
1569
1606
|
this.logger.warn(`No hook ${hookName} found`);
|
|
@@ -1766,7 +1803,7 @@ async function setup(options) {
|
|
|
1766
1803
|
if (logger.logLevel === LogLevel.info) {
|
|
1767
1804
|
logger.spinner.start(`\u{1F4BE} Writing`);
|
|
1768
1805
|
}
|
|
1769
|
-
if (logger.logLevel ===
|
|
1806
|
+
if (logger.logLevel === LogLevel.debug) {
|
|
1770
1807
|
logger.info(`PluginKey ${pc3__default.default.dim(JSON.stringify(plugin.key))}
|
|
1771
1808
|
with source
|
|
1772
1809
|
|
|
@@ -2257,10 +2294,6 @@ match_fn = function(packageJSON, dependency) {
|
|
|
2257
2294
|
__privateAdd(_PackageManager, _cache2, {});
|
|
2258
2295
|
var PackageManager = _PackageManager;
|
|
2259
2296
|
|
|
2260
|
-
// src/SchemaGenerator.ts
|
|
2261
|
-
var SchemaGenerator = class extends Generator {
|
|
2262
|
-
};
|
|
2263
|
-
|
|
2264
2297
|
// src/index.ts
|
|
2265
2298
|
var src_default = build;
|
|
2266
2299
|
|
|
@@ -2269,7 +2302,6 @@ exports.Generator = Generator;
|
|
|
2269
2302
|
exports.PackageManager = PackageManager;
|
|
2270
2303
|
exports.PluginManager = PluginManager;
|
|
2271
2304
|
exports.PromiseManager = PromiseManager;
|
|
2272
|
-
exports.SchemaGenerator = SchemaGenerator;
|
|
2273
2305
|
exports.ValidationPluginError = ValidationPluginError;
|
|
2274
2306
|
exports.Warning = Warning;
|
|
2275
2307
|
exports.build = build;
|