@kubb/cli 5.0.0-beta.6 → 5.0.0-beta.60

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 (142) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +170 -51
  3. package/dist/Telemetry-CVdyJarO.js +283 -0
  4. package/dist/Telemetry-CVdyJarO.js.map +1 -0
  5. package/dist/Telemetry-DrppRqqW.cjs +320 -0
  6. package/dist/Telemetry-DrppRqqW.cjs.map +1 -0
  7. package/dist/{define-Bdn8j5VM.cjs → define-C4AB3POr.cjs} +2 -2
  8. package/dist/{define-Bdn8j5VM.cjs.map → define-C4AB3POr.cjs.map} +1 -1
  9. package/dist/{define-Ctii4bel.js → define-C63T4jp6.js} +2 -2
  10. package/dist/{define-Ctii4bel.js.map → define-C63T4jp6.js.map} +1 -1
  11. package/dist/{errors-CjPmyZHy.js → errors-BsemQCMn.js} +2 -2
  12. package/dist/{errors-CjPmyZHy.js.map → errors-BsemQCMn.js.map} +1 -1
  13. package/dist/{errors-CLCjoSg0.cjs → errors-DykI11xo.cjs} +2 -2
  14. package/dist/{errors-CLCjoSg0.cjs.map → errors-DykI11xo.cjs.map} +1 -1
  15. package/dist/{generate-BB2Q7I9s.cjs → generate-CMsFCzhp.cjs} +22 -17
  16. package/dist/generate-CMsFCzhp.cjs.map +1 -0
  17. package/dist/{generate-BmulGxIM.js → generate-CNXTYKOV.js} +22 -17
  18. package/dist/generate-CNXTYKOV.js.map +1 -0
  19. package/dist/index.cjs +10 -27
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +10 -27
  23. package/dist/index.js.map +1 -1
  24. package/dist/{init-Dpg8e1HN.cjs → init--vszxTGP.cjs} +6 -6
  25. package/dist/{init-Dpg8e1HN.cjs.map → init--vszxTGP.cjs.map} +1 -1
  26. package/dist/{init-BTp9if7K.js → init-BD4zelZR.js} +6 -6
  27. package/dist/{init-BTp9if7K.js.map → init-BD4zelZR.js.map} +1 -1
  28. package/dist/{mcp-C9RoU-Dg.js → mcp-CKrpwcmV.js} +6 -6
  29. package/dist/{mcp-C9RoU-Dg.js.map → mcp-CKrpwcmV.js.map} +1 -1
  30. package/dist/{mcp-wpl6sYYR.cjs → mcp-DSYDu-Tk.cjs} +6 -6
  31. package/dist/{mcp-wpl6sYYR.cjs.map → mcp-DSYDu-Tk.cjs.map} +1 -1
  32. package/dist/package-BFdHEmb9.js +6 -0
  33. package/dist/package-BFdHEmb9.js.map +1 -0
  34. package/dist/{package-iheSdfas.cjs → package-CwCIaoAJ.cjs} +2 -2
  35. package/dist/package-CwCIaoAJ.cjs.map +1 -0
  36. package/dist/run-9ZhHuNZQ.cjs +33 -0
  37. package/dist/run-9ZhHuNZQ.cjs.map +1 -0
  38. package/dist/run-BG7Giryi.js +296 -0
  39. package/dist/run-BG7Giryi.js.map +1 -0
  40. package/dist/{validate-BU4fPTMc.cjs → run-BQO_tPlc.cjs} +25 -20
  41. package/dist/run-BQO_tPlc.cjs.map +1 -0
  42. package/dist/run-CIcMzR6i.js +1377 -0
  43. package/dist/run-CIcMzR6i.js.map +1 -0
  44. package/dist/run-CYnDu3ch.js +51 -0
  45. package/dist/run-CYnDu3ch.js.map +1 -0
  46. package/dist/run-DQZAMhO5.cjs +1380 -0
  47. package/dist/run-DQZAMhO5.cjs.map +1 -0
  48. package/dist/run-DpKny2hT.cjs +300 -0
  49. package/dist/run-DpKny2hT.cjs.map +1 -0
  50. package/dist/run-h8NTawHO.js +32 -0
  51. package/dist/run-h8NTawHO.js.map +1 -0
  52. package/dist/tools-BU99bhi8.js +152 -0
  53. package/dist/tools-BU99bhi8.js.map +1 -0
  54. package/dist/tools-_Xp8-_zy.cjs +175 -0
  55. package/dist/tools-_Xp8-_zy.cjs.map +1 -0
  56. package/dist/{validate-BfJoCxrC.js → validate-BPHQK1kh.js} +6 -6
  57. package/dist/{validate-BfJoCxrC.js.map → validate-BPHQK1kh.js.map} +1 -1
  58. package/dist/{validate-DIDBROB2.cjs → validate-R-AOm0fm.cjs} +6 -6
  59. package/dist/{validate-DIDBROB2.cjs.map → validate-R-AOm0fm.cjs.map} +1 -1
  60. package/package.json +12 -27
  61. package/src/Telemetry.ts +297 -0
  62. package/src/commands/generate.ts +18 -12
  63. package/src/commands/init.ts +2 -2
  64. package/src/commands/mcp.ts +2 -2
  65. package/src/commands/validate.ts +2 -2
  66. package/src/constants.ts +2 -35
  67. package/src/index.ts +5 -21
  68. package/src/loggers/clackLogger.ts +136 -202
  69. package/src/loggers/defineLogger.ts +59 -0
  70. package/src/loggers/plainLogger.ts +48 -103
  71. package/src/loggers/types.ts +6 -1
  72. package/src/loggers/utils.ts +167 -24
  73. package/src/runners/generate/run.ts +399 -0
  74. package/src/runners/generate/utils.ts +229 -0
  75. package/src/runners/{init.ts → init/run.ts} +81 -78
  76. package/src/runners/init/utils.ts +39 -0
  77. package/src/runners/mcp/run.ts +37 -0
  78. package/src/runners/{validate.ts → validate/run.ts} +25 -20
  79. package/dist/agent-BJEvbSiP.js +0 -68
  80. package/dist/agent-BJEvbSiP.js.map +0 -1
  81. package/dist/agent-CXNO6dgj.cjs +0 -70
  82. package/dist/agent-CXNO6dgj.cjs.map +0 -1
  83. package/dist/agent-D9CKYh4K.cjs +0 -122
  84. package/dist/agent-D9CKYh4K.cjs.map +0 -1
  85. package/dist/agent-VXKxLCho.js +0 -118
  86. package/dist/agent-VXKxLCho.js.map +0 -1
  87. package/dist/constants-BPJBMT_6.js +0 -45
  88. package/dist/constants-BPJBMT_6.js.map +0 -1
  89. package/dist/constants-BYGmiFs0.cjs +0 -139
  90. package/dist/constants-BYGmiFs0.cjs.map +0 -1
  91. package/dist/constants-DSJ-Xrbv.js +0 -116
  92. package/dist/constants-DSJ-Xrbv.js.map +0 -1
  93. package/dist/constants-Rcaqzyd-.cjs +0 -80
  94. package/dist/constants-Rcaqzyd-.cjs.map +0 -1
  95. package/dist/generate-BB2Q7I9s.cjs.map +0 -1
  96. package/dist/generate-B_p5dl68.cjs +0 -1755
  97. package/dist/generate-B_p5dl68.cjs.map +0 -1
  98. package/dist/generate-BmulGxIM.js.map +0 -1
  99. package/dist/generate-DAsdUw3z.js +0 -1752
  100. package/dist/generate-DAsdUw3z.js.map +0 -1
  101. package/dist/init-CJ80lKSP.cjs +0 -239
  102. package/dist/init-CJ80lKSP.cjs.map +0 -1
  103. package/dist/init-DCqcEq86.js +0 -235
  104. package/dist/init-DCqcEq86.js.map +0 -1
  105. package/dist/mcp-D1llTaRM.cjs +0 -50
  106. package/dist/mcp-D1llTaRM.cjs.map +0 -1
  107. package/dist/mcp-DNUw8nqb.js +0 -49
  108. package/dist/mcp-DNUw8nqb.js.map +0 -1
  109. package/dist/package-iheSdfas.cjs.map +0 -1
  110. package/dist/package-vLafMWCe.js +0 -6
  111. package/dist/package-vLafMWCe.js.map +0 -1
  112. package/dist/shell-475fQKaX.cjs +0 -62
  113. package/dist/shell-475fQKaX.cjs.map +0 -1
  114. package/dist/shell-DLzN4fRo.js +0 -51
  115. package/dist/shell-DLzN4fRo.js.map +0 -1
  116. package/dist/telemetry-BLX0NzRk.cjs +0 -282
  117. package/dist/telemetry-BLX0NzRk.cjs.map +0 -1
  118. package/dist/telemetry-juq4QBf7.js +0 -245
  119. package/dist/telemetry-juq4QBf7.js.map +0 -1
  120. package/dist/validate-BU4fPTMc.cjs.map +0 -1
  121. package/dist/validate-k9s_hFah.js +0 -46
  122. package/dist/validate-k9s_hFah.js.map +0 -1
  123. package/src/commands/agent/start.ts +0 -50
  124. package/src/commands/agent.ts +0 -10
  125. package/src/loggers/fileSystemLogger.ts +0 -138
  126. package/src/loggers/githubActionsLogger.ts +0 -379
  127. package/src/runners/agent.ts +0 -155
  128. package/src/runners/generate.ts +0 -333
  129. package/src/runners/mcp.ts +0 -56
  130. package/src/types.ts +0 -11
  131. package/src/utils/Writables.ts +0 -17
  132. package/src/utils/executeHooks.ts +0 -45
  133. package/src/utils/flags.ts +0 -9
  134. package/src/utils/getConfig.ts +0 -10
  135. package/src/utils/getCosmiConfig.ts +0 -75
  136. package/src/utils/getSummary.ts +0 -68
  137. package/src/utils/packageManager.ts +0 -23
  138. package/src/utils/runHook.ts +0 -91
  139. package/src/utils/telemetry.ts +0 -273
  140. package/src/utils/watcher.ts +0 -19
  141. /package/dist/{chunk-ByKO4r7w.cjs → chunk-Bx3C2hgW.cjs} +0 -0
  142. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/LICENSE CHANGED
@@ -1,14 +1,21 @@
1
- Copyright (c) 2026 Stijn Van Hulle
2
-
3
- This repository contains software under two licenses:
1
+ MIT License
4
2
 
5
- 1. Most of the code in this repository is licensed under the
6
- MIT License — see licenses/LICENSE-MIT for the full license text.
3
+ Copyright (c) 2026 Stijn Van Hulle
7
4
 
8
- 2. The following components are licensed under the
9
- GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
10
- see licenses/LICENSE-AGPL-3.0 for the full license text:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
11
 
12
- - packages/agent (published as @kubb/agent)
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
13
14
 
14
- Each package's own LICENSE file or package.json specifies its applicable license.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,95 +1,214 @@
1
1
  <div align="center">
2
- <h1>Kubb Cli</h1>
3
2
  <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
4
- <img width="180" src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/logo.png" alt="Kubb logo">
3
+ <img src="https://kubb.dev/og.png" alt="Kubb banner">
5
4
  </a>
6
5
 
7
6
  [![npm version][npm-version-src]][npm-version-href]
8
7
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
9
- [![Coverage][coverage-src]][coverage-href]
8
+ [![Stars][stars-src]][stars-href]
10
9
  [![License][license-src]][license-href]
11
- [![Sponsors][sponsors-src]][sponsors-href]
10
+ [![Node][node-src]][node-href]
12
11
 
13
12
  <h4>
14
- <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/main//examples/typescript" target="_blank">View Demo</a>
15
- <span> · </span>
16
- <a href="https://kubb.dev/" target="_blank">Documentation</a>
17
- <span> · </span>
18
- <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
19
- <span> · </span>
20
- <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
21
- </h4>
13
+ <a href="https://kubb.dev" target="_blank">Documentation</a>
14
+ <span> · </span>
15
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
+ <span> · </span>
17
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
18
+ </h4>
22
19
  </div>
23
20
 
21
+ <br />
22
+
23
+ # @kubb/cli
24
+
25
+ ### The command-line interface for Kubb
26
+
27
+ Official CLI for Kubb. Run `kubb generate` to transform OpenAPI/Swagger specs into TypeScript types, API clients, hooks, validators, and mocks. Includes interactive project setup (`kubb init`), spec validation, watch mode, and an MCP server.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ bun add -D @kubb/cli
33
+ # or
34
+ pnpm add -D @kubb/cli
35
+ # or
36
+ npm install -D @kubb/cli
37
+ ```
38
+
24
39
  ## Commands
25
40
 
41
+ - [`kubb init`](#kubb-init) — scaffold a new project
42
+ - [`kubb generate`](#kubb-generate) — run code generation
43
+ - [`kubb validate`](#kubb-validate) — validate an OpenAPI spec
44
+ - [`kubb mcp`](#kubb-mcp) — start the MCP server for AI assistants
45
+
46
+ ---
47
+
26
48
  ### `kubb init`
27
49
 
28
- Initialize a new Kubb project with an interactive setup wizard.
50
+ Scaffold a `kubb.config.ts` and install plugins for code generation from an OpenAPI spec. Run without flags for an interactive setup wizard, or pass flags to skip the prompts.
29
51
 
30
52
  ```bash
31
53
  npx kubb init
32
54
  ```
33
55
 
34
- Use the `-y` / `--yes` flag to skip all prompts and accept the defaults:
56
+ #### Options
57
+
58
+ | Flag | Short | Type | Default | Description |
59
+ | ------------------ | ----- | ------- | ---------------- | ------------------------------------------ |
60
+ | `--yes` | `-y` | boolean | `false` | Skip all prompts and use defaults |
61
+ | `--input <path>` | `-i` | string | `./openapi.yaml` | Path to the OpenAPI specification |
62
+ | `--output <path>` | `-o` | string | `./src/gen` | Output directory for generated files |
63
+ | `--plugins <list>` | | string | | Comma-separated list of plugins to install |
64
+
65
+ Available plugin values for `--plugins`: `plugin-ts`, `plugin-client`, `plugin-react-query`, `plugin-vue-query`, `plugin-zod`, `plugin-faker`, `plugin-msw`, `plugin-cypress`, `plugin-mcp`, `plugin-redoc`.
66
+
67
+ #### Examples
35
68
 
36
69
  ```bash
37
- npx kubb init -y
38
- ```
70
+ # Interactive wizard
71
+ npx kubb init
39
72
 
40
- Defaults when using `-y`:
73
+ # Accept all defaults
74
+ npx kubb init --yes
41
75
 
42
- - Input path: `./openapi.yaml`
43
- - Output path: `./src/gen`
44
- - Plugins: OpenAPI Parser + TypeScript
76
+ # Fully non-interactive
77
+ npx kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod
78
+
79
+ # Select specific plugins only
80
+ npx kubb init --plugins plugin-ts,plugin-client,plugin-react-query
81
+ ```
45
82
 
46
- This command will:
83
+ The wizard will:
47
84
 
48
- 1. Detect or create a `package.json` if it doesn't exist
49
- 2. Prompt you for your OpenAPI specification path (default: `./openapi.yaml`)
50
- 3. Ask for the output directory for generated files (default: `./src/gen`)
51
- 4. Let you select which Kubb plugins to use (default: OpenAPI Parser + TypeScript)
85
+ 1. Detect or create a `package.json` if one does not exist
86
+ 2. Prompt for your OpenAPI specification path (default: `./openapi.yaml`)
87
+ 3. Ask for the output directory (default: `./src/gen`)
88
+ 4. Let you choose which plugins to install
52
89
  5. Install the selected packages using your package manager (npm, pnpm, yarn, or bun)
53
- 6. Generate a `kubb.config.ts` file with your chosen configuration
90
+ 6. Generate a `kubb.config.ts` with your chosen configuration
91
+
92
+ ---
54
93
 
55
94
  ### `kubb generate`
56
95
 
57
- Generate files based on your `kubb.config.ts` configuration.
96
+ Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads `kubb.config.ts` by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.
58
97
 
59
98
  ```bash
60
99
  npx kubb generate
61
100
  ```
62
101
 
63
- Options:
102
+ #### Options
103
+
104
+ | Flag | Short | Type | Default | Description |
105
+ | -------------------- | ----- | ------- | ------- | --------------------------------------------------------------------------------------------------- |
106
+ | `[input]` | | string | | OpenAPI file path — overrides `input.path` in the config |
107
+ | `--config <path>` | `-c` | string | | Path to the Kubb config file |
108
+ | `--logLevel <level>` | `-l` | string | `info` | Log level: `silent`, `info`, or `verbose` |
109
+ | `--watch` | `-w` | boolean | `false` | Re-generate whenever the input file changes |
110
+ | `--verbose` | `-v` | boolean | `false` | Override log level to `verbose` |
111
+ | `--silent` | `-s` | boolean | `false` | Override log level to `silent` |
112
+ | `--reporter <names>` | | string | `cli` | Reporters that render the run, comma-separated: `cli`, `json`, `file`. Overrides `config.reporters` |
113
+
114
+ #### Examples
115
+
116
+ ```bash
117
+ # Use kubb.config.ts in the current directory
118
+ npx kubb generate
119
+
120
+ # Override the input spec without editing the config
121
+ npx kubb generate ./openapi.yaml
122
+
123
+ # Point to a custom config file
124
+ npx kubb generate --config ./configs/kubb.config.ts
125
+
126
+ # Watch for changes and regenerate automatically
127
+ npx kubb generate --watch
64
128
 
65
- - `-c, --config <path>` - Path to the Kubb config file
66
- - `-l, --logLevel <level>` - Set log level (silent, info, verbose, debug)
67
- - `-w, --watch` - Watch mode based on the input file
68
- - `-d, --debug` - Enable debug mode
69
- - `-v, --verbose` - Enable verbose mode
70
- - `-s, --silent` - Enable silent mode
129
+ # Verbose output
130
+ npx kubb generate --verbose
131
+
132
+ # Write a JSON run report alongside the CLI output
133
+ npx kubb generate --reporter cli,json
134
+ ```
135
+
136
+ ---
71
137
 
72
138
  ### `kubb validate`
73
139
 
74
- Validate a Swagger/OpenAPI file.
140
+ Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running `generate` to catch spec issues early.
75
141
 
76
142
  ```bash
77
- npx kubb validate <path-to-openapi>
143
+ npx kubb validate --input <path-or-url>
78
144
  ```
79
145
 
146
+ #### Options
147
+
148
+ | Flag | Short | Type | Required | Description |
149
+ | ---------------- | ----- | ------ | -------- | --------------------------------------------------- |
150
+ | `--input <path>` | `-i` | string | ✅ | Path or URL to the OpenAPI/Swagger file to validate |
151
+
152
+ #### Examples
153
+
154
+ ```bash
155
+ # Validate a local file
156
+ npx kubb validate --input ./openapi.yaml
157
+
158
+ # Validate a remote spec
159
+ npx kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json
160
+ ```
161
+
162
+ ---
163
+
80
164
  ### `kubb mcp`
81
165
 
82
- Start the MCP server to enable the MCP client to interact with the LLM.
166
+ Start a Model Context Protocol (MCP) server that exposes Kubb code generation as a tool for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect the assistant can then call `kubb generate` directly without leaving the chat.
167
+
168
+ Runs over **stdio** by default (compatible with all MCP clients). Pass `--port` to expose an HTTP server instead.
169
+
170
+ ```bash
171
+ npx kubb mcp
172
+ ```
173
+
174
+ #### Options
175
+
176
+ | Flag | Short | Type | Default | Description |
177
+ | ------------------- | ----- | ------ | ----------- | ----------------------------------------- |
178
+ | `--port <number>` | `-p` | string | | Port for HTTP MCP server (omit for stdio) |
179
+ | `--host <hostname>` | | string | `localhost` | Hostname to bind to (HTTP mode only) |
180
+
181
+ #### Examples
83
182
 
84
183
  ```bash
184
+ # stdio mode (recommended for Claude Desktop, Cursor, etc.)
85
185
  npx kubb mcp
186
+
187
+ # HTTP mode
188
+ npx kubb mcp --port 3001
189
+ ```
190
+
191
+ #### MCP client configuration
192
+
193
+ Add the following to your MCP client config (e.g. Claude Desktop's `claude_desktop_config.json`):
194
+
195
+ ```json
196
+ {
197
+ "mcpServers": {
198
+ "kubb": {
199
+ "command": "npx",
200
+ "args": ["kubb", "mcp"]
201
+ }
202
+ }
203
+ }
86
204
  ```
87
205
 
88
206
  ## Supporting Kubb
89
207
 
90
- Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
208
+ Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
91
209
 
92
210
  - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
211
+ - [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
93
212
 
94
213
  <p align="center">
95
214
  <a href="https://github.com/sponsors/stijnvanhulle">
@@ -97,19 +216,19 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
97
216
  </a>
98
217
  </p>
99
218
 
219
+ ## License
220
+
221
+ [MIT](https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT)
222
+
100
223
  <!-- Badges -->
101
224
 
102
- [npm-version-src]: https://img.shields.io/npm/v/@kubb/cli?flat&colorA=18181B&colorB=f58517
103
- [npm-version-href]: https://npmjs.com/package/@kubb/cli
104
- [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/cli?flat&colorA=18181B&colorB=f58517
105
- [npm-downloads-href]: https://npmjs.com/package/@kubb/cli
106
- [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
225
+ [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
226
+ [npm-version-href]: https://npmx.dev/package/@kubb/cli
227
+ [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
228
+ [npm-downloads-href]: https://npmx.dev/package/@kubb/cli
229
+ [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
230
+ [stars-href]: https://github.com/kubb-labs/kubb
231
+ [license-src]: https://shieldcn.dev/npm/license/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc
107
232
  [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
108
- [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
109
- [build-href]: https://www.npmjs.com/package/@kubb/cli
110
- [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/cli?style=flat&colorA=18181B&colorB=f58517
111
- [minified-href]: https://www.npmjs.com/package/@kubb/cli
112
- [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
113
- [coverage-href]: https://www.npmjs.com/package/@kubb/cli
114
- [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
115
- [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
233
+ [node-src]: https://shieldcn.dev/npm/node/@kubb/cli.svg?variant=secondary&size=xs&theme=zinc&mode=dark
234
+ [node-href]: https://npmx.dev/package/@kubb/cli
@@ -0,0 +1,283 @@
1
+ import "./chunk-C0LytTxp.js";
2
+ import { randomBytes } from "node:crypto";
3
+ import os from "node:os";
4
+ import process$1 from "node:process";
5
+ //#region ../../internals/utils/src/env.ts
6
+ /**
7
+ * Returns `true` when the process is running in a CI environment.
8
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
9
+ * TeamCity, Buildkite, and Azure Pipelines.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * if (isCIEnvironment()) {
14
+ * logger.level = 'error'
15
+ * }
16
+ * ```
17
+ */
18
+ function isCIEnvironment() {
19
+ return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);
20
+ }
21
+ /**
22
+ * Returns `true` when the process has an interactive TTY with a valid terminal
23
+ * width and is not running in CI.
24
+ *
25
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
26
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
27
+ * with a negative count and throw a `RangeError`). We therefore require a
28
+ * positive column count before declaring the TTY usable.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * if (canUseTTY()) {
33
+ * renderProgressBar()
34
+ * }
35
+ * ```
36
+ */
37
+ function canUseTTY() {
38
+ return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
39
+ }
40
+ //#endregion
41
+ //#region ../../internals/utils/src/runtime.ts
42
+ /**
43
+ * Detects the JavaScript runtime executing the current process and exposes its name and version.
44
+ *
45
+ * Prefer the shared {@link runtime} instance over constructing your own.
46
+ */
47
+ var Runtime = class {
48
+ /**
49
+ * `true` when the current process is running under Bun.
50
+ *
51
+ * Detection keys off the global `Bun` object rather than `process.versions`,
52
+ * because Bun polyfills `process.versions.node` for Node compatibility and would
53
+ * otherwise look like Node.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * if (runtime.isBun) {
58
+ * await Bun.write(path, data)
59
+ * }
60
+ * ```
61
+ */
62
+ get isBun() {
63
+ return typeof Bun !== "undefined";
64
+ }
65
+ /**
66
+ * `true` when the current process is running under Deno.
67
+ */
68
+ get isDeno() {
69
+ return typeof globalThis.Deno !== "undefined";
70
+ }
71
+ /**
72
+ * `true` when the current process is running under Node.
73
+ *
74
+ * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
75
+ */
76
+ get isNode() {
77
+ return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
78
+ }
79
+ /**
80
+ * Name of the runtime executing the current process.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
85
+ * ```
86
+ */
87
+ get name() {
88
+ if (this.isBun) return "bun";
89
+ if (this.isDeno) return "deno";
90
+ return "node";
91
+ }
92
+ /**
93
+ * Version of the active runtime, or an empty string when it cannot be read.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * runtime.version // '1.3.11' under Bun, '22.22.2' under Node
98
+ * ```
99
+ */
100
+ get version() {
101
+ if (this.isBun) return process.versions.bun ?? "";
102
+ if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
103
+ return process.versions?.node ?? "";
104
+ }
105
+ };
106
+ /**
107
+ * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
108
+ */
109
+ const runtime = new Runtime();
110
+ //#endregion
111
+ //#region src/constants.ts
112
+ /**
113
+ * NPM registry endpoint used to check for @kubb/cli updates.
114
+ */
115
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
116
+ /**
117
+ * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
118
+ */
119
+ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
120
+ /**
121
+ * Glob pattern for paths the file watcher ignores.
122
+ */
123
+ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
124
+ /**
125
+ * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
126
+ */
127
+ const QUIET_FLAGS = new Set([
128
+ "--help",
129
+ "-h",
130
+ "--version",
131
+ "-v"
132
+ ]);
133
+ //#endregion
134
+ //#region src/Telemetry.ts
135
+ /**
136
+ * Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`
137
+ * and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails
138
+ * silently so a failed request never breaks the run.
139
+ */
140
+ var Telemetry = class Telemetry {
141
+ /**
142
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
143
+ */
144
+ static get isDisabled() {
145
+ return process$1.env["DO_NOT_TRACK"] === "1" || process$1.env["DO_NOT_TRACK"] === "true" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "1" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "true";
146
+ }
147
+ /**
148
+ * Build an anonymous telemetry payload from a completed generation run.
149
+ */
150
+ static build(options) {
151
+ const [seconds, nanoseconds] = process$1.hrtime(options.hrStart);
152
+ const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
153
+ return {
154
+ command: options.command,
155
+ kubbVersion: options.kubbVersion,
156
+ nodeVersion: process$1.versions.node.split(".")[0],
157
+ runtime: runtime.name,
158
+ runtimeVersion: runtime.version.split(".")[0],
159
+ platform: os.platform(),
160
+ ci: isCIEnvironment(),
161
+ plugins: options.plugins ?? [],
162
+ duration,
163
+ filesCreated: options.filesCreated ?? 0,
164
+ status: options.status
165
+ };
166
+ }
167
+ /**
168
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
169
+ * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
170
+ */
171
+ static buildOtlpPayload(event) {
172
+ const traceId = randomBytes(16).toString("hex");
173
+ const spanId = randomBytes(8).toString("hex");
174
+ const endTimeNs = BigInt(Date.now()) * 1000000n;
175
+ const startTimeNs = endTimeNs - BigInt(event.duration) * 1000000n;
176
+ const attributes = [
177
+ {
178
+ key: "kubb.command",
179
+ value: { stringValue: event.command }
180
+ },
181
+ {
182
+ key: "kubb.version",
183
+ value: { stringValue: event.kubbVersion }
184
+ },
185
+ {
186
+ key: "kubb.node_version",
187
+ value: { stringValue: event.nodeVersion }
188
+ },
189
+ {
190
+ key: "kubb.runtime",
191
+ value: { stringValue: event.runtime }
192
+ },
193
+ {
194
+ key: "kubb.runtime_version",
195
+ value: { stringValue: event.runtimeVersion }
196
+ },
197
+ {
198
+ key: "kubb.platform",
199
+ value: { stringValue: event.platform }
200
+ },
201
+ {
202
+ key: "kubb.ci",
203
+ value: { boolValue: event.ci }
204
+ },
205
+ {
206
+ key: "kubb.files_created",
207
+ value: { intValue: event.filesCreated }
208
+ },
209
+ {
210
+ key: "kubb.status",
211
+ value: { stringValue: event.status }
212
+ },
213
+ {
214
+ key: "kubb.plugins",
215
+ value: { arrayValue: { values: event.plugins.map((p) => ({ kvlistValue: { values: [{
216
+ key: "name",
217
+ value: { stringValue: p.name }
218
+ }, {
219
+ key: "options",
220
+ value: { stringValue: JSON.stringify({
221
+ ...p.options,
222
+ usedEnumNames: void 0
223
+ }) }
224
+ }] } })) } }
225
+ }
226
+ ];
227
+ return { resourceSpans: [{
228
+ resource: { attributes: [
229
+ {
230
+ key: "service.name",
231
+ value: { stringValue: "kubb-core" }
232
+ },
233
+ {
234
+ key: "service.version",
235
+ value: { stringValue: event.kubbVersion }
236
+ },
237
+ {
238
+ key: "telemetry.sdk.language",
239
+ value: { stringValue: "nodejs" }
240
+ }
241
+ ] },
242
+ scopeSpans: [{
243
+ scope: {
244
+ name: "kubb-core",
245
+ version: event.kubbVersion
246
+ },
247
+ spans: [{
248
+ traceId,
249
+ spanId,
250
+ name: event.command,
251
+ kind: 1,
252
+ startTimeUnixNano: String(startTimeNs),
253
+ endTimeUnixNano: String(endTimeNs),
254
+ attributes,
255
+ status: { code: event.status === "success" ? 1 : 2 }
256
+ }]
257
+ }]
258
+ }] };
259
+ }
260
+ /**
261
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
262
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
263
+ */
264
+ static async send(event) {
265
+ if (Telemetry.isDisabled) return;
266
+ try {
267
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
268
+ method: "POST",
269
+ headers: {
270
+ "Content-Type": "application/json",
271
+ "Kubb-Telemetry-Version": "1",
272
+ "Kubb-Telemetry-Source": "kubb-core"
273
+ },
274
+ body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
275
+ signal: AbortSignal.timeout(5e3)
276
+ });
277
+ } catch (_e) {}
278
+ }
279
+ };
280
+ //#endregion
281
+ export { runtime as a, WATCHER_IGNORED_PATHS as i, KUBB_NPM_PACKAGE_URL as n, canUseTTY as o, QUIET_FLAGS as r, Telemetry as t };
282
+
283
+ //# sourceMappingURL=Telemetry-CVdyJarO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-CVdyJarO.js","names":["process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: Array<OtlpAnyValue> } }\ntype OtlpKvListValue = { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\n/**\n * @see https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103\n */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/**\n * Span status code.\n * - `0` is unset\n * - `1` is OK\n * - `2` is error\n */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n events?: Array<OtlpSpanEvent>\n droppedEventsCount?: number\n links?: Array<OtlpSpanLink>\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: Array<OtlpSpan>\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: Array<OtlpScopeSpans>\n schemaUrl?: string\n}\n\n/**\n * Root payload sent to POST /v1/traces.\n */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<OtlpResourceSpans>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`\n * and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails\n * silently so a failed request never breaks the run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static get isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n }\n\n /**\n * Build an anonymous telemetry payload from a completed generation run.\n */\n static build(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n }): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n }\n\n /**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\n static buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n }),\n ),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n }\n\n /**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.\n */\n static async send(event: TelemetryEvent): Promise<void> {\n if (Telemetry.isDisabled) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(Telemetry.buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,YAAqB;CACnC,OAAO,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,KAAK,KAAK,CAAC,gBAAgB;AACvF;;;;;;;;ACnCA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,YAAY,eAAe,QAAQ,UAAU,QAAQ;CACpG;;;;;;;;;CAUA,IAAI,OAAoB;EACtB,IAAI,KAAK,OAAO,OAAO;EACvB,IAAI,KAAK,QAAQ,OAAO;EAExB,OAAO;CACT;;;;;;;;;CAUA,IAAI,UAAkB;EACpB,IAAI,KAAK,OAAO,OAAO,QAAQ,SAAS,OAAO;EAC/C,IAAI,KAAK,QAAQ,OAAQ,WAA0D,MAAM,SAAS,QAAQ;EAE1G,OAAO,QAAQ,UAAU,QAAQ;CACnC;AACF;;;;AAKA,MAAa,UAAU,IAAI,QAAQ;;;;;;AC5EnC,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;;;;AAK7B,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAY;CAAC;CAAU;CAAM;CAAa;AAAI,CAAC;;;;;;;;ACgI9E,IAAa,YAAb,MAAa,UAAU;;;;CAIrB,WAAW,aAAsB;EAC/B,OACEA,UAAQ,IAAI,oBAAoB,OAChCA,UAAQ,IAAI,oBAAoB,UAChCA,UAAQ,IAAI,8BAA8B,OAC1CA,UAAQ,IAAI,8BAA8B;CAE9C;;;;CAKA,OAAO,MAAM,SAOM;EACjB,MAAM,CAAC,SAAS,eAAeA,UAAQ,OAAO,QAAQ,OAAO;EAC7D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,GAAG;EAE9D,OAAO;GACL,SAAS,QAAQ;GACjB,aAAa,QAAQ;GACrB,aAAaA,UAAQ,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;GAC9C,SAAS,QAAQ;GACjB,gBAAgB,QAAQ,QAAQ,MAAM,GAAG,CAAC,CAAC;GAC3C,UAAU,GAAG,SAAS;GACtB,IAAI,gBAAgB;GACpB,SAAS,QAAQ,WAAW,CAAC;GAC7B;GACA,cAAc,QAAQ,gBAAgB;GACtC,QAAQ,QAAQ;EAClB;CACF;;;;;CAMA,OAAO,iBAAiB,OAAsD;EAC5E,MAAM,UAAU,YAAY,EAAE,CAAC,CAAC,SAAS,KAAK;EAC9C,MAAM,SAAS,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK;EAC5C,MAAM,YAAY,OAAO,KAAK,IAAI,CAAC,IAAI;EACvC,MAAM,cAAc,YAAY,OAAO,MAAM,QAAQ,IAAI;EAEzD,MAAM,aAAkC;GACtC;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,MAAM,QAAQ;GAAE;GAC7D;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,MAAM,YAAY;GAAE;GACjE;IAAE,KAAK;IAAqB,OAAO,EAAE,aAAa,MAAM,YAAY;GAAE;GACtE;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,MAAM,QAAQ;GAAE;GAC7D;IAAE,KAAK;IAAwB,OAAO,EAAE,aAAa,MAAM,eAAe;GAAE;GAC5E;IAAE,KAAK;IAAiB,OAAO,EAAE,aAAa,MAAM,SAAS;GAAE;GAC/D;IAAE,KAAK;IAAW,OAAO,EAAE,WAAW,MAAM,GAAG;GAAE;GACjD;IAAE,KAAK;IAAsB,OAAO,EAAE,UAAU,MAAM,aAAa;GAAE;GACrE;IAAE,KAAK;IAAe,OAAO,EAAE,aAAa,MAAM,OAAO;GAAE;GAC3D;IACE,KAAK;IACL,OAAO,EACL,YAAY,EACV,QAAQ,MAAM,QAAQ,KACnB,OAAwB,EACvB,aAAa,EACX,QAAQ,CACN;KAAE,KAAK;KAAQ,OAAO,EAAE,aAAa,EAAE,KAAK;IAAE,GAC9C;KACE,KAAK;KACL,OAAO,EACL,aAAa,KAAK,UAAU;MAC1B,GAAG,EAAE;MACL,eAAe,KAAA;KACjB,CAAC,EACH;IACF,CACF,EACF,EACF,EACF,EACF,EACF;GACF;EACF;EAEA,OAAO,EACL,eAAe,CACb;GACE,UAAU,EACR,YAAY;IACV;KAAE,KAAK;KAAgB,OAAO,EAAE,aAAa,YAAY;IAAE;IAC3D;KACE,KAAK;KACL,OAAO,EAAE,aAAa,MAAM,YAAY;IAC1C;IACA;KAAE,KAAK;KAA0B,OAAO,EAAE,aAAa,SAAS;IAAE;GACpE,EACF;GACA,YAAY,CACV;IACE,OAAO;KAAE,MAAM;KAAa,SAAS,MAAM;IAAY;IACvD,OAAO,CACL;KACE;KACA;KACA,MAAM,MAAM;KACZ,MAAM;KACN,mBAAmB,OAAO,WAAW;KACrC,iBAAiB,OAAO,SAAS;KACjC;KACA,QAAQ,EACN,MAAO,MAAM,WAAW,YAAY,IAAI,EAC1C;IACF,CACF;GACF,CACF;EACF,CACF,EACF;CACF;;;;;CAMA,aAAa,KAAK,OAAsC;EACtD,IAAI,UAAU,YACZ;EAGF,IAAI;GACF,MAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;IAC3B;IACA,MAAM,KAAK,UAAU,UAAU,iBAAiB,KAAK,CAAC;IACtD,QAAQ,YAAY,QAAQ,GAAK;GACnC,CAAC;EACH,SAAS,IAAI,CAEb;CACF;AACF"}