From b29b534b2fd286fa194362193978d09f45873151 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Tue, 6 Jun 2023 21:52:02 +0200 Subject: [PATCH] Show version number in about dialog (#28) --- .gitignore | 1 + CHANGELOG.md | 4 ++++ build/version2file.js | 13 +++++++++++++ frontend/package.json.md5 | 2 +- frontend/src/organisms/about.svelte | 11 ++++++++++- frontend/wailsjs/go/models.ts | 2 ++ go.mod | 3 ++- go.sum | 10 +++++++--- internal/app/app.go | 5 ++++- main.go | 5 ++++- wails.json | 3 +++ 11 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 build/version2file.js diff --git a/.gitignore b/.gitignore index 66f9245..05533c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store +/build/version.txt /build/bin/ /build/windows/installer/tmp/ diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d32fe..c657abb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +* Added version number of the running Rolens instance in the about dialog (#25, #28) + ## [v0.2.0](https://github.com/garraflavatra/rolens/releases/tag/v0.2.0) * Added some external links related to Rolens to the application menu. diff --git a/build/version2file.js b/build/version2file.js new file mode 100644 index 0000000..de5d261 --- /dev/null +++ b/build/version2file.js @@ -0,0 +1,13 @@ +#!/usr/bin/node + +// This script extracts the version number from wails.json in the project root +// and writes it to version.txt + +const fs = require('fs'); + +fs.writeFileSync( + __dirname+'/version.txt', + JSON.parse( + fs.readFileSync(__dirname+'/../wails.json') + ).info.productVersion +); diff --git a/frontend/package.json.md5 b/frontend/package.json.md5 index 2fda8a2..0559e98 100755 --- a/frontend/package.json.md5 +++ b/frontend/package.json.md5 @@ -1 +1 @@ -d933a4e16d5bb0132361eef3b5d3ba22 \ No newline at end of file +541b97f7203adc96312cfd007c0d8b97 \ No newline at end of file diff --git a/frontend/src/organisms/about.svelte b/frontend/src/organisms/about.svelte index cf886d3..37161ad 100644 --- a/frontend/src/organisms/about.svelte +++ b/frontend/src/organisms/about.svelte @@ -1,6 +1,7 @@ @@ -9,7 +10,10 @@
Rolens logo
-
Rolens
+
+ Rolens + {$environment.version} +
Intuitive MongoDB
administration tool
@@ -42,6 +46,11 @@ font-weight: 600; line-height: 2.5rem; } + .brand .title .version { + font-size: 80%; + font-weight: 300; + opacity: 0.65; + } .brand .description { font-size: 1.5rem; line-height: 1.6rem; diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index d10e2e5..3704a64 100755 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -4,6 +4,7 @@ export namespace app { arch: string; buildType: string; platform: string; + version: string; hasMongoExport: boolean; hasMongoDump: boolean; homeDirectory: string; @@ -20,6 +21,7 @@ export namespace app { this.arch = source["arch"]; this.buildType = source["buildType"]; this.platform = source["platform"]; + this.version = source["version"]; this.hasMongoExport = source["hasMongoExport"]; this.hasMongoDump = source["hasMongoDump"]; this.homeDirectory = source["homeDirectory"]; diff --git a/go.mod b/go.mod index d4c1886..6935181 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/garraflavatra/rolens go 1.18 -require github.com/wailsapp/wails/v2 v2.5.1 +require github.com/wailsapp/wails/v2 v2.3.1 require ( github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 @@ -13,6 +13,7 @@ require ( require ( github.com/akavel/rsrc v0.10.2 // indirect github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f // indirect + github.com/imdario/mergo v0.3.12 // indirect github.com/josephspurrier/goversioninfo v1.4.0 // indirect github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect golang.org/x/image v0.7.0 // indirect diff --git a/go.sum b/go.sum index c16209a..6e04acc 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8= @@ -76,7 +78,7 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0 github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8= github.com/tkrajina/go-reflector v0.5.5 h1:gwoQFNye30Kk7NrExj8zm3zFtrGPqOkzFMLuQZg1DtQ= github.com/tkrajina/go-reflector v0.5.5/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -85,8 +87,8 @@ github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52 github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= -github.com/wailsapp/wails/v2 v2.5.1 h1:mfG+2kWqQXYOwdgI43HEILjOZDXbk5woPYI3jP2b+js= -github.com/wailsapp/wails/v2 v2.5.1/go.mod h1:jbOZbcr/zm79PxXxAjP8UoVlDd9wLW3uDs+isIthDfs= +github.com/wailsapp/wails/v2 v2.3.1 h1:ZJz+pyIBKyASkgO8JO31NuHO1gTTHmvwiHYHwei1CqM= +github.com/wailsapp/wails/v2 v2.3.1/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= @@ -159,6 +161,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/internal/app/app.go b/internal/app/app.go index ccc8555..684090c 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -10,6 +10,7 @@ import ( "path" "path/filepath" "runtime" + "strings" "github.com/garraflavatra/rolens/internal/ui" "github.com/ncruces/zenity" @@ -21,6 +22,7 @@ type EnvironmentInfo struct { Arch string `json:"arch"` BuildType string `json:"buildType"` Platform string `json:"platform"` + Version string `json:"version"` HasMongoExport bool `json:"hasMongoExport"` HasMongoDump bool `json:"hasMongoDump"` @@ -38,8 +40,9 @@ type App struct { ui *ui.UI } -func NewApp() *App { +func NewApp(version string) *App { a := &App{} + a.Env.Version = strings.TrimSpace(version) _, err := exec.LookPath("mongodump") a.Env.HasMongoDump = err == nil diff --git a/main.go b/main.go index e294f6f..abe0cd5 100644 --- a/main.go +++ b/main.go @@ -22,10 +22,13 @@ var ( //go:embed build/appicon.png appIcon []byte + + //go:embed build/version.txt + version string ) func main() { - app := app.NewApp() + app := app.NewApp(version) ui := uictrl.New() err := wails.Run(&options.App{ diff --git a/wails.json b/wails.json index 43575e6..b78539f 100644 --- a/wails.json +++ b/wails.json @@ -16,5 +16,8 @@ "productVersion": "0.2.0", "comments": "The intuitive MongoDB administration tool", "copyright": "© Romein van Buren 2023 (GNU GPL 3.0)." + }, + "preBuildHooks": { + "*/*": "node ../version2file.js" } }