diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2fb9b8a..8f656e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,9 @@ jobs: - name: Check formatting run: deno fmt --check + - name: Build kit-string + run: deno task build:kit-string + - name: Lint run: deno lint diff --git a/PR.md b/PR.md new file mode 100644 index 0000000..1c68e48 --- /dev/null +++ b/PR.md @@ -0,0 +1,38 @@ +## Export kit driver as injectable string for drizzle-kit + +### Summary + +Adds a `./kit-string` export containing the bundled driver code as a string. This enables drizzle-kit to inject the `node:sqlite` driver without adding a runtime dependency. + +### Changes + +**API Refactoring** +- Move kit-only functions (`prepareSqliteParams`, `normaliseSQLiteUrl`) from `shared.ts` to `kit.ts` +- Simplify driver API: `createNodeSqlDriver(dbPath, prepareSqliteParams)` — caller provides the param preparation function + +**New Export** +- `./kit-string` exports `drizzleKitDriverBlock: string` containing the bundled driver code +- Generated via `deno task build:kit-string` using `Deno.bundle` +- Output goes to `dist/kit-string.ts` (gitignored, generated at publish time) + +**CI/Publishing** +- Added `build:kit-string` step to publish workflow +- Validates export statement is stripped (fails fast if bundler output format changes) + +**Improved Error Handling** +- Add `hasColumns()` guard in proxy fallback path with descriptive error message +- Consistent error handling between shared and kit code paths + +### Usage in drizzle-kit + +```ts +import { drizzleKitDriverBlock } from "@hotsauce/drizzle-runtime-sqlite/kit-string"; + +// Inject into connections.ts at build time +const nodeSqliteDriver = new Function(drizzleKitDriverBlock + "; return createNodeSqlDriver;")(); +``` + +### Testing + +- All 133 tests pass (Deno 2.7) +- Build script validated diff --git a/deno.jsonc b/deno.jsonc index fec0d47..dc2845c 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -35,5 +35,8 @@ "strict": true, "noImplicitAny": true }, + "publish": { + "exclude": ["!dist/kit-string.ts"] + }, "nodeModulesDir": "auto" }