mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	Fix npm format script (#261)
This commit is contained in:
		
							parent
							
								
									c5ce910940
								
							
						
					
					
						commit
						ed775cbf31
					
				
					 7 changed files with 126 additions and 132 deletions
				
			
		|  | @ -16,7 +16,7 @@ import { | |||
| import {customTitlebar} from "./main"; | ||||
| import {createSettingsWindow} from "./settings/main"; | ||||
| import os from "os"; | ||||
| import fs from "fs" | ||||
| import fs from "fs"; | ||||
| import path from "path"; | ||||
| export function registerIpc() { | ||||
|     ipcMain.on("get-app-path", (event, arg) => { | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ app.whenReady().then(async () => { | |||
|         } | ||||
|     } | ||||
|     await init(); | ||||
|     await installModLoader() | ||||
|     await installModLoader(); | ||||
|     session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => { | ||||
|         if (permission === "notifications") { | ||||
|             // Approves the permissions request
 | ||||
|  |  | |||
							
								
								
									
										85
									
								
								src/utils.ts
									
										
									
									
									
								
							
							
						
						
									
										85
									
								
								src/utils.ts
									
										
									
									
									
								
							|  | @ -1,10 +1,10 @@ | |||
| import * as fs from "fs"; | ||||
| import {app, dialog, session} from "electron"; | ||||
| import path from "path"; | ||||
| import fetch from "cross-fetch" | ||||
| import extract from "extract-zip" | ||||
| import util from "util" | ||||
| const streamPipeline = util.promisify(require('stream').pipeline) | ||||
| import fetch from "cross-fetch"; | ||||
| import extract from "extract-zip"; | ||||
| import util from "util"; | ||||
| const streamPipeline = util.promisify(require("stream").pipeline); | ||||
| export var firstRun: boolean; | ||||
| export var contentPath: string; | ||||
| export var transparency: boolean; | ||||
|  | @ -77,7 +77,6 @@ export function getDisplayVersion() { | |||
|     } | ||||
| } | ||||
| export async function injectJS(inject: string) { | ||||
|      | ||||
|     const js = await (await fetch(`${inject}`)).text(); | ||||
| 
 | ||||
|     const el = document.createElement("script"); | ||||
|  | @ -125,7 +124,7 @@ export async function injectElectronFlags() { | |||
|             console.log("No performance modes set"); | ||||
|     } | ||||
|     if ((await getConfig("windowStyle")) == "transparent" && process.platform === "win32") { | ||||
|         import("@pyke/vibe").then(vibe => { | ||||
|         import("@pyke/vibe").then((vibe) => { | ||||
|             console.log("Transparent mode enabled"); | ||||
|             vibe.setup(app); | ||||
|             transparency = true; | ||||
|  | @ -287,65 +286,65 @@ export async function checkIfConfigExists() { | |||
| // Mods
 | ||||
| async function updateModBundle() { | ||||
|     try { | ||||
|     console.log("Downloading mod bundle") | ||||
|     const distFolder = app.getPath("userData") + "/plugins/loader/dist/"; | ||||
|     while (!fs.existsSync(distFolder)){ | ||||
|         //waiting
 | ||||
|         console.log("Downloading mod bundle"); | ||||
|         const distFolder = app.getPath("userData") + "/plugins/loader/dist/"; | ||||
|         while (!fs.existsSync(distFolder)) { | ||||
|             //waiting
 | ||||
|         } | ||||
|         var name: string = await getConfig("mods"); | ||||
|         const clientMods = { | ||||
|             vencord: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js", | ||||
|             cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js", | ||||
|             shelter: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js" | ||||
|         }; | ||||
|         var bundle: string = await (await fetch(clientMods[name as keyof typeof clientMods])).text(); | ||||
|         fs.writeFileSync(distFolder + "bundle.js", bundle, "utf-8"); | ||||
|     } catch (e) { | ||||
|         console.log("[Mod loader] Failed to install mods"); | ||||
|         console.error(e); | ||||
|         dialog.showErrorBox( | ||||
|             "Oops, something went wrong.", | ||||
|             "ArmCord couldn't install mods, please check if you have stable internet connection and restart the app. If this issue persists, report it on the support server/Github issues." | ||||
|         ); | ||||
|     } | ||||
|     var name: string = await getConfig("mods") | ||||
|     const clientMods = { | ||||
|         vencord: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js", | ||||
|         cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js", | ||||
|         shelter: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js" | ||||
|     }; | ||||
|     var bundle: string = await (await fetch(clientMods[name as keyof typeof clientMods])).text() | ||||
|     fs.writeFileSync(distFolder + "bundle.js", bundle, "utf-8"); | ||||
| } catch (e) { | ||||
|     console.log("[Mod loader] Failed to install mods") | ||||
|     console.error(e) | ||||
|     dialog.showErrorBox( | ||||
|         "Oops, something went wrong.", | ||||
|         "ArmCord couldn't install mods, please check if you have stable internet connection and restart the app. If this issue persists, report it on the support server/Github issues." | ||||
|     ); | ||||
| } | ||||
| } | ||||
| export var modInstallState: string; | ||||
| export async function installModLoader() { | ||||
|     if (await getConfig("mods") == "none") { | ||||
|         modInstallState = "none" | ||||
|     if ((await getConfig("mods")) == "none") { | ||||
|         modInstallState = "none"; | ||||
|         import("./extensions/plugin"); | ||||
|         console.log("[Mod loader] Skipping") | ||||
|         console.log("[Mod loader] Skipping"); | ||||
|     } else { | ||||
|         const pluginFolder = app.getPath("userData") + "/plugins/"; | ||||
|         if (!fs.existsSync(pluginFolder + "loader")) { | ||||
|             try { | ||||
|                 modInstallState = "installing" | ||||
|                 modInstallState = "installing"; | ||||
|                 var zipPath = app.getPath("temp") + "/" + "loader.zip"; | ||||
|                 if (!fs.existsSync(pluginFolder)) { | ||||
|                     fs.mkdirSync(pluginFolder); | ||||
|                     console.log("[Mod loader] Created missing plugin folder"); | ||||
|                 } | ||||
|                 var loaderZip = await fetch("https://armcord.xyz/loader.zip") | ||||
|                 if (!loaderZip.ok) throw new Error(`unexpected response ${loaderZip.statusText}`) | ||||
|                 await streamPipeline(loaderZip.body, fs.createWriteStream(zipPath)) | ||||
|                 await extract(zipPath, { dir: path.join(app.getPath("userData"), "plugins") }) | ||||
|                 modInstallState = "modDownload" | ||||
|                 updateModBundle() | ||||
|                 var loaderZip = await fetch("https://armcord.xyz/loader.zip"); | ||||
|                 if (!loaderZip.ok) throw new Error(`unexpected response ${loaderZip.statusText}`); | ||||
|                 await streamPipeline(loaderZip.body, fs.createWriteStream(zipPath)); | ||||
|                 await extract(zipPath, {dir: path.join(app.getPath("userData"), "plugins")}); | ||||
|                 modInstallState = "modDownload"; | ||||
|                 updateModBundle(); | ||||
|                 import("./extensions/plugin"); | ||||
|                 modInstallState = "done" | ||||
|             } catch(e) { | ||||
|                 console.log("[Mod loader] Failed to install modloader") | ||||
|                 console.error(e) | ||||
|                 modInstallState = "done"; | ||||
|             } catch (e) { | ||||
|                 console.log("[Mod loader] Failed to install modloader"); | ||||
|                 console.error(e); | ||||
|                 dialog.showErrorBox( | ||||
|                     "Oops, something went wrong.", | ||||
|                     "ArmCord couldn't install internal mod loader, please check if you have stable internet connection and restart the app. If this issue persists, report it on the support server/Github issues." | ||||
|                 ); | ||||
|             } | ||||
|         } else { | ||||
|             modInstallState = "modDownload" | ||||
|             updateModBundle() | ||||
|             modInstallState = "modDownload"; | ||||
|             updateModBundle(); | ||||
|             import("./extensions/plugin"); | ||||
|             modInstallState = "done" | ||||
|             modInstallState = "done"; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ import { | |||
|     setConfig, | ||||
|     setLang, | ||||
|     setWindowState, | ||||
|     transparency, | ||||
|     transparency | ||||
| } from "./utils"; | ||||
| import {registerIpc} from "./ipc"; | ||||
| import {setMenu} from "./menu"; | ||||
|  | @ -51,9 +51,9 @@ contextMenu({ | |||
| }); | ||||
| async function doAfterDefiningTheWindow() { | ||||
|     if (transparency && process.platform === "win32") { | ||||
|         import("@pyke/vibe").then(vibe => { | ||||
|         import("@pyke/vibe").then((vibe) => { | ||||
|             vibe.applyEffect(mainWindow, "acrylic"); | ||||
|             vibe.forceTheme(mainWindow, 'dark'); | ||||
|             vibe.forceTheme(mainWindow, "dark"); | ||||
|             mainWindow.show(); | ||||
|         }); | ||||
|     } | ||||
|  | @ -85,7 +85,7 @@ async function doAfterDefiningTheWindow() { | |||
|     } | ||||
|     mainWindow.webContents.setWindowOpenHandler(({url}) => { | ||||
|         // Allow about:blank (used by Vencord QuickCss popup)
 | ||||
|         if (url === "about:blank") return { action: "allow" }; | ||||
|         if (url === "about:blank") return {action: "allow"}; | ||||
| 
 | ||||
|         if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) { | ||||
|             shell.openExternal(url); | ||||
|  | @ -206,7 +206,7 @@ async function doAfterDefiningTheWindow() { | |||
|     console.log(contentPath); | ||||
|     if ((await getConfig("inviteWebsocket")) == true) { | ||||
|         //@ts-ignore
 | ||||
|         import("arrpc") | ||||
|         import("arrpc"); | ||||
|         //await startServer();
 | ||||
|     } | ||||
|     if (firstRun) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue