@kubb/cli 5.4.1 → 5.4.3
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/dist/background-BR0Ipfrd.js +2 -0
- package/dist/{background-CNHhnQ5M.cjs → background-Ce9VMMKw.cjs} +2 -2
- package/dist/{background-CNHhnQ5M.cjs.map → background-Ce9VMMKw.cjs.map} +1 -1
- package/dist/{background-BDZa6MJS.js → background-Cx8cJj7Y.js} +2 -2
- package/dist/{background-BDZa6MJS.js.map → background-Cx8cJj7Y.js.map} +1 -1
- package/dist/{connect-CIVmP_6l.js → connect-BIu_PSH-.js} +2 -2
- package/dist/{connect-CIVmP_6l.js.map → connect-BIu_PSH-.js.map} +1 -1
- package/dist/{connect-DLbFBfoV.cjs → connect-DdHw57kt.cjs} +2 -2
- package/dist/{connect-DLbFBfoV.cjs.map → connect-DdHw57kt.cjs.map} +1 -1
- package/dist/{generate-BWwjYxN5.cjs → generate-DPHF7HZV.cjs} +2 -2
- package/dist/{generate-BWwjYxN5.cjs.map → generate-DPHF7HZV.cjs.map} +1 -1
- package/dist/{generate-BY_PbRPu.js → generate-VO87PyfI.js} +2 -2
- package/dist/{generate-BY_PbRPu.js.map → generate-VO87PyfI.js.map} +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +7 -7
- package/dist/{init-Dpa1wuah.js → init-BBxc642Q.js} +3 -3
- package/dist/{init-Dpa1wuah.js.map → init-BBxc642Q.js.map} +1 -1
- package/dist/{init-yb2ZIQwp.cjs → init-DC9FUoxj.cjs} +3 -3
- package/dist/{init-yb2ZIQwp.cjs.map → init-DC9FUoxj.cjs.map} +1 -1
- package/dist/{login-LVIZdclC.cjs → login-B_izuxO_.cjs} +2 -2
- package/dist/{login-LVIZdclC.cjs.map → login-B_izuxO_.cjs.map} +1 -1
- package/dist/{login-Di6_DU_V.js → login-CpU9BK7b.js} +2 -2
- package/dist/{login-Di6_DU_V.js.map → login-CpU9BK7b.js.map} +1 -1
- package/dist/{logout-BOhSROh8.js → logout-CqkHzQH1.js} +3 -3
- package/dist/{logout-BOhSROh8.js.map → logout-CqkHzQH1.js.map} +1 -1
- package/dist/{logout-B8L-Jb8P.cjs → logout-Di36A0n6.cjs} +3 -3
- package/dist/{logout-B8L-Jb8P.cjs.map → logout-Di36A0n6.cjs.map} +1 -1
- package/dist/{output-D-9bGS7y.cjs → output-9qUFmWFq.cjs} +2 -2
- package/dist/{output-D-9bGS7y.cjs.map → output-9qUFmWFq.cjs.map} +1 -1
- package/dist/{output-C5h3LBgQ.js → output-Dkoh9Ig6.js} +32 -32
- package/dist/{output-C5h3LBgQ.js.map → output-Dkoh9Ig6.js.map} +1 -1
- package/dist/{package-DjS7Xk-S.cjs → package-B4G0q-YP.cjs} +2 -2
- package/dist/package-B4G0q-YP.cjs.map +1 -0
- package/dist/package-CfCLgvAl.js +6 -0
- package/dist/package-CfCLgvAl.js.map +1 -0
- package/dist/{run-_hE0GAWu.cjs → run-0D4BZdd3.cjs} +8 -10
- package/dist/run-0D4BZdd3.cjs.map +1 -0
- package/dist/{run-G2lUygYI.js → run-BH26mNIp.js} +2 -2
- package/dist/{run-G2lUygYI.js.map → run-BH26mNIp.js.map} +1 -1
- package/dist/{run-BNQt-kUj.cjs → run-BY1obXw_.cjs} +2 -2
- package/dist/{run-BNQt-kUj.cjs.map → run-BY1obXw_.cjs.map} +1 -1
- package/dist/{run-DQNoMoHW.js → run-BdeIqfMV.js} +4 -4
- package/dist/{run-DQNoMoHW.js.map → run-BdeIqfMV.js.map} +1 -1
- package/dist/{run-Bidc3n3b.cjs → run-BhRWMu9D.cjs} +2 -2
- package/dist/{run-Bidc3n3b.cjs.map → run-BhRWMu9D.cjs.map} +1 -1
- package/dist/{run-BsP5syy1.js → run-C1SWZ9eL.js} +8 -10
- package/dist/run-C1SWZ9eL.js.map +1 -0
- package/dist/{run-GGJ4QLsg.cjs → run-D0wlQfZ8.cjs} +2 -2
- package/dist/{run-GGJ4QLsg.cjs.map → run-D0wlQfZ8.cjs.map} +1 -1
- package/dist/{run-0k75--OI.cjs → run-DI7XBIsh.cjs} +4 -4
- package/dist/{run-0k75--OI.cjs.map → run-DI7XBIsh.cjs.map} +1 -1
- package/dist/{run-Drf9rg9j.js → run-D_C7iUvw.js} +2 -2
- package/dist/{run-Drf9rg9j.js.map → run-D_C7iUvw.js.map} +1 -1
- package/dist/{run-BaqE5cze.js → run-OrUv1xEc.js} +2 -2
- package/dist/{run-BaqE5cze.js.map → run-OrUv1xEc.js.map} +1 -1
- package/dist/{snapshot-ZY24CtRk.js → snapshot-8XW1pmpz.js} +4 -4
- package/dist/{snapshot-ZY24CtRk.js.map → snapshot-8XW1pmpz.js.map} +1 -1
- package/dist/{snapshot-DndnZx5y.cjs → snapshot-BX3KCMWD.cjs} +4 -4
- package/dist/{snapshot-DndnZx5y.cjs.map → snapshot-BX3KCMWD.cjs.map} +1 -1
- package/dist/{start-Bu5xpzix.cjs → start-DI5M1g92.cjs} +3 -3
- package/dist/{start-Bu5xpzix.cjs.map → start-DI5M1g92.cjs.map} +1 -1
- package/dist/{start-BlwmWZDb.js → start-Dx9F16X8.js} +3 -3
- package/dist/{start-BlwmWZDb.js.map → start-Dx9F16X8.js.map} +1 -1
- package/dist/{status-5UqQP9WB.js → status-DLbxVdwR.js} +3 -3
- package/dist/{status-5UqQP9WB.js.map → status-DLbxVdwR.js.map} +1 -1
- package/dist/{status-L4I8buia.cjs → status-hQ-QcLwq.cjs} +3 -3
- package/dist/{status-L4I8buia.cjs.map → status-hQ-QcLwq.cjs.map} +1 -1
- package/dist/{stop-BQkjAPNH.cjs → stop-KwKHpVjZ.cjs} +2 -2
- package/dist/{stop-BQkjAPNH.cjs.map → stop-KwKHpVjZ.cjs.map} +1 -1
- package/dist/{stop-mqUTbxMO.js → stop-Sy9iOohk.js} +2 -2
- package/dist/{stop-mqUTbxMO.js.map → stop-Sy9iOohk.js.map} +1 -1
- package/dist/{studio-BFy085ae.cjs → studio-BWsI-OYx.cjs} +9 -9
- package/dist/{studio-BFy085ae.cjs.map → studio-BWsI-OYx.cjs.map} +1 -1
- package/dist/{studio-BBnIuXst.js → studio-CfG8y4pJ.js} +9 -9
- package/dist/{studio-BBnIuXst.js.map → studio-CfG8y4pJ.js.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{utils-BWksgOYQ.js → utils-BYY3_cyq.js} +266 -266
- package/dist/utils-BYY3_cyq.js.map +1 -0
- package/dist/{utils-DqUNntyL.cjs → utils-Dcw3l4Wz.cjs} +9 -3
- package/dist/utils-Dcw3l4Wz.cjs.map +1 -0
- package/package.json +8 -8
- package/dist/background-CS7jIBAY.js +0 -2
- package/dist/package-DjS7Xk-S.cjs.map +0 -1
- package/dist/package-IY922xjh.js +0 -6
- package/dist/package-IY922xjh.js.map +0 -1
- package/dist/run-BsP5syy1.js.map +0 -1
- package/dist/run-_hE0GAWu.cjs.map +0 -1
- package/dist/utils-BWksgOYQ.js.map +0 -1
- package/dist/utils-DqUNntyL.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio-
|
|
1
|
+
{"version":3,"file":"studio-CfG8y4pJ.js","names":["definition","definition","definition","definition","definition","connectDefinition","definition","startDefinition","connectDefinition","loginDefinition","logoutDefinition","statusDefinition","snapshotDefinition"],"sources":["../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const definition = define({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const definition = define({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const definition = define({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: ['kubb studio logout'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const definition = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n rendering: {\n header: null,\n },\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n timeout: {\n type: 'number',\n description: 'Seconds to wait for the job to finish',\n default: 600,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n})\n","import { define } from 'gunshi'\nimport { definition as connectDefinition } from './connect.ts'\n\nexport const definition = define({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n toKebab: true,\n args: connectDefinition.args,\n})\nexport const stopDefinition = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\n\nexport const definition = define({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: ['kubb studio status'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n ...logLevelArg,\n },\n})\n","import { define, lazy } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { definition as connectDefinition } from './connect.ts'\nimport { definition as loginDefinition } from './login.ts'\nimport { definition as logoutDefinition } from './logout.ts'\nimport { definition as snapshotDefinition } from './snapshot.ts'\nimport { definition as startDefinition, stopDefinition } from './background.ts'\nimport { definition as statusDefinition } from './status.ts'\n\nexport const definition = define({\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/connect.ts')\n await runner(ctx)\n },\n subCommands: {\n start: lazy(async () => (await import('../../runners/studio/start.ts')).runner, startDefinition),\n stop: lazy(async () => (await import('../../runners/studio/stop.ts')).runner, stopDefinition),\n connect: lazy(async () => (await import('../../runners/studio/connect.ts')).runner, connectDefinition),\n login: lazy(async () => (await import('../../runners/studio/login.ts')).runner, loginDefinition),\n logout: lazy(async () => (await import('../../runners/studio/logout.ts')).runner, logoutDefinition),\n status: lazy(async () => (await import('../../runners/studio/status.ts')).runner, statusDefinition),\n snapshot: lazy(async () => (await import('../../runners/studio/snapshot.ts')).runner, snapshotDefinition),\n },\n})\n"],"mappings":"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"}
|
package/dist/studioWorker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import { l as getProjectKubbHome, t as connect } from "./run-
|
|
3
|
-
import { r as serveWorker, t as getWorkerLogPath } from "./background-
|
|
2
|
+
import { l as getProjectKubbHome, t as connect } from "./run-C1SWZ9eL.js";
|
|
3
|
+
import { r as serveWorker, t as getWorkerLogPath } from "./background-Cx8cJj7Y.js";
|
|
4
4
|
import { format } from "node:util";
|
|
5
5
|
import { appendFileSync, mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { createFileStorage, setStorage } from "@kubb/studio";
|
|
@@ -2,7 +2,7 @@ import "./rolldown-runtime-CRm0XQPb.js";
|
|
|
2
2
|
import { t as toError } from "./errors-BQJzaUwP.js";
|
|
3
3
|
import { t as getAgentName } from "./agent-w0Hlq4mG.js";
|
|
4
4
|
import { c as URL_WATCHER_TIMEOUT_MS, l as WATCHER_IGNORED_PATHS, s as URL_WATCHER_INTERVAL_MS } from "./Telemetry-cHHOzBW8.js";
|
|
5
|
-
import { f as
|
|
5
|
+
import { f as canUseTTY, h as getElapsedMs, m as formatMs, p as formatMsWithColor } from "./output-Dkoh9Ig6.js";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
import process from "node:process";
|
|
@@ -13,7 +13,7 @@ import { createJiti } from "jiti";
|
|
|
13
13
|
import { Diagnostics, createCliReporter, logLevel } from "@kubb/core";
|
|
14
14
|
import { NonZeroExitError, x } from "tinyexec";
|
|
15
15
|
import { loadConfig } from "unconfig";
|
|
16
|
-
import {
|
|
16
|
+
import { isGreaterThan, isValid, truncate } from "verkit";
|
|
17
17
|
//#region ../../internals/utils/src/tools.ts
|
|
18
18
|
/**
|
|
19
19
|
* CLI command descriptors for each supported code formatter.
|
|
@@ -149,6 +149,258 @@ function createModuleLoader() {
|
|
|
149
149
|
return options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath);
|
|
150
150
|
} };
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* TTY logger for local development, with animated steps and progress bars.
|
|
154
|
+
*/
|
|
155
|
+
const clackLogger = {
|
|
156
|
+
name: "clack",
|
|
157
|
+
install: createLogger({
|
|
158
|
+
group: (title) => clack.intro(title),
|
|
159
|
+
groupEnd: (text) => clack.outro(text),
|
|
160
|
+
step: (text) => clack.log.step(text, { spacing: 0 }),
|
|
161
|
+
info: (text) => clack.log.info(text),
|
|
162
|
+
success: (text) => clack.log.success(text),
|
|
163
|
+
warn: (text) => clack.log.warn(text),
|
|
164
|
+
error: (text) => clack.log.error(text),
|
|
165
|
+
block: (lines) => clack.log.message(lines, { spacing: 0 }),
|
|
166
|
+
raw: (lines) => console.log(styleText("dim", lines.join("\n"))),
|
|
167
|
+
diagnostic: (lines) => clack.log.message(lines, {
|
|
168
|
+
symbol: "",
|
|
169
|
+
secondarySymbol: ""
|
|
170
|
+
}),
|
|
171
|
+
update: (lines, title) => clack.box(lines.join("\n"), title, {
|
|
172
|
+
width: "auto",
|
|
173
|
+
formatBorder: (border) => styleText("yellow", border),
|
|
174
|
+
rounded: true,
|
|
175
|
+
withGuide: false,
|
|
176
|
+
contentAlign: "center",
|
|
177
|
+
titleAlign: "center"
|
|
178
|
+
}),
|
|
179
|
+
spinner() {
|
|
180
|
+
const spinner = clack.spinner();
|
|
181
|
+
return {
|
|
182
|
+
start: (text) => spinner.start(text),
|
|
183
|
+
message: (text) => spinner.message(text),
|
|
184
|
+
clear: () => spinner.clear(),
|
|
185
|
+
stop: (text) => spinner.stop(text),
|
|
186
|
+
error: (text) => spinner.error(text)
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
progress(max) {
|
|
190
|
+
const bar = clack.progress({
|
|
191
|
+
style: "block",
|
|
192
|
+
max,
|
|
193
|
+
size: 30
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
start: (text) => bar.start(text),
|
|
197
|
+
advance: (text) => bar.advance(1, text),
|
|
198
|
+
stop: (text) => bar.stop(text)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
};
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/loggers/utils.ts
|
|
205
|
+
/**
|
|
206
|
+
* Display path for a config's input: the string form, or its `path` field when the input is an
|
|
207
|
+
* object. Loggers show it alongside `Generation started`.
|
|
208
|
+
*/
|
|
209
|
+
function getInputPath(config) {
|
|
210
|
+
const { input } = config;
|
|
211
|
+
if (typeof input === "string") return input;
|
|
212
|
+
return typeof input?.path === "string" ? input.path : void 0;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Counts a noun, so a message never reads `1 files`.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* `pluralize(1, 'config')` returns `'1 config'`
|
|
219
|
+
*/
|
|
220
|
+
function pluralize(count, noun) {
|
|
221
|
+
return `${count} ${count === 1 ? noun : `${noun}s`}`;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.
|
|
225
|
+
* Shared across all logger adapters to avoid duplication.
|
|
226
|
+
*/
|
|
227
|
+
function formatMessage(message, logLevel$2) {
|
|
228
|
+
if (logLevel$2 >= logLevel.verbose) {
|
|
229
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
230
|
+
hour12: false,
|
|
231
|
+
hour: "2-digit",
|
|
232
|
+
minute: "2-digit",
|
|
233
|
+
second: "2-digit"
|
|
234
|
+
});
|
|
235
|
+
return `${styleText("dim", `[${timestamp}]`)} ${message}`;
|
|
236
|
+
}
|
|
237
|
+
return message;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Renders the versions from a `studio:connected` event as one parenthetical. The runtime is listed
|
|
241
|
+
* only when it differs from the host, and Studio's only when it sent one.
|
|
242
|
+
*/
|
|
243
|
+
function formatVersions({ studio, kubb, agent }) {
|
|
244
|
+
return [
|
|
245
|
+
`v${agent}`,
|
|
246
|
+
kubb !== agent ? `runtime v${kubb}` : void 0,
|
|
247
|
+
studio ? `Studio v${studio}` : void 0
|
|
248
|
+
].filter(Boolean).join(", ");
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
|
|
252
|
+
*/
|
|
253
|
+
function toCause(error) {
|
|
254
|
+
return error.cause instanceof Error ? error.cause : void 0;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* First stack frames for verbose error output, including an optional `cause` chain.
|
|
258
|
+
*/
|
|
259
|
+
function formatErrorFrames(error) {
|
|
260
|
+
if (!error.stack) return null;
|
|
261
|
+
const frames = error.stack.split("\n").slice(1, 4).map((frame) => frame.trim());
|
|
262
|
+
const caused = toCause(error);
|
|
263
|
+
if (!caused?.stack) return { frames };
|
|
264
|
+
return {
|
|
265
|
+
frames,
|
|
266
|
+
cause: {
|
|
267
|
+
header: `└─ caused by ${caused.message}`,
|
|
268
|
+
frames: caused.stack.split("\n").slice(1, 4).map((frame) => frame.trim())
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Build the progress summary line shown by the clack logger.
|
|
274
|
+
* Returns null when there is nothing to display.
|
|
275
|
+
*/
|
|
276
|
+
function buildProgressLine(state) {
|
|
277
|
+
const parts = [];
|
|
278
|
+
const duration = formatMs(getElapsedMs(state.hrStart));
|
|
279
|
+
if (state.totalPlugins > 0) {
|
|
280
|
+
const pluginStr = state.failedPlugins > 0 ? `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins} ${styleText("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
281
|
+
parts.push(pluginStr);
|
|
282
|
+
}
|
|
283
|
+
if (state.totalFiles > 0) parts.push(`Files ${styleText("green", state.processedFiles.toString())}/${state.totalFiles}`);
|
|
284
|
+
if (parts.length === 0) return null;
|
|
285
|
+
parts.push(`${styleText("green", duration)} elapsed`);
|
|
286
|
+
return parts.join(styleText("dim", " | "));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Creates the per-run progress counters used by the clack logger.
|
|
290
|
+
*/
|
|
291
|
+
function createProgressCounters() {
|
|
292
|
+
return {
|
|
293
|
+
totalPlugins: 0,
|
|
294
|
+
completedPlugins: 0,
|
|
295
|
+
failedPlugins: 0,
|
|
296
|
+
totalFiles: 0,
|
|
297
|
+
processedFiles: 0,
|
|
298
|
+
hrStart: process.hrtime()
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Resets the progress counters in place at the start/end of a generation run.
|
|
303
|
+
*/
|
|
304
|
+
function resetProgressCounters(state) {
|
|
305
|
+
state.totalPlugins = 0;
|
|
306
|
+
state.completedPlugins = 0;
|
|
307
|
+
state.failedPlugins = 0;
|
|
308
|
+
state.totalFiles = 0;
|
|
309
|
+
state.processedFiles = 0;
|
|
310
|
+
state.hrStart = process.hrtime();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Records a finished plugin against the progress counters.
|
|
314
|
+
*/
|
|
315
|
+
function recordPluginResult(state, success) {
|
|
316
|
+
if (success) state.completedPlugins++;
|
|
317
|
+
else state.failedPlugins++;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Join a command and its optional args into a single display string.
|
|
321
|
+
*
|
|
322
|
+
* @example With args
|
|
323
|
+
* `formatCommandWithArgs('prettier', ['--write', '.'])` returns `'prettier --write .'`
|
|
324
|
+
*/
|
|
325
|
+
function formatCommandWithArgs(command, args) {
|
|
326
|
+
return args?.length ? `${command} ${args.join(" ")}` : command;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's
|
|
330
|
+
* {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.
|
|
331
|
+
*/
|
|
332
|
+
function installReporter(context, reporter, ctx) {
|
|
333
|
+
const pluginFiles = reporter.needsPluginFiles ? /* @__PURE__ */ new Map() : void 0;
|
|
334
|
+
if (pluginFiles) context.hook("kubb:plugin:end", ({ config, plugin, files }) => {
|
|
335
|
+
const filesByPlugin = pluginFiles.get(config) ?? /* @__PURE__ */ new Map();
|
|
336
|
+
const seen = new Set([...filesByPlugin.values()].flatMap((paths) => [...paths]));
|
|
337
|
+
const added = files.filter((file) => !seen.has(file.path)).map((file) => file.path);
|
|
338
|
+
if (added.length) filesByPlugin.set(plugin.name, /* @__PURE__ */ new Set([...filesByPlugin.get(plugin.name) ?? [], ...added]));
|
|
339
|
+
pluginFiles.set(config, filesByPlugin);
|
|
340
|
+
});
|
|
341
|
+
context.hook("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => {
|
|
342
|
+
const files = pluginFiles?.get(config);
|
|
343
|
+
const grouped = files && [...files].map(([plugin, paths]) => ({
|
|
344
|
+
plugin,
|
|
345
|
+
files: [...paths]
|
|
346
|
+
}));
|
|
347
|
+
await reporter.report({
|
|
348
|
+
config,
|
|
349
|
+
diagnostics,
|
|
350
|
+
filesCreated,
|
|
351
|
+
status,
|
|
352
|
+
hrStart,
|
|
353
|
+
pluginFiles: grouped
|
|
354
|
+
}, ctx);
|
|
355
|
+
pluginFiles?.delete(config);
|
|
356
|
+
});
|
|
357
|
+
if (reporter.drain) context.hook("kubb:lifecycle:end", () => reporter.drain?.(ctx));
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
|
|
361
|
+
* already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This
|
|
362
|
+
* only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the
|
|
363
|
+
* `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.
|
|
364
|
+
*
|
|
365
|
+
* Loggers and reporters are independent, except for `cli`: it both installs the live logger view
|
|
366
|
+
* here and registers a reporter that renders the per-config summary through that logger, so the
|
|
367
|
+
* summary lands inside the group the logger opened. The `json` reporter owns stdout, so the whole
|
|
368
|
+
* `cli` reporter (live logger and summary) is skipped whenever `json` is among the reporters, even
|
|
369
|
+
* if `cli` is also listed.
|
|
370
|
+
*/
|
|
371
|
+
async function setupReporters(context, { logLevel, reporters, logger: forcedLogger }) {
|
|
372
|
+
let cliHandle;
|
|
373
|
+
const hasJson = reporters.some((reporter) => reporter.name === "json");
|
|
374
|
+
const ctx = { logLevel };
|
|
375
|
+
for (const reporter of reporters) {
|
|
376
|
+
if (reporter.name !== "cli") {
|
|
377
|
+
installReporter(context, reporter, ctx);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (hasJson) continue;
|
|
381
|
+
const handle = await (forcedLogger ?? (canUseTTY() && !getAgentName() ? clackLogger : plainLogger)).install(context, { logLevel }) ?? void 0;
|
|
382
|
+
cliHandle = handle;
|
|
383
|
+
installReporter(context, createCliReporter({ render: handle?.renderSummary }), ctx);
|
|
384
|
+
}
|
|
385
|
+
return cliHandle;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Picks the reporters whose `name` matches one of `names`, in the order the names are given.
|
|
389
|
+
* The config carries every available reporter, and the host selects which to activate by name
|
|
390
|
+
* (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are
|
|
391
|
+
* skipped.
|
|
392
|
+
*/
|
|
393
|
+
function selectReporters(reporters, names) {
|
|
394
|
+
const seen = /* @__PURE__ */ new Set();
|
|
395
|
+
const selected = [];
|
|
396
|
+
for (const name of names) {
|
|
397
|
+
if (seen.has(name)) continue;
|
|
398
|
+
seen.add(name);
|
|
399
|
+
const reporter = reporters.find((candidate) => candidate.name === name);
|
|
400
|
+
if (reporter) selected.push(reporter);
|
|
401
|
+
}
|
|
402
|
+
return selected;
|
|
403
|
+
}
|
|
152
404
|
//#endregion
|
|
153
405
|
//#region src/loggers/createLogger.ts
|
|
154
406
|
/**
|
|
@@ -194,8 +446,8 @@ function trimBlankEdges(lines) {
|
|
|
194
446
|
*/
|
|
195
447
|
function createLogger(writer) {
|
|
196
448
|
return function install(context, options) {
|
|
197
|
-
const logLevel$
|
|
198
|
-
const silent = logLevel$
|
|
449
|
+
const logLevel$1 = options?.logLevel ?? logLevel.info;
|
|
450
|
+
const silent = logLevel$1 <= logLevel.silent;
|
|
199
451
|
const state = {
|
|
200
452
|
...createProgressCounters(),
|
|
201
453
|
spinner: null,
|
|
@@ -209,7 +461,7 @@ function createLogger(writer) {
|
|
|
209
461
|
groupOpen: false
|
|
210
462
|
};
|
|
211
463
|
function text(message) {
|
|
212
|
-
return formatMessage(message, logLevel$
|
|
464
|
+
return formatMessage(message, logLevel$1);
|
|
213
465
|
}
|
|
214
466
|
function startSpinner(message) {
|
|
215
467
|
if (silent) return;
|
|
@@ -299,7 +551,7 @@ function createLogger(writer) {
|
|
|
299
551
|
const line = text([
|
|
300
552
|
styleText("green", "✓"),
|
|
301
553
|
message,
|
|
302
|
-
logLevel$
|
|
554
|
+
logLevel$1 >= logLevel.info && info ? styleText("dim", info) : void 0
|
|
303
555
|
].filter(Boolean).join(" "));
|
|
304
556
|
if (state.spinner) {
|
|
305
557
|
state.spinner.message(line);
|
|
@@ -308,11 +560,11 @@ function createLogger(writer) {
|
|
|
308
560
|
writer.success(line);
|
|
309
561
|
});
|
|
310
562
|
context.hook("kubb:warn", ({ message, info }) => {
|
|
311
|
-
if (logLevel$
|
|
563
|
+
if (logLevel$1 < logLevel.warn) return;
|
|
312
564
|
writer.warn(text([
|
|
313
565
|
styleText("yellow", "⚠"),
|
|
314
566
|
message,
|
|
315
|
-
logLevel$
|
|
567
|
+
logLevel$1 >= logLevel.info && info ? styleText("dim", info) : void 0
|
|
316
568
|
].filter(Boolean).join(" ")));
|
|
317
569
|
});
|
|
318
570
|
context.hook("kubb:error", ({ error }) => {
|
|
@@ -320,7 +572,7 @@ function createLogger(writer) {
|
|
|
320
572
|
const line = [styleText("red", "✗"), error.message].join(" ");
|
|
321
573
|
if (state.spinner) stopSpinner(line, "failed");
|
|
322
574
|
else writer.error(text(line));
|
|
323
|
-
const frames = logLevel$
|
|
575
|
+
const frames = logLevel$1 >= logLevel.verbose ? formatErrorFrames(error) : null;
|
|
324
576
|
if (!frames) return;
|
|
325
577
|
writer.block(frames.frames.map((frame) => text(styleText("dim", frame))));
|
|
326
578
|
if (frames.cause) writer.block([styleText("dim", frames.cause.header), ...frames.cause.frames.map((frame) => text(` ${styleText("dim", frame)}`))]);
|
|
@@ -353,7 +605,7 @@ function createLogger(writer) {
|
|
|
353
605
|
startSpinner("✓ Ready to receive jobs");
|
|
354
606
|
});
|
|
355
607
|
context.hook("studio:disconnected", ({ reason }) => {
|
|
356
|
-
if (logLevel$
|
|
608
|
+
if (logLevel$1 < logLevel.warn) return;
|
|
357
609
|
stopSpinner();
|
|
358
610
|
writer.warn(text(`⚠ Kubb Studio ended the session (${reason})`));
|
|
359
611
|
});
|
|
@@ -373,7 +625,7 @@ function createLogger(writer) {
|
|
|
373
625
|
writer.info(text(styleText("dim", `Retrying connection to Kubb Studio in ${formatMs(delayMs)}`)));
|
|
374
626
|
});
|
|
375
627
|
context.hook("studio:warn", ({ message, permission }) => {
|
|
376
|
-
if (logLevel$
|
|
628
|
+
if (logLevel$1 < logLevel.warn) return;
|
|
377
629
|
const remedy = permission ? `; pass --${permission.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)} to allow it` : "";
|
|
378
630
|
writer.warn(text(`⚠ ${message}${remedy}`));
|
|
379
631
|
});
|
|
@@ -498,57 +750,6 @@ function createLogger(writer) {
|
|
|
498
750
|
} };
|
|
499
751
|
};
|
|
500
752
|
}
|
|
501
|
-
/**
|
|
502
|
-
* TTY logger for local development, with animated steps and progress bars.
|
|
503
|
-
*/
|
|
504
|
-
const clackLogger = {
|
|
505
|
-
name: "clack",
|
|
506
|
-
install: createLogger({
|
|
507
|
-
group: (title) => clack.intro(title),
|
|
508
|
-
groupEnd: (text) => clack.outro(text),
|
|
509
|
-
step: (text) => clack.log.step(text, { spacing: 0 }),
|
|
510
|
-
info: (text) => clack.log.info(text),
|
|
511
|
-
success: (text) => clack.log.success(text),
|
|
512
|
-
warn: (text) => clack.log.warn(text),
|
|
513
|
-
error: (text) => clack.log.error(text),
|
|
514
|
-
block: (lines) => clack.log.message(lines, { spacing: 0 }),
|
|
515
|
-
raw: (lines) => console.log(styleText("dim", lines.join("\n"))),
|
|
516
|
-
diagnostic: (lines) => clack.log.message(lines, {
|
|
517
|
-
symbol: "",
|
|
518
|
-
secondarySymbol: ""
|
|
519
|
-
}),
|
|
520
|
-
update: (lines, title) => clack.box(lines.join("\n"), title, {
|
|
521
|
-
width: "auto",
|
|
522
|
-
formatBorder: (border) => styleText("yellow", border),
|
|
523
|
-
rounded: true,
|
|
524
|
-
withGuide: false,
|
|
525
|
-
contentAlign: "center",
|
|
526
|
-
titleAlign: "center"
|
|
527
|
-
}),
|
|
528
|
-
spinner() {
|
|
529
|
-
const spinner = clack.spinner();
|
|
530
|
-
return {
|
|
531
|
-
start: (text) => spinner.start(text),
|
|
532
|
-
message: (text) => spinner.message(text),
|
|
533
|
-
clear: () => spinner.clear(),
|
|
534
|
-
stop: (text) => spinner.stop(text),
|
|
535
|
-
error: (text) => spinner.error(text)
|
|
536
|
-
};
|
|
537
|
-
},
|
|
538
|
-
progress(max) {
|
|
539
|
-
const bar = clack.progress({
|
|
540
|
-
style: "block",
|
|
541
|
-
max,
|
|
542
|
-
size: 30
|
|
543
|
-
});
|
|
544
|
-
return {
|
|
545
|
-
start: (text) => bar.start(text),
|
|
546
|
-
advance: (text) => bar.advance(1, text),
|
|
547
|
-
stop: (text) => bar.stop(text)
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
})
|
|
551
|
-
};
|
|
552
753
|
//#endregion
|
|
553
754
|
//#region src/loggers/plainLogger.ts
|
|
554
755
|
/**
|
|
@@ -601,207 +802,6 @@ function createPlainLogger(write) {
|
|
|
601
802
|
*/
|
|
602
803
|
const plainLogger = createPlainLogger((line) => console.log(line));
|
|
603
804
|
//#endregion
|
|
604
|
-
//#region src/loggers/utils.ts
|
|
605
|
-
/**
|
|
606
|
-
* Display path for a config's input: the string form, or its `path` field when the input is an
|
|
607
|
-
* object. Loggers show it alongside `Generation started`.
|
|
608
|
-
*/
|
|
609
|
-
function getInputPath(config) {
|
|
610
|
-
const { input } = config;
|
|
611
|
-
if (typeof input === "string") return input;
|
|
612
|
-
return typeof input?.path === "string" ? input.path : void 0;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Counts a noun, so a message never reads `1 files`.
|
|
616
|
-
*
|
|
617
|
-
* @example
|
|
618
|
-
* `pluralize(1, 'config')` returns `'1 config'`
|
|
619
|
-
*/
|
|
620
|
-
function pluralize(count, noun) {
|
|
621
|
-
return `${count} ${count === 1 ? noun : `${noun}s`}`;
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.
|
|
625
|
-
* Shared across all logger adapters to avoid duplication.
|
|
626
|
-
*/
|
|
627
|
-
function formatMessage(message, logLevel$1) {
|
|
628
|
-
if (logLevel$1 >= logLevel.verbose) {
|
|
629
|
-
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
630
|
-
hour12: false,
|
|
631
|
-
hour: "2-digit",
|
|
632
|
-
minute: "2-digit",
|
|
633
|
-
second: "2-digit"
|
|
634
|
-
});
|
|
635
|
-
return `${styleText("dim", `[${timestamp}]`)} ${message}`;
|
|
636
|
-
}
|
|
637
|
-
return message;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Renders the versions from a `studio:connected` event as one parenthetical. The runtime is listed
|
|
641
|
-
* only when it differs from the host, and Studio's only when it sent one.
|
|
642
|
-
*/
|
|
643
|
-
function formatVersions({ studio, kubb, agent }) {
|
|
644
|
-
return [
|
|
645
|
-
`v${agent}`,
|
|
646
|
-
kubb !== agent ? `runtime v${kubb}` : void 0,
|
|
647
|
-
studio ? `Studio v${studio}` : void 0
|
|
648
|
-
].filter(Boolean).join(", ");
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
|
|
652
|
-
*/
|
|
653
|
-
function toCause(error) {
|
|
654
|
-
return error.cause instanceof Error ? error.cause : void 0;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* First stack frames for verbose error output, including an optional `cause` chain.
|
|
658
|
-
*/
|
|
659
|
-
function formatErrorFrames(error) {
|
|
660
|
-
if (!error.stack) return null;
|
|
661
|
-
const frames = error.stack.split("\n").slice(1, 4).map((frame) => frame.trim());
|
|
662
|
-
const caused = toCause(error);
|
|
663
|
-
if (!caused?.stack) return { frames };
|
|
664
|
-
return {
|
|
665
|
-
frames,
|
|
666
|
-
cause: {
|
|
667
|
-
header: `└─ caused by ${caused.message}`,
|
|
668
|
-
frames: caused.stack.split("\n").slice(1, 4).map((frame) => frame.trim())
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Build the progress summary line shown by the clack logger.
|
|
674
|
-
* Returns null when there is nothing to display.
|
|
675
|
-
*/
|
|
676
|
-
function buildProgressLine(state) {
|
|
677
|
-
const parts = [];
|
|
678
|
-
const duration = formatMs(getElapsedMs(state.hrStart));
|
|
679
|
-
if (state.totalPlugins > 0) {
|
|
680
|
-
const pluginStr = state.failedPlugins > 0 ? `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins} ${styleText("red", `(${state.failedPlugins} failed)`)}` : `Plugins ${styleText("green", state.completedPlugins.toString())}/${state.totalPlugins}`;
|
|
681
|
-
parts.push(pluginStr);
|
|
682
|
-
}
|
|
683
|
-
if (state.totalFiles > 0) parts.push(`Files ${styleText("green", state.processedFiles.toString())}/${state.totalFiles}`);
|
|
684
|
-
if (parts.length === 0) return null;
|
|
685
|
-
parts.push(`${styleText("green", duration)} elapsed`);
|
|
686
|
-
return parts.join(styleText("dim", " | "));
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* Creates the per-run progress counters used by the clack logger.
|
|
690
|
-
*/
|
|
691
|
-
function createProgressCounters() {
|
|
692
|
-
return {
|
|
693
|
-
totalPlugins: 0,
|
|
694
|
-
completedPlugins: 0,
|
|
695
|
-
failedPlugins: 0,
|
|
696
|
-
totalFiles: 0,
|
|
697
|
-
processedFiles: 0,
|
|
698
|
-
hrStart: process.hrtime()
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Resets the progress counters in place at the start/end of a generation run.
|
|
703
|
-
*/
|
|
704
|
-
function resetProgressCounters(state) {
|
|
705
|
-
state.totalPlugins = 0;
|
|
706
|
-
state.completedPlugins = 0;
|
|
707
|
-
state.failedPlugins = 0;
|
|
708
|
-
state.totalFiles = 0;
|
|
709
|
-
state.processedFiles = 0;
|
|
710
|
-
state.hrStart = process.hrtime();
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Records a finished plugin against the progress counters.
|
|
714
|
-
*/
|
|
715
|
-
function recordPluginResult(state, success) {
|
|
716
|
-
if (success) state.completedPlugins++;
|
|
717
|
-
else state.failedPlugins++;
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Join a command and its optional args into a single display string.
|
|
721
|
-
*
|
|
722
|
-
* @example With args
|
|
723
|
-
* `formatCommandWithArgs('prettier', ['--write', '.'])` returns `'prettier --write .'`
|
|
724
|
-
*/
|
|
725
|
-
function formatCommandWithArgs(command, args) {
|
|
726
|
-
return args?.length ? `${command} ${args.join(" ")}` : command;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's
|
|
730
|
-
* {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.
|
|
731
|
-
*/
|
|
732
|
-
function installReporter(context, reporter, ctx) {
|
|
733
|
-
const pluginFiles = reporter.needsPluginFiles ? /* @__PURE__ */ new Map() : void 0;
|
|
734
|
-
if (pluginFiles) context.hook("kubb:plugin:end", ({ config, plugin, files }) => {
|
|
735
|
-
const filesByPlugin = pluginFiles.get(config) ?? /* @__PURE__ */ new Map();
|
|
736
|
-
const seen = new Set([...filesByPlugin.values()].flatMap((paths) => [...paths]));
|
|
737
|
-
const added = files.filter((file) => !seen.has(file.path)).map((file) => file.path);
|
|
738
|
-
if (added.length) filesByPlugin.set(plugin.name, /* @__PURE__ */ new Set([...filesByPlugin.get(plugin.name) ?? [], ...added]));
|
|
739
|
-
pluginFiles.set(config, filesByPlugin);
|
|
740
|
-
});
|
|
741
|
-
context.hook("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => {
|
|
742
|
-
const files = pluginFiles?.get(config);
|
|
743
|
-
const grouped = files && [...files].map(([plugin, paths]) => ({
|
|
744
|
-
plugin,
|
|
745
|
-
files: [...paths]
|
|
746
|
-
}));
|
|
747
|
-
await reporter.report({
|
|
748
|
-
config,
|
|
749
|
-
diagnostics,
|
|
750
|
-
filesCreated,
|
|
751
|
-
status,
|
|
752
|
-
hrStart,
|
|
753
|
-
pluginFiles: grouped
|
|
754
|
-
}, ctx);
|
|
755
|
-
pluginFiles?.delete(config);
|
|
756
|
-
});
|
|
757
|
-
if (reporter.drain) context.hook("kubb:lifecycle:end", () => reporter.drain?.(ctx));
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
|
|
761
|
-
* already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This
|
|
762
|
-
* only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the
|
|
763
|
-
* `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.
|
|
764
|
-
*
|
|
765
|
-
* Loggers and reporters are independent, except for `cli`: it both installs the live logger view
|
|
766
|
-
* here and registers a reporter that renders the per-config summary through that logger, so the
|
|
767
|
-
* summary lands inside the group the logger opened. The `json` reporter owns stdout, so the whole
|
|
768
|
-
* `cli` reporter (live logger and summary) is skipped whenever `json` is among the reporters, even
|
|
769
|
-
* if `cli` is also listed.
|
|
770
|
-
*/
|
|
771
|
-
async function setupReporters(context, { logLevel, reporters, logger: forcedLogger }) {
|
|
772
|
-
let cliHandle;
|
|
773
|
-
const hasJson = reporters.some((reporter) => reporter.name === "json");
|
|
774
|
-
const ctx = { logLevel };
|
|
775
|
-
for (const reporter of reporters) {
|
|
776
|
-
if (reporter.name !== "cli") {
|
|
777
|
-
installReporter(context, reporter, ctx);
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
780
|
-
if (hasJson) continue;
|
|
781
|
-
const handle = await (forcedLogger ?? (canUseTTY() && !getAgentName() ? clackLogger : plainLogger)).install(context, { logLevel }) ?? void 0;
|
|
782
|
-
cliHandle = handle;
|
|
783
|
-
installReporter(context, createCliReporter({ render: handle?.renderSummary }), ctx);
|
|
784
|
-
}
|
|
785
|
-
return cliHandle;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Picks the reporters whose `name` matches one of `names`, in the order the names are given.
|
|
789
|
-
* The config carries every available reporter, and the host selects which to activate by name
|
|
790
|
-
* (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are
|
|
791
|
-
* skipped.
|
|
792
|
-
*/
|
|
793
|
-
function selectReporters(reporters, names) {
|
|
794
|
-
const seen = /* @__PURE__ */ new Set();
|
|
795
|
-
const selected = [];
|
|
796
|
-
for (const name of names) {
|
|
797
|
-
if (seen.has(name)) continue;
|
|
798
|
-
seen.add(name);
|
|
799
|
-
const reporter = reporters.find((candidate) => candidate.name === name);
|
|
800
|
-
if (reporter) selected.push(reporter);
|
|
801
|
-
}
|
|
802
|
-
return selected;
|
|
803
|
-
}
|
|
804
|
-
//#endregion
|
|
805
805
|
//#region src/runners/generate/utils.ts
|
|
806
806
|
const loader = createModuleLoader();
|
|
807
807
|
const tsLoader = (configFile) => loader.load(configFile, { default: true });
|
|
@@ -876,7 +876,7 @@ async function getConfigs({ configPath, input, watch, logLevel }) {
|
|
|
876
876
|
*/
|
|
877
877
|
function isNewerVersion(current, latest) {
|
|
878
878
|
if (!isValid(current) || !isValid(latest)) return false;
|
|
879
|
-
return
|
|
879
|
+
return isGreaterThan(truncate(latest, "patch"), truncate(current, "patch"));
|
|
880
880
|
}
|
|
881
881
|
/**
|
|
882
882
|
* Runs the `output.postGenerate` commands of a Kubb config in sequence and returns each command's
|
|
@@ -1104,6 +1104,6 @@ function startUrlWatcher(url, cb, options = {}) {
|
|
|
1104
1104
|
return stop;
|
|
1105
1105
|
}
|
|
1106
1106
|
//#endregion
|
|
1107
|
-
export { runPostGenerate as a,
|
|
1107
|
+
export { linters as _, runPostGenerate as a, createPlainLogger as c, selectReporters as d, setupReporters as f, formatters as g, detectTool as h, runHook as i, plainLogger as l, LINTER_PREFERENCE as m, getConfigs as n, startUrlWatcher as o, FORMATTER_PREFERENCE as p, isNewerVersion as r, startWatcher as s, fetchUrlBody as t, pluralize as u };
|
|
1108
1108
|
|
|
1109
|
-
//# sourceMappingURL=utils-
|
|
1109
|
+
//# sourceMappingURL=utils-BYY3_cyq.js.map
|