diff --git a/src/equicordplugins/userpluginInstaller.dev/index.tsx b/src/equicordplugins/userpluginInstaller.dev/index.tsx index 98e884661..b0919edf6 100644 --- a/src/equicordplugins/userpluginInstaller.dev/index.tsx +++ b/src/equicordplugins/userpluginInstaller.dev/index.tsx @@ -95,6 +95,8 @@ export default definePlugin({ cancelText: "Later" }); + await Native.ensurePluginsDirectory(); + plSettings.customEntries.push(this.section); this.pluginsWithUpdates.registerCallback((value, id) => { diff --git a/src/equicordplugins/userpluginInstaller.dev/native.ts b/src/equicordplugins/userpluginInstaller.dev/native.ts index 1203b4a85..579190072 100644 --- a/src/equicordplugins/userpluginInstaller.dev/native.ts +++ b/src/equicordplugins/userpluginInstaller.dev/native.ts @@ -8,7 +8,7 @@ import { NativeSettings } from "@main/settings"; import { exec, spawn } from "child_process"; import { BrowserWindow, dialog, shell, WebContentsView } from "electron"; import { existsSync, readdirSync, readFileSync } from "fs"; -import { readdir, readFile, rm } from "fs/promises"; +import { mkdir, readdir, readFile, rm } from "fs/promises"; import { basename, join } from "path"; import yaml from "yaml-js"; @@ -19,12 +19,19 @@ import setGitPathContent from "./misc/setGitPath.txt"; // @ts-ignore fuck off import updateValidateContent from "./misc/updateValidate.txt"; // see above -const PLUGIN_META_REGEX = /export default definePlugin\((?:\s|\/(?:\/|\*).*)*{\s*(?:\s|\/(?:\/|\*).*)*name:\s*(?:"|'|`)(.*)(?:"|'|`)(?:\s|\/(?:\/|\*).*)*,(?:\s|\/(?:\/|\*).*)*(?:\s|\/(?:\/|\*).*)*description:\s*(?:"|'|`)(.*)(?:"|'|`)(?:\s|\/(?:\/|\*).*)*/; +const PLUGIN_META_REGEX = /export default definePlugin\((?:\s|\/(?:\/|\*).*)*{\s*(?:\s|\/(?:\/|\*).*)*name:\s*(?:"|'|`)(.*)(?:"|'|`)(?:\s|\/(?:\/|\*).*)*,(?:\s|\/(?:\/|\*).*)*.+(?:\s|\/(?:\/|\*).*)*description:\s*(?:"|'|`)(.*)(?:"|'|`)(?:\s|\/(?:\/|\*).*)*/; // if edited, also edit in misc/constants.ts!!! const CLONE_LINK_REGEX = /https:\/\/(?:((?:git(?:hub|lab)\.com|git\.(?:[a-zA-Z0-9]|\.)+|codeberg\.org))\/(?!user-attachments)((?:[a-zA-Z0-9]|-)+)\/((?:[a-zA-Z0-9]|-|\.)+)(?:\.git)?|(plugins\.(nin0)\.dev)\/((?:[a-zA-Z0-9]|-|\.)+))(?:\/)?/; const vencordPath = ["desktop", "equibop"].includes(basename(__dirname)) ? join(__dirname, "../") : __dirname; +export async function ensurePluginsDirectory(_: any) { + if (!IS_DEV) return; + try { + await mkdir(join(vencordPath, "../src/userplugins"), { recursive: true }); + } catch(e) { } +} + export async function rmPlugin(_, name: string): Promise { // eslint-disable-next-line return new Promise(async (resolve, reject) => { diff --git a/src/equicordplugins/userpluginInstaller.dev/yaml-js.d.ts b/src/equicordplugins/userpluginInstaller.dev/yaml-js.d.ts new file mode 100644 index 000000000..0119167a7 --- /dev/null +++ b/src/equicordplugins/userpluginInstaller.dev/yaml-js.d.ts @@ -0,0 +1,9 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2026 nin0 + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +declare module "yaml-js" { + export function load(yaml: string): any; +}