Repository: tauri-apps/tauri (language: rust)

Issue:
[docs/feat] `npm run tauri add tauri-plugin-custom` for community plugins
**Describe the problem**

So - I'm not sure if this is a bug, a feature request or something where the documentation could be improved.

I'm trying to write a plugin for tauri and I was trying to add it via `npm run tauri add tauri-plugin-python`
I registered the plugin `tauri-plugin-python` in [crates.io](https://crates.io/) and the npm package as `tauri-plugin-python-api` in npmjs.com.

But when trying to add it via `npm run tauri add tauri-plugin-python`, it tries to install `@tauri-apps/plugin-python`.
According to the cli code, `@tauri-apps/plugin-...` just seems to be the only scope for npm packages:
https://github.com/tauri-apps/tauri/blob/f86e2387c96b7872a7ca661fd8c22136b2932402/crates/tauri-cli/src/add.rs#L54C7-L54C15
According to the documentation, you should still call the plugin js package `tauri-plugin-...-api`. And it is recommended to use npm-scopes. But it seems that the only supported scope is `@tauri-apps`.

I guess some good and often used community plugins are manually moved to `@tauri-apps` 
So the default way is to perform manual steps for community plugins and calling `cargo add ...` and `npm install ...` instead of `npm run tauri add...`

Is this correct (just asking)?

Edit: 

**Reproduction**
Run `npm run tauri add tauri-plugin-python` or another community plugin. It is always trying to use an npm package fro `@tauri-apps/...` 
Therefore, it is required to perform manual steps instead of just performing `tauri add` to add community plugins. This needs to be documented.

**Expected behavior**
Adding additional parameter `--community` so that community plugins can also be added via `npm run tauri add ... --community` which performs the same steps for community plugins as for official ones.


Discussion / hints:
> I guess some good and often used community plugins are manually moved to @tauri-apps

well, not really. at least not anymore (for now).

> So the default way is to perform manual steps for community plugins and calling cargo add ... and npm install ... instead of npm run tauri add...

Yep

----

iirc we want `tauri add` to be more agnostic but didn't work towards it. now the main question is how, just by a naming scheme?

Fix patch:
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();
   }


Test patch: