Skip to content

chore(dev-env): load .env via tsx + seed sheet configs#21

Merged
themightychris merged 1 commit into
mainfrom
chore/dev-env-bootstrap
May 16, 2026
Merged

chore(dev-env): load .env via tsx + seed sheet configs#21
themightychris merged 1 commit into
mainfrom
chore/dev-env-bootstrap

Conversation

@themightychris
Copy link
Copy Markdown
Member

Summary

Two small fixes so npm run dev boots the API on a fresh checkout:

  1. .env auto-loadapps/api/dev script now passes --env-file=../../.env to tsx. Node 22+ feature; no new dep.
  2. Dev-data setup script — new apps/api/scripts/setup-dev-data.ts (npm run -w apps/api script:setup-dev-data) seeds an empty data repo with the 11 sheet configs openPublicStore declares. Idempotent; safe to re-run.

Plus a documentation fix in .env.example (the old comment said paths are "relative from repo root" but the API resolves them from apps/api/), and .gitignore updates to ignore the dev data repo and agent worktree directories.

Caught while trying to hand a working dev URL to a reviewer mid-session — neither gap was caught in the api-skeleton plan's Validation since the boot path wasn't exercised against an actual filesystem there.

Test plan

  • cp .env.example .env (with CFP_JWT_SIGNING_KEY filled in)
  • npm run -w apps/api script:setup-dev-data creates the data repo + 11 .gitsheets/<name>.toml files + commits them
  • npm run dev boots both apps; api on :3001, web on :5173
  • curl http://localhost:3001/api/health returns the documented envelope

🤖 Generated with Claude Code

Two small fixes that together let `npm run dev` boot the API on a fresh
checkout (previously the api crashed at boot because @fastify/env couldn't
find required vars and openPublicStore threw config_missing for every
declared sheet):

1. `apps/api/dev` script now passes `--env-file=../../.env` to tsx so the
   repo-root .env is loaded into process.env before @fastify/env validates.
   Node 22+ supports --env-file natively; no new dependency.

2. New `apps/api/scripts/setup-dev-data.ts` (npm script:
   `script:setup-dev-data`) seeds an empty data repo with the minimal
   `[gitsheet]` blocks for each of the 11 sheets declared in
   `apps/api/src/store/public.ts`. Idempotent — skips configs that already
   exist. The path templates are dev-stub defaults documented in the
   script; the data repo is empty at this stage so they don't need to be
   the production-canonical templates.

`.env.example` updated to point at the new setup script and to note that
relative paths are resolved from apps/api/ (not the repo root, which the
old comment misleadingly implied).

`.gitignore` updated to ignore `apps/codeforphilly-data/` (where the dev
data repo lands by default), `codeforphilly-data/` (in case someone uses
an absolute path or differs the layout), and `.claude/worktrees/` (where
background agent worktrees live).

Verified locally: `cp .env.example .env`, `npm run -w apps/api script:setup-dev-data`,
`npm run dev` — both web (:5173) and api (:3001) come up; `GET /api/health`
returns the documented envelope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@themightychris themightychris merged commit bfd6acf into main May 16, 2026
1 check passed
@themightychris themightychris deleted the chore/dev-env-bootstrap branch May 16, 2026 20:52
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.

1 participant