Compare commits

...

2 Commits

Author SHA1 Message Date
Lea Anthony
2729081f2c [v2] v2.0.0-beta.8 2021-10-09 07:57:23 +11:00
Lea Anthony
cad1317fc8 [v2] Tags passthrough for wails generate module 2021-10-09 07:56:19 +11:00
7 changed files with 38 additions and 24 deletions

View File

@@ -120,7 +120,11 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
return err
}
err = runCommand(cwd, true, "wails", "generate", "module")
if flags.tags != "" {
err = runCommand(cwd, true, "wails", "generate", "module", "-tags", flags.tags)
} else {
err = runCommand(cwd, true, "wails", "generate", "module")
}
if err != nil {
return err
}
@@ -134,7 +138,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
buildOptions := generateBuildOptions(flags)
buildOptions.Logger = logger
buildOptions.UserTags = parseUserTags(flags.tags)
buildOptions.UserTags = internal.ParseUserTags(flags.tags)
var debugBinaryProcess *process.Process = nil
@@ -266,18 +270,6 @@ func generateBuildOptions(flags devFlags) *build.Options {
}
}
// parseUserTags takes the string form of tags and converts to a slice of strings
func parseUserTags(tagString string) []string {
userTags := make([]string, 0)
for _, tag := range strings.Split(tagString, " ") {
thisTag := strings.TrimSpace(tag)
if thisTag != "" {
userTags = append(userTags, thisTag)
}
}
return userTags
}
// loadAndMergeProjectConfig reconciles flags passed to the CLI with project config settings and updates
// the project config if necessary
func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, error) {

View File

@@ -2,17 +2,21 @@ package generate
import (
"github.com/leaanthony/clir"
"github.com/wailsapp/wails/v2/cmd/wails/internal"
"github.com/wailsapp/wails/v2/internal/shell"
"io"
"os"
"path/filepath"
"runtime"
"strings"
)
// AddModuleCommand adds the `module` subcommand for the `generate` command
func AddModuleCommand(app *clir.Cli, parent *clir.Command, w io.Writer) error {
command := parent.NewSubCommand("module", "Generate wailsjs modules")
var tags string
command.StringFlag("tags", "tags to pass to Go compiler (quoted and space separated)", &tags)
command.Action(func() error {
@@ -29,7 +33,10 @@ func AddModuleCommand(app *clir.Cli, parent *clir.Command, w io.Writer) error {
return err
}
_, _, err = shell.RunCommand(cwd, "go", "build", "-tags", "bindings", "-o", filename)
tagList := internal.ParseUserTags(tags)
tagList = append(tagList, "bindings")
_, _, err = shell.RunCommand(cwd, "go", "build", "-tags", strings.Join(tagList, ","), "-o", filename)
if err != nil {
return err
}

View File

@@ -0,0 +1,15 @@
package internal
import "strings"
// ParseUserTags takes the string form of tags and converts to a slice of strings
func ParseUserTags(tagString string) []string {
userTags := make([]string, 0)
for _, tag := range strings.Split(tagString, " ") {
thisTag := strings.TrimSpace(tag)
if thisTag != "" {
userTags = append(userTags, thisTag)
}
}
return userTags
}

View File

@@ -1,3 +1,3 @@
package internal
var Version = "v2.0.0-beta.7"
var Version = "v2.0.0-beta.8"

View File

@@ -10,7 +10,7 @@ const basic string = `module changeme
go 1.17
require github.com/wailsapp/wails/v2 v2.0.0-beta.7
require github.com/wailsapp/wails/v2 v2.0.0-beta.8
require (
github.com/andybalholm/brotli v1.0.2 // indirect
@@ -44,7 +44,7 @@ require (
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
)
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.8 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2
`
func TestGetWailsVersion(t *testing.T) {
@@ -54,7 +54,7 @@ func TestGetWailsVersion(t *testing.T) {
want *semver.Version
wantErr bool
}{
{"basic", []byte(basic), semver.MustParse("v2.0.0-beta.7"), false},
{"basic", []byte(basic), semver.MustParse("v2.0.0-beta.8"), false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -74,7 +74,7 @@ const basicUpdated string = `module changeme
go 1.17
require github.com/wailsapp/wails/v2 v2.0.0-beta.7
require github.com/wailsapp/wails/v2 v2.0.0-beta.8
require (
github.com/andybalholm/brotli v1.0.2 // indirect
@@ -108,7 +108,7 @@ require (
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
)
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.8 => C:\Users\leaan\Documents\wails-v2-beta\wails\v2
`
func TestUpdateGoModVersion(t *testing.T) {
@@ -122,7 +122,7 @@ func TestUpdateGoModVersion(t *testing.T) {
want []byte
wantErr bool
}{
{"basic", args{[]byte(basic), "v2.0.0-beta.7"}, []byte(basicUpdated), false},
{"basic", args{[]byte(basic), "v2.0.0-beta.8"}, []byte(basicUpdated), false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

View File

@@ -62,7 +62,7 @@ import TabItem from "@theme/TabItem";
## Installing Wails
Run `go install github.com/wailsapp/wails/v2/cmd/wails@v2.0.0-beta.7` to install the Wails CLI.
Run `go install github.com/wailsapp/wails/v2/cmd/wails@v2.0.0-beta.8` to install the Wails CLI.
## System Check

View File

@@ -63,7 +63,7 @@ import TabItem from "@theme/TabItem";
## 安装 Wails
运行 `go install github.com/wailsapp/wails/v2/cmd/wails@v2.0.0-beta.7` 安装 Wails CLI。
运行 `go install github.com/wailsapp/wails/v2/cmd/wails@v2.0.0-beta.8` 安装 Wails CLI。
## 系统检查