Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="/src/valid.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@test/builtin-framework-guard-mismatched-script",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "storybook dev",
"serve": "nuxt dev --host"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"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",
"nested-build": "vp build"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# `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"], cwd = "mismatched-script", comment = "an unrelated same-named script does not become the hint; the script that runs nuxt dev does", continue-on-failure = true },
{ argv = ["vp", "build", "web"], comment = "a positional root is inspected instead of the invocation package: the plain Vite child builds" },
{ argv = ["vp", "dev", "astro"], comment = "a positional root inside an Astro package refuses, and the hint carries -C", 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", "dev", "--help"], comment = "a help request reaches the tool, so the guard steps aside" },
{ argv = ["vp", "run", "dev"], comment = "`vp run dev` runs the dev script that the refusal points at" },
]

# A task or package script can spawn `vp dev` / `vp build` itself, for
# example a `"nested-build": "vp build"` script. The guard checks direct
# invocations only, so the nested command runs as invoked.
[[case]]
name = "builtin_framework_guard_inside_task"
vp = "local"
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "run", "nested-build"], comment = "no refusal: a task-spawned `vp build` runs the bundled Vite build as invoked" },
]

[[case]]
name = "builtin_framework_guard_inside_npm_script"
vp = "local"
skip-platforms = ["windows"]
steps = [
{ argv = ["npm", "run", "nested-build"], comment = "no refusal: an npm-spawned `vp build` runs as invoked" },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# 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`.
```

## `cd mismatched-script && vp dev`

an unrelated same-named script does not become the hint; the script that runs nuxt dev does

**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 serve`? The serve script runs `nuxt dev`.
```

## `vp build web`

a positional root is inspected instead of the invocation package: the plain Vite child builds

```
VITE+ - The Unified Toolchain for the Web

note: You are running `vp build` as a Vite+ built-in command. If you meant to run the build npm script, use `vpr build` instead.
note: `vp build web` sets Vite's root without changing the working directory. To run as if started there, use `vp -C web build`.
✓ 4 modules transformed.
computing gzip size...
web/dist/index.html <size> kB │ gzip: <size> kB
web/dist/assets/index-<hash>.js <size> kB │ gzip: <size> kB

✓ built in <duration>
```

## `vp dev astro`

a positional root inside an Astro package refuses, and the hint carries -C

**Exit code:** 1

```
VITE+ - The Unified Toolchain for the Web

note: `vp dev astro` sets Vite's root without changing the working directory. To run as if started there, use `vp -C astro dev`.
error: this project uses Astro (astro.config.mjs). `vp dev` runs the bundled Vite CLI, not the Astro CLI.
hint: did you mean `vp -C astro run dev`?
```

## `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 dev --help`

a help request reaches the tool, so the guard steps aside

```
VITE+ - The Unified Toolchain for the Web

Usage: vp dev [ROOT] [OPTIONS]

Run the development server.
Options are forwarded to Vite.

Arguments:
[ROOT] Project root directory (default: current directory)

Options:
--host [host] [string] specify hostname
--port <port> [number] specify port
--open [path] [boolean | string] open browser on startup
--cors [boolean] enable CORS
--strictPort [boolean] exit if specified port is already in use
--force [boolean] force the optimizer to ignore the cache and re-bundle
--experimentalBundle [boolean] use experimental full bundle mode (this is highly experimental)
--base <path> [string] public base path (default: /)
-l, --logLevel <level> [string] info | warn | error | silent
--clearScreen [boolean] allow/disable clear screen when logging
-d, --debug [feat] [string | boolean] show debug logs
-f, --filter <filter> [string] filter debug logs
-m, --mode <mode> [string] set env mode
-h, --help Display this message

Examples:
vp dev
vp dev --open
vp dev --host localhost --port 5173

Documentation: https://viteplus.dev/guide/dev
```

## `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
```
Loading
Loading