Skip to content

feat(devframe): expose createDevServer as a programmatic CLI building block#304

Merged
antfu merged 1 commit intomainfrom
antfu/cli-building-blocks
May 2, 2026
Merged

feat(devframe): expose createDevServer as a programmatic CLI building block#304
antfu merged 1 commit intomainfrom
antfu/cli-building-blocks

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented May 2, 2026

Description

Extracts the dev-server logic out of createCli into a peer factory at devframe/adapters/dev (createDevServer + resolveDevServerPort), so authors can drive it from their own CLI framework — commander, yargs, oclif, or any custom shell — instead of inheriting the cac-flavored `dev`/`build`/`mcp` triplet baked into `createCli`. `createBuild` and `createMcpServer` already shipped as standalone factories; this fills in the missing dev-server piece, and refactors `createCli` to be a thin cac wrapper that orchestrates all three.

`createDevServer` returns the underlying `StartedServer` handle (`origin`, `port`, `app`, `wss`, `rpcGroup`, `close()`) so callers can wire SIGINT / hot-reload teardown into their own process lifecycle. Existing `createCli` callers see no behavior or signature change. `defineCliFlags` / `parseCliFlags` / `CliFlagsSchema` / `InferCliFlags` are re-exported from `devframe/adapters/cli` (no longer at the top-level `devframe` entry).

Includes the new `adapters/dev` docs section, a "Use your own CLI framework" guide with a commander example, refreshed tsnapi snapshots, a smoke test for the start → `.connection.json` → close round-trip, and an updated SKILL.md.

Linked Issues

Additional context

Public API is purely additive — the only breaking surface is moving `defineCliFlags` / `parseCliFlags` from `devframe` to `devframe/adapters/cli`.

🤖 Generated with Claude Code

… block

Extract the dev-server logic out of `createCli` into a peer factory at
`devframe/adapters/dev` so authors can drive it from their own CLI
framework (commander, yargs, oclif). `createCli` becomes a thin cac
wrapper that orchestrates `createDevServer`, `createBuild`, and
`createMcpServer`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@304
npm i https://pkg.pr.new/@vitejs/devtools-kit@304
npm i https://pkg.pr.new/@vitejs/devtools-rolldown@304
npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@304

commit: c7857c9

@antfu antfu merged commit 94db4d7 into main May 2, 2026
9 checks passed
@antfu antfu deleted the antfu/cli-building-blocks branch May 2, 2026 21:25
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