@kubb/cli 1.15.0-canary.20231020T203110 → 1.15.0-canary.20231022T192419

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/README.md CHANGED
@@ -1,23 +1,23 @@
1
1
  <div align="center">
2
2
 
3
- <!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
4
- <h1>@kubb/cli</h1>
5
-
6
- <p>
3
+ <!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
4
+ <h1>@kubb/cli</h1>
5
+
6
+ <p>
7
7
  CLI package to generate the different clients when using the terminal.
8
- </p>
8
+ </p>
9
9
  <img src="https://raw.githubusercontent.com/kubb-project/kubb/main/assets/banner.png" alt="logo" height="auto" />
10
10
 
11
- [![npm version][npm-version-src]][npm-version-href]
12
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
13
- [![Coverage][coverage-src]][coverage-href]
14
- [![License][license-src]][license-href]
15
-
16
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
- </p>
19
-
20
- <h4>
11
+ [![npm version][npm-version-src]][npm-version-href]
12
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
13
+ [![Coverage][coverage-src]][coverage-href]
14
+ [![License][license-src]][license-href]
15
+
16
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
+ </p>
19
+
20
+ <h4>
21
21
  <a href="https://codesandbox.io/s/github/kubb-project/kubb/tree/main/examples/typescript" target="_blank">View Demo</a>
22
22
  <span> · </span>
23
23
  <a href="https://kubb.dev/" target="_blank">Documentation</a>
@@ -28,7 +28,6 @@
28
28
  </h4>
29
29
  </div>
30
30
 
31
-
32
31
  <!-- Badges -->
33
32
 
34
33
  [npm-version-src]: https://img.shields.io/npm/v/@kubb/cli?flat&colorA=18181B&colorB=f58517
@@ -42,4 +41,4 @@
42
41
  [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/cli?style=flat&colorA=18181B&colorB=f58517
43
42
  [minified-href]: https://www.npmjs.com/package/@kubb/cli
44
43
  [coverage-src]: https://img.shields.io/codecov/c/github/kubb-project/kubb?style=flat&colorA=18181B&colorB=f58517
45
- [coverage-href]: https://www.npmjs.com/package/@kubb/cli
44
+ [coverage-href]: https://www.npmjs.com/package/@kubb/cli
package/dist/index.cjs CHANGED
@@ -3,22 +3,22 @@
3
3
  var pathParser = require('path');
4
4
  var core = require('@kubb/core');
5
5
  var cac = require('cac');
6
- var pc = require('picocolors');
7
- var execa = require('execa');
8
- var stringArgv = require('string-argv');
9
- var stream = require('stream');
10
- var ora = require('ora');
6
+ var pc3 = require('picocolors');
11
7
  var cosmiconfig = require('cosmiconfig');
12
8
  var tsNode = require('ts-node');
9
+ var stream = require('stream');
13
10
  var PrettyError = require('pretty-error');
11
+ var ora = require('ora');
12
+ var execa = require('execa');
13
+ var stringArgv = require('string-argv');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
16
 
17
17
  var pathParser__default = /*#__PURE__*/_interopDefault(pathParser);
18
- var pc__default = /*#__PURE__*/_interopDefault(pc);
19
- var ora__default = /*#__PURE__*/_interopDefault(ora);
18
+ var pc3__default = /*#__PURE__*/_interopDefault(pc3);
20
19
  var tsNode__default = /*#__PURE__*/_interopDefault(tsNode);
21
20
  var PrettyError__default = /*#__PURE__*/_interopDefault(PrettyError);
21
+ var ora__default = /*#__PURE__*/_interopDefault(ora);
22
22
 
23
23
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
24
24
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -29,15 +29,189 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
29
29
  });
30
30
 
31
31
  // package.json
32
- var version = "1.14.0";
32
+ var version = "1.14.1";
33
+ function isJSONPlugins(plugins) {
34
+ return !!plugins?.some((plugin) => {
35
+ return typeof plugin?.[0] === "string";
36
+ });
37
+ }
38
+ function isObjectPlugins(plugins) {
39
+ return plugins instanceof Object && !Array.isArray(plugins);
40
+ }
41
+ async function importPlugin(name, options) {
42
+ const packageManager = new core.PackageManager(process.cwd());
43
+ const importedPlugin = process.env.NODE_ENV === "test" ? await import(name) : await packageManager.import(name, process.cwd());
44
+ return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options);
45
+ }
46
+ function getPlugins(plugins) {
47
+ if (isObjectPlugins(plugins)) {
48
+ const promises = Object.keys(plugins).map((name) => {
49
+ return importPlugin(name, plugins[name]);
50
+ });
51
+ return Promise.all(promises);
52
+ }
53
+ if (isJSONPlugins(plugins)) {
54
+ const promises = plugins.map((plugin) => {
55
+ const [name, options = {}] = plugin;
56
+ return importPlugin(name, options);
57
+ });
58
+ return Promise.all(promises);
59
+ }
60
+ return Promise.resolve(plugins);
61
+ }
62
+
63
+ // src/utils/getConfig.ts
64
+ async function getConfig(result, CLIOptions) {
65
+ const config = result?.config;
66
+ let kubbUserConfig = Promise.resolve(config);
67
+ if (typeof config === "function") {
68
+ const possiblePromise = config(CLIOptions);
69
+ if (core.isPromise(possiblePromise)) {
70
+ kubbUserConfig = possiblePromise;
71
+ }
72
+ kubbUserConfig = Promise.resolve(possiblePromise);
73
+ }
74
+ let JSONConfig = await kubbUserConfig;
75
+ JSONConfig = {
76
+ ...JSONConfig,
77
+ plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : void 0
78
+ };
79
+ return JSONConfig;
80
+ }
81
+ var tsLoader = (configFile) => {
82
+ let registerer = { enabled() {
83
+ } };
84
+ try {
85
+ registerer = tsNode__default.default.register({
86
+ compilerOptions: { module: "commonjs" },
87
+ typeCheck: false
88
+ });
89
+ const module = __require(configFile);
90
+ return module.default;
91
+ } catch (err) {
92
+ const error = err;
93
+ if (error.name === "MODULE_NOT_FOUND") {
94
+ throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed
95
+ Error: ${error.message}`);
96
+ }
97
+ throw error;
98
+ } finally {
99
+ registerer.enabled();
100
+ }
101
+ };
102
+ async function getCosmiConfig(moduleName2, config) {
103
+ const searchPlaces = [
104
+ "package.json",
105
+ `.${moduleName2}rc`,
106
+ `.${moduleName2}rc.json`,
107
+ `.${moduleName2}rc.yaml`,
108
+ `.${moduleName2}rc.yml`,
109
+ `.${moduleName2}rc.ts`,
110
+ `.${moduleName2}rc.js`,
111
+ `.${moduleName2}rc.cjs`,
112
+ `.${moduleName2}rc.mjs`,
113
+ `${moduleName2}.config.ts`,
114
+ `${moduleName2}.config.js`,
115
+ `${moduleName2}.config.cjs`,
116
+ `${moduleName2}.config.mjs`
117
+ ];
118
+ const explorer = cosmiconfig.cosmiconfig(moduleName2, {
119
+ cache: false,
120
+ searchPlaces: [
121
+ ...searchPlaces.map((searchPlace) => {
122
+ return `.config/${searchPlace}`;
123
+ }),
124
+ ...searchPlaces.map((searchPlace) => {
125
+ return `configs/${searchPlace}`;
126
+ }),
127
+ ...searchPlaces
128
+ ],
129
+ loaders: {
130
+ ".ts": tsLoader
131
+ }
132
+ });
133
+ const result = config ? await explorer.load(config) : await explorer.search();
134
+ if (result?.isEmpty || !result || !result.config) {
135
+ throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
136
+ }
137
+ return result;
138
+ }
139
+ var OraWritable = class extends stream.Writable {
140
+ command;
141
+ spinner;
142
+ constructor(spinner2, command, opts) {
143
+ super(opts);
144
+ this.command = command;
145
+ this.spinner = spinner2;
146
+ }
147
+ _write(chunk, _encoding, callback2) {
148
+ this.spinner.suffixText = `
149
+
150
+ ${pc3__default.default.bold(pc3__default.default.blue(this.command))}: ${chunk?.toString()}`;
151
+ callback2();
152
+ }
153
+ };
33
154
 
34
155
  // src/utils/parseHrtimeToSeconds.ts
35
156
  function parseHrtimeToSeconds(hrtime) {
36
157
  const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
37
158
  return seconds;
38
159
  }
39
-
40
- // src/utils/getSummary.ts
160
+ var prettyError = new PrettyError__default.default().skipPackage("commander").skip(function callback(traceLine) {
161
+ const pattern = new RegExp("renderErrors");
162
+ const hasMatch = traceLine?.file?.match(pattern);
163
+ if (typeof traceLine.packageName !== "undefined" && hasMatch) {
164
+ return true;
165
+ }
166
+ }).start();
167
+ function getErrorCauses(errors) {
168
+ return errors.reduce((prev, error) => {
169
+ const causedError = error?.cause;
170
+ if (causedError) {
171
+ prev = [...prev, ...getErrorCauses([causedError])];
172
+ }
173
+ prev = [...prev, prettyError.render(error)];
174
+ return prev;
175
+ }, []).filter(Boolean);
176
+ }
177
+ function renderErrors(error, { prefixText, logLevel = core.LogLevel.silent }) {
178
+ if (!error) {
179
+ return "";
180
+ }
181
+ if (error instanceof core.ParallelPluginError) {
182
+ return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join("\n");
183
+ }
184
+ if (logLevel === core.LogLevel.silent) {
185
+ prettyError.skipNodeFiles();
186
+ prettyError.skip(function skip() {
187
+ return true;
188
+ });
189
+ return [prefixText, prettyError.render(error)].filter(Boolean).join("\n");
190
+ }
191
+ const errors = getErrorCauses([error]);
192
+ return [prefixText, ...errors].filter(Boolean).join("\n");
193
+ }
194
+ var spinner = ora__default.default({
195
+ spinner: "clock"
196
+ });
197
+ async function startWatcher(path, cb) {
198
+ const { watch } = await import('chokidar');
199
+ const ignored = ["**/{.git,node_modules}/**"];
200
+ const watcher = watch(path, {
201
+ ignorePermissionErrors: true,
202
+ ignored
203
+ });
204
+ watcher.on("all", (type, file) => {
205
+ spinner.succeed(pc3__default.default.yellow(pc3__default.default.bold(`Change detected: ${type} ${file}`)));
206
+ spinner.spinner = "clock";
207
+ try {
208
+ cb(path);
209
+ } catch (e) {
210
+ spinner.warn(pc3__default.default.red("Watcher failed"));
211
+ }
212
+ });
213
+ return;
214
+ }
41
215
  function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
42
216
  const logs = [];
43
217
  const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
@@ -59,25 +233,25 @@ function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
59
233
  return 0;
60
234
  });
61
235
  const meta = {
62
- plugins: status === "success" ? `${pc__default.default.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc__default.default.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,
236
+ plugins: status === "success" ? `${pc3__default.default.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3__default.default.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,
63
237
  pluginsFailed: status === "failed" ? failedPlugins?.map((name) => core.randomPicoColour(name))?.join(", ") : void 0,
64
238
  filesCreated: files.length,
65
- time: pc__default.default.yellow(`${elapsedSeconds}s`),
239
+ time: pc3__default.default.yellow(`${elapsedSeconds}s`),
66
240
  output: pathParser__default.default.resolve(config.root, config.output.path)
67
241
  };
68
242
  if (logLevel === core.LogLevel.debug) {
69
- logs.push(pc__default.default.bold("\nGenerated files:\n"));
243
+ logs.push(pc3__default.default.bold("\nGenerated files:\n"));
70
244
  logs.push(files.map((file) => `${core.randomPicoColour(file.meta?.pluginName)} ${file.path}`).join("\n"));
71
245
  }
72
246
  logs.push(
73
247
  [
74
248
  [`
75
249
  `, true],
76
- [` ${pc__default.default.bold("Plugins:")} ${meta.plugins}`, true],
77
- [` ${pc__default.default.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
78
- [`${pc__default.default.bold("Generated:")} ${meta.filesCreated} files`, true],
79
- [` ${pc__default.default.bold("Time:")} ${meta.time}`, true],
80
- [` ${pc__default.default.bold("Output:")} ${meta.output}`, true],
250
+ [` ${pc3__default.default.bold("Plugins:")} ${meta.plugins}`, true],
251
+ [` ${pc3__default.default.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
252
+ [`${pc3__default.default.bold("Generated:")} ${meta.filesCreated} files`, true],
253
+ [` ${pc3__default.default.bold("Time:")} ${meta.time}`, true],
254
+ [` ${pc3__default.default.bold("Output:")} ${meta.output}`, true],
81
255
  [`
82
256
  `, true]
83
257
  ].map((item) => {
@@ -89,24 +263,6 @@ function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
89
263
  );
90
264
  return logs;
91
265
  }
92
- var OraWritable = class extends stream.Writable {
93
- command;
94
- spinner;
95
- constructor(spinner2, command, opts) {
96
- super(opts);
97
- this.command = command;
98
- this.spinner = spinner2;
99
- }
100
- _write(chunk, _encoding, callback) {
101
- this.spinner.suffixText = `
102
-
103
- ${pc__default.default.bold(pc__default.default.blue(this.command))}: ${chunk?.toString()}`;
104
- callback();
105
- }
106
- };
107
- var spinner = ora__default.default({
108
- spinner: "clock"
109
- });
110
266
 
111
267
  // src/generate.ts
112
268
  async function executeHooks({ hooks, logLevel }) {
@@ -125,11 +281,11 @@ async function executeHooks({ hooks, logLevel }) {
125
281
  return null;
126
282
  }
127
283
  await core.timeout(100);
128
- spinner.start(`Executing hook ${logLevel !== "silent" ? pc__default.default.dim(command) : ""}`);
284
+ spinner.start(`Executing hook ${logLevel !== "silent" ? pc3__default.default.dim(command) : ""}`);
129
285
  const subProcess = await execa.execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
130
286
  spinner.suffixText = "";
131
287
  if (logLevel === core.LogLevel.silent) {
132
- spinner.succeed(`Executing hook ${logLevel !== "silent" ? pc__default.default.dim(command) : ""}`);
288
+ spinner.succeed(`Executing hook ${logLevel !== "silent" ? pc3__default.default.dim(command) : ""}`);
133
289
  console.log(subProcess.stdout);
134
290
  }
135
291
  oraWritable.destroy();
@@ -147,7 +303,7 @@ async function generate({ input, config, CLIOptions, logger: logger2 }) {
147
303
  const { performance, PerformanceObserver } = await import('perf_hooks');
148
304
  const performanceOpserver = new PerformanceObserver((items) => {
149
305
  const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`;
150
- spinner.suffixText = pc__default.default.yellow(message);
306
+ spinner.suffixText = pc3__default.default.yellow(message);
151
307
  performance.clearMarks();
152
308
  });
153
309
  performanceOpserver.observe({ type: "measure" });
@@ -156,7 +312,7 @@ async function generate({ input, config, CLIOptions, logger: logger2 }) {
156
312
  const { root: _root, ...userConfig } = config;
157
313
  const logLevel = CLIOptions.logLevel ?? core.LogLevel.silent;
158
314
  const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
159
- spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? pc__default.default.dim(inputPath) : ""}`);
315
+ spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? pc3__default.default.dim(inputPath) : ""}`);
160
316
  const output = await core.build({
161
317
  config: {
162
318
  root: process.cwd(),
@@ -173,7 +329,7 @@ async function generate({ input, config, CLIOptions, logger: logger2 }) {
173
329
  logger: logger2
174
330
  });
175
331
  spinner.suffixText = "";
176
- spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? pc__default.default.dim(inputPath) : ""}`);
332
+ spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? pc3__default.default.dim(inputPath) : ""}`);
177
333
  await executeHooks({ hooks: config.hooks, logLevel });
178
334
  const summary = getSummary({ pluginManager: output.pluginManager, config, status: "success", hrstart, logLevel: CLIOptions.logLevel });
179
335
  console.log(summary.join(""));
@@ -216,15 +372,15 @@ async function init({ preset = "simple", logLevel = core.LogLevel.silent, packag
216
372
  const presetMeta = presets[preset];
217
373
  const path = pathParser__default.default.resolve(process.cwd(), "./kubb.config.js");
218
374
  const installCommand = packageManager === "npm" ? "install" : "add";
219
- spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${pc__default.default.dim(path)}`);
375
+ spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${pc3__default.default.dim(path)}`);
220
376
  await core.write(presetMeta["kubb.config"], path);
221
- spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${pc__default.default.dim(path)}`);
377
+ spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${pc3__default.default.dim(path)}`);
222
378
  const results = await Promise.allSettled([
223
379
  execa.$`npm init es6 -y`,
224
380
  ...presetMeta.packages.map(async (pack) => {
225
- spinner.start(`\u{1F4C0} Installing ${pc__default.default.dim(pack)}`);
381
+ spinner.start(`\u{1F4C0} Installing ${pc3__default.default.dim(pack)}`);
226
382
  const { stdout } = await execa.$({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`;
227
- spinner.succeed(`\u{1F4C0} Installed ${pc__default.default.dim(pack)}`);
383
+ spinner.succeed(`\u{1F4C0} Installed ${pc3__default.default.dim(pack)}`);
228
384
  return stdout;
229
385
  })
230
386
  ]);
@@ -238,163 +394,6 @@ async function init({ preset = "simple", logLevel = core.LogLevel.silent, packag
238
394
  spinner.succeed(`\u{1F4E6} initialized Kubb`);
239
395
  return;
240
396
  }
241
- function isJSONPlugins(plugins) {
242
- return !!plugins?.some((plugin) => {
243
- return typeof plugin?.[0] === "string";
244
- });
245
- }
246
- function isObjectPlugins(plugins) {
247
- return plugins instanceof Object && !Array.isArray(plugins);
248
- }
249
- async function importPlugin(name, options) {
250
- const importedPlugin = process.env.NODE_ENV === "test" ? await import(name) : await core.importModule(name, process.cwd());
251
- return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options);
252
- }
253
- function getPlugins(plugins) {
254
- if (isObjectPlugins(plugins)) {
255
- const promises = Object.keys(plugins).map((name) => {
256
- return importPlugin(name, plugins[name]);
257
- });
258
- return Promise.all(promises);
259
- }
260
- if (isJSONPlugins(plugins)) {
261
- const promises = plugins.map((plugin) => {
262
- const [name, options = {}] = plugin;
263
- return importPlugin(name, options);
264
- });
265
- return Promise.all(promises);
266
- }
267
- return Promise.resolve(plugins);
268
- }
269
-
270
- // src/utils/getConfig.ts
271
- async function getConfig(result, CLIOptions) {
272
- const config = result?.config;
273
- let kubbUserConfig = Promise.resolve(config);
274
- if (typeof config === "function") {
275
- const possiblePromise = config(CLIOptions);
276
- if (core.isPromise(possiblePromise)) {
277
- kubbUserConfig = possiblePromise;
278
- }
279
- kubbUserConfig = Promise.resolve(possiblePromise);
280
- }
281
- let JSONConfig = await kubbUserConfig;
282
- JSONConfig = {
283
- ...JSONConfig,
284
- plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : void 0
285
- };
286
- return JSONConfig;
287
- }
288
- async function startWatcher(path, cb) {
289
- const { watch } = await import('chokidar');
290
- const ignored = ["**/{.git,node_modules}/**"];
291
- const watcher = watch(path, {
292
- ignorePermissionErrors: true,
293
- ignored
294
- });
295
- watcher.on("all", (type, file) => {
296
- spinner.succeed(pc__default.default.yellow(pc__default.default.bold(`Change detected: ${type} ${file}`)));
297
- spinner.spinner = "clock";
298
- try {
299
- cb(path);
300
- } catch (e) {
301
- spinner.warn(pc__default.default.red("Watcher failed"));
302
- }
303
- });
304
- return;
305
- }
306
- var tsLoader = (configFile) => {
307
- let registerer = { enabled() {
308
- } };
309
- try {
310
- registerer = tsNode__default.default.register({
311
- compilerOptions: { module: "commonjs" },
312
- typeCheck: false
313
- });
314
- const module = __require(configFile);
315
- return module.default;
316
- } catch (err) {
317
- const error = err;
318
- if (error.name === "MODULE_NOT_FOUND") {
319
- throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed
320
- Error: ${error.message}`);
321
- }
322
- throw error;
323
- } finally {
324
- registerer.enabled();
325
- }
326
- };
327
- async function getCosmiConfig(moduleName2, config) {
328
- const searchPlaces = [
329
- "package.json",
330
- `.${moduleName2}rc`,
331
- `.${moduleName2}rc.json`,
332
- `.${moduleName2}rc.yaml`,
333
- `.${moduleName2}rc.yml`,
334
- `.${moduleName2}rc.ts`,
335
- `.${moduleName2}rc.js`,
336
- `.${moduleName2}rc.cjs`,
337
- `.${moduleName2}rc.mjs`,
338
- `${moduleName2}.config.ts`,
339
- `${moduleName2}.config.js`,
340
- `${moduleName2}.config.cjs`,
341
- `${moduleName2}.config.mjs`
342
- ];
343
- const explorer = cosmiconfig.cosmiconfig(moduleName2, {
344
- cache: false,
345
- searchPlaces: [
346
- ...searchPlaces.map((searchPlace) => {
347
- return `.config/${searchPlace}`;
348
- }),
349
- ...searchPlaces.map((searchPlace) => {
350
- return `configs/${searchPlace}`;
351
- }),
352
- ...searchPlaces
353
- ],
354
- loaders: {
355
- ".ts": tsLoader
356
- }
357
- });
358
- const result = config ? await explorer.load(config) : await explorer.search();
359
- if (result?.isEmpty || !result || !result.config) {
360
- throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
361
- }
362
- return result;
363
- }
364
- var prettyError = new PrettyError__default.default().skipPackage("commander").skip(function(traceLine) {
365
- const pattern = new RegExp("renderErrors");
366
- const hasMatch = traceLine?.file?.match(pattern);
367
- if (typeof traceLine.packageName !== "undefined" && hasMatch) {
368
- return true;
369
- }
370
- }).start();
371
- function getErrorCauses(errors) {
372
- return errors.reduce((prev, error) => {
373
- const causedError = error?.cause;
374
- if (causedError) {
375
- prev = [...prev, ...getErrorCauses([causedError])];
376
- }
377
- prev = [...prev, prettyError.render(error)];
378
- return prev;
379
- }, []).filter(Boolean);
380
- }
381
- function renderErrors(error, { prefixText, logLevel = core.LogLevel.silent }) {
382
- if (!error) {
383
- return "";
384
- }
385
- if (error instanceof core.ParallelPluginError) {
386
- return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join("\n");
387
- }
388
- if (logLevel === core.LogLevel.silent) {
389
- prettyError.skipNodeFiles();
390
- prettyError.skip(function() {
391
- return true;
392
- });
393
- return [prefixText, prettyError.render(error)].filter(Boolean).join("\n");
394
- }
395
- const errors = getErrorCauses([error]);
396
- return [prefixText, ...errors].filter(Boolean).join("\n");
397
- }
398
397
 
399
398
  // src/index.ts
400
399
  var moduleName = "kubb";
@@ -406,9 +405,9 @@ function programCatcher(e, CLIOptions) {
406
405
  if (summaryError) {
407
406
  error = summaryError.cause;
408
407
  }
409
- const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc__default.default.red(originalError?.message) });
408
+ const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc3__default.default.red(originalError?.message) });
410
409
  if (error instanceof core.Warning) {
411
- spinner.warn(pc__default.default.yellow(error.message));
410
+ spinner.warn(pc3__default.default.yellow(error.message));
412
411
  process.exit(0);
413
412
  }
414
413
  if (CLIOptions.logLevel === core.LogLevel.silent) {
@@ -421,13 +420,13 @@ function programCatcher(e, CLIOptions) {
421
420
  async function generateAction(input, CLIOptions) {
422
421
  spinner.start("\u{1F4BE} Loading config");
423
422
  const result = await getCosmiConfig(moduleName, CLIOptions.config);
424
- spinner.succeed(`\u{1F4BE} Config loaded(${pc__default.default.dim(pathParser__default.default.relative(process.cwd(), result.filepath))})`);
423
+ spinner.succeed(`\u{1F4BE} Config loaded(${pc3__default.default.dim(pathParser__default.default.relative(process.cwd(), result.filepath))})`);
425
424
  const config = await getConfig(result, CLIOptions);
426
425
  if (CLIOptions.watch && "path" in config.input) {
427
426
  return startWatcher([input || config.input.path], async (paths) => {
428
427
  await generate({ config, CLIOptions, logger });
429
428
  spinner.spinner = "simpleDotsScrolling";
430
- spinner.start(pc__default.default.yellow(pc__default.default.bold(`Watching for changes in ${paths.join(" and ")}`)));
429
+ spinner.start(pc3__default.default.yellow(pc3__default.default.bold(`Watching for changes in ${paths.join(" and ")}`)));
431
430
  });
432
431
  }
433
432
  await generate({ input, config, CLIOptions, logger });