Skip to content

Commit 9ed9ddb

Browse files
committed
fix(install): address PR review comments for bun commands
- view.rs: use native `bun info` instead of npm fallback - dlx.rs: forward `--package` flag to `bun x` (before package spec) - install.rs: forward `--lockfile-only` to bun - outdated.rs: forward `--production` and `--omit optional` to bun - login/logout/owner/ping/search/token: remove unnecessary warning logs when falling back to npm (the fallback itself is correct)
1 parent 7a72f29 commit 9ed9ddb

12 files changed

Lines changed: 52 additions & 69 deletions

File tree

crates/vite_install/src/commands/dlx.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,18 @@ impl PackageManager {
200200
// Some installation methods (e.g. mise) don't add bunx to PATH on Windows.
201201
args.push("x".into());
202202

203+
// --packages flags must come before the package spec
204+
for pkg in options.packages {
205+
args.push("--package".into());
206+
args.push(pkg.clone());
207+
}
208+
203209
// Add package spec
204210
args.push(options.package_spec.into());
205211

206212
// Add command arguments
207213
args.extend(options.args.iter().cloned());
208214

209-
// Warn about unsupported flags
210-
if !options.packages.is_empty() {
211-
output::warn("bun x does not support --package");
212-
}
213215
if options.shell_mode {
214216
output::warn("bun x does not support shell mode (-c)");
215217
}

crates/vite_install/src/commands/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl PackageManager {
317317
args.push("--ignore-scripts".into());
318318
}
319319
if options.lockfile_only {
320-
output::warn("bun does not support --lockfile-only");
320+
args.push("--lockfile-only".into());
321321
}
322322
if options.prefer_offline {
323323
output::warn("bun does not support --prefer-offline");

crates/vite_install/src/commands/login.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

87
use crate::package_manager::{
98
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
@@ -57,7 +56,6 @@ impl PackageManager {
5756
}
5857
}
5958
PackageManagerType::Bun => {
60-
output::warn("bun does not have a login command, falling back to npm login");
6159
bin_name = "npm".into();
6260
args.push("login".into());
6361
}

crates/vite_install/src/commands/logout.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

87
use crate::package_manager::{
98
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
@@ -57,7 +56,6 @@ impl PackageManager {
5756
}
5857
}
5958
PackageManagerType::Bun => {
60-
output::warn("bun does not have a logout command, falling back to npm logout");
6159
bin_name = "npm".into();
6260
args.push("logout".into());
6361
}

crates/vite_install/src/commands/outdated.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,15 @@ impl PackageManager {
249249
if options.workspace_root {
250250
output::warn("bun outdated does not support --workspace-root");
251251
}
252-
if options.prod || options.dev {
253-
output::warn("bun outdated does not support --prod/--dev");
252+
if options.prod {
253+
args.push("--production".into());
254+
}
255+
if options.dev {
256+
output::warn("bun outdated does not support --dev");
254257
}
255258
if options.no_optional {
256-
output::warn("bun outdated does not support --no-optional");
259+
args.push("--omit".into());
260+
args.push("optional".into());
257261
}
258262
if options.compatible {
259263
output::warn("bun outdated does not support --compatible");

crates/vite_install/src/commands/owner.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

8-
use crate::package_manager::{
9-
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
10-
};
7+
use crate::package_manager::{PackageManager, ResolveCommandResult, format_path_env};
118

129
/// Owner subcommand type.
1310
#[derive(Debug, Clone)]
@@ -39,10 +36,6 @@ impl PackageManager {
3936
let envs = HashMap::from([("PATH".to_string(), format_path_env(self.get_bin_prefix()))]);
4037
let mut args: Vec<String> = Vec::new();
4138

42-
if self.client == PackageManagerType::Bun {
43-
output::warn("bun does not support the owner command, falling back to npm owner");
44-
}
45-
4639
args.push("owner".into());
4740

4841
match subcommand {

crates/vite_install/src/commands/ping.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

8-
use crate::package_manager::{
9-
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
10-
};
7+
use crate::package_manager::{PackageManager, ResolveCommandResult, format_path_env};
118

129
/// Options for the ping command.
1310
#[derive(Debug, Default)]
@@ -38,10 +35,6 @@ impl PackageManager {
3835
let envs = HashMap::from([("PATH".to_string(), format_path_env(self.get_bin_prefix()))]);
3936
let mut args: Vec<String> = Vec::new();
4037

41-
if self.client == PackageManagerType::Bun {
42-
output::warn("bun does not support the ping command, falling back to npm ping");
43-
}
44-
4538
args.push("ping".into());
4639

4740
if let Some(registry_value) = options.registry {

crates/vite_install/src/commands/search.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

8-
use crate::package_manager::{
9-
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
10-
};
7+
use crate::package_manager::{PackageManager, ResolveCommandResult, format_path_env};
118

129
/// Options for the search command.
1310
#[derive(Debug, Default)]
@@ -41,10 +38,6 @@ impl PackageManager {
4138
let envs = HashMap::from([("PATH".to_string(), format_path_env(self.get_bin_prefix()))]);
4239
let mut args: Vec<String> = Vec::new();
4340

44-
if self.client == PackageManagerType::Bun {
45-
output::warn("bun does not support the search command, falling back to npm search");
46-
}
47-
4841
args.push("search".into());
4942

5043
for term in options.terms {

crates/vite_install/src/commands/token.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

8-
use crate::package_manager::{
9-
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
10-
};
7+
use crate::package_manager::{PackageManager, ResolveCommandResult, format_path_env};
118

129
/// Token subcommand type.
1310
#[derive(Debug, Clone)]
@@ -53,10 +50,6 @@ impl PackageManager {
5350
let envs = HashMap::from([("PATH".to_string(), format_path_env(self.get_bin_prefix()))]);
5451
let mut args: Vec<String> = Vec::new();
5552

56-
if self.client == PackageManagerType::Bun {
57-
output::warn("bun does not support the token command, falling back to npm token");
58-
}
59-
6053
args.push("token".into());
6154

6255
match subcommand {

crates/vite_install/src/commands/view.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{collections::HashMap, process::ExitStatus};
33
use vite_command::run_command;
44
use vite_error::Error;
55
use vite_path::AbsolutePath;
6-
use vite_shared::output;
76

87
use crate::package_manager::{
98
PackageManager, PackageManagerType, ResolveCommandResult, format_path_env,
@@ -33,28 +32,39 @@ impl PackageManager {
3332

3433
/// Resolve the view command.
3534
/// All package managers delegate to npm view (pnpm and yarn use npm internally).
36-
/// Bun does not have a direct equivalent, so we fall back to npm view.
35+
/// Bun uses `bun info` as a native alternative.
3736
#[must_use]
3837
pub fn resolve_view_command(&self, options: &ViewCommandOptions) -> ResolveCommandResult {
39-
let bin_name: String = "npm".to_string();
4038
let envs = HashMap::from([("PATH".to_string(), format_path_env(self.get_bin_prefix()))]);
4139
let mut args: Vec<String> = Vec::new();
4240

43-
if self.client == PackageManagerType::Bun {
44-
output::warn("bun does not have a view command, falling back to npm view");
45-
}
41+
let bin_name: String = if self.client == PackageManagerType::Bun {
42+
args.push("info".into());
43+
args.push(options.package.to_string());
4644

47-
args.push("view".into());
45+
if let Some(field) = options.field {
46+
args.push(field.to_string());
47+
}
4848

49-
args.push(options.package.to_string());
49+
if options.json {
50+
args.push("--json".into());
51+
}
5052

51-
if let Some(field) = options.field {
52-
args.push(field.to_string());
53-
}
53+
"bun".into()
54+
} else {
55+
args.push("view".into());
56+
args.push(options.package.to_string());
5457

55-
if options.json {
56-
args.push("--json".into());
57-
}
58+
if let Some(field) = options.field {
59+
args.push(field.to_string());
60+
}
61+
62+
if options.json {
63+
args.push("--json".into());
64+
}
65+
66+
"npm".into()
67+
};
5868

5969
// Add pass-through args
6070
if let Some(pass_through_args) = options.pass_through_args {

0 commit comments

Comments
 (0)