Skip to content

Commit

Permalink
fix: support for configs/ folder for kubb.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle committed Oct 10, 2023
1 parent 6078e86 commit e448c32
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ This means you can configure Kubb via (in order of precedence):
- A `.kubbrc.js`, `.kubbrc.cjs`, `kubb.config.js`, or `kubb.config.cjs` file that exports an object using module.exports.
- A `.kubbrc.ts` or `kubb.config.ts` file that exports an object using export default.

::: tip
You can also use `configs/kubb.config.ts` or `.config/kubb.config.ts` instead of `kubb.config.ts` in the root of your project.
:::

See [kubb.config.js](/configuration/options) on how to configure Kubb.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"scripts": {
"build": "tsup",
"clean": "npx rimraf ./dist",
"generate": "kubb generate --config kubb.config.ts",
"generate": "kubb generate",
"generate:bun": "bun ./node_modules/@kubb/cli/bin/kubb.js generate --config .kubbrc.js",
"generate:js": "kubb generate --config .kubbrc.js",
"generate:json": "kubb generate --config kubb.json",
"generate:ts": "kubb generate --config kubb.config.ts",
"generate:ts": "kubb generate --config configs/kubb.config.ts",
"start": "tsup --watch",
"test": "vitest",
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"include": [
"./src/**/*",
"kubb.config.ts"
"configs/kubb.config.ts"
],
"exclude": [
"**/node_modules",
Expand Down
39 changes: 24 additions & 15 deletions packages/cli/src/utils/getCosmiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,33 @@ const tsLoader = (configFile: string) => {
}

export async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {
const searchPlaces = [
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,

`.${moduleName}rc.ts`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`.${moduleName}rc.mjs`,

`${moduleName}.config.ts`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
`${moduleName}.config.mjs`,
]
const explorer = cosmiconfig(moduleName, {
cache: false,
searchPlaces: [
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,

`.${moduleName}rc.ts`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`.${moduleName}rc.mjs`,

`${moduleName}.config.ts`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
`${moduleName}.config.mjs`,
...searchPlaces.map((searchPlace) => {
return `.config/${searchPlace}`
}),
...searchPlaces.map((searchPlace) => {
return `configs/${searchPlace}`
}),
...searchPlaces,
],
loaders: {
'.ts': tsLoader,
Expand Down

1 comment on commit e448c32

@vercel
Copy link

@vercel vercel bot commented on e448c32 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kubb – ./

kubb-git-main-kubb.vercel.app
www.kubb.dev
kubb-kubb.vercel.app
kubb.dev

Please sign in to comment.