Skip to content

feat: generate same-origin configs with offset devPorts, fix fork detection - #25

Open
flipvh wants to merge 1 commit into
mainfrom
feat/devports-generation
Open

feat: generate same-origin configs with offset devPorts, fix fork detection#25
flipvh wants to merge 1 commit into
mainfrom
feat/devports-generation

Conversation

@flipvh

@flipvh flipvh commented Aug 16, 2026

Copy link
Copy Markdown
Member

Pairs with cellajs/cella#1067 (the devPorts config knob). Generated configs catch up with cella's same-origin URL shapes, and new forks get collision-free service ports again.

Why

The port-offset system only ever moved the URL ports and the .env PORT= line. Since cella's same-origin migration, the backend port no longer appears in any URL and the Vite proxy target was hardcoded to localhost:4000 — so an offset PORT broke the fork's own frontend, and in practice forks (e.g. projectcampus) reset PORT to 4000 and collided on the shared service ports. The generator was also emitting the pre-same-origin config shape (backendUrl on its own port, /auth path, no yjsUrl/mcpUrl), and detectUsedPorts failed to recognize same-origin forks (its backendUrl regex requires a port before the closing quote), so offset suggestions ignored them.

What

  • generateEnvConfigs: development/staging/tunnel/test now mirror cella's current same-origin shapes (URL family incl. yjsUrl/mcpUrl; tunnel gains its slug), and development bakes in an offset devPorts block (api/cdcHealth/yjs/mcp = 400x + offset) paired with the offset frontendUrl.
  • getBackendEnvReplacements: PORT dropped — devPorts governs, and a stale PORT= env line silently overrides the fork's offset (the exact projectcampus failure mode).
  • detectUsedPorts: recognizes all three config generations (devPorts, legacy ported backendUrl, bare same-origin) with the backend port parsed from devPorts where present.
  • Tests updated for the new shapes plus a new detect-used-ports.test.ts covering the three shapes and offset suggestion.

Notes

  • Merge order: cella#1067 first — the generated devPorts key only typechecks against a template that declares it in RequiredConfig.
  • generateEnvConfigs drift with cella's config shape has now bitten three times (named exports, .ts extensions, this); the shapes here are copied verbatim from cella's current config.<mode>.ts files.

🤖 Generated with Claude Code

…ection

Pairs with cella#1067 (devPorts knob). The generator's config shapes were
pre-same-origin (backendUrl on its own port, /auth path, no yjs/mcp URLs),
and the port offset only moved URLs and the .env PORT line, which the
hardcoded Vite proxy target then defeated. Generated configs now mirror
cella's same-origin shapes for development/staging/tunnel/test and bake an
offset devPorts block into development; PORT is dropped from the .env
replacements (a stale line silently overrides the offset). Fork detection
handles same-origin shapes: frontendUrl regex no longer requires a bare
closing quote, backend port parses from devPorts with legacy fallbacks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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