@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.
- package/README.md +13 -4
- package/dist/chunk-2UGBJEKD.js +209 -0
- package/dist/chunk-2UGBJEKD.js.map +1 -0
- package/dist/{chunk-NKSXZ2SM.cjs → chunk-WAXEQ7ZU.cjs} +1508 -4011
- package/dist/chunk-WAXEQ7ZU.cjs.map +1 -0
- package/dist/{generate-IC27XOTA.js → generate-5JRBGXVI.js} +44 -57
- package/dist/generate-5JRBGXVI.js.map +1 -0
- package/dist/generate-OSUA57KC.cjs +246 -0
- package/dist/generate-OSUA57KC.cjs.map +1 -0
- package/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +11 -18
- package/dist/index.js.map +1 -1
- package/package.json +17 -18
- package/src/commands/generate.ts +33 -25
- package/src/generate.ts +84 -57
- package/src/index.ts +1 -1
- package/src/utils/Writables.ts +23 -0
- package/src/utils/executeHooks.ts +24 -44
- package/src/utils/getPlugins.ts +0 -10
- package/src/utils/getSummary.ts +13 -39
- package/src/utils/watcher.ts +5 -9
- package/bin/bkubb.cjs +0 -6
- package/dist/chunk-NKSXZ2SM.cjs.map +0 -1
- package/dist/chunk-VGYRBGKV.js +0 -252
- package/dist/chunk-VGYRBGKV.js.map +0 -1
- package/dist/generate-IC27XOTA.js.map +0 -1
- package/dist/generate-SW6IGE4J.cjs +0 -228
- package/dist/generate-SW6IGE4J.cjs.map +0 -1
- package/src/utils/OraWritable.ts +0 -22
- package/src/utils/spinner.ts +0 -5
- package/src/utils/writeLog.ts +0 -18
package/src/utils/getSummary.ts
CHANGED
|
@@ -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
|
-
|
|
14
|
+
hrStart: [number, number]
|
|
15
|
+
filesCreated: number
|
|
16
16
|
config: Config
|
|
17
|
-
logger: Logger
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export function getSummary({ pluginManager, status,
|
|
21
|
-
const
|
|
22
|
-
const
|
|
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:
|
|
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
|
-
|
|
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
|
-
['
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
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
|
}
|
package/src/utils/watcher.ts
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
-
|
|
20
|
+
logger?.emit('warning', c.red('Watcher failed'))
|
|
23
21
|
}
|
|
24
22
|
})
|
|
25
|
-
|
|
26
|
-
return
|
|
27
23
|
}
|