@kubb/core 1.0.0 → 1.0.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.
package/dist/index.js CHANGED
@@ -1,14 +1,33 @@
1
1
  import { createRequire } from 'module';
2
- import pathParser2 from 'path';
3
- import { promises } from 'fs';
4
- import rimraf from 'rimraf';
2
+ import pathParser2 from 'node:path';
3
+ import { promises } from 'node:fs';
4
+ import { rimraf } from 'rimraf';
5
5
  import dirTree from 'directory-tree';
6
- import { v4 } from 'uuid';
7
- import uniq from 'lodash.uniq';
6
+ import crypto from 'node:crypto';
8
7
  import { createImportDeclaration, print, createExportDeclaration } from '@kubb/ts-codegen';
9
8
 
10
9
  createRequire(import.meta.url);
11
10
 
11
+ // src/managers/pluginManager/PluginError.ts
12
+ var PluginError = class extends Error {
13
+ pluginManager;
14
+ constructor(message, options) {
15
+ super(message, { cause: options.cause });
16
+ this.pluginManager = options.pluginManager;
17
+ }
18
+ };
19
+
20
+ // src/managers/pluginManager/ParallelPluginError.ts
21
+ var ParallelPluginError = class extends Error {
22
+ errors;
23
+ pluginManager;
24
+ constructor(message, options) {
25
+ super(message, { cause: options.cause });
26
+ this.errors = options.errors;
27
+ this.pluginManager = options.pluginManager;
28
+ }
29
+ };
30
+
12
31
  // src/utils/isPromise.ts
13
32
  function isPromise(result) {
14
33
  return typeof result?.then === "function";
@@ -204,15 +223,7 @@ function renderTemplate(template, data = void 0) {
204
223
  });
205
224
  }
206
225
  async function clean(path) {
207
- return new Promise((resolve, reject) => {
208
- rimraf(path, (err) => {
209
- if (err) {
210
- reject(err);
211
- } else {
212
- resolve(true);
213
- }
214
- });
215
- });
226
+ return rimraf(path);
216
227
  }
217
228
  var TreeNode = class {
218
229
  data;
@@ -381,12 +392,28 @@ var reservedWords = [
381
392
  "valueOf"
382
393
  ];
383
394
  function transformReservedWord(word) {
384
- if (reservedWords.includes(word)) {
395
+ if (word && reservedWords.includes(word)) {
385
396
  return `_${word}`;
386
397
  }
387
398
  return word;
388
399
  }
389
400
 
401
+ // src/utils/getStackTrace.ts
402
+ function getStackTrace(belowFn) {
403
+ const oldLimit = Error.stackTraceLimit;
404
+ Error.stackTraceLimit = Infinity;
405
+ const dummyObject = {};
406
+ const v8Handler = Error.prepareStackTrace;
407
+ Error.prepareStackTrace = function prepareStackTrace(dummyObject2, v8StackTrace2) {
408
+ return v8StackTrace2;
409
+ };
410
+ Error.captureStackTrace(dummyObject, belowFn || getStackTrace);
411
+ const v8StackTrace = dummyObject.stack;
412
+ Error.prepareStackTrace = v8Handler;
413
+ Error.stackTraceLimit = oldLimit;
414
+ return v8StackTrace;
415
+ }
416
+
390
417
  // src/plugin.ts
391
418
  function createPlugin(factory) {
392
419
  return (options) => {
@@ -411,7 +438,30 @@ var definePlugin = createPlugin((options) => {
411
438
  },
412
439
  fileManager,
413
440
  async addFile(...files) {
414
- return Promise.all(files.map((file) => file.override ? fileManager.add(file) : fileManager.addOrAppend(file)));
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
+ );
415
465
  },
416
466
  resolvePath,
417
467
  resolveName: (params) => {
@@ -464,7 +514,7 @@ var FileManager = class {
464
514
  return files;
465
515
  }
466
516
  async add(file) {
467
- const cacheItem = { id: v4(), file, status: "new" };
517
+ const cacheItem = { id: crypto.randomUUID(), file, status: "new" };
468
518
  this.cache.set(cacheItem.id, cacheItem);
469
519
  if (this.queue) {
470
520
  await this.queue.run(async () => {
@@ -518,133 +568,6 @@ ${file.source}`,
518
568
  return read(...params);
519
569
  }
520
570
  };
521
- function writeIndexes(root, options) {
522
- const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
523
- if (!tree) {
524
- return void 0;
525
- }
526
- const fileReducer = (files2, item) => {
527
- if (!item.children) {
528
- return [];
529
- }
530
- if (item.children?.length > 1) {
531
- const path = pathParser2.resolve(item.data.path, "index.ts");
532
- const exports = item.children.map((file) => {
533
- if (!file) {
534
- return void 0;
535
- }
536
- const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
537
- if (importPath.includes("index") && path.includes("index")) {
538
- return void 0;
539
- }
540
- return { path: importPath };
541
- }).filter(Boolean);
542
- files2.push({
543
- path,
544
- fileName: "index.ts",
545
- source: "",
546
- exports
547
- });
548
- } else {
549
- item.children?.forEach((child) => {
550
- const path = pathParser2.resolve(item.data.path, "index.ts");
551
- const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
552
- files2.push({
553
- path,
554
- fileName: "index.ts",
555
- source: "",
556
- exports: [{ path: importPath }]
557
- });
558
- });
559
- }
560
- item.children.forEach((childItem) => {
561
- fileReducer(files2, childItem);
562
- });
563
- return files2;
564
- };
565
- const files = fileReducer([], tree);
566
- return files;
567
- }
568
- function combineFiles(files) {
569
- return files.filter(Boolean).reduce((acc, curr) => {
570
- if (!curr) {
571
- return acc;
572
- }
573
- const prevIndex = acc.findIndex((item) => item.path === curr.path);
574
- if (prevIndex !== -1) {
575
- const prev = acc[prevIndex];
576
- acc[prevIndex] = {
577
- ...curr,
578
- source: `${prev.source}
579
- ${curr.source}`,
580
- imports: [...prev.imports || [], ...curr.imports || []],
581
- exports: [...prev.exports || [], ...curr.exports || []]
582
- };
583
- } else {
584
- acc.push(curr);
585
- }
586
- return acc;
587
- }, []);
588
- }
589
- function getFileSource(file) {
590
- let { source } = file;
591
- if (!file.fileName.endsWith(".ts")) {
592
- return file.source;
593
- }
594
- const imports = [];
595
- const exports = [];
596
- file.imports?.forEach((curr) => {
597
- const exists = imports.find((imp) => imp.path === curr.path);
598
- if (!exists) {
599
- imports.push({
600
- ...curr,
601
- name: Array.isArray(curr.name) ? uniq(curr.name) : curr.name
602
- });
603
- }
604
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
605
- imports.push(curr);
606
- }
607
- if (exists && Array.isArray(exists.name)) {
608
- if (Array.isArray(curr.name)) {
609
- exists.name = uniq([...exists.name, ...curr.name]);
610
- }
611
- }
612
- });
613
- file.exports?.forEach((curr) => {
614
- const exists = exports.find((imp) => imp.path === curr.path);
615
- if (!exists) {
616
- exports.push({
617
- ...curr,
618
- name: Array.isArray(curr.name) ? uniq(curr.name) : curr.name
619
- });
620
- }
621
- if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
622
- exports.push(curr);
623
- }
624
- if (exists && Array.isArray(exists.name)) {
625
- if (Array.isArray(curr.name)) {
626
- exists.name = uniq([...exists.name, ...curr.name]);
627
- }
628
- }
629
- });
630
- const importNodes = imports.reduce((prev, curr) => {
631
- return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
632
- }, []);
633
- const importSource = print(importNodes);
634
- const exportNodes = exports.reduce((prev, curr) => {
635
- return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
636
- }, []);
637
- const exportSource = print(exportNodes);
638
- if (importSource) {
639
- source = `${importSource}
640
- ${source}`;
641
- }
642
- if (exportSource) {
643
- source = `${exportSource}
644
- ${source}`;
645
- }
646
- return source;
647
- }
648
571
 
649
572
  // src/managers/pluginManager/PluginManager.ts
650
573
  var hookNames = {
@@ -661,13 +584,13 @@ var hooks = Object.keys(hookNames);
661
584
  var PluginManager = class {
662
585
  plugins;
663
586
  fileManager;
664
- logger;
665
- config;
587
+ onExecute;
666
588
  core;
667
589
  queue;
590
+ executer;
591
+ executed = [];
668
592
  constructor(config, options) {
669
- this.logger = options.logger;
670
- this.config = config;
593
+ this.onExecute = options.onExecute;
671
594
  this.queue = new Queue(10);
672
595
  this.fileManager = new FileManager({ task: options.task, queue: this.queue });
673
596
  this.core = definePlugin({
@@ -675,10 +598,14 @@ var PluginManager = class {
675
598
  fileManager: this.fileManager,
676
599
  load: this.load,
677
600
  resolvePath: this.resolvePath,
678
- resolveName: this.resolveName
601
+ resolveName: this.resolveName,
602
+ getExecuter: this.getExecuter.bind(this)
679
603
  });
680
604
  this.plugins = [this.core, ...config.plugins || []];
681
605
  }
606
+ getExecuter() {
607
+ return this.executer;
608
+ }
682
609
  resolvePath = (params) => {
683
610
  if (params.pluginName) {
684
611
  return this.hookForPluginSync({
@@ -721,7 +648,7 @@ var PluginManager = class {
721
648
  parameters
722
649
  }) {
723
650
  const plugin = this.getPlugin(hookName, pluginName);
724
- return this.run({
651
+ return this.execute({
725
652
  strategy: "hookFirst",
726
653
  hookName,
727
654
  parameters,
@@ -734,7 +661,7 @@ var PluginManager = class {
734
661
  parameters
735
662
  }) {
736
663
  const plugin = this.getPlugin(hookName, pluginName);
737
- return this.runSync({
664
+ return this.executeSync({
738
665
  strategy: "hookFirst",
739
666
  hookName,
740
667
  parameters,
@@ -757,7 +684,7 @@ var PluginManager = class {
757
684
  promise = promise.then((result) => {
758
685
  if (result != null)
759
686
  return result;
760
- return this.run({
687
+ return this.execute({
761
688
  strategy: "hookFirst",
762
689
  hookName,
763
690
  parameters,
@@ -780,7 +707,7 @@ var PluginManager = class {
780
707
  for (const plugin of this.getSortedPlugins(hookName)) {
781
708
  if (skipped && skipped.has(plugin))
782
709
  continue;
783
- result = this.runSync({
710
+ result = this.executeSync({
784
711
  strategy: "hookFirst",
785
712
  hookName,
786
713
  parameters,
@@ -802,18 +729,25 @@ var PluginManager = class {
802
729
  if (plugin[hookName]?.sequential) {
803
730
  await Promise.all(parallelPromises);
804
731
  parallelPromises.length = 0;
805
- await this.run({
732
+ await this.execute({
806
733
  strategy: "hookParallel",
807
734
  hookName,
808
735
  parameters,
809
736
  plugin
810
737
  });
811
738
  } else {
812
- const promise = this.run({ strategy: "hookParallel", hookName, parameters, plugin });
813
- parallelPromises.push(promise);
739
+ const promise = this.execute({ strategy: "hookParallel", hookName, parameters, plugin });
740
+ if (promise) {
741
+ parallelPromises.push(promise);
742
+ }
814
743
  }
815
744
  }
816
- return Promise.all(parallelPromises);
745
+ const results = await Promise.allSettled(parallelPromises);
746
+ const errors = results.filter((result) => result.status === "rejected").map((result) => result.reason);
747
+ if (errors.length) {
748
+ throw new ParallelPluginError("Error", { errors, pluginManager: this });
749
+ }
750
+ return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
817
751
  }
818
752
  // chains, reduces returned value, handling the reduced value as the first hook argument
819
753
  hookReduceArg0({
@@ -824,14 +758,15 @@ var PluginManager = class {
824
758
  const [argument0, ...rest] = parameters;
825
759
  let promise = Promise.resolve(argument0);
826
760
  for (const plugin of this.getSortedPlugins(hookName)) {
827
- promise = promise.then(
828
- (argument02) => this.run({
761
+ promise = promise.then((argument02) => {
762
+ const value = this.execute({
829
763
  strategy: "hookReduceArg0",
830
764
  hookName,
831
765
  parameters: [argument02, ...rest],
832
766
  plugin
833
- }).then((result) => reduce.call(this.core.api, argument02, result, plugin))
834
- );
767
+ });
768
+ return value;
769
+ }).then((result) => reduce.call(this.core.api, argument0, result, plugin));
835
770
  }
836
771
  return promise;
837
772
  }
@@ -840,7 +775,7 @@ var PluginManager = class {
840
775
  let promise = Promise.resolve();
841
776
  for (const plugin of this.getSortedPlugins(hookName)) {
842
777
  promise = promise.then(
843
- () => this.run({
778
+ () => this.execute({
844
779
  strategy: "hookSeq",
845
780
  hookName,
846
781
  parameters,
@@ -858,13 +793,16 @@ var PluginManager = class {
858
793
  const plugins = [...this.plugins];
859
794
  const pluginByPluginName = plugins.find((item) => item.name === pluginName && item[hookName]);
860
795
  if (!pluginByPluginName) {
861
- if (this.config.logLevel === "warn" && this.logger?.spinner) {
862
- this.logger.spinner.info(`Plugin hook with ${hookName} not found for plugin ${pluginName}`);
863
- }
864
796
  return this.core;
865
797
  }
866
798
  return pluginByPluginName;
867
799
  }
800
+ addExecuter(executer) {
801
+ this.onExecute?.call(this, executer);
802
+ if (executer) {
803
+ this.executed.push(executer);
804
+ }
805
+ }
868
806
  /**
869
807
  * Run an async plugin hook and return the result.
870
808
  * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
@@ -872,36 +810,42 @@ var PluginManager = class {
872
810
  * @param plugin The actual pluginObject to run.
873
811
  */
874
812
  // Implementation signature
875
- run({
813
+ execute({
876
814
  strategy,
877
815
  hookName,
878
816
  parameters,
879
817
  plugin
880
818
  }) {
881
819
  const hook = plugin[hookName];
820
+ if (!hook) {
821
+ return null;
822
+ }
882
823
  return Promise.resolve().then(() => {
883
- if (typeof hook !== "function") {
884
- return hook;
885
- }
886
- if (this.config.logLevel === "info" && this.logger?.spinner) {
887
- this.logger.spinner.text = `[${strategy}] ${hookName}: Excecuting task for plugin ${plugin.name}
888
- `;
889
- }
890
- const hookResult = hook.apply(this.core.api, parameters);
891
- if (!hookResult?.then) {
892
- if (this.config.logLevel === "info" && this.logger?.spinner) {
893
- this.logger.spinner.succeed(`[${strategy}] ${hookName}: Excecuting task for plugin ${plugin.name}
894
- `);
824
+ this.executer = {
825
+ strategy,
826
+ hookName,
827
+ plugin
828
+ };
829
+ if (typeof hook === "function") {
830
+ const hookResult = hook.apply(this.core.api, parameters);
831
+ if (isPromise(hookResult)) {
832
+ return Promise.resolve(hookResult).then((result) => {
833
+ this.addExecuter({
834
+ strategy,
835
+ hookName,
836
+ plugin
837
+ });
838
+ return result;
839
+ });
895
840
  }
896
841
  return hookResult;
897
842
  }
898
- return Promise.resolve(hookResult).then((result) => {
899
- if (this.config.logLevel === "info" && this.logger?.spinner) {
900
- this.logger.spinner.succeed(`[${strategy}] ${hookName}: Excecuting task for plugin ${plugin.name}
901
- `);
902
- }
903
- return result;
843
+ this.addExecuter({
844
+ strategy,
845
+ hookName,
846
+ plugin
904
847
  });
848
+ return hook;
905
849
  }).catch((e) => {
906
850
  this.catcher(e, plugin, hookName);
907
851
  });
@@ -913,18 +857,37 @@ var PluginManager = class {
913
857
  * @param plugin The acutal plugin
914
858
  * @param replaceContext When passed, the plugin context can be overridden.
915
859
  */
916
- runSync({
860
+ executeSync({
917
861
  strategy,
918
862
  hookName,
919
863
  parameters,
920
864
  plugin
921
865
  }) {
922
866
  const hook = plugin[hookName];
867
+ if (!hook) {
868
+ return null;
869
+ }
923
870
  try {
924
- if (typeof hook !== "function") {
925
- return hook;
871
+ this.executer = {
872
+ strategy,
873
+ hookName,
874
+ plugin
875
+ };
876
+ if (typeof hook === "function") {
877
+ const fn = hook.apply(this.core.api, parameters);
878
+ this.addExecuter({
879
+ strategy,
880
+ hookName,
881
+ plugin
882
+ });
883
+ return fn;
926
884
  }
927
- return hook.apply(this.core.api, parameters);
885
+ this.addExecuter({
886
+ strategy,
887
+ hookName,
888
+ plugin
889
+ });
890
+ return hook;
928
891
  } catch (e) {
929
892
  this.catcher(e, plugin, hookName);
930
893
  return null;
@@ -933,7 +896,7 @@ var PluginManager = class {
933
896
  catcher(e, plugin, hookName) {
934
897
  const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
935
898
  `;
936
- throw new Error(text, { cause: e });
899
+ throw new PluginError(text, { cause: e, pluginManager: this });
937
900
  }
938
901
  };
939
902
  function noReturn() {
@@ -957,6 +920,133 @@ function validatePlugins(plugins, dependedPluginNames) {
957
920
  });
958
921
  return true;
959
922
  }
923
+ function writeIndexes(root, options) {
924
+ const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
925
+ if (!tree) {
926
+ return void 0;
927
+ }
928
+ const fileReducer = (files2, item) => {
929
+ if (!item.children) {
930
+ return [];
931
+ }
932
+ if (item.children?.length > 1) {
933
+ const path = pathParser2.resolve(item.data.path, "index.ts");
934
+ const exports = item.children.map((file) => {
935
+ if (!file) {
936
+ return void 0;
937
+ }
938
+ const importPath = file.data.type === "directory" ? `./${file.data.name}` : `./${file.data.name.replace(/\.[^.]*$/, "")}`;
939
+ if (importPath.includes("index") && path.includes("index")) {
940
+ return void 0;
941
+ }
942
+ return { path: importPath };
943
+ }).filter(Boolean);
944
+ files2.push({
945
+ path,
946
+ fileName: "index.ts",
947
+ source: "",
948
+ exports
949
+ });
950
+ } else {
951
+ item.children?.forEach((child) => {
952
+ const path = pathParser2.resolve(item.data.path, "index.ts");
953
+ const importPath = child.data.type === "directory" ? `./${child.data.name}` : `./${child.data.name.replace(/\.[^.]*$/, "")}`;
954
+ files2.push({
955
+ path,
956
+ fileName: "index.ts",
957
+ source: "",
958
+ exports: [{ path: importPath }]
959
+ });
960
+ });
961
+ }
962
+ item.children.forEach((childItem) => {
963
+ fileReducer(files2, childItem);
964
+ });
965
+ return files2;
966
+ };
967
+ const files = fileReducer([], tree);
968
+ return files;
969
+ }
970
+ function combineFiles(files) {
971
+ return files.filter(Boolean).reduce((acc, curr) => {
972
+ if (!curr) {
973
+ return acc;
974
+ }
975
+ const prevIndex = acc.findIndex((item) => item.path === curr.path);
976
+ if (prevIndex !== -1) {
977
+ const prev = acc[prevIndex];
978
+ acc[prevIndex] = {
979
+ ...curr,
980
+ source: `${prev.source}
981
+ ${curr.source}`,
982
+ imports: [...prev.imports || [], ...curr.imports || []],
983
+ exports: [...prev.exports || [], ...curr.exports || []]
984
+ };
985
+ } else {
986
+ acc.push(curr);
987
+ }
988
+ return acc;
989
+ }, []);
990
+ }
991
+ function getFileSource(file) {
992
+ let { source } = file;
993
+ if (!file.fileName.endsWith(".ts")) {
994
+ return file.source;
995
+ }
996
+ const imports = [];
997
+ const exports = [];
998
+ file.imports?.forEach((curr) => {
999
+ const exists = imports.find((imp) => imp.path === curr.path);
1000
+ if (!exists) {
1001
+ imports.push({
1002
+ ...curr,
1003
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1004
+ });
1005
+ }
1006
+ if (exists && !Array.isArray(exists.name) && exists.name !== curr.name) {
1007
+ imports.push(curr);
1008
+ }
1009
+ if (exists && Array.isArray(exists.name)) {
1010
+ if (Array.isArray(curr.name)) {
1011
+ exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1012
+ }
1013
+ }
1014
+ });
1015
+ file.exports?.forEach((curr) => {
1016
+ const exists = exports.find((imp) => imp.path === curr.path);
1017
+ if (!exists) {
1018
+ exports.push({
1019
+ ...curr,
1020
+ name: Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name
1021
+ });
1022
+ }
1023
+ if (exists && !Array.isArray(exists.name) && exists.name !== curr.name && exists.asAlias === curr.asAlias) {
1024
+ exports.push(curr);
1025
+ }
1026
+ if (exists && Array.isArray(exists.name)) {
1027
+ if (Array.isArray(curr.name)) {
1028
+ exists.name = [.../* @__PURE__ */ new Set([...exists.name, ...curr.name])];
1029
+ }
1030
+ }
1031
+ });
1032
+ const importNodes = imports.reduce((prev, curr) => {
1033
+ return [...prev, createImportDeclaration({ name: curr.name, path: curr.path, isTypeOnly: curr.isTypeOnly })];
1034
+ }, []);
1035
+ const importSource = print(importNodes);
1036
+ const exportNodes = exports.reduce((prev, curr) => {
1037
+ return [...prev, createExportDeclaration({ name: curr.name, path: curr.path, asAlias: curr.asAlias })];
1038
+ }, []);
1039
+ const exportSource = print(exportNodes);
1040
+ if (importSource) {
1041
+ source = `${importSource}
1042
+ ${source}`;
1043
+ }
1044
+ if (exportSource) {
1045
+ source = `${exportSource}
1046
+ ${source}`;
1047
+ }
1048
+ return source;
1049
+ }
960
1050
 
961
1051
  // src/build.ts
962
1052
  async function transformReducer(_previousCode, result, _plugin) {
@@ -965,8 +1055,15 @@ async function transformReducer(_previousCode, result, _plugin) {
965
1055
  }
966
1056
  return result;
967
1057
  }
968
- async function buildImplementation(options) {
1058
+ async function build(options) {
969
1059
  const { config, logger } = options;
1060
+ try {
1061
+ if (!isURL(config.input.path)) {
1062
+ await read(config.input.path);
1063
+ }
1064
+ } catch (e) {
1065
+ throw new Error("Cannot read file defined in `input.path` or set with --input in the CLI of your Kubb config", { cause: e });
1066
+ }
970
1067
  if (config.output.clean) {
971
1068
  await clean(config.output.path);
972
1069
  }
@@ -994,7 +1091,17 @@ async function buildImplementation(options) {
994
1091
  }
995
1092
  }
996
1093
  };
997
- const pluginManager = new PluginManager(config, { logger, task: queueTask });
1094
+ const onExecute = (executer) => {
1095
+ if (!executer) {
1096
+ return;
1097
+ }
1098
+ const { strategy, hookName, plugin } = executer;
1099
+ if (config.logLevel === "info" && logger?.spinner) {
1100
+ logger.spinner.text = `[${strategy}] ${hookName}: Excecuting task for plugin ${plugin.name}
1101
+ `;
1102
+ }
1103
+ };
1104
+ const pluginManager = new PluginManager(config, { task: queueTask, onExecute });
998
1105
  const { plugins, fileManager } = pluginManager;
999
1106
  await pluginManager.hookParallel({
1000
1107
  hookName: "validate",
@@ -1005,19 +1112,7 @@ async function buildImplementation(options) {
1005
1112
  parameters: [config]
1006
1113
  });
1007
1114
  await pluginManager.hookParallel({ hookName: "buildEnd" });
1008
- return { files: fileManager.files.map((file) => ({ ...file, source: getFileSource(file) })) };
1009
- }
1010
- function build(options) {
1011
- return new Promise(async (resolve, reject) => {
1012
- try {
1013
- const output = await buildImplementation(options);
1014
- setTimeout(() => {
1015
- resolve(output);
1016
- }, 500);
1017
- } catch (e) {
1018
- reject(e);
1019
- }
1020
- });
1115
+ return { files: fileManager.files.map((file) => ({ ...file, source: getFileSource(file) })), pluginManager };
1021
1116
  }
1022
1117
 
1023
1118
  // src/config.ts
@@ -1047,6 +1142,4 @@ var SchemaGenerator = class extends Generator {
1047
1142
  // src/index.ts
1048
1143
  var src_default = build;
1049
1144
 
1050
- export { FileManager, Generator, PluginManager, Queue, SchemaGenerator, TreeNode, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, src_default as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, validatePlugins, write, writeIndexes };
1051
- //# sourceMappingURL=out.js.map
1052
- //# sourceMappingURL=index.js.map
1145
+ export { FileManager, Generator, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, TreeNode, ValidationPluginError, build, clean, combineFiles, createJSDocBlockText, createPlugin, createPluginCache, src_default as default, defineConfig, getEncodedText, getFileSource, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, isPromise, isURL, name, nameSorter, objectToParameters, read, renderTemplate, timeout, transformReservedWord, validatePlugins, write, writeIndexes };