From 95ad9333ff7334e1e80d6a871c4c4cb8da7cc5e8 Mon Sep 17 00:00:00 2001 From: atterpac Date: Fri, 19 Jan 2024 16:57:26 -0700 Subject: [PATCH] dynamic refresh config --- v3/internal/commands/watcher.go | 13 ++++++++--- .../_base/default/build/devmode.config.yml | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 v3/internal/templates/_base/default/build/devmode.config.yml diff --git a/v3/internal/commands/watcher.go b/v3/internal/commands/watcher.go index 2bc0ce70f3e..e23ec0be20b 100644 --- a/v3/internal/commands/watcher.go +++ b/v3/internal/commands/watcher.go @@ -1,8 +1,8 @@ package commands import ( - "log/slog" "os" + "path/filepath" "runtime" "strings" @@ -19,10 +19,10 @@ const ( linuxExtension = "" darwinExtension = ".app" + appVar = "" extensionVar = "" ) - func Watcher(options *WatcherOptions) error { stopChan := make(chan struct{}) watcherEngine := engine.Engine{} @@ -68,7 +68,14 @@ func parseConfig(config string) (string, error) { case "darwin": ext = darwinExtension } + // Replace extension stringConfig := strings.ReplaceAll(string(byteConfig), extensionVar, ext) - slog.Warn(stringConfig) + projectName, err := os.Getwd() + if err != nil { + return "", err + } + // Replace app name with init project name + projectName = filepath.Base(projectName) + stringConfig = strings.ReplaceAll(stringConfig, appVar, projectName) return stringConfig, nil } diff --git a/v3/internal/templates/_base/default/build/devmode.config.yml b/v3/internal/templates/_base/default/build/devmode.config.yml new file mode 100644 index 00000000000..e860fa4e54e --- /dev/null +++ b/v3/internal/templates/_base/default/build/devmode.config.yml @@ -0,0 +1,23 @@ +config: + root_path: .. + log_level: info + debounce: 1000 + ignore: + dir: + - frontend + file: + - .gitignore + watched_extension: + - '*.go' + git_ignore: true + background: + cmd: 'wails3 task dev:frontend' + executes: + - cmd: go mod tidy + blocking: true + - cmd: wails3 task build + blocking: true + - cmd: KILL_STALE + - cmd: ./bin/ + primary: true +