feat: add a new option to remove unused commands#12890
feat: add a new option to remove unused commands#12890lucasfernog merged 41 commits intotauri-apps:devfrom
Conversation
Package Changes Through b813b76There are 12 changes which include tauri with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-cli with minor, @tauri-apps/cli with minor, @tauri-apps/api with minor, tauri-bundler with patch, tauri-build with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
Hi @Legend-Master (I stumbled upon this PR 😇). Can we implement this feature in Sometimes I only use ref: #4670 (comment)
|
|
I have tried it first before this and unfortunately since we can't run the build script before all the macros in plugins, it's not really viable I could expose the command for generating the used commands though so that you can run it first and then exposing it to the environment manually |
In some cases, we don't even have
Can we set an environment variable pointing to the This way, we wouldn't need to rely on When I want to enable this feature, I will manually set this environment variable pointing to the (I'm not very familiar with this part of Tauri, so my idea might be wrong) |
I would also like to make those features not relying on the tauri cli if possible
Actually good idea, I'll give it a try when I got time, but instead of doing it in the macro, I think in plugins's build script should be better? (I'll see when I get there) My current approach is not that great as it relies on the build scripts to generate the acl manifest first, so definitely something I would like to improve as well
To be honest, I'm not very familiar with acl and macro related things either, so any suggestion would be much appreciated |
due to UNC paths...
I get it now, it's because of UNC paths...
I have gone ahead and did that
I have also moved this to inside of @lucasfernog This should be working now, tested locally with the api example with some configurations and all seems to work fine |
|
Actually, we should not skip this when |
Sorry, it was right, it's about the permissions, I thought it was capabilities somehow 😂 |
Co-authored-by: Fabian-Lars <github@fabianlars.de>
|
I feel like we shouldn't apply it for dev as that would likely cause rebuilds due to different environment variables from rust analyzer, and I don't think this is useful in dev anyways |
|
@Legend-Master Your work is great, thank you. ❤️ I have a question I hope you can answer: Is this determined by whether the user explicitly provides the required permissions for the command when using the plugin to determine whether it needs to be added to Thank you again for your contribution. |
❤️
Yes, but it should already be provided by your capability files that you don't need any additional configs
I'm not sure I get what |
| root_dir: PathBuf, | ||
| ) -> Result<(Value, Option<PathBuf>), ConfigError> { | ||
| let mut config: Value = parse_value(target, root_dir.join("tauri.conf.json"))?.0; | ||
| pub fn read_from(target: Target, root_dir: &Path) -> Result<(Value, Vec<PathBuf>), ConfigError> { |
There was a problem hiding this comment.
@Legend-Master Does this crate not follow semantic versioning? Changing root_dir: PathBuf to root_dir: &Path is a breaking change. My library depends on both tauri and tauri-utils, and this change caused a compilation failure when upgrading to tauri v2.4.
There was a problem hiding this comment.
Does this crate not follow semantic versioning?
No, But I think we should still note that in the release note (honestly we rarely did it for tauri-utils and tauri-runtime, but maybe we should as people started using them)
https://docs.rs/tauri-utils/latest/tauri_utils/config/index.html#stability
This is a core functionality that is not considered part of the stable API. If you use it, note that it may include breaking changes in the future.
There was a problem hiding this comment.
These items are intended to be non-breaking from a de/serialization standpoint only. Using and modifying existing config values will try to avoid breaking changes, but they are free to add fields in the future - causing breaking changes for creating and full destructuring.
This documentation misled me into thinking that only Config is unstable (I mistakenly thought other APIs were stable 😂)
I am currently using these APIs to dynamically load tauri.conf.json at runtime. I want to know if it is necessary to pin the version of tauri-utils?
There was a problem hiding this comment.
This documentation misled me into thinking that only
Configis unstable (I mistakenly thought other APIs were stable 😂)
I'm not familiar with this to be honest, not sure if other things are stable or we just didn't put the stability notice at the right place
I am currently using these APIs to dynamically load
tauri.conf.jsonat runtime. I want to know if it is necessary to pin the version oftauri-utils?
I would say yes
There was a problem hiding this comment.
if it is necessary to pin the version of tauri-utils
I would say yes
Thanks! It's okay to me.
* fix(pytauri-wheel/sdist): do not use `path` dependencies in `Cargo.toml` * fix: pin minor version for unstable `tauri-utils` ref: <tauri-apps/tauri#12890 (comment)>
Reference: #12820 (comment)
Introducing a new config option
build > removeUnusedCommandsto let the tauri-cli pass in an environment variable to let the build script oftauri-pluginandtaurito generate a list of allowed commands from the ACL, this will then be used by thegenerate_handlermacro to remove unused commandsNote: this won't be accounting for dynamically added ACLs so make sure to check it when using this
Some results:
helloworldexample in the repo gone from 3.92 MB to 1.91 MB on Windows (it doesn't use any plugin commands, so the improvement is quite big, also the basic executable contains theimagedependency, it's around 2.67 MB if that's removed, but still a great improvement!)