mirror of
https://github.com/taigrr/wails.git
synced 2026-04-12 18:11:31 -07:00
Compare commits
14 Commits
window-deb
...
v0.9.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d487347d4 | ||
|
|
fe8b7ac5c9 | ||
|
|
732c70777b | ||
|
|
753c5fd337 | ||
|
|
2dad29673d | ||
|
|
5e466893cf | ||
|
|
c15fd822c1 | ||
|
|
42b1c0befa | ||
|
|
6ef8744e02 | ||
|
|
cf916c8e8b | ||
|
|
cdc1d4be3e | ||
|
|
1c5284db3e | ||
|
|
073cdc3a55 | ||
|
|
3051628fa2 |
2
app.go
2
app.go
@@ -46,8 +46,6 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
|||||||
log: newCustomLogger("App"),
|
log: newCustomLogger("App"),
|
||||||
}
|
}
|
||||||
|
|
||||||
result.log.Info("AIOSDOIIOASIDAOSIOASID")
|
|
||||||
|
|
||||||
appconfig, err := newAppConfig(userConfig)
|
appconfig, err := newAppConfig(userConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.log.Fatalf("Cannot use custom HTML: %s", err.Error())
|
result.log.Fatalf("Cannot use custom HTML: %s", err.Error())
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
func basic() string {
|
func basic() string {
|
||||||
return "Hello World!"
|
return "Hello World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 768,
|
Height: 768,
|
||||||
Title: "{{.Name}}",
|
Title: "{{.Name}}",
|
||||||
JS: mewn.String("./frontend/dist/app.js"),
|
JS: mewn.String("./frontend/dist/app.js"),
|
||||||
CSS: mewn.String("./frontend/dist/app.css"),
|
CSS: mewn.String("./frontend/dist/app.css"),
|
||||||
})
|
Colour: "#131313",
|
||||||
app.Bind(basic)
|
})
|
||||||
app.Run()
|
app.Bind(basic)
|
||||||
|
app.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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{}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
"github.com/wailsapp/wails/cmd"
|
"github.com/wailsapp/wails/cmd"
|
||||||
@@ -20,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{}
|
||||||
@@ -38,47 +35,12 @@ func init() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate config
|
|
||||||
// Check if we have a frontend
|
|
||||||
err = cmd.ValidateFrontendConfig(projectOptions)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Program checker
|
|
||||||
program := cmd.NewProgramHelper()
|
|
||||||
|
|
||||||
if projectOptions.FrontEnd != nil {
|
|
||||||
// npm
|
|
||||||
if !program.IsInstalled("npm") {
|
|
||||||
return fmt.Errorf("it appears npm is not installed. Please install and run again")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Mewn is installed
|
// Check Mewn is installed
|
||||||
err = cmd.CheckMewn()
|
err = cmd.CheckMewn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save project directory
|
|
||||||
// TODO: Test not compiling front end for bridge mode
|
|
||||||
projectDir := fs.Cwd()
|
|
||||||
|
|
||||||
// Install deps
|
|
||||||
if projectOptions.FrontEnd != nil {
|
|
||||||
err = cmd.InstallFrontendDeps(projectDir, projectOptions, forceRebuild, "serve")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move to project directory
|
|
||||||
err = os.Chdir(projectDir)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install dependencies
|
// Install dependencies
|
||||||
err = cmd.InstallGoDependencies()
|
err = cmd.InstallGoDependencies()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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())
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -49,9 +49,11 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
|||||||
github.com/wailsapp/webview v0.2.5 h1:/VacryPEUeMBb2VHHOjpoIze6ki8tW3qYX04MnI0b7o=
|
github.com/wailsapp/webview v0.2.5 h1:/VacryPEUeMBb2VHHOjpoIze6ki8tW3qYX04MnI0b7o=
|
||||||
github.com/wailsapp/webview v0.2.5/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
github.com/wailsapp/webview v0.2.5/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
||||||
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
|
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
|
||||||
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7DUFuK3Ct1zWmZ65QN30=
|
||||||
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|||||||
Reference in New Issue
Block a user