@kubb/cli 1.2.0 → 1.2.2
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 +175 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +175 -142
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import pathParser from 'node:path';
|
|
3
|
-
import { Command, CommanderError, Option } from 'commander';
|
|
4
3
|
import ora from 'ora';
|
|
4
|
+
import cac from 'cac';
|
|
5
5
|
import pc3 from 'picocolors';
|
|
6
|
-
import {
|
|
6
|
+
import { write, canLogHierarchy, LogLevel, isPromiseFulfilledResult, ParallelPluginError, createLogger, build, timeout, PluginError, SummaryError, isPromise, Warning, randomPicoColour, importModule } from '@kubb/core';
|
|
7
7
|
import { $, execa } from 'execa';
|
|
8
|
+
import { PerformanceObserver, performance } from 'node:perf_hooks';
|
|
8
9
|
import { parseArgsStringToArgv } from 'string-argv';
|
|
9
10
|
import { Writable } from 'node:stream';
|
|
10
11
|
import { cosmiconfig } from 'cosmiconfig';
|
|
@@ -23,7 +24,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
// package.json
|
|
26
|
-
var version = "1.2.
|
|
27
|
+
var version = "1.2.2";
|
|
27
28
|
var presets = {
|
|
28
29
|
simple: {
|
|
29
30
|
"kubb.config": `
|
|
@@ -51,7 +52,7 @@ export default defineConfig({
|
|
|
51
52
|
packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
|
-
async function init({ preset = "simple", logLevel =
|
|
55
|
+
async function init({ preset = "simple", logLevel = LogLevel.silent, packageManager = "pnpm" }) {
|
|
55
56
|
spinner.start("\u{1F4E6} Initializing Kubb");
|
|
56
57
|
const presetMeta = presets[preset];
|
|
57
58
|
const path = pathParser.resolve(process.cwd(), "./kubb.config.js");
|
|
@@ -68,7 +69,7 @@ async function init({ preset = "simple", logLevel = "silent", packageManager = "
|
|
|
68
69
|
return stdout;
|
|
69
70
|
})
|
|
70
71
|
]);
|
|
71
|
-
if (logLevel
|
|
72
|
+
if (canLogHierarchy(logLevel, LogLevel.info)) {
|
|
72
73
|
results.forEach((result) => {
|
|
73
74
|
if (isPromiseFulfilledResult(result)) {
|
|
74
75
|
console.log(result.value);
|
|
@@ -84,9 +85,7 @@ function parseHrtimeToSeconds(hrtime) {
|
|
|
84
85
|
const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
|
|
85
86
|
return seconds;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
// src/utils/parseText.ts
|
|
89
|
-
function parseText(baseText, config, logLevel = "silent") {
|
|
88
|
+
function parseText(baseText, config, logLevel = LogLevel.silent) {
|
|
90
89
|
return `${baseText}${config[logLevel] || ""}`;
|
|
91
90
|
}
|
|
92
91
|
var OraWritable = class extends Writable {
|
|
@@ -106,90 +105,100 @@ ${pc3.bold(pc3.blue(this.command))}: ${chunk?.toString()}`;
|
|
|
106
105
|
};
|
|
107
106
|
|
|
108
107
|
// src/run.ts
|
|
109
|
-
async function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
async function executeHooks({ hooks, logLevel }) {
|
|
109
|
+
if (!hooks?.done) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
|
|
113
|
+
if (canLogHierarchy(logLevel, LogLevel.silent)) {
|
|
114
|
+
spinner.start(`Executing hooks`);
|
|
115
|
+
}
|
|
116
|
+
const executers = commands.map(async (command) => {
|
|
117
|
+
const oraWritable = new OraWritable(spinner, command);
|
|
118
|
+
const abortController = new AbortController();
|
|
119
|
+
const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
|
|
120
|
+
spinner.start(parseText(`Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
|
|
121
|
+
const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
|
|
122
|
+
spinner.suffixText = "";
|
|
123
|
+
if (canLogHierarchy(logLevel, LogLevel.info)) {
|
|
124
|
+
spinner.succeed(parseText(`Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
|
|
125
|
+
console.log(subProcess.stdout);
|
|
115
126
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
await timeout(100);
|
|
128
|
+
oraWritable.destroy();
|
|
129
|
+
return { subProcess, abort: abortController.abort.bind(abortController) };
|
|
130
|
+
});
|
|
131
|
+
await Promise.all(executers);
|
|
132
|
+
if (canLogHierarchy(logLevel, LogLevel.silent)) {
|
|
133
|
+
spinner.succeed(`Executing hooks`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function getSummary({ pluginManager, status, hrstart, config, logLevel }) {
|
|
137
|
+
const logs = [];
|
|
138
|
+
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
|
|
139
|
+
const buildStartPlugins = [
|
|
140
|
+
...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
|
|
141
|
+
];
|
|
142
|
+
const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
|
|
143
|
+
const pluginsCount = config.plugins?.length || 0;
|
|
144
|
+
const files = pluginManager.fileManager.files.sort((a, b) => {
|
|
145
|
+
if (!a.meta?.pluginName || !b.meta?.pluginName) {
|
|
146
|
+
return 0;
|
|
119
147
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const abortController = new AbortController();
|
|
123
|
-
const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
|
|
124
|
-
spinner.start(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
|
|
125
|
-
const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
|
|
126
|
-
spinner.suffixText = "";
|
|
127
|
-
if (logLevel === "info") {
|
|
128
|
-
spinner.succeed(parseText(`\u{1FA82} Executing hook`, { info: ` ${pc3.dim(command)}` }, logLevel));
|
|
129
|
-
console.log(subProcess.stdout);
|
|
130
|
-
}
|
|
131
|
-
await timeout(50);
|
|
132
|
-
oraWritable.destroy();
|
|
133
|
-
return { subProcess, abort: abortController.abort.bind(abortController) };
|
|
134
|
-
});
|
|
135
|
-
await Promise.all(executers);
|
|
136
|
-
if (logLevel === "silent") {
|
|
137
|
-
spinner.succeed(`\u{1FA82} Executing hooks`);
|
|
148
|
+
if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
|
|
149
|
+
return 1;
|
|
138
150
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const logs = [];
|
|
142
|
-
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
|
|
143
|
-
const buildStartPlugins = [
|
|
144
|
-
...new Set(pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name))
|
|
145
|
-
];
|
|
146
|
-
const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name);
|
|
147
|
-
const pluginsCount = config.plugins?.length || 0;
|
|
148
|
-
const files = pluginManager.fileManager.files.sort((a, b) => {
|
|
149
|
-
if (!a.meta?.pluginName || !b.meta?.pluginName) {
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
if (a.meta?.pluginName.length < b.meta?.pluginName.length) {
|
|
153
|
-
return 1;
|
|
154
|
-
}
|
|
155
|
-
if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
|
|
156
|
-
return -1;
|
|
157
|
-
}
|
|
158
|
-
return 0;
|
|
159
|
-
});
|
|
160
|
-
const meta = {
|
|
161
|
-
plugins: status === "success" ? `${pc3.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
|
|
162
|
-
pluginsFailed: status === "failed" ? failedPlugins?.join(", ") : void 0,
|
|
163
|
-
filesCreated: files.length,
|
|
164
|
-
time: pc3.yellow(`${elapsedSeconds}s`),
|
|
165
|
-
output: pathParser.resolve(config.root, config.output.path)
|
|
166
|
-
};
|
|
167
|
-
if (options.debug) {
|
|
168
|
-
logs.push(pc3.bold("Generated files:\n"));
|
|
169
|
-
logs.push(files.map((file) => `${pc3.blue(file.meta?.pluginName)} ${file.path}`).join("\n"));
|
|
151
|
+
if (a.meta?.pluginName.length > b.meta?.pluginName.length) {
|
|
152
|
+
return -1;
|
|
170
153
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
`, true]
|
|
180
|
-
].map((item) => {
|
|
181
|
-
if (item.at(1)) {
|
|
182
|
-
return item.at(0);
|
|
183
|
-
}
|
|
184
|
-
return void 0;
|
|
185
|
-
}).filter(Boolean).join("\n")
|
|
186
|
-
);
|
|
187
|
-
return logs;
|
|
154
|
+
return 0;
|
|
155
|
+
});
|
|
156
|
+
const meta = {
|
|
157
|
+
plugins: status === "success" ? `${pc3.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${pc3.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,
|
|
158
|
+
pluginsFailed: status === "failed" ? failedPlugins?.map((name) => randomPicoColour(name))?.join(", ") : void 0,
|
|
159
|
+
filesCreated: files.length,
|
|
160
|
+
time: pc3.yellow(`${elapsedSeconds}s`),
|
|
161
|
+
output: pathParser.resolve(config.root, config.output.path)
|
|
188
162
|
};
|
|
163
|
+
if (canLogHierarchy(logLevel, "stacktrace")) {
|
|
164
|
+
logs.push(pc3.bold("Generated files:\n"));
|
|
165
|
+
logs.push(files.map((file) => `${randomPicoColour(file.meta?.pluginName)} ${file.path}`).join("\n"));
|
|
166
|
+
}
|
|
167
|
+
logs.push(
|
|
168
|
+
[
|
|
169
|
+
[`
|
|
170
|
+
`, true],
|
|
171
|
+
[` ${pc3.bold("Plugins:")} ${meta.plugins}`, true],
|
|
172
|
+
[` ${pc3.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
|
|
173
|
+
[`${pc3.bold("Generated:")} ${meta.filesCreated} files`, true],
|
|
174
|
+
[` ${pc3.bold("Time:")} ${meta.time}`, true],
|
|
175
|
+
[` ${pc3.bold("Output:")} ${meta.output}`, true],
|
|
176
|
+
[`
|
|
177
|
+
`, true]
|
|
178
|
+
].map((item) => {
|
|
179
|
+
if (item.at(1)) {
|
|
180
|
+
return item.at(0);
|
|
181
|
+
}
|
|
182
|
+
return void 0;
|
|
183
|
+
}).filter(Boolean).join("\n")
|
|
184
|
+
);
|
|
185
|
+
return logs;
|
|
186
|
+
}
|
|
187
|
+
async function run({ input, config, CLIOptions }) {
|
|
188
|
+
const hrstart = process.hrtime();
|
|
189
|
+
const logger = createLogger(spinner);
|
|
190
|
+
const performanceOpserver = new PerformanceObserver((items) => {
|
|
191
|
+
const message = `${items.getEntries()[0].duration.toFixed(0)}ms`;
|
|
192
|
+
spinner.suffixText = pc3.yellow(message);
|
|
193
|
+
performance.clearMarks();
|
|
194
|
+
});
|
|
195
|
+
if (CLIOptions.debug) {
|
|
196
|
+
performanceOpserver.observe({ type: "measure" });
|
|
197
|
+
}
|
|
189
198
|
try {
|
|
190
199
|
const { root: _root, ...userConfig } = config;
|
|
191
|
-
const logLevel =
|
|
192
|
-
const inputPath =
|
|
200
|
+
const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? LogLevel.silent;
|
|
201
|
+
const inputPath = input ?? userConfig.input.path;
|
|
193
202
|
spinner.start(parseText(`\u{1F680} Building`, { info: `(${pc3.dim(inputPath)})` }, logLevel));
|
|
194
203
|
const output = await build({
|
|
195
204
|
config: {
|
|
@@ -205,18 +214,21 @@ async function run({ config, options }) {
|
|
|
205
214
|
...userConfig.output
|
|
206
215
|
}
|
|
207
216
|
},
|
|
208
|
-
logger
|
|
217
|
+
logger,
|
|
218
|
+
debug: CLIOptions.debug
|
|
209
219
|
});
|
|
220
|
+
spinner.suffixText = "";
|
|
210
221
|
spinner.succeed(parseText(`\u{1F680} Build completed`, { info: `(${pc3.dim(inputPath)})` }, logLevel));
|
|
211
|
-
await
|
|
212
|
-
|
|
222
|
+
await timeout(100);
|
|
223
|
+
await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug });
|
|
224
|
+
const summary = getSummary({ pluginManager: output.pluginManager, config, status: "success", hrstart, logLevel: CLIOptions.logLevel });
|
|
213
225
|
console.log(summary.join(""));
|
|
214
226
|
} catch (error) {
|
|
227
|
+
let summary = [];
|
|
215
228
|
if (error instanceof PluginError || error instanceof ParallelPluginError) {
|
|
216
|
-
|
|
217
|
-
throw new SummaryError("Something went wrong\n", { cause: error, summary });
|
|
229
|
+
summary = getSummary({ pluginManager: error.pluginManager, config, status: "failed", hrstart, logLevel: CLIOptions.logLevel });
|
|
218
230
|
}
|
|
219
|
-
throw new SummaryError("Something went wrong\n", { cause: error });
|
|
231
|
+
throw new SummaryError("Something went wrong\n", { cause: error, summary });
|
|
220
232
|
}
|
|
221
233
|
}
|
|
222
234
|
function isJSONPlugins(plugins) {
|
|
@@ -249,11 +261,11 @@ function getPlugins(plugins) {
|
|
|
249
261
|
}
|
|
250
262
|
|
|
251
263
|
// src/utils/getConfig.ts
|
|
252
|
-
async function getConfig(result,
|
|
264
|
+
async function getConfig(result, CLIOptions) {
|
|
253
265
|
const config = result?.config;
|
|
254
266
|
let kubbUserConfig = Promise.resolve(config);
|
|
255
267
|
if (typeof config === "function") {
|
|
256
|
-
const possiblePromise = config(
|
|
268
|
+
const possiblePromise = config(CLIOptions);
|
|
257
269
|
if (isPromise(possiblePromise)) {
|
|
258
270
|
kubbUserConfig = possiblePromise;
|
|
259
271
|
}
|
|
@@ -299,11 +311,12 @@ var tsLoader = (configFile) => {
|
|
|
299
311
|
const module = __require(configFile);
|
|
300
312
|
return module.default;
|
|
301
313
|
} catch (err) {
|
|
302
|
-
|
|
314
|
+
const error = err;
|
|
315
|
+
if (error.name === "MODULE_NOT_FOUND") {
|
|
303
316
|
throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed
|
|
304
|
-
Error: ${
|
|
317
|
+
Error: ${error.message}`);
|
|
305
318
|
}
|
|
306
|
-
throw
|
|
319
|
+
throw error;
|
|
307
320
|
} finally {
|
|
308
321
|
registerer.enabled();
|
|
309
322
|
}
|
|
@@ -342,7 +355,7 @@ async function getCosmiConfig(moduleName2, config) {
|
|
|
342
355
|
}
|
|
343
356
|
return result;
|
|
344
357
|
}
|
|
345
|
-
var prettyError = new PrettyError().skipPackage("commander").skip(function(traceLine
|
|
358
|
+
var prettyError = new PrettyError().skipPackage("commander").skip(function(traceLine) {
|
|
346
359
|
const pattern = new RegExp("renderErrors");
|
|
347
360
|
const hasMatch = traceLine?.file?.match(pattern);
|
|
348
361
|
if (typeof traceLine.packageName !== "undefined" && hasMatch) {
|
|
@@ -359,14 +372,14 @@ function getErrorCauses(errors) {
|
|
|
359
372
|
return prev;
|
|
360
373
|
}, []).filter(Boolean);
|
|
361
374
|
}
|
|
362
|
-
function renderErrors(error, { prefixText,
|
|
375
|
+
function renderErrors(error, { prefixText, logLevel = LogLevel.silent }) {
|
|
363
376
|
if (!error) {
|
|
364
377
|
return "";
|
|
365
378
|
}
|
|
366
379
|
if (error instanceof ParallelPluginError) {
|
|
367
|
-
return [prefixText, ...error.errors.map((e) => renderErrors(e, {
|
|
380
|
+
return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join("\n");
|
|
368
381
|
}
|
|
369
|
-
if (
|
|
382
|
+
if (canLogHierarchy(logLevel, "stacktrace")) {
|
|
370
383
|
const errors = getErrorCauses([error]);
|
|
371
384
|
return [prefixText, ...errors].filter(Boolean).join("\n");
|
|
372
385
|
}
|
|
@@ -380,56 +393,76 @@ var moduleName = "kubb";
|
|
|
380
393
|
var spinner = ora({
|
|
381
394
|
spinner: "clock"
|
|
382
395
|
});
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
396
|
+
function programCatcher(e, CLIOptions) {
|
|
397
|
+
const originalError = e;
|
|
398
|
+
let error = originalError;
|
|
399
|
+
const summaryError = error instanceof SummaryError ? error : void 0;
|
|
400
|
+
if (summaryError) {
|
|
401
|
+
error = summaryError.cause;
|
|
386
402
|
}
|
|
387
|
-
})
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
renderErrors(new Error(message, { cause: void 0 }), { debug: options.debug, prefixText: pc3.red("Something went wrong with processing the CLI\n") }) + "\n"
|
|
392
|
-
);
|
|
403
|
+
const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc3.red(originalError?.message) });
|
|
404
|
+
if (error instanceof Warning) {
|
|
405
|
+
spinner.warn(pc3.yellow(error.message));
|
|
406
|
+
process.exit(0);
|
|
393
407
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
408
|
+
if (canLogHierarchy(CLIOptions.logLevel, LogLevel.silent)) {
|
|
409
|
+
spinner.fail(message);
|
|
410
|
+
process.exit(1);
|
|
411
|
+
}
|
|
412
|
+
spinner.fail([message, ...summaryError?.summary || []].join("\n"));
|
|
413
|
+
process.exit(1);
|
|
414
|
+
}
|
|
415
|
+
async function createProgram(argv) {
|
|
416
|
+
const program = cac(moduleName);
|
|
417
|
+
const programAction = async (input, options) => {
|
|
418
|
+
try {
|
|
419
|
+
spinner.start("\u{1F4BE} Loading config");
|
|
420
|
+
const result = await getCosmiConfig(moduleName, options.config);
|
|
421
|
+
spinner.succeed(`\u{1F4BE} Config loaded(${pc3.dim(pathParser.relative(process.cwd(), result.filepath))})`);
|
|
422
|
+
if (options.watch) {
|
|
423
|
+
const config2 = await getConfig(result, options);
|
|
424
|
+
return startWatcher([input || config2.input.path], async (paths) => {
|
|
425
|
+
await run({ config: config2, CLIOptions: options });
|
|
426
|
+
spinner.spinner = "simpleDotsScrolling";
|
|
427
|
+
spinner.start(pc3.yellow(pc3.bold(`Watching for changes in ${paths.join(" and ")}`)));
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
const config = await getConfig(result, options);
|
|
431
|
+
await run({ input, config, CLIOptions: options });
|
|
432
|
+
} catch (e) {
|
|
433
|
+
programCatcher(e, options);
|
|
410
434
|
}
|
|
411
|
-
|
|
412
|
-
|
|
435
|
+
};
|
|
436
|
+
program.command("[input]", "Path of the input file(overrides the one in `kubb.config.js`)").action(programAction);
|
|
437
|
+
program.command("generate [input]", "Path of the input file(overrides the one in `kubb.config.js`)").option("-c, --config <path>", "Path to the Kubb config").option("-l, --log-level <type>", "Type of the logging(overrides the one in `kubb.config.js`)").option("-d, --debug", "Debug mode", { default: false }).option("-w, --watch", "Watch mode based on the input file").action(programAction);
|
|
438
|
+
program.command("init", "Init Kubb").action(async () => {
|
|
439
|
+
return init({ logLevel: "info" });
|
|
440
|
+
});
|
|
441
|
+
program.help();
|
|
442
|
+
program.version(version);
|
|
443
|
+
program.on("command:*", () => {
|
|
444
|
+
console.log(prettyError.render(`Invalid command: ${program.args.join(" ")}`));
|
|
445
|
+
process.exit(1);
|
|
446
|
+
});
|
|
447
|
+
try {
|
|
448
|
+
program.parse(argv, { run: false });
|
|
449
|
+
await program.runMatchedCommand();
|
|
413
450
|
} catch (e) {
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (error instanceof Warning) {
|
|
422
|
-
spinner.warn(pc3.yellow(error.message));
|
|
423
|
-
process.exit(0);
|
|
424
|
-
}
|
|
425
|
-
spinner.fail([message, ...summaryError?.summary || []].join("\n"));
|
|
451
|
+
const error = e;
|
|
452
|
+
console.log(
|
|
453
|
+
renderErrors(new Error(error.message, { cause: void 0 }), {
|
|
454
|
+
logLevel: "info",
|
|
455
|
+
prefixText: pc3.red("Something went wrong with processing the CLI\n")
|
|
456
|
+
})
|
|
457
|
+
);
|
|
426
458
|
process.exit(1);
|
|
427
459
|
}
|
|
428
|
-
|
|
460
|
+
return program;
|
|
461
|
+
}
|
|
429
462
|
|
|
430
463
|
// src/index.ts
|
|
431
|
-
function runCLI(argv) {
|
|
432
|
-
|
|
464
|
+
async function runCLI(argv) {
|
|
465
|
+
await createProgram(argv);
|
|
433
466
|
}
|
|
434
467
|
|
|
435
468
|
export { runCLI as default };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","spinner","importModule","moduleName","ParallelPluginError","SummaryError","write","config"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,SAAS,SAAS,gBAAgB,cAAc;AAChD,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACFb,cAAW;;;ACFb,OAAO,gBAAgB;AAEvB,SAAS,0BAA0B,aAAa;AAEhD,SAAS,SAAS;AAClB,OAAO,QAAQ;AA6Bf,IAAM,UAAsC;AAAA,EAC1C,QAAQ;AAAA,IACN,eAAe;AAAA;AAAA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vB;AAEA,UAAM,UAAU,aAAa,OAAO,EAAE,OAAO,QAAQ,OAAO,YAAYL,IAAG,IAAI,eAAe,OAAO,EAAE,CAAC;AAExG,QAAI,iBAAiB,SAAS;AAC5B,cAAQ,KAAKA,IAAG,OAAO,MAAM,OAAO,CAAC;AACrC,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,CAAC,SAAS,GAAI,cAAc,WAAW,CAAC,CAAE,EAAE,KAAK,IAAI,CAAC;AACnE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;;;AY5FY,SAAR,OAAwB,MAAmC;AAChE,SAAO,QAAQ,MAAM,IAAI;AAC3B","sourcesContent":["import pathParser from 'node:path'\n\nimport { Command, CommanderError, Option } from 'commander'\nimport ora from 'ora'\nimport pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { SummaryError } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nexport const program = new Command(moduleName)\n .name(moduleName)\n .description('Kubb')\n .version(version, '-v')\n .exitOverride((err) => {\n if (err instanceof CommanderError) {\n process.exit(1)\n }\n })\n .configureOutput({\n outputError: (message, write) => {\n const options: CLIOptions = program.opts()\n\n write(\n renderErrors(new Error(message, { cause: undefined }), { debug: options.debug, prefixText: pc.red('Something went wrong with processing the CLI\\n') }) +\n '\\n'\n )\n },\n })\n .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))\n .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))\n .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['error', 'info', 'silent']))\n .addOption(new Option('--init', 'Init Kubb'))\n .addOption(new Option('-d, --debug', 'Debug mode').default(false))\n .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))\n .action(async (options: CLIOptions) => {\n try {\n spinner.start()\n\n if (options.init) {\n return init({ logLevel: options.logLevel })\n }\n\n // CONFIG\n // TODO use options.config to show path instead of relying on the `result`\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([config.input.path], async (paths) => {\n await run({ config, options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ config, options })\n } catch (e: any) {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { debug: options.debug, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n }\n })\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.0\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-project/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"eslint --format pretty ./src\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"commander\": \"^10.0.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.1.3\"\n },\n \"packageManager\": \"pnpm@8.3.0\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.3.0\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import pathParser from 'node:path'\n\nimport { isPromiseFulfilledResult, write } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevel } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\n /**\n * @default `'silent'`\n */\n logLevel?: LogLevel\n /**\n * @default `'simple'`\n */\n preset?: Preset\n /**\n * @default `'pnpm'`\n */\n packageManager?: PackageManager\n}\n\nconst presets: Record<Preset, PresetMeta> = {\n simple: {\n 'kubb.config': `\nimport { defineConfig } from '@kubb/core'\nimport createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'\n\nexport default defineConfig({\n root: '.',\n input: {\n path: 'https://petstore3.swagger.io/api/v3/openapi.json',\n },\n output: {\n path: './src/gen',\n clean: true,\n },\n hooks: {\n done: 'echo \"🎉 done\"',\n },\n logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './hooks' })],\n})\n `,\n packages: ['@kubb/core', '@kubb/cli', '@kubb/swagger', '@kubb/swagger-ts', '@kubb/swagger-tanstack-query'],\n },\n}\n\nexport async function init({ preset = 'simple', logLevel = 'silent', packageManager = 'pnpm' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (logLevel === 'info') {\n results.forEach((result) => {\n if (isPromiseFulfilledResult(result)) {\n console.log(result.value)\n }\n })\n }\n spinner.succeed(`📦 initialized Kubb`)\n\n return\n}\n","import pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevel } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n config: KubbConfig\n options: CLIOptions\n}\n\nexport async function run({ config, options }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n\n const logger = createLogger(spinner)\n\n const executeHooks = async (hooks: KubbConfig['hooks'], logLevel: LogLevel) => {\n if (!hooks?.done) {\n return\n }\n\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done]\n\n if (logLevel === 'silent') {\n spinner.start(`🪂 Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (logLevel === 'info') {\n spinner.succeed(parseText(`🪂 Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 50ms to be sure that all open files are close(fs)\n await timeout(50)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (logLevel === 'silent') {\n spinner.succeed(`🪂 Executing hooks`)\n }\n }\n\n const getSummary = (pluginManager: BuildOutput['pluginManager'], status: 'success' | 'failed'): string[] => {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name)\n const pluginsCount = config.plugins?.length || 0\n const files = pluginManager.fileManager.files.sort((a, b) => {\n if (!a.meta?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (options.debug) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${pc.blue(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.bold('Output:')} ${meta.output}`, true],\n [`\\n`, true],\n ]\n .map((item) => {\n if (item.at(1)) {\n return item.at(0)\n }\n return undefined\n })\n .filter(Boolean)\n .join('\\n')\n )\n\n return logs\n }\n\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = options.logLevel ?? userConfig.logLevel ?? 'silent'\n const inputPath = options.input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await executeHooks(config.hooks, logLevel)\n\n const summary = getSummary(output.pluginManager, 'success')\n console.log(summary.join(''))\n } catch (error: any) {\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n const summary = getSummary(error.pluginManager, 'failed')\n\n throw new SummaryError('Something went wrong\\n', { cause: error, summary })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]) {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import type { LogLevel } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevel, string>>, logLevel: LogLevel = 'silent') {\n return `${baseText}${config[logLevel] || ''}`\n}\n","import type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\n\nexport class OraWritable extends Writable {\n public command: string\n public spinner: Ora\n constructor(spinner: Ora, command: string, opts?: WritableOptions) {\n super(opts)\n\n this.command = command\n this.spinner = spinner\n }\n _write(chunk: any, _encoding: NodeJS.BufferEncoding, callback: (error?: Error | null) => void) {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, options: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(options)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>) {\n const { watch } = await import('chokidar')\n\n const ignored = ['**/{.git,node_modules}/**']\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n spinner.succeed(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err: any) {\n if (err.code === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${err.message}`)\n }\n\n throw err\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string) {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","import { ParallelPluginError } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine, lineNumber) {\n // exclude renderErrors.ts\n const pattern = new RegExp('renderErrors')\n\n const hasMatch = traceLine?.file?.match(pattern)\n\n if (typeof traceLine.packageName !== 'undefined' && hasMatch) {\n return true\n }\n } as PrettyError.Callback)\n .start()\n\nfunction getErrorCauses(errors: Error[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, debug = false }: { prefixText?: string; debug?: boolean }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { debug }))].filter(Boolean).join('\\n')\n }\n\n if (debug) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import type { Command } from 'commander'\n\nimport { program } from './program.ts'\n\nexport default function runCLI(argv?: readonly string[]): Command {\n return program.parse(argv)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/program.ts","../package.json","../src/init.ts","../src/run.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/parseText.ts","../src/utils/OraWritable.ts","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/watcher.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/index.ts"],"names":["pathParser","pc","LogLevel","canLogHierarchy","spinner","importModule","moduleName","ParallelPluginError","SummaryError","config"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,iBAAgB;AAEvB,OAAO,SAAS;AAEhB,OAAO,SAAS;AAChB,OAAOC,SAAQ;;;ACHb,cAAW;;;ACFb,OAAO,gBAAgB;AAEvB,SAAS,UAAU,0BAA0B,OAAO,uBAAuB;AAE3E,SAAS,SAAS;AAClB,OAAO,QAAQ;AA6Bf,IAAM,UAAsC;AAAA,EAC1C,QAAQ;AAAA,IACN,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAsBf,UAAU,CAAC,cAAc,aAAa,iBAAiB,oBAAoB,8BAA8B;AAAA,EAC3G;AACF;AAEA,eAAsB,KAAK,EAAE,SAAS,UAAU,WAAW,SAAS,QAAQ,iBAAiB,OAAO,GAAiC;AACnI,UAAQ,MAAM,6BAAsB;AAEpC,QAAM,aAAa,QAAQ,MAAM;AACjC,QAAM,OAAO,WAAW,QAAQ,QAAQ,IAAI,GAAG,kBAAkB;AACjE,QAAM,iBAAiB,mBAAmB,QAAQ,YAAY;AAE9D,UAAQ,MAAM,wCAAiC,GAAG,IAAI,IAAI,GAAG;AAC7D,QAAM,MAAM,WAAW,aAAa,GAAG,IAAI;AAC3C,UAAQ,QAAQ,sCAA+B,GAAG,IAAI,IAAI,GAAG;AAE7D,QAAM,UAAU,MAAM,QAAQ,WAAW;AAAA,IACvC;AAAA,IACA,GAAG,WAAW,SAAS,IAAI,OAAO,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OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,4DAA4D,EAC7F,OAAO,eAAe,cAAc,EAAE,SAAS,MAAM,CAAC,EACtD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,aAAa;AAEvB,UAAQ,QAAQ,QAAQ,WAAW,EAAE,OAAO,YAAY;AACtD,WAAO,KAAK,EAAE,UAAU,OAAO,CAAC;AAAA,EAClC,CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AAEvB,UAAQ,GAAG,aAAa,MAAM;AAC5B,YAAQ,IAAI,YAAY,OAAO,oBAAoB,QAAQ,KAAK,KAAK,GAAG,GAAG,CAAC;AAE5E,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AAED,MAAI;AACF,YAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,UAAM,QAAQ,kBAAkB;AAAA,EAClC,SAAS,GAAP;AACA,UAAM,QAAQ;AAEd,YAAQ;AAAA,MACN,aAAa,IAAI,MAAM,MAAM,SAAS,EAAE,OAAO,OAAU,CAAC,GAAG;AAAA,QAC3D,UAAU;AAAA,QACV,YAAYA,IAAG,IAAI,gDAAgD;AAAA,MACrE,CAAC;AAAA,IACH;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AACT;;;AYvHA,eAAO,OAA8B,MAAgC;AACnE,QAAM,cAAc,IAAI;AAC1B","sourcesContent":["import pathParser from 'node:path'\n\nimport ora from 'ora'\nimport type { CAC } from 'cac'\nimport cac from 'cac'\nimport pc from 'picocolors'\n\nimport { version } from '../package.json'\nimport { init } from './init.ts'\nimport { run } from './run.ts'\nimport { getConfig, getCosmiConfig, renderErrors, startWatcher } from './utils/index.ts'\n\nimport { LogLevel, SummaryError, canLogHierarchy } from '@kubb/core'\nimport type { CLIOptions } from '@kubb/core'\nimport { Warning } from '@kubb/core'\nimport { prettyError } from './utils/renderErrors'\n\nconst moduleName = 'kubb'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const originalError = e as Error\n let error = originalError\n\n // summaryError check\n const summaryError = error instanceof SummaryError ? error : undefined\n\n if (summaryError) {\n // use the real error from summaryError and use the case of SummaryError to display a summary of plugins that failed\n error = summaryError.cause as Error\n }\n\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel, prefixText: pc.red(originalError?.message) })\n\n if (error instanceof Warning) {\n spinner.warn(pc.yellow(error.message))\n process.exit(0)\n }\n\n if (canLogHierarchy(CLIOptions.logLevel, LogLevel.silent)) {\n spinner.fail(message)\n process.exit(1)\n }\n\n spinner.fail([message, ...(summaryError?.summary || [])].join('\\n'))\n process.exit(1)\n}\n\nexport async function createProgram(argv?: string[]): Promise<CAC> {\n const program = cac(moduleName)\n\n const programAction = async (input: string, options: CLIOptions) => {\n try {\n // CONFIG\n spinner.start('💾 Loading config')\n const result = await getCosmiConfig(moduleName, options.config)\n spinner.succeed(`💾 Config loaded(${pc.dim(pathParser.relative(process.cwd(), result.filepath))})`)\n // END CONFIG\n\n if (options.watch) {\n const config = await getConfig(result, options)\n\n return startWatcher([input || config.input.path], async (paths) => {\n await run({ config, CLIOptions: options })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n\n const config = await getConfig(result, options)\n\n await run({ input, config, CLIOptions: options })\n } catch (e) {\n programCatcher(e, options)\n }\n }\n\n program.command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)').action(programAction)\n\n program\n .command('generate [input]', 'Path of the input file(overrides the one in `kubb.config.js`)')\n .option('-c, --config <path>', 'Path to the Kubb config')\n .option('-l, --log-level <type>', 'Type of the logging(overrides the one in `kubb.config.js`)')\n .option('-d, --debug', 'Debug mode', { default: false })\n .option('-w, --watch', 'Watch mode based on the input file')\n .action(programAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n\n program.on('command:*', () => {\n console.log(prettyError.render(`Invalid command: ${program.args.join(' ')}`))\n\n process.exit(1)\n })\n\n try {\n program.parse(argv, { run: false })\n\n await program.runMatchedCommand()\n } catch (e) {\n const error = e as Error\n\n console.log(\n renderErrors(new Error(error.message, { cause: undefined }), {\n logLevel: 'info',\n prefixText: pc.red('Something went wrong with processing the CLI\\n'),\n })\n )\n\n process.exit(1)\n }\n\n return program\n}\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"1.2.2\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-project/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rimraf ./dist\",\n \"lint\": \"ESLINT_USE_FLAT_CONFIG=true eslint --format pretty .\",\n \"lint-fix\": \"bun run lint --quiet --fix\",\n \"release\": \"pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@swc/core\": \"^1.3.64\",\n \"chokidar\": \"^3.5.3\",\n \"cac\": \"^6.7.14\",\n \"cosmiconfig\": \"^8.2.0\",\n \"execa\": \"^7.1.1\",\n \"ora\": \"^6.3.1\",\n \"picocolors\": \"^1.0.0\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"ts-node\": \"^10.9.1\",\n \"yaml\": \"^2.3.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.3.1\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^7.0.0\",\n \"typescript\": \"^5.1.3\"\n },\n \"packageManager\": \"pnpm@8.3.0\",\n \"engines\": {\n \"node\": \">=18\",\n \"pnpm\": \">=8.3.0\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import pathParser from 'node:path'\n\nimport { LogLevel, isPromiseFulfilledResult, write, canLogHierarchy } from '@kubb/core'\n\nimport { $ } from 'execa'\nimport pc from 'picocolors'\n\nimport type { LogLevels } from '@kubb/core'\nimport { spinner } from './program.ts'\n\nexport type Preset = 'simple'\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn'\n\nexport type PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype RunProps = {\n /**\n * @default `'silent'`\n */\n logLevel?: LogLevels\n /**\n * @default `'simple'`\n */\n preset?: Preset\n /**\n * @default `'pnpm'`\n */\n packageManager?: PackageManager\n}\n\nconst presets: Record<Preset, PresetMeta> = {\n simple: {\n 'kubb.config': `\nimport { defineConfig } from '@kubb/core'\nimport createSwagger from '@kubb/swagger'\nimport createSwaggerTS from '@kubb/swagger-ts'\nimport createSwaggerTanstackQuery from '@kubb/swagger-tanstack-query'\n\nexport default defineConfig({\n root: '.',\n input: {\n path: 'https://petstore3.swagger.io/api/v3/openapi.json',\n },\n output: {\n path: './src/gen',\n clean: true,\n },\n hooks: {\n done: 'echo \"🎉 done\"',\n },\n logLevel: 'info',\n plugins: [createSwagger({}), createSwaggerTS({ output: 'models', enumType: 'enum' }), createSwaggerTanstackQuery({ output: './hooks' })],\n})\n `,\n packages: ['@kubb/core', '@kubb/cli', '@kubb/swagger', '@kubb/swagger-ts', '@kubb/swagger-tanstack-query'],\n },\n}\n\nexport async function init({ preset = 'simple', logLevel = LogLevel.silent, packageManager = 'pnpm' }: RunProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const path = pathParser.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${pc.dim(path)}`)\n await write(presetMeta['kubb.config'], path)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${pc.dim(path)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${pc.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${pc.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (canLogHierarchy(logLevel, LogLevel.info)) {\n results.forEach((result) => {\n if (isPromiseFulfilledResult(result)) {\n console.log(result.value)\n }\n })\n }\n spinner.succeed(`📦 initialized Kubb`)\n\n return\n}\n","import pathParser from 'node:path'\n\nimport { build, ParallelPluginError, PluginError, SummaryError, timeout, createLogger, randomPicoColour, LogLevel, canLogHierarchy } from '@kubb/core'\n\nimport type { ExecaReturnValue } from 'execa'\n\nimport { performance, PerformanceObserver } from 'node:perf_hooks'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\n\nimport { parseArgsStringToArgv } from 'string-argv'\n\nimport { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'\nimport { parseText } from './utils/parseText.ts'\n\nimport type { BuildOutput, CLIOptions, KubbConfig, LogLevels } from '@kubb/core'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './program.ts'\n\ntype RunProps = {\n input?: string\n config: KubbConfig\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: KubbConfig['hooks']\n logLevel: LogLevels\n debug?: boolean\n}\n\nasync function executeHooks({ hooks, logLevel }: ExecutingHooksProps): Promise<void> {\n if (!hooks?.done) {\n return\n }\n\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done]\n\n if (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.start(`Executing hooks`)\n }\n type Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\n\n const executers: Promise<Executer>[] = commands.map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n spinner.start(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable)\n spinner.suffixText = ''\n\n if (canLogHierarchy(logLevel, LogLevel.info)) {\n spinner.succeed(parseText(`Executing hook`, { info: ` ${pc.dim(command)}` }, logLevel))\n\n console.log(subProcess.stdout)\n }\n\n // wait for 100ms to be sure that all open files are close(fs)\n await timeout(100)\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n\n await Promise.all(executers)\n\n if (canLogHierarchy(logLevel, LogLevel.silent)) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\ntype SummaryProps = {\n pluginManager: BuildOutput['pluginManager']\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: KubbConfig\n logLevel?: LogLevels\n}\n\nfunction getSummary({ pluginManager, status, hrstart, config, logLevel }: SummaryProps): string[] {\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = [\n ...new Set(pluginManager.executed.filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core').map((item) => item.plugin.name)),\n ]\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildStartPlugins.includes(plugin.name))?.map((plugin) => plugin.name)\n const pluginsCount = config.plugins?.length || 0\n const files = pluginManager.fileManager.files.sort((a, b) => {\n if (!a.meta?.pluginName || !b.meta?.pluginName) {\n return 0\n }\n if (a.meta?.pluginName.length < b.meta?.pluginName.length) {\n return 1\n }\n if (a.meta?.pluginName.length > b.meta?.pluginName.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${pc.red(`${failedPlugins?.length || 0} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomPicoColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: pc.yellow(`${elapsedSeconds}s`),\n output: pathParser.resolve(config.root, config.output.path),\n } as const\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n logs.push(pc.bold('Generated files:\\n'))\n logs.push(files.map((file) => `${randomPicoColour(file.meta?.pluginName)} ${file.path}`).join('\\n'))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${pc.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${pc.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${pc.bold('Time:')} ${meta.time}`, true],\n [` ${pc.bold('Output:')} ${meta.output}`, true],\n [`\\n`, true],\n ]\n .map((item) => {\n if (item.at(1)) {\n return item.at(0)\n }\n return undefined\n })\n .filter(Boolean)\n .join('\\n')\n )\n\n return logs\n}\n\nexport async function run({ input, config, CLIOptions }: RunProps): Promise<void> {\n const hrstart = process.hrtime()\n const logger = createLogger(spinner)\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0].duration.toFixed(0)}ms`\n\n spinner.suffixText = pc.yellow(message)\n\n performance.clearMarks()\n })\n\n if (CLIOptions.debug) {\n performanceOpserver.observe({ type: 'measure' })\n }\n\n try {\n const { root: _root, ...userConfig } = config\n const logLevel = CLIOptions.logLevel ?? userConfig.logLevel ?? LogLevel.silent\n const inputPath = input ?? userConfig.input.path\n\n spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n const output = await build({\n config: {\n root: process.cwd(),\n ...userConfig,\n logLevel,\n input: {\n ...userConfig.input,\n path: inputPath,\n },\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n debug: CLIOptions.debug,\n })\n\n spinner.suffixText = ''\n spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))\n\n await timeout(100)\n await executeHooks({ hooks: config.hooks, logLevel, debug: CLIOptions.debug })\n\n const summary = getSummary({ pluginManager: output.pluginManager, config, status: 'success', hrstart, logLevel: CLIOptions.logLevel })\n console.log(summary.join(''))\n } catch (error) {\n let summary: string[] = []\n\n if (error instanceof PluginError || error instanceof ParallelPluginError) {\n summary = getSummary({ pluginManager: error.pluginManager, config, status: 'failed', hrstart, logLevel: CLIOptions.logLevel })\n }\n\n throw new SummaryError('Something went wrong\\n', { cause: error as Error, summary })\n }\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import { LogLevel } from '@kubb/core'\nimport type { LogLevels } from '@kubb/core'\n\nexport function parseText(baseText: string, config: Partial<Record<LogLevels, string>>, logLevel: LogLevels = LogLevel.silent): string {\n return `${baseText}${config[logLevel] || ''}`\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/restrict-template-expressions */\nimport type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { Ora } from 'ora'\nimport pc from 'picocolors'\n\nexport class OraWritable extends Writable {\n public command: string\n public spinner: Ora\n constructor(spinner: Ora, command: string, opts?: WritableOptions) {\n super(opts)\n\n this.command = command\n this.spinner = spinner\n }\n _write(chunk: any, _encoding: NodeJS.BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${pc.bold(pc.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import { isPromise } from '@kubb/core'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, KubbConfig, KubbUserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from '../types.ts'\n\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<KubbConfig> {\n const config = result?.config\n let kubbUserConfig: Promise<KubbUserConfig> = Promise.resolve(config) as Promise<KubbUserConfig>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(CLIOptions)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as KubbConfig\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\n\nimport { importModule } from '@kubb/core'\n\nimport type { KubbJSONPlugins, KubbObjectPlugin, KubbUserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbJSONPlugins[] {\n return !!(plugins as KubbJSONPlugins[])?.some((plugin) => {\n return typeof plugin?.[0] === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[]): plugins is KubbObjectPlugin {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<KubbUserConfig['plugins']> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await importModule(name, process.cwd())\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: KubbUserConfig['plugins'] | KubbJSONPlugins[] | KubbObjectPlugin[]): Promise<KubbUserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n const promises = Object.keys(plugins).map((name) => {\n return importPlugin(name, plugins[name as keyof typeof plugins])\n })\n return Promise.all(promises)\n }\n\n if (isJSONPlugins(plugins)) {\n const promises = plugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises)\n }\n\n return Promise.resolve(plugins)\n}\n","import pc from 'picocolors'\n\nimport { spinner } from '../program'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\n\n const ignored = ['**/{.git,node_modules}/**']\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n spinner.succeed(pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(pc.red('Watcher failed'))\n }\n })\n\n return\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\nimport { importModule } from '@kubb/core'\n\nimport { cosmiconfig } from 'cosmiconfig'\nimport tsNode from 'ts-node'\nimport yaml from 'yaml'\n\nimport type { CosmiconfigResult } from '../types.ts'\n\nconst jsLoader = async (configFile: string) => {\n return importModule(configFile)\n}\n// TODO fix tsLoader for node 20 when using ESM only\n// https://github.com/TypeStrong/ts-node/issues/1997\nconst tsLoader = (configFile: string) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n let registerer = { enabled() {} }\n\n try {\n // Register TypeScript compiler instance\n registerer = tsNode.register({\n compilerOptions: { module: 'commonjs' },\n swc: true,\n typeCheck: false,\n })\n\n const module = require(configFile)\n\n return module.default\n } catch (err) {\n const error = err as Error\n\n if (error.name === 'MODULE_NOT_FOUND') {\n throw new Error(`'ts-node' is required for the TypeScript configuration files. Make sure it is installed\\nError: ${error.message}`)\n }\n\n throw error\n } finally {\n registerer.enabled()\n }\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.cjs`,\n `.${moduleName}rc.mjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.cjs`,\n `${moduleName}.config.mjs`,\n ],\n loaders: {\n '.yaml': (filepath, content) => yaml.parse(content),\n '.yml': (filepath, content) => yaml.parse(content),\n '.js': jsLoader,\n '.cjs': jsLoader,\n '.mjs': jsLoader,\n '.ts': tsLoader,\n noExt: jsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LogLevels } from '@kubb/core'\nimport { LogLevel, ParallelPluginError, canLogHierarchy } from '@kubb/core'\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function (traceLine: any) {\n // exclude renderErrors.ts\n const pattern = new RegExp('renderErrors')\n\n const hasMatch = traceLine?.file?.match(pattern)\n\n if (typeof traceLine.packageName !== 'undefined' && hasMatch) {\n return true\n }\n } as PrettyError.Callback)\n .start()\n\nfunction getErrorCauses(errors: Error[]): string[] {\n return errors\n .reduce((prev, error) => {\n const causedError = error?.cause as Error\n if (causedError) {\n prev = [...prev, ...getErrorCauses([causedError])]\n }\n prev = [...prev, prettyError.render(error)]\n\n return prev\n }, [] as string[])\n .filter(Boolean)\n}\n\nexport function renderErrors(error: Error | undefined, { prefixText, logLevel = LogLevel.silent }: { prefixText?: string; logLevel?: LogLevels }): string {\n if (!error) {\n return ''\n }\n\n if (error instanceof ParallelPluginError) {\n return [prefixText, ...error.errors.map((e) => renderErrors(e, { logLevel }))].filter(Boolean).join('\\n')\n }\n\n if (canLogHierarchy(logLevel, 'stacktrace')) {\n const errors = getErrorCauses([error])\n\n return [prefixText, ...errors].filter(Boolean).join('\\n')\n }\n\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function () {\n return true\n } as PrettyError.Callback)\n\n return [prefixText, prettyError.render(error.message)].filter(Boolean).join('\\n')\n}\n","import { createProgram } from './program.ts'\n\nexport default async function runCLI(argv?: string[]): Promise<void> {\n await createProgram(argv)\n}\n"]}
|