@kubb/core 4.11.2 → 4.12.0
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/fs-DhLl4-lT.cjs +177 -0
- package/dist/fs-DhLl4-lT.cjs.map +1 -0
- package/dist/fs-ph1OdgEr.js +108 -0
- package/dist/fs-ph1OdgEr.js.map +1 -0
- package/dist/fs.cjs +8 -0
- package/dist/fs.d.cts +21 -0
- package/dist/fs.d.ts +21 -0
- package/dist/fs.js +3 -0
- package/dist/{getBarrelFiles-ZIHk_1ln.d.ts → getBarrelFiles-BEWbZEZf.d.ts} +3 -6
- package/dist/{getBarrelFiles-8VEWWk9Z.cjs → getBarrelFiles-BcgToi50.cjs} +71 -62
- package/dist/getBarrelFiles-BcgToi50.cjs.map +1 -0
- package/dist/{getBarrelFiles-DQ0hksqD.js → getBarrelFiles-ClyWjO0d.js} +65 -55
- package/dist/getBarrelFiles-ClyWjO0d.js.map +1 -0
- package/dist/{getBarrelFiles-B_2WDywH.d.cts → getBarrelFiles-LW3anr-E.d.cts} +3 -6
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.d.cts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/index.cjs +68 -212
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +61 -204
- package/dist/index.js.map +1 -1
- package/dist/{transformers-B-zCAPV-.cjs → transformers-BqQRkrxy.cjs} +2 -2
- package/dist/{transformers-B-zCAPV-.cjs.map → transformers-BqQRkrxy.cjs.map} +1 -1
- package/dist/{transformers-CjdbeLAK.js → transformers-C481fXH-.js} +1 -1
- package/dist/{transformers-CjdbeLAK.js.map → transformers-C481fXH-.js.map} +1 -1
- package/dist/transformers.cjs +2 -2
- package/dist/transformers.js +1 -1
- package/dist/{types-DgfEZ3IN.d.ts → types-DZARm27h.d.ts} +253 -46
- package/dist/{types-CCEy_FVr.d.cts → types-icDNKrIP.d.cts} +253 -46
- package/dist/utils.cjs +6 -5
- package/dist/utils.d.cts +3 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +3 -3
- package/package.json +10 -17
- package/src/BarrelManager.ts +3 -18
- package/src/Kubb.ts +249 -0
- package/src/PluginManager.ts +42 -73
- package/src/build.ts +38 -138
- package/src/defineLogger.ts +7 -0
- package/src/index.ts +2 -1
- package/src/types.ts +35 -2
- package/src/utils/getBarrelFiles.ts +7 -10
- package/src/utils/index.ts +1 -0
- package/dist/EventEmitter-BwU6Ixxt.cjs +0 -31
- package/dist/EventEmitter-BwU6Ixxt.cjs.map +0 -1
- package/dist/EventEmitter-DlzW04T3.js +0 -25
- package/dist/EventEmitter-DlzW04T3.js.map +0 -1
- package/dist/chunk-CbDLau6x.cjs +0 -34
- package/dist/getBarrelFiles-8VEWWk9Z.cjs.map +0 -1
- package/dist/getBarrelFiles-DQ0hksqD.js.map +0 -1
- package/dist/logger-CQn6sdC0.js +0 -1152
- package/dist/logger-CQn6sdC0.js.map +0 -1
- package/dist/logger-US5g7KdM.cjs +0 -1187
- package/dist/logger-US5g7KdM.cjs.map +0 -1
- package/dist/logger-mq06Cxxv.d.cts +0 -94
- package/dist/logger-o16AyvGp.d.ts +0 -94
- package/dist/logger.cjs +0 -6
- package/dist/logger.d.cts +0 -2
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -3
- package/dist/prompt-CWSscQpj.cjs +0 -852
- package/dist/prompt-CWSscQpj.cjs.map +0 -1
- package/dist/prompt-Dt0jyRBe.js +0 -848
- package/dist/prompt-Dt0jyRBe.js.map +0 -1
- package/src/logger.ts +0 -236
- package/src/utils/ciDetection.ts +0 -40
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
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
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let node_path = require("node:path");
|
|
29
|
+
let fs_extra = require("fs-extra");
|
|
30
|
+
fs_extra = __toESM(fs_extra);
|
|
31
|
+
let js_runtime = require("js-runtime");
|
|
32
|
+
|
|
33
|
+
//#region src/fs/clean.ts
|
|
34
|
+
async function clean(path) {
|
|
35
|
+
return fs_extra.default.remove(path);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/fs/exists.ts
|
|
40
|
+
const reader$1 = (0, js_runtime.switcher)({
|
|
41
|
+
node: async (path) => {
|
|
42
|
+
return fs_extra.default.pathExists(path);
|
|
43
|
+
},
|
|
44
|
+
bun: async (path) => {
|
|
45
|
+
return Bun.file(path).exists();
|
|
46
|
+
}
|
|
47
|
+
}, "node");
|
|
48
|
+
const syncReader$1 = (0, js_runtime.switcher)({
|
|
49
|
+
node: (path) => {
|
|
50
|
+
return fs_extra.default.pathExistsSync(path);
|
|
51
|
+
},
|
|
52
|
+
bun: () => {
|
|
53
|
+
throw new Error("Bun cannot read sync");
|
|
54
|
+
}
|
|
55
|
+
}, "node");
|
|
56
|
+
async function exists(path) {
|
|
57
|
+
return reader$1(path);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/fs/read.ts
|
|
62
|
+
const reader = (0, js_runtime.switcher)({
|
|
63
|
+
node: async (path) => {
|
|
64
|
+
return fs_extra.default.readFile(path, { encoding: "utf8" });
|
|
65
|
+
},
|
|
66
|
+
bun: async (path) => {
|
|
67
|
+
return Bun.file(path).text();
|
|
68
|
+
}
|
|
69
|
+
}, "node");
|
|
70
|
+
const syncReader = (0, js_runtime.switcher)({
|
|
71
|
+
node: (path) => {
|
|
72
|
+
return fs_extra.default.readFileSync(path, { encoding: "utf8" });
|
|
73
|
+
},
|
|
74
|
+
bun: () => {
|
|
75
|
+
throw new Error("Bun cannot read sync");
|
|
76
|
+
}
|
|
77
|
+
}, "node");
|
|
78
|
+
async function read(path) {
|
|
79
|
+
return reader(path);
|
|
80
|
+
}
|
|
81
|
+
function readSync(path) {
|
|
82
|
+
return syncReader(path);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/fs/utils.ts
|
|
87
|
+
function slash(path, platform = "linux") {
|
|
88
|
+
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
89
|
+
const normalizedPath = (0, node_path.normalize)(path);
|
|
90
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
91
|
+
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
92
|
+
}
|
|
93
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
94
|
+
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
95
|
+
const slashedPath = slash((0, node_path.relative)(rootDir, filePath), platform);
|
|
96
|
+
if (slashedPath.startsWith("../")) return slashedPath;
|
|
97
|
+
return `./${slashedPath}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/fs/write.ts
|
|
102
|
+
const writer = (0, js_runtime.switcher)({
|
|
103
|
+
node: async (path, data, { sanity }) => {
|
|
104
|
+
try {
|
|
105
|
+
if ((await fs_extra.default.readFile((0, node_path.resolve)(path), { encoding: "utf-8" }))?.toString() === data?.toString()) return;
|
|
106
|
+
} catch (_err) {}
|
|
107
|
+
await fs_extra.default.outputFile((0, node_path.resolve)(path), data, { encoding: "utf-8" });
|
|
108
|
+
if (sanity) {
|
|
109
|
+
const savedData = await fs_extra.default.readFile((0, node_path.resolve)(path), { encoding: "utf-8" });
|
|
110
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
111
|
+
return savedData;
|
|
112
|
+
}
|
|
113
|
+
return data;
|
|
114
|
+
},
|
|
115
|
+
bun: async (path, data, { sanity }) => {
|
|
116
|
+
try {
|
|
117
|
+
await Bun.write((0, node_path.resolve)(path), data);
|
|
118
|
+
if (sanity) {
|
|
119
|
+
const savedData = await Bun.file((0, node_path.resolve)(path)).text();
|
|
120
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${path.length}]:\n${path}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
121
|
+
return savedData;
|
|
122
|
+
}
|
|
123
|
+
return data;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.error(e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, "node");
|
|
129
|
+
async function write(path, data, options = {}) {
|
|
130
|
+
if (data.trim() === "") return;
|
|
131
|
+
return writer(path, data.trim(), options);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//#endregion
|
|
135
|
+
Object.defineProperty(exports, '__toESM', {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
return __toESM;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(exports, 'clean', {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function () {
|
|
144
|
+
return clean;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(exports, 'exists', {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function () {
|
|
150
|
+
return exists;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(exports, 'getRelativePath', {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function () {
|
|
156
|
+
return getRelativePath;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
Object.defineProperty(exports, 'read', {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () {
|
|
162
|
+
return read;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(exports, 'readSync', {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function () {
|
|
168
|
+
return readSync;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(exports, 'write', {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function () {
|
|
174
|
+
return write;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=fs-DhLl4-lT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-DhLl4-lT.cjs","names":["fs","reader","fs","syncReader","fs","fs"],"sources":["../src/fs/clean.ts","../src/fs/exists.ts","../src/fs/read.ts","../src/fs/utils.ts","../src/fs/write.ts"],"sourcesContent":["import fs from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.pathExists(path)\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.exists()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.pathExistsSync(path)\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function exists(path: string): Promise<boolean> {\n return reader(path)\n}\n\nexport function existsSync(path: string): boolean {\n return syncReader(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\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 { resolve } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nconst writer = switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\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\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${path.length}]:\\n${path}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.error(e)\n }\n },\n },\n 'node',\n)\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim(), options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,eAAsB,MAAM,MAA6B;AACvD,QAAOA,iBAAG,OAAO,KAAK;;;;;ACAxB,MAAMC,oCACJ;CACE,MAAM,OAAO,SAAiB;AAC5B,SAAOC,iBAAG,WAAW,KAAK;;CAE5B,KAAK,OAAO,SAAiB;AAG3B,SAFa,IAAI,KAAK,KAAK,CAEf,QAAQ;;CAEvB,EACD,OACD;AAED,MAAMC,wCACJ;CACE,OAAO,SAAiB;A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/D,MAAI;AAIF,QAHmB,MAAMC,iBAAG,gCAAiB,KAAK,EAAE,EAClD,UAAU,SACX,CAAC,GACc,UAAU,KAAK,MAAM,UAAU,CAC7C;WAEK,MAAM;AAIf,QAAMA,iBAAG,kCAAmB,KAAK,EAAE,MAAM,EAAE,UAAU,SAAS,CAAC;AAE/D,MAAI,QAAQ;GACV,MAAM,YAAY,MAAMA,iBAAG,gCAAiB,KAAK,EAAE,EACjD,UAAU,SACX,CAAC;AAEF,OAAI,WAAW,UAAU,KAAK,MAAM,UAAU,CAC5C,OAAM,IAAI,MAAM,2BAA2B,KAAK,WAAW,KAAK,OAAO,MAAM,KAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,UAAO;;AAGT,SAAO;;CAET,KAAK,OAAO,MAAc,MAAc,EAAE,aAAsB;AAC9D,MAAI;AACF,SAAM,IAAI,6BAAc,KAAK,EAAE,KAAK;AAEpC,OAAI,QAAQ;IAEV,MAAM,YAAY,MADL,IAAI,4BAAa,KAAK,CAAC,CACP,MAAM;AAEnC,QAAI,WAAW,UAAU,KAAK,MAAM,UAAU,CAC5C,OAAM,IAAI,MAAM,2BAA2B,KAAK,WAAW,KAAK,OAAO,MAAM,KAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,WAAO;;AAGT,UAAO;WACA,GAAG;AACV,WAAQ,MAAM,EAAE;;;CAGrB,EACD,OACD;AAED,eAAsB,MAAM,MAAc,MAAc,UAAmB,EAAE,EAA+B;AAC1G,KAAI,KAAK,MAAM,KAAK,GAClB;AAEF,QAAO,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { normalize, relative, resolve } from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { switcher } from "js-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/fs/clean.ts
|
|
6
|
+
async function clean(path$1) {
|
|
7
|
+
return fs.remove(path$1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/fs/exists.ts
|
|
12
|
+
const reader$1 = switcher({
|
|
13
|
+
node: async (path$1) => {
|
|
14
|
+
return fs.pathExists(path$1);
|
|
15
|
+
},
|
|
16
|
+
bun: async (path$1) => {
|
|
17
|
+
return Bun.file(path$1).exists();
|
|
18
|
+
}
|
|
19
|
+
}, "node");
|
|
20
|
+
const syncReader$1 = switcher({
|
|
21
|
+
node: (path$1) => {
|
|
22
|
+
return fs.pathExistsSync(path$1);
|
|
23
|
+
},
|
|
24
|
+
bun: () => {
|
|
25
|
+
throw new Error("Bun cannot read sync");
|
|
26
|
+
}
|
|
27
|
+
}, "node");
|
|
28
|
+
async function exists(path$1) {
|
|
29
|
+
return reader$1(path$1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/fs/read.ts
|
|
34
|
+
const reader = switcher({
|
|
35
|
+
node: async (path$1) => {
|
|
36
|
+
return fs.readFile(path$1, { encoding: "utf8" });
|
|
37
|
+
},
|
|
38
|
+
bun: async (path$1) => {
|
|
39
|
+
return Bun.file(path$1).text();
|
|
40
|
+
}
|
|
41
|
+
}, "node");
|
|
42
|
+
const syncReader = switcher({
|
|
43
|
+
node: (path$1) => {
|
|
44
|
+
return fs.readFileSync(path$1, { encoding: "utf8" });
|
|
45
|
+
},
|
|
46
|
+
bun: () => {
|
|
47
|
+
throw new Error("Bun cannot read sync");
|
|
48
|
+
}
|
|
49
|
+
}, "node");
|
|
50
|
+
async function read(path$1) {
|
|
51
|
+
return reader(path$1);
|
|
52
|
+
}
|
|
53
|
+
function readSync(path$1) {
|
|
54
|
+
return syncReader(path$1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/fs/utils.ts
|
|
59
|
+
function slash(path$1, platform = "linux") {
|
|
60
|
+
const isWindowsPath = /^\\\\\?\\/.test(path$1);
|
|
61
|
+
const normalizedPath = normalize(path$1);
|
|
62
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
63
|
+
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
64
|
+
}
|
|
65
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
66
|
+
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
67
|
+
const slashedPath = slash(relative(rootDir, filePath), platform);
|
|
68
|
+
if (slashedPath.startsWith("../")) return slashedPath;
|
|
69
|
+
return `./${slashedPath}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/fs/write.ts
|
|
74
|
+
const writer = switcher({
|
|
75
|
+
node: async (path$1, data, { sanity }) => {
|
|
76
|
+
try {
|
|
77
|
+
if ((await fs.readFile(resolve(path$1), { encoding: "utf-8" }))?.toString() === data?.toString()) return;
|
|
78
|
+
} catch (_err) {}
|
|
79
|
+
await fs.outputFile(resolve(path$1), data, { encoding: "utf-8" });
|
|
80
|
+
if (sanity) {
|
|
81
|
+
const savedData = await fs.readFile(resolve(path$1), { encoding: "utf-8" });
|
|
82
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path$1}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
83
|
+
return savedData;
|
|
84
|
+
}
|
|
85
|
+
return data;
|
|
86
|
+
},
|
|
87
|
+
bun: async (path$1, data, { sanity }) => {
|
|
88
|
+
try {
|
|
89
|
+
await Bun.write(resolve(path$1), data);
|
|
90
|
+
if (sanity) {
|
|
91
|
+
const savedData = await Bun.file(resolve(path$1)).text();
|
|
92
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path$1}\n\nData[${path$1.length}]:\n${path$1}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
93
|
+
return savedData;
|
|
94
|
+
}
|
|
95
|
+
return data;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error(e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, "node");
|
|
101
|
+
async function write(path$1, data, options = {}) {
|
|
102
|
+
if (data.trim() === "") return;
|
|
103
|
+
return writer(path$1, data.trim(), options);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
export { exists as a, readSync as i, getRelativePath as n, clean as o, read as r, write as t };
|
|
108
|
+
//# sourceMappingURL=fs-ph1OdgEr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-ph1OdgEr.js","names":["path","reader","path","syncReader","path","path","path"],"sources":["../src/fs/clean.ts","../src/fs/exists.ts","../src/fs/read.ts","../src/fs/utils.ts","../src/fs/write.ts"],"sourcesContent":["import fs from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.pathExists(path)\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.exists()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.pathExistsSync(path)\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function exists(path: string): Promise<boolean> {\n return reader(path)\n}\n\nexport function existsSync(path: string): boolean {\n return syncReader(path)\n}\n","import fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\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 { resolve } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nconst writer = switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\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\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${path.length}]:\\n${path}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.error(e)\n }\n },\n },\n 'node',\n)\n\nexport async function write(path: string, data: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim(), options)\n}\n"],"mappings":";;;;;AAEA,eAAsB,MAAM,QAA6B;AACvD,QAAO,GAAG,OAAOA,OAAK;;;;;ACAxB,MAAMC,WAAS,SACb;CACE,MAAM,OAAO,WAAiB;AAC5B,SAAO,GAAG,WAAWC,OAAK;;CAE5B,KAAK,OAAO,WAAiB;AAG3B,SAFa,IAAI,KAAKA,OAAK,CAEf,QAAQ;;CAEvB,EACD,OACD;AAED,MAAMC,eAAa,SACjB;CACE,OAAO,WAAiB;AACtB,SAAO,GAAG,eAAeD,OAAK;;CAEhC,WAAW;AACT,QAAM,IAAI,MAAM,uBAAuB;;CAE1C,EACD,OACD;AAED,eAAsB,OAAO,QAAgC;AAC3D,QAAOD,SAAOC,OAAK;;;;;AC3BrB,MAAM,SAAS,SACb;CACE,MAAM,OAAO,WAAiB;AAC5B,SAAO,GAAG,SAASE,QAAM,EAAE,UAAU,QAAQ,CAAC;;CAEhD,KAAK,OAAO,WAAiB;AAG3B,SAFa,IAAI,KAAKA,OAAK,CAEf,MAAM;;CAErB,EACD,OACD;AAED,MAAM,aAAa,SACjB;CACE,OAAO,WAAiB;AACtB,SAAO,GAAG,aAAaA,QAAM,EAAE,UAAU,QAAQ,CAAC;;CAEpD,WAAW;AACT,QAAM,IAAI,MAAM,uBAAuB;;CAE1C,EACD,OACD;AAED,eAAsB,KAAK,QAA+B;AACxD,QAAO,OAAOA,OAAK;;AAGrB,SAAgB,SAAS,QAAsB;AAC7C,QAAO,WAAWA,OAAK;;;;;A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,QAAQ;IAEV,MAAM,YAAY,MADL,IAAI,KAAK,QAAQA,OAAK,CAAC,CACP,MAAM;AAEnC,QAAI,WAAW,UAAU,KAAK,MAAM,UAAU,CAC5C,OAAM,IAAI,MAAM,2BAA2BA,OAAK,WAAWA,OAAK,OAAO,MAAMA,OAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,WAAO;;AAGT,UAAO;WACA,GAAG;AACV,WAAQ,MAAM,EAAE;;;CAGrB,EACD,OACD;AAED,eAAsB,MAAM,QAAc,MAAc,UAAmB,EAAE,EAA+B;AAC1G,KAAI,KAAK,MAAM,KAAK,GAClB;AAEF,QAAO,OAAOA,QAAM,KAAK,MAAM,EAAE,QAAQ"}
|
package/dist/fs.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_fs = require('./fs-DhLl4-lT.cjs');
|
|
2
|
+
|
|
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.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fs/clean.d.ts
|
|
2
|
+
declare function clean(path: string): Promise<void>;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/fs/exists.d.ts
|
|
5
|
+
declare function exists(path: string): Promise<boolean>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/fs/read.d.ts
|
|
8
|
+
declare function read(path: string): Promise<string>;
|
|
9
|
+
declare function readSync(path: string): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/fs/utils.d.ts
|
|
12
|
+
declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/fs/write.d.ts
|
|
15
|
+
type Options = {
|
|
16
|
+
sanity?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare function write(path: string, data: string, options?: Options): Promise<string | undefined>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { clean, exists, getRelativePath, read, readSync, write };
|
|
21
|
+
//# sourceMappingURL=fs.d.cts.map
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fs/clean.d.ts
|
|
2
|
+
declare function clean(path: string): Promise<void>;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/fs/exists.d.ts
|
|
5
|
+
declare function exists(path: string): Promise<boolean>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/fs/read.d.ts
|
|
8
|
+
declare function read(path: string): Promise<string>;
|
|
9
|
+
declare function readSync(path: string): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/fs/utils.d.ts
|
|
12
|
+
declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/fs/write.d.ts
|
|
15
|
+
type Options = {
|
|
16
|
+
sanity?: boolean;
|
|
17
|
+
};
|
|
18
|
+
declare function write(path: string, data: string, options?: Options): Promise<string | undefined>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { clean, exists, getRelativePath, read, readSync, write };
|
|
21
|
+
//# sourceMappingURL=fs.d.ts.map
|
package/dist/fs.js
ADDED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as Plugin, t as BarrelType } from "./types-DgfEZ3IN.js";
|
|
1
|
+
import { f as Plugin, t as BarrelType } from "./types-DZARm27h.js";
|
|
3
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
3
|
|
|
5
4
|
//#region src/utils/getBarrelFiles.d.ts
|
|
@@ -22,16 +21,14 @@ type AddIndexesProps = {
|
|
|
22
21
|
output: string;
|
|
23
22
|
exportAs: string;
|
|
24
23
|
};
|
|
25
|
-
logger?: Logger;
|
|
26
24
|
meta?: FileMetaBase;
|
|
27
25
|
};
|
|
28
26
|
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
29
27
|
type,
|
|
30
28
|
meta,
|
|
31
29
|
root,
|
|
32
|
-
output
|
|
33
|
-
logger
|
|
30
|
+
output
|
|
34
31
|
}: AddIndexesProps): Promise<KubbFile.File[]>;
|
|
35
32
|
//#endregion
|
|
36
33
|
export { getBarrelFiles as n, FileMetaBase as t };
|
|
37
|
-
//# sourceMappingURL=getBarrelFiles-
|
|
34
|
+
//# sourceMappingURL=getBarrelFiles-BEWbZEZf.d.ts.map
|