@kubb/core 5.3.7 → 5.3.9

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/index.cjs CHANGED
@@ -127,7 +127,7 @@ function formatMs(ms) {
127
127
  /**
128
128
  * Docs major version, derived from the package version so the link tracks the published major.
129
129
  */
130
- const docsMajor = "5.3.7".split(".")[0] ?? "5";
130
+ const docsMajor = "5.3.9".split(".")[0] ?? "5";
131
131
  /**
132
132
  * Builds a type guard that narrows a {@link Diagnostic} to the variant for `kind`. A diagnostic
133
133
  * with no `kind` is treated as a `problem`.
@@ -2408,36 +2408,6 @@ function createReporter(reporter) {
2408
2408
  };
2409
2409
  }
2410
2410
  //#endregion
2411
- //#region src/reporters/colors.ts
2412
- /**
2413
- * ANSI color names used by {@link randomCliColor} for deterministic terminal coloring.
2414
- */
2415
- const randomColors = [
2416
- "black",
2417
- "red",
2418
- "green",
2419
- "yellow",
2420
- "blue",
2421
- "white",
2422
- "magenta",
2423
- "cyan",
2424
- "gray"
2425
- ];
2426
- /**
2427
- * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
2428
- *
2429
- * @example
2430
- * ```ts
2431
- * randomCliColor('petstore') // '\x1b[33m' + 'petstore' + '\x1b[39m' (always the same color for 'petstore')
2432
- * ```
2433
- */
2434
- function randomCliColor(text) {
2435
- if (!text) return "";
2436
- const index = (0, node_crypto.hash)("sha256", text, "buffer").readUInt32BE(0) % randomColors.length;
2437
- const color = randomColors[index] ?? "white";
2438
- return (0, node_util.styleText)(color, text);
2439
- }
2440
- //#endregion
2441
2411
  //#region src/reporters/report.ts
2442
2412
  /**
2443
2413
  * Builds the normalized {@link Report} for one config from its {@link GenerationResult}. Splits the
@@ -2471,12 +2441,43 @@ function buildReport(result) {
2471
2441
  };
2472
2442
  }
2473
2443
  //#endregion
2474
- //#region src/reporters/cliReporter.ts
2444
+ //#region src/reporters/colors.ts
2445
+ /**
2446
+ * ANSI color names used by {@link randomCliColor} for deterministic terminal coloring.
2447
+ */
2448
+ const randomColors = [
2449
+ "black",
2450
+ "red",
2451
+ "green",
2452
+ "yellow",
2453
+ "blue",
2454
+ "white",
2455
+ "magenta",
2456
+ "cyan",
2457
+ "gray"
2458
+ ];
2475
2459
  /**
2476
- * Builds the vitest/jest-style summary for one {@link Report}: right-aligned dim labels with
2477
- * `N passed (total)` counts, and a per-plugin `Timings` section when `showTimings`.
2460
+ * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
2461
+ *
2462
+ * @example
2463
+ * ```ts
2464
+ * randomCliColor('petstore') // '\x1b[33m' + 'petstore' + '\x1b[39m' (always the same color for 'petstore')
2465
+ * ```
2478
2466
  */
2479
- function buildSummaryLines(report, { showTimings }) {
2467
+ function randomCliColor(text) {
2468
+ if (!text) return "";
2469
+ const index = (0, node_crypto.hash)("sha256", text, "buffer").readUInt32BE(0) % randomColors.length;
2470
+ const color = randomColors[index] ?? "white";
2471
+ return (0, node_util.styleText)(color, text);
2472
+ }
2473
+ //#endregion
2474
+ //#region src/reporters/summary.ts
2475
+ /**
2476
+ * Formats the vitest/jest-style summary for one {@link Report}: right-aligned dim labels with
2477
+ * `N passed (total)` counts, and a per-plugin `Timings` section when `showTimings`. Pure, so a host
2478
+ * can render the same lines through whatever output it already owns.
2479
+ */
2480
+ function formatSummary(report, { showTimings }) {
2480
2481
  const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
2481
2482
  const rows = [];
2482
2483
  rows.push(["Plugins", status === "success" ? `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} (${plugins.total})` : `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} | ${(0, node_util.styleText)("red", `${plugins.failed.length} failed`)} (${plugins.total})`]);
@@ -2503,30 +2504,47 @@ function buildSummaryLines(report, { showTimings }) {
2503
2504
  }
2504
2505
  return lines;
2505
2506
  }
2507
+ //#endregion
2508
+ //#region src/reporters/cliReporter.ts
2506
2509
  /**
2507
2510
  * Renders the summary as plain `console.log` lines so it works in every CLI (no clack/TTY
2508
2511
  * dependency): a blank line, the config name colored by status, then the summary rows.
2509
2512
  */
2510
- function renderSummary(lines, { title, status }) {
2513
+ const consoleRenderer = (lines, { title, status }) => {
2511
2514
  console.log("");
2512
2515
  if (title) console.log((0, node_util.styleText)(status === "failed" ? "red" : "green", title));
2513
2516
  for (const line of lines) console.log(line);
2517
+ };
2518
+ /**
2519
+ * Builds a `cli` reporter that renders the {@link Report} for each config as it finishes.
2520
+ * Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
2521
+ *
2522
+ * Pass `render` to send the summary through output the host already owns, so it lands inside that
2523
+ * host's grouping instead of alongside it. Omit it for the plain `console.log` writer.
2524
+ *
2525
+ * @example
2526
+ * ```ts
2527
+ * const reporter = createCliReporter({ render: (lines) => lines.forEach((line) => clack.log.message(line)) })
2528
+ * ```
2529
+ */
2530
+ function createCliReporter({ render = consoleRenderer } = {}) {
2531
+ return createReporter({
2532
+ name: "cli",
2533
+ report(result, { logLevel: logLevel$1 }) {
2534
+ if (logLevel$1 <= logLevel.silent) return;
2535
+ const report = buildReport(result);
2536
+ render(formatSummary(report, { showTimings: logLevel$1 >= logLevel.verbose }), {
2537
+ title: report.name,
2538
+ status: report.status
2539
+ });
2540
+ }
2541
+ });
2514
2542
  }
2515
2543
  /**
2516
- * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
2517
- * of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
2544
+ * The default `cli` reporter, writing its summary straight to the console. Independent of the live
2545
+ * logger view.
2518
2546
  */
2519
- const cliReporter = createReporter({
2520
- name: "cli",
2521
- report(result, { logLevel: logLevel$1 }) {
2522
- if (logLevel$1 <= logLevel.silent) return;
2523
- const report = buildReport(result);
2524
- renderSummary(buildSummaryLines(report, { showTimings: logLevel$1 >= logLevel.verbose }), {
2525
- title: report.name,
2526
- status: report.status
2527
- });
2528
- }
2529
- });
2547
+ const cliReporter = createCliReporter();
2530
2548
  //#endregion
2531
2549
  //#region src/reporters/fileReporter.ts
2532
2550
  /**
@@ -2821,6 +2839,7 @@ exports.Resolver = Resolver;
2821
2839
  exports.applyConfigDefaults = applyConfigDefaults;
2822
2840
  exports.cliReporter = cliReporter;
2823
2841
  exports.createAdapter = createAdapter;
2842
+ exports.createCliReporter = createCliReporter;
2824
2843
  exports.createKubb = createKubb;
2825
2844
  exports.createRenderer = createRenderer;
2826
2845
  exports.createReporter = createReporter;