Skip to content
Merged
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
27 changes: 0 additions & 27 deletions bench/benches/auto_install.sh

This file was deleted.

11 changes: 5 additions & 6 deletions docs/vite/guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,11 @@ vp cache clean

### Environment Variables

| Variable | Description |
| --------------------------- | ------------------------------------------------------- |
| `VITE_LOG` | Set logging level (e.g., `VITE_LOG=debug`) |
| `VITE_DISABLE_AUTO_INSTALL` | Set to `1` to disable automatic dependency installation |
| `VITE_TASK_EXECUTION_ENV` | Internal: indicates running inside vite task |
| `VITE_TASK_EXECUTION_ID` | Internal: unique ID for task execution |
| Variable | Description |
| ------------------------- | -------------------------------------------- |
| `VITE_LOG` | Set logging level (e.g., `VITE_LOG=debug`) |
| `VITE_TASK_EXECUTION_ENV` | Internal: indicates running inside vite task |
| `VITE_TASK_EXECUTION_ID` | Internal: unique ID for task execution |

### Execution Modes

Expand Down
41 changes: 0 additions & 41 deletions packages/cli/binding/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,32 +644,6 @@ impl UserConfigLoader for VitePlusConfigLoader {
}
}

/// Create auto-install synthetic plan request
async fn create_install_synthetic_request(
cwd: &AbsolutePathBuf,
) -> Result<SyntheticPlanRequest, Error> {
let package_manager = vite_install::PackageManager::builder(cwd).build_with_default().await?;
let resolve_command = package_manager.resolve_install_command(&vec![]);

let mut envs: FxHashMap<Arc<OsStr>, Arc<OsStr>> = std::env::vars_os()
.map(|(k, v)| (Arc::from(k.as_os_str()), Arc::from(v.as_os_str())))
.collect();

for (k, v) in resolve_command.envs {
envs.insert(Arc::from(OsStr::new(&k)), Arc::from(OsStr::new(&v)));
}

Ok(SyntheticPlanRequest {
program: Arc::<OsStr>::from(OsStr::new(&resolve_command.bin_path).to_os_string()),
args: resolve_command.args.into_iter().map(Str::from).collect(),
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
envs: None,
pass_through_envs: None,
}),
envs: Arc::new(envs),
})
}

/// Execute a synthesizable subcommand directly (not through vite-task Session).
/// No caching, no task graph, no dependency resolution.
async fn execute_direct_subcommand(
Expand Down Expand Up @@ -766,21 +740,6 @@ async fn execute_vite_task_command(
user_config_loader: &mut config_loader,
})?;

// Auto-install (using Session::exec)
if env::var_os("VITE_DISABLE_AUTO_INSTALL") != Some("1".into()) {
if let Ok(install_request) = create_install_synthetic_request(&cwd).await {
let cache_key: Arc<[Str]> = vec![Str::from("install")].into();
let status = session
.execute_synthetic(install_request, cache_key, true)
.await
.map_err(|e| Error::Anyhow(e))?;
if status != ExitStatus::SUCCESS {
command_handler.cleanup_temp_files().await;
return Ok(status);
}
}
}

// Main execution (consumes session)
let result = session.main(command).await.map_err(|e| Error::Anyhow(e));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root",
"vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-add-npm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add --help # should show help",
"vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add testnpm2 -D -w -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root",
"vp add @vite-plus-test/utils --workspace -- --no-audit && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-add-npm11/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add --help # should show help",
"vp add testnpm2 -D -- --no-audit && cat package.json # should add package as dev dependencies",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add testnpm2 -D -w && cat package.json # should add package to workspace root",
"vp add @vite-plus-test/utils --workspace && cat package.json # should add @vite-plus-test/utils to workspace root",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-add-pnpm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add --help # should show help",
"vp add # should error because no packages specified",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1",
"NODE_OPTIONS": "--no-deprecation"
},
"commands": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1",
"NODE_OPTIONS": "--no-deprecation"
},
"commands": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add testnpm2 -D -w && cat package.json packages/app/package.json packages/utils/package.json # should add package to workspace root",
"vp add @vite-plus-test/utils --workspace -w && cat package.json packages/app/package.json packages/utils/package.json # should add @vite-plus-test/utils to workspace root",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-add-yarn4/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp add --help # should show help",
"vp add testnpm2 -D && cat package.json # should add package as dev dependencies",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-cache-npm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp pm cache dir # should show cache directory (uses npm config get cache)",
"vp pm cache path # should show cache path (alias for dir, uses npm config get cache)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp pm cache --help # should show help",
"vp pm cache dir > /dev/null # should show cache directory (uses pnpm store path)",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-cache-yarn4/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32", "darwin"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp pm cache dir # should show cache directory (uses yarn config get cacheFolder)",
"vp pm cache path # should show cache path (alias for dir, uses yarn config get cacheFolder)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"# vite pm config set vite-plus-pm-config-test-key test-value --location project # npm set will check valid keys start from npm v9, see https://github.com/npm/cli/issues/5852",
"vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp pm config --help # should show help",
"vp pm config list --location project > /dev/null # should list all project configuration",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1",
"NODE_OPTIONS": "--no-deprecation"
},
"commands": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp pm config set vite-plus-pm-config-test-key test-value --location project # should set config value in project scope",
"vp pm config get vite-plus-pm-config-test-key --location project # should get config value from project scope",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dedupe && cat package.json # should dedupe dependencies",
"vp dedupe --check && cat package.json # should check if deduplication would make changes",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dedupe --help # should show help",
"vp dedupe && cat package.json # should dedupe dependencies",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dedupe && cat package.json # should dedupe dependencies",
"vp dedupe --check && cat package.json # should check if deduplication would make changes",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-dlx-npm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dlx --help # should show help message",
"vp dlx -s cowsay hello # should run cowsay with npm exec",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-dlx-pnpm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dlx --help # should show help message",
"vp dlx -s cowsay hello # should run cowsay with pnpm dlx",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-dlx-yarn4/steps.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp dlx --help # should show help message",
"vp dlx -s cowsay hello # should run cowsay with yarn dlx",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"test ! -f package.json && echo 'no package.json' # verify no package.json exists",
"vp install --silent && cat package.json # should auto-create package.json and install",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install --no-frozen-lockfile --silent # install dependencies work",
"mkdir -p packages/sub-project && echo '{\"name\": \"sub-project\", \"dependencies\": { \"testnpm2\": \"1.0.0\" }}' > packages/sub-project/package.json # create sub project and package.json",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-link-npm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"mkdir -p ../test-lib-npm && echo '{\"name\": \"test-lib-npm\", \"version\": \"1.0.0\"}' > ../test-lib-npm/package.json # create test library",
"vp link ../test-lib-npm && cat package.json # should link local directory",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-link-pnpm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32", "linux"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp link -h # should show help message",
"vp install # install initial dependencies",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-link-yarn4/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"mkdir -p ../test-lib-yarn && echo '{\"name\": \"test-lib-yarn\", \"version\": \"1.0.0\"}' > ../test-lib-yarn/package.json # create test library",
"vp link ../test-lib-yarn && cat package.json # should link local directory",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install # should install packages first",
"vp pm list --json # should list current workspace root dependencies",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-list-npm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install # should install packages first",
"vp pm list --json # should list installed packages",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install # should install packages first",
"vp pm list # should list current workspace root dependencies",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-list-pnpm10/steps.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install # should install packages first",
"vp pm list --help # should show help",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1",
"NODE_OPTIONS": "--no-deprecation"
},
"commands": [
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/snap-tests-global/command-list-yarn4/steps.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": ["vp pm list # should show warning that yarn@2+ does not support list command"]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"ignoredPlatforms": ["win32"],
"env": {
"VITE_DISABLE_AUTO_INSTALL": "1"
},
"commands": [
"vp install",
"vp outdated testnpm2 -w # should outdated in workspace root",
Expand Down
Loading
Loading