Skip to content

feat(cli): refuse vp dev/build in Nuxt and Astro projects - #2456

Draft
fengmk2 wants to merge 5 commits into
mainfrom
feat/dev-framework-guard
Draft

feat(cli): refuse vp dev/build in Nuxt and Astro projects#2456
fengmk2 wants to merge 5 commits into
mainfrom
feat/dev-framework-guard

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 14, 2026

Copy link
Copy Markdown
Member

Refs #1506. First step from #1506 (comment): detect a Nuxt or Astro config, refuse vp dev / vp build, and point at vp run dev.

Both commands run the bundled Vite CLI, which cannot serve or build a Nuxt or Astro project: dev answers every URL with 404, and build fails on the missing index.html entry (repros: nuxt, astro). Now:

$ vp dev
error: this project uses Nuxt (nuxt.config.ts). `vp dev` runs the bundled Vite CLI, not the Nuxt CLI.
hint: did you mean `vp run dev`?

The guard sits in the NAPI binding dispatch, so the local and global CLI behave the same. It checks the config files each framework loader resolves: nuxt.config.{js,ts,mjs,cjs,mts,cts} and astro.config.{mjs,js,ts,mts}, with the upstream sources cited in code comments. Without a dev/build script, the hint points at a script that runs the framework command under another name, or at vp exec nuxt dev. The guard checks direct invocations only: a command spawned from a task or package script, such as a "dev": "vp dev" script, runs as invoked. An explicit --config/-c flag skips the refusal. A positional directory target (vp dev apps/web) is not inspected.

Covered by unit tests, the builtin_framework_guard PTY snapshot fixture (local and global flavors), and docs updates in guide/run.md and guide/troubleshooting.md.

vp dev and vp build run the bundled Vite CLI, which cannot serve or
build a Nuxt or Astro project: dev answers every URL with 404 and build
fails on the missing index.html entry. Detect nuxt.config.* or
astro.config.* next to the nearest package.json and stop with an error
that points at vp run <command>. An explicit --config/-c flag skips the
refusal.

Refs #1506
@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 19eb0e5
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a7f432e7213d90008c8cf34

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

✅ Staging deployment successful!

Preview: https://viteplus-staging.void.app/
Commit: 19eb0e5

@fengmk2 fengmk2 added the preview-build Publish this PR's commits to the registry bridge as preview builds label Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Native binary sizes (19eb0e5)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.

Artifact Format Base PR Change
vp (Linux x64) Binary 10.67 MiB 10.67 MiB 0 B (0.00%)
vp (Linux x64) gzip -9 4.62 MiB 4.62 MiB 0 B (0.00%)
NAPI (Linux x64) Binary 32.02 MiB 32.03 MiB +8.00 KiB (+0.02%)
NAPI (Linux x64) gzip -9 12.61 MiB 12.61 MiB +1.24 KiB (+0.01%)
vp (macOS ARM64) Binary 7.98 MiB 7.98 MiB 0 B (0.00%)
vp (macOS ARM64) gzip -9 4.03 MiB 4.03 MiB 0 B (0.00%)
NAPI (macOS ARM64) Binary 39.68 MiB 39.68 MiB +16 B (+0.00%)
NAPI (macOS ARM64) gzip -9 16.92 MiB 16.92 MiB +3.07 KiB (+0.02%)
vp (Windows x64) Binary 8.55 MiB 8.55 MiB 0 B (0.00%)
vp (Windows x64) gzip -9 3.73 MiB 3.73 MiB 0 B (0.00%)
NAPI (Windows x64) Binary 26.89 MiB 26.90 MiB +6.50 KiB (+0.02%)
NAPI (Windows x64) gzip -9 10.68 MiB 10.68 MiB +982 B (+0.01%)
Trampoline (Windows x64) Binary 205.00 KiB 205.00 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 99.00 KiB 99.00 KiB -1 B (-0.00%)
Installer (Windows x64) Binary 4.47 MiB 4.47 MiB 0 B (0.00%)
Installer (Windows x64) gzip -9 2.09 MiB 2.09 MiB -2 B (-0.00%)

Astro only searches astro.config.{mjs,js,ts,mts} (configPaths in
withastro/astro), so drop the .cjs/.cts names it never loads. Nuxt
resolves nuxt.config through c12, which accepts all six script
extensions. Cite the pinned upstream sources in the framework table.

Also reword the refusal to 'this project uses <name>' and drop the
article field it needed.
Split the refusal error into two sentences and rewrite the guard
comments, docs, and fixture comments in short active sentences.
Re-record the fixture snapshots for the new wording.
Without a script named after the command, the old hint pointed at a
vp run task that does not exist. The hint now picks the first path
that works: the same-name script, a script that runs the framework
command under another name (matched on whitespace boundaries against
the nuxt/nuxi/astro bins), or the framework CLI through vp exec.
Add snapshot coverage for the no-scripts and renamed-script cases.
@fengmk2

fengmk2 commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8abcf9a6b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +84 to +86
if has_explicit_config(args) {
return None;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve tool help and version requests

Inside any detected Nuxt or Astro package, vp dev --help, vp build --help, and the corresponding --version forms now exit through this guard because only explicit config flags are exempted. These requests are intended to reach the tool-backed command—the existing argument classifier explicitly treats help/version flags as forwardable, and repository guidance directs users to vp <command> --help—so bypass the framework refusal when is_app_tool_help_or_version_flag appears before the option terminator.

AGENTS.md reference: packages/cli/AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

Comment on lines +399 to +400
if let Some(exit) = framework_guard::check(&subcmd, &cwd) {
return Ok(exit);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve the configured package before applying the guard

When a repository root contains a Nuxt or Astro config but its vite.config.ts sets defaultPackage to a separate Vite app, bare vp dev or vp build now refuses based on the root before execute_direct_subcommand can call resolve_app_target. This violates the documented defaultPackage behavior as an implicit -C and can also produce a hint from the wrong package; resolve the app target first and apply the guard to the resulting directory (the existing retargeted check will still reject a Nuxt/Astro target).

Useful? React with 👍 / 👎.

- `vp test` always runs the built-in Vitest command
- `vp run dev`, `vp run build`, and `vp run test` run the matching `package.json` scripts instead

In a Nuxt or Astro project (a `nuxt.config.*` or `astro.config.*` file next to `package.json`), `vp dev` and `vp build` stop with an error that points at `vp run <name>`. Those frameworks run Vite through their own CLI. The bundled Vite CLI cannot serve or build them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Document the no-script fallback accurately

For a detected framework package without a matching script, run_hint deliberately prints vp exec nuxt <command> or vp exec astro <command>, as the new no-scripts snapshots demonstrate, so this unconditional statement that the error points at vp run <name> sends readers looking for a task that does not exist. Qualify the vp run guidance as applying when a matching script is present and mention the vp exec fallback otherwise.

Useful? React with 👍 / 👎.

A package script can run vp dev or vp build itself. The guard now
checks direct invocations only, with the same task and
npm_lifecycle_event gate the script note uses (extracted as
spawned_from_script). Add task-spawned and npm-spawned snapshot cases
that build through a nested vp build without a refusal.
@tobiasdiez

Copy link
Copy Markdown

From a user's perspective, would it not be more convenient if vp dev actually falls back to vp run dev for a nuxt project?

As far as I understand the discussion in #1506, proper support for nuxt/astro is desired just not very high on the prio queue. So for training the correct muscle memory, supporting vp dev in some form would be nice.

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

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants