@kubb/core 3.5.0 → 3.5.2

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.
Files changed (46) hide show
  1. package/dist/{FileManager-BEP6uN5W.d.cts → FileManager-BxDiClvd.d.cts} +2 -2
  2. package/dist/{FileManager-B-1XWq6Q.d.ts → FileManager-VhW4B9yd.d.ts} +2 -2
  3. package/dist/{chunk-S3IJRQEO.cjs → chunk-A5DJD2TT.cjs} +255 -39
  4. package/dist/chunk-A5DJD2TT.cjs.map +1 -0
  5. package/dist/{chunk-EECPIRGL.cjs → chunk-DSQCC7PM.cjs} +17 -17
  6. package/dist/{chunk-EECPIRGL.cjs.map → chunk-DSQCC7PM.cjs.map} +1 -1
  7. package/dist/{chunk-3CLNO5VR.js → chunk-E2WLQU27.js} +234 -26
  8. package/dist/chunk-E2WLQU27.js.map +1 -0
  9. package/dist/{chunk-LVELAYV4.cjs → chunk-LIRQEU5H.cjs} +4 -4
  10. package/dist/{chunk-LVELAYV4.cjs.map → chunk-LIRQEU5H.cjs.map} +1 -1
  11. package/dist/{chunk-MYLU2IFI.cjs → chunk-PLNJ73H7.cjs} +35 -35
  12. package/dist/{chunk-MYLU2IFI.cjs.map → chunk-PLNJ73H7.cjs.map} +1 -1
  13. package/dist/index.cjs +74 -58
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +5 -5
  16. package/dist/index.d.ts +5 -5
  17. package/dist/index.js +39 -23
  18. package/dist/index.js.map +1 -1
  19. package/dist/logger.cjs +6 -7
  20. package/dist/logger.js +1 -2
  21. package/dist/mocks.cjs +11 -11
  22. package/dist/mocks.cjs.map +1 -1
  23. package/dist/mocks.d.cts +1 -1
  24. package/dist/mocks.d.ts +1 -1
  25. package/dist/mocks.js +2 -2
  26. package/dist/mocks.js.map +1 -1
  27. package/dist/prompt-PTBVR4VS.cjs +762 -0
  28. package/dist/prompt-PTBVR4VS.cjs.map +1 -0
  29. package/dist/prompt-RQXXVSD5.js +751 -0
  30. package/dist/prompt-RQXXVSD5.js.map +1 -0
  31. package/dist/transformers.cjs +22 -22
  32. package/dist/utils.cjs +17 -17
  33. package/package.json +8 -8
  34. package/src/build.ts +41 -23
  35. package/src/config.ts +1 -1
  36. package/src/types.ts +1 -1
  37. package/dist/chunk-3CLNO5VR.js.map +0 -1
  38. package/dist/chunk-OL5US75J.js +0 -208
  39. package/dist/chunk-OL5US75J.js.map +0 -1
  40. package/dist/chunk-OQSYTQLS.cjs +0 -236
  41. package/dist/chunk-OQSYTQLS.cjs.map +0 -1
  42. package/dist/chunk-S3IJRQEO.cjs.map +0 -1
  43. package/dist/prompt-CV2GMUO3.cjs +0 -860
  44. package/dist/prompt-CV2GMUO3.cjs.map +0 -1
  45. package/dist/prompt-Y6ROOH2L.js +0 -848
  46. package/dist/prompt-Y6ROOH2L.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -2,17 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var chunkOQSYTQLS_cjs = require('./chunk-OQSYTQLS.cjs');
6
- var chunkMYLU2IFI_cjs = require('./chunk-MYLU2IFI.cjs');
7
- var chunkEECPIRGL_cjs = require('./chunk-EECPIRGL.cjs');
8
- require('./chunk-S3IJRQEO.cjs');
9
- var chunkLVELAYV4_cjs = require('./chunk-LVELAYV4.cjs');
5
+ var chunkA5DJD2TT_cjs = require('./chunk-A5DJD2TT.cjs');
6
+ var chunkPLNJ73H7_cjs = require('./chunk-PLNJ73H7.cjs');
7
+ var chunkDSQCC7PM_cjs = require('./chunk-DSQCC7PM.cjs');
8
+ var chunkLIRQEU5H_cjs = require('./chunk-LIRQEU5H.cjs');
10
9
  var fs = require('@kubb/fs');
11
10
  var path3 = require('path');
12
11
  var mod = require('module');
13
12
  var os = require('os');
14
13
  var url = require('url');
15
- var process = require('process');
14
+ var process2 = require('process');
16
15
  var fs$1 = require('fs');
17
16
  var semver = require('semver');
18
17
 
@@ -21,23 +20,23 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
20
  var path3__default = /*#__PURE__*/_interopDefault(path3);
22
21
  var mod__default = /*#__PURE__*/_interopDefault(mod);
23
22
  var os__default = /*#__PURE__*/_interopDefault(os);
24
- var process__default = /*#__PURE__*/_interopDefault(process);
23
+ var process2__default = /*#__PURE__*/_interopDefault(process2);
25
24
  var fs__default = /*#__PURE__*/_interopDefault(fs$1);
26
25
 
27
26
  // src/index.ts
28
- chunkLVELAYV4_cjs.init_cjs_shims();
27
+ chunkLIRQEU5H_cjs.init_cjs_shims();
29
28
 
30
29
  // src/build.ts
31
- chunkLVELAYV4_cjs.init_cjs_shims();
30
+ chunkLIRQEU5H_cjs.init_cjs_shims();
32
31
 
33
32
  // src/PluginManager.ts
34
- chunkLVELAYV4_cjs.init_cjs_shims();
33
+ chunkLIRQEU5H_cjs.init_cjs_shims();
35
34
 
36
35
  // src/PromiseManager.ts
37
- chunkLVELAYV4_cjs.init_cjs_shims();
36
+ chunkLIRQEU5H_cjs.init_cjs_shims();
38
37
 
39
38
  // src/utils/executeStrategies.ts
40
- chunkLVELAYV4_cjs.init_cjs_shims();
39
+ chunkLIRQEU5H_cjs.init_cjs_shims();
41
40
  function hookSeq(promises) {
42
41
  return promises.filter(Boolean).reduce(
43
42
  (promise, func) => {
@@ -99,12 +98,12 @@ function isPromiseRejectedResult(result) {
99
98
  }
100
99
 
101
100
  // src/errors.ts
102
- chunkLVELAYV4_cjs.init_cjs_shims();
101
+ chunkLIRQEU5H_cjs.init_cjs_shims();
103
102
  var ValidationPluginError = class extends Error {
104
103
  };
105
104
 
106
105
  // src/plugin.ts
107
- chunkLVELAYV4_cjs.init_cjs_shims();
106
+ chunkLIRQEU5H_cjs.init_cjs_shims();
108
107
  function createPlugin(factory) {
109
108
  return (options = {}) => {
110
109
  return factory(options);
@@ -155,7 +154,7 @@ var pluginCore = createPlugin((options) => {
155
154
  var PluginManager = class {
156
155
  plugins = /* @__PURE__ */ new Set();
157
156
  fileManager;
158
- events = new chunkOQSYTQLS_cjs.EventEmitter();
157
+ events = new chunkA5DJD2TT_cjs.EventEmitter();
159
158
  config;
160
159
  executed = [];
161
160
  logger;
@@ -167,7 +166,7 @@ var PluginManager = class {
167
166
  this.config = config;
168
167
  this.options = options;
169
168
  this.logger = options.logger;
170
- this.fileManager = new chunkMYLU2IFI_cjs.FileManager();
169
+ this.fileManager = new chunkPLNJ73H7_cjs.FileManager();
171
170
  this.#promiseManager = new PromiseManager({
172
171
  nullCheck: (state) => !!state?.result
173
172
  });
@@ -243,7 +242,7 @@ Falling back on the first item.
243
242
  const names = this.hookForPluginSync({
244
243
  pluginKey: params.pluginKey,
245
244
  hookName: "resolveName",
246
- parameters: [chunkEECPIRGL_cjs.trim(params.name), params.type],
245
+ parameters: [chunkDSQCC7PM_cjs.trim(params.name), params.type],
247
246
  message: `Resolving name '${params.name}' and type '${params.type}'`
248
247
  });
249
248
  if (names && names?.length > 1) {
@@ -259,14 +258,14 @@ Falling back on the first item.
259
258
  ]
260
259
  });
261
260
  }
262
- return chunkEECPIRGL_cjs.transformReservedWord(names?.at(0) || params.name);
261
+ return chunkDSQCC7PM_cjs.transformReservedWord(names?.at(0) || params.name);
263
262
  }
264
263
  const name = this.hookFirstSync({
265
264
  hookName: "resolveName",
266
- parameters: [chunkEECPIRGL_cjs.trim(params.name), params.type],
265
+ parameters: [chunkDSQCC7PM_cjs.trim(params.name), params.type],
267
266
  message: `Resolving name '${params.name}' and type '${params.type}'`
268
267
  }).result;
269
- return chunkEECPIRGL_cjs.transformReservedWord(name);
268
+ return chunkDSQCC7PM_cjs.transformReservedWord(name);
270
269
  };
271
270
  /**
272
271
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -596,7 +595,7 @@ Falling back on the first item.
596
595
  }
597
596
  #parse(plugin, pluginManager, context) {
598
597
  const usedPluginNames = pluginManager.#usedPluginNames;
599
- chunkMYLU2IFI_cjs.setUniqueName(plugin.name, usedPluginNames);
598
+ chunkPLNJ73H7_cjs.setUniqueName(plugin.name, usedPluginNames);
600
599
  const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
601
600
  if (plugin.context && typeof plugin.context === "function") {
602
601
  return {
@@ -631,7 +630,7 @@ Falling back on the first item.
631
630
  };
632
631
 
633
632
  // src/config.ts
634
- chunkLVELAYV4_cjs.init_cjs_shims();
633
+ chunkLIRQEU5H_cjs.init_cjs_shims();
635
634
  function defineConfig(options) {
636
635
  return options;
637
636
  }
@@ -639,23 +638,39 @@ function isInputPath(result) {
639
638
  return !!result && "path" in result?.input;
640
639
  }
641
640
  async function setup(options) {
642
- const { config, logger = chunkOQSYTQLS_cjs.createLogger() } = options;
641
+ const { config: userConfig, logger = chunkA5DJD2TT_cjs.createLogger() } = options;
643
642
  try {
644
- if (isInputPath(config) && !new chunkMYLU2IFI_cjs.URLPath(config.input.path).isURL) {
645
- await fs.read(config.input.path);
643
+ if (isInputPath(userConfig) && !new chunkPLNJ73H7_cjs.URLPath(userConfig.input.path).isURL) {
644
+ await fs.read(userConfig.input.path);
646
645
  }
647
646
  } catch (e) {
648
- if (isInputPath(config)) {
649
- throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${config.input.path}`, {
650
- cause: e
651
- });
647
+ if (isInputPath(userConfig)) {
648
+ throw new Error(
649
+ `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`,
650
+ {
651
+ cause: e
652
+ }
653
+ );
652
654
  }
653
655
  }
654
- if (config.output.clean) {
655
- await fs.clean(config.output.path);
656
- await fs.clean(path3.join(config.root, ".kubb"));
656
+ const definedConfig = {
657
+ root: userConfig.root || process.cwd(),
658
+ ...userConfig,
659
+ output: {
660
+ write: true,
661
+ barrelType: "named",
662
+ extension: {
663
+ ".ts": ".ts"
664
+ },
665
+ ...userConfig.output
666
+ },
667
+ plugins: userConfig.plugins
668
+ };
669
+ if (definedConfig.output.clean) {
670
+ await fs.clean(definedConfig.output.path);
671
+ await fs.clean(path3.join(definedConfig.root, ".kubb"));
657
672
  }
658
- return new PluginManager(config, { logger });
673
+ return new PluginManager(definedConfig, { logger });
659
674
  }
660
675
  async function build(options) {
661
676
  const { files, pluginManager, error } = await safeBuild(options);
@@ -669,6 +684,7 @@ async function build(options) {
669
684
  async function safeBuild(options) {
670
685
  let files = [];
671
686
  const pluginManager = await setup(options);
687
+ const config = pluginManager.config;
672
688
  try {
673
689
  pluginManager.events.on("executing", ({ plugin, message }) => {
674
690
  pluginManager.logger.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`] });
@@ -681,11 +697,11 @@ async function safeBuild(options) {
681
697
  });
682
698
  await pluginManager.hookParallel({
683
699
  hookName: "buildStart",
684
- parameters: [options.config],
700
+ parameters: [config],
685
701
  message: "buildStart"
686
702
  });
687
- const root = path3.resolve(options.config.root);
688
- const rootPath = path3.resolve(root, options.config.output.path, "index.ts");
703
+ const root = path3.resolve(config.root);
704
+ const rootPath = path3.resolve(root, config.output.path, "index.ts");
689
705
  const barrelFiles = pluginManager.fileManager.files.filter((file) => {
690
706
  return file.sources.some((source) => source.isIndexable);
691
707
  });
@@ -707,26 +723,26 @@ async function safeBuild(options) {
707
723
  return void 0;
708
724
  }
709
725
  return {
710
- name: options.config.output.barrelType === "all" ? void 0 : [source.name],
726
+ name: config.output.barrelType === "all" ? void 0 : [source.name],
711
727
  path: fs.getRelativePath(rootPath, file.path),
712
- isTypeOnly: options.config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
728
+ isTypeOnly: config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
713
729
  };
714
730
  }).filter(Boolean);
715
731
  }).filter(Boolean),
716
732
  sources: [],
717
733
  meta: {}
718
734
  };
719
- if (options.config.output.barrelType) {
735
+ if (config.output.barrelType) {
720
736
  await pluginManager.fileManager.add(rootFile);
721
737
  }
722
- files = await chunkMYLU2IFI_cjs.processFiles({
723
- root: options.config.root,
724
- extension: options.config.output.extension,
725
- dryRun: !options.config.output.write,
738
+ files = await chunkPLNJ73H7_cjs.processFiles({
739
+ root: config.root,
740
+ extension: config.output.extension,
741
+ dryRun: !config.output.write,
726
742
  files: pluginManager.fileManager.files,
727
743
  logger: pluginManager.logger
728
744
  });
729
- await pluginManager.hookParallel({ hookName: "buildEnd", message: `Build stopped for ${options.config.name}` });
745
+ await pluginManager.hookParallel({ hookName: "buildEnd", message: `Build stopped for ${config.name}` });
730
746
  pluginManager.fileManager.clear();
731
747
  } catch (e) {
732
748
  return {
@@ -742,7 +758,7 @@ async function safeBuild(options) {
742
758
  }
743
759
 
744
760
  // src/BaseGenerator.ts
745
- chunkLVELAYV4_cjs.init_cjs_shims();
761
+ chunkLIRQEU5H_cjs.init_cjs_shims();
746
762
  var BaseGenerator = class {
747
763
  #options = {};
748
764
  #context = {};
@@ -767,22 +783,22 @@ var BaseGenerator = class {
767
783
  };
768
784
 
769
785
  // src/PackageManager.ts
770
- chunkLVELAYV4_cjs.init_cjs_shims();
786
+ chunkLIRQEU5H_cjs.init_cjs_shims();
771
787
 
772
788
  // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
773
- chunkLVELAYV4_cjs.init_cjs_shims();
789
+ chunkLIRQEU5H_cjs.init_cjs_shims();
774
790
 
775
791
  // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
776
- chunkLVELAYV4_cjs.init_cjs_shims();
792
+ chunkLIRQEU5H_cjs.init_cjs_shims();
777
793
 
778
794
  // ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
779
- chunkLVELAYV4_cjs.init_cjs_shims();
795
+ chunkLIRQEU5H_cjs.init_cjs_shims();
780
796
 
781
797
  // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
782
- chunkLVELAYV4_cjs.init_cjs_shims();
798
+ chunkLIRQEU5H_cjs.init_cjs_shims();
783
799
 
784
800
  // ../../node_modules/.pnpm/yocto-queue@1.1.1/node_modules/yocto-queue/index.js
785
- chunkLVELAYV4_cjs.init_cjs_shims();
801
+ chunkLIRQEU5H_cjs.init_cjs_shims();
786
802
  var Node = class {
787
803
  value;
788
804
  next;
@@ -937,7 +953,7 @@ function checkType(type) {
937
953
  var matchType = (type, stat) => stat[typeMappings[type]]();
938
954
  var toPath = (urlOrPath) => urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
939
955
  async function locatePath(paths, {
940
- cwd = process__default.default.cwd(),
956
+ cwd = process2__default.default.cwd(),
941
957
  type = "file",
942
958
  allowSymlinks = true,
943
959
  concurrency,
@@ -956,7 +972,7 @@ async function locatePath(paths, {
956
972
  }, { concurrency, preserveOrder });
957
973
  }
958
974
  function locatePathSync(paths, {
959
- cwd = process__default.default.cwd(),
975
+ cwd = process2__default.default.cwd(),
960
976
  type = "file",
961
977
  allowSymlinks = true
962
978
  } = {}) {
@@ -980,13 +996,13 @@ function locatePathSync(paths, {
980
996
  }
981
997
 
982
998
  // ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
983
- chunkLVELAYV4_cjs.init_cjs_shims();
999
+ chunkLIRQEU5H_cjs.init_cjs_shims();
984
1000
  function toPath2(urlOrPath) {
985
1001
  return urlOrPath instanceof URL ? url.fileURLToPath(urlOrPath) : urlOrPath;
986
1002
  }
987
1003
 
988
1004
  // ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
989
- chunkLVELAYV4_cjs.init_cjs_shims();
1005
+ chunkLIRQEU5H_cjs.init_cjs_shims();
990
1006
 
991
1007
  // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
992
1008
  var findUpStop = Symbol("findUpStop");
@@ -1188,15 +1204,15 @@ var PackageManager = class _PackageManager {
1188
1204
 
1189
1205
  Object.defineProperty(exports, "FileManager", {
1190
1206
  enumerable: true,
1191
- get: function () { return chunkMYLU2IFI_cjs.FileManager; }
1207
+ get: function () { return chunkPLNJ73H7_cjs.FileManager; }
1192
1208
  });
1193
1209
  Object.defineProperty(exports, "getSource", {
1194
1210
  enumerable: true,
1195
- get: function () { return chunkMYLU2IFI_cjs.getSource; }
1211
+ get: function () { return chunkPLNJ73H7_cjs.getSource; }
1196
1212
  });
1197
1213
  Object.defineProperty(exports, "processFiles", {
1198
1214
  enumerable: true,
1199
- get: function () { return chunkMYLU2IFI_cjs.processFiles; }
1215
+ get: function () { return chunkPLNJ73H7_cjs.processFiles; }
1200
1216
  });
1201
1217
  exports.BaseGenerator = BaseGenerator;
1202
1218
  exports.PackageManager = PackageManager;