@kubb/core 5.0.0-beta.86 → 5.0.0-beta.88
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/{Diagnostics-aWJg-H2d.d.ts → Diagnostics-C2HF9H7A.d.ts} +99 -49
- package/dist/index.cjs +95 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -6
- package/dist/index.js +95 -26
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/package.json +2 -2
|
@@ -496,23 +496,14 @@ type ResolverDefault = {
|
|
|
496
496
|
*/
|
|
497
497
|
name(name: string): string;
|
|
498
498
|
options<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
499
|
-
path(
|
|
500
|
-
file(
|
|
499
|
+
path(options: ResolvePathOptions): string;
|
|
500
|
+
file(options: ResolveFileOptions): FileNode;
|
|
501
501
|
banner(meta: InputMeta | undefined, context: ResolveBannerContext): string | null;
|
|
502
502
|
footer(meta: InputMeta | undefined, context: ResolveBannerContext): string | null;
|
|
503
503
|
};
|
|
504
504
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* @example
|
|
509
|
-
* ```ts
|
|
510
|
-
* resolver.default.path(
|
|
511
|
-
* { baseName: 'petTypes.ts', tag: 'pets' },
|
|
512
|
-
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
513
|
-
* )
|
|
514
|
-
* // → '/src/types/pets/petTypes.ts'
|
|
515
|
-
* ```
|
|
505
|
+
* The name request for `resolver.default.path`: a `baseName` plus the optional `tag`/`path` that
|
|
506
|
+
* grouping keys off.
|
|
516
507
|
*/
|
|
517
508
|
type ResolverPathParams = {
|
|
518
509
|
baseName: FileNode['baseName'];
|
|
@@ -526,27 +517,32 @@ type ResolverPathParams = {
|
|
|
526
517
|
path?: string;
|
|
527
518
|
};
|
|
528
519
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
520
|
+
* Options for `resolver.default.path`: the name request (`baseName`, `tag`, `path`) plus where the
|
|
521
|
+
* output goes (`root`, `output`, `group`).
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* resolver.default.path({ baseName: 'petTypes.ts', tag: 'pets', root: '/src', output: { path: 'types' }, group: { type: 'tag' } })
|
|
526
|
+
* // → '/src/types/pets/petTypes.ts'
|
|
527
|
+
* ```
|
|
532
528
|
*/
|
|
533
|
-
type
|
|
529
|
+
type ResolvePathOptions = ResolverPathParams & {
|
|
530
|
+
/**
|
|
531
|
+
* Absolute project root that the output path is resolved against.
|
|
532
|
+
*/
|
|
534
533
|
root: string;
|
|
534
|
+
/**
|
|
535
|
+
* Active output config; `output.path` is the base directory.
|
|
536
|
+
*/
|
|
535
537
|
output: Output;
|
|
538
|
+
/**
|
|
539
|
+
* Optional grouping strategy applied to `tag` (tag grouping) or `path` (path grouping).
|
|
540
|
+
*/
|
|
536
541
|
group?: Group;
|
|
537
542
|
};
|
|
538
543
|
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* ```ts
|
|
544
|
-
* resolver.default.file(
|
|
545
|
-
* { name: 'listPets', extname: '.ts', tag: 'pets' },
|
|
546
|
-
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
547
|
-
* )
|
|
548
|
-
* // → { baseName: 'listPets.ts', path: '/src/types/pets/listPets.ts', ... }
|
|
549
|
-
* ```
|
|
544
|
+
* The file request for `resolver.file` and `resolver.default.file`: the `name` and `extname` plus
|
|
545
|
+
* the optional `tag`/`path` that grouping keys off.
|
|
550
546
|
*/
|
|
551
547
|
type ResolverFileParams = {
|
|
552
548
|
name: string;
|
|
@@ -559,13 +555,68 @@ type ResolverFileParams = {
|
|
|
559
555
|
* Path value used when `group.type === 'path'`.
|
|
560
556
|
*/
|
|
561
557
|
path?: string;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* Options for `resolver.file` and `resolver.default.file`: the file request (`name`, `extname`,
|
|
561
|
+
* `tag`, `path`) plus where the output goes (`root`, `output`, `group`).
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```ts
|
|
565
|
+
* resolver.default.file({ name: 'listPets', extname: '.ts', tag: 'pets', root: '/src', output: { path: 'types' }, group: { type: 'tag' } })
|
|
566
|
+
* // → { baseName: 'listPets.ts', path: '/src/types/pets/listPets.ts', ... }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
type ResolveFileOptions = ResolverFileParams & {
|
|
570
|
+
root: string;
|
|
571
|
+
output: Output;
|
|
572
|
+
group?: Group;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* The `file` field of a resolver: decides what a generated file is called and, optionally, where
|
|
576
|
+
* it lives. This is how a resolver renames or relocates its files, replacing the older per-call
|
|
577
|
+
* `resolveName` hook.
|
|
578
|
+
*
|
|
579
|
+
* @example Suffix every generated file
|
|
580
|
+
* ```ts
|
|
581
|
+
* file: {
|
|
582
|
+
* baseName({ name, extname }) {
|
|
583
|
+
* return `${name}Faker${extname}`
|
|
584
|
+
* },
|
|
585
|
+
* }
|
|
586
|
+
* ```
|
|
587
|
+
*
|
|
588
|
+
* @example Own the full path
|
|
589
|
+
* ```ts
|
|
590
|
+
* file: {
|
|
591
|
+
* path({ baseName, output }) {
|
|
592
|
+
* return `${output.path}/mocks/${baseName}`
|
|
593
|
+
* },
|
|
594
|
+
* }
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
597
|
+
type ResolverFile = {
|
|
562
598
|
/**
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
|
|
599
|
+
* Builds the file's complete base name, extension included, from the identifier and the target
|
|
600
|
+
* `extname`. Defaults to `toFilePath(name)` with `extname` appended. Reaches sibling resolver
|
|
601
|
+
* helpers through `this`.
|
|
602
|
+
*/
|
|
603
|
+
baseName?(params: Pick<ResolverFileParams, 'name' | 'extname'>): FileNode['baseName'];
|
|
604
|
+
/**
|
|
605
|
+
* Returns the file's complete path, resolved against the project `root`. Bypasses `output.path`
|
|
606
|
+
* and `group`, so the resolver owns the layout. The returned path may not escape `root`. Reaches
|
|
607
|
+
* sibling resolver helpers through `this`.
|
|
567
608
|
*/
|
|
568
|
-
|
|
609
|
+
path?(params: ResolverFilePathParams): string;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* The argument to a resolver's `file.path`: the resolved `baseName` (what `file.baseName` produced,
|
|
613
|
+
* with the extension already appended) and the active `output`. `tag`, `path`, and `group` are
|
|
614
|
+
* omitted because `file.path` owns the whole path and bypasses grouping, and `root` because the
|
|
615
|
+
* returned path is resolved against it.
|
|
616
|
+
*/
|
|
617
|
+
type ResolverFilePathParams = {
|
|
618
|
+
baseName: FileNode['baseName'];
|
|
619
|
+
output: Output;
|
|
569
620
|
};
|
|
570
621
|
/**
|
|
571
622
|
* Per-file context describing the file a banner/footer is being resolved for, so a
|
|
@@ -631,17 +682,19 @@ type ResolveBannerContext = {
|
|
|
631
682
|
type ResolverBuildOptions = {
|
|
632
683
|
pluginName: string;
|
|
633
684
|
name?: (name: string) => string;
|
|
634
|
-
file?:
|
|
685
|
+
file?: ResolverFile;
|
|
635
686
|
[key: string]: unknown;
|
|
636
687
|
};
|
|
637
688
|
/**
|
|
638
689
|
* Partial resolver fields accepted by `Resolver.merge` and `setResolver`. Parameterize with a
|
|
639
|
-
* concrete resolver type (e.g. `ResolverPatch<ResolverTs>`) to type-check
|
|
640
|
-
*
|
|
690
|
+
* concrete resolver type (e.g. `ResolverPatch<ResolverTs>`) to type-check overrides and bind
|
|
691
|
+
* `this` to the full resolver. Namespaces are partial, so a patch may override a single method
|
|
692
|
+
* (`query.name`) and the rest keep the plugin defaults. Overriding a whole resolver is not the
|
|
693
|
+
* job of this patch, that is what a custom plugin is for.
|
|
641
694
|
*/
|
|
642
|
-
type ResolverPatch<T extends Resolver = Resolver> =
|
|
695
|
+
type ResolverPatch<T extends Resolver = Resolver> = { [K in keyof Omit<T, keyof Resolver>]?: T[K] extends ((...args: Array<never>) => unknown) ? T[K] : Partial<T[K]> } & {
|
|
643
696
|
name?: T['name'];
|
|
644
|
-
file?:
|
|
697
|
+
file?: ResolverFile;
|
|
645
698
|
} & ThisType<T>;
|
|
646
699
|
/**
|
|
647
700
|
* Base constraint for all plugin resolver objects.
|
|
@@ -677,10 +730,11 @@ declare class Resolver {
|
|
|
677
730
|
*/
|
|
678
731
|
get default(): ResolverDefault;
|
|
679
732
|
name(name: string): string;
|
|
680
|
-
file(
|
|
733
|
+
file(options: ResolveFileOptions): FileNode;
|
|
681
734
|
/**
|
|
682
|
-
* Merges `override` over `base` and returns a new resolver with helpers re-bound.
|
|
683
|
-
*
|
|
735
|
+
* Merges `override` over `base` and returns a new resolver with helpers re-bound. Top-level
|
|
736
|
+
* keys replace, and a namespace (or `file`) merges per method, so overriding `query.name`
|
|
737
|
+
* keeps the base `query.keyName`. Used when applying `setResolver` partial overrides.
|
|
684
738
|
*/
|
|
685
739
|
static merge<T extends Resolver>(base: T, override: ResolverPatch<T> | Resolver): T;
|
|
686
740
|
}
|
|
@@ -1377,11 +1431,7 @@ declare class KubbDriver {
|
|
|
1377
1431
|
* the failure as a {@link Diagnostic} instead of propagating. Each plugin also
|
|
1378
1432
|
* contributes a `timing` diagnostic for the run summary.
|
|
1379
1433
|
*/
|
|
1380
|
-
run({
|
|
1381
|
-
storage
|
|
1382
|
-
}: {
|
|
1383
|
-
storage: Storage;
|
|
1384
|
-
}): Promise<{
|
|
1434
|
+
run(): Promise<{
|
|
1385
1435
|
diagnostics: Array<Diagnostic>;
|
|
1386
1436
|
}>;
|
|
1387
1437
|
/**
|
|
@@ -1499,7 +1549,7 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1499
1549
|
* `ctx.resolver.name('pet') // 'pet'`
|
|
1500
1550
|
*
|
|
1501
1551
|
* @example Resolve an output file
|
|
1502
|
-
* `ctx.resolver.file({ name: 'pet', extname: '.ts'
|
|
1552
|
+
* `ctx.resolver.file({ name: 'pet', extname: '.ts', root, output })`
|
|
1503
1553
|
*/
|
|
1504
1554
|
resolver: TOptions['resolver'];
|
|
1505
1555
|
/**
|
|
@@ -2789,5 +2839,5 @@ declare class Diagnostics {
|
|
|
2789
2839
|
static formatLines(diagnostic: Diagnostic): Array<string>;
|
|
2790
2840
|
}
|
|
2791
2841
|
//#endregion
|
|
2792
|
-
export { Include as $, KubbHookStartContext as A,
|
|
2793
|
-
//# sourceMappingURL=Diagnostics-
|
|
2842
|
+
export { Include as $, KubbHookStartContext as A, Reporter as At, Kubb$1 as B, KubbFilesProcessingEndContext as C, ResolverPathParams as Ct, KubbGenerationStartContext as D, Storage as Dt, KubbGenerationEndContext as E, createRenderer as Et, KubbSuccessContext as F, logLevel as Ft, KubbDriver as G, Generator as H, KubbWarnContext as I, Adapter as It, Parser as J, FileManagerHooks as K, PossibleConfig as L, AdapterFactoryOptions as Lt, KubbInfoContext as M, ReporterName as Mt, KubbLifecycleStartContext as N, UserReporter as Nt, KubbHookEndContext as O, createStorage as Ot, KubbPluginsEndContext as P, createReporter as Pt, Group as Q, UserConfig as R, AdapterSource as Rt, KubbFileProcessingUpdate as S, ResolverPatch as St, KubbFilesProcessingUpdateContext as T, RendererFactory as Tt, GeneratorContext as U, createKubb as V, defineGenerator as W, Exclude$1 as X, defineParser as Y, Filter as Z, InputPath as _, Resolver as _t, DiagnosticLocation as a, OutputMode as at, KubbDiagnosticContext as b, ResolverFileParams as bt, PerformanceDiagnostic as c, Plugin as ct, SerializedDiagnostic as d, BannerMeta as dt, KubbPluginEndContext as et, UpdateDiagnostic as f, ResolveBannerContext as ft, InputData as g, ResolvePathOptions as gt, Config as h, ResolveOptionsContext as ht, DiagnosticKind as i, Output as it, KubbHooks as j, ReporterContext as jt, KubbHookLineContext as k, GenerationResult as kt, ProblemCode as l, PluginFactoryOptions as lt, CLIOptions as m, ResolveFileOptions as mt, DiagnosticByCode as n, KubbPluginStartContext as nt, DiagnosticSeverity as o, OutputOptions as ot, BuildOutput as p, ResolveBannerFile as pt, Hookable as q, DiagnosticDoc as r, NormalizedPlugin as rt, Diagnostics as s, Override as st, Diagnostic as t, KubbPluginSetupContext as tt, ProblemDiagnostic as u, definePlugin as ut, KubbBuildEndContext as v, ResolverDefault as vt, KubbFilesProcessingStartContext as w, Renderer as wt, KubbErrorContext as x, ResolverFilePathParams as xt, KubbBuildStartContext as y, ResolverFile as yt, CreateKubbOptions as z, createAdapter as zt };
|
|
2843
|
+
//# sourceMappingURL=Diagnostics-C2HF9H7A.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -172,7 +172,7 @@ function memoize(store, factory) {
|
|
|
172
172
|
}
|
|
173
173
|
//#endregion
|
|
174
174
|
//#region package.json
|
|
175
|
-
var version = "5.0.0-beta.
|
|
175
|
+
var version = "5.0.0-beta.88";
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/constants.ts
|
|
178
178
|
/**
|
|
@@ -747,6 +747,12 @@ function isNamespace(value) {
|
|
|
747
747
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
750
|
+
* Built-in `file.baseName`: casts the identifier with `toFilePath` and appends the extension.
|
|
751
|
+
*/
|
|
752
|
+
function toBaseName({ name, extname }) {
|
|
753
|
+
return `${require_usingCtx.toFilePath(name)}${extname}`;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
750
756
|
* Base constraint for all plugin resolver objects.
|
|
751
757
|
*
|
|
752
758
|
* The built-in machinery lives under `default`. Generators call the top-level `name` and
|
|
@@ -775,9 +781,13 @@ var Resolver = class Resolver {
|
|
|
775
781
|
static #optionsCache = /* @__PURE__ */ new WeakMap();
|
|
776
782
|
pluginName;
|
|
777
783
|
#options;
|
|
784
|
+
#baseName;
|
|
785
|
+
#filePath;
|
|
778
786
|
constructor(options) {
|
|
779
787
|
this.pluginName = options.pluginName;
|
|
780
788
|
this.#options = options;
|
|
789
|
+
this.#baseName = options.file?.baseName ? options.file.baseName.bind(this) : toBaseName;
|
|
790
|
+
this.#filePath = options.file?.path ? options.file.path.bind(this) : void 0;
|
|
781
791
|
this.#apply(options);
|
|
782
792
|
}
|
|
783
793
|
/**
|
|
@@ -797,19 +807,26 @@ var Resolver = class Resolver {
|
|
|
797
807
|
name(name) {
|
|
798
808
|
return this.default.name(name);
|
|
799
809
|
}
|
|
800
|
-
file(
|
|
801
|
-
return this
|
|
810
|
+
file(options) {
|
|
811
|
+
return this.#resolveFile(options);
|
|
802
812
|
}
|
|
803
813
|
/**
|
|
804
|
-
* Merges `override` over `base` and returns a new resolver with helpers re-bound.
|
|
805
|
-
*
|
|
814
|
+
* Merges `override` over `base` and returns a new resolver with helpers re-bound. Top-level
|
|
815
|
+
* keys replace, and a namespace (or `file`) merges per method, so overriding `query.name`
|
|
816
|
+
* keeps the base `query.keyName`. Used when applying `setResolver` partial overrides.
|
|
806
817
|
*/
|
|
807
818
|
static merge(base, override) {
|
|
808
819
|
const patch = override instanceof Resolver ? override.#options : override;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
820
|
+
const merged = { ...base.#options };
|
|
821
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
822
|
+
if (value === void 0) continue;
|
|
823
|
+
const current = merged[key];
|
|
824
|
+
merged[key] = isNamespace(value) && isNamespace(current) ? {
|
|
825
|
+
...current,
|
|
826
|
+
...value
|
|
827
|
+
} : value;
|
|
828
|
+
}
|
|
829
|
+
return new Resolver(merged);
|
|
813
830
|
}
|
|
814
831
|
/**
|
|
815
832
|
* Binds each entry of `options` onto the resolver, so `this.name`, `this.default`, and
|
|
@@ -820,7 +837,7 @@ var Resolver = class Resolver {
|
|
|
820
837
|
const root = this;
|
|
821
838
|
const bind = (value) => typeof value === "function" ? value.bind(root) : value;
|
|
822
839
|
for (const [key, value] of Object.entries(options)) {
|
|
823
|
-
if (key === "pluginName" || key === "default" || value === void 0) continue;
|
|
840
|
+
if (key === "pluginName" || key === "default" || key === "file" || value === void 0) continue;
|
|
824
841
|
root[key] = isNamespace(value) ? Object.fromEntries(Object.entries(value).map(([method, member]) => [method, bind(member)])) : bind(value);
|
|
825
842
|
}
|
|
826
843
|
}
|
|
@@ -905,7 +922,7 @@ var Resolver = class Resolver {
|
|
|
905
922
|
* to `output.path/{baseName}`, or into a subdirectory when `group` and a `tag`/`path` value
|
|
906
923
|
* are provided.
|
|
907
924
|
*/
|
|
908
|
-
#resolvePath({ baseName, tag, path: groupPath
|
|
925
|
+
#resolvePath({ baseName, tag, path: groupPath, root, output, group }) {
|
|
909
926
|
if (output.mode === "file") return node_path.default.resolve(root, output.path);
|
|
910
927
|
const outputDir = node_path.default.resolve(root, output.path);
|
|
911
928
|
const result = group && (groupPath || tag) ? node_path.default.resolve(outputDir, Resolver.#resolveGroupDir(group, group.type === "path" ? groupPath : tag), baseName) : node_path.default.resolve(outputDir, baseName);
|
|
@@ -920,17 +937,45 @@ var Resolver = class Resolver {
|
|
|
920
937
|
return result;
|
|
921
938
|
}
|
|
922
939
|
/**
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
*
|
|
940
|
+
* Resolves a resolver-supplied full path (`file.path`) against `root`, bypassing `output.path`
|
|
941
|
+
* and `group`. The path may not escape `root`, which keeps a `file.path` that interpolates
|
|
942
|
+
* spec-derived values from writing outside the project.
|
|
943
|
+
*/
|
|
944
|
+
#resolveOverridePath(filePath, root) {
|
|
945
|
+
const resolved = node_path.default.resolve(root, filePath);
|
|
946
|
+
const rootWithSep = root.endsWith(node_path.default.sep) ? root : `${root}${node_path.default.sep}`;
|
|
947
|
+
if (resolved !== root && !resolved.startsWith(rootWithSep)) throw new Diagnostics.Error({
|
|
948
|
+
code: Diagnostics.code.pathTraversal,
|
|
949
|
+
severity: "error",
|
|
950
|
+
message: `Resolved path "${resolved}" is outside the project root "${root}".`,
|
|
951
|
+
help: "A resolver `file.path` must return a path inside the project root.",
|
|
952
|
+
location: { kind: "config" }
|
|
953
|
+
});
|
|
954
|
+
return resolved;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Builds a `FileNode`. When `#filePath` (the resolver's `file.path`) is set it owns the whole
|
|
958
|
+
* path; otherwise the base name (from `#baseName`, the resolver's `file.baseName` or the
|
|
959
|
+
* built-in `toBaseName`) is placed by the `output.path`/`group` layout. The resolved file starts
|
|
960
|
+
* with empty `sources`, `imports`, and `exports`, which consumers populate separately.
|
|
926
961
|
*/
|
|
927
|
-
#resolveFile(
|
|
928
|
-
const
|
|
929
|
-
const
|
|
930
|
-
|
|
962
|
+
#resolveFile(options) {
|
|
963
|
+
const { name, extname, tag, path: groupPath, root, output, group } = options;
|
|
964
|
+
const baseName = this.#baseName({
|
|
965
|
+
name,
|
|
966
|
+
extname
|
|
967
|
+
});
|
|
968
|
+
const filePath = this.#filePath ? this.#resolveOverridePath(this.#filePath({
|
|
969
|
+
baseName,
|
|
970
|
+
output
|
|
971
|
+
}), root) : this.#resolvePath({
|
|
972
|
+
baseName,
|
|
931
973
|
tag,
|
|
932
|
-
path: groupPath
|
|
933
|
-
|
|
974
|
+
path: groupPath,
|
|
975
|
+
root,
|
|
976
|
+
output,
|
|
977
|
+
group
|
|
978
|
+
});
|
|
934
979
|
return _kubb_ast.ast.factory.createFile({
|
|
935
980
|
path: filePath,
|
|
936
981
|
baseName: node_path.default.basename(filePath),
|
|
@@ -1007,15 +1052,39 @@ var Resolver = class Resolver {
|
|
|
1007
1052
|
* (`query`, `schema`, …). Every method reaches sibling helpers and the built-in machinery
|
|
1008
1053
|
* through `this.name`, `this.file`, and `this.default`.
|
|
1009
1054
|
*
|
|
1010
|
-
* @example Custom identifier
|
|
1055
|
+
* @example Custom identifier casing
|
|
1011
1056
|
* ```ts
|
|
1012
1057
|
* export const resolverTs = createResolver<PluginTs>({
|
|
1013
1058
|
* pluginName: 'plugin-ts',
|
|
1014
1059
|
* name(name) {
|
|
1015
1060
|
* return ensureValidVarName(pascalCase(name))
|
|
1016
1061
|
* },
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1062
|
+
* })
|
|
1063
|
+
* ```
|
|
1064
|
+
*
|
|
1065
|
+
* @example Rename generated files with `file.baseName`
|
|
1066
|
+
* ```ts
|
|
1067
|
+
* export const resolverFaker = createResolver<PluginFaker>({
|
|
1068
|
+
* pluginName: 'plugin-faker',
|
|
1069
|
+
* name(name) {
|
|
1070
|
+
* return camelCase(name, { prefix: 'create' })
|
|
1071
|
+
* },
|
|
1072
|
+
* file: {
|
|
1073
|
+
* baseName({ name, extname }) {
|
|
1074
|
+
* return `${camelCase(name, { prefix: 'create' })}${extname}`
|
|
1075
|
+
* },
|
|
1076
|
+
* },
|
|
1077
|
+
* })
|
|
1078
|
+
* ```
|
|
1079
|
+
*
|
|
1080
|
+
* @example Own the full path with `file.path`
|
|
1081
|
+
* ```ts
|
|
1082
|
+
* export const resolverFaker = createResolver<PluginFaker>({
|
|
1083
|
+
* pluginName: 'plugin-faker',
|
|
1084
|
+
* file: {
|
|
1085
|
+
* path({ baseName, output }) {
|
|
1086
|
+
* return `${output.path}/mocks/${baseName}`
|
|
1087
|
+
* },
|
|
1019
1088
|
* },
|
|
1020
1089
|
* })
|
|
1021
1090
|
* ```
|
|
@@ -1326,7 +1395,7 @@ var KubbDriver = class {
|
|
|
1326
1395
|
* the failure as a {@link Diagnostic} instead of propagating. Each plugin also
|
|
1327
1396
|
* contributes a `timing` diagnostic for the run summary.
|
|
1328
1397
|
*/
|
|
1329
|
-
async run(
|
|
1398
|
+
async run() {
|
|
1330
1399
|
const { hooks, config, fileManager } = this;
|
|
1331
1400
|
const diagnostics = [];
|
|
1332
1401
|
const parsersMap = /* @__PURE__ */ new Map();
|
|
@@ -1408,7 +1477,7 @@ var KubbDriver = class {
|
|
|
1408
1477
|
diagnostics.push(...await this.#runGenerators(generatorPlugins));
|
|
1409
1478
|
await hooks.callHook("kubb:plugins:end", Object.assign({ config }, this.#filesPayload()));
|
|
1410
1479
|
await fileManager.write(fileManager.files, {
|
|
1411
|
-
storage,
|
|
1480
|
+
storage: config.storage,
|
|
1412
1481
|
parsers: parsersMap,
|
|
1413
1482
|
extension: config.output.extension
|
|
1414
1483
|
});
|
|
@@ -1976,7 +2045,7 @@ var Kubb = class {
|
|
|
1976
2045
|
const self = _usingCtx$1.u(this);
|
|
1977
2046
|
const driver = self.driver;
|
|
1978
2047
|
const storage = self.storage;
|
|
1979
|
-
const { diagnostics } = await driver.run(
|
|
2048
|
+
const { diagnostics } = await driver.run();
|
|
1980
2049
|
return {
|
|
1981
2050
|
diagnostics,
|
|
1982
2051
|
files: driver.fileManager.files,
|