-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): handle known target specific plugins on permission add #10596
- Loading branch information
1 parent
712f104
commit f35bcda
Showing
5 changed files
with
170 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"tauri-cli": patch:enhance | ||
"@tauri-apps/cli": patch:enhance | ||
--- | ||
|
||
`permission add` and `add` commands now check if the plugin is known and if it is either desktop or mobile only | ||
we add the permission to a target-specific capability. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::collections::HashMap; | ||
|
||
#[derive(Default)] | ||
pub struct PluginMetadata { | ||
pub desktop_only: bool, | ||
pub mobile_only: bool, | ||
pub rust_only: bool, | ||
pub builder: bool, | ||
} | ||
|
||
// known plugins with particular cases | ||
pub fn known_plugins() -> HashMap<&'static str, PluginMetadata> { | ||
let mut plugins: HashMap<&'static str, PluginMetadata> = HashMap::new(); | ||
|
||
// desktop-only | ||
for p in [ | ||
"authenticator", | ||
"autostart", | ||
"cli", | ||
"global-shortcut", | ||
"positioner", | ||
"single-instance", | ||
"updater", | ||
"window-state", | ||
] { | ||
plugins.entry(p).or_default().desktop_only = true; | ||
} | ||
|
||
// mobile-only | ||
for p in ["barcode-scanner", "biometric", "nfc", "haptics"] { | ||
plugins.entry(p).or_default().mobile_only = true; | ||
} | ||
|
||
// uses builder pattern | ||
for p in [ | ||
"global-shortcut", | ||
"localhost", | ||
"log", | ||
"sql", | ||
"store", | ||
"stronghold", | ||
"updater", | ||
"window-state", | ||
] { | ||
plugins.entry(p).or_default().builder = true; | ||
} | ||
|
||
// rust-only | ||
#[allow(clippy::single_element_loop)] | ||
for p in ["localhost", "persisted-scope", "single-instance"] { | ||
plugins.entry(p).or_default().rust_only = true; | ||
} | ||
|
||
plugins | ||
} |