5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 02:02:55 +08:00
wails/v2/internal/wv2installer/wv2installer.go
Lea Anthony ea6aee91f1
Refactored build command (#2123)
* Refactored build command

* Update v2/cmd/wails/build.go

Co-authored-by: stffabi <stffabi@users.noreply.github.com>

* WIP

* Refactor `wails doctor`

* Refactor `wails dev`

* Refactor `wails dev`

* Fix merge conflict

* Fix test

* Update build_and_test.yml

Co-authored-by: stffabi <stffabi@users.noreply.github.com>
2022-12-01 18:18:02 +11:00

61 lines
1.6 KiB
Go

//go:build windows
package wv2installer
import (
"fmt"
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2/webviewloader"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/windows"
)
const MinimumRuntimeVersion string = "94.0.992.31" // WebView2 SDK 1.0.992.28
type installationStatus int
const (
needsInstalling installationStatus = iota
needsUpdating
)
func Process(appoptions *options.App) (string, error) {
messages := windows.DefaultMessages()
if appoptions.Windows != nil && appoptions.Windows.Messages != nil {
messages = appoptions.Windows.Messages
}
installStatus := needsInstalling
// Override version check for manually specified webview path if present
var webviewPath = ""
if opts := appoptions.Windows; opts != nil && opts.WebviewBrowserPath != "" {
webviewPath = opts.WebviewBrowserPath
}
installedVersion, err := webviewloader.GetAvailableCoreWebView2BrowserVersionString(webviewPath)
if err != nil {
return "", err
}
if installedVersion != "" {
installStatus = needsUpdating
compareResult, err := webviewloader.CompareBrowserVersions(installedVersion, MinimumRuntimeVersion)
if err != nil {
return "", err
}
updateRequired := compareResult < 0
// Installed and does not require updating
if !updateRequired {
return installedVersion, nil
}
}
// Force error strategy if webview is manually specified
if webviewPath != "" {
return installedVersion, fmt.Errorf(messages.InvalidFixedWebview2)
}
return installedVersion, doInstallationStrategy(installStatus, messages)
}