-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
96 lines (85 loc) · 2.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"embed"
"fmt"
"runtime"
"time"
"kalisto/src/assembly"
"kalisto/src/config"
"kalisto/src/models"
"kalisto/src/pkg/log"
"kalisto/src/pkg/update"
stdlog "log"
"github.com/adrg/xdg"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/getsentry/sentry-go"
)
var version string
var platform string
//go:embed all:frontend/dist
var assets embed.FS
func main() {
l := log.New()
sentryDsn := config.C.SentryDsn
if err := sentry.Init(sentry.ClientOptions{
Dsn: sentryDsn,
Release: version,
}); err != nil {
stdlog.Fatalln("failed to initialize sentry client:", err)
}
defer sentry.Flush(time.Second * 3)
defer sentry.Recover()
l.Debug("sentry initialized")
AppMenu := menu.NewMenu()
if runtime.GOOS == "darwin" {
AppMenu.Append(menu.EditMenu())
}
HelpMenu := AppMenu.AddSubmenu("Help")
HelpMenu.AddText(fmt.Sprintf("Version %s", version), nil, func(_ *menu.CallbackData) {})
l.Debug("menu built")
updater := update.NewUpdater(version, platform)
updated, err := updater.Run()
if err != nil {
l.Error(err.Error())
sentry.CaptureException(err)
}
if updated {
l.Info("app restart after update")
if err := updater.Restart(); err != nil {
l.Error(err.Error())
sentry.CaptureException(err)
}
}
l.Debug("updater ran")
// Create an instance of the app structure
app, err := assembly.NewApp(xdg.DataHome)
if err != nil {
sentry.CaptureException(err)
return
}
// Create application with options
if err := wails.Run(&options.App{
OnShutdown: app.OnShutdown,
Title: "kalisto",
Width: 1440,
Height: 925,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.Start,
Bind: []interface{}{
app.Api,
},
ErrorFormatter: models.NewErrorFormatter(app.Api.Context, func(err error) {
sentry.CaptureException(err)
}, app.Api.Runtime()),
Menu: AppMenu,
Logger: l,
}); err != nil {
sentry.CaptureException(err)
}
}