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

[docs/feat] npm run tauri add tauri-plugin-custom for community plugins #12217

Closed
marcomq opened this issue Jan 4, 2025 · 4 comments · Fixed by #12246
Closed

[docs/feat] npm run tauri add tauri-plugin-custom for community plugins #12217

marcomq opened this issue Jan 4, 2025 · 4 comments · Fixed by #12246

Comments

@marcomq
Copy link
Contributor

marcomq commented Jan 4, 2025

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 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.

@marcomq marcomq added the type: documentation Need to update the API documentation label Jan 4, 2025
@marcomq marcomq changed the title [docs] npm run tauri add tauri-plugin-custom for community plugins [docs] npm run tauri add tauri-plugin-custom for community plugins Jan 4, 2025
@FabianLars
Copy link
Member

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?

@marcomq
Copy link
Contributor Author

marcomq commented Jan 5, 2025

Thx for the feedback. This helps a lot :)
So - I would probably add additional documentation with steps that need to be performed to install the plugin. Usually, I prefer to write code instead of documentation.

Would it help to add some parameter --inofficial so you could run
tauri add my_plugin --inofficial?

I wasn't sure if it would be easy to read and modify the tauri code, so I tried and tested it locally first.
I created fork and added a change: marcomq@db2ab14
I could create a PR
dev...marcomq:tauri:dev

I guess I would still need to create a feature request first and sign my git commit properly. It would also be fine if I rename this parameter to something else.
Should I somehow change this issue or just create a new GH issue with a feature request?

@FabianLars FabianLars added type: feature request and removed type: documentation Need to update the API documentation labels Jan 5, 2025
@FabianLars FabianLars changed the title [docs] npm run tauri add tauri-plugin-custom for community plugins [docs/feat] npm run tauri add tauri-plugin-custom for community plugins Jan 5, 2025
@FabianLars
Copy link
Member

Would it help to add some parameter --inofficial so you could run
tauri add my_plugin --inofficial?

My first idea would be --community but i really hate naming things x)

I wasn't sure if it would be easy to read and modify the tauri code, so I tried and tested it locally first.
I created fork and added a change: marcomq@db2ab14
I could create a PR
dev...marcomq:tauri:dev

looks good on first glance

and sign my git commit properly

that would indeed be a requirement for the PR to be merged.

Should I somehow change this issue or just create a new GH issue with a feature request?

Changed it already :)

@marcomq
Copy link
Contributor Author

marcomq commented Jan 5, 2025

Thx.
I just created #12246

lucasfernog added a commit that referenced this issue Jan 7, 2025
It currently isn't possible to simply add a community plugin the same was as adding official plugins.
Trying to perform  `npm run tauri add tauri-plugin-python` is trying to install npm package `@tauri-apps/plugin-python`.
But the npm scope `@tauri-apps/` is reserved for official tauri plugins.

The official documentation recommends to name the npm package `tauri-plugin-{name}-api` and it should be possible to have a parameter that makes it possible to install that package.

- closes #12217

This changes the command to check if the plugin is an official tauri plugin or not, using the appropriate npm package name format

---------

Co-authored-by: Lucas Nogueira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants