[chore] fix lint errors

This commit is contained in:
MathieuG-P
2023-07-01 03:01:38 +02:00
parent 7addb57613
commit d62727c3f9
55 changed files with 176 additions and 181 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ import { VersionFolderLinkerService } from '../services/version-folder-linker.se
const ipc = IpcService.getInstance();
ipcMain.on('bs-version.get-version-dict', (event, req: IpcRequest<void>) => {
ipcMain.on('bs-version.get-version-dict', (_event, req: IpcRequest<void>) => {
BSVersionLibService.getInstance().getAvailableVersions().then(versions => {
UtilsService.getInstance().ipcSend(req.responceChannel, {success: true, data: versions});
}).catch(() => {
@@ -27,7 +27,7 @@ ipcMain.on('bs-version.get-version-dict', (event, req: IpcRequest<void>) => {
})
});
ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest<void>) => {
ipcMain.on('bs-version.installed-versions', async (_event, req: IpcRequest<void>) => {
BSLocalVersionService.getInstance().getInstalledVersions().then(versions => {
UtilsService.getInstance().ipcSend(req.responceChannel, {success: true, data: versions});
}).catch(() => {
@@ -35,7 +35,7 @@ ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest<void>)
})
});
ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest<BSVersion>) => {
ipcMain.on("bs-version.open-folder", async (_event, req: IpcRequest<BSVersion>) => {
const localVersionService = BSLocalVersionService.getInstance();
const versionFolder = await localVersionService.getVersionPath(req.args);
if (!(await pathExist(versionFolder)))
@@ -43,7 +43,7 @@ ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest<BSVersion>) =
shell.openPath(versionFolder);
});
ipcMain.on("bs-version.edit", async (event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => {
ipcMain.on("bs-version.edit", async (__event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => {
BSLocalVersionService.getInstance().editVersion(req.args.version, req.args.name, req.args.color).then(res => {
UtilsService.getInstance().ipcSend(req.responceChannel, {success: !!res, data: res});
}).catch((error: BsmException) => {
@@ -51,7 +51,7 @@ ipcMain.on("bs-version.edit", async (event, req: IpcRequest<{version: BSVersion,
});
});
ipcMain.on("bs-version.clone", async (event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => {
ipcMain.on("bs-version.clone", async (_event, req: IpcRequest<{version: BSVersion, name: string, color: string}>) => {
BSLocalVersionService.getInstance().cloneVersion(req.args.version, req.args.name, req.args.color).then(res => {
UtilsService.getInstance().ipcSend(req.responceChannel, {success: !!res, data: res});
}).catch((error: BsmException) => {
@@ -113,7 +113,7 @@ ipc.on("link-folder", async (req: IpcRequest<{ folder: string, options?: LinkOpt
try{
const ipaData = (await readJSON(jsonIPAPath)) ?? {} as any;
ipaData["YeetMods"] = false;
ipaData.YeetMods = false;
await writeJSON(jsonIPAPath, ipaData, {spaces: 4});
}catch(e){
log.error("Disable YeetMods", e);
+1 -3
View File
@@ -2,9 +2,7 @@ import archiver from "archiver";
import { createWriteStream } from "fs";
import { Observable } from "rxjs";
import recursive from "recursive-readdir";
import { lstatSync } from "fs";
import * as _path from "path";
import { ArchiveProgress } from "shared/models/archive.interface";
import { Progression } from "main/helpers/fs.helpers";
export class Archive{
@@ -45,7 +43,7 @@ export class Archive{
public addFile(path: string, destPath?: string): void{
this.files.push(path);
destPath = destPath ||= _path.basename(path);
destPath ||= _path.basename(path);
this.archive.file(path, {name: destPath});
}
@@ -14,13 +14,12 @@ import sanitize from "sanitize-filename";
import { Progression, ensureFolderExist, unlinkPath } from "../../helpers/fs.helpers";
import { MODEL_FILE_EXTENSIONS, MODEL_TYPES, MODEL_TYPE_FOLDERS } from "../../../shared/models/models/constants";
import { InstallationLocationService } from "../installation-location.service";
import { Observable, Subscription, lastValueFrom, map } from "rxjs";
import { Observable, Subscription, lastValueFrom } from "rxjs";
import { readdir } from "fs/promises";
import md5File from "md5-file";
import { allSettled } from "../../../shared/helpers/promise.helpers";
import { ModelSaberService } from "../thrid-party/model-saber/model-saber.service";
import { BsmLocalModel } from "shared/models/models/bsm-local-model.interface";
import { ArchiveProgress } from "shared/models/archive.interface";
import { Archive } from "../../models/archive.class";
export class LocalModelsManagerService {
@@ -66,7 +65,7 @@ export class LocalModelsManagerService {
private openOneClickDownloadModelWindow(id: string, type: string){
ipcMain.once("one-click-model-info", async (event, req: IpcRequest<void>) => {
ipcMain.once("one-click-model-info", async (_event, req: IpcRequest<void>) => {
this.utils.ipcSend(req.responceChannel, {success: true, data: {id, type}});
});
@@ -76,7 +75,7 @@ export class LocalModelsManagerService {
private async getModelFolderPath(type: MSModelType, version?: BSVersion): Promise<string>{
const rootPath = !!version ? await this.localVersion.getVersionPath(version) : this.installPaths.sharedContentPath;
const rootPath = version ? await this.localVersion.getVersionPath(version) : this.installPaths.sharedContentPath;
const modelFolderPath = path.join(rootPath, MODEL_TYPE_FOLDERS[type]);
await ensureFolderExist(modelFolderPath);
@@ -95,7 +94,7 @@ export class LocalModelsManagerService {
const modelFolder = await this.getModelFolderPath(model.type, version);
const modelDest = path.join(modelFolder, sanitize(path.basename(model.download)));
let url = model.download.split("/");
const url = model.download.split("/");
url[url.length - 1] = encodeURIComponent(url[url.length - 1]);
const download$ = this.request.downloadFile(url.join("/"), modelDest);
@@ -149,7 +148,6 @@ export class LocalModelsManagerService {
const modelsPath = await this.getModelFolderPath(type, version);
const files = await readdir(modelsPath, {withFileTypes: true});
//return files.filter(file => file.isFile() && path.extname(file.name) === MODEL_FILE_EXTENSIONS[type]).map(file => path.join(modelsPath, file.name));
return files.reduce((acc, file) => {
if(!file.isFile() || path.extname(file.name) !== MODEL_FILE_EXTENSIONS[type]){ return acc; }
acc.push(path.join(modelsPath, file.name));
@@ -2,6 +2,7 @@ import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import { UtilsService } from './utils.service';
import { gt } from 'semver';
export class AutoUpdaterService {
private static instance: AutoUpdaterService;
+3 -3
View File
@@ -45,14 +45,14 @@ export class BSLauncherService{
private async backupSteamVR(): Promise<void>{
const steamVrFolder = await this.getSteamVRPath();
if(!await pathExist(steamVrFolder)){ return; }
return rename(steamVrFolder, steamVrFolder + ".bak").catch(log.error);
return rename(steamVrFolder, `${steamVrFolder}.bak`).catch(log.error);
}
public async restoreSteamVR(): Promise<void>{
const steamVrFolder = await this.getSteamVRPath();
const steamVrBackup = steamVrFolder + ".bak";
const steamVrBackup = `${steamVrFolder}.bak`;
if(!await pathExist(steamVrBackup)){ return; }
return rename(steamVrFolder + ".bak", steamVrFolder).catch(log.error);
return rename(steamVrBackup, steamVrFolder).catch(log.error);
}
public async isBsRunning(): Promise<boolean> {
+2 -2
View File
@@ -31,7 +31,7 @@ export class FolderLinkerService {
}
private getBackupFolder(folderPath: string): string {
return folderPath + "_backup";
return `${folderPath}_backup`;
}
private async backupFolder(folderPath: string): Promise<void> {
@@ -101,7 +101,7 @@ export class FolderLinkerService {
public async isFolderSymlink(folder: string): Promise<boolean> {
try{
if(!(await pathExist(folder))){ return false; }
return lstat(folder).then(stat => stat.isSymbolicLink());
return await lstat(folder).then(stat => stat.isSymbolicLink());
}
catch(e){
log.error(e);
@@ -72,7 +72,7 @@ export class BeatModsApiService {
}
public async getAllMods(): Promise<Mod[]>{
if(!!this.allModsCache){ return this.allModsCache; }
if(this.allModsCache){ return this.allModsCache; }
return this.requestService.getJSON<Mod[]>(this.getAllModsUrl()).then(mods => {
this.allModsCache = mods;
return this.allModsCache;
@@ -5,17 +5,14 @@ import { BSLocalVersionService } from "../bs-local-version.service"
import path from "path";
import { UtilsService } from "../utils.service";
import md5File from "md5-file";
import fs from "fs"
import { RequestService } from "../request.service";
import { spawn } from "child_process";
import { BS_EXECUTABLE } from "../../constants";
import log from "electron-log";
import { deleteFolder, pathExist, unlinkPath } from "../../helpers/fs.helpers";
import { deleteFolder, pathExist, unlinkPath, ensureFolderExist } from "../../helpers/fs.helpers";
import { lastValueFrom } from "rxjs";
import JSZip from "jszip"
import { extractZip } from "../../helpers/zip.helpers";
import { ensureFolderExist } from "../../helpers/fs.helpers";
import { readdir } from "fs-extra";
import recursiveReadDir from "recursive-readdir";
export class BsModsManagerService {
@@ -133,7 +130,7 @@ export class BsModsManagerService {
resolve(false);
});
setTimeout(() => resolve(false), (1 * 60) * 1000); //timeout 1min
setTimeout(() => resolve(false), (1 * 60) * 1000); // timeout 1min
});
}
@@ -165,7 +162,7 @@ export class BsModsManagerService {
return download.hashMd5.some(md5 => md5.hash === entryMd5) ? entry : undefined;
}))).filter(entry => !!entry);
if(checkedEntries.length != download.hashMd5.length){ return false; }
if(checkedEntries.length !== download.hashMd5.length){ return false; }
const verionPath = await this.bsLocalService.getVersionPath(version);
const isBSIPA = mod.name.toLowerCase() === "bsipa";
@@ -260,7 +257,7 @@ export class BsModsManagerService {
]).then(dirMods => {
const modsDict = new Map<string, Mod>();
if(!!bsipa){ modsDict.set(bsipa.name, bsipa); }
if(bsipa){ modsDict.set(bsipa.name, bsipa); }
for(const mod of dirMods.flat()){
if(modsDict.has(mod.name)){ continue; }
+3 -3
View File
@@ -21,7 +21,7 @@ export class OculusService {
}
public async oculusRunning(): Promise<boolean> {
return await this.utils.taskRunning("OculusClient.exe");
return this.utils.taskRunning("OculusClient.exe");
}
public async getOculusLibsPath(): Promise<string[]>{
@@ -36,9 +36,9 @@ export class OculusService {
const libsPath = (await Promise.all(libsRegData.keys.map(async key => {
const originalPath = (await regedit.promisified.list([`${oculusLibsRegKey}\\${key}`]))[`${oculusLibsRegKey}\\${key}`];
if(!originalPath.exists || !libsRegData.values || !originalPath.values["OriginalPath"]){ return null; }
if(!originalPath.exists || !libsRegData.values || !originalPath.values.OriginalPath){ return null; }
return originalPath.values["OriginalPath"].value as string;
return originalPath.values.OriginalPath.value as string;
}, []))).filter(path => !!path);
+1 -1
View File
@@ -40,7 +40,7 @@ export class RequestService {
const file = createWriteStream(dest);
file.on("close", () => {
progress["data"] = dest;
progress.data = dest;
subscriber.next(progress); subscriber.complete();
});
file.on("error", err => unlink(dest, () => subscriber.error(err)));
+21 -20
View File
@@ -38,7 +38,7 @@ export class SteamService{
if (process.platform === 'win32') {
return !!(await this.getActiveUser());
}
return await psList()
return psList()
.then(processes => !!processes.find(process => process.cmd.includes('steam')))
.catch(e => {log.error(e); throw e})
}
@@ -47,26 +47,27 @@ export class SteamService{
if(this.steamPath){ return this.steamPath; }
switch (process.platform) {
case "linux":
if(process.platform === "win32"){
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.exists && win64?.values?.InstallPath?.value){ res = win64.values.InstallPath.value as string; }
else if(win32.exists && win32?.values?.InstallPath?.value){ res = win32.values.InstallPath.value as string; }
this.steamPath = res;
return res;
}
if(process.platform === "linux"){
this.steamPath = path.join(app.getPath('home'), '.steam', "steam");
return this.steamPath;
case "win32":
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.exists && win64?.values?.InstallPath?.value){ res = win64.values.InstallPath.value as string; }
else if(win32.exists && win32?.values?.InstallPath?.value){ res = win32.values.InstallPath.value as string; }
this.steamPath = res;
return res;
default:
return null;
}
return null;
}
public async getGameFolder(gameId: string, gameFolder?: string): Promise<string>{
@@ -82,8 +83,8 @@ export class SteamService{
libraryFolders = libraryFolders.libraryfolders
for(const libKey in Object.keys(libraryFolders)){
if(!libraryFolders[libKey] || !libraryFolders[libKey]["apps"]){ continue; }
if(libraryFolders[libKey]["apps"][gameId] != null){ return path.join(libraryFolders[libKey]["path"], "steamapps", "common", gameFolder); };
if(!libraryFolders[libKey] || !libraryFolders[libKey].apps){ continue; }
if(libraryFolders[libKey].apps[gameId] != null){ return path.join(libraryFolders[libKey].path, "steamapps", "common", gameFolder); };
}
return null;
}