diff --git a/.changes/add-community-plugins.md b/.changes/add-community-plugins.md new file mode 100644 index 000000000000..afddc81d539d --- /dev/null +++ b/.changes/add-community-plugins.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Properly add NPM packages for community plugins when using the `tauri add` command. diff --git a/crates/tauri-cli/src/add.rs b/crates/tauri-cli/src/add.rs index 56ad58ef0495..968cbd83ca62 100644 --- a/crates/tauri-cli/src/add.rs +++ b/crates/tauri-cli/src/add.rs @@ -49,12 +49,25 @@ pub fn run(options: Options) -> Result<()> { .map(|(p, v)| (p, Some(v))) .unwrap_or((&options.plugin, None)); + let mut plugins = crate::helpers::plugins::known_plugins(); + let (metadata, is_known) = plugins + .remove(plugin) + .map(|metadata| (metadata, true)) + .unwrap_or_default(); + let plugin_snake_case = plugin.replace('-', "_"); let crate_name = format!("tauri-plugin-{plugin}"); - let npm_name = format!("@tauri-apps/plugin-{plugin}"); + let npm_name = if is_known { + format!("tauri-apps/plugin-{plugin}") + } else { + format!("tauri-plugin-{plugin}-api") + }; - let mut plugins = crate::helpers::plugins::known_plugins(); - let metadata = plugins.remove(plugin).unwrap_or_default(); + if !is_known && (options.tag.is_some() || options.rev.is_some() || options.branch.is_some()) { + anyhow::bail!( + "Git options --tag, --rev and --branch can only be used with official Tauri plugins" + ); + } let frontend_dir = resolve_frontend_dir(); let tauri_dir = tauri_dir(); diff --git a/crates/tauri-cli/src/helpers/plugins.rs b/crates/tauri-cli/src/helpers/plugins.rs index 9c676150aeb5..83201231b705 100644 --- a/crates/tauri-cli/src/helpers/plugins.rs +++ b/crates/tauri-cli/src/helpers/plugins.rs @@ -69,6 +69,7 @@ pub fn known_plugins() -> HashMap<&'static str, PluginMetadata> { "shell", "upload", "websocket", + "opener", ] { plugins.entry(p).or_default(); }