@kubb/core 4.3.1 → 4.4.1
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/{URLPath-BYceu_vY.js → URLPath-DbWtfVa1.js} +2 -3
- package/dist/{URLPath-BYceu_vY.js.map → URLPath-DbWtfVa1.js.map} +1 -1
- package/dist/{URLPath-8WVzHBnA.cjs → URLPath-Dir2mxRT.cjs} +6 -7
- package/dist/{URLPath-8WVzHBnA.cjs.map → URLPath-Dir2mxRT.cjs.map} +1 -1
- package/dist/{chunk-CZg_9w7l.cjs → chunk-CUT6urMc.cjs} +0 -23
- package/dist/hooks.cjs +6 -6
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +5 -5
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +128 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -18
- package/dist/index.d.ts +22 -18
- package/dist/index.js +116 -53
- package/dist/index.js.map +1 -1
- package/dist/{logger-BXL0YCrv.cjs → logger-BIzTtBYJ.cjs} +48 -5
- package/dist/logger-BIzTtBYJ.cjs.map +1 -0
- package/dist/{logger-DpoDtxfo.d.cts → logger-BjfDkvkn.d.cts} +1 -1
- package/dist/{logger-BA-za85-.d.ts → logger-BwhJWK-H.d.ts} +1 -1
- package/dist/{logger-CDxSrFkR.js → logger-Bxe022ug.js} +39 -4
- package/dist/logger-Bxe022ug.js.map +1 -0
- package/dist/logger.cjs +1 -2
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -2
- package/dist/{prompt-DgONOpPH.cjs → prompt-D5DZPtWc.cjs} +2 -2
- package/dist/{prompt-DgONOpPH.cjs.map → prompt-D5DZPtWc.cjs.map} +1 -1
- package/dist/{prompt-DBVnG4Me.js → prompt-xM0onfy8.js} +1 -1
- package/dist/{prompt-DBVnG4Me.js.map → prompt-xM0onfy8.js.map} +1 -1
- package/dist/transformers-CeNW0G32.js +339 -0
- package/dist/transformers-CeNW0G32.js.map +1 -0
- package/dist/transformers-DWLXDYKb.cjs +443 -0
- package/dist/transformers-DWLXDYKb.cjs.map +1 -0
- package/dist/transformers.cjs +7 -6
- package/dist/transformers.js +1 -3
- package/dist/{types-DPeNK0FO.d.ts → types-CVONMhN_.d.cts} +51 -53
- package/dist/{types-DNxlynJr.d.cts → types-CyDeSlGF.d.ts} +51 -53
- package/dist/{types-BzI9JlV8.d.ts → types-DCR_QgGt.d.ts} +1 -1
- package/dist/{types-C3ea5qNG.d.cts → types-DueAg3XP.d.cts} +1 -1
- package/dist/utils.cjs +7 -7
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +4 -6
- package/dist/utils.js.map +1 -1
- package/package.json +15 -20
- package/src/BarrelManager.ts +1 -1
- package/src/FileManager.ts +5 -2
- package/src/PluginManager.ts +4 -8
- package/src/build.ts +39 -42
- package/src/fs/index.ts +0 -7
- package/src/hooks/useMode.ts +2 -2
- package/src/hooks/usePlugin.ts +1 -1
- package/src/hooks/usePluginManager.ts +1 -1
- package/src/plugin.ts +10 -5
- package/src/types.ts +3 -2
- package/src/utils/TreeNode.ts +1 -1
- package/dist/acorn-BAVXZMtK.cjs +0 -5082
- package/dist/acorn-BAVXZMtK.cjs.map +0 -1
- package/dist/acorn-D-VhIOLw.js +0 -5080
- package/dist/acorn-D-VhIOLw.js.map +0 -1
- package/dist/angular-Bp0XO9db.cjs +0 -3631
- package/dist/angular-Bp0XO9db.cjs.map +0 -1
- package/dist/angular-Czhp4eq5.js +0 -3629
- package/dist/angular-Czhp4eq5.js.map +0 -1
- package/dist/babel-DCR_B4Qn.js +0 -10033
- package/dist/babel-DCR_B4Qn.js.map +0 -1
- package/dist/babel-NI0v59ga.cjs +0 -10035
- package/dist/babel-NI0v59ga.cjs.map +0 -1
- package/dist/casing-BSeq_teY.js +0 -100
- package/dist/casing-BSeq_teY.js.map +0 -1
- package/dist/casing-CP-9GGdK.cjs +0 -112
- package/dist/casing-CP-9GGdK.cjs.map +0 -1
- package/dist/chunk-1SJ2vVWa.js +0 -35
- package/dist/estree-C3BZPlpU.cjs +0 -6930
- package/dist/estree-C3BZPlpU.cjs.map +0 -1
- package/dist/estree-DU2NummP.js +0 -6926
- package/dist/estree-DU2NummP.js.map +0 -1
- package/dist/flow-CWUBUkoi.cjs +0 -52252
- package/dist/flow-CWUBUkoi.cjs.map +0 -1
- package/dist/flow-JiEbweKj.js +0 -52250
- package/dist/flow-JiEbweKj.js.map +0 -1
- package/dist/fs-BIPMUfpW.js +0 -90
- package/dist/fs-BIPMUfpW.js.map +0 -1
- package/dist/fs-RSVoUw3S.cjs +0 -141
- package/dist/fs-RSVoUw3S.cjs.map +0 -1
- package/dist/fs.cjs +0 -17
- package/dist/fs.d.cts +0 -2
- package/dist/fs.d.ts +0 -2
- package/dist/fs.js +0 -4
- package/dist/glimmer-CX9OqG1j.cjs +0 -7275
- package/dist/glimmer-CX9OqG1j.cjs.map +0 -1
- package/dist/glimmer-t9nWn9aE.js +0 -7271
- package/dist/glimmer-t9nWn9aE.js.map +0 -1
- package/dist/graphql-DjErlIi5.js +0 -1897
- package/dist/graphql-DjErlIi5.js.map +0 -1
- package/dist/graphql-GOxQAKxM.cjs +0 -1902
- package/dist/graphql-GOxQAKxM.cjs.map +0 -1
- package/dist/html-CWrdYAhQ.cjs +0 -6560
- package/dist/html-CWrdYAhQ.cjs.map +0 -1
- package/dist/html-_apcbx34.js +0 -6555
- package/dist/html-_apcbx34.js.map +0 -1
- package/dist/index-BTe91LHd.d.ts +0 -145
- package/dist/index-BmQIxvw0.d.cts +0 -144
- package/dist/logger-BXL0YCrv.cjs.map +0 -1
- package/dist/logger-CDxSrFkR.js.map +0 -1
- package/dist/markdown-ckUc3Q6q.js +0 -6750
- package/dist/markdown-ckUc3Q6q.js.map +0 -1
- package/dist/markdown-pzqiRmft.cjs +0 -6755
- package/dist/markdown-pzqiRmft.cjs.map +0 -1
- package/dist/meriyah-BjnGqpUs.js +0 -8928
- package/dist/meriyah-BjnGqpUs.js.map +0 -1
- package/dist/meriyah-D_x7itbT.cjs +0 -8930
- package/dist/meriyah-D_x7itbT.cjs.map +0 -1
- package/dist/mocks.cjs +0 -16830
- package/dist/mocks.cjs.map +0 -1
- package/dist/mocks.d.cts +0 -13
- package/dist/mocks.d.ts +0 -13
- package/dist/mocks.js +0 -16818
- package/dist/mocks.js.map +0 -1
- package/dist/postcss-B_c2wbFu.cjs +0 -6689
- package/dist/postcss-B_c2wbFu.cjs.map +0 -1
- package/dist/postcss-v7BP6SZ-.js +0 -6684
- package/dist/postcss-v7BP6SZ-.js.map +0 -1
- package/dist/transformers-BH0KLJJP.cjs +0 -804
- package/dist/transformers-BH0KLJJP.cjs.map +0 -1
- package/dist/transformers-DzHGqYO2.js +0 -702
- package/dist/transformers-DzHGqYO2.js.map +0 -1
- package/dist/typescript-6kMN6Wqz.cjs +0 -23014
- package/dist/typescript-6kMN6Wqz.cjs.map +0 -1
- package/dist/typescript-B_IBfKSe.js +0 -23002
- package/dist/typescript-B_IBfKSe.js.map +0 -1
- package/dist/typescript-C5hce4HG.cjs +0 -4
- package/dist/typescript-Cas1XcNz.js +0 -3
- package/dist/write-BJfM7G1_.cjs +0 -49
- package/dist/write-BJfM7G1_.cjs.map +0 -1
- package/dist/write-CxO1CDML.js +0 -40
- package/dist/write-CxO1CDML.js.map +0 -1
- package/dist/yaml-BfWM_B73.js +0 -5209
- package/dist/yaml-BfWM_B73.js.map +0 -1
- package/dist/yaml-DZs6MhV1.cjs +0 -5215
- package/dist/yaml-DZs6MhV1.cjs.map +0 -1
- package/src/fs/types.ts +0 -132
- package/src/fs/unlink.ts +0 -5
- package/src/mocks/index.ts +0 -82
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as camelCase } from "./casing-BSeq_teY.js";
|
|
1
|
+
import { m as camelCase, v as isValidVarName } from "./transformers-CeNW0G32.js";
|
|
3
2
|
|
|
4
3
|
//#region src/utils/uniqueName.ts
|
|
5
4
|
function getUniqueName(originalName, data) {
|
|
@@ -114,4 +113,4 @@ var URLPath = class {
|
|
|
114
113
|
|
|
115
114
|
//#endregion
|
|
116
115
|
export { getUniqueName as n, setUniqueName as r, URLPath as t };
|
|
117
|
-
//# sourceMappingURL=URLPath-
|
|
116
|
+
//# sourceMappingURL=URLPath-DbWtfVa1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"URLPath-
|
|
1
|
+
{"version":3,"file":"URLPath-DbWtfVa1.js","names":["#options","params: Record<string, string>"],"sources":["../src/utils/uniqueName.ts","../src/utils/URLPath.ts"],"sourcesContent":["export function getUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n originalName += used\n }\n data[originalName] = 1\n return originalName\n}\n\nexport function setUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n\n return originalName\n }\n data[originalName] = 1\n return originalName\n}\n","import { camelCase, isValidVarName } from '../transformers'\n\nexport type URLObject = {\n url: string\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n type?: 'path' | 'template'\n replacer?: (pathParam: string) => string\n stringify?: boolean\n}\n\ntype Options = {\n casing?: 'camelcase'\n}\n\nexport class URLPath {\n path: string\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n\n return this\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n get URL(): string {\n return this.toURLPath()\n }\n get isURL(): boolean {\n try {\n const url = new URL(this.path)\n if (url?.href) {\n return true\n }\n } catch (_error) {\n return false\n }\n return false\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n get template(): string {\n return this.toTemplateString()\n }\n get object(): URLObject | string {\n return this.toObject()\n }\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n let newPath = this.path.replaceAll('{', '${')\n\n if (found) {\n newPath = found.reduce((prev, path) => {\n const pathWithoutBrackets = path.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : camelCase(pathWithoutBrackets)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n return prev.replace(path, `\\${${replacer ? replacer(param) : param}}`)\n }, this.path)\n }\n\n return `\\`${prefix}${newPath}\\``\n }\n\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n\n if (!found) {\n return undefined\n }\n\n const params: Record<string, string> = {}\n found.forEach((item) => {\n item = item.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(item) ? item : camelCase(item)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n const key = replacer ? replacer(param) : param\n\n params[key] = key\n }, this.path)\n\n return params\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n toURLPath(): string {\n return this.path.replaceAll('{', ':').replaceAll('}', '')\n }\n}\n"],"mappings":";;;AAAA,SAAgB,cAAc,cAAsB,MAAsC;CACxF,IAAI,OAAO,KAAK,iBAAiB;AACjC,KAAI,MAAM;AACR,OAAK,gBAAgB,EAAE;AACvB,kBAAgB;;AAElB,MAAK,gBAAgB;AACrB,QAAO;;AAGT,SAAgB,cAAc,cAAsB,MAAsC;CACxF,IAAI,OAAO,KAAK,iBAAiB;AACjC,KAAI,MAAM;AACR,OAAK,gBAAgB,EAAE;AAEvB,SAAO;;AAET,MAAK,gBAAgB;AACrB,QAAO;;;;;ACDT,IAAa,UAAb,MAAqB;CACnB;CACA;CAEA,YAAY,MAAc,UAAmB,EAAE,EAAE;AAC/C,OAAK,OAAO;AACZ,QAAKA,UAAW;AAEhB,SAAO;;;;;;CAOT,IAAI,MAAc;AAChB,SAAO,KAAK,WAAW;;CAEzB,IAAI,QAAiB;AACnB,MAAI;AAEF,OADY,IAAI,IAAI,KAAK,KAAK,EACrB,KACP,QAAO;WAEF,QAAQ;AACf,UAAO;;AAET,SAAO;;;;;;;;CAST,IAAI,WAAmB;AACrB,SAAO,KAAK,kBAAkB;;CAEhC,IAAI,SAA6B;AAC/B,SAAO,KAAK,UAAU;;CAExB,IAAI,SAA6C;AAC/C,SAAO,KAAK,WAAW;;CAGzB,SAAS,EAAE,OAAO,QAAQ,UAAU,cAA6B,EAAE,EAAsB;EACvF,MAAM,SAAS;GACb,KAAK,SAAS,SAAS,KAAK,WAAW,GAAG,KAAK,iBAAiB,EAAE,UAAU,CAAC;GAC7E,QAAQ,KAAK,WAAW;GACzB;AAED,MAAI,WAAW;AACb,OAAI,SAAS,WACX,QAAO,KAAK,UAAU,OAAO,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;AAGvE,OAAI,OAAO,OACT,QAAO,WAAW,OAAO,IAAI,aAAa,KAAK,UAAU,OAAO,OAAO,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;AAGlH,UAAO,WAAW,OAAO,IAAI;;AAG/B,SAAO;;;;;;;;CAST,iBAAiB,EAAE,SAAS,IAAI,aAA4E,EAAE,EAAU;EAEtH,MAAM,QAAQ,KAAK,KAAK,MADV,aACsB;EACpC,IAAI,UAAU,KAAK,KAAK,WAAW,KAAK,KAAK;AAE7C,MAAI,MACF,WAAU,MAAM,QAAQ,MAAM,SAAS;GACrC,MAAM,sBAAsB,KAAK,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;GAExE,IAAI,QAAQ,eAAe,oBAAoB,GAAG,sBAAsB,UAAU,oBAAoB;AAEtG,OAAI,MAAKA,QAAS,WAAW,YAC3B,SAAQ,UAAU,MAAM;AAG1B,UAAO,KAAK,QAAQ,MAAM,MAAM,WAAW,SAAS,MAAM,GAAG,MAAM,GAAG;KACrE,KAAK,KAAK;AAGf,SAAO,KAAK,SAAS,QAAQ;;CAG/B,UAAU,UAA8E;EAEtF,MAAM,QAAQ,KAAK,KAAK,MADV,aACsB;AAEpC,MAAI,CAAC,MACH;EAGF,MAAMC,SAAiC,EAAE;AACzC,QAAM,SAAS,SAAS;AACtB,UAAO,KAAK,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;GAEnD,IAAI,QAAQ,eAAe,KAAK,GAAG,OAAO,UAAU,KAAK;AAEzD,OAAI,MAAKD,QAAS,WAAW,YAC3B,SAAQ,UAAU,MAAM;GAG1B,MAAM,MAAM,WAAW,SAAS,MAAM,GAAG;AAEzC,UAAO,OAAO;KACb,KAAK,KAAK;AAEb,SAAO;;;;;;CAOT,YAAoB;AAClB,SAAO,KAAK,KAAK,WAAW,KAAK,IAAI,CAAC,WAAW,KAAK,GAAG"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const require_transformers = require('./transformers-
|
|
2
|
-
const require_casing = require('./casing-CP-9GGdK.cjs');
|
|
1
|
+
const require_transformers = require('./transformers-DWLXDYKb.cjs');
|
|
3
2
|
|
|
4
3
|
//#region src/utils/uniqueName.ts
|
|
5
4
|
function getUniqueName(originalName, data) {
|
|
@@ -84,8 +83,8 @@ var URLPath = class {
|
|
|
84
83
|
let newPath = this.path.replaceAll("{", "${");
|
|
85
84
|
if (found) newPath = found.reduce((prev, path) => {
|
|
86
85
|
const pathWithoutBrackets = path.replaceAll("{", "").replaceAll("}", "");
|
|
87
|
-
let param = require_transformers.isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets :
|
|
88
|
-
if (this.#options.casing === "camelcase") param =
|
|
86
|
+
let param = require_transformers.isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : require_transformers.camelCase(pathWithoutBrackets);
|
|
87
|
+
if (this.#options.casing === "camelcase") param = require_transformers.camelCase(param);
|
|
89
88
|
return prev.replace(path, `\${${replacer ? replacer(param) : param}}`);
|
|
90
89
|
}, this.path);
|
|
91
90
|
return `\`${prefix}${newPath}\``;
|
|
@@ -96,8 +95,8 @@ var URLPath = class {
|
|
|
96
95
|
const params = {};
|
|
97
96
|
found.forEach((item) => {
|
|
98
97
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
99
|
-
let param = require_transformers.isValidVarName(item) ? item :
|
|
100
|
-
if (this.#options.casing === "camelcase") param =
|
|
98
|
+
let param = require_transformers.isValidVarName(item) ? item : require_transformers.camelCase(item);
|
|
99
|
+
if (this.#options.casing === "camelcase") param = require_transformers.camelCase(param);
|
|
101
100
|
const key = replacer ? replacer(param) : param;
|
|
102
101
|
params[key] = key;
|
|
103
102
|
}, this.path);
|
|
@@ -131,4 +130,4 @@ Object.defineProperty(exports, 'setUniqueName', {
|
|
|
131
130
|
return setUniqueName;
|
|
132
131
|
}
|
|
133
132
|
});
|
|
134
|
-
//# sourceMappingURL=URLPath-
|
|
133
|
+
//# sourceMappingURL=URLPath-Dir2mxRT.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"URLPath-
|
|
1
|
+
{"version":3,"file":"URLPath-Dir2mxRT.cjs","names":["#options","isValidVarName","camelCase","params: Record<string, string>"],"sources":["../src/utils/uniqueName.ts","../src/utils/URLPath.ts"],"sourcesContent":["export function getUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n originalName += used\n }\n data[originalName] = 1\n return originalName\n}\n\nexport function setUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n\n return originalName\n }\n data[originalName] = 1\n return originalName\n}\n","import { camelCase, isValidVarName } from '../transformers'\n\nexport type URLObject = {\n url: string\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n type?: 'path' | 'template'\n replacer?: (pathParam: string) => string\n stringify?: boolean\n}\n\ntype Options = {\n casing?: 'camelcase'\n}\n\nexport class URLPath {\n path: string\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n\n return this\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n get URL(): string {\n return this.toURLPath()\n }\n get isURL(): boolean {\n try {\n const url = new URL(this.path)\n if (url?.href) {\n return true\n }\n } catch (_error) {\n return false\n }\n return false\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n get template(): string {\n return this.toTemplateString()\n }\n get object(): URLObject | string {\n return this.toObject()\n }\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n let newPath = this.path.replaceAll('{', '${')\n\n if (found) {\n newPath = found.reduce((prev, path) => {\n const pathWithoutBrackets = path.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : camelCase(pathWithoutBrackets)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n return prev.replace(path, `\\${${replacer ? replacer(param) : param}}`)\n }, this.path)\n }\n\n return `\\`${prefix}${newPath}\\``\n }\n\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n\n if (!found) {\n return undefined\n }\n\n const params: Record<string, string> = {}\n found.forEach((item) => {\n item = item.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(item) ? item : camelCase(item)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n const key = replacer ? replacer(param) : param\n\n params[key] = key\n }, this.path)\n\n return params\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n toURLPath(): string {\n return this.path.replaceAll('{', ':').replaceAll('}', '')\n }\n}\n"],"mappings":";;;AAAA,SAAgB,cAAc,cAAsB,MAAsC;CACxF,IAAI,OAAO,KAAK,iBAAiB;AACjC,KAAI,MAAM;AACR,OAAK,gBAAgB,EAAE;AACvB,kBAAgB;;AAElB,MAAK,gBAAgB;AACrB,QAAO;;AAGT,SAAgB,cAAc,cAAsB,MAAsC;CACxF,IAAI,OAAO,KAAK,iBAAiB;AACjC,KAAI,MAAM;AACR,OAAK,gBAAgB,EAAE;AAEvB,SAAO;;AAET,MAAK,gBAAgB;AACrB,QAAO;;;;;ACDT,IAAa,UAAb,MAAqB;CACnB;CACA;CAEA,YAAY,MAAc,UAAmB,EAAE,EAAE;AAC/C,OAAK,OAAO;AACZ,QAAKA,UAAW;AAEhB,SAAO;;;;;;CAOT,IAAI,MAAc;AAChB,SAAO,KAAK,WAAW;;CAEzB,IAAI,QAAiB;AACnB,MAAI;AAEF,OADY,IAAI,IAAI,KAAK,KAAK,EACrB,KACP,QAAO;WAEF,QAAQ;AACf,UAAO;;AAET,SAAO;;;;;;;;CAST,IAAI,WAAmB;AACrB,SAAO,KAAK,kBAAkB;;CAEhC,IAAI,SAA6B;AAC/B,SAAO,KAAK,UAAU;;CAExB,IAAI,SAA6C;AAC/C,SAAO,KAAK,WAAW;;CAGzB,SAAS,EAAE,OAAO,QAAQ,UAAU,cAA6B,EAAE,EAAsB;EACvF,MAAM,SAAS;GACb,KAAK,SAAS,SAAS,KAAK,WAAW,GAAG,KAAK,iBAAiB,EAAE,UAAU,CAAC;GAC7E,QAAQ,KAAK,WAAW;GACzB;AAED,MAAI,WAAW;AACb,OAAI,SAAS,WACX,QAAO,KAAK,UAAU,OAAO,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;AAGvE,OAAI,OAAO,OACT,QAAO,WAAW,OAAO,IAAI,aAAa,KAAK,UAAU,OAAO,OAAO,CAAC,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;AAGlH,UAAO,WAAW,OAAO,IAAI;;AAG/B,SAAO;;;;;;;;CAST,iBAAiB,EAAE,SAAS,IAAI,aAA4E,EAAE,EAAU;EAEtH,MAAM,QAAQ,KAAK,KAAK,MADV,aACsB;EACpC,IAAI,UAAU,KAAK,KAAK,WAAW,KAAK,KAAK;AAE7C,MAAI,MACF,WAAU,MAAM,QAAQ,MAAM,SAAS;GACrC,MAAM,sBAAsB,KAAK,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;GAExE,IAAI,QAAQC,oCAAe,oBAAoB,GAAG,sBAAsBC,+BAAU,oBAAoB;AAEtG,OAAI,MAAKF,QAAS,WAAW,YAC3B,SAAQE,+BAAU,MAAM;AAG1B,UAAO,KAAK,QAAQ,MAAM,MAAM,WAAW,SAAS,MAAM,GAAG,MAAM,GAAG;KACrE,KAAK,KAAK;AAGf,SAAO,KAAK,SAAS,QAAQ;;CAG/B,UAAU,UAA8E;EAEtF,MAAM,QAAQ,KAAK,KAAK,MADV,aACsB;AAEpC,MAAI,CAAC,MACH;EAGF,MAAMC,SAAiC,EAAE;AACzC,QAAM,SAAS,SAAS;AACtB,UAAO,KAAK,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,GAAG;GAEnD,IAAI,QAAQF,oCAAe,KAAK,GAAG,OAAOC,+BAAU,KAAK;AAEzD,OAAI,MAAKF,QAAS,WAAW,YAC3B,SAAQE,+BAAU,MAAM;GAG1B,MAAM,MAAM,WAAW,SAAS,MAAM,GAAG;AAEzC,UAAO,OAAO;KACb,KAAK,KAAK;AAEb,SAAO;;;;;;CAOT,YAAoB;AAClB,SAAO,KAAK,KAAK,WAAW,KAAK,IAAI,CAAC,WAAW,KAAK,GAAG"}
|
|
@@ -5,17 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __export = (all) => {
|
|
12
|
-
let target = {};
|
|
13
|
-
for (var name in all) __defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
return target;
|
|
18
|
-
};
|
|
19
8
|
var __copyProps = (to, from, except, desc) => {
|
|
20
9
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
10
|
key = keys[i];
|
|
@@ -33,18 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
22
|
|
|
34
23
|
//#endregion
|
|
35
24
|
|
|
36
|
-
Object.defineProperty(exports, '__commonJS', {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return __commonJS;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, '__export', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return __export;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
25
|
Object.defineProperty(exports, '__toESM', {
|
|
49
26
|
enumerable: true,
|
|
50
27
|
get: function () {
|
package/dist/hooks.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-
|
|
2
|
-
let
|
|
3
|
-
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
3
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useMode.ts
|
|
6
6
|
function useMode() {
|
|
7
|
-
const { meta } = (0,
|
|
7
|
+
const { meta } = (0, __kubb_react_fabric.useApp)();
|
|
8
8
|
return meta.mode;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/hooks/usePlugin.ts
|
|
13
13
|
function usePlugin() {
|
|
14
|
-
const { meta } = (0,
|
|
14
|
+
const { meta } = (0, __kubb_react_fabric.useApp)();
|
|
15
15
|
return meta.plugin;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/hooks/usePluginManager.ts
|
|
20
20
|
function usePluginManager() {
|
|
21
|
-
const { meta } = (0,
|
|
21
|
+
const { meta } = (0, __kubb_react_fabric.useApp)();
|
|
22
22
|
return meta.pluginManager;
|
|
23
23
|
}
|
|
24
24
|
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,0CAA0C;AAElD,QAAO,KAAK;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,0CAA+C;AAEvD,QAAO,KAAK;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,0CAAmD;AAE3D,QAAO,KAAK"}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
1
|
+
import "./logger-BjfDkvkn.cjs";
|
|
2
|
+
import { c as Plugin, u as PluginFactoryOptions, x as PluginManager } from "./types-CVONMhN_.cjs";
|
|
3
|
+
import "./types-DueAg3XP.cjs";
|
|
4
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
5
5
|
|
|
6
6
|
//#region src/hooks/useMode.d.ts
|
|
7
|
-
declare function useMode(): Mode;
|
|
7
|
+
declare function useMode(): KubbFile.Mode;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/hooks/usePlugin.d.ts
|
|
10
10
|
declare function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions>;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
1
|
+
import "./logger-BwhJWK-H.js";
|
|
2
|
+
import { c as Plugin, u as PluginFactoryOptions, x as PluginManager } from "./types-CyDeSlGF.js";
|
|
3
|
+
import "./types-DCR_QgGt.js";
|
|
4
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
5
5
|
|
|
6
6
|
//#region src/hooks/useMode.d.ts
|
|
7
|
-
declare function useMode(): Mode;
|
|
7
|
+
declare function useMode(): KubbFile.Mode;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/hooks/usePlugin.d.ts
|
|
10
10
|
declare function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions>;
|
package/dist/hooks.js
CHANGED
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;AAGA,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,QAAiC;AAElD,QAAO,KAAK;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,QAAsC;AAEvD,QAAO,KAAK;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,SAAS,QAA0C;AAE3D,QAAO,KAAK"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_chunk = require('./chunk-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_transformers = require('./transformers-BH0KLJJP.cjs');
|
|
7
|
-
const require_URLPath = require('./URLPath-8WVzHBnA.cjs');
|
|
8
|
-
require('./casing-CP-9GGdK.cjs');
|
|
2
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
|
+
const require_logger = require('./logger-BIzTtBYJ.cjs');
|
|
4
|
+
const require_transformers = require('./transformers-DWLXDYKb.cjs');
|
|
5
|
+
const require_URLPath = require('./URLPath-Dir2mxRT.cjs');
|
|
9
6
|
let node_path = require("node:path");
|
|
10
7
|
node_path = require_chunk.__toESM(node_path);
|
|
11
|
-
let
|
|
12
|
-
|
|
8
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
9
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
10
|
+
let __kubb_react_fabric_parsers = require("@kubb/react-fabric/parsers");
|
|
11
|
+
__kubb_react_fabric_parsers = require_chunk.__toESM(__kubb_react_fabric_parsers);
|
|
12
|
+
let __kubb_react_fabric_plugins = require("@kubb/react-fabric/plugins");
|
|
13
|
+
__kubb_react_fabric_plugins = require_chunk.__toESM(__kubb_react_fabric_plugins);
|
|
13
14
|
let picocolors = require("picocolors");
|
|
14
15
|
picocolors = require_chunk.__toESM(picocolors);
|
|
15
16
|
let remeda = require("remeda");
|
|
16
17
|
remeda = require_chunk.__toESM(remeda);
|
|
18
|
+
let fs_extra = require("fs-extra");
|
|
19
|
+
fs_extra = require_chunk.__toESM(fs_extra);
|
|
20
|
+
let js_runtime = require("js-runtime");
|
|
21
|
+
js_runtime = require_chunk.__toESM(js_runtime);
|
|
17
22
|
let node_process = require("node:process");
|
|
18
23
|
node_process = require_chunk.__toESM(node_process);
|
|
19
|
-
let __kubb_fabric_core = require("@kubb/fabric-core");
|
|
20
|
-
__kubb_fabric_core = require_chunk.__toESM(__kubb_fabric_core);
|
|
21
24
|
let node_module = require("node:module");
|
|
22
25
|
node_module = require_chunk.__toESM(node_module);
|
|
23
26
|
let node_os = require("node:os");
|
|
@@ -68,6 +71,74 @@ function isInputPath(result) {
|
|
|
68
71
|
return !!result && "path" in result?.input;
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/fs/clean.ts
|
|
76
|
+
async function clean(path$3) {
|
|
77
|
+
return fs_extra.default.remove(path$3);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/fs/exists.ts
|
|
82
|
+
const reader$1 = (0, js_runtime.switcher)({
|
|
83
|
+
node: async (path$3) => {
|
|
84
|
+
return fs_extra.default.pathExists(path$3);
|
|
85
|
+
},
|
|
86
|
+
bun: async (path$3) => {
|
|
87
|
+
return Bun.file(path$3).exists();
|
|
88
|
+
}
|
|
89
|
+
}, "node");
|
|
90
|
+
const syncReader$1 = (0, js_runtime.switcher)({
|
|
91
|
+
node: (path$3) => {
|
|
92
|
+
return fs_extra.default.pathExistsSync(path$3);
|
|
93
|
+
},
|
|
94
|
+
bun: () => {
|
|
95
|
+
throw new Error("Bun cannot read sync");
|
|
96
|
+
}
|
|
97
|
+
}, "node");
|
|
98
|
+
async function exists(path$3) {
|
|
99
|
+
return reader$1(path$3);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/fs/read.ts
|
|
104
|
+
const reader = (0, js_runtime.switcher)({
|
|
105
|
+
node: async (path$3) => {
|
|
106
|
+
return fs_extra.default.readFile(path$3, { encoding: "utf8" });
|
|
107
|
+
},
|
|
108
|
+
bun: async (path$3) => {
|
|
109
|
+
return Bun.file(path$3).text();
|
|
110
|
+
}
|
|
111
|
+
}, "node");
|
|
112
|
+
const syncReader = (0, js_runtime.switcher)({
|
|
113
|
+
node: (path$3) => {
|
|
114
|
+
return fs_extra.default.readFileSync(path$3, { encoding: "utf8" });
|
|
115
|
+
},
|
|
116
|
+
bun: () => {
|
|
117
|
+
throw new Error("Bun cannot read sync");
|
|
118
|
+
}
|
|
119
|
+
}, "node");
|
|
120
|
+
async function read(path$3) {
|
|
121
|
+
return reader(path$3);
|
|
122
|
+
}
|
|
123
|
+
function readSync(path$3) {
|
|
124
|
+
return syncReader(path$3);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/fs/utils.ts
|
|
129
|
+
function slash(path$3, platform = "linux") {
|
|
130
|
+
const isWindowsPath = /^\\\\\?\\/.test(path$3);
|
|
131
|
+
const normalizedPath = (0, node_path.normalize)(path$3);
|
|
132
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
133
|
+
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
134
|
+
}
|
|
135
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
136
|
+
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
137
|
+
const slashedPath = slash((0, node_path.relative)(rootDir, filePath), platform);
|
|
138
|
+
if (slashedPath.startsWith("../")) return slashedPath;
|
|
139
|
+
return `./${slashedPath}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
71
142
|
//#endregion
|
|
72
143
|
//#region src/errors.ts
|
|
73
144
|
var ValidationPluginError = class extends Error {};
|
|
@@ -251,13 +322,16 @@ function createPlugin(factory) {
|
|
|
251
322
|
};
|
|
252
323
|
}
|
|
253
324
|
const pluginCore = createPlugin((options) => {
|
|
254
|
-
const {
|
|
325
|
+
const { fabric, pluginManager, resolvePath, resolveName, logger } = options;
|
|
255
326
|
return {
|
|
256
327
|
name: "core",
|
|
257
328
|
options,
|
|
258
329
|
key: ["core"],
|
|
259
330
|
context() {
|
|
260
331
|
return {
|
|
332
|
+
get fabric() {
|
|
333
|
+
return fabric;
|
|
334
|
+
},
|
|
261
335
|
get config() {
|
|
262
336
|
return options.config;
|
|
263
337
|
},
|
|
@@ -268,10 +342,12 @@ const pluginCore = createPlugin((options) => {
|
|
|
268
342
|
return options.plugin;
|
|
269
343
|
},
|
|
270
344
|
logger,
|
|
271
|
-
fileManager
|
|
345
|
+
get fileManager() {
|
|
346
|
+
return fabric.context.fileManager;
|
|
347
|
+
},
|
|
272
348
|
pluginManager,
|
|
273
349
|
async addFile(...files) {
|
|
274
|
-
const resolvedFiles = await fileManager.add(...files);
|
|
350
|
+
const resolvedFiles = await fabric.context.fileManager.add(...files);
|
|
275
351
|
if (!Array.isArray(resolvedFiles)) return [resolvedFiles];
|
|
276
352
|
return resolvedFiles;
|
|
277
353
|
},
|
|
@@ -293,10 +369,6 @@ const pluginCore = createPlugin((options) => {
|
|
|
293
369
|
//#region src/PluginManager.ts
|
|
294
370
|
var PluginManager = class {
|
|
295
371
|
plugins = /* @__PURE__ */ new Set();
|
|
296
|
-
/**
|
|
297
|
-
* @deprecated do not use from pluginManager
|
|
298
|
-
*/
|
|
299
|
-
fileManager;
|
|
300
372
|
events = new require_logger.EventEmitter();
|
|
301
373
|
config;
|
|
302
374
|
executed = [];
|
|
@@ -309,13 +381,12 @@ var PluginManager = class {
|
|
|
309
381
|
this.config = config;
|
|
310
382
|
this.options = options;
|
|
311
383
|
this.logger = options.logger;
|
|
312
|
-
this.fileManager = new __kubb_fabric_core.FileManager();
|
|
313
384
|
this.#promiseManager = new PromiseManager({ nullCheck: (state) => !!state?.result });
|
|
314
385
|
const core = pluginCore({
|
|
386
|
+
fabric: options.fabric,
|
|
315
387
|
config,
|
|
316
388
|
logger: this.logger,
|
|
317
389
|
pluginManager: this,
|
|
318
|
-
fileManager: this.fileManager,
|
|
319
390
|
resolvePath: this.resolvePath.bind(this),
|
|
320
391
|
resolveName: this.resolveName.bind(this),
|
|
321
392
|
getPlugins: this.#getSortedPlugins.bind(this)
|
|
@@ -737,11 +808,10 @@ var PluginManager = class {
|
|
|
737
808
|
//#endregion
|
|
738
809
|
//#region src/build.ts
|
|
739
810
|
async function setup(options) {
|
|
740
|
-
if (options.pluginManager) return options.pluginManager;
|
|
741
811
|
const { config: userConfig, logger = require_logger.createLogger() } = options;
|
|
742
812
|
if (Array.isArray(userConfig.input)) console.warn(picocolors.default.yellow("This feature is still under development — use with caution"));
|
|
743
813
|
try {
|
|
744
|
-
if (isInputPath(userConfig) && !new require_URLPath.URLPath(userConfig.input.path).isURL) await
|
|
814
|
+
if (isInputPath(userConfig) && !new require_URLPath.URLPath(userConfig.input.path).isURL) await exists(userConfig.input.path);
|
|
745
815
|
} catch (e) {
|
|
746
816
|
if (isInputPath(userConfig)) throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`, { cause: e });
|
|
747
817
|
}
|
|
@@ -758,39 +828,35 @@ async function setup(options) {
|
|
|
758
828
|
plugins: userConfig.plugins
|
|
759
829
|
};
|
|
760
830
|
if (definedConfig.output.clean) {
|
|
761
|
-
await
|
|
762
|
-
await
|
|
831
|
+
await clean(definedConfig.output.path);
|
|
832
|
+
await clean((0, node_path.join)(definedConfig.root, ".kubb"));
|
|
763
833
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
834
|
+
const fabric = (0, __kubb_react_fabric.createFabric)();
|
|
835
|
+
fabric.use(__kubb_react_fabric_plugins.fsPlugin, { dryRun: !definedConfig.output.write });
|
|
836
|
+
fabric.use(__kubb_react_fabric_parsers.typescriptParser);
|
|
837
|
+
return {
|
|
838
|
+
fabric,
|
|
839
|
+
pluginManager: new PluginManager(definedConfig, {
|
|
840
|
+
fabric,
|
|
841
|
+
logger,
|
|
842
|
+
concurrency: 5
|
|
843
|
+
})
|
|
844
|
+
};
|
|
768
845
|
}
|
|
769
|
-
async function build(options) {
|
|
770
|
-
const { files, pluginManager, error } = await safeBuild(options);
|
|
846
|
+
async function build(options, overrides) {
|
|
847
|
+
const { fabric, files, pluginManager, error } = await safeBuild(options, overrides);
|
|
771
848
|
if (error) throw error;
|
|
772
849
|
return {
|
|
850
|
+
fabric,
|
|
773
851
|
files,
|
|
774
852
|
pluginManager,
|
|
775
853
|
error
|
|
776
854
|
};
|
|
777
855
|
}
|
|
778
|
-
async function safeBuild(options) {
|
|
779
|
-
const pluginManager = await setup(options);
|
|
856
|
+
async function safeBuild(options, overrides) {
|
|
857
|
+
const { fabric, pluginManager } = overrides ? overrides : await setup(options);
|
|
780
858
|
const config = pluginManager.config;
|
|
781
859
|
try {
|
|
782
|
-
pluginManager.events.on("executing", ({ plugin, message }) => {
|
|
783
|
-
pluginManager.logger.emit("debug", {
|
|
784
|
-
date: /* @__PURE__ */ new Date(),
|
|
785
|
-
logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`]
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
pluginManager.events.on("executed", ({ plugin, message, output }) => {
|
|
789
|
-
pluginManager.logger.emit("debug", {
|
|
790
|
-
date: /* @__PURE__ */ new Date(),
|
|
791
|
-
logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
|
|
792
|
-
});
|
|
793
|
-
});
|
|
794
860
|
await pluginManager.hookParallel({
|
|
795
861
|
hookName: "buildStart",
|
|
796
862
|
parameters: [config],
|
|
@@ -801,7 +867,7 @@ async function safeBuild(options) {
|
|
|
801
867
|
const rootFile = {
|
|
802
868
|
path: rootPath,
|
|
803
869
|
baseName: "index.ts",
|
|
804
|
-
exports:
|
|
870
|
+
exports: fabric.files.filter((file) => {
|
|
805
871
|
return file.sources.some((source) => source.isIndexable);
|
|
806
872
|
}).flatMap((file) => {
|
|
807
873
|
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
|
|
@@ -814,7 +880,7 @@ async function safeBuild(options) {
|
|
|
814
880
|
if (!pluginOptions || pluginOptions?.output?.barrelType === false) return;
|
|
815
881
|
return {
|
|
816
882
|
name: config.output.barrelType === "all" ? void 0 : [source.name],
|
|
817
|
-
path:
|
|
883
|
+
path: getRelativePath(rootPath, file.path),
|
|
818
884
|
isTypeOnly: config.output.barrelType === "all" ? containsOnlyTypes : source.isTypeOnly
|
|
819
885
|
};
|
|
820
886
|
}).filter(Boolean);
|
|
@@ -822,43 +888,40 @@ async function safeBuild(options) {
|
|
|
822
888
|
sources: [],
|
|
823
889
|
meta: {}
|
|
824
890
|
};
|
|
825
|
-
await
|
|
891
|
+
await fabric.addFile(rootFile);
|
|
826
892
|
}
|
|
827
|
-
|
|
893
|
+
fabric.context.events.on("process:start", ({ files: files$1 }) => {
|
|
828
894
|
pluginManager.logger.emit("progress_start", {
|
|
829
895
|
id: "files",
|
|
830
896
|
size: files$1.length,
|
|
831
897
|
message: "Writing files ..."
|
|
832
898
|
});
|
|
833
899
|
});
|
|
834
|
-
|
|
900
|
+
fabric.context.events.on("process:progress", async ({ file, source }) => {
|
|
835
901
|
const message = file ? `Writing ${(0, node_path.relative)(config.root, file.path)}` : "";
|
|
836
902
|
pluginManager.logger.emit("progressed", {
|
|
837
903
|
id: "files",
|
|
838
904
|
message
|
|
839
905
|
});
|
|
840
|
-
if (source) await
|
|
906
|
+
if (source) await require_logger.write(file.path, source, { sanity: false });
|
|
841
907
|
});
|
|
842
|
-
|
|
908
|
+
fabric.context.events.on("process:end", () => {
|
|
843
909
|
pluginManager.logger.emit("progress_stop", { id: "files" });
|
|
844
910
|
});
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
extension: config.output.extension,
|
|
848
|
-
dryRun: !config.output.write,
|
|
849
|
-
parsers
|
|
850
|
-
});
|
|
911
|
+
const files = [...fabric.files];
|
|
912
|
+
await fabric.write({ extension: config.output.extension });
|
|
851
913
|
await pluginManager.hookParallel({
|
|
852
914
|
hookName: "buildEnd",
|
|
853
915
|
message: `Build stopped for ${config.name}`
|
|
854
916
|
});
|
|
855
|
-
await pluginManager.fileManager.clear();
|
|
856
917
|
return {
|
|
918
|
+
fabric,
|
|
857
919
|
files,
|
|
858
920
|
pluginManager
|
|
859
921
|
};
|
|
860
922
|
} catch (e) {
|
|
861
923
|
return {
|
|
924
|
+
fabric,
|
|
862
925
|
files: [],
|
|
863
926
|
pluginManager,
|
|
864
927
|
error: e
|
|
@@ -1019,7 +1082,7 @@ var BarrelManager = class {
|
|
|
1019
1082
|
if (!barrelFile.exports) barrelFile.exports = [];
|
|
1020
1083
|
if (!!treeNode.parent?.data.path?.split?.("/")?.length) barrelFile.exports.push({
|
|
1021
1084
|
name: [source.name],
|
|
1022
|
-
path:
|
|
1085
|
+
path: getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
1023
1086
|
isTypeOnly: source.isTypeOnly
|
|
1024
1087
|
});
|
|
1025
1088
|
else barrelFile.exports.push({
|
|
@@ -1051,11 +1114,14 @@ function getMode(path$3) {
|
|
|
1051
1114
|
if (!path$3) return "split";
|
|
1052
1115
|
return (0, node_path.extname)(path$3) ? "single" : "split";
|
|
1053
1116
|
}
|
|
1117
|
+
function trimExtName(text) {
|
|
1118
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
1119
|
+
}
|
|
1054
1120
|
async function getBarrelFiles(files, { type, meta = {}, root, output, logger }) {
|
|
1055
1121
|
if (!type || type === "propagate") return [];
|
|
1056
1122
|
const barrelManager = new BarrelManager({ logger });
|
|
1057
1123
|
const pathToBuildFrom = (0, node_path.join)(root, output.path);
|
|
1058
|
-
if (
|
|
1124
|
+
if (trimExtName(pathToBuildFrom).endsWith("index")) {
|
|
1059
1125
|
logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
1060
1126
|
return [];
|
|
1061
1127
|
}
|
|
@@ -1297,13 +1363,13 @@ var PackageManager = class PackageManager {
|
|
|
1297
1363
|
async getPackageJSON() {
|
|
1298
1364
|
const pkgPath = await findUp(["package.json"], { cwd: this.#cwd });
|
|
1299
1365
|
if (!pkgPath) return;
|
|
1300
|
-
const json = await
|
|
1366
|
+
const json = await read(pkgPath);
|
|
1301
1367
|
return JSON.parse(json);
|
|
1302
1368
|
}
|
|
1303
1369
|
getPackageJSONSync() {
|
|
1304
1370
|
const pkgPath = findUpSync(["package.json"], { cwd: this.#cwd });
|
|
1305
1371
|
if (!pkgPath) return;
|
|
1306
|
-
const json =
|
|
1372
|
+
const json = readSync(pkgPath);
|
|
1307
1373
|
return JSON.parse(json);
|
|
1308
1374
|
}
|
|
1309
1375
|
static setVersion(dependency, version) {
|