@kubb/core 1.1.6 → 1.1.7
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 +220 -220
- package/dist/index.js +219 -219
- package/package.json +8 -5
- package/src/build.ts +4 -4
- package/src/config.ts +1 -1
- package/src/generators/SchemaGenerator.ts +1 -0
- package/src/managers/fileManager/FileManager.ts +3 -3
- package/src/managers/fileManager/utils.ts +3 -3
- package/src/managers/pluginManager/PluginManager.ts +8 -9
- package/src/managers/pluginManager/types.ts +2 -1
- package/src/plugin.ts +2 -2
- package/src/types.ts +1 -1
- package/src/utils/getStackTrace.ts +1 -1
- package/src/utils/read.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,42 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var module$1 = require('module');
|
|
6
|
-
var
|
|
6
|
+
var crypto = require('crypto');
|
|
7
7
|
var fs = require('fs');
|
|
8
|
+
var pathParser2 = require('path');
|
|
8
9
|
var changeCase = require('change-case');
|
|
9
10
|
var rimraf = require('rimraf');
|
|
10
11
|
var dirTree = require('directory-tree');
|
|
11
|
-
var crypto = require('crypto');
|
|
12
12
|
var tsCodegen = require('@kubb/ts-codegen');
|
|
13
13
|
|
|
14
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
|
|
16
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
16
17
|
var pathParser2__default = /*#__PURE__*/_interopDefault(pathParser2);
|
|
17
18
|
var dirTree__default = /*#__PURE__*/_interopDefault(dirTree);
|
|
18
|
-
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
19
19
|
|
|
20
20
|
module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('out.js', document.baseURI).href)));
|
|
21
21
|
|
|
22
|
-
// src/managers/pluginManager/PluginError.ts
|
|
23
|
-
var PluginError = class extends Error {
|
|
24
|
-
pluginManager;
|
|
25
|
-
constructor(message, options) {
|
|
26
|
-
super(message, { cause: options.cause });
|
|
27
|
-
this.pluginManager = options.pluginManager;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/managers/pluginManager/ParallelPluginError.ts
|
|
32
|
-
var ParallelPluginError = class extends Error {
|
|
33
|
-
errors;
|
|
34
|
-
pluginManager;
|
|
35
|
-
constructor(message, options) {
|
|
36
|
-
super(message, { cause: options.cause });
|
|
37
|
-
this.errors = options.errors;
|
|
38
|
-
this.pluginManager = options.pluginManager;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
22
|
// src/utils/isPromise.ts
|
|
43
23
|
function isPromise(result) {
|
|
44
24
|
return typeof result?.then === "function";
|
|
@@ -424,76 +404,7 @@ function getStackTrace(belowFn) {
|
|
|
424
404
|
return v8StackTrace;
|
|
425
405
|
}
|
|
426
406
|
|
|
427
|
-
// src/
|
|
428
|
-
function createPlugin(factory) {
|
|
429
|
-
return (options) => {
|
|
430
|
-
const plugin = factory(options);
|
|
431
|
-
if (Array.isArray(plugin)) {
|
|
432
|
-
throw new Error("Not implemented");
|
|
433
|
-
}
|
|
434
|
-
if (!plugin.transform) {
|
|
435
|
-
plugin.transform = function transform(code) {
|
|
436
|
-
return code;
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
return plugin;
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
var name = "core";
|
|
443
|
-
var definePlugin = createPlugin((options) => {
|
|
444
|
-
const { fileManager, resolvePath, resolveName, load } = options;
|
|
445
|
-
const api = {
|
|
446
|
-
get config() {
|
|
447
|
-
return options.config;
|
|
448
|
-
},
|
|
449
|
-
fileManager,
|
|
450
|
-
async addFile(...files) {
|
|
451
|
-
const trace = getStackTrace();
|
|
452
|
-
const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
|
|
453
|
-
if (a.name.length < b.name.length)
|
|
454
|
-
return 1;
|
|
455
|
-
if (a.name.length > b.name.length)
|
|
456
|
-
return -1;
|
|
457
|
-
return 0;
|
|
458
|
-
});
|
|
459
|
-
const pluginName = plugins?.[0].name;
|
|
460
|
-
return Promise.all(
|
|
461
|
-
files.map((file) => {
|
|
462
|
-
const fileWithMeta = {
|
|
463
|
-
...file,
|
|
464
|
-
meta: {
|
|
465
|
-
...file.meta || {},
|
|
466
|
-
pluginName
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
if (file.override) {
|
|
470
|
-
return fileManager.add(fileWithMeta);
|
|
471
|
-
}
|
|
472
|
-
return fileManager.addOrAppend(fileWithMeta);
|
|
473
|
-
})
|
|
474
|
-
);
|
|
475
|
-
},
|
|
476
|
-
resolvePath,
|
|
477
|
-
resolveName: (params) => {
|
|
478
|
-
const name2 = resolveName(params);
|
|
479
|
-
return transformReservedWord(name2);
|
|
480
|
-
},
|
|
481
|
-
load,
|
|
482
|
-
cache: createPluginCache(/* @__PURE__ */ Object.create(null))
|
|
483
|
-
};
|
|
484
|
-
return {
|
|
485
|
-
name,
|
|
486
|
-
options,
|
|
487
|
-
api,
|
|
488
|
-
resolvePath(fileName) {
|
|
489
|
-
const root = pathParser2__default.default.resolve(this.config.root, this.config.output.path);
|
|
490
|
-
return pathParser2__default.default.resolve(root, fileName);
|
|
491
|
-
},
|
|
492
|
-
resolveName(name2) {
|
|
493
|
-
return name2;
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
});
|
|
407
|
+
// src/managers/fileManager/FileManager.ts
|
|
497
408
|
var FileManager = class {
|
|
498
409
|
cache = /* @__PURE__ */ new Map();
|
|
499
410
|
task;
|
|
@@ -585,6 +496,222 @@ ${file.source}`,
|
|
|
585
496
|
return read(...params);
|
|
586
497
|
}
|
|
587
498
|
};
|
|
499
|
+
function writeIndexes(root, options) {
|
|
500
|
+
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
501
|
+
if (!tree) {
|
|
502
|
+
return void 0;
|
|
503
|
+
}
|
|
504
|
+
const fileReducer = (files2, item) => {
|
|
505
|
+
if (!item.children) {
|
|
506
|
+
return [];
|
|
507
|
+
}
|
|
508
|
+
if (item.children?.length > 1) {
|
|
509
|
+
const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
|
|
510
|
+
const exports = item.children.map((file) => {
|
|
511
|
+
if (!file) {
|
|
512
|
+
return void 0;
|
|
513
|
+
}
|
|
514
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
515
|
+
if (importPath.includes("index") && path.includes("index")) {
|
|
516
|
+
return void 0;
|
|
517
|
+
}
|
|
518
|
+
return { path: importPath };
|
|
519
|
+
}).filter(Boolean);
|
|
520
|
+
files2.push({
|
|
521
|
+
path,
|
|
522
|
+
fileName: "index.ts",
|
|
523
|
+
source: "",
|
|
524
|
+
exports
|
|
525
|
+
});
|
|
526
|
+
} else {
|
|
527
|
+
item.children?.forEach((child) => {
|
|
528
|
+
const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
|
|
529
|
+
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
530
|
+
files2.push({
|
|
531
|
+
path,
|
|
532
|
+
fileName: "index.ts",
|
|
533
|
+
source: "",
|
|
534
|
+
exports: [{ path: importPath }]
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
item.children.forEach((childItem) => {
|
|
539
|
+
fileReducer(files2, childItem);
|
|
540
|
+
});
|
|
541
|
+
return files2;
|
|
542
|
+
};
|
|
543
|
+
const files = fileReducer([], tree);
|
|
544
|
+
return files;
|
|
545
|
+
}
|
|
546
|
+
function combineFiles(files) {
|
|
547
|
+
return files.filter(Boolean).reduce((acc, curr) => {
|
|
548
|
+
if (!curr) {
|
|
549
|
+
return acc;
|
|
550
|
+
}
|
|
551
|
+
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
552
|
+
if (prevIndex !== -1) {
|
|
553
|
+
const prev = acc[prevIndex];
|
|
554
|
+
acc[prevIndex] = {
|
|
555
|
+
...curr,
|
|
556
|
+
source: `${prev.source}
|
|
557
|
+
${curr.source}`,
|
|
558
|
+
imports: [...prev.imports || [], ...curr.imports || []],
|
|
559
|
+
exports: [...prev.exports || [], ...curr.exports || []]
|
|
560
|
+
};
|
|
561
|
+
} else {
|
|
562
|
+
acc.push(curr);
|
|
563
|
+
}
|
|
564
|
+
return acc;
|
|
565
|
+
}, []);
|
|
566
|
+
}
|
|
567
|
+
function getFileSource(file) {
|
|
568
|
+
let { source } = file;
|
|
569
|
+
if (!file.fileName.endsWith(".ts")) {
|
|
570
|
+
return file.source;
|
|
571
|
+
}
|
|
572
|
+
const imports = [];
|
|
573
|
+
const exports = [];
|
|
574
|
+
file.imports?.forEach((curr) => {
|
|
575
|
+
const exists = imports.find((imp) => imp.path === curr.path);
|
|
576
|
+
if (!exists) {
|
|
577
|
+
imports.push({
|
|
578
|
+
...curr,
|
|
579
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
|
|
583
|
+
imports.push(curr);
|
|
584
|
+
}
|
|
585
|
+
if (exists && Array.isArray(exists.name)) {
|
|
586
|
+
if (Array.isArray(curr.name)) {
|
|
587
|
+
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
file.exports?.forEach((curr) => {
|
|
592
|
+
const exists = exports.find((imp) => imp.path === curr.path);
|
|
593
|
+
if (!exists) {
|
|
594
|
+
exports.push({
|
|
595
|
+
...curr,
|
|
596
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
|
|
600
|
+
exports.push(curr);
|
|
601
|
+
}
|
|
602
|
+
if (exists && Array.isArray(exists.name)) {
|
|
603
|
+
if (Array.isArray(curr.name)) {
|
|
604
|
+
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
const importNodes = imports.reduce((prev, curr) => {
|
|
609
|
+
return [...prev, tsCodegen.createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
|
|
610
|
+
}, []);
|
|
611
|
+
const importSource = tsCodegen.print(importNodes);
|
|
612
|
+
const exportNodes = exports.reduce((prev, curr) => {
|
|
613
|
+
return [...prev, tsCodegen.createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
|
|
614
|
+
}, []);
|
|
615
|
+
const exportSource = tsCodegen.print(exportNodes);
|
|
616
|
+
if (importSource) {
|
|
617
|
+
source = `${importSource}
|
|
618
|
+
${source}`;
|
|
619
|
+
}
|
|
620
|
+
if (exportSource) {
|
|
621
|
+
source = `${exportSource}
|
|
622
|
+
${source}`;
|
|
623
|
+
}
|
|
624
|
+
return source;
|
|
625
|
+
}
|
|
626
|
+
function createPlugin(factory) {
|
|
627
|
+
return (options) => {
|
|
628
|
+
const plugin = factory(options);
|
|
629
|
+
if (Array.isArray(plugin)) {
|
|
630
|
+
throw new Error("Not implemented");
|
|
631
|
+
}
|
|
632
|
+
if (!plugin.transform) {
|
|
633
|
+
plugin.transform = function transform(code) {
|
|
634
|
+
return code;
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
return plugin;
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
var name = "core";
|
|
641
|
+
var definePlugin = createPlugin((options) => {
|
|
642
|
+
const { fileManager, resolvePath, resolveName, load } = options;
|
|
643
|
+
const api = {
|
|
644
|
+
get config() {
|
|
645
|
+
return options.config;
|
|
646
|
+
},
|
|
647
|
+
fileManager,
|
|
648
|
+
async addFile(...files) {
|
|
649
|
+
const trace = getStackTrace();
|
|
650
|
+
const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
|
|
651
|
+
if (a.name.length < b.name.length)
|
|
652
|
+
return 1;
|
|
653
|
+
if (a.name.length > b.name.length)
|
|
654
|
+
return -1;
|
|
655
|
+
return 0;
|
|
656
|
+
});
|
|
657
|
+
const pluginName = plugins?.[0].name;
|
|
658
|
+
return Promise.all(
|
|
659
|
+
files.map((file) => {
|
|
660
|
+
const fileWithMeta = {
|
|
661
|
+
...file,
|
|
662
|
+
meta: {
|
|
663
|
+
...file.meta || {},
|
|
664
|
+
pluginName
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
if (file.override) {
|
|
668
|
+
return fileManager.add(fileWithMeta);
|
|
669
|
+
}
|
|
670
|
+
return fileManager.addOrAppend(fileWithMeta);
|
|
671
|
+
})
|
|
672
|
+
);
|
|
673
|
+
},
|
|
674
|
+
resolvePath,
|
|
675
|
+
resolveName: (params) => {
|
|
676
|
+
const name2 = resolveName(params);
|
|
677
|
+
return transformReservedWord(name2);
|
|
678
|
+
},
|
|
679
|
+
load,
|
|
680
|
+
cache: createPluginCache(/* @__PURE__ */ Object.create(null))
|
|
681
|
+
};
|
|
682
|
+
return {
|
|
683
|
+
name,
|
|
684
|
+
options,
|
|
685
|
+
api,
|
|
686
|
+
resolvePath(fileName) {
|
|
687
|
+
const root = pathParser2__default.default.resolve(this.config.root, this.config.output.path);
|
|
688
|
+
return pathParser2__default.default.resolve(root, fileName);
|
|
689
|
+
},
|
|
690
|
+
resolveName(name2) {
|
|
691
|
+
return name2;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
// src/managers/pluginManager/ParallelPluginError.ts
|
|
697
|
+
var ParallelPluginError = class extends Error {
|
|
698
|
+
errors;
|
|
699
|
+
pluginManager;
|
|
700
|
+
constructor(message, options) {
|
|
701
|
+
super(message, { cause: options.cause });
|
|
702
|
+
this.errors = options.errors;
|
|
703
|
+
this.pluginManager = options.pluginManager;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// src/managers/pluginManager/PluginError.ts
|
|
708
|
+
var PluginError = class extends Error {
|
|
709
|
+
pluginManager;
|
|
710
|
+
constructor(message, options) {
|
|
711
|
+
super(message, { cause: options.cause });
|
|
712
|
+
this.pluginManager = options.pluginManager;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
588
715
|
|
|
589
716
|
// src/managers/pluginManager/PluginManager.ts
|
|
590
717
|
var hookNames = {
|
|
@@ -942,133 +1069,6 @@ function validatePlugins(plugins, dependedPluginNames) {
|
|
|
942
1069
|
});
|
|
943
1070
|
return true;
|
|
944
1071
|
}
|
|
945
|
-
function writeIndexes(root, options) {
|
|
946
|
-
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
947
|
-
if (!tree) {
|
|
948
|
-
return void 0;
|
|
949
|
-
}
|
|
950
|
-
const fileReducer = (files2, item) => {
|
|
951
|
-
if (!item.children) {
|
|
952
|
-
return [];
|
|
953
|
-
}
|
|
954
|
-
if (item.children?.length > 1) {
|
|
955
|
-
const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
|
|
956
|
-
const exports = item.children.map((file) => {
|
|
957
|
-
if (!file) {
|
|
958
|
-
return void 0;
|
|
959
|
-
}
|
|
960
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
961
|
-
if (importPath.includes("index") && path.includes("index")) {
|
|
962
|
-
return void 0;
|
|
963
|
-
}
|
|
964
|
-
return { path: importPath };
|
|
965
|
-
}).filter(Boolean);
|
|
966
|
-
files2.push({
|
|
967
|
-
path,
|
|
968
|
-
fileName: "index.ts",
|
|
969
|
-
source: "",
|
|
970
|
-
exports
|
|
971
|
-
});
|
|
972
|
-
} else {
|
|
973
|
-
item.children?.forEach((child) => {
|
|
974
|
-
const path = pathParser2__default.default.resolve(item.data.path, "index.ts");
|
|
975
|
-
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
976
|
-
files2.push({
|
|
977
|
-
path,
|
|
978
|
-
fileName: "index.ts",
|
|
979
|
-
source: "",
|
|
980
|
-
exports: [{ path: importPath }]
|
|
981
|
-
});
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
item.children.forEach((childItem) => {
|
|
985
|
-
fileReducer(files2, childItem);
|
|
986
|
-
});
|
|
987
|
-
return files2;
|
|
988
|
-
};
|
|
989
|
-
const files = fileReducer([], tree);
|
|
990
|
-
return files;
|
|
991
|
-
}
|
|
992
|
-
function combineFiles(files) {
|
|
993
|
-
return files.filter(Boolean).reduce((acc, curr) => {
|
|
994
|
-
if (!curr) {
|
|
995
|
-
return acc;
|
|
996
|
-
}
|
|
997
|
-
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
998
|
-
if (prevIndex !== -1) {
|
|
999
|
-
const prev = acc[prevIndex];
|
|
1000
|
-
acc[prevIndex] = {
|
|
1001
|
-
...curr,
|
|
1002
|
-
source: `${prev.source}
|
|
1003
|
-
${curr.source}`,
|
|
1004
|
-
imports: [...prev.imports || [], ...curr.imports || []],
|
|
1005
|
-
exports: [...prev.exports || [], ...curr.exports || []]
|
|
1006
|
-
};
|
|
1007
|
-
} else {
|
|
1008
|
-
acc.push(curr);
|
|
1009
|
-
}
|
|
1010
|
-
return acc;
|
|
1011
|
-
}, []);
|
|
1012
|
-
}
|
|
1013
|
-
function getFileSource(file) {
|
|
1014
|
-
let { source } = file;
|
|
1015
|
-
if (!file.fileName.endsWith(".ts")) {
|
|
1016
|
-
return file.source;
|
|
1017
|
-
}
|
|
1018
|
-
const imports = [];
|
|
1019
|
-
const exports = [];
|
|
1020
|
-
file.imports?.forEach((curr) => {
|
|
1021
|
-
const exists = imports.find((imp) => imp.path === curr.path);
|
|
1022
|
-
if (!exists) {
|
|
1023
|
-
imports.push({
|
|
1024
|
-
...curr,
|
|
1025
|
-
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
|
|
1029
|
-
imports.push(curr);
|
|
1030
|
-
}
|
|
1031
|
-
if (exists && Array.isArray(exists.name)) {
|
|
1032
|
-
if (Array.isArray(curr.name)) {
|
|
1033
|
-
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
file.exports?.forEach((curr) => {
|
|
1038
|
-
const exists = exports.find((imp) => imp.path === curr.path);
|
|
1039
|
-
if (!exists) {
|
|
1040
|
-
exports.push({
|
|
1041
|
-
...curr,
|
|
1042
|
-
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
|
|
1046
|
-
exports.push(curr);
|
|
1047
|
-
}
|
|
1048
|
-
if (exists && Array.isArray(exists.name)) {
|
|
1049
|
-
if (Array.isArray(curr.name)) {
|
|
1050
|
-
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
const importNodes = imports.reduce((prev, curr) => {
|
|
1055
|
-
return [...prev, tsCodegen.createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
|
|
1056
|
-
}, []);
|
|
1057
|
-
const importSource = tsCodegen.print(importNodes);
|
|
1058
|
-
const exportNodes = exports.reduce((prev, curr) => {
|
|
1059
|
-
return [...prev, tsCodegen.createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
|
|
1060
|
-
}, []);
|
|
1061
|
-
const exportSource = tsCodegen.print(exportNodes);
|
|
1062
|
-
if (importSource) {
|
|
1063
|
-
source = `${importSource}
|
|
1064
|
-
${source}`;
|
|
1065
|
-
}
|
|
1066
|
-
if (exportSource) {
|
|
1067
|
-
source = `${exportSource}
|
|
1068
|
-
${source}`;
|
|
1069
|
-
}
|
|
1070
|
-
return source;
|
|
1071
|
-
}
|
|
1072
1072
|
|
|
1073
1073
|
// src/build.ts
|
|
1074
1074
|
async function transformReducer(_previousCode, result, _plugin) {
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
3
|
import { promises } from 'node:fs';
|
|
4
|
+
import pathParser2 from 'node:path';
|
|
4
5
|
import { camelCase, camelCaseTransformMerge } from 'change-case';
|
|
5
6
|
import { rimraf } from 'rimraf';
|
|
6
7
|
import dirTree from 'directory-tree';
|
|
7
|
-
import crypto from 'node:crypto';
|
|
8
8
|
import { createImportDeclaration, print, createExportDeclaration } from '@kubb/ts-codegen';
|
|
9
9
|
|
|
10
10
|
createRequire(import.meta.url);
|
|
11
11
|
|
|
12
|
-
// src/managers/pluginManager/PluginError.ts
|
|
13
|
-
var PluginError = class extends Error {
|
|
14
|
-
pluginManager;
|
|
15
|
-
constructor(message, options) {
|
|
16
|
-
super(message, { cause: options.cause });
|
|
17
|
-
this.pluginManager = options.pluginManager;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// src/managers/pluginManager/ParallelPluginError.ts
|
|
22
|
-
var ParallelPluginError = class extends Error {
|
|
23
|
-
errors;
|
|
24
|
-
pluginManager;
|
|
25
|
-
constructor(message, options) {
|
|
26
|
-
super(message, { cause: options.cause });
|
|
27
|
-
this.errors = options.errors;
|
|
28
|
-
this.pluginManager = options.pluginManager;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
12
|
// src/utils/isPromise.ts
|
|
33
13
|
function isPromise(result) {
|
|
34
14
|
return typeof result?.then === "function";
|
|
@@ -414,76 +394,7 @@ function getStackTrace(belowFn) {
|
|
|
414
394
|
return v8StackTrace;
|
|
415
395
|
}
|
|
416
396
|
|
|
417
|
-
// src/
|
|
418
|
-
function createPlugin(factory) {
|
|
419
|
-
return (options) => {
|
|
420
|
-
const plugin = factory(options);
|
|
421
|
-
if (Array.isArray(plugin)) {
|
|
422
|
-
throw new Error("Not implemented");
|
|
423
|
-
}
|
|
424
|
-
if (!plugin.transform) {
|
|
425
|
-
plugin.transform = function transform(code) {
|
|
426
|
-
return code;
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
return plugin;
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
var name = "core";
|
|
433
|
-
var definePlugin = createPlugin((options) => {
|
|
434
|
-
const { fileManager, resolvePath, resolveName, load } = options;
|
|
435
|
-
const api = {
|
|
436
|
-
get config() {
|
|
437
|
-
return options.config;
|
|
438
|
-
},
|
|
439
|
-
fileManager,
|
|
440
|
-
async addFile(...files) {
|
|
441
|
-
const trace = getStackTrace();
|
|
442
|
-
const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
|
|
443
|
-
if (a.name.length < b.name.length)
|
|
444
|
-
return 1;
|
|
445
|
-
if (a.name.length > b.name.length)
|
|
446
|
-
return -1;
|
|
447
|
-
return 0;
|
|
448
|
-
});
|
|
449
|
-
const pluginName = plugins?.[0].name;
|
|
450
|
-
return Promise.all(
|
|
451
|
-
files.map((file) => {
|
|
452
|
-
const fileWithMeta = {
|
|
453
|
-
...file,
|
|
454
|
-
meta: {
|
|
455
|
-
...file.meta || {},
|
|
456
|
-
pluginName
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
if (file.override) {
|
|
460
|
-
return fileManager.add(fileWithMeta);
|
|
461
|
-
}
|
|
462
|
-
return fileManager.addOrAppend(fileWithMeta);
|
|
463
|
-
})
|
|
464
|
-
);
|
|
465
|
-
},
|
|
466
|
-
resolvePath,
|
|
467
|
-
resolveName: (params) => {
|
|
468
|
-
const name2 = resolveName(params);
|
|
469
|
-
return transformReservedWord(name2);
|
|
470
|
-
},
|
|
471
|
-
load,
|
|
472
|
-
cache: createPluginCache(/* @__PURE__ */ Object.create(null))
|
|
473
|
-
};
|
|
474
|
-
return {
|
|
475
|
-
name,
|
|
476
|
-
options,
|
|
477
|
-
api,
|
|
478
|
-
resolvePath(fileName) {
|
|
479
|
-
const root = pathParser2.resolve(this.config.root, this.config.output.path);
|
|
480
|
-
return pathParser2.resolve(root, fileName);
|
|
481
|
-
},
|
|
482
|
-
resolveName(name2) {
|
|
483
|
-
return name2;
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
});
|
|
397
|
+
// src/managers/fileManager/FileManager.ts
|
|
487
398
|
var FileManager = class {
|
|
488
399
|
cache = /* @__PURE__ */ new Map();
|
|
489
400
|
task;
|
|
@@ -575,6 +486,222 @@ ${file.source}`,
|
|
|
575
486
|
return read(...params);
|
|
576
487
|
}
|
|
577
488
|
};
|
|
489
|
+
function writeIndexes(root, options) {
|
|
490
|
+
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
491
|
+
if (!tree) {
|
|
492
|
+
return void 0;
|
|
493
|
+
}
|
|
494
|
+
const fileReducer = (files2, item) => {
|
|
495
|
+
if (!item.children) {
|
|
496
|
+
return [];
|
|
497
|
+
}
|
|
498
|
+
if (item.children?.length > 1) {
|
|
499
|
+
const path = pathParser2.resolve(item.data.path, "index.ts");
|
|
500
|
+
const exports = item.children.map((file) => {
|
|
501
|
+
if (!file) {
|
|
502
|
+
return void 0;
|
|
503
|
+
}
|
|
504
|
+
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
505
|
+
if (importPath.includes("index") && path.includes("index")) {
|
|
506
|
+
return void 0;
|
|
507
|
+
}
|
|
508
|
+
return { path: importPath };
|
|
509
|
+
}).filter(Boolean);
|
|
510
|
+
files2.push({
|
|
511
|
+
path,
|
|
512
|
+
fileName: "index.ts",
|
|
513
|
+
source: "",
|
|
514
|
+
exports
|
|
515
|
+
});
|
|
516
|
+
} else {
|
|
517
|
+
item.children?.forEach((child) => {
|
|
518
|
+
const path = pathParser2.resolve(item.data.path, "index.ts");
|
|
519
|
+
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
520
|
+
files2.push({
|
|
521
|
+
path,
|
|
522
|
+
fileName: "index.ts",
|
|
523
|
+
source: "",
|
|
524
|
+
exports: [{ path: importPath }]
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
item.children.forEach((childItem) => {
|
|
529
|
+
fileReducer(files2, childItem);
|
|
530
|
+
});
|
|
531
|
+
return files2;
|
|
532
|
+
};
|
|
533
|
+
const files = fileReducer([], tree);
|
|
534
|
+
return files;
|
|
535
|
+
}
|
|
536
|
+
function combineFiles(files) {
|
|
537
|
+
return files.filter(Boolean).reduce((acc, curr) => {
|
|
538
|
+
if (!curr) {
|
|
539
|
+
return acc;
|
|
540
|
+
}
|
|
541
|
+
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
542
|
+
if (prevIndex !== -1) {
|
|
543
|
+
const prev = acc[prevIndex];
|
|
544
|
+
acc[prevIndex] = {
|
|
545
|
+
...curr,
|
|
546
|
+
source: `${prev.source}
|
|
547
|
+
${curr.source}`,
|
|
548
|
+
imports: [...prev.imports || [], ...curr.imports || []],
|
|
549
|
+
exports: [...prev.exports || [], ...curr.exports || []]
|
|
550
|
+
};
|
|
551
|
+
} else {
|
|
552
|
+
acc.push(curr);
|
|
553
|
+
}
|
|
554
|
+
return acc;
|
|
555
|
+
}, []);
|
|
556
|
+
}
|
|
557
|
+
function getFileSource(file) {
|
|
558
|
+
let { source } = file;
|
|
559
|
+
if (!file.fileName.endsWith(".ts")) {
|
|
560
|
+
return file.source;
|
|
561
|
+
}
|
|
562
|
+
const imports = [];
|
|
563
|
+
const exports = [];
|
|
564
|
+
file.imports?.forEach((curr) => {
|
|
565
|
+
const exists = imports.find((imp) => imp.path === curr.path);
|
|
566
|
+
if (!exists) {
|
|
567
|
+
imports.push({
|
|
568
|
+
...curr,
|
|
569
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
|
|
573
|
+
imports.push(curr);
|
|
574
|
+
}
|
|
575
|
+
if (exists && Array.isArray(exists.name)) {
|
|
576
|
+
if (Array.isArray(curr.name)) {
|
|
577
|
+
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
file.exports?.forEach((curr) => {
|
|
582
|
+
const exists = exports.find((imp) => imp.path === curr.path);
|
|
583
|
+
if (!exists) {
|
|
584
|
+
exports.push({
|
|
585
|
+
...curr,
|
|
586
|
+
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
|
|
590
|
+
exports.push(curr);
|
|
591
|
+
}
|
|
592
|
+
if (exists && Array.isArray(exists.name)) {
|
|
593
|
+
if (Array.isArray(curr.name)) {
|
|
594
|
+
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
const importNodes = imports.reduce((prev, curr) => {
|
|
599
|
+
return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
|
|
600
|
+
}, []);
|
|
601
|
+
const importSource = print(importNodes);
|
|
602
|
+
const exportNodes = exports.reduce((prev, curr) => {
|
|
603
|
+
return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
|
|
604
|
+
}, []);
|
|
605
|
+
const exportSource = print(exportNodes);
|
|
606
|
+
if (importSource) {
|
|
607
|
+
source = `${importSource}
|
|
608
|
+
${source}`;
|
|
609
|
+
}
|
|
610
|
+
if (exportSource) {
|
|
611
|
+
source = `${exportSource}
|
|
612
|
+
${source}`;
|
|
613
|
+
}
|
|
614
|
+
return source;
|
|
615
|
+
}
|
|
616
|
+
function createPlugin(factory) {
|
|
617
|
+
return (options) => {
|
|
618
|
+
const plugin = factory(options);
|
|
619
|
+
if (Array.isArray(plugin)) {
|
|
620
|
+
throw new Error("Not implemented");
|
|
621
|
+
}
|
|
622
|
+
if (!plugin.transform) {
|
|
623
|
+
plugin.transform = function transform(code) {
|
|
624
|
+
return code;
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
return plugin;
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
var name = "core";
|
|
631
|
+
var definePlugin = createPlugin((options) => {
|
|
632
|
+
const { fileManager, resolvePath, resolveName, load } = options;
|
|
633
|
+
const api = {
|
|
634
|
+
get config() {
|
|
635
|
+
return options.config;
|
|
636
|
+
},
|
|
637
|
+
fileManager,
|
|
638
|
+
async addFile(...files) {
|
|
639
|
+
const trace = getStackTrace();
|
|
640
|
+
const plugins = options.config.plugins?.filter((plugin) => trace[1].getFileName()?.includes(plugin.name)).sort((a, b) => {
|
|
641
|
+
if (a.name.length < b.name.length)
|
|
642
|
+
return 1;
|
|
643
|
+
if (a.name.length > b.name.length)
|
|
644
|
+
return -1;
|
|
645
|
+
return 0;
|
|
646
|
+
});
|
|
647
|
+
const pluginName = plugins?.[0].name;
|
|
648
|
+
return Promise.all(
|
|
649
|
+
files.map((file) => {
|
|
650
|
+
const fileWithMeta = {
|
|
651
|
+
...file,
|
|
652
|
+
meta: {
|
|
653
|
+
...file.meta || {},
|
|
654
|
+
pluginName
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
if (file.override) {
|
|
658
|
+
return fileManager.add(fileWithMeta);
|
|
659
|
+
}
|
|
660
|
+
return fileManager.addOrAppend(fileWithMeta);
|
|
661
|
+
})
|
|
662
|
+
);
|
|
663
|
+
},
|
|
664
|
+
resolvePath,
|
|
665
|
+
resolveName: (params) => {
|
|
666
|
+
const name2 = resolveName(params);
|
|
667
|
+
return transformReservedWord(name2);
|
|
668
|
+
},
|
|
669
|
+
load,
|
|
670
|
+
cache: createPluginCache(/* @__PURE__ */ Object.create(null))
|
|
671
|
+
};
|
|
672
|
+
return {
|
|
673
|
+
name,
|
|
674
|
+
options,
|
|
675
|
+
api,
|
|
676
|
+
resolvePath(fileName) {
|
|
677
|
+
const root = pathParser2.resolve(this.config.root, this.config.output.path);
|
|
678
|
+
return pathParser2.resolve(root, fileName);
|
|
679
|
+
},
|
|
680
|
+
resolveName(name2) {
|
|
681
|
+
return name2;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
// src/managers/pluginManager/ParallelPluginError.ts
|
|
687
|
+
var ParallelPluginError = class extends Error {
|
|
688
|
+
errors;
|
|
689
|
+
pluginManager;
|
|
690
|
+
constructor(message, options) {
|
|
691
|
+
super(message, { cause: options.cause });
|
|
692
|
+
this.errors = options.errors;
|
|
693
|
+
this.pluginManager = options.pluginManager;
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// src/managers/pluginManager/PluginError.ts
|
|
698
|
+
var PluginError = class extends Error {
|
|
699
|
+
pluginManager;
|
|
700
|
+
constructor(message, options) {
|
|
701
|
+
super(message, { cause: options.cause });
|
|
702
|
+
this.pluginManager = options.pluginManager;
|
|
703
|
+
}
|
|
704
|
+
};
|
|
578
705
|
|
|
579
706
|
// src/managers/pluginManager/PluginManager.ts
|
|
580
707
|
var hookNames = {
|
|
@@ -932,133 +1059,6 @@ function validatePlugins(plugins, dependedPluginNames) {
|
|
|
932
1059
|
});
|
|
933
1060
|
return true;
|
|
934
1061
|
}
|
|
935
|
-
function writeIndexes(root, options) {
|
|
936
|
-
const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
|
|
937
|
-
if (!tree) {
|
|
938
|
-
return void 0;
|
|
939
|
-
}
|
|
940
|
-
const fileReducer = (files2, item) => {
|
|
941
|
-
if (!item.children) {
|
|
942
|
-
return [];
|
|
943
|
-
}
|
|
944
|
-
if (item.children?.length > 1) {
|
|
945
|
-
const path = pathParser2.resolve(item.data.path, "index.ts");
|
|
946
|
-
const exports = item.children.map((file) => {
|
|
947
|
-
if (!file) {
|
|
948
|
-
return void 0;
|
|
949
|
-
}
|
|
950
|
-
const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
|
|
951
|
-
if (importPath.includes("index") && path.includes("index")) {
|
|
952
|
-
return void 0;
|
|
953
|
-
}
|
|
954
|
-
return { path: importPath };
|
|
955
|
-
}).filter(Boolean);
|
|
956
|
-
files2.push({
|
|
957
|
-
path,
|
|
958
|
-
fileName: "index.ts",
|
|
959
|
-
source: "",
|
|
960
|
-
exports
|
|
961
|
-
});
|
|
962
|
-
} else {
|
|
963
|
-
item.children?.forEach((child) => {
|
|
964
|
-
const path = pathParser2.resolve(item.data.path, "index.ts");
|
|
965
|
-
const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
|
|
966
|
-
files2.push({
|
|
967
|
-
path,
|
|
968
|
-
fileName: "index.ts",
|
|
969
|
-
source: "",
|
|
970
|
-
exports: [{ path: importPath }]
|
|
971
|
-
});
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
item.children.forEach((childItem) => {
|
|
975
|
-
fileReducer(files2, childItem);
|
|
976
|
-
});
|
|
977
|
-
return files2;
|
|
978
|
-
};
|
|
979
|
-
const files = fileReducer([], tree);
|
|
980
|
-
return files;
|
|
981
|
-
}
|
|
982
|
-
function combineFiles(files) {
|
|
983
|
-
return files.filter(Boolean).reduce((acc, curr) => {
|
|
984
|
-
if (!curr) {
|
|
985
|
-
return acc;
|
|
986
|
-
}
|
|
987
|
-
const prevIndex = acc.findIndex((item) => item.path === curr.path);
|
|
988
|
-
if (prevIndex !== -1) {
|
|
989
|
-
const prev = acc[prevIndex];
|
|
990
|
-
acc[prevIndex] = {
|
|
991
|
-
...curr,
|
|
992
|
-
source: `${prev.source}
|
|
993
|
-
${curr.source}`,
|
|
994
|
-
imports: [...prev.imports || [], ...curr.imports || []],
|
|
995
|
-
exports: [...prev.exports || [], ...curr.exports || []]
|
|
996
|
-
};
|
|
997
|
-
} else {
|
|
998
|
-
acc.push(curr);
|
|
999
|
-
}
|
|
1000
|
-
return acc;
|
|
1001
|
-
}, []);
|
|
1002
|
-
}
|
|
1003
|
-
function getFileSource(file) {
|
|
1004
|
-
let { source } = file;
|
|
1005
|
-
if (!file.fileName.endsWith(".ts")) {
|
|
1006
|
-
return file.source;
|
|
1007
|
-
}
|
|
1008
|
-
const imports = [];
|
|
1009
|
-
const exports = [];
|
|
1010
|
-
file.imports?.forEach((curr) => {
|
|
1011
|
-
const exists = imports.find((imp) => imp.path === curr.path);
|
|
1012
|
-
if (!exists) {
|
|
1013
|
-
imports.push({
|
|
1014
|
-
...curr,
|
|
1015
|
-
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
|
|
1019
|
-
imports.push(curr);
|
|
1020
|
-
}
|
|
1021
|
-
if (exists && Array.isArray(exists.name)) {
|
|
1022
|
-
if (Array.isArray(curr.name)) {
|
|
1023
|
-
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
file.exports?.forEach((curr) => {
|
|
1028
|
-
const exists = exports.find((imp) => imp.path === curr.path);
|
|
1029
|
-
if (!exists) {
|
|
1030
|
-
exports.push({
|
|
1031
|
-
...curr,
|
|
1032
|
-
name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
|
|
1036
|
-
exports.push(curr);
|
|
1037
|
-
}
|
|
1038
|
-
if (exists && Array.isArray(exists.name)) {
|
|
1039
|
-
if (Array.isArray(curr.name)) {
|
|
1040
|
-
exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
const importNodes = imports.reduce((prev, curr) => {
|
|
1045
|
-
return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
|
|
1046
|
-
}, []);
|
|
1047
|
-
const importSource = print(importNodes);
|
|
1048
|
-
const exportNodes = exports.reduce((prev, curr) => {
|
|
1049
|
-
return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
|
|
1050
|
-
}, []);
|
|
1051
|
-
const exportSource = print(exportNodes);
|
|
1052
|
-
if (importSource) {
|
|
1053
|
-
source = `${importSource}
|
|
1054
|
-
${source}`;
|
|
1055
|
-
}
|
|
1056
|
-
if (exportSource) {
|
|
1057
|
-
source = `${exportSource}
|
|
1058
|
-
${source}`;
|
|
1059
|
-
}
|
|
1060
|
-
return source;
|
|
1061
|
-
}
|
|
1062
1062
|
|
|
1063
1063
|
// src/build.ts
|
|
1064
1064
|
async function transformReducer(_previousCode, result, _plugin) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Generator core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,12 +43,15 @@
|
|
|
43
43
|
"change-case": "^4.1.2",
|
|
44
44
|
"directory-tree": "^3.5.1",
|
|
45
45
|
"rimraf": "^5.0.1",
|
|
46
|
-
"@kubb/ts-codegen": "1.1.
|
|
46
|
+
"@kubb/ts-codegen": "1.1.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"eslint": "^8.42.0",
|
|
49
50
|
"tsup": "^6.7.0",
|
|
50
51
|
"ora": "^6.3.1",
|
|
51
|
-
"typescript": "^5.1.3"
|
|
52
|
+
"typescript": "^5.1.3",
|
|
53
|
+
"@kubb/tsup-config": "0.1.0",
|
|
54
|
+
"@kubb/eslint-config": "0.1.0"
|
|
52
55
|
},
|
|
53
56
|
"publishConfig": {
|
|
54
57
|
"access": "public",
|
|
@@ -62,8 +65,8 @@
|
|
|
62
65
|
"build": "tsup",
|
|
63
66
|
"start": "tsup --watch",
|
|
64
67
|
"release": "pnpm publish --no-git-check",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
68
|
+
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
69
|
+
"lint-fix": "eslint \"**/*.{ts,tsx}\" --quiet --fix",
|
|
67
70
|
"test": "vitest --passWithNoTests",
|
|
68
71
|
"upgrade": "pnpm update",
|
|
69
72
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
package/src/build.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/* eslint-disable no-async-promise-executor */
|
|
2
|
+
import { getFileSource } from './managers/fileManager/index.ts'
|
|
2
3
|
import { PluginManager } from './managers/pluginManager/index.ts'
|
|
3
4
|
import { clean, isURL, read } from './utils/index.ts'
|
|
4
|
-
import { getFileSource } from './managers/fileManager/index.ts'
|
|
5
5
|
import { isPromise } from './utils/isPromise.ts'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { Ora } from 'ora'
|
|
8
8
|
import type { File } from './managers/fileManager/index.ts'
|
|
9
|
+
import type { OnExecute } from './managers/pluginManager/index.ts'
|
|
10
|
+
import type { BuildOutput, KubbPlugin, LogLevel, PluginContext, TransformResult } from './types.ts'
|
|
9
11
|
import type { QueueTask } from './utils/index.ts'
|
|
10
|
-
import type { PluginContext, TransformResult, LogLevel, KubbPlugin, BuildOutput } from './types.ts'
|
|
11
|
-
import type { Ora } from 'ora'
|
|
12
12
|
|
|
13
13
|
export type Logger = {
|
|
14
14
|
log: (message: string, logLevel: LogLevel) => void
|
package/src/config.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import crypto from 'node:crypto'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { read, write } from '../../utils/index.ts'
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import type { CacheStore,
|
|
5
|
+
import type { Queue, QueueTask } from '../../utils/index.ts'
|
|
6
|
+
import type { CacheStore, File, Status, UUID } from './types.ts'
|
|
7
7
|
|
|
8
8
|
export class FileManager {
|
|
9
9
|
private cache: Map<CacheStore['id'], CacheStore> = new Map()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import pathParser from 'node:path'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createExportDeclaration, createImportDeclaration, print } from '@kubb/ts-codegen'
|
|
4
4
|
|
|
5
5
|
import { TreeNode } from '../../utils/index.ts'
|
|
6
6
|
|
|
7
|
-
import type { PathMode, TreeNodeOptions } from '../../utils/index.ts'
|
|
8
|
-
import type { Path } from '../../types.ts'
|
|
9
7
|
import type ts from 'typescript'
|
|
8
|
+
import type { Path } from '../../types.ts'
|
|
9
|
+
import type { PathMode, TreeNodeOptions } from '../../utils/index.ts'
|
|
10
10
|
import type { File } from './types.ts'
|
|
11
11
|
|
|
12
12
|
export function writeIndexes(root: string, options: TreeNodeOptions) {
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
/* eslint-disable no-await-in-loop */
|
|
3
3
|
/* eslint-disable no-restricted-syntax */
|
|
4
4
|
|
|
5
|
-
import { PluginError } from './PluginError.ts'
|
|
6
|
-
import { ParallelPluginError } from './ParallelPluginError.ts'
|
|
7
|
-
|
|
8
5
|
import { definePlugin } from '../../plugin.ts'
|
|
9
|
-
import { FileManager } from '../fileManager/FileManager.ts'
|
|
10
|
-
import { Queue } from '../../utils/Queue.ts'
|
|
11
6
|
import { isPromise } from '../../utils/isPromise.ts'
|
|
7
|
+
import { Queue } from '../../utils/Queue.ts'
|
|
8
|
+
import { FileManager } from '../fileManager/FileManager.ts'
|
|
9
|
+
import { ParallelPluginError } from './ParallelPluginError.ts'
|
|
10
|
+
import { PluginError } from './PluginError.ts'
|
|
12
11
|
|
|
13
|
-
import type { QueueTask } from '../../utils/Queue.ts'
|
|
14
|
-
import type { Argument0, Strategy, Executer, OnExecute, ParseResult, SafeParseResult } from './types.ts'
|
|
15
|
-
import type { KubbConfig, KubbPlugin, PluginLifecycleHooks, PluginLifecycle, MaybePromise, ResolvePathParams, ResolveNameParams } from '../../types.ts'
|
|
16
12
|
import type { CorePluginOptions } from '../../plugin.ts'
|
|
13
|
+
import type { KubbConfig, KubbPlugin, MaybePromise, PluginLifecycle, PluginLifecycleHooks, ResolveNameParams, ResolvePathParams } from '../../types.ts'
|
|
14
|
+
import type { QueueTask } from '../../utils/Queue.ts'
|
|
15
|
+
import type { Argument0, Executer, OnExecute, ParseResult, SafeParseResult, Strategy } from './types.ts'
|
|
17
16
|
|
|
18
17
|
// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#
|
|
19
18
|
|
|
@@ -218,7 +217,7 @@ export class PluginManager {
|
|
|
218
217
|
break
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
|
-
return parseResult
|
|
220
|
+
return parseResult
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PluginManager } from './PluginManager.ts'
|
|
2
1
|
import type { KubbPlugin, PluginLifecycle, PluginLifecycleHooks } from '../../types.ts'
|
|
2
|
+
import type { PluginManager } from './PluginManager.ts'
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Get the type of the first argument in a function.
|
|
5
6
|
* @example Arg0<(a: string, b: number) => void> -> string
|
package/src/plugin.ts
CHANGED
|
@@ -2,9 +2,9 @@ import pathParser from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import { createPluginCache, getStackTrace, transformReservedWord } from './utils/index.ts'
|
|
4
4
|
|
|
5
|
-
import type { Executer } from './managers/index.ts'
|
|
6
5
|
import type { FileManager } from './managers/fileManager/FileManager.ts'
|
|
7
|
-
import type {
|
|
6
|
+
import type { Executer } from './managers/index.ts'
|
|
7
|
+
import type { KubbPlugin, PluginContext, PluginFactoryOptions, PluginLifecycleHooks } from './types.ts'
|
|
8
8
|
|
|
9
9
|
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (
|
|
10
10
|
options: T['options']
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
2
|
+
import type { File, FileManager } from './managers/fileManager/index.ts'
|
|
2
3
|
import type { PluginManager, SafeParseResult } from './managers/index.ts'
|
|
3
|
-
import type { FileManager, File } from './managers/fileManager/index.ts'
|
|
4
4
|
import type { Cache } from './utils/cache.ts'
|
|
5
5
|
|
|
6
6
|
export interface Register {}
|
|
@@ -9,7 +9,7 @@ export function getStackTrace(belowFn?: Function): NodeJS.CallSite[] {
|
|
|
9
9
|
Error.prepareStackTrace = function prepareStackTrace(dummyObject, v8StackTrace) {
|
|
10
10
|
return v8StackTrace
|
|
11
11
|
}
|
|
12
|
-
Error.captureStackTrace(dummyObject, belowFn || getStackTrace)
|
|
12
|
+
Error.captureStackTrace(dummyObject as object, belowFn || getStackTrace)
|
|
13
13
|
|
|
14
14
|
const v8StackTrace = dummyObject.stack
|
|
15
15
|
Error.prepareStackTrace = v8Handler
|