Skip to content

Commit 02b2f96

Browse files
authored
fix(cli): add command version requirement for known plugin npm (#10795)
small regression from #10699 - NPM install is now prompting users to select the version
1 parent 9718dc9 commit 02b2f96

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri-cli': 'patch:bug'
3+
'@tauri-apps/cli': 'patch:bug'
4+
---
5+
6+
Fix the `add` command NPM version specifier for known plugins from `2.0.0-rc` (unknown version requirement) to `^2.0.0-rc`.

tooling/cli/src/add.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ pub fn run(options: Options) -> Result<()> {
6868
.then_some(r#"cfg(any(target_os = "android", target_os = "ios"))"#)
6969
});
7070

71-
let version = version.or(metadata.version_req.as_deref());
71+
let cargo_version_req = version.or(metadata.version_req.as_deref());
72+
let npm_version_req = version
73+
.map(ToString::to_string)
74+
.or(metadata.version_req.as_ref().map(|v| format!("^{v}")));
7275

7376
cargo::install_one(cargo::CargoInstallOptions {
7477
name: &crate_name,
75-
version,
78+
version: cargo_version_req,
7679
branch: options.branch.as_deref(),
7780
rev: options.rev.as_deref(),
7881
tag: options.tag.as_deref(),
@@ -85,7 +88,7 @@ pub fn run(options: Options) -> Result<()> {
8588
.map(PackageManager::from_project)
8689
.and_then(|managers| managers.into_iter().next())
8790
{
88-
let npm_spec = match (version, options.tag, options.rev, options.branch) {
91+
let npm_spec = match (npm_version_req, options.tag, options.rev, options.branch) {
8992
(Some(version), _, _, _) => {
9093
format!("{npm_name}@{version}")
9194
}

0 commit comments

Comments
 (0)