mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[chore] lint fixes
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
)
|
||||
|
||||
func buildApplication(f *flags.Build) error {
|
||||
|
||||
if f.NoColour {
|
||||
pterm.DisableColor()
|
||||
colour.ColourEnabled = false
|
||||
@@ -255,5 +254,4 @@ func buildApplication(f *flags.Build) error {
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,16 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/flags"
|
||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/dev"
|
||||
"github.com/wailsapp/wails/v2/internal/colour"
|
||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||
"os"
|
||||
)
|
||||
|
||||
func devApplication(f *flags.Dev) error {
|
||||
|
||||
if f.NoColour {
|
||||
pterm.DisableColor()
|
||||
colour.ColourEnabled = false
|
||||
@@ -34,5 +34,4 @@ func devApplication(f *flags.Dev) error {
|
||||
}
|
||||
|
||||
return dev.Application(f, logger)
|
||||
|
||||
}
|
||||
|
||||
@@ -128,8 +128,8 @@ func diagnoseEnvironment(f *flags.Doctor) error {
|
||||
// Output Dependencies Status
|
||||
var dependenciesMissing []string
|
||||
var externalPackages []*packagemanager.Dependency
|
||||
var dependenciesAvailableRequired = 0
|
||||
var dependenciesAvailableOptional = 0
|
||||
dependenciesAvailableRequired := 0
|
||||
dependenciesAvailableOptional := 0
|
||||
|
||||
dependenciesTableData := pterm.TableData{
|
||||
{"Dependency", "Package Name", "Status", "Version"},
|
||||
|
||||
@@ -47,7 +47,6 @@ func (*Dev) Default() *Dev {
|
||||
}
|
||||
|
||||
func (d *Dev) Process() error {
|
||||
|
||||
var err error
|
||||
err = d.loadAndMergeProjectConfig()
|
||||
if err != nil {
|
||||
@@ -113,7 +112,6 @@ func (d *Dev) loadAndMergeProjectConfig() error {
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
// GenerateBuildOptions creates a build.Options using the flags
|
||||
|
||||
@@ -14,7 +14,6 @@ type Init struct {
|
||||
}
|
||||
|
||||
func (i *Init) Default() *Init {
|
||||
|
||||
result := &Init{
|
||||
TemplateName: "vanilla",
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/leaanthony/debme"
|
||||
"github.com/leaanthony/gosod"
|
||||
"github.com/pterm/pterm"
|
||||
@@ -14,12 +17,9 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/bindings"
|
||||
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func generateModule(f *flags.GenerateModule) error {
|
||||
|
||||
if f.NoColour {
|
||||
pterm.DisableColor()
|
||||
colour.ColourEnabled = false
|
||||
@@ -55,7 +55,6 @@ func generateModule(f *flags.GenerateModule) error {
|
||||
}
|
||||
|
||||
func generateTemplate(f *flags.GenerateTemplate) error {
|
||||
|
||||
if f.NoColour {
|
||||
pterm.DisableColor()
|
||||
colour.ColourEnabled = false
|
||||
@@ -77,7 +76,7 @@ func generateTemplate(f *flags.GenerateTemplate) error {
|
||||
}
|
||||
templateDir := filepath.Join(cwd, f.Name)
|
||||
if !fs.DirExists(templateDir) {
|
||||
err := os.MkdirAll(templateDir, 0755)
|
||||
err := os.MkdirAll(templateDir, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -200,7 +199,7 @@ func processPackageJSON(frontendDir string) error {
|
||||
json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}")
|
||||
json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}")
|
||||
|
||||
err = os.WriteFile(packageJSON, json, 0644)
|
||||
err = os.WriteFile(packageJSON, json, 0o644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -231,7 +230,7 @@ func processPackageLockJSON(frontendDir string) error {
|
||||
printBulletPoint("Updating package-lock.json data...")
|
||||
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
|
||||
|
||||
err = os.WriteFile(filename, []byte(json), 0644)
|
||||
err = os.WriteFile(filename, []byte(json), 0o644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/flytam/filenamify"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/pkg/errors"
|
||||
@@ -13,15 +19,9 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||
"github.com/wailsapp/wails/v2/pkg/git"
|
||||
"github.com/wailsapp/wails/v2/pkg/templates"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func initProject(f *flags.Init) error {
|
||||
|
||||
if f.NoColour {
|
||||
pterm.DisableColor()
|
||||
colour.ColourEnabled = false
|
||||
@@ -215,7 +215,7 @@ func initGit(options *templates.Options) error {
|
||||
"frontend/dist",
|
||||
"frontend/node_modules",
|
||||
}
|
||||
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0644)
|
||||
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0o644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Unable to create gitignore")
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func updateReplaceLine(targetPath string) {
|
||||
}
|
||||
}
|
||||
|
||||
err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0644)
|
||||
err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0o644)
|
||||
if err != nil {
|
||||
fatal(err.Error())
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ func sliceToMap(input []string) map[string]struct{} {
|
||||
|
||||
// Application runs the application in dev mode
|
||||
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||
|
||||
cwd := lo.Must(os.Getwd())
|
||||
|
||||
// Update go.mod to use current wails version
|
||||
@@ -271,7 +270,6 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d
|
||||
|
||||
// restartApp does the actual rebuilding of the application when files change
|
||||
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, string, error) {
|
||||
|
||||
appBinary, err := build.Build(buildOptions)
|
||||
println()
|
||||
if err != nil {
|
||||
@@ -298,7 +296,6 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
||||
|
||||
// parse appargs if any
|
||||
args, err := shlex.Split(f.AppArgs)
|
||||
|
||||
if err != nil {
|
||||
buildOptions.Logger.Fatal("Unable to parse appargs: %s", err.Error())
|
||||
}
|
||||
@@ -345,7 +342,7 @@ func doWatcherLoop(cwd string, buildOptions *build.Options, debugBinaryProcess *
|
||||
logutils.LogGreen("Watching (sub)/directory: %s", cwd)
|
||||
|
||||
// Main Loop
|
||||
var extensionsThatTriggerARebuild = sliceToMap(strings.Split(f.Extensions, ","))
|
||||
extensionsThatTriggerARebuild := sliceToMap(strings.Split(f.Extensions, ","))
|
||||
var dirsThatTriggerAReload []string
|
||||
for _, dir := range strings.Split(f.ReloadDirs, ",") {
|
||||
if dir == "" {
|
||||
|
||||
@@ -18,7 +18,6 @@ type Watcher interface {
|
||||
|
||||
// initialiseWatcher creates the project directory watcher that will trigger recompile
|
||||
func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {
|
||||
|
||||
// Ignore dot files, node_modules and build directories by default
|
||||
ignoreDirs := getIgnoreDirs(cwd)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func SyncGoMod(logger *clilogger.CLILogger, updateWailsVersion bool) error {
|
||||
}
|
||||
|
||||
if updated {
|
||||
return os.WriteFile(gomodFilename, gomodData, 0755)
|
||||
return os.WriteFile(gomodFilename, gomodData, 0o755)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -66,7 +66,6 @@ func bool2Str(b bool) string {
|
||||
var app *clir.Cli
|
||||
|
||||
func main() {
|
||||
|
||||
var err error
|
||||
|
||||
app = clir.NewCli("Wails", "Go/HTML Appkit", internal.Version)
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
// AddSubcommand adds the `init` command for the Wails application
|
||||
func update(f *flags.Update) error {
|
||||
|
||||
if f.NoColour {
|
||||
colour.ColourEnabled = false
|
||||
pterm.DisableColor()
|
||||
@@ -73,8 +72,7 @@ func update(f *flags.Update) error {
|
||||
}
|
||||
|
||||
func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentVersion string) error {
|
||||
|
||||
var targetVersionString = "v" + targetVersion.String()
|
||||
targetVersionString := "v" + targetVersion.String()
|
||||
|
||||
if targetVersionString == currentVersion {
|
||||
pterm.Println("\nLooks like you're up to date!")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
module changeme
|
||||
|
||||
go 1.18
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.0
|
||||
|
||||
require github.com/wailsapp/wails/v2 v2.1.0
|
||||
|
||||
@@ -24,7 +26,7 @@ require (
|
||||
github.com/tkrajina/go-reflector v0.5.6 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.7 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.10 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||
|
||||
@@ -56,6 +56,7 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
module github.com/wailsapp/wails/v2
|
||||
|
||||
go 1.18
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.0
|
||||
|
||||
require (
|
||||
github.com/Masterminds/semver v1.5.0
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
//go:build !devtools
|
||||
|
||||
package app
|
||||
|
||||
// Note: devtools flag is also added in debug builds
|
||||
func IsDevtoolsEnabled() bool {
|
||||
return false
|
||||
}
|
||||
//go:build !devtools
|
||||
|
||||
package app
|
||||
|
||||
// IsDevtoolsEnabled returns true if devtools should be enabled
|
||||
// Note: devtools flag is also added in debug builds
|
||||
func IsDevtoolsEnabled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
Executable → Regular
+1
-3
@@ -60,7 +60,6 @@ func NewBindings(logger *logger.Logger, structPointersToBind []interface{}, exem
|
||||
|
||||
// Add the given struct methods to the Bindings
|
||||
func (b *Bindings) Add(structPtr interface{}) error {
|
||||
|
||||
methods, err := b.getMethods(structPtr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot bind value to app: %s", err.Error())
|
||||
@@ -146,7 +145,6 @@ func (b *Bindings) GenerateModels() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (b *Bindings) WriteModels(modelsDir string) error {
|
||||
|
||||
modelsData, err := b.GenerateModels()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -157,7 +155,7 @@ func (b *Bindings) WriteModels(modelsDir string) error {
|
||||
}
|
||||
|
||||
filename := filepath.Join(modelsDir, "models.ts")
|
||||
err = os.WriteFile(filename, modelsData, 0755)
|
||||
err = os.WriteFile(filename, modelsData, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ func (b *BoundMethod) OutputCount() int {
|
||||
|
||||
// ParseArgs method converts the input json into the types expected by the method
|
||||
func (b *BoundMethod) ParseArgs(args []json.RawMessage) ([]interface{}, error) {
|
||||
|
||||
result := make([]interface{}, b.InputCount())
|
||||
if len(args) != b.InputCount() {
|
||||
return nil, fmt.Errorf("received %d arguments to method '%s', expected %d", len(args), b.Name, b.InputCount())
|
||||
|
||||
@@ -34,7 +34,6 @@ func newDB() *DB {
|
||||
// GetMethodFromStore returns the method for the given package/struct/method names
|
||||
// nil is returned if any one of those does not exist
|
||||
func (d *DB) GetMethodFromStore(packageName string, structName string, methodName string) *BoundMethod {
|
||||
|
||||
// Lock the db whilst processing and unlock on return
|
||||
d.lock.RLock()
|
||||
defer d.lock.RUnlock()
|
||||
@@ -53,7 +52,6 @@ func (d *DB) GetMethodFromStore(packageName string, structName string, methodNam
|
||||
// GetMethod returns the method for the given qualified method name
|
||||
// qualifiedMethodName is "packagename.structname.methodname"
|
||||
func (d *DB) GetMethod(qualifiedMethodName string) *BoundMethod {
|
||||
|
||||
// Lock the db whilst processing and unlock on return
|
||||
d.lock.RLock()
|
||||
defer d.lock.RUnlock()
|
||||
@@ -72,7 +70,6 @@ func (d *DB) GetObfuscatedMethod(id int) *BoundMethod {
|
||||
|
||||
// AddMethod adds the given method definition to the db using the given qualified path: packageName.structName.methodName
|
||||
func (d *DB) AddMethod(packageName string, structName string, methodName string, methodDefinition *BoundMethod) {
|
||||
|
||||
// Lock the db whilst processing and unlock on return
|
||||
d.lock.Lock()
|
||||
defer d.lock.Unlock()
|
||||
@@ -99,12 +96,10 @@ func (d *DB) AddMethod(packageName string, structName string, methodName string,
|
||||
// Store in the methodMap
|
||||
key := packageName + "." + structName + "." + methodName
|
||||
d.methodMap[key] = methodDefinition
|
||||
|
||||
}
|
||||
|
||||
// ToJSON converts the method map to JSON
|
||||
func (d *DB) ToJSON() (string, error) {
|
||||
|
||||
// Lock the db whilst processing and unlock on return
|
||||
d.lock.RLock()
|
||||
defer d.lock.RUnlock()
|
||||
@@ -120,8 +115,7 @@ func (d *DB) ToJSON() (string, error) {
|
||||
|
||||
// UpdateObfuscatedCallMap sets up the secure call mappings
|
||||
func (d *DB) UpdateObfuscatedCallMap() map[string]int {
|
||||
|
||||
var mappings = make(map[string]int)
|
||||
mappings := make(map[string]int)
|
||||
|
||||
// Iterate map keys and sort them
|
||||
keys := make([]string, 0, len(d.methodMap))
|
||||
|
||||
@@ -15,12 +15,14 @@ import (
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
|
||||
var mapRegex *regexp.Regexp
|
||||
var keyPackageIndex int
|
||||
var keyTypeIndex int
|
||||
var valueArrayIndex int
|
||||
var valuePackageIndex int
|
||||
var valueTypeIndex int
|
||||
var (
|
||||
mapRegex *regexp.Regexp
|
||||
keyPackageIndex int
|
||||
keyTypeIndex int
|
||||
valueArrayIndex int
|
||||
valuePackageIndex int
|
||||
valueTypeIndex int
|
||||
)
|
||||
|
||||
func init() {
|
||||
mapRegex = regexp.MustCompile(`(?:map\[(?:(?P<keyPackage>\w+)\.)?(?P<keyType>\w+)])?(?P<valueArray>\[])?(?:\*?(?P<valuePackage>\w+)\.)?(?P<valueType>.+)`)
|
||||
@@ -81,9 +83,7 @@ func (b *Bindings) GenerateGoBindings(baseDir string) error {
|
||||
} else {
|
||||
jsoutput.WriteString(fmt.Sprintf(" return window['go']['%s']['%s']['%s'](%s);", packageName, structName, methodName, argsString))
|
||||
}
|
||||
jsoutput.WriteString("\n")
|
||||
jsoutput.WriteString(fmt.Sprintf("}"))
|
||||
jsoutput.WriteString("\n")
|
||||
jsoutput.WriteString("\n}\n")
|
||||
|
||||
// Generate TS
|
||||
tsBody.WriteString(fmt.Sprintf("\nexport function %s(", methodName))
|
||||
@@ -127,12 +127,12 @@ func (b *Bindings) GenerateGoBindings(baseDir string) error {
|
||||
tsContent.WriteString(tsBody.String())
|
||||
|
||||
jsfilename := filepath.Join(packageDir, structName+".js")
|
||||
err = os.WriteFile(jsfilename, jsoutput.Bytes(), 0755)
|
||||
err = os.WriteFile(jsfilename, jsoutput.Bytes(), 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tsfilename := filepath.Join(packageDir, structName+".d.ts")
|
||||
err = os.WriteFile(tsfilename, tsContent.Bytes(), 0755)
|
||||
err = os.WriteFile(tsfilename, tsContent.Bytes(), 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -186,7 +186,7 @@ func goTypeToJSDocType(input string, importNamespaces *slicer.StringSlicer) stri
|
||||
valueArray := matches[valueArrayIndex]
|
||||
valuePackage := matches[valuePackageIndex]
|
||||
valueType := matches[valueTypeIndex]
|
||||
//fmt.Printf("input=%s, keyPackage=%s, keyType=%s, valueArray=%s, valuePackage=%s, valueType=%s\n",
|
||||
// fmt.Printf("input=%s, keyPackage=%s, keyType=%s, valueArray=%s, valuePackage=%s, valueType=%s\n",
|
||||
// input,
|
||||
// keyPackage,
|
||||
// keyType,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user