unplugin-kubb 5.9.3 → 5.9.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/astro.cjs +3 -3
- package/dist/astro.cjs.map +1 -1
- package/dist/astro.d.ts +9 -15
- package/dist/astro.js +1 -1
- package/dist/astro.js.map +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/rolldown-runtime-ClG-MNz_.cjs +13 -0
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/unpluginFactory.cjs +91 -2
- package/dist/unpluginFactory.cjs.map +1 -0
- package/dist/unpluginFactory.d.ts +21 -4
- package/dist/unpluginFactory.js +90 -1
- package/dist/unpluginFactory.js.map +1 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +7 -16
- package/dist/types.cjs +0 -0
- package/dist/types.d.ts +0 -11
- package/dist/types.js +0 -1
- package/dist/unpluginFactory-CqDfPz0M.cjs +0 -122
- package/dist/unpluginFactory-CqDfPz0M.cjs.map +0 -1
- package/dist/unpluginFactory-DKugbAOX.js +0 -105
- package/dist/unpluginFactory-DKugbAOX.js.map +0 -1
package/dist/astro.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-ClG-MNz_.cjs");
|
|
2
2
|
const require_vite = require("./vite.cjs");
|
|
3
3
|
//#region src/astro.ts
|
|
4
|
-
var astro_default = /* @__PURE__ */
|
|
4
|
+
var astro_default = /* @__PURE__ */ require_rolldown_runtime.__name((options) => ({
|
|
5
5
|
name: "unplugin-kubb",
|
|
6
|
-
hooks: { "astro:config:setup":
|
|
6
|
+
hooks: { "astro:config:setup": (astro) => {
|
|
7
7
|
astro.config.vite.plugins ||= [];
|
|
8
8
|
astro.config.vite.plugins.push(require_vite(options));
|
|
9
9
|
} }
|
package/dist/astro.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.cjs","names":["vitePlugin"],"sources":["../src/astro.ts"],"sourcesContent":["import type { Options } from './
|
|
1
|
+
{"version":3,"file":"astro.cjs","names":["vitePlugin"],"sources":["../src/astro.ts"],"sourcesContent":["import type { Options } from './unpluginFactory.ts'\nimport vitePlugin from './vite.ts'\n\nexport default (options: Options) => ({\n name: 'unplugin-kubb',\n hooks: {\n // Only the slice of Astro's `astro:config:setup` params the integration touches, so `astro` is not a dependency.\n 'astro:config:setup': (astro: { config: { vite: { plugins?: Array<unknown> } } }) => {\n astro.config.vite.plugins ||= []\n astro.config.vite.plugins.push(vitePlugin(options))\n },\n },\n})\n"],"mappings":";;;AAGA,IAAA,gBAAA,yCAAA,QAAgB,aAAsB;CACpC,MAAM;CACN,OAAO,EAEL,uBAAuB,UAA8D;EACnF,MAAM,OAAO,KAAK,YAAY,CAAC;EAC/B,MAAM,OAAO,KAAK,QAAQ,KAAKA,aAAW,OAAO,CAAC;CACpD,EACF;AACF,IAAA,SAAA"}
|
package/dist/astro.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/astro.d.ts
|
|
4
|
-
|
|
5
|
-
* Minimal shape of the params Astro passes to its `astro:config:setup` hook.
|
|
6
|
-
* Kept local rather than depending on `astro` for a single hook signature.
|
|
7
|
-
*/
|
|
8
|
-
type AstroConfigSetupParams = {
|
|
9
|
-
config: {
|
|
10
|
-
vite: {
|
|
11
|
-
plugins?: Array<unknown>;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type AstroIntegration = {
|
|
4
|
+
declare const _default: (options: Options) => {
|
|
16
5
|
name: string;
|
|
17
6
|
hooks: {
|
|
18
|
-
'astro:config:setup': (
|
|
7
|
+
'astro:config:setup': (astro: {
|
|
8
|
+
config: {
|
|
9
|
+
vite: {
|
|
10
|
+
plugins?: Array<unknown>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}) => void;
|
|
19
14
|
};
|
|
20
15
|
};
|
|
21
|
-
declare const _default: (options: Options) => AstroIntegration;
|
|
22
16
|
//#endregion
|
|
23
17
|
export { _default as default };
|
|
24
18
|
//# sourceMappingURL=astro.d.ts.map
|
package/dist/astro.js
CHANGED
|
@@ -3,7 +3,7 @@ import vite_default from "./vite.js";
|
|
|
3
3
|
//#region src/astro.ts
|
|
4
4
|
var astro_default = /* @__PURE__ */ __name((options) => ({
|
|
5
5
|
name: "unplugin-kubb",
|
|
6
|
-
hooks: { "astro:config:setup":
|
|
6
|
+
hooks: { "astro:config:setup": (astro) => {
|
|
7
7
|
astro.config.vite.plugins ||= [];
|
|
8
8
|
astro.config.vite.plugins.push(vite_default(options));
|
|
9
9
|
} }
|
package/dist/astro.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.js","names":["vitePlugin"],"sources":["../src/astro.ts"],"sourcesContent":["import type { Options } from './
|
|
1
|
+
{"version":3,"file":"astro.js","names":["vitePlugin"],"sources":["../src/astro.ts"],"sourcesContent":["import type { Options } from './unpluginFactory.ts'\nimport vitePlugin from './vite.ts'\n\nexport default (options: Options) => ({\n name: 'unplugin-kubb',\n hooks: {\n // Only the slice of Astro's `astro:config:setup` params the integration touches, so `astro` is not a dependency.\n 'astro:config:setup': (astro: { config: { vite: { plugins?: Array<unknown> } } }) => {\n astro.config.vite.plugins ||= []\n astro.config.vite.plugins.push(vitePlugin(options))\n },\n },\n})\n"],"mappings":";;;AAGA,IAAA,gBAAA,wBAAgB,aAAsB;CACpC,MAAM;CACN,OAAO,EAEL,uBAAuB,UAA8D;EACnF,MAAM,OAAO,KAAK,YAAY,CAAC;EAC/B,MAAM,OAAO,KAAK,QAAQ,KAAKA,aAAW,OAAO,CAAC;CACpD,EACF;AACF,IAAA,SAAA"}
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/esbuild.ts
|
|
3
3
|
var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/esbuild.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("esbuild").Plugin;
|
|
5
5
|
//#endregion
|
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/farm.ts
|
|
3
3
|
var farm_default = (0, require("unplugin").createFarmPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/farm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/farm.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("@farmfe/core").JsPlugin;
|
|
5
5
|
//#endregion
|
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,11 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
5
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
const plugin = /* #__PURE__ */ (0, require("unplugin").createUnplugin)(require_unpluginFactory.unpluginFactory);
|
|
8
8
|
//#endregion
|
|
9
|
+
exports.applyDefaults = require_unpluginFactory.applyDefaults;
|
|
9
10
|
exports.default = plugin;
|
|
10
11
|
exports.unplugin = plugin;
|
|
11
12
|
exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["unpluginFactory"],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["unpluginFactory"],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport { applyDefaults, type Options, unpluginFactory } from './unpluginFactory.ts'\n\nconst plugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport { plugin as unplugin, plugin as default }\n"],"mappings":";;;;;;AAKA,MAAM,SAAyB,iBAAA,qBAAA,CAAA,CAAA,eAAA,CAAeA,wBAAAA,eAAe"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
3
|
-
import { unpluginFactory } from "./unpluginFactory.js";
|
|
4
|
-
import { BarrelType } from "@kubb/plugin-barrel";
|
|
2
|
+
import { Options, applyDefaults, unpluginFactory } from "./unpluginFactory.js";
|
|
5
3
|
//#region src/index.d.ts
|
|
6
4
|
declare const plugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
|
7
5
|
//#endregion
|
|
8
|
-
export { type
|
|
6
|
+
export { type Options, applyDefaults, plugin as default, plugin as unplugin, unpluginFactory };
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyDefaults, unpluginFactory } from "./unpluginFactory.js";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const plugin = /* #__PURE__ */ createUnplugin(unpluginFactory);
|
|
5
5
|
//#endregion
|
|
6
|
-
export { plugin as default, plugin as unplugin, unpluginFactory };
|
|
6
|
+
export { applyDefaults, plugin as default, plugin as unplugin, unpluginFactory };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createUnplugin } from 'unplugin'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport { applyDefaults, type Options, unpluginFactory } from './unpluginFactory.ts'\n\nconst plugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport { plugin as unplugin, plugin as default }\n"],"mappings":";;;AAKA,MAAM,SAAyB,+BAAe,eAAe"}
|
package/dist/nuxt.cjs
CHANGED
package/dist/nuxt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.cjs","names":["defineNuxtModule","vite","webpack","rspack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport rspack from './rspack.ts'\nimport type { Options } from './
|
|
1
|
+
{"version":3,"file":"nuxt.cjs","names":["defineNuxtModule","vite","webpack","rspack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport rspack from './rspack.ts'\nimport type { Options } from './unpluginFactory.ts'\nimport vite from './vite.ts'\nimport webpack from './webpack.ts'\n\nexport type ModuleOptions = Options\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-unplugin-kubb',\n configKey: 'unpluginKubb',\n },\n defaults: undefined,\n setup(options, _nuxt) {\n // Nuxt builds the client before the server, so generating in the client build alone gives\n // the server build the files too. Skip the dev server, as the Vite integration does.\n const buildOptions = { dev: false, server: false }\n\n addVitePlugin(() => vite(options), buildOptions)\n addWebpackPlugin(() => webpack(options), buildOptions)\n addRspackPlugin(() => rspack(options), buildOptions)\n },\n})\n"],"mappings":";;;;;;;AAUA,IAAA,gBAAA,GAAeA,UAAAA,iBAAAA,CAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,UAAU,KAAA;CACV,MAAM,SAAS,OAAO;EAGpB,MAAM,eAAe;GAAE,KAAK;GAAO,QAAQ;EAAM;EAEjD,CAAA,GAAA,UAAA,cAAA,OAAoBC,aAAK,OAAO,GAAG,YAAY;EAC/C,CAAA,GAAA,UAAA,iBAAA,OAAuBC,gBAAQ,OAAO,GAAG,YAAY;EACrD,CAAA,GAAA,UAAA,gBAAA,OAAsBC,eAAO,OAAO,GAAG,YAAY;CACrD;AACF,CAAC"}
|
package/dist/nuxt.d.ts
CHANGED
package/dist/nuxt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.js","names":["vite","webpack","rspack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport rspack from './rspack.ts'\nimport type { Options } from './
|
|
1
|
+
{"version":3,"file":"nuxt.js","names":["vite","webpack","rspack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addRspackPlugin, addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport rspack from './rspack.ts'\nimport type { Options } from './unpluginFactory.ts'\nimport vite from './vite.ts'\nimport webpack from './webpack.ts'\n\nexport type ModuleOptions = Options\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-unplugin-kubb',\n configKey: 'unpluginKubb',\n },\n defaults: undefined,\n setup(options, _nuxt) {\n // Nuxt builds the client before the server, so generating in the client build alone gives\n // the server build the files too. Skip the dev server, as the Vite integration does.\n const buildOptions = { dev: false, server: false }\n\n addVitePlugin(() => vite(options), buildOptions)\n addWebpackPlugin(() => webpack(options), buildOptions)\n addRspackPlugin(() => rspack(options), buildOptions)\n },\n})\n"],"mappings":";;;;;;;AAUA,IAAA,eAAe,iBAAgC;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;CACb;CACA,UAAU,KAAA;CACV,MAAM,SAAS,OAAO;EAGpB,MAAM,eAAe;GAAE,KAAK;GAAO,QAAQ;EAAM;EAEjD,oBAAoBA,aAAK,OAAO,GAAG,YAAY;EAC/C,uBAAuBC,gBAAQ,OAAO,GAAG,YAAY;EACrD,sBAAsBC,eAAO,OAAO,GAAG,YAAY;CACrD;AACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, "__name", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return __name;
|
|
12
|
+
}
|
|
13
|
+
});
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/rolldown.ts
|
|
3
3
|
var rolldown_default = (0, require("unplugin").createRolldownPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/rolldown.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("rolldown").Plugin<any> | import("rolldown").Plugin<any>[];
|
|
5
5
|
//#endregion
|
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/rollup.ts
|
|
3
3
|
var rollup_default = (0, require("unplugin").createRollupPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/rollup.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
|
5
5
|
//#endregion
|
package/dist/rollup.js
CHANGED
package/dist/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/rspack.ts
|
|
3
3
|
var rspack_default = (0, require("unplugin").createRspackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rspack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/rspack.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("unplugin").RspackPluginInstance;
|
|
5
5
|
//#endregion
|
package/dist/rspack.js
CHANGED
package/dist/unpluginFactory.cjs
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
require("./rolldown-runtime-ClG-MNz_.cjs");
|
|
3
|
+
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
4
|
+
let _kubb_core = require("@kubb/core");
|
|
5
|
+
let _kubb_parser_md = require("@kubb/parser-md");
|
|
6
|
+
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
7
|
+
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
8
|
+
//#region src/unpluginFactory.ts
|
|
9
|
+
/**
|
|
10
|
+
* Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
|
|
11
|
+
*
|
|
12
|
+
* - `root` defaults to `process.cwd()`
|
|
13
|
+
* - `adapter` defaults to `adapterOas()`
|
|
14
|
+
* - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
|
|
15
|
+
* - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
|
|
16
|
+
* - `plugins` gets `pluginBarrel()` appended when none is already present
|
|
17
|
+
* - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
|
|
18
|
+
* - `output.format` and `output.lint` default to `false`
|
|
19
|
+
*/
|
|
20
|
+
function applyDefaults(config) {
|
|
21
|
+
const plugins = config.plugins ?? [];
|
|
22
|
+
return {
|
|
23
|
+
...config,
|
|
24
|
+
root: config.root || process.cwd(),
|
|
25
|
+
adapter: config.adapter ?? (0, _kubb_adapter_oas.adapterOas)(),
|
|
26
|
+
parsers: config.parsers?.length ? config.parsers : [
|
|
27
|
+
(0, _kubb_parser_ts.parserTs)(),
|
|
28
|
+
(0, _kubb_parser_ts.parserTsx)(),
|
|
29
|
+
(0, _kubb_parser_md.parserMd)()
|
|
30
|
+
],
|
|
31
|
+
reporters: config.reporters?.length ? config.reporters : [
|
|
32
|
+
_kubb_core.cliReporter,
|
|
33
|
+
_kubb_core.jsonReporter,
|
|
34
|
+
_kubb_core.fileReporter,
|
|
35
|
+
_kubb_core.htmlReporter
|
|
36
|
+
],
|
|
37
|
+
plugins: plugins.some((plugin) => plugin.name === _kubb_plugin_barrel.pluginBarrelName) ? plugins : [...plugins, (0, _kubb_plugin_barrel.pluginBarrel)()],
|
|
38
|
+
output: {
|
|
39
|
+
barrel: false,
|
|
40
|
+
format: false,
|
|
41
|
+
lint: false,
|
|
42
|
+
...config.output
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
48
|
+
*
|
|
49
|
+
* Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
|
|
50
|
+
* config and prints the same summary `kubb generate` does. Under Vite it only applies during
|
|
51
|
+
* `build`. A missing config or a failed generation fails the host build.
|
|
52
|
+
*/
|
|
53
|
+
const unpluginFactory = (options, meta) => {
|
|
54
|
+
const name = "unplugin-kubb";
|
|
55
|
+
const hooks = new _kubb_core.Hookable();
|
|
56
|
+
const reporter = (0, _kubb_core.createCliReporter)();
|
|
57
|
+
hooks.hook("kubb:generation:end", ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => reporter.report({
|
|
58
|
+
config,
|
|
59
|
+
diagnostics,
|
|
60
|
+
filesCreated,
|
|
61
|
+
status,
|
|
62
|
+
hrStart
|
|
63
|
+
}, { logLevel: _kubb_core.logLevel.info }));
|
|
64
|
+
async function runBuild() {
|
|
65
|
+
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
66
|
+
const result = await (0, _kubb_core.createKubb)(applyDefaults(options.config), { hooks }).generate();
|
|
67
|
+
if (!result.success) {
|
|
68
|
+
const failedCount = _kubb_core.Diagnostics.failedPlugins(result.diagnostics).length;
|
|
69
|
+
const firstError = result.diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
70
|
+
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
71
|
+
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
let generation;
|
|
75
|
+
return {
|
|
76
|
+
name,
|
|
77
|
+
enforce: "pre",
|
|
78
|
+
apply: meta.framework === "vite" ? "build" : void 0,
|
|
79
|
+
async buildStart() {
|
|
80
|
+
generation ??= runBuild().catch((error) => {
|
|
81
|
+
generation = void 0;
|
|
82
|
+
throw error;
|
|
83
|
+
});
|
|
84
|
+
await generation;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
exports.applyDefaults = applyDefaults;
|
|
90
|
+
exports.unpluginFactory = unpluginFactory;
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=unpluginFactory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory.cjs","names":["adapterOas","parserTs","parserTsx","parserMd","cliReporter","jsonReporter","fileReporter","htmlReporter","pluginBarrelName","pluginBarrel","Hookable","createCliReporter","logLevel","createKubb","Diagnostics"],"sources":["../src/unpluginFactory.ts"],"sourcesContent":["import { adapterOas } from '@kubb/adapter-oas'\nimport {\n cliReporter,\n type Config,\n createCliReporter,\n createKubb,\n Diagnostics,\n fileReporter,\n Hookable,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel,\n type UserConfig,\n} from '@kubb/core'\nimport { parserMd } from '@kubb/parser-md'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport type { UnpluginFactory } from 'unplugin'\n\nexport type Options = {\n /**\n * Kubb config passed to the unplugin entry point.\n */\n config?: UserConfig\n}\n\n/**\n * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.\n *\n * - `root` defaults to `process.cwd()`\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`\n * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`\n * - `plugins` gets `pluginBarrel()` appended when none is already present\n * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)\n * - `output.format` and `output.lint` default to `false`\n */\nexport function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const plugins = config.plugins ?? []\n\n return {\n ...config,\n root: config.root || process.cwd(),\n adapter: config.adapter ?? adapterOas(),\n parsers: config.parsers?.length ? config.parsers : [parserTs(), parserTsx(), parserMd()],\n reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter],\n plugins: plugins.some((plugin) => plugin.name === pluginBarrelName) ? plugins : [...plugins, pluginBarrel()],\n output: { barrel: false, format: false, lint: false, ...config.output },\n }\n}\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the\n * config and prints the same summary `kubb generate` does. Under Vite it only applies during\n * `build`. A missing config or a failed generation fails the host build.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new Hookable<KubbHooks>()\n const reporter = createCliReporter()\n\n hooks.hook('kubb:generation:end', ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) =>\n reporter.report({ config, diagnostics, filesCreated, status, hrStart }, { logLevel: logLevel.info }),\n )\n\n // Throw: webpack, Rspack, esbuild, and Farm contexts have no `this.error`.\n async function runBuild() {\n if (!options?.config) {\n throw new Error(`[${name}] Config is not set`)\n }\n\n const kubb = createKubb(applyDefaults(options.config) as Config, { hooks })\n const result = await kubb.generate()\n\n if (!result.success) {\n const failedCount = Diagnostics.failedPlugins(result.diagnostics).length\n const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n // A rerun with `output.clean` loops webpack and Rspack watchers, so generate once per instance.\n let generation: Promise<void> | undefined\n\n return {\n name,\n enforce: 'pre',\n apply: meta.framework === 'vite' ? 'build' : undefined,\n async buildStart() {\n generation ??= runBuild().catch((error: unknown) => {\n generation = undefined\n throw error\n })\n await generation\n },\n }\n}\n"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,SAAS;EAEnC,IAAI,CAAC,OAAO,SAAS;GACnB,MAAM,cAAcC,WAAAA,YAAY,cAAc,OAAO,WAAW,CAAC,CAAC;GAClE,MAAM,aAAa,OAAO,YAAY,OAAOA,WAAAA,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAE7G,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAGA,IAAI;CAEJ,OAAO;EACL;EACA,SAAS;EACT,OAAO,KAAK,cAAc,SAAS,UAAU,KAAA;EAC7C,MAAM,aAAa;GACjB,eAAe,SAAS,CAAC,CAAC,OAAO,UAAmB;IAClD,aAAa,KAAA;IACb,MAAM;GACR,CAAC;GACD,MAAM;EACR;CACF;AACF"}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./types.js";
|
|
3
2
|
import { UnpluginFactory } from "unplugin";
|
|
3
|
+
import { UserConfig } from "@kubb/core";
|
|
4
4
|
//#region src/unpluginFactory.d.ts
|
|
5
|
+
export type Options = {
|
|
6
|
+
/**
|
|
7
|
+
* Kubb config passed to the unplugin entry point.
|
|
8
|
+
*/
|
|
9
|
+
config?: UserConfig;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
|
|
13
|
+
*
|
|
14
|
+
* - `root` defaults to `process.cwd()`
|
|
15
|
+
* - `adapter` defaults to `adapterOas()`
|
|
16
|
+
* - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
|
|
17
|
+
* - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
|
|
18
|
+
* - `plugins` gets `pluginBarrel()` appended when none is already present
|
|
19
|
+
* - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
|
|
20
|
+
* - `output.format` and `output.lint` default to `false`
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput>;
|
|
5
23
|
/**
|
|
6
24
|
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
7
25
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
26
|
+
* Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
|
|
27
|
+
* config and prints the same summary `kubb generate` does. Under Vite it only applies during
|
|
11
28
|
* `build`. A missing config or a failed generation fails the host build.
|
|
12
29
|
*/
|
|
13
30
|
export declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
package/dist/unpluginFactory.js
CHANGED
|
@@ -1 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { adapterOas } from "@kubb/adapter-oas";
|
|
3
|
+
import { Diagnostics, Hookable, cliReporter, createCliReporter, createKubb, fileReporter, htmlReporter, jsonReporter, logLevel } from "@kubb/core";
|
|
4
|
+
import { parserMd } from "@kubb/parser-md";
|
|
5
|
+
import { parserTs, parserTsx } from "@kubb/parser-ts";
|
|
6
|
+
import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
|
|
7
|
+
//#region src/unpluginFactory.ts
|
|
8
|
+
/**
|
|
9
|
+
* Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.
|
|
10
|
+
*
|
|
11
|
+
* - `root` defaults to `process.cwd()`
|
|
12
|
+
* - `adapter` defaults to `adapterOas()`
|
|
13
|
+
* - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
|
|
14
|
+
* - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`
|
|
15
|
+
* - `plugins` gets `pluginBarrel()` appended when none is already present
|
|
16
|
+
* - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)
|
|
17
|
+
* - `output.format` and `output.lint` default to `false`
|
|
18
|
+
*/
|
|
19
|
+
function applyDefaults(config) {
|
|
20
|
+
const plugins = config.plugins ?? [];
|
|
21
|
+
return {
|
|
22
|
+
...config,
|
|
23
|
+
root: config.root || process.cwd(),
|
|
24
|
+
adapter: config.adapter ?? adapterOas(),
|
|
25
|
+
parsers: config.parsers?.length ? config.parsers : [
|
|
26
|
+
parserTs(),
|
|
27
|
+
parserTsx(),
|
|
28
|
+
parserMd()
|
|
29
|
+
],
|
|
30
|
+
reporters: config.reporters?.length ? config.reporters : [
|
|
31
|
+
cliReporter,
|
|
32
|
+
jsonReporter,
|
|
33
|
+
fileReporter,
|
|
34
|
+
htmlReporter
|
|
35
|
+
],
|
|
36
|
+
plugins: plugins.some((plugin) => plugin.name === pluginBarrelName) ? plugins : [...plugins, pluginBarrel()],
|
|
37
|
+
output: {
|
|
38
|
+
barrel: false,
|
|
39
|
+
format: false,
|
|
40
|
+
lint: false,
|
|
41
|
+
...config.output
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
47
|
+
*
|
|
48
|
+
* Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the
|
|
49
|
+
* config and prints the same summary `kubb generate` does. Under Vite it only applies during
|
|
50
|
+
* `build`. A missing config or a failed generation fails the host build.
|
|
51
|
+
*/
|
|
52
|
+
const unpluginFactory = (options, meta) => {
|
|
53
|
+
const name = "unplugin-kubb";
|
|
54
|
+
const hooks = new Hookable();
|
|
55
|
+
const reporter = createCliReporter();
|
|
56
|
+
hooks.hook("kubb:generation:end", ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => reporter.report({
|
|
57
|
+
config,
|
|
58
|
+
diagnostics,
|
|
59
|
+
filesCreated,
|
|
60
|
+
status,
|
|
61
|
+
hrStart
|
|
62
|
+
}, { logLevel: logLevel.info }));
|
|
63
|
+
async function runBuild() {
|
|
64
|
+
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
65
|
+
const result = await createKubb(applyDefaults(options.config), { hooks }).generate();
|
|
66
|
+
if (!result.success) {
|
|
67
|
+
const failedCount = Diagnostics.failedPlugins(result.diagnostics).length;
|
|
68
|
+
const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
69
|
+
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
70
|
+
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let generation;
|
|
74
|
+
return {
|
|
75
|
+
name,
|
|
76
|
+
enforce: "pre",
|
|
77
|
+
apply: meta.framework === "vite" ? "build" : void 0,
|
|
78
|
+
async buildStart() {
|
|
79
|
+
generation ??= runBuild().catch((error) => {
|
|
80
|
+
generation = void 0;
|
|
81
|
+
throw error;
|
|
82
|
+
});
|
|
83
|
+
await generation;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { applyDefaults, unpluginFactory };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=unpluginFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory.js","names":[],"sources":["../src/unpluginFactory.ts"],"sourcesContent":["import { adapterOas } from '@kubb/adapter-oas'\nimport {\n cliReporter,\n type Config,\n createCliReporter,\n createKubb,\n Diagnostics,\n fileReporter,\n Hookable,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel,\n type UserConfig,\n} from '@kubb/core'\nimport { parserMd } from '@kubb/parser-md'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport type { UnpluginFactory } from 'unplugin'\n\nexport type Options = {\n /**\n * Kubb config passed to the unplugin entry point.\n */\n config?: UserConfig\n}\n\n/**\n * Applies the defaults `defineConfig` and the unplugin share to a single user config when not set.\n *\n * - `root` defaults to `process.cwd()`\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`\n * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter, htmlReporter]`\n * - `plugins` gets `pluginBarrel()` appended when none is already present\n * - `output.barrel` defaults to `false` when not set (`pluginBarrel` is always present after the step above, but generates nothing until configured)\n * - `output.format` and `output.lint` default to `false`\n */\nexport function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const plugins = config.plugins ?? []\n\n return {\n ...config,\n root: config.root || process.cwd(),\n adapter: config.adapter ?? adapterOas(),\n parsers: config.parsers?.length ? config.parsers : [parserTs(), parserTsx(), parserMd()],\n reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter],\n plugins: plugins.some((plugin) => plugin.name === pluginBarrelName) ? plugins : [...plugins, pluginBarrel()],\n output: { barrel: false, format: false, lint: false, ...config.output },\n }\n}\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Runs the Kubb build during the first `buildStart` with {@link applyDefaults} applied to the\n * config and prints the same summary `kubb generate` does. Under Vite it only applies during\n * `build`. A missing config or a failed generation fails the host build.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new Hookable<KubbHooks>()\n const reporter = createCliReporter()\n\n hooks.hook('kubb:generation:end', ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) =>\n reporter.report({ config, diagnostics, filesCreated, status, hrStart }, { logLevel: logLevel.info }),\n )\n\n // Throw: webpack, Rspack, esbuild, and Farm contexts have no `this.error`.\n async function runBuild() {\n if (!options?.config) {\n throw new Error(`[${name}] Config is not set`)\n }\n\n const kubb = createKubb(applyDefaults(options.config) as Config, { hooks })\n const result = await kubb.generate()\n\n if (!result.success) {\n const failedCount = Diagnostics.failedPlugins(result.diagnostics).length\n const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n // A rerun with `output.clean` loops webpack and Rspack watchers, so generate once per instance.\n let generation: Promise<void> | undefined\n\n return {\n name,\n enforce: 'pre',\n apply: meta.framework === 'vite' ? 'build' : undefined,\n async buildStart() {\n generation ??= runBuild().catch((error: unknown) => {\n generation = undefined\n throw error\n })\n await generation\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,SAAgB,cAAsB,QAAgD;CACpF,MAAM,UAAU,OAAO,WAAW,CAAC;CAEnC,OAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,QAAQ,IAAI;EACjC,SAAS,OAAO,WAAW,WAAW;EACtC,SAAS,OAAO,SAAS,SAAS,OAAO,UAAU;GAAC,SAAS;GAAG,UAAU;GAAG,SAAS;EAAC;EACvF,WAAW,OAAO,WAAW,SAAS,OAAO,YAAY;GAAC;GAAa;GAAc;GAAc;EAAY;EAC/G,SAAS,QAAQ,MAAM,WAAW,OAAO,SAAS,gBAAgB,IAAI,UAAU,CAAC,GAAG,SAAS,aAAa,CAAC;EAC3G,QAAQ;GAAE,QAAQ;GAAO,QAAQ;GAAO,MAAM;GAAO,GAAG,OAAO;EAAO;CACxE;AACF;;;;;;;;AASA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAI,SAAoB;CACtC,MAAM,WAAW,kBAAkB;CAEnC,MAAM,KAAK,wBAAwB,EAAE,QAAQ,cAAc,CAAC,GAAG,eAAe,GAAG,SAAS,WAAW,UAAU,QAAQ,OAAO,QAC5H,SAAS,OAAO;EAAE;EAAQ;EAAa;EAAc;EAAQ;CAAQ,GAAG,EAAE,UAAU,SAAS,KAAK,CAAC,CACrG;CAGA,eAAe,WAAW;EACxB,IAAI,CAAC,SAAS,QACZ,MAAM,IAAI,MAAM,IAAI,KAAK,oBAAoB;EAI/C,MAAM,SAAS,MADF,WAAW,cAAc,QAAQ,MAAM,GAAa,EAAE,MAAM,CACjD,CAAC,CAAC,SAAS;EAEnC,IAAI,CAAC,OAAO,SAAS;GACnB,MAAM,cAAc,YAAY,cAAc,OAAO,WAAW,CAAC,CAAC;GAClE,MAAM,aAAa,OAAO,YAAY,OAAO,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAE7G,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAGA,IAAI;CAEJ,OAAO;EACL;EACA,SAAS;EACT,OAAO,KAAK,cAAc,SAAS,UAAU,KAAA;EAC7C,MAAM,aAAa;GACjB,eAAe,SAAS,CAAC,CAAC,OAAO,UAAmB;IAClD,aAAa,KAAA;IACb,MAAM;GACR,CAAC;GACD,MAAM;EACR;CACF;AACF"}
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/vite.ts
|
|
3
3
|
var vite_default = (0, require("unplugin").createVitePlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/vite.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
|
5
5
|
//#endregion
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory.cjs");
|
|
2
2
|
//#region src/webpack.ts
|
|
3
3
|
var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Options } from "./
|
|
2
|
+
import { Options } from "./unpluginFactory.js";
|
|
3
3
|
//#region src/webpack.d.ts
|
|
4
4
|
declare const _default: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
|
|
5
5
|
//#endregion
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-kubb",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.5",
|
|
4
4
|
"description": "Integration of Kubb for Vite, webpack, Rollup, Rolldown, Rspack, esbuild, Farm, Nuxt, and Astro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -99,16 +99,6 @@
|
|
|
99
99
|
"import": "./dist/rspack.js",
|
|
100
100
|
"require": "./dist/rspack.cjs"
|
|
101
101
|
},
|
|
102
|
-
"./types": {
|
|
103
|
-
"types": "./dist/types.d.ts",
|
|
104
|
-
"import": "./dist/types.js",
|
|
105
|
-
"require": "./dist/types.cjs"
|
|
106
|
-
},
|
|
107
|
-
"./unpluginFactory": {
|
|
108
|
-
"types": "./dist/unpluginFactory.d.ts",
|
|
109
|
-
"import": "./dist/unpluginFactory.js",
|
|
110
|
-
"require": "./dist/unpluginFactory.cjs"
|
|
111
|
-
},
|
|
112
102
|
"./vite": {
|
|
113
103
|
"types": "./dist/vite.d.ts",
|
|
114
104
|
"import": "./dist/vite.js",
|
|
@@ -126,15 +116,16 @@
|
|
|
126
116
|
"registry": "https://registry.npmjs.org/"
|
|
127
117
|
},
|
|
128
118
|
"dependencies": {
|
|
129
|
-
"@kubb/adapter-oas": "5.9.
|
|
130
|
-
"@kubb/core": "5.9.
|
|
131
|
-
"@kubb/parser-
|
|
132
|
-
"@kubb/
|
|
119
|
+
"@kubb/adapter-oas": "5.9.5",
|
|
120
|
+
"@kubb/core": "5.9.5",
|
|
121
|
+
"@kubb/parser-md": "5.9.5",
|
|
122
|
+
"@kubb/parser-ts": "5.9.5",
|
|
123
|
+
"@kubb/plugin-barrel": "5.9.5",
|
|
133
124
|
"unplugin": "^3.4.0"
|
|
134
125
|
},
|
|
135
126
|
"devDependencies": {
|
|
136
127
|
"@farmfe/core": "^1.7.11",
|
|
137
|
-
"@kubb/ast": "5.9.
|
|
128
|
+
"@kubb/ast": "5.9.5",
|
|
138
129
|
"@nuxt/kit": "^4.6.1",
|
|
139
130
|
"@nuxt/schema": "^4.6.1",
|
|
140
131
|
"@rspack/core": "^2.2.8",
|
package/dist/types.cjs
DELETED
|
File without changes
|
package/dist/types.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { UserConfig } from "@kubb/core";
|
|
3
|
-
//#region src/types.d.ts
|
|
4
|
-
export type Options = {
|
|
5
|
-
/**
|
|
6
|
-
* Kubb config passed to the unplugin entry point.
|
|
7
|
-
*/
|
|
8
|
-
config?: UserConfig;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
-
value,
|
|
5
|
-
configurable: true
|
|
6
|
-
});
|
|
7
|
-
//#endregion
|
|
8
|
-
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
9
|
-
let _kubb_core = require("@kubb/core");
|
|
10
|
-
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
11
|
-
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
12
|
-
//#region package.json
|
|
13
|
-
var version = "5.9.3";
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/unpluginFactory.ts
|
|
16
|
-
/**
|
|
17
|
-
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
18
|
-
*
|
|
19
|
-
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
20
|
-
* the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:
|
|
21
|
-
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
22
|
-
* `build`. A missing config or a failed generation fails the host build.
|
|
23
|
-
*/
|
|
24
|
-
const unpluginFactory = (options, meta) => {
|
|
25
|
-
const name = "unplugin-kubb";
|
|
26
|
-
const hooks = new _kubb_core.Hookable();
|
|
27
|
-
const isVite = meta.framework === "vite";
|
|
28
|
-
hooks.hook("kubb:lifecycle:start", ({ version }) => {
|
|
29
|
-
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
30
|
-
});
|
|
31
|
-
hooks.hook("kubb:error", ({ error }) => {
|
|
32
|
-
console.error(`✗ ${error?.message || "failed"}`);
|
|
33
|
-
});
|
|
34
|
-
hooks.hook("kubb:warn", ({ message }) => {
|
|
35
|
-
console.warn(`⚠ ${message}`);
|
|
36
|
-
});
|
|
37
|
-
hooks.hook("kubb:info", ({ message }) => {
|
|
38
|
-
console.info(`ℹ ${message}`);
|
|
39
|
-
});
|
|
40
|
-
hooks.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
41
|
-
if (diagnostic.severity === "error") return hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
42
|
-
if (diagnostic.severity === "warning") return hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
43
|
-
return hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
44
|
-
});
|
|
45
|
-
hooks.hook("kubb:success", ({ message }) => {
|
|
46
|
-
console.log(`✓ ${message}`);
|
|
47
|
-
});
|
|
48
|
-
hooks.hook("kubb:plugin:end", ({ plugin, duration }) => {
|
|
49
|
-
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
50
|
-
console.log(`✓ ${plugin.name} completed in ${durationStr}`);
|
|
51
|
-
});
|
|
52
|
-
hooks.hook("kubb:files:processing:end", () => {
|
|
53
|
-
console.log("✓ Files written successfully");
|
|
54
|
-
});
|
|
55
|
-
hooks.hook("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
56
|
-
const result = status === "failed" ? "✗ Generation failed" : "✓ Generation succeeded";
|
|
57
|
-
console.log(config.name ? `${result} for ${config.name}` : result);
|
|
58
|
-
if (!diagnostics || !status) return;
|
|
59
|
-
const failedCount = _kubb_core.Diagnostics.failedPlugins(diagnostics).length;
|
|
60
|
-
const pluginsCount = config.plugins.length;
|
|
61
|
-
const passedCount = pluginsCount - failedCount;
|
|
62
|
-
const { errors } = _kubb_core.Diagnostics.count(diagnostics);
|
|
63
|
-
console.log(status === "success" ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})` : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? "error" : "errors"}`);
|
|
64
|
-
});
|
|
65
|
-
async function runBuild() {
|
|
66
|
-
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
67
|
-
const { adapter, output, plugins } = (0, _kubb_core.applyConfigDefaults)(options.config, {
|
|
68
|
-
defaultAdapter: (0, _kubb_adapter_oas.adapterOas)(),
|
|
69
|
-
barrelPlugin: (0, _kubb_plugin_barrel.pluginBarrel)(),
|
|
70
|
-
barrelPluginName: _kubb_plugin_barrel.pluginBarrelName,
|
|
71
|
-
defaultOutput: {
|
|
72
|
-
barrel: false,
|
|
73
|
-
format: false,
|
|
74
|
-
lint: false
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const userConfig = {
|
|
78
|
-
...options.config,
|
|
79
|
-
adapter,
|
|
80
|
-
parsers: options.config.parsers?.length ? options.config.parsers : [(0, _kubb_parser_ts.parserTs)(), (0, _kubb_parser_ts.parserTsx)()],
|
|
81
|
-
plugins,
|
|
82
|
-
output
|
|
83
|
-
};
|
|
84
|
-
await hooks.callHook("kubb:lifecycle:start", { version });
|
|
85
|
-
const result = await (0, _kubb_core.createKubb)(userConfig, { hooks }).generate();
|
|
86
|
-
await hooks.callHook("kubb:lifecycle:end");
|
|
87
|
-
if (!result.success) {
|
|
88
|
-
const failedCount = _kubb_core.Diagnostics.failedPlugins(result.diagnostics).length;
|
|
89
|
-
const firstError = result.diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
90
|
-
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
91
|
-
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
let generation;
|
|
95
|
-
return {
|
|
96
|
-
name,
|
|
97
|
-
enforce: "pre",
|
|
98
|
-
apply: isVite ? "build" : void 0,
|
|
99
|
-
async buildStart() {
|
|
100
|
-
generation ??= runBuild().catch((error) => {
|
|
101
|
-
generation = void 0;
|
|
102
|
-
throw error;
|
|
103
|
-
});
|
|
104
|
-
await generation;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
//#endregion
|
|
109
|
-
Object.defineProperty(exports, "__name", {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function() {
|
|
112
|
-
return __name;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
Object.defineProperty(exports, "unpluginFactory", {
|
|
116
|
-
enumerable: true,
|
|
117
|
-
get: function() {
|
|
118
|
-
return unpluginFactory;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=unpluginFactory-CqDfPz0M.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-CqDfPz0M.cjs","names":["Hookable","Diagnostics","applyConfigDefaults","adapterOas","pluginBarrel","pluginBarrelName","parserTs","parserTsx","unpluginVersion","createKubb"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:\n * the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during\n * `build`. A missing config or a failed generation fails the host build.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new Hookable<KubbHooks>()\n const isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n const result = status === 'failed' ? '✗ Generation failed' : '✓ Generation succeeded'\n console.log(config.name ? `${result} for ${config.name}` : result)\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const passedCount = pluginsCount - failedCount\n const { errors } = Diagnostics.count(diagnostics)\n\n // A run that fails before any plugin runs has 0 failed plugins, so show the error count.\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})`\n : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? 'error' : 'errors'}`,\n )\n })\n\n // Throw: webpack, Rspack, esbuild, and Farm contexts have no `this.error`.\n async function runBuild() {\n if (!options?.config) {\n throw new Error(`[${name}] Config is not set`)\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\n\n if (!result.success) {\n const failedCount = Diagnostics.failedPlugins(result.diagnostics).length\n const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n // A rerun with `output.clean` loops webpack and Rspack watchers, so generate once per instance.\n let generation: Promise<void> | undefined\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n generation ??= runBuild().catch((error: unknown) => {\n generation = undefined\n throw error\n })\n await generation\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;ACgBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAIA,WAAAA,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC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;GACD,MAAM;EACR;CACF;AACF"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { adapterOas } from "@kubb/adapter-oas";
|
|
3
|
-
import { Diagnostics, Hookable, applyConfigDefaults, createKubb } from "@kubb/core";
|
|
4
|
-
import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
|
|
5
|
-
import { parserTs, parserTsx } from "@kubb/parser-ts";
|
|
6
|
-
//#region package.json
|
|
7
|
-
var version = "5.9.3";
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/unpluginFactory.ts
|
|
10
|
-
/**
|
|
11
|
-
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
12
|
-
*
|
|
13
|
-
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
14
|
-
* the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:
|
|
15
|
-
* the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during
|
|
16
|
-
* `build`. A missing config or a failed generation fails the host build.
|
|
17
|
-
*/
|
|
18
|
-
const unpluginFactory = (options, meta) => {
|
|
19
|
-
const name = "unplugin-kubb";
|
|
20
|
-
const hooks = new Hookable();
|
|
21
|
-
const isVite = meta.framework === "vite";
|
|
22
|
-
hooks.hook("kubb:lifecycle:start", ({ version }) => {
|
|
23
|
-
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
24
|
-
});
|
|
25
|
-
hooks.hook("kubb:error", ({ error }) => {
|
|
26
|
-
console.error(`✗ ${error?.message || "failed"}`);
|
|
27
|
-
});
|
|
28
|
-
hooks.hook("kubb:warn", ({ message }) => {
|
|
29
|
-
console.warn(`⚠ ${message}`);
|
|
30
|
-
});
|
|
31
|
-
hooks.hook("kubb:info", ({ message }) => {
|
|
32
|
-
console.info(`ℹ ${message}`);
|
|
33
|
-
});
|
|
34
|
-
hooks.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
35
|
-
if (diagnostic.severity === "error") return hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
36
|
-
if (diagnostic.severity === "warning") return hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
37
|
-
return hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
38
|
-
});
|
|
39
|
-
hooks.hook("kubb:success", ({ message }) => {
|
|
40
|
-
console.log(`✓ ${message}`);
|
|
41
|
-
});
|
|
42
|
-
hooks.hook("kubb:plugin:end", ({ plugin, duration }) => {
|
|
43
|
-
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
44
|
-
console.log(`✓ ${plugin.name} completed in ${durationStr}`);
|
|
45
|
-
});
|
|
46
|
-
hooks.hook("kubb:files:processing:end", () => {
|
|
47
|
-
console.log("✓ Files written successfully");
|
|
48
|
-
});
|
|
49
|
-
hooks.hook("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
50
|
-
const result = status === "failed" ? "✗ Generation failed" : "✓ Generation succeeded";
|
|
51
|
-
console.log(config.name ? `${result} for ${config.name}` : result);
|
|
52
|
-
if (!diagnostics || !status) return;
|
|
53
|
-
const failedCount = Diagnostics.failedPlugins(diagnostics).length;
|
|
54
|
-
const pluginsCount = config.plugins.length;
|
|
55
|
-
const passedCount = pluginsCount - failedCount;
|
|
56
|
-
const { errors } = Diagnostics.count(diagnostics);
|
|
57
|
-
console.log(status === "success" ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})` : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? "error" : "errors"}`);
|
|
58
|
-
});
|
|
59
|
-
async function runBuild() {
|
|
60
|
-
if (!options?.config) throw new Error(`[${name}] Config is not set`);
|
|
61
|
-
const { adapter, output, plugins } = applyConfigDefaults(options.config, {
|
|
62
|
-
defaultAdapter: adapterOas(),
|
|
63
|
-
barrelPlugin: pluginBarrel(),
|
|
64
|
-
barrelPluginName: pluginBarrelName,
|
|
65
|
-
defaultOutput: {
|
|
66
|
-
barrel: false,
|
|
67
|
-
format: false,
|
|
68
|
-
lint: false
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
const userConfig = {
|
|
72
|
-
...options.config,
|
|
73
|
-
adapter,
|
|
74
|
-
parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],
|
|
75
|
-
plugins,
|
|
76
|
-
output
|
|
77
|
-
};
|
|
78
|
-
await hooks.callHook("kubb:lifecycle:start", { version });
|
|
79
|
-
const result = await createKubb(userConfig, { hooks }).generate();
|
|
80
|
-
await hooks.callHook("kubb:lifecycle:end");
|
|
81
|
-
if (!result.success) {
|
|
82
|
-
const failedCount = Diagnostics.failedPlugins(result.diagnostics).length;
|
|
83
|
-
const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
84
|
-
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
85
|
-
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
let generation;
|
|
89
|
-
return {
|
|
90
|
-
name,
|
|
91
|
-
enforce: "pre",
|
|
92
|
-
apply: isVite ? "build" : void 0,
|
|
93
|
-
async buildStart() {
|
|
94
|
-
generation ??= runBuild().catch((error) => {
|
|
95
|
-
generation = void 0;
|
|
96
|
-
throw error;
|
|
97
|
-
});
|
|
98
|
-
await generation;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
//#endregion
|
|
103
|
-
export { unpluginFactory as t };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=unpluginFactory-DKugbAOX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-DKugbAOX.js","names":["unpluginVersion"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, type Config, createKubb, Diagnostics, type KubbHooks, Hookable } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during the first `buildStart`. When the config omits them, it fills in defaults:\n * the OAS adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during\n * `build`. A missing config or a failed generation fails the host build.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new Hookable<KubbHooks>()\n const isVite = meta.framework === 'vite'\n\n hooks.hook('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.hook('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.hook('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.hook('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n // Unplugin has no diagnostic renderer, so route each problem by severity to a channel it logs on.\n hooks.hook('kubb:diagnostic', ({ diagnostic }) => {\n if (diagnostic.severity === 'error') return hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n if (diagnostic.severity === 'warning') return hooks.callHook('kubb:warn', { message: diagnostic.message })\n return hooks.callHook('kubb:info', { message: diagnostic.message })\n })\n\n hooks.hook('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n hooks.hook('kubb:files:processing:end', () => {\n console.log('✓ Files written successfully')\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n const result = status === 'failed' ? '✗ Generation failed' : '✓ Generation succeeded'\n console.log(config.name ? `${result} for ${config.name}` : result)\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const passedCount = pluginsCount - failedCount\n const { errors } = Diagnostics.count(diagnostics)\n\n // A run that fails before any plugin runs has 0 failed plugins, so show the error count.\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${passedCount} passed (${pluginsCount})`\n : `Kubb Summary: ✗ ${passedCount} passed | ${failedCount} failed (${pluginsCount}) | ${errors} ${errors === 1 ? 'error' : 'errors'}`,\n )\n })\n\n // Throw: webpack, Rspack, esbuild, and Farm contexts have no `this.error`.\n async function runBuild() {\n if (!options?.config) {\n throw new Error(`[${name}] Config is not set`)\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: false, format: false, lint: false },\n })\n\n const config = {\n ...options.config,\n adapter,\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],\n plugins,\n output,\n }\n const userConfig = config as Config\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const kubb = createKubb(userConfig, { hooks })\n const result = await kubb.generate()\n\n await hooks.callHook('kubb:lifecycle:end')\n\n if (!result.success) {\n const failedCount = Diagnostics.failedPlugins(result.diagnostics).length\n const firstError = result.diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n // A rerun with `output.clean` loops webpack and Rspack watchers, so generate once per instance.\n let generation: Promise<void> | undefined\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n generation ??= runBuild().catch((error: unknown) => {\n generation = undefined\n throw error\n })\n await generation\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;ACgBA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,QAAQ,IAAI,SAAoB;CACtC,MAAM,SAAS,KAAK,cAAc;CAElC,MAAM,KAAK,yBAAyB,EAAE,cAAc;EAClD,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAC3C,CAAC;CAED,MAAM,KAAK,eAAe,EAAE,YAAY;EACtC,QAAQ,MAAM,KAAK,OAAO,WAAW,UAAU;CACjD,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAED,MAAM,KAAK,cAAc,EAAE,cAAc;EACvC,QAAQ,KAAK,KAAK,SAAS;CAC7B,CAAC;CAGD,MAAM,KAAK,oBAAoB,EAAE,iBAAiB;EAChD,IAAI,WAAW,aAAa,SAAS,OAAO,MAAM,SAAS,cAAc,EAAE,OAAO,WAAW,SAAS,IAAI,MAAM,WAAW,OAAO,EAAE,CAAC;EACrI,IAAI,WAAW,aAAa,WAAW,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;EACzG,OAAO,MAAM,SAAS,aAAa,EAAE,SAAS,WAAW,QAAQ,CAAC;CACpE,CAAC;CAED,MAAM,KAAK,iBAAiB,EAAE,cAAc;EAC1C,QAAQ,IAAI,KAAK,SAAS;CAC5B,CAAC;CAED,MAAM,KAAK,oBAAoB,EAAE,QAAQ,eAAe;EACtD,MAAM,cAAc,YAAY,MAAO,IAAI,WAAW,IAAA,CAAM,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS;EAExF,QAAQ,IAAI,KAAK,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