dev-setup: add preflight checks before prisma migrate (partial #6) - #8
Open
Bryandero98 wants to merge 1 commit into
Open
dev-setup: add preflight checks before prisma migrate (partial #6)#8Bryandero98 wants to merge 1 commit into
Bryandero98 wants to merge 1 commit into
Conversation
…d-ai#6) Adds scripts/preflight.ts: pure node:net TCP reachability check for PG_DATABASE_URL, plus docker/podman/flutter detection via spawnSync — no new dependencies, consistent with dev-setup.ts running before bun install has necessarily done anything useful. dev-setup.ts now runs this before prisma migrate deploy and prints a summary. If Postgres isn't reachable it exits early with the exact docker run command from the issue (or a system-Postgres/install hint when no container runtime is found), instead of surfacing only the generic 'Migration failed' error after the fact. Scoped to preflight item antgrid-ai#1 from the issue's priority list only — detection and messaging, no side effects. Auto-starting Postgres (item antgrid-ai#2) and the machine-checked capability tiering (item antgrid-ai#3) are separate follow-ups, per the issue's own 'a partial fix is genuinely useful, don't treat this as all-or-nothing'. Covered by scripts/preflight.test.ts (bun:test, same style as windows-dev-protocol.test.ts): real socket reachable/unreachable, hasCommand found/missing, and summary formatting for both states.
Author
|
Hi! Delivering the first milestone for the zero-credential setup: robust preflight checks for container runtimes (Docker/Podman) and database ports using pure Node net sockets (no extra dependencies). It fails early with actionable messages instead of throwing generic Prisma errors. Fully typed and tested. Let me know what you think! |
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.
Partial delivery for #6, scoped strictly to priority item #1 from the issue ("Preflight in
npm run setup"). Items #2 (offer to auto-start Postgres) and #3 (machine-checked capability tiering) are intentionally left for follow-up PRs, per the issue's own note that a partial fix is useful here.What this does
scripts/preflight.ts(new, zero new dependencies — matters here sincedev-setup.tsruns beforebun installhas necessarily done anything useful):checkPortOpen()— purenode:netTCP connect againstPG_DATABASE_URL's host/port. This is reachability only ("is anything listening"), not authentication — real credential/db-name problems still surface fromprisma migrate deployafterward, unchanged from today.hasCommand()— detectsdocker/podman/flutterviaspawnSync(cmd, ["--version"]). No shell-specific assumptions, so it resolves.exe/.cmd/POSIX binaries the same way on Windows, macOS and Linux.runPreflight()/formatPreflightSummary()assemble the result into the summary linesdev-setup.tsprints.scripts/dev-setup.tscalls this right before theprisma migrate deploystep. If Postgres isn't reachable, it now exits early with an actionable message — the exactdocker runcommand from the issue when a container runtime is present, or a system-Postgres/install hint when it isn't — instead of only surfacing today's genericMigration failed. Is Postgres running and PG_DATABASE_URL correct?after the command has already committed to migrating.Testing
scripts/preflight.test.ts, samebun:teststyle aswindows-dev-protocol.test.ts: real ephemeral-port socket for the reachable/unreachable cases,hasCommandagainst a real vs. nonexistent binary, and summary formatting for both states.I don't have Bun in the environment I wrote this in, so I couldn't run this exact suite with
bun test. I did validate the underlying logic (checkPortOpen,hasCommand,formatPreflightSummary, andrunPreflightend-to-end) against real sockets and real commands under Node 24, and type-checkedpreflight.tsin isolation undertsc --strictwith@types/node— both clean. Flagging this explicitly since it's the one thing I couldn't verify with the project's actual test runner.