feat(init): write a working config for Vite apps

KA
1d ago
+557-119

[!NOTE]
Written with Claude Code (Claude Opus 5.5), prompted and iterated on by me. I've reviewed the code. Not slop, I promise.

What

e2e init now recognizes a Vite project, the way it already recognizes Next.js. The config it writes starts npm run dev on Vite's port, 5173 or the --port in the dev script, so the first npm run test:e2e passes.

Why

Today init writes http://localhost:3000 for a Vite app, so the first run fails with APP_UNREACHABLE until you fix the port by hand.

How it works

  1. Refactor, no behavior change. init/frameworks.ts becomes a list of framework modules. Each has claims(manifest) and detect(project), and the first module that claims a project handles it. Next.js moves to frameworks/nextjs.ts as it was.

  2. Vite in frameworks/vite.ts. When init can't tell where the app runs, it keeps today's placeholder and prints the reason. That happens when:

    • a backend serves the app (Laravel, Symfony, Rails, Django)
    • the dev server uses HTTPS
    • vite.config.* sets another port, or the script passes --config or another directory
    • the dev script doesn't run vite (vite build --watch, react-router dev)

    It reads each quoted command under a launcher on its own (launchedCommands in frameworks/scripts.ts). So in concurrently "vite" "json-server --port 3001", init writes 5173, and json-server's port is never taken for Vite's.

  3. Docs. A "Vite apps" section in docs/reference/cli.mdx, the setup skill, and a changeset.

Issue

Closes #2313

Verified

Ran locally: yes, on macOS with Node 26, npm, and Vite 8.3.8. I ran e2e init --yes and the first e2e run in fresh npm create vite projects:

Projectmainthis PR
React or Vue templatelocalhost:3000, run fails5173, run passes
concurrently -k "vite" "json-server --port 3001"run fails5173, run passes
vite --port 4100run fails4100, run passes
vite --clearScreen falserun fails5173, run passes
config sets port 3000, Laravel, or an HTTPS pluginplaceholderplaceholder, and init says why
  • Next.js gives the same result as on main for 300 combinations of dev and start scripts.
  • pnpm check, the e2e unit tests, and tests/integration/cli-init.test.ts pass.
  • Not tested: pnpm, Yarn, or Bun; Linux or Windows; real SvelteKit or React Router projects.
  • Not changed: Next.js reads a port from a quoted sibling command on main too (concurrently "next dev" "json-server -p 3001"). Fixing that changes Next.js behavior, so I left it for a separate PR, which only has to switch Next.js from commandsOf to launchedCommands.

Checklist

  • Changeset added (e2e, patch).
  • Breaking change: no.
  • Docs updated: docs/reference/cli.mdx and skills/e2e/references/setup.md.
  • Contract change: no public API or wire format changes.
  • Engine contract change: no.

🤖 Generated with Claude Code