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
This commit is contained in:
Lucas Fernandes Nogueira 2024-08-27 11:02:14 -03:00 committed by GitHub
parent 9718dc9e8c
commit 02b2f964a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -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`.

View File

@ -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(),
@ -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}")
}