@kubb/cli 2.6.6 → 2.7.0
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 +139 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -48
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/utils/getCosmiConfig.ts +2 -0
package/dist/index.cjs
CHANGED
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var core = require('@kubb/core');
|
|
7
|
-
var cac = require('cac');
|
|
8
|
-
var c2 = require('tinyrainbow');
|
|
9
|
-
var utils = require('@kubb/core/utils');
|
|
10
|
-
var bundleRequire = require('bundle-require');
|
|
11
|
-
var cosmiconfig = require('cosmiconfig');
|
|
12
|
-
var logger = require('@kubb/core/logger');
|
|
13
|
-
var PrettyError = require('pretty-error');
|
|
14
|
-
var ora = require('ora');
|
|
15
|
-
var execa = require('execa');
|
|
16
|
-
var stringArgv = require('string-argv');
|
|
17
|
-
var stream = require('stream');
|
|
18
|
-
var fs = require('@kubb/core/fs');
|
|
19
|
-
|
|
20
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
|
|
22
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
23
|
-
var c2__default = /*#__PURE__*/_interopDefault(c2);
|
|
24
|
-
var PrettyError__default = /*#__PURE__*/_interopDefault(PrettyError);
|
|
25
|
-
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
26
|
-
|
|
27
|
-
// src/index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/index.ts
|
|
2
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
3
|
+
var _core = require('@kubb/core');
|
|
4
|
+
var _cac = require('cac');
|
|
5
|
+
var _tinyrainbow = require('tinyrainbow'); var _tinyrainbow2 = _interopRequireDefault(_tinyrainbow);
|
|
28
6
|
|
|
29
7
|
// package.json
|
|
30
|
-
var version = "2.
|
|
8
|
+
var version = "2.7.0";
|
|
9
|
+
|
|
10
|
+
// src/utils/getConfig.ts
|
|
11
|
+
var _utils = require('@kubb/core/utils');
|
|
12
|
+
|
|
13
|
+
// src/utils/getPlugins.ts
|
|
14
|
+
|
|
31
15
|
function isJSONPlugins(plugins) {
|
|
32
|
-
return !!plugins
|
|
33
|
-
return Array.isArray(plugin) && typeof plugin
|
|
34
|
-
});
|
|
16
|
+
return !!_optionalChain([plugins, 'optionalAccess', _ => _.some, 'call', _2 => _2((plugin) => {
|
|
17
|
+
return Array.isArray(plugin) && typeof _optionalChain([plugin, 'optionalAccess', _3 => _3.at, 'call', _4 => _4(0)]) === "string";
|
|
18
|
+
})]);
|
|
35
19
|
}
|
|
36
20
|
function isObjectPlugins(plugins) {
|
|
37
21
|
return plugins instanceof Object && !Array.isArray(plugins);
|
|
38
22
|
}
|
|
39
23
|
async function importPlugin(name, options) {
|
|
40
|
-
const packageManager = new
|
|
41
|
-
const importedPlugin = process.env.NODE_ENV === "test" ? await
|
|
42
|
-
return importedPlugin
|
|
24
|
+
const packageManager = new (0, _core.PackageManager)(process.cwd());
|
|
25
|
+
const importedPlugin = process.env.NODE_ENV === "test" ? await Promise.resolve().then(() => _interopRequireWildcard(require(name))) : await packageManager.import(name);
|
|
26
|
+
return _optionalChain([importedPlugin, 'optionalAccess', _5 => _5.default]) ? importedPlugin.default(options) : importedPlugin(options);
|
|
43
27
|
}
|
|
44
28
|
function getPlugins(plugins) {
|
|
45
29
|
if (isObjectPlugins(plugins)) {
|
|
@@ -58,11 +42,11 @@ function getPlugins(plugins) {
|
|
|
58
42
|
|
|
59
43
|
// src/utils/getConfig.ts
|
|
60
44
|
async function getConfig(result, CLIOptions) {
|
|
61
|
-
const config = result
|
|
45
|
+
const config = _optionalChain([result, 'optionalAccess', _6 => _6.config]);
|
|
62
46
|
let kubbUserConfig = Promise.resolve(config);
|
|
63
47
|
if (typeof config === "function") {
|
|
64
48
|
const possiblePromise = config(CLIOptions);
|
|
65
|
-
if (
|
|
49
|
+
if (_utils.isPromise.call(void 0, possiblePromise)) {
|
|
66
50
|
kubbUserConfig = possiblePromise;
|
|
67
51
|
}
|
|
68
52
|
kubbUserConfig = Promise.resolve(possiblePromise);
|
|
@@ -80,9 +64,15 @@ async function getConfig(result, CLIOptions) {
|
|
|
80
64
|
};
|
|
81
65
|
return JSONConfig;
|
|
82
66
|
}
|
|
67
|
+
|
|
68
|
+
// src/utils/getCosmiConfig.ts
|
|
69
|
+
var _bundlerequire = require('bundle-require');
|
|
70
|
+
var _cosmiconfig = require('cosmiconfig');
|
|
83
71
|
var tsLoader = async (configFile) => {
|
|
84
|
-
const { mod } = await bundleRequire.
|
|
85
|
-
filepath: configFile
|
|
72
|
+
const { mod } = await _bundlerequire.bundleRequire.call(void 0, {
|
|
73
|
+
filepath: configFile,
|
|
74
|
+
// makes it possible to use React and hooks
|
|
75
|
+
format: "cjs"
|
|
86
76
|
});
|
|
87
77
|
return mod.default;
|
|
88
78
|
};
|
|
@@ -102,7 +92,7 @@ async function getCosmiConfig(moduleName2, config) {
|
|
|
102
92
|
`${moduleName2}.config.mjs`,
|
|
103
93
|
`${moduleName2}.config.cjs`
|
|
104
94
|
];
|
|
105
|
-
const explorer = cosmiconfig.
|
|
95
|
+
const explorer = _cosmiconfig.cosmiconfig.call(void 0, moduleName2, {
|
|
106
96
|
cache: false,
|
|
107
97
|
searchPlaces: [
|
|
108
98
|
...searchPlaces.map((searchPlace) => {
|
|
@@ -118,21 +108,25 @@ async function getCosmiConfig(moduleName2, config) {
|
|
|
118
108
|
}
|
|
119
109
|
});
|
|
120
110
|
const result = config ? await explorer.load(config) : await explorer.search();
|
|
121
|
-
if (result
|
|
111
|
+
if (_optionalChain([result, 'optionalAccess', _7 => _7.isEmpty]) || !result || !result.config) {
|
|
122
112
|
throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
|
|
123
113
|
}
|
|
124
114
|
return result;
|
|
125
115
|
}
|
|
126
|
-
|
|
116
|
+
|
|
117
|
+
// src/utils/renderErrors.ts
|
|
118
|
+
var _logger = require('@kubb/core/logger');
|
|
119
|
+
var _prettyerror = require('pretty-error'); var _prettyerror2 = _interopRequireDefault(_prettyerror);
|
|
120
|
+
var prettyError = new (0, _prettyerror2.default)().skipPackage("commander").skip(function callback(traceLine) {
|
|
127
121
|
const pattern = new RegExp("renderErrors");
|
|
128
|
-
const hasMatch = traceLine
|
|
122
|
+
const hasMatch = _optionalChain([traceLine, 'optionalAccess', _8 => _8.file, 'optionalAccess', _9 => _9.match, 'call', _10 => _10(pattern)]);
|
|
129
123
|
if (typeof traceLine.packageName !== "undefined" && hasMatch) {
|
|
130
124
|
return true;
|
|
131
125
|
}
|
|
132
126
|
}).start();
|
|
133
127
|
function getErrorCauses(errors) {
|
|
134
128
|
return errors.reduce((prev, error) => {
|
|
135
|
-
const causedError = error
|
|
129
|
+
const causedError = _optionalChain([error, 'optionalAccess', _11 => _11.cause]);
|
|
136
130
|
if (causedError) {
|
|
137
131
|
prev = [...prev, ...getErrorCauses([causedError])];
|
|
138
132
|
}
|
|
@@ -140,11 +134,11 @@ function getErrorCauses(errors) {
|
|
|
140
134
|
return prev;
|
|
141
135
|
}, []).filter(Boolean);
|
|
142
136
|
}
|
|
143
|
-
function renderErrors(error, { logLevel =
|
|
137
|
+
function renderErrors(error, { logLevel = _logger.LogLevel.silent }) {
|
|
144
138
|
if (!error) {
|
|
145
139
|
return "";
|
|
146
140
|
}
|
|
147
|
-
if (logLevel ===
|
|
141
|
+
if (logLevel === _logger.LogLevel.silent) {
|
|
148
142
|
prettyError.skipNodeFiles();
|
|
149
143
|
prettyError.skip(function skip() {
|
|
150
144
|
return true;
|
|
@@ -154,28 +148,46 @@ function renderErrors(error, { logLevel = logger.LogLevel.silent }) {
|
|
|
154
148
|
const errors = getErrorCauses([error]);
|
|
155
149
|
return errors.filter(Boolean).join("\n");
|
|
156
150
|
}
|
|
157
|
-
|
|
151
|
+
|
|
152
|
+
// src/utils/spinner.ts
|
|
153
|
+
var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
154
|
+
var spinner = _ora2.default.call(void 0, {
|
|
158
155
|
spinner: "clock"
|
|
159
156
|
});
|
|
157
|
+
|
|
158
|
+
// src/utils/watcher.ts
|
|
159
|
+
|
|
160
160
|
async function startWatcher(path4, cb) {
|
|
161
|
-
const { watch } = await
|
|
161
|
+
const { watch } = await Promise.resolve().then(() => _interopRequireWildcard(require("chokidar")));
|
|
162
162
|
const ignored = ["**/{.git,node_modules}/**"];
|
|
163
163
|
const watcher = watch(path4, {
|
|
164
164
|
ignorePermissionErrors: true,
|
|
165
165
|
ignored
|
|
166
166
|
});
|
|
167
167
|
watcher.on("all", (type, file) => {
|
|
168
|
-
spinner.succeed(
|
|
168
|
+
spinner.succeed(_tinyrainbow2.default.yellow(_tinyrainbow2.default.bold(`Change detected: ${type} ${file}`)));
|
|
169
169
|
spinner.spinner = "clock";
|
|
170
170
|
try {
|
|
171
171
|
cb(path4);
|
|
172
172
|
} catch (e) {
|
|
173
|
-
spinner.warn(
|
|
173
|
+
spinner.warn(_tinyrainbow2.default.red("Watcher failed"));
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
// src/generate.ts
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
var _execa = require('execa');
|
|
183
|
+
var _stringargv = require('string-argv');
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
// src/utils/getSummary.ts
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
179
191
|
// src/utils/parseHrtimeToSeconds.ts
|
|
180
192
|
function parseHrtimeToSeconds(hrtime) {
|
|
181
193
|
const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
|
|
@@ -183,48 +195,48 @@ function parseHrtimeToSeconds(hrtime) {
|
|
|
183
195
|
}
|
|
184
196
|
|
|
185
197
|
// src/utils/getSummary.ts
|
|
186
|
-
function getSummary({ pluginManager, status, hrstart, config, logger
|
|
187
|
-
const { logLevel } = logger
|
|
198
|
+
function getSummary({ pluginManager, status, hrstart, config, logger }) {
|
|
199
|
+
const { logLevel } = logger;
|
|
188
200
|
const logs = [];
|
|
189
201
|
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart));
|
|
190
202
|
const buildStartPlugins = pluginManager.executed.filter((item) => item.hookName === "buildStart" && item.plugin.name !== "core").map((item) => item.plugin.name);
|
|
191
203
|
const buildEndPlugins = pluginManager.executed.filter((item) => item.hookName === "buildEnd" && item.plugin.name !== "core").map((item) => item.plugin.name);
|
|
192
|
-
const failedPlugins = config.plugins
|
|
193
|
-
const pluginsCount = config.plugins
|
|
204
|
+
const failedPlugins = _optionalChain([config, 'access', _12 => _12.plugins, 'optionalAccess', _13 => _13.filter, 'call', _14 => _14((plugin) => !buildEndPlugins.includes(plugin.name)), 'optionalAccess', _15 => _15.map, 'call', _16 => _16((plugin) => plugin.name)]);
|
|
205
|
+
const pluginsCount = _optionalChain([config, 'access', _17 => _17.plugins, 'optionalAccess', _18 => _18.length]) || 0;
|
|
194
206
|
const files = pluginManager.fileManager.files.sort((a, b) => {
|
|
195
|
-
if (!a.meta
|
|
207
|
+
if (!_optionalChain([a, 'access', _19 => _19.meta, 'optionalAccess', _20 => _20.pluginKey, 'optionalAccess', _21 => _21[0]]) || !_optionalChain([b, 'access', _22 => _22.meta, 'optionalAccess', _23 => _23.pluginKey, 'optionalAccess', _24 => _24[0]])) {
|
|
196
208
|
return 0;
|
|
197
209
|
}
|
|
198
|
-
if (a.meta
|
|
210
|
+
if (_optionalChain([a, 'access', _25 => _25.meta, 'optionalAccess', _26 => _26.pluginKey, 'optionalAccess', _27 => _27[0], 'optionalAccess', _28 => _28.length]) < _optionalChain([b, 'access', _29 => _29.meta, 'optionalAccess', _30 => _30.pluginKey, 'optionalAccess', _31 => _31[0], 'optionalAccess', _32 => _32.length])) {
|
|
199
211
|
return 1;
|
|
200
212
|
}
|
|
201
|
-
if (a.meta
|
|
213
|
+
if (_optionalChain([a, 'access', _33 => _33.meta, 'optionalAccess', _34 => _34.pluginKey, 'optionalAccess', _35 => _35[0], 'optionalAccess', _36 => _36.length]) > _optionalChain([b, 'access', _37 => _37.meta, 'optionalAccess', _38 => _38.pluginKey, 'optionalAccess', _39 => _39[0], 'optionalAccess', _40 => _40.length])) {
|
|
202
214
|
return -1;
|
|
203
215
|
}
|
|
204
216
|
return 0;
|
|
205
217
|
});
|
|
206
218
|
const meta = {
|
|
207
219
|
name: config.name,
|
|
208
|
-
plugins: status === "success" ? `${
|
|
209
|
-
pluginsFailed: status === "failed" ? failedPlugins
|
|
220
|
+
plugins: status === "success" ? `${_tinyrainbow2.default.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total` : `${_tinyrainbow2.default.red(`${_nullishCoalesce(_optionalChain([failedPlugins, 'optionalAccess', _41 => _41.length]), () => ( 1))} failed`)}, ${pluginsCount} total`,
|
|
221
|
+
pluginsFailed: status === "failed" ? _optionalChain([failedPlugins, 'optionalAccess', _42 => _42.map, 'call', _43 => _43((name) => _logger.randomCliColour.call(void 0, name)), 'optionalAccess', _44 => _44.join, 'call', _45 => _45(", ")]) : void 0,
|
|
210
222
|
filesCreated: files.length,
|
|
211
|
-
time:
|
|
212
|
-
output:
|
|
223
|
+
time: _tinyrainbow2.default.yellow(`${elapsedSeconds}s`),
|
|
224
|
+
output: _path2.default.resolve(config.root, config.output.path)
|
|
213
225
|
};
|
|
214
|
-
if (logLevel ===
|
|
215
|
-
logger
|
|
216
|
-
logger
|
|
226
|
+
if (logLevel === _logger.LogLevel.debug) {
|
|
227
|
+
logger.emit("debug", ["\nGenerated files:\n"]);
|
|
228
|
+
logger.emit("debug", files.map((file) => `${_logger.randomCliColour.call(void 0, JSON.stringify(_optionalChain([file, 'access', _46 => _46.meta, 'optionalAccess', _47 => _47.pluginKey])))} ${file.path}`));
|
|
217
229
|
}
|
|
218
230
|
logs.push(
|
|
219
231
|
[
|
|
220
232
|
[`
|
|
221
233
|
`, true],
|
|
222
|
-
[` ${
|
|
223
|
-
[` ${
|
|
224
|
-
[` ${
|
|
225
|
-
[`${
|
|
226
|
-
[` ${
|
|
227
|
-
[` ${
|
|
234
|
+
[` ${_tinyrainbow2.default.bold("Name:")} ${meta.name}`, !!meta.name],
|
|
235
|
+
[` ${_tinyrainbow2.default.bold("Plugins:")} ${meta.plugins}`, true],
|
|
236
|
+
[` ${_tinyrainbow2.default.dim("Failed:")} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
|
|
237
|
+
[`${_tinyrainbow2.default.bold("Generated:")} ${meta.filesCreated} files`, true],
|
|
238
|
+
[` ${_tinyrainbow2.default.bold("Time:")} ${meta.time}`, true],
|
|
239
|
+
[` ${_tinyrainbow2.default.bold("Output:")} ${meta.output}`, true],
|
|
228
240
|
[`
|
|
229
241
|
`, true]
|
|
230
242
|
].map((item) => {
|
|
@@ -236,7 +248,11 @@ function getSummary({ pluginManager, status, hrstart, config, logger: logger$1 }
|
|
|
236
248
|
);
|
|
237
249
|
return logs;
|
|
238
250
|
}
|
|
239
|
-
|
|
251
|
+
|
|
252
|
+
// src/utils/OraWritable.ts
|
|
253
|
+
var _stream = require('stream');
|
|
254
|
+
|
|
255
|
+
var OraWritable = class extends _stream.Writable {
|
|
240
256
|
constructor(spinner2, command, opts) {
|
|
241
257
|
super(opts);
|
|
242
258
|
this.command = command;
|
|
@@ -245,62 +261,62 @@ var OraWritable = class extends stream.Writable {
|
|
|
245
261
|
_write(chunk, _encoding, callback2) {
|
|
246
262
|
this.spinner.suffixText = `
|
|
247
263
|
|
|
248
|
-
${
|
|
264
|
+
${_tinyrainbow2.default.bold(_tinyrainbow2.default.blue(this.command))}: ${_optionalChain([chunk, 'optionalAccess', _48 => _48.toString, 'call', _49 => _49()])}`;
|
|
249
265
|
callback2();
|
|
250
266
|
}
|
|
251
267
|
};
|
|
252
268
|
|
|
253
269
|
// src/generate.ts
|
|
254
270
|
async function executeHooks({ hooks, logLevel }) {
|
|
255
|
-
if (!hooks
|
|
271
|
+
if (!_optionalChain([hooks, 'optionalAccess', _50 => _50.done])) {
|
|
256
272
|
return;
|
|
257
273
|
}
|
|
258
274
|
const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
|
|
259
|
-
if (logLevel ===
|
|
275
|
+
if (logLevel === _logger.LogLevel.silent) {
|
|
260
276
|
spinner.start(`Executing hooks`);
|
|
261
277
|
}
|
|
262
278
|
const executers = commands.map(async (command) => {
|
|
263
279
|
const oraWritable = new OraWritable(spinner, command);
|
|
264
280
|
const abortController = new AbortController();
|
|
265
|
-
const [cmd, ..._args] = [...
|
|
281
|
+
const [cmd, ..._args] = [..._stringargv.parseArgsStringToArgv.call(void 0, command)];
|
|
266
282
|
if (!cmd) {
|
|
267
283
|
return null;
|
|
268
284
|
}
|
|
269
|
-
spinner.start(`Executing hook ${logLevel !== "silent" ?
|
|
270
|
-
const subProcess = await execa.
|
|
285
|
+
spinner.start(`Executing hook ${logLevel !== "silent" ? _tinyrainbow2.default.dim(command) : ""}`);
|
|
286
|
+
const subProcess = await _execa.execa.call(void 0, cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
|
|
271
287
|
spinner.suffixText = "";
|
|
272
|
-
if (logLevel ===
|
|
273
|
-
spinner.succeed(`Executing hook ${logLevel !== "silent" ?
|
|
288
|
+
if (logLevel === _logger.LogLevel.silent) {
|
|
289
|
+
spinner.succeed(`Executing hook ${logLevel !== "silent" ? _tinyrainbow2.default.dim(command) : ""}`);
|
|
274
290
|
console.log(subProcess.stdout);
|
|
275
291
|
}
|
|
276
292
|
oraWritable.destroy();
|
|
277
293
|
return { subProcess, abort: abortController.abort.bind(abortController) };
|
|
278
294
|
}).filter(Boolean);
|
|
279
295
|
await Promise.all(executers);
|
|
280
|
-
if (logLevel ===
|
|
296
|
+
if (logLevel === _logger.LogLevel.silent) {
|
|
281
297
|
spinner.succeed(`Executing hooks`);
|
|
282
298
|
}
|
|
283
299
|
}
|
|
284
300
|
async function generate({ input, config, CLIOptions }) {
|
|
285
|
-
const logger
|
|
286
|
-
if (logger
|
|
287
|
-
spinner.prefixText =
|
|
301
|
+
const logger = _logger.createLogger.call(void 0, { logLevel: CLIOptions.logLevel || _logger.LogLevel.silent, name: config.name, spinner });
|
|
302
|
+
if (logger.name) {
|
|
303
|
+
spinner.prefixText = _logger.randomCliColour.call(void 0, logger.name);
|
|
288
304
|
}
|
|
289
305
|
const hrstart = process.hrtime();
|
|
290
|
-
if (CLIOptions.logLevel ===
|
|
291
|
-
const { performance, PerformanceObserver } = await
|
|
306
|
+
if (CLIOptions.logLevel === _logger.LogLevel.debug) {
|
|
307
|
+
const { performance, PerformanceObserver } = await Promise.resolve().then(() => _interopRequireWildcard(require("perf_hooks")));
|
|
292
308
|
const performanceOpserver = new PerformanceObserver((items) => {
|
|
293
|
-
const message = `${items.getEntries()[0]
|
|
294
|
-
spinner.suffixText =
|
|
309
|
+
const message = `${_optionalChain([items, 'access', _51 => _51.getEntries, 'call', _52 => _52(), 'access', _53 => _53[0], 'optionalAccess', _54 => _54.duration, 'access', _55 => _55.toFixed, 'call', _56 => _56(0)])}ms`;
|
|
310
|
+
spinner.suffixText = _tinyrainbow2.default.yellow(message);
|
|
295
311
|
performance.clearMarks();
|
|
296
312
|
});
|
|
297
313
|
performanceOpserver.observe({ type: "measure" });
|
|
298
314
|
}
|
|
299
315
|
const { root: _root, ...userConfig } = config;
|
|
300
|
-
const logLevel = logger
|
|
301
|
-
const inputPath = input
|
|
302
|
-
spinner.start(`\u{1F680} Building ${logLevel !== "silent" ?
|
|
303
|
-
const { pluginManager, error } = await
|
|
316
|
+
const logLevel = logger.logLevel;
|
|
317
|
+
const inputPath = _nullishCoalesce(input, () => ( ("path" in userConfig.input ? userConfig.input.path : void 0)));
|
|
318
|
+
spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? _tinyrainbow2.default.dim(inputPath) : ""}`);
|
|
319
|
+
const { pluginManager, error } = await _core.safeBuild.call(void 0, {
|
|
304
320
|
config: {
|
|
305
321
|
root: process.cwd(),
|
|
306
322
|
...userConfig,
|
|
@@ -313,20 +329,28 @@ async function generate({ input, config, CLIOptions }) {
|
|
|
313
329
|
...userConfig.output
|
|
314
330
|
}
|
|
315
331
|
},
|
|
316
|
-
logger
|
|
332
|
+
logger
|
|
317
333
|
});
|
|
318
|
-
const summary = getSummary({ pluginManager, config, status: error ? "failed" : "success", hrstart, logger
|
|
334
|
+
const summary = getSummary({ pluginManager, config, status: error ? "failed" : "success", hrstart, logger });
|
|
319
335
|
if (error) {
|
|
320
336
|
spinner.suffixText = "";
|
|
321
|
-
spinner.fail(`\u{1F680} Build failed ${logLevel !== "silent" ?
|
|
337
|
+
spinner.fail(`\u{1F680} Build failed ${logLevel !== "silent" ? _tinyrainbow2.default.dim(inputPath) : ""}`);
|
|
322
338
|
console.log(summary.join(""));
|
|
323
339
|
throw error;
|
|
324
340
|
}
|
|
325
341
|
await executeHooks({ hooks: config.hooks, logLevel });
|
|
326
342
|
spinner.suffixText = "";
|
|
327
|
-
spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ?
|
|
343
|
+
spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? _tinyrainbow2.default.dim(inputPath) : ""}`);
|
|
328
344
|
console.log(summary.join(""));
|
|
329
345
|
}
|
|
346
|
+
|
|
347
|
+
// src/init.ts
|
|
348
|
+
|
|
349
|
+
var _fs = require('@kubb/core/fs');
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
330
354
|
var presets = {
|
|
331
355
|
simple: {
|
|
332
356
|
"kubb.config": `
|
|
@@ -353,26 +377,26 @@ export default defineConfig({
|
|
|
353
377
|
packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
|
|
354
378
|
}
|
|
355
379
|
};
|
|
356
|
-
async function init({ preset = "simple", logLevel =
|
|
380
|
+
async function init({ preset = "simple", logLevel = _logger.LogLevel.silent, packageManager = "pnpm" }) {
|
|
357
381
|
spinner.start("\u{1F4E6} Initializing Kubb");
|
|
358
382
|
const presetMeta = presets[preset];
|
|
359
|
-
const configPath =
|
|
383
|
+
const configPath = _path2.default.resolve(process.cwd(), "./kubb.config.js");
|
|
360
384
|
const installCommand = packageManager === "npm" ? "install" : "add";
|
|
361
|
-
spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${
|
|
362
|
-
await
|
|
363
|
-
spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${
|
|
385
|
+
spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${_tinyrainbow2.default.dim(configPath)}`);
|
|
386
|
+
await _fs.write.call(void 0, presetMeta["kubb.config"], configPath);
|
|
387
|
+
spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${_tinyrainbow2.default.dim(configPath)}`);
|
|
364
388
|
const results = await Promise.allSettled([
|
|
365
|
-
|
|
389
|
+
_execa.$`npm init es6 -y`,
|
|
366
390
|
...presetMeta.packages.map(async (pack) => {
|
|
367
|
-
spinner.start(`\u{1F4C0} Installing ${
|
|
368
|
-
const { stdout } = await
|
|
369
|
-
spinner.succeed(`\u{1F4C0} Installed ${
|
|
391
|
+
spinner.start(`\u{1F4C0} Installing ${_tinyrainbow2.default.dim(pack)}`);
|
|
392
|
+
const { stdout } = await _execa.$.call(void 0, { preferLocal: false })`${packageManager} ${installCommand} ${pack}`;
|
|
393
|
+
spinner.succeed(`\u{1F4C0} Installed ${_tinyrainbow2.default.dim(pack)}`);
|
|
370
394
|
return stdout;
|
|
371
395
|
})
|
|
372
396
|
]);
|
|
373
|
-
if (logLevel ===
|
|
397
|
+
if (logLevel === _logger.LogLevel.info) {
|
|
374
398
|
results.forEach((result) => {
|
|
375
|
-
if (
|
|
399
|
+
if (_utils.isPromiseFulfilledResult.call(void 0, result)) {
|
|
376
400
|
console.log(result.value);
|
|
377
401
|
}
|
|
378
402
|
});
|
|
@@ -386,8 +410,8 @@ var moduleName = "kubb";
|
|
|
386
410
|
function programCatcher(e, CLIOptions) {
|
|
387
411
|
const error = e;
|
|
388
412
|
const message = renderErrors(error, { logLevel: CLIOptions.logLevel });
|
|
389
|
-
if (error instanceof
|
|
390
|
-
spinner.warn(
|
|
413
|
+
if (error instanceof _core.Warning) {
|
|
414
|
+
spinner.warn(_tinyrainbow2.default.yellow(error.message));
|
|
391
415
|
process.exit(0);
|
|
392
416
|
}
|
|
393
417
|
spinner.fail(message);
|
|
@@ -396,22 +420,22 @@ function programCatcher(e, CLIOptions) {
|
|
|
396
420
|
async function generateAction(input, CLIOptions) {
|
|
397
421
|
spinner.start("\u{1F50D} Loading config");
|
|
398
422
|
const result = await getCosmiConfig(moduleName, CLIOptions.config);
|
|
399
|
-
spinner.succeed(`\u{1F50D} Config loaded(${
|
|
423
|
+
spinner.succeed(`\u{1F50D} Config loaded(${_tinyrainbow2.default.dim(_path2.default.relative(process.cwd(), result.filepath))})`);
|
|
400
424
|
const config = await getConfig(result, CLIOptions);
|
|
401
425
|
if (CLIOptions.watch) {
|
|
402
426
|
if (Array.isArray(config)) {
|
|
403
427
|
throw new Error("Cannot use watcher with multiple Configs(array)");
|
|
404
428
|
}
|
|
405
|
-
if (
|
|
429
|
+
if (_core.isInputPath.call(void 0, config)) {
|
|
406
430
|
return startWatcher([input || config.input.path], async (paths) => {
|
|
407
431
|
await generate({ config, CLIOptions });
|
|
408
432
|
spinner.spinner = "simpleDotsScrolling";
|
|
409
|
-
spinner.start(
|
|
433
|
+
spinner.start(_tinyrainbow2.default.yellow(_tinyrainbow2.default.bold(`Watching for changes in ${paths.join(" and ")}`)));
|
|
410
434
|
});
|
|
411
435
|
}
|
|
412
436
|
}
|
|
413
437
|
if (Array.isArray(config)) {
|
|
414
|
-
const promiseManager = new
|
|
438
|
+
const promiseManager = new (0, _core.PromiseManager)();
|
|
415
439
|
const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }));
|
|
416
440
|
await promiseManager.run("seq", promises);
|
|
417
441
|
return;
|
|
@@ -419,7 +443,7 @@ async function generateAction(input, CLIOptions) {
|
|
|
419
443
|
await generate({ input, config, CLIOptions });
|
|
420
444
|
}
|
|
421
445
|
async function run(argv) {
|
|
422
|
-
const program = cac.
|
|
446
|
+
const program = _cac.cac.call(void 0, moduleName);
|
|
423
447
|
program.command("[input]", "Path of the input file(overrides the one in `kubb.config.js`)").action(generateAction);
|
|
424
448
|
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>", "Info, silent or debug").option("-w, --watch", "Watch mode based on the input file").action(generateAction);
|
|
425
449
|
program.command("init", "Init Kubb").action(async () => {
|
|
@@ -437,7 +461,7 @@ async function run(argv) {
|
|
|
437
461
|
}
|
|
438
462
|
var src_default = run;
|
|
439
463
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
exports.default = src_default; exports.run = run;
|
|
443
467
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/utils/spinner.ts","../src/utils/watcher.ts","../src/generate.ts","../src/utils/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/OraWritable.ts","../src/init.ts"],"names":["path","c","moduleName","LogLevel","randomCliColour","spinner","callback"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,SAAS,aAAa,gBAAgB,eAAe;AAErD,SAAS,WAAW;AACpB,OAAOC,QAAO;;;ACHZ,cAAW;;;ACFb,SAAS,iBAAiB;;;ACE1B,SAAS,sBAAsB;AAI/B,SAAS,cAAc,SAAmF;AACxG,SAAO,CAAC,CAAE,SAAsD,KAAK,CAAC,WAAW;AAC/E,WAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,QAAQ,GAAG,CAAC,MAAM;AAAA,EAC3D,CAAC;AACH;AAEA,SAAS,gBAAgB,SAAgD;AACvE,SAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ,OAAO;AAC5D;AAEA,eAAe,aAAa,MAAc,SAAiD;AACzF,QAAM,iBAAiB,IAAI,eAAe,QAAQ,IAAI,CAAC;AAEvD,QAAM,iBAAsB,QAAQ,IAAI,aAAa,SAAS,MAAM,OAAO,QAAQ,MAAM,eAAe,OAAO,IAAI;AAGnH,SAAO,gBAAgB,UAAU,eAAe,QAAQ,OAAO,IAAI,eAAe,OAAO;AAC3F;AAEO,SAAS,WAAW,SAAgE;AACzF,MAAI,gBAAgB,OAAO,GAAG;AAC5B,UAAM,IAAI,MAAM,4FAA4F;AAAA,EAC9G;AAEA,MAAI,cAAc,OAAO,GAAG;AAC1B,UAAM,cAAc;AACpB,UAAM,WAAW,YAAY,IAAI,CAAC,WAAW;AAC3C,YAAM,CAAC,MAAM,UAAU,CAAC,CAAC,IAA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CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AACvB,UAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,MAAI;AACF,UAAM,QAAQ,kBAAkB;AAEhC,YAAQ,KAAK,CAAC;AAAA,EAChB,SAAS,GAAG;AACV,mBAAe,GAAG,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ","sourcesContent":["import path from 'node:path'\n\nimport { isInputPath, PromiseManager, Warning } from '@kubb/core'\n\nimport { cac } from 'cac'\nimport c from 'tinyrainbow'\n\nimport { version } from '../package.json'\nimport { getConfig } from './utils/getConfig.ts'\nimport { getCosmiConfig } from './utils/getCosmiConfig.ts'\nimport { renderErrors } from './utils/renderErrors.ts'\nimport { spinner } from './utils/spinner.ts'\nimport { startWatcher } from './utils/watcher.ts'\nimport { generate } from './generate.ts'\nimport { init } from './init.ts'\n\nimport type { CLIOptions } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const error = e as Error\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel })\n\n if (error instanceof Warning) {\n spinner.warn(c.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail(message)\n process.exit(1)\n}\n\nasync function generateAction(input: string, CLIOptions: CLIOptions) {\n spinner.start('🔍 Loading config')\n const result = await getCosmiConfig(moduleName, CLIOptions.config)\n spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, CLIOptions)\n\n if (CLIOptions.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await generate({ config, CLIOptions })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(c.yellow(c.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }))\n\n await promiseManager.run('seq', promises)\n\n return\n }\n\n await generate({ input, config, CLIOptions })\n}\n\nexport async function run(argv?: string[]): Promise<void> {\n const program = cac(moduleName)\n\n program.command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)').action(generateAction)\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>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .action(generateAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n program.parse(argv, { run: false })\n\n try {\n await program.runMatchedCommand()\n\n process.exit(0)\n } catch (e) {\n programCatcher(e, program.options)\n }\n}\n\nexport default run\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.6.6\",\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.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx 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 \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && 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 \"bundle-require\": \"^4.0.2\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.6.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.19.12\",\n \"execa\": \"^8.0.1\",\n \"ora\": \"^8.0.1\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.11.24\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.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 { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, Config, UserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\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\n if (Array.isArray(JSONConfig)) {\n const promises = JSONConfig.map(async (item) => {\n return { ...item, plugins: item.plugins ? await getPlugins(item.plugins) : undefined }\n }) as unknown as Array<Promise<Config>>\n\n return Promise.all(promises)\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { PackageManager } from '@kubb/core'\n\nimport type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']): plugins is Array<[name: string, options: object]> {\n return !!(plugins as Array<[name: string, options: object]>[])?.some((plugin) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<UserConfig['plugins']> {\n const packageManager = new PackageManager(process.cwd())\n\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await packageManager.import(name)\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/guide/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n const jsonPlugins = plugins as Array<[name: string, options: object]>\n const promises = jsonPlugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises) as Promise<UserConfig['plugins']>\n }\n\n return Promise.resolve(plugins)\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } from '@kubb/core'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const { mod } = await bundleRequire({\n filepath: configFile,\n })\n\n return mod.default\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const 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.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\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\nimport { LogLevel } from '@kubb/core/logger'\n\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function callback(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, { logLevel = LogLevel.silent }: { logLevel?: LogLevel }): string {\n if (!error) {\n return ''\n }\n\n if (logLevel === LogLevel.silent) {\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function skip() {\n return true\n } as PrettyError.Callback)\n\n return [prettyError.render(error)].filter(Boolean).join('\\n')\n }\n\n const errors = getErrorCauses([error])\n\n return errors.filter(Boolean).join('\\n')\n}\n","import ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n","import c from 'tinyrainbow'\n\nimport { spinner } from './spinner.ts'\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(c.yellow(c.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(c.red('Watcher failed'))\n }\n })\n\n return\n}\n","import { safeBuild } from '@kubb/core'\nimport { createLogger, LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { getSummary } from './utils/getSummary.ts'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport type { ExecaReturnValue } from 'execa'\n\ntype GenerateProps = {\n input?: string\n config: Config\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: Config['hooks']\n logLevel: LogLevel\n}\n\ntype Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\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 (logLevel === LogLevel.silent) {\n spinner.start(`Executing hooks`)\n }\n\n const executers: Promise<Executer | null>[] = commands\n .map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n return null\n }\n\n spinner.start(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable as Writable)\n spinner.suffixText = ''\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n console.log(subProcess.stdout)\n }\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n .filter(Boolean)\n\n await Promise.all(executers)\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\nexport async function generate({ input, config, CLIOptions }: GenerateProps): Promise<void> {\n const logger = createLogger({ logLevel: CLIOptions.logLevel || LogLevel.silent, name: config.name, spinner })\n\n if (logger.name) {\n spinner.prefixText = randomCliColour(logger.name)\n }\n\n const hrstart = process.hrtime()\n\n if (CLIOptions.logLevel === LogLevel.debug) {\n const { performance, PerformanceObserver } = await import('node:perf_hooks')\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`\n\n spinner.suffixText = c.yellow(message)\n\n performance.clearMarks()\n })\n\n performanceOpserver.observe({ type: 'measure' })\n }\n\n const { root: _root, ...userConfig } = config\n const logLevel = logger.logLevel\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n const { pluginManager, error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n const summary = getSummary({ pluginManager, config, status: error ? 'failed' : 'success', hrstart, logger })\n\n if (error) {\n spinner.suffixText = ''\n spinner.fail(`🚀 Build failed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n\n throw error\n }\n\n await executeHooks({ hooks: config.hooks, logLevel })\n\n spinner.suffixText = ''\n spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","import path from 'node:path'\n\nimport { LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport c from 'tinyrainbow'\n\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\nimport type { Config, PluginManager } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype SummaryProps = {\n pluginManager: PluginManager\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: Config\n logger: Logger\n}\n\nexport function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {\n const { logLevel } = logger\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const buildEndPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildEnd' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.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?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {\n return 0\n }\n if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {\n return 1\n }\n if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n name: config.name,\n plugins: status === 'success'\n ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: c.yellow(`${elapsedSeconds}s`),\n output: path.resolve(config.root, config.output.path),\n } as const\n\n if (logLevel === LogLevel.debug) {\n logger.emit('debug', ['\\nGenerated files:\\n'])\n logger.emit('debug', files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],\n [` ${c.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${c.bold('Time:')} ${meta.time}`, true],\n [` ${c.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","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { Writable } from 'node:stream'\n\nimport c from 'tinyrainbow'\n\nimport type { WritableOptions } from 'node:stream'\nimport type { Ora } from 'ora'\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: BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${c.bold(c.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import path from 'node:path'\n\nimport { write } from '@kubb/core/fs'\nimport { LogLevel } from '@kubb/core/logger'\nimport { isPromiseFulfilledResult } from '@kubb/core/utils'\n\nimport { $ } from 'execa'\nimport c from 'tinyrainbow'\n\nimport { spinner } from './utils/spinner.ts'\n\ntype Preset = 'simple'\n\ntype PackageManager = 'pnpm' | 'npm' | 'yarn'\n\ntype PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype InitProps = {\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 plugins: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ output: { path: './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' }: InitProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const configPath = path.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${c.dim(configPath)}`)\n await write(presetMeta['kubb.config'], configPath)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${c.dim(configPath)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${c.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${c.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/utils/spinner.ts","../src/utils/watcher.ts","../src/generate.ts","../src/utils/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/OraWritable.ts","../src/init.ts"],"names":["path","c","moduleName","LogLevel","randomCliColour","spinner","callback"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,SAAS,aAAa,gBAAgB,eAAe;AAErD,SAAS,WAAW;AACpB,OAAOC,QAAO;;;ACHZ,cAAW;;;ACFb,SAAS,iBAAiB;;;ACE1B,SAAS,sBAAsB;AAI/B,SAAS,cAAc,SAAmF;AACxG,SAAO,CAAC,CAAE,SAAsD,KAAK,CAAC,WAAW;AAC/E,WAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,QAAQ,GAAG,CAAC,MAAM;AAAA,EAC3D,CAAC;AACH;A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zB,UAAM,iBAAiB,IAAI,eAAe;AAC1C,UAAM,WAAW,OAAO,IAAI,CAAC,SAAS,MAAM,SAAS,EAAE,OAAO,QAAQ,MAAM,WAAW,CAAC,CAAC;AAEzF,UAAM,eAAe,IAAI,OAAO,QAAQ;AAExC;AAAA,EACF;AAEA,QAAM,SAAS,EAAE,OAAO,QAAQ,WAAW,CAAC;AAC9C;AAEA,eAAsB,IAAI,MAAgC;AACxD,QAAM,UAAU,IAAI,UAAU;AAE9B,UAAQ,QAAQ,WAAW,+DAA+D,EAAE,OAAO,cAAc;AAEjH,UACG,QAAQ,oBAAoB,+DAA+D,EAC3F,OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,cAAc;AAExB,UAAQ,QAAQ,QAAQ,WAAW,EAAE,OAAO,YAAY;AACtD,WAAO,KAAK,EAAE,UAAU,OAAO,CAAC;AAAA,EAClC,CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AACvB,UAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,MAAI;AACF,UAAM,QAAQ,kBAAkB;AAEhC,YAAQ,KAAK,CAAC;AAAA,EAChB,SAAS,GAAG;AACV,mBAAe,GAAG,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ","sourcesContent":["import path from 'node:path'\n\nimport { isInputPath, PromiseManager, Warning } from '@kubb/core'\n\nimport { cac } from 'cac'\nimport c from 'tinyrainbow'\n\nimport { version } from '../package.json'\nimport { getConfig } from './utils/getConfig.ts'\nimport { getCosmiConfig } from './utils/getCosmiConfig.ts'\nimport { renderErrors } from './utils/renderErrors.ts'\nimport { spinner } from './utils/spinner.ts'\nimport { startWatcher } from './utils/watcher.ts'\nimport { generate } from './generate.ts'\nimport { init } from './init.ts'\n\nimport type { CLIOptions } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const error = e as Error\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel })\n\n if (error instanceof Warning) {\n spinner.warn(c.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail(message)\n process.exit(1)\n}\n\nasync function generateAction(input: string, CLIOptions: CLIOptions) {\n spinner.start('🔍 Loading config')\n const result = await getCosmiConfig(moduleName, CLIOptions.config)\n spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, CLIOptions)\n\n if (CLIOptions.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await generate({ config, CLIOptions })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(c.yellow(c.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }))\n\n await promiseManager.run('seq', promises)\n\n return\n }\n\n await generate({ input, config, CLIOptions })\n}\n\nexport async function run(argv?: string[]): Promise<void> {\n const program = cac(moduleName)\n\n program.command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)').action(generateAction)\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>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .action(generateAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n program.parse(argv, { run: false })\n\n try {\n await program.runMatchedCommand()\n\n process.exit(0)\n } catch (e) {\n programCatcher(e, program.options)\n }\n}\n\nexport default run\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.7.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.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx 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 \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && 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 \"bundle-require\": \"^4.0.2\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.6.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.19.12\",\n \"execa\": \"^8.0.1\",\n \"ora\": \"^8.0.1\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.11.24\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.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 { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, Config, UserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\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\n if (Array.isArray(JSONConfig)) {\n const promises = JSONConfig.map(async (item) => {\n return { ...item, plugins: item.plugins ? await getPlugins(item.plugins) : undefined }\n }) as unknown as Array<Promise<Config>>\n\n return Promise.all(promises)\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { PackageManager } from '@kubb/core'\n\nimport type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']): plugins is Array<[name: string, options: object]> {\n return !!(plugins as Array<[name: string, options: object]>[])?.some((plugin) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<UserConfig['plugins']> {\n const packageManager = new PackageManager(process.cwd())\n\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await packageManager.import(name)\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/guide/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n const jsonPlugins = plugins as Array<[name: string, options: object]>\n const promises = jsonPlugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises) as Promise<UserConfig['plugins']>\n }\n\n return Promise.resolve(plugins)\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } from '@kubb/core'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const { mod } = await bundleRequire({\n filepath: configFile,\n // makes it possible to use React and hooks\n format: 'cjs',\n })\n\n return mod.default\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const 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.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\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\nimport { LogLevel } from '@kubb/core/logger'\n\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function callback(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, { logLevel = LogLevel.silent }: { logLevel?: LogLevel }): string {\n if (!error) {\n return ''\n }\n\n if (logLevel === LogLevel.silent) {\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function skip() {\n return true\n } as PrettyError.Callback)\n\n return [prettyError.render(error)].filter(Boolean).join('\\n')\n }\n\n const errors = getErrorCauses([error])\n\n return errors.filter(Boolean).join('\\n')\n}\n","import ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n","import c from 'tinyrainbow'\n\nimport { spinner } from './spinner.ts'\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(c.yellow(c.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(c.red('Watcher failed'))\n }\n })\n\n return\n}\n","import { safeBuild } from '@kubb/core'\nimport { createLogger, LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { getSummary } from './utils/getSummary.ts'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport type { ExecaReturnValue } from 'execa'\n\ntype GenerateProps = {\n input?: string\n config: Config\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: Config['hooks']\n logLevel: LogLevel\n}\n\ntype Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\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 (logLevel === LogLevel.silent) {\n spinner.start(`Executing hooks`)\n }\n\n const executers: Promise<Executer | null>[] = commands\n .map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n return null\n }\n\n spinner.start(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable as Writable)\n spinner.suffixText = ''\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n console.log(subProcess.stdout)\n }\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n .filter(Boolean)\n\n await Promise.all(executers)\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\nexport async function generate({ input, config, CLIOptions }: GenerateProps): Promise<void> {\n const logger = createLogger({ logLevel: CLIOptions.logLevel || LogLevel.silent, name: config.name, spinner })\n\n if (logger.name) {\n spinner.prefixText = randomCliColour(logger.name)\n }\n\n const hrstart = process.hrtime()\n\n if (CLIOptions.logLevel === LogLevel.debug) {\n const { performance, PerformanceObserver } = await import('node:perf_hooks')\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`\n\n spinner.suffixText = c.yellow(message)\n\n performance.clearMarks()\n })\n\n performanceOpserver.observe({ type: 'measure' })\n }\n\n const { root: _root, ...userConfig } = config\n const logLevel = logger.logLevel\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n const { pluginManager, error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n const summary = getSummary({ pluginManager, config, status: error ? 'failed' : 'success', hrstart, logger })\n\n if (error) {\n spinner.suffixText = ''\n spinner.fail(`🚀 Build failed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n\n throw error\n }\n\n await executeHooks({ hooks: config.hooks, logLevel })\n\n spinner.suffixText = ''\n spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","import path from 'node:path'\n\nimport { LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport c from 'tinyrainbow'\n\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\nimport type { Config, PluginManager } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype SummaryProps = {\n pluginManager: PluginManager\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: Config\n logger: Logger\n}\n\nexport function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {\n const { logLevel } = logger\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const buildEndPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildEnd' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.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?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {\n return 0\n }\n if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {\n return 1\n }\n if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n name: config.name,\n plugins: status === 'success'\n ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: c.yellow(`${elapsedSeconds}s`),\n output: path.resolve(config.root, config.output.path),\n } as const\n\n if (logLevel === LogLevel.debug) {\n logger.emit('debug', ['\\nGenerated files:\\n'])\n logger.emit('debug', files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],\n [` ${c.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${c.bold('Time:')} ${meta.time}`, true],\n [` ${c.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","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { Writable } from 'node:stream'\n\nimport c from 'tinyrainbow'\n\nimport type { WritableOptions } from 'node:stream'\nimport type { Ora } from 'ora'\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: BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${c.bold(c.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import path from 'node:path'\n\nimport { write } from '@kubb/core/fs'\nimport { LogLevel } from '@kubb/core/logger'\nimport { isPromiseFulfilledResult } from '@kubb/core/utils'\n\nimport { $ } from 'execa'\nimport c from 'tinyrainbow'\n\nimport { spinner } from './utils/spinner.ts'\n\ntype Preset = 'simple'\n\ntype PackageManager = 'pnpm' | 'npm' | 'yarn'\n\ntype PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype InitProps = {\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 plugins: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ output: { path: './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' }: InitProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const configPath = path.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${c.dim(configPath)}`)\n await write(presetMeta['kubb.config'], configPath)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${c.dim(configPath)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${c.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${c.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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"]}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { Warning, isInputPath, PromiseManager, safeBuild, PackageManager } from '@kubb/core';
|
|
3
|
-
import { cac } from 'cac';
|
|
4
|
-
import c2 from 'tinyrainbow';
|
|
5
|
-
import { isPromiseFulfilledResult, isPromise } from '@kubb/core/utils';
|
|
6
|
-
import { bundleRequire } from 'bundle-require';
|
|
7
|
-
import { cosmiconfig } from 'cosmiconfig';
|
|
8
|
-
import { LogLevel, createLogger, randomCliColour } from '@kubb/core/logger';
|
|
9
|
-
import PrettyError from 'pretty-error';
|
|
10
|
-
import ora from 'ora';
|
|
11
|
-
import { $, execa } from 'execa';
|
|
12
|
-
import { parseArgsStringToArgv } from 'string-argv';
|
|
13
|
-
import { Writable } from 'stream';
|
|
14
|
-
import { write } from '@kubb/core/fs';
|
|
15
|
-
|
|
16
1
|
// src/index.ts
|
|
2
|
+
import path3 from "path";
|
|
3
|
+
import { isInputPath, PromiseManager, Warning } from "@kubb/core";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
import c6 from "tinyrainbow";
|
|
17
6
|
|
|
18
7
|
// package.json
|
|
19
|
-
var version = "2.
|
|
8
|
+
var version = "2.7.0";
|
|
9
|
+
|
|
10
|
+
// src/utils/getConfig.ts
|
|
11
|
+
import { isPromise } from "@kubb/core/utils";
|
|
12
|
+
|
|
13
|
+
// src/utils/getPlugins.ts
|
|
14
|
+
import { PackageManager } from "@kubb/core";
|
|
20
15
|
function isJSONPlugins(plugins) {
|
|
21
16
|
return !!plugins?.some((plugin) => {
|
|
22
17
|
return Array.isArray(plugin) && typeof plugin?.at(0) === "string";
|
|
@@ -69,9 +64,15 @@ async function getConfig(result, CLIOptions) {
|
|
|
69
64
|
};
|
|
70
65
|
return JSONConfig;
|
|
71
66
|
}
|
|
67
|
+
|
|
68
|
+
// src/utils/getCosmiConfig.ts
|
|
69
|
+
import { bundleRequire } from "bundle-require";
|
|
70
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
72
71
|
var tsLoader = async (configFile) => {
|
|
73
72
|
const { mod } = await bundleRequire({
|
|
74
|
-
filepath: configFile
|
|
73
|
+
filepath: configFile,
|
|
74
|
+
// makes it possible to use React and hooks
|
|
75
|
+
format: "cjs"
|
|
75
76
|
});
|
|
76
77
|
return mod.default;
|
|
77
78
|
};
|
|
@@ -112,6 +113,10 @@ async function getCosmiConfig(moduleName2, config) {
|
|
|
112
113
|
}
|
|
113
114
|
return result;
|
|
114
115
|
}
|
|
116
|
+
|
|
117
|
+
// src/utils/renderErrors.ts
|
|
118
|
+
import { LogLevel } from "@kubb/core/logger";
|
|
119
|
+
import PrettyError from "pretty-error";
|
|
115
120
|
var prettyError = new PrettyError().skipPackage("commander").skip(function callback(traceLine) {
|
|
116
121
|
const pattern = new RegExp("renderErrors");
|
|
117
122
|
const hasMatch = traceLine?.file?.match(pattern);
|
|
@@ -143,28 +148,46 @@ function renderErrors(error, { logLevel = LogLevel.silent }) {
|
|
|
143
148
|
const errors = getErrorCauses([error]);
|
|
144
149
|
return errors.filter(Boolean).join("\n");
|
|
145
150
|
}
|
|
151
|
+
|
|
152
|
+
// src/utils/spinner.ts
|
|
153
|
+
import ora from "ora";
|
|
146
154
|
var spinner = ora({
|
|
147
155
|
spinner: "clock"
|
|
148
156
|
});
|
|
157
|
+
|
|
158
|
+
// src/utils/watcher.ts
|
|
159
|
+
import c from "tinyrainbow";
|
|
149
160
|
async function startWatcher(path4, cb) {
|
|
150
|
-
const { watch } = await import(
|
|
161
|
+
const { watch } = await import("chokidar");
|
|
151
162
|
const ignored = ["**/{.git,node_modules}/**"];
|
|
152
163
|
const watcher = watch(path4, {
|
|
153
164
|
ignorePermissionErrors: true,
|
|
154
165
|
ignored
|
|
155
166
|
});
|
|
156
167
|
watcher.on("all", (type, file) => {
|
|
157
|
-
spinner.succeed(
|
|
168
|
+
spinner.succeed(c.yellow(c.bold(`Change detected: ${type} ${file}`)));
|
|
158
169
|
spinner.spinner = "clock";
|
|
159
170
|
try {
|
|
160
171
|
cb(path4);
|
|
161
172
|
} catch (e) {
|
|
162
|
-
spinner.warn(
|
|
173
|
+
spinner.warn(c.red("Watcher failed"));
|
|
163
174
|
}
|
|
164
175
|
});
|
|
165
176
|
return;
|
|
166
177
|
}
|
|
167
178
|
|
|
179
|
+
// src/generate.ts
|
|
180
|
+
import { safeBuild } from "@kubb/core";
|
|
181
|
+
import { createLogger, LogLevel as LogLevel3, randomCliColour as randomCliColour2 } from "@kubb/core/logger";
|
|
182
|
+
import { execa } from "execa";
|
|
183
|
+
import { parseArgsStringToArgv } from "string-argv";
|
|
184
|
+
import c4 from "tinyrainbow";
|
|
185
|
+
|
|
186
|
+
// src/utils/getSummary.ts
|
|
187
|
+
import path from "path";
|
|
188
|
+
import { LogLevel as LogLevel2, randomCliColour } from "@kubb/core/logger";
|
|
189
|
+
import c2 from "tinyrainbow";
|
|
190
|
+
|
|
168
191
|
// src/utils/parseHrtimeToSeconds.ts
|
|
169
192
|
function parseHrtimeToSeconds(hrtime) {
|
|
170
193
|
const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
|
|
@@ -200,7 +223,7 @@ function getSummary({ pluginManager, status, hrstart, config, logger }) {
|
|
|
200
223
|
time: c2.yellow(`${elapsedSeconds}s`),
|
|
201
224
|
output: path.resolve(config.root, config.output.path)
|
|
202
225
|
};
|
|
203
|
-
if (logLevel ===
|
|
226
|
+
if (logLevel === LogLevel2.debug) {
|
|
204
227
|
logger.emit("debug", ["\nGenerated files:\n"]);
|
|
205
228
|
logger.emit("debug", files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`));
|
|
206
229
|
}
|
|
@@ -225,6 +248,10 @@ function getSummary({ pluginManager, status, hrstart, config, logger }) {
|
|
|
225
248
|
);
|
|
226
249
|
return logs;
|
|
227
250
|
}
|
|
251
|
+
|
|
252
|
+
// src/utils/OraWritable.ts
|
|
253
|
+
import { Writable } from "stream";
|
|
254
|
+
import c3 from "tinyrainbow";
|
|
228
255
|
var OraWritable = class extends Writable {
|
|
229
256
|
constructor(spinner2, command, opts) {
|
|
230
257
|
super(opts);
|
|
@@ -234,7 +261,7 @@ var OraWritable = class extends Writable {
|
|
|
234
261
|
_write(chunk, _encoding, callback2) {
|
|
235
262
|
this.spinner.suffixText = `
|
|
236
263
|
|
|
237
|
-
${
|
|
264
|
+
${c3.bold(c3.blue(this.command))}: ${chunk?.toString()}`;
|
|
238
265
|
callback2();
|
|
239
266
|
}
|
|
240
267
|
};
|
|
@@ -245,7 +272,7 @@ async function executeHooks({ hooks, logLevel }) {
|
|
|
245
272
|
return;
|
|
246
273
|
}
|
|
247
274
|
const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done];
|
|
248
|
-
if (logLevel ===
|
|
275
|
+
if (logLevel === LogLevel3.silent) {
|
|
249
276
|
spinner.start(`Executing hooks`);
|
|
250
277
|
}
|
|
251
278
|
const executers = commands.map(async (command) => {
|
|
@@ -255,32 +282,32 @@ async function executeHooks({ hooks, logLevel }) {
|
|
|
255
282
|
if (!cmd) {
|
|
256
283
|
return null;
|
|
257
284
|
}
|
|
258
|
-
spinner.start(`Executing hook ${logLevel !== "silent" ?
|
|
285
|
+
spinner.start(`Executing hook ${logLevel !== "silent" ? c4.dim(command) : ""}`);
|
|
259
286
|
const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout(oraWritable);
|
|
260
287
|
spinner.suffixText = "";
|
|
261
|
-
if (logLevel ===
|
|
262
|
-
spinner.succeed(`Executing hook ${logLevel !== "silent" ?
|
|
288
|
+
if (logLevel === LogLevel3.silent) {
|
|
289
|
+
spinner.succeed(`Executing hook ${logLevel !== "silent" ? c4.dim(command) : ""}`);
|
|
263
290
|
console.log(subProcess.stdout);
|
|
264
291
|
}
|
|
265
292
|
oraWritable.destroy();
|
|
266
293
|
return { subProcess, abort: abortController.abort.bind(abortController) };
|
|
267
294
|
}).filter(Boolean);
|
|
268
295
|
await Promise.all(executers);
|
|
269
|
-
if (logLevel ===
|
|
296
|
+
if (logLevel === LogLevel3.silent) {
|
|
270
297
|
spinner.succeed(`Executing hooks`);
|
|
271
298
|
}
|
|
272
299
|
}
|
|
273
300
|
async function generate({ input, config, CLIOptions }) {
|
|
274
|
-
const logger = createLogger({ logLevel: CLIOptions.logLevel ||
|
|
301
|
+
const logger = createLogger({ logLevel: CLIOptions.logLevel || LogLevel3.silent, name: config.name, spinner });
|
|
275
302
|
if (logger.name) {
|
|
276
|
-
spinner.prefixText =
|
|
303
|
+
spinner.prefixText = randomCliColour2(logger.name);
|
|
277
304
|
}
|
|
278
305
|
const hrstart = process.hrtime();
|
|
279
|
-
if (CLIOptions.logLevel ===
|
|
280
|
-
const { performance, PerformanceObserver } = await import(
|
|
306
|
+
if (CLIOptions.logLevel === LogLevel3.debug) {
|
|
307
|
+
const { performance, PerformanceObserver } = await import("perf_hooks");
|
|
281
308
|
const performanceOpserver = new PerformanceObserver((items) => {
|
|
282
309
|
const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`;
|
|
283
|
-
spinner.suffixText =
|
|
310
|
+
spinner.suffixText = c4.yellow(message);
|
|
284
311
|
performance.clearMarks();
|
|
285
312
|
});
|
|
286
313
|
performanceOpserver.observe({ type: "measure" });
|
|
@@ -288,7 +315,7 @@ async function generate({ input, config, CLIOptions }) {
|
|
|
288
315
|
const { root: _root, ...userConfig } = config;
|
|
289
316
|
const logLevel = logger.logLevel;
|
|
290
317
|
const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
|
|
291
|
-
spinner.start(`\u{1F680} Building ${logLevel !== "silent" ?
|
|
318
|
+
spinner.start(`\u{1F680} Building ${logLevel !== "silent" ? c4.dim(inputPath) : ""}`);
|
|
292
319
|
const { pluginManager, error } = await safeBuild({
|
|
293
320
|
config: {
|
|
294
321
|
root: process.cwd(),
|
|
@@ -307,15 +334,23 @@ async function generate({ input, config, CLIOptions }) {
|
|
|
307
334
|
const summary = getSummary({ pluginManager, config, status: error ? "failed" : "success", hrstart, logger });
|
|
308
335
|
if (error) {
|
|
309
336
|
spinner.suffixText = "";
|
|
310
|
-
spinner.fail(`\u{1F680} Build failed ${logLevel !== "silent" ?
|
|
337
|
+
spinner.fail(`\u{1F680} Build failed ${logLevel !== "silent" ? c4.dim(inputPath) : ""}`);
|
|
311
338
|
console.log(summary.join(""));
|
|
312
339
|
throw error;
|
|
313
340
|
}
|
|
314
341
|
await executeHooks({ hooks: config.hooks, logLevel });
|
|
315
342
|
spinner.suffixText = "";
|
|
316
|
-
spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ?
|
|
343
|
+
spinner.succeed(`\u{1F680} Build completed ${logLevel !== "silent" ? c4.dim(inputPath) : ""}`);
|
|
317
344
|
console.log(summary.join(""));
|
|
318
345
|
}
|
|
346
|
+
|
|
347
|
+
// src/init.ts
|
|
348
|
+
import path2 from "path";
|
|
349
|
+
import { write } from "@kubb/core/fs";
|
|
350
|
+
import { LogLevel as LogLevel4 } from "@kubb/core/logger";
|
|
351
|
+
import { isPromiseFulfilledResult } from "@kubb/core/utils";
|
|
352
|
+
import { $ } from "execa";
|
|
353
|
+
import c5 from "tinyrainbow";
|
|
319
354
|
var presets = {
|
|
320
355
|
simple: {
|
|
321
356
|
"kubb.config": `
|
|
@@ -342,24 +377,24 @@ export default defineConfig({
|
|
|
342
377
|
packages: ["@kubb/core", "@kubb/cli", "@kubb/swagger", "@kubb/swagger-ts", "@kubb/swagger-tanstack-query"]
|
|
343
378
|
}
|
|
344
379
|
};
|
|
345
|
-
async function init({ preset = "simple", logLevel =
|
|
380
|
+
async function init({ preset = "simple", logLevel = LogLevel4.silent, packageManager = "pnpm" }) {
|
|
346
381
|
spinner.start("\u{1F4E6} Initializing Kubb");
|
|
347
382
|
const presetMeta = presets[preset];
|
|
348
|
-
const configPath =
|
|
383
|
+
const configPath = path2.resolve(process.cwd(), "./kubb.config.js");
|
|
349
384
|
const installCommand = packageManager === "npm" ? "install" : "add";
|
|
350
|
-
spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${
|
|
385
|
+
spinner.start(`\u{1F4C0} Writing \`kubb.config.js\` ${c5.dim(configPath)}`);
|
|
351
386
|
await write(presetMeta["kubb.config"], configPath);
|
|
352
|
-
spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${
|
|
387
|
+
spinner.succeed(`\u{1F4C0} Wrote \`kubb.config.js\` ${c5.dim(configPath)}`);
|
|
353
388
|
const results = await Promise.allSettled([
|
|
354
389
|
$`npm init es6 -y`,
|
|
355
390
|
...presetMeta.packages.map(async (pack) => {
|
|
356
|
-
spinner.start(`\u{1F4C0} Installing ${
|
|
391
|
+
spinner.start(`\u{1F4C0} Installing ${c5.dim(pack)}`);
|
|
357
392
|
const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`;
|
|
358
|
-
spinner.succeed(`\u{1F4C0} Installed ${
|
|
393
|
+
spinner.succeed(`\u{1F4C0} Installed ${c5.dim(pack)}`);
|
|
359
394
|
return stdout;
|
|
360
395
|
})
|
|
361
396
|
]);
|
|
362
|
-
if (logLevel ===
|
|
397
|
+
if (logLevel === LogLevel4.info) {
|
|
363
398
|
results.forEach((result) => {
|
|
364
399
|
if (isPromiseFulfilledResult(result)) {
|
|
365
400
|
console.log(result.value);
|
|
@@ -376,7 +411,7 @@ function programCatcher(e, CLIOptions) {
|
|
|
376
411
|
const error = e;
|
|
377
412
|
const message = renderErrors(error, { logLevel: CLIOptions.logLevel });
|
|
378
413
|
if (error instanceof Warning) {
|
|
379
|
-
spinner.warn(
|
|
414
|
+
spinner.warn(c6.yellow(error.message));
|
|
380
415
|
process.exit(0);
|
|
381
416
|
}
|
|
382
417
|
spinner.fail(message);
|
|
@@ -385,7 +420,7 @@ function programCatcher(e, CLIOptions) {
|
|
|
385
420
|
async function generateAction(input, CLIOptions) {
|
|
386
421
|
spinner.start("\u{1F50D} Loading config");
|
|
387
422
|
const result = await getCosmiConfig(moduleName, CLIOptions.config);
|
|
388
|
-
spinner.succeed(`\u{1F50D} Config loaded(${
|
|
423
|
+
spinner.succeed(`\u{1F50D} Config loaded(${c6.dim(path3.relative(process.cwd(), result.filepath))})`);
|
|
389
424
|
const config = await getConfig(result, CLIOptions);
|
|
390
425
|
if (CLIOptions.watch) {
|
|
391
426
|
if (Array.isArray(config)) {
|
|
@@ -395,7 +430,7 @@ async function generateAction(input, CLIOptions) {
|
|
|
395
430
|
return startWatcher([input || config.input.path], async (paths) => {
|
|
396
431
|
await generate({ config, CLIOptions });
|
|
397
432
|
spinner.spinner = "simpleDotsScrolling";
|
|
398
|
-
spinner.start(
|
|
433
|
+
spinner.start(c6.yellow(c6.bold(`Watching for changes in ${paths.join(" and ")}`)));
|
|
399
434
|
});
|
|
400
435
|
}
|
|
401
436
|
}
|
|
@@ -425,7 +460,8 @@ async function run(argv) {
|
|
|
425
460
|
}
|
|
426
461
|
}
|
|
427
462
|
var src_default = run;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
463
|
+
export {
|
|
464
|
+
src_default as default,
|
|
465
|
+
run
|
|
466
|
+
};
|
|
431
467
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/utils/spinner.ts","../src/utils/watcher.ts","../src/generate.ts","../src/utils/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/OraWritable.ts","../src/init.ts"],"names":["path","c","moduleName","LogLevel","randomCliColour","spinner","callback"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,SAAS,aAAa,gBAAgB,eAAe;AAErD,SAAS,WAAW;AACpB,OAAOC,QAAO;;;ACHZ,cAAW;;;ACFb,SAAS,iBAAiB;;;ACE1B,SAAS,sBAAsB;AAI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,GAAE,KAAK,2BAA2B,MAAM,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;AAAA,MAClF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,UAAM,iBAAiB,IAAI,eAAe;AAC1C,UAAM,WAAW,OAAO,IAAI,CAAC,SAAS,MAAM,SAAS,EAAE,OAAO,QAAQ,MAAM,WAAW,CAAC,CAAC;AAEzF,UAAM,eAAe,IAAI,OAAO,QAAQ;AAExC;AAAA,EACF;AAEA,QAAM,SAAS,EAAE,OAAO,QAAQ,WAAW,CAAC;AAC9C;AAEA,eAAsB,IAAI,MAAgC;AACxD,QAAM,UAAU,IAAI,UAAU;AAE9B,UAAQ,QAAQ,WAAW,+DAA+D,EAAE,OAAO,cAAc;AAEjH,UACG,QAAQ,oBAAoB,+DAA+D,EAC3F,OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,cAAc;AAExB,UAAQ,QAAQ,QAAQ,WAAW,EAAE,OAAO,YAAY;AACtD,WAAO,KAAK,EAAE,UAAU,OAAO,CAAC;AAAA,EAClC,CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AACvB,UAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,MAAI;AACF,UAAM,QAAQ,kBAAkB;AAEhC,YAAQ,KAAK,CAAC;AAAA,EAChB,SAAS,GAAG;AACV,mBAAe,GAAG,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ","sourcesContent":["import path from 'node:path'\n\nimport { isInputPath, PromiseManager, Warning } from '@kubb/core'\n\nimport { cac } from 'cac'\nimport c from 'tinyrainbow'\n\nimport { version } from '../package.json'\nimport { getConfig } from './utils/getConfig.ts'\nimport { getCosmiConfig } from './utils/getCosmiConfig.ts'\nimport { renderErrors } from './utils/renderErrors.ts'\nimport { spinner } from './utils/spinner.ts'\nimport { startWatcher } from './utils/watcher.ts'\nimport { generate } from './generate.ts'\nimport { init } from './init.ts'\n\nimport type { CLIOptions } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const error = e as Error\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel })\n\n if (error instanceof Warning) {\n spinner.warn(c.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail(message)\n process.exit(1)\n}\n\nasync function generateAction(input: string, CLIOptions: CLIOptions) {\n spinner.start('🔍 Loading config')\n const result = await getCosmiConfig(moduleName, CLIOptions.config)\n spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, CLIOptions)\n\n if (CLIOptions.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await generate({ config, CLIOptions })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(c.yellow(c.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }))\n\n await promiseManager.run('seq', promises)\n\n return\n }\n\n await generate({ input, config, CLIOptions })\n}\n\nexport async function run(argv?: string[]): Promise<void> {\n const program = cac(moduleName)\n\n program.command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)').action(generateAction)\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>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .action(generateAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n program.parse(argv, { run: false })\n\n try {\n await program.runMatchedCommand()\n\n process.exit(0)\n } catch (e) {\n programCatcher(e, program.options)\n }\n}\n\nexport default run\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.6.6\",\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.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx 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 \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && 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 \"bundle-require\": \"^4.0.2\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.6.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.19.12\",\n \"execa\": \"^8.0.1\",\n \"ora\": \"^8.0.1\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.11.24\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.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 { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, Config, UserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\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\n if (Array.isArray(JSONConfig)) {\n const promises = JSONConfig.map(async (item) => {\n return { ...item, plugins: item.plugins ? await getPlugins(item.plugins) : undefined }\n }) as unknown as Array<Promise<Config>>\n\n return Promise.all(promises)\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { PackageManager } from '@kubb/core'\n\nimport type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']): plugins is Array<[name: string, options: object]> {\n return !!(plugins as Array<[name: string, options: object]>[])?.some((plugin) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<UserConfig['plugins']> {\n const packageManager = new PackageManager(process.cwd())\n\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await packageManager.import(name)\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/guide/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n const jsonPlugins = plugins as Array<[name: string, options: object]>\n const promises = jsonPlugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises) as Promise<UserConfig['plugins']>\n }\n\n return Promise.resolve(plugins)\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } from '@kubb/core'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const { mod } = await bundleRequire({\n filepath: configFile,\n })\n\n return mod.default\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const 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.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\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\nimport { LogLevel } from '@kubb/core/logger'\n\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function callback(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, { logLevel = LogLevel.silent }: { logLevel?: LogLevel }): string {\n if (!error) {\n return ''\n }\n\n if (logLevel === LogLevel.silent) {\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function skip() {\n return true\n } as PrettyError.Callback)\n\n return [prettyError.render(error)].filter(Boolean).join('\\n')\n }\n\n const errors = getErrorCauses([error])\n\n return errors.filter(Boolean).join('\\n')\n}\n","import ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n","import c from 'tinyrainbow'\n\nimport { spinner } from './spinner.ts'\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(c.yellow(c.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(c.red('Watcher failed'))\n }\n })\n\n return\n}\n","import { safeBuild } from '@kubb/core'\nimport { createLogger, LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { getSummary } from './utils/getSummary.ts'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport type { ExecaReturnValue } from 'execa'\n\ntype GenerateProps = {\n input?: string\n config: Config\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: Config['hooks']\n logLevel: LogLevel\n}\n\ntype Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\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 (logLevel === LogLevel.silent) {\n spinner.start(`Executing hooks`)\n }\n\n const executers: Promise<Executer | null>[] = commands\n .map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n return null\n }\n\n spinner.start(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable as Writable)\n spinner.suffixText = ''\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n console.log(subProcess.stdout)\n }\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n .filter(Boolean)\n\n await Promise.all(executers)\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\nexport async function generate({ input, config, CLIOptions }: GenerateProps): Promise<void> {\n const logger = createLogger({ logLevel: CLIOptions.logLevel || LogLevel.silent, name: config.name, spinner })\n\n if (logger.name) {\n spinner.prefixText = randomCliColour(logger.name)\n }\n\n const hrstart = process.hrtime()\n\n if (CLIOptions.logLevel === LogLevel.debug) {\n const { performance, PerformanceObserver } = await import('node:perf_hooks')\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`\n\n spinner.suffixText = c.yellow(message)\n\n performance.clearMarks()\n })\n\n performanceOpserver.observe({ type: 'measure' })\n }\n\n const { root: _root, ...userConfig } = config\n const logLevel = logger.logLevel\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n const { pluginManager, error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n const summary = getSummary({ pluginManager, config, status: error ? 'failed' : 'success', hrstart, logger })\n\n if (error) {\n spinner.suffixText = ''\n spinner.fail(`🚀 Build failed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n\n throw error\n }\n\n await executeHooks({ hooks: config.hooks, logLevel })\n\n spinner.suffixText = ''\n spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","import path from 'node:path'\n\nimport { LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport c from 'tinyrainbow'\n\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\nimport type { Config, PluginManager } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype SummaryProps = {\n pluginManager: PluginManager\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: Config\n logger: Logger\n}\n\nexport function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {\n const { logLevel } = logger\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const buildEndPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildEnd' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.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?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {\n return 0\n }\n if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {\n return 1\n }\n if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n name: config.name,\n plugins: status === 'success'\n ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: c.yellow(`${elapsedSeconds}s`),\n output: path.resolve(config.root, config.output.path),\n } as const\n\n if (logLevel === LogLevel.debug) {\n logger.emit('debug', ['\\nGenerated files:\\n'])\n logger.emit('debug', files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],\n [` ${c.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${c.bold('Time:')} ${meta.time}`, true],\n [` ${c.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","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { Writable } from 'node:stream'\n\nimport c from 'tinyrainbow'\n\nimport type { WritableOptions } from 'node:stream'\nimport type { Ora } from 'ora'\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: BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${c.bold(c.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import path from 'node:path'\n\nimport { write } from '@kubb/core/fs'\nimport { LogLevel } from '@kubb/core/logger'\nimport { isPromiseFulfilledResult } from '@kubb/core/utils'\n\nimport { $ } from 'execa'\nimport c from 'tinyrainbow'\n\nimport { spinner } from './utils/spinner.ts'\n\ntype Preset = 'simple'\n\ntype PackageManager = 'pnpm' | 'npm' | 'yarn'\n\ntype PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype InitProps = {\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 plugins: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ output: { path: './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' }: InitProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const configPath = path.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${c.dim(configPath)}`)\n await write(presetMeta['kubb.config'], configPath)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${c.dim(configPath)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${c.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${c.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json","../src/utils/getConfig.ts","../src/utils/getPlugins.ts","../src/utils/getCosmiConfig.ts","../src/utils/renderErrors.ts","../src/utils/spinner.ts","../src/utils/watcher.ts","../src/generate.ts","../src/utils/getSummary.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/OraWritable.ts","../src/init.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { isInputPath, PromiseManager, Warning } from '@kubb/core'\n\nimport { cac } from 'cac'\nimport c from 'tinyrainbow'\n\nimport { version } from '../package.json'\nimport { getConfig } from './utils/getConfig.ts'\nimport { getCosmiConfig } from './utils/getCosmiConfig.ts'\nimport { renderErrors } from './utils/renderErrors.ts'\nimport { spinner } from './utils/spinner.ts'\nimport { startWatcher } from './utils/watcher.ts'\nimport { generate } from './generate.ts'\nimport { init } from './init.ts'\n\nimport type { CLIOptions } from '@kubb/core'\n\nconst moduleName = 'kubb'\n\nfunction programCatcher(e: unknown, CLIOptions: CLIOptions): void {\n const error = e as Error\n const message = renderErrors(error, { logLevel: CLIOptions.logLevel })\n\n if (error instanceof Warning) {\n spinner.warn(c.yellow(error.message))\n process.exit(0)\n }\n\n spinner.fail(message)\n process.exit(1)\n}\n\nasync function generateAction(input: string, CLIOptions: CLIOptions) {\n spinner.start('🔍 Loading config')\n const result = await getCosmiConfig(moduleName, CLIOptions.config)\n spinner.succeed(`🔍 Config loaded(${c.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, CLIOptions)\n\n if (CLIOptions.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await generate({ config, CLIOptions })\n spinner.spinner = 'simpleDotsScrolling'\n spinner.start(c.yellow(c.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((item) => () => generate({ input, config: item, CLIOptions }))\n\n await promiseManager.run('seq', promises)\n\n return\n }\n\n await generate({ input, config, CLIOptions })\n}\n\nexport async function run(argv?: string[]): Promise<void> {\n const program = cac(moduleName)\n\n program.command('[input]', 'Path of the input file(overrides the one in `kubb.config.js`)').action(generateAction)\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>', 'Info, silent or debug')\n .option('-w, --watch', 'Watch mode based on the input file')\n .action(generateAction)\n\n program.command('init', 'Init Kubb').action(async () => {\n return init({ logLevel: 'info' })\n })\n\n program.help()\n program.version(version)\n program.parse(argv, { run: false })\n\n try {\n await program.runMatchedCommand()\n\n process.exit(0)\n } catch (e) {\n programCatcher(e, program.options)\n }\n}\n\nexport default run\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"2.7.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.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"bin\": {\n \"kubb\": \"bin/kubb.js\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx 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 \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && 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 \"bundle-require\": \"^4.0.2\",\n \"cac\": \"^6.7.14\",\n \"chokidar\": \"^3.6.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"esbuild\": \"^0.19.12\",\n \"execa\": \"^8.0.1\",\n \"ora\": \"^8.0.1\",\n \"pretty-error\": \"^4.0.0\",\n \"string-argv\": \"^0.3.2\",\n \"tinyrainbow\": \"^1.1.1\"\n },\n \"devDependencies\": {\n \"@kubb/swagger\": \"workspace:*\",\n \"@kubb/ts-config\": \"workspace:*\",\n \"@kubb/tsup-config\": \"workspace:*\",\n \"@types/node\": \"^20.11.24\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.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 { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { CLIOptions, Config, UserConfig } from '@kubb/core'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, CLIOptions: CLIOptions): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\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\n if (Array.isArray(JSONConfig)) {\n const promises = JSONConfig.map(async (item) => {\n return { ...item, plugins: item.plugins ? await getPlugins(item.plugins) : undefined }\n }) as unknown as Array<Promise<Config>>\n\n return Promise.all(promises)\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport { PackageManager } from '@kubb/core'\n\nimport type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']): plugins is Array<[name: string, options: object]> {\n return !!(plugins as Array<[name: string, options: object]>[])?.some((plugin) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nasync function importPlugin(name: string, options: object): Promise<UserConfig['plugins']> {\n const packageManager = new PackageManager(process.cwd())\n\n const importedPlugin: any = process.env.NODE_ENV === 'test' ? await import(name) : await packageManager.import(name)\n\n // eslint-disable-next-line\n return importedPlugin?.default ? importedPlugin.default(options) : importedPlugin(options)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/guide/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n const jsonPlugins = plugins as Array<[name: string, options: object]>\n const promises = jsonPlugins.map((plugin) => {\n const [name, options = {}] = plugin\n return importPlugin(name, options)\n })\n return Promise.all(promises) as Promise<UserConfig['plugins']>\n }\n\n return Promise.resolve(plugins)\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { bundleRequire } from 'bundle-require'\nimport { cosmiconfig } from 'cosmiconfig'\n\nimport type { defineConfig, UserConfig } from '@kubb/core'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const { mod } = await bundleRequire({\n filepath: configFile,\n // makes it possible to use React and hooks\n format: 'cjs',\n })\n\n return mod.default\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const 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.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\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\nimport { LogLevel } from '@kubb/core/logger'\n\nimport PrettyError from 'pretty-error'\n\nexport const prettyError = new PrettyError()\n .skipPackage('commander')\n .skip(function callback(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, { logLevel = LogLevel.silent }: { logLevel?: LogLevel }): string {\n if (!error) {\n return ''\n }\n\n if (logLevel === LogLevel.silent) {\n // skip when no debug is set\n prettyError.skipNodeFiles()\n prettyError.skip(function skip() {\n return true\n } as PrettyError.Callback)\n\n return [prettyError.render(error)].filter(Boolean).join('\\n')\n }\n\n const errors = getErrorCauses([error])\n\n return errors.filter(Boolean).join('\\n')\n}\n","import ora from 'ora'\n\nexport const spinner = ora({\n spinner: 'clock',\n})\n","import c from 'tinyrainbow'\n\nimport { spinner } from './spinner.ts'\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(c.yellow(c.bold(`Change detected: ${type} ${file}`)))\n // revert back\n spinner.spinner = 'clock'\n\n try {\n cb(path)\n } catch (e) {\n spinner.warn(c.red('Watcher failed'))\n }\n })\n\n return\n}\n","import { safeBuild } from '@kubb/core'\nimport { createLogger, LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport { execa } from 'execa'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport c from 'tinyrainbow'\n\nimport { getSummary } from './utils/getSummary.ts'\nimport { OraWritable } from './utils/OraWritable.ts'\nimport { spinner } from './utils/spinner.ts'\n\nimport type { Writable } from 'node:stream'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport type { ExecaReturnValue } from 'execa'\n\ntype GenerateProps = {\n input?: string\n config: Config\n CLIOptions: CLIOptions\n}\n\ntype ExecutingHooksProps = {\n hooks: Config['hooks']\n logLevel: LogLevel\n}\n\ntype Executer = { subProcess: ExecaReturnValue<string>; abort: AbortController['abort'] }\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 (logLevel === LogLevel.silent) {\n spinner.start(`Executing hooks`)\n }\n\n const executers: Promise<Executer | null>[] = commands\n .map(async (command) => {\n const oraWritable = new OraWritable(spinner, command)\n const abortController = new AbortController()\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n return null\n }\n\n spinner.start(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n const subProcess = await execa(cmd, _args, { detached: true, signal: abortController.signal }).pipeStdout!(oraWritable as Writable)\n spinner.suffixText = ''\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hook ${logLevel !== 'silent' ? c.dim(command) : ''}`)\n\n console.log(subProcess.stdout)\n }\n\n oraWritable.destroy()\n return { subProcess, abort: abortController.abort.bind(abortController) }\n })\n .filter(Boolean)\n\n await Promise.all(executers)\n\n if (logLevel === LogLevel.silent) {\n spinner.succeed(`Executing hooks`)\n }\n}\n\nexport async function generate({ input, config, CLIOptions }: GenerateProps): Promise<void> {\n const logger = createLogger({ logLevel: CLIOptions.logLevel || LogLevel.silent, name: config.name, spinner })\n\n if (logger.name) {\n spinner.prefixText = randomCliColour(logger.name)\n }\n\n const hrstart = process.hrtime()\n\n if (CLIOptions.logLevel === LogLevel.debug) {\n const { performance, PerformanceObserver } = await import('node:perf_hooks')\n\n const performanceOpserver = new PerformanceObserver((items) => {\n const message = `${items.getEntries()[0]?.duration.toFixed(0)}ms`\n\n spinner.suffixText = c.yellow(message)\n\n performance.clearMarks()\n })\n\n performanceOpserver.observe({ type: 'measure' })\n }\n\n const { root: _root, ...userConfig } = config\n const logLevel = logger.logLevel\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n spinner.start(`🚀 Building ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n const { pluginManager, error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n const summary = getSummary({ pluginManager, config, status: error ? 'failed' : 'success', hrstart, logger })\n\n if (error) {\n spinner.suffixText = ''\n spinner.fail(`🚀 Build failed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n\n throw error\n }\n\n await executeHooks({ hooks: config.hooks, logLevel })\n\n spinner.suffixText = ''\n spinner.succeed(`🚀 Build completed ${logLevel !== 'silent' ? c.dim(inputPath) : ''}`)\n\n console.log(summary.join(''))\n}\n","import path from 'node:path'\n\nimport { LogLevel, randomCliColour } from '@kubb/core/logger'\n\nimport c from 'tinyrainbow'\n\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\nimport type { Config, PluginManager } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\n\ntype SummaryProps = {\n pluginManager: PluginManager\n status: 'success' | 'failed'\n hrstart: [number, number]\n config: Config\n logger: Logger\n}\n\nexport function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {\n const { logLevel } = logger\n const logs: string[] = []\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))\n\n const buildStartPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const buildEndPlugins = pluginManager.executed\n .filter((item) => item.hookName === 'buildEnd' && item.plugin.name !== 'core')\n .map((item) => item.plugin.name)\n\n const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.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?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {\n return 0\n }\n if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {\n return 1\n }\n if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {\n return -1\n }\n return 0\n })\n\n const meta = {\n name: config.name,\n plugins: status === 'success'\n ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`\n : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,\n filesCreated: files.length,\n time: c.yellow(`${elapsedSeconds}s`),\n output: path.resolve(config.root, config.output.path),\n } as const\n\n if (logLevel === LogLevel.debug) {\n logger.emit('debug', ['\\nGenerated files:\\n'])\n logger.emit('debug', files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`))\n }\n\n logs.push(\n [\n [`\\n`, true],\n [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],\n [` ${c.bold('Plugins:')} ${meta.plugins}`, true],\n [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],\n [` ${c.bold('Time:')} ${meta.time}`, true],\n [` ${c.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","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\nimport { Writable } from 'node:stream'\n\nimport c from 'tinyrainbow'\n\nimport type { WritableOptions } from 'node:stream'\nimport type { Ora } from 'ora'\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: BufferEncoding, callback: (error?: Error | null) => void): void {\n this.spinner.suffixText = `\\n\\n${c.bold(c.blue(this.command))}: ${chunk?.toString()}`\n\n callback()\n }\n}\n","import path from 'node:path'\n\nimport { write } from '@kubb/core/fs'\nimport { LogLevel } from '@kubb/core/logger'\nimport { isPromiseFulfilledResult } from '@kubb/core/utils'\n\nimport { $ } from 'execa'\nimport c from 'tinyrainbow'\n\nimport { spinner } from './utils/spinner.ts'\n\ntype Preset = 'simple'\n\ntype PackageManager = 'pnpm' | 'npm' | 'yarn'\n\ntype PresetMeta = {\n 'kubb.config': string\n packages: string[]\n}\n\ntype InitProps = {\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 plugins: [createSwagger({}), createSwaggerTS({ output: { path: 'models'}, enumType: 'enum' }), createSwaggerTanstackQuery({ output: { path: './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' }: InitProps): Promise<undefined> {\n spinner.start('📦 Initializing Kubb')\n\n const presetMeta = presets[preset]\n const configPath = path.resolve(process.cwd(), './kubb.config.js')\n const installCommand = packageManager === 'npm' ? 'install' : 'add'\n\n spinner.start(`📀 Writing \\`kubb.config.js\\` ${c.dim(configPath)}`)\n await write(presetMeta['kubb.config'], configPath)\n spinner.succeed(`📀 Wrote \\`kubb.config.js\\` ${c.dim(configPath)}`)\n\n const results = await Promise.allSettled([\n $`npm init es6 -y`,\n ...presetMeta.packages.map(async (pack) => {\n spinner.start(`📀 Installing ${c.dim(pack)}`)\n const { stdout } = await $({ preferLocal: false })`${packageManager} ${installCommand} ${pack}`\n spinner.succeed(`📀 Installed ${c.dim(pack)}`)\n\n return stdout\n }),\n ])\n\n if (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"],"mappings":";AAAA,OAAOA,WAAU;AAEjB,SAAS,aAAa,gBAAgB,eAAe;AAErD,SAAS,WAAW;AACpB,OAAOC,QAAO;;;ACHZ,cAAW;;;ACFb,SAAS,iBAAiB;;;ACE1B,SAAS,sBAAsB;AAI/B,SAAS,cAAc,SAAmF;AACxG,SAAO,CAAC,CAAE,SAAsD,KAAK,CAAC,WAAW;AAC/E,WAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,QAAQ,GAAG,CAAC,MAAM;AAAA,EAC3D,CAAC;AACH;AAEA,SAAS,gBAAgB,SAAgD;AACvE,SAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ,OAAO;AAC5D;AAEA,eAAe,aAAa,MAAc,SAAiD;AACzF,QAAM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C;AAEzF,UAAM,eAAe,IAAI,OAAO,QAAQ;AAExC;AAAA,EACF;AAEA,QAAM,SAAS,EAAE,OAAO,QAAQ,WAAW,CAAC;AAC9C;AAEA,eAAsB,IAAI,MAAgC;AACxD,QAAM,UAAU,IAAI,UAAU;AAE9B,UAAQ,QAAQ,WAAW,+DAA+D,EAAE,OAAO,cAAc;AAEjH,UACG,QAAQ,oBAAoB,+DAA+D,EAC3F,OAAO,uBAAuB,yBAAyB,EACvD,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,eAAe,oCAAoC,EAC1D,OAAO,cAAc;AAExB,UAAQ,QAAQ,QAAQ,WAAW,EAAE,OAAO,YAAY;AACtD,WAAO,KAAK,EAAE,UAAU,OAAO,CAAC;AAAA,EAClC,CAAC;AAED,UAAQ,KAAK;AACb,UAAQ,QAAQ,OAAO;AACvB,UAAQ,MAAM,MAAM,EAAE,KAAK,MAAM,CAAC;AAElC,MAAI;AACF,UAAM,QAAQ,kBAAkB;AAEhC,YAAQ,KAAK,CAAC;AAAA,EAChB,SAAS,GAAG;AACV,mBAAe,GAAG,QAAQ,OAAO;AAAA,EACnC;AACF;AAEA,IAAO,cAAQ;","names":["path","c","moduleName","path","LogLevel","randomCliColour","c","LogLevel","c","c","LogLevel","c","spinner","callback","LogLevel","c","randomCliColour","path","LogLevel","c","LogLevel","path","c","c","path"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Generator cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"pretty-error": "^4.0.0",
|
|
50
50
|
"string-argv": "^0.3.2",
|
|
51
51
|
"tinyrainbow": "^1.1.1",
|
|
52
|
-
"@kubb/core": "2.
|
|
52
|
+
"@kubb/core": "2.7.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.11.24",
|
|
56
56
|
"source-map-support": "^0.5.21",
|
|
57
57
|
"tsup": "^8.0.2",
|
|
58
58
|
"typescript": "^5.3.3",
|
|
59
|
-
"@kubb/swagger": "2.
|
|
59
|
+
"@kubb/swagger": "2.7.0",
|
|
60
60
|
"@kubb/ts-config": "0.1.0",
|
|
61
61
|
"@kubb/tsup-config": "1.1.8"
|
|
62
62
|
},
|