@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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import { n as getElapsedMs, t as formatMs } from "./time-C-wU7VhC.js";
|
|
3
|
+
import { t as createSpinner } from "./spinner-BZaln7O8.js";
|
|
4
|
+
import { n as isRichOutput } from "./env-rv-VgSGN.js";
|
|
5
|
+
import { s as installPackages } from "./utils-CbJ6hS_t.js";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import * as clack from "@clack/prompts";
|
|
8
|
+
// src/runners/installWithSpinner.ts
|
|
9
|
+
/** How many package manager lines stay visible under the install title while it runs. */
|
|
10
|
+
const LOG_LINES = 6;
|
|
11
|
+
/**
|
|
12
|
+
* Installs `packages` and reports how long it took. A rich terminal shows the package manager's
|
|
13
|
+
* last lines under the title while the install runs and clears them when it succeeds; a plain one
|
|
14
|
+
* prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.
|
|
15
|
+
*/
|
|
16
|
+
async function installWithSpinner({ packages, names, packageManager, cwd, install = installPackages }) {
|
|
17
|
+
const start = process.hrtime();
|
|
18
|
+
const task = createTask(`Installing ${names} with ${packageManager.name}`);
|
|
19
|
+
try {
|
|
20
|
+
await install(packages, packageManager, cwd, task.message);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
task.error("Install failed");
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
task.success(`Installed ${names} with ${packageManager.name} in ${formatMs(getElapsedMs(start))}`);
|
|
26
|
+
}
|
|
27
|
+
function createTask(title) {
|
|
28
|
+
if (isRichOutput()) {
|
|
29
|
+
const log = clack.taskLog({
|
|
30
|
+
title,
|
|
31
|
+
limit: LOG_LINES
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
message: (line) => log.message(line),
|
|
35
|
+
error: (text) => log.error(text, { showLog: false }),
|
|
36
|
+
success: (text) => log.success(text)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const spinner = createSpinner();
|
|
40
|
+
spinner.start(title);
|
|
41
|
+
return {
|
|
42
|
+
message: () => {},
|
|
43
|
+
error: (text) => spinner.error(text),
|
|
44
|
+
success: (text) => spinner.stop(text)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export { installWithSpinner as t };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=installWithSpinner-DpnpxHq5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installWithSpinner-DpnpxHq5.js","names":[],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["import process from 'node:process'\nimport * as clack from '@clack/prompts'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { isRichOutput } from '../utils/env.ts'\nimport { createSpinner } from '../ui/spinner.ts'\nimport { installPackages, type PackageManagerInfo } from './init/utils.ts'\n\n/** How many package manager lines stay visible under the install title while it runs. */\nconst LOG_LINES = 6\n\n/**\n * Installs `packages` and reports how long it took. A rich terminal shows the package manager's\n * last lines under the title while the install runs and clears them when it succeeds; a plain one\n * prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.\n */\nexport async function installWithSpinner({\n packages,\n names,\n packageManager,\n cwd,\n install = installPackages,\n}: {\n packages: Array<string>\n names: string\n packageManager: PackageManagerInfo\n cwd: string\n /** Runs the install itself, so a dry run can skip it. */\n install?: typeof installPackages\n}): Promise<void> {\n const start = process.hrtime()\n const task = createTask(`Installing ${names} with ${packageManager.name}`)\n try {\n await install(packages, packageManager, cwd, task.message)\n } catch (error) {\n task.error('Install failed')\n throw error\n }\n task.success(`Installed ${names} with ${packageManager.name} in ${formatMs(getElapsedMs(start))}`)\n}\n\ntype Task = { message: (line: string) => void; error: (text: string) => void; success: (text: string) => void }\n\n// clack's taskLog prints nothing at the end outside a TTY, so a plain terminal keeps the spinner writer.\n// The failure keeps no log: the thrown error already carries the last lines.\nfunction createTask(title: string): Task {\n if (isRichOutput()) {\n const log = clack.taskLog({ title, limit: LOG_LINES })\n return { message: (line) => log.message(line), error: (text) => log.error(text, { showLog: false }), success: (text) => log.success(text) }\n }\n const spinner = createSpinner()\n spinner.start(title)\n return { message: () => {}, error: (text) => spinner.error(text), success: (text) => spinner.stop(text) }\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAU,mBAQM;CAChB,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAM,SAAS,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAI,aAAa,GAAG;EAClB,MAAM,MAAM,MAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAU,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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_env = require("./env-eu3XyKqJ.cjs");
|
|
5
|
+
const require_utils = require("./utils-CO89mxRU.cjs");
|
|
6
|
+
let node_process = require("node:process");
|
|
7
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
8
|
+
let _clack_prompts = require("@clack/prompts");
|
|
9
|
+
_clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
|
|
10
|
+
// src/runners/installWithSpinner.ts
|
|
11
|
+
/** How many package manager lines stay visible under the install title while it runs. */
|
|
12
|
+
const LOG_LINES = 6;
|
|
13
|
+
/**
|
|
14
|
+
* Installs `packages` and reports how long it took. A rich terminal shows the package manager's
|
|
15
|
+
* last lines under the title while the install runs and clears them when it succeeds; a plain one
|
|
16
|
+
* prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.
|
|
17
|
+
*/
|
|
18
|
+
async function installWithSpinner({ packages, names, packageManager, cwd, install = require_utils.installPackages }) {
|
|
19
|
+
const start = node_process.default.hrtime();
|
|
20
|
+
const task = createTask(`Installing ${names} with ${packageManager.name}`);
|
|
21
|
+
try {
|
|
22
|
+
await install(packages, packageManager, cwd, task.message);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
task.error("Install failed");
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
task.success(`Installed ${names} with ${packageManager.name} in ${require_time.formatMs(require_time.getElapsedMs(start))}`);
|
|
28
|
+
}
|
|
29
|
+
function createTask(title) {
|
|
30
|
+
if (require_env.isRichOutput()) {
|
|
31
|
+
const log = _clack_prompts.taskLog({
|
|
32
|
+
title,
|
|
33
|
+
limit: LOG_LINES
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
message: (line) => log.message(line),
|
|
37
|
+
error: (text) => log.error(text, { showLog: false }),
|
|
38
|
+
success: (text) => log.success(text)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const spinner = require_spinner.createSpinner();
|
|
42
|
+
spinner.start(title);
|
|
43
|
+
return {
|
|
44
|
+
message: () => {},
|
|
45
|
+
error: (text) => spinner.error(text),
|
|
46
|
+
success: (text) => spinner.stop(text)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(exports, "installWithSpinner", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return installWithSpinner;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=installWithSpinner-ONGfIVUJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installWithSpinner-ONGfIVUJ.cjs","names":["installPackages","process","formatMs","getElapsedMs","isRichOutput","clack","createSpinner"],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["import process from 'node:process'\nimport * as clack from '@clack/prompts'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { isRichOutput } from '../utils/env.ts'\nimport { createSpinner } from '../ui/spinner.ts'\nimport { installPackages, type PackageManagerInfo } from './init/utils.ts'\n\n/** How many package manager lines stay visible under the install title while it runs. */\nconst LOG_LINES = 6\n\n/**\n * Installs `packages` and reports how long it took. A rich terminal shows the package manager's\n * last lines under the title while the install runs and clears them when it succeeds; a plain one\n * prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.\n */\nexport async function installWithSpinner({\n packages,\n names,\n packageManager,\n cwd,\n install = installPackages,\n}: {\n packages: Array<string>\n names: string\n packageManager: PackageManagerInfo\n cwd: string\n /** Runs the install itself, so a dry run can skip it. */\n install?: typeof installPackages\n}): Promise<void> {\n const start = process.hrtime()\n const task = createTask(`Installing ${names} with ${packageManager.name}`)\n try {\n await install(packages, packageManager, cwd, task.message)\n } catch (error) {\n task.error('Install failed')\n throw error\n }\n task.success(`Installed ${names} with ${packageManager.name} in ${formatMs(getElapsedMs(start))}`)\n}\n\ntype Task = { message: (line: string) => void; error: (text: string) => void; success: (text: string) => void }\n\n// clack's taskLog prints nothing at the end outside a TTY, so a plain terminal keeps the spinner writer.\n// The failure keeps no log: the thrown error already carries the last lines.\nfunction createTask(title: string): Task {\n if (isRichOutput()) {\n const log = clack.taskLog({ title, limit: LOG_LINES })\n return { message: (line) => log.message(line), error: (text) => log.error(text, { showLog: false }), success: (text) => log.success(text) }\n }\n const spinner = createSpinner()\n spinner.start(title)\n return { message: () => {}, error: (text) => spinner.error(text), success: (text) => spinner.stop(text) }\n}\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAUA,cAAAA,mBAQM;CAChB,MAAM,QAAQC,aAAAA,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAMC,aAAAA,SAASC,aAAAA,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAIC,YAAAA,aAAa,GAAG;EAClB,MAAM,MAAMC,eAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAUC,gBAAAA,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
|
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
import "./rolldown-runtime-
|
|
2
|
-
import {
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import { n as isRichOutput } from "./env-rv-VgSGN.js";
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
|
-
import { getAgentProfile } from "gunshi/agent";
|
|
5
4
|
import * as clack from "@clack/prompts";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
9
|
-
* width and is not running in CI.
|
|
10
|
-
*
|
|
11
|
-
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
12
|
-
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
13
|
-
* with a negative count and throw a `RangeError`). A positive column count is
|
|
14
|
-
* required before the TTY counts as usable.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* if (canUseTTY()) {
|
|
19
|
-
* renderProgressBar()
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
function canUseTTY() {
|
|
24
|
-
return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI
|
|
28
|
-
* coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a
|
|
29
|
-
* pseudo-TTY, so it gets the plain writer.
|
|
30
|
-
*/
|
|
31
|
-
function isRichOutput() {
|
|
32
|
-
return canUseTTY() && !getAgentProfile().isAgent;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/loggers/clackWriter.ts
|
|
5
|
+
// src/loggers/clackWriter.ts
|
|
36
6
|
/**
|
|
37
7
|
* Draws with clack for local development: a gutter bar per group, animated steps, and a progress
|
|
38
8
|
* bar for the writes.
|
|
@@ -74,8 +44,7 @@ const clackWriter = {
|
|
|
74
44
|
};
|
|
75
45
|
}
|
|
76
46
|
};
|
|
77
|
-
|
|
78
|
-
//#region src/loggers/plainWriter.ts
|
|
47
|
+
// src/loggers/plainWriter.ts
|
|
79
48
|
/**
|
|
80
49
|
* Prefixes that stand in for the symbols clack draws, so plain output reads the same way.
|
|
81
50
|
*/
|
|
@@ -122,8 +91,7 @@ function createPlainWriter(write) {
|
|
|
122
91
|
* Reports the same run in the same order as `clackWriter`, without the animation.
|
|
123
92
|
*/
|
|
124
93
|
const plainWriter = createPlainWriter((line) => console.log(line));
|
|
125
|
-
|
|
126
|
-
//#region src/ui/log.ts
|
|
94
|
+
// src/ui/log.ts
|
|
127
95
|
/** The writer the loggers draw with on this terminal, so a command's own lines look like its run. */
|
|
128
96
|
function writer() {
|
|
129
97
|
return isRichOutput() ? clackWriter : plainWriter;
|
|
@@ -158,8 +126,7 @@ function logError(message) {
|
|
|
158
126
|
function logStep(message) {
|
|
159
127
|
write("step", message);
|
|
160
128
|
}
|
|
161
|
-
|
|
162
|
-
//#region src/ui/intro.ts
|
|
129
|
+
// src/ui/intro.ts
|
|
163
130
|
const SPONSOR_TIPS = [
|
|
164
131
|
"Your sponsorship keeps Kubb codegen, plugins, and docs maintained",
|
|
165
132
|
"Sponsor faster generators and better Kubb Studio workflows",
|
|
@@ -223,17 +190,6 @@ function logSpacer() {
|
|
|
223
190
|
function isInteractiveRun({ yes, dryRun }) {
|
|
224
191
|
return !yes && !dryRun && process.stdin.isTTY === true;
|
|
225
192
|
}
|
|
226
|
-
|
|
227
|
-
//#region src/ui/text.ts
|
|
228
|
-
/** Counts a noun, so a message never reads `1 files`. */
|
|
229
|
-
function pluralize(count, noun) {
|
|
230
|
-
return `${count} ${count === 1 ? noun : `${noun}s`}`;
|
|
231
|
-
}
|
|
232
|
-
/** The flag that grants a permission, such as `--allow-read-ast`. */
|
|
233
|
-
function toPermissionFlag(key) {
|
|
234
|
-
return `--${key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
export { isRichOutput as _, logOutro as a, logBlock as c, logStep as d, logWarn as f, canUseTTY as g, plainWriter as h, logIntro as i, logError as l, createPlainWriter as m, toPermissionFlag as n, logSpacer as o, writer as p, isInteractiveRun as r, logTip as s, pluralize as t, logInfo as u };
|
|
193
|
+
export { logTip as a, logInfo as c, writer as d, createPlainWriter as f, logSpacer as i, logStep as l, logIntro as n, logBlock as o, plainWriter as p, logOutro as r, logError as s, isInteractiveRun as t, logWarn as u };
|
|
238
194
|
|
|
239
|
-
//# sourceMappingURL=
|
|
195
|
+
//# sourceMappingURL=intro-9PB8sE8z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intro-9PB8sE8z.js","names":[],"sources":["../src/loggers/clackWriter.ts","../src/loggers/plainWriter.ts","../src/ui/log.ts","../src/ui/intro.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { LoggerWriter } from './types.ts'\n\n/**\n * Draws with clack for local development: a gutter bar per group, animated steps, and a progress\n * bar for the writes.\n */\nexport const clackWriter: LoggerWriter = {\n audience: 'human',\n group: (title) => clack.intro(title),\n groupEnd: (text) => clack.outro(text),\n step: (text) => clack.log.step(text, { spacing: 0 }),\n info: (text) => clack.log.info(text),\n success: (text) => clack.log.success(text),\n warn: (text) => clack.log.warn(text),\n error: (text) => clack.log.error(text),\n block: (lines) => clack.log.message(lines, { spacing: 0 }),\n // A subprocess's output is not Kubb's tree, so it goes out past clack and its gutter bar. The\n // step above it is already stopped by the time this runs.\n raw: (lines) => console.log(styleText('dim', lines.join('\\n'))),\n // The diagnostic carries its own code and indented rows, so clear clack's gutter and bar and let\n // the block stand on its own.\n diagnostic: (lines) => clack.log.message(lines, { symbol: '', secondarySymbol: '' }),\n update: (lines, title) =>\n clack.box(lines.join('\\n'), title, {\n width: 'auto',\n formatBorder: (border: string) => styleText('yellow', border),\n rounded: true,\n withGuide: false,\n contentAlign: 'center',\n titleAlign: 'center',\n }),\n spinner: () => clack.spinner(),\n progress(max) {\n const bar = clack.progress({ style: 'block', max, size: 30 })\n\n return {\n start: (text) => bar.start(text),\n advance: (text) => bar.advance(1, text),\n stop: (text) => bar.stop(text),\n }\n },\n}\n","import type { LoggerWriter } from './types.ts'\n\n/**\n * Prefixes that stand in for the symbols clack draws, so plain output reads the same way.\n */\nexport const SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\n/**\n * Draws with one `write` call per line, e.g. `console.error` so stdout carries only JSON. Nothing\n * animates, so a step prints at start and end.\n */\nexport function createPlainWriter(write: (line: string) => void): LoggerWriter {\n return {\n audience: 'agent',\n group: write,\n groupEnd: write,\n step: (text) => write(`${SYMBOLS.step} ${text}`),\n info: write,\n success: write,\n warn: write,\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n block: (lines) => write(lines.join('\\n')),\n raw: (lines) => write(lines.join('\\n')),\n diagnostic: (lines) => write(lines.join('\\n')),\n update: (lines, title) => write([title, ...lines].join('\\n')),\n spinner: () => ({\n start: write,\n message: write,\n clear: () => {},\n stop: (text) => text && write(text),\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n }),\n progress: () => ({\n start: write,\n advance: write,\n stop: (text) => text && write(text),\n }),\n }\n}\n\n/**\n * Draws on the console, for non-TTY environments and for an AI coding agent reading the output.\n * Reports the same run in the same order as `clackWriter`, without the animation.\n */\nexport const plainWriter = createPlainWriter((line) => console.log(line))\n","import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\nimport { clackWriter } from '../loggers/clackWriter.ts'\nimport { plainWriter, SYMBOLS } from '../loggers/plainWriter.ts'\nimport type { LoggerWriter } from '../loggers/types.ts'\n\n/** The writer the loggers draw with on this terminal, so a command's own lines look like its run. */\nexport function writer(): LoggerWriter {\n return isRichOutput() ? clackWriter : plainWriter\n}\n\ntype Level = keyof typeof SYMBOLS\n\n// Not through the writers: in plain output a command's own info and warning carry their symbol, and clack's step keeps its spacing.\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\n/** Prints lines as one block, without a symbol in front of them. Not the writer's block, which drops clack's spacing around it. */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n","import { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\nimport { writer } from './log.ts'\n\nconst SPONSOR_TIPS = [\n 'Your sponsorship keeps Kubb codegen, plugins, and docs maintained',\n 'Sponsor faster generators and better Kubb Studio workflows',\n 'Help keep Kubb free for TypeScript teams building APIs',\n 'Support React Query, Zod, Faker, and MSW integrations',\n 'Back open-source tools that turn OpenAPI into TypeScript',\n 'Sponsor fixes, releases, and new plugins for your API workflow',\n 'Help Kubb stay independent and focused on developer tools',\n] as const\n\nconst SPONSOR_LINKS = ['https://github.com/sponsors/stijnvanhulle', 'https://opencollective.com/kubb', 'https://kubb.dev/sponsors'] as const\n\nfunction nextTip(): string {\n const tip = SPONSOR_TIPS[Math.floor(Math.random() * SPONSOR_TIPS.length)]!\n const link = SPONSOR_LINKS[Math.floor(Math.random() * SPONSOR_LINKS.length)]!\n return `${tip}: ${link}`\n}\n\nfunction formatTip(tip: string): string {\n return styleText('magenta', ' Tip ') + styleText('yellow', tip)\n}\n\n/**\n * Prints one random tip outside every group. Rich terminals get the styled variant;\n * plain/CI output gets a stable text-only line so the tip is still visible as final output.\n */\nexport function logTip(): void {\n const tip = nextTip()\n if (!isRichOutput()) {\n console.log(`Tip: ${tip}`)\n return\n }\n\n console.log(`${styleText('magenta', '✦')}${formatTip(tip)}`)\n}\n\ntype IntroOptions = {\n title?: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output. A command the banner already names passes no title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n if (title) prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n if (title) {\n console.log(title)\n }\n\n if (warning) {\n console.warn(warning)\n }\n\n if (title || warning) {\n console.log()\n }\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n writer().groupEnd(text)\n}\n\n/**\n * Prints one empty line between two groups, without clack's gutter bar, since the bar belongs to a\n * group and a spacer sits outside every one.\n */\nexport function logSpacer(): void {\n console.log('')\n}\n\n/** Whether a run stops to ask something: no `--yes`, no `--dry-run`, and a person at a terminal. */\nexport function isInteractiveRun({ yes, dryRun }: { yes?: unknown; dryRun?: unknown }): boolean {\n return !yes && !dryRun && process.stdin.isTTY === true\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAA4B;CACvC,UAAU;CACV,QAAQ,UAAU,MAAM,MAAM,KAAK;CACnC,WAAW,SAAS,MAAM,MAAM,IAAI;CACpC,OAAO,SAAS,MAAM,IAAI,KAAK,MAAM,EAAE,SAAS,EAAE,CAAC;CACnD,OAAO,SAAS,MAAM,IAAI,KAAK,IAAI;CACnC,UAAU,SAAS,MAAM,IAAI,QAAQ,IAAI;CACzC,OAAO,SAAS,MAAM,IAAI,KAAK,IAAI;CACnC,QAAQ,SAAS,MAAM,IAAI,MAAM,IAAI;CACrC,QAAQ,UAAU,MAAM,IAAI,QAAQ,OAAO,EAAE,SAAS,EAAE,CAAC;CAGzD,MAAM,UAAU,QAAQ,IAAI,UAAU,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC;CAG9D,aAAa,UAAU,MAAM,IAAI,QAAQ,OAAO;EAAE,QAAQ;EAAI,iBAAiB;CAAG,CAAC;CACnF,SAAS,OAAO,UACd,MAAM,IAAI,MAAM,KAAK,IAAI,GAAG,OAAO;EACjC,OAAO;EACP,eAAe,WAAmB,UAAU,UAAU,MAAM;EAC5D,SAAS;EACT,WAAW;EACX,cAAc;EACd,YAAY;CACd,CAAC;CACH,eAAe,MAAM,QAAQ;CAC7B,SAAS,KAAK;EACZ,MAAM,MAAM,MAAM,SAAS;GAAE,OAAO;GAAS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B,IAAI,SAAS,SACX,QAAQ,IAAI;AAEhB;;;;;AAMA,SAAgB,SAAS,MAAoB;CAC3C,OAAO,CAAC,CAAC,SAAS,IAAI;AACxB;;;;;AAMA,SAAgB,YAAkB;CAChC,QAAQ,IAAI,EAAE;AAChB;;AAGA,SAAgB,iBAAiB,EAAE,KAAK,UAAwD;CAC9F,OAAO,CAAC,OAAO,CAAC,UAAU,QAAQ,MAAM,UAAU;AACpD"}
|
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
+
const require_env = require("./env-eu3XyKqJ.cjs");
|
|
3
3
|
let node_util = require("node:util");
|
|
4
|
-
let gunshi_agent = require("gunshi/agent");
|
|
5
4
|
let _clack_prompts = require("@clack/prompts");
|
|
6
5
|
_clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
10
|
-
* width and is not running in CI.
|
|
11
|
-
*
|
|
12
|
-
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
13
|
-
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
14
|
-
* with a negative count and throw a `RangeError`). A positive column count is
|
|
15
|
-
* required before the TTY counts as usable.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* if (canUseTTY()) {
|
|
20
|
-
* renderProgressBar()
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
function canUseTTY() {
|
|
25
|
-
return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !require_Telemetry.isCIEnvironment();
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI
|
|
29
|
-
* coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a
|
|
30
|
-
* pseudo-TTY, so it gets the plain writer.
|
|
31
|
-
*/
|
|
32
|
-
function isRichOutput() {
|
|
33
|
-
return canUseTTY() && !(0, gunshi_agent.getAgentProfile)().isAgent;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/loggers/clackWriter.ts
|
|
6
|
+
// src/loggers/clackWriter.ts
|
|
37
7
|
/**
|
|
38
8
|
* Draws with clack for local development: a gutter bar per group, animated steps, and a progress
|
|
39
9
|
* bar for the writes.
|
|
@@ -75,8 +45,7 @@ const clackWriter = {
|
|
|
75
45
|
};
|
|
76
46
|
}
|
|
77
47
|
};
|
|
78
|
-
|
|
79
|
-
//#region src/loggers/plainWriter.ts
|
|
48
|
+
// src/loggers/plainWriter.ts
|
|
80
49
|
/**
|
|
81
50
|
* Prefixes that stand in for the symbols clack draws, so plain output reads the same way.
|
|
82
51
|
*/
|
|
@@ -123,14 +92,13 @@ function createPlainWriter(write) {
|
|
|
123
92
|
* Reports the same run in the same order as `clackWriter`, without the animation.
|
|
124
93
|
*/
|
|
125
94
|
const plainWriter = createPlainWriter((line) => console.log(line));
|
|
126
|
-
|
|
127
|
-
//#region src/ui/log.ts
|
|
95
|
+
// src/ui/log.ts
|
|
128
96
|
/** The writer the loggers draw with on this terminal, so a command's own lines look like its run. */
|
|
129
97
|
function writer() {
|
|
130
|
-
return isRichOutput() ? clackWriter : plainWriter;
|
|
98
|
+
return require_env.isRichOutput() ? clackWriter : plainWriter;
|
|
131
99
|
}
|
|
132
100
|
function write(level, message) {
|
|
133
|
-
if (isRichOutput()) {
|
|
101
|
+
if (require_env.isRichOutput()) {
|
|
134
102
|
_clack_prompts.log[level](message);
|
|
135
103
|
return;
|
|
136
104
|
}
|
|
@@ -138,7 +106,7 @@ function write(level, message) {
|
|
|
138
106
|
}
|
|
139
107
|
/** Prints lines as one block, without a symbol in front of them. Not the writer's block, which drops clack's spacing around it. */
|
|
140
108
|
function logBlock(lines) {
|
|
141
|
-
if (isRichOutput()) {
|
|
109
|
+
if (require_env.isRichOutput()) {
|
|
142
110
|
_clack_prompts.log.message(lines);
|
|
143
111
|
return;
|
|
144
112
|
}
|
|
@@ -159,8 +127,7 @@ function logError(message) {
|
|
|
159
127
|
function logStep(message) {
|
|
160
128
|
write("step", message);
|
|
161
129
|
}
|
|
162
|
-
|
|
163
|
-
//#region src/ui/intro.ts
|
|
130
|
+
// src/ui/intro.ts
|
|
164
131
|
const SPONSOR_TIPS = [
|
|
165
132
|
"Your sponsorship keeps Kubb codegen, plugins, and docs maintained",
|
|
166
133
|
"Sponsor faster generators and better Kubb Studio workflows",
|
|
@@ -187,7 +154,7 @@ function formatTip(tip) {
|
|
|
187
154
|
*/
|
|
188
155
|
function logTip() {
|
|
189
156
|
const tip = nextTip();
|
|
190
|
-
if (!isRichOutput()) {
|
|
157
|
+
if (!require_env.isRichOutput()) {
|
|
191
158
|
console.log(`Tip: ${tip}`);
|
|
192
159
|
return;
|
|
193
160
|
}
|
|
@@ -197,7 +164,7 @@ function logTip() {
|
|
|
197
164
|
* Opens a command's output. A command the banner already names passes no title.
|
|
198
165
|
*/
|
|
199
166
|
function logIntro({ title, warning, block = true }) {
|
|
200
|
-
if (block && isRichOutput()) {
|
|
167
|
+
if (block && require_env.isRichOutput()) {
|
|
201
168
|
if (title) _clack_prompts.intro(title);
|
|
202
169
|
if (warning) _clack_prompts.log.warn(warning);
|
|
203
170
|
return;
|
|
@@ -224,23 +191,6 @@ function logSpacer() {
|
|
|
224
191
|
function isInteractiveRun({ yes, dryRun }) {
|
|
225
192
|
return !yes && !dryRun && process.stdin.isTTY === true;
|
|
226
193
|
}
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/ui/text.ts
|
|
229
|
-
/** Counts a noun, so a message never reads `1 files`. */
|
|
230
|
-
function pluralize(count, noun) {
|
|
231
|
-
return `${count} ${count === 1 ? noun : `${noun}s`}`;
|
|
232
|
-
}
|
|
233
|
-
/** The flag that grants a permission, such as `--allow-read-ast`. */
|
|
234
|
-
function toPermissionFlag(key) {
|
|
235
|
-
return `--${key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
|
-
Object.defineProperty(exports, "canUseTTY", {
|
|
239
|
-
enumerable: true,
|
|
240
|
-
get: function() {
|
|
241
|
-
return canUseTTY;
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
194
|
Object.defineProperty(exports, "createPlainWriter", {
|
|
245
195
|
enumerable: true,
|
|
246
196
|
get: function() {
|
|
@@ -253,12 +203,6 @@ Object.defineProperty(exports, "isInteractiveRun", {
|
|
|
253
203
|
return isInteractiveRun;
|
|
254
204
|
}
|
|
255
205
|
});
|
|
256
|
-
Object.defineProperty(exports, "isRichOutput", {
|
|
257
|
-
enumerable: true,
|
|
258
|
-
get: function() {
|
|
259
|
-
return isRichOutput;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
206
|
Object.defineProperty(exports, "logBlock", {
|
|
263
207
|
enumerable: true,
|
|
264
208
|
get: function() {
|
|
@@ -319,18 +263,6 @@ Object.defineProperty(exports, "plainWriter", {
|
|
|
319
263
|
return plainWriter;
|
|
320
264
|
}
|
|
321
265
|
});
|
|
322
|
-
Object.defineProperty(exports, "pluralize", {
|
|
323
|
-
enumerable: true,
|
|
324
|
-
get: function() {
|
|
325
|
-
return pluralize;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
Object.defineProperty(exports, "toPermissionFlag", {
|
|
329
|
-
enumerable: true,
|
|
330
|
-
get: function() {
|
|
331
|
-
return toPermissionFlag;
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
266
|
Object.defineProperty(exports, "writer", {
|
|
335
267
|
enumerable: true,
|
|
336
268
|
get: function() {
|
|
@@ -338,4 +270,4 @@ Object.defineProperty(exports, "writer", {
|
|
|
338
270
|
}
|
|
339
271
|
});
|
|
340
272
|
|
|
341
|
-
//# sourceMappingURL=
|
|
273
|
+
//# sourceMappingURL=intro-YPaf1Imr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intro-YPaf1Imr.cjs","names":["clack","styleText","isRichOutput","styleText","isRichOutput"],"sources":["../src/loggers/clackWriter.ts","../src/loggers/plainWriter.ts","../src/ui/log.ts","../src/ui/intro.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { LoggerWriter } from './types.ts'\n\n/**\n * Draws with clack for local development: a gutter bar per group, animated steps, and a progress\n * bar for the writes.\n */\nexport const clackWriter: LoggerWriter = {\n audience: 'human',\n group: (title) => clack.intro(title),\n groupEnd: (text) => clack.outro(text),\n step: (text) => clack.log.step(text, { spacing: 0 }),\n info: (text) => clack.log.info(text),\n success: (text) => clack.log.success(text),\n warn: (text) => clack.log.warn(text),\n error: (text) => clack.log.error(text),\n block: (lines) => clack.log.message(lines, { spacing: 0 }),\n // A subprocess's output is not Kubb's tree, so it goes out past clack and its gutter bar. The\n // step above it is already stopped by the time this runs.\n raw: (lines) => console.log(styleText('dim', lines.join('\\n'))),\n // The diagnostic carries its own code and indented rows, so clear clack's gutter and bar and let\n // the block stand on its own.\n diagnostic: (lines) => clack.log.message(lines, { symbol: '', secondarySymbol: '' }),\n update: (lines, title) =>\n clack.box(lines.join('\\n'), title, {\n width: 'auto',\n formatBorder: (border: string) => styleText('yellow', border),\n rounded: true,\n withGuide: false,\n contentAlign: 'center',\n titleAlign: 'center',\n }),\n spinner: () => clack.spinner(),\n progress(max) {\n const bar = clack.progress({ style: 'block', max, size: 30 })\n\n return {\n start: (text) => bar.start(text),\n advance: (text) => bar.advance(1, text),\n stop: (text) => bar.stop(text),\n }\n },\n}\n","import type { LoggerWriter } from './types.ts'\n\n/**\n * Prefixes that stand in for the symbols clack draws, so plain output reads the same way.\n */\nexport const SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\n/**\n * Draws with one `write` call per line, e.g. `console.error` so stdout carries only JSON. Nothing\n * animates, so a step prints at start and end.\n */\nexport function createPlainWriter(write: (line: string) => void): LoggerWriter {\n return {\n audience: 'agent',\n group: write,\n groupEnd: write,\n step: (text) => write(`${SYMBOLS.step} ${text}`),\n info: write,\n success: write,\n warn: write,\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n block: (lines) => write(lines.join('\\n')),\n raw: (lines) => write(lines.join('\\n')),\n diagnostic: (lines) => write(lines.join('\\n')),\n update: (lines, title) => write([title, ...lines].join('\\n')),\n spinner: () => ({\n start: write,\n message: write,\n clear: () => {},\n stop: (text) => text && write(text),\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n }),\n progress: () => ({\n start: write,\n advance: write,\n stop: (text) => text && write(text),\n }),\n }\n}\n\n/**\n * Draws on the console, for non-TTY environments and for an AI coding agent reading the output.\n * Reports the same run in the same order as `clackWriter`, without the animation.\n */\nexport const plainWriter = createPlainWriter((line) => console.log(line))\n","import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\nimport { clackWriter } from '../loggers/clackWriter.ts'\nimport { plainWriter, SYMBOLS } from '../loggers/plainWriter.ts'\nimport type { LoggerWriter } from '../loggers/types.ts'\n\n/** The writer the loggers draw with on this terminal, so a command's own lines look like its run. */\nexport function writer(): LoggerWriter {\n return isRichOutput() ? clackWriter : plainWriter\n}\n\ntype Level = keyof typeof SYMBOLS\n\n// Not through the writers: in plain output a command's own info and warning carry their symbol, and clack's step keeps its spacing.\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\n/** Prints lines as one block, without a symbol in front of them. Not the writer's block, which drops clack's spacing around it. */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n","import { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\nimport { writer } from './log.ts'\n\nconst SPONSOR_TIPS = [\n 'Your sponsorship keeps Kubb codegen, plugins, and docs maintained',\n 'Sponsor faster generators and better Kubb Studio workflows',\n 'Help keep Kubb free for TypeScript teams building APIs',\n 'Support React Query, Zod, Faker, and MSW integrations',\n 'Back open-source tools that turn OpenAPI into TypeScript',\n 'Sponsor fixes, releases, and new plugins for your API workflow',\n 'Help Kubb stay independent and focused on developer tools',\n] as const\n\nconst SPONSOR_LINKS = ['https://github.com/sponsors/stijnvanhulle', 'https://opencollective.com/kubb', 'https://kubb.dev/sponsors'] as const\n\nfunction nextTip(): string {\n const tip = SPONSOR_TIPS[Math.floor(Math.random() * SPONSOR_TIPS.length)]!\n const link = SPONSOR_LINKS[Math.floor(Math.random() * SPONSOR_LINKS.length)]!\n return `${tip}: ${link}`\n}\n\nfunction formatTip(tip: string): string {\n return styleText('magenta', ' Tip ') + styleText('yellow', tip)\n}\n\n/**\n * Prints one random tip outside every group. Rich terminals get the styled variant;\n * plain/CI output gets a stable text-only line so the tip is still visible as final output.\n */\nexport function logTip(): void {\n const tip = nextTip()\n if (!isRichOutput()) {\n console.log(`Tip: ${tip}`)\n return\n }\n\n console.log(`${styleText('magenta', '✦')}${formatTip(tip)}`)\n}\n\ntype IntroOptions = {\n title?: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output. A command the banner already names passes no title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n if (title) prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n if (title) {\n console.log(title)\n }\n\n if (warning) {\n console.warn(warning)\n }\n\n if (title || warning) {\n console.log()\n }\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n writer().groupEnd(text)\n}\n\n/**\n * Prints one empty line between two groups, without clack's gutter bar, since the bar belongs to a\n * group and a spacer sits outside every one.\n */\nexport function logSpacer(): void {\n console.log('')\n}\n\n/** Whether a run stops to ask something: no `--yes`, no `--dry-run`, and a person at a terminal. */\nexport function isInteractiveRun({ yes, dryRun }: { yes?: unknown; dryRun?: unknown }): boolean {\n return !yes && !dryRun && process.stdin.isTTY === true\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAa,cAA4B;CACvC,UAAU;CACV,QAAQ,UAAUA,eAAM,MAAM,KAAK;CACnC,WAAW,SAASA,eAAM,MAAM,IAAI;CACpC,OAAO,SAASA,eAAM,IAAI,KAAK,MAAM,EAAE,SAAS,EAAE,CAAC;CACnD,OAAO,SAASA,eAAM,IAAI,KAAK,IAAI;CACnC,UAAU,SAASA,eAAM,IAAI,QAAQ,IAAI;CACzC,OAAO,SAASA,eAAM,IAAI,KAAK,IAAI;CACnC,QAAQ,SAASA,eAAM,IAAI,MAAM,IAAI;CACrC,QAAQ,UAAUA,eAAM,IAAI,QAAQ,OAAO,EAAE,SAAS,EAAE,CAAC;CAGzD,MAAM,UAAU,QAAQ,KAAA,GAAIC,UAAAA,UAAAA,CAAU,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC;CAG9D,aAAa,UAAUD,eAAM,IAAI,QAAQ,OAAO;EAAE,QAAQ;EAAI,iBAAiB;CAAG,CAAC;CACnF,SAAS,OAAO,UACdA,eAAM,IAAI,MAAM,KAAK,IAAI,GAAG,OAAO;EACjC,OAAO;EACP,eAAe,YAAA,GAAmBC,UAAAA,UAAAA,CAAU,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;;AAoBA,SAAgB,SAAS,EAAE,OAAO,SAAS,QAAQ,QAA4B;CAC7E,IAAI,SAASC,YAAAA,aAAa,GAAG;EAC3B,IAAI,OAAO,eAAQ,MAAM,KAAK;EAE9B,IAAI,SACF,eAAQ,IAAI,KAAK,OAAO;EAG1B;CACF;CAEA,IAAI,OACF,QAAQ,IAAI,KAAK;CAGnB,IAAI,SACF,QAAQ,KAAK,OAAO;CAGtB,IAAI,SAAS,SACX,QAAQ,IAAI;AAEhB;;;;;AAMA,SAAgB,SAAS,MAAoB;CAC3C,OAAO,CAAC,CAAC,SAAS,IAAI;AACxB;;;;;AAMA,SAAgB,YAAkB;CAChC,QAAQ,IAAI,EAAE;AAChB;;AAGA,SAAgB,iBAAiB,EAAE,KAAK,UAAwD;CAC9F,OAAO,CAAC,OAAO,CAAC,UAAU,QAAQ,MAAM,UAAU;AACpD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
// ../../internals/utils/src/isCIEnvironment.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
6
|
+
* `CI=false` and `CI=0` count as not CI, so a user can opt out locally.
|
|
7
|
+
*/
|
|
8
|
+
function isCIEnvironment() {
|
|
9
|
+
const ci = process.env.CI;
|
|
10
|
+
return !!(ci && ci !== "false" && ci !== "0" || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);
|
|
11
|
+
}
|
|
12
|
+
export { isCIEnvironment as t };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=isCIEnvironment-D6xtAAZ2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCIEnvironment-D6xtAAZ2.js","names":[],"sources":["../../../internals/utils/src/isCIEnvironment.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n * `CI=false` and `CI=0` count as not CI, so a user can opt out locally.\n */\nexport function isCIEnvironment(): boolean {\n const ci = process.env.CI\n return !!(\n (ci && ci !== 'false' && ci !== '0') ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,kBAA2B;CACzC,MAAM,KAAK,QAAQ,IAAI;CACvB,OAAO,CAAC,EACL,MAAM,OAAO,WAAW,OAAO,OAChC,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
+
let node_process = require("node:process");
|
|
3
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
|
+
// ../../internals/utils/src/isCIEnvironment.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
7
|
+
* `CI=false` and `CI=0` count as not CI, so a user can opt out locally.
|
|
8
|
+
*/
|
|
9
|
+
function isCIEnvironment() {
|
|
10
|
+
const ci = node_process.default.env.CI;
|
|
11
|
+
return !!(ci && ci !== "false" && ci !== "0" || node_process.default.env.GITHUB_ACTIONS || node_process.default.env.GITLAB_CI || node_process.default.env.BITBUCKET_BUILD_NUMBER || node_process.default.env.JENKINS_URL || node_process.default.env.CIRCLECI || node_process.default.env.TRAVIS || node_process.default.env.TEAMCITY_VERSION || node_process.default.env.BUILDKITE || node_process.default.env.TF_BUILD);
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(exports, "isCIEnvironment", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return isCIEnvironment;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=isCIEnvironment-DiVOMI5Q.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCIEnvironment-DiVOMI5Q.cjs","names":["process"],"sources":["../../../internals/utils/src/isCIEnvironment.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n * `CI=false` and `CI=0` count as not CI, so a user can opt out locally.\n */\nexport function isCIEnvironment(): boolean {\n const ci = process.env.CI\n return !!(\n (ci && ci !== 'false' && ci !== '0') ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,kBAA2B;CACzC,MAAM,KAAKA,aAAAA,QAAQ,IAAI;CACvB,OAAO,CAAC,EACL,MAAM,OAAO,WAAW,OAAO,OAChCA,aAAAA,QAAQ,IAAI,kBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI,0BACZA,aAAAA,QAAQ,IAAI,eACZA,aAAAA,QAAQ,IAAI,YACZA,aAAAA,QAAQ,IAAI,UACZA,aAAAA,QAAQ,IAAI,oBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI;AAEhB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
+
import { n as isRichOutput } from "./env-rv-VgSGN.js";
|
|
3
|
+
import { i as wakeUp, r as getIntro } from "./banner-BdTTDFkG.js";
|
|
4
|
+
import { t as isInteractiveRun } from "./intro-9PB8sE8z.js";
|
|
5
|
+
import { stripVTControlCharacters } from "node:util";
|
|
6
|
+
import { setTimeout } from "node:timers/promises";
|
|
7
|
+
// src/ui/mascot.ts
|
|
8
|
+
function bannerIntro(version, expression, command) {
|
|
9
|
+
return getIntro({
|
|
10
|
+
title: "Turn your API spec into type-safe code",
|
|
11
|
+
description: `kubb ${command}`,
|
|
12
|
+
version,
|
|
13
|
+
expression
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** Whether the mascot can be drawn: a rich, 256-color terminal wide enough that no line wraps and throws off a redraw. */
|
|
17
|
+
function canDrawMascot(version, command) {
|
|
18
|
+
if (!isRichOutput() || !process.stdout.hasColors(256)) return false;
|
|
19
|
+
return stripVTControlCharacters(bannerIntro(version, "open", command)).split("\n").every((line) => line.length <= process.stdout.columns);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether a command opens with the mascot. Only the long-running ones do: `generate`, a Studio
|
|
23
|
+
* session or pairing, and `add` or `update` while they ask questions. Quick commands print only
|
|
24
|
+
* their result.
|
|
25
|
+
*/
|
|
26
|
+
function wantsMascot({ commandPath, values }) {
|
|
27
|
+
const [command, subCommand] = commandPath;
|
|
28
|
+
if (values.help || values.version) return false;
|
|
29
|
+
if (command === "studio") return subCommand === void 0 || subCommand === "connect" || subCommand === "login";
|
|
30
|
+
if (command === "add" || command === "update" || command === "init") return isInteractiveRun({
|
|
31
|
+
yes: values.yes,
|
|
32
|
+
dryRun: values.dryRun ?? values["dry-run"]
|
|
33
|
+
});
|
|
34
|
+
return command === void 0 || command === "generate";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The still Kubb mascot with the version and the running command, such as `studio connect`, or a
|
|
38
|
+
* single version line where the terminal cannot draw it. Commands print it as their header; it
|
|
39
|
+
* draws at once, with no wake-up frames.
|
|
40
|
+
*/
|
|
41
|
+
function getBanner(version, command) {
|
|
42
|
+
return canDrawMascot(version, command) ? `\n${bannerIntro(version, "open", command)}` : `Kubb CLI v${version}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Opens `kubb generate` with the mascot playing its wake-up frames in place, which takes under a
|
|
46
|
+
* second and overlaps the config load. Elsewhere the still {@link getBanner} is the header.
|
|
47
|
+
*/
|
|
48
|
+
async function logBanner(version) {
|
|
49
|
+
if (!canDrawMascot(version, "generate")) {
|
|
50
|
+
console.log(getBanner(version, "generate"));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
console.log("");
|
|
54
|
+
for (const [index, [expression, ms]] of wakeUp.entries()) {
|
|
55
|
+
const frame = bannerIntro(version, expression, "generate");
|
|
56
|
+
if (index > 0) process.stdout.moveCursor(0, -frame.split("\n").length);
|
|
57
|
+
console.log(frame);
|
|
58
|
+
await setTimeout(ms);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export { logBanner as n, wantsMascot as r, getBanner as t };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=mascot--q1xjKw1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mascot--q1xjKw1.js","names":["sleep"],"sources":["../src/ui/mascot.ts"],"sourcesContent":["import { setTimeout as sleep } from 'node:timers/promises'\nimport { stripVTControlCharacters } from 'node:util'\nimport { isRichOutput } from '../utils/env.ts'\nimport { type Expression, getIntro, wakeUp } from '../loggers/banner.ts'\nimport { isInteractiveRun } from './intro.ts'\n\nfunction bannerIntro(version: string, expression: Expression, command: string): string {\n return getIntro({ title: 'Turn your API spec into type-safe code', description: `kubb ${command}`, version, expression })\n}\n\n/** Whether the mascot can be drawn: a rich, 256-color terminal wide enough that no line wraps and throws off a redraw. */\nfunction canDrawMascot(version: string, command: string): boolean {\n if (!isRichOutput() || !process.stdout.hasColors(256)) return false\n\n return stripVTControlCharacters(bannerIntro(version, 'open', command))\n .split('\\n')\n .every((line) => line.length <= process.stdout.columns)\n}\n\n/**\n * Whether a command opens with the mascot. Only the long-running ones do: `generate`, a Studio\n * session or pairing, and `add` or `update` while they ask questions. Quick commands print only\n * their result.\n */\nexport function wantsMascot({ commandPath, values }: { commandPath: ReadonlyArray<string>; values: Record<string, unknown> }): boolean {\n const [command, subCommand] = commandPath\n if (values.help || values.version) return false\n if (command === 'studio') return subCommand === undefined || subCommand === 'connect' || subCommand === 'login'\n if (command === 'add' || command === 'update' || command === 'init') return isInteractiveRun({ yes: values.yes, dryRun: values.dryRun ?? values['dry-run'] })\n\n return command === undefined || command === 'generate'\n}\n\n/**\n * The still Kubb mascot with the version and the running command, such as `studio connect`, or a\n * single version line where the terminal cannot draw it. Commands print it as their header; it\n * draws at once, with no wake-up frames.\n */\nexport function getBanner(version: string, command: string): string {\n return canDrawMascot(version, command) ? `\\n${bannerIntro(version, 'open', command)}` : `Kubb CLI v${version}`\n}\n\n/**\n * Opens `kubb generate` with the mascot playing its wake-up frames in place, which takes under a\n * second and overlaps the config load. Elsewhere the still {@link getBanner} is the header.\n */\nexport async function logBanner(version: string): Promise<void> {\n if (!canDrawMascot(version, 'generate')) {\n console.log(getBanner(version, 'generate'))\n\n return\n }\n\n console.log('')\n for (const [index, [expression, ms]] of wakeUp.entries()) {\n const frame = bannerIntro(version, expression, 'generate')\n if (index > 0) process.stdout.moveCursor(0, -frame.split('\\n').length)\n console.log(frame)\n await sleep(ms)\n }\n}\n"],"mappings":";;;;;;;AAMA,SAAS,YAAY,SAAiB,YAAwB,SAAyB;CACrF,OAAO,SAAS;EAAE,OAAO;EAA0C,aAAa,QAAQ;EAAW;EAAS;CAAW,CAAC;AAC1H;;AAGA,SAAS,cAAc,SAAiB,SAA0B;CAChE,IAAI,CAAC,aAAa,KAAK,CAAC,QAAQ,OAAO,UAAU,GAAG,GAAG,OAAO;CAE9D,OAAO,yBAAyB,YAAY,SAAS,QAAQ,OAAO,CAAC,CAAC,CACnE,MAAM,IAAI,CAAC,CACX,OAAO,SAAS,KAAK,UAAU,QAAQ,OAAO,OAAO;AAC1D;;;;;;AAOA,SAAgB,YAAY,EAAE,aAAa,UAA4F;CACrI,MAAM,CAAC,SAAS,cAAc;CAC9B,IAAI,OAAO,QAAQ,OAAO,SAAS,OAAO;CAC1C,IAAI,YAAY,UAAU,OAAO,eAAe,KAAA,KAAa,eAAe,aAAa,eAAe;CACxG,IAAI,YAAY,SAAS,YAAY,YAAY,YAAY,QAAQ,OAAO,iBAAiB;EAAE,KAAK,OAAO;EAAK,QAAQ,OAAO,UAAU,OAAO;CAAW,CAAC;CAE5J,OAAO,YAAY,KAAA,KAAa,YAAY;AAC9C;;;;;;AAOA,SAAgB,UAAU,SAAiB,SAAyB;CAClE,OAAO,cAAc,SAAS,OAAO,IAAI,KAAK,YAAY,SAAS,QAAQ,OAAO,MAAM,aAAa;AACvG;;;;;AAMA,eAAsB,UAAU,SAAgC;CAC9D,IAAI,CAAC,cAAc,SAAS,UAAU,GAAG;EACvC,QAAQ,IAAI,UAAU,SAAS,UAAU,CAAC;EAE1C;CACF;CAEA,QAAQ,IAAI,EAAE;CACd,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,QAAQ,OAAO,QAAQ,GAAG;EACxD,MAAM,QAAQ,YAAY,SAAS,YAAY,UAAU;EACzD,IAAI,QAAQ,GAAG,QAAQ,OAAO,WAAW,GAAG,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM;EACrE,QAAQ,IAAI,KAAK;EACjB,MAAMA,WAAM,EAAE;CAChB;AACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
+
const require_env = require("./env-eu3XyKqJ.cjs");
|
|
3
|
+
const require_banner = require("./banner-wJFk-L-c.cjs");
|
|
4
|
+
const require_intro = require("./intro-YPaf1Imr.cjs");
|
|
5
|
+
let node_util = require("node:util");
|
|
6
|
+
let node_timers_promises = require("node:timers/promises");
|
|
7
|
+
// src/ui/mascot.ts
|
|
8
|
+
function bannerIntro(version, expression, command) {
|
|
9
|
+
return require_banner.getIntro({
|
|
10
|
+
title: "Turn your API spec into type-safe code",
|
|
11
|
+
description: `kubb ${command}`,
|
|
12
|
+
version,
|
|
13
|
+
expression
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** Whether the mascot can be drawn: a rich, 256-color terminal wide enough that no line wraps and throws off a redraw. */
|
|
17
|
+
function canDrawMascot(version, command) {
|
|
18
|
+
if (!require_env.isRichOutput() || !process.stdout.hasColors(256)) return false;
|
|
19
|
+
return (0, node_util.stripVTControlCharacters)(bannerIntro(version, "open", command)).split("\n").every((line) => line.length <= process.stdout.columns);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether a command opens with the mascot. Only the long-running ones do: `generate`, a Studio
|
|
23
|
+
* session or pairing, and `add` or `update` while they ask questions. Quick commands print only
|
|
24
|
+
* their result.
|
|
25
|
+
*/
|
|
26
|
+
function wantsMascot({ commandPath, values }) {
|
|
27
|
+
const [command, subCommand] = commandPath;
|
|
28
|
+
if (values.help || values.version) return false;
|
|
29
|
+
if (command === "studio") return subCommand === void 0 || subCommand === "connect" || subCommand === "login";
|
|
30
|
+
if (command === "add" || command === "update" || command === "init") return require_intro.isInteractiveRun({
|
|
31
|
+
yes: values.yes,
|
|
32
|
+
dryRun: values.dryRun ?? values["dry-run"]
|
|
33
|
+
});
|
|
34
|
+
return command === void 0 || command === "generate";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The still Kubb mascot with the version and the running command, such as `studio connect`, or a
|
|
38
|
+
* single version line where the terminal cannot draw it. Commands print it as their header; it
|
|
39
|
+
* draws at once, with no wake-up frames.
|
|
40
|
+
*/
|
|
41
|
+
function getBanner(version, command) {
|
|
42
|
+
return canDrawMascot(version, command) ? `\n${bannerIntro(version, "open", command)}` : `Kubb CLI v${version}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Opens `kubb generate` with the mascot playing its wake-up frames in place, which takes under a
|
|
46
|
+
* second and overlaps the config load. Elsewhere the still {@link getBanner} is the header.
|
|
47
|
+
*/
|
|
48
|
+
async function logBanner(version) {
|
|
49
|
+
if (!canDrawMascot(version, "generate")) {
|
|
50
|
+
console.log(getBanner(version, "generate"));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
console.log("");
|
|
54
|
+
for (const [index, [expression, ms]] of require_banner.wakeUp.entries()) {
|
|
55
|
+
const frame = bannerIntro(version, expression, "generate");
|
|
56
|
+
if (index > 0) process.stdout.moveCursor(0, -frame.split("\n").length);
|
|
57
|
+
console.log(frame);
|
|
58
|
+
await (0, node_timers_promises.setTimeout)(ms);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
Object.defineProperty(exports, "getBanner", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return getBanner;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "logBanner", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function() {
|
|
70
|
+
return logBanner;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "wantsMascot", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function() {
|
|
76
|
+
return wantsMascot;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=mascot-JSA0j3Q_.cjs.map
|