Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loosen environment-override types, align environment value hint with c12's predefined environment names. #55

Merged
merged 4 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arguments/environment.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export const EnvironmentArg = {
description:
'Apply environment-specific overrides to the configuration. See https://github.com/unjs/c12#environment-specific-configuration for more information.',
type: 'string',
valueHint: 'prod | dev | test | ...',
valueHint: 'production | development | test | ...',
},
} satisfies ArgsDef
7 changes: 5 additions & 2 deletions src/config/define-config.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { createDefineConfig } from 'c12'
import type { C12InputConfig } from 'c12'
import type { PartialDeep } from 'type-fest'
import type { KyselyCTLConfig } from './kysely-ctl-config.mjs'

export const defineConfig = createDefineConfig<KyselyCTLConfig>()
export const defineConfig = (
input: KyselyCTLConfig & C12InputConfig<PartialDeep<KyselyCTLConfig>>,
): KyselyCTLConfig & C12InputConfig<PartialDeep<KyselyCTLConfig>> => input
2 changes: 1 addition & 1 deletion src/config/kysely-ctl-config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ type MigratorlessMigrationsConfig = MigrationsBaseConfig &
type SeederfulSeedsConfig = Pick<SeedsBaseConfig, 'getSeedPrefix'> & {
provider?: never
seeder: Seeder
seedsFolder?: never
seedFolder?: never
}

type SeederlessSeedsConfig = SeedsBaseConfig &
Expand Down
16 changes: 16 additions & 0 deletions tests/define-config.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,22 @@ describe('defineConfig', () => {
})
})
})

it('environment override issue - https://github.com/kysely-org/kysely-ctl/issues/53', () => {
defineConfig({
dialect: dialect,
plugins: plugins,
migrations: {
migrationFolder: './src/db/migrations',
},
$development: {
seeds: {
// this type-errored before the fix
seedFolder: './src/db/seeds/development',
},
},
})
})
})

function init() {
Expand Down