@kubb/cli 5.0.0-beta.40 → 5.0.0-beta.41

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.
Files changed (44) hide show
  1. package/README.md +11 -15
  2. package/dist/{agent-ZKJkTTGN.js → agent-D3K_-kiv.js} +2 -2
  3. package/dist/{agent-ZKJkTTGN.js.map → agent-D3K_-kiv.js.map} +1 -1
  4. package/dist/{agent-DQerNyd8.cjs → agent-DTqKBULa.cjs} +2 -2
  5. package/dist/{agent-DQerNyd8.cjs.map → agent-DTqKBULa.cjs.map} +1 -1
  6. package/dist/{generate-DQLvFw4z.cjs → generate-CZYIOngX.cjs} +2 -2
  7. package/dist/{generate-DQLvFw4z.cjs.map → generate-CZYIOngX.cjs.map} +1 -1
  8. package/dist/{generate-40x9PP4o.js → generate-HcvbU80u.js} +2 -2
  9. package/dist/{generate-40x9PP4o.js.map → generate-HcvbU80u.js.map} +1 -1
  10. package/dist/index.cjs +6 -6
  11. package/dist/index.js +6 -6
  12. package/dist/{init-CT9RChdK.js → init-BMtuczv8.js} +2 -2
  13. package/dist/{init-CT9RChdK.js.map → init-BMtuczv8.js.map} +1 -1
  14. package/dist/{init-sEaUN7Dj.cjs → init-DybfkgNy.cjs} +2 -2
  15. package/dist/{init-sEaUN7Dj.cjs.map → init-DybfkgNy.cjs.map} +1 -1
  16. package/dist/{mcp-cjPrOeot.js → mcp-BF9dnH_F.js} +2 -2
  17. package/dist/{mcp-cjPrOeot.js.map → mcp-BF9dnH_F.js.map} +1 -1
  18. package/dist/{mcp-Siyb6fTT.cjs → mcp-YzKoU6_l.cjs} +2 -2
  19. package/dist/{mcp-Siyb6fTT.cjs.map → mcp-YzKoU6_l.cjs.map} +1 -1
  20. package/dist/package-BCwMApnr.js +6 -0
  21. package/dist/package-BCwMApnr.js.map +1 -0
  22. package/dist/{package-BJ6qam2Y.cjs → package-DPe5CA4S.cjs} +2 -2
  23. package/dist/package-DPe5CA4S.cjs.map +1 -0
  24. package/dist/{run-CHZKHTv0.js → run-DaV_NiKR.js} +68 -316
  25. package/dist/run-DaV_NiKR.js.map +1 -0
  26. package/dist/{run-CcQawFNK.cjs → run-UWQ9wImP.cjs} +48 -296
  27. package/dist/run-UWQ9wImP.cjs.map +1 -0
  28. package/dist/{validate-8pgfxUTy.js → validate-BHc3lUKB.js} +2 -2
  29. package/dist/{validate-8pgfxUTy.js.map → validate-BHc3lUKB.js.map} +1 -1
  30. package/dist/{validate-CstV7Pc2.cjs → validate-CqRqJxmQ.cjs} +2 -2
  31. package/dist/{validate-CstV7Pc2.cjs.map → validate-CqRqJxmQ.cjs.map} +1 -1
  32. package/package.json +6 -6
  33. package/src/loggers/clackLogger.ts +22 -25
  34. package/src/loggers/plainLogger.ts +3 -6
  35. package/src/loggers/types.ts +1 -2
  36. package/src/loggers/utils.ts +11 -68
  37. package/src/runners/generate/run.ts +7 -14
  38. package/src/runners/generate/utils.ts +15 -18
  39. package/dist/package-BJ6qam2Y.cjs.map +0 -1
  40. package/dist/package-CR5vEK4K.js +0 -6
  41. package/dist/package-CR5vEK4K.js.map +0 -1
  42. package/dist/run-CHZKHTv0.js.map +0 -1
  43. package/dist/run-CcQawFNK.cjs.map +0 -1
  44. package/src/loggers/githubActionsLogger.ts +0 -377
@@ -1,377 +0,0 @@
1
- import { styleText } from 'node:util'
2
- import { formatMs, formatMsWithColor, toCause } from '@internals/utils'
3
- import { type Config, defineLogger, Diagnostics, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
4
- import {
5
- buildProgressLine,
6
- createHookTimer,
7
- createProgressCounters,
8
- formatCommandWithArgs,
9
- formatMessage,
10
- recordPluginResult,
11
- resetProgressCounters,
12
- } from './utils.ts'
13
-
14
- /**
15
- * GitHub Actions logger using group annotations for collapsible sections in CI.
16
- */
17
- export const githubActionsLogger = defineLogger({
18
- name: 'github-actions',
19
- install(context, options) {
20
- const logLevel = options?.logLevel ?? logLevelMap.info
21
- const state = {
22
- ...createProgressCounters(),
23
- currentConfigs: [] as Array<Config>,
24
- openGroupDepth: 0,
25
- }
26
- const hookTimer = createHookTimer()
27
-
28
- function reset() {
29
- closeAllGroups()
30
- resetProgressCounters(state)
31
- state.currentConfigs = []
32
- hookTimer.clear()
33
- }
34
-
35
- function showProgressStep() {
36
- if (logLevel <= logLevelMap.silent) {
37
- return
38
- }
39
-
40
- const line = buildProgressLine(state)
41
- if (line) {
42
- console.log(getMessage(line))
43
- }
44
- }
45
-
46
- function getMessage(message: string): string {
47
- return formatMessage(message, logLevel)
48
- }
49
-
50
- function openGroup(name: string) {
51
- console.log(`::group::${name}`)
52
- state.openGroupDepth++
53
- }
54
-
55
- function closeGroup(_name: string) {
56
- console.log('::endgroup::')
57
- if (state.openGroupDepth > 0) state.openGroupDepth--
58
- }
59
-
60
- function closeAllGroups() {
61
- while (state.openGroupDepth > 0) {
62
- console.log('::endgroup::')
63
- state.openGroupDepth--
64
- }
65
- }
66
-
67
- // Opens a group (only for single-config runs) then logs the step message.
68
- function onGroupStart<E extends keyof KubbHooks>(event: E, message: string, group: string): void {
69
- context.on(event, () => {
70
- if (logLevel <= logLevelMap.silent) {
71
- return
72
- }
73
- if (state.currentConfigs.length === 1) {
74
- openGroup(group)
75
- }
76
- console.log(getMessage(message))
77
- })
78
- }
79
-
80
- // Logs the step message then closes the matching group (single-config runs).
81
- function onGroupEnd<E extends keyof KubbHooks>(event: E, message: string, group: string): void {
82
- context.on(event, () => {
83
- if (logLevel <= logLevelMap.silent) {
84
- return
85
- }
86
- console.log(getMessage(message))
87
- if (state.currentConfigs.length === 1) {
88
- closeGroup(group)
89
- }
90
- })
91
- }
92
-
93
- context.on('kubb:info', ({ message, info = '' }) => {
94
- if (logLevel <= logLevelMap.silent) {
95
- return
96
- }
97
-
98
- const text = getMessage([styleText('blue', 'ℹ'), message, styleText('dim', info)].join(' '))
99
-
100
- console.log(text)
101
- })
102
-
103
- context.on('kubb:success', ({ message, info = '' }) => {
104
- if (logLevel <= logLevelMap.silent) {
105
- return
106
- }
107
-
108
- const text = getMessage([styleText('blue', '✓'), message, logLevel >= logLevelMap.info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))
109
-
110
- console.log(text)
111
- })
112
-
113
- context.on('kubb:warn', ({ message, info = '' }) => {
114
- if (logLevel <= logLevelMap.silent) {
115
- return
116
- }
117
-
118
- const text = getMessage([styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))
119
-
120
- console.warn(`::warning::${text}`)
121
- })
122
-
123
- context.on('kubb:error', ({ error }) => {
124
- const caused = toCause(error)
125
-
126
- // Always release any unclosed groups so a thrown :start without a matching :end
127
- // (e.g., when getConfigs or kubb.setup throws) doesn't leak an open section.
128
- closeAllGroups()
129
-
130
- // Errors are always surfaced, even at silent, so failures stay visible.
131
- const message = error.message || String(error)
132
- console.error(`::error::${message}`)
133
-
134
- // Show stack trace in verbose mode (first 3 frames)
135
- if (logLevel >= logLevelMap.verbose && error.stack) {
136
- const frames = error.stack.split('\n').slice(1, 4)
137
- for (const frame of frames) {
138
- console.log(getMessage(styleText('dim', frame.trim())))
139
- }
140
-
141
- if (caused?.stack) {
142
- console.log(styleText('dim', `└─ caused by ${caused.message}`))
143
-
144
- const frames = caused.stack.split('\n').slice(1, 4)
145
- for (const frame of frames) {
146
- console.log(getMessage(` ${styleText('dim', frame.trim())}`))
147
- }
148
- }
149
- }
150
- })
151
-
152
- context.on('kubb:diagnostic', ({ diagnostic }) => {
153
- closeAllGroups()
154
-
155
- // Silent still surfaces errors so failures stay visible. It drops warnings and info.
156
- if (logLevel <= logLevelMap.silent && diagnostic.severity !== 'error') {
157
- return
158
- }
159
-
160
- if (!Diagnostics.isProblem(diagnostic)) {
161
- console.log(`::notice::${diagnostic.message}`)
162
- return
163
- }
164
-
165
- const parts = [`${diagnostic.code} ${diagnostic.message}`]
166
- if (diagnostic.location && 'pointer' in diagnostic.location) {
167
- parts.push(`(at ${diagnostic.location.pointer})`)
168
- }
169
- if (diagnostic.plugin) {
170
- parts.push(`[plugin: ${diagnostic.plugin}]`)
171
- }
172
- if (diagnostic.help) {
173
- parts.push(`help: ${diagnostic.help}`)
174
- }
175
- if (diagnostic.code !== Diagnostics.code.unknown) {
176
- parts.push(`docs: ${Diagnostics.docsUrl(diagnostic.code)}`)
177
- }
178
- console.error(`::error::${parts.join(' ')}`)
179
- })
180
-
181
- context.on('kubb:lifecycle:start', ({ version }) => {
182
- console.log(styleText('yellow', `Kubb ${version} 🧩`))
183
- reset()
184
- })
185
-
186
- context.on('kubb:config:start', () => {
187
- if (logLevel <= logLevelMap.silent) {
188
- return
189
- }
190
-
191
- const text = getMessage('Configuration started')
192
-
193
- openGroup('Configuration')
194
-
195
- console.log(text)
196
- })
197
-
198
- context.on('kubb:config:end', ({ configs }) => {
199
- state.currentConfigs = configs
200
-
201
- if (logLevel <= logLevelMap.silent) {
202
- return
203
- }
204
-
205
- const text = getMessage('Configuration completed')
206
-
207
- console.log(text)
208
-
209
- closeGroup('Configuration')
210
- })
211
-
212
- context.on('kubb:generation:start', ({ config }) => {
213
- reset()
214
-
215
- // Initialize progress tracking for this generation
216
- state.totalPlugins = config.plugins?.length ?? 0
217
-
218
- const text = config.name ? `Generation for ${styleText('bold', config.name)}` : 'Generation'
219
-
220
- if (state.currentConfigs.length > 1) {
221
- openGroup(text)
222
- }
223
-
224
- if (state.currentConfigs.length === 1) {
225
- console.log(getMessage(text))
226
- }
227
- })
228
-
229
- context.on('kubb:plugin:start', ({ plugin }) => {
230
- if (logLevel <= logLevelMap.silent) {
231
- return
232
- }
233
- const text = getMessage(`Generating ${styleText('bold', plugin.name)}`)
234
-
235
- if (state.currentConfigs.length === 1) {
236
- openGroup(`Plugin: ${plugin.name}`)
237
- }
238
-
239
- console.log(text)
240
- })
241
-
242
- context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
243
- if (logLevel <= logLevelMap.silent) {
244
- return
245
- }
246
-
247
- recordPluginResult(state, success)
248
-
249
- const durationStr = formatMsWithColor(duration)
250
- const text = getMessage(
251
- success
252
- ? `${styleText('bold', plugin.name)} completed in ${durationStr}`
253
- : `${styleText('bold', plugin.name)} failed in ${styleText('red', formatMs(duration))}`,
254
- )
255
-
256
- console.log(text)
257
- if (state.currentConfigs.length > 1) {
258
- console.log(' ')
259
- }
260
-
261
- if (state.currentConfigs.length === 1) {
262
- closeGroup(`Plugin: ${plugin.name}`)
263
- }
264
-
265
- // Show progress step after each plugin
266
- showProgressStep()
267
- })
268
-
269
- context.on('kubb:files:processing:start', ({ files }) => {
270
- if (logLevel <= logLevelMap.silent) {
271
- return
272
- }
273
-
274
- state.totalFiles = files.length
275
- state.processedFiles = 0
276
-
277
- if (state.currentConfigs.length === 1) {
278
- openGroup('File Generation')
279
- }
280
- const text = getMessage(`Writing ${files.length} files`)
281
-
282
- console.log(text)
283
- })
284
-
285
- context.on('kubb:files:processing:end', () => {
286
- if (logLevel <= logLevelMap.silent) {
287
- return
288
- }
289
- const text = getMessage('Files written successfully')
290
-
291
- console.log(text)
292
-
293
- if (state.currentConfigs.length === 1) {
294
- closeGroup('File Generation')
295
- }
296
-
297
- // Show final progress step after files are written
298
- showProgressStep()
299
- })
300
-
301
- context.on('kubb:files:processing:update', ({ files }) => {
302
- if (logLevel <= logLevelMap.silent) {
303
- return
304
- }
305
-
306
- state.processedFiles += files.length
307
- })
308
-
309
- context.on('kubb:generation:end', ({ config }) => {
310
- const text = getMessage(
311
- config.name ? `${styleText('blue', '✓')} Generation completed for ${styleText('dim', config.name)}` : `${styleText('blue', '✓')} Generation completed`,
312
- )
313
-
314
- console.log(text)
315
-
316
- if (state.currentConfigs.length > 1) {
317
- closeGroup(config.name ? `Generation for ${styleText('bold', config.name)}` : 'Generation')
318
- }
319
- })
320
-
321
- onGroupStart('kubb:format:start', 'Format started', 'Formatting')
322
- onGroupEnd('kubb:format:end', 'Format completed', 'Formatting')
323
- onGroupStart('kubb:lint:start', 'Lint started', 'Linting')
324
- onGroupEnd('kubb:lint:end', 'Lint completed', 'Linting')
325
- onGroupStart('kubb:hooks:start', 'Hooks started', 'Hooks')
326
- onGroupEnd('kubb:hooks:end', 'Hooks completed', 'Hooks')
327
-
328
- context.on('kubb:hook:start', ({ id, command, args }) => {
329
- if (logLevel <= logLevelMap.silent) {
330
- return
331
- }
332
-
333
- if (id) {
334
- hookTimer.start(id)
335
- }
336
-
337
- const commandWithArgs = formatCommandWithArgs(command, args)
338
- const text = getMessage(`Hook ${styleText('dim', commandWithArgs)} started`)
339
-
340
- if (state.currentConfigs.length === 1) {
341
- openGroup(`Hook ${commandWithArgs}`)
342
- }
343
- console.log(text)
344
- })
345
-
346
- context.on('kubb:hook:end', ({ id, command, args, success, error }) => {
347
- if (logLevel <= logLevelMap.silent) {
348
- return
349
- }
350
-
351
- const ms = id ? hookTimer.end(id) : undefined
352
- const durationStr = ms !== undefined ? ` in ${formatMsWithColor(ms)}` : ''
353
-
354
- const commandWithArgs = formatCommandWithArgs(command, args)
355
-
356
- if (success) {
357
- console.log(getMessage(`${styleText('green', '✓')} Hook ${styleText('dim', commandWithArgs)} completed${durationStr}`))
358
- } else {
359
- const reason = error?.message ? ` (${error.message})` : ''
360
- console.log(`::error::Hook ${commandWithArgs} failed${durationStr}${reason}`)
361
- }
362
-
363
- if (state.currentConfigs.length === 1) {
364
- closeGroup(`Hook ${commandWithArgs}`)
365
- }
366
- })
367
-
368
- context.on('kubb:lifecycle:end', () => {
369
- reset()
370
- })
371
-
372
- return (_commandWithArgs: string, _hookId: string) => ({
373
- onStdout: logLevel > logLevelMap.silent ? (s: string) => console.log(s) : undefined,
374
- onStderr: logLevel > logLevelMap.silent ? (s: string) => console.error(`::error::${s}`) : undefined,
375
- })
376
- },
377
- })