unplugin-kubb 5.0.0-beta.100 → 5.0.0-beta.102
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 +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{unpluginFactory-Cj8fnyy9.cjs → unpluginFactory-Cr1rGH4R.cjs} +13 -48
- package/dist/unpluginFactory-Cr1rGH4R.cjs.map +1 -0
- package/dist/{unpluginFactory-BYY-auoy.js → unpluginFactory-DpmWkzAZ.js} +13 -28
- package/dist/unpluginFactory-DpmWkzAZ.js.map +1 -0
- package/dist/unpluginFactory.cjs +1 -1
- package/dist/unpluginFactory.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -6
- package/dist/unpluginFactory-BYY-auoy.js.map +0 -1
- package/dist/unpluginFactory-Cj8fnyy9.cjs.map +0 -1
package/dist/astro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.cjs");
|
|
2
2
|
const require_vite = require("./vite.cjs");
|
|
3
3
|
//#region src/astro.ts
|
|
4
4
|
var astro_default = /* @__PURE__ */ require_unpluginFactory.__name((options) => ({
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
3
3
|
//#region src/esbuild.ts
|
|
4
4
|
var esbuild_default = createEsbuildPlugin(unpluginFactory);
|
package/dist/farm.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ 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-Cr1rGH4R.cjs");
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
const plugin = /* #__PURE__ */ (0, require("unplugin").createUnplugin)(require_unpluginFactory.unpluginFactory);
|
|
8
8
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const plugin = /* #__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/nuxt.cjs
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createRolldownPlugin } from "unplugin";
|
|
3
3
|
//#region src/rolldown.ts
|
|
4
4
|
var rolldown_default = createRolldownPlugin(unpluginFactory);
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createRollupPlugin } from "unplugin";
|
|
3
3
|
//#region src/rollup.ts
|
|
4
4
|
var rollup_default = createRollupPlugin(unpluginFactory);
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createRspackPlugin } from "unplugin";
|
|
3
3
|
//#region src/rspack.ts
|
|
4
4
|
var rspack_default = createRspackPlugin(unpluginFactory);
|
|
@@ -1,37 +1,16 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __name = (target, value) => __defProp(target, "name", {
|
|
5
4
|
value,
|
|
6
5
|
configurable: true
|
|
7
6
|
});
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
-
key = keys[i];
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: ((k) => from[k]).bind(null, key),
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
7
|
//#endregion
|
|
27
|
-
let node_process = require("node:process");
|
|
28
|
-
node_process = __toESM(node_process, 1);
|
|
29
8
|
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
30
9
|
let _kubb_core = require("@kubb/core");
|
|
31
10
|
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
32
11
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
33
12
|
//#region package.json
|
|
34
|
-
var version = "5.0.0-beta.
|
|
13
|
+
var version = "5.0.0-beta.102";
|
|
35
14
|
//#endregion
|
|
36
15
|
//#region src/unpluginFactory.ts
|
|
37
16
|
/**
|
|
@@ -57,6 +36,11 @@ const unpluginFactory = (options, meta) => {
|
|
|
57
36
|
hooks.hook("kubb:info", ({ message }) => {
|
|
58
37
|
console.info(`ℹ ${message}`);
|
|
59
38
|
});
|
|
39
|
+
hooks.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
40
|
+
if (diagnostic.severity === "error") return hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
41
|
+
if (diagnostic.severity === "warning") return hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
42
|
+
return hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
43
|
+
});
|
|
60
44
|
hooks.hook("kubb:success", ({ message }) => {
|
|
61
45
|
console.log(`✓ ${message}`);
|
|
62
46
|
});
|
|
@@ -85,43 +69,24 @@ const unpluginFactory = (options, meta) => {
|
|
|
85
69
|
barrelPlugin: (0, _kubb_plugin_barrel.pluginBarrel)(),
|
|
86
70
|
barrelPluginName: _kubb_plugin_barrel.pluginBarrelName,
|
|
87
71
|
defaultOutput: {
|
|
88
|
-
barrel:
|
|
72
|
+
barrel: false,
|
|
89
73
|
format: false,
|
|
90
74
|
lint: false
|
|
91
75
|
}
|
|
92
76
|
});
|
|
93
|
-
const
|
|
77
|
+
const userConfig = {
|
|
94
78
|
...options.config,
|
|
95
79
|
adapter,
|
|
96
80
|
parsers: options.config.parsers?.length ? options.config.parsers : [(0, _kubb_parser_ts.parserTs)(), (0, _kubb_parser_ts.parserTsx)()],
|
|
97
81
|
plugins,
|
|
98
82
|
output
|
|
99
83
|
};
|
|
100
|
-
const hrStart = node_process.default.hrtime();
|
|
101
84
|
await hooks.callHook("kubb:lifecycle:start", { version });
|
|
102
|
-
const
|
|
103
|
-
await kubb.setup();
|
|
104
|
-
await hooks.callHook("kubb:generation:start", { config: kubb.config });
|
|
105
|
-
const { diagnostics, files, storage } = await kubb.safeBuild();
|
|
106
|
-
const hasFailures = _kubb_core.Diagnostics.hasError(diagnostics);
|
|
107
|
-
for (const diagnostic of diagnostics) {
|
|
108
|
-
if (!_kubb_core.Diagnostics.isProblem(diagnostic)) continue;
|
|
109
|
-
if (diagnostic.severity === "error") await hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
110
|
-
else if (diagnostic.severity === "warning") await hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
111
|
-
else await hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
112
|
-
}
|
|
113
|
-
await hooks.callHook("kubb:generation:end", {
|
|
114
|
-
config: kubb.config,
|
|
115
|
-
storage,
|
|
116
|
-
diagnostics,
|
|
117
|
-
filesCreated: files.length,
|
|
118
|
-
status: hasFailures ? "failed" : "success",
|
|
119
|
-
hrStart
|
|
120
|
-
});
|
|
85
|
+
const result = await (0, _kubb_core.createKubb)(userConfig, { hooks }).generate();
|
|
121
86
|
await hooks.callHook("kubb:lifecycle:end");
|
|
122
|
-
if (
|
|
123
|
-
const failedCount = _kubb_core.Diagnostics.failedPlugins(diagnostics).length;
|
|
124
|
-
const firstError = diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
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");
|
|
125
90
|
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
126
91
|
if (ctx.error) {
|
|
127
92
|
ctx.error(`[${name}] ${message}`);
|
|
@@ -154,4 +119,4 @@ Object.defineProperty(exports, "unpluginFactory", {
|
|
|
154
119
|
}
|
|
155
120
|
});
|
|
156
121
|
|
|
157
|
-
//# sourceMappingURL=unpluginFactory-
|
|
122
|
+
//# sourceMappingURL=unpluginFactory-Cr1rGH4R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-Cr1rGH4R.cjs","names":["Hookable","Diagnostics","pluginBarrelName","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\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\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 `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;ACqBA,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,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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AAAA;GAClB,eAAe;IAAE,QAAQ;IAAO,QAAQ;IAAO,MAAM;GAAM;EAC7D,CAAC;EASD,MAAM,aAAa;GANjB,GAAG,QAAQ;GACX;GACA,SAAS,QAAQ,OAAO,SAAS,SAAS,QAAQ,OAAO,UAAU,EAAA,GAAA,gBAAA,SAAA,CAAU,IAAA,GAAA,gBAAA,UAAA,CAAa,CAAC;GAC3F;GACA;EAEsB;EAExB,MAAM,MAAM,SAAS,wBAAwB,EAAWC,QAAgB,CAAC;EAGzE,MAAM,SAAS,OAAA,GAAA,WAAA,WAAA,CADS,YAAY,EAAE,MAAM,CACpB,CAAC,CAAC,SAAS;EAEnC,MAAM,MAAM,SAAS,oBAAoB;EAEzC,IAAI,CAAC,OAAO,SAAS;GACnB,MAAM,cAAcF,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;GAC7G,IAAI,IAAI,OAAO;IACb,IAAI,MAAM,IAAI,KAAK,IAAI,SAAS;IAChC;GACF;GAEA,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAEA,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,MAAM,SAAS,IAAgC;EACjD;EACA,MAAM,CAAC;CACT;AACF"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import process from "node:process";
|
|
3
2
|
import { adapterOas } from "@kubb/adapter-oas";
|
|
4
3
|
import { Diagnostics, Hookable, applyConfigDefaults, createKubb } from "@kubb/core";
|
|
5
4
|
import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
|
|
6
5
|
import { parserTs, parserTsx } from "@kubb/parser-ts";
|
|
7
6
|
//#region package.json
|
|
8
|
-
var version = "5.0.0-beta.
|
|
7
|
+
var version = "5.0.0-beta.102";
|
|
9
8
|
//#endregion
|
|
10
9
|
//#region src/unpluginFactory.ts
|
|
11
10
|
/**
|
|
@@ -31,6 +30,11 @@ const unpluginFactory = (options, meta) => {
|
|
|
31
30
|
hooks.hook("kubb:info", ({ message }) => {
|
|
32
31
|
console.info(`ℹ ${message}`);
|
|
33
32
|
});
|
|
33
|
+
hooks.hook("kubb:diagnostic", ({ diagnostic }) => {
|
|
34
|
+
if (diagnostic.severity === "error") return hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
35
|
+
if (diagnostic.severity === "warning") return hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
36
|
+
return hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
37
|
+
});
|
|
34
38
|
hooks.hook("kubb:success", ({ message }) => {
|
|
35
39
|
console.log(`✓ ${message}`);
|
|
36
40
|
});
|
|
@@ -59,43 +63,24 @@ const unpluginFactory = (options, meta) => {
|
|
|
59
63
|
barrelPlugin: pluginBarrel(),
|
|
60
64
|
barrelPluginName: pluginBarrelName,
|
|
61
65
|
defaultOutput: {
|
|
62
|
-
barrel:
|
|
66
|
+
barrel: false,
|
|
63
67
|
format: false,
|
|
64
68
|
lint: false
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
|
-
const
|
|
71
|
+
const userConfig = {
|
|
68
72
|
...options.config,
|
|
69
73
|
adapter,
|
|
70
74
|
parsers: options.config.parsers?.length ? options.config.parsers : [parserTs(), parserTsx()],
|
|
71
75
|
plugins,
|
|
72
76
|
output
|
|
73
77
|
};
|
|
74
|
-
const hrStart = process.hrtime();
|
|
75
78
|
await hooks.callHook("kubb:lifecycle:start", { version });
|
|
76
|
-
const
|
|
77
|
-
await kubb.setup();
|
|
78
|
-
await hooks.callHook("kubb:generation:start", { config: kubb.config });
|
|
79
|
-
const { diagnostics, files, storage } = await kubb.safeBuild();
|
|
80
|
-
const hasFailures = Diagnostics.hasError(diagnostics);
|
|
81
|
-
for (const diagnostic of diagnostics) {
|
|
82
|
-
if (!Diagnostics.isProblem(diagnostic)) continue;
|
|
83
|
-
if (diagnostic.severity === "error") await hooks.callHook("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
84
|
-
else if (diagnostic.severity === "warning") await hooks.callHook("kubb:warn", { message: diagnostic.message });
|
|
85
|
-
else await hooks.callHook("kubb:info", { message: diagnostic.message });
|
|
86
|
-
}
|
|
87
|
-
await hooks.callHook("kubb:generation:end", {
|
|
88
|
-
config: kubb.config,
|
|
89
|
-
storage,
|
|
90
|
-
diagnostics,
|
|
91
|
-
filesCreated: files.length,
|
|
92
|
-
status: hasFailures ? "failed" : "success",
|
|
93
|
-
hrStart
|
|
94
|
-
});
|
|
79
|
+
const result = await createKubb(userConfig, { hooks }).generate();
|
|
95
80
|
await hooks.callHook("kubb:lifecycle:end");
|
|
96
|
-
if (
|
|
97
|
-
const failedCount = Diagnostics.failedPlugins(diagnostics).length;
|
|
98
|
-
const firstError = diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
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");
|
|
99
84
|
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
100
85
|
if (ctx.error) {
|
|
101
86
|
ctx.error(`[${name}] ${message}`);
|
|
@@ -117,4 +102,4 @@ const unpluginFactory = (options, meta) => {
|
|
|
117
102
|
//#endregion
|
|
118
103
|
export { unpluginFactory as t };
|
|
119
104
|
|
|
120
|
-
//# sourceMappingURL=unpluginFactory-
|
|
105
|
+
//# sourceMappingURL=unpluginFactory-DpmWkzAZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-DpmWkzAZ.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\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\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 `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;ACqBA,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,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AO,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACxH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAC7G,IAAI,IAAI,OAAO;IACb,IAAI,MAAM,IAAI,KAAK,IAAI,SAAS;IAChC;GACF;GAEA,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAEA,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,MAAM,SAAS,IAAgC;EACjD;EACA,MAAM,CAAC;CACT;AACF"}
|
package/dist/unpluginFactory.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
2
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.cjs");
|
|
3
3
|
exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
|
package/dist/unpluginFactory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
export { unpluginFactory };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-Cr1rGH4R.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DpmWkzAZ.js";
|
|
2
2
|
import { createWebpackPlugin } from "unplugin";
|
|
3
3
|
//#region src/webpack.ts
|
|
4
4
|
var webpack_default = createWebpackPlugin(unpluginFactory);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-kubb",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.102",
|
|
4
4
|
"description": "Integration of Kubb for Vite, Webpack, Rollup, esbuild, Rspack, Nuxt, and Astro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"unplugin": "^3.3.0",
|
|
103
|
-
"@kubb/
|
|
104
|
-
"@kubb/
|
|
105
|
-
"@kubb/
|
|
106
|
-
"@kubb/
|
|
103
|
+
"@kubb/core": "5.0.0-beta.102",
|
|
104
|
+
"@kubb/parser-ts": "5.0.0-beta.102",
|
|
105
|
+
"@kubb/plugin-barrel": "5.0.0-beta.102",
|
|
106
|
+
"@kubb/adapter-oas": "5.0.0-beta.102"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@farmfe/core": "^1.7.11",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"rollup": "^4.62.2",
|
|
115
115
|
"vite": "^8.1.4",
|
|
116
116
|
"webpack": "^5.108.4",
|
|
117
|
-
"@kubb/ast": "5.0.0-beta.
|
|
117
|
+
"@kubb/ast": "5.0.0-beta.102"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"@farmfe/core": "^1.7.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-BYY-auoy.js","names":["unpluginVersion","userConfig"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import process from 'node:process'\nimport { 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\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\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 `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 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 const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: { type: 'named' }, 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 hrStart = process.hrtime()\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const userConfig = config as Config\n\n const kubb = createKubb(userConfig, { hooks })\n await kubb.setup()\n\n await hooks.callHook('kubb:generation:start', { config: kubb.config })\n\n const { diagnostics, files, storage } = await kubb.safeBuild()\n\n const hasFailures = Diagnostics.hasError(diagnostics)\n\n // Surface every problem by severity. Unplugin has no diagnostic renderer, so route\n // errors/warnings/info to the channels it does listen on. Non-problem diagnostics are skipped.\n for (const diagnostic of diagnostics) {\n if (!Diagnostics.isProblem(diagnostic)) {\n continue\n }\n if (diagnostic.severity === 'error') {\n await hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n } else if (diagnostic.severity === 'warning') {\n await hooks.callHook('kubb:warn', { message: diagnostic.message })\n } else {\n await hooks.callHook('kubb:info', { message: diagnostic.message })\n }\n }\n\n await hooks.callHook('kubb:generation:end', {\n config: kubb.config,\n storage,\n diagnostics,\n filesCreated: files.length,\n status: hasFailures ? 'failed' : 'success',\n hrStart,\n })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n if (hasFailures) {\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const firstError = 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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;ACsBA,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;CAED,MAAM,KAAK,iBAAiB,EAAE,cAAc;EAC1C,QAAQ,IAAI,KAAK,SAAS;CAC5B,CAAC;CAED,MAAM,KAAK,oBAAoB,EAAE,QAAQ,eAAe;EACtD,MAAM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fnyy9.cjs","names":["Hookable","Diagnostics","pluginBarrelName","process","unpluginVersion","userConfig"],"sources":["../package.json","../src/unpluginFactory.ts"],"sourcesContent":["","import process from 'node:process'\nimport { 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\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\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 `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `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 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 const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.hook('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${successCount} successful, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${successCount} successful, ✗ ${failedCount} failed, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const { adapter, output, plugins } = applyConfigDefaults(options.config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: { type: 'named' }, 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 hrStart = process.hrtime()\n\n await hooks.callHook('kubb:lifecycle:start', { version: unpluginVersion })\n\n const userConfig = config as Config\n\n const kubb = createKubb(userConfig, { hooks })\n await kubb.setup()\n\n await hooks.callHook('kubb:generation:start', { config: kubb.config })\n\n const { diagnostics, files, storage } = await kubb.safeBuild()\n\n const hasFailures = Diagnostics.hasError(diagnostics)\n\n // Surface every problem by severity. Unplugin has no diagnostic renderer, so route\n // errors/warnings/info to the channels it does listen on. Non-problem diagnostics are skipped.\n for (const diagnostic of diagnostics) {\n if (!Diagnostics.isProblem(diagnostic)) {\n continue\n }\n if (diagnostic.severity === 'error') {\n await hooks.callHook('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n } else if (diagnostic.severity === 'warning') {\n await hooks.callHook('kubb:warn', { message: diagnostic.message })\n } else {\n await hooks.callHook('kubb:info', { message: diagnostic.message })\n }\n }\n\n await hooks.callHook('kubb:generation:end', {\n config: kubb.config,\n storage,\n diagnostics,\n filesCreated: files.length,\n status: hasFailures ? 'failed' : 'success',\n hrStart,\n })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n if (hasFailures) {\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const firstError = 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 if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACsBA,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,QAAQ,KAAK,KAAK,SAAS;CAC7B,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;E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