@kubb/core 3.0.0-alpha.3 → 3.0.0-alpha.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.
Files changed (41) hide show
  1. package/dist/{FileManager-BW--rO8q.d.ts → FileManager-jZpqETKU.d.cts} +15 -20
  2. package/dist/{FileManager-Bw-FNS3q.d.cts → FileManager-tzl0YsYE.d.ts} +15 -20
  3. package/dist/{chunk-SA2GZKXS.js → chunk-CEWT73XF.js} +110 -69
  4. package/dist/chunk-CEWT73XF.js.map +1 -0
  5. package/dist/{chunk-ADC5UNZ5.cjs → chunk-FWU62YO5.cjs} +319 -281
  6. package/dist/chunk-FWU62YO5.cjs.map +1 -0
  7. package/dist/{chunk-LM2YQC3T.cjs → chunk-RBP2ASUX.cjs} +38 -23
  8. package/dist/chunk-RBP2ASUX.cjs.map +1 -0
  9. package/dist/{chunk-3OXCZ5DJ.js → chunk-Z5CHJQJB.js} +29 -21
  10. package/dist/chunk-Z5CHJQJB.js.map +1 -0
  11. package/dist/index.cjs +43 -130
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +4 -15
  14. package/dist/index.d.ts +4 -15
  15. package/dist/index.js +25 -105
  16. package/dist/index.js.map +1 -1
  17. package/dist/{logger-DChjnJMn.d.cts → logger-BnWJh6Yq.d.cts} +17 -19
  18. package/dist/{logger-DChjnJMn.d.ts → logger-BnWJh6Yq.d.ts} +17 -19
  19. package/dist/logger.cjs +3 -4
  20. package/dist/logger.cjs.map +1 -1
  21. package/dist/logger.d.cts +2 -2
  22. package/dist/logger.d.ts +2 -2
  23. package/dist/logger.js +2 -3
  24. package/dist/mocks.cjs +3 -3
  25. package/dist/mocks.cjs.map +1 -1
  26. package/dist/mocks.d.cts +2 -4
  27. package/dist/mocks.d.ts +2 -4
  28. package/dist/mocks.js +4 -4
  29. package/dist/mocks.js.map +1 -1
  30. package/package.json +7 -8
  31. package/src/BarrelManager.ts +10 -1
  32. package/src/FileManager.ts +107 -63
  33. package/src/PluginManager.ts +6 -22
  34. package/src/build.ts +19 -101
  35. package/src/errors.ts +0 -11
  36. package/src/index.ts +0 -1
  37. package/src/logger.ts +43 -33
  38. package/dist/chunk-3OXCZ5DJ.js.map +0 -1
  39. package/dist/chunk-ADC5UNZ5.cjs.map +0 -1
  40. package/dist/chunk-LM2YQC3T.cjs.map +0 -1
  41. package/dist/chunk-SA2GZKXS.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -3,12 +3,11 @@
3
3
 
4
4
 
5
5
 
6
+ var _chunkRBP2ASUXcjs = require('./chunk-RBP2ASUX.cjs');
6
7
 
7
- var _chunkLM2YQC3Tcjs = require('./chunk-LM2YQC3T.cjs');
8
8
 
9
9
 
10
-
11
- var _chunkADC5UNZ5cjs = require('./chunk-ADC5UNZ5.cjs');
10
+ var _chunkFWU62YO5cjs = require('./chunk-FWU62YO5.cjs');
12
11
 
13
12
 
14
13
  var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
@@ -17,9 +16,7 @@ var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
17
16
 
18
17
  var _chunkYTSNYMHWcjs = require('./chunk-YTSNYMHW.cjs');
19
18
  require('./chunk-67C6RBGQ.cjs');
20
-
21
-
22
- var _chunk34BPAXR2cjs = require('./chunk-34BPAXR2.cjs');
19
+ require('./chunk-34BPAXR2.cjs');
23
20
 
24
21
 
25
22
 
@@ -110,12 +107,6 @@ function isPromiseRejectedResult(result) {
110
107
 
111
108
  // src/errors.ts
112
109
  _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
113
- var Warning = class extends Error {
114
- constructor(message, options) {
115
- super(message, { cause: _optionalChain([options, 'optionalAccess', _3 => _3.cause]) });
116
- this.name = "Warning";
117
- }
118
- };
119
110
  var ValidationPluginError = class extends Error {
120
111
  };
121
112
 
@@ -205,7 +196,7 @@ var _core, _usedPluginNames, _promiseManager, _PluginManager_instances, getSorte
205
196
  var PluginManager = class {
206
197
  constructor(config, options) {
207
198
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PluginManager_instances);
208
- this.events = new (0, _chunkLM2YQC3Tcjs.EventEmitter)();
199
+ this.events = new (0, _chunkRBP2ASUXcjs.EventEmitter)();
209
200
  this.executed = [];
210
201
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _core);
211
202
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _usedPluginNames, {});
@@ -217,7 +208,7 @@ var PluginManager = class {
217
208
  hookName: "resolvePath",
218
209
  parameters: [params.baseName, params.mode, params.options]
219
210
  });
220
- if (paths && _optionalChain([paths, 'optionalAccess', _4 => _4.length]) > 1) {
211
+ if (paths && _optionalChain([paths, 'optionalAccess', _3 => _3.length]) > 1) {
221
212
  this.logger.emit("debug", [
222
213
  `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
223
214
 
@@ -227,7 +218,7 @@ Falling back on the first item.
227
218
  `
228
219
  ]);
229
220
  }
230
- return _optionalChain([paths, 'optionalAccess', _5 => _5.at, 'call', _6 => _6(0)]);
221
+ return _optionalChain([paths, 'optionalAccess', _4 => _4.at, 'call', _5 => _5(0)]);
231
222
  }
232
223
  return this.hookFirstSync({
233
224
  hookName: "resolvePath",
@@ -241,7 +232,7 @@ Falling back on the first item.
241
232
  hookName: "resolveName",
242
233
  parameters: [params.name, params.type]
243
234
  });
244
- if (names && _optionalChain([names, 'optionalAccess', _7 => _7.length]) > 1) {
235
+ if (names && _optionalChain([names, 'optionalAccess', _6 => _6.length]) > 1) {
245
236
  this.logger.emit("debug", [
246
237
  `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
247
238
 
@@ -251,7 +242,7 @@ Falling back on the first item.
251
242
  `
252
243
  ]);
253
244
  }
254
- return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _8 => _8.at, 'call', _9 => _9(0)]) || params.name);
245
+ return _chunkPZT4CTBVcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _7 => _7.at, 'call', _8 => _8(0)]) || params.name);
255
246
  }
256
247
  const name = this.hookFirstSync({
257
248
  hookName: "resolveName",
@@ -261,13 +252,9 @@ Falling back on the first item.
261
252
  };
262
253
  this.config = config;
263
254
  this.logger = options.logger;
264
- this.queue = new (0, _chunkADC5UNZ5cjs.PQueue)({ concurrency: 1 });
265
- this.fileManager = new (0, _chunkADC5UNZ5cjs.FileManager)({
266
- task: options.task,
267
- queue: this.queue
268
- });
255
+ this.fileManager = new (0, _chunkFWU62YO5cjs.FileManager)();
269
256
  _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
270
- nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _10 => _10.result])
257
+ nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _9 => _9.result])
271
258
  }));
272
259
  const plugins = config.plugins || [];
273
260
  const core = pluginCore({
@@ -384,7 +371,7 @@ Falling back on the first item.
384
371
  }) {
385
372
  let parseResult = null;
386
373
  for (const plugin of _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PluginManager_instances, getSortedPlugins_fn).call(this)) {
387
- if (_optionalChain([skipped, 'optionalAccess', _11 => _11.has, 'call', _12 => _12(plugin)])) {
374
+ if (_optionalChain([skipped, 'optionalAccess', _10 => _10.has, 'call', _11 => _11(plugin)])) {
388
375
  continue;
389
376
  }
390
377
  parseResult = {
@@ -396,7 +383,7 @@ Falling back on the first item.
396
383
  }),
397
384
  plugin
398
385
  };
399
- if (_optionalChain([parseResult, 'optionalAccess', _13 => _13.result]) != null) {
386
+ if (_optionalChain([parseResult, 'optionalAccess', _12 => _12.result]) != null) {
400
387
  break;
401
388
  }
402
389
  }
@@ -468,19 +455,19 @@ Falling back on the first item.
468
455
  const [searchPluginName, searchIdentifier] = pluginKey;
469
456
  const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
470
457
  const [name, identifier] = item.key;
471
- const identifierCheck = _optionalChain([identifier, 'optionalAccess', _14 => _14.toString, 'call', _15 => _15()]) === _optionalChain([searchIdentifier, 'optionalAccess', _16 => _16.toString, 'call', _17 => _17()]);
458
+ const identifierCheck = _optionalChain([identifier, 'optionalAccess', _13 => _13.toString, 'call', _14 => _14()]) === _optionalChain([searchIdentifier, 'optionalAccess', _15 => _15.toString, 'call', _16 => _16()]);
472
459
  const nameCheck = name === searchPluginName;
473
460
  if (searchIdentifier) {
474
461
  return identifierCheck && nameCheck;
475
462
  }
476
463
  return nameCheck;
477
464
  });
478
- if (!_optionalChain([pluginByPluginName, 'optionalAccess', _18 => _18.length])) {
465
+ if (!_optionalChain([pluginByPluginName, 'optionalAccess', _17 => _17.length])) {
479
466
  const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
480
467
  if (corePlugin) {
481
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]);
468
+ this.logger.emit("warning", `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
482
469
  } else {
483
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]);
470
+ this.logger.emit("warning", `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`);
484
471
  }
485
472
  return corePlugin ? [corePlugin] : [];
486
473
  }
@@ -512,11 +499,9 @@ _PluginManager_instances = new WeakSet();
512
499
  getSortedPlugins_fn = function(hookName) {
513
500
  const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
514
501
  if (hookName) {
515
- if (this.logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
516
- const containsHookName = plugins.some((item) => item[hookName]);
517
- if (!containsHookName) {
518
- this.logger.emit("warning", `No hook ${hookName} found`);
519
- }
502
+ const containsHookName = plugins.some((item) => item[hookName]);
503
+ if (!containsHookName) {
504
+ this.logger.emit("info", `No hook ${hookName} found`);
520
505
  }
521
506
  return plugins.filter((item) => item[hookName]);
522
507
  }
@@ -529,10 +514,10 @@ getSortedPlugins_fn = function(hookName) {
529
514
  }
530
515
  return plugin;
531
516
  }).sort((a, b) => {
532
- if (_optionalChain([b, 'access', _19 => _19.pre, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(a.name)])) {
517
+ if (_optionalChain([b, 'access', _18 => _18.pre, 'optionalAccess', _19 => _19.includes, 'call', _20 => _20(a.name)])) {
533
518
  return 1;
534
519
  }
535
- if (_optionalChain([b, 'access', _22 => _22.post, 'optionalAccess', _23 => _23.includes, 'call', _24 => _24(a.name)])) {
520
+ if (_optionalChain([b, 'access', _21 => _21.post, 'optionalAccess', _22 => _22.includes, 'call', _23 => _23(a.name)])) {
536
521
  return -1;
537
522
  }
538
523
  return 0;
@@ -628,7 +613,7 @@ executeSync_fn = function({
628
613
  }
629
614
  };
630
615
  catcher_fn = function(cause, plugin, hookName) {
631
- const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _25 => _25.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
616
+ const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _24 => _24.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
632
617
  this.logger.emit("error", text, cause);
633
618
  this.events.emit("error", cause);
634
619
  };
@@ -658,25 +643,9 @@ function isInputPath(result) {
658
643
  return !!result && "path" in result;
659
644
  }
660
645
 
661
- // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/index.mjs
662
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
663
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
664
- require('tty');
665
- require('util');
666
-
667
-
668
646
  // src/build.ts
669
647
  async function setup(options) {
670
- const {
671
- config,
672
- logger = _chunkLM2YQC3Tcjs.createLogger.call(void 0, {
673
- logLevel: _chunkLM2YQC3Tcjs.LogLevel.silent,
674
- consola: _chunk34BPAXR2cjs.createConsola.call(void 0, {
675
- level: 3
676
- })
677
- })
678
- } = options;
679
- let count = 0;
648
+ const { config, logger = _chunkRBP2ASUXcjs.createLogger.call(void 0, ) } = options;
680
649
  try {
681
650
  if (isInputPath(config) && !new (0, _chunkYTSNYMHWcjs.URLPath)(config.input.path).isURL) {
682
651
  await _fs.read.call(void 0, config.input.path);
@@ -684,7 +653,7 @@ async function setup(options) {
684
653
  } catch (e) {
685
654
  if (isInputPath(config)) {
686
655
  throw new Error(
687
- `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkLM2YQC3Tcjs.p.dim(config.input.path)}`,
656
+ `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkRBP2ASUXcjs.p.dim(config.input.path)}`,
688
657
  {
689
658
  cause: e
690
659
  }
@@ -694,54 +663,14 @@ async function setup(options) {
694
663
  if (config.output.clean) {
695
664
  await _fs.clean.call(void 0, config.output.path);
696
665
  }
697
- const task = async (file) => {
698
- const { path: path4 } = file;
699
- const source = await _chunkADC5UNZ5cjs.FileManager.getSource(file);
700
- if (source) {
701
- if (config.output.write || config.output.write === void 0) {
702
- await pluginManager.fileManager.write(path4, source, { sanity: false });
703
- }
704
- }
705
- return {
706
- ...file,
707
- source: source || ""
708
- };
709
- };
710
- const pluginManager = new PluginManager(config, { logger, task });
711
- pluginManager.queue.on("add", () => {
712
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
713
- return;
714
- }
715
- if (count === 0) {
716
- logger.emit("start", "\u{1F4BE} Writing");
717
- }
718
- });
719
- pluginManager.queue.on("active", () => {
720
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
721
- return;
722
- }
723
- if (logger.spinner && pluginManager.queue.size > 0) {
724
- const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
725
- logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
726
- }
727
- ++count;
728
- });
729
- pluginManager.queue.on("completed", () => {
730
- if (logger.logLevel !== _chunkLM2YQC3Tcjs.LogLevel.info) {
731
- return;
732
- }
733
- if (logger.spinner) {
734
- const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
735
- logger.spinner.suffixText = _chunkLM2YQC3Tcjs.p.dim(text);
736
- }
737
- });
666
+ const pluginManager = new PluginManager(config, { logger });
738
667
  pluginManager.on("executed", (executer) => {
739
668
  const { hookName, plugin, output, parameters } = executer;
740
669
  const logs = [
741
- `${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
742
- parameters && `${_chunkLM2YQC3Tcjs.p.bgWhite("Parameters")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
670
+ `${_chunkRBP2ASUXcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
671
+ parameters && `${_chunkRBP2ASUXcjs.p.bgWhite("Parameters")} ${_chunkRBP2ASUXcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
743
672
  JSON.stringify(parameters, void 0, 2),
744
- output && `${_chunkLM2YQC3Tcjs.p.bgWhite("Output")} ${_chunkLM2YQC3Tcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
673
+ output && `${_chunkRBP2ASUXcjs.p.bgWhite("Output")} ${_chunkRBP2ASUXcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
745
674
  output
746
675
  ].filter(Boolean);
747
676
  logger.emit("debug", logs);
@@ -750,21 +679,16 @@ async function setup(options) {
750
679
  }
751
680
  async function build(options) {
752
681
  const pluginManager = await setup(options);
753
- const { fileManager, logger } = pluginManager;
754
682
  await pluginManager.hookParallel({
755
683
  hookName: "buildStart",
756
684
  parameters: [options.config]
757
685
  });
686
+ const files = await _chunkFWU62YO5cjs.processFiles.call(void 0, {
687
+ dryRun: !options.config.output.write,
688
+ files: pluginManager.fileManager.files,
689
+ logger: pluginManager.logger
690
+ });
758
691
  await pluginManager.hookParallel({ hookName: "buildEnd" });
759
- if (logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
760
- logger.emit("end", "\u{1F4BE} Writing completed");
761
- }
762
- const files = await Promise.all(
763
- fileManager.files.map(async (file) => ({
764
- ...file,
765
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
766
- }))
767
- );
768
692
  return {
769
693
  files,
770
694
  pluginManager
@@ -772,35 +696,25 @@ async function build(options) {
772
696
  }
773
697
  async function safeBuild(options) {
774
698
  const pluginManager = await setup(options);
775
- const { fileManager, logger } = pluginManager;
699
+ let files = [];
776
700
  try {
777
701
  await pluginManager.hookParallel({
778
702
  hookName: "buildStart",
779
703
  parameters: [options.config]
780
704
  });
705
+ files = await _chunkFWU62YO5cjs.processFiles.call(void 0, {
706
+ dryRun: !options.config.output.write,
707
+ files: pluginManager.fileManager.files,
708
+ logger: pluginManager.logger
709
+ });
781
710
  await pluginManager.hookParallel({ hookName: "buildEnd" });
782
- if (logger.logLevel === _chunkLM2YQC3Tcjs.LogLevel.info) {
783
- logger.emit("end", "\u{1F4BE} Writing completed");
784
- }
785
711
  } catch (e) {
786
- const files2 = await Promise.all(
787
- fileManager.files.map(async (file) => ({
788
- ...file,
789
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
790
- }))
791
- );
792
712
  return {
793
- files: files2,
713
+ files: [],
794
714
  pluginManager,
795
715
  error: e
796
716
  };
797
717
  }
798
- const files = await Promise.all(
799
- fileManager.files.map(async (file) => ({
800
- ...file,
801
- source: await _chunkADC5UNZ5cjs.FileManager.getSource(file)
802
- }))
803
- );
804
718
  return {
805
719
  files,
806
720
  pluginManager
@@ -847,7 +761,7 @@ _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
847
761
 
848
762
  // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
849
763
  _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
850
-
764
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
851
765
 
852
766
  var _fs3 = require('fs'); var _fs4 = _interopRequireDefault(_fs3);
853
767
 
@@ -1181,7 +1095,7 @@ var _PackageManager = class _PackageManager {
1181
1095
  location = _url.pathToFileURL.call(void 0, location).href;
1182
1096
  }
1183
1097
  const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
1184
- return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _26 => _26.default]), () => ( module));
1098
+ return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _25 => _25.default]), () => ( module));
1185
1099
  } catch (e) {
1186
1100
  console.log(e);
1187
1101
  return void 0;
@@ -1285,6 +1199,5 @@ var PackageManager = _PackageManager;
1285
1199
 
1286
1200
 
1287
1201
 
1288
-
1289
- exports.FileManager = _chunkADC5UNZ5cjs.FileManager; exports.Generator = Generator; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.Warning = Warning; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
1202
+ exports.FileManager = _chunkFWU62YO5cjs.FileManager; exports.Generator = Generator; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
1290
1203
  //# sourceMappingURL=index.cjs.map