-
Notifications
You must be signed in to change notification settings - Fork 256
feat(cli): refuse vp dev/build in Nuxt and Astro projects #2456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
fengmk2
wants to merge
7
commits into
main
Choose a base branch
from
feat/dev-framework-guard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9da276b
feat(cli): refuse vp dev/build in Nuxt and Astro projects
fengmk2 47a2821
fix(cli): align framework config detection with upstream loaders
fengmk2 63e3cb9
refactor(cli): simplify refusal wording to short sentences
fengmk2 8abcf9a
feat(cli): adapt the refusal hint to the package scripts
fengmk2 19eb0e5
fix(cli): skip the framework guard for script-spawned commands
fengmk2 dad5d88
fix(cli): apply the framework guard to the resolved target
fengmk2 ae9bdba
fix(cli): guard the directory Vite would use
fengmk2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/astro/astro.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default {}; |
10 changes: 10 additions & 0 deletions
10
.../vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/astro/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "@test/builtin-framework-guard-astro", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "vpt print astro build script", | ||
| "dev": "vpt print astro dev script" | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
..._snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/no-scripts/nuxt.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default {}; |
6 changes: 6 additions & 0 deletions
6
...li_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/no-scripts/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "@test/builtin-framework-guard-no-scripts", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module" | ||
| } |
1 change: 1 addition & 0 deletions
1
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/nuxt.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default {}; |
10 changes: 10 additions & 0 deletions
10
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "@test/builtin-framework-guard", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "vpt print nuxt build script", | ||
| "dev": "vpt print nuxt dev script" | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
...pshots/tests/cli_snapshots/fixtures/builtin_framework_guard/renamed-script/nuxt.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default {}; |
11 changes: 11 additions & 0 deletions
11
...napshots/tests/cli_snapshots/fixtures/builtin_framework_guard/renamed-script/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "@test/builtin-framework-guard-renamed-script", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "devtools": "nuxt devtools enable", | ||
| "make": "nuxt build", | ||
| "start": "nuxi dev --host" | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/snapshots.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # `vp dev` and `vp build` run the bundled Vite CLI. That CLI cannot serve or | ||
| # build a project whose framework wraps Vite behind its own CLI. When a Nuxt | ||
| # or Astro config file is next to the nearest `package.json`, the two | ||
| # commands stop with an error that points at `vp run <command>`. The root of | ||
| # this project looks like a Nuxt app, and `astro/` holds an Astro package. | ||
| [[case]] | ||
| name = "builtin_framework_guard" | ||
| vp = ["local", "global"] | ||
| skip-platforms = ["windows"] | ||
| steps = [ | ||
| { argv = ["vp", "dev"], comment = "`vp dev` refuses in a Nuxt project and points at the dev script", continue-on-failure = true }, | ||
| { argv = ["vp", "build"], comment = "`vp build` refuses the same way", continue-on-failure = true }, | ||
| { argv = ["vp", "dev"], cwd = "src", comment = "the refusal finds the enclosing package from a subdirectory, with the same walk `vp run` uses", continue-on-failure = true }, | ||
| { argv = ["vp", "dev"], cwd = "astro", comment = "an Astro config triggers the same refusal", continue-on-failure = true }, | ||
| { argv = ["vp", "dev"], cwd = "no-scripts", comment = "without scripts, the hint points at the framework CLI through `vp exec`", continue-on-failure = true }, | ||
| { argv = ["vp", "build"], cwd = "no-scripts", comment = "`vp build` gets the same fallback hint", continue-on-failure = true }, | ||
| { argv = ["vp", "dev"], cwd = "renamed-script", comment = "a script that runs the framework dev command under another name becomes the hint target", continue-on-failure = true }, | ||
| { argv = ["vp", "build"], cwd = "renamed-script", comment = "the build hint finds the renamed build script the same way", continue-on-failure = true }, | ||
| { argv = ["vp", "dev", "--config", "vite.config.ts", "--port", "12312312312"], comment = "an explicit --config selects the bundled Vite CLI on purpose, so only the script note prints (the invalid port stops the server immediately)", continue-on-failure = true }, | ||
| { argv = ["vp", "run", "dev"], comment = "`vp run dev` runs the dev script that the refusal points at" }, | ||
| ] |
130 changes: 130 additions & 0 deletions
130
...ts/fixtures/builtin_framework_guard/snapshots/builtin_framework_guard.global.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| # builtin_framework_guard | ||
|
|
||
| ## `vp dev` | ||
|
|
||
| `vp dev` refuses in a Nuxt project and points at the dev script | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| 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`? | ||
| ``` | ||
|
|
||
| ## `vp build` | ||
|
|
||
| `vp build` refuses the same way | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: did you mean `vp run build`? | ||
| ``` | ||
|
|
||
| ## `cd src && vp dev` | ||
|
|
||
| the refusal finds the enclosing package from a subdirectory, with the same walk `vp run` uses | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| 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`? | ||
| ``` | ||
|
|
||
| ## `cd astro && vp dev` | ||
|
|
||
| an Astro config triggers the same refusal | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| error: this project uses Astro (astro.config.mjs). `vp dev` runs the bundled Vite CLI, not the Astro CLI. | ||
| hint: did you mean `vp run dev`? | ||
| ``` | ||
|
|
||
| ## `cd no-scripts && vp dev` | ||
|
|
||
| without scripts, the hint points at the framework CLI through `vp exec` | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| error: this project uses Nuxt (nuxt.config.ts). `vp dev` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: run the Nuxt CLI with `vp exec nuxt dev`. | ||
| ``` | ||
|
|
||
| ## `cd no-scripts && vp build` | ||
|
|
||
| `vp build` gets the same fallback hint | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: run the Nuxt CLI with `vp exec nuxt build`. | ||
| ``` | ||
|
|
||
| ## `cd renamed-script && vp dev` | ||
|
|
||
| a script that runs the framework dev command under another name becomes the hint target | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| 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 start`? The start script runs `nuxi dev`. | ||
| ``` | ||
|
|
||
| ## `cd renamed-script && vp build` | ||
|
|
||
| the build hint finds the renamed build script the same way | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: did you mean `vp run make`? The make script runs `nuxt build`. | ||
| ``` | ||
|
|
||
| ## `vp dev --config vite.config.ts --port 12312312312` | ||
|
|
||
| an explicit --config selects the bundled Vite CLI on purpose, so only the script note prints (the invalid port stops the server immediately) | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| note: You are running `vp dev` as a Vite+ built-in command. If you meant to run the dev npm script, use `vpr dev` instead. | ||
| error when starting dev server: | ||
| Error: No available ports found between 12312312312 and 65535 | ||
| ``` | ||
|
|
||
| ## `vp run dev` | ||
|
|
||
| `vp run dev` runs the dev script that the refusal points at | ||
|
|
||
| ``` | ||
| VITE+ - The Unified Toolchain for the Web | ||
|
|
||
| $ vpt print nuxt dev script ⊘ cache disabled | ||
| nuxt dev script | ||
| ``` |
110 changes: 110 additions & 0 deletions
110
...ots/fixtures/builtin_framework_guard/snapshots/builtin_framework_guard.local.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # builtin_framework_guard | ||
|
|
||
| ## `vp dev` | ||
|
|
||
| `vp dev` refuses in a Nuxt project and points at the dev script | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| 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`? | ||
| ``` | ||
|
|
||
| ## `vp build` | ||
|
|
||
| `vp build` refuses the same way | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: did you mean `vp run build`? | ||
| ``` | ||
|
|
||
| ## `cd src && vp dev` | ||
|
|
||
| the refusal finds the enclosing package from a subdirectory, with the same walk `vp run` uses | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| 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`? | ||
| ``` | ||
|
|
||
| ## `cd astro && vp dev` | ||
|
|
||
| an Astro config triggers the same refusal | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| error: this project uses Astro (astro.config.mjs). `vp dev` runs the bundled Vite CLI, not the Astro CLI. | ||
| hint: did you mean `vp run dev`? | ||
| ``` | ||
|
|
||
| ## `cd no-scripts && vp dev` | ||
|
|
||
| without scripts, the hint points at the framework CLI through `vp exec` | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| error: this project uses Nuxt (nuxt.config.ts). `vp dev` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: run the Nuxt CLI with `vp exec nuxt dev`. | ||
| ``` | ||
|
|
||
| ## `cd no-scripts && vp build` | ||
|
|
||
| `vp build` gets the same fallback hint | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: run the Nuxt CLI with `vp exec nuxt build`. | ||
| ``` | ||
|
|
||
| ## `cd renamed-script && vp dev` | ||
|
|
||
| a script that runs the framework dev command under another name becomes the hint target | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| 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 start`? The start script runs `nuxi dev`. | ||
| ``` | ||
|
|
||
| ## `cd renamed-script && vp build` | ||
|
|
||
| the build hint finds the renamed build script the same way | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| error: this project uses Nuxt (nuxt.config.ts). `vp build` runs the bundled Vite CLI, not the Nuxt CLI. | ||
| hint: did you mean `vp run make`? The make script runs `nuxt build`. | ||
| ``` | ||
|
|
||
| ## `vp dev --config vite.config.ts --port 12312312312` | ||
|
|
||
| an explicit --config selects the bundled Vite CLI on purpose, so only the script note prints (the invalid port stops the server immediately) | ||
|
|
||
| **Exit code:** 1 | ||
|
|
||
| ``` | ||
| note: You are running `vp dev` as a Vite+ built-in command. If you meant to run the dev npm script, use `vpr dev` instead. | ||
| error when starting dev server: | ||
| Error: No available ports found between 12312312312 and 65535 | ||
| ``` | ||
|
|
||
| ## `vp run dev` | ||
|
|
||
| `vp run dev` runs the dev script that the refusal points at | ||
|
|
||
| ``` | ||
| $ vpt print nuxt dev script ⊘ cache disabled | ||
| nuxt dev script | ||
| ``` |
1 change: 1 addition & 0 deletions
1
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/src/valid.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const valid = true; |
1 change: 1 addition & 0 deletions
1
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/builtin_framework_guard/vite.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export default {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.