mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
Add BepInEx installation
This commit is contained in:
44
main.js
44
main.js
@@ -2,9 +2,13 @@ const { app, BrowserWindow , ipcMain, dialog, shell} = require('electron/main');
|
||||
const path = require('node:path');
|
||||
const Store = require('electron-store').default;
|
||||
const fs = require('fs/promises');
|
||||
const { createWriteStream } = require('fs');
|
||||
const { pipeline } = require('stream/promises');
|
||||
const extract = require("extract-zip");
|
||||
|
||||
const store = new Store();
|
||||
const userSavePath = app.getPath('userData')
|
||||
let silksongPath = store.get('silksong-path')
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
@@ -35,11 +39,13 @@ app.on('window-all-closed', () => {
|
||||
})
|
||||
|
||||
ipcMain.handle('save-path', (event, path) => {
|
||||
silksongPath = path;
|
||||
store.set('silksong-path', path);
|
||||
});
|
||||
|
||||
ipcMain.handle('load-path', () => {
|
||||
return store.get('silksong-path');
|
||||
silksongPath = store.get('silksong-path');
|
||||
return silksongPath;
|
||||
});
|
||||
|
||||
async function fileExists(filePath) {
|
||||
@@ -98,4 +104,40 @@ ipcMain.handle('import-data', async () => {
|
||||
|
||||
ipcMain.handle('open-link', async (event, link) => {
|
||||
await shell.openExternal(link)
|
||||
})
|
||||
|
||||
ipcMain.handle('install-bepinex', async () => {
|
||||
const GITHUB_URL = "https://api.github.com/repos/bepinex/bepinex/releases/latest"
|
||||
|
||||
const res = await fetch(GITHUB_URL, {
|
||||
headers: {
|
||||
"User-Agent": "SilkFlyLauncher/1.0.0",
|
||||
"Accept": "application/vnd.github+json",
|
||||
}
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`GitHub API error: ${res.status}`)
|
||||
}
|
||||
|
||||
const release = await res.json();
|
||||
|
||||
const asset = release.assets.find(
|
||||
a => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64")
|
||||
);
|
||||
|
||||
const download = await fetch(asset.browser_download_url)
|
||||
if (!download.ok) {
|
||||
throw new Error("Download error");
|
||||
}
|
||||
const filePath = `${userSavePath}\\bepinex.zip`
|
||||
console.log(filePath)
|
||||
|
||||
await pipeline(
|
||||
download.body,
|
||||
createWriteStream(filePath)
|
||||
)
|
||||
|
||||
await extract(filePath, { dir: silksongPath})
|
||||
await fs.unlink(filePath)
|
||||
})
|
||||
20
package-lock.json
generated
20
package-lock.json
generated
@@ -9,7 +9,8 @@
|
||||
"version": "1.0.0",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"dependencies": {
|
||||
"electron-store": "^11.0.2"
|
||||
"electron-store": "^11.0.2",
|
||||
"extract-zip": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^39.2.7"
|
||||
@@ -97,7 +98,7 @@
|
||||
"version": "22.19.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.3.tgz",
|
||||
"integrity": "sha512-1N9SBnWYOJTrNZCdh/yJE+t910Y128BoyY+zBLWhL3r0TYzlTmFdXrPwHL9DyFZmlEXNQQolTZh3KHV31QDhyA==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
@@ -117,7 +118,6 @@
|
||||
"version": "2.10.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz",
|
||||
"integrity": "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
@@ -180,7 +180,6 @@
|
||||
"version": "0.2.13",
|
||||
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
|
||||
"integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
@@ -294,7 +293,6 @@
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
@@ -477,7 +475,6 @@
|
||||
"version": "1.4.5",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"once": "^1.4.0"
|
||||
@@ -541,7 +538,6 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
|
||||
"integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
@@ -584,7 +580,6 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
|
||||
"integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pend": "~1.2.0"
|
||||
@@ -609,7 +604,6 @@
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
|
||||
"integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pump": "^3.0.0"
|
||||
@@ -851,7 +845,6 @@
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/normalize-url": {
|
||||
@@ -882,7 +875,6 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
@@ -902,7 +894,6 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
||||
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/progress": {
|
||||
@@ -919,7 +910,6 @@
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz",
|
||||
"integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"end-of-stream": "^1.1.0",
|
||||
@@ -1100,7 +1090,7 @@
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
@@ -1123,14 +1113,12 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/yauzl": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
||||
"integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-crc32": "~0.2.3",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"electron": "^39.2.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-store": "^11.0.2"
|
||||
"electron-store": "^11.0.2",
|
||||
"extract-zip": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,9 @@ contextBridge.exposeInMainWorld('files', {
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openExternalLink: (url) => ipcRenderer.invoke('open-link', url)
|
||||
});
|
||||
openExternalLink: (url) => ipcRenderer.invoke('open-link', url)
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('bepinex', {
|
||||
install: () => ipcRenderer.invoke('install-bepinex')
|
||||
})
|
||||
@@ -103,6 +103,13 @@
|
||||
<button class="default-button" onclick="autoDetectGamePath()">Auto Detect</button>
|
||||
</div>
|
||||
<br>
|
||||
<h2>BepInEx</h2>
|
||||
<p class="transparent-text">BepInEx V1.0.0 is installed</p>
|
||||
<div class="horizontal-div">
|
||||
<button class="default-button" onclick="installBepinex()">Install</button>
|
||||
<button class="important-button" onclick="uninstallBepinex()">Uninstall</button>
|
||||
</div>
|
||||
<br>
|
||||
<h2>Import/Export</h2>
|
||||
<div class="horizontal-div">
|
||||
<button class="default-button" onclick="importData()">Import Data</button>
|
||||
|
||||
@@ -115,4 +115,12 @@ async function importData() {
|
||||
|
||||
async function downloadMod() {
|
||||
console.log("WIP")
|
||||
}
|
||||
|
||||
async function installBepinex() {
|
||||
bepinex.install()
|
||||
}
|
||||
|
||||
async function uninstallBepinex() {
|
||||
console.log("WIP")
|
||||
}
|
||||
@@ -130,6 +130,7 @@ body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.silksong-path-input {
|
||||
|
||||
Reference in New Issue
Block a user