@kubb/cli 5.0.0-beta.53 → 5.0.0-beta.55

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 (74) hide show
  1. package/README.md +0 -1
  2. package/dist/{Telemetry-DC5WVMB9.cjs → Telemetry-BuDSora3.cjs} +83 -112
  3. package/dist/Telemetry-BuDSora3.cjs.map +1 -0
  4. package/dist/{Telemetry-BZH4YIxq.js → Telemetry-C66uYyC2.js} +82 -111
  5. package/dist/Telemetry-C66uYyC2.js.map +1 -0
  6. package/dist/define-C4AB3POr.cjs.map +1 -1
  7. package/dist/define-C63T4jp6.js.map +1 -1
  8. package/dist/{generate-w8nvAG7i.js → generate-CByoI4cQ.js} +3 -9
  9. package/dist/generate-CByoI4cQ.js.map +1 -0
  10. package/dist/{generate-DzULb5D8.cjs → generate-Dg9jZ8xa.cjs} +3 -9
  11. package/dist/generate-Dg9jZ8xa.cjs.map +1 -0
  12. package/dist/index.cjs +8 -22
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +8 -22
  15. package/dist/index.js.map +1 -1
  16. package/dist/{init-BtYgNYSH.js → init-C7KqFbJT.js} +3 -3
  17. package/dist/{init-BtYgNYSH.js.map → init-C7KqFbJT.js.map} +1 -1
  18. package/dist/{init-Dptxcf7c.cjs → init-Cptp_SSW.cjs} +3 -3
  19. package/dist/{init-Dptxcf7c.cjs.map → init-Cptp_SSW.cjs.map} +1 -1
  20. package/dist/{mcp-CccZq-lH.cjs → mcp-CM19f7rG.cjs} +3 -3
  21. package/dist/{mcp-CccZq-lH.cjs.map → mcp-CM19f7rG.cjs.map} +1 -1
  22. package/dist/{mcp-7cxItivW.js → mcp-ClbeosGy.js} +3 -3
  23. package/dist/{mcp-7cxItivW.js.map → mcp-ClbeosGy.js.map} +1 -1
  24. package/dist/{package-C5Egcs3F.cjs → package-dLlE0LgE.cjs} +2 -2
  25. package/dist/package-dLlE0LgE.cjs.map +1 -0
  26. package/dist/package-scFCPMiP.js +6 -0
  27. package/dist/package-scFCPMiP.js.map +1 -0
  28. package/dist/{run-C-omuksC.js → run-BG7Giryi.js} +36 -99
  29. package/dist/run-BG7Giryi.js.map +1 -0
  30. package/dist/{run-DMWGLJUx.cjs → run-Bj64iPU_.cjs} +2 -2
  31. package/dist/{run-DMWGLJUx.cjs.map → run-Bj64iPU_.cjs.map} +1 -1
  32. package/dist/{run-CmW3AT37.cjs → run-BoR5nxtV.cjs} +86 -168
  33. package/dist/run-BoR5nxtV.cjs.map +1 -0
  34. package/dist/{run-C7cr0qhi.js → run-CUkZ6gnP.js} +2 -2
  35. package/dist/{run-C7cr0qhi.js.map → run-CUkZ6gnP.js.map} +1 -1
  36. package/dist/{run-DJP6fr9w.js → run-CY0htF8O.js} +83 -165
  37. package/dist/run-CY0htF8O.js.map +1 -0
  38. package/dist/{run-DGMgkbD3.cjs → run-DCXY-eRK.cjs} +2 -2
  39. package/dist/{run-DGMgkbD3.cjs.map → run-DCXY-eRK.cjs.map} +1 -1
  40. package/dist/{run-BtjzfTz3.cjs → run-DpKny2hT.cjs} +30 -93
  41. package/dist/run-DpKny2hT.cjs.map +1 -0
  42. package/dist/{run-DLVIbuN0.js → run-OWQyNzZx.js} +2 -2
  43. package/dist/{run-DLVIbuN0.js.map → run-OWQyNzZx.js.map} +1 -1
  44. package/dist/tools-BU99bhi8.js +152 -0
  45. package/dist/tools-BU99bhi8.js.map +1 -0
  46. package/dist/tools-_Xp8-_zy.cjs +175 -0
  47. package/dist/tools-_Xp8-_zy.cjs.map +1 -0
  48. package/dist/{validate-DNzxpCMJ.js → validate-BtKwM4zb.js} +3 -3
  49. package/dist/{validate-DNzxpCMJ.js.map → validate-BtKwM4zb.js.map} +1 -1
  50. package/dist/{validate-CiL4bco7.cjs → validate-Cj5IIh1M.cjs} +3 -3
  51. package/dist/{validate-CiL4bco7.cjs.map → validate-Cj5IIh1M.cjs.map} +1 -1
  52. package/package.json +5 -5
  53. package/src/Telemetry.ts +20 -22
  54. package/src/commands/generate.ts +0 -6
  55. package/src/constants.ts +1 -1
  56. package/src/index.ts +4 -21
  57. package/src/runners/generate/run.ts +12 -16
  58. package/src/runners/generate/utils.ts +18 -19
  59. package/src/runners/init/utils.ts +9 -3
  60. package/dist/Telemetry-BZH4YIxq.js.map +0 -1
  61. package/dist/Telemetry-DC5WVMB9.cjs.map +0 -1
  62. package/dist/generate-DzULb5D8.cjs.map +0 -1
  63. package/dist/generate-w8nvAG7i.js.map +0 -1
  64. package/dist/package-C5Egcs3F.cjs.map +0 -1
  65. package/dist/package-DJCeuUrP.js +0 -6
  66. package/dist/package-DJCeuUrP.js.map +0 -1
  67. package/dist/run-BtjzfTz3.cjs.map +0 -1
  68. package/dist/run-C-omuksC.js.map +0 -1
  69. package/dist/run-CmW3AT37.cjs.map +0 -1
  70. package/dist/run-DJP6fr9w.js.map +0 -1
  71. package/dist/shell-DsgkfUSW.js +0 -51
  72. package/dist/shell-DsgkfUSW.js.map +0 -1
  73. package/dist/shell-Lh-vLWwH.cjs +0 -62
  74. package/dist/shell-Lh-vLWwH.cjs.map +0 -1
@@ -0,0 +1,152 @@
1
+ import "./chunk-C0LytTxp.js";
2
+ import { spawn } from "node:child_process";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ //#region ../../internals/utils/src/tools.ts
6
+ /**
7
+ * CLI command descriptors for each supported code formatter.
8
+ *
9
+ * Each entry contains the executable `command`, an `args` factory that maps an
10
+ * output path to the correct argument list, and an `errorMessage` shown when
11
+ * the formatter is not found.
12
+ */
13
+ const formatters = {
14
+ prettier: {
15
+ command: "prettier",
16
+ args: (outputPath) => [
17
+ "--ignore-unknown",
18
+ "--write",
19
+ outputPath
20
+ ],
21
+ errorMessage: "Prettier not found"
22
+ },
23
+ biome: {
24
+ command: "biome",
25
+ args: (outputPath) => [
26
+ "format",
27
+ "--write",
28
+ outputPath
29
+ ],
30
+ errorMessage: "Biome not found"
31
+ },
32
+ oxfmt: {
33
+ command: "oxfmt",
34
+ args: (outputPath) => [outputPath],
35
+ errorMessage: "Oxfmt not found"
36
+ }
37
+ };
38
+ /**
39
+ * CLI command descriptors for each supported linter.
40
+ *
41
+ * Each entry contains the executable `command`, an `args` factory that maps an
42
+ * output path to the correct argument list, and an `errorMessage` shown when
43
+ * the linter is not found.
44
+ */
45
+ const linters = {
46
+ eslint: {
47
+ command: "eslint",
48
+ args: (outputPath) => [outputPath, "--fix"],
49
+ errorMessage: "Eslint not found"
50
+ },
51
+ biome: {
52
+ command: "biome",
53
+ args: (outputPath) => [
54
+ "lint",
55
+ "--fix",
56
+ outputPath
57
+ ],
58
+ errorMessage: "Biome not found"
59
+ },
60
+ oxlint: {
61
+ command: "oxlint",
62
+ args: (outputPath) => [
63
+ "--fix",
64
+ "--no-ignore",
65
+ outputPath
66
+ ],
67
+ errorMessage: "Oxlint not found"
68
+ }
69
+ };
70
+ /**
71
+ * Resolves to `true` when running `tool --version` exits with code 0.
72
+ */
73
+ async function isToolAvailable(tool) {
74
+ return new Promise((resolve) => {
75
+ const child = spawn(tool, ["--version"], { stdio: "ignore" });
76
+ child.on("close", (code) => resolve(code === 0));
77
+ child.on("error", () => resolve(false));
78
+ });
79
+ }
80
+ /**
81
+ * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.
82
+ *
83
+ * Availability is probed by running `<tool> --version` and checking for a zero exit code.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)
88
+ * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)
89
+ * ```
90
+ */
91
+ async function detectTool(candidates) {
92
+ for (const tool of candidates) if (await isToolAvailable(tool)) return tool;
93
+ return null;
94
+ }
95
+ /**
96
+ * Metadata for each supported package manager, keyed by its short name.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * packageManagers.pnpm.installCommand // ['add', '-D']
101
+ * packageManagers.npm.lockFile // 'package-lock.json'
102
+ * ```
103
+ */
104
+ const packageManagers = {
105
+ pnpm: {
106
+ name: "pnpm",
107
+ lockFile: "pnpm-lock.yaml",
108
+ installCommand: ["add", "-D"]
109
+ },
110
+ yarn: {
111
+ name: "yarn",
112
+ lockFile: "yarn.lock",
113
+ installCommand: ["add", "-D"]
114
+ },
115
+ bun: {
116
+ name: "bun",
117
+ lockFile: "bun.lockb",
118
+ installCommand: ["add", "-d"]
119
+ },
120
+ npm: {
121
+ name: "npm",
122
+ lockFile: "package-lock.json",
123
+ installCommand: ["install", "--save-dev"]
124
+ }
125
+ };
126
+ /**
127
+ * Detects the active package manager for the given directory.
128
+ * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
129
+ * Falls back to `npm` when no signal is found.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
134
+ * detectPackageManager() // falls back to npm when no lock file is found
135
+ * ```
136
+ */
137
+ function detectPackageManager(cwd = process.cwd()) {
138
+ const packageJsonPath = join(cwd, "package.json");
139
+ if (existsSync(packageJsonPath)) try {
140
+ const pmField = JSON.parse(readFileSync(packageJsonPath, "utf-8")).packageManager;
141
+ if (typeof pmField === "string") {
142
+ const name = pmField.split("@")[0];
143
+ if (name && name in packageManagers) return packageManagers[name];
144
+ }
145
+ } catch {}
146
+ for (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;
147
+ return packageManagers.npm;
148
+ }
149
+ //#endregion
150
+ export { linters as i, detectTool as n, formatters as r, detectPackageManager as t };
151
+
152
+ //# sourceMappingURL=tools-BU99bhi8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-BU99bhi8.js","names":[],"sources":["../../../internals/utils/src/tools.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * CLI command descriptors for each supported code formatter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the formatter is not found.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const\n\n/**\n * CLI command descriptors for each supported linter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the linter is not found.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const\n\n/**\n * Resolves to `true` when running `tool --version` exits with code 0.\n */\nasync function isToolAvailable(tool: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(tool, ['--version'], { stdio: 'ignore' })\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.\n *\n * Availability is probed by running `<tool> --version` and checking for a zero exit code.\n *\n * @example\n * ```ts\n * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)\n * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)\n * ```\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const tool of candidates) {\n if (await isToolAvailable(tool)) {\n return tool\n }\n }\n\n return null\n}\n\n/**\n * Supported package manager identifiers.\n *\n * @example\n * ```ts\n * const pm: PackageManagerName = 'pnpm'\n * ```\n */\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/**\n * Metadata describing a package manager's lock file and install command.\n */\nexport interface PackageManagerInfo {\n /**\n * Identifier used in CLI commands, e.g. `pnpm`, `yarn`.\n */\n name: PackageManagerName\n /**\n * Lock file name that uniquely identifies this package manager in a project root.\n */\n lockFile: string\n /**\n * Subcommands passed to the package manager binary to install a dev dependency.\n */\n installCommand: ReadonlyArray<string>\n}\n\n/**\n * Metadata for each supported package manager, keyed by its short name.\n *\n * @example\n * ```ts\n * packageManagers.pnpm.installCommand // ['add', '-D']\n * packageManagers.npm.lockFile // 'package-lock.json'\n * ```\n */\nconst packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFile: 'pnpm-lock.yaml',\n installCommand: ['add', '-D'],\n },\n yarn: {\n name: 'yarn',\n lockFile: 'yarn.lock',\n installCommand: ['add', '-D'],\n },\n bun: {\n name: 'bun',\n lockFile: 'bun.lockb',\n installCommand: ['add', '-d'],\n },\n npm: {\n name: 'npm',\n lockFile: 'package-lock.json',\n installCommand: ['install', '--save-dev'],\n },\n}\n\n/**\n * Minimal shape of `package.json` fields read during detection.\n */\ntype PackageJson = {\n /**\n * The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`).\n */\n packageManager?: string\n}\n\n/**\n * Detects the active package manager for the given directory.\n * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n * Falls back to `npm` when no signal is found.\n *\n * @example\n * ```ts\n * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }\n * detectPackageManager() // falls back to npm when no lock file is found\n * ```\n */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = join(cwd, 'package.json')\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (existsSync(join(cwd, pm.lockFile))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;;;;;AASA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;AAKA,eAAe,gBAAgB,MAAgC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,MAAM,CAAC,WAAW,GAAG,EAAE,OAAO,SAAS,CAAC;EAC5D,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,CAAC,CAAC;EAC/C,MAAM,GAAG,eAAe,QAAQ,KAAK,CAAC;CACxC,CAAC;AACH;;;;;;;;;;;;AAaA,eAAsB,WAAiC,YAAyD;CAC9G,KAAK,MAAM,QAAQ,YACjB,IAAI,MAAM,gBAAgB,IAAI,GAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;AAuCA,MAAM,kBAAkE;CACtE,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,WAAW,YAAY;CAC1C;AACF;;;;;;;;;;;;AAuBA,SAAgB,qBAAqB,MAAc,QAAQ,IAAI,GAAuB;CACpF,MAAM,kBAAkB,KAAK,KAAK,cAAc;CAChD,IAAI,WAAW,eAAe,GAC5B,IAAI;EAEF,MAAM,UADc,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAC1C,CAAC,CAAC;EAC5B,IAAI,OAAO,YAAY,UAAU;GAC/B,MAAM,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC;GAChC,IAAI,QAAQ,QAAQ,iBAClB,OAAO,gBAAgB;EAE3B;CACF,QAAQ,CAER;CAGF,KAAK,MAAM,MAAM,OAAO,OAAO,eAAe,GAC5C,IAAI,WAAW,KAAK,KAAK,GAAG,QAAQ,CAAC,GACnC,OAAO;CAIX,OAAO,gBAAgB;AACzB"}
@@ -0,0 +1,175 @@
1
+ require("./chunk-Bx3C2hgW.cjs");
2
+ let node_child_process = require("node:child_process");
3
+ let node_fs = require("node:fs");
4
+ let node_path = require("node:path");
5
+ //#region ../../internals/utils/src/tools.ts
6
+ /**
7
+ * CLI command descriptors for each supported code formatter.
8
+ *
9
+ * Each entry contains the executable `command`, an `args` factory that maps an
10
+ * output path to the correct argument list, and an `errorMessage` shown when
11
+ * the formatter is not found.
12
+ */
13
+ const formatters = {
14
+ prettier: {
15
+ command: "prettier",
16
+ args: (outputPath) => [
17
+ "--ignore-unknown",
18
+ "--write",
19
+ outputPath
20
+ ],
21
+ errorMessage: "Prettier not found"
22
+ },
23
+ biome: {
24
+ command: "biome",
25
+ args: (outputPath) => [
26
+ "format",
27
+ "--write",
28
+ outputPath
29
+ ],
30
+ errorMessage: "Biome not found"
31
+ },
32
+ oxfmt: {
33
+ command: "oxfmt",
34
+ args: (outputPath) => [outputPath],
35
+ errorMessage: "Oxfmt not found"
36
+ }
37
+ };
38
+ /**
39
+ * CLI command descriptors for each supported linter.
40
+ *
41
+ * Each entry contains the executable `command`, an `args` factory that maps an
42
+ * output path to the correct argument list, and an `errorMessage` shown when
43
+ * the linter is not found.
44
+ */
45
+ const linters = {
46
+ eslint: {
47
+ command: "eslint",
48
+ args: (outputPath) => [outputPath, "--fix"],
49
+ errorMessage: "Eslint not found"
50
+ },
51
+ biome: {
52
+ command: "biome",
53
+ args: (outputPath) => [
54
+ "lint",
55
+ "--fix",
56
+ outputPath
57
+ ],
58
+ errorMessage: "Biome not found"
59
+ },
60
+ oxlint: {
61
+ command: "oxlint",
62
+ args: (outputPath) => [
63
+ "--fix",
64
+ "--no-ignore",
65
+ outputPath
66
+ ],
67
+ errorMessage: "Oxlint not found"
68
+ }
69
+ };
70
+ /**
71
+ * Resolves to `true` when running `tool --version` exits with code 0.
72
+ */
73
+ async function isToolAvailable(tool) {
74
+ return new Promise((resolve) => {
75
+ const child = (0, node_child_process.spawn)(tool, ["--version"], { stdio: "ignore" });
76
+ child.on("close", (code) => resolve(code === 0));
77
+ child.on("error", () => resolve(false));
78
+ });
79
+ }
80
+ /**
81
+ * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.
82
+ *
83
+ * Availability is probed by running `<tool> --version` and checking for a zero exit code.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)
88
+ * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)
89
+ * ```
90
+ */
91
+ async function detectTool(candidates) {
92
+ for (const tool of candidates) if (await isToolAvailable(tool)) return tool;
93
+ return null;
94
+ }
95
+ /**
96
+ * Metadata for each supported package manager, keyed by its short name.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * packageManagers.pnpm.installCommand // ['add', '-D']
101
+ * packageManagers.npm.lockFile // 'package-lock.json'
102
+ * ```
103
+ */
104
+ const packageManagers = {
105
+ pnpm: {
106
+ name: "pnpm",
107
+ lockFile: "pnpm-lock.yaml",
108
+ installCommand: ["add", "-D"]
109
+ },
110
+ yarn: {
111
+ name: "yarn",
112
+ lockFile: "yarn.lock",
113
+ installCommand: ["add", "-D"]
114
+ },
115
+ bun: {
116
+ name: "bun",
117
+ lockFile: "bun.lockb",
118
+ installCommand: ["add", "-d"]
119
+ },
120
+ npm: {
121
+ name: "npm",
122
+ lockFile: "package-lock.json",
123
+ installCommand: ["install", "--save-dev"]
124
+ }
125
+ };
126
+ /**
127
+ * Detects the active package manager for the given directory.
128
+ * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
129
+ * Falls back to `npm` when no signal is found.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
134
+ * detectPackageManager() // falls back to npm when no lock file is found
135
+ * ```
136
+ */
137
+ function detectPackageManager(cwd = process.cwd()) {
138
+ const packageJsonPath = (0, node_path.join)(cwd, "package.json");
139
+ if ((0, node_fs.existsSync)(packageJsonPath)) try {
140
+ const pmField = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")).packageManager;
141
+ if (typeof pmField === "string") {
142
+ const name = pmField.split("@")[0];
143
+ if (name && name in packageManagers) return packageManagers[name];
144
+ }
145
+ } catch {}
146
+ for (const pm of Object.values(packageManagers)) if ((0, node_fs.existsSync)((0, node_path.join)(cwd, pm.lockFile))) return pm;
147
+ return packageManagers.npm;
148
+ }
149
+ //#endregion
150
+ Object.defineProperty(exports, "detectPackageManager", {
151
+ enumerable: true,
152
+ get: function() {
153
+ return detectPackageManager;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "detectTool", {
157
+ enumerable: true,
158
+ get: function() {
159
+ return detectTool;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "formatters", {
163
+ enumerable: true,
164
+ get: function() {
165
+ return formatters;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "linters", {
169
+ enumerable: true,
170
+ get: function() {
171
+ return linters;
172
+ }
173
+ });
174
+
175
+ //# sourceMappingURL=tools-_Xp8-_zy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-_Xp8-_zy.cjs","names":[],"sources":["../../../internals/utils/src/tools.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\n/**\n * CLI command descriptors for each supported code formatter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the formatter is not found.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const\n\n/**\n * CLI command descriptors for each supported linter.\n *\n * Each entry contains the executable `command`, an `args` factory that maps an\n * output path to the correct argument list, and an `errorMessage` shown when\n * the linter is not found.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const\n\n/**\n * Resolves to `true` when running `tool --version` exits with code 0.\n */\nasync function isToolAvailable(tool: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(tool, ['--version'], { stdio: 'ignore' })\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed tool from `candidates`, checked in order, or `null` when none are found.\n *\n * Availability is probed by running `<tool> --version` and checking for a zero exit code.\n *\n * @example\n * ```ts\n * const formatter = await detectTool(['oxfmt', 'biome', 'prettier'] as const)\n * const linter = await detectTool(['oxlint', 'biome', 'eslint'] as const)\n * ```\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const tool of candidates) {\n if (await isToolAvailable(tool)) {\n return tool\n }\n }\n\n return null\n}\n\n/**\n * Supported package manager identifiers.\n *\n * @example\n * ```ts\n * const pm: PackageManagerName = 'pnpm'\n * ```\n */\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/**\n * Metadata describing a package manager's lock file and install command.\n */\nexport interface PackageManagerInfo {\n /**\n * Identifier used in CLI commands, e.g. `pnpm`, `yarn`.\n */\n name: PackageManagerName\n /**\n * Lock file name that uniquely identifies this package manager in a project root.\n */\n lockFile: string\n /**\n * Subcommands passed to the package manager binary to install a dev dependency.\n */\n installCommand: ReadonlyArray<string>\n}\n\n/**\n * Metadata for each supported package manager, keyed by its short name.\n *\n * @example\n * ```ts\n * packageManagers.pnpm.installCommand // ['add', '-D']\n * packageManagers.npm.lockFile // 'package-lock.json'\n * ```\n */\nconst packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFile: 'pnpm-lock.yaml',\n installCommand: ['add', '-D'],\n },\n yarn: {\n name: 'yarn',\n lockFile: 'yarn.lock',\n installCommand: ['add', '-D'],\n },\n bun: {\n name: 'bun',\n lockFile: 'bun.lockb',\n installCommand: ['add', '-d'],\n },\n npm: {\n name: 'npm',\n lockFile: 'package-lock.json',\n installCommand: ['install', '--save-dev'],\n },\n}\n\n/**\n * Minimal shape of `package.json` fields read during detection.\n */\ntype PackageJson = {\n /**\n * The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`).\n */\n packageManager?: string\n}\n\n/**\n * Detects the active package manager for the given directory.\n * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.\n * Falls back to `npm` when no signal is found.\n *\n * @example\n * ```ts\n * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }\n * detectPackageManager() // falls back to npm when no lock file is found\n * ```\n */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = join(cwd, 'package.json')\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (existsSync(join(cwd, pm.lockFile))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;;;;;AASA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;AAKA,eAAe,gBAAgB,MAAgC;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAAA,GAAA,mBAAA,MAAA,CAAc,MAAM,CAAC,WAAW,GAAG,EAAE,OAAO,SAAS,CAAC;EAC5D,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,CAAC,CAAC;EAC/C,MAAM,GAAG,eAAe,QAAQ,KAAK,CAAC;CACxC,CAAC;AACH;;;;;;;;;;;;AAaA,eAAsB,WAAiC,YAAyD;CAC9G,KAAK,MAAM,QAAQ,YACjB,IAAI,MAAM,gBAAgB,IAAI,GAC5B,OAAO;CAIX,OAAO;AACT;;;;;;;;;;AAuCA,MAAM,kBAAkE;CACtE,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,MAAM;EACJ,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,OAAO,IAAI;CAC9B;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,gBAAgB,CAAC,WAAW,YAAY;CAC1C;AACF;;;;;;;;;;;;AAuBA,SAAgB,qBAAqB,MAAc,QAAQ,IAAI,GAAuB;CACpF,MAAM,mBAAA,GAAA,UAAA,KAAA,CAAuB,KAAK,cAAc;CAChD,KAAA,GAAA,QAAA,WAAA,CAAe,eAAe,GAC5B,IAAI;EAEF,MAAM,UADc,KAAK,OAAA,GAAA,QAAA,aAAA,CAAmB,iBAAiB,OAAO,CAC1C,CAAC,CAAC;EAC5B,IAAI,OAAO,YAAY,UAAU;GAC/B,MAAM,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC;GAChC,IAAI,QAAQ,QAAQ,iBAClB,OAAO,gBAAgB;EAE3B;CACF,QAAQ,CAER;CAGF,KAAK,MAAM,MAAM,OAAO,OAAO,eAAe,GAC5C,KAAA,GAAA,QAAA,WAAA,EAAA,GAAA,UAAA,KAAA,CAAoB,KAAK,GAAG,QAAQ,CAAC,GACnC,OAAO;CAIX,OAAO,gBAAgB;AACzB"}
@@ -1,6 +1,6 @@
1
1
  import "./chunk-C0LytTxp.js";
2
2
  import { n as defineCommand } from "./define-C63T4jp6.js";
3
- import { t as version } from "./package-DJCeuUrP.js";
3
+ import { t as version } from "./package-scFCPMiP.js";
4
4
  //#region src/commands/validate.ts
5
5
  const command = defineCommand({
6
6
  name: "validate",
@@ -13,7 +13,7 @@ const command = defineCommand({
13
13
  required: true
14
14
  } },
15
15
  async run({ values }) {
16
- const { run } = await import("./run-C7cr0qhi.js");
16
+ const { run } = await import("./run-CUkZ6gnP.js");
17
17
  await run({
18
18
  input: values.input,
19
19
  version
@@ -23,4 +23,4 @@ const command = defineCommand({
23
23
  //#endregion
24
24
  export { command };
25
25
 
26
- //# sourceMappingURL=validate-DNzxpCMJ.js.map
26
+ //# sourceMappingURL=validate-BtKwM4zb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-DNzxpCMJ.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;EAAQ,CAAC;CAC5C;AACF,CAAC"}
1
+ {"version":3,"file":"validate-BtKwM4zb.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;EAAQ,CAAC;CAC5C;AACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  require("./chunk-Bx3C2hgW.cjs");
2
2
  const require_define = require("./define-C4AB3POr.cjs");
3
- const require_package = require("./package-C5Egcs3F.cjs");
3
+ const require_package = require("./package-dLlE0LgE.cjs");
4
4
  //#region src/commands/validate.ts
5
5
  const command = require_define.defineCommand({
6
6
  name: "validate",
@@ -13,7 +13,7 @@ const command = require_define.defineCommand({
13
13
  required: true
14
14
  } },
15
15
  async run({ values }) {
16
- const { run } = await Promise.resolve().then(() => require("./run-DMWGLJUx.cjs"));
16
+ const { run } = await Promise.resolve().then(() => require("./run-Bj64iPU_.cjs"));
17
17
  await run({
18
18
  input: values.input,
19
19
  version: require_package.version
@@ -23,4 +23,4 @@ const command = require_define.defineCommand({
23
23
  //#endregion
24
24
  exports.command = command;
25
25
 
26
- //# sourceMappingURL=validate-CiL4bco7.cjs.map
26
+ //# sourceMappingURL=validate-Cj5IIh1M.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-CiL4bco7.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;EAAQ,CAAC;CAC5C;AACF,CAAC"}
1
+ {"version":3,"file":"validate-Cj5IIh1M.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;EAAQ,CAAC;CAC5C;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "5.0.0-beta.53",
3
+ "version": "5.0.0-beta.55",
4
4
  "description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, and kubb mcp to manage the full code generation lifecycle from OpenAPI/Swagger specs.",
5
5
  "keywords": [
6
6
  "cli",
@@ -52,16 +52,16 @@
52
52
  "cosmiconfig": "^9.0.2",
53
53
  "jiti": "^2.7.0",
54
54
  "tinyexec": "~1.1.2",
55
- "@kubb/core": "5.0.0-beta.53"
55
+ "@kubb/core": "5.0.0-beta.55"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@internals/shared": "0.0.0",
59
59
  "@internals/utils": "0.0.0",
60
- "@kubb/adapter-oas": "5.0.0-beta.53"
60
+ "@kubb/adapter-oas": "5.0.0-beta.55"
61
61
  },
62
62
  "peerDependencies": {
63
- "@kubb/adapter-oas": "5.0.0-beta.53",
64
- "@kubb/mcp": "5.0.0-beta.53"
63
+ "@kubb/adapter-oas": "5.0.0-beta.55",
64
+ "@kubb/mcp": "5.0.0-beta.55"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@kubb/adapter-oas": {
package/src/Telemetry.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { randomBytes } from 'node:crypto'
2
2
  import os from 'node:os'
3
3
  import process from 'node:process'
4
- import { executeIfOnline, getRuntimeName, getRuntimeVersion, isCIEnvironment, type RuntimeName } from '@internals/utils'
4
+ import { isCIEnvironment, runtime } from '@internals/utils'
5
5
  import { OTLP_ENDPOINT } from './constants.ts'
6
6
 
7
7
  // OpenTelemetry OTLP JSON types
@@ -117,7 +117,7 @@ export type TelemetryEvent = {
117
117
  /**
118
118
  * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.
119
119
  */
120
- runtime: RuntimeName
120
+ runtime: string
121
121
  /**
122
122
  * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.
123
123
  */
@@ -139,7 +139,7 @@ export class Telemetry {
139
139
  /**
140
140
  * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
141
141
  */
142
- static isDisabled(): boolean {
142
+ static get isDisabled(): boolean {
143
143
  return (
144
144
  process.env['DO_NOT_TRACK'] === '1' ||
145
145
  process.env['DO_NOT_TRACK'] === 'true' ||
@@ -166,8 +166,8 @@ export class Telemetry {
166
166
  command: options.command,
167
167
  kubbVersion: options.kubbVersion,
168
168
  nodeVersion: process.versions.node.split('.')[0] as string,
169
- runtime: getRuntimeName(),
170
- runtimeVersion: getRuntimeVersion().split('.')[0] as string,
169
+ runtime: runtime.name,
170
+ runtimeVersion: runtime.version.split('.')[0] as string,
171
171
  platform: os.platform(),
172
172
  ci: isCIEnvironment(),
173
173
  plugins: options.plugins ?? [],
@@ -266,25 +266,23 @@ export class Telemetry {
266
266
  * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
267
267
  */
268
268
  static async send(event: TelemetryEvent): Promise<void> {
269
- if (Telemetry.isDisabled()) {
269
+ if (Telemetry.isDisabled) {
270
270
  return
271
271
  }
272
272
 
273
- await executeIfOnline(async () => {
274
- try {
275
- await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
276
- method: 'POST',
277
- headers: {
278
- 'Content-Type': 'application/json',
279
- 'Kubb-Telemetry-Version': '1',
280
- 'Kubb-Telemetry-Source': 'kubb-core',
281
- },
282
- body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
283
- signal: AbortSignal.timeout(5_000),
284
- })
285
- } catch (_e) {
286
- // Fail silently, telemetry must never break the run
287
- }
288
- })
273
+ try {
274
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
275
+ method: 'POST',
276
+ headers: {
277
+ 'Content-Type': 'application/json',
278
+ 'Kubb-Telemetry-Version': '1',
279
+ 'Kubb-Telemetry-Source': 'kubb-core',
280
+ },
281
+ body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
282
+ signal: AbortSignal.timeout(5_000),
283
+ })
284
+ } catch (_e) {
285
+ // Fail silently, telemetry must never break the run
286
+ }
289
287
  }
290
288
  }
@@ -45,11 +45,6 @@ export const command = defineCommand({
45
45
  hint: 'cli|json|file',
46
46
  enum: ['cli', 'json', 'file'],
47
47
  },
48
- 'no-cache': {
49
- type: 'boolean',
50
- description: 'Disable the incremental build cache and force a full regeneration',
51
- default: false,
52
- },
53
48
  },
54
49
  async run({ values, positionals }) {
55
50
  const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
@@ -65,7 +60,6 @@ export const command = defineCommand({
65
60
  logLevel,
66
61
  watch: values.watch,
67
62
  reporters,
68
- noCache: values['no-cache'],
69
63
  })
70
64
  },
71
65
  })
package/src/constants.ts CHANGED
@@ -16,4 +16,4 @@ export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
16
16
  /**
17
17
  * Flags that short-circuit execution (help/version), no telemetry notice is shown.
18
18
  */
19
- export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
19
+ export const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])
package/src/index.ts CHANGED
@@ -1,31 +1,14 @@
1
1
  import { styleText } from 'node:util'
2
- import { createCLI, isFlag } from '@internals/utils'
2
+ import { createCLI } from '@internals/utils'
3
3
  import { Telemetry } from './Telemetry.ts'
4
4
  import { version } from '../package.json'
5
5
  import { QUIET_FLAGS } from './constants.ts'
6
6
 
7
7
  const cli = createCLI()
8
-
9
- function shouldShowTelemetryNotice(argv: Array<string>): boolean {
10
- if (Telemetry.isDisabled()) {
11
- return false
12
- }
13
-
14
- // Skip when the user is just asking for help or version info
15
- if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {
16
- return false
17
- }
18
-
19
- // Skip in non-interactive / scripting contexts
20
- if (!process.stdout.isTTY) {
21
- return false
22
- }
23
-
24
- return true
25
- }
26
-
27
8
  export async function run(argv: Array<string> = process.argv): Promise<void> {
28
- if (shouldShowTelemetryNotice(argv)) {
9
+ const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))
10
+
11
+ if (!Telemetry.isDisabled && !isQuietFlag) {
29
12
  console.log(
30
13
  `${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`,
31
14
  )