kysely-org / kysely-ctl

Command-line tool for Kysely
MIT License
46 stars 1 forks source link

defineConfig using --environment type issue with seedFolder #53

Closed shane-js closed 1 week ago

shane-js commented 1 week ago

Error: "Type 'string' is not assignable to type 'undefined'.ts(2322)" seen when doing:

export default defineConfig({
  dialect: dialect,
  plugins: plugins,
  migrations: {
    migrationFolder: "./src/db/migrations",
  },
  $development: {
    seeds: {
      // @ts-expect-error for now igal on discord said he is looking into it
      seedFolder: "./src/db/seeds/development",
    },
  },
});

image

Additionally it also only lets you use the environment name strings found in c12's C12InputConfig interface but kysely-ctl's src/arguments/environment.mts has valueHint of 'prod | dev | test | ...' but you actually can't use those abbreviations for production and development without other typescript compilation error.

Object literal may only specify known properties, and '$dev' does not exist in type '(C12InputConfig<KyselyCTLConfig, ConfigLayerMeta> & KyselyCTLConfigBase & { ...; } & { ...; } & { ...; }) | ... 7 more ... | (C12InputConfig<...> & ... 3 more ... & { ...; })'.ts(2353)

image

Per @igalklebanov review on discord issue is appropriate to raise on this.

igalklebanov commented 1 week ago

Hey 👋

This should be addressed in https://github.com/kysely-org/kysely-ctl/releases/tag/v0.8.9.

c12 allows for custom environment names, not part of their predefined environment names list. You can use those in your config via:

{
  // ...
  $env: {
    staging: {
      // ...
    }
  }
  // ...
}