@kubb/cli 5.14.6 → 5.15.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 (186) hide show
  1. package/bin/kubb.js +2 -1
  2. package/dist/{Telemetry-DrnGartf.js → Telemetry-B3edcFoB.js} +12 -86
  3. package/dist/Telemetry-B3edcFoB.js.map +1 -0
  4. package/dist/{Telemetry-B5V_ufmv.cjs → Telemetry-COWGqYmh.cjs} +14 -118
  5. package/dist/Telemetry-COWGqYmh.cjs.map +1 -0
  6. package/dist/{background-CdPT1eaq.cjs → background-B24lIehn.cjs} +5 -6
  7. package/dist/{background-CdPT1eaq.cjs.map → background-B24lIehn.cjs.map} +1 -1
  8. package/dist/{background-C6XHpEo7.js → background-D-7OGjvg.js} +1 -1
  9. package/dist/{background-DlK0by5c.js → background-_dKcGjM7.js} +5 -6
  10. package/dist/{background-DlK0by5c.js.map → background-_dKcGjM7.js.map} +1 -1
  11. package/dist/banner-BdTTDFkG.js +140 -0
  12. package/dist/banner-BdTTDFkG.js.map +1 -0
  13. package/dist/banner-wJFk-L-c.cjs +163 -0
  14. package/dist/banner-wJFk-L-c.cjs.map +1 -0
  15. package/dist/config-BL3HnFhb.js +1 -0
  16. package/dist/config-BWj9jBVj.cjs +62 -0
  17. package/dist/config-BWj9jBVj.cjs.map +1 -0
  18. package/dist/{config-CNqgDSu3.js → config-CQTxXvIG.js} +6 -52
  19. package/dist/config-CQTxXvIG.js.map +1 -0
  20. package/dist/{config-BG_Nr2CZ.cjs → config-CRrmj88c.cjs} +15 -62
  21. package/dist/config-CRrmj88c.cjs.map +1 -0
  22. package/dist/config-Uk3rbZfb.js +49 -0
  23. package/dist/config-Uk3rbZfb.js.map +1 -0
  24. package/dist/configFile-C0DIXNMD.js +993 -0
  25. package/dist/configFile-C0DIXNMD.js.map +1 -0
  26. package/dist/configFile-CoEpHdXG.cjs +1028 -0
  27. package/dist/configFile-CoEpHdXG.cjs.map +1 -0
  28. package/dist/{credentials-C8tjAhTo.js → credentials-B77iJx9H.js} +1 -1
  29. package/dist/{credentials-DDaKqtJn.cjs → credentials-DEsGwcGD.cjs} +3 -4
  30. package/dist/{credentials-DDaKqtJn.cjs.map → credentials-DEsGwcGD.cjs.map} +1 -1
  31. package/dist/{credentials-CZK6zPLv.js → credentials-osgjujE_.js} +3 -4
  32. package/dist/{credentials-CZK6zPLv.js.map → credentials-osgjujE_.js.map} +1 -1
  33. package/dist/env-C3xHRMez.js +1 -0
  34. package/dist/env-eu3XyKqJ.cjs +55 -0
  35. package/dist/env-eu3XyKqJ.cjs.map +1 -0
  36. package/dist/env-rv-VgSGN.js +34 -0
  37. package/dist/env-rv-VgSGN.js.map +1 -0
  38. package/dist/{errors-Cl69p_vI.cjs → errors-BponpdjN.cjs} +3 -4
  39. package/dist/{errors-Cl69p_vI.cjs.map → errors-BponpdjN.cjs.map} +1 -1
  40. package/dist/{errors-DmC83ALX.js → errors-wzqmMpMo.js} +3 -4
  41. package/dist/{errors-DmC83ALX.js.map → errors-wzqmMpMo.js.map} +1 -1
  42. package/dist/index.cjs +37 -2719
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +0 -2
  45. package/dist/index.d.ts +0 -2
  46. package/dist/index.js +35 -2713
  47. package/dist/index.js.map +1 -1
  48. package/dist/installWithSpinner-DpnpxHq5.js +49 -0
  49. package/dist/installWithSpinner-DpnpxHq5.js.map +1 -0
  50. package/dist/installWithSpinner-ONGfIVUJ.cjs +56 -0
  51. package/dist/installWithSpinner-ONGfIVUJ.cjs.map +1 -0
  52. package/dist/{text-CL6N6yPS.js → intro-9PB8sE8z.js} +8 -52
  53. package/dist/intro-9PB8sE8z.js.map +1 -0
  54. package/dist/{text-DrsG1EDN.cjs → intro-YPaf1Imr.cjs} +12 -80
  55. package/dist/intro-YPaf1Imr.cjs.map +1 -0
  56. package/dist/isCIEnvironment-D6xtAAZ2.js +14 -0
  57. package/dist/isCIEnvironment-D6xtAAZ2.js.map +1 -0
  58. package/dist/isCIEnvironment-DiVOMI5Q.cjs +20 -0
  59. package/dist/isCIEnvironment-DiVOMI5Q.cjs.map +1 -0
  60. package/dist/mascot--q1xjKw1.js +63 -0
  61. package/dist/mascot--q1xjKw1.js.map +1 -0
  62. package/dist/mascot-JSA0j3Q_.cjs +80 -0
  63. package/dist/mascot-JSA0j3Q_.cjs.map +1 -0
  64. package/dist/mcp-CYPOFKnP.cjs +20 -0
  65. package/dist/mcp-CYPOFKnP.cjs.map +1 -0
  66. package/dist/mcp-CxeZR5vb.js +21 -0
  67. package/dist/mcp-CxeZR5vb.js.map +1 -0
  68. package/dist/package-D3Yss9Bb.js +5 -0
  69. package/dist/package-D3Yss9Bb.js.map +1 -0
  70. package/dist/package-aX0q9SZr.cjs +10 -0
  71. package/dist/package-aX0q9SZr.cjs.map +1 -0
  72. package/dist/{registry-DOGpflct.js → registry-B3eYk4LN.js} +7 -67
  73. package/dist/registry-B3eYk4LN.js.map +1 -0
  74. package/dist/{registry-BzBp6aZI.cjs → registry-YE1pFWL-.cjs} +4 -82
  75. package/dist/registry-YE1pFWL-.cjs.map +1 -0
  76. package/dist/{reporters-GzXlc4CK.cjs → reporters-2cgjvXwR.cjs} +32 -40
  77. package/dist/{reporters-GzXlc4CK.cjs.map → reporters-2cgjvXwR.cjs.map} +1 -1
  78. package/dist/{reporters-mYHIUZSx.js → reporters-BM430HdQ.js} +19 -27
  79. package/dist/{reporters-mYHIUZSx.js.map → reporters-BM430HdQ.js.map} +1 -1
  80. package/dist/{rolldown-runtime-CPE0t6oh.cjs → rolldown-runtime-C3-Zg-KD.cjs} +1 -2
  81. package/dist/{rolldown-runtime-CRm0XQPb.js → rolldown-runtime-xo6NMXYd.js} +1 -2
  82. package/dist/run-1H9TGT8v.js +77 -0
  83. package/dist/run-1H9TGT8v.js.map +1 -0
  84. package/dist/run-B4zvF9WY.cjs +233 -0
  85. package/dist/run-B4zvF9WY.cjs.map +1 -0
  86. package/dist/run-BYP_t9dR.cjs +324 -0
  87. package/dist/run-BYP_t9dR.cjs.map +1 -0
  88. package/dist/{run-C8Prej7s.cjs → run-Bb19PlwV.cjs} +44 -37
  89. package/dist/run-Bb19PlwV.cjs.map +1 -0
  90. package/dist/{run-DC_xH5H3.cjs → run-BoO7H8RA.cjs} +49 -41
  91. package/dist/run-BoO7H8RA.cjs.map +1 -0
  92. package/dist/run-BrM7-NSV.js +181 -0
  93. package/dist/run-BrM7-NSV.js.map +1 -0
  94. package/dist/{run-l8IiOR_c.js → run-C0KI-NE3.js} +9 -9
  95. package/dist/{run-l8IiOR_c.js.map → run-C0KI-NE3.js.map} +1 -1
  96. package/dist/run-CCLPt4hr.js +1 -0
  97. package/dist/run-CCsdLz3X.js +385 -0
  98. package/dist/run-CCsdLz3X.js.map +1 -0
  99. package/dist/{run-EJtgdIin.js → run-CbX6tpqB.js} +31 -23
  100. package/dist/run-CbX6tpqB.js.map +1 -0
  101. package/dist/run-CrM4jsix.cjs +80 -0
  102. package/dist/run-CrM4jsix.cjs.map +1 -0
  103. package/dist/run-CvFakE3B.cjs +185 -0
  104. package/dist/run-CvFakE3B.cjs.map +1 -0
  105. package/dist/run-D-nn9-Wq.js +319 -0
  106. package/dist/run-D-nn9-Wq.js.map +1 -0
  107. package/dist/{run-CypFtkVE.cjs → run-D5Z6nfzK.cjs} +5 -6
  108. package/dist/{run-CypFtkVE.cjs.map → run-D5Z6nfzK.cjs.map} +1 -1
  109. package/dist/{run-sjzj0ir-.cjs → run-DCqmf5W1.cjs} +10 -10
  110. package/dist/{run-sjzj0ir-.cjs.map → run-DCqmf5W1.cjs.map} +1 -1
  111. package/dist/{run-j1g5si5R.js → run-DFXhBS64.js} +5 -6
  112. package/dist/{run-j1g5si5R.js.map → run-DFXhBS64.js.map} +1 -1
  113. package/dist/run-DgGZOC_x.cjs +389 -0
  114. package/dist/run-DgGZOC_x.cjs.map +1 -0
  115. package/dist/{run-9fs2T2Je.js → run-KqdudiWQ.js} +26 -20
  116. package/dist/run-KqdudiWQ.js.map +1 -0
  117. package/dist/run-RN_31Q4u.js +228 -0
  118. package/dist/run-RN_31Q4u.js.map +1 -0
  119. package/dist/shared-C0EtrdUm.cjs +123 -0
  120. package/dist/shared-C0EtrdUm.cjs.map +1 -0
  121. package/dist/shared-Ct9stKpp.js +94 -0
  122. package/dist/shared-Ct9stKpp.js.map +1 -0
  123. package/dist/{snapshot-laSRD0z1.cjs → snapshot-D7Ytw8S0.cjs} +13 -14
  124. package/dist/{snapshot-laSRD0z1.cjs.map → snapshot-D7Ytw8S0.cjs.map} +1 -1
  125. package/dist/{snapshot-BJWnL6hE.js → snapshot-n7dJGCWv.js} +10 -11
  126. package/dist/{snapshot-BJWnL6hE.js.map → snapshot-n7dJGCWv.js.map} +1 -1
  127. package/dist/spinner-BZaln7O8.js +160 -0
  128. package/dist/spinner-BZaln7O8.js.map +1 -0
  129. package/dist/spinner-CfB0sIPy.cjs +208 -0
  130. package/dist/spinner-CfB0sIPy.cjs.map +1 -0
  131. package/dist/{status-DFEdbBPu.cjs → status-Bc0_4T41.cjs} +7 -8
  132. package/dist/{status-DFEdbBPu.cjs.map → status-Bc0_4T41.cjs.map} +1 -1
  133. package/dist/{status-BjmXLRm2.js → status-DxSkp1cH.js} +6 -7
  134. package/dist/{status-BjmXLRm2.js.map → status-DxSkp1cH.js.map} +1 -1
  135. package/dist/studio-BpYwgFb0.cjs +218 -0
  136. package/dist/studio-BpYwgFb0.cjs.map +1 -0
  137. package/dist/studio-mw6HaPkr.js +215 -0
  138. package/dist/studio-mw6HaPkr.js.map +1 -0
  139. package/dist/studioWorker.js +4 -5
  140. package/dist/{summary-DDnI70tn.js → summary-CbmQKA8l.js} +5 -6
  141. package/dist/{summary-DDnI70tn.js.map → summary-CbmQKA8l.js.map} +1 -1
  142. package/dist/{summary-1DCwzWEU.cjs → summary-Clvl5Hxs.cjs} +7 -8
  143. package/dist/{summary-1DCwzWEU.cjs.map → summary-Clvl5Hxs.cjs.map} +1 -1
  144. package/dist/table-BlRe9YTZ.cjs +15 -0
  145. package/dist/table-BlRe9YTZ.cjs.map +1 -0
  146. package/dist/table-CR7iZJGo.js +10 -0
  147. package/dist/table-CR7iZJGo.js.map +1 -0
  148. package/dist/text-BmiI4s6N.js +13 -0
  149. package/dist/text-BmiI4s6N.js.map +1 -0
  150. package/dist/text-Ep3AulAS.cjs +24 -0
  151. package/dist/text-Ep3AulAS.cjs.map +1 -0
  152. package/dist/time-3BKoci3G.cjs +82 -0
  153. package/dist/time-3BKoci3G.cjs.map +1 -0
  154. package/dist/time-C-wU7VhC.js +65 -0
  155. package/dist/time-C-wU7VhC.js.map +1 -0
  156. package/dist/utils-BdibacYq.js +244 -0
  157. package/dist/utils-BdibacYq.js.map +1 -0
  158. package/dist/utils-CO89mxRU.cjs +290 -0
  159. package/dist/utils-CO89mxRU.cjs.map +1 -0
  160. package/dist/utils-CbJ6hS_t.js +222 -0
  161. package/dist/utils-CbJ6hS_t.js.map +1 -0
  162. package/dist/utils-CcARPB45.cjs +286 -0
  163. package/dist/utils-CcARPB45.cjs.map +1 -0
  164. package/dist/validate-8ZcWXfMt.js +28 -0
  165. package/dist/validate-8ZcWXfMt.js.map +1 -0
  166. package/dist/validate-CMSeDpGT.cjs +27 -0
  167. package/dist/validate-CMSeDpGT.cjs.map +1 -0
  168. package/package.json +7 -7
  169. package/dist/Telemetry-B5V_ufmv.cjs.map +0 -1
  170. package/dist/Telemetry-DrnGartf.js.map +0 -1
  171. package/dist/config-BG_Nr2CZ.cjs.map +0 -1
  172. package/dist/config-CNqgDSu3.js.map +0 -1
  173. package/dist/config-DWDpFSn1.js +0 -1
  174. package/dist/registry-BzBp6aZI.cjs.map +0 -1
  175. package/dist/registry-DOGpflct.js.map +0 -1
  176. package/dist/run-9fs2T2Je.js.map +0 -1
  177. package/dist/run-C8Prej7s.cjs.map +0 -1
  178. package/dist/run-CXVme-aS.js +0 -1
  179. package/dist/run-DC_xH5H3.cjs.map +0 -1
  180. package/dist/run-EJtgdIin.js.map +0 -1
  181. package/dist/text-CL6N6yPS.js.map +0 -1
  182. package/dist/text-DrsG1EDN.cjs.map +0 -1
  183. package/dist/utils-C3vTpUje.cjs +0 -645
  184. package/dist/utils-C3vTpUje.cjs.map +0 -1
  185. package/dist/utils-CIc8YFtr.js +0 -536
  186. package/dist/utils-CIc8YFtr.js.map +0 -1
@@ -0,0 +1,228 @@
1
+ import "./rolldown-runtime-xo6NMXYd.js";
2
+ import { t as getErrorMessage } from "./errors-wzqmMpMo.js";
3
+ import { n as withSpinner, t as createSpinner } from "./spinner-BZaln7O8.js";
4
+ import { a as readOutputFiles, n as diffFiles } from "./utils-BdibacYq.js";
5
+ import { l as logStep, n as logIntro, o as logBlock, s as logError, t as isInteractiveRun, u as logWarn } from "./intro-9PB8sE8z.js";
6
+ import { n as dryRunId, o as yesArg } from "./shared-Ct9stKpp.js";
7
+ import { t as pluralize } from "./text-BmiI4s6N.js";
8
+ import { t as findConfigFile } from "./config-CQTxXvIG.js";
9
+ import { t as logCommandSummary } from "./summary-CbmQKA8l.js";
10
+ import { a as installSpec, c as toRegistryId, i as incompatibility, l as toShortId, o as isOutdated, r as fetchRegistryIndex, s as registryUrl, t as bumpOf } from "./registry-B3eYk4LN.js";
11
+ import { n as detectPackageManager } from "./utils-CbJ6hS_t.js";
12
+ import { t as installWithSpinner } from "./installWithSpinner-DpnpxHq5.js";
13
+ import { t as formatTable } from "./table-CR7iZJGo.js";
14
+ import { styleText } from "node:util";
15
+ import { defineWithTypes } from "gunshi";
16
+ import process from "node:process";
17
+ import path from "node:path";
18
+ import * as clack from "@clack/prompts";
19
+ import { Hookable, readInstalledPackages } from "@kubb/core";
20
+ // src/runners/update/run.ts
21
+ /**
22
+ * Generates every config in this process, the way `kubb generate` does, and returns the output files
23
+ * it changed. Runs after the install, so the config loads the new versions. `undefined` when the
24
+ * config fails to load or a build fails.
25
+ */
26
+ async function regenerate({ cwd, configPath }) {
27
+ const spinner = createSpinner();
28
+ spinner.start("Generating with the new versions");
29
+ try {
30
+ const [{ getConfigs }, { generate }] = await Promise.all([import("./config-BL3HnFhb.js"), import("./run-CbX6tpqB.js")]);
31
+ const { configs } = await getConfigs({ configPath });
32
+ const dirs = configs.map((config) => path.resolve(config.root ?? cwd, config.output.path));
33
+ const before = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]));
34
+ const hooks = new Hookable();
35
+ for (const config of configs) if (!await generate({
36
+ config,
37
+ hooks
38
+ })) throw new Error("Generation failed");
39
+ const after = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]));
40
+ const diff = diffFiles(before, after);
41
+ spinner.stop(diff.files.length ? `Generated: ${pluralize(diff.files.length, "file")} changed` : "Generated: no files changed");
42
+ return {
43
+ ...diff,
44
+ output: dirs.map((dir) => path.relative(cwd, dir) || ".").join(", ")
45
+ };
46
+ } catch (error) {
47
+ spinner.error(`Generation failed: ${getErrorMessage(error)}`);
48
+ return;
49
+ }
50
+ }
51
+ /**
52
+ * Moves installed extensions to the version the registry pins. Shows each version change with its
53
+ * bump, asks which to install with majors left out, installs them, and regenerates to show which
54
+ * files changed. With `dryRun`, only lists the updates and installs nothing.
55
+ */
56
+ async function run({ ids, dryRun, yes }) {
57
+ const cwd = process.cwd();
58
+ const hrStart = process.hrtime();
59
+ const installedPackages = [];
60
+ const summary = (title, status, lines) => logCommandSummary({
61
+ title,
62
+ status,
63
+ hrStart,
64
+ block: true,
65
+ lines
66
+ });
67
+ logIntro({ title: isInteractiveRun({
68
+ yes,
69
+ dryRun
70
+ }) ? void 0 : styleText("bgCyan", styleText("black", " Kubb Update ")) });
71
+ try {
72
+ const wanted = new Set(ids.map(toRegistryId));
73
+ const [entries, installed] = await withSpinner({
74
+ message: "Checking the registry",
75
+ promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })])
76
+ });
77
+ const versions = new Map(installed.map((item) => [item.package, item.version]));
78
+ const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)));
79
+ for (const id of wanted) {
80
+ if (tracked.some((entry) => entry.id === id)) continue;
81
+ logWarn(`${id} is not installed, or not in the registry.`);
82
+ process.exitCode = 1;
83
+ }
84
+ const current = ({ artifact }) => versions.get(artifact.package);
85
+ const isMajor = (entry) => bumpOf({
86
+ installed: current(entry),
87
+ latest: entry.artifact.version
88
+ }) === "major";
89
+ const outdated = tracked.filter((entry) => isOutdated({
90
+ installed: current(entry),
91
+ latest: entry.artifact.version
92
+ }));
93
+ const proposals = outdated.filter((entry) => {
94
+ const problem = incompatibility(entry.manifest);
95
+ if (problem) {
96
+ logWarn(`Skipped ${entry.id}: ${problem}`);
97
+ if (wanted.has(entry.id)) process.exitCode = 1;
98
+ }
99
+ return !problem;
100
+ });
101
+ if (!proposals.length) {
102
+ const title = outdated.length ? "No compatible updates available" : "Already up to date";
103
+ summary(tracked.length ? title : "No installed extensions to update", outdated.length ? "warning" : "success", [` ${tracked.length - outdated.length} of ${tracked.length} up to date`, ...ids.length ? ["", `No updates for ${ids.join(", ")}.`] : []]);
104
+ return;
105
+ }
106
+ if (tracked.length) {
107
+ const header = [
108
+ "Extension",
109
+ "Current",
110
+ "Latest",
111
+ ""
112
+ ];
113
+ const rows = tracked.map((entry) => {
114
+ if (!outdated.includes(entry)) return [
115
+ entry.artifact.package,
116
+ current(entry) ?? "-",
117
+ "up to date",
118
+ ""
119
+ ];
120
+ const bump = bumpOf({
121
+ installed: current(entry),
122
+ latest: entry.artifact.version
123
+ }) ?? "";
124
+ return [
125
+ entry.artifact.package,
126
+ current(entry) ?? "not installed",
127
+ entry.artifact.version,
128
+ bump === "major" ? "major · breaking" : bump
129
+ ];
130
+ });
131
+ const lines = formatTable([header, ...rows]);
132
+ logStep(`Checked ${pluralize(tracked.length, "extension")} against the registry`);
133
+ logBlock([styleText("dim", lines[0]), ...lines.slice(1).map((line, index) => {
134
+ if (!outdated.includes(tracked[index])) return styleText("dim", line);
135
+ return line.endsWith("major · breaking") ? styleText("yellow", line) : line;
136
+ })]);
137
+ }
138
+ if (dryRun) {
139
+ summary("Updates available", "planned", [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? "it" : "them"}.`]);
140
+ return;
141
+ }
142
+ const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry));
143
+ const chosen = yes ? defaults.map((entry) => entry.id) : await clack.multiselect({
144
+ message: "Select the updates to install",
145
+ options: proposals.map((entry) => ({
146
+ value: entry.id,
147
+ label: entry.artifact.package,
148
+ hint: `${current(entry) ?? "not installed"} → ${entry.artifact.version}`
149
+ })),
150
+ initialValues: defaults.map((entry) => entry.id),
151
+ required: false
152
+ });
153
+ if (clack.isCancel(chosen)) {
154
+ summary("Update canceled", "canceled", [" No changes made"]);
155
+ return;
156
+ }
157
+ const selected = proposals.filter((entry) => chosen.includes(entry.id));
158
+ const skipped = proposals.filter((entry) => !selected.includes(entry)).map((entry) => {
159
+ const kind = entry.manifest.kind.charAt(0).toUpperCase() + entry.manifest.kind.slice(1);
160
+ return ` ${styleText("dim", "Skipped")} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText("dim", `run kubb update ${toShortId(entry.id)} later`)}`;
161
+ });
162
+ if (!selected.length) {
163
+ summary("No updates installed", "canceled", [" No updates selected.", ...skipped]);
164
+ return;
165
+ }
166
+ const packageManager = detectPackageManager(cwd);
167
+ const names = selected.map(({ artifact }) => artifact.package).join(", ");
168
+ await installWithSpinner({
169
+ packages: selected.map(({ artifact }) => installSpec(artifact)),
170
+ names,
171
+ packageManager,
172
+ cwd
173
+ });
174
+ installedPackages.push(...selected.map((entry) => entry.artifact.package));
175
+ const foundConfig = findConfigFile(cwd);
176
+ const configPath = foundConfig && !yes && await clack.confirm({
177
+ message: "Regenerate now? This rewrites the generated files.",
178
+ initialValue: true
179
+ }) === true ? foundConfig : void 0;
180
+ const changed = configPath ? await regenerate({
181
+ cwd,
182
+ configPath
183
+ }) : void 0;
184
+ const generationFailed = Boolean(configPath && !changed);
185
+ const fileCounts = {
186
+ A: 0,
187
+ M: 0,
188
+ D: 0
189
+ };
190
+ for (const file of changed?.files ?? []) fileCounts[file.status]++;
191
+ summary(generationFailed ? "Extensions updated; generation failed" : "Update complete", generationFailed ? "warning" : "success", [
192
+ ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ""}`,
193
+ ...skipped,
194
+ ...changed ? [` Files ${fileCounts.A} added · ${fileCounts.M} modified · ${fileCounts.D} deleted`] : [],
195
+ ...!configPath ? [" Regeneration not run"] : [],
196
+ ...generationFailed ? ["", "Fix the generation error, then run kubb generate."] : []
197
+ ]);
198
+ } catch (error) {
199
+ logError(getErrorMessage(error));
200
+ summary("Update failed", "failed", installedPackages.length ? [` Packages ${installedPackages.join(", ")} installed`] : [" No changes made"]);
201
+ process.exitCode = 1;
202
+ }
203
+ }
204
+ const command = defineWithTypes()({
205
+ name: "update",
206
+ description: "Update installed extensions, regenerate, and summarize file changes.",
207
+ examples: [
208
+ "kubb update",
209
+ "kubb update --dry-run",
210
+ "kubb update plugin-zod plugin-ts --yes"
211
+ ].join("\n"),
212
+ args: {
213
+ ids: {
214
+ type: "positional",
215
+ description: "Registry ids to update, all installed extensions when omitted",
216
+ multiple: true
217
+ },
218
+ ...yesArg
219
+ },
220
+ run: ({ values, extensions }) => run({
221
+ ids: values.ids ?? [],
222
+ dryRun: extensions[dryRunId].enabled,
223
+ yes: values.yes
224
+ })
225
+ });
226
+ export { command, run };
227
+
228
+ //# sourceMappingURL=run-RN_31Q4u.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-RN_31Q4u.js","names":[],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage } from '@internals/utils'\nimport { Hookable, type KubbHooks, readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport { diffFiles, type FileChange, readOutputFiles } from '../generate/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the output files\n * it changed. Runs after the install, so the config loads the new versions. `undefined` when the\n * config fails to load or a build fails.\n */\nasync function regenerate({\n cwd,\n configPath,\n}: {\n cwd: string\n configPath: string\n}): Promise<{ files: Array<FileChange>; unchanged: number; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }] = await Promise.all([import('../../config.ts'), import('../generate/run.ts')])\n const { configs } = await getConfigs({ configPath })\n const dirs = configs.map((config) => path.resolve(config.root ?? cwd, config.output.path))\n const before = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const hooks = new Hookable<KubbHooks>()\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const after = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const diff = diffFiles(before, after)\n spinner.stop(diff.files.length ? `Generated: ${pluralize(diff.files.length, 'file')} changed` : 'Generated: no files changed')\n return { ...diff, output: dirs.map((dir) => path.relative(cwd, dir) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (tracked.some((entry) => entry.id === id)) continue\n logWarn(`${id} is not installed, or not in the registry.`)\n // A caller that named it, such as Studio, must not read the run as a successful update.\n process.exitCode = 1\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) {\n logWarn(`Skipped ${entry.id}: ${problem}`)\n // Same as a missing id: Studio would report an update that installed nothing.\n if (wanted.has(entry.id)) process.exitCode = 1\n }\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = entry.manifest.kind.charAt(0).toUpperCase() + entry.manifest.kind.slice(1)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n const fileCounts = { A: 0, M: 0, D: 0 }\n for (const file of changed?.files ?? []) fileCounts[file.status]++\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${fileCounts.A} added · ${fileCounts.M} modified · ${fileCounts.D} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], d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AAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAe;EAAyB;CAAwC,CAAC,CAAC,KAAK,IAAI;CACtG,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAG;CACL;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO,OAAO,CAAC;EAAG,QAAQ,WAAW,SAAS,CAAC;EAAS,KAAK,OAAO;CAAI,CAAC;AACvH,CAAC"}
@@ -0,0 +1,123 @@
1
+ require("@gunshi/plugin-dryrun");
2
+ // src/commands/shared.ts
3
+ const configArg = { config: {
4
+ type: "string",
5
+ description: "Path to the Kubb config",
6
+ short: "c"
7
+ } };
8
+ const yesArg = { yes: {
9
+ type: "boolean",
10
+ description: "Skip the confirmation",
11
+ short: "y",
12
+ default: false
13
+ } };
14
+ const logLevelArg = { logLevel: {
15
+ type: "enum",
16
+ choices: [
17
+ "silent",
18
+ "info",
19
+ "verbose"
20
+ ],
21
+ description: "Info, silent or verbose",
22
+ short: "l",
23
+ default: "info",
24
+ toKebab: true
25
+ } };
26
+ const studioConnectionArgs = {
27
+ url: {
28
+ type: "string",
29
+ description: "Base URL of the Kubb Studio instance"
30
+ },
31
+ token: {
32
+ type: "string",
33
+ description: "Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN"
34
+ }
35
+ };
36
+ const studioPermissionArgs = {
37
+ allowRead: {
38
+ type: "boolean",
39
+ description: "Read the source of files a generation produced. Asked for once per project when omitted",
40
+ default: false,
41
+ toKebab: true
42
+ },
43
+ allowReadAst: {
44
+ type: "boolean",
45
+ description: "Read the parsed spec (the Kubb AST). Asked for once per project when omitted",
46
+ default: false,
47
+ toKebab: true
48
+ },
49
+ allowWrite: {
50
+ type: "boolean",
51
+ description: "Write generated files to disk. Asked for once per project when omitted",
52
+ default: false,
53
+ toKebab: true
54
+ },
55
+ allowConfigEdit: {
56
+ type: "boolean",
57
+ description: "Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted",
58
+ default: false,
59
+ toKebab: true
60
+ },
61
+ allowInstall: {
62
+ type: "boolean",
63
+ description: "Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted",
64
+ default: false,
65
+ toKebab: true
66
+ },
67
+ allowUpdate: {
68
+ type: "boolean",
69
+ description: "Let Studio update installed extensions with kubb update. Asked for once per project when omitted",
70
+ default: false,
71
+ toKebab: true
72
+ },
73
+ allowRemove: {
74
+ type: "boolean",
75
+ description: "Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted",
76
+ default: false,
77
+ toKebab: true
78
+ },
79
+ allowSaveInput: {
80
+ type: "boolean",
81
+ description: "Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted",
82
+ default: false,
83
+ toKebab: true
84
+ },
85
+ allowExec: {
86
+ type: "boolean",
87
+ description: "Run the formatter, the linter, and output.postGenerate after a generation",
88
+ default: false,
89
+ toKebab: true
90
+ }
91
+ };
92
+ Object.defineProperty(exports, "configArg", {
93
+ enumerable: true,
94
+ get: function() {
95
+ return configArg;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "logLevelArg", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return logLevelArg;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "studioConnectionArgs", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return studioConnectionArgs;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, "studioPermissionArgs", {
111
+ enumerable: true,
112
+ get: function() {
113
+ return studioPermissionArgs;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, "yesArg", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return yesArg;
120
+ }
121
+ });
122
+
123
+ //# sourceMappingURL=shared-C0EtrdUm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-C0EtrdUm.cjs","names":[],"sources":["../src/commands/shared.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowInstall: {\n type: 'boolean',\n description: 'Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowUpdate: {\n type: 'boolean',\n description: 'Let Studio update installed extensions with kubb update. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowRemove: {\n type: 'boolean',\n description:\n 'Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowSaveInput: {\n type: 'boolean',\n description: 'Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n"],"mappings":";;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aACE;EACF,SAAS;EACT,SAAS;CACX;CACA,gBAAgB;EACd,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF"}
@@ -0,0 +1,94 @@
1
+ import { pluginId as dryRunId } from "@gunshi/plugin-dryrun";
2
+ // src/commands/shared.ts
3
+ const configArg = { config: {
4
+ type: "string",
5
+ description: "Path to the Kubb config",
6
+ short: "c"
7
+ } };
8
+ const yesArg = { yes: {
9
+ type: "boolean",
10
+ description: "Skip the confirmation",
11
+ short: "y",
12
+ default: false
13
+ } };
14
+ const logLevelArg = { logLevel: {
15
+ type: "enum",
16
+ choices: [
17
+ "silent",
18
+ "info",
19
+ "verbose"
20
+ ],
21
+ description: "Info, silent or verbose",
22
+ short: "l",
23
+ default: "info",
24
+ toKebab: true
25
+ } };
26
+ const studioConnectionArgs = {
27
+ url: {
28
+ type: "string",
29
+ description: "Base URL of the Kubb Studio instance"
30
+ },
31
+ token: {
32
+ type: "string",
33
+ description: "Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN"
34
+ }
35
+ };
36
+ const studioPermissionArgs = {
37
+ allowRead: {
38
+ type: "boolean",
39
+ description: "Read the source of files a generation produced. Asked for once per project when omitted",
40
+ default: false,
41
+ toKebab: true
42
+ },
43
+ allowReadAst: {
44
+ type: "boolean",
45
+ description: "Read the parsed spec (the Kubb AST). Asked for once per project when omitted",
46
+ default: false,
47
+ toKebab: true
48
+ },
49
+ allowWrite: {
50
+ type: "boolean",
51
+ description: "Write generated files to disk. Asked for once per project when omitted",
52
+ default: false,
53
+ toKebab: true
54
+ },
55
+ allowConfigEdit: {
56
+ type: "boolean",
57
+ description: "Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted",
58
+ default: false,
59
+ toKebab: true
60
+ },
61
+ allowInstall: {
62
+ type: "boolean",
63
+ description: "Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted",
64
+ default: false,
65
+ toKebab: true
66
+ },
67
+ allowUpdate: {
68
+ type: "boolean",
69
+ description: "Let Studio update installed extensions with kubb update. Asked for once per project when omitted",
70
+ default: false,
71
+ toKebab: true
72
+ },
73
+ allowRemove: {
74
+ type: "boolean",
75
+ description: "Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted",
76
+ default: false,
77
+ toKebab: true
78
+ },
79
+ allowSaveInput: {
80
+ type: "boolean",
81
+ description: "Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted",
82
+ default: false,
83
+ toKebab: true
84
+ },
85
+ allowExec: {
86
+ type: "boolean",
87
+ description: "Run the formatter, the linter, and output.postGenerate after a generation",
88
+ default: false,
89
+ toKebab: true
90
+ }
91
+ };
92
+ export { studioPermissionArgs as a, studioConnectionArgs as i, dryRunId as n, yesArg as o, logLevelArg as r, configArg as t };
93
+
94
+ //# sourceMappingURL=shared-Ct9stKpp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-Ct9stKpp.js","names":[],"sources":["../src/commands/shared.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowInstall: {\n type: 'boolean',\n description: 'Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowUpdate: {\n type: 'boolean',\n description: 'Let Studio update installed extensions with kubb update. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowRemove: {\n type: 'boolean',\n description:\n 'Let Studio remove extensions with kubb remove, which edits kubb.config.ts and uninstalls packages; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowSaveInput: {\n type: 'boolean',\n description: 'Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n"],"mappings":";;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,aAAa;EACX,MAAM;EACN,aACE;EACF,SAAS;EACT,SAAS;CACX;CACA,gBAAgB;EACd,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF"}
@@ -1,9 +1,10 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-CPE0t6oh.cjs");
2
- const require_Telemetry = require("./Telemetry-B5V_ufmv.cjs");
3
- const require_utils = require("./utils-C3vTpUje.cjs");
4
- const require_text = require("./text-DrsG1EDN.cjs");
5
- const require_reporters = require("./reporters-GzXlc4CK.cjs");
6
- const require_run = require("./run-C8Prej7s.cjs");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
2
+ const require_time = require("./time-3BKoci3G.cjs");
3
+ const require_spinner = require("./spinner-CfB0sIPy.cjs");
4
+ const require_intro = require("./intro-YPaf1Imr.cjs");
5
+ const require_text = require("./text-Ep3AulAS.cjs");
6
+ const require_reporters = require("./reporters-2cgjvXwR.cjs");
7
+ const require_run = require("./run-Bb19PlwV.cjs");
7
8
  let node_util = require("node:util");
8
9
  let node_process = require("node:process");
9
10
  node_process = require_rolldown_runtime.__toESM(node_process, 1);
@@ -11,7 +12,7 @@ let node_path = require("node:path");
11
12
  let node_fs = require("node:fs");
12
13
  let _kubb_core = require("@kubb/core");
13
14
  let _kubb_studio = require("@kubb/studio");
14
- //#region src/runners/studio/ci.ts
15
+ // src/runners/studio/ci.ts
15
16
  function readGithubPullRequest(eventPath) {
16
17
  if (!eventPath) return;
17
18
  try {
@@ -80,13 +81,12 @@ function detectCi(env = node_process.default.env) {
80
81
  }
81
82
  return null;
82
83
  }
83
- //#endregion
84
- //#region src/runners/studio/snapshot.ts
84
+ // src/runners/studio/snapshot.ts
85
85
  /**
86
86
  * Walks up from `directory` to the first package.json with a name and a version.
87
87
  */
88
88
  async function findPackageJson(directory) {
89
- const packageJson = JSON.parse(await require_utils.read((0, node_path.join)(directory, "package.json")).catch(() => "{}"));
89
+ const packageJson = JSON.parse(await require_spinner.read((0, node_path.join)(directory, "package.json")).catch(() => "{}"));
90
90
  if (packageJson.name && packageJson.version) return {
91
91
  name: packageJson.name,
92
92
  version: packageJson.version
@@ -201,13 +201,13 @@ async function snapshot(options) {
201
201
  require_reporters.setupReporters(hooks, {
202
202
  logLevel: logLevel > _kubb_core.logLevel.info ? logLevel : _kubb_core.logLevel.silent,
203
203
  reporters: [_kubb_core.cliReporter],
204
- writer: require_text.createPlainWriter(write)
204
+ writer: require_intro.createPlainWriter(write)
205
205
  });
206
206
  const step = (message) => {
207
207
  if (logLevel > _kubb_core.logLevel.silent) write(message);
208
208
  };
209
209
  hooks.hook("kubb:generation:end", ({ filesCreated = 0, status, hrStart }) => {
210
- if (status !== "failed" && hrStart) step(`✓ Generated ${require_text.pluralize(filesCreated, "file")} in ${require_Telemetry.formatMs(require_Telemetry.getElapsedMs(hrStart))}`);
210
+ if (status !== "failed" && hrStart) step(`✓ Generated ${require_text.pluralize(filesCreated, "file")} in ${require_time.formatMs(require_time.getElapsedMs(hrStart))}`);
211
211
  });
212
212
  try {
213
213
  const published = await (0, _kubb_studio.createSnapshot)({
@@ -245,7 +245,6 @@ const runner = ({ values }) => require_run.runStudio(values, (options) => snapsh
245
245
  packageVersion: values.packageVersion,
246
246
  json: values.json
247
247
  }), { json: values.json });
248
- //#endregion
249
248
  exports.runner = runner;
250
249
 
251
- //# sourceMappingURL=snapshot-laSRD0z1.cjs.map
250
+ //# sourceMappingURL=snapshot-D7Ytw8S0.cjs.map