Skip to content

Commit

Permalink
fix(cli): add should use 2.0.0-rc for known plugins (#10699)
Browse files Browse the repository at this point in the history
changes the CLI `add` command to match the CLI major and pre requirements for known plugins

this is required because right now adding the deep-link plugin installs the v1 plugin (latest version known by cargo as the v2 is still in RC), even though we're running the v2 CLI
  • Loading branch information
lucasfernog committed Aug 20, 2024
1 parent da381e0 commit 1a60822
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-cli-add-plugin-version.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions tooling/cli/src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
36 changes: 36 additions & 0 deletions tooling/cli/src/helpers/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct PluginMetadata {
pub mobile_only: bool,
pub rust_only: bool,
pub builder: bool,
pub version_req: Option<String>,
}

// known plugins with particular cases
Expand Down Expand Up @@ -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()
)
}
}
4 changes: 1 addition & 3 deletions tooling/cli/src/migrate/migrations/v1/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ pub fn migrate(app_dir: &Path) -> Result<Vec<String>> {
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()
)
};
Expand Down
4 changes: 1 addition & 3 deletions tooling/cli/src/migrate/migrations/v1/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
}
Expand Down

0 comments on commit 1a60822

Please sign in to comment.