[chore] Use regedit-rs instead of node-regedit

This commit is contained in:
MathieuG-P
2023-12-15 20:43:03 +01:00
parent 04f811f53b
commit c2ff4fed8b
7 changed files with 132 additions and 173 deletions
-105
View File
@@ -39,7 +39,6 @@
"react-virtualized-auto-sizer": "^1.0.12",
"react-window": "^1.8.8",
"recursive-readdir": "^2.2.3",
"regedit": "^5.1.2",
"rfdc": "^1.3.0",
"rxjs": "^7.8.0",
"sanitize-filename": "^1.6.3",
@@ -10129,11 +10128,6 @@
}
]
},
"node_modules/if-async": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/if-async/-/if-async-3.7.4.tgz",
"integrity": "sha512-BFEH2mZyeF6KZKaKLVPZ0wMjIiWOdjvZ7zbx8ENec0qfZhJwKFbX/4jKM5LTKyJEc/GOqUKiiJ2IFKT9yWrZqA=="
},
"node_modules/ignore": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
@@ -15840,17 +15834,6 @@
"integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==",
"dev": true
},
"node_modules/regedit": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/regedit/-/regedit-5.1.2.tgz",
"integrity": "sha512-pQpWqO/I40bMNoMO9kTQx3e5iK542kYcB/Z8X3Y7Hcri6ydc4KZ9ByUsEWFkBRMcwo+2irHuNK5s+pMGPr6VPw==",
"dependencies": {
"debug": "^4.1.0",
"if-async": "^3.7.4",
"stream-slicer": "0.0.6",
"through2": "^0.6.3"
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
@@ -16968,11 +16951,6 @@
"node": ">= 0.8"
}
},
"node_modules/stream-slicer": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/stream-slicer/-/stream-slicer-0.0.6.tgz",
"integrity": "sha512-QsY0LbweYE5L+e+iBQgtkM5WUIf7+kCMA/m2VULv8rEEDDnlDPsPvOHH4nli6uaZOKQEt64u65h0l/eeZo7lCw=="
},
"node_modules/stream-to": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-to/-/stream-to-0.2.2.tgz",
@@ -17587,36 +17565,6 @@
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
"dev": true
},
"node_modules/through2": {
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
"integrity": "sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==",
"dependencies": {
"readable-stream": ">=1.0.33-1 <1.1.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
}
},
"node_modules/through2/node_modules/isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ=="
},
"node_modules/through2/node_modules/readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"node_modules/through2/node_modules/string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ=="
},
"node_modules/thunky": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
@@ -26907,11 +26855,6 @@
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"dev": true
},
"if-async": {
"version": "3.7.4",
"resolved": "https://registry.npmjs.org/if-async/-/if-async-3.7.4.tgz",
"integrity": "sha512-BFEH2mZyeF6KZKaKLVPZ0wMjIiWOdjvZ7zbx8ENec0qfZhJwKFbX/4jKM5LTKyJEc/GOqUKiiJ2IFKT9yWrZqA=="
},
"ignore": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
@@ -31235,17 +31178,6 @@
}
}
},
"regedit": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/regedit/-/regedit-5.1.2.tgz",
"integrity": "sha512-pQpWqO/I40bMNoMO9kTQx3e5iK542kYcB/Z8X3Y7Hcri6ydc4KZ9ByUsEWFkBRMcwo+2irHuNK5s+pMGPr6VPw==",
"requires": {
"debug": "^4.1.0",
"if-async": "^3.7.4",
"stream-slicer": "0.0.6",
"through2": "^0.6.3"
}
},
"regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
@@ -32107,11 +32039,6 @@
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"dev": true
},
"stream-slicer": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/stream-slicer/-/stream-slicer-0.0.6.tgz",
"integrity": "sha512-QsY0LbweYE5L+e+iBQgtkM5WUIf7+kCMA/m2VULv8rEEDDnlDPsPvOHH4nli6uaZOKQEt64u65h0l/eeZo7lCw=="
},
"stream-to": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/stream-to/-/stream-to-0.2.2.tgz",
@@ -32559,38 +32486,6 @@
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
"dev": true
},
"through2": {
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
"integrity": "sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==",
"requires": {
"readable-stream": ">=1.0.33-1 <1.1.0-0",
"xtend": ">=4.0.0 <4.1.0-0"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ=="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ=="
}
}
},
"thunky": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
-1
View File
@@ -264,7 +264,6 @@
"react-virtualized-auto-sizer": "^1.0.12",
"react-window": "^1.8.8",
"recursive-readdir": "^2.2.3",
"regedit": "^5.1.2",
"rfdc": "^1.3.0",
"rxjs": "^7.8.0",
"sanitize-filename": "^1.6.3",
+89 -2
View File
@@ -1,16 +1,17 @@
{
"name": "bs-manager",
"version": "1.3.1-alpha.2",
"version": "1.4.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "bs-manager",
"version": "1.3.1-alpha.2",
"version": "1.4.1",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"ps-list": "^7.2.0",
"regedit-rs": "^1.0.1",
"sharp": "^0.32.6"
}
},
@@ -375,6 +376,64 @@
"node": ">= 6"
}
},
"node_modules/regedit-rs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs/-/regedit-rs-1.0.1.tgz",
"integrity": "sha512-wsvoGP5JDevIcx3q52aATW1c1dY86bQx7/tJ32gqV+L98OHRJykobKkjYqGzROtz9c2Pr+wGJZr0glFyc2dpvQ==",
"engines": {
"node": ">= 10"
},
"optionalDependencies": {
"regedit-rs-win32-arm64-msvc": "1.0.1",
"regedit-rs-win32-ia32-msvc": "1.0.1",
"regedit-rs-win32-x64-msvc": "1.0.1"
}
},
"node_modules/regedit-rs-win32-arm64-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-arm64-msvc/-/regedit-rs-win32-arm64-msvc-1.0.1.tgz",
"integrity": "sha512-QA46d/wiUHlW2h0ZlHKrtDhnwoxMpVle+EbFziEbLYC7dimtAiWCeXu4zNymaFClDimYSifQkWgza5GBmD8etg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/regedit-rs-win32-ia32-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-ia32-msvc/-/regedit-rs-win32-ia32-msvc-1.0.1.tgz",
"integrity": "sha512-V2NisvicQqiozl0yMas9tjDYmBwHWf48M/dMJUWMQxxkJaDCNoHW8PljL59A/h8ew2NBFsJK5RYkYfxW1o+OyQ==",
"cpu": [
"ia32"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/regedit-rs-win32-x64-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-x64-msvc/-/regedit-rs-win32-x64-msvc-1.0.1.tgz",
"integrity": "sha512-qhQawjYPzXGrz0xODJiviwrzw0eytGP9+quuQJUQAiLEw2P1tQ0LCyID3jOvNltLH+tqJChSV4JaQcPVleohZg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -818,6 +877,34 @@
"util-deprecate": "^1.0.1"
}
},
"regedit-rs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs/-/regedit-rs-1.0.1.tgz",
"integrity": "sha512-wsvoGP5JDevIcx3q52aATW1c1dY86bQx7/tJ32gqV+L98OHRJykobKkjYqGzROtz9c2Pr+wGJZr0glFyc2dpvQ==",
"requires": {
"regedit-rs-win32-arm64-msvc": "1.0.1",
"regedit-rs-win32-ia32-msvc": "1.0.1",
"regedit-rs-win32-x64-msvc": "1.0.1"
}
},
"regedit-rs-win32-arm64-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-arm64-msvc/-/regedit-rs-win32-arm64-msvc-1.0.1.tgz",
"integrity": "sha512-QA46d/wiUHlW2h0ZlHKrtDhnwoxMpVle+EbFziEbLYC7dimtAiWCeXu4zNymaFClDimYSifQkWgza5GBmD8etg==",
"optional": true
},
"regedit-rs-win32-ia32-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-ia32-msvc/-/regedit-rs-win32-ia32-msvc-1.0.1.tgz",
"integrity": "sha512-V2NisvicQqiozl0yMas9tjDYmBwHWf48M/dMJUWMQxxkJaDCNoHW8PljL59A/h8ew2NBFsJK5RYkYfxW1o+OyQ==",
"optional": true
},
"regedit-rs-win32-x64-msvc": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/regedit-rs-win32-x64-msvc/-/regedit-rs-win32-x64-msvc-1.0.1.tgz",
"integrity": "sha512-qhQawjYPzXGrz0xODJiviwrzw0eytGP9+quuQJUQAiLEw2P1tQ0LCyID3jOvNltLH+tqJChSV4JaQcPVleohZg==",
"optional": true
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+1
View File
@@ -15,6 +15,7 @@
},
"dependencies": {
"ps-list": "^7.2.0",
"regedit-rs": "^1.0.1",
"sharp": "^0.32.6"
},
"license": "MIT"
+12 -24
View File
@@ -1,6 +1,6 @@
import { execOnOs } from "../../helpers/env.helpers";
import { list, createKey, putValue, deleteKey, RegSzValue } from "regedit-rs";
import path from "path";
import regedit from "regedit";
export class LivService {
@@ -23,8 +23,8 @@ export class LivService {
public async isLivInstalled(): Promise<boolean> {
return execOnOs({
win32: async () => {
const regRes = await regedit.promisified.list([this.livRegeditKey]).then(res => res[this.livRegeditKey]);
return regRes?.exists;
const regRes = await list(this.livRegeditKey).then(res => res[this.livRegeditKey]);
return regRes.exists;
},
}, true);
}
@@ -33,25 +33,13 @@ export class LivService {
return execOnOs({
win32: async () => {
const livExternalAppRegeditKey = path.join(this.livExternalAppsRegeditKey, entry.id);
await regedit.promisified.createKey([livExternalAppRegeditKey]);
await regedit.promisified.putValue({
await createKey(livExternalAppRegeditKey);
await putValue({
[livExternalAppRegeditKey]: {
"InstallPath": {
value: entry.installPath,
type: "REG_SZ"
},
"Executable": {
value: entry.executable,
type: "REG_SZ"
},
"Arguments": {
value: entry.arguments,
type: "REG_SZ"
},
"Name": {
value: entry.name,
type: "REG_SZ"
}
InstallPath: new RegSzValue(entry.installPath),
Executable: new RegSzValue(entry.executable),
Arguments: new RegSzValue(entry.arguments),
Name: new RegSzValue(entry.name)
}
});
}
@@ -62,7 +50,7 @@ export class LivService {
return execOnOs({
win32: async () => {
const shotcutsKeys = ids.map(id => path.join(this.livExternalAppsRegeditKey, id));
return regedit.promisified.deleteKey(shotcutsKeys);
return deleteKey(shotcutsKeys);
}
})
}
@@ -70,7 +58,7 @@ export class LivService {
public getLivShortcuts(): Promise<LivEntry[]> {
return execOnOs({
win32: async () => {
const regRes = await regedit.promisified.list([this.livExternalAppsRegeditKey]).then(res => res[this.livExternalAppsRegeditKey]);
const regRes = await list(this.livExternalAppsRegeditKey).then(res => res[this.livExternalAppsRegeditKey]);
if(!regRes.exists){
return [];
@@ -78,7 +66,7 @@ export class LivService {
const promises = regRes.keys.map(async key => {
const shortcutKey = path.join(this.livExternalAppsRegeditKey, key);
const entries = await regedit.promisified.list([shortcutKey]).then(res => res[shortcutKey]);
const entries = await list(shortcutKey).then(res => res[shortcutKey]);
if(!entries.exists){
return undefined;
+12 -13
View File
@@ -1,4 +1,4 @@
import regedit from "regedit";
import { list } from "regedit-rs";
import path from "path";
import { pathExist } from "../helpers/fs.helpers";
import log from "electron-log";
@@ -29,26 +29,25 @@ export class OculusService {
}
const oculusLibsRegKey = "HKCU\\SOFTWARE\\Oculus VR, LLC\\Oculus\\Libraries";
const libsRegData = await list(oculusLibsRegKey).then(data => data[oculusLibsRegKey]);
const libsRegData = (await regedit.promisified.list([oculusLibsRegKey]))["HKCU\\SOFTWARE\\Oculus VR, LLC\\Oculus\\Libraries"];
if (!libsRegData.exists || !libsRegData.keys) {
if (!libsRegData.keys?.length) {
log.info("Registry key \"HKCU\\SOFTWARE\\Oculus VR, LLC\\Oculus\\Libraries\" not found");
return null;
}
const defaultLibraryId = libsRegData.values.DefaultLibrary.value as string;
const libsPath: OculusLibrary[] = (
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;
}
await Promise.all(libsRegData.keys.map(async key => {
const originalPath = await list([`${oculusLibsRegKey}\\${key}`]).then(res => res[`${oculusLibsRegKey}\\${key}`]);
if (!originalPath.values?.OriginalPath) {
return null;
}
return { id: key, path: originalPath.values.OriginalPath.value, isDefault: defaultLibraryId === key } as OculusLibrary
}, [])
)
return { id: key, path: originalPath.values.OriginalPath.value, isDefault: defaultLibraryId === key } as OculusLibrary
}, []))
).filter(Boolean);
this.oculusLibraries = libsPath;
+18 -28
View File
@@ -1,5 +1,4 @@
import { UtilsService } from "./utils.service";
import regedit from "regedit";
import { list, RegDwordValue } from "regedit-rs"
import path from "path";
import { parse } from "@node-steam/vdf";
import { readFile } from "fs/promises";
@@ -11,15 +10,9 @@ import { taskRunning } from "../helpers/os.helpers";
export class SteamService {
private static instance: SteamService;
private readonly utils: UtilsService = UtilsService.getInstance();
private steamPath: string = '';
private constructor(){
const vbsDirectory = path.join(this.utils.getAssetsScriptsPath(), "node-regedit", "vbs");
regedit.setExternalVBSLocation(vbsDirectory);
}
private constructor(){}
public static getInstance(){
if(!SteamService.instance){ SteamService.instance = new SteamService(); }
@@ -27,17 +20,19 @@ export class SteamService {
}
public async getActiveUser(): Promise<number>{
const res = await regedit.promisified.list(["HKCU\\Software\\Valve\\Steam\\ActiveProcess"]);
const keys = res?.["HKCU\\Software\\Valve\\Steam\\ActiveProcess"];
if(!keys?.exists){ throw "Key \"HKCU\\Software\\Valve\\Steam\\ActiveProcess\" not exist"; }
return (keys.values?.ActiveUser.value || undefined) as number;
const res = await list("HKCU\\Software\\Valve\\Steam\\ActiveProcess");
const key = res["HKCU\\Software\\Valve\\Steam\\ActiveProcess"];
if(!key.exists){ throw "Key \"HKCU\\Software\\Valve\\Steam\\ActiveProcess\" not exist"; }
const registryValue = key.values.ActiveUser as RegDwordValue;
if(!registryValue){ throw "Value \"ActiveUser\" not exist"; }
return registryValue.value;
}
public async steamRunning(): Promise<boolean>{
const steamProcessRunning = await taskRunning("steam");
if(process.platform === "linux") { return steamProcessRunning; }
return steamProcessRunning && !!(await this.getActiveUser());
const activeUser = await this.getActiveUser().catch(err => log.error(err));
return steamProcessRunning && !!activeUser;
}
public async getSteamPath(): Promise<string>{
@@ -48,24 +43,19 @@ export class SteamService {
case "linux":
this.steamPath = path.join(app.getPath('home'), '.steam', "steam");
return this.steamPath;
case "win32":
// eslint-disable-next-line no-case-declarations
const [win32Res, win64Res] = await Promise.all([
regedit.promisified.list(['HKLM\\SOFTWARE\\Valve\\Steam']),
regedit.promisified.list(['HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam'])
]);
case "win32": {
const res = await list(['HKLM\\SOFTWARE\\Valve\\Steam', 'HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam']);
const win64 = res['HKLM\\SOFTWARE\\Valve\\Steam'];
const win32 = res['HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam'];
// eslint-disable-next-line no-case-declarations
const [win32, win64] = [win32Res["HKLM\\SOFTWARE\\Valve\\Steam"], win64Res["HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam"]];
if(win64.exists && win64?.values?.InstallPath?.value){
if (win64.exists && win64?.values?.InstallPath?.value) {
this.steamPath = win64.values.InstallPath.value as string;
}
else if (win32.exists && win32?.values?.InstallPath?.value){
this.steamPath = win32.values.InstallPath.value as string;
} else if (win32.exists && win32?.values?.InstallPath?.value) {
this.steamPath = win32.values.InstallPath.value as string;
}
return this.steamPath;
}
default:
return null;
}