@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
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { n as Logger } from "./logger-BwhJWK-H.js";
|
|
2
|
+
import { _ as ResolvePathParams, a as InputData, b as UserPluginWithLifeCycle, c as Plugin, d as PluginKey, f as PluginLifecycle, g as ResolveNameParams, h as PluginWithLifeCycle, i as Group, l as PluginContext, m as PluginParameter, n as Config, o as InputPath, p as PluginLifecycleHooks, r as GetPluginFactoryOptions, s as Output, t as BarrelType, u as PluginFactoryOptions, v as UserConfig, x as PluginManager, y as UserPlugin } from "./types-CyDeSlGF.js";
|
|
3
|
+
import { t as PossiblePromise } from "./types-DCR_QgGt.js";
|
|
4
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
6
6
|
|
|
7
7
|
//#region src/BaseGenerator.d.ts
|
|
8
8
|
/**
|
|
@@ -25,19 +25,23 @@ type BuildOptions = {
|
|
|
25
25
|
* @default Logger without the spinner
|
|
26
26
|
*/
|
|
27
27
|
logger?: Logger;
|
|
28
|
-
pluginManager?: PluginManager;
|
|
29
28
|
};
|
|
30
29
|
type BuildOutput = {
|
|
31
|
-
|
|
30
|
+
fabric: Fabric;
|
|
31
|
+
files: Array<KubbFile.ResolvedFile>;
|
|
32
32
|
pluginManager: PluginManager;
|
|
33
33
|
/**
|
|
34
34
|
* Only for safeBuild
|
|
35
35
|
*/
|
|
36
36
|
error?: Error;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
type SetupResult = {
|
|
39
|
+
fabric: Fabric;
|
|
40
|
+
pluginManager: PluginManager;
|
|
41
|
+
};
|
|
42
|
+
declare function setup(options: BuildOptions): Promise<SetupResult>;
|
|
43
|
+
declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
44
|
+
declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
41
45
|
//#endregion
|
|
42
46
|
//#region src/config.d.ts
|
|
43
47
|
type Args = {
|
|
@@ -95,14 +99,14 @@ type AddIndexesProps = {
|
|
|
95
99
|
logger?: Logger;
|
|
96
100
|
meta?: FileMetaBase;
|
|
97
101
|
};
|
|
98
|
-
declare function getMode(path: string | undefined | null): Mode;
|
|
99
|
-
declare function getBarrelFiles(files: Array<ResolvedFile>, {
|
|
102
|
+
declare function getMode(path: string | undefined | null): KubbFile.Mode;
|
|
103
|
+
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
100
104
|
type,
|
|
101
105
|
meta,
|
|
102
106
|
root,
|
|
103
107
|
output,
|
|
104
108
|
logger
|
|
105
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
109
|
+
}: AddIndexesProps): Promise<KubbFile.File[]>;
|
|
106
110
|
//#endregion
|
|
107
111
|
//#region src/PackageManager.d.ts
|
|
108
112
|
type PackageJSON = {
|
|
@@ -130,24 +134,24 @@ declare class PackageManager {
|
|
|
130
134
|
//#endregion
|
|
131
135
|
//#region src/utils/executeStrategies.d.ts
|
|
132
136
|
type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
133
|
-
type ValueOfPromiseFuncArray<TInput
|
|
134
|
-
type SeqOutput<TInput
|
|
137
|
+
type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
|
|
138
|
+
type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>;
|
|
135
139
|
/**
|
|
136
140
|
* Chains promises
|
|
137
141
|
*/
|
|
138
142
|
|
|
139
|
-
type HookFirstOutput<TInput
|
|
143
|
+
type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
|
|
140
144
|
/**
|
|
141
145
|
* Chains promises, first non-null result stops and returns
|
|
142
146
|
*/
|
|
143
147
|
|
|
144
|
-
type HookParallelOutput<TInput
|
|
148
|
+
type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
|
|
145
149
|
/**
|
|
146
150
|
* Runs an array of promise functions with optional concurrency limit.
|
|
147
151
|
*/
|
|
148
152
|
|
|
149
153
|
type Strategy = 'seq' | 'first' | 'parallel';
|
|
150
|
-
type StrategySwitch<TStrategy
|
|
154
|
+
type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
|
|
151
155
|
//#endregion
|
|
152
156
|
//#region src/PromiseManager.d.ts
|
|
153
157
|
type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { h as trim, v as transformReservedWord } from "./transformers-DzHGqYO2.js";
|
|
5
|
-
import { r as setUniqueName, t as URLPath } from "./URLPath-BYceu_vY.js";
|
|
6
|
-
import "./casing-BSeq_teY.js";
|
|
1
|
+
import { a as EventEmitter, n as createLogger, o as write } from "./logger-Bxe022ug.js";
|
|
2
|
+
import { g as trim, y as transformReservedWord } from "./transformers-CeNW0G32.js";
|
|
3
|
+
import { r as setUniqueName, t as URLPath } from "./URLPath-DbWtfVa1.js";
|
|
7
4
|
import mod from "node:module";
|
|
8
|
-
import path, { extname, join, relative, resolve } from "node:path";
|
|
9
|
-
import {
|
|
5
|
+
import path, { extname, join, normalize, relative, resolve } from "node:path";
|
|
6
|
+
import { createFabric } from "@kubb/react-fabric";
|
|
7
|
+
import { typescriptParser } from "@kubb/react-fabric/parsers";
|
|
8
|
+
import { fsPlugin } from "@kubb/react-fabric/plugins";
|
|
10
9
|
import pc from "picocolors";
|
|
11
10
|
import { isDeepEqual } from "remeda";
|
|
11
|
+
import fs from "fs-extra";
|
|
12
|
+
import { switcher } from "js-runtime";
|
|
12
13
|
import g$1 from "node:process";
|
|
13
|
-
import { FileManager } from "@kubb/fabric-core";
|
|
14
14
|
import os from "node:os";
|
|
15
15
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
16
|
-
import fs, { promises } from "node:fs";
|
|
16
|
+
import fs$1, { promises } from "node:fs";
|
|
17
17
|
import { coerce, satisfies } from "semver";
|
|
18
18
|
|
|
19
19
|
//#region src/BaseGenerator.ts
|
|
@@ -55,6 +55,74 @@ function isInputPath(result) {
|
|
|
55
55
|
return !!result && "path" in result?.input;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/fs/clean.ts
|
|
60
|
+
async function clean(path$1) {
|
|
61
|
+
return fs.remove(path$1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/fs/exists.ts
|
|
66
|
+
const reader$1 = switcher({
|
|
67
|
+
node: async (path$1) => {
|
|
68
|
+
return fs.pathExists(path$1);
|
|
69
|
+
},
|
|
70
|
+
bun: async (path$1) => {
|
|
71
|
+
return Bun.file(path$1).exists();
|
|
72
|
+
}
|
|
73
|
+
}, "node");
|
|
74
|
+
const syncReader$1 = switcher({
|
|
75
|
+
node: (path$1) => {
|
|
76
|
+
return fs.pathExistsSync(path$1);
|
|
77
|
+
},
|
|
78
|
+
bun: () => {
|
|
79
|
+
throw new Error("Bun cannot read sync");
|
|
80
|
+
}
|
|
81
|
+
}, "node");
|
|
82
|
+
async function exists(path$1) {
|
|
83
|
+
return reader$1(path$1);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/fs/read.ts
|
|
88
|
+
const reader = switcher({
|
|
89
|
+
node: async (path$1) => {
|
|
90
|
+
return fs.readFile(path$1, { encoding: "utf8" });
|
|
91
|
+
},
|
|
92
|
+
bun: async (path$1) => {
|
|
93
|
+
return Bun.file(path$1).text();
|
|
94
|
+
}
|
|
95
|
+
}, "node");
|
|
96
|
+
const syncReader = switcher({
|
|
97
|
+
node: (path$1) => {
|
|
98
|
+
return fs.readFileSync(path$1, { encoding: "utf8" });
|
|
99
|
+
},
|
|
100
|
+
bun: () => {
|
|
101
|
+
throw new Error("Bun cannot read sync");
|
|
102
|
+
}
|
|
103
|
+
}, "node");
|
|
104
|
+
async function read(path$1) {
|
|
105
|
+
return reader(path$1);
|
|
106
|
+
}
|
|
107
|
+
function readSync(path$1) {
|
|
108
|
+
return syncReader(path$1);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/fs/utils.ts
|
|
113
|
+
function slash(path$1, platform = "linux") {
|
|
114
|
+
const isWindowsPath = /^\\\\\?\\/.test(path$1);
|
|
115
|
+
const normalizedPath = normalize(path$1);
|
|
116
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
117
|
+
return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
|
|
118
|
+
}
|
|
119
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
120
|
+
if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
121
|
+
const slashedPath = slash(relative(rootDir, filePath), platform);
|
|
122
|
+
if (slashedPath.startsWith("../")) return slashedPath;
|
|
123
|
+
return `./${slashedPath}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
58
126
|
//#endregion
|
|
59
127
|
//#region src/errors.ts
|
|
60
128
|
var ValidationPluginError = class extends Error {};
|
|
@@ -238,13 +306,16 @@ function createPlugin(factory) {
|
|
|
238
306
|
};
|
|
239
307
|
}
|
|
240
308
|
const pluginCore = createPlugin((options) => {
|
|
241
|
-
const {
|
|
309
|
+
const { fabric, pluginManager, resolvePath, resolveName, logger } = options;
|
|
242
310
|
return {
|
|
243
311
|
name: "core",
|
|
244
312
|
options,
|
|
245
313
|
key: ["core"],
|
|
246
314
|
context() {
|
|
247
315
|
return {
|
|
316
|
+
get fabric() {
|
|
317
|
+
return fabric;
|
|
318
|
+
},
|
|
248
319
|
get config() {
|
|
249
320
|
return options.config;
|
|
250
321
|
},
|
|
@@ -255,10 +326,12 @@ const pluginCore = createPlugin((options) => {
|
|
|
255
326
|
return options.plugin;
|
|
256
327
|
},
|
|
257
328
|
logger,
|
|
258
|
-
fileManager
|
|
329
|
+
get fileManager() {
|
|
330
|
+
return fabric.context.fileManager;
|
|
331
|
+
},
|
|
259
332
|
pluginManager,
|
|
260
333
|
async addFile(...files) {
|
|
261
|
-
const resolvedFiles = await fileManager.add(...files);
|
|
334
|
+
const resolvedFiles = await fabric.context.fileManager.add(...files);
|
|
262
335
|
if (!Array.isArray(resolvedFiles)) return [resolvedFiles];
|
|
263
336
|
return resolvedFiles;
|
|
264
337
|
},
|
|
@@ -280,10 +353,6 @@ const pluginCore = createPlugin((options) => {
|
|
|
280
353
|
//#region src/PluginManager.ts
|
|
281
354
|
var PluginManager = class {
|
|
282
355
|
plugins = /* @__PURE__ */ new Set();
|
|
283
|
-
/**
|
|
284
|
-
* @deprecated do not use from pluginManager
|
|
285
|
-
*/
|
|
286
|
-
fileManager;
|
|
287
356
|
events = new EventEmitter();
|
|
288
357
|
config;
|
|
289
358
|
executed = [];
|
|
@@ -296,13 +365,12 @@ var PluginManager = class {
|
|
|
296
365
|
this.config = config;
|
|
297
366
|
this.options = options;
|
|
298
367
|
this.logger = options.logger;
|
|
299
|
-
this.fileManager = new FileManager();
|
|
300
368
|
this.#promiseManager = new PromiseManager({ nullCheck: (state) => !!state?.result });
|
|
301
369
|
const core = pluginCore({
|
|
370
|
+
fabric: options.fabric,
|
|
302
371
|
config,
|
|
303
372
|
logger: this.logger,
|
|
304
373
|
pluginManager: this,
|
|
305
|
-
fileManager: this.fileManager,
|
|
306
374
|
resolvePath: this.resolvePath.bind(this),
|
|
307
375
|
resolveName: this.resolveName.bind(this),
|
|
308
376
|
getPlugins: this.#getSortedPlugins.bind(this)
|
|
@@ -724,7 +792,6 @@ var PluginManager = class {
|
|
|
724
792
|
//#endregion
|
|
725
793
|
//#region src/build.ts
|
|
726
794
|
async function setup(options) {
|
|
727
|
-
if (options.pluginManager) return options.pluginManager;
|
|
728
795
|
const { config: userConfig, logger = createLogger() } = options;
|
|
729
796
|
if (Array.isArray(userConfig.input)) console.warn(pc.yellow("This feature is still under development — use with caution"));
|
|
730
797
|
try {
|
|
@@ -748,36 +815,32 @@ async function setup(options) {
|
|
|
748
815
|
await clean(definedConfig.output.path);
|
|
749
816
|
await clean(join(definedConfig.root, ".kubb"));
|
|
750
817
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
818
|
+
const fabric = createFabric();
|
|
819
|
+
fabric.use(fsPlugin, { dryRun: !definedConfig.output.write });
|
|
820
|
+
fabric.use(typescriptParser);
|
|
821
|
+
return {
|
|
822
|
+
fabric,
|
|
823
|
+
pluginManager: new PluginManager(definedConfig, {
|
|
824
|
+
fabric,
|
|
825
|
+
logger,
|
|
826
|
+
concurrency: 5
|
|
827
|
+
})
|
|
828
|
+
};
|
|
755
829
|
}
|
|
756
|
-
async function build(options) {
|
|
757
|
-
const { files, pluginManager, error } = await safeBuild(options);
|
|
830
|
+
async function build(options, overrides) {
|
|
831
|
+
const { fabric, files, pluginManager, error } = await safeBuild(options, overrides);
|
|
758
832
|
if (error) throw error;
|
|
759
833
|
return {
|
|
834
|
+
fabric,
|
|
760
835
|
files,
|
|
761
836
|
pluginManager,
|
|
762
837
|
error
|
|
763
838
|
};
|
|
764
839
|
}
|
|
765
|
-
async function safeBuild(options) {
|
|
766
|
-
const pluginManager = await setup(options);
|
|
840
|
+
async function safeBuild(options, overrides) {
|
|
841
|
+
const { fabric, pluginManager } = overrides ? overrides : await setup(options);
|
|
767
842
|
const config = pluginManager.config;
|
|
768
843
|
try {
|
|
769
|
-
pluginManager.events.on("executing", ({ plugin, message }) => {
|
|
770
|
-
pluginManager.logger.emit("debug", {
|
|
771
|
-
date: /* @__PURE__ */ new Date(),
|
|
772
|
-
logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`]
|
|
773
|
-
});
|
|
774
|
-
});
|
|
775
|
-
pluginManager.events.on("executed", ({ plugin, message, output }) => {
|
|
776
|
-
pluginManager.logger.emit("debug", {
|
|
777
|
-
date: /* @__PURE__ */ new Date(),
|
|
778
|
-
logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
|
|
779
|
-
});
|
|
780
|
-
});
|
|
781
844
|
await pluginManager.hookParallel({
|
|
782
845
|
hookName: "buildStart",
|
|
783
846
|
parameters: [config],
|
|
@@ -788,7 +851,7 @@ async function safeBuild(options) {
|
|
|
788
851
|
const rootFile = {
|
|
789
852
|
path: rootPath,
|
|
790
853
|
baseName: "index.ts",
|
|
791
|
-
exports:
|
|
854
|
+
exports: fabric.files.filter((file) => {
|
|
792
855
|
return file.sources.some((source) => source.isIndexable);
|
|
793
856
|
}).flatMap((file) => {
|
|
794
857
|
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
|
|
@@ -809,16 +872,16 @@ async function safeBuild(options) {
|
|
|
809
872
|
sources: [],
|
|
810
873
|
meta: {}
|
|
811
874
|
};
|
|
812
|
-
await
|
|
875
|
+
await fabric.addFile(rootFile);
|
|
813
876
|
}
|
|
814
|
-
|
|
877
|
+
fabric.context.events.on("process:start", ({ files: files$1 }) => {
|
|
815
878
|
pluginManager.logger.emit("progress_start", {
|
|
816
879
|
id: "files",
|
|
817
880
|
size: files$1.length,
|
|
818
881
|
message: "Writing files ..."
|
|
819
882
|
});
|
|
820
883
|
});
|
|
821
|
-
|
|
884
|
+
fabric.context.events.on("process:progress", async ({ file, source }) => {
|
|
822
885
|
const message = file ? `Writing ${relative(config.root, file.path)}` : "";
|
|
823
886
|
pluginManager.logger.emit("progressed", {
|
|
824
887
|
id: "files",
|
|
@@ -826,26 +889,23 @@ async function safeBuild(options) {
|
|
|
826
889
|
});
|
|
827
890
|
if (source) await write(file.path, source, { sanity: false });
|
|
828
891
|
});
|
|
829
|
-
|
|
892
|
+
fabric.context.events.on("process:end", () => {
|
|
830
893
|
pluginManager.logger.emit("progress_stop", { id: "files" });
|
|
831
894
|
});
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
extension: config.output.extension,
|
|
835
|
-
dryRun: !config.output.write,
|
|
836
|
-
parsers
|
|
837
|
-
});
|
|
895
|
+
const files = [...fabric.files];
|
|
896
|
+
await fabric.write({ extension: config.output.extension });
|
|
838
897
|
await pluginManager.hookParallel({
|
|
839
898
|
hookName: "buildEnd",
|
|
840
899
|
message: `Build stopped for ${config.name}`
|
|
841
900
|
});
|
|
842
|
-
await pluginManager.fileManager.clear();
|
|
843
901
|
return {
|
|
902
|
+
fabric,
|
|
844
903
|
files,
|
|
845
904
|
pluginManager
|
|
846
905
|
};
|
|
847
906
|
} catch (e) {
|
|
848
907
|
return {
|
|
908
|
+
fabric,
|
|
849
909
|
files: [],
|
|
850
910
|
pluginManager,
|
|
851
911
|
error: e
|
|
@@ -1038,6 +1098,9 @@ function getMode(path$1) {
|
|
|
1038
1098
|
if (!path$1) return "split";
|
|
1039
1099
|
return extname(path$1) ? "single" : "split";
|
|
1040
1100
|
}
|
|
1101
|
+
function trimExtName(text) {
|
|
1102
|
+
return text.replace(/\.[^/.]+$/, "");
|
|
1103
|
+
}
|
|
1041
1104
|
async function getBarrelFiles(files, { type, meta = {}, root, output, logger }) {
|
|
1042
1105
|
if (!type || type === "propagate") return [];
|
|
1043
1106
|
const barrelManager = new BarrelManager({ logger });
|
|
@@ -1165,7 +1228,7 @@ async function locatePath(paths, { cwd = g$1.cwd(), type = "file", allowSymlinks
|
|
|
1165
1228
|
function locatePathSync(paths, { cwd = g$1.cwd(), type = "file", allowSymlinks = true } = {}) {
|
|
1166
1229
|
checkType(type);
|
|
1167
1230
|
cwd = toPath$1(cwd);
|
|
1168
|
-
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
|
|
1231
|
+
const statFunction = allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
|
|
1169
1232
|
for (const path_ of paths) try {
|
|
1170
1233
|
const stat = statFunction(path.resolve(cwd, path_), { throwIfNoEntry: false });
|
|
1171
1234
|
if (!stat) continue;
|