mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 13:19:00 -07:00
Compare commits
147 Commits
98-use-sna
...
linux-db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93d01f80f | ||
|
|
eca750e895 | ||
|
|
6b78cdd838 | ||
|
|
2a3cb35dc1 | ||
|
|
af6b631b7b | ||
|
|
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 | ||
|
|
fa27be083d | ||
|
|
ddcc103f37 | ||
|
|
b849964562 |
@@ -1,42 +0,0 @@
|
||||
{{ if .Versions -}}
|
||||
<a name="unreleased"></a>
|
||||
## [Unreleased]
|
||||
|
||||
{{ if .Unreleased.CommitGroups -}}
|
||||
{{ range .Unreleased.CommitGroups -}}
|
||||
### {{ .Title }}
|
||||
{{ range .Commits -}}
|
||||
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ range .Versions }}
|
||||
<a name="{{ .Tag.Name }}"></a>
|
||||
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
|
||||
{{ range .CommitGroups -}}
|
||||
### {{ .Title }}
|
||||
{{ range .Commits -}}
|
||||
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
|
||||
{{- if .NoteGroups -}}
|
||||
{{ range .NoteGroups -}}
|
||||
### {{ .Title }}
|
||||
{{ range .Notes }}
|
||||
{{ .Body }}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{- if .Versions }}
|
||||
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
|
||||
{{ range .Versions -}}
|
||||
{{ if .Tag.Previous -}}
|
||||
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
@@ -1,27 +0,0 @@
|
||||
style: github
|
||||
template: CHANGELOG.tpl.md
|
||||
info:
|
||||
title: CHANGELOG
|
||||
repository_url: https://github.com/wailsapp/wails
|
||||
options:
|
||||
commits:
|
||||
# filters:
|
||||
# Type:
|
||||
# - feat
|
||||
# - fix
|
||||
# - perf
|
||||
# - refactor
|
||||
commit_groups:
|
||||
# title_maps:
|
||||
# feat: Features
|
||||
# fix: Bug Fixes
|
||||
# perf: Performance Improvements
|
||||
# refactor: Code Refactoring
|
||||
header:
|
||||
pattern: "^(\\w*)\\:\\s(.*)$"
|
||||
pattern_maps:
|
||||
- Type
|
||||
- Subject
|
||||
notes:
|
||||
keywords:
|
||||
- BREAKING CHANGE
|
||||
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.
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,4 +16,4 @@ examples/**/example*
|
||||
cmd/wails/wails
|
||||
.DS_Store
|
||||
tmp
|
||||
dist
|
||||
node_modules/
|
||||
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
|
||||
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -4,6 +4,13 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Test cmd package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "test",
|
||||
"program": "${workspaceFolder}/cmd/"
|
||||
},
|
||||
{
|
||||
"name": "Wails Init",
|
||||
"type": "go",
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"go.formatTool": "goimports"
|
||||
"go.formatTool": "goimports",
|
||||
"eslint.alwaysShowStatus": true
|
||||
}
|
||||
45
CHANGELOG.md
45
CHANGELOG.md
@@ -1,19 +1,34 @@
|
||||
|
||||
<a name="v0.13.0"></a>
|
||||
## [v0.13.0] - 2019-05-12
|
||||
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)!
|
||||
|
||||
### Feat
|
||||
- revamped 'update' system
|
||||
- no need for explicit GO111MODULE=on
|
||||
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
|
||||
|
||||
### Fix
|
||||
- documentation typo fixes
|
||||
- windows init project
|
||||
- windows 10 colour
|
||||
- leave windows assets on -p flag
|
||||
- show prerequisite errors
|
||||
2019-05-29 **v0.14.11-pre**
|
||||
* Windows fix for spinner
|
||||
|
||||
### Docs
|
||||
- updated contributors
|
||||
- added awesomego logo
|
||||
- added Redhat distro
|
||||
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)!
|
||||
|
||||
@@ -8,5 +8,11 @@ Wails is what it is because of the time and effort given by these great people.
|
||||
* [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)
|
||||
* [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)
|
||||
|
||||
25
README.md
25
README.md
@@ -9,7 +9,8 @@
|
||||
<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/sindresorhus/awesome" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></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!
|
||||
@@ -18,6 +19,7 @@ The traditional method of providing web interfaces to Go programs is via a built
|
||||
|
||||
- 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
|
||||
@@ -44,19 +46,25 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
||||
|
||||
### Linux
|
||||
|
||||
#### Ubuntu 18.04
|
||||
#### Debian 9, Ubuntu 18.04, Zorin 15, Parrot 4.7
|
||||
|
||||
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
`sudo pacman -S webkit2gtk gtk3`
|
||||
|
||||
#### Red Hat Based Distros
|
||||
#### Centos 7
|
||||
|
||||
`sudo yum install webkit2gtk-devel gtk3-devel`
|
||||
`sudo yum install webkitgtk3-devel gtk3-devel`
|
||||
|
||||
Note: If you have successfully installed these dependencies on a different flavour of Linux, please consider submitting a PR.
|
||||
#### Fedora 30
|
||||
|
||||
`sudo yum install webkit2gtk3-devel gtk3-devel`
|
||||
|
||||
#### Gentoo
|
||||
|
||||
`sudo emerge gtk+:3 webkit-gtk`
|
||||
|
||||
### Windows
|
||||
|
||||
@@ -64,6 +72,8 @@ Windows requires gcc and related tooling. The recommended download is from [http
|
||||
|
||||
## 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'>
|
||||
@@ -95,7 +105,7 @@ 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.
|
||||
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:
|
||||
|
||||
@@ -117,4 +127,3 @@ This project was mainly coded to the following albums:
|
||||
* [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)
|
||||
|
||||
|
||||
75
app.go
75
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())
|
||||
}
|
||||
@@ -80,14 +81,14 @@ func (a *App) Run() error {
|
||||
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
|
||||
@@ -97,26 +98,20 @@ 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
|
||||
return a.renderer.Run()
|
||||
}
|
||||
@@ -124,17 +119,5 @@ func (a *App) start() error {
|
||||
// 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 HTML
|
||||
// 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
|
||||
}
|
||||
@@ -11,10 +11,9 @@ func (app *App) setupCli() *cmd.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
|
||||
11
cmd/cmd-mewn.go
Normal file
11
cmd/cmd-mewn.go
Normal file
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
mewn "github.com/leaanthony/mewn"
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/leaanthony/spinner"
|
||||
)
|
||||
@@ -249,8 +249,8 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
}
|
||||
|
||||
// Install the bridge library
|
||||
err = InstallBridge(caller, projectDir, projectOptions)
|
||||
// Install the runtime
|
||||
err = InstallRuntime(caller, projectDir, projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -263,22 +263,29 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallBridge installs the relevant bridge javascript library
|
||||
func InstallBridge(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
||||
bridgeFile := "wailsbridge.prod.js"
|
||||
if caller == "serve" {
|
||||
bridgeFile = "wailsbridge.js"
|
||||
// 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)
|
||||
}
|
||||
|
||||
// Copy bridge to project
|
||||
bridgeAssets := mewn.Group("../wailsruntimeassets/bridge/")
|
||||
bridgeFileData := bridgeAssets.Bytes(bridgeFile)
|
||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
|
||||
err := fs.CreateFile(bridgeFileTarget, bridgeFileData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
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
|
||||
|
||||
194
cmd/linux.go
194
cmd/linux.go
@@ -3,9 +3,12 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/browser"
|
||||
)
|
||||
|
||||
// LinuxDistribution is of type int
|
||||
@@ -14,78 +17,116 @@ type LinuxDistribution int
|
||||
const (
|
||||
// Unknown is the catch-all distro
|
||||
Unknown LinuxDistribution = iota
|
||||
// Debian distribution
|
||||
Debian
|
||||
// Ubuntu distribution
|
||||
Ubuntu
|
||||
// Arch linux distribution
|
||||
Arch
|
||||
// RedHat linux distribution
|
||||
RedHat
|
||||
// CentOS linux distribution
|
||||
CentOS
|
||||
// Fedora linux distribution
|
||||
Fedora
|
||||
// Gentoo distribution
|
||||
Gentoo
|
||||
// Zorin distribution
|
||||
Zorin
|
||||
// Parrot distribution
|
||||
Parrot
|
||||
)
|
||||
|
||||
// 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 "Arch", "ManjaroLinux":
|
||||
result.Distribution = Arch
|
||||
}
|
||||
case "Description":
|
||||
result.Description = value
|
||||
case "Release":
|
||||
result.Release = value
|
||||
case "Codename":
|
||||
result.Codename = value
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if /etc/os-release exists
|
||||
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
||||
// read /etc/os-release
|
||||
result := &DistroInfo{
|
||||
Distribution: Unknown,
|
||||
ID: "unknown",
|
||||
Name: "Unknown",
|
||||
}
|
||||
_, err := os.Stat("/etc/os-release")
|
||||
if !os.IsNotExist(err) {
|
||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||
// compile a regex to find NAME=distro
|
||||
re := regexp.MustCompile(`^NAME=(.*)\n`)
|
||||
// extract the distro name
|
||||
osName := string(re.FindSubmatch(osRelease)[1])
|
||||
// Check distro name against list of RedHat distros
|
||||
if osName == "Fedora" || osName == "CentOS" {
|
||||
//if it matches set result.Distribution to RedHat
|
||||
result.Distribution = RedHat
|
||||
}
|
||||
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
|
||||
result.Release = version
|
||||
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
|
||||
default:
|
||||
result.Distribution = Unknown
|
||||
}
|
||||
|
||||
result.ID = osID
|
||||
result.Name = osNAME
|
||||
return result
|
||||
}
|
||||
|
||||
// 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) {
|
||||
program := NewProgramHelper()
|
||||
@@ -118,3 +159,44 @@ func RpmInstalled(packageName string) (bool, error) {
|
||||
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
// RequestSupportForDistribution promts the user to submit a request to support their
|
||||
// currently unsupported distribution
|
||||
func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
|
||||
var logger = NewLogger()
|
||||
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.Name, libraryName)
|
||||
|
||||
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(name string) *Release {
|
||||
result := d.Releases[name]
|
||||
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(name string) *Distribution {
|
||||
return l.Distributions[name]
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
124
cmd/linuxdb.yaml
Normal file
124
cmd/linuxdb.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
---
|
||||
distributions:
|
||||
ubuntu:
|
||||
id: ubuntu
|
||||
releases:
|
||||
default:
|
||||
name: Ubuntu
|
||||
version: default
|
||||
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
||||
programs: &ubuntudefaultprograms
|
||||
- name: gcc
|
||||
help: Please install with `sudo apt install build-essential` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo apt 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: &ubuntudefaultlibraries
|
||||
- name: libgtk-3-dev
|
||||
help: Please install with `sudo apt install libgtk-3-dev` and try again
|
||||
- name: libwebkit2gtk-4.0-dev
|
||||
help: Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again
|
||||
debian:
|
||||
id: debian
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Debian
|
||||
gccversioncommand: &gccdumpversion -dumpversion
|
||||
programs: *ubuntudefaultprograms
|
||||
libraries: *ubuntudefaultlibraries
|
||||
parrot:
|
||||
id: parrot
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Parrot
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs: *ubuntudefaultprograms
|
||||
libraries: *ubuntudefaultlibraries
|
||||
zorin:
|
||||
id: zorin
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Zorin
|
||||
gccversioncommand: *gccdumpversion
|
||||
programs:
|
||||
- name: gcc
|
||||
help: Please install with `sudo apt install build-essential` and try again
|
||||
- name: pkg-config
|
||||
help: Please install with `sudo apt install pkg-config` and try again
|
||||
- name: npm
|
||||
help: Please install with `sudo snap install node --channel=12/stable --classic` and try again
|
||||
libraries: *ubuntudefaultlibraries
|
||||
centos:
|
||||
id: centos
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: CentOS
|
||||
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 `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` and try again
|
||||
libraries: ¢osdefaultlibraries
|
||||
- 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
|
||||
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 -y nodejs` and try again
|
||||
libraries: *centosdefaultlibraries
|
||||
arch:
|
||||
id: arch
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Arch Linux
|
||||
gccversioncommand: *gccdumpversion
|
||||
prerequisites:
|
||||
- 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
|
||||
- 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
|
||||
gentoo:
|
||||
id: gentoo
|
||||
releases:
|
||||
default:
|
||||
version: default
|
||||
name: Gentoo
|
||||
gccversioncommand: *gccdumpversion
|
||||
prerequisites:
|
||||
- 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
|
||||
- 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
|
||||
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))
|
||||
}
|
||||
}
|
||||
@@ -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 snap install node --channel=12/stable --classic` and try again"))
|
||||
|
||||
default:
|
||||
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
|
||||
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
|
||||
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,20 +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"))
|
||||
case Arch:
|
||||
result.Add(newPrerequisite("gtk3", "Please install with `sudo pacman -S gtk3` and try again"))
|
||||
result.Add(newPrerequisite("webkit2gtk", "Please install with `sudo pacman -S webkit2gtk` and try again"))
|
||||
case RedHat:
|
||||
result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again"))
|
||||
result.Add(newPrerequisite("webkit2gtk3-devel", "Please install with `sudo yum install webkit2gtk3-devel` 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
|
||||
}
|
||||
|
||||
@@ -117,14 +117,15 @@ func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
||||
}
|
||||
args = args[1:]
|
||||
var stderr string
|
||||
// fmt.Printf("RunCommandArray = %s %+v\n", program, args)
|
||||
var stdout string
|
||||
if len(dir) > 0 {
|
||||
_, stderr, err = p.shell.RunInDirectory(dir[0], program, args...)
|
||||
stdout, stderr, err = p.shell.RunInDirectory(dir[0], program, args...)
|
||||
} else {
|
||||
_, stderr, err = p.shell.Run(program, args...)
|
||||
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"
|
||||
@@ -143,11 +144,13 @@ type ProjectOptions struct {
|
||||
log *Logger
|
||||
templates *TemplateHelper
|
||||
selectedTemplate *TemplateDetails
|
||||
WailsVersion string
|
||||
}
|
||||
|
||||
// Defaults sets the default project template
|
||||
func (po *ProjectOptions) Defaults() {
|
||||
po.Template = "vuebasic"
|
||||
po.WailsVersion = Version
|
||||
}
|
||||
|
||||
// PromptForInputs asks the user to input project details
|
||||
@@ -182,7 +185,13 @@ func (po *ProjectOptions) PromptForInputs() error {
|
||||
po.selectedTemplate = templateDetails[po.Template]
|
||||
} else {
|
||||
|
||||
for _, templateDetail := range templateDetails {
|
||||
keys := make([]string, 0)
|
||||
for k := range templateDetails {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
templateDetail := templateDetails[k]
|
||||
templateList.Add(templateDetail)
|
||||
options.Add(fmt.Sprintf("%s - %s", templateDetail.Metadata.Name, templateDetail.Metadata.ShortDescription))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,7 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/masterminds/semver"
|
||||
"github.com/Masterminds/semver"
|
||||
)
|
||||
|
||||
// SemanticVersion is a struct containing a semantic version
|
||||
|
||||
@@ -272,7 +272,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
distroInfo := GetLinuxDistroInfo()
|
||||
for _, library := range *requiredLibraries {
|
||||
switch distroInfo.Distribution {
|
||||
case Ubuntu:
|
||||
case Ubuntu, Debian, Zorin, Parrot:
|
||||
installed, err := DpkgInstalled(library.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -294,8 +294,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
} else {
|
||||
logger.Green("Library '%s' installed.", library.Name)
|
||||
}
|
||||
case RedHat:
|
||||
|
||||
case CentOS, Fedora:
|
||||
installed, err := RpmInstalled(library.Name)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -306,8 +305,19 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
||||
} else {
|
||||
logger.Green("Library '%s' installed.", library.Name)
|
||||
}
|
||||
case Gentoo:
|
||||
installed, err := EqueryInstalled(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)
|
||||
}
|
||||
default:
|
||||
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
|
||||
return false, RequestSupportForDistribution(distroInfo, library.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,26 @@ import (
|
||||
|
||||
// TemplateMetadata holds all the metadata for a Wails template
|
||||
type TemplateMetadata struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
ShortDescription string `json:"shortdescription"`
|
||||
Description string `json:"description"`
|
||||
Install string `json:"install"`
|
||||
Build string `json:"build"`
|
||||
Author string `json:"author"`
|
||||
Created string `json:"created"`
|
||||
FrontendDir string `json:"frontenddir"`
|
||||
Serve string `json:"serve"`
|
||||
Bridge string `json:"bridge"`
|
||||
WailsDir string `json:"wailsdir"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
ShortDescription string `json:"shortdescription"`
|
||||
Description string `json:"description"`
|
||||
Install string `json:"install"`
|
||||
Build string `json:"build"`
|
||||
Author string `json:"author"`
|
||||
Created string `json:"created"`
|
||||
FrontendDir string `json:"frontenddir"`
|
||||
Serve string `json:"serve"`
|
||||
Bridge string `json:"bridge"`
|
||||
WailsDir string `json:"wailsdir"`
|
||||
TemplateDependencies []*TemplateDependency `json:"dependencies,omitempty"`
|
||||
}
|
||||
|
||||
// TemplateDependency defines a binary dependency for the template
|
||||
// EG: ng for angular
|
||||
type TemplateDependency struct {
|
||||
Bin string `json:"bin"`
|
||||
Help string `json:"help"`
|
||||
}
|
||||
|
||||
// TemplateDetails holds information about a specific template
|
||||
@@ -152,6 +160,31 @@ func (t *TemplateHelper) GetTemplateFilenames(template *TemplateDetails) (*slice
|
||||
// project path given
|
||||
func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *ProjectOptions) error {
|
||||
|
||||
// Check dependencies before installing
|
||||
dependencies := projectOptions.selectedTemplate.Metadata.TemplateDependencies
|
||||
if dependencies != nil {
|
||||
programHelper := NewProgramHelper()
|
||||
logger := NewLogger()
|
||||
errors := []string{}
|
||||
for _, dep := range dependencies {
|
||||
program := programHelper.FindProgram(dep.Bin)
|
||||
if program == nil {
|
||||
errors = append(errors, dep.Help)
|
||||
}
|
||||
}
|
||||
if len(errors) > 0 {
|
||||
mainError := "template dependencies not installed"
|
||||
if len(errors) == 1 {
|
||||
mainError = errors[0]
|
||||
} else {
|
||||
for _, error := range errors {
|
||||
logger.Red(error)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf(mainError)
|
||||
}
|
||||
}
|
||||
|
||||
// Get template files
|
||||
templateFilenames, err := t.GetTemplateFilenames(projectOptions.selectedTemplate)
|
||||
if err != nil {
|
||||
@@ -160,6 +193,9 @@ func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *Pro
|
||||
|
||||
templatePath := projectOptions.selectedTemplate.Path
|
||||
|
||||
// Save the version
|
||||
projectOptions.WailsVersion = Version
|
||||
|
||||
templateJSONFilename := filepath.Join(templatePath, t.metadataFilename)
|
||||
|
||||
templateFiles := templateFilenames.Filter(func(filename string) bool {
|
||||
|
||||
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",
|
||||
|
||||
@@ -1,13 +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
|
||||
}
|
||||
21
cmd/templates/vuetify-basic/frontend/.gitignore
vendored
Normal file
21
cmd/templates/vuetify-basic/frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw*
|
||||
5
cmd/templates/vuetify-basic/frontend/babel.config.js
Normal file
5
cmd/templates/vuetify-basic/frontend/babel.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/app'
|
||||
]
|
||||
}
|
||||
53
cmd/templates/vuetify-basic/frontend/package.json.template
Normal file
53
cmd/templates/vuetify-basic/frontend/package.json.template
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "{{.NPMProjectName}}",
|
||||
"author": "{{.Author.Name}}<{{.Author.Email}}>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"core-js": "^2.6.4",
|
||||
"material-design-icons-iconfont": "^5.0.1",
|
||||
"vue": "^2.5.22",
|
||||
"vuetify": "^1.5.14",
|
||||
"@wailsapp/runtime": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^3.4.0",
|
||||
"@vue/cli-plugin-eslint": "^3.4.0",
|
||||
"@vue/cli-service": "^3.4.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"vue-template-compiler": "^2.5.21",
|
||||
"webpack-hot-middleware": "^2.24.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"rules": {},
|
||||
"parserOptions": {
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
},
|
||||
"postcss": {
|
||||
"plugins": {
|
||||
"autoprefixer": {}
|
||||
}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
]
|
||||
}
|
||||
60
cmd/templates/vuetify-basic/frontend/src/App.vue
Normal file
60
cmd/templates/vuetify-basic/frontend/src/App.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<v-app id="inspire" dark>
|
||||
<v-navigation-drawer v-model="drawer" clipped fixed app>
|
||||
<v-list dense>
|
||||
<v-list-tile>
|
||||
<v-list-tile-action>
|
||||
<v-icon>dashboard</v-icon>
|
||||
</v-list-tile-action>
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>Dashboard</v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
<v-list-tile>
|
||||
<v-list-tile-action>
|
||||
<v-icon>settings</v-icon>
|
||||
</v-list-tile-action>
|
||||
<v-list-tile-content>
|
||||
<v-list-tile-title>Settings</v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
</v-list>
|
||||
</v-navigation-drawer>
|
||||
<v-toolbar app fixed clipped-left>
|
||||
<v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
|
||||
<v-toolbar-title>Application</v-toolbar-title>
|
||||
</v-toolbar>
|
||||
<v-content>
|
||||
<v-container fluid class="px-0">
|
||||
<v-layout justify-center align-center class="px-0">
|
||||
<hello-world></hello-world>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</v-content>
|
||||
<v-footer app fixed>
|
||||
<span style="margin-left:1em">© You</span>
|
||||
</v-footer>
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HelloWorld from "./components/HelloWorld.vue";
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
drawer: false
|
||||
}),
|
||||
components: {
|
||||
HelloWorld
|
||||
},
|
||||
props: {
|
||||
source: String
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.logo {
|
||||
width: 16em;
|
||||
}
|
||||
</style>
|
||||
BIN
cmd/templates/vuetify-basic/frontend/src/assets/images/logo.png
Normal file
BIN
cmd/templates/vuetify-basic/frontend/src/assets/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<v-container fluid class="px-0">
|
||||
<v-layout>
|
||||
<v-flex xs12 sm6 offset-sm3>
|
||||
<v-card raised="raised" class="pa-4 ma-4">
|
||||
<v-layout justify-center align-center class="pa-4 ma-4">
|
||||
<v-img :src="require('../assets/images/logo.png')"></v-img>
|
||||
</v-layout>
|
||||
<v-card-actions>
|
||||
<v-layout justify-center align-center class="px-0">
|
||||
<v-btn color="blue" dark @click="getMessage">Press Me</v-btn>
|
||||
</v-layout>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
<div class="text-xs-center">
|
||||
<v-dialog v-model="dialog" width="500">
|
||||
<v-card>
|
||||
<v-card-title class="headline" primary-title>Message from Go</v-card-title>
|
||||
<v-card-text>{{message}}</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="primary" flat @click="dialog = false">Awesome</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</div>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
message: " ",
|
||||
raised: true,
|
||||
dialog: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getMessage: function() {
|
||||
var self = this;
|
||||
window.backend.basic().then(result => {
|
||||
self.message = result;
|
||||
self.dialog = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
h1 {
|
||||
margin-top: 2em;
|
||||
position: relative;
|
||||
min-height: 5rem;
|
||||
width: 100%;
|
||||
}
|
||||
a:hover {
|
||||
font-size: 1.7em;
|
||||
border-color: blue;
|
||||
background-color: blue;
|
||||
color: white;
|
||||
border: 3px solid white;
|
||||
border-radius: 10px;
|
||||
padding: 9px;
|
||||
cursor: pointer;
|
||||
transition: 500ms;
|
||||
}
|
||||
a {
|
||||
font-size: 1.7em;
|
||||
border-color: white;
|
||||
background-color: #121212;
|
||||
color: white;
|
||||
border: 3px solid white;
|
||||
border-radius: 10px;
|
||||
padding: 9px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
21
cmd/templates/vuetify-basic/frontend/src/main.js
Normal file
21
cmd/templates/vuetify-basic/frontend/src/main.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'babel-polyfill';
|
||||
import Vue from 'vue';
|
||||
|
||||
// Setup Vuetify
|
||||
import Vuetify from 'vuetify';
|
||||
Vue.use(Vuetify);
|
||||
import 'vuetify/dist/vuetify.min.css';
|
||||
import 'material-design-icons-iconfont';
|
||||
|
||||
import App from './App.vue';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.devtools = true;
|
||||
|
||||
import Wails from '@wailsapp/runtime';
|
||||
|
||||
Wails.Init(() => {
|
||||
new Vue({
|
||||
render: h => h(App)
|
||||
}).$mount('#app');
|
||||
});
|
||||
43
cmd/templates/vuetify-basic/frontend/vue.config.js
Normal file
43
cmd/templates/vuetify-basic/frontend/vue.config.js
Normal file
@@ -0,0 +1,43 @@
|
||||
let cssConfig = {};
|
||||
|
||||
if (process.env.NODE_ENV == "production") {
|
||||
cssConfig = {
|
||||
extract: {
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[name].css"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
chainWebpack: config => {
|
||||
let limit = 9999999999999999;
|
||||
config.module
|
||||
.rule("images")
|
||||
.test(/\.(png|gif|jpg)(\?.*)?$/i)
|
||||
.use("url-loader")
|
||||
.loader("url-loader")
|
||||
.tap(options => Object.assign(options, { limit: limit }));
|
||||
config.module
|
||||
.rule("fonts")
|
||||
.test(/\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/i)
|
||||
.use("url-loader")
|
||||
.loader("url-loader")
|
||||
.options({
|
||||
limit: limit
|
||||
});
|
||||
},
|
||||
css: cssConfig,
|
||||
configureWebpack: {
|
||||
output: {
|
||||
filename: "[name].js"
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: false
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
disableHostCheck: true,
|
||||
host: "localhost"
|
||||
}
|
||||
};
|
||||
5
cmd/templates/vuetify-basic/go.mod.template
Normal file
5
cmd/templates/vuetify-basic/go.mod.template
Normal file
@@ -0,0 +1,5 @@
|
||||
module {{.BinaryName}}
|
||||
|
||||
require (
|
||||
github.com/wailsapp/wails {{.WailsVersion}}
|
||||
)
|
||||
27
cmd/templates/vuetify-basic/main.go.template
Normal file
27
cmd/templates/vuetify-basic/main.go.template
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
func basic() string {
|
||||
return "Hello World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
js := mewn.String("./frontend/dist/app.js")
|
||||
css := mewn.String("./frontend/dist/app.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/vuetify-basic/template.json
Executable file
14
cmd/templates/vuetify-basic/template.json
Executable file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Vuetify Basic",
|
||||
"version": "1.0.0",
|
||||
"shortdescription": "Vuetify + Webpack",
|
||||
"description": "Basic template using Vuetify and bundled using Webpack",
|
||||
"install": "npm install",
|
||||
"build": "npm run build",
|
||||
"author": "lea <lea.anthony@gmail.com>",
|
||||
"created": "2019-05-25 09:39:40.009307 +1000 AEST m=+59.539991073",
|
||||
"frontenddir": "frontend",
|
||||
"serve": "npm run serve",
|
||||
"bridge": "src",
|
||||
"wailsdir": ""
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user