Skip to content

Commit 1a60822

Browse files
authored
fix(cli): add should use 2.0.0-rc for known plugins (#10699)
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
1 parent da381e0 commit 1a60822

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
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+
Changed the `add` command to use a version requirement that matches the CLI's stable and prerelease numbers.

tooling/cli/src/add.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ 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());
72+
7173
cargo::install_one(cargo::CargoInstallOptions {
7274
name: &crate_name,
7375
version,

tooling/cli/src/helpers/plugins.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct PluginMetadata {
1010
pub mobile_only: bool,
1111
pub rust_only: bool,
1212
pub builder: bool,
13+
pub version_req: Option<String>,
1314
}
1415

1516
// known plugins with particular cases
@@ -55,5 +56,40 @@ pub fn known_plugins() -> HashMap<&'static str, PluginMetadata> {
5556
plugins.entry(p).or_default().rust_only = true;
5657
}
5758

59+
// known, but no particular config
60+
for p in [
61+
"geolocation",
62+
"deep-link",
63+
"dialog",
64+
"fs",
65+
"http",
66+
"notification",
67+
"os",
68+
"process",
69+
"shell",
70+
"upload",
71+
"websocket",
72+
] {
73+
plugins.entry(p).or_default();
74+
}
75+
76+
let version_req = version_req();
77+
for plugin in plugins.values_mut() {
78+
plugin.version_req.replace(version_req.clone());
79+
}
80+
5881
plugins
5982
}
83+
84+
fn version_req() -> String {
85+
let pre = env!("CARGO_PKG_VERSION_PRE");
86+
if pre.is_empty() {
87+
env!("CARGO_PKG_VERSION_MAJOR").to_string()
88+
} else {
89+
format!(
90+
"{}.0.0-{}",
91+
env!("CARGO_PKG_VERSION_MAJOR"),
92+
pre.split('.').next().unwrap()
93+
)
94+
}
95+
}

tooling/cli/src/migrate/migrations/v1/frontend.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ pub fn migrate(app_dir: &Path) -> Result<Vec<String>> {
6565
format!("{}.0.0", env!("CARGO_PKG_VERSION_MAJOR"))
6666
} else {
6767
format!(
68-
"{}.{}.{}-{}.0",
68+
"{}.0.0-{}.0",
6969
env!("CARGO_PKG_VERSION_MAJOR"),
70-
env!("CARGO_PKG_VERSION_MINOR"),
71-
env!("CARGO_PKG_VERSION_PATCH"),
7270
pre.split('.').next().unwrap()
7371
)
7472
};

tooling/cli/src/migrate/migrations/v1/manifest.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ fn dependency_version() -> String {
198198
env!("CARGO_PKG_VERSION_MAJOR").to_string()
199199
} else {
200200
format!(
201-
"{}.{}.{}-{}",
201+
"{}.0.0-{}",
202202
env!("CARGO_PKG_VERSION_MAJOR"),
203-
env!("CARGO_PKG_VERSION_MINOR"),
204-
env!("CARGO_PKG_VERSION_PATCH"),
205203
pre.split('.').next().unwrap()
206204
)
207205
}

0 commit comments

Comments
 (0)