From da79c8fec8a879394a33956e639101b1171d6217 Mon Sep 17 00:00:00 2001 From: Ciberus Date: Sun, 16 Jun 2024 13:23:01 +0300 Subject: [PATCH] v0.8.0 add igdb as games info source --- package-lock.json | 89 ++++++++++++++++++++++++++++++++--- package.json | 3 +- release/app/package-lock.json | 2 +- release/app/package.json | 2 +- src/main/handlers/game.ts | 4 +- src/main/stores/games.ts | 54 +++++++++++++++++++++ src/main/utils/fileSystem.ts | 3 ++ src/main/utils/games.ts | 2 +- 8 files changed, 146 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95e306c..9d17fa3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FireSave", - "version": "0.7.4", + "version": "0.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "FireSave", - "version": "0.7.4", + "version": "0.8.0", "hasInstallScript": true, "dependencies": { "@ciberus/find-steam-app": "^4.0.0", @@ -29,6 +29,7 @@ "i18next-fs-backend": "^1.1.4", "lodash.debounce": "^4.0.8", "lodash.groupby": "^4.6.0", + "make-synchronous": "^0.1.1", "nanoid": "^3.2.0", "node-wmi": "^0.0.5", "parse-filepath": "^1.0.2", @@ -6189,7 +6190,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", - "dev": true, "engines": { "node": ">=8" } @@ -12691,6 +12691,32 @@ "node": ">= 6" } }, + "node_modules/make-synchronous": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/make-synchronous/-/make-synchronous-0.1.1.tgz", + "integrity": "sha512-Y4SxxqhaoyMDokJQ0AZz0E+bLhRkOSR7Z/IQoTKPdS6HYi3aobal2kMHoHHoqBadPWjf07P4K1FQLXOx3wf9Yw==", + "dependencies": { + "subsume": "^3.0.0", + "type-fest": "^0.16.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-synchronous/node_modules/type-fest": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz", + "integrity": "sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -17071,6 +17097,26 @@ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.13.tgz", "integrity": "sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==" }, + "node_modules/subsume": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/subsume/-/subsume-3.0.0.tgz", + "integrity": "sha512-6n/UfV8UWKwJNO8OAOiKntwEMihuBeeoJfzpL542C+OuvT4iWG9SwjrXkOmsxjb4SteHUsos9SvrdqZ9+ICwTQ==", + "dependencies": { + "escape-string-regexp": "^2.0.0", + "unique-string": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/subsume/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "engines": { + "node": ">=8" + } + }, "node_modules/sumchecker": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", @@ -17836,7 +17882,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", - "dev": true, "dependencies": { "crypto-random-string": "^2.0.0" }, @@ -24182,8 +24227,7 @@ "crypto-random-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", - "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", - "dev": true + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==" }, "css": { "version": "3.0.0", @@ -29107,6 +29151,22 @@ } } }, + "make-synchronous": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/make-synchronous/-/make-synchronous-0.1.1.tgz", + "integrity": "sha512-Y4SxxqhaoyMDokJQ0AZz0E+bLhRkOSR7Z/IQoTKPdS6HYi3aobal2kMHoHHoqBadPWjf07P4K1FQLXOx3wf9Yw==", + "requires": { + "subsume": "^3.0.0", + "type-fest": "^0.16.0" + }, + "dependencies": { + "type-fest": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz", + "integrity": "sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==" + } + } + }, "makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -32385,6 +32445,22 @@ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.13.tgz", "integrity": "sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==" }, + "subsume": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/subsume/-/subsume-3.0.0.tgz", + "integrity": "sha512-6n/UfV8UWKwJNO8OAOiKntwEMihuBeeoJfzpL542C+OuvT4iWG9SwjrXkOmsxjb4SteHUsos9SvrdqZ9+ICwTQ==", + "requires": { + "escape-string-regexp": "^2.0.0", + "unique-string": "^2.0.0" + }, + "dependencies": { + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==" + } + } + }, "sumchecker": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", @@ -32937,7 +33013,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", - "dev": true, "requires": { "crypto-random-string": "^2.0.0" } diff --git a/package.json b/package.json index 5a5a0ac..b6d987a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "FireSave", - "version": "0.7.4", + "version": "0.8.0", "description": "Saves manager", "main": "./src/main/main.ts", "scripts": { @@ -136,6 +136,7 @@ "i18next-fs-backend": "^1.1.4", "lodash.debounce": "^4.0.8", "lodash.groupby": "^4.6.0", + "make-synchronous": "^0.1.1", "nanoid": "^3.2.0", "node-wmi": "^0.0.5", "parse-filepath": "^1.0.2", diff --git a/release/app/package-lock.json b/release/app/package-lock.json index 6ea6ef0..44e1738 100644 --- a/release/app/package-lock.json +++ b/release/app/package-lock.json @@ -1,6 +1,6 @@ { "name": "FireSave", - "version": "0.7.4", + "version": "0.8.0", "description": "Saves manager", "main": "./dist/main/main.js", "author": { diff --git a/release/app/package.json b/release/app/package.json index 6ea6ef0..44e1738 100644 --- a/release/app/package.json +++ b/release/app/package.json @@ -1,6 +1,6 @@ { "name": "FireSave", - "version": "0.7.4", + "version": "0.8.0", "description": "Saves manager", "main": "./dist/main/main.js", "author": { diff --git a/src/main/handlers/game.ts b/src/main/handlers/game.ts index 42e9e5c..048453c 100644 --- a/src/main/handlers/game.ts +++ b/src/main/handlers/game.ts @@ -36,6 +36,7 @@ const GamesHandlers: TGamesHandlers = { } const name = payload.gamePath.files?.[0] || "Unknown"; + const savePointsFolderName = name.replace(".exe", ""); const newGame: TGame = { id, @@ -47,8 +48,7 @@ const GamesHandlers: TGamesHandlers = { isSaveConfigValid: false, isSettupedAtLeastOnce: true, isPlaingNow: false, - // name but probably installDir better, mb for steamgames prefix "steam__" can be done or for others "nonsteam__" - savePointsFolderName: name.replace(".exe", ""), + savePointsFolderName, savesStats: { total: 0, auto: 0, manual: 0 }, imageUrl: undefined, gamePath: { [PLATFORM]: payload.gamePath }, diff --git a/src/main/stores/games.ts b/src/main/stores/games.ts index d9c530e..167edf0 100644 --- a/src/main/stores/games.ts +++ b/src/main/stores/games.ts @@ -1,8 +1,10 @@ import ElectronStore from "electron-store"; +import makeSynchronous from "make-synchronous"; import persistentStore from "./persistent"; import FileSystem from "../utils/fileSystem"; import { PLATFORM } from "../utils/config"; +import { findSteam, ISteamApp } from "@ciberus/find-steam-app"; const DEFAULT_TAGS_LIST = [ "auto", @@ -124,6 +126,58 @@ const gamesStore = new ElectronStore({ store.set("games", games); }, + "0.8.0": (store) => { + let games = store.store.games; + + const steamInfo = makeSynchronous(findSteam)(); + const steamApps: ISteamApp[] = []; + for (const lib of steamInfo.libraries) { + for (const steamApp of lib.apps) { + steamApps.push(steamApp); + } + } + + console.log("KDSFLKD", steamApps.length, steamApps); + + Object.entries(games).forEach(async ([, game]) => { + if ( + game.isAutoDetectionEnabled && + game.autoDetectionMethod === "steam" + ) { + console.log("KDSFLKD 1 ", game.id, game.name); + const steamAppInfo = steamApps.find( + (s) => s.appId === game.steamAppId + ); + const newSavePointsFolderName = steamAppInfo?.manifest.installdir; + console.log( + "KDSFLKD 2 ", + game.id, + game.name, + newSavePointsFolderName + ); + + if (newSavePointsFolderName) { + const savesFolderPath = FileSystem.joinUpath( + persistentStore.store.savesFolder, + `${game.savePointsFolderName}__${game.id}` + ); + const newSavesFolderPath = FileSystem.joinUpath( + persistentStore.store.savesFolder, + `${newSavePointsFolderName}__${game.id}` + ); + + game.savePointsFolderName = newSavePointsFolderName; + + try { + FileSystem.renameFolder(savesFolderPath, newSavesFolderPath); + } catch (err) {} + } + } + }); + + console.log("New GAMES EPTA", games); + gamesStore.set("games", games); + }, }, }); diff --git a/src/main/utils/fileSystem.ts b/src/main/utils/fileSystem.ts index 4b59121..7a9d072 100644 --- a/src/main/utils/fileSystem.ts +++ b/src/main/utils/fileSystem.ts @@ -49,6 +49,8 @@ const normalizePathForCurrentOS = (pathString: string): string => { return path.normalize(pathString); }; +const renameFolder = fs.promises.rename; + const FileSystem = { writeFileSync, copyFolder, @@ -63,6 +65,7 @@ const FileSystem = { join, joinUpath, normalizePathForCurrentOS, + renameFolder, }; export default FileSystem; diff --git a/src/main/utils/games.ts b/src/main/utils/games.ts index db7dfd9..4825b92 100644 --- a/src/main/utils/games.ts +++ b/src/main/utils/games.ts @@ -56,7 +56,7 @@ const convertSteamAppToGame = ( isSettupedAtLeastOnce: false, isPlaingNow: false, // name but probably installDir better, mb for steamgames prefix "steam__" can be done or for others "nonsteam__" - savePointsFolderName: steamApp.manifest.name, + savePointsFolderName: steamApp.manifest.installdir, savesStats: { total: 0, auto: 0, manual: 0 }, imageUrl: storeInfo?.header_image, gamePath: {