feat: use pglite by default so postgres isn't required for generate#45
Open
Tamish-25 wants to merge 1 commit into
Open
feat: use pglite by default so postgres isn't required for generate#45Tamish-25 wants to merge 1 commit into
Tamish-25 wants to merge 1 commit into
Conversation
Fixes seveibar#2. `pgstrap generate` (and therefore the scaffolded `bun run db:generate` script) now defaults to running migrations against an in-memory PGlite database, so generating zapatos types and structure dumps no longer requires a running Postgres server. Use `--no-pglite` to connect to a real Postgres via DATABASE_URL as before. Also: - await the generate handler and pass argv through yargs' factory invocation (hideBin) so the CLI runs under both the CJS build and direct ESM/bun execution - wrap the PGlite generate path in try/finally so DATABASE_URL is restored and the gateway server + PGlite instance are closed even when generation fails - load pgstrap.config.js via pathToFileURL so dynamic import works on Windows - add an end-to-end test that runs `pgstrap generate` with no flags in a scaffolded project with no reachable Postgres Co-Authored-By: Claude Fable 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.
What
pgstrap generate(and the scaffoldeddb:generate) now runs against in-memory PGlite by default — no postgres server required. The existing PGlite path (from #7) was opt-in; this flips the default per #2:--pglitedefaults totrue;--no-pgliteopts back into connecting to real postgres viaDATABASE_URLtry/finallyso the gateway server, PGlite instance, andDATABASE_URLare restored even when codegen fails (previously leaked on error)Bugs fixed en route (both blocked running the CLI at all in some environments)
src/cli.tsused the yargs CJS singleton, which breaks under ESM semantics (bun); switched to the standard v17yargs(hideBin(process.argv))factory and awaited the handlersrc/get-project-context.tsimportedpgstrap.config.jsby raw absolute path, which node's ESM loader rejects on Windows (ERR_UNSUPPORTED_ESM_URL_SCHEME); fixed withpathToFileURLVerification (machine with no postgres running at all)
node dist/cli.cjs: scaffolded temp projects with a node-pg-migrate migration, clearedPG*/DATABASE_URLenv → exit 0, correctzapatos/schema.d.tsandstructure/**/table.sqloutputtests/cli-generate-default.test.tsbun test: 4 pass / 0 fail;bun run buildsucceedsCloses #2
/claim #2
🤖 Generated with Claude Code