@kubb/core 4.32.4 → 4.33.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/hooks.d.ts +1 -1
- package/dist/index.cjs +1695 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +150 -20
- package/dist/index.js +1673 -65
- package/dist/index.js.map +1 -1
- package/dist/{types-f_no0d7G.d.ts → types-DfjjJb2r.d.ts} +70 -27
- package/package.json +3 -24
- package/src/BarrelManager.ts +10 -31
- package/src/PackageManager.ts +13 -21
- package/src/PluginManager.ts +65 -87
- package/src/PromiseManager.ts +3 -5
- package/src/build.ts +61 -47
- package/src/config.ts +1 -1
- package/src/constants.ts +60 -0
- package/src/errors.ts +1 -14
- package/src/index.ts +6 -3
- package/src/types.ts +5 -14
- package/src/utils/FunctionParams.ts +7 -8
- package/src/utils/TreeNode.ts +12 -23
- package/src/utils/executeStrategies.ts +5 -3
- package/src/utils/formatters.ts +3 -20
- package/src/utils/getBarrelFiles.ts +8 -2
- package/src/utils/getConfigs.ts +6 -15
- package/src/utils/getPlugins.ts +7 -7
- package/src/utils/linters.ts +3 -20
- package/dist/fs-D4eqq6bR.cjs +0 -103
- package/dist/fs-D4eqq6bR.cjs.map +0 -1
- package/dist/fs-TVBCPkE-.js +0 -67
- package/dist/fs-TVBCPkE-.js.map +0 -1
- package/dist/fs.cjs +0 -8
- package/dist/fs.d.ts +0 -23
- package/dist/fs.js +0 -2
- package/dist/packageManager-_7I0WFQU.d.ts +0 -82
- package/dist/packageManager-jzjuEj2U.cjs +0 -1103
- package/dist/packageManager-jzjuEj2U.cjs.map +0 -1
- package/dist/packageManager-wMCQlgd6.js +0 -1024
- package/dist/packageManager-wMCQlgd6.js.map +0 -1
- package/dist/transformers-BwSpAhvT.js +0 -267
- package/dist/transformers-BwSpAhvT.js.map +0 -1
- package/dist/transformers-BweFhqh-.cjs +0 -380
- package/dist/transformers-BweFhqh-.cjs.map +0 -1
- package/dist/transformers.cjs +0 -24
- package/dist/transformers.d.ts +0 -108
- package/dist/transformers.js +0 -2
- package/dist/utils.cjs +0 -430
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.ts +0 -290
- package/dist/utils.js +0 -402
- package/dist/utils.js.map +0 -1
- package/src/BaseGenerator.ts +0 -34
- package/src/fs/clean.ts +0 -5
- package/src/fs/exists.ts +0 -16
- package/src/fs/index.ts +0 -5
- package/src/fs/read.ts +0 -13
- package/src/fs/utils.ts +0 -32
- package/src/fs/write.ts +0 -46
- package/src/transformers/casing.ts +0 -62
- package/src/transformers/combineCodes.ts +0 -3
- package/src/transformers/createJSDocBlockText.ts +0 -9
- package/src/transformers/escape.ts +0 -31
- package/src/transformers/indent.ts +0 -3
- package/src/transformers/index.ts +0 -46
- package/src/transformers/nameSorter.ts +0 -9
- package/src/transformers/searchAndReplace.ts +0 -25
- package/src/transformers/stringify.ts +0 -25
- package/src/transformers/toRegExp.ts +0 -22
- package/src/transformers/transformReservedWord.ts +0 -106
- package/src/transformers/trim.ts +0 -18
- package/src/utils/AsyncEventEmitter.ts +0 -48
- package/src/utils/Cache.ts +0 -31
- package/src/utils/URLPath.ts +0 -146
- package/src/utils/buildJSDoc.ts +0 -34
- package/src/utils/checkOnlineStatus.ts +0 -40
- package/src/utils/formatHrtime.ts +0 -33
- package/src/utils/getNestedAccessor.ts +0 -25
- package/src/utils/index.ts +0 -26
- package/src/utils/packageManager.ts +0 -58
- package/src/utils/promise.ts +0 -13
- package/src/utils/renderTemplate.ts +0 -31
- package/src/utils/serializePluginOptions.ts +0 -29
- package/src/utils/timeout.ts +0 -11
- package/src/utils/tokenize.ts +0 -23
- package/src/utils/types.ts +0 -1
- package/src/utils/uniqueName.ts +0 -20
package/dist/fs-D4eqq6bR.cjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
let node_fs_promises = require("node:fs/promises");
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
6
|
-
//#region src/fs/clean.ts
|
|
7
|
-
async function clean(path) {
|
|
8
|
-
return (0, node_fs_promises.rm)(path, {
|
|
9
|
-
recursive: true,
|
|
10
|
-
force: true
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/fs/exists.ts
|
|
15
|
-
async function exists(path) {
|
|
16
|
-
if (typeof Bun !== "undefined") return Bun.file(path).exists();
|
|
17
|
-
return (0, node_fs_promises.access)(path).then(() => true, () => false);
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/fs/read.ts
|
|
21
|
-
async function read(path) {
|
|
22
|
-
if (typeof Bun !== "undefined") return Bun.file(path).text();
|
|
23
|
-
return (0, node_fs_promises.readFile)(path, { encoding: "utf8" });
|
|
24
|
-
}
|
|
25
|
-
function readSync(path) {
|
|
26
|
-
return (0, node_fs.readFileSync)(path, { encoding: "utf8" });
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/fs/utils.ts
|
|
30
|
-
function slash(path, platform = "linux") {
|
|
31
|
-
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
32
|
-
const normalizedPath = (0, node_path.normalize)(path);
|
|
33
|
-
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
34
|
-
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
35
|
-
}
|
|
36
|
-
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
37
|
-
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
38
|
-
const slashedPath = slash((0, node_path.relative)(rootDir, filePath), platform);
|
|
39
|
-
if (slashedPath.startsWith("../")) return slashedPath;
|
|
40
|
-
return `./${slashedPath}`;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/fs/write.ts
|
|
44
|
-
async function write(path, data, options = {}) {
|
|
45
|
-
if (data.trim() === "") return;
|
|
46
|
-
const resolved = (0, node_path.resolve)(path);
|
|
47
|
-
if (typeof Bun !== "undefined") {
|
|
48
|
-
const file = Bun.file(resolved);
|
|
49
|
-
if ((await file.exists() ? await file.text() : null) === data.trim()) return;
|
|
50
|
-
await Bun.write(resolved, data.trim());
|
|
51
|
-
return data.trim();
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
if ((await (0, node_fs_promises.readFile)(resolved, { encoding: "utf-8" }))?.toString() === data.trim()) return;
|
|
55
|
-
} catch (_err) {}
|
|
56
|
-
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(resolved), { recursive: true });
|
|
57
|
-
await (0, node_fs_promises.writeFile)(resolved, data.trim(), { encoding: "utf-8" });
|
|
58
|
-
if (options.sanity) {
|
|
59
|
-
const savedData = await (0, node_fs_promises.readFile)(resolved, { encoding: "utf-8" });
|
|
60
|
-
if (savedData?.toString() !== data.trim()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
61
|
-
return savedData;
|
|
62
|
-
}
|
|
63
|
-
return data.trim();
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
Object.defineProperty(exports, "clean", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function() {
|
|
69
|
-
return clean;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(exports, "exists", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function() {
|
|
75
|
-
return exists;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, "getRelativePath", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function() {
|
|
81
|
-
return getRelativePath;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(exports, "read", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function() {
|
|
87
|
-
return read;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(exports, "readSync", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function() {
|
|
93
|
-
return readSync;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, "write", {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function() {
|
|
99
|
-
return write;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
//# sourceMappingURL=fs-D4eqq6bR.cjs.map
|
package/dist/fs-D4eqq6bR.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs-D4eqq6bR.cjs","names":[],"sources":["../src/fs/clean.ts","../src/fs/exists.ts","../src/fs/read.ts","../src/fs/utils.ts","../src/fs/write.ts"],"sourcesContent":["import { rm } from 'node:fs/promises'\n\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n","import fs from 'node:fs'\nimport { access } from 'node:fs/promises'\n\nexport async function exists(path: string): Promise<boolean> {\n if (typeof Bun !== 'undefined') {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\nexport function existsSync(path: string): boolean {\n return fs.existsSync(path)\n}\n","import { readFileSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\n\nexport async function read(path: string): Promise<string> {\n if (typeof Bun !== 'undefined') {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\nexport function readSync(path: string): string {\n return readFileSync(path, { encoding: 'utf8' })\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\n\ntype Options = { sanity?: boolean }\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n\n const resolved = resolve(path)\n\n if (typeof Bun !== 'undefined') {\n const file = Bun.file(resolved)\n const oldContent = (await file.exists()) ? await file.text() : null\n if (oldContent === data.trim()) {\n return undefined\n }\n await Bun.write(resolved, data.trim())\n return data.trim()\n }\n\n try {\n const oldContent = await readFile(resolved, { encoding: 'utf-8' })\n if (oldContent?.toString() === data.trim()) {\n return undefined\n }\n } catch (_err) {\n /* file doesn't exist yet */\n }\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, data.trim(), { encoding: 'utf-8' })\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n\n if (savedData?.toString() !== data.trim()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data.trim()\n}\n"],"mappings":";;;;;;AAEA,eAAsB,MAAM,MAA6B;AACvD,SAAA,GAAA,iBAAA,IAAU,MAAM;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC;;;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AK,QAAQ,GAAI,MAAM,KAAK,MAAM,GAAG,UAC5C,KAAK,MAAM,CAC5B;AAEF,QAAM,IAAI,MAAM,UAAU,KAAK,MAAM,CAAC;AACtC,SAAO,KAAK,MAAM;;AAGpB,KAAI;AAEF,OADmB,OAAA,GAAA,iBAAA,UAAe,UAAU,EAAE,UAAU,SAAS,CAAC,GAClD,UAAU,KAAK,KAAK,MAAM,CACxC;UAEK,MAAM;AAIf,QAAA,GAAA,iBAAA,QAAA,GAAA,UAAA,SAAoB,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,QAAA,GAAA,iBAAA,WAAgB,UAAU,KAAK,MAAM,EAAE,EAAE,UAAU,SAAS,CAAC;AAE7D,KAAI,QAAQ,QAAQ;EAClB,MAAM,YAAY,OAAA,GAAA,iBAAA,UAAe,UAAU,EAAE,UAAU,SAAS,CAAC;AAEjE,MAAI,WAAW,UAAU,KAAK,KAAK,MAAM,CACvC,OAAM,IAAI,MAAM,2BAA2B,KAAK,WAAW,KAAK,OAAO,MAAM,KAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,SAAO;;AAGT,QAAO,KAAK,MAAM"}
|
package/dist/fs-TVBCPkE-.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { dirname, normalize, relative, resolve } from "node:path";
|
|
3
|
-
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
//#region src/fs/clean.ts
|
|
6
|
-
async function clean(path) {
|
|
7
|
-
return rm(path, {
|
|
8
|
-
recursive: true,
|
|
9
|
-
force: true
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/fs/exists.ts
|
|
14
|
-
async function exists(path) {
|
|
15
|
-
if (typeof Bun !== "undefined") return Bun.file(path).exists();
|
|
16
|
-
return access(path).then(() => true, () => false);
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/fs/read.ts
|
|
20
|
-
async function read(path) {
|
|
21
|
-
if (typeof Bun !== "undefined") return Bun.file(path).text();
|
|
22
|
-
return readFile(path, { encoding: "utf8" });
|
|
23
|
-
}
|
|
24
|
-
function readSync(path) {
|
|
25
|
-
return readFileSync(path, { encoding: "utf8" });
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/fs/utils.ts
|
|
29
|
-
function slash(path, platform = "linux") {
|
|
30
|
-
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
31
|
-
const normalizedPath = normalize(path);
|
|
32
|
-
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
33
|
-
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
34
|
-
}
|
|
35
|
-
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
36
|
-
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
37
|
-
const slashedPath = slash(relative(rootDir, filePath), platform);
|
|
38
|
-
if (slashedPath.startsWith("../")) return slashedPath;
|
|
39
|
-
return `./${slashedPath}`;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/fs/write.ts
|
|
43
|
-
async function write(path, data, options = {}) {
|
|
44
|
-
if (data.trim() === "") return;
|
|
45
|
-
const resolved = resolve(path);
|
|
46
|
-
if (typeof Bun !== "undefined") {
|
|
47
|
-
const file = Bun.file(resolved);
|
|
48
|
-
if ((await file.exists() ? await file.text() : null) === data.trim()) return;
|
|
49
|
-
await Bun.write(resolved, data.trim());
|
|
50
|
-
return data.trim();
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
if ((await readFile(resolved, { encoding: "utf-8" }))?.toString() === data.trim()) return;
|
|
54
|
-
} catch (_err) {}
|
|
55
|
-
await mkdir(dirname(resolved), { recursive: true });
|
|
56
|
-
await writeFile(resolved, data.trim(), { encoding: "utf-8" });
|
|
57
|
-
if (options.sanity) {
|
|
58
|
-
const savedData = await readFile(resolved, { encoding: "utf-8" });
|
|
59
|
-
if (savedData?.toString() !== data.trim()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
60
|
-
return savedData;
|
|
61
|
-
}
|
|
62
|
-
return data.trim();
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
export { exists as a, readSync as i, getRelativePath as n, clean as o, read as r, write as t };
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=fs-TVBCPkE-.js.map
|
package/dist/fs-TVBCPkE-.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs-TVBCPkE-.js","names":[],"sources":["../src/fs/clean.ts","../src/fs/exists.ts","../src/fs/read.ts","../src/fs/utils.ts","../src/fs/write.ts"],"sourcesContent":["import { rm } from 'node:fs/promises'\n\nexport async function clean(path: string): Promise<void> {\n return rm(path, { recursive: true, force: true })\n}\n","import fs from 'node:fs'\nimport { access } from 'node:fs/promises'\n\nexport async function exists(path: string): Promise<boolean> {\n if (typeof Bun !== 'undefined') {\n return Bun.file(path).exists()\n }\n return access(path).then(\n () => true,\n () => false,\n )\n}\n\nexport function existsSync(path: string): boolean {\n return fs.existsSync(path)\n}\n","import { readFileSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\n\nexport async function read(path: string): Promise<string> {\n if (typeof Bun !== 'undefined') {\n return Bun.file(path).text()\n }\n return readFile(path, { encoding: 'utf8' })\n}\n\nexport function readSync(path: string): string {\n return readFileSync(path, { encoding: 'utf8' })\n}\n","import { normalize, relative } from 'node:path'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n const normalizedPath = normalize(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n }\n\n // windows\n return normalizedPath.replaceAll(/\\\\/g, '/').replace('../', '')\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath\n }\n\n return `./${slashedPath}`\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname, resolve } from 'node:path'\n\ntype Options = { sanity?: boolean }\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n\n const resolved = resolve(path)\n\n if (typeof Bun !== 'undefined') {\n const file = Bun.file(resolved)\n const oldContent = (await file.exists()) ? await file.text() : null\n if (oldContent === data.trim()) {\n return undefined\n }\n await Bun.write(resolved, data.trim())\n return data.trim()\n }\n\n try {\n const oldContent = await readFile(resolved, { encoding: 'utf-8' })\n if (oldContent?.toString() === data.trim()) {\n return undefined\n }\n } catch (_err) {\n /* file doesn't exist yet */\n }\n\n await mkdir(dirname(resolved), { recursive: true })\n await writeFile(resolved, data.trim(), { encoding: 'utf-8' })\n\n if (options.sanity) {\n const savedData = await readFile(resolved, { encoding: 'utf-8' })\n\n if (savedData?.toString() !== data.trim()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data.trim()\n}\n"],"mappings":";;;;;AAEA,eAAsB,MAAM,MAA6B;AACvD,QAAO,GAAG,MAAM;EAAE,WAAW;EAAM,OAAO;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C5B;AAEF,QAAM,IAAI,MAAM,UAAU,KAAK,MAAM,CAAC;AACtC,SAAO,KAAK,MAAM;;AAGpB,KAAI;AAEF,OADmB,MAAM,SAAS,UAAU,EAAE,UAAU,SAAS,CAAC,GAClD,UAAU,KAAK,KAAK,MAAM,CACxC;UAEK,MAAM;AAIf,OAAM,MAAM,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACnD,OAAM,UAAU,UAAU,KAAK,MAAM,EAAE,EAAE,UAAU,SAAS,CAAC;AAE7D,KAAI,QAAQ,QAAQ;EAClB,MAAM,YAAY,MAAM,SAAS,UAAU,EAAE,UAAU,SAAS,CAAC;AAEjE,MAAI,WAAW,UAAU,KAAK,KAAK,MAAM,CACvC,OAAM,IAAI,MAAM,2BAA2B,KAAK,WAAW,KAAK,OAAO,MAAM,KAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,SAAO;;AAGT,QAAO,KAAK,MAAM"}
|
package/dist/fs.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_fs = require("./fs-D4eqq6bR.cjs");
|
|
3
|
-
exports.clean = require_fs.clean;
|
|
4
|
-
exports.exists = require_fs.exists;
|
|
5
|
-
exports.getRelativePath = require_fs.getRelativePath;
|
|
6
|
-
exports.read = require_fs.read;
|
|
7
|
-
exports.readSync = require_fs.readSync;
|
|
8
|
-
exports.write = require_fs.write;
|
package/dist/fs.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
|
|
3
|
-
//#region src/fs/clean.d.ts
|
|
4
|
-
declare function clean(path: string): Promise<void>;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/fs/exists.d.ts
|
|
7
|
-
declare function exists(path: string): Promise<boolean>;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/fs/read.d.ts
|
|
10
|
-
declare function read(path: string): Promise<string>;
|
|
11
|
-
declare function readSync(path: string): string;
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/fs/utils.d.ts
|
|
14
|
-
declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/fs/write.d.ts
|
|
17
|
-
type Options = {
|
|
18
|
-
sanity?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare function write(path: string, data: string, options?: Options): Promise<string | undefined>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { clean, exists, getRelativePath, read, readSync, write };
|
|
23
|
-
//# sourceMappingURL=fs.d.ts.map
|
package/dist/fs.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { E as PossiblePromise, S as UserConfig, f as Plugin, o as InputPath, t as BarrelType } from "./types-f_no0d7G.js";
|
|
3
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
|
-
|
|
5
|
-
//#region src/config.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* CLI options derived from command-line flags.
|
|
8
|
-
*/
|
|
9
|
-
type CLIOptions = {
|
|
10
|
-
/** Path to `kubb.config.js` */config?: string; /** Enable watch mode for input files */
|
|
11
|
-
watch?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Logging verbosity for CLI usage.
|
|
14
|
-
*
|
|
15
|
-
* - `silent`: hide non-essential logs
|
|
16
|
-
* - `info`: show general logs (non-plugin-related)
|
|
17
|
-
* - `debug`: include detailed plugin lifecycle logs
|
|
18
|
-
* @default 'silent'
|
|
19
|
-
*/
|
|
20
|
-
logLevel?: 'silent' | 'info' | 'debug'; /** Run Kubb with Bun */
|
|
21
|
-
bun?: boolean;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Helper for defining a Kubb configuration.
|
|
25
|
-
*
|
|
26
|
-
* Accepts either:
|
|
27
|
-
* - A config object or array of configs
|
|
28
|
-
* - A function returning the config(s), optionally async,
|
|
29
|
-
* receiving the CLI options as argument
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* export default defineConfig(({ logLevel }) => ({
|
|
33
|
-
* root: 'src',
|
|
34
|
-
* plugins: [myPlugin()],
|
|
35
|
-
* }))
|
|
36
|
-
*/
|
|
37
|
-
declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>)): typeof config;
|
|
38
|
-
/**
|
|
39
|
-
* Type guard to check if a given config has an `input.path`.
|
|
40
|
-
*/
|
|
41
|
-
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/utils/getBarrelFiles.d.ts
|
|
44
|
-
type FileMetaBase = {
|
|
45
|
-
pluginKey?: Plugin['key'];
|
|
46
|
-
};
|
|
47
|
-
type AddIndexesProps = {
|
|
48
|
-
type: BarrelType | false | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Root based on root and output.path specified in the config
|
|
51
|
-
*/
|
|
52
|
-
root: string;
|
|
53
|
-
/**
|
|
54
|
-
* Output for plugin
|
|
55
|
-
*/
|
|
56
|
-
output: {
|
|
57
|
-
path: string;
|
|
58
|
-
};
|
|
59
|
-
group?: {
|
|
60
|
-
output: string;
|
|
61
|
-
exportAs: string;
|
|
62
|
-
};
|
|
63
|
-
meta?: FileMetaBase;
|
|
64
|
-
};
|
|
65
|
-
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
66
|
-
type,
|
|
67
|
-
meta,
|
|
68
|
-
root,
|
|
69
|
-
output
|
|
70
|
-
}: AddIndexesProps): Promise<KubbFile.File[]>;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/utils/packageManager.d.ts
|
|
73
|
-
type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
74
|
-
interface PackageManagerInfo {
|
|
75
|
-
name: PackageManagerName;
|
|
76
|
-
lockFile: string;
|
|
77
|
-
installCommand: string[];
|
|
78
|
-
}
|
|
79
|
-
declare function detectPackageManager(cwd?: string): PackageManagerInfo;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { getBarrelFiles as a, isInputPath as c, FileMetaBase as i, PackageManagerName as n, CLIOptions as o, detectPackageManager as r, defineConfig as s, PackageManagerInfo as t };
|
|
82
|
-
//# sourceMappingURL=packageManager-_7I0WFQU.d.ts.map
|