Closed Woody88 closed 2 years ago
Perhaps is something to do with your .env I suppose
I got the chance to have a look at the code today. The problem is in the way the DialectManager
constructs each respective dialect.
They should be dynamically imported. I fixed it by ensuring that the instantiate
returns a Promise
so that I may import it dynamically.
In addition, I am not sure if it's worth parsing the connection string. I think that it can be passed down to the appropriate dialect and let it handle it.
Lastly, The URL
object will break for SQLite
because it needs the file:
scheme or will throw an exception.
https://github.com/RobinBlomberg/kysely-codegen/blob/5e40c284c4a3fad154c382fb1128c0cd45b3c58e/src/connection-string-parser.ts#L64
I'm implementing dynamic imports in #12, which I hope should solve this. It might not solve everything (I'm still not sure how I want to handle connection strings), but it's a start!
I am trying to test
kysely-codegen
with SQLite but the CLI keeps throwingCannot find module 'pg'
for any commands that I pass it.Click to expand!
```bash > pnpm kysely-codegen --dialect sqlite node:internal/modules/cjs/loader:936 throw err; ^ Error: Cannot find module 'pg' Require stack: - /home/woody88/Code/Typescript/meetapp/node_modules/.pnpm/kysely-codegen@0.3.0_eb47a1c54283209bc69ae17fc7e73157/node_modules/kysely-codegen/dist/dialects/postgres.js - /home/woody88/Code/Typescript/meetapp/node_modules/.pnpm/kysely-codegen@0.3.0_eb47a1c54283209bc69ae17fc7e73157/node_modules/kysely-codegen/dist/dialect-manager.js - /home/woody88/Code/Typescript/meetapp/node_modules/.pnpm/kysely-codegen@0.3.0_eb47a1c54283209bc69ae17fc7e73157/node_modules/kysely-codegen/dist/cli.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.