Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1301 use wails for front end #1302

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6195ee7
Delete useless package-lock.json
thomas-senechal Dec 21, 2023
dc3beeb
Add basic Wails setup
thomas-senechal Dec 21, 2023
a0f64c0
Remove useless output dir from vite.config.ts file
thomas-senechal Dec 21, 2023
8c5a184
Fix API calls to station.massa
thomas-senechal Dec 21, 2023
6358a4d
Fix cors error
thomas-senechal Dec 21, 2023
ea3e9c2
Fix plugins opening
thomas-senechal Dec 21, 2023
72149f6
Use Massa Station logo as Wails App logo
thomas-senechal Dec 21, 2023
f4fa8cf
Remove old main
thomas-senechal Dec 21, 2023
9b5ed81
Add build/bin/ to .gitignore
thomas-senechal Dec 21, 2023
dc87767
Improve opening links in web browser
thomas-senechal Dec 21, 2023
ac0dfe0
Fix lint errors
thomas-senechal Dec 21, 2023
fcdd8df
TMP: Disable fail fast to see what does compile
thomas-senechal Jan 5, 2024
f76926a
Update Taskfile.yml
thomas-senechal Jan 5, 2024
4607239
Update build in build workflow
thomas-senechal Jan 5, 2024
adfe0f8
Remove frontend handlers
thomas-senechal Jan 5, 2024
d3886ac
Improve MacOS build and remove fyne in build workflow
thomas-senechal Jan 5, 2024
ac96e55
Add libwebkit2gtk installation in task install on linux
thomas-senechal Jan 5, 2024
cd1da40
Remove systray package
thomas-senechal Jan 12, 2024
db4ec68
Improve API server shutdown
thomas-senechal Jan 12, 2024
f0db5f0
Rewrite MS update check handling
thomas-senechal Jan 12, 2024
5a19ea7
Replace generated runtime with @wailsio/runtime lib in frontend
thomas-senechal Jan 12, 2024
d7bdfde
Add int/gui package with systray
thomas-senechal Jan 12, 2024
bcb1229
Update go.mod
thomas-senechal Jan 12, 2024
01304cd
TMP: Remove compiler option in build workflow (to see if it compiles …
thomas-senechal Jan 15, 2024
85c4fe7
Fix build issue in configure_massastation.go
thomas-senechal Jan 15, 2024
6f92be3
Implement systray network submenu
thomas-senechal Jan 18, 2024
ddee41d
Fix typo in update dialog
thomas-senechal Jan 18, 2024
414dbcf
Add and CTRL+C interceptor to ensure MS is always gracefully closed
thomas-senechal Jan 18, 2024
e6bd85e
Add -H windowsgui for Windows build in CI
thomas-senechal Jan 18, 2024
7bfbff4
Update build command in Taskfile.yml for macOS
thomas-senechal Jan 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ jobs:
build:
name: build and upload artifacts
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: amd64
target: windows
cc: x86_64-w64-mingw32-gcc
ext: .exe
- os: ubuntu-20.04
ldflags: "-H windowsgui"
- os: ubuntu-22.04
arch: amd64
target: linux
- os: macos-latest
Expand All @@ -47,25 +49,19 @@ jobs:
with:
os: ${{ matrix.os }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Fyne
run: go install fyne.io/fyne/v2/cmd/fyne@latest
- name: Set environment variables
run: |
echo "GOOS=${{ matrix.target }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV
- name: Build binary for ${{ matrix.target }} on ${{ matrix.arch}}
- name: Build binary for ${{ matrix.target }} on ${{ matrix.arch }}
shell: bash
run: |
go build -ldflags "-X github.com/massalabs/station/int/config.Version=${{env.VERSION}}" -o massastation_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }} ./cmd/massastation/
- name: Package binary for ${{ matrix.target }} on ${{ matrix.arch}}
# We don't need to package for windows since fyne package generates a similar .exe as go build.
if: matrix.target != 'windows'
shell: bash
run: |
cp massastation_${{ matrix.target }}_${{ matrix.arch }} massastation
fyne package -name MassaStation -icon ./int/systray/embedded/logo.png -appID net.massalabs.massastation -exe massastation
go build \
-tags desktop,production -ldflags "-w -s -X github.com/massalabs/station/int/config.Version=${{ env.VERSION }} ${{ matrix.ldflags }}" \
-o massastation_${{ matrix.target }}_${{ matrix.arch }}${{ matrix.ext }}

- name: Upload MassaStation Binary
uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build/massastation/*
/build/bin/

*.spec

Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ linters-settings:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: snake
gomoddirectives:
replace-allow-list:
- github.com/wailsapp/wails/v3
12 changes: 9 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ tasks:
install:
cmds:
- echo "Installing dependencies"
- cmd: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev javascriptcoregtk-4.1-dev build-essential pkg-config
platforms: [linux]
ignore_error: true
- cmd: go install github.com/wailsapp/wails/v3/cmd/wails3@latest
- cmd: go install github.com/go-swagger/go-swagger/cmd/swagger@latest
- cmd: go install golang.org/x/tools/cmd/stringer@latest
- cmd: go install go.uber.org/mock/[email protected]
Expand Down Expand Up @@ -58,22 +62,24 @@ tasks:
platforms: [linux]
cmds:
- cmd: mkdir -p build/massastation
- cmd: go build -o build/massastation/massastation cmd/massastation/main.go
- cmd: go build -o build/massastation/massastation ./main.go
- cmd: sudo setcap CAP_NET_BIND_SERVICE=+eip build/massastation/massastation

build-macos:
platforms: [darwin]
cmds:
- cmd: mkdir -p build/massastation
- cmd: go build -o build/massastation/massastation cmd/massastation/main.go
- cmd: go build -o build/massastation/massastation ./main.go
env:
MACOSX_DEPLOYMENT_TARGET: 11.0

build-windows:
platforms: [windows]
cmds:
- cmd: mkdir -p build/massastation
- cmd: mkdir -p build/massastation/logs
- cmd: mkdir -p build/massastation/certs
- cmd: go build -o build/massastation/massastation.exe cmd/massastation/main.go
- cmd: go build -o build/massastation/massastation.exe ./main.go

run:
env:
Expand Down
11 changes: 9 additions & 2 deletions api/swagger/server/restapi/configure_massastation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ func configureMassaStationAPI(api *operations.MassastationAPI, shutdown chan str
}

api.ServerShutdown = func() {
close(shutdown)
// We check if the shutdown channel is closed to avoid closing it twice.
select {
case <-shutdown:
return
default:
close(shutdown)
}
}
api.Logger = func(msg string, args ...interface{}) {
logger.Infof(msg, args...)
Expand Down Expand Up @@ -124,7 +130,8 @@ func setupMiddlewares(handler http.Handler) http.Handler {
// document.
// So this is a good place to plug in a panic handling middleware, logging and metrics.
func setupGlobalMiddleware(handler http.Handler) http.Handler {
handleCORS := cors.Default().Handler
// Maybe we should use a more restrictive CORS policy?
handleCORS := cors.AllowAll().Handler

return api.TopMiddleware(handleCORS(handler))
}
24 changes: 0 additions & 24 deletions api/swagger/server/restapi/resource/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -763,30 +763,6 @@ paths:
description: Internal Server Error - The server has encountered a situation it does not know how to handle.
schema:
$ref: "#/definitions/Error"
/web/{resource}:
get:
description: Frontend router for the MassaStation.
operationId: MassaStationWebApp
produces:
- application/json
- text/javascript
- text/html
- text/css
- text/webp
- image/png
parameters:
- in: path
name: resource
required : true
type: string
description: Website resource.
responses:
"200":
description: Page found
"404":
description: Resource not found.
schema:
$ref: "#/definitions/Error"
/plugin/{author-name}/{plugin-name}:
get:
operationId: pluginRouter
Expand Down
File renamed without changes
78 changes: 78 additions & 0 deletions build/darwin/Info.dev.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>{{.Info.ProductName}}</string>
<key>CFBundleExecutable</key>
<string>{{.Name}}</string>
<key>CFBundleIdentifier</key>
<string>com.wails.{{.Name}}</string>
<key>CFBundleVersion</key>
<string>{{.Info.ProductVersion}}</string>
<key>CFBundleGetInfoString</key>
<string>{{.Info.Comments}}</string>
<key>CFBundleShortVersionString</key>
<string>{{.Info.ProductVersion}}</string>
<key>CFBundleIconFile</key>
<string>iconfile</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>{{.Info.Copyright}}</string>
{{if .Info.FileAssociations}}
<key>CFBundleDocumentTypes</key>
<array>
{{range .Info.FileAssociations}}
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>{{.Ext}}</string>
</array>
<key>CFBundleTypeName</key>
<string>{{.Name}}</string>
<key>CFBundleTypeRole</key>
<string>{{.Role}}</string>
<key>CFBundleTypeIconFile</key>
<string>{{.IconName}}</string>
</dict>
{{end}}
</array>
{{end}}
{{if .Info.Protocols}}
<key>CFBundleURLTypes</key>
<array>
{{range .Info.Protocols}}
<dict>
<key>CFBundleURLName</key>
<string>com.wails.{{.Scheme}}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>{{.Scheme}}</string>
</array>
<key>CFBundleTypeRole</key>
<string>{{.Role}}</string>
</dict>
{{end}}
</array>
{{end}}
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>station.massa</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
78 changes: 78 additions & 0 deletions build/darwin/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>{{.Info.ProductName}}</string>
<key>CFBundleExecutable</key>
<string>{{.Name}}</string>
<key>CFBundleIdentifier</key>
<string>com.wails.{{.Name}}</string>
<key>CFBundleVersion</key>
<string>{{.Info.ProductVersion}}</string>
<key>CFBundleGetInfoString</key>
<string>{{.Info.Comments}}</string>
<key>CFBundleShortVersionString</key>
<string>{{.Info.ProductVersion}}</string>
<key>CFBundleIconFile</key>
<string>iconfile</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>{{.Info.Copyright}}</string>
{{if .Info.FileAssociations}}
<key>CFBundleDocumentTypes</key>
<array>
{{range .Info.FileAssociations}}
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>{{.Ext}}</string>
</array>
<key>CFBundleTypeName</key>
<string>{{.Name}}</string>
<key>CFBundleTypeRole</key>
<string>{{.Role}}</string>
<key>CFBundleTypeIconFile</key>
<string>{{.IconName}}</string>
</dict>
{{end}}
</array>
{{end}}
{{if .Info.Protocols}}
<key>CFBundleURLTypes</key>
<array>
{{range .Info.Protocols}}
<dict>
<key>CFBundleURLName</key>
<string>com.wails.{{.Scheme}}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>{{.Scheme}}</string>
</array>
<key>CFBundleTypeRole</key>
<string>{{.Role}}</string>
</dict>
{{end}}
</array>
{{end}}
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>station.massa</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
2 changes: 1 addition & 1 deletion gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package resource
package main

// API swagger
//go:generate swagger generate server --quiet --target api/swagger/server --name massastation --spec api/swagger/server/restapi/resource/swagger.yml --exclude-main
Loading
Loading