@kubb/kit 5.0.0-beta.80
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/README.md +108 -0
- package/dist/index.cjs +75 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/testing.cjs +9 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +2 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
3
|
+
<img src="https://kubb.dev/og.png" alt="Kubb banner">
|
|
4
|
+
</a>
|
|
5
|
+
|
|
6
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
7
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
8
|
+
[![Stars][stars-src]][stars-href]
|
|
9
|
+
[![License][license-src]][license-href]
|
|
10
|
+
[![Node][node-src]][node-href]
|
|
11
|
+
|
|
12
|
+
<h4>
|
|
13
|
+
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
14
|
+
<span> · </span>
|
|
15
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
16
|
+
<span> · </span>
|
|
17
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
18
|
+
</h4>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<br />
|
|
22
|
+
|
|
23
|
+
# @kubb/kit
|
|
24
|
+
|
|
25
|
+
### Authoring toolkit for Kubb plugins
|
|
26
|
+
|
|
27
|
+
`@kubb/kit` gathers the helpers you call when you author a plugin, generator, adapter, resolver, or renderer: `definePlugin`, `defineGenerator`, `defineResolver`, `defineParser`, `createAdapter`, `createRenderer`, the `ast` namespace and `factory` node builders, and the option and hook types that go with them. It sits next to the `kubb` package, which is where end users configure and run builds. `kubb/kit` re-exports this package, so most consumers reach it through `kubb/kit` rather than installing `@kubb/kit` directly.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Install `kubb` and import from the `kubb/kit` subpath, rather than depending on `@kubb/kit` directly.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
bun add kubb
|
|
35
|
+
# or
|
|
36
|
+
pnpm add kubb
|
|
37
|
+
# or
|
|
38
|
+
npm install kubb
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { ast, definePlugin, defineGenerator } from 'kubb/kit'
|
|
45
|
+
|
|
46
|
+
export const pluginExample = definePlugin(() => {
|
|
47
|
+
return {
|
|
48
|
+
name: 'example',
|
|
49
|
+
generators: [
|
|
50
|
+
defineGenerator({
|
|
51
|
+
schema({ schema }) {
|
|
52
|
+
return ast.factory.createSchema(schema)
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## What is in the box
|
|
61
|
+
|
|
62
|
+
`definePlugin`, `defineGenerator`, `defineResolver`, and `defineParser` wrap a plugin, a generator, a resolver, or a parser into the shape the build engine expects. `createAdapter`, `createRenderer`, and `createStorage` are the matching factories for a custom spec adapter, output renderer, or storage backend.
|
|
63
|
+
|
|
64
|
+
`ast` and `factory` are the node builders a generator calls to construct the file, schema, and operation nodes it returns. `Diagnostics` is the structured error a plugin throws to report a problem with a location and a fix suggestion, and `memoryStorage` and `fsStorage` are the built-in storage backends, useful in tests and custom configs.
|
|
65
|
+
|
|
66
|
+
Rounding out the package are the option and hook types every plugin, generator, adapter, resolver, and renderer author references, among them `PluginFactoryOptions`, `GeneratorContext`, `ResolverContext`, `AdapterFactoryOptions`, `RendererFactory`, and `KubbHooks`.
|
|
67
|
+
|
|
68
|
+
## Testing helpers
|
|
69
|
+
|
|
70
|
+
`kubb/kit/testing` holds the Vitest-backed test helpers (`createMockedPlugin`, `createMockedAdapter`, `renderGeneratorOperation`, `matchFiles`) used to unit test a plugin or generator without running a full build. It is a separate entry point so the main `kubb/kit` import never pulls in Vitest.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { createMockedPlugin, renderGeneratorSchema } from 'kubb/kit/testing'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Why a separate package from `@kubb/core`
|
|
77
|
+
|
|
78
|
+
`@kubb/core` also runs the build engine: the plugin driver, the file manager, and the CLI reporters. None of that is part of authoring a plugin. `@kubb/kit` keeps the two apart, the same way the surrounding `kubb/ast` and `kubb/jsx` subpaths separate the AST layer and the JSX renderer from the engine that drives them.
|
|
79
|
+
|
|
80
|
+
## Supporting Kubb
|
|
81
|
+
|
|
82
|
+
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
|
|
83
|
+
|
|
84
|
+
- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
|
|
85
|
+
- [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
|
|
86
|
+
|
|
87
|
+
<p align="center">
|
|
88
|
+
<a href="https://github.com/sponsors/stijnvanhulle">
|
|
89
|
+
<img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
|
|
90
|
+
</a>
|
|
91
|
+
</p>
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
[MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
|
|
96
|
+
|
|
97
|
+
<!-- Badges -->
|
|
98
|
+
|
|
99
|
+
[npm-version-src]: https://shieldcn.dev/npm/v/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
100
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/kit
|
|
101
|
+
[npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
102
|
+
[npm-downloads-href]: https://npmx.dev/package/@kubb/kit
|
|
103
|
+
[stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
104
|
+
[stars-href]: https://github.com/kubb-labs/kubb
|
|
105
|
+
[license-src]: https://shieldcn.dev/npm/license/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc
|
|
106
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
107
|
+
[node-src]: https://shieldcn.dev/npm/node/@kubb/kit.svg?variant=secondary&size=xs&theme=zinc&mode=dark
|
|
108
|
+
[node-href]: https://npmx.dev/package/@kubb/kit
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _kubb_ast = require("@kubb/ast");
|
|
3
|
+
let _kubb_core = require("@kubb/core");
|
|
4
|
+
Object.defineProperty(exports, "Diagnostics", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return _kubb_core.Diagnostics;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, "ast", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return _kubb_ast.ast;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "createAdapter", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function() {
|
|
19
|
+
return _kubb_core.createAdapter;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "createRenderer", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return _kubb_core.createRenderer;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "createStorage", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return _kubb_core.createStorage;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "defineGenerator", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function() {
|
|
37
|
+
return _kubb_core.defineGenerator;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "defineParser", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function() {
|
|
43
|
+
return _kubb_core.defineParser;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "definePlugin", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function() {
|
|
49
|
+
return _kubb_core.definePlugin;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "defineResolver", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function() {
|
|
55
|
+
return _kubb_core.defineResolver;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, "factory", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function() {
|
|
61
|
+
return _kubb_ast.factory;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "fsStorage", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function() {
|
|
67
|
+
return _kubb_core.fsStorage;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "memoryStorage", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function() {
|
|
73
|
+
return _kubb_core.memoryStorage;
|
|
74
|
+
}
|
|
75
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ast, factory } from "@kubb/ast";
|
|
2
|
+
import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator, GeneratorContext, Group, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Output, OutputMode, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveBannerContext, ResolveBannerFile, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, UserConfig, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fsStorage, memoryStorage } from "@kubb/core";
|
|
3
|
+
export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator, type GeneratorContext, type Group, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type Storage, type UserConfig, ast, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, factory, fsStorage, memoryStorage };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ast, factory } from "@kubb/ast";
|
|
2
|
+
import { Diagnostics, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fsStorage, memoryStorage } from "@kubb/core";
|
|
3
|
+
export { Diagnostics, ast, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, factory, fsStorage, memoryStorage };
|
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var _kubb_core_mocks = require("@kubb/core/mocks");
|
|
2
|
+
Object.keys(_kubb_core_mocks).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _kubb_core_mocks[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@kubb/core/mocks";
|
package/dist/testing.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/kit",
|
|
3
|
+
"version": "5.0.0-beta.80",
|
|
4
|
+
"description": "Authoring toolkit for Kubb plugins, generators, adapters, resolvers, and renderers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"codegen",
|
|
7
|
+
"kit",
|
|
8
|
+
"kubb",
|
|
9
|
+
"meta-framework",
|
|
10
|
+
"plugin",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "stijnvanhulle",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
18
|
+
"directory": "packages/kit"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"*.d.ts",
|
|
23
|
+
"*.d.cts",
|
|
24
|
+
"!/**/**.test.**",
|
|
25
|
+
"!/**/__tests__/**",
|
|
26
|
+
"!/**/__snapshots__/**"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"require": "./dist/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./testing": {
|
|
39
|
+
"import": "./dist/testing.js",
|
|
40
|
+
"require": "./dist/testing.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsdown",
|
|
50
|
+
"clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
|
|
51
|
+
"lint": "oxlint .",
|
|
52
|
+
"lint:fix": "oxlint --fix .",
|
|
53
|
+
"release": "pnpm publish --no-git-check",
|
|
54
|
+
"release:stage": "pnpm stage publish --no-git-check",
|
|
55
|
+
"start": "tsdown --watch",
|
|
56
|
+
"test": "vitest --passWithNoTests",
|
|
57
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@kubb/ast": "workspace:*",
|
|
61
|
+
"@kubb/core": "workspace:*"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@internals/utils": "workspace:*"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@kubb/core": "workspace:*"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=22"
|
|
71
|
+
}
|
|
72
|
+
}
|