diff --git a/package.json b/package.json index 35230cb..01a1964 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "devtools-x", - "version": "3.3.2", + "version": "3.3.3", "license": "MIT", "type": "module", "scripts": { @@ -37,8 +37,10 @@ "@tauri-apps/plugin-clipboard-manager": "^2.0.0", "@tauri-apps/plugin-dialog": "~2", "@tauri-apps/plugin-fs": "^2.0.1", + "@tauri-apps/plugin-process": "~2", "@tauri-apps/plugin-sql": "^2.0.0", "@tauri-apps/plugin-store": "^2.1.0", + "@tauri-apps/plugin-updater": "^2.0.0", "@uiw/react-markdown-preview": "^5.1.1", "angular-html-parser": "^5.2.0", "chroma-js": "^2.4.2", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 6dc0a8e..4da1dbe 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1151,7 +1151,7 @@ dependencies = [ [[package]] name = "devtools-x" -version = "3.3.2" +version = "3.3.3" dependencies = [ "anyhow", "bardecoder", @@ -1174,6 +1174,7 @@ dependencies = [ "tauri-plugin-clipboard-manager", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-process", "tauri-plugin-sql", "tauri-plugin-store", "tauri-plugin-updater", @@ -5529,6 +5530,16 @@ dependencies = [ "uuid", ] +[[package]] +name = "tauri-plugin-process" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae06a00087c148962a52814a2d7265b1a0505bced5ffb74f8c284a5f96a4d03d" +dependencies = [ + "tauri", + "tauri-plugin", +] + [[package]] name = "tauri-plugin-sql" version = "2.0.1" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index f8d6beb..5bedfaf 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "devtools-x" -version = "3.3.2" +version = "3.3.3" description = "Developer tools desktop application" authors = ["Sparkenstein"] license = "MIT" @@ -42,6 +42,7 @@ base64 = "0.21.7" flate2 = "1.0" bardecoder = "0.5.0" imageinfo = "0.7.17" +tauri-plugin-process = "2" [dependencies.tauri-plugin-sql] features = ["sqlite"] # or "postgres", or "mysql" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 52d9216..82d8392 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -8,6 +8,9 @@ "sql:allow-execute", "dialog:default", "fs:write-all", - "clipboard-manager:allow-write-text" + "clipboard-manager:allow-write-text", + "updater:default", + "updater:allow-check", + "process:allow-restart" ] } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b587587..f2e5dc6 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,7 +3,6 @@ windows_subsystem = "windows" )] -use std::convert::TryInto; use std::env; use tauri::{Manager, WebviewUrl, WebviewWindowBuilder}; @@ -148,6 +147,7 @@ fn main() { ]; tauri::Builder::default() + .plugin(tauri_plugin_process::init()) .plugin( tauri_plugin_sql::Builder::default() .add_migrations("sqlite:devtools.db", migrations) @@ -172,7 +172,7 @@ fn main() { #[cfg(desktop)] let res = app .handle() - .plugin(tauri_plugin_updater::Builder::new().build()); + .plugin(tauri_plugin_updater::Builder::new().pubkey("dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IERCN0M1MDY1Q0QwRkM1OEUKUldTT3hRL05aVkI4MjhGUW9LSjhZMldoUmNSYmRNYnl0RGNrUW5NTk1lSmNtc2FJTE5NMUhRTzgK").build()); if res.is_err() { println!("Error: {:?}", res.err()); } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 7e2bb59..01abfe1 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -44,7 +44,7 @@ }, "productName": "devtools-x", "mainBinaryName": "devtools-x", - "version": "3.3.2", + "version": "3.3.3", "identifier": "com.fosslife.devtoolsx", "plugins": { "sql": { diff --git a/src/App.tsx b/src/App.tsx index 825a40a..5615566 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -28,6 +28,7 @@ import { PanelGroup, PanelResizeHandle, } from "react-resizable-panels"; +import { check } from "@tauri-apps/plugin-updater"; // NOTE: keep Num converter here, do not lazy load. there's a rare crashing bug. import Nums from "./Features/number-tools/Nums"; @@ -36,6 +37,8 @@ import { Settings } from "./Layout/Settings"; import { useDisclosure, useWindowEvent } from "@mantine/hooks"; import { trackOtherEvent, trackPageView } from "./utils/analytics"; import { db } from "./utils"; +import { ask, message } from "@tauri-apps/plugin-dialog"; +import { relaunch } from "@tauri-apps/plugin-process"; // Lazy load components const Welcome = loadable(() => import("./Components/Welcome")); @@ -154,6 +157,30 @@ function App() { useEffect(() => { async function init() { + const update = await check(); + if (update === null) { + await message("Failed to check for updates.\nPlease try again later.", { + title: "Error", + kind: "error", + okLabel: "OK", + }); + return; + } else if (update?.available) { + const yes = await ask( + `Update to ${update.version} is available!\n\nRelease notes: ${update.body}`, + { + title: "Update Available", + kind: "info", + okLabel: "Update", + cancelLabel: "Cancel", + } + ); + if (yes) { + await update.downloadAndInstall(); + await relaunch(); + } + } + const isFirstTime = await db.get("firstTime"); if (isFirstTime === true) { tour.start(); diff --git a/yarn.lock b/yarn.lock index 9125a4d..c830815 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1912,6 +1912,13 @@ dependencies: "@tauri-apps/api" "^2.0.0" +"@tauri-apps/plugin-process@~2": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-process/-/plugin-process-2.0.0.tgz#002fd73f0d7b1ae2a5aacf442aa657e83dc2960b" + integrity sha512-OYzi0GnkrF4NAnsHZU7U3tjSoP0PbeAlO7T1Z+vJoBUH9sFQ1NSLqWYWQyf8hcb3gVWe7P1JggjiskO+LST1ug== + dependencies: + "@tauri-apps/api" "^2.0.0" + "@tauri-apps/plugin-sql@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-sql/-/plugin-sql-2.0.0.tgz#ff8a2edea726ced140782d11f3fcfe9be2bde75f" @@ -1926,6 +1933,13 @@ dependencies: "@tauri-apps/api" "^2.0.0" +"@tauri-apps/plugin-updater@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-updater/-/plugin-updater-2.0.0.tgz#38cb3e735da28cd1726a3c0e13f032117e4db111" + integrity sha512-N0cl71g7RPr7zK2Fe5aoIwzw14NcdLcz7XMGFWZVjprsqgDRWoxbnUkknyCQMZthjhGkppCd/wN2MIsUz+eAhQ== + dependencies: + "@tauri-apps/api" "^2.0.0" + "@tsconfig/node10@^1.0.7": version "1.0.11" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2"