@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.
Files changed (57) hide show
  1. package/dist/chunk-56YH3VX6.js +239 -0
  2. package/dist/chunk-56YH3VX6.js.map +1 -0
  3. package/dist/chunk-6N4JBFFS.js +79 -0
  4. package/dist/chunk-6N4JBFFS.js.map +1 -0
  5. package/dist/chunk-72O327DC.cjs +247 -0
  6. package/dist/chunk-72O327DC.cjs.map +1 -0
  7. package/dist/chunk-77QZQ377.cjs +155 -0
  8. package/dist/chunk-77QZQ377.cjs.map +1 -0
  9. package/dist/chunk-ABFPJZJL.cjs +131 -0
  10. package/dist/chunk-ABFPJZJL.cjs.map +1 -0
  11. package/dist/chunk-FOQFLMOC.js +2336 -0
  12. package/dist/chunk-FOQFLMOC.js.map +1 -0
  13. package/dist/chunk-I7UUR5MZ.cjs +91 -0
  14. package/dist/chunk-I7UUR5MZ.cjs.map +1 -0
  15. package/dist/chunk-L6F5QUH2.js +129 -0
  16. package/dist/chunk-L6F5QUH2.js.map +1 -0
  17. package/dist/chunk-PY7I7OEN.cjs +92 -0
  18. package/dist/chunk-PY7I7OEN.cjs.map +1 -0
  19. package/dist/chunk-SX2AYX5F.js +18 -0
  20. package/dist/chunk-SX2AYX5F.js.map +1 -0
  21. package/dist/chunk-WFDR7OMY.js +148 -0
  22. package/dist/chunk-WFDR7OMY.js.map +1 -0
  23. package/dist/chunk-Z7XZQBAK.cjs +2339 -0
  24. package/dist/chunk-Z7XZQBAK.cjs.map +1 -0
  25. package/dist/fs.cjs +19 -2372
  26. package/dist/fs.cjs.map +1 -1
  27. package/dist/fs.js +3 -2373
  28. package/dist/fs.js.map +1 -1
  29. package/dist/index.cjs +219 -3118
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +0 -1
  32. package/dist/index.d.ts +0 -1
  33. package/dist/index.js +55 -3245
  34. package/dist/index.js.map +1 -1
  35. package/dist/logger.cjs +16 -81
  36. package/dist/logger.cjs.map +1 -1
  37. package/dist/logger.d.cts +2 -3
  38. package/dist/logger.d.ts +2 -3
  39. package/dist/logger.js +2 -73
  40. package/dist/logger.js.map +1 -1
  41. package/dist/transformers.cjs +40 -138
  42. package/dist/transformers.cjs.map +1 -1
  43. package/dist/transformers.js +14 -126
  44. package/dist/transformers.js.map +1 -1
  45. package/dist/utils.cjs +29 -461
  46. package/dist/utils.cjs.map +1 -1
  47. package/dist/utils.js +10 -453
  48. package/dist/utils.js.map +1 -1
  49. package/package.json +7 -7
  50. package/src/BarrelManager.ts +3 -3
  51. package/src/FileManager.ts +6 -5
  52. package/src/build.ts +8 -8
  53. package/src/logger.ts +6 -8
  54. package/src/plugin.ts +1 -1
  55. package/src/transformers/casing.ts +3 -3
  56. package/src/utils/FunctionParams.ts +2 -2
  57. package/src/utils/URLPath.ts +5 -5
@@ -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 transformers from './transformers/index.ts'
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: transformers.trimExtName(file.baseName), ...file }
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 !== transformers.trimExtName(file.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 = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: 'process.env', key })
559
+ prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: 'process.env', key })
559
560
  // removes `declare const ...`
560
- prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*\n`, 'ig'), ''), replaceBy, key })
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 pc from 'picocolors'
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, randomPicoColour } from './logger.ts'
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 ' + pc.dim(config.input.path),
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 ${pc.dim(JSON.stringify(plugin.key))} \nwith source\n\n${code}`)
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 = `${randomPicoColour(plugin.name)} Executing ${hookName}`
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 = pc.dim(path)
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 && `${pc.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
141
+ parameters && `${c.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,
142
142
  JSON.stringify(parameters, undefined, 2),
143
- output && `${pc.bgWhite('Output')} ${randomPicoColour(plugin.name)} ${hookName}`,
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 'picocolors/types.ts'
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(pc.yellow(message))
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 randomPicoColour(text?: string, colors = defaultColours): string {
92
- const colours = pc.createColors(true)
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 pc.bold(formatter(text))
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
@@ -21,7 +21,7 @@ type Options = {
21
21
  resolvePath: PluginContext['resolvePath']
22
22
  resolveName: PluginContext['resolveName']
23
23
  logger: PluginContext['logger']
24
- getPlugins: () => KubbPlugin[]
24
+ getPlugins: () => Array<KubbPlugin>
25
25
  plugin?: PluginContext['plugin']
26
26
  }
27
27
 
@@ -1,9 +1,9 @@
1
- import { camelCase as changeCaseCamel, camelCaseTransformMerge, pascalCase as changePascalCase, pascalCaseTransformMerge } from 'change-case'
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: '', stripRegexp: /[^A-Z0-9$]/gi, transform: camelCaseTransformMerge })
4
+ return changeCaseCamel(text, { delimiter: '', mergeAmbiguousCharacters: true })
5
5
  }
6
6
 
7
7
  export function pascalCase(text: string): string {
8
- return changePascalCase(text, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })
8
+ return changePascalCase(text, { delimiter: '', mergeAmbiguousCharacters: true })
9
9
  }
@@ -1,6 +1,6 @@
1
1
  import { orderBy } from 'natural-orderby'
2
2
 
3
- import transformers from '../transformers/index.ts'
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 : transformers.camelCase(name)
70
+ const parameterName = name.startsWith('{') ? name : camelCase(name)
71
71
 
72
72
  if (type) {
73
73
  if (required) {
@@ -1,4 +1,4 @@
1
- import transformers from '../transformers/index.ts'
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(transformers.camelCase(curr))
94
- : transformers.camelCase(curr)
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(transformers.camelCase(item))
118
- : transformers.camelCase(item)
117
+ ? replacer(camelCase(item))
118
+ : camelCase(item)
119
119
 
120
120
  params[pathParam] = pathParam
121
121
  }, this.path)