@kubb/core 3.0.0-alpha.4 → 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 (37) hide show
  1. package/dist/{FileManager-CaejIVBd.d.ts → FileManager-jZpqETKU.d.cts} +4 -17
  2. package/dist/{FileManager--scIq4y4.d.cts → FileManager-tzl0YsYE.d.ts} +4 -17
  3. package/dist/{chunk-UUBPTMRW.js → chunk-CEWT73XF.js} +72 -43
  4. package/dist/chunk-CEWT73XF.js.map +1 -0
  5. package/dist/{chunk-V5THHXXQ.cjs → chunk-FWU62YO5.cjs} +77 -48
  6. package/dist/chunk-FWU62YO5.cjs.map +1 -0
  7. package/dist/{chunk-QRIDQ4RG.cjs → chunk-RBP2ASUX.cjs} +1 -1
  8. package/dist/{chunk-QRIDQ4RG.cjs.map → chunk-RBP2ASUX.cjs.map} +1 -1
  9. package/dist/{chunk-EFQPHF4E.js → chunk-Z5CHJQJB.js} +1 -1
  10. package/dist/chunk-Z5CHJQJB.js.map +1 -0
  11. package/dist/index.cjs +15 -20
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +5 -10
  16. package/dist/index.js.map +1 -1
  17. package/dist/{logger-dzAcLeAA.d.cts → logger-BnWJh6Yq.d.cts} +6 -1
  18. package/dist/{logger-dzAcLeAA.d.ts → logger-BnWJh6Yq.d.ts} +6 -1
  19. package/dist/logger.cjs +2 -2
  20. package/dist/logger.d.cts +2 -1
  21. package/dist/logger.d.ts +2 -1
  22. package/dist/logger.js +1 -1
  23. package/dist/mocks.cjs +2 -2
  24. package/dist/mocks.cjs.map +1 -1
  25. package/dist/mocks.d.cts +2 -2
  26. package/dist/mocks.d.ts +2 -2
  27. package/dist/mocks.js +3 -3
  28. package/dist/mocks.js.map +1 -1
  29. package/package.json +7 -7
  30. package/src/BarrelManager.ts +10 -1
  31. package/src/FileManager.ts +57 -33
  32. package/src/PluginManager.ts +2 -2
  33. package/src/build.ts +1 -7
  34. package/src/logger.ts +2 -1
  35. package/dist/chunk-EFQPHF4E.js.map +0 -1
  36. package/dist/chunk-UUBPTMRW.js.map +0 -1
  37. package/dist/chunk-V5THHXXQ.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -3,11 +3,11 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkQRIDQ4RGcjs = require('./chunk-QRIDQ4RG.cjs');
6
+ var _chunkRBP2ASUXcjs = require('./chunk-RBP2ASUX.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkV5THHXXQcjs = require('./chunk-V5THHXXQ.cjs');
10
+ var _chunkFWU62YO5cjs = require('./chunk-FWU62YO5.cjs');
11
11
 
12
12
 
13
13
  var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
@@ -196,7 +196,7 @@ var _core, _usedPluginNames, _promiseManager, _PluginManager_instances, getSorte
196
196
  var PluginManager = class {
197
197
  constructor(config, options) {
198
198
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PluginManager_instances);
199
- this.events = new (0, _chunkQRIDQ4RGcjs.EventEmitter)();
199
+ this.events = new (0, _chunkRBP2ASUXcjs.EventEmitter)();
200
200
  this.executed = [];
201
201
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _core);
202
202
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _usedPluginNames, {});
@@ -252,7 +252,7 @@ Falling back on the first item.
252
252
  };
253
253
  this.config = config;
254
254
  this.logger = options.logger;
255
- this.fileManager = new (0, _chunkV5THHXXQcjs.FileManager)();
255
+ this.fileManager = new (0, _chunkFWU62YO5cjs.FileManager)();
256
256
  _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
257
257
  nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _9 => _9.result])
258
258
  }));
@@ -465,9 +465,9 @@ Falling back on the first item.
465
465
  if (!_optionalChain([pluginByPluginName, 'optionalAccess', _17 => _17.length])) {
466
466
  const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
467
467
  if (corePlugin) {
468
- 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`);
469
469
  } else {
470
- 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`);
471
471
  }
472
472
  return corePlugin ? [corePlugin] : [];
473
473
  }
@@ -645,7 +645,7 @@ function isInputPath(result) {
645
645
 
646
646
  // src/build.ts
647
647
  async function setup(options) {
648
- const { config, logger = _chunkQRIDQ4RGcjs.createLogger.call(void 0, ) } = options;
648
+ const { config, logger = _chunkRBP2ASUXcjs.createLogger.call(void 0, ) } = options;
649
649
  try {
650
650
  if (isInputPath(config) && !new (0, _chunkYTSNYMHWcjs.URLPath)(config.input.path).isURL) {
651
651
  await _fs.read.call(void 0, config.input.path);
@@ -653,7 +653,7 @@ async function setup(options) {
653
653
  } catch (e) {
654
654
  if (isInputPath(config)) {
655
655
  throw new Error(
656
- `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkQRIDQ4RGcjs.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)}`,
657
657
  {
658
658
  cause: e
659
659
  }
@@ -667,10 +667,10 @@ async function setup(options) {
667
667
  pluginManager.on("executed", (executer) => {
668
668
  const { hookName, plugin, output, parameters } = executer;
669
669
  const logs = [
670
- `${_chunkQRIDQ4RGcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
671
- parameters && `${_chunkQRIDQ4RGcjs.p.bgWhite("Parameters")} ${_chunkQRIDQ4RGcjs.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}`,
672
672
  JSON.stringify(parameters, void 0, 2),
673
- output && `${_chunkQRIDQ4RGcjs.p.bgWhite("Output")} ${_chunkQRIDQ4RGcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
673
+ output && `${_chunkRBP2ASUXcjs.p.bgWhite("Output")} ${_chunkRBP2ASUXcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
674
674
  output
675
675
  ].filter(Boolean);
676
676
  logger.emit("debug", logs);
@@ -683,7 +683,7 @@ async function build(options) {
683
683
  hookName: "buildStart",
684
684
  parameters: [options.config]
685
685
  });
686
- const files = await _chunkV5THHXXQcjs.processFiles.call(void 0, {
686
+ const files = await _chunkFWU62YO5cjs.processFiles.call(void 0, {
687
687
  dryRun: !options.config.output.write,
688
688
  files: pluginManager.fileManager.files,
689
689
  logger: pluginManager.logger
@@ -702,20 +702,15 @@ async function safeBuild(options) {
702
702
  hookName: "buildStart",
703
703
  parameters: [options.config]
704
704
  });
705
- files = await _chunkV5THHXXQcjs.processFiles.call(void 0, {
705
+ files = await _chunkFWU62YO5cjs.processFiles.call(void 0, {
706
706
  dryRun: !options.config.output.write,
707
707
  files: pluginManager.fileManager.files,
708
708
  logger: pluginManager.logger
709
709
  });
710
710
  await pluginManager.hookParallel({ hookName: "buildEnd" });
711
711
  } catch (e) {
712
- const files2 = await _chunkV5THHXXQcjs.processFiles.call(void 0, {
713
- dryRun: true,
714
- files: pluginManager.fileManager.files,
715
- logger: pluginManager.logger
716
- });
717
712
  return {
718
- files: files2,
713
+ files: [],
719
714
  pluginManager,
720
715
  error: e
721
716
  };
@@ -1204,5 +1199,5 @@ var PackageManager = _PackageManager;
1204
1199
 
1205
1200
 
1206
1201
 
1207
- exports.FileManager = _chunkV5THHXXQcjs.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;
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;
1208
1203
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","../src/index.ts","../src/build.ts","../src/PluginManager.ts","../src/PromiseManager.ts","../src/utils/executeStrategies.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js"],"names":["path","files","read","require","readSync"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AA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AA;AACT,IAAA;AAEe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACY,EAAA;AACJ,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AACe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACF;AAlKS;AAEP;AACA;AAJK;AAuFE;AACC,EAAA;AACY,IAAA;AACA,IAAA;AAClB,EAAA;AAEW,EAAA;AACF,IAAA;AACT,EAAA;AAEM,EAAA;AAEC,EAAA;AACT;AApGW;AAAN;AXwpCc;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","sourcesContent":[null,"export { build, build as default, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { FileManager } from './FileManager.ts'\nexport type { FileMetaBase } from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\nexport { createPlugin } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type * from './types.ts'\n","import c from 'tinyrainbow'\n\nimport { clean, read, write } from '@kubb/fs'\nimport { type FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger, randomCliColour } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = options\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n `Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${c.dim(config.input.path)}`,\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const pluginManager = new PluginManager(config, { logger })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n\n const logs = [\n `${randomCliColour(plugin.name)} Executing ${hookName}`,\n parameters && `${c.bgWhite('Parameters')} ${randomCliColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n logger.emit('debug', logs as string[])\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n const files = await processFiles({\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n return {\n files,\n pluginManager,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n files = await processFiles({\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n } catch (e) {\n const files = await processFiles({\n dryRun: true,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n return {\n files,\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","import { readSync } from '@kubb/fs'\nimport { FileManager, type ResolvedFile } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.ts'\n\ntype RequiredPluginLifecycle = Required<PluginLifecycle>\n\n/**\n * Get the type of the first argument in a function.\n * @example Arg0<(a: string, b: number) => void> -> string\n */\ntype Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0]\n\ntype Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq'\n\ntype Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {\n strategy: Strategy\n hookName: H\n plugin: Plugin\n parameters?: unknown[] | undefined\n output?: unknown\n}\n\ntype ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H]\n\ntype SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {\n result: Result\n plugin: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\n config,\n logger: this.logger,\n pluginManager: this,\n fileManager: this.fileManager,\n resolvePath: this.resolvePath.bind(this),\n resolveName: this.resolveName.bind(this),\n getPlugins: this.#getSortedPlugins.bind(this),\n })\n\n // call core.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n let source = ''\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n try {\n source = readSync(path)\n } catch (_e) {\n //\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n source,\n }\n }\n\n resolvePath = <TOptions = object>(params: ResolvePathParams<TOptions>): KubbFile.OptionalPath => {\n if (params.pluginKey) {\n const paths = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ])\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n resolveName = (params: ResolveNameParams): string => {\n if (params.pluginKey) {\n const names = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n })\n\n if (names && names?.length > 1) {\n this.logger.emit('debug', [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ])\n }\n\n return transformReservedWord(names?.at(0) || params.name)\n }\n\n const name = this.hookFirstSync({\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n }).result\n\n return transformReservedWord(name)\n }\n\n /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const promises = plugins\n .map((plugin) => {\n return this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n\n return Promise.all(promises)\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n return plugins\n .map((plugin) => {\n return this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const promises = this.#getSortedPlugins()\n .filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n .map((plugin) => {\n return async () => {\n const value = await this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n\n return Promise.resolve({\n plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n return this.#promiseManager.run('first', promises)\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n\n for (const plugin of this.#getSortedPlugins()) {\n if (skipped?.has(plugin)) {\n continue\n }\n\n parseResult = {\n result: this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n }),\n plugin,\n } as SafeParseResult<H>\n\n if (parseResult?.result != null) {\n break\n }\n }\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\n */\n async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({\n hookName,\n parameters,\n }: {\n hookName: H\n parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined\n }): Promise<Awaited<TOuput>[]> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins()[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\n */\n hookReduceArg0<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n reduce,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of this.#getSortedPlugins()) {\n promise = promise\n .then((arg0) => {\n const value = this.#execute({\n strategy: 'hookReduceArg0',\n hookName,\n parameters: [arg0, ...rest] as PluginParameter<H>,\n plugin,\n })\n return value\n })\n .then((result) => reduce.call(this.#core.context, argument0, result as ReturnType<ParseResult<H>>, plugin)) as Promise<Argument0<H>>\n }\n\n return promise\n }\n\n /**\n * Chains plugins\n */\n async hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: { hookName: H; parameters?: PluginParameter<H> }): Promise<void> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n return this.#promiseManager.run('seq', promises)\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('info', `No hook ${hookName} found`)\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .map((plugin) => {\n if (plugin.pre) {\n const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName))\n\n if (!isValid) {\n throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, undefined, 2)})`)\n }\n }\n\n return plugin\n })\n .sort((a, b) => {\n if (b.pre?.includes(a.name)) {\n return 1\n }\n if (b.post?.includes(a.name)) {\n return -1\n }\n return 0\n })\n }\n\n getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[] {\n const plugins = [...this.plugins]\n const [searchPluginName, searchIdentifier] = pluginKey\n\n const pluginByPluginName = plugins\n .filter((plugin) => plugin[hookName])\n .filter((item) => {\n const [name, identifier] = item.key\n\n const identifierCheck = identifier?.toString() === searchIdentifier?.toString()\n const nameCheck = name === searchPluginName\n\n if (searchIdentifier) {\n return identifierCheck && nameCheck\n }\n\n return nameCheck\n })\n\n if (!pluginByPluginName?.length) {\n // fallback on the core plugin when there is no match\n\n const corePlugin = plugins.find((plugin) => plugin.name === 'core' && plugin[hookName])\n\n if (corePlugin) {\n this.logger.emit('debug', [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`])\n } else {\n this.logger.emit('debug', [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`])\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n }\n }\n\n /**\n * Run an async plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The actual pluginObject to run.\n */\n // Implementation signature\n #execute<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: unknown[] | undefined\n plugin: PluginWithLifeCycle\n }): Promise<ReturnType<ParseResult<H>> | null> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n const task = Promise.resolve()\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as Promise<ReturnType<ParseResult<H>>>\n\n if (isPromise(possiblePromiseResult)) {\n return Promise.resolve(possiblePromiseResult)\n }\n return possiblePromiseResult\n }\n\n return hook\n })\n .then((result) => {\n output = result\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return result\n })\n .catch((e: Error) => {\n this.#catcher<H>(e, plugin, hookName)\n\n return null\n })\n\n return task\n }\n\n /**\n * Run a sync plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be in `PluginHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The acutal plugin\n * @param replaceContext When passed, the plugin context can be overridden.\n */\n #executeSync<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: PluginParameter<H>\n plugin: PluginWithLifeCycle\n }): ReturnType<ParseResult<H>> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as ReturnType<ParseResult<H>>\n\n output = fn\n return fn\n }\n\n output = hook\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return hook\n } catch (e) {\n this.#catcher<H>(e as Error, plugin, hookName)\n\n return null\n }\n }\n\n #catcher<H extends PluginLifecycleHooks>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<GetPluginFactoryOptions<TPlugin>> {\n const usedPluginNames = pluginManager.#usedPluginNames\n\n setUniqueName(plugin.name, usedPluginNames)\n\n const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]\n\n if (plugin.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n static getDependedPlugins<\n T1 extends PluginFactoryOptions,\n T2 extends PluginFactoryOptions = never,\n T3 extends PluginFactoryOptions = never,\n TOutput = T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput {\n let pluginNames: string[] = []\n if (typeof dependedPluginNames === 'string') {\n pluginNames = [dependedPluginNames]\n } else {\n pluginNames = dependedPluginNames\n }\n\n return pluginNames.map((pluginName) => {\n const plugin = plugins.find((plugin) => plugin.name === pluginName)\n if (!plugin) {\n throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`)\n }\n return plugin\n }) as TOutput\n }\n\n static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\n}\n","import { hookFirst, hookParallel, hookSeq } from './utils/executeStrategies.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Strategy, StrategySwitch } from './utils/executeStrategies.ts'\n\ntype PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype Options<TState = any> = {\n nullCheck?: (state: TState) => boolean\n}\n\nexport class PromiseManager<TState = any> {\n #options: Options<TState> = {}\n\n constructor(options: Options<TState> = {}) {\n this.#options = options\n\n return this\n }\n\n run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(\n strategy: TStrategy,\n promises: TInput,\n ): TOutput {\n if (strategy === 'seq') {\n return hookSeq<TInput, TValue, TOutput>(promises)\n }\n\n if (strategy === 'first') {\n return hookFirst<TInput, TValue, TOutput>(promises, this.#options.nullCheck)\n }\n\n if (strategy === 'parallel') {\n return hookParallel<TInput, TValue, TOutput>(promises)\n }\n\n throw new Error(`${strategy} not implemented`)\n }\n}\n\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return !!result && typeof (result as Promise<unknown>)?.then === 'function'\n}\n\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","type PromiseFunc<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2\n\nexport type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc<infer X, infer Y>> ? X | Y : never\n\nexport function noReturn(): void {}\n\ntype SeqOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): TOutput {\n return promises.filter(Boolean).reduce(\n (promise, func) => {\n if (typeof func !== 'function') {\n throw new Error('HookSeq needs a function that returns a promise `() => Promise<unknown>`')\n }\n\n return promise.then((state) => {\n const calledFunc = func(state as TValue)\n\n if (calledFunc) {\n return calledFunc.then(Array.prototype.concat.bind(state))\n }\n })\n },\n Promise.resolve([] as unknown),\n ) as TOutput\n}\n\ntype HookFirstOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>\n\n/**\n * Chains promises, first non-null result stops and returns\n */\nexport function hookFirst<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookFirstOutput<TInput, TValue>>(\n promises: TInput,\n nullCheck = (state: any) => state !== null,\n): TOutput {\n let promise: Promise<unknown> = Promise.resolve(null) as Promise<unknown>\n\n for (const func of promises.filter(Boolean)) {\n promise = promise.then((state) => {\n if (nullCheck(state)) {\n return state\n }\n\n const calledFunc = func(state as TValue)\n\n return calledFunc\n })\n }\n\n return promise as TOutput\n}\n\ntype HookParallelOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>\n\n/**\n * Run promises in parallel with allSettled\n */\nexport function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookParallelOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return Promise.allSettled(promises.filter(Boolean).map((promise) => promise())) as TOutput\n}\n\nexport type Strategy = 'seq' | 'first' | 'parallel'\n\nexport type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = TStrategy extends 'first'\n ? HookFirstOutput<TInput, TValue>\n : TStrategy extends 'seq'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","export class ValidationPluginError extends Error {}\n","import path from 'node:path'\n\nimport { createPluginCache } from './utils/cache.ts'\n\nimport type { FileManager } from './FileManager.ts'\nimport type { PluginManager } from './PluginManager.ts'\nimport type { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\n return factory(options)\n }\n}\n\ntype Options = {\n config: PluginContext['config']\n fileManager: FileManager\n pluginManager: PluginManager\n resolvePath: PluginContext['resolvePath']\n resolveName: PluginContext['resolveName']\n logger: PluginContext['logger']\n getPlugins: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\n return {\n get config() {\n return options.config\n },\n get plugins() {\n return options.getPlugins()\n },\n get plugin() {\n // see pluginManger.#execute where we override with `.call` the this with the correct plugin\n return options.plugin as NonNullable<Options['plugin']>\n },\n logger,\n fileManager,\n pluginManager,\n async addFile(...files) {\n const resolvedFiles = await fileManager.add(...files)\n\n if (!Array.isArray(resolvedFiles)) {\n return [resolvedFiles]\n }\n\n return resolvedFiles\n },\n resolvePath,\n resolveName,\n cache: createPluginCache(),\n }\n },\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name) {\n return name\n },\n }\n})\n","import type { PluginCache } from '../types.ts'\n\nexport interface Cache<TStore extends object = object> {\n delete(id: keyof TStore): boolean\n get(id: keyof TStore): TStore[keyof TStore] | null\n has(id: keyof TStore): boolean\n set(id: keyof TStore, value: unknown): void\n}\n\nexport function createPluginCache<TStore extends PluginCache>(Store: TStore = Object.create(null) as TStore): Cache<TStore> {\n return {\n set(id, value): void {\n Store[id] = [0, value] as TStore[keyof TStore]\n },\n get(id): TStore[keyof TStore] | null {\n const item = Store[id]\n if (!item) {\n return null\n }\n item[0] = 0\n return item[1] as TStore[keyof TStore]\n },\n has(id): boolean {\n const item = Store[id]\n if (!item) {\n return false\n }\n item[0] = 0\n return true\n },\n delete(id: keyof TStore): boolean {\n return delete Store[id]\n },\n }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\nimport { read, readSync } from '@kubb/fs'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() === 'win32') {\n location = pathToFileURL(location).href\n }\n\n const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = await read(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = readSync(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...(packageJSON['dependencies'] || {}),\n ...(packageJSON['devDependencies'] || {}),\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n","import path from 'node:path';\nimport {locatePath, locatePathSync} from 'locate-path';\nimport {toPath} from 'unicorn-magic';\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt ?? root));\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","import pLimit from 'p-limit';\n\nclass EndError extends Error {\n\tconstructor(value) {\n\t\tsuper();\n\t\tthis.value = value;\n\t}\n}\n\n// The input can also be a promise, so we await it.\nconst testElement = async (element, tester) => tester(await element);\n\n// The input can also be a promise, so we `Promise.all()` them both.\nconst finder = async element => {\n\tconst values = await Promise.all(element);\n\tif (values[1] === true) {\n\t\tthrow new EndError(values[0]);\n\t}\n\n\treturn false;\n};\n\nexport default async function pLocate(\n\titerable,\n\ttester,\n\t{\n\t\tconcurrency = Number.POSITIVE_INFINITY,\n\t\tpreserveOrder = true,\n\t} = {},\n) {\n\tconst limit = pLimit(concurrency);\n\n\t// Start all the promises concurrently with optional limit.\n\tconst items = [...iterable].map(element => [element, limit(testElement, element, tester)]);\n\n\t// Check the promises either serially or concurrently.\n\tconst checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);\n\n\ttry {\n\t\tawait Promise.all(items.map(element => checkLimit(finder, element)));\n\t} catch (error) {\n\t\tif (error instanceof EndError) {\n\t\t\treturn error.value;\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import {fileURLToPath} from 'node:url';\n\nexport function toPath(urlOrPath) {\n\treturn urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n}\n\nexport * from './default.js';\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","../src/index.ts","../src/build.ts","../src/PluginManager.ts","../src/PromiseManager.ts","../src/utils/executeStrategies.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_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,EAAA;AACN,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEI,IAAA;AACK,MAAA;AACT,IAAA;AAEe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACY,EAAA;AACJ,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AACe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACF;AAlKS;AAEP;AACA;AAJK;AAuFE;AACC,EAAA;AACY,IAAA;AACA,IAAA;AAClB,EAAA;AAEW,EAAA;AACF,IAAA;AACT,EAAA;AAEM,EAAA;AAEC,EAAA;AACT;AApGW;AAAN;AXmpCc;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","sourcesContent":[null,"export { build, build as default, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { FileManager } from './FileManager.ts'\nexport type { FileMetaBase } from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\nexport { createPlugin } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type * from './types.ts'\n","import c from 'tinyrainbow'\n\nimport { clean, read, write } from '@kubb/fs'\nimport { type FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger, randomCliColour } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = options\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n `Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${c.dim(config.input.path)}`,\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const pluginManager = new PluginManager(config, { logger })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n\n const logs = [\n `${randomCliColour(plugin.name)} Executing ${hookName}`,\n parameters && `${c.bgWhite('Parameters')} ${randomCliColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n logger.emit('debug', logs as string[])\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n const files = await processFiles({\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n return {\n files,\n pluginManager,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n files = await processFiles({\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n } catch (e) {\n return {\n files: [],\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","import { readSync } from '@kubb/fs'\nimport { FileManager, type ResolvedFile } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.ts'\n\ntype RequiredPluginLifecycle = Required<PluginLifecycle>\n\n/**\n * Get the type of the first argument in a function.\n * @example Arg0<(a: string, b: number) => void> -> string\n */\ntype Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0]\n\ntype Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq'\n\ntype Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {\n strategy: Strategy\n hookName: H\n plugin: Plugin\n parameters?: unknown[] | undefined\n output?: unknown\n}\n\ntype ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H]\n\ntype SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {\n result: Result\n plugin: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\n config,\n logger: this.logger,\n pluginManager: this,\n fileManager: this.fileManager,\n resolvePath: this.resolvePath.bind(this),\n resolveName: this.resolveName.bind(this),\n getPlugins: this.#getSortedPlugins.bind(this),\n })\n\n // call core.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n let source = ''\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n try {\n source = readSync(path)\n } catch (_e) {\n //\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n source,\n }\n }\n\n resolvePath = <TOptions = object>(params: ResolvePathParams<TOptions>): KubbFile.OptionalPath => {\n if (params.pluginKey) {\n const paths = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ])\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n resolveName = (params: ResolveNameParams): string => {\n if (params.pluginKey) {\n const names = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n })\n\n if (names && names?.length > 1) {\n this.logger.emit('debug', [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ])\n }\n\n return transformReservedWord(names?.at(0) || params.name)\n }\n\n const name = this.hookFirstSync({\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n }).result\n\n return transformReservedWord(name)\n }\n\n /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const promises = plugins\n .map((plugin) => {\n return this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n\n return Promise.all(promises)\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n return plugins\n .map((plugin) => {\n return this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const promises = this.#getSortedPlugins()\n .filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n .map((plugin) => {\n return async () => {\n const value = await this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n\n return Promise.resolve({\n plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n return this.#promiseManager.run('first', promises)\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n\n for (const plugin of this.#getSortedPlugins()) {\n if (skipped?.has(plugin)) {\n continue\n }\n\n parseResult = {\n result: this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n }),\n plugin,\n } as SafeParseResult<H>\n\n if (parseResult?.result != null) {\n break\n }\n }\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\n */\n async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({\n hookName,\n parameters,\n }: {\n hookName: H\n parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined\n }): Promise<Awaited<TOuput>[]> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins()[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\n */\n hookReduceArg0<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n reduce,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of this.#getSortedPlugins()) {\n promise = promise\n .then((arg0) => {\n const value = this.#execute({\n strategy: 'hookReduceArg0',\n hookName,\n parameters: [arg0, ...rest] as PluginParameter<H>,\n plugin,\n })\n return value\n })\n .then((result) => reduce.call(this.#core.context, argument0, result as ReturnType<ParseResult<H>>, plugin)) as Promise<Argument0<H>>\n }\n\n return promise\n }\n\n /**\n * Chains plugins\n */\n async hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: { hookName: H; parameters?: PluginParameter<H> }): Promise<void> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n return this.#promiseManager.run('seq', promises)\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('info', `No hook ${hookName} found`)\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .map((plugin) => {\n if (plugin.pre) {\n const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName))\n\n if (!isValid) {\n throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, undefined, 2)})`)\n }\n }\n\n return plugin\n })\n .sort((a, b) => {\n if (b.pre?.includes(a.name)) {\n return 1\n }\n if (b.post?.includes(a.name)) {\n return -1\n }\n return 0\n })\n }\n\n getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[] {\n const plugins = [...this.plugins]\n const [searchPluginName, searchIdentifier] = pluginKey\n\n const pluginByPluginName = plugins\n .filter((plugin) => plugin[hookName])\n .filter((item) => {\n const [name, identifier] = item.key\n\n const identifierCheck = identifier?.toString() === searchIdentifier?.toString()\n const nameCheck = name === searchPluginName\n\n if (searchIdentifier) {\n return identifierCheck && nameCheck\n }\n\n return nameCheck\n })\n\n if (!pluginByPluginName?.length) {\n // fallback on the core plugin when there is no match\n\n const corePlugin = plugins.find((plugin) => plugin.name === 'core' && plugin[hookName])\n\n if (corePlugin) {\n this.logger.emit('warning', `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`)\n } else {\n this.logger.emit('warning', `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`)\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n }\n }\n\n /**\n * Run an async plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The actual pluginObject to run.\n */\n // Implementation signature\n #execute<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: unknown[] | undefined\n plugin: PluginWithLifeCycle\n }): Promise<ReturnType<ParseResult<H>> | null> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n const task = Promise.resolve()\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as Promise<ReturnType<ParseResult<H>>>\n\n if (isPromise(possiblePromiseResult)) {\n return Promise.resolve(possiblePromiseResult)\n }\n return possiblePromiseResult\n }\n\n return hook\n })\n .then((result) => {\n output = result\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return result\n })\n .catch((e: Error) => {\n this.#catcher<H>(e, plugin, hookName)\n\n return null\n })\n\n return task\n }\n\n /**\n * Run a sync plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be in `PluginHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The acutal plugin\n * @param replaceContext When passed, the plugin context can be overridden.\n */\n #executeSync<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: PluginParameter<H>\n plugin: PluginWithLifeCycle\n }): ReturnType<ParseResult<H>> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as ReturnType<ParseResult<H>>\n\n output = fn\n return fn\n }\n\n output = hook\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return hook\n } catch (e) {\n this.#catcher<H>(e as Error, plugin, hookName)\n\n return null\n }\n }\n\n #catcher<H extends PluginLifecycleHooks>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<GetPluginFactoryOptions<TPlugin>> {\n const usedPluginNames = pluginManager.#usedPluginNames\n\n setUniqueName(plugin.name, usedPluginNames)\n\n const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]\n\n if (plugin.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n static getDependedPlugins<\n T1 extends PluginFactoryOptions,\n T2 extends PluginFactoryOptions = never,\n T3 extends PluginFactoryOptions = never,\n TOutput = T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput {\n let pluginNames: string[] = []\n if (typeof dependedPluginNames === 'string') {\n pluginNames = [dependedPluginNames]\n } else {\n pluginNames = dependedPluginNames\n }\n\n return pluginNames.map((pluginName) => {\n const plugin = plugins.find((plugin) => plugin.name === pluginName)\n if (!plugin) {\n throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`)\n }\n return plugin\n }) as TOutput\n }\n\n static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\n}\n","import { hookFirst, hookParallel, hookSeq } from './utils/executeStrategies.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Strategy, StrategySwitch } from './utils/executeStrategies.ts'\n\ntype PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype Options<TState = any> = {\n nullCheck?: (state: TState) => boolean\n}\n\nexport class PromiseManager<TState = any> {\n #options: Options<TState> = {}\n\n constructor(options: Options<TState> = {}) {\n this.#options = options\n\n return this\n }\n\n run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(\n strategy: TStrategy,\n promises: TInput,\n ): TOutput {\n if (strategy === 'seq') {\n return hookSeq<TInput, TValue, TOutput>(promises)\n }\n\n if (strategy === 'first') {\n return hookFirst<TInput, TValue, TOutput>(promises, this.#options.nullCheck)\n }\n\n if (strategy === 'parallel') {\n return hookParallel<TInput, TValue, TOutput>(promises)\n }\n\n throw new Error(`${strategy} not implemented`)\n }\n}\n\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return !!result && typeof (result as Promise<unknown>)?.then === 'function'\n}\n\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","type PromiseFunc<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2\n\nexport type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc<infer X, infer Y>> ? X | Y : never\n\nexport function noReturn(): void {}\n\ntype SeqOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): TOutput {\n return promises.filter(Boolean).reduce(\n (promise, func) => {\n if (typeof func !== 'function') {\n throw new Error('HookSeq needs a function that returns a promise `() => Promise<unknown>`')\n }\n\n return promise.then((state) => {\n const calledFunc = func(state as TValue)\n\n if (calledFunc) {\n return calledFunc.then(Array.prototype.concat.bind(state))\n }\n })\n },\n Promise.resolve([] as unknown),\n ) as TOutput\n}\n\ntype HookFirstOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>\n\n/**\n * Chains promises, first non-null result stops and returns\n */\nexport function hookFirst<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookFirstOutput<TInput, TValue>>(\n promises: TInput,\n nullCheck = (state: any) => state !== null,\n): TOutput {\n let promise: Promise<unknown> = Promise.resolve(null) as Promise<unknown>\n\n for (const func of promises.filter(Boolean)) {\n promise = promise.then((state) => {\n if (nullCheck(state)) {\n return state\n }\n\n const calledFunc = func(state as TValue)\n\n return calledFunc\n })\n }\n\n return promise as TOutput\n}\n\ntype HookParallelOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>\n\n/**\n * Run promises in parallel with allSettled\n */\nexport function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookParallelOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return Promise.allSettled(promises.filter(Boolean).map((promise) => promise())) as TOutput\n}\n\nexport type Strategy = 'seq' | 'first' | 'parallel'\n\nexport type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = TStrategy extends 'first'\n ? HookFirstOutput<TInput, TValue>\n : TStrategy extends 'seq'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","export class ValidationPluginError extends Error {}\n","import path from 'node:path'\n\nimport { createPluginCache } from './utils/cache.ts'\n\nimport type { FileManager } from './FileManager.ts'\nimport type { PluginManager } from './PluginManager.ts'\nimport type { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\n return factory(options)\n }\n}\n\ntype Options = {\n config: PluginContext['config']\n fileManager: FileManager\n pluginManager: PluginManager\n resolvePath: PluginContext['resolvePath']\n resolveName: PluginContext['resolveName']\n logger: PluginContext['logger']\n getPlugins: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\n return {\n get config() {\n return options.config\n },\n get plugins() {\n return options.getPlugins()\n },\n get plugin() {\n // see pluginManger.#execute where we override with `.call` the this with the correct plugin\n return options.plugin as NonNullable<Options['plugin']>\n },\n logger,\n fileManager,\n pluginManager,\n async addFile(...files) {\n const resolvedFiles = await fileManager.add(...files)\n\n if (!Array.isArray(resolvedFiles)) {\n return [resolvedFiles]\n }\n\n return resolvedFiles\n },\n resolvePath,\n resolveName,\n cache: createPluginCache(),\n }\n },\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name) {\n return name\n },\n }\n})\n","import type { PluginCache } from '../types.ts'\n\nexport interface Cache<TStore extends object = object> {\n delete(id: keyof TStore): boolean\n get(id: keyof TStore): TStore[keyof TStore] | null\n has(id: keyof TStore): boolean\n set(id: keyof TStore, value: unknown): void\n}\n\nexport function createPluginCache<TStore extends PluginCache>(Store: TStore = Object.create(null) as TStore): Cache<TStore> {\n return {\n set(id, value): void {\n Store[id] = [0, value] as TStore[keyof TStore]\n },\n get(id): TStore[keyof TStore] | null {\n const item = Store[id]\n if (!item) {\n return null\n }\n item[0] = 0\n return item[1] as TStore[keyof TStore]\n },\n has(id): boolean {\n const item = Store[id]\n if (!item) {\n return false\n }\n item[0] = 0\n return true\n },\n delete(id: keyof TStore): boolean {\n return delete Store[id]\n },\n }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\nimport { read, readSync } from '@kubb/fs'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() === 'win32') {\n location = pathToFileURL(location).href\n }\n\n const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = await read(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n const json = readSync(pkgPath)\n\n return JSON.parse(json) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...(packageJSON['dependencies'] || {}),\n ...(packageJSON['devDependencies'] || {}),\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n","import path from 'node:path';\nimport {locatePath, locatePathSync} from 'locate-path';\nimport {toPath} from 'unicorn-magic';\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt ?? root));\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) ?? '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);\n\tconst limit = options.limit ?? Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","import pLimit from 'p-limit';\n\nclass EndError extends Error {\n\tconstructor(value) {\n\t\tsuper();\n\t\tthis.value = value;\n\t}\n}\n\n// The input can also be a promise, so we await it.\nconst testElement = async (element, tester) => tester(await element);\n\n// The input can also be a promise, so we `Promise.all()` them both.\nconst finder = async element => {\n\tconst values = await Promise.all(element);\n\tif (values[1] === true) {\n\t\tthrow new EndError(values[0]);\n\t}\n\n\treturn false;\n};\n\nexport default async function pLocate(\n\titerable,\n\ttester,\n\t{\n\t\tconcurrency = Number.POSITIVE_INFINITY,\n\t\tpreserveOrder = true,\n\t} = {},\n) {\n\tconst limit = pLimit(concurrency);\n\n\t// Start all the promises concurrently with optional limit.\n\tconst items = [...iterable].map(element => [element, limit(testElement, element, tester)]);\n\n\t// Check the promises either serially or concurrently.\n\tconst checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);\n\n\ttry {\n\t\tawait Promise.all(items.map(element => checkLimit(finder, element)));\n\t} catch (error) {\n\t\tif (error instanceof EndError) {\n\t\t\treturn error.value;\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n","/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n","import {fileURLToPath} from 'node:url';\n\nexport function toPath(urlOrPath) {\n\treturn urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n}\n\nexport * from './default.js';\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as PluginContext, F as FileManager, a as PluginManager, U as UserConfig, C as Config, I as InputPath, b as PluginFactoryOptions, c as UserPluginWithLifeCycle } from './FileManager--scIq4y4.cjs';
2
- export { d as FileMetaBase, G as GetPluginFactoryOptions, e as InputData, h as Plugin, m as PluginCache, f as PluginKey, j as PluginLifecycle, k as PluginLifecycleHooks, l as PluginParameter, i as PluginWithLifeCycle, n as ResolveNameParams, R as ResolvePathParams, g as UserPlugin } from './FileManager--scIq4y4.cjs';
3
- import { L as Logger } from './logger-dzAcLeAA.cjs';
1
+ import { P as PluginContext, F as FileManager, a as PluginManager, U as UserConfig, C as Config, I as InputPath, b as PluginFactoryOptions, c as UserPluginWithLifeCycle } from './FileManager-jZpqETKU.cjs';
2
+ export { d as FileMetaBase, G as GetPluginFactoryOptions, e as InputData, h as Plugin, m as PluginCache, f as PluginKey, j as PluginLifecycle, k as PluginLifecycleHooks, l as PluginParameter, i as PluginWithLifeCycle, n as ResolveNameParams, R as ResolvePathParams, g as UserPlugin } from './FileManager-jZpqETKU.cjs';
3
+ import { L as Logger } from './logger-BnWJh6Yq.cjs';
4
4
  import { PossiblePromise } from '@kubb/types';
5
5
  import '@kubb/fs';
6
6
  import '@kubb/fs/types';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as PluginContext, F as FileManager, a as PluginManager, U as UserConfig, C as Config, I as InputPath, b as PluginFactoryOptions, c as UserPluginWithLifeCycle } from './FileManager-CaejIVBd.js';
2
- export { d as FileMetaBase, G as GetPluginFactoryOptions, e as InputData, h as Plugin, m as PluginCache, f as PluginKey, j as PluginLifecycle, k as PluginLifecycleHooks, l as PluginParameter, i as PluginWithLifeCycle, n as ResolveNameParams, R as ResolvePathParams, g as UserPlugin } from './FileManager-CaejIVBd.js';
3
- import { L as Logger } from './logger-dzAcLeAA.js';
1
+ import { P as PluginContext, F as FileManager, a as PluginManager, U as UserConfig, C as Config, I as InputPath, b as PluginFactoryOptions, c as UserPluginWithLifeCycle } from './FileManager-tzl0YsYE.js';
2
+ export { d as FileMetaBase, G as GetPluginFactoryOptions, e as InputData, h as Plugin, m as PluginCache, f as PluginKey, j as PluginLifecycle, k as PluginLifecycleHooks, l as PluginParameter, i as PluginWithLifeCycle, n as ResolveNameParams, R as ResolvePathParams, g as UserPlugin } from './FileManager-tzl0YsYE.js';
3
+ import { L as Logger } from './logger-BnWJh6Yq.js';
4
4
  import { PossiblePromise } from '@kubb/types';
5
5
  import '@kubb/fs';
6
6
  import '@kubb/fs/types';
package/dist/index.js CHANGED
@@ -3,11 +3,11 @@ import {
3
3
  createLogger,
4
4
  p,
5
5
  randomCliColour
6
- } from "./chunk-EFQPHF4E.js";
6
+ } from "./chunk-Z5CHJQJB.js";
7
7
  import {
8
8
  FileManager,
9
9
  processFiles
10
- } from "./chunk-UUBPTMRW.js";
10
+ } from "./chunk-CEWT73XF.js";
11
11
  import {
12
12
  transformReservedWord
13
13
  } from "./chunk-JKZG2IJR.js";
@@ -450,9 +450,9 @@ Falling back on the first item.
450
450
  if (!pluginByPluginName?.length) {
451
451
  const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
452
452
  if (corePlugin) {
453
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]);
453
+ this.logger.emit("warning", `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
454
454
  } else {
455
- this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]);
455
+ this.logger.emit("warning", `No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`);
456
456
  }
457
457
  return corePlugin ? [corePlugin] : [];
458
458
  }
@@ -693,13 +693,8 @@ async function safeBuild(options) {
693
693
  });
694
694
  await pluginManager.hookParallel({ hookName: "buildEnd" });
695
695
  } catch (e) {
696
- const files2 = await processFiles({
697
- dryRun: true,
698
- files: pluginManager.fileManager.files,
699
- logger: pluginManager.logger
700
- });
701
696
  return {
702
- files: files2,
697
+ files: [],
703
698
  pluginManager,
704
699
  error: e
705
700
  };