diff --git a/.changes/fix-cli-add-plugin-version.md b/.changes/fix-cli-add-plugin-version.md new file mode 100644 index 00000000000..3c0db7e0722 --- /dev/null +++ b/.changes/fix-cli-add-plugin-version.md @@ -0,0 +1,6 @@ +--- +'tauri-cli': 'patch:bug' +'@tauri-apps/cli': 'patch:bug' +--- + +Changed the `add` command to use a version requirement that matches the CLI's stable and prerelease numbers. diff --git a/tooling/cli/src/add.rs b/tooling/cli/src/add.rs index 08635c589f6..7b488b5fcc5 100644 --- a/tooling/cli/src/add.rs +++ b/tooling/cli/src/add.rs @@ -68,6 +68,8 @@ 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()); + cargo::install_one(cargo::CargoInstallOptions { name: &crate_name, version, diff --git a/tooling/cli/src/helpers/plugins.rs b/tooling/cli/src/helpers/plugins.rs index 52280635bae..9c676150aeb 100644 --- a/tooling/cli/src/helpers/plugins.rs +++ b/tooling/cli/src/helpers/plugins.rs @@ -10,6 +10,7 @@ pub struct PluginMetadata { pub mobile_only: bool, pub rust_only: bool, pub builder: bool, + pub version_req: Option, } // known plugins with particular cases @@ -55,5 +56,40 @@ pub fn known_plugins() -> HashMap<&'static str, PluginMetadata> { plugins.entry(p).or_default().rust_only = true; } + // known, but no particular config + for p in [ + "geolocation", + "deep-link", + "dialog", + "fs", + "http", + "notification", + "os", + "process", + "shell", + "upload", + "websocket", + ] { + plugins.entry(p).or_default(); + } + + let version_req = version_req(); + for plugin in plugins.values_mut() { + plugin.version_req.replace(version_req.clone()); + } + plugins } + +fn version_req() -> String { + let pre = env!("CARGO_PKG_VERSION_PRE"); + if pre.is_empty() { + env!("CARGO_PKG_VERSION_MAJOR").to_string() + } else { + format!( + "{}.0.0-{}", + env!("CARGO_PKG_VERSION_MAJOR"), + pre.split('.').next().unwrap() + ) + } +} diff --git a/tooling/cli/src/migrate/migrations/v1/frontend.rs b/tooling/cli/src/migrate/migrations/v1/frontend.rs index b68b59eb0f4..5afba76da92 100644 --- a/tooling/cli/src/migrate/migrations/v1/frontend.rs +++ b/tooling/cli/src/migrate/migrations/v1/frontend.rs @@ -65,10 +65,8 @@ pub fn migrate(app_dir: &Path) -> Result> { format!("{}.0.0", env!("CARGO_PKG_VERSION_MAJOR")) } else { format!( - "{}.{}.{}-{}.0", + "{}.0.0-{}.0", env!("CARGO_PKG_VERSION_MAJOR"), - env!("CARGO_PKG_VERSION_MINOR"), - env!("CARGO_PKG_VERSION_PATCH"), pre.split('.').next().unwrap() ) }; diff --git a/tooling/cli/src/migrate/migrations/v1/manifest.rs b/tooling/cli/src/migrate/migrations/v1/manifest.rs index 73acd1111c9..9a83d985dec 100644 --- a/tooling/cli/src/migrate/migrations/v1/manifest.rs +++ b/tooling/cli/src/migrate/migrations/v1/manifest.rs @@ -198,10 +198,8 @@ fn dependency_version() -> String { env!("CARGO_PKG_VERSION_MAJOR").to_string() } else { format!( - "{}.{}.{}-{}", + "{}.0.0-{}", env!("CARGO_PKG_VERSION_MAJOR"), - env!("CARGO_PKG_VERSION_MINOR"), - env!("CARGO_PKG_VERSION_PATCH"), pre.split('.').next().unwrap() ) }