From 32b647a6c85b8a13a8c1f4fc30f769dc5be58d94 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Tue, 5 Mar 2024 11:22:05 +0800 Subject: [PATCH 1/6] Fix missing word --- src/content/docs/features/window-state.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/features/window-state.mdx b/src/content/docs/features/window-state.mdx index f580f6e1a9..1b2494251c 100644 --- a/src/content/docs/features/window-state.mdx +++ b/src/content/docs/features/window-state.mdx @@ -72,7 +72,7 @@ fn main() { ## Usage -After adding the all windows will remember their state when the app is being closed and will restore to their previous state on the next launch. +After adding the plugin all windows will remember their state when the app is being closed and will restore to their previous state on the next launch. You can also access the window-state plugin in both JavaScript and Rust. From 4025115ed0a22a9c23cc93567da660706dd81cd3 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Tue, 5 Mar 2024 11:24:45 +0800 Subject: [PATCH 2/6] Update shell.mdx --- src/content/docs/features/shell.mdx | 76 +++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/src/content/docs/features/shell.mdx b/src/content/docs/features/shell.mdx index a5e1debae2..2c728fd104 100644 --- a/src/content/docs/features/shell.mdx +++ b/src/content/docs/features/shell.mdx @@ -3,11 +3,79 @@ title: Shell description: Access the system shell to manage files and URLs using their default application and to spawn child processes. --- -import Stub from '@components/Stub.astro'; import PluginLinks from '@components/PluginLinks.astro'; +import { Tabs, TabItem } from '@astrojs/starlight/components'; +import CommandTabs from '@components/CommandTabs.astro'; - - Based on https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/shell - +Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. + +## Supported Platforms + +- Windows +- Linux +- macOS + +## Setup + +_This plugin requires a Rust version of at least **1.75**_ + +Install the shell plugin to get started. + + + + +Use your project's package manager to add the dependency: + +{' '} + + + + + + +1. Install the Core plugin by adding the following to your `Cargo.toml` file: + +```toml title="src-tauri/Cargo.toml" +[dependencies] +tauri-plugin-shell = "2.0.0-beta" +# alternatively with Git: +tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } +``` + +2. Modify `lib.rs` to initialize the plugin: + +```rust title="src-tauri/src/main.rs" {3} +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_shell::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +3. Install the JavaScript Guest bindings using your preferred JavaScript package manager: + + + + + +## Usage + +The plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { Command } from "@tauri-apps/plugin-shell"; + +Command.create("git", ["commit", "-m", "the commit message"]); +``` \ No newline at end of file From 6140e4f927a452965aa45bc918deda10a00ae41b Mon Sep 17 00:00:00 2001 From: DK Liao Date: Tue, 5 Mar 2024 11:38:31 +0800 Subject: [PATCH 3/6] Added in Permissions --- src/content/docs/features/shell.mdx | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/content/docs/features/shell.mdx b/src/content/docs/features/shell.mdx index 2c728fd104..9f3039d0c8 100644 --- a/src/content/docs/features/shell.mdx +++ b/src/content/docs/features/shell.mdx @@ -78,4 +78,34 @@ The plugin's APIs are available through the JavaScript guest bindings: import { Command } from "@tauri-apps/plugin-shell"; Command.create("git", ["commit", "-m", "the commit message"]); -``` \ No newline at end of file +``` + +## Permissions + +By default all plugin commands are blocked and cannot be accessed. +You must define a list of permissions in your `capabilities` configuration. + +See [Access Control List](/references/v2/acl) for more information. + +```json title="src-tauri/capabilities/main.json" ins={4-7} +{ + "permissions": [ + ..., + "shell:allow-execute", + "shell:allow-kill", + "shell:allow-open", + "shell:allow-stdin-write", + ] +} +``` + +| Permission | Description | +|------|-----| +|`shell:allow-execute`|Enables the execute command without any pre-configured scope.| +|`shell:deny-execute`|Denies the execute command without any pre-configured scope.| +|`shell:allow-kill`|Enables the kill command without any pre-configured scope.| +|`shell:deny-kill`|Denies the kill command without any pre-configured scope.| +|`shell:allow-open`|Enables the open command without any pre-configured scope.| +|`shell:deny-open`|Denies the open command without any pre-configured scope.| +|`shell:allow-stdin-write`|Enables the stdin_write command without any pre-configured scope.| +|`shell:deny-stdin-write`|Denies the stdin_write command without any pre-configured scope.| \ No newline at end of file From e77ded9fd6cc186150a673069bd8879dbcedaad6 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Tue, 5 Mar 2024 11:45:13 +0800 Subject: [PATCH 4/6] fix formatting (I hope it works) --- src/content/docs/features/shell.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content/docs/features/shell.mdx b/src/content/docs/features/shell.mdx index 9f3039d0c8..e433ee4805 100644 --- a/src/content/docs/features/shell.mdx +++ b/src/content/docs/features/shell.mdx @@ -90,11 +90,11 @@ See [Access Control List](/references/v2/acl) for more information. ```json title="src-tauri/capabilities/main.json" ins={4-7} { "permissions": [ - ..., - "shell:allow-execute", - "shell:allow-kill", - "shell:allow-open", - "shell:allow-stdin-write", + ..., + "shell:allow-execute", + "shell:allow-kill", + "shell:allow-open", + "shell:allow-stdin-write", ] } ``` From 67db30286bd8e6d2d2ecdfeb35d1615c931de799 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Tue, 5 Mar 2024 11:50:45 +0800 Subject: [PATCH 5/6] Lemme try again --- src/content/docs/features/shell.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/features/shell.mdx b/src/content/docs/features/shell.mdx index e433ee4805..72b5130a1c 100644 --- a/src/content/docs/features/shell.mdx +++ b/src/content/docs/features/shell.mdx @@ -91,7 +91,7 @@ See [Access Control List](/references/v2/acl) for more information. { "permissions": [ ..., - "shell:allow-execute", + "shell:allow-execute", "shell:allow-kill", "shell:allow-open", "shell:allow-stdin-write", From f551a948d6f11f2a614b0e84d49760f0bc00f662 Mon Sep 17 00:00:00 2001 From: DK Liao Date: Wed, 6 Mar 2024 17:28:05 +0800 Subject: [PATCH 6/6] Update shell.mdx --- src/content/docs/features/shell.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/features/shell.mdx b/src/content/docs/features/shell.mdx index 72b5130a1c..f7b55cbec4 100644 --- a/src/content/docs/features/shell.mdx +++ b/src/content/docs/features/shell.mdx @@ -51,8 +51,8 @@ tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", 2. Modify `lib.rs` to initialize the plugin: -```rust title="src-tauri/src/main.rs" {3} -fn main() { +```rust title="src-tauri/src/lib.rs" {3} +fn run() { tauri::Builder::default() .plugin(tauri_plugin_shell::init()) .run(tauri::generate_context!())