Skip to content

Commit f492efd

Browse files
authored
feat(cli): update template with permissions and capabilities (#8666)
* feat(cli): update template with permissions and capabilities * update gitignore [skip ci]
1 parent 6639a57 commit f492efd

10 files changed

Lines changed: 45 additions & 3 deletions

File tree

.changes/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@
218218
"manager": "rust",
219219
"dependencies": [
220220
"tauri"
221-
]
221+
],
222+
"postversion": "node ../../.scripts/covector/sync-cli-metadata.js ${ pkg.pkg } ${ release.type }"
222223
},
223224
"tauri-build": {
224225
"path": "./core/tauri-build",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:enhance
3+
"@tauri-apps/cli": patch:enhance
4+
---
5+
6+
Update app and plugin template following the new access control permission model.

tooling/cli/metadata-v2.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"node": ">= 10.0.0"
55
},
66
"tauri": "2.0.0-alpha.21",
7-
"tauri-build": "2.0.0-alpha.14"
7+
"tauri-build": "2.0.0-alpha.14",
8+
"tauri-plugin": "2.0.0-alpha.-1"
89
}

tooling/cli/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub struct VersionMetadata {
6969
tauri: String,
7070
#[serde(rename = "tauri-build")]
7171
tauri_build: String,
72+
#[serde(rename = "tauri-plugin")]
73+
tauri_plugin: String,
7274
}
7375

7476
#[derive(Deserialize)]

tooling/cli/src/plugin/init.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn command(mut options: Options) -> Result<()> {
8484
if std::fs::read_dir(&template_target_path)?.count() > 0 {
8585
warn!("Plugin dir ({:?}) not empty.", template_target_path);
8686
} else {
87-
let (tauri_dep, tauri_example_dep, tauri_build_dep) =
87+
let (tauri_dep, tauri_example_dep, tauri_build_dep, tauri_plugin_dep) =
8888
if let Some(tauri_path) = options.tauri_path {
8989
(
9090
format!(
@@ -99,12 +99,20 @@ pub fn command(mut options: Options) -> Result<()> {
9999
"{{ path = {:?} }}",
100100
resolve_tauri_path(&tauri_path, "core/tauri-build")
101101
),
102+
format!(
103+
r#"{{ path = {:?}, features = ["build"] }}"#,
104+
resolve_tauri_path(&tauri_path, "core/tauri-plugin")
105+
),
102106
)
103107
} else {
104108
(
105109
format!(r#"{{ version = "{}" }}"#, metadata.tauri),
106110
format!(r#"{{ version = "{}" }}"#, metadata.tauri),
107111
format!(r#"{{ version = "{}" }}"#, metadata.tauri_build),
112+
format!(
113+
r#"{{ version = "{}", features = ["build"] }}"#,
114+
metadata.tauri_plugin
115+
),
108116
)
109117
};
110118

@@ -117,6 +125,7 @@ pub fn command(mut options: Options) -> Result<()> {
117125
data.insert("tauri_dep", to_json(tauri_dep));
118126
data.insert("tauri_example_dep", to_json(tauri_example_dep));
119127
data.insert("tauri_build_dep", to_json(tauri_build_dep));
128+
data.insert("tauri_plugin_dep", to_json(tauri_plugin_dep));
120129
data.insert("author", to_json(options.author));
121130

122131
if options.tauri {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
schemas/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "./schemas/desktop-schema.json",
3+
"identifier": "default-plugins",
4+
"description": "enables the default permissions",
5+
"windows": ["main"],
6+
"permissions": [
7+
"path:default",
8+
"event:default",
9+
"window:default",
10+
"webview:default",
11+
"app:default",
12+
"resources:default",
13+
"menu:default",
14+
"tray:default",
15+
]
16+
}

tooling/cli/templates/plugin/Cargo.crate-manifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ thiserror = "1.0"
1515

1616
[build-dependencies]
1717
tauri-build = {{{ tauri_build_dep }}}
18+
tauri-plugin = {{{ tauri_plugin_dep }}}

tooling/cli/templates/plugin/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::process::exit;
22

3+
const COMMANDS: &[&str] = &["ping", "execute"];
4+
35
fn main() {
46
if let Err(error) = tauri_build::mobile::PluginBuilder::new()
57
.android_path("android")
@@ -9,4 +11,6 @@ fn main() {
911
println!("{error:#}");
1012
exit(1);
1113
}
14+
15+
tauri_plugin::Builder::new(COMMANDS).build();
1216
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
schemas/

0 commit comments

Comments
 (0)