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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@ jobs:
RUST_BACKTRACE: '1'
RUST_MIN_STACK: 8388608

- name: Test completion integration
run: vp env exec --node ${{ matrix.test-node }} node packages/tools/src/test-completion.ts
env:
VP_COMPLETION_CONSUMER_BIN: ${{ github.workspace }}/target/${{ matrix.target }}/release/vp${{ runner.os == 'Windows' && '.exe' || '' }}
RUST_BACKTRACE: '1'
RUST_MIN_STACK: 8388608

- name: Test global package install (powershell)
if: ${{ runner.os != 'Linux' }}
shell: pwsh
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ To create a release build of Vite+ and all upstream dependencies, run:
just build
```

## Completion integration tests

After building the JavaScript packages, run `pnpm test:completion` for the metadata and startup integration tests. It builds `vp_global_cli` and uses Cargo's reported executable. To use a prebuilt binary, set `VP_COMPLETION_CONSUMER_BIN` to its exact path; an invalid path fails the suite.

CI runs this suite separately with the downloaded native binary. Ordinary `pnpm test:unit` does not build Rust or discover the `*.integration.ts` files.

## Git Hooks (optional)

Pre-commit checks are opt-in. Run `vp config` after a build to install the hook dispatcher; each commit then runs `vp staged` on staged files. `vp staged` loads its config from `vite.config.ts` and needs the built JS packages, so build first. Opt out with `vp hooks disable`, or skip one run with `VP_GIT_HOOKS=0`. If husky was active in your clone before, run `git config --unset core.hooksPath` once first.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Completion must never execute JavaScript');
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"schemaVersion": 1,
"vitePlusVersion": "1.2.0",
"vitestVersion": "5.0.5",
"globalOptions": [
{
"flags": [
"--alpha"
],
"description": "alpha option",
"valueMode": "none"
}
],
"commands": [
{
"name": "",
"options": []
},
{
"name": "run",
"options": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vite-plus", "version": "1.2.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vitest", "version": "5.0.5"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Completion must never execute JavaScript');
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"schemaVersion": 1,
"vitePlusVersion": "1.3.0",
"vitestVersion": "5.1.0",
"globalOptions": [
{
"flags": [
"--beta"
],
"description": "beta option",
"valueMode": "none"
}
],
"commands": [
{
"name": "",
"options": []
},
{
"name": "run",
"options": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vite-plus", "version": "1.3.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vitest", "version": "5.1.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Completion must never execute JavaScript');
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"schemaVersion": 1,
"vitePlusVersion": "1.2.0",
"vitestVersion": "5.0.5",
"globalOptions": [
{
"flags": [
"--global-option"
],
"description": "global option",
"valueMode": "none"
}
],
"commands": [
{
"name": "",
"options": []
},
{
"name": "run",
"options": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vite-plus", "version": "1.2.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vitest", "version": "5.0.5"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Completion must never execute JavaScript');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vite-plus", "version": "1.1.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "vitest", "version": "5.0.3"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[[case]]
name = "test_completion_follows_local_toolchain"
vp = "global"
seed-runtime = false
env = { VP_COMPLETE = "bash", _CLAP_COMPLETE_INDEX = "2" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "node_modules"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha", "node_modules/vite-plus"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha/artifacts", "node_modules/vite-plus/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "node_modules/vite-plus/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "cp", "package-alpha/vitest-package.json", "node_modules/vite-plus/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "other/node_modules"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-beta", "other/node_modules/vite-plus"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-beta/artifacts", "other/node_modules/vite-plus/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "other/node_modules/vite-plus/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "cp", "package-beta/vitest-package.json", "other/node_modules/vite-plus/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Uses the runnable local CLI metadata without starting Node" },
{ argv = ["vp", "--", "vp", "-C", "other", "test", "--be"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"], ["_CLAP_COMPLETE_INDEX", "4"]], comment = "Reads metadata from the directory selected inside the completion payload" },
{ argv = ["vp", "--", "vp", "-Cother", "test", "--be"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"], ["_CLAP_COMPLETE_INDEX", "3"]] },
{ argv = ["vp", "--", "vp", "-C=other", "test", "--be"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"], ["_CLAP_COMPLETE_INDEX", "3"]] },
]

[[case]]
name = "test_completion_old_local_does_not_use_global_metadata"
vp = "global"
seed-runtime = false
env = { VP_COMPLETE = "bash", _CLAP_COMPLETE_INDEX = "2" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "node_modules"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-old", "node_modules/vite-plus"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-old/artifacts", "node_modules/vite-plus/dist"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global", "global"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global/artifacts", "global/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "global/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "cp", "package-global/vitest-package.json", "global/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--glob"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "An old runnable local package must not use a newer global completion schema" },
{ argv = ["vpt", "rm", "node_modules/vite-plus/dist/bin.js"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--glob"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Falls back globally only when the local CLI is not runnable" },
]

[[case]]
name = "test_completion_vitest_3_silently_declines"
vp = "global"
seed-runtime = false
env = { VP_COMPLETE = "bash", _CLAP_COMPLETE_INDEX = "2" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "node_modules"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha", "node_modules/vite-plus"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha/artifacts", "node_modules/vite-plus/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "node_modules/vite-plus/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "write-file", "node_modules/vite-plus/node_modules/vitest/package.json", '{"name":"vitest","version":"3.2.4"}'], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global", "global"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global/artifacts", "global/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "global/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "cp", "package-global/vitest-package.json", "global/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Stale Vitest 5 metadata with legacy Vitest: empty stdout/stderr and success" },
{ argv = ["vp", "--", "vp", "test", "--glob"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Does not borrow the global toolchain's Vitest 5 metadata" },
{ argv = ["vpt", "rm", "node_modules/vite-plus/dist/completion/test.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Missing metadata also completes silently" },
{ argv = ["vpt", "cp", "package-alpha/artifacts/completion/test.json", "node_modules/vite-plus/dist/completion/test.json"], snapshot = false },
{ argv = ["vpt", "cp", "package-alpha/vitest-package.json", "node_modules/vite-plus/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], comment = "Positive control: matched Vitest 5 metadata completes again, without executing tests" },
]

[[case]]
name = "test_completion_vitest_4_silently_declines"
vp = "global"
seed-runtime = false
env = { VP_COMPLETE = "bash", _CLAP_COMPLETE_INDEX = "2" }
steps = [
{ argv = ["vpt", "mkdir", "-p", "node_modules"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha", "node_modules/vite-plus"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-alpha/artifacts", "node_modules/vite-plus/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "node_modules/vite-plus/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "write-file", "node_modules/vite-plus/node_modules/vitest/package.json", '{"name":"vitest","version":"4.1.10"}'], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global", "global"], snapshot = false },
{ argv = ["vpt", "cp", "-r", "package-global/artifacts", "global/dist"], snapshot = false },
{ argv = ["vpt", "mkdir", "-p", "global/node_modules/vitest"], snapshot = false },
{ argv = ["vpt", "cp", "package-global/vitest-package.json", "global/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Stale Vitest 5 metadata with legacy Vitest: empty stdout/stderr and success" },
{ argv = ["vp", "--", "vp", "test", "--glob"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Does not borrow the global toolchain's Vitest 5 metadata" },
{ argv = ["vpt", "rm", "node_modules/vite-plus/dist/completion/test.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], envs = [["VP_GLOBAL_CLI_JS_SCRIPTS_DIR", "${workspace}/global/dist"]], comment = "Missing metadata also completes silently" },
{ argv = ["vpt", "cp", "package-alpha/artifacts/completion/test.json", "node_modules/vite-plus/dist/completion/test.json"], snapshot = false },
{ argv = ["vpt", "cp", "package-alpha/vitest-package.json", "node_modules/vite-plus/node_modules/vitest/package.json"], snapshot = false },
{ argv = ["vp", "--", "vp", "test", "--al"], comment = "Positive control: matched Vitest 5 metadata completes again, without executing tests" },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# test_completion_follows_local_toolchain

## `vpt mkdir -p node_modules`


## `vpt cp -r package-alpha node_modules/vite-plus`


## `vpt cp -r package-alpha/artifacts node_modules/vite-plus/dist`


## `vpt mkdir -p node_modules/vite-plus/node_modules/vitest`


## `vpt cp package-alpha/vitest-package.json node_modules/vite-plus/node_modules/vitest/package.json`


## `vpt mkdir -p other/node_modules`


## `vpt cp -r package-beta other/node_modules/vite-plus`


## `vpt cp -r package-beta/artifacts other/node_modules/vite-plus/dist`


## `vpt mkdir -p other/node_modules/vite-plus/node_modules/vitest`


## `vpt cp package-beta/vitest-package.json other/node_modules/vite-plus/node_modules/vitest/package.json`


## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --al`

Uses the runnable local CLI metadata without starting Node

```
--alpha
```

## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist _CLAP_COMPLETE_INDEX=4 vp -- vp -C other test --be`

Reads metadata from the directory selected inside the completion payload

```
--beta
```

## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist _CLAP_COMPLETE_INDEX=3 vp -- vp -Cother test --be`

```
--beta
```

## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist _CLAP_COMPLETE_INDEX=3 vp -- vp -C=other test --be`

```
--beta
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# test_completion_old_local_does_not_use_global_metadata

## `vpt mkdir -p node_modules`


## `vpt cp -r package-old node_modules/vite-plus`


## `vpt cp -r package-old/artifacts node_modules/vite-plus/dist`


## `vpt cp -r package-global global`


## `vpt cp -r package-global/artifacts global/dist`


## `vpt mkdir -p global/node_modules/vitest`


## `vpt cp package-global/vitest-package.json global/node_modules/vitest/package.json`


## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --glob`

An old runnable local package must not use a newer global completion schema

```
```

## `vpt rm node_modules/vite-plus/dist/bin.js`


## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --glob`

Falls back globally only when the local CLI is not runnable

```
--global-option
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# test_completion_vitest_3_silently_declines

## `vpt mkdir -p node_modules`


## `vpt cp -r package-alpha node_modules/vite-plus`


## `vpt cp -r package-alpha/artifacts node_modules/vite-plus/dist`


## `vpt mkdir -p node_modules/vite-plus/node_modules/vitest`


## `vpt write-file node_modules/vite-plus/node_modules/vitest/package.json '{"name":"vitest","version":"3.2.4"}'`


## `vpt cp -r package-global global`


## `vpt cp -r package-global/artifacts global/dist`


## `vpt mkdir -p global/node_modules/vitest`


## `vpt cp package-global/vitest-package.json global/node_modules/vitest/package.json`


## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --al`

Stale Vitest 5 metadata with legacy Vitest: empty stdout/stderr and success

```
```

## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --glob`

Does not borrow the global toolchain's Vitest 5 metadata

```
```

## `vpt rm node_modules/vite-plus/dist/completion/test.json`


## `VP_GLOBAL_CLI_JS_SCRIPTS_DIR=${workspace}/global/dist vp -- vp test --al`

Missing metadata also completes silently

```
```

## `vpt cp package-alpha/artifacts/completion/test.json node_modules/vite-plus/dist/completion/test.json`


## `vpt cp package-alpha/vitest-package.json node_modules/vite-plus/node_modules/vitest/package.json`


## `vp -- vp test --al`

Positive control: matched Vitest 5 metadata completes again, without executing tests

```
--alpha
```
Loading
Loading