@kubb/cli 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
@@ -7,20 +7,18 @@ import c from 'tinyrainbow'
7
7
  import { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'
8
8
 
9
9
  import type { Config, PluginManager } from '@kubb/core'
10
- import type { Logger } from '@kubb/core/logger'
11
10
 
12
11
  type SummaryProps = {
13
12
  pluginManager: PluginManager
14
13
  status: 'success' | 'failed'
15
- hrstart: [number, number]
14
+ hrStart: [number, number]
15
+ filesCreated: number
16
16
  config: Config
17
- logger: Logger
18
17
  }
19
18
 
20
- export function getSummary({ pluginManager, status, hrstart, config, logger }: SummaryProps): string[] {
21
- const { logLevel } = logger
22
- const logs: string[] = []
23
- const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrstart))
19
+ export function getSummary({ pluginManager, filesCreated, status, hrStart, config }: SummaryProps): string[] {
20
+ const logs = new Set<string>()
21
+ const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrStart))
24
22
 
25
23
  const buildStartPlugins = pluginManager.executed
26
24
  .filter((item) => item.hookName === 'buildStart' && item.plugin.name !== 'core')
@@ -30,48 +28,24 @@ export function getSummary({ pluginManager, status, hrstart, config, logger }: S
30
28
 
31
29
  const failedPlugins = config.plugins?.filter((plugin) => !buildEndPlugins.includes(plugin.name))?.map((plugin) => plugin.name)
32
30
  const pluginsCount = config.plugins?.length || 0
33
- const files = pluginManager.fileManager.files.sort((a, b) => {
34
- if (!a.meta?.pluginKey?.[0] || !b.meta?.pluginKey?.[0]) {
35
- return 0
36
- }
37
- if (a.meta?.pluginKey?.[0]?.length < b.meta?.pluginKey?.[0]?.length) {
38
- return 1
39
- }
40
- if (a.meta?.pluginKey?.[0]?.length > b.meta?.pluginKey?.[0]?.length) {
41
- return -1
42
- }
43
- return 0
44
- })
45
31
 
46
32
  const meta = {
47
- name: config.name,
48
33
  plugins:
49
34
  status === 'success'
50
35
  ? `${c.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`
51
36
  : `${c.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,
52
37
  pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,
53
- filesCreated: files.length,
54
- time: c.yellow(`${elapsedSeconds}s`),
55
- endTime: c.yellow(Date()),
38
+ filesCreated: filesCreated,
39
+ time: `${c.yellow(`${elapsedSeconds}s`)}`,
56
40
  output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,
57
41
  } as const
58
42
 
59
- logger.emit('debug', ['\nGenerated files:\n'])
60
- logger.emit(
61
- 'debug',
62
- files.map((file) => `${randomCliColour(JSON.stringify(file.meta?.pluginKey))} ${file.path}`),
63
- )
64
-
65
- logs.push(
43
+ logs.add(
66
44
  [
67
- ['\n', true],
68
- [` ${c.bold('Name:')} ${meta.name}`, !!meta.name],
69
- [` ${c.bold('Plugins:')} ${meta.plugins}`, true],
70
- [` ${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],
71
- [`${c.bold('Generated:')} ${meta.filesCreated} files`, true],
72
- [` ${c.bold('Time:')} ${meta.time}`, true],
73
- [` ${c.bold('Ended:')} ${meta.endTime}`, true],
74
- [` ${c.bold('Output:')} ${meta.output}`, true],
45
+ [`${c.bold('Plugins:')} ${meta.plugins}`, true],
46
+ [`${c.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],
47
+ [`${c.bold('Generated:')} ${meta.filesCreated} files in ${meta.time}`, true],
48
+ [`${c.bold('Output:')} ${meta.output}`, true],
75
49
  ]
76
50
  .map((item) => {
77
51
  if (item.at(1)) {
@@ -83,5 +57,5 @@ export function getSummary({ pluginManager, status, hrstart, config, logger }: S
83
57
  .join('\n'),
84
58
  )
85
59
 
86
- return logs
60
+ return [...logs]
87
61
  }
@@ -1,27 +1,23 @@
1
+ import { createLogger } from '@kubb/core/logger'
1
2
  import c from 'tinyrainbow'
2
3
 
3
- import { spinner } from './spinner.ts'
4
-
5
4
  export async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {
6
5
  const { watch } = await import('chokidar')
6
+ const logger = createLogger()
7
7
 
8
- const ignored = ['**/{.git,node_modules}/**']
8
+ const ignored = '**/{.git,node_modules}/**'
9
9
 
10
10
  const watcher = watch(path, {
11
11
  ignorePermissionErrors: true,
12
12
  ignored,
13
13
  })
14
14
  watcher.on('all', (type, file) => {
15
- spinner.succeed(c.yellow(c.bold(`Change detected: ${type} ${file}`)))
16
- // revert back
17
- spinner.spinner = 'clock'
15
+ logger?.emit('info', c.yellow(c.bold(`Change detected: ${type} ${file}`)))
18
16
 
19
17
  try {
20
18
  cb(path)
21
19
  } catch (e) {
22
- spinner.warn(c.red('Watcher failed'))
20
+ logger?.emit('warning', c.red('Watcher failed'))
23
21
  }
24
22
  })
25
-
26
- return
27
23
  }
package/bin/bkubb.cjs DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import('../dist/index.js').then(({ run }) => {
4
- process.title = 'Kubb'
5
- run(process.argv)
6
- })