Skip to content

Commit

Permalink
wails implementation in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
KnockOutEZ committed Apr 6, 2024
1 parent 95800d0 commit a74d429
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 65 deletions.
62 changes: 62 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package cmd

import (
"github.com/nexentra/midgard/cmd/app"
"github.com/nexentra/midgard/pkg/clients/logger"
"github.com/nexentra/midgard/pkg/config"

"github.com/spf13/cobra"
)

// appCmd represents the start command
var appCmd = &cobra.Command{
Use: "app <option>",
Short: "App service",
Long: `Start app service.
When running this command without options, it will start open desktop app.
If you wish to add any options instead, you can choose from the
available options.`,

Run: execAppCmd,
}

func init() {
// This is auto executed upon start
// Initialization processes can go here ...

// Register sub commands
// appCmd.AddCommand(start.PublicApiCmd)
// appCmd.AddCommand(start.ProtectedApiCmd)
// appCmd.AddCommand(start.HiddenApiCmd)
// appCmd.AddCommand(start.WatcherCmd)

// Set global flags
appCmd.PersistentFlags().BoolVar(&config.StartWatcherFlag, "watcher", false, "Start watcher daemon in background")
appCmd.PersistentFlags().StringVarP(&config.HostFlag, "host", "H", "", "Service host")
appCmd.PersistentFlags().StringVar(&config.ProtectedPortFlag, "protected-api-port", "", "Protected API Service port")
appCmd.PersistentFlags().StringVar(&config.PublicPortFlag, "public-api-port", "", "Public API Service port")
appCmd.PersistentFlags().StringVar(&config.HiddenPortFlag, "hidden-api-port", "", "Hidden API Service port")

// Register persistent function for all sub commands
appCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
rootCmd.PersistentPreRun(cmd, args)
execAppPersistentPreRun()
}

// Register start command
rootCmd.AddCommand(appCmd)
}

func execAppPersistentPreRun() {
logger.Debug("Executing start persistent pre run ...")

// You can initialize other features here ...
// this will run before any command, make sure to put only global initializations here
// to avoid running into nil pointers or undefined variables
// ...
}

func execAppCmd(cmd *cobra.Command, args []string) {
app.WailsStart.Run(cmd, args)
}
46 changes: 46 additions & 0 deletions cmd/app/wails.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package app

import (
client "github.com/nexentra/midgard/client"
wailsapp "github.com/nexentra/midgard/pkg/app/init"
"github.com/spf13/cobra"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)

// WailsStart represents the protectedApi command
var WailsStart = &cobra.Command{
Use: "wails",
Short: "Start wails service",
Long: `Start wails app servive.`,
Run: execWailsStart,
}

func init() {
// This is auto executed upon start
// Initialization processes can go here ...
}

func execWailsStart(cmd *cobra.Command, args []string) {
app := wailsapp.NewApp()

// Create application with options
err := wails.Run(&options.App{
Title: "midgard",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: client.BuildFs,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.Startup,
Bind: []interface{}{
app,
},
})

if err != nil {
println("Error:", err.Error())
}
}
13 changes: 13 additions & 0 deletions cmd/app/wails.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://wails.io/schemas/config.v2.json",
"name": "midgard",
"outputfilename": "midgard",
"frontend:install": "npm install",
"frontend:build": "npm run build",
"frontend:dev:watcher": "npm run dev",
"frontend:dev:serverUrl": "auto",
"author": {
"name": "KnockOutEZ",
"email": "ktowhid20@gmail.com"
}
}
42 changes: 22 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,40 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/wailsapp/wails/v2 v2.8.0
golang.org/x/crypto v0.21.0
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.4
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.5
)

require github.com/go-jose/go-jose/v3 v3.0.1 // indirect
require (
github.com/bep/debounce v1.2.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/leaanthony/go-ansi-parser v1.6.0 // indirect
github.com/leaanthony/gosod v1.0.3 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/leaanthony/u v1.1.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/tkrajina/go-reflector v0.5.6 // indirect
github.com/wailsapp/go-webview2 v1.0.10 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.2.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/clerk/clerk-sdk-go/v2 v2.0.0
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/getkin/kin-openapi v0.123.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-fuego/fuego v0.13.4 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
Expand All @@ -53,15 +66,11 @@ require (
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/gorilla/schema v1.2.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
Expand All @@ -78,28 +87,22 @@ require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/robfig/cron/v3 v3.0.0 // indirect
github.com/rosedblabs/wal v1.3.6-0.20230924022528-3202245af020 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/echo-swagger v1.4.1 // indirect
github.com/swaggo/files v1.0.1
github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/swaggo/swag v1.16.3 // indirect
github.com/urfave/cli/v2 v2.27.1 // indirect
github.com/swaggo/swag v1.16.3
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.22.0 // indirect
Expand All @@ -114,5 +117,4 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

0 comments on commit a74d429

Please sign in to comment.