Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Add windows build script, detect if app is from package manager, swit…
Browse files Browse the repository at this point in the history
…ch prefs to json
  • Loading branch information
achhabra2 committed Dec 30, 2021
1 parent 58f8d57 commit 88189fb
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ node_modules
gon-config.json

microsoft.system.package.metadata
RiftShare.msix
*.msix
15 changes: 13 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/exec"
"path/filepath"
goruntime "runtime"
"strings"
"time"

"riftshare/internal/settings"
Expand Down Expand Up @@ -59,9 +60,9 @@ func (b *App) startup(ctx context.Context) {
// domReady is called after the front-end dom has been loaded
func (b *App) domReady(ctx context.Context) {
// Add your action here
if b.UserPrefs.SelfUpdate {
if b.UserPrefs.SelfUpdate && !b.AppInstalledFromPackageManager() {
b.UpdateCheckUI()
}
}
}

// shutdown is called at application termination
Expand Down Expand Up @@ -408,3 +409,13 @@ func (b *App) ShowErrorDialog(message string) {
opts := runtime.MessageDialogOptions{Title: "Error Occured", Message: message, Buttons: buttons, Type: runtime.ErrorDialog, DefaultButton: "Ok"}
runtime.MessageDialog(b.ctx, opts)
}

func (b *App) AppInstalledFromPackageManager() bool {
switch goruntime.GOOS {
case "windows":
cmdPath, _ := os.Executable()
return strings.Contains(cmdPath, "WindowsApps")
default:
return false
}
}
14 changes: 14 additions & 0 deletions build-windows.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off
echo "Building for Windows"
wails build -platform windows/amd64 -clean
echo "Creating MSIX Package"
cd build\windows
MakeAppx pack /m appxmanifest.xml /f mapping.txt /p RiftShare.msix
move RiftShare.msix ..\..\
cd ..\..\
rename RiftShare.msix RiftShare-windows-amd64.msix
echo "Signing Packages"
SignTool sign /fd SHA256 /a /f %WINDOWS_CERT_PATH% /p %WINDOWS_CERT_PASSWORD% /t http://timestamp.digicert.com RiftShare-windows-amd64.msix
SignTool sign /fd SHA256 /a /f %WINDOWS_CERT_PATH% /p %WINDOWS_CERT_PASSWORD% /t http://timestamp.digicert.com .\build\bin\RiftShare.exe
echo "Compressing exe"
Compress-Archive -Path .\build\bin\RiftShare.exe -DestinationPath .\RiftShare-windows-amd64.zip
2 changes: 1 addition & 1 deletion frontend/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/dist/bundle.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions frontend/src/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
let notifications = false;
let overwrite = false;
let selfUpdate = false;
let packageManaged = false;
onMount(() => {
go.main.App.GetUserPrefs().then(prefs => {
Expand All @@ -18,6 +19,10 @@
go.main.App.GetLogPath().then((path) => {
logPath = path;
});
go.main.App.AppInstalledFromPackageManager().then(managed => {
packageManaged = managed;
});
});
function setDownloadsFolder() {
Expand Down Expand Up @@ -91,6 +96,9 @@
</div>
<div class="text-gray-300">Auto Update</div>
<div class="flex flex-row items-center justify-between mb-1">
{#if packageManaged}
<span class="text-sm">Update from Package Manager</span>
{:else}
<label class="text-sm" for="selfUpdate">Auto Update Enabled</label>
<input
class="checkbox"
Expand All @@ -100,6 +108,7 @@
checked={selfUpdate}
on:input={toggleSelfUpdate}
/>
{/if}
</div>
<div class="mb-1">
<div class="text-gray-300">Logs</div>
Expand Down
4 changes: 1 addition & 3 deletions frontend/wailsjs/go/bindings.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
interface go {
"main": {
"App": {
AppInstalledFromPackageManager():Promise<boolean>
CancelWormholeRequest():Promise<void>
ClearSelectedFiles():Promise<void>
GetCurrentVersion():Promise<string>
GetDownloadsFolder():Promise<string>
GetLogPath():Promise<string>
GetNotificationsParam():Promise<boolean>
GetOverwriteParam():Promise<boolean>
GetReceivedFile():Promise<string>
GetSelectedFiles():Promise<Array<string>>
GetUserPrefs():Promise<UserSettings>
Expand Down
28 changes: 7 additions & 21 deletions frontend/wailsjs/go/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
const go = {
"main": {
"App": {
/**
* AppInstalledFromPackageManager
* @returns {Promise<boolean>} - Go Type: bool
*/
"AppInstalledFromPackageManager": () => {
return window.go.main.App.AppInstalledFromPackageManager();
},
/**
* CancelWormholeRequest
* @returns {Promise<void>}
Expand All @@ -25,34 +32,13 @@ const go = {
"GetCurrentVersion": () => {
return window.go.main.App.GetCurrentVersion();
},
/**
* GetDownloadsFolder
* @returns {Promise<string>} - Go Type: string
*/
"GetDownloadsFolder": () => {
return window.go.main.App.GetDownloadsFolder();
},
/**
* GetLogPath
* @returns {Promise<string>} - Go Type: string
*/
"GetLogPath": () => {
return window.go.main.App.GetLogPath();
},
/**
* GetNotificationsParam
* @returns {Promise<boolean>} - Go Type: bool
*/
"GetNotificationsParam": () => {
return window.go.main.App.GetNotificationsParam();
},
/**
* GetOverwriteParam
* @returns {Promise<boolean>} - Go Type: bool
*/
"GetOverwriteParam": () => {
return window.go.main.App.GetOverwriteParam();
},
/**
* GetReceivedFile
* @returns {Promise<string>} - Go Type: string
Expand Down
10 changes: 4 additions & 6 deletions frontend/wailsjs/runtime/runtime.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
interface Position {
export interface Position {
x: number;
y: number;
}

interface Size {
export interface Size {
w: number;
h: number;
}

interface RGBA {
export interface RGBA {
r: number;
g: number;
b: number;
a: number;
}


interface runtime {
export interface runtime {
EventsEmit(eventName: string, data?: any): void;

EventsOn(eventName: string, callback: (data?: any) => void): void;
Expand Down Expand Up @@ -83,5 +83,3 @@ declare global {
runtime: runtime;
}
}

export { };
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/psanford/wormhole-william v1.0.6
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/wailsapp/wails/v2 v2.0.0-beta.27
gopkg.in/yaml.v2 v2.4.0
)

require (
Expand All @@ -31,7 +30,6 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
github.com/leaanthony/go-webview2 v1.0.2 // indirect
Expand All @@ -42,7 +40,6 @@ require (
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tcnksm/go-gitconfig v0.1.2 // indirect
Expand All @@ -57,7 +54,6 @@ require (
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
nhooyr.io/websocket v1.8.6 // indirect
salsa.debian.org/vasudev/gospake2 v0.0.0-20180813171123-adcc69dd31d5 // indirect
)
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leaanthony/clir v1.0.4/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
Expand Down Expand Up @@ -280,7 +278,6 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc=
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -306,8 +303,6 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f h1:PgA+Olipyj258EIEYnpFFONrrCcAIWNUNoFhUfMqAGY=
Expand Down Expand Up @@ -550,7 +545,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down
9 changes: 4 additions & 5 deletions internal/settings/user_settings.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package settings

import (
"encoding/json"
"errors"
"log"
"os"
"path/filepath"
"riftshare/internal/transport"
"riftshare/internal/update"
"runtime"

"gopkg.in/yaml.v2"
)

type UserSettings struct {
Expand All @@ -33,7 +32,7 @@ func SaveUserSettings(settings UserSettings) error {
return errors.New("error opening settings file")
}
defer prefs.Close()
encoder := yaml.NewEncoder(prefs)
encoder := json.NewEncoder(prefs)
err = encoder.Encode(settings)
if err != nil {
log.Println(err)
Expand All @@ -51,7 +50,7 @@ func GetUserSettings() (UserSettings, error) {
defer prefs.Close()

var settings UserSettings
decoder := yaml.NewDecoder(prefs)
decoder := json.NewDecoder(prefs)
err = decoder.Decode(&settings)
if err != nil {
log.Println(err)
Expand Down Expand Up @@ -98,7 +97,7 @@ func openPrefFile() (*os.File, error) {
return &os.File{}, err
}
}
settingsPath := filepath.Join(dir, "riftshare_config.yaml")
settingsPath := filepath.Join(dir, "riftshare_config.json")
prefs, err := os.OpenFile(settingsPath, os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
log.Println(err)
Expand Down

0 comments on commit 88189fb

Please sign in to comment.