@kubb/cli 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -34,6 +34,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? requi
34
34
  throw new Error('Dynamic require of "' + x + '" is not supported');
35
35
  });
36
36
 
37
+ // src/utils/parseText.ts
38
+ function parseText(baseText, config, logLevel = "silent") {
39
+ return `${baseText}${config[logLevel] || ""}`;
40
+ }
41
+
37
42
  // src/utils/parseHrtimeToSeconds.ts
38
43
  function parseHrtimeToSeconds(hrtime) {
39
44
  const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
@@ -53,7 +58,7 @@ async function run({ config, options, spinner: spinner2 }) {
53
58
  },
54
59
  spinner: spinner2
55
60
  };
56
- const onDone = async (hooks) => {
61
+ const onDone = async (hooks, logLevel) => {
57
62
  if (!hooks?.done) {
58
63
  return;
59
64
  }
@@ -65,10 +70,10 @@ async function run({ config, options, spinner: spinner2 }) {
65
70
  }
66
71
  const promises = commands.map(async (command) => {
67
72
  const [cmd, ..._args] = [...stringArgv.parseArgsStringToArgv(command)];
68
- spinner2.start(`\u{1FA82} Executing hooks(${pc__default.default.yellow("done")}) ${pc__default.default.dim(command)}`);
73
+ spinner2.start(parseText(`\u{1FA82} Executing hooks(${pc__default.default.yellow("done")})`, { info: ` ${pc__default.default.dim(command)}` }, logLevel));
69
74
  const { stdout } = await execa.execa(cmd, _args);
70
- spinner2.succeed(`\u{1FA82} Executed hooks(${pc__default.default.yellow("done")}) ${pc__default.default.dim(command)}`);
71
- if (config.logLevel === "info") {
75
+ spinner2.succeed(parseText(`\u{1FA82} Executing hooks(${pc__default.default.yellow("done")})`, { info: ` ${pc__default.default.dim(command)}` }, logLevel));
76
+ if (logLevel === "info") {
72
77
  console.log(stdout);
73
78
  }
74
79
  });
@@ -130,15 +135,17 @@ ${error?.message}`));
130
135
  };
131
136
  try {
132
137
  const { root, ...userConfig } = config;
133
- spinner2.start(`\u{1F680} Building(${pc__default.default.dim(options.input ?? userConfig.input.path)})`);
138
+ const logLevel = options.logLevel ?? userConfig.logLevel ?? "silent";
139
+ const inputPath = options.input ?? userConfig.input.path;
140
+ spinner2.start(parseText(`\u{1F680} Building`, { info: `(${pc__default.default.dim(inputPath)})` }, logLevel));
134
141
  const output = await core.build({
135
142
  config: {
136
143
  root: process.cwd(),
137
- logLevel: "silent",
138
144
  ...userConfig,
145
+ logLevel,
139
146
  input: {
140
147
  ...userConfig.input,
141
- path: options.input ?? userConfig.input.path
148
+ path: inputPath
142
149
  },
143
150
  output: {
144
151
  write: true,
@@ -147,8 +154,8 @@ ${error?.message}`));
147
154
  },
148
155
  logger
149
156
  });
150
- spinner2.succeed(`\u{1F680} Build completed(${pc__default.default.dim(options.input ?? userConfig.input.path)})`);
151
- await onDone(config.hooks);
157
+ spinner2.succeed(parseText(`\u{1F680} Build completed`, { info: `(${pc__default.default.dim(inputPath)})` }, logLevel));
158
+ await onDone(config.hooks, logLevel);
152
159
  printSummary(output.pluginManager, "success");
153
160
  } catch (error) {
154
161
  printErrors(error);
@@ -304,7 +311,7 @@ async function getCosmiConfig(moduleName2, config) {
304
311
  }
305
312
 
306
313
  // package.json
307
- var version = "1.1.2";
314
+ var version = "1.1.3";
308
315
 
309
316
  // src/index.ts
310
317
  var moduleName = "kubb";
@@ -338,5 +345,5 @@ var program = new commander.Command(moduleName).description("Kubb").action(async
338
345
  } catch (e) {
339
346
  process.exit(1);
340
347
  }
341
- }).addOption(new commander.Option("-c, --config <path>", "Path to the Kubb config")).addOption(new commander.Option("-i, --input <path>", "Path of the input file(overrides the on in `kubb.config.js`)")).addOption(new commander.Option("-d, --debug", "Debug mode").default(false)).addOption(new commander.Option("-w, --watch", "Watch mode based on the input file"));
348
+ }).addOption(new commander.Option("-c, --config <path>", "Path to the Kubb config")).addOption(new commander.Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new commander.Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["error", "info", "silent"])).addOption(new commander.Option("-d, --debug", "Debug mode").default(false)).addOption(new commander.Option("-w, --watch", "Watch mode based on the input file"));
342
349
  program.name(moduleName).description("Generate").version(version, "-v").parse();
package/dist/index.js CHANGED
@@ -23,6 +23,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
23
  throw new Error('Dynamic require of "' + x + '" is not supported');
24
24
  });
25
25
 
26
+ // src/utils/parseText.ts
27
+ function parseText(baseText, config, logLevel = "silent") {
28
+ return `${baseText}${config[logLevel] || ""}`;
29
+ }
30
+
26
31
  // src/utils/parseHrtimeToSeconds.ts
27
32
  function parseHrtimeToSeconds(hrtime) {
28
33
  const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
@@ -42,7 +47,7 @@ async function run({ config, options, spinner: spinner2 }) {
42
47
  },
43
48
  spinner: spinner2
44
49
  };
45
- const onDone = async (hooks) => {
50
+ const onDone = async (hooks, logLevel) => {
46
51
  if (!hooks?.done) {
47
52
  return;
48
53
  }
@@ -54,10 +59,10 @@ async function run({ config, options, spinner: spinner2 }) {
54
59
  }
55
60
  const promises = commands.map(async (command) => {
56
61
  const [cmd, ..._args] = [...parseArgsStringToArgv(command)];
57
- spinner2.start(`\u{1FA82} Executing hooks(${pc.yellow("done")}) ${pc.dim(command)}`);
62
+ spinner2.start(parseText(`\u{1FA82} Executing hooks(${pc.yellow("done")})`, { info: ` ${pc.dim(command)}` }, logLevel));
58
63
  const { stdout } = await execa(cmd, _args);
59
- spinner2.succeed(`\u{1FA82} Executed hooks(${pc.yellow("done")}) ${pc.dim(command)}`);
60
- if (config.logLevel === "info") {
64
+ spinner2.succeed(parseText(`\u{1FA82} Executing hooks(${pc.yellow("done")})`, { info: ` ${pc.dim(command)}` }, logLevel));
65
+ if (logLevel === "info") {
61
66
  console.log(stdout);
62
67
  }
63
68
  });
@@ -119,15 +124,17 @@ ${error?.message}`));
119
124
  };
120
125
  try {
121
126
  const { root, ...userConfig } = config;
122
- spinner2.start(`\u{1F680} Building(${pc.dim(options.input ?? userConfig.input.path)})`);
127
+ const logLevel = options.logLevel ?? userConfig.logLevel ?? "silent";
128
+ const inputPath = options.input ?? userConfig.input.path;
129
+ spinner2.start(parseText(`\u{1F680} Building`, { info: `(${pc.dim(inputPath)})` }, logLevel));
123
130
  const output = await build({
124
131
  config: {
125
132
  root: process.cwd(),
126
- logLevel: "silent",
127
133
  ...userConfig,
134
+ logLevel,
128
135
  input: {
129
136
  ...userConfig.input,
130
- path: options.input ?? userConfig.input.path
137
+ path: inputPath
131
138
  },
132
139
  output: {
133
140
  write: true,
@@ -136,8 +143,8 @@ ${error?.message}`));
136
143
  },
137
144
  logger
138
145
  });
139
- spinner2.succeed(`\u{1F680} Build completed(${pc.dim(options.input ?? userConfig.input.path)})`);
140
- await onDone(config.hooks);
146
+ spinner2.succeed(parseText(`\u{1F680} Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel));
147
+ await onDone(config.hooks, logLevel);
141
148
  printSummary(output.pluginManager, "success");
142
149
  } catch (error) {
143
150
  printErrors(error);
@@ -293,7 +300,7 @@ async function getCosmiConfig(moduleName2, config) {
293
300
  }
294
301
 
295
302
  // package.json
296
- var version = "1.1.2";
303
+ var version = "1.1.3";
297
304
 
298
305
  // src/index.ts
299
306
  var moduleName = "kubb";
@@ -327,5 +334,5 @@ var program = new Command(moduleName).description("Kubb").action(async (options)
327
334
  } catch (e) {
328
335
  process.exit(1);
329
336
  }
330
- }).addOption(new Option("-c, --config <path>", "Path to the Kubb config")).addOption(new Option("-i, --input <path>", "Path of the input file(overrides the on in `kubb.config.js`)")).addOption(new Option("-d, --debug", "Debug mode").default(false)).addOption(new Option("-w, --watch", "Watch mode based on the input file"));
337
+ }).addOption(new Option("-c, --config <path>", "Path to the Kubb config")).addOption(new Option("-i, --input <path>", "Path of the input file(overrides the one in `kubb.config.js`)")).addOption(new Option("-l, --logLevel <type>", "Type of the logging(overrides the one in `kubb.config.js`)").choices(["error", "info", "silent"])).addOption(new Option("-d, --debug", "Debug mode").default(false)).addOption(new Option("-w, --watch", "Watch mode based on the input file"));
331
338
  program.name(moduleName).description("Generate").version(version, "-v").parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Generator cli",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,13 +43,13 @@
43
43
  "yaml": "^2.3.1",
44
44
  "@swc/core": "^1.3.62",
45
45
  "pretty-error": "^4.0.0",
46
- "@kubb/core": "1.1.2"
46
+ "@kubb/core": "1.1.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^20.2.5",
50
50
  "tsup": "^6.7.0",
51
51
  "typescript": "^5.1.3",
52
- "@kubb/swagger": "1.1.2"
52
+ "@kubb/swagger": "1.1.3"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public",
package/src/index.ts CHANGED
@@ -56,7 +56,8 @@ const program = new Command(moduleName)
56
56
  }
57
57
  })
58
58
  .addOption(new Option('-c, --config <path>', 'Path to the Kubb config'))
59
- .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the on in `kubb.config.js`)'))
59
+ .addOption(new Option('-i, --input <path>', 'Path of the input file(overrides the one in `kubb.config.js`)'))
60
+ .addOption(new Option('-l, --logLevel <type>', 'Type of the logging(overrides the one in `kubb.config.js`)').choices(['error', 'info', 'silent']))
60
61
  .addOption(new Option('-d, --debug', 'Debug mode').default(false))
61
62
  .addOption(new Option('-w, --watch', 'Watch mode based on the input file'))
62
63
 
package/src/run.ts CHANGED
@@ -7,8 +7,9 @@ import { parseArgsStringToArgv } from 'string-argv'
7
7
  import PrettyError from 'pretty-error'
8
8
 
9
9
  import { ParallelPluginError, PluginError, build } from '@kubb/core'
10
- import type { Logger, CLIOptions, KubbConfig, BuildOutput } from '@kubb/core'
10
+ import type { Logger, CLIOptions, KubbConfig, BuildOutput, LogLevel } from '@kubb/core'
11
11
 
12
+ import { parseText } from './utils/parseText.ts'
12
13
  import { parseHrtimeToSeconds } from './utils/parseHrtimeToSeconds.ts'
13
14
 
14
15
  import type { Ora } from 'ora'
@@ -32,7 +33,7 @@ export async function run({ config, options, spinner }: RunProps): Promise<void>
32
33
  spinner,
33
34
  }
34
35
 
35
- const onDone = async (hooks: KubbConfig['hooks']) => {
36
+ const onDone = async (hooks: KubbConfig['hooks'], logLevel: LogLevel) => {
36
37
  if (!hooks?.done) {
37
38
  return
38
39
  }
@@ -46,11 +47,11 @@ export async function run({ config, options, spinner }: RunProps): Promise<void>
46
47
 
47
48
  const promises = commands.map(async (command) => {
48
49
  const [cmd, ..._args] = [...parseArgsStringToArgv(command)]
49
- spinner.start(`🪂 Executing hooks(${pc.yellow('done')}) ${pc.dim(command)}`)
50
+ spinner.start(parseText(`🪂 Executing hooks(${pc.yellow('done')})`, { info: ` ${pc.dim(command)}` }, logLevel))
50
51
  const { stdout } = await execa(cmd, _args)
51
- spinner.succeed(`🪂 Executed hooks(${pc.yellow('done')}) ${pc.dim(command)}`)
52
+ spinner.succeed(parseText(`🪂 Executing hooks(${pc.yellow('done')})`, { info: ` ${pc.dim(command)}` }, logLevel))
52
53
 
53
- if (config.logLevel === 'info') {
54
+ if (logLevel === 'info') {
54
55
  console.log(stdout)
55
56
  }
56
57
  })
@@ -123,17 +124,19 @@ ${pc.bold('Generated:')} ${meta.filesCreated} files
123
124
  try {
124
125
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars
125
126
  const { root, ...userConfig } = config
127
+ const logLevel = options.logLevel ?? userConfig.logLevel ?? 'silent'
128
+ const inputPath = options.input ?? userConfig.input.path
126
129
 
127
- spinner.start(`🚀 Building(${pc.dim(options.input ?? userConfig.input.path)})`)
130
+ spinner.start(parseText(`🚀 Building`, { info: `(${pc.dim(inputPath)})` }, logLevel))
128
131
 
129
132
  const output = await build({
130
133
  config: {
131
134
  root: process.cwd(),
132
- logLevel: 'silent',
133
135
  ...userConfig,
136
+ logLevel,
134
137
  input: {
135
138
  ...userConfig.input,
136
- path: options.input ?? userConfig.input.path,
139
+ path: inputPath,
137
140
  },
138
141
  output: {
139
142
  write: true,
@@ -143,9 +146,9 @@ ${pc.bold('Generated:')} ${meta.filesCreated} files
143
146
  logger,
144
147
  })
145
148
 
146
- spinner.succeed(`🚀 Build completed(${pc.dim(options.input ?? userConfig.input.path)})`)
149
+ spinner.succeed(parseText(`🚀 Build completed`, { info: `(${pc.dim(inputPath)})` }, logLevel))
147
150
 
148
- await onDone(config.hooks)
151
+ await onDone(config.hooks, logLevel)
149
152
 
150
153
  printSummary(output.pluginManager, 'success')
151
154
  } catch (error: any) {
@@ -4,3 +4,4 @@ export * from './watcher.ts'
4
4
  export * from './getCosmiConfig.ts'
5
5
  export * from './importModule.ts'
6
6
  export * from './parseHrtimeToSeconds.ts'
7
+ export * from './parseText.ts'
@@ -0,0 +1,5 @@
1
+ import type { LogLevel } from '@kubb/core'
2
+
3
+ export function parseText(baseText: string, config: Partial<Record<LogLevel, string>>, logLevel: LogLevel = 'silent') {
4
+ return `${baseText}${config[logLevel] || ''}`
5
+ }