diff --git a/.changes/migrate-plugins.md b/.changes/migrate-plugins.md new file mode 100644 index 000000000..b9a979579 --- /dev/null +++ b/.changes/migrate-plugins.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Migrate v1 plugins to their v2 releases. diff --git a/.changes/migrate-prevent-duplications.md b/.changes/migrate-prevent-duplications.md new file mode 100644 index 000000000..0edf2f3af --- /dev/null +++ b/.changes/migrate-prevent-duplications.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Prevent duplicate permissions on v1 migration. diff --git a/tooling/cli/src/add.rs b/tooling/cli/src/add.rs index e5309780e..08635c589 100644 --- a/tooling/cli/src/add.rs +++ b/tooling/cli/src/add.rs @@ -39,7 +39,10 @@ pub struct Options { pub fn command(options: Options) -> Result<()> { crate::helpers::app_paths::resolve(); + run(options) +} +pub fn run(options: Options) -> Result<()> { let (plugin, version) = options .plugin .split_once('@') diff --git a/tooling/cli/src/migrate/migrations/v1/config.rs b/tooling/cli/src/migrate/migrations/v1/config.rs index 6722e67f2..af60d3d02 100644 --- a/tooling/cli/src/migrate/migrations/v1/config.rs +++ b/tooling/cli/src/migrate/migrations/v1/config.rs @@ -386,13 +386,16 @@ fn allowlist_to_permissions( allowlist: tauri_utils_v1::config::AllowlistConfig, ) -> Vec { macro_rules! permissions { - ($allowlist: ident, $permissions_list: ident, $object: ident, $field: ident => $associated_permission: expr) => { + ($allowlist: ident, $permissions_list: ident, $object: ident, $field: ident => $associated_permission: expr) => {{ if $allowlist.all || $allowlist.$object.all || $allowlist.$object.$field { $permissions_list.push(PermissionEntry::PermissionRef( $associated_permission.to_string().try_into().unwrap(), )); + true + } else { + false } - }; + }}; } let mut permissions = Vec::new(); @@ -474,8 +477,11 @@ fn allowlist_to_permissions( // shell if allowlist.shell.scope.0.is_empty() { - permissions!(allowlist, permissions, shell, execute => "shell:allow-execute"); - permissions!(allowlist, permissions, shell, sidecar => "shell:allow-execute"); + let added = permissions!(allowlist, permissions, shell, execute => "shell:allow-execute"); + // prevent duplicated permission + if !added { + permissions!(allowlist, permissions, shell, sidecar => "shell:allow-execute"); + } } else { let allowed = allowlist .shell diff --git a/tooling/cli/src/migrate/migrations/v1/manifest.rs b/tooling/cli/src/migrate/migrations/v1/manifest.rs index 44bad7aa4..73acd1111 100644 --- a/tooling/cli/src/migrate/migrations/v1/manifest.rs +++ b/tooling/cli/src/migrate/migrations/v1/manifest.rs @@ -45,6 +45,22 @@ fn migrate_manifest(manifest: &mut Document) -> Result<()> { ("tauri-codegen", "dependencies"), ("tauri-macros", "dependencies"), ("tauri-runtime-wry", "dependencies"), + // normal deps - plugins + ("tauri-plugin-authenticator", "dependencies"), + ("tauri-plugin-autostart", "dependencies"), + ("tauri-plugin-fs-extra", "dependencies"), + ("tauri-plugin-fs-watch", "dependencies"), + ("tauri-plugin-localhost", "dependencies"), + ("tauri-plugin-log", "dependencies"), + ("tauri-plugin-persisted-scope", "dependencies"), + ("tauri-plugin-positioner", "dependencies"), + ("tauri-plugin-single-instance", "dependencies"), + ("tauri-plugin-sql", "dependencies"), + ("tauri-plugin-store", "dependencies"), + ("tauri-plugin-stronghold", "dependencies"), + ("tauri-plugin-upload", "dependencies"), + ("tauri-plugin-websocket", "dependencies"), + ("tauri-plugin-window-state", "dependencies"), // dev ("tauri", "dev-dependencies"), ("tauri-utils", "dev-dependencies"), @@ -207,6 +223,10 @@ fn migrate_dependency_table( remove: &[&str], rename: &[(&str, &str)], ) { + dep.remove("rev"); + dep.remove("git"); + dep.remove("branch"); + dep.remove("tag"); *dep.entry("version").or_insert(Item::None) = Item::Value(version.into()); let manifest_features = dep.entry("features").or_insert(Item::None); if let Some(features_array) = manifest_features.as_array_mut() { diff --git a/tooling/cli/src/migrate/migrations/v1/mod.rs b/tooling/cli/src/migrate/migrations/v1/mod.rs index e378ab35a..26a7b7b20 100644 --- a/tooling/cli/src/migrate/migrations/v1/mod.rs +++ b/tooling/cli/src/migrate/migrations/v1/mod.rs @@ -25,7 +25,7 @@ pub fn run() -> Result<()> { // Add plugins for plugin in migrated.plugins { - crate::add::command(crate::add::Options { + crate::add::run(crate::add::Options { plugin: plugin.clone(), branch: None, tag: None,