Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli/migrate): migrate zipped updater #10212

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/migrate-zipped-updater.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:feat'
'@tauri-apps/cli': 'patch:feat'
---

Migrate updater plugin with zip feature
9 changes: 8 additions & 1 deletion tooling/cli/src/helpers/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ pub struct CargoInstallOptions<'a> {
pub target: Option<&'a str>,
}

pub fn install(dependencies: &[String], cwd: Option<&Path>) -> crate::Result<()> {
pub fn install(
dependencies: &[String],
features: &[String],
cwd: Option<&Path>,
) -> crate::Result<()> {
let dependencies_str = if dependencies.len() > 1 {
"dependencies"
} else {
Expand All @@ -34,6 +38,9 @@ pub fn install(dependencies: &[String], cwd: Option<&Path>) -> crate::Result<()>

let mut cmd = Command::new("cargo");
cmd.arg("add").args(dependencies);
if !features.is_empty() {
cmd.arg("--features").args(features);
}

if let Some(cwd) = cwd {
cmd.current_dir(cwd);
Expand Down
9 changes: 8 additions & 1 deletion tooling/cli/src/migrate/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const PLUGINIFIED_MODULES: &[&str] = &[
"shell",
"updater",
];
const ADDITIONAL_FEATURES: &[&str] = &["tauri-plugin-updater/zip"];
const JS_EXTENSIONS: &[&str] = &["js", "mjs", "jsx", "ts", "mts", "tsx"];

/// Returns a list of paths that could not be migrated
pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
let mut new_npm_packages = Vec::new();
let mut new_cargo_packages = Vec::new();
let mut new_cargo_features = Vec::new();

let pm = PackageManager::from_project(app_dir)
.into_iter()
Expand Down Expand Up @@ -66,6 +68,11 @@ pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
let js_plugin = format!("@tauri-apps/plugin-{module}");
let cargo_crate = format!("tauri-plugin-{module}");
new_npm_packages.push(js_plugin.clone());
for feature in ADDITIONAL_FEATURES {
if feature.starts_with(&cargo_crate) {
new_cargo_features.push(feature.to_string());
}
}
new_cargo_packages.push(cargo_crate);
js_plugin
} else {
Expand All @@ -90,7 +97,7 @@ pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
}

if !new_cargo_packages.is_empty() {
cargo::install(&new_cargo_packages, Some(tauri_dir))
cargo::install(&new_cargo_packages, &new_cargo_features, Some(tauri_dir))
.context("Error installing new Cargo packages")?;
}

Expand Down
Loading