mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-09 18:31:29 +08:00
Fixed runtime. cp tool.
This commit is contained in:
parent
c01bc4dbd7
commit
5115b294ee
@ -54,6 +54,7 @@ func main() {
|
||||
tool := app.NewSubCommand("tool", "Various tools")
|
||||
tool.NewSubCommandFunction("checkport", "Checks if a port is open. Useful for testing if vite is running.", commands.ToolCheckPort)
|
||||
tool.NewSubCommandFunction("watcher", "Watches files and runs a command when they change", commands.Watcher)
|
||||
tool.NewSubCommandFunction("cp", "Copy files", commands.Cp)
|
||||
|
||||
app.NewSubCommandFunction("version", "Print the version", commands.Version)
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@ go 1.21.1
|
||||
toolchain go1.21.4
|
||||
|
||||
require (
|
||||
github.com/atterpac/refresh v0.4.32
|
||||
github.com/atterpac/refresh v0.5.11
|
||||
github.com/bep/debounce v1.2.1
|
||||
github.com/ebitengine/purego v0.4.0-alpha.4
|
||||
github.com/go-git/go-git/v5 v5.11.0
|
||||
@ -32,6 +32,7 @@ require (
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pterm/pterm v0.12.51
|
||||
github.com/rjeczalik/notify v0.9.3
|
||||
github.com/samber/lo v1.38.1
|
||||
github.com/tc-hib/winres v0.1.6
|
||||
github.com/wailsapp/go-webview2 v1.0.9
|
||||
@ -83,7 +84,6 @@ require (
|
||||
github.com/radovskyb/watcher v1.0.7 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/rjeczalik/notify v0.9.3 // indirect
|
||||
github.com/sajari/fuzzy v1.0.0 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/skeema/knownhosts v1.2.1 // indirect
|
||||
|
@ -69,8 +69,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuW
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
|
||||
github.com/atterpac/refresh v0.4.32 h1:sy2T3rNtbGYffZQWGpqRafZ1QwQMGLkRafCTX52fv0w=
|
||||
github.com/atterpac/refresh v0.4.32/go.mod h1:1mhPVWQ9R8Xlr/ouNrtAVEAsEVOt65J+6FFYWMMKRN0=
|
||||
github.com/atterpac/refresh v0.5.11 h1:ixFxqR7TCuEGzjFhtt7oHCXD1skhB+Ye59HtIblLRak=
|
||||
github.com/atterpac/refresh v0.5.11/go.mod h1:IubLmdAVDaTxarKH/AehgJ/QKUtSnawxgvj5HCsIcYo=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
|
@ -2,7 +2,7 @@
|
||||
root_path = ".."
|
||||
# debug | info | warn | error | mute
|
||||
# Defaults to Info if not provided
|
||||
log_level = "info"
|
||||
log_level = "warn"
|
||||
# Debounce setting for ignoring reptitive file system notifications
|
||||
debounce = 1000 # Milliseconds
|
||||
# Sets what files the watcher should ignore
|
||||
|
38
v3/internal/commands/tool_cp.go
Normal file
38
v3/internal/commands/tool_cp.go
Normal file
@ -0,0 +1,38 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type CpOptions struct{}
|
||||
|
||||
func Cp(options *CpOptions) error {
|
||||
// extract the source and destination from os.Args
|
||||
if len(os.Args) != 5 {
|
||||
return fmt.Errorf("cp requires a source and destination")
|
||||
}
|
||||
// Extract source
|
||||
source := os.Args[3]
|
||||
for _, destination := range os.Args[4:] {
|
||||
src, err := filepath.Abs(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dst, err := filepath.Abs(destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
input, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.WriteFile(dst, input, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating %s: %s", dst, err.Error())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
@ -12,16 +12,18 @@ type WatcherOptions struct {
|
||||
|
||||
func Watcher(options *WatcherOptions) error {
|
||||
stopChan := make(chan struct{})
|
||||
watcherEngine := engine.NewEngineFromTOML(options.Config)
|
||||
watcherEngine, err := engine.NewEngineFromTOML(options.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
signalHandler := signal.NewSignalHandler(func() {
|
||||
watcherEngine.Stop()
|
||||
stopChan <- struct{}{}
|
||||
})
|
||||
signalHandler.ExitMessage = func(sig os.Signal) string {
|
||||
return ""
|
||||
}
|
||||
signalHandler.Start()
|
||||
err := watcherEngine.Start()
|
||||
err = watcherEngine.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ tasks:
|
||||
- build:production
|
||||
|
||||
cmds:
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../examples/wml/assets/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../internal/commands/build_assets/runtime/runtime.js
|
||||
- cmd: wails3 tool cp ../commands/build_assets/runtime/runtime.js ../../pkg/application/assets/alpha/runtime.js
|
||||
- cmd: echo "Build Complete."
|
||||
|
||||
build:
|
||||
|
@ -19,7 +19,7 @@ export function invoke(msg) {
|
||||
if(window.chrome) {
|
||||
return window.chrome.webview.postMessage(msg);
|
||||
}
|
||||
return window.webkit.messageHandlers.external.postMessage;
|
||||
return window.webkit.messageHandlers.external.postMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -433,13 +433,10 @@ tasks:
|
||||
summary: Runs the application in development mode
|
||||
cmds:
|
||||
- wails3 tool watcher -config ./build/devmode.config.toml
|
||||
vars:
|
||||
FRONTEND_DEVSERVER_URL: 'http://localhost:5173'
|
||||
env:
|
||||
# This is the default vite dev server port
|
||||
FRONTEND_DEVSERVER_URL: 'http://localhost:5173'
|
||||
|
||||
|
||||
dev:reload:
|
||||
summary: Reloads the application
|
||||
cmds:
|
||||
|
File diff suppressed because one or more lines are too long
@ -1490,7 +1490,6 @@ func (w *windowsWebviewWindow) flash(enabled bool) {
|
||||
func (w *windowsWebviewWindow) navigationCompleted(sender *edge.ICoreWebView2, args *edge.ICoreWebView2NavigationCompletedEventArgs) {
|
||||
|
||||
// Install the runtime core
|
||||
println("runtime core = ", runtime.Core())
|
||||
w.execJS(runtime.Core())
|
||||
|
||||
// Emit DomReady Event
|
||||
|
Loading…
Reference in New Issue
Block a user