mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 01:31:54 +08:00
Merge branch 'develop'
This commit is contained in:
commit
a8ecc1e872
@ -22,4 +22,7 @@ Wails is what it is because of the time and effort given by these great people.
|
||||
* [Kris Raney](https://github.com/kraney)
|
||||
* [Jack Mordaunt](https://github.com/JackMordaunt)
|
||||
* [Michael Hipp](https://github.com/MichaelHipp)
|
||||
* [Travis McLane](https://github.com/tmclane)
|
||||
* [Travis McLane](https://github.com/tmclane)
|
||||
* [Reuben Thomas-Davis](https://github.com/Rested)
|
||||
* [Jarek](https://github.com/Jarek-SRT)
|
||||
* [Konez2k](https://github.com/konez2k)
|
||||
|
@ -147,3 +147,11 @@ This project was mainly coded to the following albums:
|
||||
## Licensing
|
||||
|
||||
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
|
||||
|
||||
## Special Thank You
|
||||
|
||||
<p align="center" style="text-align: center">
|
||||
A special thank you to JetBrains for donating licenses to us!<br/><br/>
|
||||
Please click the logo to let them know your appreciation!<br/><br/>
|
||||
<a href="https://www.jetbrains.com?from=Wails"><img src="jetbrains-grayscale.png" width="30%"></a>
|
||||
</p>
|
||||
|
@ -1,4 +1,4 @@
|
||||
// +build +linux +darwin !windows
|
||||
// +build linux darwin !windows
|
||||
|
||||
package wails
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
21
cmd/fs.go
21
cmd/fs.go
@ -12,6 +12,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
@ -47,6 +48,22 @@ func (fs *FSHelper) FileExists(path string) bool {
|
||||
return fi.Mode().IsRegular()
|
||||
}
|
||||
|
||||
// FindFile returns the first occurrence of match inside path.
|
||||
func (fs *FSHelper) FindFile(path, match string) (string, error) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if !f.IsDir() && strings.Contains(f.Name(), match) {
|
||||
return f.Name(), nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("file not found")
|
||||
}
|
||||
|
||||
// CreateFile creates a file at the given filename location with the contents
|
||||
// set to the given data. It will create intermediary directories if needed.
|
||||
func (fs *FSHelper) CreateFile(filename string, data []byte) error {
|
||||
@ -100,10 +117,10 @@ func (fs *FSHelper) RemoveFile(filename string) error {
|
||||
}
|
||||
|
||||
// RemoveFiles removes the given filenames
|
||||
func (fs *FSHelper) RemoveFiles(files []string) error {
|
||||
func (fs *FSHelper) RemoveFiles(files []string, continueOnError bool) error {
|
||||
for _, filename := range files {
|
||||
err := os.Remove(filename)
|
||||
if err != nil {
|
||||
if err != nil && !continueOnError {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
410
cmd/helpers.go
410
cmd/helpers.go
@ -5,12 +5,15 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/leaanthony/mewn/lib"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/leaanthony/spinner"
|
||||
)
|
||||
@ -36,34 +39,161 @@ func ValidateFrontendConfig(projectOptions *ProjectOptions) error {
|
||||
}
|
||||
|
||||
// InstallGoDependencies will run go get in the current directory
|
||||
func InstallGoDependencies() error {
|
||||
depSpinner := spinner.New("Ensuring Dependencies are up to date...")
|
||||
depSpinner.SetSpinSpeed(50)
|
||||
depSpinner.Start()
|
||||
err := NewProgramHelper().RunCommand("go get")
|
||||
func InstallGoDependencies(verbose bool) error {
|
||||
var depSpinner *spinner.Spinner
|
||||
if !verbose {
|
||||
depSpinner = spinner.New("Ensuring Dependencies are up to date...")
|
||||
depSpinner.SetSpinSpeed(50)
|
||||
depSpinner.Start()
|
||||
}
|
||||
err := NewProgramHelper(verbose).RunCommand("go get")
|
||||
if err != nil {
|
||||
depSpinner.Error()
|
||||
if !verbose {
|
||||
depSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
depSpinner.Success()
|
||||
if !verbose {
|
||||
depSpinner.Success()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildApplication will attempt to build the project based on the given inputs
|
||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||
// EmbedAssets will embed the built frontend assets via mewn.
|
||||
func EmbedAssets() ([]string, error) {
|
||||
mewnFiles := lib.GetMewnFiles([]string{}, false)
|
||||
|
||||
// Generate Windows assets if needed
|
||||
if runtime.GOOS == "windows" {
|
||||
cleanUp := !packageApp
|
||||
err := NewPackageHelper().PackageWindows(projectOptions, cleanUp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
referencedAssets, err := lib.GetReferencedAssets(mewnFiles)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
// Check Mewn is installed
|
||||
err := CheckMewn()
|
||||
targetFiles := []string{}
|
||||
|
||||
for _, referencedAsset := range referencedAssets {
|
||||
packfileData, err := lib.GeneratePackFileString(referencedAsset, false)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
targetFile := filepath.Join(referencedAsset.BaseDir, referencedAsset.PackageName+"-mewn.go")
|
||||
targetFiles = append(targetFiles, targetFile)
|
||||
ioutil.WriteFile(targetFile, []byte(packfileData), 0644)
|
||||
}
|
||||
|
||||
return targetFiles, nil
|
||||
}
|
||||
|
||||
func InitializeCrossCompilation(verbose bool) error {
|
||||
// Check Docker
|
||||
if err := CheckIfInstalled("docker"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var packSpinner *spinner.Spinner
|
||||
if !verbose {
|
||||
packSpinner = spinner.New("Pulling wailsapp/xgo:latest docker image... (may take a while)")
|
||||
packSpinner.SetSpinSpeed(50)
|
||||
packSpinner.Start()
|
||||
} else {
|
||||
println("Pulling wailsapp/xgo:latest docker image... (may take a while)")
|
||||
}
|
||||
|
||||
err := NewProgramHelper(verbose).RunCommandArray([]string{"docker",
|
||||
"pull", "wailsapp/xgo:latest"})
|
||||
|
||||
if err != nil {
|
||||
if packSpinner != nil {
|
||||
packSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
if packSpinner != nil {
|
||||
packSpinner.Success()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildDocker builds the project using the cross compiling wailsapp/xgo:latest container
|
||||
func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOptions) error {
|
||||
var packSpinner *spinner.Spinner
|
||||
if buildMode == BuildModeBridge {
|
||||
return fmt.Errorf("you cant serve the application in cross-compilation")
|
||||
}
|
||||
|
||||
// Check build directory
|
||||
buildDirectory := filepath.Join(fs.Cwd(), "build")
|
||||
if !fs.DirExists(buildDirectory) {
|
||||
fs.MkDir(buildDirectory)
|
||||
}
|
||||
|
||||
buildCommand := slicer.String()
|
||||
userid := 1000
|
||||
user, _ := user.Current()
|
||||
if i, err := strconv.Atoi(user.Uid); err == nil {
|
||||
userid = i
|
||||
}
|
||||
for _, arg := range []string{
|
||||
"docker",
|
||||
"run",
|
||||
"--rm",
|
||||
"-v", fmt.Sprintf("%s:/build", filepath.Join(fs.Cwd(), "build")),
|
||||
"-v", fmt.Sprintf("%s:/source", fs.Cwd()),
|
||||
"-e", fmt.Sprintf("LOCAL_USER_ID=%v", userid),
|
||||
"-e", fmt.Sprintf("FLAG_LDFLAGS=%s", ldFlags(projectOptions, buildMode)),
|
||||
"-e", "FLAG_V=false",
|
||||
"-e", "FLAG_X=false",
|
||||
"-e", "FLAG_RACE=false",
|
||||
"-e", "FLAG_BUILDMODE=default",
|
||||
"-e", "FLAG_TRIMPATH=false",
|
||||
"-e", fmt.Sprintf("TARGETS=%s", projectOptions.Platform+"/"+projectOptions.Architecture),
|
||||
"-e", "GOPROXY=",
|
||||
"-e", "GO111MODULE=on",
|
||||
"wailsapp/xgo:latest",
|
||||
".",
|
||||
} {
|
||||
buildCommand.Add(arg)
|
||||
}
|
||||
|
||||
compileMessage := fmt.Sprintf(
|
||||
"Packing + Compiling project for %s/%s using docker image wailsapp/xgo:latest",
|
||||
projectOptions.Platform, projectOptions.Architecture)
|
||||
|
||||
if buildMode == BuildModeDebug {
|
||||
compileMessage += " (Debug Mode)"
|
||||
}
|
||||
|
||||
if !projectOptions.Verbose {
|
||||
packSpinner = spinner.New(compileMessage + "...")
|
||||
packSpinner.SetSpinSpeed(50)
|
||||
packSpinner.Start()
|
||||
} else {
|
||||
println(compileMessage)
|
||||
}
|
||||
|
||||
err := NewProgramHelper(projectOptions.Verbose).RunCommandArray(buildCommand.AsSlice())
|
||||
if err != nil {
|
||||
if packSpinner != nil {
|
||||
packSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
if packSpinner != nil {
|
||||
packSpinner.Success()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildNative builds on the target platform itself.
|
||||
func BuildNative(binaryName string, forceRebuild bool, buildMode string, projectOptions *ProjectOptions) error {
|
||||
|
||||
// Check Mewn is installed
|
||||
if err := CheckMewn(projectOptions.Verbose); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := CheckWindres(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -73,23 +203,27 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
compileMessage += " (Debug Mode)"
|
||||
}
|
||||
|
||||
packSpinner := spinner.New(compileMessage + "...")
|
||||
packSpinner.SetSpinSpeed(50)
|
||||
packSpinner.Start()
|
||||
var packSpinner *spinner.Spinner
|
||||
if !projectOptions.Verbose {
|
||||
packSpinner = spinner.New(compileMessage + "...")
|
||||
packSpinner.SetSpinSpeed(50)
|
||||
packSpinner.Start()
|
||||
} else {
|
||||
println(compileMessage)
|
||||
}
|
||||
|
||||
buildCommand := slicer.String()
|
||||
buildCommand.Add("mewn")
|
||||
buildCommand.Add("go")
|
||||
|
||||
buildCommand.Add("build")
|
||||
if buildMode == BuildModeBridge {
|
||||
// Ignore errors
|
||||
buildCommand.Add("-i")
|
||||
}
|
||||
|
||||
buildCommand.Add("build")
|
||||
|
||||
if binaryName != "" {
|
||||
// Alter binary name based on OS
|
||||
switch runtime.GOOS {
|
||||
switch projectOptions.Platform {
|
||||
case "windows":
|
||||
if !strings.HasSuffix(binaryName, ".exe") {
|
||||
binaryName += ".exe"
|
||||
@ -99,7 +233,7 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
binaryName = strings.TrimSuffix(binaryName, ".exe")
|
||||
}
|
||||
}
|
||||
buildCommand.Add("-o", binaryName)
|
||||
buildCommand.Add("-o", filepath.Join("build", binaryName))
|
||||
}
|
||||
|
||||
// If we are forcing a rebuild
|
||||
@ -107,38 +241,72 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
buildCommand.Add("-a")
|
||||
}
|
||||
|
||||
// Setup ld flags
|
||||
ldflags := "-w -s "
|
||||
if buildMode == BuildModeDebug {
|
||||
ldflags = ""
|
||||
buildCommand.AddSlice([]string{"-ldflags", ldFlags(projectOptions, buildMode)})
|
||||
|
||||
if projectOptions.Verbose {
|
||||
fmt.Printf("Command: %v\n", buildCommand.AsSlice())
|
||||
}
|
||||
|
||||
// Add windows flags
|
||||
if runtime.GOOS == "windows" && buildMode == BuildModeProd {
|
||||
ldflags += "-H windowsgui "
|
||||
}
|
||||
|
||||
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
||||
|
||||
// If we wish to generate typescript
|
||||
if projectOptions.typescriptDefsFilename != "" {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filename := filepath.Join(cwd, projectOptions.FrontEnd.Dir, projectOptions.typescriptDefsFilename)
|
||||
ldflags += " -X github.com/wailsapp/wails/lib/binding.typescriptDefinitionFilename=" + filename
|
||||
}
|
||||
|
||||
buildCommand.AddSlice([]string{"-ldflags", ldflags})
|
||||
err = NewProgramHelper().RunCommandArray(buildCommand.AsSlice())
|
||||
err := NewProgramHelper(projectOptions.Verbose).RunCommandArray(buildCommand.AsSlice())
|
||||
if err != nil {
|
||||
if packSpinner != nil {
|
||||
packSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
if packSpinner != nil {
|
||||
packSpinner.Success()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildApplication will attempt to build the project based on the given inputs
|
||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||
var err error
|
||||
|
||||
// embed resources
|
||||
targetFiles, err := EmbedAssets()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if projectOptions.CrossCompile {
|
||||
if err := InitializeCrossCompilation(projectOptions.Verbose); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
helper := NewPackageHelper(projectOptions.Platform)
|
||||
|
||||
// Generate windows resources
|
||||
if projectOptions.Platform == "windows" {
|
||||
if err := helper.PackageWindows(projectOptions, false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup temporary embedded assets
|
||||
defer func() {
|
||||
for _, filename := range targetFiles {
|
||||
if err := os.Remove(filename); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
if projectOptions.Platform == "windows" {
|
||||
helper.CleanWindows(projectOptions)
|
||||
}
|
||||
}()
|
||||
|
||||
if projectOptions.CrossCompile {
|
||||
err = BuildDocker(binaryName, buildMode, projectOptions)
|
||||
} else {
|
||||
err = BuildNative(binaryName, forceRebuild, buildMode, projectOptions)
|
||||
}
|
||||
if err != nil {
|
||||
packSpinner.Error()
|
||||
return err
|
||||
}
|
||||
packSpinner.Success()
|
||||
|
||||
// packageApp
|
||||
if packageApp {
|
||||
err = PackageApplication(projectOptions)
|
||||
if err != nil {
|
||||
@ -151,61 +319,76 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
|
||||
// PackageApplication will attempt to package the application in a platform dependent way
|
||||
func PackageApplication(projectOptions *ProjectOptions) error {
|
||||
// Package app
|
||||
message := "Generating .app"
|
||||
if runtime.GOOS == "windows" {
|
||||
err := CheckWindres()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message = "Generating resource bundle"
|
||||
var packageSpinner *spinner.Spinner
|
||||
if projectOptions.Verbose {
|
||||
packageSpinner = spinner.New("Packaging application...")
|
||||
packageSpinner.SetSpinSpeed(50)
|
||||
packageSpinner.Start()
|
||||
}
|
||||
packageSpinner := spinner.New(message)
|
||||
packageSpinner.SetSpinSpeed(50)
|
||||
packageSpinner.Start()
|
||||
err := NewPackageHelper().Package(projectOptions)
|
||||
|
||||
err := NewPackageHelper(projectOptions.Platform).Package(projectOptions)
|
||||
if err != nil {
|
||||
packageSpinner.Error()
|
||||
if packageSpinner != nil {
|
||||
packageSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
packageSpinner.Success()
|
||||
if packageSpinner != nil {
|
||||
packageSpinner.Success()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildFrontend runs the given build command
|
||||
func BuildFrontend(buildCommand string) error {
|
||||
buildFESpinner := spinner.New("Building frontend...")
|
||||
buildFESpinner.SetSpinSpeed(50)
|
||||
buildFESpinner.Start()
|
||||
err := NewProgramHelper().RunCommand(buildCommand)
|
||||
func BuildFrontend(projectOptions *ProjectOptions) error {
|
||||
var buildFESpinner *spinner.Spinner
|
||||
if !projectOptions.Verbose {
|
||||
buildFESpinner = spinner.New("Building frontend...")
|
||||
buildFESpinner.SetSpinSpeed(50)
|
||||
buildFESpinner.Start()
|
||||
} else {
|
||||
println("Building frontend...")
|
||||
}
|
||||
err := NewProgramHelper(projectOptions.Verbose).RunCommand(projectOptions.FrontEnd.Build)
|
||||
if err != nil {
|
||||
buildFESpinner.Error()
|
||||
if buildFESpinner != nil {
|
||||
buildFESpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
buildFESpinner.Success()
|
||||
if buildFESpinner != nil {
|
||||
buildFESpinner.Success()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckMewn checks if mewn is installed and if not, attempts to fetch it
|
||||
func CheckMewn() (err error) {
|
||||
programHelper := NewProgramHelper()
|
||||
func CheckMewn(verbose bool) (err error) {
|
||||
programHelper := NewProgramHelper(verbose)
|
||||
if !programHelper.IsInstalled("mewn") {
|
||||
buildSpinner := spinner.New()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
buildSpinner.Start("Installing Mewn asset packer...")
|
||||
var buildSpinner *spinner.Spinner
|
||||
if !verbose {
|
||||
buildSpinner = spinner.New()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
buildSpinner.Start("Installing Mewn asset packer...")
|
||||
}
|
||||
err := programHelper.InstallGoPackage("github.com/leaanthony/mewn/cmd/mewn")
|
||||
if err != nil {
|
||||
buildSpinner.Error()
|
||||
if buildSpinner != nil {
|
||||
buildSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
buildSpinner.Success()
|
||||
if buildSpinner != nil {
|
||||
buildSpinner.Success()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckWindres checks if Windres is installed and if not, aborts
|
||||
func CheckWindres() (err error) {
|
||||
if runtime.GOOS != "windows" {
|
||||
if runtime.GOOS != "windows" { // FIXME: Handle windows cross-compile for windows!
|
||||
return nil
|
||||
}
|
||||
programHelper := NewProgramHelper()
|
||||
@ -215,6 +398,15 @@ func CheckWindres() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckIfInstalled returns if application is installed
|
||||
func CheckIfInstalled(application string) (err error) {
|
||||
programHelper := NewProgramHelper()
|
||||
if !programHelper.IsInstalled(application) {
|
||||
return fmt.Errorf("%s not installed. Ensure you have installed %s correctly", application, application)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallFrontendDeps attempts to install the frontend dependencies based on the given options
|
||||
func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forceRebuild bool, caller string) error {
|
||||
|
||||
@ -225,9 +417,14 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
}
|
||||
|
||||
// Check if frontend deps have been updated
|
||||
feSpinner := spinner.New("Ensuring frontend dependencies are up to date (This may take a while)")
|
||||
feSpinner.SetSpinSpeed(50)
|
||||
feSpinner.Start()
|
||||
var feSpinner *spinner.Spinner
|
||||
if !projectOptions.Verbose {
|
||||
feSpinner = spinner.New("Ensuring frontend dependencies are up to date (This may take a while)")
|
||||
feSpinner.SetSpinSpeed(50)
|
||||
feSpinner.Start()
|
||||
} else {
|
||||
println("Ensuring frontend dependencies are up to date (This may take a while)")
|
||||
}
|
||||
|
||||
requiresNPMInstall := true
|
||||
|
||||
@ -259,7 +456,11 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
if savedMD5sum == packageJSONMD5 {
|
||||
// Same - no need for reinstall
|
||||
requiresNPMInstall = false
|
||||
feSpinner.Success("Skipped frontend dependencies (-f to force rebuild)")
|
||||
if feSpinner != nil {
|
||||
feSpinner.Success("Skipped frontend dependencies (-f to force rebuild)")
|
||||
} else {
|
||||
println("Skipped frontend dependencies (-f to force rebuild)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -268,12 +469,16 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
// Different? Build
|
||||
if requiresNPMInstall || forceRebuild {
|
||||
// Install dependencies
|
||||
err = NewProgramHelper().RunCommand(projectOptions.FrontEnd.Install)
|
||||
err = NewProgramHelper(projectOptions.Verbose).RunCommand(projectOptions.FrontEnd.Install)
|
||||
if err != nil {
|
||||
feSpinner.Error()
|
||||
if feSpinner != nil {
|
||||
feSpinner.Error()
|
||||
}
|
||||
return err
|
||||
}
|
||||
feSpinner.Success()
|
||||
if feSpinner != nil {
|
||||
feSpinner.Success()
|
||||
}
|
||||
|
||||
// Update md5sum file
|
||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
@ -286,7 +491,7 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
}
|
||||
|
||||
// Build frontend
|
||||
err = BuildFrontend(projectOptions.FrontEnd.Build)
|
||||
err = BuildFrontend(projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -325,7 +530,7 @@ func ServeProject(projectOptions *ProjectOptions, logger *Logger) error {
|
||||
time.Sleep(2 * time.Second)
|
||||
logger.Green(">>>>> To connect, you will need to run '" + projectOptions.FrontEnd.Serve + "' in the '" + projectOptions.FrontEnd.Dir + "' directory <<<<<")
|
||||
}()
|
||||
location, err := filepath.Abs(projectOptions.BinaryName)
|
||||
location, err := filepath.Abs(filepath.Join("build", projectOptions.BinaryName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -341,3 +546,28 @@ func ServeProject(projectOptions *ProjectOptions, logger *Logger) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ldFlags(po *ProjectOptions, buildMode string) string {
|
||||
// Setup ld flags
|
||||
ldflags := "-w -s "
|
||||
if buildMode == BuildModeDebug {
|
||||
ldflags = ""
|
||||
}
|
||||
|
||||
// Add windows flags
|
||||
if po.Platform == "windows" && buildMode == BuildModeProd {
|
||||
ldflags += "-H windowsgui "
|
||||
}
|
||||
|
||||
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
|
||||
|
||||
// If we wish to generate typescript
|
||||
if po.typescriptDefsFilename != "" {
|
||||
cwd, err := os.Getwd()
|
||||
if err == nil {
|
||||
filename := filepath.Join(cwd, po.FrontEnd.Dir, po.typescriptDefsFilename)
|
||||
ldflags += " -X github.com/wailsapp/wails/lib/binding.typescriptDefinitionFilename=" + filename
|
||||
}
|
||||
}
|
||||
return ldflags
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ const (
|
||||
Deepin
|
||||
// Raspbian distribution
|
||||
Raspbian
|
||||
// openSUSE Tumbleweed distribution
|
||||
Tumbleweed
|
||||
// openSUSE Leap distribution
|
||||
Leap
|
||||
)
|
||||
|
||||
// DistroInfo contains all the information relating to a linux distribution
|
||||
@ -147,6 +151,10 @@ func parseOsRelease(osRelease string) *DistroInfo {
|
||||
result.Distribution = Deepin
|
||||
case "raspbian":
|
||||
result.Distribution = Raspbian
|
||||
case "opensuse-tumbleweed":
|
||||
result.Distribution = Tumbleweed
|
||||
case "opensuse-leap":
|
||||
result.Distribution = Leap
|
||||
default:
|
||||
result.Distribution = Unknown
|
||||
}
|
||||
|
@ -22,5 +22,25 @@ UBUNTU_CODENAME=bionic
|
||||
if result.Distribution != Ubuntu {
|
||||
t.Errorf("expected 'Ubuntu' ID but got '%d'", result.Distribution)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestTumbleweedDetection(t *testing.T) {
|
||||
osrelease := `
|
||||
NAME="openSUSE Tumbleweed"
|
||||
# VERSION="20200414"
|
||||
ID="opensuse-tumbleweed"
|
||||
ID_LIKE="opensuse suse"
|
||||
VERSION_ID="20200414"
|
||||
PRETTY_NAME="openSUSE Tumbleweed"
|
||||
ANSI_COLOR="0;32"
|
||||
CPE_NAME="cpe:/o:opensuse:tumbleweed:20200414"
|
||||
BUG_REPORT_URL="https://bugs.opensuse.org"
|
||||
HOME_URL="https://www.opensuse.org/"
|
||||
LOGO="distributor-logo"
|
||||
`
|
||||
|
||||
result := parseOsRelease(osrelease)
|
||||
if result.Distribution != Tumbleweed {
|
||||
t.Errorf("expected 'Tumbleweed' ID but got '%d'", result.Distribution)
|
||||
}
|
||||
}
|
||||
|
@ -223,3 +223,32 @@ distributions:
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
|
||||
opensuse-tumbleweed:
|
||||
id: opensuse-tumbleweed
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: openSUSE Tumbleweed
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs: &opensusedefaultprograms
|
||||
- name: gcc
|
||||
help: Please install with `sudo zypper in gcc-c++` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo zypper in pkgconf-pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install `sudo zypper in nodejs` and try again
|
||||
libraries: &opensusedefaultlibraries
|
||||
- name: gtk3-devel
|
||||
help: Please install with `sudo zypper in gtk3-devel` and try again
|
||||
- name: webkit2gtk3-devel
|
||||
help: Please install with `sudo zypper in webkit2gtk3-devel` and try again
|
||||
opensuse-leap:
|
||||
id: opensuse-leap
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: openSUSE Leap
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs: *opensusedefaultprograms
|
||||
libraries: *opensusedefaultlibraries
|
||||
|
113
cmd/package.go
113
cmd/package.go
@ -18,17 +18,19 @@ import (
|
||||
|
||||
// PackageHelper helps with the 'wails package' command
|
||||
type PackageHelper struct {
|
||||
fs *FSHelper
|
||||
log *Logger
|
||||
system *SystemHelper
|
||||
platform string
|
||||
fs *FSHelper
|
||||
log *Logger
|
||||
system *SystemHelper
|
||||
}
|
||||
|
||||
// NewPackageHelper creates a new PackageHelper!
|
||||
func NewPackageHelper() *PackageHelper {
|
||||
func NewPackageHelper(platform string) *PackageHelper {
|
||||
return &PackageHelper{
|
||||
fs: NewFSHelper(),
|
||||
log: NewLogger(),
|
||||
system: NewSystemHelper(),
|
||||
platform: platform,
|
||||
fs: NewFSHelper(),
|
||||
log: NewLogger(),
|
||||
system: NewSystemHelper(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,29 +65,30 @@ func defaultString(val string, defaultVal string) string {
|
||||
func (b *PackageHelper) getPackageFileBaseDir() string {
|
||||
// Calculate template base dir
|
||||
_, filename, _, _ := runtime.Caller(1)
|
||||
return filepath.Join(path.Dir(filename), "packages", runtime.GOOS)
|
||||
return filepath.Join(path.Dir(filename), "packages", b.platform)
|
||||
}
|
||||
|
||||
// Package the application into a platform specific package
|
||||
func (b *PackageHelper) Package(po *ProjectOptions) error {
|
||||
switch runtime.GOOS {
|
||||
switch b.platform {
|
||||
case "darwin":
|
||||
// Check we have the exe
|
||||
if !b.fs.FileExists(po.BinaryName) {
|
||||
return fmt.Errorf("cannot bundle non-existent binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
||||
}
|
||||
return b.packageOSX(po)
|
||||
case "windows":
|
||||
return b.PackageWindows(po, false)
|
||||
return b.PackageWindows(po, true)
|
||||
case "linux":
|
||||
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
||||
return b.packageLinux(po)
|
||||
default:
|
||||
return fmt.Errorf("platform '%s' not supported for bundling yet", runtime.GOOS)
|
||||
return fmt.Errorf("platform '%s' not supported for bundling yet", b.platform)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *PackageHelper) packageLinux(po *ProjectOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Package the application for OSX
|
||||
func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
build := path.Join(b.fs.Cwd(), "build")
|
||||
|
||||
system := NewSystemHelper()
|
||||
config, err := system.LoadConfig()
|
||||
@ -102,18 +105,25 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
appname := po.Name + ".app"
|
||||
|
||||
// Check binary exists
|
||||
source := path.Join(b.fs.Cwd(), exe)
|
||||
if !b.fs.FileExists(source) {
|
||||
// We need to build!
|
||||
return fmt.Errorf("Target '%s' not available. Has it been compiled yet?", exe)
|
||||
source := path.Join(build, exe)
|
||||
if po.CrossCompile == true {
|
||||
file, err := b.fs.FindFile(build, "darwin")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
source = path.Join(build, file)
|
||||
}
|
||||
|
||||
if !b.fs.FileExists(source) {
|
||||
// We need to build!
|
||||
return fmt.Errorf("Target '%s' not available. Has it been compiled yet?", source)
|
||||
}
|
||||
// Remove the existing package
|
||||
os.RemoveAll(appname)
|
||||
|
||||
exeDir := path.Join(b.fs.Cwd(), appname, "/Contents/MacOS")
|
||||
exeDir := path.Join(build, appname, "/Contents/MacOS")
|
||||
b.fs.MkDirs(exeDir, 0755)
|
||||
resourceDir := path.Join(b.fs.Cwd(), appname, "/Contents/Resources")
|
||||
resourceDir := path.Join(build, appname, "/Contents/Resources")
|
||||
b.fs.MkDirs(resourceDir, 0755)
|
||||
tmpl := template.New("infoPlist")
|
||||
plistFile := filepath.Join(b.getPackageFileBaseDir(), "info.plist")
|
||||
@ -129,7 +139,7 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filename := path.Join(b.fs.Cwd(), appname, "Contents", "Info.plist")
|
||||
filename := path.Join(build, appname, "Contents", "Info.plist")
|
||||
err = ioutil.WriteFile(filename, tpl.Bytes(), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -150,12 +160,25 @@ func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// CleanWindows removes any windows related files found in the directory
|
||||
func (b *PackageHelper) CleanWindows(po *ProjectOptions) {
|
||||
pdir := b.fs.Cwd()
|
||||
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||
exts := []string{".ico", ".exe.manifest", ".rc", "-res.syso"}
|
||||
rsrcs := []string{}
|
||||
for _, ext := range exts {
|
||||
rsrcs = append(rsrcs, filepath.Join(pdir, basename+ext))
|
||||
}
|
||||
b.fs.RemoveFiles(rsrcs, true)
|
||||
}
|
||||
|
||||
// PackageWindows packages the application for windows platforms
|
||||
func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
outputDir := b.fs.Cwd()
|
||||
basename := strings.TrimSuffix(po.BinaryName, ".exe")
|
||||
|
||||
// Copy icon
|
||||
tgtIconFile := filepath.Join(b.fs.Cwd(), basename+".ico")
|
||||
tgtIconFile := filepath.Join(outputDir, basename+".ico")
|
||||
if !b.fs.FileExists(tgtIconFile) {
|
||||
srcIconfile := filepath.Join(b.getPackageFileBaseDir(), "wails.ico")
|
||||
err := b.fs.CopyFile(srcIconfile, tgtIconFile)
|
||||
@ -165,7 +188,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
}
|
||||
|
||||
// Copy manifest
|
||||
tgtManifestFile := filepath.Join(b.fs.Cwd(), basename+".exe.manifest")
|
||||
tgtManifestFile := filepath.Join(outputDir, basename+".exe.manifest")
|
||||
if !b.fs.FileExists(tgtManifestFile) {
|
||||
srcManifestfile := filepath.Join(b.getPackageFileBaseDir(), "wails.exe.manifest")
|
||||
err := b.fs.CopyFile(srcManifestfile, tgtManifestFile)
|
||||
@ -175,7 +198,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
}
|
||||
|
||||
// Copy rc file
|
||||
tgtRCFile := filepath.Join(b.fs.Cwd(), basename+".rc")
|
||||
tgtRCFile := filepath.Join(outputDir, basename+".rc")
|
||||
if !b.fs.FileExists(tgtRCFile) {
|
||||
srcRCfile := filepath.Join(b.getPackageFileBaseDir(), "wails.rc")
|
||||
rcfilebytes, err := ioutil.ReadFile(srcRCfile)
|
||||
@ -190,29 +213,33 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
}
|
||||
|
||||
// Build syso
|
||||
sysofile := filepath.Join(b.fs.Cwd(), basename+"-res.syso")
|
||||
sysofile := filepath.Join(outputDir, basename+"-res.syso")
|
||||
|
||||
batfile, err := fs.LocalDir(".")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// cross-compile
|
||||
if b.platform != runtime.GOOS {
|
||||
args := []string{
|
||||
"docker", "run", "--rm",
|
||||
"-v", outputDir + ":/build",
|
||||
"--entrypoint", "/bin/sh",
|
||||
"wailsapp/xgo:latest",
|
||||
"-c", "/usr/bin/x86_64-w64-mingw32-windres -o /build/" + basename + "-res.syso /build/" + basename + ".rc",
|
||||
}
|
||||
if err := NewProgramHelper().RunCommandArray(args); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
batfile, err := fs.LocalDir(".")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
windresBatFile := filepath.Join(batfile.fullPath, "windres.bat")
|
||||
windresCommand := []string{windresBatFile, sysofile, tgtRCFile}
|
||||
err = NewProgramHelper().RunCommandArray(windresCommand)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// clean up
|
||||
if cleanUp {
|
||||
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile, sysofile}
|
||||
err := b.fs.RemoveFiles(filesToDelete)
|
||||
windresBatFile := filepath.Join(batfile.fullPath, "windres.bat")
|
||||
windresCommand := []string{windresBatFile, sysofile, tgtRCFile}
|
||||
err = NewProgramHelper().RunCommandArray(windresCommand)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict>
|
||||
<key>CFBundlePackageType</key><string>APPL</string>
|
||||
<key>CFBundleName</key><string>{{.Title}}</string>
|
||||
<key>CFBundleExecutable</key><string>{{.Exe}}</string>
|
||||
<key>CFBundleIdentifier</key><string>{{.PackageID}}</string>
|
||||
|
@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -11,14 +12,22 @@ import (
|
||||
|
||||
// ProgramHelper - Utility functions around installed applications
|
||||
type ProgramHelper struct {
|
||||
shell *ShellHelper
|
||||
shell *ShellHelper
|
||||
verbose bool
|
||||
}
|
||||
|
||||
// NewProgramHelper - Creates a new ProgramHelper
|
||||
func NewProgramHelper() *ProgramHelper {
|
||||
return &ProgramHelper{
|
||||
func NewProgramHelper(verbose ...bool) *ProgramHelper {
|
||||
result := &ProgramHelper{
|
||||
shell: NewShellHelper(),
|
||||
}
|
||||
if len(verbose) > 0 {
|
||||
result.verbose = verbose[0]
|
||||
if result.verbose {
|
||||
result.shell.SetVerbose()
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// IsInstalled tries to determine if the given binary name is installed
|
||||
@ -29,8 +38,9 @@ func (p *ProgramHelper) IsInstalled(programName string) bool {
|
||||
|
||||
// Program - A struct to define an installed application/binary
|
||||
type Program struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
verbose bool
|
||||
}
|
||||
|
||||
// FindProgram attempts to find the given program on the system.FindProgram
|
||||
@ -45,8 +55,9 @@ func (p *ProgramHelper) FindProgram(programName string) *Program {
|
||||
return nil
|
||||
}
|
||||
return &Program{
|
||||
Name: programName,
|
||||
Path: path,
|
||||
Name: programName,
|
||||
Path: path,
|
||||
verbose: p.verbose,
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,12 +74,18 @@ func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err
|
||||
return "", "", 1, err
|
||||
}
|
||||
cmd := exec.Command(command, vars...)
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
if !p.verbose {
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
} else {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/10385551/get-exit-code-go
|
||||
if err != nil {
|
||||
@ -121,11 +138,11 @@ func (p *ProgramHelper) RunCommand(command string) error {
|
||||
|
||||
// RunCommandArray runs the command specified in the array
|
||||
func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
||||
program := args[0]
|
||||
programCommand := args[0]
|
||||
// TODO: Run FindProgram here and get the full path to the exe
|
||||
program, err := exec.LookPath(program)
|
||||
program, err := exec.LookPath(programCommand)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", program)
|
||||
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", programCommand)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@ -158,6 +157,10 @@ type ProjectOptions struct {
|
||||
selectedTemplate *TemplateDetails
|
||||
WailsVersion string
|
||||
typescriptDefsFilename string
|
||||
Verbose bool `json:"-"`
|
||||
CrossCompile bool
|
||||
Platform string
|
||||
Architecture string
|
||||
}
|
||||
|
||||
// Defaults sets the default project template
|
||||
@ -332,11 +335,6 @@ func processBinaryName(po *ProjectOptions) {
|
||||
if po.BinaryName == "" {
|
||||
var binaryNameComputed = computeBinaryName(po.Name)
|
||||
po.BinaryName = Prompt("The output binary name", binaryNameComputed)
|
||||
if runtime.GOOS == "windows" {
|
||||
if !strings.HasSuffix(po.BinaryName, ".exe") {
|
||||
po.BinaryName += ".exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("Output binary Name: " + po.BinaryName)
|
||||
}
|
||||
|
42
cmd/shell.go
42
cmd/shell.go
@ -8,6 +8,7 @@ import (
|
||||
|
||||
// ShellHelper helps with Shell commands
|
||||
type ShellHelper struct {
|
||||
verbose bool
|
||||
}
|
||||
|
||||
// NewShellHelper creates a new ShellHelper!
|
||||
@ -15,16 +16,27 @@ func NewShellHelper() *ShellHelper {
|
||||
return &ShellHelper{}
|
||||
}
|
||||
|
||||
// SetVerbose sets the verbose flag
|
||||
func (sh *ShellHelper) SetVerbose() {
|
||||
sh.verbose = true
|
||||
}
|
||||
|
||||
// Run the given command
|
||||
func (sh *ShellHelper) Run(command string, vars ...string) (stdout, stderr string, err error) {
|
||||
cmd := exec.Command(command, vars...)
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
if !sh.verbose {
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
} else {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -33,11 +45,17 @@ func (sh *ShellHelper) RunInDirectory(dir string, command string, vars ...string
|
||||
cmd := exec.Command(command, vars...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
if !sh.verbose {
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
} else {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
libraryChecker = DpkgInstalled
|
||||
case Arch, ArcoLinux, Manjaro, ManjaroARM:
|
||||
libraryChecker = PacmanInstalled
|
||||
case CentOS, Fedora:
|
||||
case CentOS, Fedora, Tumbleweed, Leap:
|
||||
libraryChecker = RpmInstalled
|
||||
case Gentoo:
|
||||
libraryChecker = EqueryInstalled
|
||||
|
@ -4,12 +4,12 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"core-js": "^3.1.4",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"core-js": "^3.6.4",
|
||||
"react": "^16.13.0",
|
||||
"react-dom": "^16.13.0",
|
||||
"wails-react-scripts": "3.0.1-2",
|
||||
"react-modal": "3.8.1",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
"react-modal": "3.11.2",
|
||||
"@wailsapp/runtime": "^1.0.10"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
@ -8,21 +8,21 @@
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.1",
|
||||
"core-js": "^3.6.4",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"vue": "^2.5.22",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
"vue": "^2.6.11",
|
||||
"@wailsapp/runtime": "^1.0.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.4.0",
|
||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
||||
"@vue/cli-service": "^3.4.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"@vue/cli-plugin-babel": "^4.2.3",
|
||||
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-vue": "^6.2.1",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"vue-template-compiler": "^2.5.21",
|
||||
"webpack-hot-middleware": "^2.24.3"
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"webpack-hot-middleware": "^2.25.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
@ -7,24 +7,24 @@
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.1",
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.4",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"material-design-icons-iconfont": "^5.0.1",
|
||||
"vue": "^2.5.22",
|
||||
"vuetify": "^1.5.14",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
"@wailsapp/runtime": "^1.0.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.4.0",
|
||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
||||
"@vue/cli-service": "^3.4.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"@vue/cli-plugin-babel": "^4.2.3",
|
||||
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-vue": "^6.2.1",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"vue-template-compiler": "^2.5.21",
|
||||
"webpack-hot-middleware": "^2.24.3"
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"webpack-hot-middleware": "^2.25.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
@ -8,23 +8,23 @@
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.1",
|
||||
"core-js": "^3.6.4",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"vue": "^2.5.22",
|
||||
"vuetify": "^2.0.15",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
"vue": "^2.6.11",
|
||||
"vuetify": "^2.2.15",
|
||||
"@wailsapp/runtime": "^1.0.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdi/font": "^4.3.95",
|
||||
"@vue/cli-plugin-babel": "^3.4.0",
|
||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
||||
"@vue/cli-service": "^3.4.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"@mdi/font": "^4.9.95",
|
||||
"@vue/cli-plugin-babel": "^4.2.3",
|
||||
"@vue/cli-plugin-eslint": "^4.2.3",
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-vue": "^6.2.1",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"vue-template-compiler": "^2.5.21",
|
||||
"webpack-hot-middleware": "^2.24.3"
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"webpack-hot-middleware": "^2.25.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
|
||||
// Version - Wails version
|
||||
const Version = "v1.0.2"
|
||||
const Version = "v1.5.0"
|
||||
|
@ -40,7 +40,7 @@ Create your first project by running 'wails init'.`
|
||||
}
|
||||
|
||||
// Check Mewn
|
||||
err = cmd.CheckMewn()
|
||||
err = cmd.CheckMewn(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -3,17 +3,32 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
)
|
||||
|
||||
// getSupportedPlatforms returns a slice of platform/architecture
|
||||
// targets that are buildable using the cross-platform 'x' option.
|
||||
func getSupportedPlatforms() []string {
|
||||
return []string{
|
||||
"darwin/amd64",
|
||||
"linux/amd64",
|
||||
"linux/arm-7",
|
||||
"windows/amd64",
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
var packageApp = false
|
||||
var forceRebuild = false
|
||||
var debugMode = false
|
||||
var typescriptFilename = ""
|
||||
var verbose = false
|
||||
var platform = ""
|
||||
|
||||
buildSpinner := spinner.NewSpinner()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
@ -24,8 +39,17 @@ func init() {
|
||||
BoolFlag("p", "Package application on successful build", &packageApp).
|
||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild).
|
||||
BoolFlag("d", "Build in Debug mode", &debugMode).
|
||||
BoolFlag("verbose", "Verbose output", &verbose).
|
||||
StringFlag("t", "Generate Typescript definitions to given file (at runtime)", &typescriptFilename)
|
||||
|
||||
var b strings.Builder
|
||||
for _, plat := range getSupportedPlatforms() {
|
||||
fmt.Fprintf(&b, " - %s\n", plat)
|
||||
}
|
||||
initCmd.StringFlag("x",
|
||||
fmt.Sprintf("Cross-compile application to specified platform via xgo\n%s", b.String()),
|
||||
&platform)
|
||||
|
||||
initCmd.Action(func() error {
|
||||
|
||||
message := "Building Application"
|
||||
@ -40,6 +64,7 @@ func init() {
|
||||
|
||||
// Project options
|
||||
projectOptions := &cmd.ProjectOptions{}
|
||||
projectOptions.Verbose = verbose
|
||||
|
||||
// Check we are in project directory
|
||||
// Check project.json loads correctly
|
||||
@ -49,6 +74,25 @@ func init() {
|
||||
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
|
||||
}
|
||||
|
||||
// Set cross-compile
|
||||
projectOptions.Platform = runtime.GOOS
|
||||
if len(platform) > 0 {
|
||||
supported := false
|
||||
for _, plat := range getSupportedPlatforms() {
|
||||
if plat == platform {
|
||||
supported = true
|
||||
}
|
||||
}
|
||||
if !supported {
|
||||
return fmt.Errorf("Unsupported platform '%s' specified.\nPlease run `wails build -h` to see the supported platform/architecture options.", platform)
|
||||
}
|
||||
|
||||
projectOptions.CrossCompile = true
|
||||
plat := strings.Split(platform, "/")
|
||||
projectOptions.Platform = plat[0]
|
||||
projectOptions.Architecture = plat[1]
|
||||
}
|
||||
|
||||
// Validate config
|
||||
// Check if we have a frontend
|
||||
err = cmd.ValidateFrontendConfig(projectOptions)
|
||||
@ -90,7 +134,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Install dependencies
|
||||
err = cmd.InstallGoDependencies()
|
||||
err = cmd.InstallGoDependencies(projectOptions.Verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -10,12 +10,14 @@ import (
|
||||
func init() {
|
||||
|
||||
var forceRebuild = false
|
||||
var verbose = false
|
||||
buildSpinner := spinner.NewSpinner()
|
||||
buildSpinner.SetSpinSpeed(50)
|
||||
|
||||
commandDescription := `This command builds then serves your application in bridge mode. Useful for developing your app in a browser.`
|
||||
initCmd := app.Command("serve", "Run your Wails project in bridge mode").
|
||||
LongDescription(commandDescription).
|
||||
BoolFlag("verbose", "Verbose output", &verbose).
|
||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
|
||||
|
||||
initCmd.Action(func() error {
|
||||
@ -25,13 +27,14 @@ func init() {
|
||||
fmt.Println()
|
||||
|
||||
// Check Mewn is installed
|
||||
err := cmd.CheckMewn()
|
||||
err := cmd.CheckMewn(verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Project options
|
||||
projectOptions := &cmd.ProjectOptions{}
|
||||
projectOptions.Verbose = verbose
|
||||
|
||||
// Check we are in project directory
|
||||
// Check project.json loads correctly
|
||||
@ -51,7 +54,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Install dependencies
|
||||
err = cmd.InstallGoDependencies()
|
||||
err = cmd.InstallGoDependencies(projectOptions.Verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -3,9 +3,6 @@ module github.com/wailsapp/wails
|
||||
require (
|
||||
github.com/Masterminds/semver v1.4.2
|
||||
github.com/abadojack/whatlanggo v1.0.1
|
||||
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc // indirect
|
||||
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac
|
||||
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 // indirect
|
||||
github.com/fatih/color v1.7.0
|
||||
github.com/go-playground/colors v1.2.0
|
||||
github.com/gorilla/websocket v1.4.0
|
||||
|
8
go.sum
8
go.sum
@ -7,12 +7,6 @@ github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc h1:VBS1z48BFEe00G81z8MKOtwX7f/ISkuH38NscT8iVPw=
|
||||
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc/go.mod h1:ABJPuor7YlcsHmvJ1QxX38e2NcufLY3hm0yXv+cy9sI=
|
||||
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac h1:DpMwFluHWoZpV9ex5XjkWO4HyCz5HLVI8XbHw0FhHi4=
|
||||
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac/go.mod h1:XsAE+b4rOZc8gvgsgF+wU75mNBvBcyED1wdd9PBLlJ0=
|
||||
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 h1:Fm10/KNuoAyBm2P5P5H91Xy21hGcZnBdjR+cMdytv1M=
|
||||
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947/go.mod h1:Dv9D0NUlAsaQcGQZa5kc5mqR9ua72SmA8VXi4cd+cBw=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/go-playground/colors v1.2.0 h1:0EdjTXKrr2g1L/LQTYtIqabeHpZuGZz1U4osS1T8+5M=
|
||||
@ -34,8 +28,6 @@ github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/leaanthony/mewn v0.10.7 h1:jCcNJyIUOpwj+I5SuATvCugDjHkoo+j6ubEOxxrxmPA=
|
||||
github.com/leaanthony/mewn v0.10.7/go.mod h1:CRkTx8unLiSSilu/Sd7i1LwrdaAL+3eQ3ses99qGMEQ=
|
||||
github.com/leaanthony/slicer v1.3.2 h1:kGWWFoyaY5WzwGrUsHXMmGbssuYthP4qYBNlkNpNAB8=
|
||||
github.com/leaanthony/slicer v1.3.2/go.mod h1:VMB/HGvr3uR3MRpFWHWAm0w+DHQLzPHYe2pKfpFlQIQ=
|
||||
github.com/leaanthony/slicer v1.4.0 h1:Q9u4w+UBU4WHjXnEDdz+eRLMKF/rnyosRBiqULnc1J8=
|
||||
github.com/leaanthony/slicer v1.4.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||
github.com/leaanthony/spinner v0.5.3 h1:IMTvgdQCec5QA4qRy0wil4XsRP+QcG1OwLWVK/LPZ5Y=
|
||||
|
BIN
jetbrains-grayscale.png
Normal file
BIN
jetbrains-grayscale.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 KiB |
@ -42,12 +42,12 @@ type Bridge struct {
|
||||
server *http.Server
|
||||
|
||||
lock sync.Mutex
|
||||
sessions map[string]session
|
||||
sessions map[string]*session
|
||||
}
|
||||
|
||||
// Initialise the Bridge Renderer
|
||||
func (h *Bridge) Initialise(appConfig interfaces.AppConfig, ipcManager interfaces.IPCManager, eventManager interfaces.EventManager) error {
|
||||
h.sessions = map[string]session{}
|
||||
h.sessions = map[string]*session{}
|
||||
h.ipcManager = ipcManager
|
||||
h.appConfig = appConfig
|
||||
h.eventManager = eventManager
|
||||
@ -70,13 +70,11 @@ func (h *Bridge) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *Bridge) startSession(conn *websocket.Conn) {
|
||||
s := session{
|
||||
conn: conn,
|
||||
bindingCache: h.bindingCache,
|
||||
ipc: h.ipcManager,
|
||||
log: h.log,
|
||||
eventManager: h.eventManager,
|
||||
}
|
||||
s := newSession(conn,
|
||||
h.bindingCache,
|
||||
h.ipcManager,
|
||||
logger.NewCustomLogger("BridgeSession"),
|
||||
h.eventManager)
|
||||
|
||||
conn.SetCloseHandler(func(int, string) error {
|
||||
h.log.Infof("Connection dropped [%s].", s.Identifier())
|
||||
@ -160,7 +158,7 @@ func (h *Bridge) NotifyEvent(event *messages.EventData) error {
|
||||
}
|
||||
|
||||
message := fmt.Sprintf("window.wails._.Notify('%s','%s')", event.Name, data)
|
||||
dead := []session{}
|
||||
dead := []*session{}
|
||||
for _, session := range h.sessions {
|
||||
err := session.evalJS(message, notifyMessage)
|
||||
if err != nil {
|
||||
@ -207,6 +205,9 @@ func (h *Bridge) SetTitle(title string) {
|
||||
// for the Renderer interface
|
||||
func (h *Bridge) Close() {
|
||||
h.log.Debug("Shutting down")
|
||||
for _, session := range h.sessions {
|
||||
session.Shutdown()
|
||||
}
|
||||
err := h.server.Close()
|
||||
if err != nil {
|
||||
h.log.Errorf(err.Error())
|
||||
|
@ -1,7 +1,8 @@
|
||||
package renderer
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/leaanthony/mewn"
|
||||
@ -20,7 +21,22 @@ type session struct {
|
||||
ipc interfaces.IPCManager
|
||||
|
||||
// Mutex for writing to the socket
|
||||
lock sync.Mutex
|
||||
shutdown chan bool
|
||||
writeChan chan []byte
|
||||
|
||||
done bool
|
||||
}
|
||||
|
||||
func newSession(conn *websocket.Conn, bindingCache []string, ipc interfaces.IPCManager, logger *logger.CustomLogger, eventMgr interfaces.EventManager) *session {
|
||||
return &session{
|
||||
conn: conn,
|
||||
bindingCache: bindingCache,
|
||||
ipc: ipc,
|
||||
log: logger,
|
||||
eventManager: eventMgr,
|
||||
shutdown: make(chan bool),
|
||||
writeChan: make(chan []byte, 100),
|
||||
}
|
||||
}
|
||||
|
||||
// Identifier returns a string identifier for the remote connection.
|
||||
@ -33,19 +49,15 @@ func (s *session) Identifier() string {
|
||||
}
|
||||
|
||||
func (s *session) sendMessage(msg string) error {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if err := s.conn.WriteMessage(websocket.TextMessage, []byte(msg)); err != nil {
|
||||
s.log.Debug(err.Error())
|
||||
return err
|
||||
if !s.done {
|
||||
s.writeChan <- *(*[]byte)(unsafe.Pointer(&msg))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *session) start(firstSession bool) {
|
||||
s.log.Infof("Connected to frontend.")
|
||||
go s.writePump()
|
||||
|
||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||
s.evalJS(wailsRuntime, wailsRuntimeMessage)
|
||||
@ -74,6 +86,10 @@ func (s *session) start(firstSession bool) {
|
||||
s.log.Debugf("Got message: %#v\n", string(buffer))
|
||||
|
||||
s.ipc.Dispatch(string(buffer), s.Callback)
|
||||
|
||||
if s.done {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,8 +99,38 @@ func (s *session) Callback(data string) error {
|
||||
}
|
||||
|
||||
func (s *session) evalJS(js string, mtype messageType) error {
|
||||
|
||||
// Prepend message type to message
|
||||
return s.sendMessage(mtype.toString() + js)
|
||||
|
||||
}
|
||||
|
||||
// Shutdown
|
||||
func (s *session) Shutdown() {
|
||||
s.done = true
|
||||
s.shutdown <- true
|
||||
s.log.Debugf("session %v exit", s.Identifier())
|
||||
}
|
||||
|
||||
// writePump pulls messages from the writeChan and sends them to the client
|
||||
// since it uses a channel to read the messages the socket is protected without locks
|
||||
func (s *session) writePump() {
|
||||
s.log.Debugf("Session %v - writePump start", s.Identifier())
|
||||
for {
|
||||
select {
|
||||
case msg, ok := <-s.writeChan:
|
||||
s.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))
|
||||
if !ok {
|
||||
s.log.Debug("writeChan was closed!")
|
||||
s.conn.WriteMessage(websocket.CloseMessage, []byte{})
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.conn.WriteMessage(websocket.TextMessage, msg); err != nil {
|
||||
s.log.Debug(err.Error())
|
||||
return
|
||||
}
|
||||
case <-s.shutdown:
|
||||
break
|
||||
}
|
||||
}
|
||||
s.log.Debug("writePump exiting...")
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
2799
runtime/js/package-lock.json
generated
2799
runtime/js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wailsapp/runtime",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"description": "Wails Javascript runtime library",
|
||||
"main": "main.js",
|
||||
"types": "runtime.d.ts",
|
||||
@ -25,4 +25,4 @@
|
||||
"devDependencies": {
|
||||
"dts-gen": "^0.5.8"
|
||||
}
|
||||
}
|
||||
}
|
12
runtime/js/runtime/runtime.d.ts
vendored
12
runtime/js/runtime/runtime.d.ts
vendored
@ -6,12 +6,12 @@ declare const wailsapp__runtime: {
|
||||
OpenURL(url: string): Promise<any>;
|
||||
};
|
||||
Events: {
|
||||
Acknowledge(eventName: string): void;
|
||||
Emit(eventName: string): void;
|
||||
Heartbeat(eventName: string, timeInMilliseconds: number, callback: () => void): void;
|
||||
On(eventName: string, callback: () => void): void;
|
||||
OnMultiple(eventName: string, callback: () => void, maxCallbacks: number): void;
|
||||
Once(eventName: string, callback: () => void): void;
|
||||
Acknowledge(eventName: string): void;
|
||||
Emit(eventName: string, data?: any): void;
|
||||
Heartbeat(eventName: string, timeInMilliseconds: number, callback: (data?: any) => void): void;
|
||||
On(eventName: string, callback: (data?: any) => void): void;
|
||||
OnMultiple(eventName: string, callback: (data?: any) => void, maxCallbacks: number): void;
|
||||
Once(eventName: string, callback: (data?: any) => void): void;
|
||||
};
|
||||
Init(callback: () => void): void;
|
||||
Log: {
|
||||
|
@ -1,5 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "**** Checking if Wails passes unit tests ****"
|
||||
if ! go test ./...
|
||||
then
|
||||
echo ""
|
||||
echo "ERROR: Unit tests failed!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Build runtime
|
||||
echo "**** Building Runtime ****"
|
||||
cd runtime/js
|
||||
@ -15,9 +23,23 @@ cd lib/renderer
|
||||
mewn
|
||||
cd ../..
|
||||
|
||||
echo "**** Installing Wails locally ****"
|
||||
|
||||
cd cmd/wails
|
||||
go install
|
||||
echo "**** Checking if Wails compiles ****"
|
||||
if ! go build .
|
||||
then
|
||||
echo ""
|
||||
echo "ERROR: Build failed!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "**** Installing Wails locally ****"
|
||||
if ! go install
|
||||
then
|
||||
echo ""
|
||||
echo "ERROR: Install failed!"
|
||||
exit 1;
|
||||
fi
|
||||
cd ../..
|
||||
|
||||
echo "**** Tidying the mods! ****"
|
||||
|
Loading…
Reference in New Issue
Block a user