diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 000000000..cbe661bc5
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,29 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "es6": true
+ },
+ "extends": "eslint:recommended",
+ "parserOptions": {
+ "ecmaVersion": 2016,
+ "sourceType": "module",
+ },
+ "rules": {
+ "indent": [
+ "error",
+ "tab"
+ ],
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "quotes": [
+ "error",
+ "single"
+ ],
+ "semi": [
+ "error",
+ "always"
+ ]
+ }
+};
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 000000000..53b202cb9
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "esversion": 6
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index f06b59310..dde13a901 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,4 @@
{
- "go.formatTool": "goimports"
+ "go.formatTool": "goimports",
+ "eslint.alwaysShowStatus": true
}
\ No newline at end of file
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 45a6f57c8..01781999f 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -12,3 +12,4 @@ Wails is what it is because of the time and effort given by these great people.
* [intelwalk](https://github.com/intelwalk)
* [Mark Stenglein](https://github.com/ocelotsloth)
* [admin_3.exe](https://github.com/bh90210)
+* [iceleo-com](https://github.com/iceleo-com)
diff --git a/README.md b/README.md
index 7d1a02574..65b7cf286 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@
+
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!
@@ -45,7 +46,7 @@ Make sure you have the xcode command line tools installed. This can be done by r
### Linux
-#### Ubuntu 18.04
+#### Ubuntu 18.04, Debian 9
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
diff --git a/binding_internal.go b/binding_internal.go
new file mode 100644
index 000000000..cc6bd34a8
--- /dev/null
+++ b/binding_internal.go
@@ -0,0 +1,65 @@
+package wails
+
+import "strings"
+import "fmt"
+
+type internalMethods struct{
+ log *CustomLogger
+ browser *RuntimeBrowser
+}
+
+func newInternalMethods() *internalMethods {
+ return &internalMethods{
+ log: newCustomLogger("InternalCall"),
+ browser: newRuntimeBrowser(),
+ }
+}
+
+func (i *internalMethods) processCall(callData *callData) (interface{}, error) {
+ if !strings.HasPrefix(callData.BindingName, ".wails.") {
+ return nil, fmt.Errorf("Invalid call signature '%s'", callData.BindingName)
+ }
+
+ // Strip prefix
+ var splitCall = strings.Split(callData.BindingName,".")[2:]
+ if len(splitCall) != 2 {
+ return nil, fmt.Errorf("Invalid call signature '%s'", callData.BindingName)
+ }
+
+ group := splitCall[0]
+ switch group {
+ case "Browser":
+ return i.processBrowserCommand(splitCall[1], callData.Data)
+ default:
+ return nil, fmt.Errorf("Unknown internal command group '%s'", group)
+ }
+}
+
+func (i *internalMethods) processBrowserCommand(command string, data interface{}) (interface{}, error) {
+ switch command {
+ case "OpenURL":
+ url := data.(string)
+ // Strip string quotes. Credit: https://stackoverflow.com/a/44222648
+ if url[0] == '"' {
+ url = url[1:]
+ }
+ if i := len(url)-1; url[i] == '"' {
+ url = url[:i]
+ }
+ i.log.Debugf("Calling Browser.OpenURL with '%s'", url)
+ return nil, i.browser.OpenURL(url)
+ case "OpenFile":
+ filename := data.(string)
+ // Strip string quotes. Credit: https://stackoverflow.com/a/44222648
+ if filename[0] == '"' {
+ filename = filename[1:]
+ }
+ if i := len(filename)-1; filename[i] == '"' {
+ filename = filename[:i]
+ }
+ i.log.Debugf("Calling Browser.OpenFile with '%s'", filename)
+ return nil, i.browser.OpenFile(filename)
+ default:
+ return nil, fmt.Errorf("Unknown Browser command '%s'", command)
+ }
+}
\ No newline at end of file
diff --git a/binding_manager.go b/binding_manager.go
index f6a04f8f9..0f33e501e 100644
--- a/binding_manager.go
+++ b/binding_manager.go
@@ -17,6 +17,7 @@ binding:
type bindingManager struct {
methods map[string]*boundMethod
functions map[string]*boundFunction
+ internalMethods *internalMethods
initMethods []*boundMethod
log *CustomLogger
renderer Renderer
@@ -27,9 +28,10 @@ type bindingManager struct {
func newBindingManager() *bindingManager {
result := &bindingManager{
- methods: make(map[string]*boundMethod),
- functions: make(map[string]*boundFunction),
- log: newCustomLogger("Bind"),
+ methods: make(map[string]*boundMethod),
+ functions: make(map[string]*boundFunction),
+ log: newCustomLogger("Bind"),
+ internalMethods: newInternalMethods(),
}
return result
}
@@ -163,6 +165,11 @@ func (b *bindingManager) bind(object interface{}) {
b.objectsToBind = append(b.objectsToBind, object)
}
+func (b *bindingManager) processInternalCall(callData *callData) (interface{}, error) {
+ // Strip prefix
+ return b.internalMethods.processCall(callData)
+}
+
func (b *bindingManager) processFunctionCall(callData *callData) (interface{}, error) {
// Return values
var result []reflect.Value
@@ -254,6 +261,8 @@ func (b *bindingManager) processCall(callData *callData) (result interface{}, er
result, err = b.processFunctionCall(callData)
case 2:
result, err = b.processMethodCall(callData)
+ case 3:
+ result, err = b.processInternalCall(callData)
default:
result = nil
err = fmt.Errorf("Invalid binding name '%s'", callData.BindingName)
diff --git a/cmd/cmd-mewn.go b/cmd/cmd-mewn.go
new file mode 100644
index 000000000..848f70657
--- /dev/null
+++ b/cmd/cmd-mewn.go
@@ -0,0 +1,10 @@
+package cmd
+
+// Autogenerated by Mewn - Do not alter
+
+import "github.com/leaanthony/mewn"
+
+func init() {
+ mewn.AddAsset("../wailsruntimeassets/bridge/", "wailsbridge.js", "1f8b08000000000000ffac7a7953eb3ad2f7ff7c0a4da66e9d3040f6842cf7dc7a9d05084b201b4ba6a6de2bdb1d5b604b4652e22467f8ee4f49b61387012ef3d4935309b6d5ddeafea9d58b7cf2ff384008a1074c3c81da9cd80ea0ac75884a8562e324e020804a740d181954ba8cae0f34f9c4250279c4e498af91c5014b10082333e23741860014add982231c041eb1b0248c6a564c6d245d4073cea8046a1f23ec792c24d451f4483264c3123c166cd9d142a851cd2d24a636e636928c79ea69d6e42c14c011ac2450411815c7c8234b401c3c86ed6304d23acca148efa9c00e34f5e59f7ffea9ff123f605c26a6cf39f35126970f151e91399996a68b08726389b9cc0af56b04c1616b2b2bc6059043964091853dcfc4d60bdad22242b5e1b0c27ee0c1210a89e721133429d89a3f7421228a9174b14062615920c47ce1796b442891047b44809d437d89022c0408c512f1136ab330a7b547cc7c064b22a5c5b19adcc20210918808449944588b25a607c8261c2ce9ad7307ffc81f1ce4f3091a918483b4d458b19fe8d701421c2c462958f27609dcc3eb26a20bcf3b4e8f4c880fbc89ca85827a1c8ae9e8ba8932a168e6f31eb3b0e732219be54ab158cdc7702bba9899303a9658c24eaec5e89c384df4eb4d8b035330eb05648a20c67df78445ba5d4c6eaea395fff1bb4d96c8f2b0103f33daa893adba273175e68f6f109d58da85e5f78825911e64fe48efb4dff33659fef1bbc9bf2540b933a18e0808a5c0337fbce326f6e7ac3e08e5f97a76a9b6cd9c71ed1840ed584ceaf7470ab6ce781ca196c97d22fc57c004514bd59c9315d82dc98266a1e5c15c360bad90d8d26d160b85df5a2e10c795d1b59adae16c41ed26774c9c2d1cab7fb9da616bcea83c99639f78eba6c0549c08e064deb2890894835146a1b53921d48655b3a13f6f9f29962ccfaf00db0ab866a910ac50b910ac5a1256f2047bc4a14d0ba8041e2b5a2a80dfdadac3c1c3922c61ab7a05fc96c9b80dfc84639b2c44b3087ecbc7dc21b459fd0de18564a890b2eec4621ee3cdbfcfe7f396c95627c2c5360b9bc56085d437522858a53988af42d4827b591b4bdcd4b7f9803a2d130ba8558ec97dfb761416aece1d66188631184fddded4310ca35357f78b8e71a36eee02d338550f5ecfda37f7bda9f15f7e7a6d63f8d17572afbe5d23bc5197ea59f237f9a4ef3b86d357dff7341fd12bbaff56d7b3f6f0e1aaf35c8b00298fc613efc6b826fdd7aefb72de364478f97c57385fddd506a3ca4323bf91cfa3ee8dfb30ad16ce1b4e152e1e97e6acf1d8eb3756b389f53af34ad8b3af58b53a0c5967399b3a1b5709168dcb51ef6c3abe818107f0f0fa6c4cdd69a1ddc117e5be246163733569948f36e785d2f0aae8faf9eac5d9d1f36676599b0fa166ad1f7b47cf4ee3f19435c2d562edf5fbf3ca6459ba2f1f99b7bcf748e7753b1ce6af86fdf3eea0941f1f556efdfbcefde3757e6cb5e99c98abe9e8b5df5edfe5dddb41afceeb9323b37be30d1bf5abb177fa547737cfc1b8be2cbecaae5b5f54e7f5ab61701ecce9dd9dfb7a5ebf04e60ccaa717af0dc083d26ae4f643039fd36528ea67c5b1bb7abdaa32b324c327523c336eba15fe289e24ede42f7b64647a156bca3b0f2ebde95c8fcec07f84cda369561bc3abca8331be157e8d961e8a47954e7b52baf4e566589b0b6e9e2fcc517e7066da25a7fa543c6d1c55c3fc79ef025f898be7a70ec8d38ec31fa765b9c27cd0397d5addde5fcafe7325df1b6d6eecd97c63958b6e7054b7ba3538ef5f3b98cf9e1a8b59b1e41aa2505ecedbdd46a7785a74c6d55b7f737a6b2d57c6f5b04f2b8bfa68d46eb72d411a0f0fa590dd364870edcc37c193e7384e7936b247b7d34efd6a723abc7e7d2d3f34aedad5b6699fdd3b9546a9f1628741ede815cfe84da73368dbcf4783f5a0f850af5747ebbc715dee568ca129eeef2b9475c84dbe532fbfac9f5eeb8547af6b3c0d25c7de2de96ed8c8b8f0987cf0eaaf25f9bc7cf26e1dcb291af5e79e11ccf051a7509bb46d63531a2e0be1a258ece737b3dbf5e5b0d60bcf6153ba2b99f5bbfe9017dd30a4c64c18abd0a84c8da7dbf5e37475935f05357961d0caf9d4bf3bbf698c4a7576bf723a05c86f869797fd5a77edae67457ebad88c866e603d9cae4e9713fc30de5c8dcf6b1882d3d317ce263daf3cad1717e37b3c9d48a7d71fcc3b75085647c3ca59631c04dec579bdd27ba9f99591f1dac84fae5f6edb7cb586856dcfdc8be5793f283e3ececfd6e5597929c381e95d9d932e3dba3c6a94966168b42f1cf7f9f4826ebc71f1a2fad2ae348cd9d23eef9c39a47df75a6bbcce1fef78797d74b426de59e1765019d561742a02435c07b34675f06a3c5425368b5665f932f36bd803fc6cb937e1d3c4ee5f0f8793b057babdaf148bb39bc6c346769fef5ebd62c9c26d5273bac1f4caefda9569f171600f57b3ca75ff7158cd4f78e5eeb4df904fd619ef5e95a328e69d4d5ec68ba1dfe91ca603308700b06c52165fa5c7b6a921ca1a9fa71e9dec7fe96426c8069a25f03f278eb3738abc982b7fc5b05f09fc0a1851da9cc012a814518e8cf359ae0a7e92bea29b287f357315f091601eb191e4988a0073a032c96e71da2af76aa7bd0efa3b00e89f77c9af5af8ad8529f17571df4c29858aaa3ba080392274ae6a5648b2a44a91ad6d42561abdfdbf1758cf39f641a0948c5faa50f8a5759b33ee3739539560b65c2bd8e01cbebde93ad1634e13cd1754978a281b0379a88b5384f27904c223549ed84460d38313aaf2bed24c8f5b8c0ae641ce634e563f4028f39b85a2ea392e747fb350061da158323a4219a467d6c4a93206fd1de342a15068a1083ba4733eda074ce57a5488bf2aefa30409550eb4d0ce01502177cac1ff64aa42a1d1f8aba9e2299229ff7a2a3d936e68de0ede5aba0d306c1c48b0a3ae2804734920442748ba98be08b411c01df8dbc1167f4255bbd0198fb39610d1222c3147e0818f7e229b590b1fa8cc45fd62cf037597cd08b9f620a32756943901d29092137321219b91eb0032c728a32ab6bc25444448e6281b112be6b10b2093457ff7386709318195443f912584b60e8127204d8d8300a8dd71896767df69a95807cc066d510c4e64950bd84e5ba5effffdefdd0307646ca368af27d819601fb219459639fc67e15f4a96bad99b5da973d83a78d3e877b67d35653624ed6397f93bc42325b582d1063ed6160195937500c788d8c75157a1263f467141bc5b1afbf37549c9d9424eec04653b47142fb11348d4f076a61dd5f691c23fb9dee349aba4e5aa90a69a35c5110d26f49189fbcba575e320179c223b416e0c52a045a0f18a63e60e33017211c40d6b760785c9ec751a0d75df8ac77444885a3685b5d26c07bc223c46199b2c959f46213b6e65b572ef98f70cfccfce3a976a575b07073a88f5f5be4a5b833ae3b10270bbe13e17d4198fb71ea50f2fb49c74179a82468d470f63642230df4189de61a8f5fc40836d7b8e7eea6ebcf53159faa4e06bcaf7e70de9f57a5d005f8fc1034b329efdba6555b1eef06b6d92a307f4532dad889f829d491665ecb250bc836507a4cbc2d13b65b3898f7fc3b02880e5e2ae57e9607acc7ac9443b2152e082d8f0a9022eb1e1ff56015555eccd1f9f11c14a02a7d8cb11ba642fb003351988cf8a94b72a82bd7c2d9c44a7af1d282780da9a3c3a7053d1e02d5909c3b65590141627814492256132170d8fc0674b10fae46b8e8432d456a104fb2081232290e40bc8a5d1c3b63dd6d2b291d063c4b59044591513c457294d73656265c57e4afba152da8f63f443a7b467bcc411f98f2db91ae844a10ffd8ced8ac6f6b2cd5e2014d12e4c598c7451a816202e5e4494c7353ab737d192cc5176df34357f146775b08a0677536cc14f9c1053db53e0528bf9843abb23b9d4199ed8f34ccdd18906bf72495595653ac9be53eb1a1f5825b87eece3d198e501e67d05c0127b1f45c774d08979be7440462d8f09150e2203badb98f02de6a47e4cd86fa2fb4f793f8842e910f49f0bb0c37d17ad3ec07da7f65f42df4d45bdc873dee1ffcd88ffbf8cb2da153f0ca3ada4788fcc48a331e16be528f158120b62bd112c81af51b950f005cada30c70b4fa225f6167018c78a8e8ba90348ba44440349d5e5634251fa003c3a1adf8b1adf00f65daa1320b73eba8b8abbada8b6e7d7284730ef38fe7a5520440f608ef5fd87c2c574741d63fc0dc76601d0ad5777d23be21bccc0395338ec6c87b42908414e4816f47d1f6c8225dc71166047b79bd9948a09dd17c301d7cd71375af4fdd16ffb71f4898bcd39f604ec9ebf25976f518c3cfe32cbeec28ef6dc779b340e0e1fb4b346ea2d5b088838947140cf42bf55b384882bc238e6222442222d77db18e76c2cf13f0bffda819ccfc7a560f232ef2416f1b79840bf34ca8499e6d6d25d724c4bcd098f58902d1e267928963e6061dc50f30595c4079570559b0ff6713c30675cef310ed85e23bd4e6909dab4e46d5abca3f576c441f0a1a3e57afa1c24774bb35139de8ce6cb1ca38f36d9573130c266a414cbecf9cc273b33d1735ffae7f2074c92f95ae5cdd46bd2fd993e8e23f13c7b3aecb1bded3cf3ebcdacf5b8d600c5ae308a162aad86c901bfb40e52ab2ac93c5657ec790afdbea71cebc2eb8b59da84da843a7bf2cd947cddb64534e827fa708e56ca93b4a5b1cca63ed589990f3f76a3ff9fa310c6f4d984f4736d3bd8f374aad9d3d77aa76fb2725d2cf15f2bfd4e9fedb2a7a57cac52ba488bda3e73adf3a9022bd534e4722a877d966823fe5c2ea736219612fca8c28e290ff6d2f0dbc101acf4cbf424b7c61de424d9b1c9f68b1edf6ddf5d47a30fe9b7d6f146df6e7c328f5eac2b6db53de93ee2fdb65336e325ec49f834252733fcdc92ee2ae908b9b84d46d1ff3fd875c8dbb3b2ff090000ffff9e7f4ebf45210000")
+ mewn.AddAsset("../wailsruntimeassets/bridge/", "wailsbridge.prod.js", "1f8b08000000000000ff6490316fdb30108577fe8a074fb6e14a6db7da530b742bd00031e099124fd225ccd1208f528cc0ff3d200d7bc9c0e5ddbbef3d5ebb350070b2ec13fe44762361dd6ff0f3fb8f5fdfce911289e21f59fc169d825c4cb51f274e38c7e030534c1c049ca00123296c0c591c263bb38c458cb44456c225e4883e38aa8821c44ac8bd729006a789042e941d8b489e6c227499bddb414bdcc09eb0b0f7e808399143e5b02425eb1006e84418b2f7f7528dd9b6c6d0fb394485a3c166aff83040dbe23811de2c0b862cb5c14d7eb22951aaa43abddd25742fd46bf94b19f4d6fbcef6afe00123cf248d019ed546dd3f6858df5d9b9a8862fea2010b8b0b4bb39498e6ef4ca2a9f92feb5515f691acbbac768fc4cda1ae5d4d79d783f90c0000ffff2bfba0b2bd010000")
+}
diff --git a/cmd/linux.go b/cmd/linux.go
index 781c34298..c15284958 100644
--- a/cmd/linux.go
+++ b/cmd/linux.go
@@ -3,9 +3,12 @@ package cmd
import (
"fmt"
"io/ioutil"
+ "net/url"
"os"
- "regexp"
+ "runtime"
"strings"
+
+ "github.com/pkg/browser"
)
// LinuxDistribution is of type int
@@ -20,6 +23,8 @@ const (
Arch
// RedHat linux distribution
RedHat
+ // Debian distribution
+ Debian
)
// DistroInfo contains all the information relating to a linux distribution
@@ -29,6 +34,7 @@ type DistroInfo struct {
Release string
Codename string
DistributorID string
+ DiscoveredBy string
}
// GetLinuxDistroInfo returns information about the running linux distribution
@@ -43,7 +49,7 @@ func GetLinuxDistroInfo() *DistroInfo {
if err != nil {
return result
}
-
+ result.DiscoveredBy = "lsb"
for _, line := range strings.Split(stdout, "\n") {
if strings.Contains(line, ":") {
// Iterate lines a
@@ -58,6 +64,8 @@ func GetLinuxDistroInfo() *DistroInfo {
result.Distribution = Ubuntu
case "Arch", "ManjaroLinux":
result.Distribution = Arch
+ case "Debian":
+ result.Distribution = Debian
}
case "Description":
result.Description = value
@@ -65,21 +73,37 @@ func GetLinuxDistroInfo() *DistroInfo {
result.Release = value
case "Codename":
result.Codename = value
-
}
}
}
// check if /etc/os-release exists
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
+ // Default value
+ osName := "Unknown"
+ version := ""
// read /etc/os-release
osRelease, _ := ioutil.ReadFile("/etc/os-release")
- // compile a regex to find NAME=distro
- re := regexp.MustCompile(`^NAME=(.*)\n`)
- // extract the distro name
- osName := string(re.FindSubmatch(osRelease)[1])
- // strip quotations
- osName = strings.Trim(osName, "\"")
+ // Split into lines
+ lines := strings.Split(string(osRelease), "\n")
+ // Iterate lines
+ for _, line := range lines {
+ // Split each line by the equals char
+ splitLine := strings.SplitN(line, "=", 2)
+ // Check we have
+ if len(splitLine) != 2 {
+ continue
+ }
+ switch splitLine[0] {
+ case "NAME":
+ osName = strings.Trim(splitLine[1], "\"")
+ case "VERSION_ID":
+ version = strings.Trim(splitLine[1], "\"")
+ }
+
+ }
// Check distro name against list of distros
+ result.Release = version
+ result.DiscoveredBy = "os-release"
switch osName {
case "Fedora":
result.Distribution = RedHat
@@ -87,6 +111,11 @@ func GetLinuxDistroInfo() *DistroInfo {
result.Distribution = RedHat
case "Arch Linux":
result.Distribution = Arch
+ case "Debian GNU/Linux":
+ result.Distribution = Debian
+ default:
+ result.Distribution = Unknown
+ result.DistributorID = osName
}
}
return result
@@ -124,3 +153,45 @@ func RpmInstalled(packageName string) (bool, error) {
_, _, exitCode, _ := rpm.Run("--query", packageName)
return exitCode == 0, nil
}
+
+// RequestSupportForDistribution promts the user to submit a request to support their
+// currently unsupported distribution
+func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
+ var logger = NewLogger()
+ defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, libraryName)
+
+ logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.DistributorID)
+ q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.DistributorID)
+ result := Prompt(q, "yes")
+ if strings.ToLower(result) != "yes" {
+ return defaultError
+ }
+
+ title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID)
+
+ var str strings.Builder
+
+ gomodule, exists := os.LookupEnv("GO111MODULE")
+ if !exists {
+ gomodule = "(Not Set)"
+ }
+
+ str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
+ str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", Version))
+ str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version()))
+ str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
+ str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
+ str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
+ str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.DistributorID))
+ str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
+ str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy))
+
+ body := fmt.Sprintf("**Description**\nDistribution '%s' is currently unsupported.\n\n**Further Information**\n\n%s\n\n*Please add any extra information here, EG: libraries that are needed to make the distribution work, or commands to install them*", distroInfo.DistributorID, str.String())
+ fullURL := "https://github.com/wailsapp/wails/issues/new?"
+ params := "title=" + title + "&body=" + body
+
+ fmt.Println("Opening browser to file request.")
+ browser.OpenURL(fullURL + url.PathEscape(params))
+ return nil
+
+}
diff --git a/cmd/prerequisites.go b/cmd/prerequisites.go
index 0f6bbe66c..0d1a5901d 100644
--- a/cmd/prerequisites.go
+++ b/cmd/prerequisites.go
@@ -49,11 +49,10 @@ func getRequiredProgramsLinux() *Prerequisites {
result := &Prerequisites{}
distroInfo := GetLinuxDistroInfo()
switch distroInfo.Distribution {
- case Ubuntu:
+ case Ubuntu, Debian:
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
result.Add(newPrerequisite("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
-
default:
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
diff --git a/cmd/project.go b/cmd/project.go
index 21e2047ff..90a0d146b 100644
--- a/cmd/project.go
+++ b/cmd/project.go
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "sort"
"strings"
"github.com/leaanthony/slicer"
@@ -143,11 +144,13 @@ type ProjectOptions struct {
log *Logger
templates *TemplateHelper
selectedTemplate *TemplateDetails
+ WailsVersion string
}
// Defaults sets the default project template
func (po *ProjectOptions) Defaults() {
po.Template = "vuebasic"
+ po.WailsVersion = Version
}
// PromptForInputs asks the user to input project details
@@ -182,7 +185,13 @@ func (po *ProjectOptions) PromptForInputs() error {
po.selectedTemplate = templateDetails[po.Template]
} else {
- for _, templateDetail := range templateDetails {
+ keys := make([]string, 0)
+ for k := range templateDetails {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ for _, k := range keys {
+ templateDetail := templateDetails[k]
templateList.Add(templateDetail)
options.Add(fmt.Sprintf("%s - %s", templateDetail.Metadata.Name, templateDetail.Metadata.ShortDescription))
}
diff --git a/cmd/system.go b/cmd/system.go
index af28058f6..86ce69d9b 100644
--- a/cmd/system.go
+++ b/cmd/system.go
@@ -272,7 +272,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
distroInfo := GetLinuxDistroInfo()
for _, library := range *requiredLibraries {
switch distroInfo.Distribution {
- case Ubuntu:
+ case Ubuntu, Debian:
installed, err := DpkgInstalled(library.Name)
if err != nil {
return false, err
@@ -295,7 +295,6 @@ func CheckDependencies(logger *Logger) (bool, error) {
logger.Green("Library '%s' installed.", library.Name)
}
case RedHat:
-
installed, err := RpmInstalled(library.Name)
if err != nil {
return false, err
@@ -307,7 +306,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
logger.Green("Library '%s' installed.", library.Name)
}
default:
- return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
+ return false, RequestSupportForDistribution(distroInfo, library.Name)
}
}
}
diff --git a/cmd/templates.go b/cmd/templates.go
index ab28b50e1..241077b0c 100644
--- a/cmd/templates.go
+++ b/cmd/templates.go
@@ -16,18 +16,26 @@ import (
// TemplateMetadata holds all the metadata for a Wails template
type TemplateMetadata struct {
- Name string `json:"name"`
- Version string `json:"version"`
- ShortDescription string `json:"shortdescription"`
- Description string `json:"description"`
- Install string `json:"install"`
- Build string `json:"build"`
- Author string `json:"author"`
- Created string `json:"created"`
- FrontendDir string `json:"frontenddir"`
- Serve string `json:"serve"`
- Bridge string `json:"bridge"`
- WailsDir string `json:"wailsdir"`
+ Name string `json:"name"`
+ Version string `json:"version"`
+ ShortDescription string `json:"shortdescription"`
+ Description string `json:"description"`
+ Install string `json:"install"`
+ Build string `json:"build"`
+ Author string `json:"author"`
+ Created string `json:"created"`
+ FrontendDir string `json:"frontenddir"`
+ Serve string `json:"serve"`
+ Bridge string `json:"bridge"`
+ WailsDir string `json:"wailsdir"`
+ TemplateDependencies []*TemplateDependency `json:"dependencies,omitempty"`
+}
+
+// TemplateDependency defines a binary dependency for the template
+// EG: ng for angular
+type TemplateDependency struct {
+ Bin string `json:"bin"`
+ Help string `json:"help"`
}
// TemplateDetails holds information about a specific template
@@ -152,6 +160,31 @@ func (t *TemplateHelper) GetTemplateFilenames(template *TemplateDetails) (*slice
// project path given
func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *ProjectOptions) error {
+ // Check dependencies before installing
+ dependencies := projectOptions.selectedTemplate.Metadata.TemplateDependencies
+ if dependencies != nil {
+ programHelper := NewProgramHelper()
+ logger := NewLogger()
+ errors := []string{}
+ for _, dep := range dependencies {
+ program := programHelper.FindProgram(dep.Bin)
+ if program == nil {
+ errors = append(errors, dep.Help)
+ }
+ }
+ if len(errors) > 0 {
+ mainError := "template dependencies not installed"
+ if len(errors) == 1 {
+ mainError = errors[0]
+ } else {
+ for _, error := range errors {
+ logger.Red(error)
+ }
+ }
+ return fmt.Errorf(mainError)
+ }
+ }
+
// Get template files
templateFilenames, err := t.GetTemplateFilenames(projectOptions.selectedTemplate)
if err != nil {
@@ -160,6 +193,9 @@ func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *Pro
templatePath := projectOptions.selectedTemplate.Path
+ // Save the version
+ projectOptions.WailsVersion = Version
+
templateJSONFilename := filepath.Join(templatePath, t.metadataFilename)
templateFiles := templateFilenames.Filter(func(filename string) bool {
diff --git a/cmd/templates/angular-template/frontend/.editorconfig b/cmd/templates/angular-template/frontend/.editorconfig
new file mode 100644
index 000000000..e89330a61
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/.editorconfig
@@ -0,0 +1,13 @@
+# Editor configuration, see https://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+max_line_length = off
+trim_trailing_whitespace = false
diff --git a/cmd/templates/angular-template/frontend/.gitignore b/cmd/templates/angular-template/frontend/.gitignore
new file mode 100644
index 000000000..2d5d82ccd
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/.gitignore
@@ -0,0 +1,47 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+
+# compiled output
+/dist
+/tmp
+/out-tsc
+# Only exists if Bazel was run
+/bazel-out
+
+# dependencies
+/node_modules
+
+# profiling files
+chrome-profiler-events.json
+speed-measure-plugin.json
+
+# IDEs and editors
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+.history/*
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db
+.editorcinfig
diff --git a/cmd/templates/angular-template/frontend/README.md b/cmd/templates/angular-template/frontend/README.md
new file mode 100644
index 000000000..f5aa03f4c
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/README.md
@@ -0,0 +1,27 @@
+# MyApp
+
+This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.0.3.
+
+## Development server
+
+Run `npx ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
+
+## Code scaffolding
+
+Run `npx ng generate component component-name` to generate a new component. You can also use `npx ng generate directive|pipe|service|class|guard|interface|enum|module`.
+
+## Build
+
+Run `npx ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
+
+## Running unit tests
+
+Run `npx ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
+
+## Running end-to-end tests
+
+Run `npx ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
+
+## Further help
+
+To get more help on the Angular CLI use `npx ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
diff --git a/cmd/templates/angular-template/frontend/angular.json b/cmd/templates/angular-template/frontend/angular.json
new file mode 100644
index 000000000..73d12e71f
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/angular.json
@@ -0,0 +1,121 @@
+{
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
+ "version": 1,
+ "newProjectRoot": "projects",
+ "projects": {
+ "my-app": {
+ "projectType": "application",
+ "schematics": {},
+ "root": "",
+ "sourceRoot": "src",
+ "prefix": "app",
+ "architect": {
+ "build": {
+ "builder": "ngx-build-plus:browser",
+ "options": {
+ "outputPath": "dist/my-app",
+ "index": "src/index.html",
+ "main": "src/main.ts",
+ "polyfills": "src/polyfills.ts",
+ "tsConfig": "tsconfig.app.json",
+ "aot": false,
+ "assets": [
+ "src/favicon.ico",
+ "src/assets"
+ ],
+ "styles": [
+ "src/styles.css"
+ ],
+ "scripts": []
+ },
+ "configurations": {
+ "production": {
+ "fileReplacements": [
+ {
+ "replace": "src/environments/environment.ts",
+ "with": "src/environments/environment.prod.ts"
+ }
+ ],
+ "optimization": true,
+ "outputHashing": "all",
+ "sourceMap": false,
+ "extractCss": true,
+ "namedChunks": false,
+ "aot": true,
+ "extractLicenses": true,
+ "vendorChunk": false,
+ "buildOptimizer": true,
+ "budgets": [
+ {
+ "type": "initial",
+ "maximumWarning": "2mb",
+ "maximumError": "5mb"
+ }
+ ]
+ }
+ }
+ },
+ "serve": {
+ "builder": "ngx-build-plus:dev-server",
+ "options": {
+ "browserTarget": "my-app:build"
+ },
+ "configurations": {
+ "production": {
+ "browserTarget": "my-app:build:production"
+ }
+ }
+ },
+ "extract-i18n": {
+ "builder": "@angular-devkit/build-angular:extract-i18n",
+ "options": {
+ "browserTarget": "my-app:build"
+ }
+ },
+ "test": {
+ "builder": "ngx-build-plus:karma",
+ "options": {
+ "main": "src/test.ts",
+ "polyfills": "src/polyfills.ts",
+ "tsConfig": "tsconfig.spec.json",
+ "karmaConfig": "karma.conf.js",
+ "assets": [
+ "src/favicon.ico",
+ "src/assets"
+ ],
+ "styles": [
+ "src/styles.css"
+ ],
+ "scripts": []
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": [
+ "tsconfig.app.json",
+ "tsconfig.spec.json",
+ "e2e/tsconfig.json"
+ ],
+ "exclude": [
+ "**/node_modules/**"
+ ]
+ }
+ },
+ "e2e": {
+ "builder": "@angular-devkit/build-angular:protractor",
+ "options": {
+ "protractorConfig": "e2e/protractor.conf.js",
+ "devServerTarget": "my-app:serve"
+ },
+ "configurations": {
+ "production": {
+ "devServerTarget": "my-app:serve:production"
+ }
+ }
+ }
+ }
+ }
+ },
+ "defaultProject": "my-app"
+}
\ No newline at end of file
diff --git a/cmd/templates/angular-template/frontend/browserslist b/cmd/templates/angular-template/frontend/browserslist
new file mode 100644
index 000000000..80848532e
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/browserslist
@@ -0,0 +1,12 @@
+# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+
+# You can see what browsers were selected by your queries by running:
+# npx browserslist
+
+> 0.5%
+last 2 versions
+Firefox ESR
+not dead
+not IE 9-11 # For IE 9-11 support, remove 'not'.
\ No newline at end of file
diff --git a/cmd/templates/angular-template/frontend/e2e/protractor.conf.js b/cmd/templates/angular-template/frontend/e2e/protractor.conf.js
new file mode 100644
index 000000000..73e4e6806
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/e2e/protractor.conf.js
@@ -0,0 +1,32 @@
+// @ts-check
+// Protractor configuration file, see link for more information
+// https://github.com/angular/protractor/blob/master/lib/config.ts
+
+const { SpecReporter } = require('jasmine-spec-reporter');
+
+/**
+ * @type { import("protractor").Config }
+ */
+exports.config = {
+ allScriptsTimeout: 11000,
+ specs: [
+ './src/**/*.e2e-spec.ts'
+ ],
+ capabilities: {
+ 'browserName': 'chrome'
+ },
+ directConnect: true,
+ baseUrl: 'http://localhost:4200/',
+ framework: 'jasmine',
+ jasmineNodeOpts: {
+ showColors: true,
+ defaultTimeoutInterval: 30000,
+ print: function() {}
+ },
+ onPrepare() {
+ require('ts-node').register({
+ project: require('path').join(__dirname, './tsconfig.json')
+ });
+ jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
+ }
+};
\ No newline at end of file
diff --git a/cmd/templates/angular-template/frontend/e2e/src/app.e2e-spec.ts b/cmd/templates/angular-template/frontend/e2e/src/app.e2e-spec.ts
new file mode 100644
index 000000000..3b79f7c47
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/e2e/src/app.e2e-spec.ts
@@ -0,0 +1,23 @@
+import { AppPage } from './app.po';
+import { browser, logging } from 'protractor';
+
+describe('workspace-project App', () => {
+ let page: AppPage;
+
+ beforeEach(() => {
+ page = new AppPage();
+ });
+
+ it('should display welcome message', () => {
+ page.navigateTo();
+ expect(page.getTitleText()).toEqual('Welcome to my-app!');
+ });
+
+ afterEach(async () => {
+ // Assert that there are no errors emitted from the browser
+ const logs = await browser.manage().logs().get(logging.Type.BROWSER);
+ expect(logs).not.toContain(jasmine.objectContaining({
+ level: logging.Level.SEVERE,
+ } as logging.Entry));
+ });
+});
diff --git a/cmd/templates/angular-template/frontend/e2e/src/app.po.ts b/cmd/templates/angular-template/frontend/e2e/src/app.po.ts
new file mode 100644
index 000000000..5776aa9eb
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/e2e/src/app.po.ts
@@ -0,0 +1,11 @@
+import { browser, by, element } from 'protractor';
+
+export class AppPage {
+ navigateTo() {
+ return browser.get(browser.baseUrl) as Promise;
+ }
+
+ getTitleText() {
+ return element(by.css('app-root h1')).getText() as Promise;
+ }
+}
diff --git a/cmd/templates/angular-template/frontend/e2e/tsconfig.json b/cmd/templates/angular-template/frontend/e2e/tsconfig.json
new file mode 100644
index 000000000..39b800f78
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/e2e/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../out-tsc/e2e",
+ "module": "commonjs",
+ "target": "es5",
+ "types": [
+ "jasmine",
+ "jasminewd2",
+ "node"
+ ]
+ }
+}
diff --git a/cmd/templates/angular-template/frontend/karma.conf.js b/cmd/templates/angular-template/frontend/karma.conf.js
new file mode 100644
index 000000000..b0d5cbe01
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/karma.conf.js
@@ -0,0 +1,32 @@
+// Karma configuration file, see link for more information
+// https://karma-runner.github.io/1.0/config/configuration-file.html
+
+module.exports = function (config) {
+ config.set({
+ basePath: '',
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
+ plugins: [
+ require('karma-jasmine'),
+ require('karma-chrome-launcher'),
+ require('karma-jasmine-html-reporter'),
+ require('karma-coverage-istanbul-reporter'),
+ require('@angular-devkit/build-angular/plugins/karma')
+ ],
+ client: {
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
+ },
+ coverageIstanbulReporter: {
+ dir: require('path').join(__dirname, './coverage/my-app'),
+ reports: ['html', 'lcovonly', 'text-summary'],
+ fixWebpackSourcePaths: true
+ },
+ reporters: ['progress', 'kjhtml'],
+ port: 9876,
+ colors: true,
+ logLevel: config.LOG_INFO,
+ autoWatch: true,
+ browsers: ['Chrome'],
+ singleRun: false,
+ restartOnFileChange: true
+ });
+};
diff --git a/cmd/templates/angular-template/frontend/package.json.template b/cmd/templates/angular-template/frontend/package.json.template
new file mode 100644
index 000000000..9bdabc534
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/package.json.template
@@ -0,0 +1,50 @@
+{
+ "name": "my-app",
+ "version": "0.0.0",
+ "scripts": {
+ "ng": "npx ng",
+ "start": "npx ng serve --poll=2000",
+ "build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false",
+ "test": "npx ng test",
+ "lint": "npx ng lint",
+ "e2e": "npx ng e2e"
+ },
+ "private": true,
+ "dependencies": {
+ "@angular/animations": "^8.0.2",
+ "@angular/cdk": "^8.0.1",
+ "@angular/common": "~8.0.1",
+ "@angular/compiler": "~8.0.1",
+ "@angular/core": "~8.0.1",
+ "@angular/forms": "~8.0.1",
+ "@angular/material": "^8.0.1",
+ "@angular/platform-browser": "~8.0.1",
+ "@angular/platform-browser-dynamic": "~8.0.1",
+ "@angular/router": "~8.0.1",
+ "ngx-build-plus": "^8.0.3",
+ "rxjs": "~6.4.0",
+ "tslib": "^1.9.0",
+ "zone.js": "~0.9.1"
+ },
+ "devDependencies": {
+ "@angular-devkit/build-angular": "~0.800.0",
+ "@angular/cli": "~8.0.3",
+ "@angular/compiler-cli": "~8.0.1",
+ "@angular/language-service": "~8.0.1",
+ "@types/node": "~8.9.4",
+ "@types/jasmine": "~3.3.8",
+ "@types/jasminewd2": "~2.0.3",
+ "codelyzer": "^5.0.0",
+ "jasmine-core": "~3.4.0",
+ "jasmine-spec-reporter": "~4.2.1",
+ "karma": "~4.1.0",
+ "karma-chrome-launcher": "~2.2.0",
+ "karma-coverage-istanbul-reporter": "~2.0.1",
+ "karma-jasmine": "~2.0.1",
+ "karma-jasmine-html-reporter": "^1.4.0",
+ "protractor": "~5.4.0",
+ "ts-node": "~7.0.0",
+ "tslint": "~5.15.0",
+ "typescript": "~3.4.3"
+ }
+}
diff --git a/cmd/templates/angular-template/frontend/src/app/app-routing.module.ts b/cmd/templates/angular-template/frontend/src/app/app-routing.module.ts
new file mode 100644
index 000000000..4e5f86c41
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/app/app-routing.module.ts
@@ -0,0 +1,13 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+const routes: Routes = [];
+
+@NgModule({
+ imports: [
+ RouterModule.forRoot(routes)
+ ],
+ exports: [RouterModule]
+})
+
+export class AppRoutingModule { }
diff --git a/cmd/templates/angular-template/frontend/src/app/app.component.css b/cmd/templates/angular-template/frontend/src/app/app.component.css
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/templates/angular-template/frontend/src/app/app.component.html b/cmd/templates/angular-template/frontend/src/app/app.component.html
new file mode 100644
index 000000000..4a0437517
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/app/app.component.html
@@ -0,0 +1,14 @@
+
+
+
+ Welcome to {{ title }}!
+
+

+
+
+
+
{{clickMessage}}
+
+
+
diff --git a/cmd/templates/angular-template/frontend/src/app/app.component.spec.ts b/cmd/templates/angular-template/frontend/src/app/app.component.spec.ts
new file mode 100644
index 000000000..3fe58ce0f
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/app/app.component.spec.ts
@@ -0,0 +1,35 @@
+import { TestBed, async } from '@angular/core/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { AppComponent } from './app.component';
+
+describe('AppComponent', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ RouterTestingModule
+ ],
+ declarations: [
+ AppComponent
+ ],
+ }).compileComponents();
+ }));
+
+ it('should create the app', () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.debugElement.componentInstance;
+ expect(app).toBeTruthy();
+ });
+
+ it(`should have as title 'my-app'`, () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.debugElement.componentInstance;
+ expect(app.title).toEqual('my-app');
+ });
+
+ it('should render title in a h1 tag', () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ fixture.detectChanges();
+ const compiled = fixture.debugElement.nativeElement;
+ expect(compiled.querySelector('h1').textContent).toContain('Welcome to my-app!');
+ });
+});
diff --git a/cmd/templates/angular-template/frontend/src/app/app.component.ts b/cmd/templates/angular-template/frontend/src/app/app.component.ts
new file mode 100644
index 000000000..e91b91686
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/app/app.component.ts
@@ -0,0 +1,19 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: '[id="app"]',
+ templateUrl: './app.component.html',
+ styleUrls: ['./app.component.css']
+})
+export class AppComponent {
+ title = 'my-app';
+
+ clickMessage = '';
+
+ onClickMe() {
+ // @ts-ignore
+ window.backend.basic().then(result =>
+ this.clickMessage = result
+ );
+ }
+}
diff --git a/cmd/templates/angular-template/frontend/src/app/app.module.ts b/cmd/templates/angular-template/frontend/src/app/app.module.ts
new file mode 100644
index 000000000..4c082cefe
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/app/app.module.ts
@@ -0,0 +1,20 @@
+import { BrowserModule } from '@angular/platform-browser';
+import { NgModule } from '@angular/core';
+
+import { AppRoutingModule } from './app-routing.module';
+import { AppComponent } from './app.component';
+
+import { APP_BASE_HREF } from '@angular/common';
+
+@NgModule({
+ declarations: [
+ AppComponent
+ ],
+ imports: [
+ BrowserModule,
+ AppRoutingModule
+ ],
+ providers: [{provide: APP_BASE_HREF, useValue : '/' }],
+ bootstrap: [AppComponent]
+})
+export class AppModule { }
diff --git a/cmd/templates/angular-template/frontend/src/assets/.gitkeep b/cmd/templates/angular-template/frontend/src/assets/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/cmd/templates/angular-template/frontend/src/environments/environment.prod.ts b/cmd/templates/angular-template/frontend/src/environments/environment.prod.ts
new file mode 100644
index 000000000..3612073bc
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+ production: true
+};
diff --git a/cmd/templates/angular-template/frontend/src/environments/environment.ts b/cmd/templates/angular-template/frontend/src/environments/environment.ts
new file mode 100644
index 000000000..7b4f817ad
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+ production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
diff --git a/cmd/templates/angular-template/frontend/src/favicon.ico b/cmd/templates/angular-template/frontend/src/favicon.ico
new file mode 100644
index 000000000..8081c7cea
Binary files /dev/null and b/cmd/templates/angular-template/frontend/src/favicon.ico differ
diff --git a/cmd/templates/angular-template/frontend/src/index.html.template b/cmd/templates/angular-template/frontend/src/index.html.template
new file mode 100644
index 000000000..df56c4116
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/index.html.template
@@ -0,0 +1,14 @@
+
+
+
+
+my-app
+
+
+
+
+
+
+
+
+
diff --git a/cmd/templates/angular-template/frontend/src/main.ts b/cmd/templates/angular-template/frontend/src/main.ts
new file mode 100644
index 000000000..08cb1acbf
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/main.ts
@@ -0,0 +1,18 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+import 'zone.js'
+
+import Bridge from './wailsbridge';
+
+if (environment.production) {
+ enableProdMode();
+}
+
+Bridge.Start(() => {
+ platformBrowserDynamic().bootstrapModule(AppModule)
+ .catch(err => console.error(err));
+});
diff --git a/cmd/templates/angular-template/frontend/src/polyfills.ts b/cmd/templates/angular-template/frontend/src/polyfills.ts
new file mode 100644
index 000000000..22a5df87d
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/polyfills.ts
@@ -0,0 +1,63 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ * file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/** IE10 and IE11 requires the following for NgClass support on SVG elements */
+// import 'classlist.js'; // Run `npm install --save classlist.js`.
+
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ */
+// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags.ts';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+ *
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+//import 'zone.js/dist/zone'; // Included with Angular CLI.
+
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/cmd/templates/angular-template/frontend/src/styles.css b/cmd/templates/angular-template/frontend/src/styles.css
new file mode 100644
index 000000000..4cf0ed8d1
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/styles.css
@@ -0,0 +1,24 @@
+/* You can add global styles to this file, and also import other style files */
+body {
+ margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
+ "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
+ sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+
+ background-color: #282c34;
+}
+
+p {
+ color: white
+}
+
+h1 {
+ color: white
+}
+
+button {
+ background-color: white;
+ color: black;
+}
diff --git a/cmd/templates/angular-template/frontend/src/test.ts b/cmd/templates/angular-template/frontend/src/test.ts
new file mode 100644
index 000000000..16317897b
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/test.ts
@@ -0,0 +1,20 @@
+// This file is required by karma.conf.js and loads recursively all the .spec and framework files
+
+import 'zone.js/dist/zone-testing';
+import { getTestBed } from '@angular/core/testing';
+import {
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
+
+declare const require: any;
+
+// First, initialize the Angular testing environment.
+getTestBed().initTestEnvironment(
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting()
+);
+// Then we find all the tests.
+const context = require.context('./', true, /\.spec\.ts$/);
+// And load the modules.
+context.keys().map(context);
diff --git a/cmd/templates/angular-template/frontend/src/wailsbridge.js b/cmd/templates/angular-template/frontend/src/wailsbridge.js
new file mode 100644
index 000000000..62c723900
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/src/wailsbridge.js
@@ -0,0 +1,17 @@
+/*
+ Wails Bridge (c) 2019-present Lea Anthony
+
+ This prod version is to get around having to rewrite your code
+ for production. When doing a release build, this file will be used
+ instead of the full version.
+*/
+
+export default {
+ // The main function
+ // Passes the main Wails object to the callback if given.
+ Start: function(callback) {
+ if (callback) {
+ window.wails.events.on("wails:ready", callback);
+ }
+ }
+};
diff --git a/cmd/templates/angular-template/frontend/tsconfig.app.json b/cmd/templates/angular-template/frontend/tsconfig.app.json
new file mode 100644
index 000000000..31f8397ac
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/tsconfig.app.json
@@ -0,0 +1,14 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./out-tsc/app",
+ "types": []
+ },
+ "include": [
+ "src/**/*.ts"
+ ],
+ "exclude": [
+ "src/test.ts",
+ "src/**/*.spec.ts"
+ ]
+}
diff --git a/cmd/templates/angular-template/frontend/tsconfig.json b/cmd/templates/angular-template/frontend/tsconfig.json
new file mode 100644
index 000000000..0a91f8107
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "baseUrl": "./",
+ "outDir": "./dist/out-tsc",
+ "sourceMap": true,
+ "declaration": false,
+ "downlevelIteration": true,
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "module": "esnext",
+ "moduleResolution": "node",
+ "importHelpers": true,
+ "target": "es2015",
+ "typeRoots": [
+ "node_modules/@types"
+ ],
+ "lib": [
+ "es2018",
+ "dom"
+ ]
+ }
+}
diff --git a/cmd/templates/angular-template/frontend/tsconfig.spec.json b/cmd/templates/angular-template/frontend/tsconfig.spec.json
new file mode 100644
index 000000000..6400fde7d
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/tsconfig.spec.json
@@ -0,0 +1,18 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./out-tsc/spec",
+ "types": [
+ "jasmine",
+ "node"
+ ]
+ },
+ "files": [
+ "src/test.ts",
+ "src/polyfills.ts"
+ ],
+ "include": [
+ "src/**/*.spec.ts",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/cmd/templates/angular-template/frontend/tslint.json b/cmd/templates/angular-template/frontend/tslint.json
new file mode 100644
index 000000000..188bd78d3
--- /dev/null
+++ b/cmd/templates/angular-template/frontend/tslint.json
@@ -0,0 +1,92 @@
+{
+ "extends": "tslint:recommended",
+ "rules": {
+ "array-type": false,
+ "arrow-parens": false,
+ "deprecation": {
+ "severity": "warn"
+ },
+ "component-class-suffix": true,
+ "contextual-lifecycle": true,
+ "directive-class-suffix": true,
+ "directive-selector": [
+ true,
+ "attribute",
+ "app",
+ "camelCase"
+ ],
+ "component-selector": [
+ true,
+ "element",
+ "app",
+ "kebab-case"
+ ],
+ "import-blacklist": [
+ true,
+ "rxjs/Rx"
+ ],
+ "interface-name": false,
+ "max-classes-per-file": false,
+ "max-line-length": [
+ true,
+ 140
+ ],
+ "member-access": false,
+ "member-ordering": [
+ true,
+ {
+ "order": [
+ "static-field",
+ "instance-field",
+ "static-method",
+ "instance-method"
+ ]
+ }
+ ],
+ "no-consecutive-blank-lines": false,
+ "no-console": [
+ true,
+ "debug",
+ "info",
+ "time",
+ "timeEnd",
+ "trace"
+ ],
+ "no-empty": false,
+ "no-inferrable-types": [
+ true,
+ "ignore-params"
+ ],
+ "no-non-null-assertion": true,
+ "no-redundant-jsdoc": true,
+ "no-switch-case-fall-through": true,
+ "no-use-before-declare": true,
+ "no-var-requires": false,
+ "object-literal-key-quotes": [
+ true,
+ "as-needed"
+ ],
+ "object-literal-sort-keys": false,
+ "ordered-imports": false,
+ "quotemark": [
+ true,
+ "single"
+ ],
+ "trailing-comma": false,
+ "no-conflicting-lifecycle": true,
+ "no-host-metadata-property": true,
+ "no-input-rename": true,
+ "no-inputs-metadata-property": true,
+ "no-output-native": true,
+ "no-output-on-prefix": true,
+ "no-output-rename": true,
+ "no-outputs-metadata-property": true,
+ "template-banana-in-box": true,
+ "template-no-negated-async": true,
+ "use-lifecycle-interface": true,
+ "use-pipe-transform-interface": true
+ },
+ "rulesDirectory": [
+ "codelyzer"
+ ]
+}
\ No newline at end of file
diff --git a/cmd/templates/angular-template/go.mod.template b/cmd/templates/angular-template/go.mod.template
new file mode 100644
index 000000000..780381065
--- /dev/null
+++ b/cmd/templates/angular-template/go.mod.template
@@ -0,0 +1,5 @@
+module {{.BinaryName}}
+
+require (
+ github.com/wailsapp/wails {{.WailsVersion}}
+)
\ No newline at end of file
diff --git a/cmd/templates/angular-template/main.go.template b/cmd/templates/angular-template/main.go.template
new file mode 100644
index 000000000..592c6b7d0
--- /dev/null
+++ b/cmd/templates/angular-template/main.go.template
@@ -0,0 +1,27 @@
+package main
+
+import (
+ "github.com/leaanthony/mewn"
+ "github.com/wailsapp/wails"
+)
+
+func basic() string {
+ return "World!"
+}
+
+func main() {
+
+ js := mewn.String("./frontend/dist/my-app/main-es2015.js")
+ css := mewn.String("./frontend/dist/my-app/styles.css")
+
+ app := wails.CreateApp(&wails.AppConfig{
+ Width: 1024,
+ Height: 768,
+ Title: "{{.Name}}",
+ JS: js,
+ CSS: css,
+ Colour: "#131313",
+ })
+ app.Bind(basic)
+ app.Run()
+}
diff --git a/cmd/templates/angular-template/template.json b/cmd/templates/angular-template/template.json
new file mode 100644
index 000000000..89ac169e4
--- /dev/null
+++ b/cmd/templates/angular-template/template.json
@@ -0,0 +1,20 @@
+{
+ "name": "Angular",
+ "version": "1.0.0",
+ "shortdescription": "Angular 8 template (Requires node 10.8+)",
+ "description": "Angular projects w/ @angular/cli - Note: in order to reach the cli use npx like this: npx ng",
+ "dependencies": [
+ {
+ "bin": "npx",
+ "help": "This template requires 'npx'. Please install with 'npm install -g npx'"
+ }
+ ],
+ "install": "npm install",
+ "build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false",
+ "author": "bh90210 ",
+ "created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008",
+ "frontenddir": "frontend",
+ "serve": "npx ng serve --poll=2000",
+ "bridge": "src",
+ "wailsdir": ""
+}
\ No newline at end of file
diff --git a/cmd/templates/create-react-app/.jshint b/cmd/templates/create-react-app/.jshint
new file mode 100644
index 000000000..0557edf11
--- /dev/null
+++ b/cmd/templates/create-react-app/.jshint
@@ -0,0 +1,3 @@
+{
+ "esversion": 6
+}
\ No newline at end of file
diff --git a/cmd/templates/create-react-app/frontend/src/components/HelloWorld.js b/cmd/templates/create-react-app/frontend/src/components/HelloWorld.js
index e96d04732..cc6f8c84f 100644
--- a/cmd/templates/create-react-app/frontend/src/components/HelloWorld.js
+++ b/cmd/templates/create-react-app/frontend/src/components/HelloWorld.js
@@ -26,22 +26,8 @@ class HelloWorld extends React.Component {
this.setState({ showModal: false });
}
-
- startAsync() {
- this.setState({
- loading: true
- });
-
- window.backend.basic().then(result =>
- this.setState({
- loading: false,
- result
- })
- );
- }
-
render() {
- const { loading, result } = this.state;
+ const { result } = this.state;
return (