@kubb/core 5.5.6 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +649 -301
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +175 -4
- package/dist/index.js +593 -247
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +30 -47
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +24 -41
- package/dist/mocks.js.map +1 -1
- package/dist/{usingCtx-C_vhSf7M.cjs → nodeCache-CllHsCcy.cjs} +101 -222
- package/dist/nodeCache-CllHsCcy.cjs.map +1 -0
- package/dist/{usingCtx-DdG2edpx.js → nodeCache-CumrOPh-.js} +101 -216
- package/dist/nodeCache-CumrOPh-.js.map +1 -0
- package/dist/{types-DNE8KVDT.d.ts → types-B-w6zShf.d.ts} +66 -296
- package/package.json +3 -2
- package/dist/usingCtx-C_vhSf7M.cjs.map +0 -1
- package/dist/usingCtx-DdG2edpx.js.map +0 -1
|
@@ -289,7 +289,7 @@ declare class Hookable<THooks extends { [K in keyof THooks]: Array<unknown>; }>
|
|
|
289
289
|
constructor(maxListener?: number);
|
|
290
290
|
/**
|
|
291
291
|
* Calls `hookName` and awaits all registered listeners sequentially.
|
|
292
|
-
* Throws if any listener rejects, wrapping the cause
|
|
292
|
+
* Throws if any listener rejects, wrapping the cause in an error that names the hook.
|
|
293
293
|
*
|
|
294
294
|
* @example
|
|
295
295
|
* ```ts
|
|
@@ -1000,16 +1000,8 @@ type ResolverDefault = {
|
|
|
1000
1000
|
* The name request for `resolver.default.path`: a `baseName` plus the optional `tag`/`path` that
|
|
1001
1001
|
* grouping keys off.
|
|
1002
1002
|
*/
|
|
1003
|
-
type ResolverPathParams = {
|
|
1003
|
+
type ResolverPathParams = Omit<ResolverFileParams, 'name' | 'extname'> & {
|
|
1004
1004
|
baseName: FileNode['baseName'];
|
|
1005
|
-
/**
|
|
1006
|
-
* Tag value used when `group.type === 'tag'`.
|
|
1007
|
-
*/
|
|
1008
|
-
tag?: string;
|
|
1009
|
-
/**
|
|
1010
|
-
* Path value used when `group.type === 'path'`.
|
|
1011
|
-
*/
|
|
1012
|
-
path?: string;
|
|
1013
1005
|
};
|
|
1014
1006
|
/**
|
|
1015
1007
|
* Options for `resolver.default.path`: the name request (`baseName`, `tag`, `path`) plus where the
|
|
@@ -1256,14 +1248,11 @@ declare const resolverOptions: unique symbol;
|
|
|
1256
1248
|
declare class Resolver {
|
|
1257
1249
|
#private;
|
|
1258
1250
|
readonly pluginName: string;
|
|
1251
|
+
/** The built-in machinery, untouched by `name`/`file` overrides and built once since the driver reads it per node. */
|
|
1252
|
+
readonly default: ResolverDefault;
|
|
1259
1253
|
constructor(options: ResolverBuildOptions);
|
|
1260
1254
|
/** Exposes the raw build options so `Resolver.merge` can read them across `@kubb/core` copies. */
|
|
1261
1255
|
get [resolverOptions](): ResolverBuildOptions;
|
|
1262
|
-
/**
|
|
1263
|
-
* The built-in resolution machinery. Always reaches the untouched defaults, even when a
|
|
1264
|
-
* plugin overrides the top-level `name` or `file`.
|
|
1265
|
-
*/
|
|
1266
|
-
get default(): ResolverDefault;
|
|
1267
1256
|
name(name: string): string;
|
|
1268
1257
|
file(options: ResolveFileOptions): FileNode;
|
|
1269
1258
|
/**
|
|
@@ -1296,7 +1285,8 @@ declare class Resolver {
|
|
|
1296
1285
|
}
|
|
1297
1286
|
//#endregion
|
|
1298
1287
|
//#region src/definePlugin.d.ts
|
|
1299
|
-
|
|
1288
|
+
/** Reads key `K` from a registry interface, or `{}` when no package has augmented it. @internal */
|
|
1289
|
+
type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
|
|
1300
1290
|
/**
|
|
1301
1291
|
* A plugin name as accepted by `getPlugin`/`requirePlugin`/`getResolver`. Registered names from
|
|
1302
1292
|
* `Kubb.PluginRegistry` autocomplete, and any other string is still allowed.
|
|
@@ -1350,7 +1340,7 @@ type Output = {
|
|
|
1350
1340
|
* Pass a function to compute the footer from the file's `BannerMeta`.
|
|
1351
1341
|
*/
|
|
1352
1342
|
footer?: string | ((meta: BannerMeta) => string);
|
|
1353
|
-
} & ExtractRegistryKey
|
|
1343
|
+
} & ExtractRegistryKey<Kubb.PluginOptionsRegistry, 'output'>;
|
|
1354
1344
|
/**
|
|
1355
1345
|
* Groups generated files into subdirectories based on an OpenAPI tag or path
|
|
1356
1346
|
* segment.
|
|
@@ -1364,7 +1354,7 @@ type Group = {
|
|
|
1364
1354
|
type: 'tag' | 'path';
|
|
1365
1355
|
/**
|
|
1366
1356
|
* Returns the subdirectory name from the group key. Defaults to the camelCased tag for
|
|
1367
|
-
* `tag` groups, or the
|
|
1357
|
+
* `tag` groups, or the first path segment as written in the spec for `path` groups.
|
|
1368
1358
|
*/
|
|
1369
1359
|
name?: (context: {
|
|
1370
1360
|
group: string;
|
|
@@ -1655,21 +1645,12 @@ type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1655
1645
|
type KubbPluginStartContext = {
|
|
1656
1646
|
plugin: NormalizedPlugin;
|
|
1657
1647
|
};
|
|
1658
|
-
type KubbPluginEndContext = {
|
|
1648
|
+
type KubbPluginEndContext = FilesContext & {
|
|
1659
1649
|
plugin: NormalizedPlugin;
|
|
1660
1650
|
duration: number;
|
|
1661
1651
|
success: boolean;
|
|
1662
1652
|
error?: Error;
|
|
1663
1653
|
config: Config;
|
|
1664
|
-
/**
|
|
1665
|
-
* Returns all files currently in the file manager (lazy snapshot).
|
|
1666
|
-
* Includes files added by plugins that have already run.
|
|
1667
|
-
*/
|
|
1668
|
-
readonly files: ReadonlyArray<FileNode>;
|
|
1669
|
-
/**
|
|
1670
|
-
* Upsert one or more files into the file manager.
|
|
1671
|
-
*/
|
|
1672
|
-
upsertFile: (...files: Array<FileNode>) => void;
|
|
1673
1654
|
};
|
|
1674
1655
|
/**
|
|
1675
1656
|
* Wraps a plugin factory and returns a function that accepts user options and
|
|
@@ -1838,7 +1819,11 @@ declare class FileManager {
|
|
|
1838
1819
|
readonly hooks: Hookable<FileManagerHooks>;
|
|
1839
1820
|
add(...files: Array<FileNode>): Array<FileNode>;
|
|
1840
1821
|
upsert(...files: Array<FileNode>): Array<FileNode>;
|
|
1841
|
-
|
|
1822
|
+
/** Stores a generator result: a file array is upserted as is, an element renders through `renderer` first, falsy is a no-op. */
|
|
1823
|
+
dispatch<TElement = unknown>({ result, renderer }: {
|
|
1824
|
+
result: TElement | Array<FileNode> | undefined | null;
|
|
1825
|
+
renderer?: RendererFactory<TElement> | null;
|
|
1826
|
+
}): Promise<void>;
|
|
1842
1827
|
/**
|
|
1843
1828
|
* Releases all stored files and clears every `hooks` listener. Called by the core after
|
|
1844
1829
|
* `kubb:build:end`.
|
|
@@ -1914,25 +1899,7 @@ declare class KubbDriver {
|
|
|
1914
1899
|
* plugins can configure generators, resolvers, macros, and options before `buildStart`.
|
|
1915
1900
|
*/
|
|
1916
1901
|
setupHooks(): Promise<void>;
|
|
1917
|
-
/**
|
|
1918
|
-
* Appends a generator to its owning plugin so the generate loop can call it directly.
|
|
1919
|
-
*
|
|
1920
|
-
* The generator's `schema`, `operation`, and `operations` methods run per node during the AST
|
|
1921
|
-
* walk in `#runGenerators`, and their result is routed through `dispatch`. Because a generator is
|
|
1922
|
-
* bound to a plugin, generators from different plugins never cross-fire without a name check. The
|
|
1923
|
-
* renderer comes from `generator.renderer`; set it to `null` (or leave it unset) to opt out of
|
|
1924
|
-
* rendering.
|
|
1925
|
-
*
|
|
1926
|
-
* Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
|
|
1927
|
-
*/
|
|
1928
|
-
registerGenerator(pluginName: string, generator: Generator): void;
|
|
1929
|
-
/**
|
|
1930
|
-
* Returns `true` when at least one generator was registered for the given plugin
|
|
1931
|
-
* via `addGenerator()` in `kubb:plugin:setup`.
|
|
1932
|
-
*
|
|
1933
|
-
* Used by the build loop to decide whether to walk the AST and run the generators
|
|
1934
|
-
* for a plugin.
|
|
1935
|
-
*/
|
|
1902
|
+
/** `true` once `addGenerator()` in `kubb:plugin:setup` registered a generator for the plugin. */
|
|
1936
1903
|
hasHookGenerators(pluginName: string): boolean;
|
|
1937
1904
|
/**
|
|
1938
1905
|
* Runs the full plugin pipeline. Returns the diagnostics collected so far even
|
|
@@ -1943,19 +1910,8 @@ declare class KubbDriver {
|
|
|
1943
1910
|
run(): Promise<{
|
|
1944
1911
|
diagnostics: Array<Diagnostic>;
|
|
1945
1912
|
}>;
|
|
1946
|
-
/**
|
|
1947
|
-
|
|
1948
|
-
*
|
|
1949
|
-
* - An `Array<FileNode>` goes straight into `fileManager` via `upsert`.
|
|
1950
|
-
* - A renderer element runs through `renderer` (the renderer factory, e.g. JSX) and the
|
|
1951
|
-
* produced files go to `fileManager.upsert`.
|
|
1952
|
-
* - A falsy result is treated as a no-op. The generator wrote files itself via
|
|
1953
|
-
* `ctx.upsertFile`.
|
|
1954
|
-
*
|
|
1955
|
-
* Pass `renderer` when the result may be a renderer element. Generators that only return
|
|
1956
|
-
* `Array<FileNode>` do not need one.
|
|
1957
|
-
*/
|
|
1958
|
-
dispatch<TElement = unknown>({ result, renderer }: {
|
|
1913
|
+
/** Stores whatever a generator method or `kubb:generate:*` hook returned, see {@link FileManager.dispatch}. */
|
|
1914
|
+
dispatch<TElement = unknown>(params: {
|
|
1959
1915
|
result: TElement | Array<FileNode> | undefined | null;
|
|
1960
1916
|
renderer?: RendererFactory<TElement> | null;
|
|
1961
1917
|
}): Promise<void>;
|
|
@@ -1967,16 +1923,7 @@ declare class KubbDriver {
|
|
|
1967
1923
|
*/
|
|
1968
1924
|
dispose(): void;
|
|
1969
1925
|
[Symbol.dispose](): void;
|
|
1970
|
-
/**
|
|
1971
|
-
* Merges `partial` onto a fresh default resolver and stores the result on `plugin.resolver`,
|
|
1972
|
-
* which is the single source `getResolver` and `getPlugin(name).resolver` both read.
|
|
1973
|
-
*/
|
|
1974
|
-
setPluginResolver(pluginName: string, partial: ResolverPatch | Resolver): void;
|
|
1975
|
-
/**
|
|
1976
|
-
* Returns the resolver for the given plugin. It reads `plugin.resolver` (seeded with the default
|
|
1977
|
-
* at registration and replaced by `setPluginResolver`), falling back to a fresh default for a
|
|
1978
|
-
* name that is not a registered plugin.
|
|
1979
|
-
*/
|
|
1926
|
+
/** Reads `plugin.resolver`, falling back to a fresh default for a name that is not a registered plugin. */
|
|
1980
1927
|
getResolver<TName extends PluginName>(pluginName: TName): ResolvePluginOptions<TName>['resolver'];
|
|
1981
1928
|
getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options' | 'cache'>;
|
|
1982
1929
|
getPlugin<TName extends PluginName>(pluginName: TName): Plugin<ResolvePluginOptions<TName>> | undefined;
|
|
@@ -2241,160 +2188,40 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TEl
|
|
|
2241
2188
|
*/
|
|
2242
2189
|
declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
|
|
2243
2190
|
//#endregion
|
|
2244
|
-
//#region src/
|
|
2245
|
-
type CreateKubbOptions = {
|
|
2246
|
-
/**
|
|
2247
|
-
* Receives Kubb lifecycle hooks for the run.
|
|
2248
|
-
*/
|
|
2249
|
-
hooks?: Hookable<KubbHooks>;
|
|
2250
|
-
/**
|
|
2251
|
-
* Stops the build at the next safe checkpoint.
|
|
2252
|
-
*/
|
|
2253
|
-
signal?: AbortSignal;
|
|
2254
|
-
};
|
|
2191
|
+
//#region src/output/runHook.d.ts
|
|
2255
2192
|
/**
|
|
2256
|
-
*
|
|
2257
|
-
* `kubb:*` lifecycle hooks on `.hooks`, so hosts subscribe there rather than pass a callback.
|
|
2193
|
+
* Outcome of one hook subprocess, also carried by the `kubb:hook:end` hook it emits.
|
|
2258
2194
|
*/
|
|
2259
|
-
type
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
}) => Promise<Array<Diagnostic>>;
|
|
2195
|
+
type HookResult = {
|
|
2196
|
+
success: true;
|
|
2197
|
+
error: null;
|
|
2198
|
+
} | {
|
|
2199
|
+
success: false;
|
|
2200
|
+
error: Error;
|
|
2201
|
+
stdout?: string;
|
|
2202
|
+
stderr?: string;
|
|
2268
2203
|
};
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
*/
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
*/
|
|
2280
|
-
files: Array<FileNode>;
|
|
2281
|
-
/**
|
|
2282
|
-
* Build diagnostics plus any collected from the output passes.
|
|
2283
|
-
*/
|
|
2284
|
-
diagnostics: Array<Diagnostic>;
|
|
2204
|
+
type RunHookOptions = {
|
|
2205
|
+
hooks: Hookable<KubbHooks>;
|
|
2206
|
+
/** Executable to run, resolved on `PATH` and in every `node_modules/.bin` above `cwd`. */
|
|
2207
|
+
command: string;
|
|
2208
|
+
args?: ReadonlyArray<string>;
|
|
2209
|
+
/** Label shown instead of the command line, for example a `postGenerate` step name. */
|
|
2210
|
+
name?: string;
|
|
2211
|
+
/** Working directory for the command. Defaults to the current process directory. */
|
|
2212
|
+
cwd?: string;
|
|
2213
|
+
signal?: AbortSignal;
|
|
2285
2214
|
};
|
|
2286
2215
|
/**
|
|
2287
|
-
*
|
|
2288
|
-
*
|
|
2289
|
-
* `
|
|
2290
|
-
*
|
|
2291
|
-
* `
|
|
2292
|
-
* not a fluent builder.
|
|
2293
|
-
*
|
|
2294
|
-
* Attach hook listeners to `.hooks` before calling `setup()` or `build()`.
|
|
2295
|
-
*
|
|
2296
|
-
* @example
|
|
2297
|
-
* ```ts
|
|
2298
|
-
* const kubb = createKubb(userConfig)
|
|
2299
|
-
* kubb.hooks.hook('kubb:plugin:end', ({ plugin, duration }) => console.log(plugin.name, duration))
|
|
2300
|
-
* const { files, diagnostics } = await kubb.safeBuild()
|
|
2301
|
-
* ```
|
|
2216
|
+
* Spawns a command and returns its outcome, announcing it through `kubb:hook:start`,
|
|
2217
|
+
* `kubb:hook:line` (one per stdout or stderr line, only while a listener is attached) and
|
|
2218
|
+
* `kubb:hook:end`. A non-zero exit, a spawn failure, an abort or a throwing line listener returns
|
|
2219
|
+
* `success: false` instead of throwing. The failure travels on the result and `kubb:hook:end`
|
|
2220
|
+
* only, and the caller emits `kubb:success` or a diagnostic, so nothing is reported twice.
|
|
2302
2221
|
*/
|
|
2303
|
-
declare
|
|
2304
|
-
#private;
|
|
2305
|
-
readonly hooks: Hookable<KubbHooks>;
|
|
2306
|
-
readonly config: Config;
|
|
2307
|
-
constructor(userConfig: UserConfig, options?: CreateKubbOptions);
|
|
2308
|
-
get storage(): Storage;
|
|
2309
|
-
get driver(): KubbDriver;
|
|
2310
|
-
/**
|
|
2311
|
-
* Initializes the driver and storage. `build()` calls this automatically.
|
|
2312
|
-
*/
|
|
2313
|
-
setup(): Promise<void>;
|
|
2314
|
-
/**
|
|
2315
|
-
* Runs the full pipeline and throws on any plugin error.
|
|
2316
|
-
* Automatically calls `setup()` if needed.
|
|
2317
|
-
*/
|
|
2318
|
-
build(): Promise<BuildOutput>;
|
|
2319
|
-
/**
|
|
2320
|
-
* Runs the full pipeline and captures errors in `BuildOutput` instead of throwing.
|
|
2321
|
-
* Automatically calls `setup()` if needed. This is the canonical call: it never throws on
|
|
2322
|
-
* plugin errors, so callers stay in control of how failures surface.
|
|
2323
|
-
*/
|
|
2324
|
-
safeBuild(): Promise<BuildOutput>;
|
|
2325
|
-
/**
|
|
2326
|
-
* Run one build and its output passes end to end, emitting the surrounding `kubb:generation:*`
|
|
2327
|
-
* hooks. Never throws on a build error: the outcome comes back in {@link GenerateResult} so the
|
|
2328
|
-
* host decides how failures surface. Telemetry and progress narration stay with the host, which
|
|
2329
|
-
* reads the result and subscribes to the `kubb:*` hooks.
|
|
2330
|
-
*
|
|
2331
|
-
* @example
|
|
2332
|
-
* ```ts
|
|
2333
|
-
* const result = await createKubb(config, { hooks }).generate()
|
|
2334
|
-
* if (!result.success) process.exitCode = 1
|
|
2335
|
-
* ```
|
|
2336
|
-
*/
|
|
2337
|
-
generate(options?: GenerateOptions): Promise<GenerateResult>;
|
|
2338
|
-
dispose(): void;
|
|
2339
|
-
[Symbol.dispose](): void;
|
|
2340
|
-
}
|
|
2341
|
-
/**
|
|
2342
|
-
* Constructs a {@link Kubb} build orchestrator from a user config. Equivalent
|
|
2343
|
-
* to `new Kubb(userConfig, options)` and the canonical public entry point.
|
|
2344
|
-
*
|
|
2345
|
-
* @example
|
|
2346
|
-
* ```ts
|
|
2347
|
-
* import { createKubb } from '@kubb/core'
|
|
2348
|
-
* import { adapterOas } from '@kubb/adapter-oas'
|
|
2349
|
-
* import { pluginTs } from '@kubb/plugin-ts'
|
|
2350
|
-
*
|
|
2351
|
-
* const kubb = createKubb({
|
|
2352
|
-
* input: './petStore.yaml',
|
|
2353
|
-
* output: { path: './src/gen' },
|
|
2354
|
-
* adapter: adapterOas(),
|
|
2355
|
-
* plugins: [pluginTs()],
|
|
2356
|
-
* })
|
|
2357
|
-
*
|
|
2358
|
-
* await kubb.build()
|
|
2359
|
-
* ```
|
|
2360
|
-
*/
|
|
2361
|
-
declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb$1;
|
|
2362
|
-
//#endregion
|
|
2363
|
-
//#region src/reporters/summary.d.ts
|
|
2364
|
-
/**
|
|
2365
|
-
* Writes a finished summary. The `cli` reporter formats the lines and hands them to one of these,
|
|
2366
|
-
* so the caller decides where they land: plain `console.log` by default, or the active logger's own
|
|
2367
|
-
* output when a host installs one.
|
|
2368
|
-
*/
|
|
2369
|
-
type SummaryRenderer = (lines: ReadonlyArray<string>, meta: {
|
|
2370
|
-
title: string;
|
|
2371
|
-
status: 'success' | 'failed';
|
|
2372
|
-
}) => void;
|
|
2373
|
-
//#endregion
|
|
2374
|
-
//#region src/input.d.ts
|
|
2375
|
-
/**
|
|
2376
|
-
* What an `input` value points at, once Kubb has looked at it.
|
|
2377
|
-
*
|
|
2378
|
-
* - `file` is a local file path, absolute or relative to the config file.
|
|
2379
|
-
* - `url` is a remote document to fetch.
|
|
2380
|
-
* - `inline` is OpenAPI content held in the string itself (JSON or YAML).
|
|
2381
|
-
* - `object` is an already-parsed spec.
|
|
2382
|
-
*/
|
|
2383
|
-
type InputKind = 'file' | 'url' | 'inline' | 'object';
|
|
2384
|
-
/**
|
|
2385
|
-
* Classifies an `input` value so callers branch on it once instead of repeating the checks.
|
|
2386
|
-
*
|
|
2387
|
-
* A non-string is a parsed spec (`object`). A string is `inline` when it holds OpenAPI content,
|
|
2388
|
-
* meaning it starts with `{` or `[`, spans multiple lines, or opens with a YAML `openapi:` or
|
|
2389
|
-
* `swagger:` key. Otherwise a string is a `url` when it parses as one, or a `file` path.
|
|
2390
|
-
*/
|
|
2391
|
-
declare function getInputKind(input: NonNullable<Input>): InputKind;
|
|
2222
|
+
declare function runHook({ hooks, command, args, name, cwd, signal }: RunHookOptions): Promise<HookResult>;
|
|
2392
2223
|
//#endregion
|
|
2393
2224
|
//#region src/types.d.ts
|
|
2394
|
-
/**
|
|
2395
|
-
* @internal
|
|
2396
|
-
*/
|
|
2397
|
-
type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
|
|
2398
2225
|
/**
|
|
2399
2226
|
* Source to generate from. Kubb detects what it was given:
|
|
2400
2227
|
*
|
|
@@ -2550,13 +2377,13 @@ type Config<TInput = Input> = {
|
|
|
2550
2377
|
postGenerate?: Array<PostGenerateCommand>;
|
|
2551
2378
|
/**
|
|
2552
2379
|
* Banner prepended to every generated file. `'simple'` is the basic Kubb notice, `'full'` adds
|
|
2553
|
-
* source, title,
|
|
2380
|
+
* source, title, and OpenAPI spec version, and `false` omits it.
|
|
2554
2381
|
*
|
|
2555
2382
|
* @default 'simple'
|
|
2556
2383
|
* @example
|
|
2557
2384
|
* ```ts
|
|
2558
|
-
* defaultBanner: 'simple' // "
|
|
2559
|
-
* defaultBanner: 'full' // adds source, title,
|
|
2385
|
+
* defaultBanner: 'simple' // "Generated by Kubb (https://kubb.dev/). Do not edit manually."
|
|
2386
|
+
* defaultBanner: 'full' // adds source, title, and OpenAPI spec version
|
|
2560
2387
|
* defaultBanner: false // no banner
|
|
2561
2388
|
* ```
|
|
2562
2389
|
*/
|
|
@@ -2800,7 +2627,14 @@ declare global {
|
|
|
2800
2627
|
* ```
|
|
2801
2628
|
*/
|
|
2802
2629
|
type KubbHooks = Kubb.KubbHooksRegistry;
|
|
2803
|
-
|
|
2630
|
+
/** The file access every file-carrying hook context shares: a lazy snapshot of the files so far, and a way to add more. */
|
|
2631
|
+
type FilesContext = {
|
|
2632
|
+
/** Snapshot of all files accumulated so far, including those added by plugins that already ran. */
|
|
2633
|
+
readonly files: ReadonlyArray<FileNode>;
|
|
2634
|
+
/** Adds or merges one or more files into the file manager. */
|
|
2635
|
+
upsertFile: (...files: Array<FileNode>) => void;
|
|
2636
|
+
};
|
|
2637
|
+
type KubbBuildStartContext = FilesContext & {
|
|
2804
2638
|
/**
|
|
2805
2639
|
* Resolved configuration for this build.
|
|
2806
2640
|
*/
|
|
@@ -2818,28 +2652,12 @@ type KubbBuildStartContext = {
|
|
|
2818
2652
|
* Looks up a registered plugin by name, typed by the plugin registry.
|
|
2819
2653
|
*/
|
|
2820
2654
|
getPlugin<TName extends PluginName>(name: TName): Plugin<ResolvePluginOptions<TName>> | undefined;
|
|
2821
|
-
/**
|
|
2822
|
-
* Snapshot of all files accumulated so far.
|
|
2823
|
-
*/
|
|
2824
|
-
readonly files: ReadonlyArray<FileNode>;
|
|
2825
|
-
/**
|
|
2826
|
-
* Adds or merges one or more files into the file manager.
|
|
2827
|
-
*/
|
|
2828
|
-
upsertFile: (...files: Array<FileNode>) => void;
|
|
2829
2655
|
};
|
|
2830
|
-
type KubbPluginsEndContext = {
|
|
2656
|
+
type KubbPluginsEndContext = FilesContext & {
|
|
2831
2657
|
/**
|
|
2832
2658
|
* Resolved configuration for this build.
|
|
2833
2659
|
*/
|
|
2834
2660
|
config: Config;
|
|
2835
|
-
/**
|
|
2836
|
-
* Snapshot of all files accumulated across all plugins.
|
|
2837
|
-
*/
|
|
2838
|
-
readonly files: ReadonlyArray<FileNode>;
|
|
2839
|
-
/**
|
|
2840
|
-
* Adds or merges one or more files into the file manager.
|
|
2841
|
-
*/
|
|
2842
|
-
upsertFile: (...files: Array<FileNode>) => void;
|
|
2843
2661
|
};
|
|
2844
2662
|
type KubbBuildEndContext = {
|
|
2845
2663
|
/**
|
|
@@ -2906,9 +2724,10 @@ type KubbGenerationEndContext = {
|
|
|
2906
2724
|
*/
|
|
2907
2725
|
filesCreated?: number;
|
|
2908
2726
|
};
|
|
2909
|
-
|
|
2727
|
+
/** A human-readable message with optional detail, as carried by `kubb:info`, `kubb:success`, and `kubb:warn`. */
|
|
2728
|
+
type KubbMessageContext = {
|
|
2910
2729
|
/**
|
|
2911
|
-
* Human-readable
|
|
2730
|
+
* Human-readable message.
|
|
2912
2731
|
*/
|
|
2913
2732
|
message: string;
|
|
2914
2733
|
/**
|
|
@@ -2916,6 +2735,9 @@ type KubbInfoContext = {
|
|
|
2916
2735
|
*/
|
|
2917
2736
|
info?: string;
|
|
2918
2737
|
};
|
|
2738
|
+
type KubbInfoContext = KubbMessageContext;
|
|
2739
|
+
type KubbSuccessContext = KubbMessageContext;
|
|
2740
|
+
type KubbWarnContext = KubbMessageContext;
|
|
2919
2741
|
type KubbErrorContext = {
|
|
2920
2742
|
/**
|
|
2921
2743
|
* The caught error.
|
|
@@ -2926,26 +2748,6 @@ type KubbErrorContext = {
|
|
|
2926
2748
|
*/
|
|
2927
2749
|
meta?: Record<string, unknown>;
|
|
2928
2750
|
};
|
|
2929
|
-
type KubbSuccessContext = {
|
|
2930
|
-
/**
|
|
2931
|
-
* Human-readable success message.
|
|
2932
|
-
*/
|
|
2933
|
-
message: string;
|
|
2934
|
-
/**
|
|
2935
|
-
* Optional supplementary detail.
|
|
2936
|
-
*/
|
|
2937
|
-
info?: string;
|
|
2938
|
-
};
|
|
2939
|
-
type KubbWarnContext = {
|
|
2940
|
-
/**
|
|
2941
|
-
* Human-readable warning message.
|
|
2942
|
-
*/
|
|
2943
|
-
message: string;
|
|
2944
|
-
/**
|
|
2945
|
-
* Optional supplementary detail.
|
|
2946
|
-
*/
|
|
2947
|
-
info?: string;
|
|
2948
|
-
};
|
|
2949
2751
|
type KubbDiagnosticContext = {
|
|
2950
2752
|
/**
|
|
2951
2753
|
* The structured diagnostic to render: a build problem or a version-update notice.
|
|
@@ -3030,40 +2832,8 @@ type KubbHookLineContext = {
|
|
|
3030
2832
|
*/
|
|
3031
2833
|
line: string;
|
|
3032
2834
|
};
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
* Optional identifier matching the corresponding `kubb:hook:start` hook.
|
|
3036
|
-
*/
|
|
3037
|
-
id?: string;
|
|
3038
|
-
/**
|
|
3039
|
-
* The shell command that ran.
|
|
3040
|
-
*/
|
|
3041
|
-
command: string;
|
|
3042
|
-
/**
|
|
3043
|
-
* Optional label for the command, shown in the CLI output when set.
|
|
3044
|
-
*/
|
|
3045
|
-
name?: string;
|
|
3046
|
-
/**
|
|
3047
|
-
* Parsed argument list, when available.
|
|
3048
|
-
*/
|
|
3049
|
-
args?: ReadonlyArray<string>;
|
|
3050
|
-
/**
|
|
3051
|
-
* `true` when the command exited with code `0`.
|
|
3052
|
-
*/
|
|
3053
|
-
success: boolean;
|
|
3054
|
-
/**
|
|
3055
|
-
* Error thrown by the command, or `null` on success.
|
|
3056
|
-
*/
|
|
3057
|
-
error: Error | null;
|
|
3058
|
-
/**
|
|
3059
|
-
* Captured stdout from the process, populated when it exits non-zero.
|
|
3060
|
-
*/
|
|
3061
|
-
stdout?: string;
|
|
3062
|
-
/**
|
|
3063
|
-
* Captured stderr from the process, populated when it exits non-zero.
|
|
3064
|
-
*/
|
|
3065
|
-
stderr?: string;
|
|
3066
|
-
};
|
|
2835
|
+
/** Emitted when a hook subprocess ends: its `kubb:hook:start` context plus the outcome. */
|
|
2836
|
+
type KubbHookEndContext = KubbHookStartContext & HookResult;
|
|
3067
2837
|
/**
|
|
3068
2838
|
* CLI options derived from command-line flags.
|
|
3069
2839
|
*/
|
|
@@ -3126,5 +2896,5 @@ type BuildOutput = {
|
|
|
3126
2896
|
storage: Storage;
|
|
3127
2897
|
};
|
|
3128
2898
|
//#endregion
|
|
3129
|
-
export {
|
|
3130
|
-
//# sourceMappingURL=types-
|
|
2899
|
+
export { Plugin as $, HookResult as A, logLevel as At, defineParser as B, SerializedDiagnostic as Bt, KubbMessageContext as C, GenerationResult as Ct, PossibleConfig as D, ReporterPluginFiles as Dt, KubbWarnContext as E, ReporterName as Et, defineGenerator as F, DiagnosticSeverity as Ft, KubbPluginEndContext as G, AdapterSource as Gt, Filter as H, Hookable as Ht, NodeCache as I, Diagnostics as It, NormalizedPlugin as J, KubbPluginSetupContext as K, createAdapter as Kt, KubbDriver as L, PerformanceDiagnostic as Lt, runHook as M, DiagnosticDoc as Mt, Generator as N, DiagnosticKind as Nt, PostGenerateCommand as O, UserReporter as Ot, GeneratorContext as P, DiagnosticLocation as Pt, Override as Q, FileManagerHooks as R, ProblemCode as Rt, KubbLifecycleStartContext as S, createStorage as St, KubbSuccessContext as T, ReporterContext as Tt, Group as U, Adapter as Ut, Exclude$1 as V, UpdateDiagnostic as Vt, Include as W, AdapterFactoryOptions as Wt, OutputMode as X, Output as Y, OutputOptions as Z, KubbHookEndContext as _, ResolverPathParams as _t, Input as a, ResolveBannerContext as at, KubbHooks as b, createRenderer as bt, KubbDiagnosticContext as c, ResolveImportsOptions as ct, KubbFilesProcessingEndContext as d, Resolver as dt, PluginFactoryOptions as et, KubbFilesProcessingStartContext as f, ResolverDefault as ft, KubbGenerationSummaryContext as g, ResolverPatch as gt, KubbGenerationStartContext as h, ResolverFilePathParams as ht, FilesContext as i, BannerMeta as it, RunHookOptions as j, Diagnostic as jt, UserConfig as k, createReporter as kt, KubbErrorContext as l, ResolveOptionsContext as lt, KubbGenerationEndContext as m, ResolverFileParams as mt, CLIOptions as n, ResolvePluginOptions as nt, KubbBuildEndContext as o, ResolveBannerFile as ot, KubbFilesProcessingUpdateContext as p, ResolverFile as pt, KubbPluginStartContext as q, Config as r, definePlugin as rt, KubbBuildStartContext as s, ResolveFileOptions as st, BuildOutput as t, PluginName as tt, KubbFileProcessingUpdate as u, ResolvePathOptions as ut, KubbHookLineContext as v, Renderer as vt, KubbPluginsEndContext as w, Reporter as wt, KubbInfoContext as x, Storage as xt, KubbHookStartContext as y, RendererFactory as yt, Parser as z, ProblemDiagnostic as zt };
|
|
2900
|
+
//# sourceMappingURL=types-B-w6zShf.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Core engine for Kubb. Provides the plugin driver, file manager and build orchestration used by every Kubb plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generator",
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@kubb/ast": "5.
|
|
75
|
+
"@kubb/ast": "5.6.0",
|
|
76
|
+
"tinyexec": "^1.3.1"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
79
|
"@internals/utils": "0.0.1",
|