Skip to content

Commit

Permalink
fix(cli): add command version requirement for known plugin npm (#10795
Browse files Browse the repository at this point in the history
)

small regression from #10699 - NPM install is now prompting users to select the version
  • Loading branch information
lucasfernog committed Aug 27, 2024
1 parent 9718dc9 commit 02b2f96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-add-plugin-npm-version-req.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---

Fix the `add` command NPM version specifier for known plugins from `2.0.0-rc` (unknown version requirement) to `^2.0.0-rc`.
9 changes: 6 additions & 3 deletions tooling/cli/src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ pub fn run(options: Options) -> Result<()> {
.then_some(r#"cfg(any(target_os = "android", target_os = "ios"))"#)
});

let version = version.or(metadata.version_req.as_deref());
let cargo_version_req = version.or(metadata.version_req.as_deref());
let npm_version_req = version
.map(ToString::to_string)
.or(metadata.version_req.as_ref().map(|v| format!("^{v}")));

cargo::install_one(cargo::CargoInstallOptions {
name: &crate_name,
version,
version: cargo_version_req,
branch: options.branch.as_deref(),
rev: options.rev.as_deref(),
tag: options.tag.as_deref(),
Expand All @@ -85,7 +88,7 @@ pub fn run(options: Options) -> Result<()> {
.map(PackageManager::from_project)
.and_then(|managers| managers.into_iter().next())
{
let npm_spec = match (version, options.tag, options.rev, options.branch) {
let npm_spec = match (npm_version_req, options.tag, options.rev, options.branch) {
(Some(version), _, _, _) => {
format!("{npm_name}@{version}")
}
Expand Down

0 comments on commit 02b2f96

Please sign in to comment.