@kubb/core 4.11.3 → 4.12.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/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
package/src/build.ts
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import { join,
|
|
1
|
+
import { join, resolve } from 'node:path'
|
|
2
2
|
import { performance } from 'node:perf_hooks'
|
|
3
3
|
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
4
4
|
import type { Fabric } from '@kubb/react-fabric'
|
|
5
5
|
import { createFabric } from '@kubb/react-fabric'
|
|
6
6
|
import { typescriptParser } from '@kubb/react-fabric/parsers'
|
|
7
7
|
import { fsPlugin } from '@kubb/react-fabric/plugins'
|
|
8
|
-
import pc from 'picocolors'
|
|
9
8
|
import { isDeepEqual } from 'remeda'
|
|
10
9
|
import { isInputPath } from './config.ts'
|
|
11
10
|
import { clean, exists, getRelativePath, write } from './fs/index.ts'
|
|
12
|
-
import type { Logger } from './logger.ts'
|
|
13
|
-
import { createLogger } from './logger.ts'
|
|
14
11
|
import { PluginManager } from './PluginManager.ts'
|
|
15
|
-
import type { Config, Output, Plugin, UserConfig } from './types.ts'
|
|
12
|
+
import type { Config, KubbEvents, Output, Plugin, UserConfig } from './types.ts'
|
|
13
|
+
import { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
|
|
16
14
|
import { getDiagnosticInfo } from './utils/diagnostics.ts'
|
|
17
15
|
import { URLPath } from './utils/URLPath.ts'
|
|
18
16
|
|
|
19
17
|
type BuildOptions = {
|
|
20
18
|
config: UserConfig
|
|
21
|
-
|
|
22
|
-
* @default Logger without the spinner
|
|
23
|
-
*/
|
|
24
|
-
logger?: Logger
|
|
19
|
+
events?: AsyncEventEmitter<KubbEvents>
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
type BuildOutput = {
|
|
@@ -34,23 +29,22 @@ type BuildOutput = {
|
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
type SetupResult = {
|
|
37
|
-
|
|
32
|
+
events: AsyncEventEmitter<KubbEvents>
|
|
38
33
|
fabric: Fabric
|
|
39
34
|
pluginManager: PluginManager
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
export async function setup(options: BuildOptions): Promise<SetupResult> {
|
|
43
|
-
const { config: userConfig,
|
|
38
|
+
const { config: userConfig, events = new AsyncEventEmitter<KubbEvents>() } = options
|
|
44
39
|
|
|
45
40
|
const diagnosticInfo = getDiagnosticInfo()
|
|
46
41
|
|
|
47
42
|
if (Array.isArray(userConfig.input)) {
|
|
48
|
-
|
|
43
|
+
await events.emit('warn', 'This feature is still under development — use with caution')
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
|
|
46
|
+
await events.emit('debug', {
|
|
52
47
|
date: new Date(),
|
|
53
|
-
category: 'setup',
|
|
54
48
|
logs: [
|
|
55
49
|
'Configuration:',
|
|
56
50
|
` • Name: ${userConfig.name || 'unnamed'}`,
|
|
@@ -72,9 +66,8 @@ export async function setup(options: BuildOptions): Promise<SetupResult> {
|
|
|
72
66
|
if (isInputPath(userConfig) && !new URLPath(userConfig.input.path).isURL) {
|
|
73
67
|
await exists(userConfig.input.path)
|
|
74
68
|
|
|
75
|
-
|
|
69
|
+
await events.emit('debug', {
|
|
76
70
|
date: new Date(),
|
|
77
|
-
category: 'setup',
|
|
78
71
|
logs: [`✓ Input file validated: ${userConfig.input.path}`],
|
|
79
72
|
})
|
|
80
73
|
}
|
|
@@ -107,9 +100,8 @@ export async function setup(options: BuildOptions): Promise<SetupResult> {
|
|
|
107
100
|
}
|
|
108
101
|
|
|
109
102
|
if (definedConfig.output.clean) {
|
|
110
|
-
|
|
103
|
+
await events.emit('debug', {
|
|
111
104
|
date: new Date(),
|
|
112
|
-
category: 'setup',
|
|
113
105
|
logs: ['Cleaning output directories', ` • Output: ${definedConfig.output.path}`, ' • Cache: .kubb'],
|
|
114
106
|
})
|
|
115
107
|
await clean(definedConfig.output.path)
|
|
@@ -120,36 +112,33 @@ export async function setup(options: BuildOptions): Promise<SetupResult> {
|
|
|
120
112
|
fabric.use(fsPlugin, { dryRun: !definedConfig.output.write })
|
|
121
113
|
fabric.use(typescriptParser)
|
|
122
114
|
|
|
123
|
-
fabric.context.on('
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
fabric.context.on('files:processing:start', (files) => {
|
|
116
|
+
events.emit('files:processing:start', files)
|
|
117
|
+
events.emit('debug', {
|
|
126
118
|
date: new Date(),
|
|
127
|
-
category: 'file',
|
|
128
119
|
logs: [`Writing ${files.length} files...`],
|
|
129
120
|
})
|
|
130
121
|
})
|
|
131
122
|
|
|
132
|
-
fabric.context.on('
|
|
133
|
-
const
|
|
134
|
-
|
|
123
|
+
fabric.context.on('file:processing:update', async (params) => {
|
|
124
|
+
const { file, source } = params
|
|
125
|
+
await events.emit('file:processing:update', { ...params, config: definedConfig, source })
|
|
135
126
|
|
|
136
127
|
if (source) {
|
|
137
128
|
await write(file.path, source, { sanity: false })
|
|
138
129
|
}
|
|
139
130
|
})
|
|
140
131
|
|
|
141
|
-
fabric.context.on('
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
fabric.context.on('files:processing:end', async (files) => {
|
|
133
|
+
await events.emit('files:processing:end', files)
|
|
134
|
+
await events.emit('debug', {
|
|
144
135
|
date: new Date(),
|
|
145
|
-
category: 'file',
|
|
146
136
|
logs: ['✓ File write process completed'],
|
|
147
137
|
})
|
|
148
138
|
})
|
|
149
139
|
|
|
150
|
-
|
|
140
|
+
await events.emit('debug', {
|
|
151
141
|
date: new Date(),
|
|
152
|
-
category: 'setup',
|
|
153
142
|
logs: [
|
|
154
143
|
'✓ Fabric initialized',
|
|
155
144
|
` • File writing: ${definedConfig.output.write ? 'enabled' : 'disabled (dry-run)'}`,
|
|
@@ -157,78 +146,14 @@ export async function setup(options: BuildOptions): Promise<SetupResult> {
|
|
|
157
146
|
],
|
|
158
147
|
})
|
|
159
148
|
|
|
160
|
-
const pluginManager = new PluginManager(definedConfig, {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
date: new Date(),
|
|
165
|
-
category: 'hook',
|
|
166
|
-
pluginName: plugin.name,
|
|
167
|
-
logs: [`Executing hook: ${hookName}`, ` • Strategy: ${strategy}`, ' • Parameters:', JSON.stringify(parameters, null, 2)],
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
pluginManager.on('executed', ({ plugin, hookName, duration, parameters }) => {
|
|
172
|
-
let message = ''
|
|
173
|
-
if (hookName === 'resolvePath') {
|
|
174
|
-
const [path] = parameters || []
|
|
175
|
-
message = `Resolving path '${path}'`
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (hookName === 'resolveName') {
|
|
179
|
-
const [name, type] = parameters || []
|
|
180
|
-
message = `Resolving name '${name}' and type '${type}'`
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
logger.emit('progressed', {
|
|
184
|
-
id: hookName,
|
|
185
|
-
message: `${plugin.name}: ${message}`,
|
|
186
|
-
})
|
|
187
|
-
logger.emit('debug', {
|
|
188
|
-
date: new Date(),
|
|
189
|
-
category: 'hook',
|
|
190
|
-
pluginName: plugin.name,
|
|
191
|
-
logs: [`✓ Completed in ${duration}ms`],
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
pluginManager.on('progress_start', ({ hookName, plugins }) => {
|
|
196
|
-
logger.emit('progress_start', { id: hookName, size: plugins.length, message: 'Running plugins...' })
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
pluginManager.on('progress_stop', ({ hookName }) => {
|
|
200
|
-
logger.emit('progress_stop', { id: hookName })
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
pluginManager.on('error', (error, { plugin, strategy, duration, parameters, hookName }) => {
|
|
204
|
-
const text = `${error.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`
|
|
205
|
-
|
|
206
|
-
logger.emit('error', text, error)
|
|
207
|
-
|
|
208
|
-
logger.emit('debug', {
|
|
209
|
-
date: new Date(),
|
|
210
|
-
category: 'error',
|
|
211
|
-
pluginName: plugin.name,
|
|
212
|
-
logs: [
|
|
213
|
-
`✗ Hook '${hookName}' failed after ${duration}ms`,
|
|
214
|
-
` • Strategy: ${strategy}`,
|
|
215
|
-
` • Error: ${error.constructor.name} - ${error.message}`,
|
|
216
|
-
' • Stack Trace:',
|
|
217
|
-
error.stack || 'No stack trace available',
|
|
218
|
-
' • Parameters:',
|
|
219
|
-
JSON.stringify(parameters, null, 2),
|
|
220
|
-
],
|
|
221
|
-
})
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
logger.emit('debug', {
|
|
225
|
-
date: new Date(),
|
|
226
|
-
category: 'setup',
|
|
227
|
-
logs: ['✓ PluginManager initialized', ' • Concurrency: 5', ` • Total plugins: ${pluginManager.plugins.length}`],
|
|
149
|
+
const pluginManager = new PluginManager(definedConfig, {
|
|
150
|
+
fabric,
|
|
151
|
+
events,
|
|
152
|
+
concurrency: 5,
|
|
228
153
|
})
|
|
229
154
|
|
|
230
155
|
return {
|
|
231
|
-
|
|
156
|
+
events,
|
|
232
157
|
fabric,
|
|
233
158
|
pluginManager,
|
|
234
159
|
}
|
|
@@ -252,7 +177,7 @@ export async function build(options: BuildOptions, overrides?: SetupResult): Pro
|
|
|
252
177
|
}
|
|
253
178
|
|
|
254
179
|
export async function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput> {
|
|
255
|
-
const { fabric, pluginManager,
|
|
180
|
+
const { fabric, pluginManager, events } = overrides ? overrides : await setup(options)
|
|
256
181
|
|
|
257
182
|
const failedPlugins = new Set<{ plugin: Plugin; error: Error }>()
|
|
258
183
|
const pluginTimings = new Map<string, number>()
|
|
@@ -268,18 +193,10 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
268
193
|
const startTime = performance.now()
|
|
269
194
|
const timestamp = new Date()
|
|
270
195
|
|
|
271
|
-
|
|
272
|
-
logger.emit('debug', {
|
|
273
|
-
date: timestamp,
|
|
274
|
-
pluginGroupMarker: 'start',
|
|
275
|
-
pluginName: plugin.name,
|
|
276
|
-
logs: [],
|
|
277
|
-
})
|
|
196
|
+
await events.emit('plugin:start', plugin)
|
|
278
197
|
|
|
279
|
-
|
|
198
|
+
await events.emit('debug', {
|
|
280
199
|
date: timestamp,
|
|
281
|
-
category: 'plugin',
|
|
282
|
-
pluginName: plugin.name,
|
|
283
200
|
logs: ['Installing plugin...', ` • Plugin Key: ${JSON.stringify(plugin.key)}`],
|
|
284
201
|
})
|
|
285
202
|
|
|
@@ -288,28 +205,18 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
288
205
|
const duration = Math.round(performance.now() - startTime)
|
|
289
206
|
pluginTimings.set(plugin.name, duration)
|
|
290
207
|
|
|
291
|
-
|
|
292
|
-
date: new Date(),
|
|
293
|
-
category: 'plugin',
|
|
294
|
-
pluginName: plugin.name,
|
|
295
|
-
logs: [`✓ Plugin installed successfully (${duration}ms)`],
|
|
296
|
-
})
|
|
208
|
+
await events.emit('plugin:end', plugin, duration)
|
|
297
209
|
|
|
298
|
-
|
|
299
|
-
logger.emit('debug', {
|
|
210
|
+
await events.emit('debug', {
|
|
300
211
|
date: new Date(),
|
|
301
|
-
|
|
302
|
-
pluginName: plugin.name,
|
|
303
|
-
logs: [],
|
|
212
|
+
logs: [`✓ Plugin installed successfully (${duration}ms)`],
|
|
304
213
|
})
|
|
305
214
|
} catch (e) {
|
|
306
215
|
const error = e as Error
|
|
307
216
|
const errorTimestamp = new Date()
|
|
308
217
|
|
|
309
|
-
|
|
218
|
+
await events.emit('debug', {
|
|
310
219
|
date: errorTimestamp,
|
|
311
|
-
category: 'error',
|
|
312
|
-
pluginName: plugin.name,
|
|
313
220
|
logs: [
|
|
314
221
|
'✗ Plugin installation failed',
|
|
315
222
|
` • Plugin Key: ${JSON.stringify(plugin.key)}`,
|
|
@@ -319,14 +226,6 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
319
226
|
],
|
|
320
227
|
})
|
|
321
228
|
|
|
322
|
-
// End plugin group even on error
|
|
323
|
-
logger.emit('debug', {
|
|
324
|
-
date: errorTimestamp,
|
|
325
|
-
pluginGroupMarker: 'end',
|
|
326
|
-
pluginName: plugin.name,
|
|
327
|
-
logs: [],
|
|
328
|
-
})
|
|
329
|
-
|
|
330
229
|
failedPlugins.add({ plugin, error })
|
|
331
230
|
}
|
|
332
231
|
}
|
|
@@ -335,7 +234,7 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
335
234
|
const root = resolve(config.root)
|
|
336
235
|
const rootPath = resolve(root, config.output.path, 'index.ts')
|
|
337
236
|
|
|
338
|
-
|
|
237
|
+
await events.emit('debug', {
|
|
339
238
|
date: new Date(),
|
|
340
239
|
logs: ['Generating barrel file', ` • Type: ${config.output.barrelType}`, ` • Path: ${rootPath}`],
|
|
341
240
|
})
|
|
@@ -344,7 +243,7 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
344
243
|
return file.sources.some((source) => source.isIndexable)
|
|
345
244
|
})
|
|
346
245
|
|
|
347
|
-
|
|
246
|
+
await events.emit('debug', {
|
|
348
247
|
date: new Date(),
|
|
349
248
|
logs: [`Found ${barrelFiles.length} indexable files for barrel export`],
|
|
350
249
|
})
|
|
@@ -367,7 +266,9 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
367
266
|
const meta = file.meta as any
|
|
368
267
|
return isDeepEqual(item.key, meta?.pluginKey)
|
|
369
268
|
})
|
|
370
|
-
const pluginOptions = plugin?.options as {
|
|
269
|
+
const pluginOptions = plugin?.options as {
|
|
270
|
+
output?: Output<any>
|
|
271
|
+
}
|
|
371
272
|
|
|
372
273
|
if (!pluginOptions || pluginOptions?.output?.barrelType === false) {
|
|
373
274
|
return undefined
|
|
@@ -388,9 +289,8 @@ export async function safeBuild(options: BuildOptions, overrides?: SetupResult):
|
|
|
388
289
|
|
|
389
290
|
await fabric.upsertFile(rootFile)
|
|
390
291
|
|
|
391
|
-
|
|
292
|
+
await events.emit('debug', {
|
|
392
293
|
date: new Date(),
|
|
393
|
-
category: 'file',
|
|
394
294
|
logs: [`✓ Generated barrel file (${rootFile.exports?.length || 0} exports)`],
|
|
395
295
|
})
|
|
396
296
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { BaseGenerator } from './BaseGenerator.ts'
|
|
2
2
|
export { build, build as default, safeBuild, setup } from './build.ts'
|
|
3
3
|
export { type CLIOptions, defineConfig, isInputPath } from './config.ts'
|
|
4
|
+
export { defineLogger } from './defineLogger.ts'
|
|
4
5
|
export { definePlugin } from './definePlugin.ts'
|
|
5
6
|
export { PackageManager } from './PackageManager.ts'
|
|
6
7
|
export { getMode, PluginManager } from './PluginManager.ts'
|
|
7
8
|
export { PromiseManager } from './PromiseManager.ts'
|
|
8
|
-
export
|
|
9
|
+
export * from './types.ts'
|
|
9
10
|
export type { FileMetaBase } from './utils/getBarrelFiles.ts'
|
|
10
11
|
export { getBarrelFiles } from './utils/getBarrelFiles.ts'
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
2
2
|
import type { Fabric } from '@kubb/react-fabric'
|
|
3
|
-
import type {
|
|
3
|
+
import type { KubbEvents } from './Kubb.ts'
|
|
4
4
|
import type { PluginManager } from './PluginManager.ts'
|
|
5
|
+
import type { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'
|
|
5
6
|
import type { PossiblePromise } from './utils/types.ts'
|
|
6
7
|
|
|
7
8
|
declare global {
|
|
@@ -299,7 +300,7 @@ export type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryO
|
|
|
299
300
|
* merging multiple sources into the same output file
|
|
300
301
|
*/
|
|
301
302
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>
|
|
302
|
-
|
|
303
|
+
events: AsyncEventEmitter<KubbEvents>
|
|
303
304
|
mode: KubbFile.Mode
|
|
304
305
|
/**
|
|
305
306
|
* Current plugin
|
|
@@ -343,3 +344,35 @@ export type Group = {
|
|
|
343
344
|
*/
|
|
344
345
|
name?: (context: GroupContext) => string
|
|
345
346
|
}
|
|
347
|
+
|
|
348
|
+
export const LogLevel = {
|
|
349
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
350
|
+
error: 0,
|
|
351
|
+
warn: 1,
|
|
352
|
+
info: 3,
|
|
353
|
+
verbose: 4,
|
|
354
|
+
debug: 5,
|
|
355
|
+
} as const
|
|
356
|
+
|
|
357
|
+
export type LoggerOptions = {
|
|
358
|
+
/**
|
|
359
|
+
* @default 3
|
|
360
|
+
*/
|
|
361
|
+
logLevel: (typeof LogLevel)[keyof typeof LogLevel]
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Shared context passed to all plugins, parsers, and Fabric internals.
|
|
366
|
+
*/
|
|
367
|
+
export interface LoggerContext extends AsyncEventEmitter<KubbEvents> {}
|
|
368
|
+
|
|
369
|
+
type Install<TOptions = unknown> = (context: LoggerContext, options?: TOptions) => void | Promise<void>
|
|
370
|
+
|
|
371
|
+
export type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
|
|
372
|
+
name: string
|
|
373
|
+
install: Install<TOptions>
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Omit<Logger<TOptions>, 'logLevel'>
|
|
377
|
+
|
|
378
|
+
export type { KubbEvents } from './Kubb.ts'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
2
|
import type { KubbFile } from '@kubb/fabric-core/types'
|
|
3
3
|
import { BarrelManager } from '../BarrelManager.ts'
|
|
4
|
-
import type { Logger } from '../logger.ts'
|
|
5
4
|
import type { BarrelType, Plugin } from '../types.ts'
|
|
6
5
|
|
|
7
6
|
export type FileMetaBase = {
|
|
@@ -24,7 +23,6 @@ type AddIndexesProps = {
|
|
|
24
23
|
output: string
|
|
25
24
|
exportAs: string
|
|
26
25
|
}
|
|
27
|
-
logger?: Logger
|
|
28
26
|
|
|
29
27
|
meta?: FileMetaBase
|
|
30
28
|
}
|
|
@@ -33,25 +31,24 @@ function trimExtName(text: string): string {
|
|
|
33
31
|
return text.replace(/\.[^/.]+$/, '')
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
export async function getBarrelFiles(
|
|
37
|
-
files: Array<KubbFile.ResolvedFile>,
|
|
38
|
-
{ type, meta = {}, root, output, logger }: AddIndexesProps,
|
|
39
|
-
): Promise<KubbFile.File[]> {
|
|
34
|
+
export async function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, { type, meta = {}, root, output }: AddIndexesProps): Promise<KubbFile.File[]> {
|
|
40
35
|
if (!type || type === 'propagate') {
|
|
41
36
|
return []
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
const barrelManager = new BarrelManager({
|
|
39
|
+
const barrelManager = new BarrelManager({})
|
|
45
40
|
|
|
46
41
|
const pathToBuildFrom = join(root, output.path)
|
|
47
42
|
|
|
48
43
|
if (trimExtName(pathToBuildFrom).endsWith('index')) {
|
|
49
|
-
logger?.emit('warning', 'Output has the same fileName as the barrelFiles, please disable barrel generation')
|
|
50
|
-
|
|
51
44
|
return []
|
|
52
45
|
}
|
|
53
46
|
|
|
54
|
-
const barrelFiles = barrelManager.getFiles({
|
|
47
|
+
const barrelFiles = barrelManager.getFiles({
|
|
48
|
+
files,
|
|
49
|
+
root: pathToBuildFrom,
|
|
50
|
+
meta,
|
|
51
|
+
})
|
|
55
52
|
|
|
56
53
|
if (type === 'all') {
|
|
57
54
|
return barrelFiles.map((file) => {
|
package/src/utils/index.ts
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
let node_events = require("node:events");
|
|
3
|
-
|
|
4
|
-
//#region src/utils/EventEmitter.ts
|
|
5
|
-
var EventEmitter = class {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.#emitter.setMaxListeners(100);
|
|
8
|
-
}
|
|
9
|
-
#emitter = new node_events.EventEmitter();
|
|
10
|
-
emit(eventName, ...eventArg) {
|
|
11
|
-
this.#emitter.emit(eventName, ...eventArg);
|
|
12
|
-
}
|
|
13
|
-
on(eventName, handler) {
|
|
14
|
-
this.#emitter.on(eventName, handler);
|
|
15
|
-
}
|
|
16
|
-
off(eventName, handler) {
|
|
17
|
-
this.#emitter.off(eventName, handler);
|
|
18
|
-
}
|
|
19
|
-
removeAll() {
|
|
20
|
-
this.#emitter.removeAllListeners();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
Object.defineProperty(exports, 'EventEmitter', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return EventEmitter;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=EventEmitter-BwU6Ixxt.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitter-BwU6Ixxt.cjs","names":["#emitter","NodeEventEmitter"],"sources":["../src/utils/EventEmitter.ts"],"sourcesContent":["import { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class EventEmitter<TEvents extends Record<string, any>> {\n constructor() {\n this.#emitter.setMaxListeners(100)\n }\n #emitter = new NodeEventEmitter()\n\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {\n this.#emitter.emit(eventName, ...(eventArg as any))\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n"],"mappings":";;;;AAEA,IAAa,eAAb,MAA+D;CAC7D,cAAc;AACZ,QAAKA,QAAS,gBAAgB,IAAI;;CAEpC,WAAW,IAAIC,0BAAkB;CAEjC,KAAgD,WAAuB,GAAG,UAAqC;AAC7G,QAAKD,QAAS,KAAK,WAAW,GAAI,SAAiB;;CAGrD,GAA8C,WAAuB,SAA2D;AAC9H,QAAKA,QAAS,GAAG,WAAW,QAAe;;CAG7C,IAA+C,WAAuB,SAA2D;AAC/H,QAAKA,QAAS,IAAI,WAAW,QAAe;;CAE9C,YAAkB;AAChB,QAAKA,QAAS,oBAAoB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/EventEmitter.ts
|
|
4
|
-
var EventEmitter$1 = class {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.#emitter.setMaxListeners(100);
|
|
7
|
-
}
|
|
8
|
-
#emitter = new EventEmitter();
|
|
9
|
-
emit(eventName, ...eventArg) {
|
|
10
|
-
this.#emitter.emit(eventName, ...eventArg);
|
|
11
|
-
}
|
|
12
|
-
on(eventName, handler) {
|
|
13
|
-
this.#emitter.on(eventName, handler);
|
|
14
|
-
}
|
|
15
|
-
off(eventName, handler) {
|
|
16
|
-
this.#emitter.off(eventName, handler);
|
|
17
|
-
}
|
|
18
|
-
removeAll() {
|
|
19
|
-
this.#emitter.removeAllListeners();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { EventEmitter$1 as t };
|
|
25
|
-
//# sourceMappingURL=EventEmitter-DlzW04T3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitter-DlzW04T3.js","names":["EventEmitter","#emitter","NodeEventEmitter"],"sources":["../src/utils/EventEmitter.ts"],"sourcesContent":["import { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class EventEmitter<TEvents extends Record<string, any>> {\n constructor() {\n this.#emitter.setMaxListeners(100)\n }\n #emitter = new NodeEventEmitter()\n\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {\n this.#emitter.emit(eventName, ...(eventArg as any))\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n"],"mappings":";;;AAEA,IAAaA,iBAAb,MAA+D;CAC7D,cAAc;AACZ,QAAKC,QAAS,gBAAgB,IAAI;;CAEpC,WAAW,IAAIC,cAAkB;CAEjC,KAAgD,WAAuB,GAAG,UAAqC;AAC7G,QAAKD,QAAS,KAAK,WAAW,GAAI,SAAiB;;CAGrD,GAA8C,WAAuB,SAA2D;AAC9H,QAAKA,QAAS,GAAG,WAAW,QAAe;;CAG7C,IAA+C,WAAuB,SAA2D;AAC/H,QAAKA,QAAS,IAAI,WAAW,QAAe;;CAE9C,YAAkB;AAChB,QAAKA,QAAS,oBAAoB"}
|
package/dist/chunk-CbDLau6x.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
|
|
29
|
-
Object.defineProperty(exports, '__toESM', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return __toESM;
|
|
33
|
-
}
|
|
34
|
-
});
|