From b4a61e11fa61afe8be7bee19f1fd6d8a95949f15 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 9 Nov 2024 09:18:33 +1100 Subject: [PATCH] Add devmode config to config.yml. Remove devmode.config.yaml. Update Watcher command. Update templates. --- v3/examples/file-association/Taskfile.yml | 2 +- v3/internal/commands/build_assets/config.yml | 30 +++++++++++++++++++ v3/internal/commands/dev.go | 2 +- .../devmode.config.tmpl.yaml | 28 ----------------- v3/internal/commands/watcher.go | 21 ++++++++++++- .../templates/_common/Taskfile.tmpl.yml | 2 +- 6 files changed, 53 insertions(+), 32 deletions(-) delete mode 100644 v3/internal/commands/updatable_build_assets/devmode.config.tmpl.yaml diff --git a/v3/examples/file-association/Taskfile.yml b/v3/examples/file-association/Taskfile.yml index f4a2fc817..f0dcbdbf0 100644 --- a/v3/examples/file-association/Taskfile.yml +++ b/v3/examples/file-association/Taskfile.yml @@ -30,4 +30,4 @@ tasks: dev: summary: Runs the application in development mode cmds: - - wails3 dev -config ./build/devmode.config.yaml -port {{.VITE_PORT}} + - wails3 dev -config ./build/config.yml -port {{.VITE_PORT}} diff --git a/v3/internal/commands/build_assets/config.yml b/v3/internal/commands/build_assets/config.yml index a9c1ab4ea..37da25119 100644 --- a/v3/internal/commands/build_assets/config.yml +++ b/v3/internal/commands/build_assets/config.yml @@ -13,6 +13,36 @@ info: comments: "Some Product Comments" # Comments version: "v0.0.1" # The application version +# Dev mode configuration +dev_mode: + root_path: . + log_level: warn + debounce: 1000 + ignore: + dir: + - .git + - node_modules + - frontend + - bin + file: + - .DS_Store + - .gitignore + - .gitkeep + watched_extension: + - "*.go" + git_ignore: true + executes: + - cmd: wails3 task common:install:frontend:deps + type: once + - cmd: wails3 task common:dev:frontend + type: background + - cmd: go mod tidy + type: blocking + - cmd: wails3 task build + type: blocking + - cmd: wails3 task run + type: primary + # File Associations # More information at: https://v3alpha.wails.io/noit/done/yet fileAssociations: diff --git a/v3/internal/commands/dev.go b/v3/internal/commands/dev.go index c76d483ad..f7053e377 100644 --- a/v3/internal/commands/dev.go +++ b/v3/internal/commands/dev.go @@ -15,7 +15,7 @@ const wailsVitePort = "WAILS_VITE_PORT" type DevOptions struct { flags.Common - Config string `description:"The config file including path" default:"./build/devmode.config.yaml"` + Config string `description:"The config file including path" default:"./build/config.yml"` VitePort int `name:"port" description:"Specify the vite dev server port"` Secure bool `name:"s" description:"Enable HTTPS"` } diff --git a/v3/internal/commands/updatable_build_assets/devmode.config.tmpl.yaml b/v3/internal/commands/updatable_build_assets/devmode.config.tmpl.yaml deleted file mode 100644 index 7d674a261..000000000 --- a/v3/internal/commands/updatable_build_assets/devmode.config.tmpl.yaml +++ /dev/null @@ -1,28 +0,0 @@ -config: - root_path: . - log_level: warn - debounce: 1000 - ignore: - dir: - - .git - - node_modules - - frontend - - bin - file: - - .DS_Store - - .gitignore - - .gitkeep - watched_extension: - - "*.go" - git_ignore: true - executes: - - cmd: wails3 task common:install:frontend:deps - type: once - - cmd: wails3 task common:dev:frontend - type: background - - cmd: go mod tidy - type: blocking - - cmd: wails3 task build - type: blocking - - cmd: wails3 task run - type: primary diff --git a/v3/internal/commands/watcher.go b/v3/internal/commands/watcher.go index 25a67a6e2..6cdd6dc3a 100644 --- a/v3/internal/commands/watcher.go +++ b/v3/internal/commands/watcher.go @@ -3,6 +3,7 @@ package commands import ( "github.com/atterpac/refresh/engine" "github.com/wailsapp/wails/v3/internal/signal" + "gopkg.in/yaml.v3" "os" ) @@ -12,7 +13,25 @@ type WatcherOptions struct { func Watcher(options *WatcherOptions) error { stopChan := make(chan struct{}) - watcherEngine, err := engine.NewEngineFromYAML(options.Config) + + // Parse the config file + type devConfig struct { + Config engine.Config `yaml:"dev_mode"` + } + + var devconfig devConfig + + // Parse the config file + c, err := os.ReadFile(options.Config) + if err != nil { + return err + } + err = yaml.Unmarshal(c, &devconfig) + if err != nil { + return err + } + + watcherEngine, err := engine.NewEngineFromConfig(devconfig.Config) if err != nil { return err } diff --git a/v3/internal/templates/_common/Taskfile.tmpl.yml b/v3/internal/templates/_common/Taskfile.tmpl.yml index 491d4553a..c5f99d931 100644 --- a/v3/internal/templates/_common/Taskfile.tmpl.yml +++ b/v3/internal/templates/_common/Taskfile.tmpl.yml @@ -30,4 +30,4 @@ tasks: dev: summary: Runs the application in development mode cmds: - - wails3 dev -config ./build/devmode.config.yaml -port {{ "{{.VITE_PORT}}" }} + - wails3 dev -config ./build/config.yml -port {{ "{{.VITE_PORT}}" }}