82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"verstak/internal/core/actions"
|
|
"verstak/internal/core/files"
|
|
"verstak/internal/core/notes"
|
|
"verstak/internal/core/nodes"
|
|
"verstak/internal/core/plugins"
|
|
"verstak/internal/core/search"
|
|
"verstak/internal/core/storage"
|
|
"verstak/internal/core/worklog"
|
|
|
|
"github.com/wailsapp/wails/v2"
|
|
"github.com/wailsapp/wails/v2/pkg/options"
|
|
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
|
)
|
|
|
|
//go:embed all:frontend-dist
|
|
var assets embed.FS
|
|
|
|
func main() {
|
|
vaultPath := "."
|
|
if len(os.Args) > 1 {
|
|
vaultPath = os.Args[1]
|
|
}
|
|
|
|
abs, err := filepath.Abs(vaultPath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
dbPath := filepath.Join(abs, ".verstak", "index.db")
|
|
db, err := storage.Open(dbPath)
|
|
if err != nil {
|
|
log.Fatalf("Open vault: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
// Init core services
|
|
nodeRepo := nodes.NewRepository(db)
|
|
fileSvc := files.NewService(db, abs)
|
|
noteSvc := notes.NewService(db, abs, nodeRepo, fileSvc)
|
|
actionSvc := actions.NewService(db)
|
|
worklogSvc := worklog.NewService(db)
|
|
searchSvc := search.NewService(db)
|
|
plugins.NewManager(abs).Discover()
|
|
_ = searchSvc
|
|
|
|
app := &App{
|
|
db: db,
|
|
nodes: nodeRepo,
|
|
files: fileSvc,
|
|
notes: noteSvc,
|
|
actions: actionSvc,
|
|
worklog: worklogSvc,
|
|
vault: abs,
|
|
}
|
|
|
|
err = wails.Run(&options.App{
|
|
Title: "Верстак",
|
|
Width: 1280,
|
|
Height: 800,
|
|
MinWidth: 800,
|
|
MinHeight: 600,
|
|
BackgroundColour: &options.RGBA{R: 19, G: 19, B: 31, A: 1},
|
|
AssetServer: &assetserver.Options{
|
|
Assets: assets,
|
|
},
|
|
OnStartup: app.startup,
|
|
Bind: []interface{}{app},
|
|
})
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|