mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 13:19:00 -07:00
Compare commits
302 Commits
0.9.9
...
2---Suppor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af1a1a2498 | ||
|
|
cc0617d247 | ||
|
|
99a3f87cef | ||
|
|
1ccdb1bc4e | ||
|
|
62b1967e45 | ||
|
|
c10303e7c0 | ||
|
|
4a61584827 | ||
|
|
cf249ba836 | ||
|
|
08fe7b64d6 | ||
|
|
77939ea414 | ||
|
|
468394d03c | ||
|
|
dc87699a1e | ||
|
|
36e906507d | ||
|
|
a5f9688708 | ||
|
|
880f900e51 | ||
|
|
349306cf73 | ||
|
|
f140697857 | ||
|
|
26ff8df7e5 | ||
|
|
b7dae216df | ||
|
|
0b9d093d6c | ||
|
|
7f282ad071 | ||
|
|
d6ed583e07 | ||
|
|
930cab2d9d | ||
|
|
ae41f33dcc | ||
|
|
5af6b7cafe | ||
|
|
68ac3763d0 | ||
|
|
cdc66b556e | ||
|
|
3ff16322c2 | ||
|
|
d60066a0b1 | ||
|
|
9d6ebf0fd4 | ||
|
|
839815e2fb | ||
|
|
846fe479bf | ||
|
|
62f7070e0c | ||
|
|
dd418b36c2 | ||
|
|
f4f04f2199 | ||
|
|
3a7514bbdc | ||
|
|
213f07fed4 | ||
|
|
ed3ed8aa18 | ||
|
|
d038dca37c | ||
|
|
bb86d770a1 | ||
|
|
33daa8621e | ||
|
|
6c124fcff4 | ||
|
|
45833574b3 | ||
|
|
5cb00eb481 | ||
|
|
e2105331c1 | ||
|
|
21d2383e63 | ||
|
|
6c945a4eed | ||
|
|
6c8d34dfd3 | ||
|
|
b9b42c059e | ||
|
|
3f657b34cf | ||
|
|
6e81a36ada | ||
|
|
ddec01a429 | ||
|
|
21fdb3be7d | ||
|
|
c1a13ab6d0 | ||
|
|
750a02efc6 | ||
|
|
5e047debfc | ||
|
|
9cac336708 | ||
|
|
827c2b9a95 | ||
|
|
b36a3c4abb | ||
|
|
0bac205565 | ||
|
|
67a8ad8e12 | ||
|
|
9de2f66f50 | ||
|
|
9370030ff3 | ||
|
|
e38d6e7ef0 | ||
|
|
2f21fc3575 | ||
|
|
63e73f5f64 | ||
|
|
e1adc1ba49 | ||
|
|
030e911ea4 | ||
|
|
d2f114e44e | ||
|
|
700d3f84d3 | ||
|
|
1d49042013 | ||
|
|
8671b1e6cf | ||
|
|
517d6c44ec | ||
|
|
a082a659ea | ||
|
|
083153efc9 | ||
|
|
65a2560153 | ||
|
|
29535c10a3 | ||
|
|
24c7362163 | ||
|
|
f6ff7d7b16 | ||
|
|
b0a075cdf2 | ||
|
|
98d4d6b33c | ||
|
|
9ba3e0512b | ||
|
|
eff63175e5 | ||
|
|
75a0b632bc | ||
|
|
a2af626477 | ||
|
|
8aa97f64ef | ||
|
|
caa1e04b5a | ||
|
|
cddf6a0204 | ||
|
|
9fa1f42dc7 | ||
|
|
c7e709d487 | ||
|
|
6801398f3d | ||
|
|
982d14c049 | ||
|
|
ddbaf55ae7 | ||
|
|
5552a8501b | ||
|
|
b997becb2f | ||
|
|
753516bab7 | ||
|
|
89992d8636 | ||
|
|
7dd42f964b | ||
|
|
078a7a5519 | ||
|
|
d811f721ac | ||
|
|
26950ba045 | ||
|
|
80adb70e78 | ||
|
|
0c042acd4a | ||
|
|
0ad0c4151a | ||
|
|
65a8a1e1f7 | ||
|
|
a2ac8af882 | ||
|
|
52afbd3f15 | ||
|
|
ce35ee5ca8 | ||
|
|
74c64c6420 | ||
|
|
678328b7aa | ||
|
|
345c8bc094 | ||
|
|
44386490c8 | ||
|
|
87158a342a | ||
|
|
0b43fae32a | ||
|
|
89f7a95167 | ||
|
|
c5be3e5634 | ||
|
|
7156740f6c | ||
|
|
2d29b626c7 | ||
|
|
698145be1e | ||
|
|
a9188cbfdd | ||
|
|
d07cca0278 | ||
|
|
60d1dc51ad | ||
|
|
105073e412 | ||
|
|
9d1f1fff47 | ||
|
|
08050ec35e | ||
|
|
bd9751d888 | ||
|
|
7d171b0907 | ||
|
|
5b8f311465 | ||
|
|
801465ac51 | ||
|
|
a84e2ae9b3 | ||
|
|
9496d1d47f | ||
|
|
36e575e0a2 | ||
|
|
70ccb8942b | ||
|
|
d3cd3d43bd | ||
|
|
9116f0d06c | ||
|
|
2c91e26add | ||
|
|
f1647443dc | ||
|
|
b6b6ce2d4a | ||
|
|
abcc869537 | ||
|
|
3e02e1676a | ||
|
|
5c8a4de446 | ||
|
|
7cabef946e | ||
|
|
f2519e5af2 | ||
|
|
63f1767755 | ||
|
|
5b002e88b7 | ||
|
|
3723e70e6f | ||
|
|
7c08ddbb07 | ||
|
|
c8027f5b81 | ||
|
|
393e418e68 | ||
|
|
dcc3e5fa79 | ||
|
|
f4e6c407ba | ||
|
|
e718a56ed9 | ||
|
|
068443f3fd | ||
|
|
1efc8cb934 | ||
|
|
1ce0620620 | ||
|
|
249a35f90f | ||
|
|
d003de3270 | ||
|
|
9cb2ed10b5 | ||
|
|
4a376f1b67 | ||
|
|
c540f3902c | ||
|
|
accc04ef90 | ||
|
|
d54bd3dc54 | ||
|
|
a54bbb4e14 | ||
|
|
6b1b999546 | ||
|
|
a5aeafc4bc | ||
|
|
39ea5cc456 | ||
|
|
a225b8d50a | ||
|
|
e0036b1cbb | ||
|
|
9a5833f7c9 | ||
|
|
06a1372e80 | ||
|
|
7a16cf74f0 | ||
|
|
4239c89b76 | ||
|
|
29ea5cc74d | ||
|
|
fa27be083d | ||
|
|
9be56c47e4 | ||
|
|
249720b0cc | ||
|
|
3553cb6694 | ||
|
|
3c0fa4c55e | ||
|
|
c07a4b6c16 | ||
|
|
8175eb4446 | ||
|
|
eeab418c90 | ||
|
|
0eb59d823e | ||
|
|
f07705268d | ||
|
|
63fef39854 | ||
|
|
3ea45da2c8 | ||
|
|
eb0d9f3ba4 | ||
|
|
8432f725a9 | ||
|
|
7015b80888 | ||
|
|
ddcc103f37 | ||
|
|
1ac16d1933 | ||
|
|
0f36a88f0e | ||
|
|
b30031d025 | ||
|
|
b849964562 | ||
|
|
cd152f0cd7 | ||
|
|
12280b51b9 | ||
|
|
29256c5766 | ||
|
|
8b13c0b197 | ||
|
|
50e2037fba | ||
|
|
f86c10af02 | ||
|
|
00e165b139 | ||
|
|
02199bbe9d | ||
|
|
d591a55140 | ||
|
|
508295b558 | ||
|
|
bdc33e1430 | ||
|
|
d55dcb2dfb | ||
|
|
79ac4c1d45 | ||
|
|
c6bfa85a1a | ||
|
|
82289714ba | ||
|
|
77142bd99e | ||
|
|
538f5c6501 | ||
|
|
3ff02fb183 | ||
|
|
30298b4237 | ||
|
|
9f2c9a989f | ||
|
|
146147bed8 | ||
|
|
76499b20c4 | ||
|
|
b21e79daf5 | ||
|
|
71194108de | ||
|
|
11fd50f78d | ||
|
|
c08d1d7b3c | ||
|
|
2febf5a97a | ||
|
|
cea7b1e494 | ||
|
|
25962e2e53 | ||
|
|
43f9b141fe | ||
|
|
e1b729ea96 | ||
|
|
f9a18817b7 | ||
|
|
23cb97d314 | ||
|
|
32e085b609 | ||
|
|
389dee8db9 | ||
|
|
dba6fdf7e4 | ||
|
|
cc45dcf91e | ||
|
|
4aeb554f1b | ||
|
|
3d2268420b | ||
|
|
ca388be121 | ||
|
|
f9ca13ff30 | ||
|
|
319dbcdc49 | ||
|
|
bffbbd59ce | ||
|
|
8bd1d0ec92 | ||
|
|
0daec29fab | ||
|
|
bb3dbe0510 | ||
|
|
2fa9e3b0ee | ||
|
|
40d1750345 | ||
|
|
d2d4ea3033 | ||
|
|
ff55170002 | ||
|
|
444db6a560 | ||
|
|
b015f27e14 | ||
|
|
67a1f23b13 | ||
|
|
9c98a7a9e3 | ||
|
|
5aa5ad8ad3 | ||
|
|
ac203ec931 | ||
|
|
3fd73186f4 | ||
|
|
46307469e5 | ||
|
|
31a67f3aed | ||
|
|
44919d2750 | ||
|
|
cff87c641b | ||
|
|
abbd71d057 | ||
|
|
aacfe8386a | ||
|
|
97944d771a | ||
|
|
3f1b616a5e | ||
|
|
fdcc2fd2e5 | ||
|
|
855032ed1e | ||
|
|
760e109aab | ||
|
|
4c799bca8f | ||
|
|
2d08ebc054 | ||
|
|
91ab2c2b31 | ||
|
|
13ad57d49f | ||
|
|
a109e3078d | ||
|
|
2e61a3c309 | ||
|
|
0373bea4e5 | ||
|
|
2d5825d73d | ||
|
|
c4a042cb1d | ||
|
|
205f9476fa | ||
|
|
a1230fcbb6 | ||
|
|
ba5c32a4a1 | ||
|
|
58eee64326 | ||
|
|
41d786a13c | ||
|
|
a2b7906c89 | ||
|
|
eeb6fa4677 | ||
|
|
6a36d75774 | ||
|
|
6078f3c780 | ||
|
|
fc11197725 | ||
|
|
8c40b99194 | ||
|
|
de53fc6510 | ||
|
|
d4f4feb429 | ||
|
|
02973c49ff | ||
|
|
01dce9f139 | ||
|
|
6c0906e87d | ||
|
|
d7cfc4c71a | ||
|
|
fec3e7eac5 | ||
|
|
9f5e2c7dd4 | ||
|
|
c5276cca6c | ||
|
|
74dbbbed8a | ||
|
|
629ac4b93c | ||
|
|
5ece7e84b3 | ||
|
|
eaba857676 | ||
|
|
db489a3cae | ||
|
|
4821ab8597 | ||
|
|
670b769f82 | ||
|
|
eb53399824 | ||
|
|
24e4fbfb68 | ||
|
|
7f54ca4ac3 | ||
|
|
b224803e4d | ||
|
|
28b2025aaa |
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
runtime/assets/default.html
|
||||
30
.eslintrc
Normal file
30
.eslintrc
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2016,
|
||||
"sourceType": "module",
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
"tab"
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
||||
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -7,6 +7,11 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#####################################################
|
||||
If you have a technical issue, please do not open a bug this way!
|
||||
Please use the `wails issue` command!
|
||||
#####################################################
|
||||
|
||||
**Description**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
@@ -24,7 +29,7 @@ A clear and concise description of what you expected to happen.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**System Details**
|
||||
Please paste the output of `wails report` here.
|
||||
Please provide your platform, GO version and variables, etc
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
19
.github/stale.yml
vendored
Normal file
19
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 30
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- onhold
|
||||
- inprogress
|
||||
# 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
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
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
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -15,4 +15,5 @@ examples/**/example*
|
||||
!examples/**/*.*
|
||||
cmd/wails/wails
|
||||
.DS_Store
|
||||
tmp
|
||||
tmp
|
||||
node_modules/
|
||||
34
.goreleaser.yml
Normal file
34
.goreleaser.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
# This is an example goreleaser.yaml file with some sane defaults.
|
||||
# Make sure to check the documentation at http://goreleaser.com
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- windows
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- 386
|
||||
- amd64
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: 386
|
||||
main: ./cmd/wails/main.go
|
||||
archive:
|
||||
replacements:
|
||||
darwin: Darwin
|
||||
linux: Linux
|
||||
windows: Windows
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
name_template: "{{ .Tag }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
6
.hound.yml
Normal file
6
.hound.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
jshint:
|
||||
config_file: .jshintrc
|
||||
eslint:
|
||||
enabled: true
|
||||
config_file: .eslintrc
|
||||
ignore_file: .eslintignore
|
||||
33
.vscode/launch.json
vendored
33
.vscode/launch.json
vendored
@@ -5,14 +5,43 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch",
|
||||
"name": "Test cmd package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "test",
|
||||
"program": "${workspaceFolder}/cmd/"
|
||||
},
|
||||
{
|
||||
"name": "Wails Init",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/cmd/wails/main.go",
|
||||
"env": {},
|
||||
"cwd": "/tmp",
|
||||
"args": [
|
||||
"setup"
|
||||
"init",
|
||||
"-name",
|
||||
"runtime",
|
||||
"-dir",
|
||||
"runtime",
|
||||
"-output",
|
||||
"runtime",
|
||||
"-template",
|
||||
"vuebasic"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Wails Update Pre",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/cmd/wails/main.go",
|
||||
"env": {},
|
||||
"cwd": "/tmp",
|
||||
"args": [
|
||||
"update",
|
||||
"-pre"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"go.formatTool": "goimports",
|
||||
"eslint.alwaysShowStatus": true
|
||||
}
|
||||
34
CHANGELOG.md
Normal file
34
CHANGELOG.md
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
2019-07-20 **v0.17.6-pre**
|
||||
* Significant refactor of runtime
|
||||
* Removed wailsbridge file - now a unified approach taken
|
||||
* Fixed React on Windows - Thanks [Florian Didran](https://github.com/fdidron)!
|
||||
|
||||
2019-06-18 **v0.16.0**
|
||||
* React template FTW! - Thanks [admin_3.exe](https://github.com/bh90210)!
|
||||
* Updated contributors
|
||||
* Arch Linux detection without lsb-release
|
||||
* Removed deprecated methods for dealing with JS/CSS in the backend
|
||||
|
||||
2019-05-29 **v0.14.11-pre**
|
||||
* Windows fix for spinner
|
||||
|
||||
2019-05-29 **v0.14.10-pre**
|
||||
* Windows fix for Vuetify
|
||||
|
||||
2019-05-29 **v0.14.9-pre**
|
||||
* Vuetify project template 🎉
|
||||
|
||||
2019-05-29 **v0.14.8-pre**
|
||||
* Updated Ubuntu npm install command
|
||||
|
||||
2019-05-22 **v0.14.7-pre**
|
||||
* New projects are built automatically when initialised
|
||||
* Go 1.12 is now a minimum requirement
|
||||
|
||||
2019-05-21 **v0.14.6-pre**
|
||||
* Hotfix for module dependency issue
|
||||
|
||||
2019-05-20 **v0.14.5-pre**
|
||||
* Added developer tooling - New Template Generator
|
||||
* Documentation fixes - Thanks [admin_3.exe](https://github.com/bh90210)!
|
||||
19
CONTRIBUTORS.md
Normal file
19
CONTRIBUTORS.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Contributors
|
||||
|
||||
Wails is what it is because of the time and effort given by these great people. A huge thank you to each and every one!
|
||||
|
||||
* [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot)
|
||||
* [Qais Patankar](https://github.com/qaisjp)
|
||||
* [Anthony Lee](https://github.com/alee792)
|
||||
* [Adrian Lanzafame](https://github.com/lanzafame)
|
||||
* [0xflotus](https://github.com/0xflotus)
|
||||
* [Michael D Henderson](https://github.com/mdhender)
|
||||
* [fred2104](https://github.com/fishfishfish2104)
|
||||
* [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)
|
||||
* [fallendusk](https://github.com/fallendusk)
|
||||
* [Florian Didran](https://github.com/fdidron)
|
||||
* [Nikolai Zimmermann](https://github.com/Chronophylos)
|
||||
* [Toyam Cox](https://github.com/Vaelatern)
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 wailsapp
|
||||
Copyright (c) 2018-Present Lea Anthony
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
145
README.md
145
README.md
@@ -1 +1,144 @@
|
||||
# Coming Soon
|
||||
<p align="center" style="text-align: center">
|
||||
<img src="https://github.com/wailsapp/docs/raw/master/.vuepress/public/media/logo_cropped.png" width="40%"><br/>
|
||||
</p>
|
||||
<p align="center">
|
||||
A framework for building desktop applications using Go & Web Technologies.<br/><br/>
|
||||
<a href="https://github.com/wailsapp/wails/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
|
||||
<a href="https://goreportcard.com/report/github.com/wailsapp/wails"><img src="https://goreportcard.com/badge/github.com/wailsapp/wails"/></a>
|
||||
<a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
|
||||
<a href="https://www.codefactor.io/repository/github/wailsapp/wails"><img src="https://www.codefactor.io/repository/github/wailsapp/wails/badge" alt="CodeFactor" /></a>
|
||||
<a href="https://github.com/wailsapp/wails/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="CodeFactor" /></a>
|
||||
<a href="https://houndci.com"><img src="https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg"/></a>
|
||||
<a href="https://github.com/avelino/awesome-go" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></a>
|
||||
<a href="https://dashboard.guardrails.io/default/gh/wailsapp/wails"><img src="https://badges.guardrails.io/wailsapp/wails.svg?token=53657bc22ec360d7673c894fdd70568e918ec581d10d84427ed4de5fe1eeff1a"></a>
|
||||
</p>
|
||||
|
||||
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!
|
||||
|
||||
## Features
|
||||
|
||||
- Use standard Go libraries/frameworks for the backend
|
||||
- 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
|
||||
|
||||
## Project Status
|
||||
|
||||
Wails is currently in Beta. Please make sure you read the [Project Status](https://wails.app/project_status.html) if you are interested in using this project.
|
||||
|
||||
## 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.12
|
||||
- npm
|
||||
|
||||
### MacOS
|
||||
|
||||
Make sure you have the xcode command line tools installed. This can be done by running:
|
||||
|
||||
`xcode-select --install`
|
||||
|
||||
### Linux
|
||||
|
||||
#### 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-Rolling_
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
`sudo pacman -S webkit2gtk gtk3`
|
||||
|
||||
_Also succesfully test on: ArcoLinuxB_
|
||||
|
||||
#### Centos
|
||||
|
||||
`sudo yum install webkitgtk3-devel gtk3-devel`
|
||||
|
||||
_CentOS 6, 7_
|
||||
|
||||
#### Fedora
|
||||
|
||||
`sudo yum install webkit2gtk3-devel gtk3-devel`
|
||||
|
||||
_Fedora 29, 30_
|
||||
|
||||
#### VoidLinux & VoidLinux-musl
|
||||
|
||||
`xbps-install gtk+3-devel webkit2gtk-devel`
|
||||
|
||||
#### Gentoo
|
||||
|
||||
`sudo emerge gtk+:3 webkit-gtk`
|
||||
|
||||
### 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.
|
||||
|
||||
## Installation
|
||||
|
||||
**Ensure Go modules are enabled: GO111MODULE=on and go/bin is in your PATH variable.**
|
||||
|
||||
Installation is as simple as running the following command:
|
||||
|
||||
<pre style='color:white'>
|
||||
go get github.com/wailsapp/wails/cmd/wails
|
||||
</pre>
|
||||
|
||||
## Next Steps
|
||||
|
||||
It is recommended at this stage to read the comprehensive documentation at [https://wails.app](https://wails.app).
|
||||
|
||||
## FAQ
|
||||
|
||||
* Is this an alternative to Electron?
|
||||
|
||||
Depends on your requirements. It's designed to make it easy for Go programmers to make lightweight desktop applications or add a frontend to their existing applications. Whilst Wails does not currently offer hooks into native elements such as menus, this may change in the future.
|
||||
|
||||
* Who is this project aimed at?
|
||||
|
||||
Go programmers who want to bundle an HTML/JS/CSS frontend with their applications, without resorting to creating a server and opening a browser to view it.
|
||||
|
||||
* What's with the name?
|
||||
|
||||
When I saw WebView, I thought "What I really want is tooling around building a WebView app, a bit like Rails is to Ruby". So initially it was a play on words (Webview on Rails). It just so happened to also be a homophone of the English name for the [Country](https://en.wikipedia.org/wiki/Wales) I am from. So it stuck.
|
||||
|
||||
## Shoulders of Giants
|
||||
|
||||
Without the following people, this project would never have existed:
|
||||
|
||||
* [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) - His support and feedback has been immense. More patience than you can throw a stick at (Not long now Dustin!).
|
||||
* [Serge Zaitsev](https://github.com/zserge) - Creator of [Webview](https://github.com/zserge/webview) which Wails uses for the windowing.
|
||||
|
||||
And without [these people](CONTRIBUTORS.md), it wouldn't be what it is today. A huge thank you to each and every one of you!
|
||||
|
||||
Special Mentions:
|
||||
|
||||
* [Bill Kennedy](https://twitter.com/goinggodotnet) - Go guru, encourager and all-round nice guy, whose infectious energy and inspiration powered me on when I had none left.
|
||||
* [Mark Bates](https://github.com/markbates) - Creator of [Packr](https://github.com/gobuffalo/packr), inspiration for packing strategies which fed into some of the tooling.
|
||||
|
||||
This project was mainly coded to the following albums:
|
||||
|
||||
* [Manic Street Preachers - Resistance Is Futile](https://open.spotify.com/album/1R2rsEUqXjIvAbzM0yHrxA)
|
||||
* [Manic Street Preachers - This Is My Truth, Tell Me Yours](https://open.spotify.com/album/4VzCL9kjhgGQeKCiojK1YN)
|
||||
* [The Midnight - Endless Summer](https://open.spotify.com/album/4Krg8zvprquh7TVn9OxZn8)
|
||||
* [Gary Newman - Savage (Songs from a Broken World)](https://open.spotify.com/album/3kMfsD07Q32HRWKRrpcexr)
|
||||
* [Steve Vai - Passion & Warfare](https://open.spotify.com/album/0oL0OhrE2rYVns4IGj8h2m)
|
||||
* [Ben Howard - Every Kingdom](https://open.spotify.com/album/1nJsbWm3Yy2DW1KIc1OKle)
|
||||
* [Ben Howard - Noonday Dream](https://open.spotify.com/album/6astw05cTiXEc2OvyByaPs)
|
||||
* [Adwaith - Melyn](https://open.spotify.com/album/2vBE40Rp60tl7rNqIZjaXM)
|
||||
* [Gwidaith Hen Fran - Cedors Hen Wrach](https://open.spotify.com/album/3v2hrfNGINPLuDP0YDTOjm)
|
||||
* [Metallica - Metallica](https://open.spotify.com/album/2Kh43m04B1UkVcpcRa1Zug)
|
||||
* [Bloc Party - Silent Alarm](https://open.spotify.com/album/6SsIdN05HQg2GwYLfXuzLB)
|
||||
* [Maxthor - Another World](https://open.spotify.com/album/3tklE2Fgw1hCIUstIwPBJF)
|
||||
* [Alun Tan Lan - Y Distawrwydd](https://open.spotify.com/album/0c32OywcLpdJCWWMC6vB8v)
|
||||
|
||||
85
app.go
85
app.go
@@ -2,6 +2,12 @@ package wails
|
||||
|
||||
import (
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
"github.com/wailsapp/wails/lib/binding"
|
||||
"github.com/wailsapp/wails/lib/event"
|
||||
"github.com/wailsapp/wails/lib/interfaces"
|
||||
"github.com/wailsapp/wails/lib/ipc"
|
||||
"github.com/wailsapp/wails/lib/logger"
|
||||
"github.com/wailsapp/wails/lib/renderer"
|
||||
)
|
||||
|
||||
// -------------------------------- Compile time Flags ------------------------------
|
||||
@@ -13,20 +19,15 @@ var BuildMode = cmd.BuildModeProd
|
||||
|
||||
// App defines the main application struct
|
||||
type App struct {
|
||||
config *AppConfig // The Application configuration object
|
||||
cli *cmd.Cli // In debug mode, we have a cli
|
||||
renderer Renderer // The renderer is what we will render the app to
|
||||
logLevel string // The log level of the app
|
||||
ipc *ipcManager // Handles the IPC calls
|
||||
log *CustomLogger // Logger
|
||||
bindingManager *bindingManager // Handles binding of Go code to renderer
|
||||
eventManager *eventManager // Handles all the events
|
||||
runtime *Runtime // The runtime object for registered structs
|
||||
|
||||
// This is a list of all the JS/CSS that needs injecting
|
||||
// It will get injected in order
|
||||
jsCache []string
|
||||
cssCache []string
|
||||
config *AppConfig // The Application configuration object
|
||||
cli *cmd.Cli // In debug mode, we have a cli
|
||||
renderer interfaces.Renderer // The renderer is what we will render the app to
|
||||
logLevel string // The log level of the app
|
||||
ipc interfaces.IPCManager // Handles the IPC calls
|
||||
log *logger.CustomLogger // Logger
|
||||
bindingManager interfaces.BindingManager // Handles binding of Go code to renderer
|
||||
eventManager interfaces.EventManager // Handles all the events
|
||||
runtime interfaces.Runtime // The runtime object for registered structs
|
||||
}
|
||||
|
||||
// CreateApp creates the application window with the given configuration
|
||||
@@ -39,14 +40,14 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
||||
|
||||
result := &App{
|
||||
logLevel: "info",
|
||||
renderer: &webViewRenderer{},
|
||||
ipc: newIPCManager(),
|
||||
bindingManager: newBindingManager(),
|
||||
eventManager: newEventManager(),
|
||||
log: newCustomLogger("App"),
|
||||
renderer: renderer.NewWebView(),
|
||||
ipc: ipc.NewManager(),
|
||||
bindingManager: binding.NewManager(),
|
||||
eventManager: event.NewManager(),
|
||||
log: logger.NewCustomLogger("App"),
|
||||
}
|
||||
|
||||
appconfig, err := newAppConfig(userConfig)
|
||||
appconfig, err := newConfig(userConfig)
|
||||
if err != nil {
|
||||
result.log.Fatalf("Cannot use custom HTML: %s", err.Error())
|
||||
}
|
||||
@@ -70,20 +71,24 @@ func (a *App) Run() error {
|
||||
}
|
||||
|
||||
a.logLevel = "error"
|
||||
return a.start()
|
||||
err := a.start()
|
||||
if err != nil {
|
||||
a.log.Error(err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) start() error {
|
||||
|
||||
// Set the log level
|
||||
setLogLevel(a.logLevel)
|
||||
logger.SetLogLevel(a.logLevel)
|
||||
|
||||
// Log starup
|
||||
a.log.Info("Starting")
|
||||
|
||||
// Check if we are to run in headless mode
|
||||
// Check if we are to run in bridge mode
|
||||
if BuildMode == cmd.BuildModeBridge {
|
||||
a.renderer = &Headless{}
|
||||
a.renderer = &renderer.Bridge{}
|
||||
}
|
||||
|
||||
// Initialise the renderer
|
||||
@@ -93,46 +98,26 @@ func (a *App) start() error {
|
||||
}
|
||||
|
||||
// Start event manager and give it our renderer
|
||||
a.eventManager.start(a.renderer)
|
||||
a.eventManager.Start(a.renderer)
|
||||
|
||||
// Start the IPC Manager and give it the event manager and binding manager
|
||||
a.ipc.start(a.eventManager, a.bindingManager)
|
||||
a.ipc.Start(a.eventManager, a.bindingManager)
|
||||
|
||||
// Create the runtime
|
||||
a.runtime = newRuntime(a.eventManager, a.renderer)
|
||||
a.runtime = NewRuntime(a.eventManager, a.renderer)
|
||||
|
||||
// Start binding manager and give it our renderer
|
||||
err = a.bindingManager.start(a.renderer, a.runtime)
|
||||
err = a.bindingManager.Start(a.renderer, a.runtime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Inject CSS
|
||||
a.renderer.AddCSSList(a.cssCache)
|
||||
|
||||
// Inject JS
|
||||
a.renderer.AddJSList(a.jsCache)
|
||||
|
||||
// Run the renderer
|
||||
a.renderer.Run()
|
||||
|
||||
return nil
|
||||
return a.renderer.Run()
|
||||
}
|
||||
|
||||
// Bind allows the user to bind the given object
|
||||
// with the application
|
||||
func (a *App) Bind(object interface{}) {
|
||||
a.bindingManager.bind(object)
|
||||
}
|
||||
|
||||
// AddJS adds a piece of Javascript to a cache that
|
||||
// gets injected at runtime
|
||||
func (a *App) AddJS(js string) {
|
||||
a.jsCache = append(a.jsCache, js)
|
||||
}
|
||||
|
||||
// AddCSS adds a CSS string to a cache that
|
||||
// gets injected at runtime
|
||||
func (a *App) AddCSS(js string) {
|
||||
a.cssCache = append(a.cssCache, js)
|
||||
a.bindingManager.Bind(object)
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package wails
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/dchest/htmlmin"
|
||||
"github.com/leaanthony/mewn"
|
||||
)
|
||||
|
||||
// AppConfig is the configuration structure used when creating a Wails App object
|
||||
type AppConfig struct {
|
||||
Width, Height int
|
||||
Title string
|
||||
defaultHTML string
|
||||
HTML string
|
||||
JS string
|
||||
CSS string
|
||||
Colour string
|
||||
Resizable bool
|
||||
DisableInspector bool
|
||||
isHTMLFragment bool
|
||||
}
|
||||
|
||||
func (a *AppConfig) merge(in *AppConfig) error {
|
||||
if in.CSS != "" {
|
||||
a.CSS = in.CSS
|
||||
}
|
||||
if in.Title != "" {
|
||||
a.Title = in.Title
|
||||
}
|
||||
if in.HTML != "" {
|
||||
minified, err := htmlmin.Minify([]byte(in.HTML), &htmlmin.Options{
|
||||
MinifyScripts: true,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inlineHTML := string(minified)
|
||||
inlineHTML = strings.Replace(inlineHTML, "'", "\\'", -1)
|
||||
inlineHTML = strings.Replace(inlineHTML, "\n", " ", -1)
|
||||
a.HTML = strings.TrimSpace(inlineHTML)
|
||||
|
||||
// Deduce whether this is a full html page or a fragment
|
||||
// The document is determined to be a fragment if an HMTL
|
||||
// tag exists and is located before the first div tag
|
||||
HTMLTagIndex := strings.Index(a.HTML, "<html")
|
||||
DivTagIndex := strings.Index(a.HTML, "<div")
|
||||
|
||||
if HTMLTagIndex == -1 {
|
||||
a.isHTMLFragment = true
|
||||
} else {
|
||||
if DivTagIndex < HTMLTagIndex {
|
||||
a.isHTMLFragment = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if in.Colour != "" {
|
||||
a.Colour = in.Colour
|
||||
}
|
||||
|
||||
if in.JS != "" {
|
||||
a.JS = in.JS
|
||||
}
|
||||
|
||||
if in.Width != 0 {
|
||||
a.Width = in.Width
|
||||
}
|
||||
if in.Height != 0 {
|
||||
a.Height = in.Height
|
||||
}
|
||||
a.Resizable = in.Resizable
|
||||
a.DisableInspector = in.DisableInspector
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Creates the default configuration
|
||||
func newAppConfig(userConfig *AppConfig) (*AppConfig, error) {
|
||||
result := &AppConfig{
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
Resizable: true,
|
||||
Title: "My Wails App",
|
||||
Colour: "#FFF", // White by default
|
||||
HTML: mewn.String("./wailsruntimeassets/default/default.html"),
|
||||
}
|
||||
|
||||
if userConfig != nil {
|
||||
err := result.merge(userConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
138
azure-pipelines.yaml
Normal file
138
azure-pipelines.yaml
Normal file
@@ -0,0 +1,138 @@
|
||||
# avoid double trigger by applying some rules
|
||||
# start a pipeline when push to 'master' branch
|
||||
trigger:
|
||||
- master
|
||||
# or when pull request on 'develop' branch
|
||||
pr:
|
||||
- develop
|
||||
|
||||
# for now there is only one stage 'Build'
|
||||
# in the future we could use multistage strategy for releases
|
||||
stages:
|
||||
- stage: Build
|
||||
|
||||
# there are 3 jobs
|
||||
# one for each os
|
||||
jobs:
|
||||
- deployment: Linux
|
||||
displayName: Lin
|
||||
variables:
|
||||
GOPATH: '$(Agent.BuildDirectory)/gopath' # Go workspace path
|
||||
GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path
|
||||
GOBIN: '$(GOPATH)/bin' # Go binaries path
|
||||
GOMODULE: 'on'
|
||||
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
|
||||
pool:
|
||||
vmImage: 'Ubuntu-16.04'
|
||||
environment: 'linux-dev'
|
||||
strategy:
|
||||
runOnce:
|
||||
deploy:
|
||||
steps:
|
||||
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
|
||||
clean: true # whether to fetch clean each time
|
||||
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
|
||||
# go version 1.12.7
|
||||
- script: |
|
||||
wget "https://storage.googleapis.com/golang/go1.12.7.linux-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
|
||||
tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
|
||||
displayName: 'Install Go 1.12.7 Linux'
|
||||
- script: |
|
||||
mkdir -p '$(GOBIN)'
|
||||
mkdir -p '$(GOPATH)/pkg'
|
||||
mkdir -p '$(GOROOT)'
|
||||
shopt -s extglob
|
||||
shopt -s dotglob
|
||||
echo '##vso[task.prependpath]$(GOBIN)'
|
||||
echo '##vso[task.prependpath]$(GOROOT)/bin'
|
||||
displayName: 'Set up the Go workspace'
|
||||
- script: |
|
||||
go version
|
||||
go get -v -d ./...
|
||||
cd cmd/wails
|
||||
go install
|
||||
workingDirectory: '$(modulePath)'
|
||||
displayName: 'Get dependencies, then build'
|
||||
- script: |
|
||||
wails version
|
||||
workingDirectory: '$(modulePath)'
|
||||
displayName: 'Check we have output'
|
||||
|
||||
- deployment: Mac
|
||||
displayName: Mac
|
||||
variables:
|
||||
GOPATH: '$(Agent.BuildDirectory)/gopath' # Go workspace path
|
||||
GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path
|
||||
GOBIN: '$(GOPATH)/bin' # Go binaries path
|
||||
GOMODULE: 'on'
|
||||
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
|
||||
pool:
|
||||
vmImage: 'macOS-10.14'
|
||||
environment: 'mac-dev'
|
||||
strategy:
|
||||
runOnce:
|
||||
deploy:
|
||||
steps:
|
||||
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
|
||||
clean: true # whether to fetch clean each time
|
||||
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
|
||||
# go version 1.12.7
|
||||
- script: |
|
||||
wget "https://storage.googleapis.com/golang/go1.12.7.darwin-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
|
||||
tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
|
||||
displayName: 'Install Go 1.12.7 Linux'
|
||||
- script: |
|
||||
mkdir -p '$(GOBIN)'
|
||||
mkdir -p '$(GOPATH)/pkg'
|
||||
mkdir -p '$(GOROOT)'
|
||||
shopt -s extglob
|
||||
shopt -s dotglob
|
||||
echo '##vso[task.prependpath]$(GOBIN)'
|
||||
echo '##vso[task.prependpath]$(GOROOT)/bin'
|
||||
displayName: 'Set up the Go workspace'
|
||||
- script: |
|
||||
go version
|
||||
go get -v -d ./...
|
||||
cd cmd/wails
|
||||
go install
|
||||
workingDirectory: '$(modulePath)'
|
||||
displayName: 'Get dependencies, then build'
|
||||
- script: |
|
||||
wails version
|
||||
workingDirectory: '$(modulePath)'
|
||||
displayName: 'Check we have output'
|
||||
|
||||
- deployment: Win
|
||||
displayName: Win
|
||||
variables:
|
||||
GOMODULE: 'on'
|
||||
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
environment: 'win-dev'
|
||||
strategy:
|
||||
runOnce:
|
||||
deploy:
|
||||
steps:
|
||||
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
|
||||
clean: true # whether to fetch clean each time
|
||||
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
|
||||
# Go tool installer
|
||||
# Find in cache or download a specific version of Go and add it to the PATH
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
version: '1.12.7'
|
||||
goPath: '$(Agent.BuildDirectory)/go'
|
||||
goBin: '$(Agent.BuildDirectory)/go/bin'
|
||||
displayName: 'Set up the Go workspace'
|
||||
- script: |
|
||||
go version
|
||||
go get -v -d ./...
|
||||
cd cmd/wails
|
||||
go install
|
||||
workingDirectory: '$(modulePath)'
|
||||
displayName: 'Get dependencies, then build'
|
||||
- script: |
|
||||
wails version
|
||||
workingDirectory: '$(Agent.BuildDirectory)/go/bin'
|
||||
displayName: 'Check we have output'
|
||||
@@ -1,8 +1,6 @@
|
||||
package wails
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
)
|
||||
|
||||
@@ -11,18 +9,16 @@ func (app *App) setupCli() *cmd.Cli {
|
||||
|
||||
// Create a new cli
|
||||
result := cmd.NewCli(app.config.Title, "Debug build")
|
||||
result.Version(cmd.Version)
|
||||
|
||||
// Setup cli to handle loglevel and headless flags
|
||||
// Setup cli to handle loglevel
|
||||
result.
|
||||
StringFlag("loglevel", "Sets the log level [debug|info|error|panic|fatal]. Default debug", &app.logLevel).
|
||||
// BoolFlag("headless", "Runs the app in headless mode", &app.headless).
|
||||
Action(app.start)
|
||||
|
||||
// Banner
|
||||
result.PreRun(func(cli *cmd.Cli) error {
|
||||
log := cmd.NewLogger()
|
||||
log.PrintSmallBanner()
|
||||
fmt.Println()
|
||||
log.YellowUnderline(app.config.Title + " - Debug Build")
|
||||
return nil
|
||||
})
|
||||
20
cmd/cli.go
20
cmd/cli.go
@@ -96,6 +96,7 @@ type Command struct {
|
||||
flagCount int
|
||||
log *Logger
|
||||
helpFlag bool
|
||||
hidden bool
|
||||
}
|
||||
|
||||
// NewCommand creates a new Command
|
||||
@@ -106,6 +107,7 @@ func NewCommand(name string, description string, app *Cli, parentCommandPath str
|
||||
SubCommandsMap: make(map[string]*Command),
|
||||
App: app,
|
||||
log: NewLogger(),
|
||||
hidden: false,
|
||||
}
|
||||
|
||||
// Set up command path
|
||||
@@ -195,10 +197,7 @@ func (c *Command) Action(callback Action) *Command {
|
||||
// PrintHelp - Output the help text for this command
|
||||
func (c *Command) PrintHelp() {
|
||||
c.log.PrintBanner()
|
||||
versionString := c.AppVersion
|
||||
if versionString != "" {
|
||||
versionString = " " + versionString
|
||||
}
|
||||
|
||||
commandTitle := c.CommandPath
|
||||
if c.Shortdescription != "" {
|
||||
commandTitle += " - " + c.Shortdescription
|
||||
@@ -215,6 +214,9 @@ func (c *Command) PrintHelp() {
|
||||
c.log.White("Available commands:")
|
||||
fmt.Println("")
|
||||
for _, subcommand := range c.SubCommands {
|
||||
if subcommand.isHidden() {
|
||||
continue
|
||||
}
|
||||
spacer := strings.Repeat(" ", 3+c.longestSubcommand-len(subcommand.Name))
|
||||
isDefault := ""
|
||||
if subcommand.isDefaultCommand() {
|
||||
@@ -240,6 +242,16 @@ func (c *Command) isDefaultCommand() bool {
|
||||
return c.App.defaultCommand == c
|
||||
}
|
||||
|
||||
// isHidden returns true if the command is a hidden command
|
||||
func (c *Command) isHidden() bool {
|
||||
return c.hidden
|
||||
}
|
||||
|
||||
// Hidden hides the command from the Help system
|
||||
func (c *Command) Hidden() {
|
||||
c.hidden = true
|
||||
}
|
||||
|
||||
// Command - Defines a subcommand
|
||||
func (c *Command) Command(name, description string) *Command {
|
||||
result := NewCommand(name, description, c.App, c.CommandPath)
|
||||
|
||||
File diff suppressed because one or more lines are too long
76
cmd/fs.go
76
cmd/fs.go
@@ -1,13 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
|
||||
// FSHelper - Wrapper struct for File System utility commands
|
||||
@@ -104,11 +110,33 @@ func (fs *FSHelper) RemoveFiles(files []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Dir holds information about a directory
|
||||
type Dir struct {
|
||||
localPath string
|
||||
fullPath string
|
||||
}
|
||||
|
||||
// Directory creates a new Dir struct with the given directory path
|
||||
func (fs *FSHelper) Directory(dir string) (*Dir, error) {
|
||||
fullPath, err := filepath.Abs(dir)
|
||||
return &Dir{fullPath: fullPath}, err
|
||||
}
|
||||
|
||||
// LocalDir creates a new Dir struct based on a path relative to the caller
|
||||
func (fs *FSHelper) LocalDir(dir string) (*Dir, error) {
|
||||
_, filename, _, _ := runtime.Caller(1)
|
||||
fullPath, err := filepath.Abs(filepath.Join(path.Dir(filename), dir))
|
||||
return &Dir{
|
||||
localPath: dir,
|
||||
fullPath: fullPath,
|
||||
}, err
|
||||
}
|
||||
|
||||
// GetSubdirs will return a list of FQPs to subdirectories in the given directory
|
||||
func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error) {
|
||||
func (d *Dir) GetSubdirs() (map[string]string, error) {
|
||||
|
||||
// Read in the directory information
|
||||
fileInfo, err := ioutil.ReadDir(dir)
|
||||
fileInfo, err := ioutil.ReadDir(d.fullPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -120,25 +148,65 @@ func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error) {
|
||||
// map["directoryName"] = "path/to/directoryName"
|
||||
for _, file := range fileInfo {
|
||||
if file.IsDir() {
|
||||
subdirs[file.Name()] = filepath.Join(dir, file.Name())
|
||||
subdirs[file.Name()] = filepath.Join(d.fullPath, file.Name())
|
||||
}
|
||||
}
|
||||
return subdirs, nil
|
||||
}
|
||||
|
||||
// GetAllFilenames returns all filename in and below this directory
|
||||
func (d *Dir) GetAllFilenames() (*slicer.StringSlicer, error) {
|
||||
result := slicer.String()
|
||||
err := filepath.Walk(d.fullPath, func(dir string, info os.FileInfo, err error) error {
|
||||
if dir == d.fullPath {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Don't copy template metadata
|
||||
result.Add(dir)
|
||||
|
||||
return nil
|
||||
})
|
||||
return result, err
|
||||
}
|
||||
|
||||
// MkDir creates the given directory.
|
||||
// Returns error on failure
|
||||
func (fs *FSHelper) MkDir(dir string) error {
|
||||
return os.Mkdir(dir, 0700)
|
||||
}
|
||||
|
||||
// SaveAsJSON saves the JSON representation of the given data to the given filename
|
||||
func (fs *FSHelper) SaveAsJSON(data interface{}, filename string) error {
|
||||
|
||||
var buf bytes.Buffer
|
||||
e := json.NewEncoder(&buf)
|
||||
e.SetEscapeHTML(false)
|
||||
e.SetIndent("", " ")
|
||||
e.Encode(data)
|
||||
|
||||
err := ioutil.WriteFile(filename, buf.Bytes(), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadAsString will attempt to load the given file and return
|
||||
// its contents as a string
|
||||
func (fs *FSHelper) LoadAsString(filename string) (string, error) {
|
||||
bytes, err := ioutil.ReadFile(filename)
|
||||
bytes, err := fs.LoadAsBytes(filename)
|
||||
return string(bytes), err
|
||||
}
|
||||
|
||||
// LoadAsBytes returns the contents of the file as a byte slice
|
||||
func (fs *FSHelper) LoadAsBytes(filename string) ([]byte, error) {
|
||||
return ioutil.ReadFile(filename)
|
||||
}
|
||||
|
||||
// FileMD5 returns the md5sum of the given file
|
||||
func (fs *FSHelper) FileMD5(filename string) (string, error) {
|
||||
f, err := os.Open(filename)
|
||||
|
||||
108
cmd/github.go
Normal file
108
cmd/github.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// GitHubHelper is a utility class for interacting with GitHub
|
||||
type GitHubHelper struct {
|
||||
}
|
||||
|
||||
// NewGitHubHelper returns a new GitHub Helper
|
||||
func NewGitHubHelper() *GitHubHelper {
|
||||
return &GitHubHelper{}
|
||||
}
|
||||
|
||||
// GetVersionTags gets the list of tags on the Wails repo
|
||||
// It returns a list of sorted tags in descending order
|
||||
func (g *GitHubHelper) GetVersionTags() ([]*SemanticVersion, error) {
|
||||
|
||||
result := []*SemanticVersion{}
|
||||
var err error
|
||||
|
||||
resp, err := http.Get("https://api.github.com/repos/wailsapp/wails/tags")
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
data := []map[string]interface{}{}
|
||||
err = json.Unmarshal(body, &data)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
// Convert tag data to Version structs
|
||||
for _, tag := range data {
|
||||
version := tag["name"].(string)
|
||||
semver, err := NewSemanticVersion(version)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
result = append(result, semver)
|
||||
}
|
||||
|
||||
// Reverse Sort
|
||||
sort.Sort(sort.Reverse(SemverCollection(result)))
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetLatestStableRelease gets the latest stable release on GitHub
|
||||
func (g *GitHubHelper) GetLatestStableRelease() (result *SemanticVersion, err error) {
|
||||
|
||||
tags, err := g.GetVersionTags()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
if tag.IsRelease() {
|
||||
return tag, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no release tag found")
|
||||
}
|
||||
|
||||
// GetLatestPreRelease gets the latest prerelease on GitHub
|
||||
func (g *GitHubHelper) GetLatestPreRelease() (result *SemanticVersion, err error) {
|
||||
|
||||
tags, err := g.GetVersionTags()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
if tag.IsPreRelease() {
|
||||
return tag, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no prerelease tag found")
|
||||
}
|
||||
|
||||
// IsValidTag returns true if the given string is a valid tag
|
||||
func (g *GitHubHelper) IsValidTag(tagVersion string) (bool, error) {
|
||||
if tagVersion[0] == 'v' {
|
||||
tagVersion = tagVersion[1:]
|
||||
}
|
||||
tags, err := g.GetVersionTags()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
if tag.String() == tagVersion {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/leaanthony/spinner"
|
||||
)
|
||||
@@ -36,7 +36,7 @@ func ValidateFrontendConfig(projectOptions *ProjectOptions) error {
|
||||
|
||||
// InstallGoDependencies will run go get in the current directory
|
||||
func InstallGoDependencies() error {
|
||||
depSpinner := spinner.New("Installing Dependencies...")
|
||||
depSpinner := spinner.New("Ensuring Dependencies are up to date...")
|
||||
depSpinner.SetSpinSpeed(50)
|
||||
depSpinner.Start()
|
||||
err := NewProgramHelper().RunCommand("go get")
|
||||
@@ -77,7 +77,14 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
packSpinner.Start()
|
||||
|
||||
buildCommand := slicer.String()
|
||||
buildCommand.AddSlice([]string{"mewn", "build"})
|
||||
buildCommand.Add("mewn")
|
||||
|
||||
if buildMode == BuildModeBridge {
|
||||
// Ignore errors
|
||||
buildCommand.Add("-i")
|
||||
}
|
||||
|
||||
buildCommand.Add("build")
|
||||
|
||||
if binaryName != "" {
|
||||
buildCommand.Add("-o")
|
||||
@@ -110,10 +117,18 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
||||
}
|
||||
packSpinner.Success()
|
||||
|
||||
// packageApp
|
||||
if packageApp {
|
||||
err = PackageApplication(projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PackageApplication will attempt to package the application in a pltform dependent way
|
||||
// PackageApplication will attempt to package the application in a platform dependent way
|
||||
func PackageApplication(projectOptions *ProjectOptions) error {
|
||||
// Package app
|
||||
message := "Generating .app"
|
||||
@@ -189,7 +204,7 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
}
|
||||
|
||||
// Check if frontend deps have been updated
|
||||
feSpinner := spinner.New("Installing frontend dependencies (This may take a while)...")
|
||||
feSpinner := spinner.New("Ensuring frontend dependencies are up to date (This may take a while)")
|
||||
feSpinner.SetSpinSpeed(50)
|
||||
feSpinner.Start()
|
||||
|
||||
@@ -234,16 +249,8 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
}
|
||||
|
||||
bridgeFile := "wailsbridge.prod.js"
|
||||
if caller == "serve" {
|
||||
bridgeFile = "wailsbridge.js"
|
||||
}
|
||||
|
||||
// Copy bridge to project
|
||||
_, filename, _, _ := runtime.Caller(1)
|
||||
bridgeFileSource := filepath.Join(path.Dir(filename), "..", "..", "wailsruntimeassets", "bridge", bridgeFile)
|
||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
|
||||
err = fs.CopyFile(bridgeFileSource, bridgeFileTarget)
|
||||
// Install the runtime
|
||||
err = InstallRuntime(caller, projectDir, projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -256,6 +263,31 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallRuntime installs the correct runtime for the type of build
|
||||
func InstallRuntime(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
||||
if caller == "build" {
|
||||
return InstallProdRuntime(projectDir, projectOptions)
|
||||
}
|
||||
|
||||
return InstallBridge(projectDir, projectOptions)
|
||||
}
|
||||
|
||||
// InstallBridge installs the relevant bridge javascript library
|
||||
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
|
||||
bridgeFileData := mewn.String("../runtime/assets/bridge.js")
|
||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js")
|
||||
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
|
||||
return err
|
||||
}
|
||||
|
||||
// InstallProdRuntime installs the production runtime
|
||||
func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error {
|
||||
prodInit := mewn.String("../runtime/js/runtime/init.js")
|
||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js")
|
||||
err := fs.CreateFile(bridgeFileTarget, []byte(prodInit))
|
||||
return err
|
||||
}
|
||||
|
||||
// ServeProject attempts to serve up the current project so that it may be connected to
|
||||
// via the Wails bridge
|
||||
func ServeProject(projectOptions *ProjectOptions, logger *Logger) error {
|
||||
|
||||
242
cmd/linux.go
242
cmd/linux.go
@@ -2,7 +2,13 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/browser"
|
||||
)
|
||||
|
||||
// LinuxDistribution is of type int
|
||||
@@ -10,70 +16,216 @@ type LinuxDistribution int
|
||||
|
||||
const (
|
||||
// Unknown is the catch-all distro
|
||||
Unknown LinuxDistribution = 0
|
||||
Unknown LinuxDistribution = iota
|
||||
// Debian distribution
|
||||
Debian
|
||||
// Ubuntu distribution
|
||||
Ubuntu LinuxDistribution = 1
|
||||
Ubuntu
|
||||
// Arch linux distribution
|
||||
Arch
|
||||
// CentOS linux distribution
|
||||
CentOS
|
||||
// Fedora linux distribution
|
||||
Fedora
|
||||
// Gentoo distribution
|
||||
Gentoo
|
||||
// Zorin distribution
|
||||
Zorin
|
||||
// Parrot distribution
|
||||
Parrot
|
||||
// Linuxmint distribution
|
||||
Linuxmint
|
||||
// VoidLinux distribution
|
||||
VoidLinux
|
||||
// Elementary distribution
|
||||
Elementary
|
||||
// Kali distribution
|
||||
Kali
|
||||
)
|
||||
|
||||
// DistroInfo contains all the information relating to a linux distribution
|
||||
type DistroInfo struct {
|
||||
Distribution LinuxDistribution
|
||||
Description string
|
||||
Release string
|
||||
Codename string
|
||||
DistributorID string
|
||||
Distribution LinuxDistribution
|
||||
Name string
|
||||
ID string
|
||||
Description string
|
||||
Release string
|
||||
}
|
||||
|
||||
// GetLinuxDistroInfo returns information about the running linux distribution
|
||||
func GetLinuxDistroInfo() *DistroInfo {
|
||||
result := &DistroInfo{Distribution: Unknown}
|
||||
program := NewProgramHelper()
|
||||
// Does lsb_release exist?
|
||||
|
||||
lsbRelease := program.FindProgram("lsb_release")
|
||||
if lsbRelease != nil {
|
||||
stdout, _, _, err := lsbRelease.Run("-a")
|
||||
if err != nil {
|
||||
return result
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(stdout, "\n") {
|
||||
if strings.Contains(line, ":") {
|
||||
// Iterate lines a
|
||||
details := strings.Split(line, ":")
|
||||
key := strings.TrimSpace(details[0])
|
||||
value := strings.TrimSpace(details[1])
|
||||
switch key {
|
||||
case "Distributor ID":
|
||||
result.DistributorID = value
|
||||
switch value {
|
||||
case "Ubuntu":
|
||||
result.Distribution = Ubuntu
|
||||
}
|
||||
case "Description":
|
||||
result.Description = value
|
||||
case "Release":
|
||||
result.Release = value
|
||||
case "Codename":
|
||||
result.Codename = value
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result := &DistroInfo{
|
||||
Distribution: Unknown,
|
||||
ID: "unknown",
|
||||
Name: "Unknown",
|
||||
}
|
||||
_, err := os.Stat("/etc/os-release")
|
||||
if !os.IsNotExist(err) {
|
||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||
result = parseOsRelease(string(osRelease))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// parseOsRelease parses the given os-release data and returns
|
||||
// a DistroInfo struct with the details
|
||||
func parseOsRelease(osRelease string) *DistroInfo {
|
||||
result := &DistroInfo{Distribution: Unknown}
|
||||
|
||||
// Default value
|
||||
osID := "unknown"
|
||||
osNAME := "Unknown"
|
||||
version := ""
|
||||
|
||||
// Split into lines
|
||||
lines := strings.Split(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 "ID":
|
||||
osID = strings.Trim(splitLine[1], "\"")
|
||||
case "NAME":
|
||||
osNAME = strings.Trim(splitLine[1], "\"")
|
||||
case "VERSION_ID":
|
||||
version = strings.Trim(splitLine[1], "\"")
|
||||
}
|
||||
}
|
||||
// Check distro name against list of distros
|
||||
switch osID {
|
||||
case "fedora":
|
||||
result.Distribution = Fedora
|
||||
case "centos":
|
||||
result.Distribution = CentOS
|
||||
case "arch":
|
||||
result.Distribution = Arch
|
||||
case "debian":
|
||||
result.Distribution = Debian
|
||||
case "ubuntu":
|
||||
result.Distribution = Ubuntu
|
||||
case "gentoo":
|
||||
result.Distribution = Gentoo
|
||||
case "zorin":
|
||||
result.Distribution = Zorin
|
||||
case "parrot":
|
||||
result.Distribution = Parrot
|
||||
case "linuxmint":
|
||||
result.Distribution = Linuxmint
|
||||
case "void":
|
||||
result.Distribution = VoidLinux
|
||||
case "elementary":
|
||||
result.Distribution = Elementary
|
||||
default:
|
||||
result.Distribution = Unknown
|
||||
}
|
||||
|
||||
result.Name = osNAME
|
||||
result.ID = osID
|
||||
result.Release = version
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// CheckPkgInstalled is all functions that use local programs to see if a package is installed
|
||||
type CheckPkgInstalled func(string) (bool, error)
|
||||
|
||||
// EqueryInstalled uses equery to see if a package is installed
|
||||
func EqueryInstalled(packageName string) (bool, error) {
|
||||
program := NewProgramHelper()
|
||||
equery := program.FindProgram("equery")
|
||||
if equery == nil {
|
||||
return false, fmt.Errorf("cannont check dependencies: equery not found")
|
||||
}
|
||||
_, _, exitCode, _ := equery.Run("l", packageName)
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
// DpkgInstalled uses dpkg to see if a package is installed
|
||||
func DpkgInstalled(packageName string) (bool, error) {
|
||||
result := false
|
||||
program := NewProgramHelper()
|
||||
dpkg := program.FindProgram("dpkg")
|
||||
if dpkg == nil {
|
||||
return false, fmt.Errorf("cannot check dependencies: dpkg not found")
|
||||
}
|
||||
_, _, exitCode, _ := dpkg.Run("-L", packageName)
|
||||
result = exitCode == 0
|
||||
return result, nil
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
// PacmanInstalled uses pacman to see if a package is installed.
|
||||
func PacmanInstalled(packageName string) (bool, error) {
|
||||
program := NewProgramHelper()
|
||||
pacman := program.FindProgram("pacman")
|
||||
if pacman == nil {
|
||||
return false, fmt.Errorf("cannot check dependencies: pacman not found")
|
||||
}
|
||||
_, _, exitCode, _ := pacman.Run("-Qs", packageName)
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
// XbpsInstalled uses pacman to see if a package is installed.
|
||||
func XbpsInstalled(packageName string) (bool, error) {
|
||||
program := NewProgramHelper()
|
||||
xbpsQuery := program.FindProgram("xbps-query")
|
||||
if xbpsQuery == nil {
|
||||
return false, fmt.Errorf("cannot check dependencies: xbps-query not found")
|
||||
}
|
||||
_, _, exitCode, _ := xbpsQuery.Run("-S", packageName)
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
// RpmInstalled uses rpm to see if a package is installed
|
||||
func RpmInstalled(packageName string) (bool, error) {
|
||||
program := NewProgramHelper()
|
||||
rpm := program.FindProgram("rpm")
|
||||
if rpm == nil {
|
||||
return false, fmt.Errorf("cannot check dependencies: rpm not found")
|
||||
}
|
||||
_, _, 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) error {
|
||||
var logger = NewLogger()
|
||||
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'", distroInfo.Name)
|
||||
|
||||
logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.Name)
|
||||
q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.Name)
|
||||
result := Prompt(q, "yes")
|
||||
if strings.ToLower(result) != "yes" {
|
||||
return defaultError
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("Support Distribution '%s'", distroInfo.Name)
|
||||
|
||||
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.ID))
|
||||
str.WriteString(fmt.Sprintf("| Distribution Name | %s |\n", distroInfo.Name))
|
||||
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
||||
|
||||
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.ID, 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
|
||||
}
|
||||
|
||||
26
cmd/linux_test.go
Normal file
26
cmd/linux_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package cmd
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUbuntuDetection(t *testing.T) {
|
||||
osrelease := `
|
||||
NAME="Ubuntu"
|
||||
VERSION="18.04.2 LTS (Bionic Beaver)"
|
||||
ID=ubuntu
|
||||
ID_LIKE=debian
|
||||
PRETTY_NAME="Ubuntu 18.04.2 LTS"
|
||||
VERSION_ID="18.04"
|
||||
HOME_URL="https://www.ubuntu.com/"
|
||||
SUPPORT_URL="https://help.ubuntu.com/"
|
||||
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
||||
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
||||
VERSION_CODENAME=bionic
|
||||
UBUNTU_CODENAME=bionic
|
||||
`
|
||||
|
||||
result := parseOsRelease(osrelease)
|
||||
if result.Distribution != Ubuntu {
|
||||
t.Errorf("expected 'Ubuntu' ID but got '%d'", result.Distribution)
|
||||
}
|
||||
|
||||
}
|
||||
91
cmd/linuxdb.go
Normal file
91
cmd/linuxdb.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/leaanthony/mewn"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// LinuxDB is the database for linux distribution data.
|
||||
type LinuxDB struct {
|
||||
Distributions map[string]*Distribution `yaml:"distributions"`
|
||||
}
|
||||
|
||||
// Distribution holds the os-release ID and a map of releases.
|
||||
type Distribution struct {
|
||||
ID string `yaml:"id"`
|
||||
Releases map[string]*Release `yaml:"releases"`
|
||||
}
|
||||
|
||||
// GetRelease attempts to return the specific Release information
|
||||
// for the given release name. If there is no specific match, the
|
||||
// default release data is returned.
|
||||
func (d *Distribution) GetRelease(version string) *Release {
|
||||
result := d.Releases[version]
|
||||
if result == nil {
|
||||
result = d.Releases["default"]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Release holds the name and version of the release as given by
|
||||
// os-release. Programs is a slice of dependant programs required
|
||||
// to be present on the local installation for Wails to function.
|
||||
// Libraries is a slice of libraries that must be present for Wails
|
||||
// applications to compile.
|
||||
type Release struct {
|
||||
Name string `yaml:"name"`
|
||||
Version string `yaml:"version"`
|
||||
GccVersionCommand string `yaml:"gccversioncommand"`
|
||||
Programs []*Prerequisite `yaml:"programs"`
|
||||
Libraries []*Prerequisite `yaml:"libraries"`
|
||||
}
|
||||
|
||||
// Prerequisite is a simple struct containing a program/library name
|
||||
// plus the distribution specific help text indicating how to install
|
||||
// it.
|
||||
type Prerequisite struct {
|
||||
Name string `yaml:"name"`
|
||||
Help string `yaml:"help,omitempty"`
|
||||
}
|
||||
|
||||
// Load will load the given filename from disk and attempt to
|
||||
// import the data into the LinuxDB.
|
||||
func (l *LinuxDB) Load(filename string) error {
|
||||
if fs.FileExists(filename) {
|
||||
data, err := fs.LoadAsBytes(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return l.ImportData(data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ImportData will unmarshal the given YAML formatted data
|
||||
// into the LinuxDB
|
||||
func (l *LinuxDB) ImportData(data []byte) error {
|
||||
return yaml.Unmarshal(data, l)
|
||||
}
|
||||
|
||||
// GetDistro returns the Distribution information for the
|
||||
// given distribution name. If the distribution is not supported,
|
||||
// nil is returned.
|
||||
func (l *LinuxDB) GetDistro(distro string) *Distribution {
|
||||
return l.Distributions[distro]
|
||||
}
|
||||
|
||||
// NewLinuxDB creates a new LinuxDB instance from the bundled
|
||||
// linuxdb.yaml file.
|
||||
func NewLinuxDB() *LinuxDB {
|
||||
data := mewn.Bytes("./linuxdb.yaml")
|
||||
result := LinuxDB{
|
||||
Distributions: make(map[string]*Distribution),
|
||||
}
|
||||
err := result.ImportData(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return &result
|
||||
}
|
||||
170
cmd/linuxdb.yaml
Normal file
170
cmd/linuxdb.yaml
Normal file
@@ -0,0 +1,170 @@
|
||||
---
|
||||
distributions:
|
||||
debian:
|
||||
id: debian
|
||||
releases:
|
||||
default:
|
||||
name: Debian
|
||||
version: default
|
||||
gccversioncommand: &gccdumpversion -dumpversion
|
||||
programs: &debiandefaultprograms
|
||||
- name: gcc
|
||||
help: Please install with `sudo apt-get install build-essential` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo apt-get install pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - && sudo apt-get install -y nodejs` and try again
|
||||
libraries: &debiandefaultlibraries
|
||||
- name: libgtk-3-dev
|
||||
help: Please install with `sudo apt-get install libgtk-3-dev` and try again
|
||||
- name: libwebkit2gtk-4.0-dev
|
||||
help: Please install with `sudo apt-get install libwebkit2gtk-4.0-dev` and try again
|
||||
ubuntu:
|
||||
id: ubuntu
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Ubuntu
|
||||
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
kali:
|
||||
id: kali
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Kali GNU/Linux
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
parrot:
|
||||
id: parrot
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Parrot GNU/Linux
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
zorin:
|
||||
id: zorin
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Zorin
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
linuxmint:
|
||||
id: linuxmint
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Linux Mint
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
elementary:
|
||||
id: elementary
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: elementary OS
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs: *debiandefaultprograms
|
||||
libraries: *debiandefaultlibraries
|
||||
void:
|
||||
id: void
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: VoidLinux
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install with `xbps-install base-devel` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `xbps-install pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install with `xbps-install nodejs` and try again
|
||||
libraries:
|
||||
- name: gtk+3-devel
|
||||
help: Please install with `xbps-install gtk+3-devel` and try again
|
||||
- name: webkit2gtk-devel
|
||||
help: Please install with `xbps-install webkit2gtk-devel` and try again
|
||||
centos:
|
||||
id: centos
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: CentOS Linux
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install with `sudo yum install gcc-c++ make` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo yum install pkgconf-pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install with `sudo yum install epel-release && sudo yum install nodejs` and try again
|
||||
libraries:
|
||||
- name: gtk3-devel
|
||||
help: Please install with `sudo yum install gtk3-devel` and try again
|
||||
- name: webkitgtk3-devel
|
||||
help: Please install with `sudo yum install webkitgtk3-devel` and try again
|
||||
fedora:
|
||||
id: fedora
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Fedora
|
||||
gccversioncommand: *gccdumpfullversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install with `sudo yum install gcc-c++ make` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo yum install pkgconf-pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install `sudo yum install nodejs` and try again
|
||||
libraries:
|
||||
- name: gtk3-devel
|
||||
help: Please install with `sudo yum install gtk3-devel` and try again
|
||||
- name: webkit2gtk3-devel
|
||||
help: Please install with `sudo yum install webkit2gtk3-devel` and try again
|
||||
arch:
|
||||
id: arch
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Arch Linux
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install with `sudo pacman -S gcc` and try again
|
||||
- name: pkgconf
|
||||
help: Please install with `sudo pacman -S pkgconf` and try again
|
||||
- name: npm
|
||||
help: Please install with `sudo pacman -S npm` and try again
|
||||
libraries:
|
||||
- name: gtk3
|
||||
help: Please install with `sudo pacman -S gtk3` and try again
|
||||
- name: webkit2gtk
|
||||
help: Please install with `sudo pacman -S webkit2gtk` and try again
|
||||
gentoo:
|
||||
id: gentoo
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Gentoo
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install using your system's package manager
|
||||
- name: pkg-config
|
||||
help: Please install using your system's package manager
|
||||
- name: npm
|
||||
help: Please install using your system's package manager
|
||||
libraries:
|
||||
- name: gtk+:3
|
||||
help: Please install with `sudo emerge gtk+:3` and try again
|
||||
- name: webkit-gtk
|
||||
help: Please install with `sudo emerge webkit-gtk` and try again
|
||||
81
cmd/linuxdb_test.go
Normal file
81
cmd/linuxdb_test.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package cmd
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNewLinuxDB(t *testing.T) {
|
||||
_ = NewLinuxDB()
|
||||
}
|
||||
|
||||
func TestKnownDistro(t *testing.T) {
|
||||
var linuxDB = NewLinuxDB()
|
||||
result := linuxDB.GetDistro("ubuntu")
|
||||
if result == nil {
|
||||
t.Error("Cannot get distro 'ubuntu'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownDistro(t *testing.T) {
|
||||
var linuxDB = NewLinuxDB()
|
||||
result := linuxDB.GetDistro("unknown")
|
||||
if result != nil {
|
||||
t.Error("Should get nil for distribution 'unknown'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultRelease(t *testing.T) {
|
||||
var linuxDB = NewLinuxDB()
|
||||
result := linuxDB.GetDistro("ubuntu")
|
||||
if result == nil {
|
||||
t.Error("Cannot get distro 'ubuntu'")
|
||||
}
|
||||
|
||||
release := result.GetRelease("default")
|
||||
if release == nil {
|
||||
t.Error("Cannot get release 'default' for distro 'ubuntu'")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownRelease(t *testing.T) {
|
||||
var linuxDB = NewLinuxDB()
|
||||
result := linuxDB.GetDistro("ubuntu")
|
||||
if result == nil {
|
||||
t.Error("Cannot get distro 'ubuntu'")
|
||||
}
|
||||
|
||||
release := result.GetRelease("16.04")
|
||||
if release == nil {
|
||||
t.Error("Failed to get release 'default' for unknown release version '16.04'")
|
||||
}
|
||||
|
||||
if release.Version != "default" {
|
||||
t.Errorf("Got version '%s' instead of 'default' for unknown release version '16.04'", result.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPrerequisites(t *testing.T) {
|
||||
var linuxDB = NewLinuxDB()
|
||||
result := linuxDB.GetDistro("debian")
|
||||
if result == nil {
|
||||
t.Error("Cannot get distro 'debian'")
|
||||
}
|
||||
|
||||
release := result.GetRelease("default")
|
||||
if release == nil {
|
||||
t.Error("Failed to get release 'default' for unknown release version '16.04'")
|
||||
}
|
||||
|
||||
if release.Version != "default" {
|
||||
t.Errorf("Got version '%s' instead of 'default' for unknown release version '16.04'", result.ID)
|
||||
}
|
||||
|
||||
if release.Name != "Debian" {
|
||||
t.Errorf("Got Release Name '%s' instead of 'debian' for unknown release version '16.04'", release.Name)
|
||||
}
|
||||
|
||||
if len(release.Programs) != 3 {
|
||||
t.Errorf("Expected %d programs for unknown release version '16.04'", len(release.Programs))
|
||||
}
|
||||
if len(release.Libraries) != 2 {
|
||||
t.Errorf("Expected %d libraries for unknown release version '16.04'", len(release.Libraries))
|
||||
}
|
||||
}
|
||||
@@ -72,11 +72,11 @@ func (b *PackageHelper) Package(po *ProjectOptions) error {
|
||||
case "darwin":
|
||||
// Check we have the exe
|
||||
if !b.fs.FileExists(po.BinaryName) {
|
||||
return fmt.Errorf("cannot bundle non-existant binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
||||
return fmt.Errorf("cannot bundle non-existent binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
||||
}
|
||||
return b.packageOSX(po)
|
||||
case "windows":
|
||||
return b.PackageWindows(po, true)
|
||||
return b.PackageWindows(po, false)
|
||||
case "linux":
|
||||
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
|
||||
default:
|
||||
@@ -199,7 +199,7 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
||||
|
||||
// clean up
|
||||
if cleanUp {
|
||||
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile}
|
||||
filesToDelete := []string{tgtIconFile, tgtManifestFile, tgtRCFile, sysofile}
|
||||
err := b.fs.RemoveFiles(filesToDelete)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -255,9 +255,5 @@ func (b *PackageHelper) packageIconOSX(resourceDir string) error {
|
||||
|
||||
}
|
||||
defer dest.Close()
|
||||
if err := icns.Encode(dest, srcImg); err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
return nil
|
||||
return icns.Encode(dest, srcImg)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,6 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// Prerequisite defines a Prerequisite!
|
||||
type Prerequisite struct {
|
||||
Name string
|
||||
Help string
|
||||
Path string
|
||||
}
|
||||
|
||||
func newPrerequisite(name, help string) *Prerequisite {
|
||||
return &Prerequisite{Name: name, Help: help}
|
||||
}
|
||||
@@ -48,17 +41,13 @@ func getRequiredProgramsOSX() *Prerequisites {
|
||||
func getRequiredProgramsLinux() *Prerequisites {
|
||||
result := &Prerequisites{}
|
||||
distroInfo := GetLinuxDistroInfo()
|
||||
switch distroInfo.Distribution {
|
||||
case Ubuntu:
|
||||
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 apt install npm` 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"))
|
||||
result.Add(newPrerequisite("npm", "Please install from https://nodejs.org/en/download/ and try again"))
|
||||
|
||||
if distroInfo.Distribution != Unknown {
|
||||
var linuxDB = NewLinuxDB()
|
||||
distro := linuxDB.GetDistro(distroInfo.ID)
|
||||
release := distro.GetRelease(distroInfo.Release)
|
||||
for _, program := range release.Programs {
|
||||
result.Add(program)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -92,14 +81,15 @@ func getRequiredLibrariesOSX() (*Prerequisites, error) {
|
||||
|
||||
func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
||||
result := &Prerequisites{}
|
||||
// The Linux Distribution DB
|
||||
distroInfo := GetLinuxDistroInfo()
|
||||
switch distroInfo.Distribution {
|
||||
case Ubuntu:
|
||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||
default:
|
||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with your system package manager and try again"))
|
||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with your system package manager and try again"))
|
||||
if distroInfo.Distribution != Unknown {
|
||||
var linuxDB = NewLinuxDB()
|
||||
distro := linuxDB.GetDistro(distroInfo.ID)
|
||||
release := distro.GetRelease(distroInfo.Release)
|
||||
for _, library := range release.Libraries {
|
||||
result.Add(library)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (p *Program) GetFullPathToBinary() (string, error) {
|
||||
}
|
||||
|
||||
// Run will execute the program with the given parameters
|
||||
// Returns stdout + stderr as strings and an error if one occured
|
||||
// Returns stdout + stderr as strings and an error if one occurred
|
||||
func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err error) {
|
||||
command, err := p.GetFullPathToBinary()
|
||||
if err != nil {
|
||||
@@ -92,7 +92,7 @@ func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err
|
||||
|
||||
// InstallGoPackage installs the given Go package
|
||||
func (p *ProgramHelper) InstallGoPackage(packageName string) error {
|
||||
args := strings.Split("get -u "+packageName, " ")
|
||||
args := strings.Split("get "+packageName, " ")
|
||||
_, stderr, err := p.shell.Run("go", args...)
|
||||
if err != nil {
|
||||
fmt.Println(stderr)
|
||||
@@ -107,7 +107,7 @@ func (p *ProgramHelper) RunCommand(command string) error {
|
||||
}
|
||||
|
||||
// RunCommandArray runs the command specified in the array
|
||||
func (p *ProgramHelper) RunCommandArray(args []string) error {
|
||||
func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
||||
program := args[0]
|
||||
// TODO: Run FindProgram here and get the full path to the exe
|
||||
program, err := exec.LookPath(program)
|
||||
@@ -116,10 +116,16 @@ func (p *ProgramHelper) RunCommandArray(args []string) error {
|
||||
return err
|
||||
}
|
||||
args = args[1:]
|
||||
// fmt.Printf("RunCommandArray = %s %+v\n", program, args)
|
||||
_, stderr, err := p.shell.Run(program, args...)
|
||||
var stderr string
|
||||
var stdout string
|
||||
if len(dir) > 0 {
|
||||
stdout, stderr, err = p.shell.RunInDirectory(dir[0], program, args...)
|
||||
} else {
|
||||
stdout, stderr, err = p.shell.Run(program, args...)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(stderr)
|
||||
fmt.Println(stdout)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/slicer"
|
||||
@@ -50,12 +51,6 @@ func NewProjectHelper() *ProjectHelper {
|
||||
// GenerateProject generates a new project using the options given
|
||||
func (ph *ProjectHelper) GenerateProject(projectOptions *ProjectOptions) error {
|
||||
|
||||
// exists := ph.templates.TemplateExists(projectOptions.Template)
|
||||
|
||||
// if !exists {
|
||||
// return fmt.Errorf("template '%s' is invalid", projectOptions.Template)
|
||||
// }
|
||||
|
||||
// Calculate project path
|
||||
projectPath, err := filepath.Abs(projectOptions.OutputDirectory)
|
||||
if err != nil {
|
||||
@@ -90,8 +85,6 @@ func (ph *ProjectHelper) GenerateProject(projectOptions *ProjectOptions) error {
|
||||
// ph.GenerateWindowsResourceConfig(projectOptions)
|
||||
// }
|
||||
|
||||
ph.log.Yellow("Project '%s' generated in directory '%s'!", projectOptions.Name, projectOptions.OutputDirectory)
|
||||
ph.log.Yellow("To compile the project, run 'wails build' in the project directory.")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -119,9 +112,9 @@ func (ph *ProjectHelper) NewProjectOptions() *ProjectOptions {
|
||||
Description: "Enter your project description",
|
||||
Version: "0.1.0",
|
||||
BinaryName: "",
|
||||
system: NewSystemHelper(),
|
||||
log: NewLogger(),
|
||||
templates: NewTemplateHelper(),
|
||||
system: ph.system,
|
||||
log: ph.log,
|
||||
templates: ph.templates,
|
||||
Author: &author{},
|
||||
}
|
||||
|
||||
@@ -151,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
|
||||
@@ -173,19 +168,49 @@ func (po *ProjectOptions) PromptForInputs() error {
|
||||
// Process Templates
|
||||
templateList := slicer.Interface()
|
||||
options := slicer.String()
|
||||
for _, templateDetails := range po.templates.TemplateList.details {
|
||||
templateList.Add(templateDetails)
|
||||
options.Add(fmt.Sprintf("%s - %s", templateDetails.Metadata.Name, templateDetails.Metadata.ShortDescription))
|
||||
templateDetails, err := po.templates.GetTemplateDetails()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
templateIndex := 0
|
||||
if po.Template != "" {
|
||||
// Check template is valid if given
|
||||
if templateDetails[po.Template] == nil {
|
||||
keys := make([]string, 0, len(templateDetails))
|
||||
for k := range templateDetails {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
return fmt.Errorf("invalid template name '%s'. Valid options: %s", po.Template, strings.Join(keys, ", "))
|
||||
}
|
||||
po.selectedTemplate = templateDetails[po.Template]
|
||||
} else {
|
||||
|
||||
if len(options.AsSlice()) > 1 {
|
||||
templateIndex = PromptSelection("Please select a template", options.AsSlice(), 0)
|
||||
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))
|
||||
}
|
||||
|
||||
templateIndex := 0
|
||||
|
||||
if len(options.AsSlice()) > 1 {
|
||||
templateIndex = PromptSelection("Please select a template", options.AsSlice(), 0)
|
||||
}
|
||||
|
||||
if len(templateList.AsSlice()) == 0 {
|
||||
return fmt.Errorf("aborting: no templates found")
|
||||
}
|
||||
|
||||
// After selection do this....
|
||||
po.selectedTemplate = templateList.AsSlice()[templateIndex].(*TemplateDetails)
|
||||
}
|
||||
|
||||
// After selection do this....
|
||||
po.selectedTemplate = templateList.AsSlice()[templateIndex].(*TemplateDetails)
|
||||
fmt.Println("Template: " + po.selectedTemplate.Metadata.Name)
|
||||
|
||||
// Setup NPM Project name
|
||||
po.NPMProjectName = strings.ToLower(strings.Replace(po.Name, " ", "_", -1))
|
||||
@@ -266,7 +291,6 @@ func processProjectName(po *ProjectOptions) {
|
||||
po.Name = Prompt("The name of the project", "My Project")
|
||||
}
|
||||
fmt.Println("Project Name: " + po.Name)
|
||||
|
||||
}
|
||||
|
||||
func processBinaryName(po *ProjectOptions) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -20,11 +19,7 @@ func Prompt(question string, defaultValue ...string) string {
|
||||
fmt.Printf(question + ": ")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
input, _ := reader.ReadString('\n')
|
||||
EOL := "\n"
|
||||
if runtime.GOOS == "windows" {
|
||||
EOL = "\r\n"
|
||||
}
|
||||
input = strings.Replace(input, EOL, "", -1)
|
||||
input = strings.TrimSpace(input)
|
||||
|
||||
if input != "" {
|
||||
answer = input
|
||||
|
||||
98
cmd/semver.go
Normal file
98
cmd/semver.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
)
|
||||
|
||||
// SemanticVersion is a struct containing a semantic version
|
||||
type SemanticVersion struct {
|
||||
Version *semver.Version
|
||||
}
|
||||
|
||||
// NewSemanticVersion creates a new SemanticVersion object with the given version string
|
||||
func NewSemanticVersion(version string) (*SemanticVersion, error) {
|
||||
semverVersion, err := semver.NewVersion(version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SemanticVersion{
|
||||
Version: semverVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// IsRelease returns true if it's a release version
|
||||
func (s *SemanticVersion) IsRelease() bool {
|
||||
return len(s.Version.Prerelease()) == 0 && len(s.Version.Metadata()) == 0
|
||||
}
|
||||
|
||||
// IsPreRelease returns true if it's a prerelease version
|
||||
func (s *SemanticVersion) IsPreRelease() bool {
|
||||
return len(s.Version.Prerelease()) > 0
|
||||
}
|
||||
|
||||
func (s *SemanticVersion) String() string {
|
||||
return s.Version.String()
|
||||
}
|
||||
|
||||
// IsGreaterThan returns true if this version is greater than the given version
|
||||
func (s *SemanticVersion) IsGreaterThan(version *SemanticVersion) (bool, error) {
|
||||
// Set up new constraint
|
||||
constraint, err := semver.NewConstraint("> " + version.Version.String())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Check if the desired one is greater than the requested on
|
||||
success, msgs := constraint.Validate(s.Version)
|
||||
if !success {
|
||||
return false, msgs[0]
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// IsGreaterThanOrEqual returns true if this version is greater than or equal the given version
|
||||
func (s *SemanticVersion) IsGreaterThanOrEqual(version *SemanticVersion) (bool, error) {
|
||||
// Set up new constraint
|
||||
constraint, err := semver.NewConstraint(">= " + version.Version.String())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// Check if the desired one is greater than the requested on
|
||||
success, msgs := constraint.Validate(s.Version)
|
||||
if !success {
|
||||
return false, msgs[0]
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// MainVersion returns the main version of any version+prerelease+metadata
|
||||
// EG: MainVersion("1.2.3-pre") => "1.2.3"
|
||||
func (s *SemanticVersion) MainVersion() *SemanticVersion {
|
||||
mainVersion := fmt.Sprintf("%d.%d.%d", s.Version.Major(), s.Version.Minor(), s.Version.Patch())
|
||||
result, _ := NewSemanticVersion(mainVersion)
|
||||
return result
|
||||
}
|
||||
|
||||
// SemverCollection is a collection of SemanticVersion objects
|
||||
type SemverCollection []*SemanticVersion
|
||||
|
||||
// Len returns the length of a collection. The number of Version instances
|
||||
// on the slice.
|
||||
func (c SemverCollection) Len() int {
|
||||
return len(c)
|
||||
}
|
||||
|
||||
// Less is needed for the sort interface to compare two Version objects on the
|
||||
// slice. If checks if one is less than the other.
|
||||
func (c SemverCollection) Less(i, j int) bool {
|
||||
return c[i].Version.LessThan(c[j].Version)
|
||||
}
|
||||
|
||||
// Swap is needed for the sort interface to replace the Version objects
|
||||
// at two different positions in the slice.
|
||||
func (c SemverCollection) Swap(i, j int) {
|
||||
c[i], c[j] = c[j], c[i]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package cmd
|
||||
16
cmd/shell.go
16
cmd/shell.go
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
@@ -17,6 +18,21 @@ func NewShellHelper() *ShellHelper {
|
||||
// Run the given command
|
||||
func (sh *ShellHelper) Run(command string, vars ...string) (stdout, stderr string, err error) {
|
||||
cmd := exec.Command(command, vars...)
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
err = cmd.Run()
|
||||
stdout = string(stdo.Bytes())
|
||||
stderr = string(stde.Bytes())
|
||||
return
|
||||
}
|
||||
|
||||
// RunInDirectory runs the given command in the given directory
|
||||
func (sh *ShellHelper) RunInDirectory(dir string, command string, vars ...string) (stdout, stderr string, err error) {
|
||||
cmd := exec.Command(command, vars...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
||||
var stdo, stde bytes.Buffer
|
||||
cmd.Stdout = &stdo
|
||||
cmd.Stderr = &stde
|
||||
|
||||
@@ -68,6 +68,17 @@ func (s *SystemHelper) ConfigFileIsValid() bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// GetAuthor returns a formatted string of the user's name and email
|
||||
func (s *SystemHelper) GetAuthor() (string, error) {
|
||||
var config *SystemConfig
|
||||
config, err := s.LoadConfig()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s <%s>", config.Name, config.Email), nil
|
||||
}
|
||||
|
||||
// BackupConfig attempts to backup the system config file
|
||||
func (s *SystemHelper) BackupConfig() (string, error) {
|
||||
now := strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
|
||||
@@ -81,21 +92,24 @@ func (s *SystemHelper) BackupConfig() (string, error) {
|
||||
|
||||
func (s *SystemHelper) setup() error {
|
||||
|
||||
systemConfig := make(map[string]string)
|
||||
|
||||
// Try to load current values - ignore errors
|
||||
config, err := s.LoadConfig()
|
||||
defaultName := ""
|
||||
defaultEmail := ""
|
||||
if config != nil {
|
||||
defaultName = config.Name
|
||||
defaultEmail = config.Email
|
||||
config, _ := s.LoadConfig()
|
||||
|
||||
if config.Name != "" {
|
||||
systemConfig["name"] = PromptRequired("What is your name", config.Name)
|
||||
} else {
|
||||
systemConfig["name"] = PromptRequired("What is your name")
|
||||
}
|
||||
if config.Email != "" {
|
||||
systemConfig["email"] = PromptRequired("What is your email address", config.Email)
|
||||
} else {
|
||||
systemConfig["email"] = PromptRequired("What is your email address")
|
||||
}
|
||||
|
||||
systemConfig := make(map[string]string)
|
||||
systemConfig["name"] = PromptRequired("What is your name", defaultName)
|
||||
systemConfig["email"] = PromptRequired("What is your email address", defaultEmail)
|
||||
|
||||
// Create the directory
|
||||
err = s.fs.MkDirs(s.wailsSystemDir)
|
||||
err := s.fs.MkDirs(s.wailsSystemDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -242,7 +256,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
bin := programHelper.FindProgram(program.Name)
|
||||
if bin == nil {
|
||||
errors = true
|
||||
logger.Red("Program '%s' not found. %s", program.Name, program.Help)
|
||||
logger.Error("Program '%s' not found. %s", program.Name, program.Help)
|
||||
} else {
|
||||
logger.Green("Program '%s' found: %s", program.Name, bin.Path)
|
||||
}
|
||||
@@ -255,22 +269,35 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var libraryChecker CheckPkgInstalled
|
||||
distroInfo := GetLinuxDistroInfo()
|
||||
|
||||
switch distroInfo.Distribution {
|
||||
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali:
|
||||
libraryChecker = DpkgInstalled
|
||||
case Arch:
|
||||
libraryChecker = PacmanInstalled
|
||||
case CentOS, Fedora:
|
||||
libraryChecker = RpmInstalled
|
||||
case Gentoo:
|
||||
libraryChecker = EqueryInstalled
|
||||
case VoidLinux:
|
||||
libraryChecker = XbpsInstalled
|
||||
default:
|
||||
return false, RequestSupportForDistribution(distroInfo)
|
||||
}
|
||||
|
||||
for _, library := range *requiredLibraries {
|
||||
switch distroInfo.Distribution {
|
||||
case Ubuntu:
|
||||
installed, err := DpkgInstalled(library.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !installed {
|
||||
errors = true
|
||||
logger.Red("Library '%s' not found. %s", library.Name, library.Help)
|
||||
} else {
|
||||
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)
|
||||
installed, err := libraryChecker(library.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !installed {
|
||||
errors = true
|
||||
logger.Error("Library '%s' not found. %s", library.Name, library.Help)
|
||||
} else {
|
||||
logger.Green("Library '%s' installed.", library.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
231
cmd/templates.go
231
cmd/templates.go
@@ -3,114 +3,206 @@ package cmd
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
mewn "github.com/leaanthony/mewn"
|
||||
mewnlib "github.com/leaanthony/mewn/lib"
|
||||
"github.com/kennygrant/sanitize"
|
||||
"github.com/leaanthony/slicer"
|
||||
)
|
||||
|
||||
// TemplateMetadata holds all the metadata for a Wails template
|
||||
type TemplateMetadata struct {
|
||||
Name string `json:"name"`
|
||||
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"`
|
||||
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
|
||||
type TemplateDetails struct {
|
||||
BasePath string
|
||||
Name string
|
||||
Path string
|
||||
Metadata *TemplateMetadata
|
||||
}
|
||||
|
||||
// TemplateList is a list of available templates
|
||||
type TemplateList struct {
|
||||
details map[string]*TemplateDetails
|
||||
}
|
||||
|
||||
// NewTemplateList creates a new TemplateList object
|
||||
func NewTemplateList(filenames *mewnlib.FileGroup) *TemplateList {
|
||||
// Iterate each template and store information
|
||||
|
||||
result := &TemplateList{details: make(map[string]*TemplateDetails)}
|
||||
|
||||
entries := slicer.String()
|
||||
entries.AddSlice(filenames.Entries())
|
||||
|
||||
// Find all template.json files
|
||||
metadataFiles := entries.Filter(func(filename string) bool {
|
||||
match, _ := regexp.MatchString("(.)+template.json$", filename)
|
||||
return match
|
||||
})
|
||||
|
||||
// Load each metadata file
|
||||
metadataFiles.Each(func(filename string) {
|
||||
fileData := filenames.Bytes(filename)
|
||||
var metadata TemplateMetadata
|
||||
err := json.Unmarshal(fileData, &metadata)
|
||||
if err != nil {
|
||||
log.Fatalf("corrupt metadata for template: %s", filename)
|
||||
}
|
||||
path := strings.Split(filename, string(filepath.Separator))[0]
|
||||
thisTemplate := &TemplateDetails{Path: path, Metadata: &metadata}
|
||||
result.details[filename] = thisTemplate
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Template holds details about a Wails template
|
||||
type Template struct {
|
||||
Name string
|
||||
Path string
|
||||
Description string
|
||||
fs *FSHelper
|
||||
}
|
||||
|
||||
// TemplateHelper is a utility object to help with processing templates
|
||||
type TemplateHelper struct {
|
||||
TemplateList *TemplateList
|
||||
Files *mewnlib.FileGroup
|
||||
templateDir *Dir
|
||||
fs *FSHelper
|
||||
metadataFilename string
|
||||
}
|
||||
|
||||
// NewTemplateHelper creates a new template helper
|
||||
func NewTemplateHelper() *TemplateHelper {
|
||||
files := mewn.Group("./templates")
|
||||
|
||||
templateDir, err := fs.LocalDir("./templates")
|
||||
if err != nil {
|
||||
log.Fatal("Unable to find the template directory. Please reinstall Wails.")
|
||||
}
|
||||
|
||||
return &TemplateHelper{
|
||||
TemplateList: NewTemplateList(files),
|
||||
Files: files,
|
||||
templateDir: templateDir,
|
||||
metadataFilename: "template.json",
|
||||
}
|
||||
}
|
||||
|
||||
// IsValidTemplate returns true if the given template name resides on disk
|
||||
func (t *TemplateHelper) IsValidTemplate(templateName string) bool {
|
||||
pathToTemplate := filepath.Join(t.templateDir.fullPath, templateName)
|
||||
return t.fs.DirExists(pathToTemplate)
|
||||
}
|
||||
|
||||
// SanitizeFilename sanitizes the given string to make a valid filename
|
||||
func (t *TemplateHelper) SanitizeFilename(name string) string {
|
||||
return sanitize.Name(name)
|
||||
}
|
||||
|
||||
// CreateNewTemplate creates a new template based on the given directory name and string
|
||||
func (t *TemplateHelper) CreateNewTemplate(dirname string, details *TemplateMetadata) (string, error) {
|
||||
|
||||
// Check if this template has already been created
|
||||
if t.IsValidTemplate(dirname) {
|
||||
return "", fmt.Errorf("cannot create template in directory '%s' - already exists", dirname)
|
||||
}
|
||||
|
||||
targetDir := filepath.Join(t.templateDir.fullPath, dirname)
|
||||
err := t.fs.MkDir(targetDir)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
targetMetadata := filepath.Join(targetDir, t.metadataFilename)
|
||||
err = t.fs.SaveAsJSON(details, targetMetadata)
|
||||
|
||||
return targetDir, err
|
||||
}
|
||||
|
||||
// LoadMetadata loads the template's 'metadata.json' file
|
||||
func (t *TemplateHelper) LoadMetadata(dir string) (*TemplateMetadata, error) {
|
||||
templateFile := filepath.Join(dir, t.metadataFilename)
|
||||
result := &TemplateMetadata{}
|
||||
if !t.fs.FileExists(templateFile) {
|
||||
return nil, nil
|
||||
}
|
||||
rawJSON, err := ioutil.ReadFile(templateFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(rawJSON, &result)
|
||||
return result, err
|
||||
}
|
||||
|
||||
// GetTemplateDetails returns a map of Template structs containing details
|
||||
// of the found templates
|
||||
func (t *TemplateHelper) GetTemplateDetails() (map[string]*TemplateDetails, error) {
|
||||
|
||||
// Get the subdirectory details
|
||||
templateDirs, err := t.templateDir.GetSubdirs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make(map[string]*TemplateDetails)
|
||||
|
||||
for name, dir := range templateDirs {
|
||||
result[name] = &TemplateDetails{
|
||||
Path: dir,
|
||||
}
|
||||
_ = &TemplateMetadata{}
|
||||
metadata, err := t.LoadMetadata(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[name].Metadata = metadata
|
||||
if metadata.Name != "" {
|
||||
result[name].Name = metadata.Name
|
||||
} else {
|
||||
// Ignore bad templates?
|
||||
result[name] = nil
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetTemplateFilenames returns all the filenames of the given template
|
||||
func (t *TemplateHelper) GetTemplateFilenames(template *TemplateDetails) (*slicer.StringSlicer, error) {
|
||||
|
||||
// Get the subdirectory details
|
||||
templateDir, err := t.fs.Directory(template.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return templateDir.GetAllFilenames()
|
||||
}
|
||||
|
||||
// InstallTemplate installs the template given in the project options to the
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
|
||||
templatePath := projectOptions.selectedTemplate.Path
|
||||
|
||||
templateFilenames := slicer.String()
|
||||
templateFilenames.AddSlice(projectOptions.templates.Files.Entries())
|
||||
// Save the version
|
||||
projectOptions.WailsVersion = Version
|
||||
|
||||
templateJSONFilename := filepath.Join(templatePath, "template.json")
|
||||
templateJSONFilename := filepath.Join(templatePath, t.metadataFilename)
|
||||
|
||||
templateFiles := templateFilenames.Filter(func(filename string) bool {
|
||||
filename = filepath.FromSlash(filename)
|
||||
return strings.HasPrefix(filename, templatePath) && filename != templateJSONFilename
|
||||
})
|
||||
|
||||
var err error
|
||||
templateFiles.Each(func(templateFile string) {
|
||||
|
||||
// Setup filenames
|
||||
@@ -119,11 +211,14 @@ func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *Pro
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
filedata := projectOptions.templates.Files.Bytes(templateFile)
|
||||
filedata, err := t.fs.LoadAsBytes(templateFile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// If file is a template, process it
|
||||
if strings.HasSuffix(templateFile, ".template") {
|
||||
templateData := projectOptions.templates.Files.String(templateFile)
|
||||
templateData := string(filedata)
|
||||
tmpl := template.New(templateFile)
|
||||
tmpl.Parse(templateData)
|
||||
var tpl bytes.Buffer
|
||||
|
||||
13
cmd/templates/angular-template/frontend/.editorconfig
Normal file
13
cmd/templates/angular-template/frontend/.editorconfig
Normal file
@@ -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
|
||||
47
cmd/templates/angular-template/frontend/.gitignore
vendored
Normal file
47
cmd/templates/angular-template/frontend/.gitignore
vendored
Normal file
@@ -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
|
||||
27
cmd/templates/angular-template/frontend/README.md
Normal file
27
cmd/templates/angular-template/frontend/README.md
Normal file
@@ -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).
|
||||
121
cmd/templates/angular-template/frontend/angular.json
Normal file
121
cmd/templates/angular-template/frontend/angular.json
Normal file
@@ -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"
|
||||
}
|
||||
12
cmd/templates/angular-template/frontend/browserslist
Normal file
12
cmd/templates/angular-template/frontend/browserslist
Normal file
@@ -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'.
|
||||
@@ -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 } }));
|
||||
}
|
||||
};
|
||||
@@ -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));
|
||||
});
|
||||
});
|
||||
11
cmd/templates/angular-template/frontend/e2e/src/app.po.ts
Normal file
11
cmd/templates/angular-template/frontend/e2e/src/app.po.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
navigateTo() {
|
||||
return browser.get(browser.baseUrl) as Promise<any>;
|
||||
}
|
||||
|
||||
getTitleText() {
|
||||
return element(by.css('app-root h1')).getText() as Promise<string>;
|
||||
}
|
||||
}
|
||||
13
cmd/templates/angular-template/frontend/e2e/tsconfig.json
Normal file
13
cmd/templates/angular-template/frontend/e2e/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/e2e",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"jasminewd2",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
}
|
||||
32
cmd/templates/angular-template/frontend/karma.conf.js
Normal file
32
cmd/templates/angular-template/frontend/karma.conf.js
Normal file
@@ -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
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"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",
|
||||
"@wailsapp/runtime": "^1.0.0",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -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 { }
|
||||
@@ -0,0 +1,14 @@
|
||||
<!--The content below is only a placeholder and can be replaced.-->
|
||||
<div style="text-align:center">
|
||||
<h1>
|
||||
Welcome to {{ title }}!
|
||||
</h1>
|
||||
<img width="300" alt="Angular Logo"
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
||||
|
||||
<br />
|
||||
<button (click)="onClickMe()">Hello</button>
|
||||
<p>{{clickMessage}}</p>
|
||||
</div>
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
@@ -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!');
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 { }
|
||||
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
production: true
|
||||
};
|
||||
@@ -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.
|
||||
BIN
cmd/templates/angular-template/frontend/src/favicon.ico
Normal file
BIN
cmd/templates/angular-template/frontend/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>my-app</title>
|
||||
<base href="/">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
18
cmd/templates/angular-template/frontend/src/main.ts
Normal file
18
cmd/templates/angular-template/frontend/src/main.ts
Normal file
@@ -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 Wails from '@wailsapp/runtime';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
Wails.Init(() => {
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
});
|
||||
63
cmd/templates/angular-template/frontend/src/polyfills.ts
Normal file
63
cmd/templates/angular-template/frontend/src/polyfills.ts
Normal file
@@ -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
|
||||
*/
|
||||
24
cmd/templates/angular-template/frontend/src/styles.css
Normal file
24
cmd/templates/angular-template/frontend/src/styles.css
Normal file
@@ -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;
|
||||
}
|
||||
20
cmd/templates/angular-template/frontend/src/test.ts
Normal file
20
cmd/templates/angular-template/frontend/src/test.ts
Normal file
@@ -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);
|
||||
14
cmd/templates/angular-template/frontend/tsconfig.app.json
Normal file
14
cmd/templates/angular-template/frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"src/**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
23
cmd/templates/angular-template/frontend/tsconfig.json
Normal file
23
cmd/templates/angular-template/frontend/tsconfig.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
18
cmd/templates/angular-template/frontend/tsconfig.spec.json
Normal file
18
cmd/templates/angular-template/frontend/tsconfig.spec.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
92
cmd/templates/angular-template/frontend/tslint.json
Normal file
92
cmd/templates/angular-template/frontend/tslint.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
5
cmd/templates/angular-template/go.mod.template
Normal file
5
cmd/templates/angular-template/go.mod.template
Normal file
@@ -0,0 +1,5 @@
|
||||
module {{.BinaryName}}
|
||||
|
||||
require (
|
||||
github.com/wailsapp/wails {{.WailsVersion}}
|
||||
)
|
||||
27
cmd/templates/angular-template/main.go.template
Normal file
27
cmd/templates/angular-template/main.go.template
Normal file
@@ -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()
|
||||
}
|
||||
20
cmd/templates/angular-template/template.json
Normal file
20
cmd/templates/angular-template/template.json
Normal file
@@ -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 <ktc@pm.me>",
|
||||
"created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
||||
"frontenddir": "frontend",
|
||||
"serve": "npx ng serve --poll=2000",
|
||||
"bridge": "src",
|
||||
"wailsdir": ""
|
||||
}
|
||||
3
cmd/templates/create-react-app/.jshint
Normal file
3
cmd/templates/create-react-app/.jshint
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"esversion": 6
|
||||
}
|
||||
23
cmd/templates/create-react-app/frontend/.gitignore
vendored
Normal file
23
cmd/templates/create-react-app/frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
68
cmd/templates/create-react-app/frontend/README.md
Normal file
68
cmd/templates/create-react-app/frontend/README.md
Normal file
@@ -0,0 +1,68 @@
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.<br>
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.<br>
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.<br>
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.<br>
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.<br>
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "{{.NPMProjectName}}",
|
||||
"author": "{{.Author.Name}}<{{.Author.Email}}>",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"core-js": "^3.1.4",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"wails-react-scripts": "3.0.1-2",
|
||||
"react-modal": "3.8.1",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
cmd/templates/create-react-app/frontend/public/favicon.ico
Normal file
BIN
cmd/templates/create-react-app/frontend/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
38
cmd/templates/create-react-app/frontend/public/index.html
Normal file
38
cmd/templates/create-react-app/frontend/public/index.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="app"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
15
cmd/templates/create-react-app/frontend/public/manifest.json
Normal file
15
cmd/templates/create-react-app/frontend/public/manifest.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
33
cmd/templates/create-react-app/frontend/src/App.css
Normal file
33
cmd/templates/create-react-app/frontend/src/App.css
Normal file
@@ -0,0 +1,33 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
21
cmd/templates/create-react-app/frontend/src/App.js
Normal file
21
cmd/templates/create-react-app/frontend/src/App.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import logo from './logo.png';
|
||||
import './App.css';
|
||||
import HelloWorld from './components/HelloWorld';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div id="app" className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Welcome to your new <code>wails/react</code> project.
|
||||
</p>
|
||||
|
||||
<HelloWorld />
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
9
cmd/templates/create-react-app/frontend/src/App.test.js
Normal file
9
cmd/templates/create-react-app/frontend/src/App.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(<App />, div);
|
||||
ReactDOM.unmountComponentAtNode(div);
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
import Modal from 'react-modal';
|
||||
|
||||
class HelloWorld extends React.Component {
|
||||
constructor(props, context) {
|
||||
super();
|
||||
this.state = {
|
||||
showModal: false
|
||||
};
|
||||
|
||||
this.handleOpenModal = this.handleOpenModal.bind(this);
|
||||
this.handleCloseModal = this.handleCloseModal.bind(this);
|
||||
}
|
||||
|
||||
handleOpenModal () {
|
||||
this.setState({ showModal: true });
|
||||
|
||||
window.backend.basic().then(result =>
|
||||
this.setState({
|
||||
result
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
handleCloseModal () {
|
||||
this.setState({ showModal: false });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { result } = this.state;
|
||||
return (
|
||||
<div className="App">
|
||||
<button onClick={this.handleOpenModal} type="button">
|
||||
Hello
|
||||
</button>
|
||||
<Modal
|
||||
isOpen={this.state.showModal}
|
||||
contentLabel="Minimal Modal Example"
|
||||
>
|
||||
<p>{result}</p>
|
||||
<button onClick={this.handleCloseModal}>Close Modal</button>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default HelloWorld;
|
||||
13
cmd/templates/create-react-app/frontend/src/index.css
Normal file
13
cmd/templates/create-react-app/frontend/src/index.css
Normal file
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
||||
11
cmd/templates/create-react-app/frontend/src/index.js
Normal file
11
cmd/templates/create-react-app/frontend/src/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import 'core-js/stable';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
import Wails from '@wailsapp/runtime';
|
||||
|
||||
Wails.Init(() => {
|
||||
ReactDOM.render(<App />, document.getElementById('app'));
|
||||
});
|
||||
BIN
cmd/templates/create-react-app/frontend/src/logo.png
Normal file
BIN
cmd/templates/create-react-app/frontend/src/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
135
cmd/templates/create-react-app/frontend/src/serviceWorker.js
Normal file
135
cmd/templates/create-react-app/frontend/src/serviceWorker.js
Normal file
@@ -0,0 +1,135 @@
|
||||
// This optional code is used to register a service worker.
|
||||
// register() is not called by default.
|
||||
|
||||
// This lets the app load faster on subsequent visits in production, and gives
|
||||
// it offline capabilities. However, it also means that developers (and users)
|
||||
// will only see deployed updates on subsequent visits to a page, after all the
|
||||
// existing tabs open on the page have been closed, since previously cached
|
||||
// resources are updated in the background.
|
||||
|
||||
// To learn more about the benefits of this model and instructions on how to
|
||||
// opt-in, read https://bit.ly/CRA-PWA
|
||||
|
||||
const isLocalhost = Boolean(
|
||||
window.location.hostname === 'localhost' ||
|
||||
// [::1] is the IPv6 localhost address.
|
||||
window.location.hostname === '[::1]' ||
|
||||
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||
window.location.hostname.match(
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||
)
|
||||
);
|
||||
|
||||
export function register(config) {
|
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
|
||||
if (publicUrl.origin !== window.location.origin) {
|
||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||
// from what our page is served on. This might happen if a CDN is used to
|
||||
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||
|
||||
if (isLocalhost) {
|
||||
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||
checkValidServiceWorker(swUrl, config);
|
||||
|
||||
// Add some additional logging to localhost, pointing developers to the
|
||||
// service worker/PWA documentation.
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
console.log(
|
||||
'This web app is being served cache-first by a service ' +
|
||||
'worker. To learn more, visit https://bit.ly/CRA-PWA'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// Is not localhost. Just register service worker
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(registration => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
if (installingWorker == null) {
|
||||
return;
|
||||
}
|
||||
installingWorker.onstatechange = () => {
|
||||
if (installingWorker.state === 'installed') {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
// At this point, the updated precached content has been fetched,
|
||||
// but the previous service worker will still serve the older
|
||||
// content until all client tabs are closed.
|
||||
console.log(
|
||||
'New content is available and will be used when all ' +
|
||||
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
|
||||
);
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onUpdate) {
|
||||
config.onUpdate(registration);
|
||||
}
|
||||
} else {
|
||||
// At this point, everything has been precached.
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
console.log('Content is cached for offline use.');
|
||||
|
||||
// Execute callback
|
||||
if (config && config.onSuccess) {
|
||||
config.onSuccess(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during service worker registration:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function checkValidServiceWorker(swUrl, config) {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl)
|
||||
.then(response => {
|
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (
|
||||
response.status === 404 ||
|
||||
(contentType != null && contentType.indexOf('javascript') === -1)
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Service worker found. Proceed as normal.
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@
|
||||
export default {
|
||||
// The main function
|
||||
// Passes the main Wails object to the callback if given.
|
||||
Start: function(callback) {
|
||||
Start: function (callback) {
|
||||
if (callback) {
|
||||
window.wails.events.on("wails:ready", callback);
|
||||
window.wails.Events.On("wails:ready", callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
5
cmd/templates/create-react-app/go.mod.template
Normal file
5
cmd/templates/create-react-app/go.mod.template
Normal file
@@ -0,0 +1,5 @@
|
||||
module {{.BinaryName}}
|
||||
|
||||
require (
|
||||
github.com/wailsapp/wails {{.WailsVersion}}
|
||||
)
|
||||
27
cmd/templates/create-react-app/main.go.template
Normal file
27
cmd/templates/create-react-app/main.go.template
Normal file
@@ -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/build/static/js/main.js")
|
||||
css := mewn.String("./frontend/build/static/css/main.css")
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
Title: "{{.Name}}",
|
||||
JS: js,
|
||||
CSS: css,
|
||||
Colour: "#131313",
|
||||
})
|
||||
app.Bind(basic)
|
||||
app.Run()
|
||||
}
|
||||
14
cmd/templates/create-react-app/template.json
Executable file
14
cmd/templates/create-react-app/template.json
Executable file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "React JS",
|
||||
"version": "1.0.0",
|
||||
"shortdescription": "Create React App v3 template",
|
||||
"description": "Create React App v3 standar tooling",
|
||||
"install": "npm install",
|
||||
"build": "npm run build",
|
||||
"author": "bh90210 <ktc@pm.me>",
|
||||
"created": "2019-06-07 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
||||
"frontenddir": "frontend",
|
||||
"serve": "npm run start",
|
||||
"bridge": "src",
|
||||
"wailsdir": ""
|
||||
}
|
||||
3
cmd/templates/vuebasic/.jshint
Normal file
3
cmd/templates/vuebasic/.jshint
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"esversion": 6
|
||||
}
|
||||
11109
cmd/templates/vuebasic/frontend/package-lock.json
generated
11109
cmd/templates/vuebasic/frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^2.6.4",
|
||||
"vue": "^2.5.22"
|
||||
"vue": "^2.5.22",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.4.0",
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>my-vue-app-01</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but my-vue-app-01 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,12 +1,13 @@
|
||||
import Vue from "vue";
|
||||
import App from "./App.vue";
|
||||
import Vue from 'vue';
|
||||
import App from './App.vue';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.devtools = true;
|
||||
|
||||
import Bridge from "./wailsbridge";
|
||||
import Wails from '@wailsapp/runtime';
|
||||
|
||||
Bridge.Start(() => {
|
||||
new Vue({
|
||||
render: h => h(App)
|
||||
}).$mount("#app");
|
||||
Wails.Init(() => {
|
||||
new Vue({
|
||||
render: h => h(App)
|
||||
}).$mount('#app');
|
||||
});
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
module {{.BinaryName}}
|
||||
module {{.BinaryName}}
|
||||
|
||||
require (
|
||||
github.com/wailsapp/wails {{.WailsVersion}}
|
||||
)
|
||||
3
cmd/templates/vuetify-basic/.jshint
Normal file
3
cmd/templates/vuetify-basic/.jshint
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"esversion": 6
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user