Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kubb/core

Package Overview
Dependencies
Maintainers
1
Versions
662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubb/core - npm Package Compare versions

Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8

dist/chunk-27CPVXAT.js

10

dist/index.js

@@ -13,3 +13,3 @@ import {

setUniqueName
} from "./chunk-BHZAXMKP.js";
} from "./chunk-27CPVXAT.js";
import "./chunk-4X5FFJPJ.js";

@@ -501,3 +501,3 @@ import "./chunk-HBQM723K.js";

this.executed.push(executer);
this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name}` });
this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(", ") || ""}` });
}

@@ -681,3 +681,3 @@ }

const barrelFiles = pluginManager.fileManager.files.filter((file) => {
return file.sources.some((source) => source.isExportable);
return file.sources.some((source) => source.isIndexable);
});

@@ -689,3 +689,3 @@ const rootFile = {

return file.sources?.map((source) => {
if (!file.path || !source.isExportable) {
if (!file.path || !source.isIndexable) {
return void 0;

@@ -704,3 +704,3 @@ }

return {
name: [source.name],
name: options.config.output.exportType === "barrel" ? void 0 : [source.name],
path: getRelativePath(rootPath, file.path),

@@ -707,0 +707,0 @@ isTypeOnly: source.isTypeOnly

import {
getSource
} from "./chunk-BHZAXMKP.js";
} from "./chunk-27CPVXAT.js";
import {

@@ -5,0 +5,0 @@ camelCase,

@@ -16,3 +16,3 @@ import {

timeout
} from "./chunk-BHZAXMKP.js";
} from "./chunk-27CPVXAT.js";
import "./chunk-4X5FFJPJ.js";

@@ -19,0 +19,0 @@ export {

{
"name": "@kubb/core",
"version": "3.0.0-alpha.7",
"version": "3.0.0-alpha.8",
"description": "Generator core",

@@ -87,5 +87,5 @@ "keywords": [

"unraw": "^3.0.0",
"@kubb/fs": "3.0.0-alpha.7",
"@kubb/parser-ts": "3.0.0-alpha.7",
"@kubb/types": "3.0.0-alpha.7"
"@kubb/fs": "3.0.0-alpha.8",
"@kubb/parser-ts": "3.0.0-alpha.8",
"@kubb/types": "3.0.0-alpha.8"
},

@@ -102,5 +102,5 @@ "devDependencies": {

"typescript": "^5.5.4",
"@kubb/config-biome": "3.0.0-alpha.7",
"@kubb/config-ts": "3.0.0-alpha.7",
"@kubb/config-tsup": "3.0.0-alpha.7"
"@kubb/config-biome": "3.0.0-alpha.8",
"@kubb/config-ts": "3.0.0-alpha.8",
"@kubb/config-tsup": "3.0.0-alpha.8"
},

@@ -107,0 +107,0 @@ "engines": {

@@ -30,15 +30,18 @@ [

{
"name": "hello",
"name": "test",
"value": "",
"isExportable": false
"isExportable": false,
"isIndexable": false
},
{
"name": "world",
"name": "hello",
"value": "",
"isExportable": false
"isExportable": false,
"isIndexable": false
},
{
"name": "test",
"name": "world",
"value": "",
"isExportable": false
"isExportable": false,
"isIndexable": false
}

@@ -74,3 +77,4 @@ ],

"value": "",
"isExportable": false
"isExportable": false,
"isIndexable": false
},

@@ -80,3 +84,4 @@ {

"value": "",
"isExportable": false
"isExportable": false,
"isIndexable": false
}

@@ -83,0 +88,0 @@ ],

@@ -7,3 +7,3 @@ import { join } from 'node:path'

import type * as KubbFile from '@kubb/fs/types'
import { combineExports } from './FileManager.ts'
import { combineExports, combineSources } from './FileManager.ts'
import type { Logger } from './logger.ts'

@@ -27,75 +27,64 @@

const files = TreeNode.build(generatedFiles, root)
?.map((treeNode) => {
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
return undefined
}
const files = new Map<KubbFile.Path, KubbFile.File>()
const barrelPath: KubbFile.Path = join(treeNode.parent?.data.path, 'index.ts')
TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
return undefined
}
const leaves = treeNode.leaves
const barrelPath: KubbFile.Path = join(treeNode.parent?.data.path, 'index.ts')
// biome-ignore lint/complexity/useFlatMap: we have a custom map in TreeNode
const exports = leaves
.map((item) => {
if (!item.data.name) {
return undefined
}
const leaves = treeNode.leaves
const sources = item.data.file?.sources || []
// biome-ignore lint/complexity/useFlatMap: we have a custom map in TreeNode
const exports = leaves
.map((item) => {
if (!item.data.name) {
return undefined
}
if (!sources.some((source) => source.isExportable)) {
logger?.emit(
'warning',
`No exportable source found(source should have a name and isExportable):\nFile: ${JSON.stringify(item.data.file, undefined, 2)}`,
)
}
const sources = item.data.file?.sources || []
return sources.map((source) => {
if (!item.data.file?.path || !source.isExportable) {
return undefined
}
if (!sources.some((source) => source.isIndexable)) {
logger?.emit(
'warning',
`No isIndexable source found(source should have a name and isIndexable):\nFile: ${JSON.stringify(item.data.file, undefined, 2)}`,
)
}
// true when we have a subdirectory that also contains barrel files
const isSubExport = !!treeNode.parent?.data.path?.split?.('/')?.length
return sources.map((source) => {
if (!item.data.file?.path || !source.isIndexable) {
return undefined
}
if (isSubExport) {
return {
name: [source.name],
path: getRelativePath(treeNode.parent?.data.path, item.data.path),
isTypeOnly: source.isTypeOnly,
} as KubbFile.Export
}
// true when we have a subdirectory that also contains barrel files
const isSubExport = !!treeNode.parent?.data.path?.split?.('/')?.length
if (isSubExport) {
return {
name: [source.name],
path: `./${item.data.file.baseName}`,
path: getRelativePath(treeNode.parent?.data.path, item.data.path),
isTypeOnly: source.isTypeOnly,
} as KubbFile.Export
})
}
return {
name: [source.name],
path: `./${item.data.file.baseName}`,
isTypeOnly: source.isTypeOnly,
} as KubbFile.Export
})
.flat()
.filter(Boolean)
})
.flat()
.filter(Boolean)
const combinedExports = combineExports(exports)
const barrelFile: KubbFile.File = {
path: barrelPath,
baseName: 'index.ts',
exports: combinedExports,
sources: combinedExports.flatMap((item) => {
if (Array.isArray(item.name)) {
return item.name.map((name) => {
return {
name: name,
isTypeOnly: item.isTypeOnly,
//TODO use parser to generate import
value: '',
isExportable: false,
} as KubbFile.Source
})
}
return [
{
name: item.name,
const barrelFile: KubbFile.File = {
path: barrelPath,
baseName: 'index.ts',
exports: exports,
sources: exports.flatMap((item) => {
if (Array.isArray(item.name)) {
return item.name.map((name) => {
return {
name: name,
isTypeOnly: item.isTypeOnly,

@@ -105,12 +94,35 @@ //TODO use parser to generate import

isExportable: false,
} as KubbFile.Source,
]
}),
}
return barrelFile
})
.filter(Boolean)
isIndexable: false,
} as KubbFile.Source
})
}
return [
{
name: item.name,
isTypeOnly: item.isTypeOnly,
//TODO use parser to generate import
value: '',
isExportable: false,
isIndexable: false,
} as KubbFile.Source,
]
}),
}
return files || []
const previousBarrelFile = files.get(barrelFile.path)
if (previousBarrelFile) {
files.set(barrelFile.path, {
...previousBarrelFile,
...barrelFile,
exports: combineExports([...(previousBarrelFile.exports || []), ...(barrelFile.exports || [])]),
sources: combineSources([...(previousBarrelFile.sources || []), ...(barrelFile.sources || [])]),
})
} else {
files.set(barrelFile.path, barrelFile)
}
})
return [...files.values()]
}
}

@@ -79,3 +79,3 @@ import { clean, read } from '@kubb/fs'

const barrelFiles = pluginManager.fileManager.files.filter((file) => {
return file.sources.some((source) => source.isExportable)
return file.sources.some((source) => source.isIndexable)
})

@@ -90,3 +90,3 @@

?.map((source) => {
if (!file.path || !source.isExportable) {
if (!file.path || !source.isIndexable) {
return undefined

@@ -108,5 +108,4 @@ }

}
return {
name: [source.name],
name: options.config.output.exportType === 'barrel' ? undefined : [source.name],
path: getRelativePath(rootPath, file.path),

@@ -113,0 +112,0 @@ isTypeOnly: source.isTypeOnly,

@@ -6,3 +6,3 @@ import { extname, join, relative } from 'node:path'

import { getRelativePath, read, write } from '@kubb/fs'
import { read, write } from '@kubb/fs'
import { BarrelManager } from './BarrelManager.ts'

@@ -240,2 +240,3 @@

prevByName.isTypeOnly = curr.isTypeOnly
prevByName.isIndexable = curr.isIndexable

@@ -242,0 +243,0 @@ return prev

@@ -512,3 +512,3 @@ import { FileManager } from './FileManager.ts'

this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name}` })
this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(', ') || ''}` })
}

@@ -515,0 +515,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc