@kubb/cli 5.0.0-alpha.52 → 5.0.0-alpha.53

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 (43) hide show
  1. package/dist/{agent-CyXvl4j6.cjs → agent-BGS_7MP9.cjs} +2 -2
  2. package/dist/{agent-CyXvl4j6.cjs.map → agent-BGS_7MP9.cjs.map} +1 -1
  3. package/dist/{agent-D_DzTqSx.js → agent-Dw0KlUTC.js} +2 -2
  4. package/dist/{agent-D_DzTqSx.js.map → agent-Dw0KlUTC.js.map} +1 -1
  5. package/dist/{generate-BEWAGgDc.cjs → generate-BxzJaEso.cjs} +111 -80
  6. package/dist/generate-BxzJaEso.cjs.map +1 -0
  7. package/dist/{generate-C5ZuMK47.js → generate-Cn3YNt91.js} +111 -80
  8. package/dist/generate-Cn3YNt91.js.map +1 -0
  9. package/dist/{generate-Cr4SXhUE.js → generate-DQWnQVDD.js} +2 -2
  10. package/dist/{generate-Cr4SXhUE.js.map → generate-DQWnQVDD.js.map} +1 -1
  11. package/dist/{generate-XfgAmKJO.cjs → generate-NingTsUs.cjs} +2 -2
  12. package/dist/{generate-XfgAmKJO.cjs.map → generate-NingTsUs.cjs.map} +1 -1
  13. package/dist/index.cjs +6 -6
  14. package/dist/index.js +6 -6
  15. package/dist/{init-Cfgb3-m1.cjs → init-CHW9Rmto.cjs} +2 -2
  16. package/dist/{init-Cfgb3-m1.cjs.map → init-CHW9Rmto.cjs.map} +1 -1
  17. package/dist/{init-DntPjNaL.js → init-CTXpwqzv.js} +2 -2
  18. package/dist/{init-DntPjNaL.js.map → init-CTXpwqzv.js.map} +1 -1
  19. package/dist/{mcp-DfElIp1N.cjs → mcp-BXZYLBex.cjs} +2 -2
  20. package/dist/{mcp-DfElIp1N.cjs.map → mcp-BXZYLBex.cjs.map} +1 -1
  21. package/dist/{mcp-xQpXtS4T.js → mcp-DTdbpugQ.js} +2 -2
  22. package/dist/{mcp-xQpXtS4T.js.map → mcp-DTdbpugQ.js.map} +1 -1
  23. package/dist/{package-TAugqkSc.cjs → package-QtWhMWf6.cjs} +2 -2
  24. package/dist/package-QtWhMWf6.cjs.map +1 -0
  25. package/dist/package-dBI-ufat.js +6 -0
  26. package/dist/package-dBI-ufat.js.map +1 -0
  27. package/dist/{validate-Q5FM7up3.js → validate-BwS40gTp.js} +2 -2
  28. package/dist/{validate-Q5FM7up3.js.map → validate-BwS40gTp.js.map} +1 -1
  29. package/dist/{validate-C6cbSTUd.cjs → validate-D0QmlH_5.cjs} +2 -2
  30. package/dist/{validate-C6cbSTUd.cjs.map → validate-D0QmlH_5.cjs.map} +1 -1
  31. package/package.json +5 -5
  32. package/src/loggers/clackLogger.ts +16 -16
  33. package/src/loggers/fileSystemLogger.ts +9 -9
  34. package/src/loggers/githubActionsLogger.ts +12 -12
  35. package/src/loggers/plainLogger.ts +9 -9
  36. package/src/runners/generate.ts +28 -27
  37. package/src/utils/executeHooks.ts +6 -6
  38. package/src/utils/runHook.ts +2 -2
  39. package/dist/generate-BEWAGgDc.cjs.map +0 -1
  40. package/dist/generate-C5ZuMK47.js.map +0 -1
  41. package/dist/package-D5-gtCQz.js +0 -6
  42. package/dist/package-D5-gtCQz.js.map +0 -1
  43. package/dist/package-TAugqkSc.cjs.map +0 -1
@@ -73,7 +73,7 @@ export const clackLogger = defineLogger({
73
73
  state.isSpinning = false
74
74
  }
75
75
 
76
- context.on('kubb:info', (message, info = '') => {
76
+ context.on('kubb:info', ({ message, info = '' }) => {
77
77
  if (logLevel <= logLevelMap.silent) {
78
78
  return
79
79
  }
@@ -87,7 +87,7 @@ export const clackLogger = defineLogger({
87
87
  }
88
88
  })
89
89
 
90
- context.on('kubb:success', (message, info = '') => {
90
+ context.on('kubb:success', ({ message, info = '' }) => {
91
91
  if (logLevel <= logLevelMap.silent) {
92
92
  return
93
93
  }
@@ -101,7 +101,7 @@ export const clackLogger = defineLogger({
101
101
  }
102
102
  })
103
103
 
104
- context.on('kubb:warn', (message, info) => {
104
+ context.on('kubb:warn', ({ message, info }) => {
105
105
  if (logLevel < logLevelMap.warn) {
106
106
  return
107
107
  }
@@ -113,7 +113,7 @@ export const clackLogger = defineLogger({
113
113
  clack.log.warn(text)
114
114
  })
115
115
 
116
- context.on('kubb:error', (error) => {
116
+ context.on('kubb:error', ({ error }) => {
117
117
  const caused = toCause(error)
118
118
 
119
119
  const text = [styleText('red', '✗'), error.message].join(' ')
@@ -142,14 +142,14 @@ export const clackLogger = defineLogger({
142
142
  }
143
143
  })
144
144
 
145
- context.on('kubb:version:new', (version, latestVersion) => {
145
+ context.on('kubb:version:new', ({ currentVersion, latestVersion }) => {
146
146
  if (logLevel <= logLevelMap.silent) {
147
147
  return
148
148
  }
149
149
 
150
150
  try {
151
151
  clack.box(
152
- `\`v${version}\` → \`v${latestVersion}\`
152
+ `\`v${currentVersion}\` → \`v${latestVersion}\`
153
153
  Run \`npm install -g @kubb/cli\` to update`,
154
154
  'Update available for `Kubb`',
155
155
  {
@@ -162,12 +162,12 @@ Run \`npm install -g @kubb/cli\` to update`,
162
162
  },
163
163
  )
164
164
  } catch {
165
- console.log(`Update available for Kubb: v${version} → v${latestVersion}`)
165
+ console.log(`Update available for Kubb: v${currentVersion} → v${latestVersion}`)
166
166
  console.log('Run `npm install -g @kubb/cli` to update')
167
167
  }
168
168
  })
169
169
 
170
- context.on('kubb:lifecycle:start', async (version) => {
170
+ context.on('kubb:lifecycle:start', async ({ version }) => {
171
171
  console.log(`\n${getIntro({ title: 'The ultimate toolkit for working with APIs', description: 'Ready to start', version, areEyesOpen: true })}\n`)
172
172
 
173
173
  reset()
@@ -184,7 +184,7 @@ Run \`npm install -g @kubb/cli\` to update`,
184
184
  startSpinner(getMessage('Configuration loading'))
185
185
  })
186
186
 
187
- context.on('kubb:config:end', (_configs) => {
187
+ context.on('kubb:config:end', () => {
188
188
  if (logLevel <= logLevelMap.silent) {
189
189
  return
190
190
  }
@@ -194,7 +194,7 @@ Run \`npm install -g @kubb/cli\` to update`,
194
194
  clack.outro(text)
195
195
  })
196
196
 
197
- context.on('kubb:generation:start', (config) => {
197
+ context.on('kubb:generation:start', ({ config }) => {
198
198
  reset()
199
199
 
200
200
  // Initialize progress tracking for this generation
@@ -205,7 +205,7 @@ Run \`npm install -g @kubb/cli\` to update`,
205
205
  clack.intro(text)
206
206
  })
207
207
 
208
- context.on('kubb:plugin:start', (plugin) => {
208
+ context.on('kubb:plugin:start', ({ plugin }) => {
209
209
  if (logLevel <= logLevelMap.silent) {
210
210
  return
211
211
  }
@@ -227,7 +227,7 @@ Run \`npm install -g @kubb/cli\` to update`,
227
227
  state.activeProgress.set(plugin.name, { progressBar, interval })
228
228
  })
229
229
 
230
- context.on('kubb:plugin:end', (plugin, { duration, success }) => {
230
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
231
231
  stopSpinner()
232
232
 
233
233
  const active = state.activeProgress.get(plugin.name)
@@ -258,7 +258,7 @@ Run \`npm install -g @kubb/cli\` to update`,
258
258
  showProgressStep()
259
259
  })
260
260
 
261
- context.on('kubb:files:processing:start', (files) => {
261
+ context.on('kubb:files:processing:start', ({ files }) => {
262
262
  if (logLevel <= logLevelMap.silent) {
263
263
  return
264
264
  }
@@ -275,7 +275,7 @@ Run \`npm install -g @kubb/cli\` to update`,
275
275
  size: 30,
276
276
  })
277
277
 
278
- context.emit('kubb:info', text)
278
+ context.emit('kubb:info', { message: text })
279
279
  progressBar.start(getMessage(text))
280
280
  state.activeProgress.set('files', { progressBar })
281
281
  })
@@ -319,7 +319,7 @@ Run \`npm install -g @kubb/cli\` to update`,
319
319
  showProgressStep()
320
320
  })
321
321
 
322
- context.on('kubb:generation:end', (config) => {
322
+ context.on('kubb:generation:end', ({ config }) => {
323
323
  const text = getMessage(config.name ? `Generation completed for ${styleText('dim', config.name)}` : 'Generation completed')
324
324
 
325
325
  clack.outro(text)
@@ -423,7 +423,7 @@ Run \`npm install -g @kubb/cli\` to update`,
423
423
  clack.outro(text)
424
424
  })
425
425
 
426
- context.on('kubb:generation:summary', (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
426
+ context.on('kubb:generation:summary', ({ config, pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
427
427
  const summary = getSummary({
428
428
  failedPlugins,
429
429
  filesCreated,
@@ -57,28 +57,28 @@ export const fileSystemLogger = defineLogger({
57
57
  return Object.keys(files)
58
58
  }
59
59
 
60
- context.on('kubb:info', (message, info) => {
60
+ context.on('kubb:info', ({ message, info }) => {
61
61
  state.cachedLogs.add({
62
62
  date: new Date(),
63
63
  logs: [`ℹ ${message} ${info}`],
64
64
  })
65
65
  })
66
66
 
67
- context.on('kubb:success', (message, info) => {
67
+ context.on('kubb:success', ({ message, info }) => {
68
68
  state.cachedLogs.add({
69
69
  date: new Date(),
70
70
  logs: [`✓ ${message} ${info}`],
71
71
  })
72
72
  })
73
73
 
74
- context.on('kubb:warn', (message, info) => {
74
+ context.on('kubb:warn', ({ message, info }) => {
75
75
  state.cachedLogs.add({
76
76
  date: new Date(),
77
77
  logs: [`⚠ ${message} ${info}`],
78
78
  })
79
79
  })
80
80
 
81
- context.on('kubb:error', (error) => {
81
+ context.on('kubb:error', ({ error }) => {
82
82
  state.cachedLogs.add({
83
83
  date: new Date(),
84
84
  logs: [`✗ ${error.message}`, error.stack || 'unknown stack'],
@@ -92,14 +92,14 @@ export const fileSystemLogger = defineLogger({
92
92
  })
93
93
  })
94
94
 
95
- context.on('kubb:plugin:start', (plugin) => {
95
+ context.on('kubb:plugin:start', ({ plugin }) => {
96
96
  state.cachedLogs.add({
97
97
  date: new Date(),
98
98
  logs: [`Generating ${plugin.name}`],
99
99
  })
100
100
  })
101
101
 
102
- context.on('kubb:plugin:end', (plugin, { duration, success }) => {
102
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
103
103
  const durationStr = formatMs(duration)
104
104
 
105
105
  state.cachedLogs.add({
@@ -108,18 +108,18 @@ export const fileSystemLogger = defineLogger({
108
108
  })
109
109
  })
110
110
 
111
- context.on('kubb:files:processing:start', (files) => {
111
+ context.on('kubb:files:processing:start', ({ files }) => {
112
112
  state.cachedLogs.add({
113
113
  date: new Date(),
114
114
  logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)],
115
115
  })
116
116
  })
117
117
 
118
- context.on('kubb:generation:end', async (config) => {
118
+ context.on('kubb:generation:end', async ({ config }) => {
119
119
  const writtenFilePaths = await writeLogs(config.name)
120
120
  if (writtenFilePaths.length > 0) {
121
121
  const files = writtenFilePaths.map((f) => relative(process.cwd(), f))
122
- await context.emit('kubb:info', 'Debug files written to:', files.join(', '))
122
+ await context.emit('kubb:info', { message: 'Debug files written to:', info: files.join(', ') })
123
123
  }
124
124
  reset()
125
125
  })
@@ -55,7 +55,7 @@ export const githubActionsLogger = defineLogger({
55
55
  console.log('::endgroup::')
56
56
  }
57
57
 
58
- context.on('kubb:info', (message, info = '') => {
58
+ context.on('kubb:info', ({ message, info = '' }) => {
59
59
  if (logLevel <= logLevelMap.silent) {
60
60
  return
61
61
  }
@@ -65,7 +65,7 @@ export const githubActionsLogger = defineLogger({
65
65
  console.log(text)
66
66
  })
67
67
 
68
- context.on('kubb:success', (message, info = '') => {
68
+ context.on('kubb:success', ({ message, info = '' }) => {
69
69
  if (logLevel <= logLevelMap.silent) {
70
70
  return
71
71
  }
@@ -75,7 +75,7 @@ export const githubActionsLogger = defineLogger({
75
75
  console.log(text)
76
76
  })
77
77
 
78
- context.on('kubb:warn', (message, info = '') => {
78
+ context.on('kubb:warn', ({ message, info = '' }) => {
79
79
  if (logLevel <= logLevelMap.silent) {
80
80
  return
81
81
  }
@@ -85,7 +85,7 @@ export const githubActionsLogger = defineLogger({
85
85
  console.warn(`::warning::${text}`)
86
86
  })
87
87
 
88
- context.on('kubb:error', (error) => {
88
+ context.on('kubb:error', ({ error }) => {
89
89
  const caused = toCause(error)
90
90
 
91
91
  if (logLevel <= logLevelMap.silent) {
@@ -112,7 +112,7 @@ export const githubActionsLogger = defineLogger({
112
112
  }
113
113
  })
114
114
 
115
- context.on('kubb:lifecycle:start', (version) => {
115
+ context.on('kubb:lifecycle:start', ({ version }) => {
116
116
  console.log(styleText('yellow', `Kubb ${version} 🧩`))
117
117
  reset()
118
118
  })
@@ -129,7 +129,7 @@ export const githubActionsLogger = defineLogger({
129
129
  console.log(text)
130
130
  })
131
131
 
132
- context.on('kubb:config:end', (configs) => {
132
+ context.on('kubb:config:end', ({ configs }) => {
133
133
  state.currentConfigs = configs
134
134
 
135
135
  if (logLevel <= logLevelMap.silent) {
@@ -143,7 +143,7 @@ export const githubActionsLogger = defineLogger({
143
143
  closeGroup('Configuration')
144
144
  })
145
145
 
146
- context.on('kubb:generation:start', (config) => {
146
+ context.on('kubb:generation:start', ({ config }) => {
147
147
  reset()
148
148
 
149
149
  // Initialize progress tracking for this generation
@@ -160,7 +160,7 @@ export const githubActionsLogger = defineLogger({
160
160
  }
161
161
  })
162
162
 
163
- context.on('kubb:plugin:start', (plugin) => {
163
+ context.on('kubb:plugin:start', ({ plugin }) => {
164
164
  if (logLevel <= logLevelMap.silent) {
165
165
  return
166
166
  }
@@ -173,7 +173,7 @@ export const githubActionsLogger = defineLogger({
173
173
  console.log(text)
174
174
  })
175
175
 
176
- context.on('kubb:plugin:end', (plugin, { duration, success }) => {
176
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
177
177
  if (logLevel <= logLevelMap.silent) {
178
178
  return
179
179
  }
@@ -204,7 +204,7 @@ export const githubActionsLogger = defineLogger({
204
204
  showProgressStep()
205
205
  })
206
206
 
207
- context.on('kubb:files:processing:start', (files) => {
207
+ context.on('kubb:files:processing:start', ({ files }) => {
208
208
  if (logLevel <= logLevelMap.silent) {
209
209
  return
210
210
  }
@@ -244,7 +244,7 @@ export const githubActionsLogger = defineLogger({
244
244
  state.processedFiles++
245
245
  })
246
246
 
247
- context.on('kubb:generation:end', (config) => {
247
+ context.on('kubb:generation:end', ({ config }) => {
248
248
  const text = getMessage(
249
249
  config.name ? `${styleText('blue', '✓')} Generation completed for ${styleText('dim', config.name)}` : `${styleText('blue', '✓')} Generation completed`,
250
250
  )
@@ -353,7 +353,7 @@ export const githubActionsLogger = defineLogger({
353
353
  }
354
354
  })
355
355
 
356
- context.on('kubb:generation:summary', (config, { status, hrStart, failedPlugins }) => {
356
+ context.on('kubb:generation:summary', ({ config, status, hrStart, failedPlugins }) => {
357
357
  const pluginsCount = config.plugins?.length ?? 0
358
358
  const successCount = pluginsCount - failedPlugins.size
359
359
  const duration = formatHrtime(hrStart)
@@ -19,7 +19,7 @@ export const plainLogger = defineLogger({
19
19
  return formatMessage(message, logLevel)
20
20
  }
21
21
 
22
- context.on('kubb:info', (message, info) => {
22
+ context.on('kubb:info', ({ message, info }) => {
23
23
  if (logLevel <= logLevelMap.silent) {
24
24
  return
25
25
  }
@@ -29,7 +29,7 @@ export const plainLogger = defineLogger({
29
29
  console.log(text)
30
30
  })
31
31
 
32
- context.on('kubb:success', (message, info = '') => {
32
+ context.on('kubb:success', ({ message, info = '' }) => {
33
33
  if (logLevel <= logLevelMap.silent) {
34
34
  return
35
35
  }
@@ -39,7 +39,7 @@ export const plainLogger = defineLogger({
39
39
  console.log(text)
40
40
  })
41
41
 
42
- context.on('kubb:warn', (message, info) => {
42
+ context.on('kubb:warn', ({ message, info }) => {
43
43
  if (logLevel < logLevelMap.warn) {
44
44
  return
45
45
  }
@@ -49,7 +49,7 @@ export const plainLogger = defineLogger({
49
49
  console.log(text)
50
50
  })
51
51
 
52
- context.on('kubb:error', (error) => {
52
+ context.on('kubb:error', ({ error }) => {
53
53
  const caused = toCause(error)
54
54
 
55
55
  const text = getMessage(['✗', error.message].join(' '))
@@ -104,7 +104,7 @@ export const plainLogger = defineLogger({
104
104
  console.log(text)
105
105
  })
106
106
 
107
- context.on('kubb:plugin:start', (plugin) => {
107
+ context.on('kubb:plugin:start', ({ plugin }) => {
108
108
  if (logLevel <= logLevelMap.silent) {
109
109
  return
110
110
  }
@@ -113,7 +113,7 @@ export const plainLogger = defineLogger({
113
113
  console.log(text)
114
114
  })
115
115
 
116
- context.on('kubb:plugin:end', (plugin, { duration, success }) => {
116
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
117
117
  if (logLevel <= logLevelMap.silent) {
118
118
  return
119
119
  }
@@ -124,7 +124,7 @@ export const plainLogger = defineLogger({
124
124
  console.log(text)
125
125
  })
126
126
 
127
- context.on('kubb:files:processing:start', (files) => {
127
+ context.on('kubb:files:processing:start', ({ files }) => {
128
128
  if (logLevel <= logLevelMap.silent) {
129
129
  return
130
130
  }
@@ -154,7 +154,7 @@ export const plainLogger = defineLogger({
154
154
  console.log(text)
155
155
  })
156
156
 
157
- context.on('kubb:generation:end', (config) => {
157
+ context.on('kubb:generation:end', ({ config }) => {
158
158
  const text = getMessage(config.name ? `Generation completed for ${config.name}` : 'Generation completed')
159
159
 
160
160
  console.log(text)
@@ -237,7 +237,7 @@ export const plainLogger = defineLogger({
237
237
  console.log(text)
238
238
  })
239
239
 
240
- context.on('kubb:generation:summary', (config, { pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
240
+ context.on('kubb:generation:summary', ({ config, pluginTimings, status, hrStart, failedPlugins, filesCreated }) => {
241
241
  const summary = getSummary({
242
242
  failedPlugins,
243
243
  filesCreated,
@@ -61,10 +61,10 @@ async function runToolPass({
61
61
  if (resolvedTool === 'auto') {
62
62
  const detected = await detect()
63
63
  if (!detected) {
64
- await hooks.emit('kubb:warn', noToolMessage)
64
+ await hooks.emit('kubb:warn', { message: noToolMessage })
65
65
  } else {
66
66
  resolvedTool = detected
67
- await hooks.emit('kubb:info', `Auto-detected ${toolLabel}: ${styleText('dim', resolvedTool)}`)
67
+ await hooks.emit('kubb:info', { message: `Auto-detected ${toolLabel}: ${styleText('dim', resolvedTool)}` })
68
68
  }
69
69
  }
70
70
 
@@ -79,24 +79,23 @@ async function runToolPass({
79
79
  // Wire up the hook:end listener BEFORE emitting hook:start to avoid the race condition
80
80
  // where hook:end fires synchronously inside emit('kubb:hook:start') before the listener is registered.
81
81
  const hookEndPromise = new Promise<void>((resolve, reject) => {
82
- const handler = ({ id, success, error }: { id?: string; command: string; args?: readonly string[]; success: boolean; error: Error | null }) => {
83
- if (id !== hookId) return
82
+ const handler = (ctx: { id?: string; command: string; args?: readonly string[]; success: boolean; error: Error | null }) => {
83
+ if (ctx.id !== hookId) return
84
84
  hooks.off('kubb:hook:end', handler)
85
- if (!success) {
86
- reject(error ?? new Error(`${toolConfig.errorMessage}`))
85
+ if (!ctx.success) {
86
+ reject(ctx.error ?? new Error(`${toolConfig.errorMessage}`))
87
87
  return
88
88
  }
89
89
  hooks
90
- .emit(
91
- 'kubb:success',
92
- [
90
+ .emit('kubb:success', {
91
+ message: [
93
92
  `${successPrefix} with ${styleText('dim', resolvedTool)}`,
94
93
  logLevel >= logLevelMap.info ? `on ${styleText('dim', outputPath)}` : undefined,
95
94
  'successfully',
96
95
  ]
97
96
  .filter(Boolean)
98
97
  .join(' '),
99
- )
98
+ })
100
99
  .then(resolve)
101
100
  .catch(reject)
102
101
  }
@@ -116,7 +115,7 @@ async function runToolPass({
116
115
  // runHook already emitted kubb:error for binary-not-found cases; here we surface the
117
116
  // real reason (e.g. "Hook execute failed: oxlint --fix …") for non-zero exits.
118
117
  const err = toError(caughtError)
119
- await hooks.emit('kubb:error', err)
118
+ await hooks.emit('kubb:error', { error: err })
120
119
  toolError = err
121
120
  }
122
121
  }
@@ -148,15 +147,15 @@ async function generate(options: GenerateProps): Promise<void> {
148
147
  const kubb = createKubb(config, { hooks })
149
148
  await kubb.setup()
150
149
 
151
- await hooks.emit('kubb:generation:start', config)
150
+ await hooks.emit('kubb:generation:start', { config })
152
151
 
153
- await hooks.emit('kubb:info', config.name ? `Setup generation ${styleText('bold', config.name)}` : 'Setup generation', inputPath)
152
+ await hooks.emit('kubb:info', { message: config.name ? `Setup generation ${styleText('bold', config.name)}` : 'Setup generation', info: inputPath })
154
153
 
155
- await hooks.emit('kubb:info', config.name ? `Build generation ${styleText('bold', config.name)}` : 'Build generation', inputPath)
154
+ await hooks.emit('kubb:info', { message: config.name ? `Build generation ${styleText('bold', config.name)}` : 'Build generation', info: inputPath })
156
155
 
157
156
  const { files, failedPlugins, pluginTimings, error, driver } = await kubb.safeBuild()
158
157
 
159
- await hooks.emit('kubb:info', 'Load summary')
158
+ await hooks.emit('kubb:info', { message: 'Load summary' })
160
159
 
161
160
  // Handle build failures (either from failed plugins or general errors)
162
161
 
@@ -171,12 +170,13 @@ async function generate(options: GenerateProps): Promise<void> {
171
170
  ].filter(Boolean)
172
171
 
173
172
  for (const err of allErrors) {
174
- await hooks.emit('kubb:error', err)
173
+ await hooks.emit('kubb:error', { error: err })
175
174
  }
176
175
 
177
- await hooks.emit('kubb:generation:end', config, files, kubb.sources)
176
+ await hooks.emit('kubb:generation:end', { config, files, sources: kubb.sources })
178
177
 
179
- await hooks.emit('kubb:generation:summary', config, {
178
+ await hooks.emit('kubb:generation:summary', {
179
+ config,
180
180
  failedPlugins,
181
181
  filesCreated: files.length,
182
182
  status: 'failed',
@@ -201,8 +201,8 @@ async function generate(options: GenerateProps): Promise<void> {
201
201
  process.exit(1)
202
202
  }
203
203
 
204
- await hooks.emit('kubb:success', 'Generation successfully', inputPath)
205
- await hooks.emit('kubb:generation:end', config, files, kubb.sources)
204
+ await hooks.emit('kubb:success', { message: 'Generation successfully', info: inputPath })
205
+ await hooks.emit('kubb:generation:end', { config, files, sources: kubb.sources })
206
206
 
207
207
  const outputPath = path.resolve(config.root, config.output.path)
208
208
 
@@ -248,7 +248,8 @@ async function generate(options: GenerateProps): Promise<void> {
248
248
  }
249
249
 
250
250
  // Only reached when there are no failures (process.exit(1) is called above otherwise)
251
- await hooks.emit('kubb:generation:summary', config, {
251
+ await hooks.emit('kubb:generation:summary', {
252
+ config,
252
253
  failedPlugins,
253
254
  filesCreated: files.length,
254
255
  status: 'success',
@@ -291,7 +292,7 @@ export async function runGenerateCommand({ input, configPath, logLevel: logLevel
291
292
  const latestVersion = data.version
292
293
 
293
294
  if (latestVersion && version < latestVersion) {
294
- await hooks.emit('kubb:version:new', version, latestVersion)
295
+ await hooks.emit('kubb:version:new', { currentVersion: version, latestVersion })
295
296
  }
296
297
  } catch {
297
298
  // Ignore network errors for version check
@@ -303,11 +304,11 @@ export async function runGenerateCommand({ input, configPath, logLevel: logLevel
303
304
  const configs = await getConfigs(result.config, { input } as CLIOptions)
304
305
 
305
306
  await hooks.emit('kubb:config:start')
306
- await hooks.emit('kubb:info', 'Config loaded', path.relative(process.cwd(), result.filepath))
307
- await hooks.emit('kubb:success', 'Config loaded successfully', path.relative(process.cwd(), result.filepath))
308
- await hooks.emit('kubb:config:end', configs)
307
+ await hooks.emit('kubb:info', { message: 'Config loaded', info: path.relative(process.cwd(), result.filepath) })
308
+ await hooks.emit('kubb:success', { message: 'Config loaded successfully', info: path.relative(process.cwd(), result.filepath) })
309
+ await hooks.emit('kubb:config:end', { configs })
309
310
 
310
- await hooks.emit('kubb:lifecycle:start', version)
311
+ await hooks.emit('kubb:lifecycle:start', { version })
311
312
 
312
313
  for (const config of configs) {
313
314
  if (isInputPath(config) && watch) {
@@ -326,7 +327,7 @@ export async function runGenerateCommand({ input, configPath, logLevel: logLevel
326
327
 
327
328
  await hooks.emit('kubb:lifecycle:end')
328
329
  } catch (error) {
329
- await hooks.emit('kubb:error', toError(error))
330
+ await hooks.emit('kubb:error', { error: toError(error) })
330
331
  process.exit(1)
331
332
  }
332
333
  }
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto'
2
2
  import { styleText } from 'node:util'
3
3
  import type { AsyncEventEmitter } from '@internals/utils'
4
4
  import { tokenize } from '@internals/utils'
5
- import type { Config, KubbHooks } from '@kubb/core'
5
+ import type { Config, KubbHookEndContext, KubbHooks } from '@kubb/core'
6
6
 
7
7
  type ExecutingHooksProps = {
8
8
  configHooks: NonNullable<Config['hooks']>
@@ -24,15 +24,15 @@ export async function executeHooks({ configHooks, hooks }: ExecutingHooksProps):
24
24
  // Wire up the hook:end listener BEFORE emitting hook:start to avoid the race condition
25
25
  // where hook:end fires synchronously inside emit('kubb:hook:start') before the listener is registered.
26
26
  const hookEndPromise = new Promise<void>((resolve, reject) => {
27
- const handler = ({ id, success, error }: { id?: string; command: string; args?: readonly string[]; success: boolean; error: Error | null }) => {
28
- if (id !== hookId) return
27
+ const handler = (ctx: KubbHookEndContext) => {
28
+ if (ctx.id !== hookId) return
29
29
  hooks.off('kubb:hook:end', handler)
30
- if (!success) {
31
- reject(error ?? new Error(`Hook failed: ${command}`))
30
+ if (!ctx.success) {
31
+ reject(ctx.error ?? new Error(`Hook failed: ${command}`))
32
32
  return
33
33
  }
34
34
  hooks
35
- .emit('kubb:success', `${styleText('dim', command)} successfully executed`)
35
+ .emit('kubb:success', { message: `${styleText('dim', command)} successfully executed` })
36
36
  .then(resolve)
37
37
  .catch(reject)
38
38
  }
@@ -64,7 +64,7 @@ export async function runHook({ id, command, args, commandWithArgs, context, str
64
64
  success: false,
65
65
  error: toError(err),
66
66
  })
67
- await context.emit('kubb:error', toError(err))
67
+ await context.emit('kubb:error', { error: toError(err) })
68
68
  return
69
69
  }
70
70
 
@@ -88,6 +88,6 @@ export async function runHook({ id, command, args, commandWithArgs, context, str
88
88
  success: false,
89
89
  error: errorMessage,
90
90
  })
91
- await context.emit('kubb:error', errorMessage)
91
+ await context.emit('kubb:error', { error: errorMessage })
92
92
  }
93
93
  }