@kubb/cli 5.0.0-beta.29 → 5.0.0-beta.30
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/{agent-C5Fwtkwy.js → agent-CPKt8QQU.js} +2 -2
- package/dist/{agent-C5Fwtkwy.js.map → agent-CPKt8QQU.js.map} +1 -1
- package/dist/{agent-BBnJ3z1X.cjs → agent-lxTI4Krn.cjs} +2 -2
- package/dist/{agent-BBnJ3z1X.cjs.map → agent-lxTI4Krn.cjs.map} +1 -1
- package/dist/{generate-DoOmhbH4.cjs → generate-DgTJz23F.cjs} +2 -2
- package/dist/{generate-DoOmhbH4.cjs.map → generate-DgTJz23F.cjs.map} +1 -1
- package/dist/{generate-Ga3rWDun.js → generate-qCPyPiD6.js} +2 -2
- package/dist/{generate-Ga3rWDun.js.map → generate-qCPyPiD6.js.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +6 -6
- package/dist/{init-zA8dUkIL.cjs → init-CM61rK5A.cjs} +2 -2
- package/dist/{init-zA8dUkIL.cjs.map → init-CM61rK5A.cjs.map} +1 -1
- package/dist/{init-DBl4w2eq.js → init-_-CN-ASE.js} +2 -2
- package/dist/{init-DBl4w2eq.js.map → init-_-CN-ASE.js.map} +1 -1
- package/dist/{mcp-Dy2q0IpZ.js → mcp-1ld_vD4n.js} +2 -2
- package/dist/{mcp-Dy2q0IpZ.js.map → mcp-1ld_vD4n.js.map} +1 -1
- package/dist/{mcp-vcwhUjDa.cjs → mcp-IMkVgOtF.cjs} +2 -2
- package/dist/{mcp-vcwhUjDa.cjs.map → mcp-IMkVgOtF.cjs.map} +1 -1
- package/dist/package-BDL80yHv.js +6 -0
- package/dist/package-BDL80yHv.js.map +1 -0
- package/dist/{package-DlcR7TDy.cjs → package-CHmy7tzG.cjs} +2 -2
- package/dist/package-CHmy7tzG.cjs.map +1 -0
- package/dist/{run-Cmub7x_z.js → run-BonExv0-.js} +111 -125
- package/dist/run-BonExv0-.js.map +1 -0
- package/dist/{run-BGQSMjOH.cjs → run-e1Pda1tW.cjs} +111 -125
- package/dist/run-e1Pda1tW.cjs.map +1 -0
- package/dist/{validate-DVs01Mu6.js → validate-26X6uBG3.js} +2 -2
- package/dist/{validate-DVs01Mu6.js.map → validate-26X6uBG3.js.map} +1 -1
- package/dist/{validate-B8z4X5Cc.cjs → validate-BAEo4Dcd.cjs} +2 -2
- package/dist/{validate-B8z4X5Cc.cjs.map → validate-BAEo4Dcd.cjs.map} +1 -1
- package/package.json +6 -6
- package/src/loggers/clackLogger.ts +18 -42
- package/src/loggers/githubActionsLogger.ts +51 -106
- package/src/loggers/plainLogger.ts +25 -83
- package/src/loggers/utils.ts +76 -1
- package/dist/package-DlcR7TDy.cjs.map +0 -1
- package/dist/package-DmWpQ3SY.js +0 -6
- package/dist/package-DmWpQ3SY.js.map +0 -1
- package/dist/run-BGQSMjOH.cjs.map +0 -1
- package/dist/run-Cmub7x_z.js.map +0 -1
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import process from 'node:process'
|
|
2
1
|
import { styleText } from 'node:util'
|
|
3
|
-
import { formatHrtime, formatMs, formatMsWithColor,
|
|
4
|
-
import { type Config, defineLogger, logLevel as logLevelMap } from '@kubb/core'
|
|
5
|
-
import {
|
|
2
|
+
import { formatHrtime, formatMs, formatMsWithColor, toCause } from '@internals/utils'
|
|
3
|
+
import { type Config, defineLogger, 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'
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* GitHub Actions logger using group annotations for collapsible sections in CI.
|
|
@@ -12,27 +19,17 @@ export const githubActionsLogger = defineLogger({
|
|
|
12
19
|
install(context, options) {
|
|
13
20
|
const logLevel = options?.logLevel ?? logLevelMap.info
|
|
14
21
|
const state = {
|
|
15
|
-
|
|
16
|
-
completedPlugins: 0,
|
|
17
|
-
failedPlugins: 0,
|
|
18
|
-
totalFiles: 0,
|
|
19
|
-
processedFiles: 0,
|
|
20
|
-
hrStart: process.hrtime(),
|
|
22
|
+
...createProgressCounters(),
|
|
21
23
|
currentConfigs: [] as Array<Config>,
|
|
22
|
-
hookStarts: new Map<string, [number, number]>(),
|
|
23
24
|
openGroupDepth: 0,
|
|
24
25
|
}
|
|
26
|
+
const hookTimer = createHookTimer()
|
|
25
27
|
|
|
26
28
|
function reset() {
|
|
27
29
|
closeAllGroups()
|
|
28
|
-
state
|
|
29
|
-
state.completedPlugins = 0
|
|
30
|
-
state.failedPlugins = 0
|
|
31
|
-
state.totalFiles = 0
|
|
32
|
-
state.processedFiles = 0
|
|
33
|
-
state.hrStart = process.hrtime()
|
|
30
|
+
resetProgressCounters(state)
|
|
34
31
|
state.currentConfigs = []
|
|
35
|
-
|
|
32
|
+
hookTimer.clear()
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
function showProgressStep() {
|
|
@@ -67,6 +64,32 @@ export const githubActionsLogger = defineLogger({
|
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
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
|
+
|
|
70
93
|
context.on('kubb:info', ({ message, info = '' }) => {
|
|
71
94
|
if (logLevel <= logLevelMap.silent) {
|
|
72
95
|
return
|
|
@@ -198,11 +221,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
198
221
|
return
|
|
199
222
|
}
|
|
200
223
|
|
|
201
|
-
|
|
202
|
-
state.completedPlugins++
|
|
203
|
-
} else {
|
|
204
|
-
state.failedPlugins++
|
|
205
|
-
}
|
|
224
|
+
recordPluginResult(state, success)
|
|
206
225
|
|
|
207
226
|
const durationStr = formatMsWithColor(duration)
|
|
208
227
|
const text = getMessage(
|
|
@@ -272,85 +291,12 @@ export const githubActionsLogger = defineLogger({
|
|
|
272
291
|
console.log(text)
|
|
273
292
|
})
|
|
274
293
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (state.currentConfigs.length === 1) {
|
|
283
|
-
openGroup('Formatting')
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
console.log(text)
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
context.on('kubb:format:end', () => {
|
|
290
|
-
if (logLevel <= logLevelMap.silent) {
|
|
291
|
-
return
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const text = getMessage('Format completed')
|
|
295
|
-
|
|
296
|
-
console.log(text)
|
|
297
|
-
|
|
298
|
-
if (state.currentConfigs.length === 1) {
|
|
299
|
-
closeGroup('Formatting')
|
|
300
|
-
}
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
context.on('kubb:lint:start', () => {
|
|
304
|
-
if (logLevel <= logLevelMap.silent) {
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const text = getMessage('Lint started')
|
|
309
|
-
|
|
310
|
-
if (state.currentConfigs.length === 1) {
|
|
311
|
-
openGroup('Linting')
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
console.log(text)
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
context.on('kubb:lint:end', () => {
|
|
318
|
-
if (logLevel <= logLevelMap.silent) {
|
|
319
|
-
return
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const text = getMessage('Lint completed')
|
|
323
|
-
|
|
324
|
-
console.log(text)
|
|
325
|
-
|
|
326
|
-
if (state.currentConfigs.length === 1) {
|
|
327
|
-
closeGroup('Linting')
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
context.on('kubb:hooks:start', () => {
|
|
332
|
-
if (logLevel <= logLevelMap.silent) {
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (state.currentConfigs.length === 1) {
|
|
337
|
-
openGroup('Hooks')
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
console.log(getMessage('Hooks started'))
|
|
341
|
-
})
|
|
342
|
-
|
|
343
|
-
context.on('kubb:hooks:end', () => {
|
|
344
|
-
if (logLevel <= logLevelMap.silent) {
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
console.log(getMessage('Hooks completed'))
|
|
349
|
-
|
|
350
|
-
if (state.currentConfigs.length === 1) {
|
|
351
|
-
closeGroup('Hooks')
|
|
352
|
-
}
|
|
353
|
-
})
|
|
294
|
+
onGroupStart('kubb:format:start', 'Format started', 'Formatting')
|
|
295
|
+
onGroupEnd('kubb:format:end', 'Format completed', 'Formatting')
|
|
296
|
+
onGroupStart('kubb:lint:start', 'Lint started', 'Linting')
|
|
297
|
+
onGroupEnd('kubb:lint:end', 'Lint completed', 'Linting')
|
|
298
|
+
onGroupStart('kubb:hooks:start', 'Hooks started', 'Hooks')
|
|
299
|
+
onGroupEnd('kubb:hooks:end', 'Hooks completed', 'Hooks')
|
|
354
300
|
|
|
355
301
|
context.on('kubb:hook:start', ({ id, command, args }) => {
|
|
356
302
|
if (logLevel <= logLevelMap.silent) {
|
|
@@ -358,7 +304,7 @@ export const githubActionsLogger = defineLogger({
|
|
|
358
304
|
}
|
|
359
305
|
|
|
360
306
|
if (id) {
|
|
361
|
-
|
|
307
|
+
hookTimer.start(id)
|
|
362
308
|
}
|
|
363
309
|
|
|
364
310
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
@@ -375,9 +321,8 @@ export const githubActionsLogger = defineLogger({
|
|
|
375
321
|
return
|
|
376
322
|
}
|
|
377
323
|
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
const durationStr = hrStart ? ` in ${formatMsWithColor(getElapsedMs(hrStart))}` : ''
|
|
324
|
+
const ms = id ? hookTimer.end(id) : undefined
|
|
325
|
+
const durationStr = ms !== undefined ? ` in ${formatMsWithColor(ms)}` : ''
|
|
381
326
|
|
|
382
327
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
383
328
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { relative } from 'node:path'
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { defineLogger, logLevel as logLevelMap } from '@kubb/core'
|
|
2
|
+
import { formatMs, toCause } from '@internals/utils'
|
|
3
|
+
import { defineLogger, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'
|
|
5
4
|
import { SUMMARY_SEPARATOR } from '../constants.ts'
|
|
6
5
|
import { getSummary } from './utils.ts'
|
|
7
|
-
import { formatCommandWithArgs, formatMessage } from './utils.ts'
|
|
6
|
+
import { createHookTimer, formatCommandWithArgs, formatMessage } from './utils.ts'
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Plain console adapter for non-TTY environments with simple `console.log` output.
|
|
@@ -13,12 +12,22 @@ export const plainLogger = defineLogger({
|
|
|
13
12
|
name: 'plain',
|
|
14
13
|
install(context, options) {
|
|
15
14
|
const logLevel = options?.logLevel ?? logLevelMap.info
|
|
16
|
-
const
|
|
15
|
+
const hookTimer = createHookTimer()
|
|
17
16
|
|
|
18
17
|
function getMessage(message: string): string {
|
|
19
18
|
return formatMessage(message, logLevel)
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
// Registers a handler that logs a fixed message, skipped at silent level.
|
|
22
|
+
function onStep<E extends keyof KubbHooks>(event: E, message: string): void {
|
|
23
|
+
context.on(event, () => {
|
|
24
|
+
if (logLevel <= logLevelMap.silent) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
console.log(getMessage(message))
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
context.on('kubb:info', ({ message, info }) => {
|
|
23
32
|
if (logLevel <= logLevelMap.silent) {
|
|
24
33
|
return
|
|
@@ -86,25 +95,8 @@ export const plainLogger = defineLogger({
|
|
|
86
95
|
console.log(getMessage(`Update available: v${currentVersion} → v${latestVersion}. Run \`npm install -g @kubb/cli\` to update.`))
|
|
87
96
|
})
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const text = getMessage('Configuration started')
|
|
95
|
-
|
|
96
|
-
console.log(text)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
context.on('kubb:config:end', () => {
|
|
100
|
-
if (logLevel <= logLevelMap.silent) {
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const text = getMessage('Configuration completed')
|
|
105
|
-
|
|
106
|
-
console.log(text)
|
|
107
|
-
})
|
|
98
|
+
onStep('kubb:config:start', 'Configuration started')
|
|
99
|
+
onStep('kubb:config:end', 'Configuration completed')
|
|
108
100
|
|
|
109
101
|
context.on('kubb:generation:start', () => {
|
|
110
102
|
const text = getMessage('Generation started')
|
|
@@ -168,61 +160,12 @@ export const plainLogger = defineLogger({
|
|
|
168
160
|
console.log(text)
|
|
169
161
|
})
|
|
170
162
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
console.log(text)
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
context.on('kubb:format:end', () => {
|
|
182
|
-
if (logLevel <= logLevelMap.silent) {
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const text = getMessage('Format completed')
|
|
187
|
-
|
|
188
|
-
console.log(text)
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
context.on('kubb:lint:start', () => {
|
|
192
|
-
if (logLevel <= logLevelMap.silent) {
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const text = getMessage('Lint started')
|
|
197
|
-
|
|
198
|
-
console.log(text)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
context.on('kubb:lint:end', () => {
|
|
202
|
-
if (logLevel <= logLevelMap.silent) {
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const text = getMessage('Lint completed')
|
|
207
|
-
|
|
208
|
-
console.log(text)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
context.on('kubb:hooks:start', () => {
|
|
212
|
-
if (logLevel <= logLevelMap.silent) {
|
|
213
|
-
return
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
console.log(getMessage('Hooks started'))
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
context.on('kubb:hooks:end', () => {
|
|
220
|
-
if (logLevel <= logLevelMap.silent) {
|
|
221
|
-
return
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
console.log(getMessage('Hooks completed'))
|
|
225
|
-
})
|
|
163
|
+
onStep('kubb:format:start', 'Format started')
|
|
164
|
+
onStep('kubb:format:end', 'Format completed')
|
|
165
|
+
onStep('kubb:lint:start', 'Lint started')
|
|
166
|
+
onStep('kubb:lint:end', 'Lint completed')
|
|
167
|
+
onStep('kubb:hooks:start', 'Hooks started')
|
|
168
|
+
onStep('kubb:hooks:end', 'Hooks completed')
|
|
226
169
|
|
|
227
170
|
context.on('kubb:hook:start', ({ id, command, args }) => {
|
|
228
171
|
if (logLevel <= logLevelMap.silent) {
|
|
@@ -230,7 +173,7 @@ export const plainLogger = defineLogger({
|
|
|
230
173
|
}
|
|
231
174
|
|
|
232
175
|
if (id) {
|
|
233
|
-
|
|
176
|
+
hookTimer.start(id)
|
|
234
177
|
}
|
|
235
178
|
|
|
236
179
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
@@ -242,9 +185,8 @@ export const plainLogger = defineLogger({
|
|
|
242
185
|
return
|
|
243
186
|
}
|
|
244
187
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
const durationStr = hrStart ? ` in ${formatMs(getElapsedMs(hrStart))}` : ''
|
|
188
|
+
const ms = id ? hookTimer.end(id) : undefined
|
|
189
|
+
const durationStr = ms !== undefined ? ` in ${formatMs(ms)}` : ''
|
|
248
190
|
|
|
249
191
|
const commandWithArgs = formatCommandWithArgs(command, args)
|
|
250
192
|
|
package/src/loggers/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
+
import process from 'node:process'
|
|
2
3
|
import { styleText } from 'node:util'
|
|
3
|
-
import { canUseTTY, formatHrtime, isGitHubActions, randomCliColor } from '@internals/utils'
|
|
4
|
+
import { canUseTTY, formatHrtime, getElapsedMs, isGitHubActions, randomCliColor } from '@internals/utils'
|
|
4
5
|
import type { Config, Logger, LoggerContext, LoggerOptions, Plugin } from '@kubb/core'
|
|
5
6
|
import { logLevel as logLevelMap } from '@kubb/core'
|
|
6
7
|
import { SUMMARY_MAX_BAR_LENGTH, SUMMARY_TIME_SCALE_DIVISOR } from '../constants.ts'
|
|
@@ -127,6 +128,80 @@ export function buildProgressLine(state: ProgressState): string | null {
|
|
|
127
128
|
return parts.join(styleText('dim', ' | '))
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Creates the per-run progress counters shared by the clack and GitHub Actions loggers.
|
|
133
|
+
*/
|
|
134
|
+
export function createProgressCounters(): ProgressState {
|
|
135
|
+
return {
|
|
136
|
+
totalPlugins: 0,
|
|
137
|
+
completedPlugins: 0,
|
|
138
|
+
failedPlugins: 0,
|
|
139
|
+
totalFiles: 0,
|
|
140
|
+
processedFiles: 0,
|
|
141
|
+
hrStart: process.hrtime(),
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Resets the progress counters in place at the start/end of a generation run.
|
|
147
|
+
*/
|
|
148
|
+
export function resetProgressCounters(state: ProgressState): void {
|
|
149
|
+
state.totalPlugins = 0
|
|
150
|
+
state.completedPlugins = 0
|
|
151
|
+
state.failedPlugins = 0
|
|
152
|
+
state.totalFiles = 0
|
|
153
|
+
state.processedFiles = 0
|
|
154
|
+
state.hrStart = process.hrtime()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Records a finished plugin against the progress counters.
|
|
159
|
+
*/
|
|
160
|
+
export function recordPluginResult(state: ProgressState, success: boolean): void {
|
|
161
|
+
if (success) {
|
|
162
|
+
state.completedPlugins++
|
|
163
|
+
} else {
|
|
164
|
+
state.failedPlugins++
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Tracks per-hook start times so a logger can report a hook's elapsed duration.
|
|
170
|
+
* Used by the loggers that key timing by hook `id` (GitHub Actions, plain).
|
|
171
|
+
*/
|
|
172
|
+
export type HookTimer = {
|
|
173
|
+
start(id: string): void
|
|
174
|
+
/**
|
|
175
|
+
* Returns the elapsed milliseconds since `start(id)`, or `undefined` when no start was recorded.
|
|
176
|
+
*/
|
|
177
|
+
end(id: string): number | undefined
|
|
178
|
+
clear(): void
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Creates a {@link HookTimer} backed by a private `id → hrtime` map.
|
|
183
|
+
*/
|
|
184
|
+
export function createHookTimer(): HookTimer {
|
|
185
|
+
const starts = new Map<string, [number, number]>()
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
start(id: string): void {
|
|
189
|
+
starts.set(id, process.hrtime())
|
|
190
|
+
},
|
|
191
|
+
end(id: string): number | undefined {
|
|
192
|
+
const hrStart = starts.get(id)
|
|
193
|
+
if (!hrStart) {
|
|
194
|
+
return undefined
|
|
195
|
+
}
|
|
196
|
+
starts.delete(id)
|
|
197
|
+
return getElapsedMs(hrStart)
|
|
198
|
+
},
|
|
199
|
+
clear(): void {
|
|
200
|
+
starts.clear()
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
130
205
|
/**
|
|
131
206
|
* Join a command and its optional args into a single display string.
|
|
132
207
|
* e.g. ("prettier", ["--write", "."]) → "prettier --write ."
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-DlcR7TDy.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
package/dist/package-DmWpQ3SY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-DmWpQ3SY.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|