@kubb/cli 4.12.5 → 4.12.7
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/{generate-DKUIRxiL.js → generate--x91ECr5.js} +137 -71
- package/dist/generate--x91ECr5.js.map +1 -0
- package/dist/{generate-BGEmIdHW.cjs → generate-7e5eF2O-.cjs} +136 -70
- package/dist/generate-7e5eF2O-.cjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +5 -5
- package/dist/{mcp-LLlOFV3c.js → mcp-B5FWDVjp.js} +3 -3
- package/dist/mcp-B5FWDVjp.js.map +1 -0
- package/dist/{mcp-N1IVyiXf.cjs → mcp-D7d_8Bma.cjs} +3 -3
- package/dist/mcp-D7d_8Bma.cjs.map +1 -0
- package/dist/{package-ChTBCRJt.cjs → package-CrqsFX0R.cjs} +2 -2
- package/dist/package-CrqsFX0R.cjs.map +1 -0
- package/dist/package-V7YSB1bN.js +6 -0
- package/dist/package-V7YSB1bN.js.map +1 -0
- package/dist/{validate-BptoQ-63.js → validate-Bt922JN-.js} +3 -3
- package/dist/validate-Bt922JN-.js.map +1 -0
- package/dist/{validate-Dn6hZ7Z4.cjs → validate-D9LPzg3-.cjs} +3 -3
- package/dist/validate-D9LPzg3-.cjs.map +1 -0
- package/package.json +4 -4
- package/src/commands/generate.ts +2 -2
- package/src/commands/mcp.ts +3 -5
- package/src/commands/validate.ts +3 -5
- package/src/loggers/clackLogger.ts +85 -25
- package/src/loggers/githubActionsLogger.ts +94 -20
- package/src/loggers/plainLogger.ts +4 -3
- package/src/runners/generate.ts +10 -10
- package/src/utils/Writables.ts +0 -8
- package/src/utils/getCosmiConfig.ts +2 -2
- package/src/utils/getSummary.ts +3 -3
- package/dist/generate-BGEmIdHW.cjs.map +0 -1
- package/dist/generate-DKUIRxiL.js.map +0 -1
- package/dist/mcp-LLlOFV3c.js.map +0 -1
- package/dist/mcp-N1IVyiXf.cjs.map +0 -1
- package/dist/package-BqxUFXm-.js +0 -6
- package/dist/package-BqxUFXm-.js.map +0 -1
- package/dist/package-ChTBCRJt.cjs.map +0 -1
- package/dist/validate-BptoQ-63.js.map +0 -1
- package/dist/validate-Dn6hZ7Z4.cjs.map +0 -1
- package/src/utils/parseHrtimeToSeconds.ts +0 -4
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { relative } from 'node:path'
|
|
2
|
+
import process from 'node:process'
|
|
2
3
|
import * as clack from '@clack/prompts'
|
|
3
4
|
import { defineLogger, LogLevel } from '@kubb/core'
|
|
5
|
+
import { formatHrtime, formatMs } from '@kubb/core/utils'
|
|
4
6
|
import { execa } from 'execa'
|
|
5
7
|
import { default as gradientString } from 'gradient-string'
|
|
6
8
|
import pc from 'picocolors'
|
|
7
|
-
|
|
8
9
|
import { getSummary } from '../utils/getSummary.ts'
|
|
9
10
|
import { ClackWritable } from '../utils/Writables.ts'
|
|
10
11
|
|
|
@@ -16,9 +17,43 @@ export const clackLogger = defineLogger({
|
|
|
16
17
|
name: 'clack',
|
|
17
18
|
install(context, options) {
|
|
18
19
|
const logLevel = options?.logLevel || LogLevel.info
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const state = {
|
|
21
|
+
totalPlugins: 0,
|
|
22
|
+
completedPlugins: 0,
|
|
23
|
+
failedPlugins: 0,
|
|
24
|
+
totalFiles: 0,
|
|
25
|
+
processedFiles: 0,
|
|
26
|
+
hrStart: process.hrtime(),
|
|
27
|
+
spinner: clack.spinner(),
|
|
28
|
+
isSpinning: false,
|
|
29
|
+
activeProgress: new Map<string, { interval?: NodeJS.Timeout; progressBar: clack.ProgressResult }>(),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function showProgressStep() {
|
|
33
|
+
if (logLevel <= LogLevel.silent) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const parts: string[] = []
|
|
38
|
+
const duration = formatHrtime(state.hrStart)
|
|
39
|
+
|
|
40
|
+
if (state.totalPlugins > 0) {
|
|
41
|
+
const pluginStr =
|
|
42
|
+
state.failedPlugins > 0
|
|
43
|
+
? `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins} ${pc.red(`(${state.failedPlugins} failed)`)}`
|
|
44
|
+
: `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins}`
|
|
45
|
+
parts.push(pluginStr)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (state.totalFiles > 0) {
|
|
49
|
+
parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (parts.length > 0) {
|
|
53
|
+
parts.push(pc.green(duration))
|
|
54
|
+
clack.log.step(parts.join(pc.dim(' | ')))
|
|
55
|
+
}
|
|
56
|
+
}
|
|
22
57
|
|
|
23
58
|
function getMessage(message: string): string {
|
|
24
59
|
if (logLevel >= LogLevel.verbose) {
|
|
@@ -36,13 +71,13 @@ export const clackLogger = defineLogger({
|
|
|
36
71
|
}
|
|
37
72
|
|
|
38
73
|
function startSpinner(text?: string) {
|
|
39
|
-
spinner.start(text)
|
|
40
|
-
isSpinning = true
|
|
74
|
+
state.spinner.start(text)
|
|
75
|
+
state.isSpinning = true
|
|
41
76
|
}
|
|
42
77
|
|
|
43
78
|
function stopSpinner(text?: string) {
|
|
44
|
-
spinner.stop(text)
|
|
45
|
-
isSpinning = false
|
|
79
|
+
state.spinner.stop(text)
|
|
80
|
+
state.isSpinning = false
|
|
46
81
|
}
|
|
47
82
|
|
|
48
83
|
context.on('info', (message, info = '') => {
|
|
@@ -52,8 +87,8 @@ export const clackLogger = defineLogger({
|
|
|
52
87
|
|
|
53
88
|
const text = getMessage([pc.blue('ℹ'), message, pc.dim(info)].join(' '))
|
|
54
89
|
|
|
55
|
-
if (isSpinning) {
|
|
56
|
-
spinner.message(text)
|
|
90
|
+
if (state.isSpinning) {
|
|
91
|
+
state.spinner.message(text)
|
|
57
92
|
} else {
|
|
58
93
|
clack.log.info(text)
|
|
59
94
|
}
|
|
@@ -66,7 +101,7 @@ export const clackLogger = defineLogger({
|
|
|
66
101
|
|
|
67
102
|
const text = getMessage([pc.blue('✓'), message, logLevel >= LogLevel.info ? pc.dim(info) : undefined].filter(Boolean).join(' '))
|
|
68
103
|
|
|
69
|
-
if (isSpinning) {
|
|
104
|
+
if (state.isSpinning) {
|
|
70
105
|
stopSpinner(text)
|
|
71
106
|
} else {
|
|
72
107
|
clack.log.success(text)
|
|
@@ -88,7 +123,7 @@ export const clackLogger = defineLogger({
|
|
|
88
123
|
|
|
89
124
|
const text = [pc.red('✗'), error.message].join(' ')
|
|
90
125
|
|
|
91
|
-
if (isSpinning) {
|
|
126
|
+
if (state.isSpinning) {
|
|
92
127
|
stopSpinner(getMessage(text))
|
|
93
128
|
} else {
|
|
94
129
|
clack.log.error(getMessage(text))
|
|
@@ -147,7 +182,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
147
182
|
startSpinner(getMessage('Configuration loading'))
|
|
148
183
|
})
|
|
149
184
|
|
|
150
|
-
context.on('config:end', () => {
|
|
185
|
+
context.on('config:end', (_configs) => {
|
|
151
186
|
if (logLevel <= LogLevel.silent) {
|
|
152
187
|
return
|
|
153
188
|
}
|
|
@@ -158,6 +193,12 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
158
193
|
})
|
|
159
194
|
|
|
160
195
|
context.on('generation:start', (config) => {
|
|
196
|
+
// Initialize progress tracking
|
|
197
|
+
state.totalPlugins = config.plugins?.length || 0
|
|
198
|
+
state.completedPlugins = 0
|
|
199
|
+
state.failedPlugins = 0
|
|
200
|
+
state.hrStart = process.hrtime()
|
|
201
|
+
|
|
161
202
|
const text = getMessage(['Generation started', config.name ? `for ${pc.dim(config.name)}` : undefined].filter(Boolean).join(' '))
|
|
162
203
|
|
|
163
204
|
clack.intro(text)
|
|
@@ -182,13 +223,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
182
223
|
progressBar.advance()
|
|
183
224
|
}, 50)
|
|
184
225
|
|
|
185
|
-
activeProgress.set(plugin.name, { progressBar, interval })
|
|
226
|
+
state.activeProgress.set(plugin.name, { progressBar, interval })
|
|
186
227
|
})
|
|
187
228
|
|
|
188
|
-
context.on('plugin:end', (plugin, duration) => {
|
|
229
|
+
context.on('plugin:end', (plugin, { duration, success }) => {
|
|
189
230
|
stopSpinner()
|
|
190
231
|
|
|
191
|
-
const active = activeProgress.get(plugin.name)
|
|
232
|
+
const active = state.activeProgress.get(plugin.name)
|
|
192
233
|
|
|
193
234
|
if (!active || logLevel === LogLevel.silent) {
|
|
194
235
|
return
|
|
@@ -196,11 +237,22 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
196
237
|
|
|
197
238
|
clearInterval(active.interval)
|
|
198
239
|
|
|
199
|
-
|
|
200
|
-
|
|
240
|
+
if (success) {
|
|
241
|
+
state.completedPlugins++
|
|
242
|
+
} else {
|
|
243
|
+
state.failedPlugins++
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const durationStr = formatMs(duration)
|
|
247
|
+
const text = getMessage(
|
|
248
|
+
success ? `${pc.bold(plugin.name)} completed in ${pc.green(durationStr)}` : `${pc.bold(plugin.name)} failed in ${pc.red(durationStr)}`,
|
|
249
|
+
)
|
|
201
250
|
|
|
202
251
|
active.progressBar.stop(text)
|
|
203
|
-
activeProgress.delete(plugin.name)
|
|
252
|
+
state.activeProgress.delete(plugin.name)
|
|
253
|
+
|
|
254
|
+
// Show progress step after each plugin
|
|
255
|
+
showProgressStep()
|
|
204
256
|
})
|
|
205
257
|
|
|
206
258
|
context.on('files:processing:start', (files) => {
|
|
@@ -210,6 +262,9 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
210
262
|
|
|
211
263
|
stopSpinner()
|
|
212
264
|
|
|
265
|
+
state.totalFiles = files.length
|
|
266
|
+
state.processedFiles = 0
|
|
267
|
+
|
|
213
268
|
const text = `Writing ${files.length} files`
|
|
214
269
|
const progressBar = clack.progress({
|
|
215
270
|
style: 'block',
|
|
@@ -219,7 +274,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
219
274
|
|
|
220
275
|
context.emit('info', text)
|
|
221
276
|
progressBar.start(getMessage(text))
|
|
222
|
-
activeProgress.set('files', { progressBar })
|
|
277
|
+
state.activeProgress.set('files', { progressBar })
|
|
223
278
|
})
|
|
224
279
|
|
|
225
280
|
context.on('file:processing:update', ({ file, config }) => {
|
|
@@ -229,8 +284,10 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
229
284
|
|
|
230
285
|
stopSpinner()
|
|
231
286
|
|
|
287
|
+
state.processedFiles++
|
|
288
|
+
|
|
232
289
|
const text = `Writing ${relative(config.root, file.path)}`
|
|
233
|
-
const active = activeProgress.get('files')
|
|
290
|
+
const active = state.activeProgress.get('files')
|
|
234
291
|
|
|
235
292
|
if (!active) {
|
|
236
293
|
return
|
|
@@ -246,14 +303,17 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
246
303
|
stopSpinner()
|
|
247
304
|
|
|
248
305
|
const text = getMessage('Files written successfully')
|
|
249
|
-
const active = activeProgress.get('files')
|
|
306
|
+
const active = state.activeProgress.get('files')
|
|
250
307
|
|
|
251
308
|
if (!active) {
|
|
252
309
|
return
|
|
253
310
|
}
|
|
254
311
|
|
|
255
312
|
active.progressBar.stop(text)
|
|
256
|
-
activeProgress.delete('files')
|
|
313
|
+
state.activeProgress.delete('files')
|
|
314
|
+
|
|
315
|
+
// Show final progress step after files are written
|
|
316
|
+
showProgressStep()
|
|
257
317
|
})
|
|
258
318
|
|
|
259
319
|
context.on('generation:end', (config) => {
|
|
@@ -421,13 +481,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
421
481
|
})
|
|
422
482
|
|
|
423
483
|
context.on('lifecycle:end', () => {
|
|
424
|
-
for (const [_key, active] of activeProgress) {
|
|
484
|
+
for (const [_key, active] of state.activeProgress) {
|
|
425
485
|
if (active.interval) {
|
|
426
486
|
clearInterval(active.interval)
|
|
427
487
|
}
|
|
428
488
|
active.progressBar?.stop()
|
|
429
489
|
}
|
|
430
|
-
activeProgress.clear()
|
|
490
|
+
state.activeProgress.clear()
|
|
431
491
|
})
|
|
432
492
|
},
|
|
433
493
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Config, defineLogger, LogLevel } from '@kubb/core'
|
|
2
|
+
import { formatHrtime, formatMs } from '@kubb/core/utils'
|
|
2
3
|
import { execa } from 'execa'
|
|
3
4
|
import pc from 'picocolors'
|
|
4
5
|
|
|
@@ -10,7 +11,41 @@ export const githubActionsLogger = defineLogger({
|
|
|
10
11
|
name: 'github-actions',
|
|
11
12
|
install(context, options) {
|
|
12
13
|
const logLevel = options?.logLevel || LogLevel.info
|
|
13
|
-
|
|
14
|
+
const state = {
|
|
15
|
+
totalPlugins: 0,
|
|
16
|
+
completedPlugins: 0,
|
|
17
|
+
failedPlugins: 0,
|
|
18
|
+
totalFiles: 0,
|
|
19
|
+
processedFiles: 0,
|
|
20
|
+
hrStart: process.hrtime(),
|
|
21
|
+
currentConfigs: [] as Array<Config>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function showProgressStep() {
|
|
25
|
+
if (logLevel <= LogLevel.silent) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const parts: string[] = []
|
|
30
|
+
const duration = formatHrtime(state.hrStart)
|
|
31
|
+
|
|
32
|
+
if (state.totalPlugins > 0) {
|
|
33
|
+
const pluginStr =
|
|
34
|
+
state.failedPlugins > 0
|
|
35
|
+
? `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins} ${pc.red(`(${state.failedPlugins} failed)`)}`
|
|
36
|
+
: `Plugins ${pc.green(state.completedPlugins.toString())}/${state.totalPlugins}`
|
|
37
|
+
parts.push(pluginStr)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (state.totalFiles > 0) {
|
|
41
|
+
parts.push(`Files ${pc.green(state.processedFiles.toString())}/${state.totalFiles}`)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (parts.length > 0) {
|
|
45
|
+
parts.push(pc.green(duration))
|
|
46
|
+
console.log(parts.join(pc.dim(' | ')))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
14
49
|
|
|
15
50
|
function getMessage(message: string): string {
|
|
16
51
|
if (logLevel >= LogLevel.verbose) {
|
|
@@ -90,7 +125,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
90
125
|
})
|
|
91
126
|
|
|
92
127
|
context.on('config:end', (configs) => {
|
|
93
|
-
currentConfigs = configs
|
|
128
|
+
state.currentConfigs = configs
|
|
94
129
|
|
|
95
130
|
if (logLevel <= LogLevel.silent) {
|
|
96
131
|
return
|
|
@@ -104,13 +139,19 @@ export const githubActionsLogger = defineLogger({
|
|
|
104
139
|
})
|
|
105
140
|
|
|
106
141
|
context.on('generation:start', (config) => {
|
|
142
|
+
// Initialize progress tracking
|
|
143
|
+
state.totalPlugins = config.plugins?.length || 0
|
|
144
|
+
state.completedPlugins = 0
|
|
145
|
+
state.failedPlugins = 0
|
|
146
|
+
state.hrStart = process.hrtime()
|
|
147
|
+
|
|
107
148
|
const text = config.name ? `Generation for ${pc.bold(config.name)}` : 'Generation'
|
|
108
149
|
|
|
109
|
-
if (currentConfigs.length > 1) {
|
|
150
|
+
if (state.currentConfigs.length > 1) {
|
|
110
151
|
openGroup(text)
|
|
111
152
|
}
|
|
112
153
|
|
|
113
|
-
if (currentConfigs.length === 1) {
|
|
154
|
+
if (state.currentConfigs.length === 1) {
|
|
114
155
|
console.log(getMessage(text))
|
|
115
156
|
}
|
|
116
157
|
})
|
|
@@ -121,35 +162,51 @@ export const githubActionsLogger = defineLogger({
|
|
|
121
162
|
}
|
|
122
163
|
const text = getMessage(`Generating ${pc.bold(plugin.name)}`)
|
|
123
164
|
|
|
124
|
-
if (currentConfigs.length === 1) {
|
|
165
|
+
if (state.currentConfigs.length === 1) {
|
|
125
166
|
openGroup(`Plugin: ${plugin.name}`)
|
|
126
167
|
}
|
|
127
168
|
|
|
128
169
|
console.log(text)
|
|
129
170
|
})
|
|
130
171
|
|
|
131
|
-
context.on('plugin:end', (plugin, duration) => {
|
|
172
|
+
context.on('plugin:end', (plugin, { duration, success }) => {
|
|
132
173
|
if (logLevel <= LogLevel.silent) {
|
|
133
174
|
return
|
|
134
175
|
}
|
|
135
|
-
|
|
136
|
-
|
|
176
|
+
|
|
177
|
+
if (success) {
|
|
178
|
+
state.completedPlugins++
|
|
179
|
+
} else {
|
|
180
|
+
state.failedPlugins++
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const durationStr = formatMs(duration)
|
|
184
|
+
const text = getMessage(
|
|
185
|
+
success ? `${pc.bold(plugin.name)} completed in ${pc.green(durationStr)}` : `${pc.bold(plugin.name)} failed in ${pc.red(durationStr)}`,
|
|
186
|
+
)
|
|
137
187
|
|
|
138
188
|
console.log(text)
|
|
139
|
-
if (currentConfigs.length > 1) {
|
|
189
|
+
if (state.currentConfigs.length > 1) {
|
|
140
190
|
console.log(' ')
|
|
141
191
|
}
|
|
142
192
|
|
|
143
|
-
if (currentConfigs.length === 1) {
|
|
193
|
+
if (state.currentConfigs.length === 1) {
|
|
144
194
|
closeGroup(`Plugin: ${plugin.name}`)
|
|
145
195
|
}
|
|
196
|
+
|
|
197
|
+
// Show progress step after each plugin
|
|
198
|
+
showProgressStep()
|
|
146
199
|
})
|
|
147
200
|
|
|
148
201
|
context.on('files:processing:start', (files) => {
|
|
149
202
|
if (logLevel <= LogLevel.silent) {
|
|
150
203
|
return
|
|
151
204
|
}
|
|
152
|
-
|
|
205
|
+
|
|
206
|
+
state.totalFiles = files.length
|
|
207
|
+
state.processedFiles = 0
|
|
208
|
+
|
|
209
|
+
if (state.currentConfigs.length === 1) {
|
|
153
210
|
openGroup('File Generation')
|
|
154
211
|
}
|
|
155
212
|
const text = getMessage(`Writing ${files.length} files`)
|
|
@@ -165,11 +222,28 @@ export const githubActionsLogger = defineLogger({
|
|
|
165
222
|
|
|
166
223
|
console.log(text)
|
|
167
224
|
|
|
168
|
-
if (currentConfigs.length === 1) {
|
|
225
|
+
if (state.currentConfigs.length === 1) {
|
|
169
226
|
closeGroup('File Generation')
|
|
170
227
|
}
|
|
171
228
|
})
|
|
172
229
|
|
|
230
|
+
context.on('file:processing:update', () => {
|
|
231
|
+
if (logLevel <= LogLevel.silent) {
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
state.processedFiles++
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
context.on('files:processing:end', () => {
|
|
239
|
+
if (logLevel <= LogLevel.silent) {
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Show final progress step after files are written
|
|
244
|
+
showProgressStep()
|
|
245
|
+
})
|
|
246
|
+
|
|
173
247
|
context.on('generation:end', (config) => {
|
|
174
248
|
const text = getMessage(config.name ? `${pc.blue('✓')} Generation completed for ${pc.dim(config.name)}` : `${pc.blue('✓')} Generation completed`)
|
|
175
249
|
|
|
@@ -211,7 +285,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
211
285
|
|
|
212
286
|
const text = getMessage('Format started')
|
|
213
287
|
|
|
214
|
-
if (currentConfigs.length === 1) {
|
|
288
|
+
if (state.currentConfigs.length === 1) {
|
|
215
289
|
openGroup('Formatting')
|
|
216
290
|
}
|
|
217
291
|
|
|
@@ -227,7 +301,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
227
301
|
|
|
228
302
|
console.log(text)
|
|
229
303
|
|
|
230
|
-
if (currentConfigs.length === 1) {
|
|
304
|
+
if (state.currentConfigs.length === 1) {
|
|
231
305
|
closeGroup('Formatting')
|
|
232
306
|
}
|
|
233
307
|
})
|
|
@@ -239,7 +313,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
239
313
|
|
|
240
314
|
const text = getMessage('Lint started')
|
|
241
315
|
|
|
242
|
-
if (currentConfigs.length === 1) {
|
|
316
|
+
if (state.currentConfigs.length === 1) {
|
|
243
317
|
openGroup('Linting')
|
|
244
318
|
}
|
|
245
319
|
|
|
@@ -255,7 +329,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
255
329
|
|
|
256
330
|
console.log(text)
|
|
257
331
|
|
|
258
|
-
if (currentConfigs.length === 1) {
|
|
332
|
+
if (state.currentConfigs.length === 1) {
|
|
259
333
|
closeGroup('Linting')
|
|
260
334
|
}
|
|
261
335
|
})
|
|
@@ -267,7 +341,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
267
341
|
|
|
268
342
|
const text = getMessage(`Hook ${pc.dim(command)} started`)
|
|
269
343
|
|
|
270
|
-
if (currentConfigs.length === 1) {
|
|
344
|
+
if (state.currentConfigs.length === 1) {
|
|
271
345
|
openGroup(`Hook ${command}`)
|
|
272
346
|
}
|
|
273
347
|
|
|
@@ -283,7 +357,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
283
357
|
|
|
284
358
|
console.log(text)
|
|
285
359
|
|
|
286
|
-
if (currentConfigs.length === 1) {
|
|
360
|
+
if (state.currentConfigs.length === 1) {
|
|
287
361
|
closeGroup(`Hook ${command}`)
|
|
288
362
|
}
|
|
289
363
|
})
|
|
@@ -292,7 +366,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
292
366
|
const pluginsCount = config.plugins?.length || 0
|
|
293
367
|
const successCount = pluginsCount - failedPlugins.size
|
|
294
368
|
|
|
295
|
-
if (currentConfigs.length > 1) {
|
|
369
|
+
if (state.currentConfigs.length > 1) {
|
|
296
370
|
console.log(' ')
|
|
297
371
|
}
|
|
298
372
|
|
|
@@ -302,7 +376,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
302
376
|
: `Kubb Summary: ${pc.blue('✓')} ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,
|
|
303
377
|
)
|
|
304
378
|
|
|
305
|
-
if (currentConfigs.length > 1) {
|
|
379
|
+
if (state.currentConfigs.length > 1) {
|
|
306
380
|
closeGroup(config.name ? `Generation for ${pc.bold(config.name)}` : 'Generation')
|
|
307
381
|
}
|
|
308
382
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { relative } from 'node:path'
|
|
2
2
|
import { defineLogger, LogLevel } from '@kubb/core'
|
|
3
|
+
import { formatMs } from '@kubb/core/utils'
|
|
3
4
|
import { execa } from 'execa'
|
|
4
5
|
import { getSummary } from '../utils/getSummary.ts'
|
|
5
6
|
|
|
@@ -121,13 +122,13 @@ export const plainLogger = defineLogger({
|
|
|
121
122
|
console.log(text)
|
|
122
123
|
})
|
|
123
124
|
|
|
124
|
-
context.on('plugin:end', (plugin, duration) => {
|
|
125
|
+
context.on('plugin:end', (plugin, { duration, success }) => {
|
|
125
126
|
if (logLevel <= LogLevel.silent) {
|
|
126
127
|
return
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
const durationStr =
|
|
130
|
-
const text = getMessage(`${plugin.name} completed in ${durationStr}`)
|
|
130
|
+
const durationStr = formatMs(duration)
|
|
131
|
+
const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`)
|
|
131
132
|
|
|
132
133
|
console.log(text)
|
|
133
134
|
})
|
package/src/runners/generate.ts
CHANGED
|
@@ -125,8 +125,8 @@ export async function generate({ input, config, events, logLevel }: GenerateProp
|
|
|
125
125
|
)
|
|
126
126
|
},
|
|
127
127
|
)
|
|
128
|
-
} catch (
|
|
129
|
-
await events.emit('error',
|
|
128
|
+
} catch (caughtError) {
|
|
129
|
+
await events.emit('error', caughtError as Error)
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
await events.emit('success', `Formatted with ${config.output.format}`)
|
|
@@ -153,9 +153,9 @@ export async function generate({ input, config, events, logLevel }: GenerateProp
|
|
|
153
153
|
)
|
|
154
154
|
},
|
|
155
155
|
)
|
|
156
|
-
} catch (
|
|
156
|
+
} catch (caughtError) {
|
|
157
157
|
const error = new Error('Biome not found')
|
|
158
|
-
error.cause =
|
|
158
|
+
error.cause = caughtError
|
|
159
159
|
await events.emit('error', error)
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -198,9 +198,9 @@ export async function generate({ input, config, events, logLevel }: GenerateProp
|
|
|
198
198
|
)
|
|
199
199
|
},
|
|
200
200
|
)
|
|
201
|
-
} catch (
|
|
201
|
+
} catch (caughtError) {
|
|
202
202
|
const error = new Error('Eslint not found')
|
|
203
|
-
error.cause =
|
|
203
|
+
error.cause = caughtError
|
|
204
204
|
await events.emit('error', error)
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -226,9 +226,9 @@ export async function generate({ input, config, events, logLevel }: GenerateProp
|
|
|
226
226
|
)
|
|
227
227
|
},
|
|
228
228
|
)
|
|
229
|
-
} catch (
|
|
229
|
+
} catch (caughtError) {
|
|
230
230
|
const error = new Error('Biome not found')
|
|
231
|
-
error.cause =
|
|
231
|
+
error.cause = caughtError
|
|
232
232
|
await events.emit('error', error)
|
|
233
233
|
}
|
|
234
234
|
}
|
|
@@ -254,9 +254,9 @@ export async function generate({ input, config, events, logLevel }: GenerateProp
|
|
|
254
254
|
)
|
|
255
255
|
},
|
|
256
256
|
)
|
|
257
|
-
} catch (
|
|
257
|
+
} catch (caughtError) {
|
|
258
258
|
const error = new Error('Oxlint not found')
|
|
259
|
-
error.cause =
|
|
259
|
+
error.cause = caughtError
|
|
260
260
|
await events.emit('error', error)
|
|
261
261
|
}
|
|
262
262
|
}
|
package/src/utils/Writables.ts
CHANGED
|
@@ -15,11 +15,3 @@ export class ClackWritable extends Writable {
|
|
|
15
15
|
callback()
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
export class StdoutWritable extends Writable {
|
|
20
|
-
_write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
|
21
|
-
process.stdout.write(`${pc.dim(chunk?.toString())}`)
|
|
22
|
-
|
|
23
|
-
callback()
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -59,8 +59,8 @@ export async function getCosmiConfig(moduleName: string, config?: string): Promi
|
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
61
|
result = config ? ((await explorer.load(config)) as CosmiconfigResult) : ((await explorer.search()) as CosmiconfigResult)
|
|
62
|
-
} catch (
|
|
63
|
-
throw new Error('Config failed loading', { cause:
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new Error('Config failed loading', { cause: error })
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (result?.isEmpty || !result || !result.config) {
|
package/src/utils/getSummary.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import type { Config, Plugin } from '@kubb/core'
|
|
3
|
+
import { formatHrtime } from '@kubb/core/utils'
|
|
3
4
|
import pc from 'picocolors'
|
|
4
|
-
import { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'
|
|
5
5
|
import { randomCliColour } from './randomColour.ts'
|
|
6
6
|
|
|
7
7
|
type SummaryProps = {
|
|
@@ -14,7 +14,7 @@ type SummaryProps = {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }: SummaryProps): string[] {
|
|
17
|
-
const
|
|
17
|
+
const duration = formatHrtime(hrStart)
|
|
18
18
|
|
|
19
19
|
const pluginsCount = config.plugins?.length || 0
|
|
20
20
|
const successCount = pluginsCount - failedPlugins.size
|
|
@@ -26,7 +26,7 @@ export function getSummary({ failedPlugins, filesCreated, status, hrStart, confi
|
|
|
26
26
|
: `${pc.green(`${successCount} successful`)}, ${pc.red(`${failedPlugins.size} failed`)}, ${pluginsCount} total`,
|
|
27
27
|
pluginsFailed: status === 'failed' ? [...failedPlugins]?.map(({ plugin }) => randomCliColour(plugin.name))?.join(', ') : undefined,
|
|
28
28
|
filesCreated: filesCreated,
|
|
29
|
-
time:
|
|
29
|
+
time: pc.green(duration),
|
|
30
30
|
output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,
|
|
31
31
|
} as const
|
|
32
32
|
|