kubb 5.0.0-beta.63 → 5.0.0-beta.64

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/bin/kubb.js CHANGED
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import('@kubb/cli').then(({ run }) => {
3
- run(process.argv)
4
- })
2
+
3
+ process.setSourceMapsEnabled?.(true)
4
+ process.title = 'Kubb'
5
+
6
+ try {
7
+ const { run } = await import('@kubb/cli')
8
+ await run(process.argv)
9
+ } catch (err) {
10
+ console.error(err)
11
+ process.exit(1)
12
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
2
  import { CLIOptions, UserConfig } from "@kubb/core";
3
3
  import { BarrelType } from "@kubb/plugin-barrel";
4
4
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-C0LytTxp.js";
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
2
  import { adapterOas } from "@kubb/adapter-oas";
3
3
  import { cliReporter, fileReporter, jsonReporter } from "@kubb/core";
4
4
  import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubb",
3
- "version": "5.0.0-beta.63",
3
+ "version": "5.0.0-beta.64",
4
4
  "description": "Meta-package and entry point for Kubb — a plugin-based code generation framework for OpenAPI. Includes defineConfig, all public APIs, and serves as the gateway to the entire Kubb ecosystem.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -30,7 +30,6 @@
30
30
  "kubb": "bin/kubb.js"
31
31
  },
32
32
  "files": [
33
- "src",
34
33
  "dist",
35
34
  "bin",
36
35
  "!/**/**.test.**",
@@ -54,14 +53,14 @@
54
53
  "registry": "https://registry.npmjs.org/"
55
54
  },
56
55
  "dependencies": {
57
- "@kubb/adapter-oas": "5.0.0-beta.63",
58
- "@kubb/cli": "5.0.0-beta.63",
59
- "@kubb/core": "5.0.0-beta.63",
60
- "@kubb/mcp": "5.0.0-beta.63",
61
- "@kubb/parser-md": "5.0.0-beta.63",
62
- "@kubb/parser-ts": "5.0.0-beta.63",
63
- "@kubb/plugin-barrel": "5.0.0-beta.63",
64
- "@kubb/renderer-jsx": "5.0.0-beta.63"
56
+ "@kubb/adapter-oas": "5.0.0-beta.64",
57
+ "@kubb/cli": "5.0.0-beta.64",
58
+ "@kubb/core": "5.0.0-beta.64",
59
+ "@kubb/mcp": "5.0.0-beta.64",
60
+ "@kubb/parser-md": "5.0.0-beta.64",
61
+ "@kubb/parser-ts": "5.0.0-beta.64",
62
+ "@kubb/plugin-barrel": "5.0.0-beta.64",
63
+ "@kubb/renderer-jsx": "5.0.0-beta.64"
65
64
  },
66
65
  "devDependencies": {
67
66
  "typescript": "^6.0.3",
@@ -1,117 +0,0 @@
1
- import { isPromise, type PossiblePromise } from '@internals/utils'
2
- import { adapterOas } from '@kubb/adapter-oas'
3
- import { cliReporter, type CLIOptions, fileReporter, jsonReporter, type UserConfig } from '@kubb/core'
4
- import { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'
5
- import { parserTs, parserTsx } from '@kubb/parser-ts'
6
- import { parserMd } from '@kubb/parser-md'
7
-
8
- type AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>
9
- type ConfigInput = AnyConfigResult | Promise<AnyConfigResult> | ((cli: CLIOptions) => PossiblePromise<AnyConfigResult>)
10
- type NormalizeConfig<TConfig> =
11
- TConfig extends Array<UserConfig<infer TInput>> ? Array<UserConfig<TInput>> : TConfig extends UserConfig<infer TInput> ? UserConfig<TInput> : never
12
- type DefinedConfig<TConfig extends ConfigInput> = TConfig extends (cli: CLIOptions) => PossiblePromise<infer TResult>
13
- ? (cli: CLIOptions) => Promise<NormalizeConfig<TResult>>
14
- : TConfig extends Promise<infer TResult>
15
- ? Promise<NormalizeConfig<TResult>>
16
- : NormalizeConfig<TConfig>
17
-
18
- /**
19
- * Applies default `root`, adapter, parsers, plugins, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.
20
- *
21
- * - `root` defaults to `process.cwd()`
22
- * - `adapter` defaults to `adapterOas()`
23
- * - `parsers` defaults to `[parserTs, parserTsx, parserMd]`
24
- * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter]`
25
- * - `plugins` gets `pluginBarrel()` appended when none is already present
26
- * - `output.barrel` defaults to `{ type: 'named' }` only when `pluginBarrel` is part of `plugins`.
27
- * When the user provides a plugins list without `pluginBarrel`, `barrel` is left untouched.
28
- * - `output.format` defaults to `false`
29
- * - `output.lint` defaults to `false`
30
- */
31
- function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {
32
- const alreadyHasBarrel = config.plugins?.some((p) => p.name === pluginBarrelName)
33
- const plugins = alreadyHasBarrel ? (config.plugins ?? []) : [...(config.plugins ?? []), pluginBarrel()]
34
- const hasBarrelPlugin = plugins.some((p) => p.name === pluginBarrelName)
35
-
36
- const output = { ...config.output }
37
- if (hasBarrelPlugin && output.barrel === undefined) {
38
- output.barrel = { type: 'named' }
39
- }
40
- if (output.format === undefined) {
41
- output.format = false
42
- }
43
- if (output.lint === undefined) {
44
- output.lint = false
45
- }
46
-
47
- return {
48
- ...config,
49
- root: config.root || process.cwd(),
50
- adapter: config.adapter ?? adapterOas(),
51
- parsers: config.parsers?.length ? config.parsers : [parserTs, parserTsx, parserMd],
52
- reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter],
53
- plugins,
54
- output,
55
- }
56
- }
57
-
58
- function normalizeConfig<TInput>(config: UserConfig<TInput> | Array<UserConfig<TInput>>): UserConfig<TInput> | Array<UserConfig<TInput>> {
59
- if (Array.isArray(config)) {
60
- return config.map(applyDefaults)
61
- }
62
-
63
- return applyDefaults(config)
64
- }
65
-
66
- /**
67
- * Defines a Kubb build configuration and fills in defaults for any omitted fields.
68
- *
69
- * Defaults applied when omitted:
70
- * - `adapter` → `adapterOas()` (OpenAPI 2.0/3.0/3.1).
71
- * - `parsers` → `[parserTs, parserTsx, parserMd]`.
72
- * - `reporters` → `[cliReporter, jsonReporter, fileReporter]`.
73
- * - `plugins` → `pluginBarrel()` is appended when not already present.
74
- * - `output.barrel` → `{ type: 'named' }` only when `pluginBarrel` is
75
- * in the plugins list.
76
- * - `output.format` and `output.lint` → `false`.
77
- *
78
- * Accepts a config object, an array of configs, a Promise resolving to one,
79
- * or a function that receives the parsed CLI options and returns any of the
80
- * above. The return type is preserved so async/array variants stay typed.
81
- *
82
- * @example
83
- * ```ts
84
- * import { defineConfig } from 'kubb'
85
- * import { pluginTs } from '@kubb/plugin-ts'
86
- *
87
- * export default defineConfig({
88
- * input: { path: './petStore.yaml' },
89
- * output: { path: './src/gen' },
90
- * plugins: [pluginTs()],
91
- * })
92
- * ```
93
- *
94
- * @example Function form with CLI options
95
- * ```ts
96
- * import { defineConfig } from 'kubb'
97
- *
98
- * export default defineConfig(({ input }) => ({
99
- * input: { path: input ?? './petStore.yaml' },
100
- * output: { path: './src/gen' },
101
- * plugins: [],
102
- * }))
103
- * ```
104
- */
105
- export function defineConfig<TConfig extends ConfigInput>(config: TConfig): DefinedConfig<TConfig> {
106
- if (typeof config === 'function') {
107
- return (async (cli: CLIOptions) => {
108
- return normalizeConfig(await config(cli))
109
- }) as DefinedConfig<TConfig>
110
- }
111
-
112
- if (isPromise(config)) {
113
- return config.then((resolved) => normalizeConfig(resolved)) as DefinedConfig<TConfig>
114
- }
115
-
116
- return normalizeConfig(config) as DefinedConfig<TConfig>
117
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export type { BarrelType } from '@kubb/plugin-barrel'
2
- export { defineConfig } from './defineConfig.ts'