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
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
|
@ -9,14 +9,9 @@
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Debug ArmCord via NPM",
|
"name": "Debug ArmCord via NPM",
|
||||||
"runtimeExecutable": "npm",
|
"runtimeExecutable": "npm",
|
||||||
"runtimeArgs": [
|
"runtimeArgs": ["start", "debug"],
|
||||||
"start",
|
|
||||||
"debug",
|
|
||||||
],
|
|
||||||
"port": 9229,
|
"port": 9229,
|
||||||
"skipFiles": [
|
"skipFiles": ["<node_internals>/**"]
|
||||||
"<node_internals>/**"
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@
|
||||||
"startNoSandbox": "npm run build && electron ./ts-out/main.js --no-sandbox",
|
"startNoSandbox": "npm run build && electron ./ts-out/main.js --no-sandbox",
|
||||||
"package": "npm run build && electron-builder",
|
"package": "npm run build && electron-builder",
|
||||||
"packageQuick": "npm run build && electron-builder --dir",
|
"packageQuick": "npm run build && electron-builder --dir",
|
||||||
"format": "prettier --write src/**/*",
|
"format": "prettier --write src *.json",
|
||||||
"CIbuild": "npm run build && electron-builder --linux zip && electron-builder --windows zip && electron-builder --macos zip",
|
"CIbuild": "npm run build && electron-builder --linux zip && electron-builder --windows zip && electron-builder --macos zip",
|
||||||
"prepare": "git config --local core.hooksPath .hooks/"
|
"prepare": "git config --local core.hooksPath .hooks/"
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
import {customTitlebar} from "./main";
|
import {customTitlebar} from "./main";
|
||||||
import {createSettingsWindow} from "./settings/main";
|
import {createSettingsWindow} from "./settings/main";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
import fs from "fs"
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
export function registerIpc() {
|
export function registerIpc() {
|
||||||
ipcMain.on("get-app-path", (event, arg) => {
|
ipcMain.on("get-app-path", (event, arg) => {
|
||||||
|
|
|
@ -52,7 +52,7 @@ app.whenReady().then(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await init();
|
await init();
|
||||||
await installModLoader()
|
await installModLoader();
|
||||||
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
||||||
if (permission === "notifications") {
|
if (permission === "notifications") {
|
||||||
// Approves the permissions request
|
// Approves the permissions request
|
||||||
|
|
61
src/utils.ts
61
src/utils.ts
|
@ -1,10 +1,10 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {app, dialog, session} from "electron";
|
import {app, dialog, session} from "electron";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fetch from "cross-fetch"
|
import fetch from "cross-fetch";
|
||||||
import extract from "extract-zip"
|
import extract from "extract-zip";
|
||||||
import util from "util"
|
import util from "util";
|
||||||
const streamPipeline = util.promisify(require('stream').pipeline)
|
const streamPipeline = util.promisify(require("stream").pipeline);
|
||||||
export var firstRun: boolean;
|
export var firstRun: boolean;
|
||||||
export var contentPath: string;
|
export var contentPath: string;
|
||||||
export var transparency: boolean;
|
export var transparency: boolean;
|
||||||
|
@ -77,7 +77,6 @@ export function getDisplayVersion() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function injectJS(inject: string) {
|
export async function injectJS(inject: string) {
|
||||||
|
|
||||||
const js = await (await fetch(`${inject}`)).text();
|
const js = await (await fetch(`${inject}`)).text();
|
||||||
|
|
||||||
const el = document.createElement("script");
|
const el = document.createElement("script");
|
||||||
|
@ -125,7 +124,7 @@ export async function injectElectronFlags() {
|
||||||
console.log("No performance modes set");
|
console.log("No performance modes set");
|
||||||
}
|
}
|
||||||
if ((await getConfig("windowStyle")) == "transparent" && process.platform === "win32") {
|
if ((await getConfig("windowStyle")) == "transparent" && process.platform === "win32") {
|
||||||
import("@pyke/vibe").then(vibe => {
|
import("@pyke/vibe").then((vibe) => {
|
||||||
console.log("Transparent mode enabled");
|
console.log("Transparent mode enabled");
|
||||||
vibe.setup(app);
|
vibe.setup(app);
|
||||||
transparency = true;
|
transparency = true;
|
||||||
|
@ -287,65 +286,65 @@ export async function checkIfConfigExists() {
|
||||||
// Mods
|
// Mods
|
||||||
async function updateModBundle() {
|
async function updateModBundle() {
|
||||||
try {
|
try {
|
||||||
console.log("Downloading mod bundle")
|
console.log("Downloading mod bundle");
|
||||||
const distFolder = app.getPath("userData") + "/plugins/loader/dist/";
|
const distFolder = app.getPath("userData") + "/plugins/loader/dist/";
|
||||||
while (!fs.existsSync(distFolder)){
|
while (!fs.existsSync(distFolder)) {
|
||||||
//waiting
|
//waiting
|
||||||
}
|
}
|
||||||
var name: string = await getConfig("mods")
|
var name: string = await getConfig("mods");
|
||||||
const clientMods = {
|
const clientMods = {
|
||||||
vencord: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
|
vencord: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
|
||||||
cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js",
|
cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js",
|
||||||
shelter: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.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()
|
var bundle: string = await (await fetch(clientMods[name as keyof typeof clientMods])).text();
|
||||||
fs.writeFileSync(distFolder + "bundle.js", bundle, "utf-8");
|
fs.writeFileSync(distFolder + "bundle.js", bundle, "utf-8");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("[Mod loader] Failed to install mods")
|
console.log("[Mod loader] Failed to install mods");
|
||||||
console.error(e)
|
console.error(e);
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
"Oops, something went wrong.",
|
"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."
|
"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 var modInstallState: string;
|
||||||
export async function installModLoader() {
|
export async function installModLoader() {
|
||||||
if (await getConfig("mods") == "none") {
|
if ((await getConfig("mods")) == "none") {
|
||||||
modInstallState = "none"
|
modInstallState = "none";
|
||||||
import("./extensions/plugin");
|
import("./extensions/plugin");
|
||||||
console.log("[Mod loader] Skipping")
|
console.log("[Mod loader] Skipping");
|
||||||
} else {
|
} else {
|
||||||
const pluginFolder = app.getPath("userData") + "/plugins/";
|
const pluginFolder = app.getPath("userData") + "/plugins/";
|
||||||
if (!fs.existsSync(pluginFolder + "loader")) {
|
if (!fs.existsSync(pluginFolder + "loader")) {
|
||||||
try {
|
try {
|
||||||
modInstallState = "installing"
|
modInstallState = "installing";
|
||||||
var zipPath = app.getPath("temp") + "/" + "loader.zip";
|
var zipPath = app.getPath("temp") + "/" + "loader.zip";
|
||||||
if (!fs.existsSync(pluginFolder)) {
|
if (!fs.existsSync(pluginFolder)) {
|
||||||
fs.mkdirSync(pluginFolder);
|
fs.mkdirSync(pluginFolder);
|
||||||
console.log("[Mod loader] Created missing plugin folder");
|
console.log("[Mod loader] Created missing plugin folder");
|
||||||
}
|
}
|
||||||
var loaderZip = await fetch("https://armcord.xyz/loader.zip")
|
var loaderZip = await fetch("https://armcord.xyz/loader.zip");
|
||||||
if (!loaderZip.ok) throw new Error(`unexpected response ${loaderZip.statusText}`)
|
if (!loaderZip.ok) throw new Error(`unexpected response ${loaderZip.statusText}`);
|
||||||
await streamPipeline(loaderZip.body, fs.createWriteStream(zipPath))
|
await streamPipeline(loaderZip.body, fs.createWriteStream(zipPath));
|
||||||
await extract(zipPath, { dir: path.join(app.getPath("userData"), "plugins") })
|
await extract(zipPath, {dir: path.join(app.getPath("userData"), "plugins")});
|
||||||
modInstallState = "modDownload"
|
modInstallState = "modDownload";
|
||||||
updateModBundle()
|
updateModBundle();
|
||||||
import("./extensions/plugin");
|
import("./extensions/plugin");
|
||||||
modInstallState = "done"
|
modInstallState = "done";
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.log("[Mod loader] Failed to install modloader")
|
console.log("[Mod loader] Failed to install modloader");
|
||||||
console.error(e)
|
console.error(e);
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
"Oops, something went wrong.",
|
"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."
|
"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 {
|
} else {
|
||||||
modInstallState = "modDownload"
|
modInstallState = "modDownload";
|
||||||
updateModBundle()
|
updateModBundle();
|
||||||
import("./extensions/plugin");
|
import("./extensions/plugin");
|
||||||
modInstallState = "done"
|
modInstallState = "done";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
setConfig,
|
setConfig,
|
||||||
setLang,
|
setLang,
|
||||||
setWindowState,
|
setWindowState,
|
||||||
transparency,
|
transparency
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import {registerIpc} from "./ipc";
|
import {registerIpc} from "./ipc";
|
||||||
import {setMenu} from "./menu";
|
import {setMenu} from "./menu";
|
||||||
|
@ -51,9 +51,9 @@ contextMenu({
|
||||||
});
|
});
|
||||||
async function doAfterDefiningTheWindow() {
|
async function doAfterDefiningTheWindow() {
|
||||||
if (transparency && process.platform === "win32") {
|
if (transparency && process.platform === "win32") {
|
||||||
import("@pyke/vibe").then(vibe => {
|
import("@pyke/vibe").then((vibe) => {
|
||||||
vibe.applyEffect(mainWindow, "acrylic");
|
vibe.applyEffect(mainWindow, "acrylic");
|
||||||
vibe.forceTheme(mainWindow, 'dark');
|
vibe.forceTheme(mainWindow, "dark");
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ async function doAfterDefiningTheWindow() {
|
||||||
}
|
}
|
||||||
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||||
// Allow about:blank (used by Vencord QuickCss popup)
|
// 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:"))) {
|
if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) {
|
||||||
shell.openExternal(url);
|
shell.openExternal(url);
|
||||||
|
@ -206,7 +206,7 @@ async function doAfterDefiningTheWindow() {
|
||||||
console.log(contentPath);
|
console.log(contentPath);
|
||||||
if ((await getConfig("inviteWebsocket")) == true) {
|
if ((await getConfig("inviteWebsocket")) == true) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import("arrpc")
|
import("arrpc");
|
||||||
//await startServer();
|
//await startServer();
|
||||||
}
|
}
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
|
|
Loading…
Reference in a new issue