This commit is contained in:
nin0 2024-11-01 15:36:58 -04:00
parent 9a83a6a012
commit 925e5ec850
No known key found for this signature in database
GPG key ID: 3FA8F96ABAE04214
5 changed files with 246 additions and 11 deletions

View file

@ -6,11 +6,15 @@ import { Button, ChannelStore, Forms, Toasts } from "@webpack/common";
import { Message } from "discord-types/general";
import { clone } from "lodash";
import UserpluginInstallButton from "./UserpluginInstallButton";
import { showInstallModal } from "./UserpluginInstallModal";
import "./style.css";
export let plugins: any[] = [];
export 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)?(?:\/)?/;
// @ts-ignore
const Native = VencordNative.pluginHelpers.UserpluginInstaller as PluginNative<typeof import("./native")>;
export const Native = VencordNative.pluginHelpers.UserpluginInstaller as PluginNative<typeof import("./native")>;
export async function clonePlugin(gitLink: RegExpMatchArray) {
Toasts.show({
@ -19,7 +23,11 @@ export async function clonePlugin(gitLink: RegExpMatchArray) {
type: Toasts.Type.MESSAGE
});
try {
const clonedRepo = await Native.cloneRepo(gitLink[0], `${VesktopNative.fileManager.getVencordDir().replace("\\", "/")}/../src/userplugins/${gitLink[1]}`);
const path = `${VesktopNative.fileManager.getVencordDir().replace("\\", "/")}/../src/userplugins/${gitLink[1]}`;
const clonedRepo = await Native.cloneRepo(gitLink[0], path);
const meta = await Native.getPluginMeta(path);
console.log(meta);
showInstallModal(meta, path);
}
catch (e) {
Toasts.pop();
@ -35,7 +43,9 @@ export default definePlugin({
name: "UserpluginInstaller",
description: "Install userplugins with a simple button click",
authors: [Devs.nin0dev],
start() {
async start() {
plugins = await Native.getPlugins(`${VesktopNative.fileManager.getVencordDir().replace("\\", "/")}/../src/userplugins/`);
console.log(plugins);
addAccessory("userpluginInstallButton", (props: Record<string, any>) => (
<UserpluginInstallButton props={props} />
), 4);