@kubb/core 4.2.1 → 4.3.0
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 +10 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +4 -1
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.js +3 -1
- package/dist/mocks.js.map +1 -1
- package/package.json +3 -3
- package/src/build.ts +10 -6
- package/src/mocks/index.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"!/**/__tests__/**"
|
|
88
88
|
],
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@kubb/fabric-core": "0.
|
|
90
|
+
"@kubb/fabric-core": "0.1.5",
|
|
91
91
|
"@kubb/parser-ts": "^4.1.4",
|
|
92
92
|
"camelcase": "^8.0.0",
|
|
93
93
|
"find-up": "^7.0.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"remeda": "^2.32.0",
|
|
101
101
|
"seedrandom": "^3.0.5",
|
|
102
102
|
"semver": "^7.7.3",
|
|
103
|
-
"@kubb/react": "4.
|
|
103
|
+
"@kubb/react": "4.3.0"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@types/fs-extra": "^11.0.4",
|
package/src/build.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { join, relative, resolve } from 'node:path'
|
|
|
2
2
|
import pc from 'picocolors'
|
|
3
3
|
import { isDeepEqual } from 'remeda'
|
|
4
4
|
import { isInputPath } from './config.ts'
|
|
5
|
-
import type
|
|
5
|
+
import { type KubbFile, write } from './fs/index.ts'
|
|
6
6
|
import { clean, exists, getRelativePath } from './fs/index.ts'
|
|
7
7
|
import type { Logger } from './logger.ts'
|
|
8
8
|
import { createLogger } from './logger.ts'
|
|
9
9
|
import { PluginManager } from './PluginManager.ts'
|
|
10
10
|
import type { Config, Output, UserConfig } from './types.ts'
|
|
11
11
|
import { URLPath } from './utils/URLPath.ts'
|
|
12
|
+
import { typescriptParser } from '@kubb/react'
|
|
12
13
|
|
|
13
14
|
type BuildOptions = {
|
|
14
15
|
config: UserConfig
|
|
@@ -164,24 +165,27 @@ export async function safeBuild(options: BuildOptions): Promise<BuildOutput> {
|
|
|
164
165
|
await pluginManager.fileManager.add(rootFile)
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
pluginManager.fileManager.processor.on('start', ({ files }) => {
|
|
168
|
+
pluginManager.fileManager.processor.events.on('process:start', ({ files }) => {
|
|
168
169
|
pluginManager.logger.emit('progress_start', { id: 'files', size: files.length, message: 'Writing files ...' })
|
|
169
170
|
})
|
|
170
171
|
|
|
171
|
-
pluginManager.fileManager.processor.on('
|
|
172
|
+
pluginManager.fileManager.processor.events.on('process:progress', async ({ file, source }) => {
|
|
172
173
|
const message = file ? `Writing ${relative(config.root, file.path)}` : ''
|
|
173
174
|
pluginManager.logger.emit('progressed', { id: 'files', message })
|
|
174
|
-
})
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
await write(file.path, source, { sanity: false })
|
|
177
|
+
})
|
|
177
178
|
|
|
178
|
-
pluginManager.fileManager.processor.on('
|
|
179
|
+
pluginManager.fileManager.processor.events.on('process:end', () => {
|
|
179
180
|
pluginManager.logger.emit('progress_stop', { id: 'files' })
|
|
180
181
|
})
|
|
181
182
|
|
|
183
|
+
const parsers = new Set<any>([typescriptParser])
|
|
184
|
+
|
|
182
185
|
const files = await pluginManager.fileManager.write({
|
|
183
186
|
extension: config.output.extension,
|
|
184
187
|
dryRun: !config.output.write,
|
|
188
|
+
parsers,
|
|
185
189
|
})
|
|
186
190
|
|
|
187
191
|
await pluginManager.hookParallel({ hookName: 'buildEnd', message: `Build stopped for ${config.name}` })
|
package/src/mocks/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Logger } from '../logger'
|
|
|
6
6
|
import type { PluginManager } from '../PluginManager.ts'
|
|
7
7
|
import { camelCase, pascalCase } from '../transformers/casing.ts'
|
|
8
8
|
import type { Plugin } from '../types.ts'
|
|
9
|
+
import { typescriptParser } from '@kubb/fabric-core/parsers/typescript'
|
|
9
10
|
|
|
10
11
|
export const mockedLogger = {
|
|
11
12
|
emit(_type, _message) {},
|
|
@@ -67,9 +68,10 @@ export async function matchFiles(files: Array<ResolvedFile | File> | undefined,
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
const fileProcessor = new FileProcessor()
|
|
71
|
+
const parsers = new Set<any>([typescriptParser])
|
|
70
72
|
|
|
71
73
|
for await (const file of files) {
|
|
72
|
-
const source = await fileProcessor.parse(createFile(file))
|
|
74
|
+
const source = await fileProcessor.parse(createFile(file), { parsers })
|
|
73
75
|
let code = source
|
|
74
76
|
if (!file.baseName.endsWith('.json')) {
|
|
75
77
|
code = await format(source)
|