@kubb/cli 5.0.6 → 5.2.0

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 (101) hide show
  1. package/README.md +66 -0
  2. package/dist/{Telemetry-Fiymfxez.js → Telemetry-BCTY-Nzq.js} +3 -49
  3. package/dist/Telemetry-BCTY-Nzq.js.map +1 -0
  4. package/dist/{Telemetry-D-Jpt27O.cjs → Telemetry-DKfJQxnC.cjs} +8 -60
  5. package/dist/Telemetry-DKfJQxnC.cjs.map +1 -0
  6. package/dist/constants-CdxpgX3_.cjs +115 -0
  7. package/dist/constants-CdxpgX3_.cjs.map +1 -0
  8. package/dist/constants-DHRspBTo.js +92 -0
  9. package/dist/constants-DHRspBTo.js.map +1 -0
  10. package/dist/env-DHaFBZTX.cjs +82 -0
  11. package/dist/env-DHaFBZTX.cjs.map +1 -0
  12. package/dist/env-DqPKEL59.js +59 -0
  13. package/dist/env-DqPKEL59.js.map +1 -0
  14. package/dist/{errors-CZtH2dKk.cjs → errors-C-wEou02.cjs} +2 -19
  15. package/dist/errors-C-wEou02.cjs.map +1 -0
  16. package/dist/errors-C8yNfV7w.js +20 -0
  17. package/dist/errors-C8yNfV7w.js.map +1 -0
  18. package/dist/{generate-DcEkxx4R.cjs → generate-Btnbf2_0.cjs} +9 -6
  19. package/dist/generate-Btnbf2_0.cjs.map +1 -0
  20. package/dist/{generate-FtWB7SiZ.js → generate-PT8_WDJZ.js} +9 -6
  21. package/dist/generate-PT8_WDJZ.js.map +1 -0
  22. package/dist/index.cjs +14 -9
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +2 -3
  25. package/dist/index.js +15 -10
  26. package/dist/index.js.map +1 -1
  27. package/dist/{init-ClG_bvAo.cjs → init-BwuaIvJr.cjs} +3 -3
  28. package/dist/{init-ClG_bvAo.cjs.map → init-BwuaIvJr.cjs.map} +1 -1
  29. package/dist/{init-B5G3LIla.js → init-dkS7T-wO.js} +3 -3
  30. package/dist/{init-B5G3LIla.js.map → init-dkS7T-wO.js.map} +1 -1
  31. package/dist/{mcp-DOHymcpS.js → mcp-B-GxGgVr.js} +8 -10
  32. package/dist/mcp-B-GxGgVr.js.map +1 -0
  33. package/dist/{mcp-ESVy9meL.cjs → mcp-B3B-rE7W.cjs} +8 -10
  34. package/dist/mcp-B3B-rE7W.cjs.map +1 -0
  35. package/dist/output-B2V2MN_C.cjs +137 -0
  36. package/dist/output-B2V2MN_C.cjs.map +1 -0
  37. package/dist/output-LZvrgF3z.js +89 -0
  38. package/dist/output-LZvrgF3z.js.map +1 -0
  39. package/dist/package-CrOAfe1h.js +6 -0
  40. package/dist/package-CrOAfe1h.js.map +1 -0
  41. package/dist/{package-CPbMhmPi.cjs → package-Dzjrfs0O.cjs} +2 -2
  42. package/dist/package-Dzjrfs0O.cjs.map +1 -0
  43. package/dist/{run-DSgLksGj.js → run-BzvsJ0Ek.js} +80 -112
  44. package/dist/run-BzvsJ0Ek.js.map +1 -0
  45. package/dist/run-CHfPmjaA.cjs +283 -0
  46. package/dist/run-CHfPmjaA.cjs.map +1 -0
  47. package/dist/{run-FPqeAEF4.cjs → run-DRBqVXX0.cjs} +93 -125
  48. package/dist/run-DRBqVXX0.cjs.map +1 -0
  49. package/dist/{run-ChKPZlIB.js → run-DReizVV9.js} +15 -4
  50. package/dist/run-DReizVV9.js.map +1 -0
  51. package/dist/run-DUY0lV8l.js +499 -0
  52. package/dist/run-DUY0lV8l.js.map +1 -0
  53. package/dist/run-DXPXPj4B.js +281 -0
  54. package/dist/run-DXPXPj4B.js.map +1 -0
  55. package/dist/{run-DCfdTu52.js → run-DvRhuqUM.js} +11 -4
  56. package/dist/run-DvRhuqUM.js.map +1 -0
  57. package/dist/run-Wkl7oK6Q.cjs +502 -0
  58. package/dist/run-Wkl7oK6Q.cjs.map +1 -0
  59. package/dist/{run-BV2tMjuz.cjs → run-aIkuYiQ6.cjs} +15 -4
  60. package/dist/run-aIkuYiQ6.cjs.map +1 -0
  61. package/dist/{run-Cs5FunVC.cjs → run-y7oTgJI3.cjs} +11 -4
  62. package/dist/run-y7oTgJI3.cjs.map +1 -0
  63. package/dist/studio-DKv2YLJZ.js +77 -0
  64. package/dist/studio-DKv2YLJZ.js.map +1 -0
  65. package/dist/studio-PDMxqFN0.cjs +76 -0
  66. package/dist/studio-PDMxqFN0.cjs.map +1 -0
  67. package/dist/{run-DzVVS0FV.cjs → utils-B0SrWoNh.cjs} +303 -323
  68. package/dist/utils-B0SrWoNh.cjs.map +1 -0
  69. package/dist/{run-D_TXufIV.js → utils-CzoNURwq.js} +274 -364
  70. package/dist/utils-CzoNURwq.js.map +1 -0
  71. package/dist/{validate-1sZ8wo6V.cjs → validate-BcB0tFQ6.cjs} +8 -13
  72. package/dist/validate-BcB0tFQ6.cjs.map +1 -0
  73. package/dist/{validate-DXT2hYwJ.js → validate-QpkCbIFJ.js} +8 -13
  74. package/dist/validate-QpkCbIFJ.js.map +1 -0
  75. package/package.json +15 -9
  76. package/dist/Telemetry-D-Jpt27O.cjs.map +0 -1
  77. package/dist/Telemetry-Fiymfxez.js.map +0 -1
  78. package/dist/errors-CMvLO2NE.js +0 -31
  79. package/dist/errors-CMvLO2NE.js.map +0 -1
  80. package/dist/errors-CZtH2dKk.cjs.map +0 -1
  81. package/dist/generate-DcEkxx4R.cjs.map +0 -1
  82. package/dist/generate-FtWB7SiZ.js.map +0 -1
  83. package/dist/mcp-DOHymcpS.js.map +0 -1
  84. package/dist/mcp-ESVy9meL.cjs.map +0 -1
  85. package/dist/package-BEDssgn1.js +0 -6
  86. package/dist/package-BEDssgn1.js.map +0 -1
  87. package/dist/package-CPbMhmPi.cjs.map +0 -1
  88. package/dist/run-BV2tMjuz.cjs.map +0 -1
  89. package/dist/run-ChKPZlIB.js.map +0 -1
  90. package/dist/run-Cs5FunVC.cjs.map +0 -1
  91. package/dist/run-DCfdTu52.js.map +0 -1
  92. package/dist/run-DSgLksGj.js.map +0 -1
  93. package/dist/run-D_TXufIV.js.map +0 -1
  94. package/dist/run-DzVVS0FV.cjs.map +0 -1
  95. package/dist/run-FPqeAEF4.cjs.map +0 -1
  96. package/dist/tools-DH1a7ZJH.js +0 -152
  97. package/dist/tools-DH1a7ZJH.js.map +0 -1
  98. package/dist/tools-bwKAf_r-.cjs +0 -175
  99. package/dist/tools-bwKAf_r-.cjs.map +0 -1
  100. package/dist/validate-1sZ8wo6V.cjs.map +0 -1
  101. package/dist/validate-DXT2hYwJ.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
+ const require_env = require("./env-DHaFBZTX.cjs");
3
+ let _clack_prompts = require("@clack/prompts");
4
+ _clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
5
+ //#region src/loggers/output.ts
6
+ /**
7
+ * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output
8
+ * and the hook output around it read as one stream.
9
+ */
10
+ const SYMBOLS = {
11
+ info: "ℹ",
12
+ warn: "⚠",
13
+ error: "✗",
14
+ step: "◇"
15
+ };
16
+ function write(level, message) {
17
+ if (require_env.isRichOutput()) {
18
+ _clack_prompts.log[level](message);
19
+ return;
20
+ }
21
+ console.log(`${SYMBOLS[level]} ${message}`);
22
+ }
23
+ /**
24
+ * Opens a command's output with its title.
25
+ */
26
+ function logIntro({ title, warning, block = true }) {
27
+ if (block && require_env.isRichOutput()) {
28
+ _clack_prompts.intro(title);
29
+ if (warning) _clack_prompts.log.warn(warning);
30
+ return;
31
+ }
32
+ console.log(title);
33
+ if (warning) console.warn(warning);
34
+ console.log();
35
+ }
36
+ /**
37
+ * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain
38
+ * output prints the text on its own.
39
+ */
40
+ function logOutro(text) {
41
+ if (require_env.isRichOutput()) {
42
+ _clack_prompts.outro(text);
43
+ return;
44
+ }
45
+ console.log(text);
46
+ }
47
+ /**
48
+ * Prints lines as one block, without a symbol in front of them.
49
+ */
50
+ function logBlock(lines) {
51
+ if (require_env.isRichOutput()) {
52
+ _clack_prompts.log.message(lines);
53
+ return;
54
+ }
55
+ console.log([lines].flat().join("\n"));
56
+ }
57
+ function logInfo(message) {
58
+ write("info", message);
59
+ }
60
+ function logWarn(message) {
61
+ write("warn", message);
62
+ }
63
+ function logError(message) {
64
+ write("error", message);
65
+ }
66
+ /**
67
+ * Reports a step the command is taking, rather than something it found.
68
+ */
69
+ function logStep(message) {
70
+ write("step", message);
71
+ }
72
+ /**
73
+ * A progress spinner, or a writer that prints each message it is given when the terminal cannot
74
+ * animate one. Callers drive both the same way.
75
+ */
76
+ function createSpinner() {
77
+ if (require_env.isRichOutput()) return _clack_prompts.spinner();
78
+ const print = (message) => {
79
+ if (message) console.log(message);
80
+ };
81
+ return {
82
+ start: print,
83
+ stop: print,
84
+ message: print
85
+ };
86
+ }
87
+ //#endregion
88
+ Object.defineProperty(exports, "createSpinner", {
89
+ enumerable: true,
90
+ get: function() {
91
+ return createSpinner;
92
+ }
93
+ });
94
+ Object.defineProperty(exports, "logBlock", {
95
+ enumerable: true,
96
+ get: function() {
97
+ return logBlock;
98
+ }
99
+ });
100
+ Object.defineProperty(exports, "logError", {
101
+ enumerable: true,
102
+ get: function() {
103
+ return logError;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, "logInfo", {
107
+ enumerable: true,
108
+ get: function() {
109
+ return logInfo;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, "logIntro", {
113
+ enumerable: true,
114
+ get: function() {
115
+ return logIntro;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, "logOutro", {
119
+ enumerable: true,
120
+ get: function() {
121
+ return logOutro;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, "logStep", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return logStep;
128
+ }
129
+ });
130
+ Object.defineProperty(exports, "logWarn", {
131
+ enumerable: true,
132
+ get: function() {
133
+ return logWarn;
134
+ }
135
+ });
136
+
137
+ //# sourceMappingURL=output-B2V2MN_C.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-B2V2MN_C.cjs","names":["isRichOutput","prompts"],"sources":["../src/loggers/output.ts"],"sourcesContent":["import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\n\n/**\n * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output\n * and the hook output around it read as one stream.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\ntype Level = keyof typeof SYMBOLS\n\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\ntype IntroOptions = {\n title: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output with its title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n console.log(title)\n\n if (warning) {\n console.warn(warning)\n }\n\n console.log()\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n if (isRichOutput()) {\n prompts.outro(text)\n\n return\n }\n\n console.log(text)\n}\n\n/**\n * Prints lines as one block, without a symbol in front of them.\n */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n\ntype Spinner = {\n start: (message?: string) => void\n stop: (message?: string, code?: number) => void\n message: (message?: string) => void\n}\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way.\n */\nexport function createSpinner(): Spinner {\n if (isRichOutput()) {\n return prompts.spinner()\n }\n\n const print = (message?: string) => {\n if (message) {\n console.log(message)\n }\n }\n\n return { start: print, stop: print, message: print }\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,UAAU;CAAE,MAAM;CAAK,MAAM;CAAK,OAAO;CAAK,MAAM;AAAI;AAI9D,SAAS,MAAM,OAAc,SAAuB;CAClD,IAAIA,YAAAA,aAAa,GAAG;EAClB,eAAQ,IAAI,MAAM,CAAC,OAAO;EAE1B;CACF;CAEA,QAAQ,IAAI,GAAG,QAAQ,OAAO,GAAG,SAAS;AAC5C;;;;AAoBA,SAAgB,SAAS,EAAE,OAAO,SAAS,QAAQ,QAA4B;CAC7E,IAAI,SAASA,YAAAA,aAAa,GAAG;EAC3B,eAAQ,MAAM,KAAK;EAEnB,IAAI,SACF,eAAQ,IAAI,KAAK,OAAO;EAG1B;CACF;CAEA,QAAQ,IAAI,KAAK;CAEjB,IAAI,SACF,QAAQ,KAAK,OAAO;CAGtB,QAAQ,IAAI;AACd;;;;;AAMA,SAAgB,SAAS,MAAoB;CAC3C,IAAIA,YAAAA,aAAa,GAAG;EAClB,eAAQ,MAAM,IAAI;EAElB;CACF;CAEA,QAAQ,IAAI,IAAI;AAClB;;;;AAKA,SAAgB,SAAS,OAAqC;CAC5D,IAAIA,YAAAA,aAAa,GAAG;EAClB,eAAQ,IAAI,QAAQ,KAAK;EAEzB;CACF;CAEA,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AACvC;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,SAAS,SAAuB;CAC9C,MAAM,SAAS,OAAO;AACxB;;;;AAKA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;;;;;AAYA,SAAgB,gBAAyB;CACvC,IAAIA,YAAAA,aAAa,GACf,OAAOC,eAAQ,QAAQ;CAGzB,MAAM,SAAS,YAAqB;EAClC,IAAI,SACF,QAAQ,IAAI,OAAO;CAEvB;CAEA,OAAO;EAAE,OAAO;EAAO,MAAM;EAAO,SAAS;CAAM;AACrD"}
@@ -0,0 +1,89 @@
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { r as isRichOutput } from "./env-DqPKEL59.js";
3
+ import * as prompts from "@clack/prompts";
4
+ //#region src/loggers/output.ts
5
+ /**
6
+ * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output
7
+ * and the hook output around it read as one stream.
8
+ */
9
+ const SYMBOLS = {
10
+ info: "ℹ",
11
+ warn: "⚠",
12
+ error: "✗",
13
+ step: "◇"
14
+ };
15
+ function write(level, message) {
16
+ if (isRichOutput()) {
17
+ prompts.log[level](message);
18
+ return;
19
+ }
20
+ console.log(`${SYMBOLS[level]} ${message}`);
21
+ }
22
+ /**
23
+ * Opens a command's output with its title.
24
+ */
25
+ function logIntro({ title, warning, block = true }) {
26
+ if (block && isRichOutput()) {
27
+ prompts.intro(title);
28
+ if (warning) prompts.log.warn(warning);
29
+ return;
30
+ }
31
+ console.log(title);
32
+ if (warning) console.warn(warning);
33
+ console.log();
34
+ }
35
+ /**
36
+ * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain
37
+ * output prints the text on its own.
38
+ */
39
+ function logOutro(text) {
40
+ if (isRichOutput()) {
41
+ prompts.outro(text);
42
+ return;
43
+ }
44
+ console.log(text);
45
+ }
46
+ /**
47
+ * Prints lines as one block, without a symbol in front of them.
48
+ */
49
+ function logBlock(lines) {
50
+ if (isRichOutput()) {
51
+ prompts.log.message(lines);
52
+ return;
53
+ }
54
+ console.log([lines].flat().join("\n"));
55
+ }
56
+ function logInfo(message) {
57
+ write("info", message);
58
+ }
59
+ function logWarn(message) {
60
+ write("warn", message);
61
+ }
62
+ function logError(message) {
63
+ write("error", message);
64
+ }
65
+ /**
66
+ * Reports a step the command is taking, rather than something it found.
67
+ */
68
+ function logStep(message) {
69
+ write("step", message);
70
+ }
71
+ /**
72
+ * A progress spinner, or a writer that prints each message it is given when the terminal cannot
73
+ * animate one. Callers drive both the same way.
74
+ */
75
+ function createSpinner() {
76
+ if (isRichOutput()) return prompts.spinner();
77
+ const print = (message) => {
78
+ if (message) console.log(message);
79
+ };
80
+ return {
81
+ start: print,
82
+ stop: print,
83
+ message: print
84
+ };
85
+ }
86
+ //#endregion
87
+ export { logIntro as a, logWarn as c, logInfo as i, logBlock as n, logOutro as o, logError as r, logStep as s, createSpinner as t };
88
+
89
+ //# sourceMappingURL=output-LZvrgF3z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-LZvrgF3z.js","names":[],"sources":["../src/loggers/output.ts"],"sourcesContent":["import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\n\n/**\n * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output\n * and the hook output around it read as one stream.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\ntype Level = keyof typeof SYMBOLS\n\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\ntype IntroOptions = {\n title: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output with its title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n console.log(title)\n\n if (warning) {\n console.warn(warning)\n }\n\n console.log()\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n if (isRichOutput()) {\n prompts.outro(text)\n\n return\n }\n\n console.log(text)\n}\n\n/**\n * Prints lines as one block, without a symbol in front of them.\n */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n\ntype Spinner = {\n start: (message?: string) => void\n stop: (message?: string, code?: number) => void\n message: (message?: string) => void\n}\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way.\n */\nexport function createSpinner(): Spinner {\n if (isRichOutput()) {\n return prompts.spinner()\n }\n\n const print = (message?: string) => {\n if (message) {\n console.log(message)\n }\n }\n\n return { start: print, stop: print, message: print }\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,UAAU;CAAE,MAAM;CAAK,MAAM;CAAK,OAAO;CAAK,MAAM;AAAI;AAI9D,SAAS,MAAM,OAAc,SAAuB;CAClD,IAAI,aAAa,GAAG;EAClB,QAAQ,IAAI,MAAM,CAAC,OAAO;EAE1B;CACF;CAEA,QAAQ,IAAI,GAAG,QAAQ,OAAO,GAAG,SAAS;AAC5C;;;;AAoBA,SAAgB,SAAS,EAAE,OAAO,SAAS,QAAQ,QAA4B;CAC7E,IAAI,SAAS,aAAa,GAAG;EAC3B,QAAQ,MAAM,KAAK;EAEnB,IAAI,SACF,QAAQ,IAAI,KAAK,OAAO;EAG1B;CACF;CAEA,QAAQ,IAAI,KAAK;CAEjB,IAAI,SACF,QAAQ,KAAK,OAAO;CAGtB,QAAQ,IAAI;AACd;;;;;AAMA,SAAgB,SAAS,MAAoB;CAC3C,IAAI,aAAa,GAAG;EAClB,QAAQ,MAAM,IAAI;EAElB;CACF;CAEA,QAAQ,IAAI,IAAI;AAClB;;;;AAKA,SAAgB,SAAS,OAAqC;CAC5D,IAAI,aAAa,GAAG;EAClB,QAAQ,IAAI,QAAQ,KAAK;EAEzB;CACF;CAEA,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AACvC;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,SAAS,SAAuB;CAC9C,MAAM,SAAS,OAAO;AACxB;;;;AAKA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;;;;;AAYA,SAAgB,gBAAyB;CACvC,IAAI,aAAa,GACf,OAAO,QAAQ,QAAQ;CAGzB,MAAM,SAAS,YAAqB;EAClC,IAAI,SACF,QAAQ,IAAI,OAAO;CAEvB;CAEA,OAAO;EAAE,OAAO;EAAO,MAAM;EAAO,SAAS;CAAM;AACrD"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "5.2.0";
3
+ //#endregion
4
+ export { version as t };
5
+
6
+ //# sourceMappingURL=package-CrOAfe1h.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-CrOAfe1h.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "5.0.6";
2
+ var version = "5.2.0";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "version", {
8
8
  }
9
9
  });
10
10
 
11
- //# sourceMappingURL=package-CPbMhmPi.cjs.map
11
+ //# sourceMappingURL=package-Dzjrfs0O.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-Dzjrfs0O.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,100 +1,12 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { t as detectPackageManager } from "./tools-DH1a7ZJH.js";
2
+ import { a as logIntro, c as logWarn, i as logInfo, o as logOutro, r as logError, t as createSpinner } from "./output-LZvrgF3z.js";
3
+ import { i as initDefaults, n as KUBB_PACKAGE_NAME, r as availablePlugins, t as KUBB_CONFIG_FILENAME } from "./constants-DHRspBTo.js";
3
4
  import { styleText } from "node:util";
4
- import process from "node:process";
5
- import path from "node:path";
6
- import fs from "node:fs";
5
+ import process$1 from "node:process";
6
+ import path, { join } from "node:path";
7
+ import fs, { existsSync, readFileSync } from "node:fs";
7
8
  import * as clack from "@clack/prompts";
8
9
  import { x } from "tinyexec";
9
- //#region ../../internals/shared/src/constants.ts
10
- const KUBB_CONFIG_FILENAME = "kubb.config.ts";
11
- const KUBB_PACKAGE_NAME = "kubb";
12
- const initDefaults = {
13
- inputPath: "./openapi.yaml",
14
- outputPath: "./src/gen",
15
- plugins: ["plugin-ts"]
16
- };
17
- const availablePlugins = [
18
- {
19
- value: "plugin-ts",
20
- label: "TypeScript",
21
- hint: "Recommended",
22
- packageName: "@kubb/plugin-ts",
23
- importName: "pluginTs",
24
- category: "types"
25
- },
26
- {
27
- value: "plugin-axios",
28
- label: "Axios Client",
29
- packageName: "@kubb/plugin-axios",
30
- importName: "pluginAxios",
31
- category: "client"
32
- },
33
- {
34
- value: "plugin-fetch",
35
- label: "Fetch Client",
36
- packageName: "@kubb/plugin-fetch",
37
- importName: "pluginFetch",
38
- category: "client"
39
- },
40
- {
41
- value: "plugin-react-query",
42
- label: "React Query / TanStack Query",
43
- packageName: "@kubb/plugin-react-query",
44
- importName: "pluginReactQuery",
45
- category: "framework"
46
- },
47
- {
48
- value: "plugin-vue-query",
49
- label: "Vue Query",
50
- packageName: "@kubb/plugin-vue-query",
51
- importName: "pluginVueQuery",
52
- category: "framework"
53
- },
54
- {
55
- value: "plugin-zod",
56
- label: "Zod Schemas",
57
- packageName: "@kubb/plugin-zod",
58
- importName: "pluginZod",
59
- category: "validation"
60
- },
61
- {
62
- value: "plugin-faker",
63
- label: "Faker.js Mocks",
64
- packageName: "@kubb/plugin-faker",
65
- importName: "pluginFaker",
66
- category: "mocks"
67
- },
68
- {
69
- value: "plugin-msw",
70
- label: "MSW Handlers",
71
- packageName: "@kubb/plugin-msw",
72
- importName: "pluginMsw",
73
- category: "mocks"
74
- },
75
- {
76
- value: "plugin-cypress",
77
- label: "Cypress Tests",
78
- packageName: "@kubb/plugin-cypress",
79
- importName: "pluginCypress",
80
- category: "testing"
81
- },
82
- {
83
- value: "plugin-mcp",
84
- label: "MCP Server (AI / Model Context Protocol)",
85
- packageName: "@kubb/plugin-mcp",
86
- importName: "pluginMcp",
87
- category: "ai"
88
- },
89
- {
90
- value: "plugin-redoc",
91
- label: "ReDoc Documentation",
92
- packageName: "@kubb/plugin-redoc",
93
- importName: "pluginRedoc",
94
- category: "documentation"
95
- }
96
- ];
97
- //#endregion
98
10
  //#region ../../internals/shared/src/init.ts
99
11
  /**
100
12
  * Resolves a comma-separated plugin flag (e.g. `--plugins plugin-ts,plugin-zod`) into the
@@ -135,11 +47,67 @@ function resolveInstallVersions({ packages, version }) {
135
47
  return packages.map((name) => name === "kubb" ? `${name}@${version}` : `${name}@${tag}`);
136
48
  }
137
49
  //#endregion
50
+ //#region src/tools.ts
51
+ /**
52
+ * Metadata for each supported package manager, keyed by its short name.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * packageManagers.pnpm.installCommand // ['add', '-D']
57
+ * packageManagers.npm.lockFile // 'package-lock.json'
58
+ * ```
59
+ */
60
+ const packageManagers = {
61
+ pnpm: {
62
+ name: "pnpm",
63
+ lockFile: "pnpm-lock.yaml",
64
+ installCommand: ["add", "-D"]
65
+ },
66
+ yarn: {
67
+ name: "yarn",
68
+ lockFile: "yarn.lock",
69
+ installCommand: ["add", "-D"]
70
+ },
71
+ bun: {
72
+ name: "bun",
73
+ lockFile: "bun.lockb",
74
+ installCommand: ["add", "-d"]
75
+ },
76
+ npm: {
77
+ name: "npm",
78
+ lockFile: "package-lock.json",
79
+ installCommand: ["install", "--save-dev"]
80
+ }
81
+ };
82
+ /**
83
+ * Detects the active package manager for the given directory.
84
+ * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
85
+ * Falls back to `npm` when no signal is found.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
90
+ * detectPackageManager() // falls back to npm when no lock file is found
91
+ * ```
92
+ */
93
+ function detectPackageManager(cwd = process.cwd()) {
94
+ const packageJsonPath = join(cwd, "package.json");
95
+ if (existsSync(packageJsonPath)) try {
96
+ const pmField = JSON.parse(readFileSync(packageJsonPath, "utf-8")).packageManager;
97
+ if (typeof pmField === "string") {
98
+ const name = pmField.split("@")[0];
99
+ if (name && name in packageManagers) return packageManagers[name];
100
+ }
101
+ } catch {}
102
+ for (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;
103
+ return packageManagers.npm;
104
+ }
105
+ //#endregion
138
106
  //#region src/runners/init/utils.ts
139
107
  /**
140
108
  * Returns `true` when a `package.json` exists at `cwd`.
141
109
  */
142
- function hasPackageJson(cwd = process.cwd()) {
110
+ function hasPackageJson(cwd = process$1.cwd()) {
143
111
  return fs.existsSync(path.join(cwd, "package.json"));
144
112
  }
145
113
  /**
@@ -162,7 +130,7 @@ async function initPackageJson(cwd, packageManager) {
162
130
  /**
163
131
  * Installs the given packages at `cwd` using the detected package manager.
164
132
  */
165
- async function installPackages(packages, packageManager, cwd = process.cwd()) {
133
+ async function installPackages(packages, packageManager, cwd = process$1.cwd()) {
166
134
  await x(packageManager.name, [...packageManager.installCommand, ...packages], {
167
135
  nodeOptions: {
168
136
  cwd,
@@ -175,7 +143,7 @@ async function installPackages(packages, packageManager, cwd = process.cwd()) {
175
143
  //#region src/runners/init/run.ts
176
144
  function cancelAndExit(message = "Operation canceled.") {
177
145
  clack.cancel(message);
178
- process.exit(0);
146
+ process$1.exit(0);
179
147
  }
180
148
  /**
181
149
  * Runs the interactive Kubb scaffolding wizard.
@@ -183,19 +151,19 @@ function cancelAndExit(message = "Operation canceled.") {
183
151
  * Pass `yes: true` to skip all prompts and use defaults.
184
152
  */
185
153
  async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }) {
186
- const cwd = process.cwd();
187
- clack.intro(styleText("bgCyan", styleText("black", " Kubb Init ")));
154
+ const cwd = process$1.cwd();
155
+ logIntro({ title: styleText("bgCyan", styleText("black", " Kubb Init ")) });
188
156
  /**
189
157
  * Returns `flag` when provided, the `defaultValue` when `yes` is set,
190
158
  * or calls `prompt()` for interactive input. Exits on cancellation.
191
159
  */
192
160
  async function resolveOrPrompt(flag, defaultValue, logLabel, prompt) {
193
161
  if (flag !== void 0) {
194
- clack.log.info(`${logLabel}: ${styleText("cyan", String(flag))}`);
162
+ logInfo(`${logLabel}: ${styleText("cyan", String(flag))}`);
195
163
  return flag;
196
164
  }
197
165
  if (yes) {
198
- clack.log.info(`${logLabel}: ${styleText("cyan", String(defaultValue))}`);
166
+ logInfo(`${logLabel}: ${styleText("cyan", String(defaultValue))}`);
199
167
  return defaultValue;
200
168
  }
201
169
  const result = await prompt();
@@ -212,13 +180,13 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
212
180
  if (clack.isCancel(shouldInit) || !shouldInit) cancelAndExit();
213
181
  }
214
182
  const packageManager = detectPackageManager(cwd);
215
- const spinner = clack.spinner();
183
+ const spinner = createSpinner();
216
184
  spinner.start(`Initializing package.json with ${packageManager.name}`);
217
185
  await initPackageJson(cwd, packageManager);
218
186
  spinner.stop(`Created package.json with ${packageManager.name}`);
219
187
  }
220
188
  const packageManager = detectPackageManager(cwd);
221
- if (hasPackageJson(cwd)) clack.log.info(`Detected package manager: ${styleText("cyan", packageManager.name)}`);
189
+ if (hasPackageJson(cwd)) logInfo(`Detected package manager: ${styleText("cyan", packageManager.name)}`);
222
190
  const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, "Using input path", () => clack.text({
223
191
  message: "Where is your OpenAPI specification located?",
224
192
  placeholder: initDefaults.inputPath,
@@ -241,14 +209,14 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
241
209
  if (pluginsFlag) {
242
210
  const plugins = resolvePlugins(pluginsFlag);
243
211
  if (plugins.length === 0) {
244
- clack.log.warn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`);
212
+ logWarn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`);
245
213
  return defaultPlugins;
246
214
  }
247
- clack.log.info(`Using plugins: ${pluginLabel(plugins)}`);
215
+ logInfo(`Using plugins: ${pluginLabel(plugins)}`);
248
216
  return plugins;
249
217
  }
250
218
  if (yes) {
251
- clack.log.info(`Using plugins: ${pluginLabel(defaultPlugins)}`);
219
+ logInfo(`Using plugins: ${pluginLabel(defaultPlugins)}`);
252
220
  return defaultPlugins;
253
221
  }
254
222
  const values = await clack.multiselect({
@@ -268,7 +236,7 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
268
236
  packages: [KUBB_PACKAGE_NAME, ...selectedPlugins.map((p) => p.packageName)],
269
237
  version
270
238
  });
271
- const spinner = clack.spinner();
239
+ const spinner = createSpinner();
272
240
  spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`);
273
241
  try {
274
242
  await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` });
@@ -277,7 +245,7 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
277
245
  spinner.stop("Installation failed");
278
246
  throw error;
279
247
  }
280
- const configSpinner = clack.spinner();
248
+ const configSpinner = createSpinner();
281
249
  configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`);
282
250
  const configContent = generateConfigFile({
283
251
  selectedPlugins,
@@ -298,14 +266,14 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
298
266
  }
299
267
  await dryRun.run(() => fs.promises.writeFile(configPath, configContent, "utf-8"), { message: `write ${KUBB_CONFIG_FILENAME}` });
300
268
  configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`);
301
- clack.outro(styleText("green", "✓ All set!") + "\n\n" + styleText("dim", "Next steps:") + "\n" + styleText("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + styleText("cyan", " 2. Generate code with: npx kubb generate") + "\n" + styleText("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + styleText("dim", `Using ${packageManager.name} • Kubb v${version}`));
269
+ logOutro(styleText("green", "✓ All set!") + "\n\n" + styleText("dim", "Next steps:") + "\n" + styleText("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + styleText("cyan", " 2. Generate code with: npx kubb generate") + "\n" + styleText("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + styleText("dim", `Using ${packageManager.name} • Kubb v${version}`));
302
270
  } catch (error) {
303
- clack.log.error(styleText("red", "An error occurred during initialization"));
304
- if (error instanceof Error) clack.log.error(error.message);
305
- process.exit(1);
271
+ logError(styleText("red", "An error occurred during initialization"));
272
+ if (error instanceof Error) logError(error.message);
273
+ process$1.exit(1);
306
274
  }
307
275
  }
308
276
  //#endregion
309
277
  export { run };
310
278
 
311
- //# sourceMappingURL=run-DSgLksGj.js.map
279
+ //# sourceMappingURL=run-BzvsJ0Ek.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-BzvsJ0Ek.js","names":["process","process"],"sources":["../../../internals/shared/src/init.ts","../src/tools.ts","../src/runners/init/utils.ts","../src/runners/init/run.ts"],"sourcesContent":["import { availablePlugins, KUBB_PACKAGE_NAME } from './constants.ts'\nimport type { PluginOption } from './types.ts'\n\n/**\n * Resolves a comma-separated plugin flag (e.g. `--plugins plugin-ts,plugin-zod`) into the\n * matching known plugin options. Unrecognized names are dropped, and a missing flag yields\n * an empty list.\n */\nexport function resolvePlugins(pluginsFlag: string | undefined): Array<PluginOption> {\n if (!pluginsFlag) {\n return []\n }\n const requested = pluginsFlag\n .split(',')\n .map((value) => value.trim())\n .filter(Boolean)\n return availablePlugins.filter((plugin) => requested.includes(plugin.value))\n}\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: Array<PluginOption>\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins.map((plugin) => ` ${plugin.importName}(),`).join('\\n')\n\n return `import { defineConfig } from 'kubb/config'\n${imports}\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n\n/**\n * Turns package names into install specifiers for the wizard.\n *\n * `kubb` is pinned to the exact version of the running CLI, since both ship from the same release\n * and resolving `kubb@beta` separately can land on a different version than the CLI doing the\n * scaffolding. Plugins release from their own repo on their own cadence, so they follow the\n * release channel of the CLI through its dist-tag.\n */\nexport function resolveInstallVersions({ packages, version }: { packages: Array<string>; version: string }): Array<string> {\n const prerelease = version.match(/-([a-z]+)/)?.[1]\n const tag = prerelease ?? 'latest'\n\n return packages.map((name) => (name === KUBB_PACKAGE_NAME ? `${name}@${version}` : `${name}@${tag}`))\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { formatters, linters } from '@internals/utils'\nimport type { Config } from '@kubb/core'\n\n/**\n * The configurable formatter names, mirrored from `Config['output'].format`. Excludes `'auto'`\n * (detection, not a tool) and `false` (skip). The `formatters`/`linters` tables below are pinned to\n * these so adding a tool to the config union without a descriptor fails to compile.\n */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned to core's union here rather than in `@internals/utils`, which must not import `@kubb/core`:\n// adding a tool to the config union without a descriptor stays a compile error.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\nexport { detectTool, formatters, linters } from '@internals/utils'\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","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { x } from 'tinyexec'\nimport type { PackageManagerInfo, PackageManagerName } from '../../tools.ts'\n\n/**\n * Returns `true` when a `package.json` exists at `cwd`.\n */\nexport function hasPackageJson(cwd: string = process.cwd()): boolean {\n return fs.existsSync(path.join(cwd, 'package.json'))\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n const commands: Record<PackageManagerName, Array<string>> = {\n npm: ['init', '-y'],\n pnpm: ['init'],\n yarn: ['init', '-y'],\n bun: ['init', '-y'],\n }\n\n await x(packageManager.name, commands[packageManager.name], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/**\n * Installs the given packages at `cwd` using the detected package manager.\n */\nexport async function installPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n await x(packageManager.name, [...packageManager.installCommand, ...packages], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport {\n availablePlugins,\n generateConfigFile,\n initDefaults,\n KUBB_CONFIG_FILENAME,\n KUBB_PACKAGE_NAME,\n type PluginOption,\n resolveInstallVersions,\n resolvePlugins,\n} from '@internals/shared'\nimport { createSpinner, logError, logInfo, logIntro, logOutro, logWarn } from '../../loggers/output.ts'\nimport { hasPackageJson, initPackageJson, installPackages } from './utils.ts'\nimport { detectPackageManager } from '../../tools.ts'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses default values.\n */\n yes: boolean\n /**\n * Current `@kubb/cli` version string, shown in the closing outro.\n */\n version: string\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,plugin-zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation and the\n * config file write are skipped.\n */\n dryRun: DryRunExtension\n}\n\n/**\n * Runs the interactive Kubb scaffolding wizard.\n * Detects the package manager, prompts for input/output paths and plugins, installs packages, and writes `kubb.config.ts`.\n * Pass `yes: true` to skip all prompts and use defaults.\n */\nexport async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Init ')) })\n\n /**\n * Returns `flag` when provided, the `defaultValue` when `yes` is set,\n * or calls `prompt()` for interactive input. Exits on cancellation.\n */\n async function resolveOrPrompt<T>(flag: T | undefined, defaultValue: T, logLabel: string, prompt: () => Promise<T | symbol>): Promise<T> {\n if (flag !== undefined) {\n logInfo(`${logLabel}: ${styleText('cyan', String(flag))}`)\n return flag\n }\n if (yes) {\n logInfo(`${logLabel}: ${styleText('cyan', String(defaultValue))}`)\n return defaultValue\n }\n const result = await prompt()\n if (clack.isCancel(result)) cancelAndExit()\n return result as T\n }\n\n try {\n // Check/create package.json, detect package manager once after the block\n if (!hasPackageJson(cwd)) {\n if (!yes) {\n const shouldInit = await clack.confirm({\n message: 'No package.json found. Would you like to create one?',\n initialValue: true,\n })\n\n if (clack.isCancel(shouldInit) || !shouldInit) {\n cancelAndExit()\n }\n }\n\n const packageManager = detectPackageManager(cwd)\n const spinner = createSpinner()\n spinner.start(`Initializing package.json with ${packageManager.name}`)\n await initPackageJson(cwd, packageManager)\n spinner.stop(`Created package.json with ${packageManager.name}`)\n }\n\n const packageManager = detectPackageManager(cwd)\n if (hasPackageJson(cwd)) {\n logInfo(`Detected package manager: ${styleText('cyan', packageManager.name)}`)\n }\n\n // Prompt for OpenAPI spec path\n const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, 'Using input path', () =>\n clack.text({\n message: 'Where is your OpenAPI specification located?',\n placeholder: initDefaults.inputPath,\n defaultValue: initDefaults.inputPath,\n validate: (value) => {\n if (!value) return 'Input path is required'\n },\n }),\n )\n\n // Prompt for output directory\n const outputPath = await resolveOrPrompt(outputFlag, initDefaults.outputPath, 'Using output path', () =>\n clack.text({\n message: 'Where should the generated files be output?',\n placeholder: initDefaults.outputPath,\n defaultValue: initDefaults.outputPath,\n validate: (value) => {\n if (!value) return 'Output path is required'\n },\n }),\n )\n\n // Plugin selection\n const defaultPlugins = availablePlugins.filter((p) => (initDefaults.plugins as ReadonlyArray<string>).includes(p.value))\n const pluginLabel = (plugins: Array<PluginOption>) => styleText('cyan', plugins.map((p) => p.label).join(', '))\n\n const selectedPlugins: Array<PluginOption> = await (async () => {\n if (pluginsFlag) {\n const plugins = resolvePlugins(pluginsFlag)\n if (plugins.length === 0) {\n logWarn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n logInfo(`Using plugins: ${pluginLabel(plugins)}`)\n return plugins\n }\n if (yes) {\n logInfo(`Using plugins: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n const values = await clack.multiselect({\n message: 'Select plugins to use:',\n options: availablePlugins.map(({ value, label, hint }) => ({ value, label, hint })),\n initialValues: [...initDefaults.plugins],\n required: true,\n })\n if (clack.isCancel(values)) cancelAndExit()\n return availablePlugins.filter((p) => (values as Array<string>).includes(p.value))\n })()\n\n // Install packages, matching the release of the running CLI\n const packagesToInstall = resolveInstallVersions({ packages: [KUBB_PACKAGE_NAME, ...selectedPlugins.map((p) => p.packageName)], version })\n\n const spinner = createSpinner()\n spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`)\n\n try {\n await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), {\n message: `install ${packagesToInstall.length} packages with ${packageManager.name}`,\n })\n spinner.stop(`Installed ${packagesToInstall.length} packages`)\n } catch (error) {\n spinner.stop('Installation failed')\n throw error\n }\n\n // Generate config file\n const configSpinner = createSpinner()\n configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`)\n\n const configContent = generateConfigFile({ selectedPlugins, inputPath, outputPath })\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n\n if (fs.existsSync(configPath)) {\n configSpinner.stop(`${KUBB_CONFIG_FILENAME} already exists`)\n\n if (!yes) {\n const shouldOverwrite = await clack.confirm({\n message: `${KUBB_CONFIG_FILENAME} already exists. Overwrite?`,\n initialValue: false,\n })\n\n if (clack.isCancel(shouldOverwrite) || !shouldOverwrite) {\n cancelAndExit('Keeping existing configuration. Packages have been installed.')\n }\n }\n\n configSpinner.start(`Overwriting ${KUBB_CONFIG_FILENAME}`)\n }\n\n await dryRun.run(() => fs.promises.writeFile(configPath, configContent, 'utf-8'), { message: `write ${KUBB_CONFIG_FILENAME}` })\n\n configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`)\n\n logOutro(\n styleText('green', '✓ All set!') +\n '\\n\\n' +\n styleText('dim', 'Next steps:') +\n '\\n' +\n styleText('cyan', ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) +\n '\\n' +\n styleText('cyan', ' 2. Generate code with: npx kubb generate') +\n '\\n' +\n styleText('cyan', ` 3. Find generated files in: ${outputPath}`) +\n '\\n\\n' +\n styleText('dim', `Using ${packageManager.name} • Kubb v${version}`),\n )\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAQA,SAAgB,eAAe,aAAsD;CACnF,IAAI,CAAC,aACH,OAAO,CAAC;CAEV,MAAM,YAAY,YACf,MAAM,GAAG,CAAC,CACV,KAAK,UAAU,MAAM,KAAK,CAAC,CAAC,CAC5B,OAAO,OAAO;CACjB,OAAO,iBAAiB,QAAQ,WAAW,UAAU,SAAS,OAAO,KAAK,CAAC;AAC7E;AAEA,SAAgB,mBAAmB,EACjC,iBACA,WACA,cAKS;CAKT,OAAO;EAJS,gBAAgB,KAAK,WAAW,YAAY,OAAO,WAAW,WAAW,OAAO,YAAY,EAAE,CAAC,CAAC,KAAK,IAK/G,EAAE;;;YAGE,UAAU;;aAET,WAAW;;;;EARA,gBAAgB,KAAK,WAAW,OAAO,OAAO,WAAW,IAAI,CAAC,CAAC,KAAK,IAY9E,EAAE;;;;AAIhB;;;;;;;;;AAUA,SAAgB,uBAAuB,EAAE,UAAU,WAAwE;CAEzH,MAAM,MADa,QAAQ,MAAM,WAAW,CAAC,GAAG,MACtB;CAE1B,OAAO,SAAS,KAAK,SAAU,SAAA,SAA6B,GAAG,KAAK,GAAG,YAAY,GAAG,KAAK,GAAG,KAAM;AACtG;;;;;;;;;;;;ACZA,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,MA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