@kubb/core 3.10.5 → 3.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{FileManager-D2fUBfwx.d.cts → FileManager-3ug7EyFN.d.cts} +29 -31
  2. package/dist/{FileManager-B14BOfNb.d.ts → FileManager-Zd55TEM3.d.ts} +29 -31
  3. package/dist/chunk-533OTQHD.js +131 -0
  4. package/dist/chunk-533OTQHD.js.map +1 -0
  5. package/dist/{chunk-4ESUQQVB.js → chunk-7TZ5IOVL.js} +3 -4
  6. package/dist/chunk-7TZ5IOVL.js.map +1 -0
  7. package/dist/{chunk-NGF5XEJP.cjs → chunk-C6ZMCVRD.cjs} +4 -4
  8. package/dist/{chunk-NGF5XEJP.cjs.map → chunk-C6ZMCVRD.cjs.map} +1 -1
  9. package/dist/{chunk-PEVYXGYF.cjs → chunk-H7WBARWY.cjs} +49 -47
  10. package/dist/chunk-H7WBARWY.cjs.map +1 -0
  11. package/dist/{chunk-XICDTA6N.js → chunk-IMO6IX7W.js} +5 -3
  12. package/dist/chunk-IMO6IX7W.js.map +1 -0
  13. package/dist/{chunk-5UFNQWFW.cjs → chunk-K7NAX5WN.cjs} +17 -17
  14. package/dist/{chunk-5UFNQWFW.cjs.map → chunk-K7NAX5WN.cjs.map} +1 -1
  15. package/dist/{chunk-FO6OOIML.cjs → chunk-PLNVC6RC.cjs} +13 -13
  16. package/dist/chunk-PLNVC6RC.cjs.map +1 -0
  17. package/dist/chunk-TYHNMIVY.cjs +155 -0
  18. package/dist/chunk-TYHNMIVY.cjs.map +1 -0
  19. package/dist/fs.cjs +37 -0
  20. package/dist/fs.cjs.map +1 -0
  21. package/dist/fs.d.cts +7 -0
  22. package/dist/fs.d.ts +7 -0
  23. package/dist/fs.js +3 -0
  24. package/dist/fs.js.map +1 -0
  25. package/dist/index.cjs +45 -45
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +4 -5
  28. package/dist/index.d.ts +4 -5
  29. package/dist/index.js +4 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/logger.cjs +7 -6
  32. package/dist/logger.js +2 -1
  33. package/dist/mocks.cjs +10 -9
  34. package/dist/mocks.cjs.map +1 -1
  35. package/dist/mocks.d.cts +2 -3
  36. package/dist/mocks.d.ts +2 -3
  37. package/dist/mocks.js +2 -1
  38. package/dist/mocks.js.map +1 -1
  39. package/dist/{parser-CYKQRXlL.d.ts → parser--5gRW-zL.d.ts} +8 -8
  40. package/dist/{parser-fbk23k1t.d.cts → parser-t_YKG02d.d.cts} +8 -8
  41. package/dist/{prompt-5L3BUBG6.cjs → prompt-7UC6AUNR.cjs} +4 -4
  42. package/dist/{prompt-5L3BUBG6.cjs.map → prompt-7UC6AUNR.cjs.map} +1 -1
  43. package/dist/transformers.cjs +22 -22
  44. package/dist/types-CFmeCPcR.d.cts +147 -0
  45. package/dist/types-CFmeCPcR.d.ts +147 -0
  46. package/dist/utils.cjs +19 -18
  47. package/dist/utils.d.cts +3 -4
  48. package/dist/utils.d.ts +3 -4
  49. package/dist/utils.js +2 -1
  50. package/package.json +15 -5
  51. package/src/BarrelManager.ts +2 -2
  52. package/src/FileManager.ts +4 -4
  53. package/src/PackageManager.ts +1 -1
  54. package/src/PluginManager.ts +1 -1
  55. package/src/build.ts +3 -3
  56. package/src/fs/clean.ts +5 -0
  57. package/src/fs/index.ts +9 -0
  58. package/src/fs/read.ts +69 -0
  59. package/src/fs/types.ts +138 -0
  60. package/src/fs/write.ts +67 -0
  61. package/src/logger.ts +1 -1
  62. package/src/types.ts +1 -1
  63. package/src/utils/TreeNode.ts +1 -1
  64. package/src/utils/parser.ts +2 -2
  65. package/dist/chunk-4ESUQQVB.js.map +0 -1
  66. package/dist/chunk-FO6OOIML.cjs.map +0 -1
  67. package/dist/chunk-PEVYXGYF.cjs.map +0 -1
  68. package/dist/chunk-XICDTA6N.js.map +0 -1
@@ -1,6 +1,4 @@
1
- import { write, read } from '@kubb/fs';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { ResolvedFile } from '@kubb/fs/types';
1
+ import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CFmeCPcR.cjs';
4
2
  import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.cjs';
5
3
 
6
4
  type PossiblePromise<T> = Promise<T> | T;
@@ -32,8 +30,8 @@ type Events = {
32
30
  };
33
31
  type GetFileProps<TOptions = object> = {
34
32
  name: string;
35
- mode?: KubbFile.Mode;
36
- extname: KubbFile.Extname;
33
+ mode?: Mode;
34
+ extname: Extname;
37
35
  pluginKey: Plugin['key'];
38
36
  options?: TOptions;
39
37
  };
@@ -47,10 +45,10 @@ declare class PluginManager {
47
45
  readonly logger: Logger;
48
46
  readonly options: Options;
49
47
  constructor(config: Config, options: Options);
50
- getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
48
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
51
49
  pluginKey: Plugin['key'];
52
50
  }>;
53
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
51
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
54
52
  resolveName: (params: ResolveNameParams) => string;
55
53
  /**
56
54
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -184,7 +182,7 @@ type Config<TInput = Input> = {
184
182
  * Override the extension to the generated imports and exports, by default each plugin will add an extension
185
183
  * @default { '.ts': '.ts'}
186
184
  */
187
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
185
+ extension?: Record<Extname, Extname | ''>;
188
186
  /**
189
187
  * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
190
188
  * @default 'named'
@@ -317,7 +315,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
317
315
  * @type hookFirst
318
316
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
319
317
  */
320
- resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
318
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
321
319
  /**
322
320
  * Resolve to a name based on a string.
323
321
  * Useful when converting to PascalCase or camelCase.
@@ -335,8 +333,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
335
333
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
336
334
  type ResolvePathParams<TOptions = object> = {
337
335
  pluginKey?: Plugin['key'];
338
- baseName: KubbFile.BaseName;
339
- mode?: KubbFile.Mode;
336
+ baseName: BaseName;
337
+ mode?: Mode;
340
338
  /**
341
339
  * Options to be passed to 'resolvePath' 3th parameter
342
340
  */
@@ -357,8 +355,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
357
355
  config: Config;
358
356
  fileManager: FileManager;
359
357
  pluginManager: PluginManager;
360
- addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
361
- resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
358
+ addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
359
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
362
360
  resolveName: (params: ResolveNameParams) => string;
363
361
  logger: Logger;
364
362
  /**
@@ -407,11 +405,11 @@ type Group = {
407
405
  };
408
406
 
409
407
  type BarrelData = {
410
- file?: KubbFile.File;
408
+ file?: File;
411
409
  /**
412
410
  * @deprecated use file instead
413
411
  */
414
- type: KubbFile.Mode;
412
+ type: Mode;
415
413
  path: string;
416
414
  name: string;
417
415
  };
@@ -429,26 +427,26 @@ declare class TreeNode {
429
427
  forEachDeep(callback: (treeNode: TreeNode) => void): void;
430
428
  filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
431
429
  mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
432
- static build(files: KubbFile.File[], root?: string): TreeNode | null;
430
+ static build(files: File[], root?: string): TreeNode | null;
433
431
  }
434
432
  type DirectoryTree = {
435
433
  name: string;
436
434
  path: string;
437
- file?: KubbFile.File;
435
+ file?: File;
438
436
  children: Array<DirectoryTree>;
439
437
  };
440
438
 
441
439
  type FileMetaBase = {
442
440
  pluginKey?: Plugin['key'];
443
441
  };
444
- type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
442
+ type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
445
443
  type AddIndexesProps = {
446
444
  type: BarrelType | false | undefined;
447
445
  /**
448
446
  * Root based on root and output.path specified in the config
449
447
  */
450
448
  root: string;
451
- files: KubbFile.File[];
449
+ files: File[];
452
450
  /**
453
451
  * Output for plugin
454
452
  */
@@ -465,32 +463,32 @@ type AddIndexesProps = {
465
463
  declare class FileManager {
466
464
  #private;
467
465
  constructor();
468
- get files(): Array<KubbFile.ResolvedFile>;
469
- get orderedFiles(): Array<KubbFile.ResolvedFile>;
466
+ get files(): Array<ResolvedFile>;
467
+ get orderedFiles(): Array<ResolvedFile>;
470
468
  get groupedFiles(): DirectoryTree | null;
471
469
  get treeNode(): TreeNode | null;
472
- add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
470
+ add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
473
471
  clear(): void;
474
- getCacheById(id: string): KubbFile.File | undefined;
475
- getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined;
476
- deleteByPath(path: KubbFile.Path): void;
477
- getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
472
+ getCacheById(id: string): File | undefined;
473
+ getByPath(path: Path): ResolvedFile | undefined;
474
+ deleteByPath(path: Path): void;
475
+ getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
478
476
  write(...params: Parameters<typeof write>): ReturnType<typeof write>;
479
477
  read(...params: Parameters<typeof read>): ReturnType<typeof read>;
480
- static getMode(path: string | undefined | null): KubbFile.Mode;
478
+ static getMode(path: string | undefined | null): Mode;
481
479
  }
482
480
  type GetSourceOptions = {
483
- extname?: KubbFile.Extname;
481
+ extname?: Extname;
484
482
  logger?: Logger;
485
483
  };
486
484
  declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
487
485
  type WriteFilesProps = {
488
486
  root: Config['root'];
489
- files: Array<KubbFile.ResolvedFile>;
490
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
487
+ files: Array<ResolvedFile>;
488
+ extension?: Record<Extname, Extname | ''>;
491
489
  logger?: Logger;
492
490
  dryRun?: boolean;
493
491
  };
494
- declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<KubbFile.ResolvedFile[]>;
492
+ declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
495
493
 
496
494
  export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
@@ -1,6 +1,4 @@
1
- import { write, read } from '@kubb/fs';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { ResolvedFile } from '@kubb/fs/types';
1
+ import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CFmeCPcR.js';
4
2
  import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.js';
5
3
 
6
4
  type PossiblePromise<T> = Promise<T> | T;
@@ -32,8 +30,8 @@ type Events = {
32
30
  };
33
31
  type GetFileProps<TOptions = object> = {
34
32
  name: string;
35
- mode?: KubbFile.Mode;
36
- extname: KubbFile.Extname;
33
+ mode?: Mode;
34
+ extname: Extname;
37
35
  pluginKey: Plugin['key'];
38
36
  options?: TOptions;
39
37
  };
@@ -47,10 +45,10 @@ declare class PluginManager {
47
45
  readonly logger: Logger;
48
46
  readonly options: Options;
49
47
  constructor(config: Config, options: Options);
50
- getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
48
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
51
49
  pluginKey: Plugin['key'];
52
50
  }>;
53
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
51
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
54
52
  resolveName: (params: ResolveNameParams) => string;
55
53
  /**
56
54
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -184,7 +182,7 @@ type Config<TInput = Input> = {
184
182
  * Override the extension to the generated imports and exports, by default each plugin will add an extension
185
183
  * @default { '.ts': '.ts'}
186
184
  */
187
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
185
+ extension?: Record<Extname, Extname | ''>;
188
186
  /**
189
187
  * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
190
188
  * @default 'named'
@@ -317,7 +315,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
317
315
  * @type hookFirst
318
316
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
319
317
  */
320
- resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
318
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
321
319
  /**
322
320
  * Resolve to a name based on a string.
323
321
  * Useful when converting to PascalCase or camelCase.
@@ -335,8 +333,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
335
333
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
336
334
  type ResolvePathParams<TOptions = object> = {
337
335
  pluginKey?: Plugin['key'];
338
- baseName: KubbFile.BaseName;
339
- mode?: KubbFile.Mode;
336
+ baseName: BaseName;
337
+ mode?: Mode;
340
338
  /**
341
339
  * Options to be passed to 'resolvePath' 3th parameter
342
340
  */
@@ -357,8 +355,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
357
355
  config: Config;
358
356
  fileManager: FileManager;
359
357
  pluginManager: PluginManager;
360
- addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
361
- resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
358
+ addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
359
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
362
360
  resolveName: (params: ResolveNameParams) => string;
363
361
  logger: Logger;
364
362
  /**
@@ -407,11 +405,11 @@ type Group = {
407
405
  };
408
406
 
409
407
  type BarrelData = {
410
- file?: KubbFile.File;
408
+ file?: File;
411
409
  /**
412
410
  * @deprecated use file instead
413
411
  */
414
- type: KubbFile.Mode;
412
+ type: Mode;
415
413
  path: string;
416
414
  name: string;
417
415
  };
@@ -429,26 +427,26 @@ declare class TreeNode {
429
427
  forEachDeep(callback: (treeNode: TreeNode) => void): void;
430
428
  filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
431
429
  mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
432
- static build(files: KubbFile.File[], root?: string): TreeNode | null;
430
+ static build(files: File[], root?: string): TreeNode | null;
433
431
  }
434
432
  type DirectoryTree = {
435
433
  name: string;
436
434
  path: string;
437
- file?: KubbFile.File;
435
+ file?: File;
438
436
  children: Array<DirectoryTree>;
439
437
  };
440
438
 
441
439
  type FileMetaBase = {
442
440
  pluginKey?: Plugin['key'];
443
441
  };
444
- type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
442
+ type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
445
443
  type AddIndexesProps = {
446
444
  type: BarrelType | false | undefined;
447
445
  /**
448
446
  * Root based on root and output.path specified in the config
449
447
  */
450
448
  root: string;
451
- files: KubbFile.File[];
449
+ files: File[];
452
450
  /**
453
451
  * Output for plugin
454
452
  */
@@ -465,32 +463,32 @@ type AddIndexesProps = {
465
463
  declare class FileManager {
466
464
  #private;
467
465
  constructor();
468
- get files(): Array<KubbFile.ResolvedFile>;
469
- get orderedFiles(): Array<KubbFile.ResolvedFile>;
466
+ get files(): Array<ResolvedFile>;
467
+ get orderedFiles(): Array<ResolvedFile>;
470
468
  get groupedFiles(): DirectoryTree | null;
471
469
  get treeNode(): TreeNode | null;
472
- add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
470
+ add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
473
471
  clear(): void;
474
- getCacheById(id: string): KubbFile.File | undefined;
475
- getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined;
476
- deleteByPath(path: KubbFile.Path): void;
477
- getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
472
+ getCacheById(id: string): File | undefined;
473
+ getByPath(path: Path): ResolvedFile | undefined;
474
+ deleteByPath(path: Path): void;
475
+ getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
478
476
  write(...params: Parameters<typeof write>): ReturnType<typeof write>;
479
477
  read(...params: Parameters<typeof read>): ReturnType<typeof read>;
480
- static getMode(path: string | undefined | null): KubbFile.Mode;
478
+ static getMode(path: string | undefined | null): Mode;
481
479
  }
482
480
  type GetSourceOptions = {
483
- extname?: KubbFile.Extname;
481
+ extname?: Extname;
484
482
  logger?: Logger;
485
483
  };
486
484
  declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
487
485
  type WriteFilesProps = {
488
486
  root: Config['root'];
489
- files: Array<KubbFile.ResolvedFile>;
490
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
487
+ files: Array<ResolvedFile>;
488
+ extension?: Record<Extname, Extname | ''>;
491
489
  logger?: Logger;
492
490
  dryRun?: boolean;
493
491
  };
494
- declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<KubbFile.ResolvedFile[]>;
492
+ declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
495
493
 
496
494
  export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
@@ -0,0 +1,131 @@
1
+ import fs3 from 'fs-extra';
2
+ import { resolve, relative, normalize } from 'node:path';
3
+ import { switcher } from 'js-runtime';
4
+
5
+ // src/fs/clean.ts
6
+ async function clean(path) {
7
+ return fs3.remove(path);
8
+ }
9
+ function slash(path, platform = "linux") {
10
+ const isWindowsPath = /^\\\\\?\\/.test(path);
11
+ const normalizedPath = normalize(path);
12
+ if (["linux", "mac"].includes(platform) && !isWindowsPath) {
13
+ return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
14
+ }
15
+ return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
16
+ }
17
+ function getRelativePath(rootDir, filePath, platform = "linux") {
18
+ if (!rootDir || !filePath) {
19
+ throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
20
+ }
21
+ const relativePath = relative(rootDir, filePath);
22
+ const slashedPath = slash(relativePath, platform);
23
+ if (slashedPath.startsWith("../")) {
24
+ return slashedPath;
25
+ }
26
+ return `./${slashedPath}`;
27
+ }
28
+ var reader = switcher(
29
+ {
30
+ node: async (path) => {
31
+ return fs3.readFile(path, { encoding: "utf8" });
32
+ },
33
+ bun: async (path) => {
34
+ const file = Bun.file(path);
35
+ return file.text();
36
+ }
37
+ },
38
+ "node"
39
+ );
40
+ var syncReader = switcher(
41
+ {
42
+ node: (path) => {
43
+ return fs3.readFileSync(path, { encoding: "utf8" });
44
+ },
45
+ bun: () => {
46
+ throw new Error("Bun cannot read sync");
47
+ }
48
+ },
49
+ "node"
50
+ );
51
+ async function read(path) {
52
+ return reader(path);
53
+ }
54
+ function readSync(path) {
55
+ return syncReader(path);
56
+ }
57
+ var writer = switcher(
58
+ {
59
+ node: async (path, data, { sanity }) => {
60
+ try {
61
+ const oldContent = await fs3.readFile(resolve(path), {
62
+ encoding: "utf-8"
63
+ });
64
+ if (oldContent?.toString() === data?.toString()) {
65
+ return;
66
+ }
67
+ } catch (_err) {
68
+ }
69
+ await fs3.outputFile(resolve(path), data, { encoding: "utf-8" });
70
+ if (sanity) {
71
+ const savedData = await fs3.readFile(resolve(path), {
72
+ encoding: "utf-8"
73
+ });
74
+ if (savedData?.toString() !== data?.toString()) {
75
+ throw new Error(`Sanity check failed for ${path}
76
+
77
+ Data[${data.length}]:
78
+ ${data}
79
+
80
+ Saved[${savedData.length}]:
81
+ ${savedData}
82
+ `);
83
+ }
84
+ return savedData;
85
+ }
86
+ return data;
87
+ },
88
+ bun: async (path, data, { sanity }) => {
89
+ try {
90
+ await Bun.write(resolve(path), data);
91
+ if (sanity) {
92
+ const file = Bun.file(resolve(path));
93
+ const savedData = await file.text();
94
+ if (savedData?.toString() !== data?.toString()) {
95
+ throw new Error(`Sanity check failed for ${path}
96
+
97
+ Data[${path.length}]:
98
+ ${path}
99
+
100
+ Saved[${savedData.length}]:
101
+ ${savedData}
102
+ `);
103
+ }
104
+ return savedData;
105
+ }
106
+ return data;
107
+ } catch (e) {
108
+ console.error(e);
109
+ }
110
+ }
111
+ },
112
+ "node"
113
+ );
114
+ async function write(path, data, options = {}) {
115
+ if (data.trim() === "") {
116
+ return void 0;
117
+ }
118
+ return writer(path, data.trim(), options);
119
+ }
120
+
121
+ // src/fs/types.ts
122
+ var types_exports = {};
123
+
124
+ // src/fs/index.ts
125
+ function trimExtName(text) {
126
+ return text.replace(/\.[^/.]+$/, "");
127
+ }
128
+
129
+ export { clean, getRelativePath, read, readSync, trimExtName, types_exports, write };
130
+ //# sourceMappingURL=chunk-533OTQHD.js.map
131
+ //# sourceMappingURL=chunk-533OTQHD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/fs/clean.ts","../src/fs/read.ts","../src/fs/write.ts","../src/fs/types.ts","../src/fs/index.ts"],"names":["fs","switcher"],"mappings":";;;;;AAEA,eAAsB,MAAM,IAA6B,EAAA;AACvD,EAAO,OAAAA,GAAA,CAAG,OAAO,IAAI,CAAA;AAC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KAAM,EAAI,EAAA;AACtB,IAAO,OAAA,MAAA;AAAA;AAET,EAAA,OAAO,MAAO,CAAA,IAAA,EAAM,IAAK,CAAA,IAAA,IAAQ,OAAO,CAAA;AAC1C;;;AClEA,IAAA,aAAA,GAAA;;;ACIO,SAAS,YAAY,IAAsB,EAAA;AAChD,EAAO,OAAA,IAAA,CAAK,OAAQ,CAAA,WAAA,EAAa,EAAE,CAAA;AACrC","file":"chunk-533OTQHD.js","sourcesContent":["import fs from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n","import { normalize, relative } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\n}\n","import { resolve } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nconst writer = switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${path.length}]:\\n${path}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.error(e)\n }\n },\n },\n 'node',\n)\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim(), options)\n}\n","type BasePath<T extends string = string> = `${T}/`\n\nexport type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n | string\n | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n\n isNameSpace?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n}\n\nexport type Source = {\n name?: string\n value?: string\n isTypeOnly?: boolean\n /**\n * Has const or type 'export'\n * @default false\n */\n isExportable?: boolean\n /**\n * When set, barrel generation will add this\n * @default false\n */\n isIndexable?: boolean\n}\n\nexport type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @example '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n}\n\nexport type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\nexport type Mode = 'single' | 'split'\n\n/**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\nexport type BaseName = `${string}.${string}`\n\n/**\n * Path will be full qualified path to a specified file\n */\nexport type Path = string\n\nexport type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\nexport type OptionalPath = Path | undefined | null\n\nexport type File<TMeta extends object = object> = {\n /**\n * Name to be used to create the path\n * Based on UNIX basename, `${name}.extname`\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: BaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<BaseName> | Path\n sources: Array<Source>\n imports?: Array<Import>\n exports?: Array<Export>\n /**\n * This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists\n * This will also ignore the combinefiles utils\n * @default `false`\n */\n override?: boolean\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n banner?: string\n footer?: string\n}\n\nexport type ResolvedImport = Import\n\nexport type ResolvedExport = Export\n\nexport type ResolvedFile<TMeta extends object = object> = File<TMeta> & {\n /**\n * @default object-hash\n */\n id: string\n /**\n * Contains the first part of the baseName, generated based on baseName\n * @link https://nodejs.org/api/path.html#pathformatpathobject\n */\n name: string\n extname: Extname\n imports: Array<ResolvedImport>\n exports: Array<ResolvedExport>\n}\n","export { clean } from './clean.ts'\nexport { getRelativePath, read, readSync } from './read.ts'\nexport { write } from './write.ts'\n\nexport function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n\nexport * as KubbFile from './types.ts'\n"]}
@@ -1,12 +1,11 @@
1
+ import { write } from './chunk-533OTQHD.js';
1
2
  import seedrandom from 'seedrandom';
2
3
  import * as tty from 'node:tty';
3
4
  import { EventEmitter as EventEmitter$1 } from 'node:events';
4
5
  import { sep, resolve } from 'node:path';
5
- import { write } from '@kubb/fs';
6
6
  import { formatWithOptions } from 'node:util';
7
7
  import g$1 from 'node:process';
8
8
 
9
- // src/logger.ts
10
9
  var {
11
10
  env = {},
12
11
  argv = [],
@@ -1196,5 +1195,5 @@ function randomCliColour(text) {
1196
1195
  }
1197
1196
 
1198
1197
  export { EventEmitter, LogMapper, createLogger, randomCliColour, randomColour };
1199
- //# sourceMappingURL=chunk-4ESUQQVB.js.map
1200
- //# sourceMappingURL=chunk-4ESUQQVB.js.map
1198
+ //# sourceMappingURL=chunk-7TZ5IOVL.js.map
1199
+ //# sourceMappingURL=chunk-7TZ5IOVL.js.map