mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
réarganisation du back en services, mise de depot downloader dans les assets
This commit is contained in:
@@ -1,121 +0,0 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"DepotDownloader/2.4.6": {
|
||||
"dependencies": {
|
||||
"SteamKit2": "2.4.1",
|
||||
"protobuf-net": "3.0.101"
|
||||
},
|
||||
"runtime": {
|
||||
"DepotDownloader.dll": {}
|
||||
}
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {},
|
||||
"Microsoft.Win32.Registry/5.0.0": {
|
||||
"dependencies": {
|
||||
"System.Security.AccessControl": "5.0.0",
|
||||
"System.Security.Principal.Windows": "5.0.0"
|
||||
}
|
||||
},
|
||||
"protobuf-net/3.0.101": {
|
||||
"dependencies": {
|
||||
"protobuf-net.Core": "3.0.101"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net5.0/protobuf-net.dll": {
|
||||
"assemblyVersion": "3.0.0.0",
|
||||
"fileVersion": "3.0.101.59408"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobuf-net.Core/3.0.101": {
|
||||
"runtime": {
|
||||
"lib/net5.0/protobuf-net.Core.dll": {
|
||||
"assemblyVersion": "3.0.0.0",
|
||||
"fileVersion": "3.0.101.59408"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SteamKit2/2.4.1": {
|
||||
"dependencies": {
|
||||
"Microsoft.Win32.Registry": "5.0.0",
|
||||
"protobuf-net": "3.0.101"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/SteamKit2.dll": {
|
||||
"assemblyVersion": "2.4.1.0",
|
||||
"fileVersion": "2.4.1.10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.Security.AccessControl/5.0.0": {
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Platforms": "5.0.0",
|
||||
"System.Security.Principal.Windows": "5.0.0"
|
||||
}
|
||||
},
|
||||
"System.Security.Principal.Windows/5.0.0": {}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"DepotDownloader/2.4.6": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Microsoft.NETCore.Platforms/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
|
||||
"path": "microsoft.netcore.platforms/5.0.0",
|
||||
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.Win32.Registry/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
|
||||
"path": "microsoft.win32.registry/5.0.0",
|
||||
"hashPath": "microsoft.win32.registry.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"protobuf-net/3.0.101": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-mLm8VGfGylp9q+rbJDp3uw0BOeNzfGENecVz/EYGlzq3ss7tfajGXHCMoZm/GxJ9vSn9pcK22UXWZnQ5GJQMjA==",
|
||||
"path": "protobuf-net/3.0.101",
|
||||
"hashPath": "protobuf-net.3.0.101.nupkg.sha512"
|
||||
},
|
||||
"protobuf-net.Core/3.0.101": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-gf9QIF0RlctfjmOjbE6eOyMulkNEsH7tHncjKj/4BTu9tkuTyrH3fv5I+35GnolJqKJ6fh9kYaezvNRL3t75+Q==",
|
||||
"path": "protobuf-net.core/3.0.101",
|
||||
"hashPath": "protobuf-net.core.3.0.101.nupkg.sha512"
|
||||
},
|
||||
"SteamKit2/2.4.1": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-t9yptysn/2YY6KZaI123vOOnumS+ZCFcC6MhFEkTiQ04mdpZ/EWhk5RVY7jU36IQHyTQUXotmn7taKFCXMKp4g==",
|
||||
"path": "steamkit2/2.4.1",
|
||||
"hashPath": "steamkit2.2.4.1.nupkg.sha512"
|
||||
},
|
||||
"System.Security.AccessControl/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-dagJ1mHZO3Ani8GH0PHpPEe/oYO+rVdbQjvjJkBRNQkX4t0r1iaeGn8+/ybkSLEan3/slM0t59SVdHzuHf2jmw==",
|
||||
"path": "system.security.accesscontrol/5.0.0",
|
||||
"hashPath": "system.security.accesscontrol.5.0.0.nupkg.sha512"
|
||||
},
|
||||
"System.Security.Principal.Windows/5.0.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==",
|
||||
"path": "system.security.principal.windows/5.0.0",
|
||||
"hashPath": "system.security.principal.windows.5.0.0.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"rollForward": "LatestMajor",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
export const BS_EXECUTABLE = "Beat Saber.exe";
|
||||
export const BS_APP_ID = "620980";
|
||||
export const BS_DEPOT = "620981";
|
||||
@@ -12,7 +12,7 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import path from 'path';
|
||||
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
|
||||
import { createFolderIfNotExist } from '../utils';
|
||||
import { UtilsService } from '../services/utils.service';
|
||||
|
||||
|
||||
export interface InitDownloadInfoInterface {
|
||||
@@ -26,14 +26,15 @@ export interface InitDownloadInfoInterface {
|
||||
}
|
||||
|
||||
const DEPOT_DOWNLOADER_EXE = 'DepotDownloader.exe';
|
||||
const DEPOT_DOWNLOADER_PATH = path.join(path.dirname(__dirname), '..', 'extraResources', 'depot-downloader', DEPOT_DOWNLOADER_EXE);
|
||||
|
||||
let PROCESS: ChildProcessWithoutNullStreams;
|
||||
|
||||
ipcMain.on('bs-download.start', async (event, args: InitDownloadInfoInterface) => {
|
||||
const DEPOT_DOWNLOADER_PATH = path.join(UtilsService.getInstance().getAssetsPath(), 'depot-downloader', DEPOT_DOWNLOADER_EXE);
|
||||
console.log(UtilsService.getInstance().getAssetsPath());
|
||||
console.log(DEPOT_DOWNLOADER_PATH);
|
||||
console.log(args.cwd);
|
||||
createFolderIfNotExist(args.cwd);
|
||||
UtilsService.getInstance().createFolderIfNotExist(args.cwd);
|
||||
PROCESS = spawn(DEPOT_DOWNLOADER_PATH, [`-app ${args.app}`, `-depot ${args.depot}`, `-manifest ${args.manifest}`, `-username ${args.username}`, `-dir ${args.folder}`, args.stay ? `-remember-password` : ''], {shell: true, cwd: args.cwd});
|
||||
|
||||
PROCESS.stdout.on('data', data => {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import path from "path";
|
||||
import { spawn } from 'child_process';
|
||||
import { UtilsService } from '../services/utils.service'
|
||||
import { SteamService } from '../services/steam.service';
|
||||
import { BSVersionManagerService } from '../services/bs-version-manager.service';
|
||||
import { BSInstallerService } from '../services/bs-installer.service'
|
||||
import { BS_EXECUTABLE, BS_APP_ID } from '../constants';
|
||||
|
||||
ipcMain.on('test-launch', async () => {
|
||||
console.log("steam "+ UtilsService.getInstance().taskRunning('steam.exe'));
|
||||
console.log(await SteamService.getInstance().getSteamGameFolder());
|
||||
console.log(BSInstallerService.getInstance().getBSInstallationFolder());
|
||||
console.log((await BSVersionManagerService.getInstance().loadBsVersions()));
|
||||
return;
|
||||
|
||||
const BS_EXE = "Beat Saber.exe"
|
||||
const BS_PATH = path.join('C:', 'Users', 'Mathieu', 'Desktop', 'BSLegacyLauncher', 'Beat Saber')
|
||||
let a = spawn(`\"${path.join(BS_PATH, BS_EXE)}\"`, ["-vrmode oculus", "--verbose"], { shell: true, cwd: BS_PATH, env: {...process.env ,"SteamAppId": "620980"}});
|
||||
a.stdout.on('data', data => console.log(data.toString()));
|
||||
a.stderr.on('data', data => console.log(data.toString()));
|
||||
a.on('message', m => console.log(m));
|
||||
a.on('error', err => console.log(err));
|
||||
a.on('exit', e => console.log(e));
|
||||
a.on('disconnect', (d: any) => console.log(d))
|
||||
console.log('oui');
|
||||
});
|
||||
|
||||
ipcMain.on('bs-launch.steam', async (event, args) => {
|
||||
const steamService = SteamService.getInstance();
|
||||
if(!steamService.isGameInstalled(BS_APP_ID)){ event.reply('bs-launch.not-installed'); }
|
||||
const beatSaberSteamFolder = path.join(await steamService.getSteamPath(), "Beat Saber");
|
||||
const beatSaberSteamExe = path.join(beatSaberSteamFolder, BS_EXECUTABLE);
|
||||
const spawnProcess = spawn(`\"${beatSaberSteamExe}\"`, [], {shell: true, cwd: beatSaberSteamFolder, env: {...process.env, "SteamAppId": "620980"}});
|
||||
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { BSVersionManagerService } from '../services/bs-version-manager.service'
|
||||
|
||||
ipcMain.on('bs-version.request', async (event, args) => {
|
||||
|
||||
|
||||
|
||||
});
|
||||
@@ -1,2 +1,3 @@
|
||||
import './bs-download-ipcs';
|
||||
import './window-controls-ipcs';
|
||||
import './bs-launcher-ipcs';
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { ipcMain } from 'electron';
|
||||
import { getMainWindow } from '../main';
|
||||
|
||||
ipcMain.on('window.close', () => {
|
||||
ipcMain.on('window.close', async () => {
|
||||
getMainWindow()?.close();
|
||||
});
|
||||
|
||||
ipcMain.on('window.maximize', () => {
|
||||
ipcMain.on('window.maximize', async () => {
|
||||
getMainWindow()?.maximize();
|
||||
});
|
||||
|
||||
ipcMain.on('window.minimize', () => {
|
||||
ipcMain.on('window.minimize', async () => {
|
||||
getMainWindow()?.minimize();
|
||||
});
|
||||
|
||||
ipcMain.on('window.reset', () => {
|
||||
ipcMain.on('window.reset', async () => {
|
||||
console.log('aaaaaa');
|
||||
getMainWindow()?.restore();
|
||||
});
|
||||
|
||||
+4
-3
@@ -15,6 +15,7 @@ import log from 'electron-log';
|
||||
import MenuBuilder from './menu';
|
||||
import { resolveHtmlPath } from './util';
|
||||
import './ipcs/custom-ipcs';
|
||||
import { UtilsService } from './services/utils.service';
|
||||
|
||||
export default class AppUpdater {
|
||||
constructor() {
|
||||
@@ -66,9 +67,9 @@ const createWindow = async () => {
|
||||
await installExtensions();
|
||||
}
|
||||
|
||||
const RESOURCES_PATH = app.isPackaged
|
||||
? path.join(process.resourcesPath, 'assets')
|
||||
: path.join(__dirname, '../../assets');
|
||||
const RESOURCES_PATH = app.isPackaged ? path.join(process.resourcesPath, 'assets') : path.join(__dirname, '../../assets');
|
||||
|
||||
UtilsService.getInstance().setAssetsPath(RESOURCES_PATH);
|
||||
|
||||
const getAssetPath = (...paths: string[]): string => {
|
||||
return path.join(RESOURCES_PATH, ...paths);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import path from "path";
|
||||
import { BSVersionManagerService } from "./bs-version-manager.service";
|
||||
import { UtilsService } from "./utils.service";
|
||||
|
||||
export class BSInstallerService{
|
||||
|
||||
private static readonly INSTALLATION_FOLDER = "BSManager";
|
||||
|
||||
private static instance: BSInstallerService;
|
||||
|
||||
private readonly utils: UtilsService = UtilsService.getInstance();
|
||||
|
||||
private installationFolder: string;
|
||||
|
||||
private constructor(){
|
||||
this.installationFolder = path.join(this.utils.getUserDocumentsFolder(), BSInstallerService.INSTALLATION_FOLDER)
|
||||
}
|
||||
|
||||
public static getInstance(){
|
||||
if(!BSInstallerService.instance){ BSInstallerService.instance = new BSInstallerService(); }
|
||||
return BSInstallerService.instance;
|
||||
}
|
||||
|
||||
public getBSInstallationFolder(): string{ return this.installationFolder; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { get } from 'https'
|
||||
|
||||
export class BSVersionManagerService{
|
||||
|
||||
private static readonly REMOTE_BS_VERSIONS_URL: string = "https://raw.githubusercontent.com/Zagrios/bs-manager/master/dynamic-resources/bs-versions.json"
|
||||
|
||||
private static instance: BSVersionManagerService;
|
||||
|
||||
private bsVersions: BSVersion[] = [];
|
||||
|
||||
private constructor(){}
|
||||
|
||||
public static getInstance(): BSVersionManagerService{
|
||||
if(!BSVersionManagerService.instance){ BSVersionManagerService.instance = new BSVersionManagerService() }
|
||||
return BSVersionManagerService.instance;
|
||||
}
|
||||
|
||||
public loadBsVersions(): Promise<BSVersion[]>{
|
||||
return new Promise<BSVersion[]>((resolve, reject) => {
|
||||
let body = ''
|
||||
get(BSVersionManagerService.REMOTE_BS_VERSIONS_URL, (res) => {
|
||||
res.on('data', chunk => body += chunk);
|
||||
res.on('end', () => {
|
||||
this.bsVersions = JSON.parse(body);
|
||||
resolve(this.bsVersions);
|
||||
});
|
||||
res.on('error', (err) => reject(err))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
public getVersionDetailFromVersionNumber(version: string): BSVersion{
|
||||
return this.bsVersions.find(v => v.BSVersion === version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface BSVersion { BSVersion: string, BSManifest: string, ReleaseURL: string, year: string }
|
||||
@@ -0,0 +1,62 @@
|
||||
import { UtilsService } from "./utils.service";
|
||||
import regedit from 'regedit'
|
||||
import path from "path";
|
||||
import { parse } from "@node-steam/vdf";
|
||||
import { readFile } from "fs/promises";
|
||||
|
||||
export class SteamService{
|
||||
|
||||
private static instance: SteamService;
|
||||
|
||||
private readonly utils: UtilsService = UtilsService.getInstance();
|
||||
|
||||
private steamPath: string = '';
|
||||
|
||||
private constructor(){}
|
||||
|
||||
public static getInstance(){
|
||||
if(!SteamService.instance){ SteamService.instance = new SteamService(); }
|
||||
return SteamService.instance;
|
||||
}
|
||||
|
||||
public steamRunning(): boolean{
|
||||
return this.utils.taskRunning('steam.exe');
|
||||
}
|
||||
|
||||
public async getSteamPath(): Promise<string>{
|
||||
if(this.steamPath !== ''){ return this.steamPath; }
|
||||
const [win32Res, win64Res] = await Promise.all([
|
||||
regedit.promisified.list(['HKLM\\SOFTWARE\\Valve\\Steam']),
|
||||
regedit.promisified.list(['HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam'])
|
||||
]);
|
||||
const [win32, win64] = [win32Res["HKLM\\SOFTWARE\\Valve\\Steam"], win64Res["HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam"]];
|
||||
let res = ''
|
||||
if(win64.values.InstallPath.value){ res = win64.values.InstallPath.value as string; }
|
||||
else if(win32.values.InstallPath.value){ res = win32.values.InstallPath.value as string; }
|
||||
this.steamPath = res;
|
||||
return this.steamPath;
|
||||
}
|
||||
|
||||
public async getSteamGameFolder(): Promise<string>{
|
||||
const steamFolder = await this.getSteamPath();
|
||||
return path.join(steamFolder, 'common');
|
||||
}
|
||||
|
||||
public async isGameInstalled(gameId: string): Promise<boolean>{
|
||||
const steamPath = await this.getSteamPath();
|
||||
let libraryFolders: any = path.join(steamPath, 'steamapps', 'libraryfolders.vdf');
|
||||
|
||||
if(!this.utils.pathExist(libraryFolders)){ return false; }
|
||||
libraryFolders = parse(await readFile(libraryFolders, {encoding: 'utf-8'}));
|
||||
|
||||
if(!libraryFolders.libraryfolders){ return false; }
|
||||
libraryFolders = libraryFolders.libraryfolders
|
||||
|
||||
for(const libKey in Object.keys(libraryFolders)){
|
||||
if(!libraryFolders[libKey]["apps"]){ continue; }
|
||||
if(libraryFolders[libKey]["apps"][gameId]){ return true };
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import { spawnSync } from "child_process";
|
||||
import { homedir } from "os";
|
||||
import path from "path";
|
||||
|
||||
export class UtilsService{
|
||||
|
||||
private static instance: UtilsService;
|
||||
|
||||
private assetsPath: string = '';
|
||||
|
||||
private constructor(){}
|
||||
|
||||
public static getInstance(){
|
||||
if(!this.instance){ UtilsService.instance = new UtilsService(); }
|
||||
return UtilsService.instance;
|
||||
}
|
||||
|
||||
public setAssetsPath(path: string): void{ this.assetsPath = path; }
|
||||
public getAssetsPath(): string{ return this.assetsPath; }
|
||||
|
||||
//à supprimer
|
||||
public folderExist(path: string): boolean{ return existsSync(path); }
|
||||
|
||||
public pathExist(path: string): boolean{ return existsSync(path); }
|
||||
|
||||
public createFolderIfNotExist(path: string): void{
|
||||
if(!this.folderExist(path)){ mkdirSync(path); }
|
||||
}
|
||||
|
||||
public taskRunning(task: string): boolean{
|
||||
const tasks = spawnSync('tasklist').stdout.toString();
|
||||
return tasks.includes(task);
|
||||
}
|
||||
|
||||
public getUserFolder(){ return homedir(); }
|
||||
|
||||
public getUserDocumentsFolder(): string{
|
||||
return path.join(this.getUserFolder(), 'Documents');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export function createFolderIfNotExist(path: string){
|
||||
const [existsSync, mkdirSync] = [require('fs').existsSync, require('fs').mkdirSync];
|
||||
if (!existsSync(path)){ mkdirSync(path); }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { InitDownloadInfoInterface } from 'main/ipcs/bs-download-ipcs';
|
||||
import { InitDownloadInfoInterface } from '../main/ipcs/bs-download-ipcs';
|
||||
import App from './App';
|
||||
import 'tailwindcss/tailwind.css';
|
||||
import './index.css'
|
||||
@@ -8,8 +8,14 @@ const container = document.getElementById('root')!;
|
||||
const root = createRoot(container);
|
||||
root.render(<App />);
|
||||
|
||||
// setTimeout(() => {
|
||||
// window.electron.ipcRenderer.sendMessage('bs-download.start', {app: '620980', depot: '620981', manifest: '6222769774084748916', stay: true, username: 'lekilleur618', folder: 'test2', cwd: 'C:\\test'} as InitDownloadInfoInterface);
|
||||
// }, 5000);
|
||||
|
||||
// window.electron.ipcRenderer.on('bs-download.ask-password', () => console.log('omg popup password'));
|
||||
|
||||
setTimeout(() => {
|
||||
window.electron.ipcRenderer.sendMessage('bs-download.start', {app: '620980', depot: '620981', manifest: '6222769774084748916', stay: true, username: 'lekilleur618', folder: 'test2', cwd: 'C:\\test'} as InitDownloadInfoInterface);
|
||||
window.electron.ipcRenderer.sendMessage('test-launch', null);
|
||||
}, 5000);
|
||||
|
||||
window.electron.ipcRenderer.on('bs-download.ask-password', () => console.log('omg popup password'));
|
||||
|
||||
Reference in New Issue
Block a user