@kubb/core 2.18.3 → 2.18.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.
- package/dist/chunk-7TB4GNKF.cjs +1268 -0
- package/dist/chunk-7TB4GNKF.cjs.map +1 -0
- package/dist/{chunk-JLT7YQF5.js → chunk-7UMWFPXG.js} +9 -10
- package/dist/chunk-7UMWFPXG.js.map +1 -0
- package/dist/{chunk-WNT5FJKX.cjs → chunk-BE4KSMB4.cjs} +5 -5
- package/dist/chunk-EPAC7V2R.js +597 -0
- package/dist/chunk-EPAC7V2R.js.map +1 -0
- package/dist/{chunk-LSRMKE3Q.cjs → chunk-FWUA552W.cjs} +29 -29
- package/dist/{chunk-I6K57NKM.cjs → chunk-JI763CHT.cjs} +18 -18
- package/dist/{chunk-CURDPCUG.cjs → chunk-M6VNU2SJ.cjs} +21 -22
- package/dist/chunk-M6VNU2SJ.cjs.map +1 -0
- package/dist/{chunk-SJLROYQM.cjs → chunk-TCFN5BZ6.cjs} +5 -13
- package/dist/chunk-TCFN5BZ6.cjs.map +1 -0
- package/dist/index.cjs +1297 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -175
- package/dist/index.d.ts +54 -175
- package/dist/index.js +991 -22
- package/dist/index.js.map +1 -1
- package/dist/{logger-Cskfrvra.d.ts → logger-DChjnJMn.d.cts} +10 -2
- package/dist/{logger-Cskfrvra.d.cts → logger-DChjnJMn.d.ts} +10 -2
- package/dist/logger.cjs +5 -4
- package/dist/logger.d.cts +2 -1
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +3 -2
- package/dist/mocks.cjs +15 -14
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +6 -3
- package/dist/mocks.d.ts +6 -3
- package/dist/mocks.js +7 -6
- package/dist/mocks.js.map +1 -1
- package/dist/transformers.cjs +4 -4
- package/dist/utils.cjs +4 -4
- package/package.json +10 -19
- package/src/BarrelManager.ts +1 -1
- package/src/FileManager.ts +36 -167
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +5 -5
- package/src/build.ts +6 -8
- package/src/config.ts +29 -2
- package/src/index.ts +2 -3
- package/src/logger.ts +11 -9
- package/src/types.ts +4 -30
- package/src/utils/TreeNode.ts +1 -1
- package/dist/chunk-2F7E62RD.js +0 -85
- package/dist/chunk-2F7E62RD.js.map +0 -1
- package/dist/chunk-CURDPCUG.cjs.map +0 -1
- package/dist/chunk-J7SXH3YG.js +0 -1597
- package/dist/chunk-J7SXH3YG.js.map +0 -1
- package/dist/chunk-JLT7YQF5.js.map +0 -1
- package/dist/chunk-KSXPJNIA.cjs +0 -2584
- package/dist/chunk-KSXPJNIA.cjs.map +0 -1
- package/dist/chunk-MDO6MCFJ.js +0 -65
- package/dist/chunk-MDO6MCFJ.js.map +0 -1
- package/dist/chunk-RPDYCQHF.cjs +0 -2332
- package/dist/chunk-RPDYCQHF.cjs.map +0 -1
- package/dist/chunk-SJLROYQM.cjs.map +0 -1
- package/dist/chunk-U2XQEWRF.cjs +0 -75
- package/dist/chunk-U2XQEWRF.cjs.map +0 -1
- package/dist/fs.cjs +0 -23
- package/dist/fs.cjs.map +0 -1
- package/dist/fs.d.cts +0 -5
- package/dist/fs.d.ts +0 -5
- package/dist/fs.js +0 -18
- package/dist/fs.js.map +0 -1
- package/dist/write-CN8f7bYv.d.cts +0 -10
- package/dist/write-CN8f7bYv.d.ts +0 -10
- package/src/fs/clean.ts +0 -5
- package/src/fs/index.ts +0 -3
- package/src/fs/read.ts +0 -68
- package/src/fs/write.ts +0 -83
- /package/dist/{chunk-WNT5FJKX.cjs.map → chunk-BE4KSMB4.cjs.map} +0 -0
- /package/dist/{chunk-LSRMKE3Q.cjs.map → chunk-FWUA552W.cjs.map} +0 -0
- /package/dist/{chunk-I6K57NKM.cjs.map → chunk-JI763CHT.cjs.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import PQueue from 'p-queue';
|
|
2
|
-
import {
|
|
2
|
+
import { write, read } from '@kubb/fs';
|
|
3
|
+
import * as KubbFile from '@kubb/fs/types';
|
|
4
|
+
import { BaseName, File, UUID } from '@kubb/fs/src/types.ts';
|
|
3
5
|
import { PossiblePromise, TupleToUnion, ObjValueTuple, GreaterThan } from '@kubb/types';
|
|
4
6
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
5
|
-
import { E as EventEmitter, L as Logger
|
|
7
|
+
import { E as EventEmitter, L as Logger } from './logger-DChjnJMn.js';
|
|
8
|
+
import 'consola';
|
|
6
9
|
import 'ora';
|
|
7
10
|
|
|
8
11
|
type BarrelManagerOptions = {
|
|
@@ -38,7 +41,7 @@ type Options$2 = {
|
|
|
38
41
|
/**
|
|
39
42
|
* Task for the FileManager
|
|
40
43
|
*/
|
|
41
|
-
task: (file:
|
|
44
|
+
task: (file: ResolvedFile) => Promise<ResolvedFile>;
|
|
42
45
|
};
|
|
43
46
|
type Events = {
|
|
44
47
|
execute: [executer: Executer];
|
|
@@ -134,17 +137,7 @@ type Plugins = _Register;
|
|
|
134
137
|
type OptionsPlugins = {
|
|
135
138
|
[K in keyof Plugins]: Plugins[K]['options'];
|
|
136
139
|
};
|
|
137
|
-
type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
138
140
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
139
|
-
type Plugin$1 = keyof Plugins;
|
|
140
|
-
|
|
141
|
-
type kubb_OptionsOfPlugin<K extends keyof Plugins> = OptionsOfPlugin<K>;
|
|
142
|
-
type kubb_OptionsPlugins = OptionsPlugins;
|
|
143
|
-
type kubb_PluginUnion = PluginUnion;
|
|
144
|
-
type kubb_Plugins = Plugins;
|
|
145
|
-
declare namespace kubb {
|
|
146
|
-
export type { kubb_OptionsOfPlugin as OptionsOfPlugin, kubb_OptionsPlugins as OptionsPlugins, Plugin$1 as Plugin, kubb_PluginUnion as PluginUnion, kubb_Plugins as Plugins };
|
|
147
|
-
}
|
|
148
141
|
|
|
149
142
|
interface Cache<TStore extends object = object> {
|
|
150
143
|
delete(id: keyof TStore): boolean;
|
|
@@ -237,31 +230,6 @@ type Config<TInput = Input> = {
|
|
|
237
230
|
done?: string | Array<string>;
|
|
238
231
|
};
|
|
239
232
|
};
|
|
240
|
-
type CLIOptions = {
|
|
241
|
-
/**
|
|
242
|
-
* Path to `kubb.config.js`
|
|
243
|
-
*/
|
|
244
|
-
config?: string;
|
|
245
|
-
/**
|
|
246
|
-
* Watch changes on input
|
|
247
|
-
*/
|
|
248
|
-
watch?: string;
|
|
249
|
-
/**
|
|
250
|
-
* Log level to report when using the CLI
|
|
251
|
-
*
|
|
252
|
-
* `silent` will hide all information that is not relevant
|
|
253
|
-
*
|
|
254
|
-
* `info` will show all information possible(not related to the PluginManager)
|
|
255
|
-
*
|
|
256
|
-
* `debug` will show all information possible(related to the PluginManager), handy for seeing logs
|
|
257
|
-
* @default `silent`
|
|
258
|
-
*/
|
|
259
|
-
logLevel?: LogLevel;
|
|
260
|
-
/**
|
|
261
|
-
* Run Kubb with Bun
|
|
262
|
-
*/
|
|
263
|
-
bun?: boolean;
|
|
264
|
-
};
|
|
265
233
|
type UnionPlugins = PluginUnion;
|
|
266
234
|
type ObjectPlugin = keyof OptionsPlugins;
|
|
267
235
|
type PluginFactoryOptions<
|
|
@@ -388,7 +356,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
388
356
|
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
389
357
|
* @type hookParallel
|
|
390
358
|
*/
|
|
391
|
-
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string | undefined
|
|
359
|
+
writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
|
|
392
360
|
/**
|
|
393
361
|
* End of the plugin lifecycle.
|
|
394
362
|
* @type hookParallel
|
|
@@ -437,136 +405,22 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
437
405
|
};
|
|
438
406
|
type TransformResult = string | null;
|
|
439
407
|
|
|
440
|
-
type
|
|
441
|
-
declare namespace KubbFile {
|
|
442
|
-
type Import = {
|
|
443
|
-
/**
|
|
444
|
-
* Import name to be used
|
|
445
|
-
* @example ["useState"]
|
|
446
|
-
* @example "React"
|
|
447
|
-
*/
|
|
448
|
-
name: string | Array<string | {
|
|
449
|
-
propertyName: string;
|
|
450
|
-
name?: string;
|
|
451
|
-
}>;
|
|
452
|
-
/**
|
|
453
|
-
* Path for the import
|
|
454
|
-
* @xample '@kubb/core'
|
|
455
|
-
*/
|
|
456
|
-
path: string;
|
|
457
|
-
/**
|
|
458
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
459
|
-
*/
|
|
460
|
-
isTypeOnly?: boolean;
|
|
461
|
-
/**
|
|
462
|
-
* Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
|
|
463
|
-
*/
|
|
464
|
-
isNameSpace?: boolean;
|
|
465
|
-
/**
|
|
466
|
-
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
467
|
-
*/
|
|
468
|
-
root?: string;
|
|
469
|
-
};
|
|
470
|
-
type Export = {
|
|
471
|
-
/**
|
|
472
|
-
* Export name to be used.
|
|
473
|
-
* @example ["useState"]
|
|
474
|
-
* @example "React"
|
|
475
|
-
*/
|
|
476
|
-
name?: string | Array<string>;
|
|
477
|
-
/**
|
|
478
|
-
* Path for the import.
|
|
479
|
-
* @xample '@kubb/core'
|
|
480
|
-
*/
|
|
481
|
-
path: string;
|
|
482
|
-
/**
|
|
483
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
484
|
-
*/
|
|
485
|
-
isTypeOnly?: boolean;
|
|
486
|
-
/**
|
|
487
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
488
|
-
*/
|
|
489
|
-
asAlias?: boolean;
|
|
490
|
-
};
|
|
491
|
-
const dataTagSymbol: unique symbol;
|
|
492
|
-
type DataTag<Type, Value> = Type & {
|
|
493
|
-
[dataTagSymbol]: Value;
|
|
494
|
-
};
|
|
495
|
-
type UUID = string;
|
|
496
|
-
type Source = string;
|
|
497
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
498
|
-
type Mode = 'single' | 'split';
|
|
408
|
+
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
|
|
499
409
|
/**
|
|
500
|
-
*
|
|
501
|
-
* Based on UNIX basename
|
|
502
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
410
|
+
* @default crypto.randomUUID()
|
|
503
411
|
*/
|
|
504
|
-
|
|
412
|
+
id: UUID;
|
|
505
413
|
/**
|
|
506
|
-
*
|
|
414
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
415
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
507
416
|
*/
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Unique identifier to reuse later
|
|
517
|
-
* @default crypto.randomUUID()
|
|
518
|
-
*/
|
|
519
|
-
id?: string;
|
|
520
|
-
/**
|
|
521
|
-
* Name to be used to create the path
|
|
522
|
-
* Based on UNIX basename, `${name}.extName`
|
|
523
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
524
|
-
*/
|
|
525
|
-
baseName: TBaseName;
|
|
526
|
-
/**
|
|
527
|
-
* Path will be full qualified path to a specified file
|
|
528
|
-
*/
|
|
529
|
-
path: AdvancedPath<TBaseName> | Path;
|
|
530
|
-
source: Source;
|
|
531
|
-
imports?: Import[];
|
|
532
|
-
exports?: Export[];
|
|
533
|
-
/**
|
|
534
|
-
* This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
|
|
535
|
-
* This will also ignore the combinefiles utils
|
|
536
|
-
* @default `false`
|
|
537
|
-
*/
|
|
538
|
-
override?: boolean;
|
|
539
|
-
/**
|
|
540
|
-
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
541
|
-
*/
|
|
542
|
-
meta?: TMeta;
|
|
543
|
-
/**
|
|
544
|
-
* Override if a file can be exported by the BarrelManager
|
|
545
|
-
* @default true
|
|
546
|
-
*/
|
|
547
|
-
exportable?: boolean;
|
|
548
|
-
/**
|
|
549
|
-
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
550
|
-
*/
|
|
551
|
-
env?: NodeJS.ProcessEnv;
|
|
552
|
-
/**
|
|
553
|
-
* The name of the language being used. This can be TypeScript, JavaScript and still have another ext.
|
|
554
|
-
*/
|
|
555
|
-
language?: string;
|
|
556
|
-
};
|
|
557
|
-
type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
|
|
558
|
-
/**
|
|
559
|
-
* @default crypto.randomUUID()
|
|
560
|
-
*/
|
|
561
|
-
id: UUID;
|
|
562
|
-
/**
|
|
563
|
-
* Contains the first part of the baseName, generated based on baseName
|
|
564
|
-
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
565
|
-
*/
|
|
566
|
-
name: string;
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
|
417
|
+
name: string;
|
|
418
|
+
};
|
|
419
|
+
type FileMetaBase = {
|
|
420
|
+
pluginKey?: Plugin['key'];
|
|
421
|
+
};
|
|
422
|
+
type FileWithMeta<TMeta extends FileMetaBase = FileMetaBase> = KubbFile.File<TMeta>;
|
|
423
|
+
type AddResult<T extends Array<FileWithMeta>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
570
424
|
type AddIndexesProps = {
|
|
571
425
|
/**
|
|
572
426
|
* Root based on root and output.path specified in the config
|
|
@@ -583,26 +437,26 @@ type AddIndexesProps = {
|
|
|
583
437
|
};
|
|
584
438
|
logger: Logger;
|
|
585
439
|
options?: BarrelManagerOptions;
|
|
586
|
-
meta?:
|
|
440
|
+
meta?: FileWithMeta['meta'];
|
|
587
441
|
};
|
|
588
442
|
type Options$1 = {
|
|
589
443
|
queue?: PQueue;
|
|
590
|
-
task?: (file:
|
|
444
|
+
task?: (file: ResolvedFile) => Promise<ResolvedFile>;
|
|
591
445
|
};
|
|
592
446
|
declare class FileManager {
|
|
593
447
|
#private;
|
|
594
448
|
constructor({ task, queue }?: Options$1);
|
|
595
|
-
get files(): Array<
|
|
449
|
+
get files(): Array<FileWithMeta>;
|
|
596
450
|
get isExecuting(): boolean;
|
|
597
|
-
add<T extends Array<
|
|
451
|
+
add<T extends Array<FileWithMeta> = Array<FileWithMeta>>(...files: T): AddResult<T>;
|
|
598
452
|
addIndexes({ root, output, meta, logger, options }: AddIndexesProps): Promise<void>;
|
|
599
|
-
getCacheByUUID(UUID: KubbFile.UUID):
|
|
600
|
-
get(path: KubbFile.Path): Array<
|
|
453
|
+
getCacheByUUID(UUID: KubbFile.UUID): FileWithMeta | undefined;
|
|
454
|
+
get(path: KubbFile.Path): Array<FileWithMeta> | undefined;
|
|
601
455
|
remove(path: KubbFile.Path): void;
|
|
602
456
|
write(...params: Parameters<typeof write>): Promise<string | undefined>;
|
|
603
457
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
604
|
-
static getSource<TMeta extends
|
|
605
|
-
static combineFiles<TMeta extends
|
|
458
|
+
static getSource<TMeta extends FileMetaBase = FileMetaBase>(file: FileWithMeta<TMeta>): Promise<string>;
|
|
459
|
+
static combineFiles<TMeta extends FileMetaBase = FileMetaBase>(files: Array<FileWithMeta<TMeta> | null>): Array<FileWithMeta<TMeta>>;
|
|
606
460
|
static getMode(path: string | undefined | null): KubbFile.Mode;
|
|
607
461
|
static get extensions(): Array<KubbFile.Extname>;
|
|
608
462
|
static isJavascript(baseName: string): boolean;
|
|
@@ -626,6 +480,31 @@ type BuildOutput = {
|
|
|
626
480
|
declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
627
481
|
declare function safeBuild(options: BuildOptions): Promise<BuildOutput>;
|
|
628
482
|
|
|
483
|
+
type Args = {
|
|
484
|
+
/**
|
|
485
|
+
* Path to `kubb.config.js`
|
|
486
|
+
*/
|
|
487
|
+
config?: string;
|
|
488
|
+
/**
|
|
489
|
+
* Watch changes on input
|
|
490
|
+
*/
|
|
491
|
+
watch?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Log level to report when using the CLI
|
|
494
|
+
*
|
|
495
|
+
* `silent` will hide all information that is not relevant
|
|
496
|
+
*
|
|
497
|
+
* `info` will show all information possible(not related to the PluginManager)
|
|
498
|
+
*
|
|
499
|
+
* `debug` will show all information possible(related to the PluginManager), handy for seeing logs
|
|
500
|
+
* @default `silent`
|
|
501
|
+
*/
|
|
502
|
+
logLevel?: string;
|
|
503
|
+
/**
|
|
504
|
+
* Run Kubb with Bun
|
|
505
|
+
*/
|
|
506
|
+
bun?: boolean;
|
|
507
|
+
};
|
|
629
508
|
/**
|
|
630
509
|
* Type helper to make it easier to use kubb.config.js
|
|
631
510
|
* accepts a direct {@link Config} object, or a function that returns it.
|
|
@@ -633,7 +512,7 @@ declare function safeBuild(options: BuildOptions): Promise<BuildOutput>;
|
|
|
633
512
|
*/
|
|
634
513
|
declare function defineConfig(options: PossiblePromise<UserConfig | Array<UserConfig>> | ((
|
|
635
514
|
/** The options derived from the CLI flags */
|
|
636
|
-
|
|
515
|
+
args: Args) => PossiblePromise<UserConfig | Array<UserConfig>>)): typeof options;
|
|
637
516
|
declare function isInputPath(result: Config | undefined): result is Config<InputPath>;
|
|
638
517
|
|
|
639
518
|
/**
|
|
@@ -706,4 +585,4 @@ declare class PromiseManager<TState = any> {
|
|
|
706
585
|
interface _Register {
|
|
707
586
|
}
|
|
708
587
|
|
|
709
|
-
export { type
|
|
588
|
+
export { type Config, FileManager, type FileMetaBase, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type ObjectPlugin, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginKey, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginWithLifeCycle, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, type UnionPlugins, type UserConfig, type UserPlugin, type UserPluginWithLifeCycle, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
|