mirror of
https://github.com/taigrr/wails.git
synced 2026-04-14 02:48:21 -07:00
Compare commits
8 Commits
minor-fixe
...
v0.9.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d487347d4 | ||
|
|
fe8b7ac5c9 | ||
|
|
732c70777b | ||
|
|
753c5fd337 | ||
|
|
2dad29673d | ||
|
|
5e466893cf | ||
|
|
c15fd822c1 | ||
|
|
6ef8744e02 |
@@ -21,7 +21,7 @@ func (app *App) setupCli() *cmd.Cli {
|
|||||||
// Banner
|
// Banner
|
||||||
result.PreRun(func(cli *cmd.Cli) error {
|
result.PreRun(func(cli *cmd.Cli) error {
|
||||||
log := cmd.NewLogger()
|
log := cmd.NewLogger()
|
||||||
log.PrintBanner()
|
log.PrintSmallBanner()
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
log.YellowUnderline(app.config.Title + " - Debug Build")
|
log.YellowUnderline(app.config.Title + " - Debug Build")
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ func (c *Command) Action(callback Action) *Command {
|
|||||||
|
|
||||||
// PrintHelp - Output the help text for this command
|
// PrintHelp - Output the help text for this command
|
||||||
func (c *Command) PrintHelp() {
|
func (c *Command) PrintHelp() {
|
||||||
|
c.log.PrintBanner()
|
||||||
versionString := c.AppVersion
|
versionString := c.AppVersion
|
||||||
if versionString != "" {
|
if versionString != "" {
|
||||||
versionString = " " + versionString
|
versionString = " " + versionString
|
||||||
@@ -211,7 +212,6 @@ func (c *Command) PrintHelp() {
|
|||||||
fmt.Println(c.Longdescription + "\n")
|
fmt.Println(c.Longdescription + "\n")
|
||||||
}
|
}
|
||||||
if len(c.SubCommands) > 0 {
|
if len(c.SubCommands) > 0 {
|
||||||
fmt.Println("")
|
|
||||||
c.log.White("Available commands:")
|
c.log.White("Available commands:")
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
for _, subcommand := range c.SubCommands {
|
for _, subcommand := range c.SubCommands {
|
||||||
@@ -222,9 +222,9 @@ func (c *Command) PrintHelp() {
|
|||||||
}
|
}
|
||||||
fmt.Printf(" %s%s%s %s\n", subcommand.Name, spacer, subcommand.Shortdescription, isDefault)
|
fmt.Printf(" %s%s%s %s\n", subcommand.Name, spacer, subcommand.Shortdescription, isDefault)
|
||||||
}
|
}
|
||||||
|
fmt.Println("")
|
||||||
}
|
}
|
||||||
if c.flagCount > 0 {
|
if c.flagCount > 0 {
|
||||||
fmt.Println("")
|
|
||||||
c.log.White("Flags:")
|
c.log.White("Flags:")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
c.Flags.SetOutput(os.Stdout)
|
c.Flags.SetOutput(os.Stdout)
|
||||||
|
|||||||
16
cmd/fs.go
16
cmd/fs.go
@@ -80,6 +80,22 @@ func (fs *FSHelper) Cwd() string {
|
|||||||
return cwd
|
return cwd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveFile removes the given filename
|
||||||
|
func (fs *FSHelper) RemoveFile(filename string) error {
|
||||||
|
return os.Remove(filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveFiles removes the given filenames
|
||||||
|
func (fs *FSHelper) RemoveFiles(files []string) error {
|
||||||
|
for _, filename := range files {
|
||||||
|
err := os.Remove(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetSubdirs will return a list of FQPs to subdirectories in the given directory
|
// GetSubdirs will return a list of FQPs to subdirectories in the given directory
|
||||||
func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error) {
|
func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error) {
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ func InstallGoDependencies() error {
|
|||||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||||
|
|
||||||
// Generate Windows assets if needed
|
// Generate Windows assets if needed
|
||||||
if runtime.GOOS == "windows" && packageApp {
|
if runtime.GOOS == "windows" {
|
||||||
err := PackageApplication(projectOptions)
|
cleanUp := !packageApp
|
||||||
|
err := NewPackageHelper().PackageWindows(projectOptions, cleanUp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -107,14 +108,6 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
}
|
}
|
||||||
packSpinner.Success()
|
packSpinner.Success()
|
||||||
|
|
||||||
// Package application
|
|
||||||
if runtime.GOOS != "windows" && packageApp {
|
|
||||||
err = PackageApplication(projectOptions)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
cmd/log.go
10
cmd/log.go
@@ -99,6 +99,16 @@ func (l *Logger) Error(format string, a ...interface{}) {
|
|||||||
color.New(color.FgHiRed).PrintfFunc()("Error: "+format+"\n", a...)
|
color.New(color.FgHiRed).PrintfFunc()("Error: "+format+"\n", a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Logger) PrintSmallBanner(message ...string) {
|
||||||
|
yellow := color.New(color.FgYellow).SprintFunc()
|
||||||
|
red := color.New(color.FgRed).SprintFunc()
|
||||||
|
msg := ""
|
||||||
|
if len(message) > 0 {
|
||||||
|
msg = " - " + message[0]
|
||||||
|
}
|
||||||
|
fmt.Printf("%s %s%s\n", yellow("Wails"), red(Version), msg)
|
||||||
|
}
|
||||||
|
|
||||||
// PrintBanner prints the Wails banner before running commands
|
// PrintBanner prints the Wails banner before running commands
|
||||||
func (l *Logger) PrintBanner() error {
|
func (l *Logger) PrintBanner() error {
|
||||||
banner1 := ` _ __ _ __
|
banner1 := ` _ __ _ __
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (b *PackageHelper) Package(po *ProjectOptions) error {
|
|||||||
}
|
}
|
||||||
return b.packageOSX(po)
|
return b.packageOSX(po)
|
||||||
case "windows":
|
case "windows":
|
||||||
return b.packageWindows(po)
|
return b.PackageWindows(po, true)
|
||||||
case "linux":
|
case "linux":
|
||||||
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
||||||
default:
|
default:
|
||||||
@@ -150,7 +150,7 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *PackageHelper) packageWindows(po *ProjectOptions) error {
|
func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||||
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||||
|
|
||||||
// Copy icon
|
// Copy icon
|
||||||
@@ -196,6 +196,15 @@ func (b *PackageHelper) packageWindows(po *ProjectOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
if cleanUp {
|
||||||
|
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile}
|
||||||
|
err := b.fs.RemoveFiles(filesToDelete)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func computeBinaryName(projectName string) string {
|
|||||||
func processOutputDirectory(po *ProjectOptions) error {
|
func processOutputDirectory(po *ProjectOptions) error {
|
||||||
// po.OutputDirectory
|
// po.OutputDirectory
|
||||||
if po.OutputDirectory == "" {
|
if po.OutputDirectory == "" {
|
||||||
po.OutputDirectory = PromptRequired("Project directory name")
|
po.OutputDirectory = PromptRequired("Project directory name", computeBinaryName(po.Name))
|
||||||
}
|
}
|
||||||
projectPath, err := filepath.Abs(po.OutputDirectory)
|
projectPath, err := filepath.Abs(po.OutputDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ package cmd
|
|||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
// ...oO(There must be a better way)
|
// ...oO(There must be a better way)
|
||||||
const Version = "v0.9.1"
|
const Version = "v0.9.2"
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ func init() {
|
|||||||
|
|
||||||
setupCommand.Action(func() error {
|
setupCommand.Action(func() error {
|
||||||
|
|
||||||
|
logger.PrintBanner();
|
||||||
|
|
||||||
system := cmd.NewSystemHelper()
|
system := cmd.NewSystemHelper()
|
||||||
err := system.Initialise()
|
err := system.Initialise()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Any flags that are required and not given will be prompted for.`
|
|||||||
|
|
||||||
initCommand.Action(func() error {
|
initCommand.Action(func() error {
|
||||||
|
|
||||||
logger.WhiteUnderline("Initialising project")
|
logger.PrintSmallBanner("Initialising project")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
// Check if the system is initialised
|
// Check if the system is initialised
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ func init() {
|
|||||||
|
|
||||||
initCmd.Action(func() error {
|
initCmd.Action(func() error {
|
||||||
|
|
||||||
log := cmd.NewLogger()
|
|
||||||
message := "Building Application"
|
message := "Building Application"
|
||||||
if forceRebuild {
|
if forceRebuild {
|
||||||
message += " (force rebuild)"
|
message += " (force rebuild)"
|
||||||
}
|
}
|
||||||
log.WhiteUnderline(message)
|
logger.PrintSmallBanner(message)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
// Project options
|
// Project options
|
||||||
projectOptions := &cmd.ProjectOptions{}
|
projectOptions := &cmd.ProjectOptions{}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
"github.com/wailsapp/wails/cmd"
|
"github.com/wailsapp/wails/cmd"
|
||||||
)
|
)
|
||||||
@@ -17,12 +19,10 @@ func init() {
|
|||||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
|
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
|
||||||
|
|
||||||
initCmd.Action(func() error {
|
initCmd.Action(func() error {
|
||||||
log := cmd.NewLogger()
|
|
||||||
message := "Building Application"
|
message := "Serving Application"
|
||||||
if forceRebuild {
|
logger.PrintSmallBanner(message)
|
||||||
message += " (force rebuild)"
|
fmt.Println()
|
||||||
}
|
|
||||||
log.WhiteUnderline(message)
|
|
||||||
|
|
||||||
// Project options
|
// Project options
|
||||||
projectOptions := &cmd.ProjectOptions{}
|
projectOptions := &cmd.ProjectOptions{}
|
||||||
|
|||||||
@@ -10,15 +10,8 @@ var logger = cmd.NewLogger()
|
|||||||
// Create main app
|
// Create main app
|
||||||
var app = cmd.NewCli("wails", "A cli tool for building Wails applications.")
|
var app = cmd.NewCli("wails", "A cli tool for building Wails applications.")
|
||||||
|
|
||||||
// Prints the cli banner
|
|
||||||
func printBanner(app *cmd.Cli) error {
|
|
||||||
logger.PrintBanner()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main!
|
// Main!
|
||||||
func main() {
|
func main() {
|
||||||
app.PreRun(printBanner)
|
|
||||||
err := app.Run()
|
err := app.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err.Error())
|
logger.Error(err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user