@kubb/cli 5.14.6 → 5.15.1
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.
- package/bin/kubb.js +2 -1
- package/dist/{Telemetry-B5V_ufmv.cjs → Telemetry-B52pKz9i.cjs} +14 -118
- package/dist/Telemetry-B52pKz9i.cjs.map +1 -0
- package/dist/{Telemetry-DrnGartf.js → Telemetry-C7Qwy2s7.js} +12 -86
- package/dist/Telemetry-C7Qwy2s7.js.map +1 -0
- package/dist/{background-DlK0by5c.js → background-BJCuXYuB.js} +5 -6
- package/dist/{background-DlK0by5c.js.map → background-BJCuXYuB.js.map} +1 -1
- package/dist/{background-CdPT1eaq.cjs → background-CK2gQtTU.cjs} +5 -6
- package/dist/{background-CdPT1eaq.cjs.map → background-CK2gQtTU.cjs.map} +1 -1
- package/dist/{background-C6XHpEo7.js → background-D4mZCg-4.js} +1 -1
- package/dist/banner-BdTTDFkG.js +140 -0
- package/dist/banner-BdTTDFkG.js.map +1 -0
- package/dist/banner-wJFk-L-c.cjs +163 -0
- package/dist/banner-wJFk-L-c.cjs.map +1 -0
- package/dist/config-BL3HnFhb.js +1 -0
- package/dist/config-BWj9jBVj.cjs +62 -0
- package/dist/config-BWj9jBVj.cjs.map +1 -0
- package/dist/{config-CNqgDSu3.js → config-CQTxXvIG.js} +6 -52
- package/dist/config-CQTxXvIG.js.map +1 -0
- package/dist/{config-BG_Nr2CZ.cjs → config-CRrmj88c.cjs} +15 -62
- package/dist/config-CRrmj88c.cjs.map +1 -0
- package/dist/config-Uk3rbZfb.js +49 -0
- package/dist/config-Uk3rbZfb.js.map +1 -0
- package/dist/configFile-C0DIXNMD.js +993 -0
- package/dist/configFile-C0DIXNMD.js.map +1 -0
- package/dist/configFile-CoEpHdXG.cjs +1028 -0
- package/dist/configFile-CoEpHdXG.cjs.map +1 -0
- package/dist/{credentials-C8tjAhTo.js → credentials-B77iJx9H.js} +1 -1
- package/dist/{credentials-DDaKqtJn.cjs → credentials-DEsGwcGD.cjs} +3 -4
- package/dist/{credentials-DDaKqtJn.cjs.map → credentials-DEsGwcGD.cjs.map} +1 -1
- package/dist/{credentials-CZK6zPLv.js → credentials-osgjujE_.js} +3 -4
- package/dist/{credentials-CZK6zPLv.js.map → credentials-osgjujE_.js.map} +1 -1
- package/dist/env-C3xHRMez.js +1 -0
- package/dist/env-eu3XyKqJ.cjs +55 -0
- package/dist/env-eu3XyKqJ.cjs.map +1 -0
- package/dist/env-rv-VgSGN.js +34 -0
- package/dist/env-rv-VgSGN.js.map +1 -0
- package/dist/{errors-Cl69p_vI.cjs → errors-BponpdjN.cjs} +3 -4
- package/dist/{errors-Cl69p_vI.cjs.map → errors-BponpdjN.cjs.map} +1 -1
- package/dist/{errors-DmC83ALX.js → errors-wzqmMpMo.js} +3 -4
- package/dist/{errors-DmC83ALX.js.map → errors-wzqmMpMo.js.map} +1 -1
- package/dist/index.cjs +37 -2719
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +35 -2713
- package/dist/index.js.map +1 -1
- package/dist/installWithSpinner-DpnpxHq5.js +49 -0
- package/dist/installWithSpinner-DpnpxHq5.js.map +1 -0
- package/dist/installWithSpinner-ONGfIVUJ.cjs +56 -0
- package/dist/installWithSpinner-ONGfIVUJ.cjs.map +1 -0
- package/dist/{text-CL6N6yPS.js → intro-9PB8sE8z.js} +8 -52
- package/dist/intro-9PB8sE8z.js.map +1 -0
- package/dist/{text-DrsG1EDN.cjs → intro-YPaf1Imr.cjs} +12 -80
- package/dist/intro-YPaf1Imr.cjs.map +1 -0
- package/dist/isCIEnvironment-D6xtAAZ2.js +14 -0
- package/dist/isCIEnvironment-D6xtAAZ2.js.map +1 -0
- package/dist/isCIEnvironment-DiVOMI5Q.cjs +20 -0
- package/dist/isCIEnvironment-DiVOMI5Q.cjs.map +1 -0
- package/dist/mascot--q1xjKw1.js +63 -0
- package/dist/mascot--q1xjKw1.js.map +1 -0
- package/dist/mascot-JSA0j3Q_.cjs +80 -0
- package/dist/mascot-JSA0j3Q_.cjs.map +1 -0
- package/dist/mcp-CcseJJwh.cjs +20 -0
- package/dist/mcp-CcseJJwh.cjs.map +1 -0
- package/dist/mcp-DUTsS8tR.js +21 -0
- package/dist/mcp-DUTsS8tR.js.map +1 -0
- package/dist/package-B1hUUjio.cjs +10 -0
- package/dist/package-B1hUUjio.cjs.map +1 -0
- package/dist/package-MYPMnnTX.js +5 -0
- package/dist/package-MYPMnnTX.js.map +1 -0
- package/dist/{registry-DOGpflct.js → registry-B3eYk4LN.js} +7 -67
- package/dist/registry-B3eYk4LN.js.map +1 -0
- package/dist/{registry-BzBp6aZI.cjs → registry-YE1pFWL-.cjs} +4 -82
- package/dist/registry-YE1pFWL-.cjs.map +1 -0
- package/dist/{reporters-GzXlc4CK.cjs → reporters-2cgjvXwR.cjs} +32 -40
- package/dist/{reporters-GzXlc4CK.cjs.map → reporters-2cgjvXwR.cjs.map} +1 -1
- package/dist/{reporters-mYHIUZSx.js → reporters-BM430HdQ.js} +19 -27
- package/dist/{reporters-mYHIUZSx.js.map → reporters-BM430HdQ.js.map} +1 -1
- package/dist/{rolldown-runtime-CPE0t6oh.cjs → rolldown-runtime-C3-Zg-KD.cjs} +1 -2
- package/dist/{rolldown-runtime-CRm0XQPb.js → rolldown-runtime-xo6NMXYd.js} +1 -2
- package/dist/run-1H9TGT8v.js +77 -0
- package/dist/run-1H9TGT8v.js.map +1 -0
- package/dist/run-BYP_t9dR.cjs +324 -0
- package/dist/run-BYP_t9dR.cjs.map +1 -0
- package/dist/run-Bq6gcfkS.js +1 -0
- package/dist/run-BrM7-NSV.js +181 -0
- package/dist/run-BrM7-NSV.js.map +1 -0
- package/dist/run-BsrNfFIl.js +228 -0
- package/dist/run-BsrNfFIl.js.map +1 -0
- package/dist/{run-l8IiOR_c.js → run-CLiHI99L.js} +9 -9
- package/dist/{run-l8IiOR_c.js.map → run-CLiHI99L.js.map} +1 -1
- package/dist/{run-C8Prej7s.cjs → run-CQORv7Gq.cjs} +44 -37
- package/dist/run-CQORv7Gq.cjs.map +1 -0
- package/dist/{run-EJtgdIin.js → run-CXVhxFfC.js} +31 -23
- package/dist/run-CXVhxFfC.js.map +1 -0
- package/dist/run-CrM4jsix.cjs +80 -0
- package/dist/run-CrM4jsix.cjs.map +1 -0
- package/dist/run-CvFakE3B.cjs +185 -0
- package/dist/run-CvFakE3B.cjs.map +1 -0
- package/dist/{run-DC_xH5H3.cjs → run-CyzKy-0p.cjs} +49 -41
- package/dist/run-CyzKy-0p.cjs.map +1 -0
- package/dist/run-D-nn9-Wq.js +319 -0
- package/dist/run-D-nn9-Wq.js.map +1 -0
- package/dist/run-DBnSbwtU.cjs +389 -0
- package/dist/run-DBnSbwtU.cjs.map +1 -0
- package/dist/{run-j1g5si5R.js → run-DTqMrPS9.js} +5 -6
- package/dist/{run-j1g5si5R.js.map → run-DTqMrPS9.js.map} +1 -1
- package/dist/{run-9fs2T2Je.js → run-DUwX6Icx.js} +26 -20
- package/dist/run-DUwX6Icx.js.map +1 -0
- package/dist/run-FEiyv6_U.js +385 -0
- package/dist/run-FEiyv6_U.js.map +1 -0
- package/dist/run-LY_UAYyM.cjs +233 -0
- package/dist/run-LY_UAYyM.cjs.map +1 -0
- package/dist/{run-sjzj0ir-.cjs → run-dMTJfs4_.cjs} +10 -10
- package/dist/{run-sjzj0ir-.cjs.map → run-dMTJfs4_.cjs.map} +1 -1
- package/dist/{run-CypFtkVE.cjs → run-uPA5s3rI.cjs} +5 -6
- package/dist/{run-CypFtkVE.cjs.map → run-uPA5s3rI.cjs.map} +1 -1
- package/dist/shared-C0EtrdUm.cjs +123 -0
- package/dist/shared-C0EtrdUm.cjs.map +1 -0
- package/dist/shared-Ct9stKpp.js +94 -0
- package/dist/shared-Ct9stKpp.js.map +1 -0
- package/dist/{snapshot-laSRD0z1.cjs → snapshot-CPF9zyZj.cjs} +13 -14
- package/dist/{snapshot-laSRD0z1.cjs.map → snapshot-CPF9zyZj.cjs.map} +1 -1
- package/dist/{snapshot-BJWnL6hE.js → snapshot-CiV08NJr.js} +10 -11
- package/dist/{snapshot-BJWnL6hE.js.map → snapshot-CiV08NJr.js.map} +1 -1
- package/dist/spinner-BZaln7O8.js +160 -0
- package/dist/spinner-BZaln7O8.js.map +1 -0
- package/dist/spinner-CfB0sIPy.cjs +208 -0
- package/dist/spinner-CfB0sIPy.cjs.map +1 -0
- package/dist/{status-DFEdbBPu.cjs → status-C066YA-4.cjs} +7 -8
- package/dist/{status-DFEdbBPu.cjs.map → status-C066YA-4.cjs.map} +1 -1
- package/dist/{status-BjmXLRm2.js → status-Dj8tivag.js} +6 -7
- package/dist/{status-BjmXLRm2.js.map → status-Dj8tivag.js.map} +1 -1
- package/dist/studio-B4XsXgKj.js +215 -0
- package/dist/studio-B4XsXgKj.js.map +1 -0
- package/dist/studio-D9_-mKee.cjs +218 -0
- package/dist/studio-D9_-mKee.cjs.map +1 -0
- package/dist/studioWorker.js +4 -5
- package/dist/{summary-DDnI70tn.js → summary-CbmQKA8l.js} +5 -6
- package/dist/{summary-DDnI70tn.js.map → summary-CbmQKA8l.js.map} +1 -1
- package/dist/{summary-1DCwzWEU.cjs → summary-Clvl5Hxs.cjs} +7 -8
- package/dist/{summary-1DCwzWEU.cjs.map → summary-Clvl5Hxs.cjs.map} +1 -1
- package/dist/table-BlRe9YTZ.cjs +15 -0
- package/dist/table-BlRe9YTZ.cjs.map +1 -0
- package/dist/table-CR7iZJGo.js +10 -0
- package/dist/table-CR7iZJGo.js.map +1 -0
- package/dist/text-BmiI4s6N.js +13 -0
- package/dist/text-BmiI4s6N.js.map +1 -0
- package/dist/text-Ep3AulAS.cjs +24 -0
- package/dist/text-Ep3AulAS.cjs.map +1 -0
- package/dist/time-3BKoci3G.cjs +82 -0
- package/dist/time-3BKoci3G.cjs.map +1 -0
- package/dist/time-C-wU7VhC.js +65 -0
- package/dist/time-C-wU7VhC.js.map +1 -0
- package/dist/utils-BdibacYq.js +244 -0
- package/dist/utils-BdibacYq.js.map +1 -0
- package/dist/utils-CO89mxRU.cjs +290 -0
- package/dist/utils-CO89mxRU.cjs.map +1 -0
- package/dist/utils-CbJ6hS_t.js +222 -0
- package/dist/utils-CbJ6hS_t.js.map +1 -0
- package/dist/utils-CcARPB45.cjs +286 -0
- package/dist/utils-CcARPB45.cjs.map +1 -0
- package/dist/validate-B3tLWYJU.cjs +27 -0
- package/dist/validate-B3tLWYJU.cjs.map +1 -0
- package/dist/validate-C5fyNF4v.js +28 -0
- package/dist/validate-C5fyNF4v.js.map +1 -0
- package/package.json +7 -7
- package/dist/Telemetry-B5V_ufmv.cjs.map +0 -1
- package/dist/Telemetry-DrnGartf.js.map +0 -1
- package/dist/config-BG_Nr2CZ.cjs.map +0 -1
- package/dist/config-CNqgDSu3.js.map +0 -1
- package/dist/config-DWDpFSn1.js +0 -1
- package/dist/registry-BzBp6aZI.cjs.map +0 -1
- package/dist/registry-DOGpflct.js.map +0 -1
- package/dist/run-9fs2T2Je.js.map +0 -1
- package/dist/run-C8Prej7s.cjs.map +0 -1
- package/dist/run-CXVme-aS.js +0 -1
- package/dist/run-DC_xH5H3.cjs.map +0 -1
- package/dist/run-EJtgdIin.js.map +0 -1
- package/dist/text-CL6N6yPS.js.map +0 -1
- package/dist/text-DrsG1EDN.cjs.map +0 -1
- package/dist/utils-C3vTpUje.cjs +0 -645
- package/dist/utils-C3vTpUje.cjs.map +0 -1
- package/dist/utils-CIc8YFtr.js +0 -536
- package/dist/utils-CIc8YFtr.js.map +0 -1
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
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_utils = require("./utils-CcARPB45.cjs");
|
|
5
|
+
const require_package = require("./package-B1hUUjio.cjs");
|
|
6
|
+
const require_Telemetry = require("./Telemetry-B52pKz9i.cjs");
|
|
7
|
+
const require_intro = require("./intro-YPaf1Imr.cjs");
|
|
8
|
+
const require_mascot = require("./mascot-JSA0j3Q_.cjs");
|
|
9
|
+
const require_config = require("./config-BWj9jBVj.cjs");
|
|
10
|
+
const require_registry = require("./registry-YE1pFWL-.cjs");
|
|
11
|
+
const require_text = require("./text-Ep3AulAS.cjs");
|
|
12
|
+
const require_reporters = require("./reporters-2cgjvXwR.cjs");
|
|
8
13
|
let node_util = require("node:util");
|
|
9
14
|
let node_process = require("node:process");
|
|
10
15
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
11
16
|
let node_path = require("node:path");
|
|
12
17
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
13
18
|
let _kubb_core = require("@kubb/core");
|
|
14
|
-
|
|
19
|
+
// src/runners/generate/run.ts
|
|
15
20
|
/** NPM registry endpoint used to check for @kubb/cli updates. */
|
|
16
21
|
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
17
22
|
/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */
|
|
@@ -35,7 +40,7 @@ async function generate(options) {
|
|
|
35
40
|
};
|
|
36
41
|
const kubb = (0, _kubb_core.createKubb)(config, { hooks });
|
|
37
42
|
const result = await kubb.generate();
|
|
38
|
-
|
|
43
|
+
report({
|
|
39
44
|
plugins: kubb.config.plugins.flatMap((p) => p && typeof p === "object" ? [{
|
|
40
45
|
name: p.meta?.name ?? p.name ?? "",
|
|
41
46
|
options: p.options ?? {}
|
|
@@ -45,21 +50,20 @@ async function generate(options) {
|
|
|
45
50
|
});
|
|
46
51
|
return result.success;
|
|
47
52
|
}
|
|
48
|
-
/** The latest published version, `undefined` when the registry does not answer in time. Never rejects. */
|
|
49
|
-
async function fetchLatestVersion() {
|
|
53
|
+
/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */
|
|
54
|
+
async function fetchLatestVersion(signal) {
|
|
50
55
|
try {
|
|
51
|
-
return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })).json()).version;
|
|
56
|
+
return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })).json()).version;
|
|
52
57
|
} catch {
|
|
53
58
|
return;
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
|
-
async function checkForUpdate({ hooks,
|
|
57
|
-
const latestVersion = await latest;
|
|
61
|
+
async function checkForUpdate({ hooks, latestVersion }) {
|
|
58
62
|
if (latestVersion && require_registry.isOutdated({
|
|
59
|
-
installed:
|
|
63
|
+
installed: require_package.version,
|
|
60
64
|
latest: latestVersion
|
|
61
65
|
})) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
|
|
62
|
-
currentVersion:
|
|
66
|
+
currentVersion: require_package.version,
|
|
63
67
|
latestVersion
|
|
64
68
|
}));
|
|
65
69
|
}
|
|
@@ -71,15 +75,19 @@ function logRebuild({ diff: { schemas, operations }, durationMs }) {
|
|
|
71
75
|
operations.added && (0, node_util.styleText)("green", `+${require_text.pluralize(operations.added, "operation")}`),
|
|
72
76
|
operations.removed && (0, node_util.styleText)("red", `-${require_text.pluralize(operations.removed, "operation")}`)
|
|
73
77
|
].filter(Boolean).join(" ");
|
|
74
|
-
|
|
78
|
+
require_intro.logStep([`Rebuilt in ${require_time.formatMs(durationMs)}`, specChange].filter(Boolean).join((0, node_util.styleText)("dim", " · ")));
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* Runs the full Kubb generation lifecycle for the given CLI options.
|
|
78
82
|
* Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),
|
|
79
|
-
*
|
|
83
|
+
* calls `generate` for each config entry, and prints an update notice when the registry answered in time.
|
|
80
84
|
*/
|
|
81
85
|
async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }) {
|
|
82
|
-
const
|
|
86
|
+
const updateCheck = new AbortController();
|
|
87
|
+
let latestVersion;
|
|
88
|
+
fetchLatestVersion(updateCheck.signal).then((value) => {
|
|
89
|
+
latestVersion = value;
|
|
90
|
+
});
|
|
83
91
|
const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
|
|
84
92
|
const hooks = new _kubb_core.Hookable();
|
|
85
93
|
const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
|
|
@@ -89,9 +97,9 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
89
97
|
if (json) require_reporters.setupReporters(errorHooks, {
|
|
90
98
|
logLevel,
|
|
91
99
|
reporters: [_kubb_core.cliReporter],
|
|
92
|
-
writer:
|
|
100
|
+
writer: require_intro.createPlainWriter(console.error)
|
|
93
101
|
});
|
|
94
|
-
const banner = quiet ? void 0 :
|
|
102
|
+
const banner = quiet ? void 0 : require_mascot.logBanner(require_package.version);
|
|
95
103
|
const loading = require_config.getConfigs({
|
|
96
104
|
configPath,
|
|
97
105
|
input,
|
|
@@ -100,8 +108,8 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
100
108
|
});
|
|
101
109
|
loading.catch(() => void 0);
|
|
102
110
|
await banner;
|
|
103
|
-
if (!quiet)
|
|
104
|
-
const configSpinner =
|
|
111
|
+
if (!quiet) require_intro.logIntro({ title: "Configuration" });
|
|
112
|
+
const configSpinner = require_spinner.createSpinner();
|
|
105
113
|
let configs;
|
|
106
114
|
let resolvedConfigPath;
|
|
107
115
|
try {
|
|
@@ -117,7 +125,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
117
125
|
reporters: [_kubb_core.cliReporter]
|
|
118
126
|
});
|
|
119
127
|
await _kubb_core.Diagnostics.emit(errorHooks, error);
|
|
120
|
-
if (!quiet)
|
|
128
|
+
if (!quiet) require_intro.logOutro((0, node_util.styleText)("red", "✗ Configuration failed"));
|
|
121
129
|
node_process.default.exit(1);
|
|
122
130
|
}
|
|
123
131
|
const available = configs[0]?.reporters?.length ? configs[0].reporters : [
|
|
@@ -132,12 +140,8 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
132
140
|
reporters,
|
|
133
141
|
dryRun
|
|
134
142
|
});
|
|
135
|
-
await hooks.callHook("kubb:lifecycle:start", { version:
|
|
136
|
-
|
|
137
|
-
hooks,
|
|
138
|
-
latest
|
|
139
|
-
});
|
|
140
|
-
if (!quiet) require_text.logOutro(`${require_text.pluralize(configs.length, "config")} ready`);
|
|
143
|
+
await hooks.callHook("kubb:lifecycle:start", { version: require_package.version });
|
|
144
|
+
if (!quiet) require_intro.logOutro(`${require_text.pluralize(configs.length, "config")} ready`);
|
|
141
145
|
try {
|
|
142
146
|
let anyFailed = false;
|
|
143
147
|
const tracker = watch ? require_utils.trackBuild(hooks) : void 0;
|
|
@@ -161,14 +165,14 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
161
165
|
const snapshot = tracker.take();
|
|
162
166
|
if (previous) logRebuild({
|
|
163
167
|
diff: require_utils.diffBuilds(previous, snapshot),
|
|
164
|
-
durationMs:
|
|
168
|
+
durationMs: require_time.getElapsedMs(hrStart)
|
|
165
169
|
});
|
|
166
170
|
previous = snapshot;
|
|
167
|
-
|
|
171
|
+
require_intro.logStep(armKeys ? `${label} ${(0, node_util.styleText)("dim", "r rebuild · q quit")}` : label);
|
|
168
172
|
armKeys?.();
|
|
169
173
|
if (succeeded) {
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
require_intro.logSpacer();
|
|
175
|
+
require_intro.logTip();
|
|
172
176
|
}
|
|
173
177
|
};
|
|
174
178
|
let pending = false;
|
|
@@ -188,11 +192,11 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
188
192
|
});
|
|
189
193
|
await rebuild();
|
|
190
194
|
await require_utils.startWatcher([watchPath], rebuild, {
|
|
191
|
-
info:
|
|
192
|
-
error:
|
|
195
|
+
info: require_intro.logInfo,
|
|
196
|
+
error: require_intro.logError
|
|
193
197
|
});
|
|
194
198
|
} else {
|
|
195
|
-
if (tracker && !quiet)
|
|
199
|
+
if (tracker && !quiet) require_intro.logWarn("Watch mode only follows a local `input` file, so this config is generated once.");
|
|
196
200
|
try {
|
|
197
201
|
if (!await generate({
|
|
198
202
|
input,
|
|
@@ -206,16 +210,20 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
}
|
|
213
|
+
updateCheck.abort();
|
|
214
|
+
await checkForUpdate({
|
|
215
|
+
hooks,
|
|
216
|
+
latestVersion
|
|
217
|
+
});
|
|
209
218
|
await hooks.callHook("kubb:lifecycle:end");
|
|
210
|
-
if (!quiet && !watch && !anyFailed)
|
|
211
|
-
if (anyFailed) node_process.default.
|
|
219
|
+
if (!quiet && !watch && !anyFailed) require_intro.logTip();
|
|
220
|
+
if (anyFailed) node_process.default.exitCode = 1;
|
|
212
221
|
} catch (error) {
|
|
213
222
|
await _kubb_core.Diagnostics.emit(errorHooks, error);
|
|
214
223
|
node_process.default.exit(1);
|
|
215
224
|
}
|
|
216
225
|
}
|
|
217
|
-
//#endregion
|
|
218
226
|
exports.generate = generate;
|
|
219
227
|
exports.run = run;
|
|
220
228
|
|
|
221
|
-
//# sourceMappingURL=run-
|
|
229
|
+
//# sourceMappingURL=run-CyzKy-0p.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-CyzKy-0p.cjs","names":["trackRun","process","memoryStorage","createKubb","isOutdated","version","Diagnostics","styleText","pluralize","formatMs","logLevelMap","Hookable","cliReporter","createPlainWriter","logBanner","getConfigs","createSpinner","path","jsonReporter","fileReporter","htmlReporter","selectReporters","trackBuild","getInputKind","diffBuilds","getElapsedMs","listenForKeys","startWatcher","logInfo","logError"],"sources":["../src/runners/generate/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, skips formatting, linting, and\n * post-generate commands, and prints what would change on disk.\n */\n dryRun?: boolean\n}\n\nexport async function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n // Not awaited: the request finishes in the background, capped by its timeout, so it never delays the summary.\n void report({\n // A setup that threw leaves no driver, so read the configured plugins instead.\n plugins: kubb.config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n const data = (await res.json()) as { version: string }\n return data.version\n } catch {\n // Ignore network errors\n return undefined\n }\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when the registry answered in time.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n // Started first and never awaited: the notice prints at the end only when the registry has answered by then.\n const updateCheck = new AbortController()\n let latestVersion: string | undefined\n void fetchLatestVersion(updateCheck.signal).then((value) => {\n latestVersion = value\n })\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // Errors raised outside a build have no report entry. In `json` mode they go to a stderr logger,\n // so they are never silent and stdout stays one JSON document.\n const errorHooks = json ? new Hookable<KubbHooks>() : hooks\n if (json) setupReporters(errorHooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays; the output still prints in order once the banner is done.\n const banner = quiet ? undefined : logBanner(version)\n const loading = getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n // Handled below; this keeps a rejection during the banner from counting as unhandled.\n loading.catch(() => undefined)\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(errorHooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n // One tracker, one key listener and one build queue serve every watched config, so several configs never mix diffs or answer `r` twice.\n const tracker = watch ? trackBuild(hooks) : undefined\n const rebuilds: Array<() => Promise<void>> = []\n let armKeys: (() => void) | undefined\n // Configs share the hooks emitter, so every build, from any watcher or the `r` key, waits for the one before it.\n let queue = Promise.resolve()\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' ? (effectiveInput as string) : undefined\n if (watchPath && tracker) {\n const label = styleText('yellow', `Watching ${path.relative(process.cwd(), watchPath)}`)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n const succeeded = await generate({ input, config, hooks, dryRun })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while this config's build is queued joins it; one that lands during the build queues one more. Never rejects.\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(errorHooks, error))\n return queue\n }\n rebuilds.push(rebuild)\n if (!quiet) {\n armKeys ??= listenForKeys({\n rebuild: () => rebuilds.forEach((trigger) => void trigger()),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n }\n\n // The watcher ignores its startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n await rebuild()\n\n await startWatcher([watchPath], rebuild, { info: logInfo, error: logError })\n } else {\n if (tracker && !quiet) logWarn('Watch mode only follows a local `input` file, so this config is generated once.')\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await Diagnostics.emit(errorHooks, configError)\n anyFailed = true\n }\n }\n }\n\n // A request still in flight would keep the process alive until its timeout.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (anyFailed) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(errorHooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAqBhC,eAAsB,SAAS,SAA0C;CACvE,MAAM,EAAE,OAAO,OAAO,SAAS,UAAU;CAEzC,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAY,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAE1E,MAAM,SAAiB;EACrB,GAAG,QAAQ;EACX,OAAO,SAAS,QAAQ,OAAO;EAE/B,SAAS,UAAA,GAASC,WAAAA,cAAAA,CAAc,IAAI,QAAQ,OAAO;EAEnD,QAAQ,SAAS;GAAE,GAAG,QAAQ,OAAO;GAAQ,QAAQ;GAAO,MAAM;GAAO,cAAc,CAAC;EAAE,IAAI,QAAQ,OAAO;CAC/G;CAIA,MAAM,QAAA,GAAOC,WAAAA,WAAAA,CAAW,QAAQ,EAAE,MAAM,CAAC;CACzC,MAAM,SAAS,MAAM,KAAK,SAAS;CAGnC,OAAY;EAEV,SAAS,KAAK,OAAO,QAAQ,SAAS,MACpC,KAAK,OAAO,MAAM,WAAW,CAAC;GAAE,MAAM,EAAE,MAAM,QAAQ,EAAE,QAAQ;GAAI,SAAU,EAAE,WAAW,CAAC;EAA8B,CAAC,IAAI,CAAC,CAClI;EACA,cAAc,OAAO,MAAM;EAC3B,QAAQ,OAAO,UAAU,YAAY;CACvC,CAAC;CAED,OAAO,OAAO;AAChB;;AAYA,eAAe,mBAAmB,QA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,SAAS,CAAC,SAAS,CAAC,WACvB,cAAA,OAAO;EAIT,IAAI,WACF,aAAA,QAAA,WAAmB;CAEvB,SAAS,OAAO;EACd,MAAMA,WAAAA,YAAY,KAAK,YAAY,KAAK;EACxC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import { a as ConfigEditOperation, i as readImports, n as editConfigFile, o as extensionKinds, t as editConfig } from "./configFile-C0DIXNMD.js";
|
|
3
|
+
import { t as getErrorMessage } from "./errors-wzqmMpMo.js";
|
|
4
|
+
import { n as withSpinner, o as read } from "./spinner-BZaln7O8.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 { o as yesArg, t as configArg } from "./shared-Ct9stKpp.js";
|
|
7
|
+
import { r as BUNDLED_PACKAGES, t as findConfigFile } from "./config-CQTxXvIG.js";
|
|
8
|
+
import { t as logCommandSummary } from "./summary-CbmQKA8l.js";
|
|
9
|
+
import { a as installSpec, c as toRegistryId, i as incompatibility, l as toShortId, n as closestIds, r as fetchRegistryIndex, s as registryUrl } from "./registry-B3eYk4LN.js";
|
|
10
|
+
import { n as detectPackageManager } from "./utils-CbJ6hS_t.js";
|
|
11
|
+
import { t as installWithSpinner } from "./installWithSpinner-DpnpxHq5.js";
|
|
12
|
+
import { styleText } from "node:util";
|
|
13
|
+
import { define } from "gunshi";
|
|
14
|
+
import process from "node:process";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import * as clack from "@clack/prompts";
|
|
17
|
+
import { Diagnostics, readInstalledPackages } from "@kubb/core";
|
|
18
|
+
// src/runners/add/run.ts
|
|
19
|
+
/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */
|
|
20
|
+
function toSnippet({ artifact, manifest }) {
|
|
21
|
+
const call = `${manifest.export}()`;
|
|
22
|
+
const property = {
|
|
23
|
+
plugin: `plugins: [..., ${call}],`,
|
|
24
|
+
adapter: `adapter: ${call},`,
|
|
25
|
+
parser: `parsers: [..., ${call}],`
|
|
26
|
+
};
|
|
27
|
+
return [
|
|
28
|
+
`import { ${manifest.export} } from '${artifact.package}'`,
|
|
29
|
+
"",
|
|
30
|
+
property[manifest.kind]
|
|
31
|
+
].join("\n");
|
|
32
|
+
}
|
|
33
|
+
/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */
|
|
34
|
+
function toConfigEdits(details) {
|
|
35
|
+
return {
|
|
36
|
+
edits: details.map(({ artifact, manifest }) => ({
|
|
37
|
+
operation: ConfigEditOperation.ADD_PLUGIN,
|
|
38
|
+
...manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {},
|
|
39
|
+
plugin: artifact.package
|
|
40
|
+
})),
|
|
41
|
+
extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, {
|
|
42
|
+
package: artifact.package,
|
|
43
|
+
version: artifact.version,
|
|
44
|
+
manifest
|
|
45
|
+
}]))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */
|
|
49
|
+
function previewConfig({ details, source }) {
|
|
50
|
+
const result = editConfig({
|
|
51
|
+
source,
|
|
52
|
+
...toConfigEdits(details)
|
|
53
|
+
});
|
|
54
|
+
const failed = result.outcomes.find((outcome) => !outcome.applied);
|
|
55
|
+
if (failed) return { reason: failed.reason ?? "the config file was not changed" };
|
|
56
|
+
const remaining = source.split("\n");
|
|
57
|
+
return {
|
|
58
|
+
lines: result.source.split("\n").filter((line) => {
|
|
59
|
+
const index = remaining.indexOf(line);
|
|
60
|
+
if (index !== -1) remaining.splice(index, 1);
|
|
61
|
+
return index === -1;
|
|
62
|
+
}).map((line) => line.trim()),
|
|
63
|
+
source: result.source
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function selectExtension({ entries, versions, registry }) {
|
|
67
|
+
if (!entries.length) throw new Diagnostics.Error({
|
|
68
|
+
code: Diagnostics.code.unknown,
|
|
69
|
+
severity: "error",
|
|
70
|
+
message: `The registry at ${registry} lists no extensions.`,
|
|
71
|
+
help: "Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry."
|
|
72
|
+
});
|
|
73
|
+
const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]));
|
|
74
|
+
const options = entries.toSorted((a, b) => a.id.localeCompare(b.id)).map((entry) => {
|
|
75
|
+
const installed = versions.has(entry.artifact.package);
|
|
76
|
+
return {
|
|
77
|
+
value: entry.id,
|
|
78
|
+
label: toShortId(entry.id),
|
|
79
|
+
hint: installed ? "installed" : summarize(entry.manifest.description),
|
|
80
|
+
disabled: installed
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
const id = await clack.autocomplete({
|
|
84
|
+
message: `Add an extension · ${entries.length} in the registry`,
|
|
85
|
+
placeholder: "Search",
|
|
86
|
+
options,
|
|
87
|
+
filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false
|
|
88
|
+
});
|
|
89
|
+
return clack.isCancel(id) ? void 0 : id;
|
|
90
|
+
}
|
|
91
|
+
/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */
|
|
92
|
+
async function confirmDependencies({ entry, missing, yes }) {
|
|
93
|
+
if (!missing.length || yes) return true;
|
|
94
|
+
const names = missing.map((dependency) => dependency.manifest.name).join(", ");
|
|
95
|
+
const answer = await clack.select({
|
|
96
|
+
message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,
|
|
97
|
+
options: [{
|
|
98
|
+
value: true,
|
|
99
|
+
label: `Yes, add ${missing.length === 1 ? "both" : "all"}`,
|
|
100
|
+
hint: "recommended"
|
|
101
|
+
}, {
|
|
102
|
+
value: false,
|
|
103
|
+
label: `Only ${entry.manifest.name}`,
|
|
104
|
+
hint: "generate fails until you add it"
|
|
105
|
+
}],
|
|
106
|
+
initialValue: true
|
|
107
|
+
});
|
|
108
|
+
return clack.isCancel(answer) ? void 0 : answer;
|
|
109
|
+
}
|
|
110
|
+
/** The first sentence of a registry description, cut to one terminal line. */
|
|
111
|
+
function summarize(description, max = 64) {
|
|
112
|
+
const sentence = description.split(/\.\s/)[0].replace(/\.$/, "");
|
|
113
|
+
return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Installs an extension from the Kubb registry at its reviewed version and, for a plugin or a parser,
|
|
117
|
+
* adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never
|
|
118
|
+
* written: the command prints the snippet to swap it in by hand. Without an id, asks which one.
|
|
119
|
+
* Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js
|
|
120
|
+
* version is outside its compatibility.
|
|
121
|
+
*/
|
|
122
|
+
async function run({ id: input, configPath, yes, install }) {
|
|
123
|
+
const cwd = process.cwd();
|
|
124
|
+
const hrStart = process.hrtime();
|
|
125
|
+
const summary = (title, status, lines) => logCommandSummary({
|
|
126
|
+
title,
|
|
127
|
+
status,
|
|
128
|
+
hrStart,
|
|
129
|
+
block: true,
|
|
130
|
+
lines
|
|
131
|
+
});
|
|
132
|
+
const installedPackages = [];
|
|
133
|
+
const configured = [];
|
|
134
|
+
logIntro({ title: isInteractiveRun({ yes }) ? void 0 : styleText("bgCyan", styleText("black", " Kubb Add ")) });
|
|
135
|
+
try {
|
|
136
|
+
const registry = registryUrl();
|
|
137
|
+
if (!input && yes) throw new Diagnostics.Error({
|
|
138
|
+
code: Diagnostics.code.unknown,
|
|
139
|
+
severity: "error",
|
|
140
|
+
message: "Pass a registry id, such as plugin-zod, when using --yes.",
|
|
141
|
+
help: "Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list."
|
|
142
|
+
});
|
|
143
|
+
const inputId = input ? toRegistryId(input) : void 0;
|
|
144
|
+
const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd);
|
|
145
|
+
const [entries, installed, configSource] = await withSpinner({
|
|
146
|
+
message: "Reading the registry",
|
|
147
|
+
promise: Promise.all([
|
|
148
|
+
fetchRegistryIndex({ registry }),
|
|
149
|
+
readInstalledPackages({ root: cwd }),
|
|
150
|
+
foundConfig ? read(foundConfig).catch(() => void 0) : void 0
|
|
151
|
+
])
|
|
152
|
+
});
|
|
153
|
+
const versions = new Map(installed.map((item) => [item.package, item.version]));
|
|
154
|
+
const id = inputId ?? await selectExtension({
|
|
155
|
+
entries,
|
|
156
|
+
versions,
|
|
157
|
+
registry
|
|
158
|
+
});
|
|
159
|
+
if (!id) {
|
|
160
|
+
summary("Add canceled", "canceled", [" No changes made"]);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const entry = entries.find((candidate) => candidate.id === id);
|
|
164
|
+
if (!entry) {
|
|
165
|
+
const suggestions = closestIds({
|
|
166
|
+
input: id,
|
|
167
|
+
ids: entries.map((entry) => entry.id)
|
|
168
|
+
}).map(toShortId);
|
|
169
|
+
summary(`No extension named ${input ?? id}`, "failed", [...suggestions.map((suggestion) => ` kubb add ${suggestion}`), " Browse all kubb.dev/extensions"]);
|
|
170
|
+
process.exitCode = 1;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const { artifact, manifest } = entry;
|
|
174
|
+
const kind = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1);
|
|
175
|
+
const problem = incompatibility(manifest);
|
|
176
|
+
if (problem) throw new Diagnostics.Error({
|
|
177
|
+
code: Diagnostics.code.incompatibleExtension,
|
|
178
|
+
severity: "error",
|
|
179
|
+
message: problem,
|
|
180
|
+
help: "Upgrade Kubb or Node.js to a version the extension supports."
|
|
181
|
+
});
|
|
182
|
+
const configFile = manifest.kind === extensionKinds.adapter ? void 0 : foundConfig;
|
|
183
|
+
if (manifest.kind !== extensionKinds.adapter && !configFile) throw new Diagnostics.Error({
|
|
184
|
+
code: Diagnostics.code.unknown,
|
|
185
|
+
severity: "error",
|
|
186
|
+
message: "No kubb.config.ts found. Run `kubb init` first, or pass --config.",
|
|
187
|
+
help: "Run `kubb init` to create a config, or pass its path with `--config`."
|
|
188
|
+
});
|
|
189
|
+
const configName = configFile ? path.relative(cwd, configFile) || configFile : void 0;
|
|
190
|
+
const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]));
|
|
191
|
+
const inConfig = (name) => {
|
|
192
|
+
const dependency = byName.get(name);
|
|
193
|
+
return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name);
|
|
194
|
+
};
|
|
195
|
+
const dependencies = manifest.dependencies ?? [];
|
|
196
|
+
const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : [];
|
|
197
|
+
const withDependencies = await confirmDependencies({
|
|
198
|
+
entry,
|
|
199
|
+
missing,
|
|
200
|
+
yes
|
|
201
|
+
});
|
|
202
|
+
if (withDependencies === void 0) {
|
|
203
|
+
summary("Add canceled", "canceled", [` ${kind} ${manifest.name}`, " No changes made"]);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const targets = [...withDependencies ? missing : [], entry];
|
|
207
|
+
const dependencyStatus = (name) => {
|
|
208
|
+
if (inConfig(name)) return `${name} ${styleText("green", "✓ installed")}`;
|
|
209
|
+
return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText("cyan", "+ adding")}` : `${name} ${styleText("yellow", "missing")}`;
|
|
210
|
+
};
|
|
211
|
+
const preview = configFile && configSource !== void 0 ? previewConfig({
|
|
212
|
+
details: targets,
|
|
213
|
+
source: configSource
|
|
214
|
+
}) : void 0;
|
|
215
|
+
const before = readImports(configSource ?? "");
|
|
216
|
+
const added = preview && "lines" in preview ? readImports(preview.source).filter((name) => !before.includes(name)) : [];
|
|
217
|
+
const bundled = BUNDLED_PACKAGES.filter((name) => added.includes(name) && !versions.has(name) && !targets.some((target) => target.artifact.package === name));
|
|
218
|
+
const kubbVersion = versions.get("kubb");
|
|
219
|
+
const specs = [...targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact)), ...bundled.map((name) => kubbVersion ? `${name}@${kubbVersion}` : name)];
|
|
220
|
+
logStep(`${kind} ${styleText("cyan", manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`);
|
|
221
|
+
logBlock([
|
|
222
|
+
...dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(" ")}`] : [],
|
|
223
|
+
install ? `Installs ${specs.join(" ")}` : "Installs nothing (--no-install)",
|
|
224
|
+
...configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`],
|
|
225
|
+
...preview && "lines" in preview ? preview.lines.map((line) => styleText("green", ` + ${line}`)) : [],
|
|
226
|
+
...preview && "reason" in preview ? [styleText("yellow", ` cannot edit it: ${preview.reason}`)] : []
|
|
227
|
+
]);
|
|
228
|
+
const confirmed = yes || await clack.confirm({
|
|
229
|
+
message: "Add it?",
|
|
230
|
+
initialValue: true
|
|
231
|
+
});
|
|
232
|
+
if (clack.isCancel(confirmed) || !confirmed) {
|
|
233
|
+
summary("Add canceled", "canceled", [` ${kind} ${manifest.name}`, " No changes made"]);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const packageManager = detectPackageManager(cwd);
|
|
237
|
+
const packages = () => install ? `${installedPackages.length} installed with ${packageManager.name}` : "installation skipped (--no-install)";
|
|
238
|
+
if (install) {
|
|
239
|
+
const names = [...targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package), ...bundled];
|
|
240
|
+
await installWithSpinner({
|
|
241
|
+
packages: specs,
|
|
242
|
+
names: names.join(", "),
|
|
243
|
+
packageManager,
|
|
244
|
+
cwd
|
|
245
|
+
});
|
|
246
|
+
installedPackages.push(...names);
|
|
247
|
+
}
|
|
248
|
+
const unconfigured = configFile ? [] : [entry];
|
|
249
|
+
if (configFile) for (const target of targets) try {
|
|
250
|
+
const { outcomes, changed } = await editConfigFile({
|
|
251
|
+
filePath: configFile,
|
|
252
|
+
...toConfigEdits([target])
|
|
253
|
+
});
|
|
254
|
+
if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? "the config file was not changed");
|
|
255
|
+
if (changed) configured.push(target);
|
|
256
|
+
logStep(`${target.manifest.export}() configured in ${configName}`);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`);
|
|
259
|
+
unconfigured.push(target);
|
|
260
|
+
}
|
|
261
|
+
const manual = unconfigured.length > 0;
|
|
262
|
+
if (manual && manifest.kind !== extensionKinds.adapter) process.exitCode = 1;
|
|
263
|
+
if (manual) logBlock([
|
|
264
|
+
"Add the import to your Kubb config and merge the property into its defineConfig call:",
|
|
265
|
+
"",
|
|
266
|
+
...unconfigured.map((target) => toSnippet(target))
|
|
267
|
+
]);
|
|
268
|
+
const dependenciesMissing = !withDependencies && missing.length > 0;
|
|
269
|
+
summary(manual ? `${kind} needs configuration` : dependenciesMissing ? "Plugin configured; dependencies missing" : configured.length ? install ? `${kind} ready` : `${kind} configured` : `${kind} already configured`, manual || dependenciesMissing ? "warning" : "success", [
|
|
270
|
+
` Packages ${packages()}`,
|
|
271
|
+
...configured.map((target) => styleText("green", ` + ${target.manifest.export}()`)),
|
|
272
|
+
"",
|
|
273
|
+
...!install ? [`Install ${specs.join(" ")} to use it.`] : [],
|
|
274
|
+
...dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(", ")}`] : [],
|
|
275
|
+
manual ? "Add the snippet above, then run kubb generate." : "Next kubb generate",
|
|
276
|
+
`Options kubb.dev/extensions/${entry.id}`
|
|
277
|
+
]);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
logError(getErrorMessage(error));
|
|
280
|
+
summary("Add failed", "failed", installedPackages.length ? [` Packages ${installedPackages.join(", ")} installed`] : [" No changes made"]);
|
|
281
|
+
process.exitCode = 1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const command = define({
|
|
285
|
+
name: "add",
|
|
286
|
+
description: "Find and install plugins, adapters, and parsers from the Kubb registry.",
|
|
287
|
+
examples: [
|
|
288
|
+
"kubb add",
|
|
289
|
+
"kubb add plugin-zod",
|
|
290
|
+
"kubb add kubb-labs/plugin-react-query",
|
|
291
|
+
"kubb add acme/plugin-x --yes",
|
|
292
|
+
"kubb add plugin-zod --no-install"
|
|
293
|
+
].join("\n"),
|
|
294
|
+
toKebab: true,
|
|
295
|
+
args: {
|
|
296
|
+
id: {
|
|
297
|
+
type: "positional",
|
|
298
|
+
description: "Registry id: owner/slug, or a slug for an official extension. Asked for when omitted",
|
|
299
|
+
required: false
|
|
300
|
+
},
|
|
301
|
+
...configArg,
|
|
302
|
+
...yesArg,
|
|
303
|
+
install: {
|
|
304
|
+
type: "boolean",
|
|
305
|
+
description: "Install the package. Pass --no-install to only edit the config",
|
|
306
|
+
negatable: true,
|
|
307
|
+
default: true
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
run: ({ values }) => run({
|
|
311
|
+
id: values.id,
|
|
312
|
+
configPath: values.config,
|
|
313
|
+
yes: values.yes,
|
|
314
|
+
install: values.install
|
|
315
|
+
})
|
|
316
|
+
});
|
|
317
|
+
export { command, run, summarize };
|
|
318
|
+
|
|
319
|
+
//# sourceMappingURL=run-D-nn9-Wq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-D-nn9-Wq.js","names":[],"sources":["../src/runners/add/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 { define } from 'gunshi'\nimport { BUNDLED_PACKAGES, ConfigEditOperation, extensionKinds, editConfig, editConfigFile, findConfigFile, readImports } from '@internals/shared'\nimport { getErrorMessage, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact, manifest }) => ({\n operation: ConfigEditOperation.ADD_PLUGIN,\n ...(manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {}),\n plugin: artifact.package,\n })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nfunction previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): { lines: Array<string>; source: string } | { reason: string } {\n const result = editConfig({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()), source: result.source }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin or a parser,\n * adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never\n * written: the command prints the snippet to swap it in by hand. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === extensionKinds.adapter ? undefined : foundConfig\n if (manifest.kind !== extensionKinds.adapter && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? previewConfig({ details: targets, source: configSource }) : undefined\n // The default parsers written next to a new parser come with `kubb`. A strict node_modules layout\n // only lets the config import direct dependencies, so they are installed at the project's `kubb` version.\n const before = readImports(configSource ?? '')\n const added = preview && 'lines' in preview ? readImports(preview.source).filter((name) => !before.includes(name)) : []\n const bundled = BUNDLED_PACKAGES.filter(\n (name) => added.includes(name) && !versions.has(name) && !targets.some((target) => target.artifact.package === name),\n )\n const kubbVersion = versions.get('kubb')\n const specs = [\n ...targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact)),\n ...bundled.map((name) => (kubbVersion ? `${name}@${kubbVersion}` : name)),\n ]\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = [...targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package), ...bundled]\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { outcomes, changed } = await editConfigFile({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n // A plugin or parser the command could not write into the config is a failure a caller can act on; an adapter never gets written.\n if (manual && manifest.kind !== extensionKinds.adapter) process.exitCode = 1\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? `${kind} ready`\n : `${kind} configured`\n : `${kind} already configured`\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n"],"mappings":";;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