Compare commits

..

1 Commits

Author SHA1 Message Date
Lea Anthony c24aef8ea1 Initial commit. Need to fix userid write permission issues 2022-02-22 19:12:13 +11:00
1051 changed files with 34078 additions and 55127 deletions
+41
View File
@@ -0,0 +1,41 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
#####################################################
**V1 users: If you have a technical issue, please do not open a bug this way!**
Please use the `wails issue` command!
If you do not do this then the issue may be closed automatically.
NOTE: If your bug is related to Windows, make sure you read
the [Windows Developer Guide](https://wails.app/guides/windows/)
#####################################################
**Description**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behaviour:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behaviour**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**System Details**
V2 users: Please add the output of `wails doctor`.
**Additional context**
Add any other context about the problem here.
- [ ] This issue is for Windows and I have read the [Windows Developer Guide](https://wails.app/guides/windows/)
-81
View File
@@ -1,81 +0,0 @@
name: Bug Report
description: Create a report to help us improve
# title: ""
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
***Please note: No new bug reports are being accepted for Wails v1***
Before submitting this issue, please do the following:
- Do a web search for your error. This usually leads to a much better understanding of the issue.
- Prove that the error is indeed a Wails bug and not an application bug, with a specific set of steps to reproduce.
- Search both the issue tracker (even closed issues) and discussion forums.
- Try to fix it yourself. Keep a list of things you have done to fix the problem.
If after doing all the above, the problem remains, please continue with this ticket providing *all* the information requested.
Bug reports that do not follow these steps will likely be closed, so please help us to help you.
- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what the bug is.
placeholder: A clear and concise description of what the bug is.
# value: ""
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: To Reproduce
description: Steps to reproduce the behaviour
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: Expected behaviour
description: A clear and concise description of what you expected to happen.
placeholder: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem.
placeholder: If applicable, add screenshots to help explain your problem.
validations:
required: false
- type: textarea
id: attempted-fixes
attributes:
label: Attempted Fixes
description: A list of things you have tried to fix the problem, including search engine links.
placeholder: A list of things you have tried to fix the problem, including search engine links.
validations:
required: false
- type: textarea
id: systemetails
attributes:
label: System Details
description: Please add the output of `wails doctor`.
render: shell
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context about the problem here.
placeholder: Add any other context about the problem here.
validations:
required: false
-5
View File
@@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: GitHub Community Discussions
url: https://github.com/wailsapp/wails/discussions
about: If your question is not a feature or a bug, please go to the discussion panel and retrieve if your question already exists before submitting.
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -1,38 +0,0 @@
name: Feature request
description: Suggest an idea for this project
# title: ""
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
***Please note: No new feature requests are being accepted for Wails v1***
- type: textarea
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
validations:
required: false
- type: textarea
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
validations:
required: false
+1 -4
View File
@@ -8,7 +8,6 @@ exemptLabels:
- security
- onhold
- inprogress
- "Selected for development"
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
@@ -17,6 +16,4 @@ markComment: >
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
exemptMilestones: true
exemptAssignees: true
closeComment: false
-1
View File
@@ -31,4 +31,3 @@ v2/test/kitchensink/frontend/package.json.md5
!v2/internal/ffenestri/windows/x64/webview2.dll
!v2/internal/ffenestri/windows/x64/WebView2Loader.dll
.idea/
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
+121 -28
View File
@@ -1,5 +1,5 @@
<p align="center" style="text-align: center">
<img src="logo-universal.png" width="55%"><br/>
<img src="logo.png" width="55%"><br/>
</p>
<p align="center">
Build desktop applications using Go & Web Technologies.<br/><br/>
@@ -52,50 +52,53 @@
- [4. Features](#nav-4)
- [5. Sponsors](#nav-5)
- [6. Installation](#nav-6)
- [7. FAQ](#nav-8)
- [8. Contributors](#nav-9)
- [9. Special Mentions](#nav-10)
- [10. Special Thanks](#nav-11)
- [6.1 MacOS](#nav-6-1)
- [6.2 Linux](#nav-6-2)
- [6.2.1 Debian/Ubuntu](#nav-6-2-1)
- [6.2.2 Arch Linux / ArchLabs / Ctlos Linux](#nav-6-2-2)
- [6.2.3 Centos](#nav-6-2-3)
- [6.2.4 Fedora](#nav-6-2-4)
- [6.2.5 VoidLinux & VoidLinux-musl](#nav-6-2-5)
- [6.2.6 Gentoo](#nav-6-2-6)
- [6.3 Windows](#nav-6-3)
- [7. Usage](#nav-7)
- [7.1 Next Steps](#nav-7-1)
- [8. FAQ](#nav-8)
- [9. Contributors](#nav-9)
- [10. Special Mentions](#nav-10)
- [12. Special Thanks](#nav-11)
</details>
<span id="nav-3"></span>
## Introduction
## Introductions
The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different
approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to
make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative!
<span id="nav-3-1"></span>
<hr/>
<h3><strong>PLEASE NOTE: As we are approaching the v2 release, we are not accepting any new feature requests or bug reports for v1. If you have a critical issue, please open a ticket and state why it is critical.</strong></h3>
<hr/>
### Version 2
### Official Website
Wails v2 has been released in Beta for all 3 platforms. Check out the [new website](https://wails.io) if you are
interested in trying it out.
The official docs can be found at [https://wails.app](https://wails.app).
### Legacy v1 Website
The legacy v1 docs can be found at [https://wails.app](https://wails.app).
Click [here](https://wails.io) if you are interested in trying out v2 Beta for Windows.
<span id="nav-4"></span>
## Features
- Use standard Go for the backend
- Use any frontend technology you are already familiar with to build your UI
- Quickly create rich frontends for your Go programs using pre-built templates
- Easily call Go methods from Javascript
- Auto-generated Typescript definitions for your Go structs and methods
- Native Dialogs & Menus
- Supports modern translucency and "frosted window" effects
- Unified eventing system between Go and Javascript
- Powerful cli tool to quickly generate and build your projects
- Use any frontend technology to build your UI
- Quickly create Vue, Vuetify or React frontends for your Go programs
- Expose Go methods/functions to the frontend via a single bind command
- Uses native rendering engines - no embedded browser
- Shared events system
- Native file dialogs
- Powerful cli tool
- Multiplatform
- Uses native rendering engines - *no embedded browser*!
<span id="nav-5"></span>
@@ -120,6 +123,9 @@ This project is supported by these kind people / companies:
<a href="https://github.com/codydbentley" style="width:100px">
<img src="https://github.com/codydbentley.png?size=100" width="100"/>
</a>
<a href="https://github.com/CrackDavid" style="width:100px">
<img src="https://github.com/CrackDavid.png?size=100" width="100"/>
</a>
<a href="https://www.easywebadv.it/" style="width:100px">
<img src="website/static/img/easyweb.png" width="100"/>
</a>
@@ -194,15 +200,102 @@ This project is supported by these kind people / companies:
<a href="https://github.com/GargantuaX" style="width:45px">
<img src="https://github.com/GargantuaX.png?size=45" width="45"/>
</a>
<a href="https://github.com/brodyover" style="width:45px">
<img src="https://github.com/brodyover.png?size=45" width="45"/>
</a>
<span id="nav-6"></span>
## Installation
The installation instructions are on the [official website](https://wails.io/docs/gettingstarted/installation).
Wails uses cgo to bind to the native rendering engines so a number of platform dependent libraries are needed as well as
an installation of Go. The basic requirements are:
- Go 1.16
- npm
<span id="nav-6-1"></span>
### MacOS
Make sure you have the xcode command line tools installed. This can be done by running:
`xcode-select --install`
<span id="nav-6-2"></span>
### Linux
<span id="nav-6-2-1"></span>
#### Debian/Ubuntu
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
_Debian: 8, 9, 10_
_Ubuntu: 16.04, 18.04, 19.04_
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_, Pop!\_OS
<span id="nav-6-2-2"></span>
#### Arch Linux / ArchLabs / Ctlos Linux
`sudo pacman -S webkit2gtk gtk3`
_Also succesfully test on: Manjaro & ArcoLinux_
<span id="nav-6-2-3"></span>
#### Centos
`sudo yum install webkitgtk3-devel gtk3-devel`
_CentOS 6, 7_
<span id="nav-6-2-4"></span>
#### Fedora
`sudo yum install webkit2gtk3-devel gtk3-devel`
_Fedora 29, 30_
<span id="nav-6-2-5"></span>
#### VoidLinux & VoidLinux-musl
`xbps-install gtk+3-devel webkit2gtk-devel`
<span id="nav-6-2-6"></span>
#### Gentoo
`sudo emerge gtk+:3 webkit-gtk`
<span id="nav-6-3"></span>
### Windows
Windows requires gcc and related tooling. The recommended download is
from [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download). Once this is installed, you are good to
go.
<span id="nav-7"></span>
## Usage
**Ensure Go modules are enabled: GO111MODULE=on and go/bin is in your PATH variable.**
Installation is as simple as running the following command:
```
go get -u github.com/wailsapp/wails/cmd/wails
```
<span id="nav-7-1"></span>
### Next Steps
It is recommended at this stage to read the comprehensive documentation at [https://wails.app](https://wails.app).
<span id="nav-8"></span>
+6 -9
View File
@@ -1,5 +1,5 @@
<p align="center" style="text-align: center">
<img src="logo-universal.png" width="55%"><br/>
<img src="logo.png" width="55%"><br/>
</p>
<p align="center">
使用 Go 和 Web 技术构建桌面应用程序。<br/><br/>
@@ -81,13 +81,9 @@
### 官方网站
#### v1
官方文档可以在 [https://wails.app](https://wails.app) 中找到。
#### v2
Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝试一下,请查看[新网站](https://wails.io)。
如果您对适用于 Windows 的 v2 测试版感兴趣,可以点击[此处](https://wails.io)查看。
镜像网站:
@@ -130,6 +126,9 @@ Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝
<a href="https://github.com/codydbentley" style="width:100px">
<img src="https://github.com/codydbentley.png?size=100" width="100"/>
</a>
<a href="https://github.com/CrackDavid" style="width:100px">
<img src="https://github.com/CrackDavid.png?size=100" width="100"/>
</a>
<a href="https://www.easywebadv.it/" style="width:100px">
<img src="website/static/img/easyweb.png" width="100"/>
</a>
@@ -204,9 +203,7 @@ Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝
<a href="https://github.com/GargantuaX" style="width:45px">
<img src="https://github.com/GargantuaX.png?size=45" width="45"/>
</a>
<a href="https://github.com/brodyover" style="width:45px">
<img src="https://github.com/brodyover.png?size=45" width="45"/>
</a>
<span id="nav-6"></span>
## 安装
Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

+15 -15
View File
@@ -1461,9 +1461,9 @@
"dev": true
},
"ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
},
"ansi-styles": {
@@ -2297,9 +2297,9 @@
},
"dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"strip-ansi": {
@@ -4385,9 +4385,9 @@
}
},
"minimist": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"mississippi": {
@@ -5605,9 +5605,9 @@
},
"dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"strip-ansi": {
@@ -6535,9 +6535,9 @@
},
"dependencies": {
"ansi-regex": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"ansi-styles": {
+23 -63
View File
@@ -93,12 +93,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
debug := false
command.BoolFlag("debug", "Retains debug data in the compiled application", &debug)
nsis := false
command.BoolFlag("nsis", "Generate NSIS installer for Windows", &nsis)
trimpath := false
command.BoolFlag("trimpath", "Remove all file system paths from the resulting executable", &trimpath)
command.Action(func() error {
quiet := verbosity == 0
@@ -123,12 +117,20 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
}
// Tags
experimental := false
userTags := []string{}
for _, tag := range strings.Split(tags, " ") {
thisTag := strings.TrimSpace(tag)
if thisTag != "" {
userTags = append(userTags, thisTag)
}
if thisTag == "exp" {
experimental = true
}
}
if runtime.GOOS == "linux" && !experimental {
return fmt.Errorf("Linux version coming soon!")
}
// Webview2 installer strategy (download by default)
@@ -179,7 +181,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
CompressFlags: compressFlags,
UserTags: userTags,
WebView2Strategy: wv2rtstrategy,
TrimPath: trimpath,
}
// Start a new tabwriter
@@ -187,24 +188,21 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
w.Init(os.Stdout, 8, 8, 0, '\t', 0)
// Write out the system information
_, _ = fmt.Fprintf(w, "App Type: \t%s\n", buildOptions.OutputType)
_, _ = fmt.Fprintf(w, "Platforms: \t%s\n", platform)
_, _ = fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath)
_, _ = fmt.Fprintf(w, "Build Mode: \t%s\n", modeString)
_, _ = fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend)
_, _ = fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
_, _ = fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
_, _ = fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
_, _ = fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
_, _ = fmt.Fprintf(w, "Tags: \t[%s]\n", strings.Join(buildOptions.UserTags, ","))
fmt.Fprintf(w, "App Type: \t%s\n", buildOptions.OutputType)
fmt.Fprintf(w, "Platforms: \t%s\n", platform)
fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath)
fmt.Fprintf(w, "Build Mode: \t%s\n", modeString)
fmt.Fprintf(w, "Skip Frontend: \t%t\n", skipFrontend)
fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
fmt.Fprintf(w, "Tags: \t[%s]\n", strings.Join(buildOptions.UserTags, ","))
if len(buildOptions.OutputFile) > 0 && targets.Length() == 1 {
_, _ = fmt.Fprintf(w, "Output File: \t%s\n", buildOptions.OutputFile)
}
_, _ = fmt.Fprintf(w, "\n")
err = w.Flush()
if err != nil {
return err
fmt.Fprintf(w, "Output File: \t%s\n", buildOptions.OutputFile)
}
fmt.Fprintf(w, "\n")
w.Flush()
err = checkGoModVersion(logger, updateGoMod)
if err != nil {
@@ -216,9 +214,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
return err
}
projectOptions, err := project.Load(cwd)
if err != nil {
return err
}
// Check platform
validPlatformArch := slicer.String([]string{
@@ -232,18 +227,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
"windows",
"windows/amd64",
"windows/arm64",
"windows/386",
})
outputBinaries := map[string]string{}
// Allows cancelling the build after the first error. It would be nice if targets.Each would support funcs
// returning an error.
var targetErr error
targets.Each(func(platform string) {
if targetErr != nil {
return
}
if !validPlatformArch.Contains(platform) {
buildOptions.Logger.Println("platform '%s' is not supported - skipping. Supported platforms: %s", platform, validPlatformArch.Join(","))
@@ -278,11 +264,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
}
switch buildOptions.Platform {
case "linux":
if runtime.GOOS != "linux" {
logger.Println("Crosscompiling to Linux not currently supported.\n")
return
}
case "darwin":
if runtime.GOOS != "darwin" {
logger.Println("Crosscompiling to Mac not currently supported.\n")
@@ -310,44 +291,23 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
}
buildOptions.OutputFile = desiredFilename
if outputFilename != "" {
buildOptions.OutputFile = outputFilename
}
// Start Time
start := time.Now()
outputFilename, err := build.Build(buildOptions)
if err != nil {
logger.Println("Error: %s", err.Error())
targetErr = err
logger.Println("Error: ", err.Error())
return
}
// Subsequent iterations
buildOptions.IgnoreFrontend = true
buildOptions.CleanBuildDirectory = false
// Output stats
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.\n", outputFilename, time.Since(start).Round(time.Millisecond).String()))
outputBinaries[platform] = outputFilename
})
if targetErr != nil {
return targetErr
}
if nsis {
amd64Binary := outputBinaries["windows/amd64"]
arm64Binary := outputBinaries["windows/arm64"]
if amd64Binary == "" && arm64Binary == "" {
return fmt.Errorf("cannot build nsis installer - no windows targets")
}
if err := build.GenerateNSISInstaller(buildOptions, amd64Binary, arm64Binary); err != nil {
return err
}
}
return nil
})
}
+68 -81
View File
@@ -4,15 +4,13 @@ import (
"context"
"fmt"
"io"
"net"
"net/http"
"net/url"
"os"
"os/exec"
"os/signal"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
@@ -35,6 +33,8 @@ import (
"github.com/wailsapp/wails/v2/pkg/commands/build"
)
const defaultDevServerURL = "http://localhost:34115"
func LogGreen(message string, args ...interface{}) {
text := fmt.Sprintf(message, args...)
println(colour.Green(text))
@@ -72,11 +72,8 @@ type devFlags struct {
loglevel string
forceBuild bool
debounceMS int
devServer string
devServerURL string
appargs string
saveConfig bool
frontendDevServerURL string
}
// AddSubcommand adds the `dev` command for the Wails application
@@ -98,22 +95,28 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
command.StringFlag("loglevel", "Loglevel to use - Trace, Debug, Info, Warning, Error", &flags.loglevel)
command.BoolFlag("f", "Force build application", &flags.forceBuild)
command.IntFlag("debounce", "The amount of time to wait to trigger a reload on change", &flags.debounceMS)
command.StringFlag("devserver", "The address of the wails dev server", &flags.devServer)
command.StringFlag("frontenddevserverurl", "The url of the external frontend dev server to use", &flags.frontendDevServerURL)
command.StringFlag("devserverurl", "The url of the dev server to use", &flags.devServerURL)
command.StringFlag("appargs", "arguments to pass to the underlying app (quoted and space searated)", &flags.appargs)
command.BoolFlag("save", "Save given flags as defaults", &flags.saveConfig)
command.Action(func() error {
// Create logger
logger := clilogger.New(w)
app.PrintBanner()
experimental := false
userTags := []string{}
for _, tag := range strings.Split(flags.tags, " ") {
thisTag := strings.TrimSpace(tag)
if thisTag != "" {
userTags = append(userTags, thisTag)
}
if thisTag == "exp" {
experimental = true
}
}
if runtime.GOOS == "linux" && !experimental {
return fmt.Errorf("Linux version coming soon!")
}
cwd, err := os.Getwd()
@@ -126,16 +129,6 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
return err
}
devServer := flags.devServer
if _, _, err := net.SplitHostPort(devServer); err != nil {
return fmt.Errorf("DevServer is not of the form 'host:port', please check your wails.json")
}
devServerURL, err := url.Parse("http://" + devServer)
if err != nil {
return err
}
// Update go.mod to use current wails version
err = syncGoModVersion(cwd)
if err != nil {
@@ -143,21 +136,27 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
}
// Run go mod tidy to ensure we're up to date
err = runCommand(cwd, false, "go", "mod", "tidy", "-compat=1.17")
err = runCommand(cwd, false, "go", "mod", "tidy")
if err != nil {
return err
}
self := os.Args[0]
if flags.tags != "" {
err = runCommand(cwd, true, self, "generate", "module", "-tags", flags.tags)
err = runCommand(cwd, true, "wails", "generate", "module", "-tags", flags.tags)
} else {
err = runCommand(cwd, true, self, "generate", "module")
err = runCommand(cwd, true, "wails", "generate", "module")
}
if err != nil {
return err
}
// frontend:dev server command
if projectConfig.DevCommand != "" {
var devCommandWaitGroup sync.WaitGroup
closer := runFrontendDevCommand(cwd, projectConfig.DevCommand, &devCommandWaitGroup)
defer closer(&devCommandWaitGroup)
}
buildOptions := generateBuildOptions(flags)
buildOptions.Logger = logger
buildOptions.UserTags = internal.ParseUserTags(flags.tags)
@@ -179,16 +178,13 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
debugBinaryProcess = newProcess
}
// frontend:dev:watcher command.
if command := projectConfig.DevWatcherCommand; command != "" {
var devCommandWaitGroup sync.WaitGroup
closer := runFrontendDevWatcherCommand(cwd, command, &devCommandWaitGroup)
defer closer(&devCommandWaitGroup)
}
// open browser
if flags.openBrowser {
err = browser.OpenURL(devServerURL.String())
url := defaultDevServerURL
if flags.devServerURL != "" {
url = flags.devServerURL
}
err = browser.OpenURL(url)
if err != nil {
return err
}
@@ -196,10 +192,6 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
// create the project files watcher
watcher, err := initialiseWatcher(cwd, logger.Fatal)
if err != nil {
return err
}
defer func(watcher *fsnotify.Watcher) {
err := watcher.Close()
if err != nil {
@@ -208,14 +200,11 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
}(watcher)
LogGreen("Watching (sub)/directory: %s", cwd)
LogGreen("Using DevServer URL: %s", devServerURL)
if flags.frontendDevServerURL != "" {
LogGreen("Using Frontend DevServer URL: %s", flags.frontendDevServerURL)
}
LogGreen("Using Dev Server URL: %s", flags.devServerURL)
LogGreen("Using reload debounce setting of %d milliseconds", flags.debounceMS)
// Watch for changes and trigger restartApp()
doWatcherLoop(buildOptions, debugBinaryProcess, flags, watcher, exitCodeChannel, quitChannel, devServerURL)
doWatcherLoop(buildOptions, debugBinaryProcess, flags, watcher, exitCodeChannel, quitChannel)
// Kill the current program if running
if debugBinaryProcess != nil {
@@ -266,7 +255,6 @@ func runCommand(dir string, exitOnError bool, command string, args ...string) er
output, err := cmd.CombinedOutput()
if err != nil {
println(string(output))
println(err.Error())
if exitOnError {
os.Exit(1)
}
@@ -278,6 +266,7 @@ func runCommand(dir string, exitOnError bool, command string, args ...string) er
// defaultDevFlags generates devFlags with default options
func defaultDevFlags() devFlags {
return devFlags{
devServerURL: defaultDevServerURL,
compilerCommand: "go",
verbosity: 1,
extensions: "go",
@@ -312,12 +301,15 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
return nil, err
}
var shouldSaveConfig bool
if flags.assetDir == "" && projectConfig.AssetDirectory != "" {
flags.assetDir = projectConfig.AssetDirectory
}
if flags.assetDir != projectConfig.AssetDirectory {
projectConfig.AssetDirectory = filepath.ToSlash(flags.assetDir)
shouldSaveConfig = true
}
if flags.assetDir != "" {
@@ -333,14 +325,16 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
if flags.reloadDirs != projectConfig.ReloadDirectories {
projectConfig.ReloadDirectories = filepath.ToSlash(flags.reloadDirs)
shouldSaveConfig = true
}
if flags.devServer == "" && projectConfig.DevServer != "" {
flags.devServer = projectConfig.DevServer
if flags.devServerURL == defaultDevServerURL && projectConfig.DevServerURL != defaultDevServerURL && projectConfig.DevServerURL != "" {
flags.devServerURL = projectConfig.DevServerURL
}
if flags.frontendDevServerURL == "" && projectConfig.FrontendDevServerURL != "" {
flags.frontendDevServerURL = projectConfig.FrontendDevServerURL
if flags.devServerURL != projectConfig.DevServerURL {
projectConfig.DevServerURL = flags.devServerURL
shouldSaveConfig = true
}
if flags.wailsjsdir == "" && projectConfig.WailsJSDir != "" {
@@ -353,6 +347,7 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
if flags.wailsjsdir != projectConfig.WailsJSDir {
projectConfig.WailsJSDir = filepath.ToSlash(flags.wailsjsdir)
shouldSaveConfig = true
}
if flags.debounceMS == 100 && projectConfig.DebounceMS != 100 {
@@ -364,13 +359,14 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
if flags.debounceMS != projectConfig.DebounceMS {
projectConfig.DebounceMS = flags.debounceMS
shouldSaveConfig = true
}
if flags.appargs == "" && projectConfig.AppArgs != "" {
flags.appargs = projectConfig.AppArgs
}
if flags.saveConfig {
if shouldSaveConfig {
err = projectConfig.Save()
if err != nil {
return nil, err
@@ -380,9 +376,9 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
return projectConfig, nil
}
// runFrontendDevWatcherCommand will run the `frontend:dev:watcher` command if it was given, ex- `npm run dev`
func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGroup) func(group *sync.WaitGroup) {
LogGreen("Running frontend dev watcher command: '%s'", devCommand)
// runFrontendDevCommand will run the `frontend:dev` command if it was given, ex- `npm run dev`
func runFrontendDevCommand(cwd string, devCommand string, wg *sync.WaitGroup) func(group *sync.WaitGroup) {
LogGreen("Running frontend dev command: '%s'", devCommand)
ctx, cancel := context.WithCancel(context.Background())
dir := filepath.Join(cwd, "frontend")
cmdSlice := strings.Split(devCommand, " ")
@@ -391,8 +387,6 @@ func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGr
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Dir = dir
setParentGID(cmd)
go func(ctx context.Context, devCommand string, cwd string, wg *sync.WaitGroup) {
err := cmd.Run()
if err != nil {
@@ -405,9 +399,23 @@ func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGr
}(ctx, devCommand, cwd, wg)
return func(wg *sync.WaitGroup) {
killProc(cmd, devCommand)
LogGreen("Dev command killed!")
cancel()
if runtime.GOOS == "windows" {
// Credit: https://stackoverflow.com/a/44551450
// For whatever reason, killing an npm script on windows just doesn't exit properly with cancel
if cmd != nil && cmd.Process != nil {
kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
kill.Stderr = os.Stderr
kill.Stdout = os.Stdout
err := kill.Run()
if err != nil {
if err.Error() != "exit status 1" {
LogRed("Error from '%s': %s", devCommand, err.Error())
}
}
}
} else {
cancel()
}
wg.Wait()
}
}
@@ -431,10 +439,6 @@ func initialiseWatcher(cwd string, logFatal func(string, ...interface{})) (*fsno
return
}
// Ignore build directory
if strings.Contains(dir, ".git") {
return
}
// Ignore build directory
if strings.HasPrefix(dir, filepath.Join(cwd, "build")) {
return
}
@@ -482,8 +486,7 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
// Set environment variables accordingly
os.Setenv("loglevel", flags.loglevel)
os.Setenv("assetdir", flags.assetDir)
os.Setenv("devserver", flags.devServer)
os.Setenv("frontenddevserverurl", flags.frontendDevServerURL)
os.Setenv("devserverurl", flags.devServerURL)
// Start up new binary with correct args
newProcess := process.NewProcess(appBinary, args...)
@@ -503,7 +506,7 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
}
// doWatcherLoop is the main watch loop that runs while dev is active
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, flags devFlags, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL) {
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, flags devFlags, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal) {
// Main Loop
var (
err error
@@ -530,9 +533,6 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
reload := false
assetDir := ""
changedPaths := map[string]struct{}{}
assetDirURL := joinPath(devServerURL, "/wails/assetdir")
reloadURL := joinPath(devServerURL, "/wails/reload")
for quit == false {
//reload := false
select {
@@ -540,8 +540,6 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
if exitCode == 0 {
quit = true
}
case err := <-watcher.Errors:
LogDarkYellow(err.Error())
case item := <-watcher.Events:
// Check for file writes
if item.Op&fsnotify.Write == fsnotify.Write {
@@ -599,19 +597,14 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
LogRed("Error during build: %s", err.Error())
continue
}
// If we have a new process, saveConfig it
// If we have a new process, save it
if newBinaryProcess != nil {
debugBinaryProcess = newBinaryProcess
}
}
if flags.frontendDevServerURL != "" {
// If we are using an external dev server all the reload of the frontend part can be skipped
continue
}
if len(changedPaths) != 0 {
if assetDir == "" {
resp, err := http.Get(assetDirURL)
resp, err := http.Get("http://localhost:34115/wails/assetdir")
if err != nil {
LogRed("Error during retrieving assetdir: %s", err.Error())
} else {
@@ -640,7 +633,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
}
if reload {
reload = false
_, err = http.Get(reloadURL)
_, err = http.Get("http://localhost:34115/wails/reload")
if err != nil {
LogRed("Error during refresh: %s", err.Error())
}
@@ -651,9 +644,3 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
}
}
}
func joinPath(url *url.URL, subPath string) string {
u := *url
u.Path = path.Join(u.Path, subPath)
return u.String()
}
@@ -1,30 +0,0 @@
//go:build darwin || linux
// +build darwin linux
package dev
import (
"os/exec"
"syscall"
)
func setParentGID(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}
}
func killProc(cmd *exec.Cmd, devCommand string) {
// Experiencing the same issue on macOS BigSur
// I'm using Vite, but I would imagine this could be an issue with Node (npm) in general
// Also, after several edit/rebuild cycles any abnormal shutdown (crash or CTRL-C) may still leave Node running
// Credit: https://stackoverflow.com/a/29552044/14764450 (same page as the Windows solution above)
// Not tested on *nix
pgid, err := syscall.Getpgid(cmd.Process.Pid)
if err == nil {
err := syscall.Kill(-pgid, 15) // note the minus sign
if err != nil {
LogRed("Error from '%s' when attempting to kill the process: %s", devCommand, err.Error())
}
}
}
@@ -1,28 +0,0 @@
//go:build windows
// +build windows
package dev
import (
"os"
"os/exec"
"strconv"
)
func setParentGID(_ *exec.Cmd) {}
func killProc(cmd *exec.Cmd, devCommand string) {
// Credit: https://stackoverflow.com/a/44551450
// For whatever reason, killing an npm script on windows just doesn't exit properly with cancel
if cmd != nil && cmd.Process != nil {
kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(cmd.Process.Pid))
kill.Stderr = os.Stderr
kill.Stdout = os.Stdout
err := kill.Run()
if err != nil {
if err.Error() != "exit status 1" {
LogRed("Error from '%s': %s", devCommand, err.Error())
}
}
}
}
@@ -53,14 +53,6 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
fmt.Fprintf(w, "%s\t%s\n", "Platform:", runtime.GOOS)
fmt.Fprintf(w, "%s\t%s\n", "Architecture:", runtime.GOARCH)
// Write out the wails information
fmt.Fprintf(w, "\n")
fmt.Fprintf(w, "Wails\n")
fmt.Fprintf(w, "------\n")
fmt.Fprintf(w, "%s\t%s\n", "Version: ", app.Version())
printBuildSettings(w)
// Exit early if PM not found
if info.PM != nil {
fmt.Fprintf(w, "%s\t%s\n", "Package Manager: ", info.PM.Name())
@@ -141,11 +133,21 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
if dependenciesAvailableOptional != 0 {
logger.Println("Optional package(s) installation details: \n" + info.Dependencies.InstallAllOptionalCommand())
}
//
//if len(externalPackages) > 0 {
// for _, p := range externalPackages {
// if p.Optional {
// print("[Optional] ")
// }
// logger.Println("Install " + p.Name + ": " + p.InstallCommand)
// }
//}
if len(dependenciesMissing) != 0 {
// TODO: Check if apps are available locally and if so, adjust the diagnosis
logger.Println("Fatal:")
logger.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " "))
logger.Println("Please read this article on how to resolve this: https://wails.io/guides/resolving-missing-packages")
logger.Println("Please read this article on how to resolve this: https://wails.app/guides/resolving-missing-packages")
}
logger.Println("")
@@ -1,10 +0,0 @@
//go:build !go1.18
// +build !go1.18
package doctor
import "text/tabwriter"
func printBuildSettings(_ *tabwriter.Writer) {
return
}
@@ -1,27 +0,0 @@
//go:build go1.18
// +build go1.18
package doctor
import (
"fmt"
"runtime/debug"
"text/tabwriter"
)
func printBuildSettings(w *tabwriter.Writer) {
if buildInfo, _ := debug.ReadBuildInfo(); buildInfo != nil {
buildSettingToName := map[string]string{
"vcs.revision": "Revision",
"vcs.modified": "Modified",
}
for _, buildSetting := range buildInfo.Settings {
name := buildSettingToName[buildSetting.Key]
if name == "" {
continue
}
fmt.Fprintf(w, "%s:\t%s\n", name, buildSetting.Value)
}
}
}
@@ -2,15 +2,14 @@ package generate
import (
"fmt"
"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"
"github.com/leaanthony/clir"
"github.com/wailsapp/wails/v2/cmd/wails/internal"
"github.com/wailsapp/wails/v2/internal/shell"
)
// AddModuleCommand adds the `module` subcommand for the `generate` command
@@ -44,8 +43,6 @@ func AddModuleCommand(app *clir.Cli, parent *clir.Command, w io.Writer) error {
}
stdout, stderr, err = shell.RunCommand(cwd, filename)
println(stdout)
println(stderr)
if err != nil {
return fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
}

Some files were not shown because too many files have changed in this diff Show More