@kubb/core 2.0.0-beta.11 → 2.0.0-beta.13
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/chunk-56YH3VX6.js +239 -0
- package/dist/chunk-56YH3VX6.js.map +1 -0
- package/dist/chunk-6N4JBFFS.js +79 -0
- package/dist/chunk-6N4JBFFS.js.map +1 -0
- package/dist/chunk-72O327DC.cjs +247 -0
- package/dist/chunk-72O327DC.cjs.map +1 -0
- package/dist/chunk-77QZQ377.cjs +155 -0
- package/dist/chunk-77QZQ377.cjs.map +1 -0
- package/dist/chunk-ABFPJZJL.cjs +131 -0
- package/dist/chunk-ABFPJZJL.cjs.map +1 -0
- package/dist/chunk-FOQFLMOC.js +2336 -0
- package/dist/chunk-FOQFLMOC.js.map +1 -0
- package/dist/chunk-I7UUR5MZ.cjs +91 -0
- package/dist/chunk-I7UUR5MZ.cjs.map +1 -0
- package/dist/chunk-L6F5QUH2.js +129 -0
- package/dist/chunk-L6F5QUH2.js.map +1 -0
- package/dist/chunk-PY7I7OEN.cjs +92 -0
- package/dist/chunk-PY7I7OEN.cjs.map +1 -0
- package/dist/chunk-SX2AYX5F.js +18 -0
- package/dist/chunk-SX2AYX5F.js.map +1 -0
- package/dist/chunk-WFDR7OMY.js +148 -0
- package/dist/chunk-WFDR7OMY.js.map +1 -0
- package/dist/chunk-Z7XZQBAK.cjs +2339 -0
- package/dist/chunk-Z7XZQBAK.cjs.map +1 -0
- package/dist/fs.cjs +19 -2372
- package/dist/fs.cjs.map +1 -1
- package/dist/fs.js +3 -2373
- package/dist/fs.js.map +1 -1
- package/dist/index.cjs +219 -3118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +55 -3245
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +16 -81
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +2 -3
- package/dist/logger.d.ts +2 -3
- package/dist/logger.js +2 -73
- package/dist/logger.js.map +1 -1
- package/dist/transformers.cjs +40 -138
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +14 -126
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +29 -461
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +10 -453
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/BarrelManager.ts +3 -3
- package/src/FileManager.ts +6 -5
- package/src/build.ts +8 -8
- package/src/logger.ts +6 -8
- package/src/plugin.ts +1 -1
- package/src/transformers/casing.ts +3 -3
- package/src/utils/FunctionParams.ts +2 -2
- package/src/utils/URLPath.ts +5 -5
package/src/FileManager.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { orderBy } from 'natural-orderby'
|
|
|
10
10
|
|
|
11
11
|
import { getRelativePath, read } from './fs/read.ts'
|
|
12
12
|
import { write } from './fs/write.ts'
|
|
13
|
-
import
|
|
13
|
+
import { searchAndReplace } from './transformers/searchAndReplace.ts'
|
|
14
|
+
import { trimExtName } from './transformers/trim.ts'
|
|
14
15
|
import { timeout } from './utils/timeout.ts'
|
|
15
16
|
import { BarrelManager } from './BarrelManager.ts'
|
|
16
17
|
|
|
@@ -262,7 +263,7 @@ export class FileManager {
|
|
|
262
263
|
|
|
263
264
|
async #add(file: KubbFile.File): Promise<KubbFile.ResolvedFile> {
|
|
264
265
|
const controller = new AbortController()
|
|
265
|
-
const resolvedFile: KubbFile.ResolvedFile = { id: crypto.randomUUID(), name:
|
|
266
|
+
const resolvedFile: KubbFile.ResolvedFile = { id: crypto.randomUUID(), name: trimExtName(file.baseName), ...file }
|
|
266
267
|
|
|
267
268
|
this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }])
|
|
268
269
|
|
|
@@ -418,7 +419,7 @@ export function getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMet
|
|
|
418
419
|
const importNodes = imports.filter(item => {
|
|
419
420
|
// isImportNotNeeded
|
|
420
421
|
// trim extName
|
|
421
|
-
return item.path !==
|
|
422
|
+
return item.path !== trimExtName(file.path)
|
|
422
423
|
}).map((item) => {
|
|
423
424
|
return factory.createImportDeclaration({
|
|
424
425
|
name: item.name,
|
|
@@ -555,9 +556,9 @@ function getEnvSource(source: string, env: NodeJS.ProcessEnv | undefined): strin
|
|
|
555
556
|
}
|
|
556
557
|
|
|
557
558
|
if (typeof replaceBy === 'string') {
|
|
558
|
-
prev =
|
|
559
|
+
prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: 'process.env', key })
|
|
559
560
|
// removes `declare const ...`
|
|
560
|
-
prev =
|
|
561
|
+
prev = searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*\n`, 'ig'), ''), replaceBy, key })
|
|
561
562
|
}
|
|
562
563
|
|
|
563
564
|
return prev
|
package/src/build.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from 'tinyrainbow'
|
|
2
2
|
|
|
3
3
|
import { clean } from './fs/clean.ts'
|
|
4
4
|
import { read } from './fs/read.ts'
|
|
5
5
|
import { URLPath } from './utils/URLPath.ts'
|
|
6
6
|
import { isInputPath } from './config.ts'
|
|
7
7
|
import { FileManager } from './FileManager.ts'
|
|
8
|
-
import { createLogger, LogLevel,
|
|
8
|
+
import { createLogger, LogLevel, randomCliColour } from './logger.ts'
|
|
9
9
|
import { PluginManager } from './PluginManager.ts'
|
|
10
10
|
import { isPromise } from './PromiseManager.ts'
|
|
11
11
|
|
|
@@ -50,7 +50,7 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
|
50
50
|
} catch (e) {
|
|
51
51
|
if (isInputPath(config)) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' +
|
|
53
|
+
'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' + c.dim(config.input.path),
|
|
54
54
|
{
|
|
55
55
|
cause: e,
|
|
56
56
|
},
|
|
@@ -116,20 +116,20 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
if (logger.logLevel === LogLevel.debug) {
|
|
119
|
-
logger.info(`PluginKey ${
|
|
119
|
+
logger.info(`PluginKey ${c.dim(JSON.stringify(plugin.key))} \nwith source\n\n${code}`)
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
})
|
|
123
123
|
|
|
124
124
|
pluginManager.on('executed', (executer) => {
|
|
125
125
|
const { hookName, plugin, output, parameters } = executer
|
|
126
|
-
const messsage = `${
|
|
126
|
+
const messsage = `${randomCliColour(plugin.name)} Executing ${hookName}`
|
|
127
127
|
|
|
128
128
|
if (logger.logLevel === LogLevel.info && logger.spinner) {
|
|
129
129
|
if (hookName === 'writeFile') {
|
|
130
130
|
const [_code, path] = parameters as PluginParameter<'writeFile'>
|
|
131
131
|
|
|
132
|
-
logger.spinner.suffixText =
|
|
132
|
+
logger.spinner.suffixText = c.dim(path)
|
|
133
133
|
} else {
|
|
134
134
|
logger.spinner.suffixText = messsage
|
|
135
135
|
}
|
|
@@ -138,9 +138,9 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
|
|
|
138
138
|
if (logger.logLevel === LogLevel.debug) {
|
|
139
139
|
logger.info(messsage)
|
|
140
140
|
const logs = [
|
|
141
|
-
parameters && `${
|
|
141
|
+
parameters && `${c.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,
|
|
142
142
|
JSON.stringify(parameters, undefined, 2),
|
|
143
|
-
output && `${
|
|
143
|
+
output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,
|
|
144
144
|
output,
|
|
145
145
|
].filter(Boolean)
|
|
146
146
|
|
package/src/logger.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import pc from 'picocolors'
|
|
2
1
|
import seedrandom from 'seedrandom'
|
|
2
|
+
import c, { createColors } from 'tinyrainbow'
|
|
3
3
|
|
|
4
4
|
import type { Ora } from 'ora'
|
|
5
|
-
import type { Formatter } from '
|
|
5
|
+
import type { Formatter } from 'tinyrainbow'
|
|
6
6
|
|
|
7
7
|
export const LogLevel = {
|
|
8
8
|
silent: 'silent',
|
|
@@ -49,7 +49,7 @@ export function createLogger({ logLevel, name, spinner }: Props): Logger {
|
|
|
49
49
|
|
|
50
50
|
const warn: Logger['warn'] = (message) => {
|
|
51
51
|
if (message && spinner) {
|
|
52
|
-
spinner.warn(
|
|
52
|
+
spinner.warn(c.yellow(message))
|
|
53
53
|
logs.push(message)
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -88,8 +88,8 @@ export function randomColour(text?: string, colours = defaultColours): string {
|
|
|
88
88
|
return colour
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export function
|
|
92
|
-
const colours =
|
|
91
|
+
export function randomCliColour(text?: string, colors = defaultColours): string {
|
|
92
|
+
const colours = createColors(true)
|
|
93
93
|
|
|
94
94
|
if (!text) {
|
|
95
95
|
return colours.white(text)
|
|
@@ -101,7 +101,7 @@ export function randomPicoColour(text?: string, colors = defaultColours): string
|
|
|
101
101
|
const formatter: Formatter = colours[key] as Formatter
|
|
102
102
|
|
|
103
103
|
if (isDark) {
|
|
104
|
-
return
|
|
104
|
+
return c.bold(formatter(text))
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
if (typeof formatter !== 'function') {
|
|
@@ -109,5 +109,3 @@ export function randomPicoColour(text?: string, colors = defaultColours): string
|
|
|
109
109
|
}
|
|
110
110
|
return formatter(text)
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
export { default as pc } from 'picocolors'
|
package/src/plugin.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { camelCase as changeCaseCamel,
|
|
1
|
+
import { camelCase as changeCaseCamel, pascalCase as changePascalCase } from 'change-case'
|
|
2
2
|
|
|
3
3
|
export function camelCase(text: string): string {
|
|
4
|
-
return changeCaseCamel(text, { delimiter: '',
|
|
4
|
+
return changeCaseCamel(text, { delimiter: '', mergeAmbiguousCharacters: true })
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function pascalCase(text: string): string {
|
|
8
|
-
return changePascalCase(text, { delimiter: '',
|
|
8
|
+
return changePascalCase(text, { delimiter: '', mergeAmbiguousCharacters: true })
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { orderBy } from 'natural-orderby'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { camelCase } from '../transformers/casing.ts'
|
|
4
4
|
|
|
5
5
|
type FunctionParamsASTWithoutType = {
|
|
6
6
|
name?: string
|
|
@@ -67,7 +67,7 @@ export class FunctionParams {
|
|
|
67
67
|
return acc
|
|
68
68
|
}
|
|
69
69
|
// TODO check whey we still need the camelcase here
|
|
70
|
-
const parameterName = name.startsWith('{') ? name :
|
|
70
|
+
const parameterName = name.startsWith('{') ? name : camelCase(name)
|
|
71
71
|
|
|
72
72
|
if (type) {
|
|
73
73
|
if (required) {
|
package/src/utils/URLPath.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { camelCase } from '../transformers/casing.ts'
|
|
2
2
|
|
|
3
3
|
export type URLObject = {
|
|
4
4
|
url: string
|
|
@@ -90,8 +90,8 @@ export class URLPath {
|
|
|
90
90
|
if (found) {
|
|
91
91
|
newPath = found.reduce((prev, curr) => {
|
|
92
92
|
const pathParam = replacer
|
|
93
|
-
? replacer(
|
|
94
|
-
:
|
|
93
|
+
? replacer(camelCase(curr))
|
|
94
|
+
: camelCase(curr)
|
|
95
95
|
const replacement = `\${${pathParam}}`
|
|
96
96
|
|
|
97
97
|
return prev.replace(curr, replacement)
|
|
@@ -114,8 +114,8 @@ export class URLPath {
|
|
|
114
114
|
item = item.replaceAll('{', '').replaceAll('}', '')
|
|
115
115
|
|
|
116
116
|
const pathParam = replacer
|
|
117
|
-
? replacer(
|
|
118
|
-
:
|
|
117
|
+
? replacer(camelCase(item))
|
|
118
|
+
: camelCase(item)
|
|
119
119
|
|
|
120
120
|
params[pathParam] = pathParam
|
|
121
121
|
}, this.path)
|