@kubb/cli 5.0.0-alpha.7 → 5.0.0-alpha.71

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 (138) hide show
  1. package/README.md +4 -2
  2. package/bin/kubb.js +6 -0
  3. package/dist/agent-CouS-H2S.js +112 -0
  4. package/dist/agent-CouS-H2S.js.map +1 -0
  5. package/dist/{agent-Cc-0-A8t.cjs → agent-D5OIwM0z.cjs} +5 -5
  6. package/dist/agent-D5OIwM0z.cjs.map +1 -0
  7. package/dist/{agent-CjXjyuPe.js → agent-DypvJBwO.js} +5 -5
  8. package/dist/agent-DypvJBwO.js.map +1 -0
  9. package/dist/agent-Zo8CQwxZ.cjs +116 -0
  10. package/dist/agent-Zo8CQwxZ.cjs.map +1 -0
  11. package/dist/{constants-BTUap0zs.cjs → constants-BgLUQ1nx.cjs} +50 -9
  12. package/dist/constants-BgLUQ1nx.cjs.map +1 -0
  13. package/dist/{constants-CM3dJzjK.js → constants-mIdg9ls2.js} +39 -10
  14. package/dist/constants-mIdg9ls2.js.map +1 -0
  15. package/dist/define-Bdn8j5VM.cjs +54 -0
  16. package/dist/define-Bdn8j5VM.cjs.map +1 -0
  17. package/dist/define-Ctii4bel.js +43 -0
  18. package/dist/define-Ctii4bel.js.map +1 -0
  19. package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
  20. package/dist/errors-CLCjoSg0.cjs.map +1 -0
  21. package/dist/errors-CjPmyZHy.js +43 -0
  22. package/dist/errors-CjPmyZHy.js.map +1 -0
  23. package/dist/{generate-BP0WpC20.cjs → generate-BW0J1wvg.cjs} +3 -3
  24. package/dist/generate-BW0J1wvg.cjs.map +1 -0
  25. package/dist/{generate-yOyKmo19.cjs → generate-CLYhWYY1.cjs} +553 -251
  26. package/dist/generate-CLYhWYY1.cjs.map +1 -0
  27. package/dist/{generate-BX6LmxKo.js → generate-Cy11Ra5n.js} +3 -3
  28. package/dist/generate-Cy11Ra5n.js.map +1 -0
  29. package/dist/{generate-BYqhZfbq.js → generate-DfhKa1mG.js} +546 -244
  30. package/dist/generate-DfhKa1mG.js.map +1 -0
  31. package/dist/index.cjs +49 -21
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +49 -21
  35. package/dist/index.js.map +1 -1
  36. package/dist/{init-DkwG4Gbs.cjs → init-C_EgqqO4.cjs} +4 -4
  37. package/dist/init-C_EgqqO4.cjs.map +1 -0
  38. package/dist/{init-BqkRvRTM.js → init-CaQZcAvy.js} +4 -4
  39. package/dist/init-CaQZcAvy.js.map +1 -0
  40. package/dist/{init-hmolV6B4.cjs → init-CmrUd26x.cjs} +31 -21
  41. package/dist/init-CmrUd26x.cjs.map +1 -0
  42. package/dist/{init-C-InrmSY.js → init-DEC1gCsk.js} +27 -17
  43. package/dist/init-DEC1gCsk.js.map +1 -0
  44. package/dist/{mcp-Cqn_PHUg.js → mcp-7rBVhoQz.js} +4 -4
  45. package/dist/{mcp-Cqn_PHUg.js.map → mcp-7rBVhoQz.js.map} +1 -1
  46. package/dist/{mcp-BnEafD5r.cjs → mcp-CmXrXzDF.cjs} +4 -4
  47. package/dist/{mcp-BnEafD5r.cjs.map → mcp-CmXrXzDF.cjs.map} +1 -1
  48. package/dist/{mcp-D2SHEg_d.js → mcp-nlFo36z0.js} +4 -5
  49. package/dist/mcp-nlFo36z0.js.map +1 -0
  50. package/dist/{mcp-ChHFPRzD.cjs → mcp-vi8t2Rkb.cjs} +5 -6
  51. package/dist/mcp-vi8t2Rkb.cjs.map +1 -0
  52. package/dist/package-BD90dOVc.js +6 -0
  53. package/dist/package-BD90dOVc.js.map +1 -0
  54. package/dist/{package-DZb6I8FQ.cjs → package-DsKVMEXO.cjs} +2 -2
  55. package/dist/package-DsKVMEXO.cjs.map +1 -0
  56. package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
  57. package/dist/shell-475fQKaX.cjs.map +1 -0
  58. package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
  59. package/dist/shell-DLzN4fRo.js.map +1 -0
  60. package/dist/{telemetry-DxiR7clS.js → telemetry-CS5ZE0cN.js} +48 -6
  61. package/dist/telemetry-CS5ZE0cN.js.map +1 -0
  62. package/dist/{telemetry-Cn9X1I5B.cjs → telemetry-kmnc5OAT.cjs} +50 -8
  63. package/dist/telemetry-kmnc5OAT.cjs.map +1 -0
  64. package/dist/{validate-l8vLmwKA.js → validate-BR_0eveE.js} +5 -13
  65. package/dist/validate-BR_0eveE.js.map +1 -0
  66. package/dist/{validate-9FoHgtvi.cjs → validate-BZKRjT0Y.cjs} +4 -4
  67. package/dist/validate-BZKRjT0Y.cjs.map +1 -0
  68. package/dist/{validate-Bbrn3Q-A.cjs → validate-Db7vfaU9.cjs} +6 -14
  69. package/dist/validate-Db7vfaU9.cjs.map +1 -0
  70. package/dist/{validate-Bgqwmhir.js → validate-RG85Fqjh.js} +4 -4
  71. package/dist/validate-RG85Fqjh.js.map +1 -0
  72. package/package.json +47 -46
  73. package/src/commands/agent/start.ts +20 -4
  74. package/src/commands/generate.ts +35 -6
  75. package/src/commands/init.ts +6 -1
  76. package/src/commands/validate.ts +6 -1
  77. package/src/constants.ts +40 -11
  78. package/src/index.ts +10 -12
  79. package/src/loggers/clackLogger.ts +54 -46
  80. package/src/loggers/fileSystemLogger.ts +13 -11
  81. package/src/loggers/githubActionsLogger.ts +22 -22
  82. package/src/loggers/plainLogger.ts +21 -21
  83. package/src/runners/agent.ts +81 -34
  84. package/src/runners/generate.ts +90 -100
  85. package/src/runners/init.ts +9 -9
  86. package/src/runners/mcp.ts +17 -4
  87. package/src/runners/validate.ts +19 -15
  88. package/src/types.ts +11 -0
  89. package/src/utils/executeHooks.ts +15 -15
  90. package/src/utils/flags.ts +10 -0
  91. package/src/utils/getConfig.ts +10 -0
  92. package/src/utils/getCosmiConfig.ts +21 -12
  93. package/src/utils/getSummary.ts +1 -1
  94. package/src/utils/runHook.ts +28 -10
  95. package/src/utils/telemetry.ts +16 -3
  96. package/bin/kubb.cjs +0 -18
  97. package/dist/agent-C6o_6GSJ.cjs +0 -92
  98. package/dist/agent-C6o_6GSJ.cjs.map +0 -1
  99. package/dist/agent-Cc-0-A8t.cjs.map +0 -1
  100. package/dist/agent-CjXjyuPe.js.map +0 -1
  101. package/dist/agent-L50VNhXv.js +0 -88
  102. package/dist/agent-L50VNhXv.js.map +0 -1
  103. package/dist/constants-BTUap0zs.cjs.map +0 -1
  104. package/dist/constants-CM3dJzjK.js.map +0 -1
  105. package/dist/define--M_JMcDC.js +0 -25
  106. package/dist/define--M_JMcDC.js.map +0 -1
  107. package/dist/define-D6Kfm7-Z.cjs +0 -36
  108. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  109. package/dist/errors-6mF_WKxg.js +0 -27
  110. package/dist/errors-6mF_WKxg.js.map +0 -1
  111. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  112. package/dist/generate-BP0WpC20.cjs.map +0 -1
  113. package/dist/generate-BX6LmxKo.js.map +0 -1
  114. package/dist/generate-BYqhZfbq.js.map +0 -1
  115. package/dist/generate-yOyKmo19.cjs.map +0 -1
  116. package/dist/init-BqkRvRTM.js.map +0 -1
  117. package/dist/init-C-InrmSY.js.map +0 -1
  118. package/dist/init-DkwG4Gbs.cjs.map +0 -1
  119. package/dist/init-hmolV6B4.cjs.map +0 -1
  120. package/dist/jiti-Cd3S0xwr.cjs +0 -16
  121. package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
  122. package/dist/jiti-e08mD2Ph.js +0 -11
  123. package/dist/jiti-e08mD2Ph.js.map +0 -1
  124. package/dist/mcp-ChHFPRzD.cjs.map +0 -1
  125. package/dist/mcp-D2SHEg_d.js.map +0 -1
  126. package/dist/package-DLd3fZNd.js +0 -6
  127. package/dist/package-DLd3fZNd.js.map +0 -1
  128. package/dist/package-DZb6I8FQ.cjs.map +0 -1
  129. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  130. package/dist/shell-DqqWsHCD.js.map +0 -1
  131. package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
  132. package/dist/telemetry-DxiR7clS.js.map +0 -1
  133. package/dist/validate-9FoHgtvi.cjs.map +0 -1
  134. package/dist/validate-Bbrn3Q-A.cjs.map +0 -1
  135. package/dist/validate-Bgqwmhir.js.map +0 -1
  136. package/dist/validate-l8vLmwKA.js.map +0 -1
  137. package/src/utils/getIntro.ts +0 -1
  138. package/src/utils/jiti.ts +0 -9
@@ -5,7 +5,11 @@ export const command = defineCommand({
5
5
  description: "[input] Generate files based on a 'kubb.config.ts' file",
6
6
  arguments: ['[input]'],
7
7
  options: {
8
- config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },
8
+ config: {
9
+ type: 'string',
10
+ description: 'Path to the Kubb config',
11
+ short: 'c',
12
+ },
9
13
  logLevel: {
10
14
  type: 'string',
11
15
  description: 'Info, silent, verbose or debug',
@@ -14,15 +18,40 @@ export const command = defineCommand({
14
18
  hint: 'silent|info|verbose|debug',
15
19
  enum: ['silent', 'info', 'verbose', 'debug'],
16
20
  },
17
- watch: { type: 'boolean', description: 'Watch mode based on the input file', short: 'w', default: false },
18
- debug: { type: 'boolean', description: 'Override logLevel to debug', short: 'd', default: false },
19
- verbose: { type: 'boolean', description: 'Override logLevel to verbose', short: 'v', default: false },
20
- silent: { type: 'boolean', description: 'Override logLevel to silent', short: 's', default: false },
21
+ watch: {
22
+ type: 'boolean',
23
+ description: 'Watch mode based on the input file',
24
+ short: 'w',
25
+ default: false,
26
+ },
27
+ debug: {
28
+ type: 'boolean',
29
+ description: 'Override logLevel to debug',
30
+ short: 'd',
31
+ default: false,
32
+ },
33
+ verbose: {
34
+ type: 'boolean',
35
+ description: 'Override logLevel to verbose',
36
+ short: 'v',
37
+ default: false,
38
+ },
39
+ silent: {
40
+ type: 'boolean',
41
+ description: 'Override logLevel to silent',
42
+ short: 's',
43
+ default: false,
44
+ },
21
45
  },
22
46
  async run({ values, positionals }) {
23
47
  const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
24
48
  const { runGenerateCommand } = await import('../runners/generate.ts')
25
49
 
26
- await runGenerateCommand({ input: positionals[0], configPath: values.config, logLevel, watch: values.watch })
50
+ await runGenerateCommand({
51
+ input: positionals[0],
52
+ configPath: values.config,
53
+ logLevel,
54
+ watch: values.watch,
55
+ })
27
56
  },
28
57
  })
@@ -5,7 +5,12 @@ export const command = defineCommand({
5
5
  name: 'init',
6
6
  description: 'Initialize a new Kubb project with interactive setup',
7
7
  options: {
8
- yes: { type: 'boolean', description: 'Skip prompts and use default options', short: 'y', default: false },
8
+ yes: {
9
+ type: 'boolean',
10
+ description: 'Skip prompts and use default options',
11
+ short: 'y',
12
+ default: false,
13
+ },
9
14
  },
10
15
  async run({ values }) {
11
16
  const { runInit } = await import('../runners/init.ts')
@@ -5,7 +5,12 @@ export const command = defineCommand({
5
5
  name: 'validate',
6
6
  description: 'Validate a Swagger/OpenAPI file',
7
7
  options: {
8
- input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },
8
+ input: {
9
+ type: 'string',
10
+ description: 'Path to Swagger/OpenAPI file',
11
+ short: 'i',
12
+ required: true,
13
+ },
9
14
  },
10
15
  async run({ values }) {
11
16
  const { runValidate } = await import('../runners/validate.ts')
package/src/constants.ts CHANGED
@@ -1,33 +1,60 @@
1
- /** NPM registry endpoint used to check for @kubb/cli updates. */
1
+ /**
2
+ * Default filename for the Kubb configuration file.
3
+ *
4
+ * Used by the `init` command when scaffolding new projects and by the `agent` default config.
5
+ */
6
+ export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const
7
+
8
+ /**
9
+ * NPM registry endpoint used to check for @kubb/cli updates.
10
+ */
2
11
  export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
3
12
 
4
- /** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */
13
+ /**
14
+ * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
15
+ */
5
16
  export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
6
17
 
7
- /** Horizontal rule rendered above/below the plain-logger generation summary. */
18
+ /**
19
+ * Horizontal rule rendered above/below the plain-logger generation summary.
20
+ */
8
21
  export const SUMMARY_SEPARATOR = '─'.repeat(27)
9
22
 
10
- /** Maximum number of █ characters in a plugin timing bar. */
23
+ /**
24
+ * Maximum number of █ characters in a plugin timing bar.
25
+ */
11
26
  export const SUMMARY_MAX_BAR_LENGTH = 10 as const
12
27
 
13
- /** Divides elapsed milliseconds into bar-length units (1 block per 100 ms). */
28
+ /**
29
+ * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
30
+ */
14
31
  export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
15
32
 
16
- /** Glob pattern for paths the file watcher ignores. */
33
+ /**
34
+ * Glob pattern for paths the file watcher ignores.
35
+ */
17
36
  export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
18
37
 
19
- /** Default runtime values for the `agent start` command. */
38
+ /**
39
+ * Flags that short-circuit execution (help/version) — no telemetry notice is shown.
40
+ */
41
+ export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
42
+
20
43
  export const agentDefaults = {
21
44
  port: '3000',
22
45
  host: 'localhost',
23
- configFile: 'kubb.config.ts',
46
+ configFile: KUBB_CONFIG_FILENAME,
24
47
  retryTimeout: '30000',
25
48
  studioUrl: 'https://studio.kubb.dev',
26
- /** Relative path from the @kubb/agent package root to the server entry. */
49
+ /**
50
+ * Relative path from the @kubb/agent package root to the server entry.
51
+ */
27
52
  serverEntryPath: '.output/server/index.mjs',
28
53
  } as const
29
54
 
30
- /** Default values used during interactive `init` scaffolding. */
55
+ /**
56
+ * Default values used during interactive `init` scaffolding.
57
+ */
31
58
  export const initDefaults = {
32
59
  inputPath: './openapi.yaml',
33
60
  outputPath: './src/gen',
@@ -73,4 +100,6 @@ export const pluginDefaultConfigs = {
73
100
  })`,
74
101
  } as const satisfies Record<string, string>
75
102
 
76
- /** Color palette used by randomCliColor() for deterministic plugin name coloring. */
103
+ /**
104
+ * Color palette used by randomCliColor() for deterministic plugin name coloring.
105
+ */
package/src/index.ts CHANGED
@@ -1,17 +1,18 @@
1
1
  import { styleText } from 'node:util'
2
2
  import { createCLI } from '@internals/utils'
3
3
  import { version } from '../package.json'
4
+ import { QUIET_FLAGS } from './constants.ts'
5
+ import { isFlag } from './utils/flags.ts'
4
6
  import { isTelemetryDisabled } from './utils/telemetry.ts'
5
7
 
6
8
  const cli = createCLI()
7
9
 
8
- function shouldShowTelemetryNotice(argv: string[]): boolean {
10
+ function shouldShowTelemetryNotice(argv: Array<string>): boolean {
9
11
  if (isTelemetryDisabled()) {
10
12
  return false
11
13
  }
12
14
  // Skip when the user is just asking for help or version info
13
- const quietFlags = new Set(['--help', '-h', '--version', '-v'])
14
- if (argv.some((arg) => quietFlags.has(arg))) {
15
+ if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {
15
16
  return false
16
17
  }
17
18
  // Skip in non-interactive / scripting contexts
@@ -21,21 +22,18 @@ function shouldShowTelemetryNotice(argv: string[]): boolean {
21
22
  return true
22
23
  }
23
24
 
24
- export async function run(argv: string[] = process.argv): Promise<void> {
25
+ export async function run(argv: Array<string> = process.argv): Promise<void> {
25
26
  if (shouldShowTelemetryNotice(argv)) {
26
27
  console.log(
27
28
  `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\n`,
28
29
  )
29
30
  }
30
31
 
31
- const [{ command: generateCommand }, { command: validateCommand }, { command: mcpCommand }, { command: agentCommand }, { command: initCommand }] =
32
- await Promise.all([
33
- import('./commands/generate.ts'),
34
- import('./commands/validate.ts'),
35
- import('./commands/mcp.ts'),
36
- import('./commands/agent.ts'),
37
- import('./commands/init.ts'),
38
- ])
32
+ const { command: generateCommand } = await import('./commands/generate.ts')
33
+ const { command: validateCommand } = await import('./commands/validate.ts')
34
+ const { command: mcpCommand } = await import('./commands/mcp.ts')
35
+ const { command: agentCommand } = await import('./commands/agent.ts')
36
+ const { command: initCommand } = await import('./commands/init.ts')
39
37
 
40
38
  await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {
41
39
  programName: 'kubb',
@@ -2,9 +2,8 @@ import { relative } from 'node:path'
2
2
  import process from 'node:process'
3
3
  import { styleText } from 'node:util'
4
4
  import * as clack from '@clack/prompts'
5
- import { formatMs, formatMsWithColor, toCause } from '@internals/utils'
5
+ import { formatMs, formatMsWithColor, getIntro, toCause } from '@internals/utils'
6
6
  import { defineLogger, logLevel as logLevelMap } from '@kubb/core'
7
- import { getIntro } from '../utils/getIntro.ts'
8
7
  import { getSummary } from '../utils/getSummary.ts'
9
8
  import { runHook } from '../utils/runHook.ts'
10
9
  import { ClackWritable } from '../utils/Writables.ts'
@@ -74,7 +73,7 @@ export const clackLogger = defineLogger({
74
73
  state.isSpinning = false
75
74
  }
76
75
 
77
- context.on('info', (message, info = '') => {
76
+ context.on('kubb:info', ({ message, info = '' }) => {
78
77
  if (logLevel <= logLevelMap.silent) {
79
78
  return
80
79
  }
@@ -88,7 +87,7 @@ export const clackLogger = defineLogger({
88
87
  }
89
88
  })
90
89
 
91
- context.on('success', (message, info = '') => {
90
+ context.on('kubb:success', ({ message, info = '' }) => {
92
91
  if (logLevel <= logLevelMap.silent) {
93
92
  return
94
93
  }
@@ -102,7 +101,7 @@ export const clackLogger = defineLogger({
102
101
  }
103
102
  })
104
103
 
105
- context.on('warn', (message, info) => {
104
+ context.on('kubb:warn', ({ message, info }) => {
106
105
  if (logLevel < logLevelMap.warn) {
107
106
  return
108
107
  }
@@ -114,7 +113,7 @@ export const clackLogger = defineLogger({
114
113
  clack.log.warn(text)
115
114
  })
116
115
 
117
- context.on('error', (error) => {
116
+ context.on('kubb:error', ({ error }) => {
118
117
  const caused = toCause(error)
119
118
 
120
119
  const text = [styleText('red', '✗'), error.message].join(' ')
@@ -143,33 +142,38 @@ export const clackLogger = defineLogger({
143
142
  }
144
143
  })
145
144
 
146
- context.on('version:new', (version, latestVersion) => {
145
+ context.on('kubb:version:new', ({ currentVersion, latestVersion }) => {
147
146
  if (logLevel <= logLevelMap.silent) {
148
147
  return
149
148
  }
150
149
 
151
- clack.box(
152
- `\`v${version}\` → \`v${latestVersion}\`
150
+ try {
151
+ clack.box(
152
+ `\`v${currentVersion}\` → \`v${latestVersion}\`
153
153
  Run \`npm install -g @kubb/cli\` to update`,
154
- 'Update available for `Kubb`',
155
- {
156
- width: 'auto',
157
- formatBorder: (s: string) => styleText('yellow', s),
158
- rounded: true,
159
- withGuide: false,
160
- contentAlign: 'center',
161
- titleAlign: 'center',
162
- },
163
- )
154
+ 'Update available for `Kubb`',
155
+ {
156
+ width: 'auto',
157
+ formatBorder: (s: string) => styleText('yellow', s),
158
+ rounded: true,
159
+ withGuide: false,
160
+ contentAlign: 'center',
161
+ titleAlign: 'center',
162
+ },
163
+ )
164
+ } catch {
165
+ console.log(`Update available for Kubb: v${currentVersion} → v${latestVersion}`)
166
+ console.log('Run `npm install -g @kubb/cli` to update')
167
+ }
164
168
  })
165
169
 
166
- context.on('lifecycle:start', async (version) => {
170
+ context.on('kubb:lifecycle:start', async ({ version }) => {
167
171
  console.log(`\n${getIntro({ title: 'The ultimate toolkit for working with APIs', description: 'Ready to start', version, areEyesOpen: true })}\n`)
168
172
 
169
173
  reset()
170
174
  })
171
175
 
172
- context.on('config:start', () => {
176
+ context.on('kubb:config:start', () => {
173
177
  if (logLevel <= logLevelMap.silent) {
174
178
  return
175
179
  }
@@ -180,7 +184,7 @@ Run \`npm install -g @kubb/cli\` to update`,
180
184
  startSpinner(getMessage('Configuration loading'))
181
185
  })
182
186
 
183
- context.on('config:end', (_configs) => {
187
+ context.on('kubb:config:end', () => {
184
188
  if (logLevel <= logLevelMap.silent) {
185
189
  return
186
190
  }
@@ -190,7 +194,7 @@ Run \`npm install -g @kubb/cli\` to update`,
190
194
  clack.outro(text)
191
195
  })
192
196
 
193
- context.on('generation:start', (config) => {
197
+ context.on('kubb:generation:start', ({ config }) => {
194
198
  reset()
195
199
 
196
200
  // Initialize progress tracking for this generation
@@ -201,7 +205,7 @@ Run \`npm install -g @kubb/cli\` to update`,
201
205
  clack.intro(text)
202
206
  })
203
207
 
204
- context.on('plugin:start', (plugin) => {
208
+ context.on('kubb:plugin:start', ({ plugin }) => {
205
209
  if (logLevel <= logLevelMap.silent) {
206
210
  return
207
211
  }
@@ -223,7 +227,7 @@ Run \`npm install -g @kubb/cli\` to update`,
223
227
  state.activeProgress.set(plugin.name, { progressBar, interval })
224
228
  })
225
229
 
226
- context.on('plugin:end', (plugin, { duration, success }) => {
230
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
227
231
  stopSpinner()
228
232
 
229
233
  const active = state.activeProgress.get(plugin.name)
@@ -254,7 +258,7 @@ Run \`npm install -g @kubb/cli\` to update`,
254
258
  showProgressStep()
255
259
  })
256
260
 
257
- context.on('files:processing:start', (files) => {
261
+ context.on('kubb:files:processing:start', ({ files }) => {
258
262
  if (logLevel <= logLevelMap.silent) {
259
263
  return
260
264
  }
@@ -271,12 +275,12 @@ Run \`npm install -g @kubb/cli\` to update`,
271
275
  size: 30,
272
276
  })
273
277
 
274
- context.emit('info', text)
278
+ context.emit('kubb:info', { message: text })
275
279
  progressBar.start(getMessage(text))
276
280
  state.activeProgress.set('files', { progressBar })
277
281
  })
278
282
 
279
- context.on('file:processing:update', ({ file, config }) => {
283
+ context.on('kubb:file:processing:update', ({ file, config }) => {
280
284
  if (logLevel <= logLevelMap.silent) {
281
285
  return
282
286
  }
@@ -294,7 +298,7 @@ Run \`npm install -g @kubb/cli\` to update`,
294
298
 
295
299
  active.progressBar.advance(undefined, text)
296
300
  })
297
- context.on('files:processing:end', () => {
301
+ context.on('kubb:files:processing:end', () => {
298
302
  if (logLevel <= logLevelMap.silent) {
299
303
  return
300
304
  }
@@ -315,13 +319,13 @@ Run \`npm install -g @kubb/cli\` to update`,
315
319
  showProgressStep()
316
320
  })
317
321
 
318
- context.on('generation:end', (config) => {
322
+ context.on('kubb:generation:end', ({ config }) => {
319
323
  const text = getMessage(config.name ? `Generation completed for ${styleText('dim', config.name)}` : 'Generation completed')
320
324
 
321
325
  clack.outro(text)
322
326
  })
323
327
 
324
- context.on('format:start', () => {
328
+ context.on('kubb:format:start', () => {
325
329
  if (logLevel <= logLevelMap.silent) {
326
330
  return
327
331
  }
@@ -331,7 +335,7 @@ Run \`npm install -g @kubb/cli\` to update`,
331
335
  clack.intro(text)
332
336
  })
333
337
 
334
- context.on('format:end', () => {
338
+ context.on('kubb:format:end', () => {
335
339
  if (logLevel <= logLevelMap.silent) {
336
340
  return
337
341
  }
@@ -341,7 +345,7 @@ Run \`npm install -g @kubb/cli\` to update`,
341
345
  clack.outro(text)
342
346
  })
343
347
 
344
- context.on('lint:start', () => {
348
+ context.on('kubb:lint:start', () => {
345
349
  if (logLevel <= logLevelMap.silent) {
346
350
  return
347
351
  }
@@ -351,7 +355,7 @@ Run \`npm install -g @kubb/cli\` to update`,
351
355
  clack.intro(text)
352
356
  })
353
357
 
354
- context.on('lint:end', () => {
358
+ context.on('kubb:lint:end', () => {
355
359
  if (logLevel <= logLevelMap.silent) {
356
360
  return
357
361
  }
@@ -361,7 +365,7 @@ Run \`npm install -g @kubb/cli\` to update`,
361
365
  clack.outro(text)
362
366
  })
363
367
 
364
- context.on('hook:start', async ({ id, command, args }) => {
368
+ context.on('kubb:hook:start', async ({ id, command, args }) => {
365
369
  const commandWithArgs = formatCommandWithArgs(command, args)
366
370
  const text = getMessage(`Hook ${styleText('dim', commandWithArgs)} started`)
367
371
 
@@ -408,7 +412,7 @@ Run \`npm install -g @kubb/cli\` to update`,
408
412
  })
409
413
  })
410
414
 
411
- context.on('hook:end', ({ command, args }) => {
415
+ context.on('kubb:hook:end', ({ command, args }) => {
412
416
  if (logLevel <= logLevelMap.silent) {
413
417
  return
414
418
  }
@@ -419,7 +423,7 @@ Run \`npm install -g @kubb/cli\` to update`,
419
423
  clack.outro(text)
420
424
  })
421
425
 
422
- context.on('generation:summary', (config, { pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
426
+ context.on('kubb:generation:summary', ({ config, pluginTimings, failedPlugins, filesCreated, status, hrStart }) => {
423
427
  const summary = getSummary({
424
428
  failedPlugins,
425
429
  filesCreated,
@@ -434,17 +438,21 @@ Run \`npm install -g @kubb/cli\` to update`,
434
438
  summary.push('\n')
435
439
 
436
440
  const borderColor = status === 'success' ? 'green' : 'red'
437
- clack.box(summary.join('\n'), getMessage(title), {
438
- width: 'auto',
439
- formatBorder: (s: string) => styleText(borderColor, s),
440
- rounded: true,
441
- withGuide: false,
442
- contentAlign: 'left',
443
- titleAlign: 'center',
444
- })
441
+ try {
442
+ clack.box(summary.join('\n'), getMessage(title), {
443
+ width: 'auto',
444
+ formatBorder: (s: string) => styleText(borderColor, s),
445
+ rounded: true,
446
+ withGuide: false,
447
+ contentAlign: 'left',
448
+ titleAlign: 'center',
449
+ })
450
+ } catch {
451
+ console.log(summary.join('\n'))
452
+ }
445
453
  })
446
454
 
447
- context.on('lifecycle:end', () => {
455
+ context.on('kubb:lifecycle:end', () => {
448
456
  reset()
449
457
  })
450
458
  },
@@ -50,54 +50,56 @@ export const fileSystemLogger = defineLogger({
50
50
  }
51
51
  }
52
52
 
53
- await Promise.all(Object.entries(files).map(([fileName, logs]) => write(fileName, logs.join('\n\n'))))
53
+ for (const [fileName, logs] of Object.entries(files)) {
54
+ await write(fileName, logs.join('\n\n'))
55
+ }
54
56
 
55
57
  return Object.keys(files)
56
58
  }
57
59
 
58
- context.on('info', (message, info) => {
60
+ context.on('kubb:info', ({ message, info }) => {
59
61
  state.cachedLogs.add({
60
62
  date: new Date(),
61
63
  logs: [`ℹ ${message} ${info}`],
62
64
  })
63
65
  })
64
66
 
65
- context.on('success', (message, info) => {
67
+ context.on('kubb:success', ({ message, info }) => {
66
68
  state.cachedLogs.add({
67
69
  date: new Date(),
68
70
  logs: [`✓ ${message} ${info}`],
69
71
  })
70
72
  })
71
73
 
72
- context.on('warn', (message, info) => {
74
+ context.on('kubb:warn', ({ message, info }) => {
73
75
  state.cachedLogs.add({
74
76
  date: new Date(),
75
77
  logs: [`⚠ ${message} ${info}`],
76
78
  })
77
79
  })
78
80
 
79
- context.on('error', (error) => {
81
+ context.on('kubb:error', ({ error }) => {
80
82
  state.cachedLogs.add({
81
83
  date: new Date(),
82
84
  logs: [`✗ ${error.message}`, error.stack || 'unknown stack'],
83
85
  })
84
86
  })
85
87
 
86
- context.on('debug', (message) => {
88
+ context.on('kubb:debug', (message) => {
87
89
  state.cachedLogs.add({
88
90
  date: new Date(),
89
91
  logs: message.logs,
90
92
  })
91
93
  })
92
94
 
93
- context.on('plugin:start', (plugin) => {
95
+ context.on('kubb:plugin:start', ({ plugin }) => {
94
96
  state.cachedLogs.add({
95
97
  date: new Date(),
96
98
  logs: [`Generating ${plugin.name}`],
97
99
  })
98
100
  })
99
101
 
100
- context.on('plugin:end', (plugin, { duration, success }) => {
102
+ context.on('kubb:plugin:end', ({ plugin, duration, success }) => {
101
103
  const durationStr = formatMs(duration)
102
104
 
103
105
  state.cachedLogs.add({
@@ -106,18 +108,18 @@ export const fileSystemLogger = defineLogger({
106
108
  })
107
109
  })
108
110
 
109
- context.on('files:processing:start', (files) => {
111
+ context.on('kubb:files:processing:start', ({ files }) => {
110
112
  state.cachedLogs.add({
111
113
  date: new Date(),
112
114
  logs: [`Start ${files.length} writing:`, ...files.map((file) => file.path)],
113
115
  })
114
116
  })
115
117
 
116
- context.on('generation:end', async (config) => {
118
+ context.on('kubb:generation:end', async ({ config }) => {
117
119
  const writtenFilePaths = await writeLogs(config.name)
118
120
  if (writtenFilePaths.length > 0) {
119
121
  const files = writtenFilePaths.map((f) => relative(process.cwd(), f))
120
- await context.emit('info', 'Debug files written to:', files.join(', '))
122
+ await context.emit('kubb:info', { message: 'Debug files written to:', info: files.join(', ') })
121
123
  }
122
124
  reset()
123
125
  })