@kubb/core 3.4.5 → 3.5.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.
Files changed (55) hide show
  1. package/dist/{FileManager-CODtuwOW.d.cts → FileManager-BxDiClvd.d.cts} +5 -5
  2. package/dist/{FileManager-BXCK_2OY.d.ts → FileManager-VhW4B9yd.d.ts} +5 -5
  3. package/dist/{chunk-3CLNO5VR.js → chunk-E2WLQU27.js} +234 -26
  4. package/dist/chunk-E2WLQU27.js.map +1 -0
  5. package/dist/{chunk-LVELAYV4.cjs → chunk-NQBPIAF4.cjs} +4 -4
  6. package/dist/{chunk-LVELAYV4.cjs.map → chunk-NQBPIAF4.cjs.map} +1 -1
  7. package/dist/{chunk-GTR42WIS.js → chunk-O5ASNFB7.js} +4 -4
  8. package/dist/chunk-O5ASNFB7.js.map +1 -0
  9. package/dist/{chunk-HPTZVWK5.cjs → chunk-R4P3J4TG.cjs} +19 -19
  10. package/dist/chunk-R4P3J4TG.cjs.map +1 -0
  11. package/dist/{chunk-4SHSEMU2.cjs → chunk-VMPADUCV.cjs} +35 -35
  12. package/dist/{chunk-4SHSEMU2.cjs.map → chunk-VMPADUCV.cjs.map} +1 -1
  13. package/dist/{chunk-S3IJRQEO.cjs → chunk-WSUPUMYM.cjs} +255 -39
  14. package/dist/chunk-WSUPUMYM.cjs.map +1 -0
  15. package/dist/{chunk-SX3K2Q5X.js → chunk-YYMV5PIX.js} +3 -3
  16. package/dist/{chunk-SX3K2Q5X.js.map → chunk-YYMV5PIX.js.map} +1 -1
  17. package/dist/index.cjs +74 -58
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +5 -5
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.js +42 -26
  22. package/dist/index.js.map +1 -1
  23. package/dist/logger.cjs +6 -7
  24. package/dist/logger.js +1 -2
  25. package/dist/mocks.cjs +11 -11
  26. package/dist/mocks.cjs.map +1 -1
  27. package/dist/mocks.d.cts +1 -1
  28. package/dist/mocks.d.ts +1 -1
  29. package/dist/mocks.js +4 -4
  30. package/dist/mocks.js.map +1 -1
  31. package/dist/prompt-JRPIEHU3.cjs +762 -0
  32. package/dist/prompt-JRPIEHU3.cjs.map +1 -0
  33. package/dist/prompt-RQXXVSD5.js +751 -0
  34. package/dist/prompt-RQXXVSD5.js.map +1 -0
  35. package/dist/transformers.cjs +22 -22
  36. package/dist/transformers.js +1 -1
  37. package/dist/utils.cjs +17 -17
  38. package/dist/utils.js +2 -2
  39. package/package.json +8 -8
  40. package/src/build.ts +42 -24
  41. package/src/config.ts +1 -1
  42. package/src/transformers/casing.ts +2 -2
  43. package/src/types.ts +4 -4
  44. package/dist/chunk-3CLNO5VR.js.map +0 -1
  45. package/dist/chunk-GTR42WIS.js.map +0 -1
  46. package/dist/chunk-HPTZVWK5.cjs.map +0 -1
  47. package/dist/chunk-OL5US75J.js +0 -208
  48. package/dist/chunk-OL5US75J.js.map +0 -1
  49. package/dist/chunk-OQSYTQLS.cjs +0 -236
  50. package/dist/chunk-OQSYTQLS.cjs.map +0 -1
  51. package/dist/chunk-S3IJRQEO.cjs.map +0 -1
  52. package/dist/prompt-CV2GMUO3.cjs +0 -860
  53. package/dist/prompt-CV2GMUO3.cjs.map +0 -1
  54. package/dist/prompt-Y6ROOH2L.js +0 -848
  55. package/dist/prompt-Y6ROOH2L.js.map +0 -1
@@ -123,7 +123,7 @@ declare class PluginManager {
123
123
  * ...
124
124
  * })
125
125
  */
126
- type UserConfig = Omit<Config, 'root' | 'plugins'> & {
126
+ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
127
127
  /**
128
128
  * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
129
129
  * @default process.cwd()
@@ -366,7 +366,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
366
366
  /**
367
367
  * Specify the export location for the files and define the behavior of the output
368
368
  */
369
- type Output = {
369
+ type Output<TOptions> = {
370
370
  /**
371
371
  * Path to the output folder or file that will contain the generated code
372
372
  */
@@ -379,11 +379,11 @@ type Output = {
379
379
  /**
380
380
  * Add a banner text in the beginning of every file
381
381
  */
382
- banner?: string;
382
+ banner?: string | ((options: TOptions) => string);
383
383
  /**
384
384
  * Add a footer text in the beginning of every file
385
385
  */
386
- footer?: string;
386
+ footer?: string | ((options: TOptions) => string);
387
387
  };
388
388
  type GroupContext = {
389
389
  group: string;
@@ -486,4 +486,4 @@ type WriteFilesProps = {
486
486
  };
487
487
  declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<KubbFile.ResolvedFile[]>;
488
488
 
489
- export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type Group as o, processFiles as p };
489
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PluginFactoryOptions as a, type UserPluginWithLifeCycle as b, type FileMetaBase as c, type InputData as d, type PluginKey as e, type UserPlugin as f, getSource as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type ResolveNameParams as m, type PluginContext as n, type Group as o, processFiles as p };
@@ -123,7 +123,7 @@ declare class PluginManager {
123
123
  * ...
124
124
  * })
125
125
  */
126
- type UserConfig = Omit<Config, 'root' | 'plugins'> & {
126
+ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
127
127
  /**
128
128
  * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
129
129
  * @default process.cwd()
@@ -366,7 +366,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
366
366
  /**
367
367
  * Specify the export location for the files and define the behavior of the output
368
368
  */
369
- type Output = {
369
+ type Output<TOptions> = {
370
370
  /**
371
371
  * Path to the output folder or file that will contain the generated code
372
372
  */
@@ -379,11 +379,11 @@ type Output = {
379
379
  /**
380
380
  * Add a banner text in the beginning of every file
381
381
  */
382
- banner?: string;
382
+ banner?: string | ((options: TOptions) => string);
383
383
  /**
384
384
  * Add a footer text in the beginning of every file
385
385
  */
386
- footer?: string;
386
+ footer?: string | ((options: TOptions) => string);
387
387
  };
388
388
  type GroupContext = {
389
389
  group: string;
@@ -486,4 +486,4 @@ type WriteFilesProps = {
486
486
  };
487
487
  declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<KubbFile.ResolvedFile[]>;
488
488
 
489
- export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type Group as o, processFiles as p };
489
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PluginFactoryOptions as a, type UserPluginWithLifeCycle as b, type FileMetaBase as c, type InputData as d, type PluginKey as e, type UserPlugin as f, getSource as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type ResolveNameParams as m, type PluginContext as n, type Group as o, processFiles as p };
@@ -1,9 +1,113 @@
1
+ import seedrandom from 'seedrandom';
2
+ import { isatty } from 'tty';
3
+ import { EventEmitter as EventEmitter$1 } from 'node:events';
4
+ import { resolve, sep } from 'node:path';
5
+ import { write } from '@kubb/fs';
1
6
  import { formatWithOptions } from 'node:util';
2
- import { sep } from 'node:path';
7
+ import p$1 from 'node:process';
3
8
  import * as tty from 'node:tty';
4
- import process$1 from 'node:process';
5
9
 
6
- // ../../node_modules/.pnpm/consola@3.3.3/node_modules/consola/dist/core.mjs
10
+ // src/logger.ts
11
+
12
+ // ../../node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js
13
+ var f = {
14
+ reset: [0, 0],
15
+ bold: [1, 22, "\x1B[22m\x1B[1m"],
16
+ dim: [2, 22, "\x1B[22m\x1B[2m"],
17
+ italic: [3, 23],
18
+ underline: [4, 24],
19
+ inverse: [7, 27],
20
+ hidden: [8, 28],
21
+ strikethrough: [9, 29],
22
+ black: [30, 39],
23
+ red: [31, 39],
24
+ green: [32, 39],
25
+ yellow: [33, 39],
26
+ blue: [34, 39],
27
+ magenta: [35, 39],
28
+ cyan: [36, 39],
29
+ white: [37, 39],
30
+ gray: [90, 39],
31
+ bgBlack: [40, 49],
32
+ bgRed: [41, 49],
33
+ bgGreen: [42, 49],
34
+ bgYellow: [43, 49],
35
+ bgBlue: [44, 49],
36
+ bgMagenta: [45, 49],
37
+ bgCyan: [46, 49],
38
+ bgWhite: [47, 49],
39
+ blackBright: [90, 39],
40
+ redBright: [91, 39],
41
+ greenBright: [92, 39],
42
+ yellowBright: [93, 39],
43
+ blueBright: [94, 39],
44
+ magentaBright: [95, 39],
45
+ cyanBright: [96, 39],
46
+ whiteBright: [97, 39],
47
+ bgBlackBright: [100, 49],
48
+ bgRedBright: [101, 49],
49
+ bgGreenBright: [102, 49],
50
+ bgYellowBright: [103, 49],
51
+ bgBlueBright: [104, 49],
52
+ bgMagentaBright: [105, 49],
53
+ bgCyanBright: [106, 49],
54
+ bgWhiteBright: [107, 49]
55
+ };
56
+ var h = Object.entries(f);
57
+ function a(n2) {
58
+ return String(n2);
59
+ }
60
+ a.open = "";
61
+ a.close = "";
62
+ function C(n2 = false) {
63
+ let e = typeof process != "undefined" ? process : void 0, i2 = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
64
+ return !("NO_COLOR" in i2 || g.includes("--no-color")) && ("FORCE_COLOR" in i2 || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n2 && i2.TERM !== "dumb" || "CI" in i2) || typeof window != "undefined" && !!window.chrome;
65
+ }
66
+ function p(n2 = false) {
67
+ let e = C(n2), i2 = (r3, t2, c2, o) => {
68
+ let l2 = "", s2 = 0;
69
+ do
70
+ l2 += r3.substring(s2, o) + c2, s2 = o + t2.length, o = r3.indexOf(t2, s2);
71
+ while (~o);
72
+ return l2 + r3.substring(s2);
73
+ }, g = (r3, t2, c2 = r3) => {
74
+ let o = (l2) => {
75
+ let s2 = String(l2), b = s2.indexOf(t2, r3.length);
76
+ return ~b ? r3 + i2(s2, t2, c2, b) + t2 : r3 + s2 + t2;
77
+ };
78
+ return o.open = r3, o.close = t2, o;
79
+ }, u2 = {
80
+ isColorSupported: e
81
+ }, d = (r3) => `\x1B[${r3}m`;
82
+ for (let [r3, t2] of h)
83
+ u2[r3] = e ? g(
84
+ d(t2[0]),
85
+ d(t2[1]),
86
+ t2[2]
87
+ ) : a;
88
+ return u2;
89
+ }
90
+ var p2 = p(isatty(1));
91
+ var EventEmitter = class {
92
+ constructor() {
93
+ this.#emitter.setMaxListeners(100);
94
+ }
95
+ #emitter = new EventEmitter$1();
96
+ emit(eventName, ...eventArg) {
97
+ this.#emitter.emit(eventName, ...eventArg);
98
+ }
99
+ on(eventName, handler) {
100
+ this.#emitter.on(eventName, handler);
101
+ }
102
+ off(eventName, handler) {
103
+ this.#emitter.off(eventName, handler);
104
+ }
105
+ removeAll() {
106
+ this.#emitter.removeAllListeners();
107
+ }
108
+ };
109
+
110
+ // ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/core.mjs
7
111
  var LogLevels = {
8
112
  silent: Number.NEGATIVE_INFINITY,
9
113
  fatal: 0,
@@ -117,7 +221,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
117
221
  function createDefu(merger) {
118
222
  return (...arguments_) => (
119
223
  // eslint-disable-next-line unicorn/no-array-reduce
120
- arguments_.reduce((p2, c2) => _defu(p2, c2, ""), {})
224
+ arguments_.reduce((p4, c2) => _defu(p4, c2, ""), {})
121
225
  );
122
226
  }
123
227
  var defu = createDefu();
@@ -511,8 +615,8 @@ function parseStack(stack) {
511
615
  return lines;
512
616
  }
513
617
  function writeStream(data, stream) {
514
- const write = stream.__write || stream.write;
515
- return write.call(stream, data);
618
+ const write2 = stream.__write || stream.write;
619
+ return write2.call(stream, data);
516
620
  }
517
621
  var bracket = (x) => x ? `[${x}]` : "";
518
622
  var BasicReporter = class {
@@ -755,7 +859,7 @@ function box(text, _opts = {}) {
755
859
  }
756
860
  const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
757
861
  const height = textLines.length + paddingOffset;
758
- const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
862
+ const width = Math.max(...textLines.map((line) => stripAnsi(line).length)) + paddingOffset;
759
863
  const widthOffset = width + paddingOffset;
760
864
  const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
761
865
  if (opts.style.marginTop > 0) {
@@ -800,13 +904,15 @@ function box(text, _opts = {}) {
800
904
  }
801
905
  return boxLines.join("\n");
802
906
  }
803
- var r = /* @__PURE__ */ Object.create(null);
804
- var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
805
- var s$1 = new Proxy(r, { get(e, o) {
806
- return i()[o] ?? r[o];
907
+
908
+ // ../../node_modules/.pnpm/consola@3.4.0/node_modules/consola/dist/index.mjs
909
+ var r2 = /* @__PURE__ */ Object.create(null);
910
+ var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r2 : globalThis);
911
+ var s$1 = new Proxy(r2, { get(e, o) {
912
+ return i()[o] ?? r2[o];
807
913
  }, has(e, o) {
808
914
  const E = i();
809
- return o in E || o in r;
915
+ return o in E || o in r2;
810
916
  }, set(e, o, E) {
811
917
  const b = i(true);
812
918
  return b[o] = E, true;
@@ -820,14 +926,14 @@ var s$1 = new Proxy(r, { get(e, o) {
820
926
  } });
821
927
  var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
822
928
  var B = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
823
- function p() {
929
+ function p3() {
824
930
  if (globalThis.process?.env) for (const e of B) {
825
931
  const o = e[1] || e[0];
826
932
  if (globalThis.process?.env[o]) return { name: e[0].toLowerCase(), ...e[2] };
827
933
  }
828
934
  return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
829
935
  }
830
- var l = p();
936
+ var l = p3();
831
937
  l.name;
832
938
  function n(e) {
833
939
  return e ? e !== "false" : false;
@@ -840,8 +946,8 @@ var A = t === "test" || n(s$1.TEST);
840
946
  n(s$1.MINIMAL) || T || A || !R;
841
947
  var _ = /^win/i.test(I);
842
948
  !n(s$1.NO_COLOR) && (n(s$1.FORCE_COLOR) || (R || _) && s$1.TERM !== "dumb" || T);
843
- var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
844
- Number(C?.split(".")[0]) || null;
949
+ var C2 = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
950
+ Number(C2?.split(".")[0]) || null;
845
951
  var y = globalThis.process || /* @__PURE__ */ Object.create(null);
846
952
  var c = { versions: {} };
847
953
  new Proxy(y, { get(e, o) {
@@ -850,13 +956,13 @@ new Proxy(y, { get(e, o) {
850
956
  if (o in c) return c[o];
851
957
  } });
852
958
  var L = globalThis.process?.release?.name === "node";
853
- var a = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
959
+ var a2 = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
854
960
  var D = !!globalThis.Deno;
855
961
  var O = !!globalThis.fastly;
856
962
  var S = !!globalThis.Netlify;
857
963
  var N = !!globalThis.EdgeRuntime;
858
964
  var P = globalThis.navigator?.userAgent === "Cloudflare-Workers";
859
- var F = [[S, "netlify"], [N, "edge-light"], [P, "workerd"], [O, "fastly"], [D, "deno"], [a, "bun"], [L, "node"]];
965
+ var F = [[S, "netlify"], [N, "edge-light"], [P, "workerd"], [O, "fastly"], [D, "deno"], [a2, "bun"], [L, "node"]];
860
966
  function G() {
861
967
  const e = F.find((o) => o[0]);
862
968
  if (e) return { name: e[1] };
@@ -949,9 +1055,9 @@ function stringWidth$1(string, options = {}) {
949
1055
  return width;
950
1056
  }
951
1057
  function isUnicodeSupported() {
952
- const { env: env2 } = process$1;
1058
+ const { env: env2 } = p$1;
953
1059
  const { TERM, TERM_PROGRAM } = env2;
954
- if (process$1.platform !== "win32") {
1060
+ if (p$1.platform !== "win32") {
955
1061
  return TERM !== "linux";
956
1062
  }
957
1063
  return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
@@ -994,7 +1100,7 @@ var FancyReporter = class extends BasicReporter {
994
1100
  const indent = " ".repeat((opts?.errorLevel || 0) + 1);
995
1101
  return `
996
1102
  ${indent}` + parseStack(stack).map(
997
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_2, m) => `(${colors.cyan(m)})`)
1103
+ (line) => " " + line.replace(/^at +/, (m2) => colors.gray(m2)).replace(/\((.+)\)/, (_2, m2) => `(${colors.cyan(m2)})`)
998
1104
  ).join(`
999
1105
  ${indent}`);
1000
1106
  }
@@ -1044,7 +1150,7 @@ ${indent}`);
1044
1150
  }
1045
1151
  };
1046
1152
  function characterFormat(str) {
1047
- return str.replace(/`([^`]+)`/gm, (_2, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_2, m) => ` ${colors.underline(m)} `);
1153
+ return str.replace(/`([^`]+)`/gm, (_2, m2) => colors.cyan(m2)).replace(/\s+_([^_]+)_\s+/gm, (_2, m2) => ` ${colors.underline(m2)} `);
1048
1154
  }
1049
1155
  function getColor2(color = "white") {
1050
1156
  return colors[color] || colors.white;
@@ -1062,7 +1168,7 @@ function createConsola2(options = {}) {
1062
1168
  defaults: { level },
1063
1169
  stdout: process.stdout,
1064
1170
  stderr: process.stderr,
1065
- prompt: (...args) => import('./prompt-Y6ROOH2L.js').then((m) => m.prompt(...args)),
1171
+ prompt: (...args) => import('./prompt-RQXXVSD5.js').then((m2) => m2.prompt(...args)),
1066
1172
  reporters: options.reporters || [
1067
1173
  options.fancy ?? !(T || A) ? new FancyReporter() : new BasicReporter()
1068
1174
  ],
@@ -1081,6 +1187,108 @@ function _getDefaultLogLevel() {
1081
1187
  }
1082
1188
  createConsola2();
1083
1189
 
1084
- export { colors, createConsola2 as createConsola, isUnicodeSupported };
1085
- //# sourceMappingURL=chunk-3CLNO5VR.js.map
1086
- //# sourceMappingURL=chunk-3CLNO5VR.js.map
1190
+ // src/logger.ts
1191
+ var LogMapper = {
1192
+ silent: Number.NEGATIVE_INFINITY,
1193
+ info: 3,
1194
+ debug: 4
1195
+ };
1196
+ function createLogger({ logLevel = 3, name, consola: _consola } = {}) {
1197
+ const events = new EventEmitter();
1198
+ const startDate = Date.now();
1199
+ const cachedLogs = /* @__PURE__ */ new Set();
1200
+ const consola2 = _consola || createConsola2({
1201
+ level: logLevel,
1202
+ formatOptions: {
1203
+ colors: true,
1204
+ date: true,
1205
+ columns: 80,
1206
+ compact: logLevel !== LogMapper.debug
1207
+ }
1208
+ }).withTag(name ? randomCliColour(name) : "");
1209
+ consola2?.wrapConsole();
1210
+ events.on("start", (message) => {
1211
+ consola2.start(message);
1212
+ });
1213
+ events.on("success", (message) => {
1214
+ consola2.success(message);
1215
+ });
1216
+ events.on("warning", (message) => {
1217
+ consola2.warn(p2.yellow(message));
1218
+ });
1219
+ events.on("info", (message) => {
1220
+ consola2.info(p2.yellow(message));
1221
+ });
1222
+ events.on("debug", (message) => {
1223
+ if (message.logs.join("\n\n").length <= 100 && logLevel === LogMapper.debug) {
1224
+ console.log(message.logs.join("\n\n"));
1225
+ }
1226
+ cachedLogs.add(message);
1227
+ });
1228
+ events.on("error", (message, cause) => {
1229
+ const error = new Error(message || "Something went wrong");
1230
+ error.cause = cause;
1231
+ throw error;
1232
+ });
1233
+ if (consola2) {
1234
+ consola2.level = logLevel;
1235
+ }
1236
+ const logger = {
1237
+ name,
1238
+ logLevel,
1239
+ consola: consola2,
1240
+ on(...args) {
1241
+ return events.on(...args);
1242
+ },
1243
+ emit(...args) {
1244
+ return events.emit(...args);
1245
+ },
1246
+ async writeLogs() {
1247
+ const files = {};
1248
+ cachedLogs.forEach((log) => {
1249
+ const fileName = resolve(process.cwd(), ".kubb", log.fileName || `kubb-${startDate}.log`);
1250
+ if (!files[fileName]) {
1251
+ files[fileName] = [];
1252
+ }
1253
+ files[fileName] = [...files[fileName], `[${log.date.toLocaleString()}]: ${log.logs.join("\n\n")}`];
1254
+ });
1255
+ await Promise.all(
1256
+ Object.entries(files).map(async ([fileName, logs]) => {
1257
+ return write(fileName, logs.join("\n"));
1258
+ })
1259
+ );
1260
+ return Object.keys(files);
1261
+ }
1262
+ };
1263
+ return logger;
1264
+ }
1265
+ var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
1266
+ function randomColour(text, colours = defaultColours) {
1267
+ if (!text) {
1268
+ return "white";
1269
+ }
1270
+ const random = seedrandom(text);
1271
+ const colour = colours.at(Math.floor(random() * colours.length)) || "white";
1272
+ return colour;
1273
+ }
1274
+ function randomCliColour(text, colors2 = defaultColours) {
1275
+ const colours = p(true);
1276
+ if (!text) {
1277
+ return colours.white(text);
1278
+ }
1279
+ const colour = randomColour(text, colors2);
1280
+ const isDark = colour.includes("dark");
1281
+ const key = colour.replace("dark", "").toLowerCase();
1282
+ const formatter = colours[key];
1283
+ if (isDark) {
1284
+ return p2.bold(formatter(text));
1285
+ }
1286
+ if (typeof formatter !== "function") {
1287
+ throw new Error("Formatter for picoColor is not of type function/Formatter");
1288
+ }
1289
+ return formatter(text);
1290
+ }
1291
+
1292
+ export { EventEmitter, LogMapper, createLogger, randomCliColour, randomColour };
1293
+ //# sourceMappingURL=chunk-E2WLQU27.js.map
1294
+ //# sourceMappingURL=chunk-E2WLQU27.js.map