Skip to content

feat(#16): one-command setup script + Makefile + friendly env validation#133

Closed
georgyia wants to merge 3 commits into
mainfrom
feat/issue-16-setup-script
Closed

feat(#16): one-command setup script + Makefile + friendly env validation#133
georgyia wants to merge 3 commits into
mainfrom
feat/issue-16-setup-script

Conversation

@georgyia

Copy link
Copy Markdown
Collaborator

Summary

Closes #16.

Gets a fresh clone running with a single command and replaces stack-trace crashes on missing env vars with a readable error block.

  • scripts/setup.sh walks through prereq checks (Node 20+, Docker, optional Stripe CLI), bootstraps .env, boots Postgres + Redis via docker compose and waits for readiness, runs npm install, prisma generate, prisma migrate deploy, and npm run seed. Supports --yes, --skip-seed, and picks up CI=true for unattended runs.
  • Makefile wraps the common dev flows (setup, dev, worker, test, test-integration, migrate, seed, reset, lint, format, build, infra, clean) with make help.
  • src/config/env.ts is rewritten around a Zod schema. Missing/invalid values now print a single block listing exactly what is wrong (one bullet per issue) and process.exit(1) — no stack trace.
  • README Quick Start leads with ./scripts/setup.sh; the manual steps are preserved as a collapsible fallback.
  • .env.example gains explicit NODE_ENV and PAYMENT_PROVIDER entries.

Test plan

  • npm test (361 unit tests pass, incl. 6 new cases in tests/unit/config/env.test.ts covering defaults, coercion, malformed URLs, invalid LOG_LEVEL, and aggregate error formatting).
  • ./scripts/setup.sh --yes --skip-seed on the running stack completes end-to-end.
  • make help renders all targets; make test delegates correctly.
  • Manual repro: running the server with all required vars missing prints the friendly block and exits — no stack trace.

Acceptance checklist (from the issue)

  • ./scripts/setup.sh runs end-to-end on a clean clone (macOS verified; bash-only, Linux-compatible syntax).
  • Missing env vars produce a clear startup error, not a stack trace.
  • README Getting Started section references the script as the entry point.
  • Makefile covers all common dev workflows.

…ation

- scripts/setup.sh: prereq checks (Node 20+, Docker, optional Stripe CLI),
  .env bootstrap with interactive prompts, waits for Postgres + Redis
  readiness, runs npm install, prisma generate, migrate deploy, and seed.
  Supports --yes/--skip-seed/CI=true for unattended runs.
- Makefile: thin wrappers around npm scripts + setup.sh (make help lists
  all common dev tasks).
- src/config/env.ts: Zod-based aggregate validation; missing/invalid vars
  print a single human-readable block and exit(1) instead of a stack trace.
  Exports validateEnv/envSchema for unit testing.
- .env.example: document NODE_ENV and PAYMENT_PROVIDER.
- README: lead with ./scripts/setup.sh (manual steps kept as fallback),
  link make help.
- tests/unit/config/env.test.ts: covers defaults, coercions, aggregate
  error reporting, and regex validation.

Closes #16
ESLint's no-undef rule flags `NodeJS.ProcessEnv` as undefined under the
repo's globals config (globals.node doesn't expose the NodeJS namespace),
and `fail()` is no longer a Jest global in newer @types/jest.

- src/config/env.ts: replace `NodeJS.ProcessEnv` with
  `Record<string, string | undefined>` — equivalent shape, no namespace.
- tests/unit/config/env.test.ts: alias the same shape locally; rewrite
  the malformed-URL test with a try/catch so it no longer depends on
  Jest's removed `fail()` global.

Lint now passes with 0 errors (pre-existing `no-explicit-any` warnings
unchanged). All 6 env unit tests still pass.
@georgyia georgyia requested a review from JonasBaeumer April 21, 2026 07:40

@JonasBaeumer JonasBaeumer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this might be conflicting with the approach / code PR in #111

@JonasBaeumer

Copy link
Copy Markdown
Owner

Closing in favor of #111 which addresses the same setup-script work (#16). Thanks for the contribution — already discussed offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add one-command deployment and first-run setup script

2 participants