Several changes

- added `Launcher.version` field that represents... current launcher version
- made `Git` class to work with git repositories;
  made `Git.getTags()` method to list remove repository tags
- added outdated launcher version notification
This commit is contained in:
Observer KRypt0n_ 2022-01-10 17:44:24 +02:00
parent d7162e85a4
commit 02984394ee
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
19 changed files with 130 additions and 28 deletions

View file

@ -1,6 +1,6 @@
{
"applicationId": "com.krypt0nn.an-anime-game-launcher",
"version": "2.0.0-beta-9",
"version": "2.0.0-rc1",
"defaultMode": "window",
"port": 0,
"documentRoot": "/bundle/",

View file

@ -1,6 +1,6 @@
{
"name": "an-anime-game-launcher",
"version": "2.0.0-beta-9",
"version": "2.0.0-rc1",
"license": "GPL-3.0",
"type": "module",
"scripts": {
@ -12,6 +12,7 @@
},
"dependencies": {
"js-md5": "^0.7.3",
"semver": "^7.3.5",
"svelte-i18n": "^3.3.13",
"yaml": "^1.10.2"
},
@ -23,7 +24,7 @@
"neutralino-appimage-bundler": "^1.3.1",
"sass": "^1.47.0",
"svelte": "^3.45.0",
"svelte-check": "^2.2.11",
"svelte-check": "^2.2.12",
"svelte-preprocess": "^4.10.1",
"tslib": "^2.3.1",
"typescript": "^4.5.4",

View file

@ -44,6 +44,11 @@ launcher:
launch: Starten
predownload: Update vorinstallieren
# Launcher update
update:
title: 'Launcher update available: {from} -> {to}'
body: You can download a new version of the launcher from the project's repository at {repository}
# Einstellungs Fenster
settings:
# General

View file

@ -44,6 +44,11 @@ launcher:
launch: Launch
predownload: Pre-download update
# Launcher update
update:
title: 'Launcher update available: {from} -> {to}'
body: You can download a new version of the launcher from the project's repository at {repository}
# Settings window
settings:
# General

View file

@ -45,6 +45,11 @@ launcher:
launch: Lancer
predownload: Pre-téléchargement de mise à jour
# Launcher update
update:
title: 'Launcher update available: {from} -> {to}'
body: You can download a new version of the launcher from the project's repository at {repository}
# Settings window
settings:
# General

View file

@ -43,7 +43,12 @@ launcher:
ready:
launch: Launch
predownload: Pre-download update
# Launcher update
update:
title: 'Launcher update available: {from} -> {to}'
body: You can download a new version of the launcher from the project's repository at {repository}
# Settings window
settings:
# General

View file

@ -44,6 +44,11 @@ launcher:
launch: Запустить
predownload: Предзагрузить обновление
# Обновление лаунчера
update:
title: 'Доступно обновление лаунчера: {from} -> {to}'
body: Вы можете загрузить новую версию лаунчера из репозитория проекта по ссылке {repository}
# Окно настроек
settings:
# Основное

View file

@ -44,6 +44,11 @@ launcher:
launch: launch (◕▿◕✿)
predownload: pwe-downwoad update
# Launcher update
update:
title: 'Launcher update available: {from} -> {to}'
body: You can download a new version of the launcher from the project's repository at {repository}
# Settings window
settings:
# General

View file

@ -39,7 +39,7 @@ const bundler = new Bundler({
output: path.join(__dirname, '../dist/An Anime Game Launcher.AppImage'),
// Application version
version: '2.0.0-beta-9'
version: '2.0.0-rc1'
});
// Bundle project

View file

@ -29,7 +29,7 @@
</script>
<div>
<table class="table" style="margin-top: 16px">
<table class="table properties-table" style="margin-top: 16px">
<tr>
<th>{$_('settings.environment.items.table.name')}</th>
<th>{$_('settings.environment.items.table.value')}</th>

View file

@ -1,6 +1,6 @@
import { register, init } from 'svelte-i18n';
import Locales from './ts/core/Locales';
import Locales from './ts/launcher/Locales';
register('en-us', () => Locales.get('en-us'));
register('ru-ru', () => Locales.get('ru-ru'));

View file

@ -7,6 +7,7 @@
import { _, locale } from 'svelte-i18n';
import Window from './ts/neutralino/Window';
import Process from './ts/neutralino/Process';
import Launcher from './ts/Launcher';
import constants from './ts/Constants';
@ -16,7 +17,6 @@
import Debug from './ts/core/Debug';
import Downloader from './ts/core/Downloader';
import IPC from './ts/core/IPC';
import Process from './ts/neutralino/Process';
import Configs from './ts/Configs';
import Gear from './assets/images/gear.png';

View file

@ -2,25 +2,24 @@
@mixin themable($theme-name, $theme-map)
body[data-theme=#{$theme-name}]
table.table
table.properties-table tr
td, th
width: auto
width: auto !important
td input
display: none !important
tr
td input
display: none
&.selected
td
background-color: map.get($theme-map, "background2")
span
display: none !important
input
display: block !important
&.selected
td
background-color: map.get($theme-map, "background2")
span
display: none
input
display: block
background-color: map.get($theme-map, "background2")
@import "../themes/light"
@import "../themes/dark"

View file

@ -9,12 +9,14 @@ import Configs from './Configs';
import Debug from './core/Debug';
import IPC from './core/IPC';
import DiscordRPC from './core/DiscordRPC';
import Locales from './core/Locales';
import Locales from './launcher/Locales';
import ProgressBar from './launcher/ProgressBar';
import State from './launcher/State';
import Background from './launcher/Background';
import { version } from '../../package.json';
export default class Launcher
{
public state?: State;
@ -22,6 +24,8 @@ export default class Launcher
public rpc?: DiscordRPC;
public tray: Tray;
public static readonly version: string = version;
protected settingsMenu?: Process;
public constructor(onMount)

42
src/ts/core/Git.ts Normal file
View file

@ -0,0 +1,42 @@
import Process from '../neutralino/Process';
type Tag = {
tag: string,
commit: string
};
declare const Neutralino;
export default class Git
{
/**
* Get list of git repository tags
*
* @param repository URI of the repository
*/
public static getTags(repository: string): Promise<Tag[]>
{
return new Promise(async (resolve) => {
const output = await Neutralino.os.execCommand(`git ls-remote --tags "${Process.addSlashes(repository)}"`);
let tags: Tag[] = [];
output.stdOut.split(/\r\n|\r|\n/).forEach((line: string) => {
if (line != '')
{
const matches = /^([0-9a-f]+)\trefs\/tags\/(.*)/.exec (line);
if (matches)
{
tags.push({
tag: matches[2],
commit: matches[1]
});
}
}
});
resolve(tags);
});
}
};

View file

@ -1,6 +1,6 @@
import constants from '../Constants';
import fetch from '../core/Fetch';
import Locales from '../core/Locales';
import Locales from './Locales';
export default class Background
{

View file

@ -3,7 +3,7 @@ import { dictionary, locale } from 'svelte-i18n';
import YAML from 'yaml';
import constants from '../Constants';
import promisify from './promisify';
import promisify from '../core/promisify';
import Configs from '../Configs';
type AvailableLocales =

View file

@ -1,11 +1,13 @@
import { get as svelteget } from 'svelte/store';
import { dictionary, locale } from 'svelte-i18n';
import type Launcher from '../Launcher';
import semver from 'semver';
import type { LauncherState } from '../types/Launcher';
import Window from '../neutralino/Window';
import Launcher from '../Launcher';
import Game from '../Game';
import Patch from '../Patch';
import Voice from '../Voice';
@ -13,7 +15,10 @@ import Runners from '../core/Runners';
import Debug, { DebugThread } from '../core/Debug';
import DXVK from '../core/DXVK';
import IPC from '../core/IPC';
import Locales from '../core/Locales';
import Locales from './Locales';
import Git from '../core/Git';
import constants from '../Constants';
import Notifications from '../core/Notifications';
export default class State
{
@ -93,6 +98,26 @@ export default class State
await Window.current.show();
await Window.current.center(1280, 700);
// Check for new versions of the launcher
Git.getTags(constants.uri.launcher).then((tags) => {
for (const tag of tags.reverse())
if (semver.gt(tag.tag, Launcher.version))
{
const currentDictionary = svelteget(dictionary);
const currentLocale = svelteget(locale);
const locales = (currentDictionary[currentLocale ?? 'en-us'] ?? currentDictionary['en-us'])['launcher']!['update'] as object;
Notifications.show({
title: locales['title'].replace('{from}', Launcher.version).replace('{to}', tag.tag),
body: locales['body'].replace('{repository}', constants.uri.launcher),
icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`
});
break;
}
});
// This thing will fix window resizing
// in several cases (wayland + gnome + custom theme)
const resizer = () => {

View file

@ -7,6 +7,7 @@
"strict": true,
"noImplicitAny": false,
"removeComments": true,
"resolveJsonModule": true,
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable checkJs if you'd like to use dynamic types in JS.