Skip to content

Commit b44e38e

Browse files
committed
versioning changes
1 parent df1db29 commit b44e38e

11 files changed

Lines changed: 117 additions & 18 deletions

File tree

app.go

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type versionResponse struct {
4343
Linux string `json:"linux"`
4444
Macos string `json:"macos"`
4545
}
46+
Sizes struct {
47+
Windows int64 `json:"windows"`
48+
Linux int64 `json:"linux"`
49+
Macos int64 `json:"macos"`
50+
}
4651
}
4752

4853
type launcherConfig struct {
@@ -70,6 +75,7 @@ func (a *App) domReady(ctx context.Context) {
7075

7176
func (a *App) shutdown(ctx context.Context) {
7277
cmd.Process.Kill()
78+
os.Exit(1)
7379
}
7480

7581
func hasArg(str string) bool {
@@ -141,10 +147,9 @@ func PrintDownloadPercent(done chan int64, path string, total int64, ctx context
141147
}
142148

143149
var percent float64 = float64(size) / float64(total) * 100
144-
runtime.EventsEmit(ctx, "launch_lilith", fmt.Sprintf("\r%.0f", percent)+"% Downloaded")
145-
runtime.EventsEmit(ctx, "lilith_log", fmt.Sprintf("\r[Launcher] %.0f", percent)+"% Downloaded")
146-
log.Printf("\r%.0f", percent)
147-
print("% Downloaded")
150+
runtime.EventsEmit(ctx, "launch_lilith", fmt.Sprintf("%.0f%% Downloaded", percent))
151+
runtime.EventsEmit(ctx, "lilith_log", fmt.Sprintf("[Launcher] %.0f%% Downloaded", percent))
152+
runtime.LogInfo(ctx, fmt.Sprintf("\r%.0f", percent))
148153
}
149154

150155
if stop {
@@ -181,6 +186,10 @@ func (a *App) HandleErrorFrontend(err string) {
181186
})
182187
}
183188

189+
func (a *App) GetVersion() string {
190+
return update.Version
191+
}
192+
184193
func (a *App) HTTPGetRequest(url string) (string, error) {
185194
resp, err := http.Get(url)
186195
if err != nil {
@@ -291,6 +300,18 @@ func (a *App) LaunchLilith() (string, error) {
291300
default:
292301
download = f.Download.Linux
293302
}
303+
304+
var size int64
305+
switch goruntime.GOOS {
306+
case "windows":
307+
size = f.Sizes.Windows
308+
case "darwin":
309+
size = f.Sizes.Macos
310+
case "linux":
311+
size = f.Sizes.Linux
312+
default:
313+
size = f.Sizes.Linux
314+
}
294315

295316
filename := download[strings.LastIndex(download, "/")+1:]
296317
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
@@ -314,8 +335,24 @@ func (a *App) LaunchLilith() (string, error) {
314335
runtime.EventsEmit(a.ctx, "launch_lilith", "Launching lilith "+f.Version)
315336
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
316337
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Lilith has started")
317-
runtime.LogInfo(a.ctx, "\r100% Downloaded")
338+
runtime.LogInfo(a.ctx, "\rDownload Complete")
318339
path = bindir + "/" + filename
340+
} else {
341+
fi, _ := os.Stat(path)
342+
if (fi.Size() != size) {
343+
err := os.Remove(path)
344+
a.HandleError(err)
345+
runtime.LogInfo(a.ctx, "Couldn't find the latest Lilith version, downloading...")
346+
runtime.EventsEmit(a.ctx, "launch_lilith", "Downloading lilith "+f.Version)
347+
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Downloading lilith "+f.Version)
348+
err = DownloadFile(bindir+"/"+filename, download, a.ctx)
349+
a.HandleError(err)
350+
runtime.EventsEmit(a.ctx, "launch_lilith", "Launching lilith "+f.Version)
351+
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
352+
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Lilith has started")
353+
runtime.LogInfo(a.ctx, "\rDownload Complete")
354+
path = bindir + "/" + filename
355+
}
319356
}
320357

321358
if goruntime.GOOS != "windows" {

app_windows.go

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ type versionResponse struct {
4343
Linux string `json:"linux"`
4444
Macos string `json:"macos"`
4545
}
46+
Sizes struct {
47+
Windows int64 `json:"windows"`
48+
Linux int64 `json:"linux"`
49+
Macos int64 `json:"macos"`
50+
}
4651
}
4752

4853
type launcherConfig struct {
@@ -70,6 +75,7 @@ func (a *App) domReady(ctx context.Context) {
7075

7176
func (a *App) shutdown(ctx context.Context) {
7277
cmd.Process.Kill()
78+
os.Exit(1)
7379
}
7480

7581
func hasArg(str string) bool {
@@ -141,10 +147,9 @@ func PrintDownloadPercent(done chan int64, path string, total int64, ctx context
141147
}
142148

143149
var percent float64 = float64(size) / float64(total) * 100
144-
runtime.EventsEmit(ctx, "launch_lilith", fmt.Sprintf("\r%.0f", percent)+"% Downloaded")
145-
runtime.EventsEmit(ctx, "lilith_log", fmt.Sprintf("\r[Launcher] %.0f", percent)+"% Downloaded")
146-
log.Printf("\r%.0f", percent)
147-
print("% Downloaded")
150+
runtime.EventsEmit(ctx, "launch_lilith", fmt.Sprintf("%.0f%% Downloaded", percent))
151+
runtime.EventsEmit(ctx, "lilith_log", fmt.Sprintf("[Launcher] %.0f%% Downloaded", percent))
152+
runtime.LogInfo(ctx, fmt.Sprintf("\r%.0f", percent))
148153
}
149154

150155
if stop {
@@ -181,6 +186,10 @@ func (a *App) HandleErrorFrontend(err string) {
181186
})
182187
}
183188

189+
func (a *App) GetVersion() string {
190+
return update.Version
191+
}
192+
184193
func (a *App) HTTPGetRequest(url string) (string, error) {
185194
resp, err := http.Get(url)
186195
if err != nil {
@@ -291,6 +300,18 @@ func (a *App) LaunchLilith() (string, error) {
291300
default:
292301
download = f.Download.Linux
293302
}
303+
304+
var size int64
305+
switch goruntime.GOOS {
306+
case "windows":
307+
size = f.Sizes.Windows
308+
case "darwin":
309+
size = f.Sizes.Macos
310+
case "linux":
311+
size = f.Sizes.Linux
312+
default:
313+
size = f.Sizes.Linux
314+
}
294315

295316
filename := download[strings.LastIndex(download, "/")+1:]
296317
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
@@ -314,8 +335,24 @@ func (a *App) LaunchLilith() (string, error) {
314335
runtime.EventsEmit(a.ctx, "launch_lilith", "Launching lilith "+f.Version)
315336
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
316337
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Lilith has started")
317-
runtime.LogInfo(a.ctx, "\r100% Downloaded")
338+
runtime.LogInfo(a.ctx, "\rDownload Complete")
318339
path = bindir + "/" + filename
340+
} else {
341+
fi, _ := os.Stat(path)
342+
if (fi.Size() != size) {
343+
err := os.Remove(path)
344+
a.HandleError(err)
345+
runtime.LogInfo(a.ctx, "Couldn't find the latest Lilith version, downloading...")
346+
runtime.EventsEmit(a.ctx, "launch_lilith", "Downloading lilith "+f.Version)
347+
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Downloading lilith "+f.Version)
348+
err = DownloadFile(bindir+"/"+filename, download, a.ctx)
349+
a.HandleError(err)
350+
runtime.EventsEmit(a.ctx, "launch_lilith", "Launching lilith "+f.Version)
351+
runtime.EventsEmit(a.ctx, "launch_lilith", "Lilith is now running")
352+
runtime.EventsEmit(a.ctx, "lilith_log", "[Launcher] Lilith has started")
353+
runtime.LogInfo(a.ctx, "\rDownload Complete")
354+
path = bindir + "/" + filename
355+
}
319356
}
320357

321358
if goruntime.GOOS != "windows" {

frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "lilith_launcher",
33
"private": true,
4-
"version": "0.0.2",
54
"homepage": ".",
65
"babelMacros": {
76
"twin": {

frontend/package.json.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14ddd71aaaec9a041ecad091144dd114
1+
9da9a91c9352d46229c89ee3bac39a6c

frontend/src/components/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ import { useStoreState } from 'easy-peasy';
77
import { SettingsRouter } from '@/routers';
88
import { Offline } from 'react-detect-offline';
99
import { store, ApplicationStore } from '@/state';
10-
import { ShowDialog, HandleErrorFrontend } from '@/wailsjs/go/main/App';
10+
import { ShowDialog, HandleErrorFrontend, GetVersion } from '@/wailsjs/go/main/App';
1111
import GlobalStyles from '@/assets/styles/GlobalStyles';
1212
import { BrowserOpenURL, EventsOn } from '@/wailsjs/runtime';
1313
import { Spinner, Appbar } from '@/components/elements/Generic';
1414
import { HashRouter, Routes, Route, Navigate } from 'react-router-dom';
1515
import { LauncherHome, LauncherPremium } from '@/components/pages/Launcher';
1616

1717
const App = () => {
18+
const [version, setVersion] = useState('0.0.0');
19+
20+
GetVersion().then((data: string) => {
21+
setVersion(data);
22+
});
23+
1824
useEffect(() => {
1925
EventsOn('launch_lilith', (messages) => {
2026
store.getActions().button.setButtonData(messages);
@@ -56,6 +62,7 @@ const App = () => {
5662
<HashRouter>
5763
<GlobalStyles />
5864
<Appbar />
65+
<div tw="absolute bottom-1 right-1 text-[9px] text-neutral-500 opacity-30 z-20">v{version}</div>
5966
<Routes>
6067
<Route path="/" element={<Navigate to="/launch" replace />} />
6168
<Route path="/launch" element={<Page component={LauncherHome} id="homepage-launcher" />} />

frontend/src/components/pages/Settings/Launcher.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ import { Link, useParams } from 'react-router-dom';
77
import { Dialog, Menu, Transition, Switch } from '@headlessui/react';
88
import { PageContentBlock, Spinner } from '@/components/elements/Generic';
99
import { useNavigate } from 'react-router-dom';
10-
import { SaveConfig } from '@/wailsjs/go/main/App';
10+
import { SaveConfig, GetVersion, ShowDialog } from '@/wailsjs/go/main/App';
11+
import { BrowserOpenURL } from '@/wailsjs/runtime';
1112

1213
const Base = (props: { id: string; config: any }) => {
1314
const AppSettings = useStoreState((state: ApplicationStore) => state.settings.data);
15+
const [version, setVersion] = useState('0.0.0');
1416
const navigate = useNavigate();
1517
const { config } = props;
1618

19+
GetVersion().then((data: string) => {
20+
setVersion(data);
21+
});
22+
1723
return (
1824
<PageContentBlock pageId={props.id}>
25+
<div
26+
onClick={() => ShowDialog(`Lilith Launcher v${version}`, `© 2022 Lilith Development`, ['Ok'], 'Ok', '', '')}
27+
tw="absolute bottom-3 right-3 text-sm text-neutral-500 hover:text-transparent hover:bg-clip-text hover:bg-gradient-to-br hover:from-purple-500 hover:to-pink-500 font-bold z-40 hover:cursor-pointer"
28+
>
29+
v{version}
30+
</div>
31+
<div tw="absolute bottom-1 right-1 text-[9px] bg-neutral-900 py-2 px-8 z-30" />
1932
<div tw="max-w-7xl mx-auto py-5 px-4 sm:px-6 md:px-8 w-full pt-16">
2033
<div tw="bg-neutral-800 shadow px-4 py-5 rounded-lg sm:p-6 mt-4 w-full">
2134
<div tw="md:grid md:grid-cols-4 md:gap-6">

frontend/src/wailsjs/go/main/App.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
22
// This file is automatically generated. DO NOT EDIT
33

4+
export function GetVersion():Promise<string>;
5+
46
export function HTTPGetRequest(arg1:string):Promise<string>;
57

68
export function HandleError(arg1:Error):void;

frontend/src/wailsjs/go/main/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
33
// This file is automatically generated. DO NOT EDIT
44

5+
export function GetVersion() {
6+
return window['go']['main']['App']['GetVersion']();
7+
}
8+
59
export function HTTPGetRequest(arg1) {
610
return window['go']['main']['App']['HTTPGetRequest'](arg1);
711
}

internal/update/selfupdate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/rhysd/go-github-selfupdate/selfupdate"
1414
)
1515

16-
const Version = "0.0.3"
16+
const Version = "0.0.4"
1717

1818
func DoSelfUpdate() bool {
1919
v := semver.MustParse(Version)

internal/update/selfupdate_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/rhysd/go-github-selfupdate/selfupdate"
1616
)
1717

18-
const Version = "0.0.3"
18+
const Version = "0.0.4"
1919

2020
func DoSelfUpdate() bool {
2121
v := semver.MustParse(Version)

0 commit comments

Comments
 (0)