Repository navigation
Use PGlite by default for scaffolded db:generate - #83
Open
jacobsenscott235-web wants to merge 2 commits into
Open
jacobsenscott235-web wants to merge 2 commits into
jacobsenscott235-web wants to merge 2 commits into
Conversation
New projects get "pgstrap generate --pglite", so generating types no longer needs a running Postgres server (seveibar#2). - init: scaffold db:generate with --pglite - generate: bind the temporary PGlite gateway to 127.0.0.1, and close it and restore DATABASE_URL even when generation fails - cli: await generate so failures surface through yargs - config: import pgstrap.config.js through a file:// URL; Node's ESM loader rejects absolute Windows paths, so every command failed there - tests: give the two PGlite tests a 30 s timeout; they take 6-7 s on Windows and failed the 5 s default - README: document the default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Gateway shutdown is not awaited, and the new failure-cleanup behavior lacks regression coverage.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Updates scaffolded projects to generate database types through PGlite by default, while improving Windows compatibility and failure cleanup.
Changes:
- Makes
db:generateuse--pgliteby default. - Fixes Windows config imports and binds the gateway to localhost.
- Adds error propagation, cleanup, documentation, and longer test timeouts.
| File | Description |
|---|---|
README.md |
Documents PGlite generation behavior. |
src/cli.ts |
Awaits type generation. |
src/generate.ts |
Restricts gateway binding and adds cleanup. |
src/get-project-context.ts |
Imports config through a file URL. |
src/init.ts |
Scaffolds the PGlite generation command. |
tests/generate.pglite.test.ts |
Extends the generation test timeout. |
tests/init.test.ts |
Updates the expected scaffolded command. |
tests/pglite.test.ts |
Extends the migration test timeout. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- generate: wait for the temporary gateway to finish closing before returning - tests: check that DATABASE_URL is restored when generation fails after the gateway has started Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #2.
New projects scaffolded with
pgstrap initnow get"db:generate": "pgstrap generate --pglite", sobun run db:generategenerates types without a Postgres server running.pgstrap generatewithout the flag still generates from a live database.While testing on Windows I hit three problems on the same path, fixed here as well:
getProjectContextdidimport(path.join(cwd, "pgstrap.config.js")). Node's ESM loader rejects absolute Windows paths (ERR_UNSUPPORTED_ESM_URL_SCHEME), so every CLI command failed there. It now imports throughpathToFileURL(...), which resolves to the same file on Linux and macOS.postgres, and triggered a Windows Firewall prompt. It now binds to127.0.0.1, which the connection string already used.finallyblock, the gateway is closed (and the close is awaited) andDATABASE_URLis restored. The CLI also awaitsgenerate, so errors go through yargs.The two PGlite tests also get a 30 s timeout. On this machine they take 6–7 s and failed bun's 5 s default even on unmodified
main.Verification (Windows 11, Node 24.13.1, bun 1.4.2)
bun test: 4 pass, 0 failbun run build: CJS and DTS builds succeedbiome format: changed files are clean with LF line endingstsc --noEmit: 0 errors insrc/; the 3 existingbun:testtype errors intests/are unchangedDATABASE_URLunset: in a freshpgstrap initproject with this build linked in,bun run db:generateapplies a migration and writessrc/db/zapatos/schema.d.tsandsrc/db/structure/public/tables/<table>/table.sql. With a migration containing invalid SQL it exits 1 and prints the SQL error. Before the config fix, running the CLI under Node exited withERR_UNSUPPORTED_ESM_URL_SCHEME.dbDirpointing at a file, generation fails after the gateway starts.generate()now waits for the gateway to close and restoresDATABASE_URL; onmainthe gateway stays listening andDATABASE_URLstill points at it. The new testgenerate with pglite restores DATABASE_URL on failurecovers this, and it fails againstmain'sgenerate.ts.@algora-pbc /claim #2
🤖 Generated with Claude Code