Compare commits

4 Commits

6 changed files with 47 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import stylistic from "@stylistic/eslint-plugin";
export default defineConfig([
{
files: ["**/*.{js,mjs,cjs}"],
ignores: ["node_modules/**", "out/**"],
plugins: { js, "@stylistic": stylistic },
extends: ["js/recommended"],
languageOptions: { globals: { ...globals.browser, ...globals.node } },

24
main.js
View File

@@ -208,9 +208,13 @@ function saveBepinexVersion(version) {
}
ipcMain.handle("load-bepinex-version", () => {
return loadBepinexVersion();
});
function loadBepinexVersion() {
bepinexVersion = bepinexStore.get("bepinex-version");
return bepinexVersion;
});
}
function saveBepinexBackupVersion(version) {
bepinexBackupVersion = version;
@@ -377,8 +381,6 @@ async function installBepinex() {
saveBepinexVersion(bepinexBackupVersion);
saveBepinexBackupVersion(undefined);
} else {
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
const GITHUB_URL = "https://api.github.com/repos/bepinex/bepinex/releases/latest";
const res = await fetch(GITHUB_URL, {
@@ -397,6 +399,14 @@ async function installBepinex() {
const release = await res.json();
if (loadBepinexVersion() == release.tag_name) {
mainWindow.webContents.send("showToast", "No new BepInEx update.");
return;
}
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
await uninstallBepinex();
let asset;
if (process.platform === "win32") {
asset = release.assets.find((a) => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64"));
@@ -700,6 +710,12 @@ async function searchThunderstoreMods(keywords, offset = 0, count = 10, sortFilt
"User-Agent": userAgent,
},
});
if (!res.ok) {
if (res.status == 403) {
mainWindow.webContents.send("showToast", "Thunderstore has blocked the application. Please try again later.", "error");
}
throw new Error(`Thunderstore API error: ${res.status}`);
}
const modsInfo = await res.json();
const modsToRemove = ["f21c391c-0bc5-431d-a233-95323b95e01b", "42f76853-d2a4-4520-949b-13a02fdbbbcb", "34eac80c-5497-470e-b98c-f53421b828c0"];
@@ -964,7 +980,7 @@ ipcMain.handle("add-offline-mod", async () => {
async function checkForCoreAndPatcherMods() {
const bepinexFolderPath = path.join(loadSilksongPath(), "BepInEx");
const bepinexPluginsPath = path.join(bepinexFolderPath, "Plugins");
const bepinexPluginsPath = path.join(bepinexFolderPath, "plugins");
const bepinexCorePath = path.join(bepinexFolderPath, "core", "custom");
const bepinexPatcherPath = path.join(bepinexFolderPath, "patchers", "custom");

32
package-lock.json generated
View File

@@ -12,7 +12,7 @@
"@nexusmods/nexus-api": "^1.1.5",
"7zip-bin": "^5.2.0",
"electron-store": "^11.0.2",
"graphql": "^16.12.0",
"graphql": "^16.13.2",
"graphql-request": "^7.4.0",
"node-7z": "^3.0.0",
"semver": "^7.7.4",
@@ -30,8 +30,8 @@
"@reforged/maker-appimage": "^5.2.0",
"@stylistic/eslint-plugin": "^5.10.0",
"cross-env": "^10.1.0",
"electron": "^40.6.0",
"eslint": "^10.2.0",
"electron": "^41.2.1",
"eslint": "^10.2.1",
"globals": "^17.5.0"
}
},
@@ -3182,9 +3182,9 @@
}
},
"node_modules/electron": {
"version": "40.6.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-40.6.0.tgz",
"integrity": "sha512-ett8W+yOFGDuM0vhJMamYSkrbV3LoaffzJd9GfjI96zRAxyrNqUSKqBpf/WGbQCweDxX2pkUCUfrv4wwKpsFZA==",
"version": "41.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-41.2.1.tgz",
"integrity": "sha512-teeRThiYGTPKf/2yOW7zZA1bhb91KEQ4yLBPOg7GxpmnkLFLugKgQaAKOrCgdzwsXh/5mFIfmkm+4+wACJKwaA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
@@ -3725,18 +3725,18 @@
}
},
"node_modules/eslint": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.2.0.tgz",
"integrity": "sha512-+L0vBFYGIpSNIt/KWTpFonPrqYvgKw1eUI5Vn7mEogrQcWtWYtNQ7dNqC+px/J0idT3BAkiWrhfS7k+Tum8TUA==",
"version": "10.2.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.2.1.tgz",
"integrity": "sha512-wiyGaKsDgqXvF40P8mDwiUp/KQjE1FdrIEJsM8PZ3XCiniTMXS3OHWWUe5FI5agoCnr8x4xPrTDZuxsBlNHl+Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.2",
"@eslint/config-array": "^0.23.4",
"@eslint/config-helpers": "^0.5.4",
"@eslint/core": "^1.2.0",
"@eslint/plugin-kit": "^0.7.0",
"@eslint/config-array": "^0.23.5",
"@eslint/config-helpers": "^0.5.5",
"@eslint/core": "^1.2.1",
"@eslint/plugin-kit": "^0.7.1",
"@humanfs/node": "^0.16.6",
"@humanwhocodes/module-importer": "^1.0.1",
"@humanwhocodes/retry": "^0.4.2",
@@ -4692,9 +4692,9 @@
"license": "ISC"
},
"node_modules/graphql": {
"version": "16.12.0",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.12.0.tgz",
"integrity": "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==",
"version": "16.13.2",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.13.2.tgz",
"integrity": "sha512-5bJ+nf/UCpAjHM8i06fl7eLyVC9iuNAjm9qzkiu2ZGhM0VscSvS6WDPfAwkdkBuoXGM9FJSbKl6wylMwP9Ktig==",
"license": "MIT",
"engines": {
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"

View File

@@ -2,7 +2,7 @@
"name": "silkflylauncher",
"productName": "Silk Fly Launcher",
"version": "1.0.0-dev",
"description": "Silk Fly Launcher is a launcher and mod manager for Silksong mods from Nexus, built with Electron.",
"description": "Silk Fly Launcher is a launcher and mod manager for Silksong mods from Thunderstore and Nexus, built with Electron.",
"main": "main.js",
"type": "module",
"scripts": {
@@ -12,7 +12,8 @@
"make:msi": "cross-env BUILD_TARGET=msi electron-forge make",
"make:zip": "cross-env BUILD_TARGET=zip electron-forge make",
"make:deb": "cross-env BUILD_TARGET=deb electron-forge make",
"make:appimage": "cross-env BUILD_TARGET=appimage electron-forge make"
"make:appimage": "cross-env BUILD_TARGET=appimage electron-forge make",
"lint": "npx eslint"
},
"author": "GabiZar",
"license": "GPL-3.0",
@@ -28,15 +29,15 @@
"@reforged/maker-appimage": "^5.2.0",
"@stylistic/eslint-plugin": "^5.10.0",
"cross-env": "^10.1.0",
"electron": "^40.6.0",
"eslint": "^10.2.0",
"electron": "^41.2.1",
"eslint": "^10.2.1",
"globals": "^17.5.0"
},
"dependencies": {
"@nexusmods/nexus-api": "^1.1.5",
"7zip-bin": "^5.2.0",
"electron-store": "^11.0.2",
"graphql": "^16.12.0",
"graphql": "^16.13.2",
"graphql-request": "^7.4.0",
"node-7z": "^3.0.0",
"semver": "^7.7.4",

View File

@@ -281,7 +281,7 @@
<p class="transparent-text" id="bepinex-version-text"></p>
<br />
<div class="horizontal-div">
<button class="default-button" onclick="installBepinex()">Install</button>
<button id="install-bepinex-button" class="default-button" onclick="installBepinex()">Install</button>
<button class="important-button" onclick="uninstallBepinex()">Uninstall</button>
<button class="default-button" onclick="backupBepinex()">Backup</button>
<button class="important-button" onclick="deleteBepinexBackup()">Delete Backup</button>

View File

@@ -589,6 +589,7 @@ async function deleteBepinexBackup() {
async function setBepinexVersion() {
const bepinexVersionText = document.getElementById("bepinex-version-text");
const bepinexInstallButton = document.getElementById("install-bepinex-button");
if (bepinexVersionText == undefined) {
return;
}
@@ -601,8 +602,10 @@ async function setBepinexVersion() {
} else {
bepinexVersionText.innerText = `BepInEx ${bepinexBackupVersion} is backed up`;
}
bepinexInstallButton.innerText = "Install";
} else {
bepinexVersionText.innerText = `BepInEx ${bepinexVersion} is installed`;
bepinexInstallButton.innerText = "Update";
}
}