The very basic client app, not adapted for mobiles.
Some checks failed
Linting and tests / Linting (push) Failing after 5s
Linting and tests / Tests (push) Failing after 4s

This commit is contained in:
2025-09-10 19:34:49 +05:00
parent b65b8a9e72
commit e3b9c9ae40
50 changed files with 2816 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
---
version: "3"
vars:
ClientBinary: name.pztrn.bunker.client{{exeExt}}
MetadataParams: --metadata "Branch={{ .BRANCH }}" --metadata "Build={{ .BUILD }}" --metadata "BuildDate={{ .BUILD_DATE }}" --metadata "Commit={{ .COMMIT }}" --metadata "Version={{ .VERSION }}"
env:
CGO_ENABLED: 1
tasks:
build:
desc: "Build client."
dir: ./client/cmd/client
internal: true
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne build --release -o ../../../.build/{{ .ClientBinary }} --pprof --pprof-port 6060 {{ .MetadataParams }}
build-debug:
desc: "Build client in debug mode."
internal: true
dir: ./client/cmd/client
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne build -o ../../../.build/{{ .ClientBinary }} --tags debug {{ .MetadataParams }}
# build-production:
# desc: "Build production package for current OS."
# dir: ./client/cmd/client
# cmds:
# - task: ::ensure-builddir
# - task: cleanup
# - fyne package --release --app-id name.pztrn.bunker.client -executable name.pztrn.bunker.client -icon ../../Icon.png --release --name "pztrn's Bunker" --app-version "{{ .CLIENT_VERSION }}" --app-build "{{ .BUILD }}" {{ .MetadataParams }}
# build-web:
# desc: "Build web version."
# dir: ./client/cmd/client
# cmds:
# - fyne package -os web --app-id name.pztrn.bunker.client -icon ../../Icon.png --release --name "pztrn's Bunker" --app-version "{{ .CLIENT_VERSION }}" --app-build "{{ .BUILD }}" {{ .MetadataParams }}
build-darwin-amd64:
desc: "Build darwin/arm64 using fyne-cross"
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne-cross darwin -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -arch=amd64 -category=6007 -pull client/cmd/client
build-darwin-arm64:
desc: "Build darwin/arm64 using fyne-cross"
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne-cross darwin -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -arch=arm64 -category=6007 -pull client/cmd/client
build-linux-amd64:
desc: "Build linux/amd64 using fyne-cross"
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne-cross linux -app-id=name.pztrn.bunker.client -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -icon=client/Icon.png -arch=amd64 -name="pztrn's Bunker" -pull client/cmd/client
build-windows-amd64:
desc: "Build windows/amd64 using fyne-cross"
cmds:
- task: ::ensure-builddir
- task: cleanup
- fyne-cross windows -app-id=name.pztrn.bunker.client -app-version="{{ .CLIENT_VERSION }}" -app-build="{{ .BUILD }}" -icon=client/Icon.png -arch=amd64 -name="pztrn's Bunker" -pull client/cmd/client
cleanup:
desc: "Cleanup build environment."
cmds:
- rm .build/{{ .ClientBinary }}
ignore_error: true
run:
desc: "Launch client."
cmds:
- task: build
- .build/{{ .ClientBinary }}
run-debug:
desc: "Launch client in debug mode."
cmds:
- task: build-debug
- .build/{{ .ClientBinary }}

69
client/cmd/client/main.go Normal file
View File

@@ -0,0 +1,69 @@
package main
import (
"log/slog"
"os"
"bunker/client/internal/application"
"bunker/client/internal/services/core/database"
"bunker/client/internal/services/core/mainwindow"
"bunker/client/internal/services/core/options"
"bunker/client/internal/services/core/translations"
"bunker/commons"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
slog.Info("Starting Bunker client...")
_ = slog.SetLogLoggerLevel(slog.LevelDebug)
app := application.New()
checkError(translations.Initialize(app))
checkError(database.Initialize(app))
checkError(options.Initialize(app))
checkError(mainwindow.Initialize(app))
checkError(app.Start())
}
func checkError(err error) {
if err == nil {
return
}
fyneApp := app.NewWithID(commons.ClientAppID)
wnd := fyneApp.NewWindow("pztrn's Bunker - Error occurred!")
//nolint:mnd
wnd.Resize(fyne.NewSize(550, 300))
lbl := widget.NewLabel("Error appeared while starting pztrn's Bunker:")
lbl.Wrapping = fyne.TextWrapWord
errLabel := widget.NewLabel(err.Error())
errLabel.Wrapping = fyne.TextWrapWord
lbl2 := widget.NewLabel("Please, report this to developer!")
lbl2.Wrapping = fyne.TextWrapWord
copyToClipboardButton := widget.NewButton("Copy to clipboard", func() {
fyneApp.Clipboard().SetContent(err.Error())
})
wnd.SetContent(container.NewVBox(
lbl,
errLabel,
lbl2,
copyToClipboardButton,
))
wnd.ShowAndRun()
os.Exit(1)
}

View File

@@ -0,0 +1,26 @@
---
version: "3"
vars:
TCClientBinary: name.pztrn.bunker.app.translations_checker{{exeExt}}
tasks:
build:
desc: "Build translations checker."
dir: ./client/cmd/translations_checker
cmds:
- task: ::ensure-builddir
- task: cleanup
- go build -o ../../../.build/{{ .TCClientBinary }} main.go
cleanup:
desc: "Cleanup build environment for translations checker."
cmds:
- rm .build/{{ .TCClientBinary }}
ignore_error: true
run:
desc: "Launch translations checker."
cmds:
- task: build
- .build/{{ .TCClientBinary }} -translations-path client/internal/langfiles/files

View File

@@ -0,0 +1,128 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"io/fs"
"log/slog"
"os"
"path/filepath"
"sort"
"strings"
)
const (
exitCodeFailedToReadEnglishFile = 3
exitCodeFailedToReadTranslationsFile = 6
exitCodeFailedToNormalizePath = 2
exitCodeFailedToUnmarshalEnglishFile = 4
exitCodeFailedToUnmarshalTranslationsFile = 7
exitCodeFailedToWalkTranslationsPath = 5
exitCodeNoTranslationsPath = 1
)
var translationsPath string
func main() {
flag.StringVar(&translationsPath, "translations-path", "", "Path to translations JSON files.")
flag.Parse()
if translationsPath == "" {
slog.Error("No -translations-path specified.")
os.Exit(exitCodeNoTranslationsPath)
}
slog.Info(
"Checking translations file for missing translations, using 'en.json' as original source...",
"path", translationsPath,
)
dirPath, err := filepath.Abs(translationsPath)
if err != nil {
slog.Error("Failed to normalize translations files path!", "error", err.Error())
os.Exit(exitCodeFailedToNormalizePath)
}
sourceDataAsBytes, err := os.ReadFile(filepath.Join(dirPath, "en.json"))
if err != nil {
slog.Error("Failed to read 'en.json' file!", "error", err.Error())
os.Exit(exitCodeFailedToReadEnglishFile)
}
sourceData := make(map[string]string)
if err := json.Unmarshal(sourceDataAsBytes, &sourceData); err != nil {
slog.Error("Failed to unmarshal 'en.json' file!", "error", err.Error())
os.Exit(exitCodeFailedToUnmarshalEnglishFile)
}
langFilesToCheck := make([]string, 0)
if err := filepath.WalkDir(dirPath, func(path string, _ fs.DirEntry, _ error) error {
if strings.Contains(path, ".json") && !strings.Contains(path, "en.json") {
langFilesToCheck = append(langFilesToCheck, path)
}
return nil
}); err != nil {
slog.Error("Failed to walk translations path!", "error", err.Error())
os.Exit(exitCodeFailedToWalkTranslationsPath)
}
slog.Info("Got langfiles to check", "count", len(langFilesToCheck))
missingTranslations := make(map[string][]string)
for _, langFile := range langFilesToCheck {
slog.Info("Checking language file...", "file", langFile)
langFileBytes, err := os.ReadFile(langFile)
if err != nil {
slog.Error("Failed to read language file!", "file", langFile, "error", err.Error())
os.Exit(exitCodeFailedToReadTranslationsFile)
}
langFileData := make(map[string]string)
if err := json.Unmarshal(langFileBytes, &langFileData); err != nil {
slog.Error("Failed to parse language file!", "file", langFile, "error", err.Error())
os.Exit(exitCodeFailedToUnmarshalTranslationsFile)
}
for originalTranslation := range sourceData {
if _, found := langFileData[originalTranslation]; !found {
if _, langFound := missingTranslations[langFile]; !langFound {
missingTranslations[langFile] = make([]string, 0)
}
missingTranslations[langFile] = append(missingTranslations[langFile], originalTranslation)
}
}
}
if len(missingTranslations) == 0 {
slog.Info("Yay, no missing translations!")
os.Exit(0)
}
for langFile, missing := range missingTranslations {
_, fileName := filepath.Split(langFile)
slog.Info("Found missing translations for file.", "file", fileName)
sort.Strings(missing)
//nolint:forbidigo
fmt.Println("============================== " + fileName + " MISSING START")
for _, name := range missing {
//nolint:forbidigo
fmt.Println(name)
}
//nolint:forbidigo
fmt.Println("============================== " + fileName + " MISSING END")
}
}