From 3f1ff779891ff546bb4ee11c023488496d64a29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20=C3=98strem?= Date: Tue, 17 Dec 2024 17:07:47 +0100 Subject: [PATCH] debug: Add versions to top level, install edge webview2 explicitly for windows --- .github/workflows/build.yml | 62 +++++++++++++++++++++---------------- src-tauri/Cargo.toml | 2 +- src-tauri/src/lib.rs | 9 ++++-- src-tauri/tauri.conf.json | 3 +- src/App.tsx | 57 ++++++++++++++++++++++++---------- 5 files changed, 86 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0132dc..f72673f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,31 +116,39 @@ jobs: echo "'${{ github.ref_name }}' is not a valid version - using default. Must be a numerical only semver version." fi - - name: Tauri build - uses: tauri-apps/tauri-action@v0 - env: - VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }} - VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }} - SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }} - SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }} - id: tauri_build - - - name: Setup JFrog CLI - uses: jfrog/setup-jfrog-cli@v3 - - # Upload to Artifactory - # Echo array of absolute paths to created artifacts. - # e.g. '["/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/deb/app.deb", "/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/appimage/app.appimage"]' - # sed directly after echo is to handle windows paths with backwards slashes - # e.g. C:\Users\user\actions-runner\_work\trokk\trokk\src-tauri\target\release\bundle\nsis\app.nsis - # jq is used to parse the array - # sed is used to remove the absolute path and only keep the relative path to the artifact - - name: Upload to Artifactory - shell: bash - working-directory: ./src-tauri/target/release/bundle + - name: Supply webview2 + if: ${{ matrix.windows }} + shell: cmd run: | - echo '${{ steps.tauri_build.outputs.artifactPaths }}' | - sed -e 's#\\#/#g' -e 's#//#/#g' | - jq -r .[] | - sed -n -e 's/^.*bundle\///p' | - xargs -I % jf rt u --url ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_URL }} --user ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_USER }} --password ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_PASSWORD }} % "generic/trokk/${{ github.ref_name }}/" + qgi curl -L -o Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/023aa9c1-c16d-4b52-a1dd-55f125aa3061/Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab" + C:\Windows\System32\expand.exe Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab -f:* ./src-tauri + del Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab + +- name: Tauri build + uses: tauri-apps/tauri-action@v0 + env: + VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }} + VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }} + SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }} + SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }} + id: tauri_build + +- name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v3 + +# Upload to Artifactory +# Echo array of absolute paths to created artifacts. +# e.g. '["/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/deb/app.deb", "/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/appimage/app.appimage"]' +# sed directly after echo is to handle windows paths with backwards slashes +# e.g. C:\Users\user\actions-runner\_work\trokk\trokk\src-tauri\target\release\bundle\nsis\app.nsis +# jq is used to parse the array +# sed is used to remove the absolute path and only keep the relative path to the artifact +- name: Upload to Artifactory + shell: bash + working-directory: ./src-tauri/target/release/bundle + run: | + echo '${{ steps.tauri_build.outputs.artifactPaths }}' | + sed -e 's#\\#/#g' -e 's#//#/#g' | + jq -r .[] | + sed -n -e 's/^.*bundle\///p' | + xargs -I % jf rt u --url ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_URL }} --user ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_USER }} --password ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_PASSWORD }} % "generic/trokk/${{ github.ref_name }}/" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d80f57e..f408e11 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" tauri-build = { version = "2.0.1", features = [] } [dependencies] -tauri = { version = "2.0.2", features = ["protocol-asset", "test", "tray-icon"] } +tauri = { version = "2.0.2", features = ["protocol-asset", "test", "tray-icon", "devtools"] } tauri-plugin-store = "2.1.0" tauri-plugin-fs = { version = "2", features = ["watch"] } tauri-plugin-oauth = "2" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2d73ce7..5926cec 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -161,6 +161,11 @@ async fn upload_directory_to_s3( s3::upload_directory(directory_path, object_id, material_type, app_window).await } +#[tauri::command] +fn get_webview_version() -> String { + tauri::webview_version().unwrap() +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::async_runtime::set(tokio::runtime::Handle::current()); @@ -179,7 +184,6 @@ pub fn run() { .plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_oauth::init()) .setup(|app| { - #[cfg(debug_assertions)] app.get_webview_window("main").unwrap().open_devtools(); { let handle = app.handle(); @@ -197,7 +201,8 @@ pub fn run() { delete_dir, pick_directory, get_papi_access_token, - upload_directory_to_s3 + upload_directory_to_s3, + get_webview_version ]) .on_window_event(|window, event| { if let tauri::WindowEvent::CloseRequested { api, .. } = event { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a5a54ae..eedbc65 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -10,7 +10,8 @@ "targets": "all", "windows": { "webviewInstallMode": { - "type": "offlineInstaller" + "type": "fixedRuntime", + "path": "./Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86/" } }, "shortDescription": "Filflytting og registrering fra skannermaskiner", diff --git a/src/App.tsx b/src/App.tsx index d211b49..e31549e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { FolderOpen, User } from 'lucide-react'; import './App.css'; import { AuthContextType, AuthProvider, useAuth } from './context/auth-context.tsx'; @@ -10,6 +10,8 @@ import { UploadProgressProvider } from './context/upload-progress-context.tsx'; import Button from './components/ui/button.tsx'; import { SecretProvider } from './context/secret-context.tsx'; import { SettingProvider, useSettings } from './context/setting-context.tsx'; +import { invoke } from '@tauri-apps/api/core'; +import { getTauriVersion, getVersion } from '@tauri-apps/api/app'; function App() { // TODO figure out what is making that "Unhandled Promise Rejection: window not found" error @@ -20,23 +22,46 @@ function App() { }); const [openSettings, setOpenSettings] = useState(false); + const [webviewVersion, setWebviewVersion] = useState(null); + const [trokkVersion, setTrokkVersion] = useState(null); + const [tauriVersion, setTauriVersion] = useState(null); + + useEffect(() => { + const fetchWebviewVersion = async () => { + const webviewVersionFetched = await invoke('get_webview_version'); + const trokkVersionFetched = await getVersion(); + const tauriVersion = await getTauriVersion(); + setWebviewVersion(webviewVersionFetched); + setTrokkVersion(trokkVersionFetched); + setTauriVersion(tauriVersion); + }; + void fetchWebviewVersion(); + }, []); + return ( - - - -
- -
- setOpenSettings(false)}> - - -
-
-
+ <> +
+

WebviewVersion: {webviewVersion}

+

Trøkk version: {trokkVersion}

+

Tauri version: {tauriVersion}

+
+ + + +
+ +
+ setOpenSettings(false)}> + + +
+
+
+ ); }