feat: Install via git url

This commit is contained in:
Dr.Lt.Data
2023-11-08 13:24:26 +09:00
parent 78183e009d
commit 84979f6438
4 changed files with 73 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import { CustomNodesInstaller } from "./custom-nodes-downloader.js";
import { AlternativesInstaller } from "./a1111-alter-downloader.js";
import { SnapshotManager } from "./snapshot.js";
import { ModelInstaller } from "./model-downloader.js";
import { manager_instance, setManagerInstance } from "./common.js";
import { manager_instance, setManagerInstance, install_via_git_url } from "./common.js";
var style = document.createElement('style');
style.innerHTML = `
@@ -372,6 +372,17 @@ class ManagerMenuDialog extends ComfyDialog {
SnapshotManager.instance.show();
}
}),
$el("button", {
type: "button",
textContent: "Install via Git URL",
onclick: () => {
var url = prompt("Please enter the URL of the Git repository to install", "");
if (url !== null) {
install_via_git_url(url);
}
}
}),
];
}

View File

@@ -59,4 +59,35 @@ export var manager_instance = null;
export function setManagerInstance(obj) {
manager_instance = obj;
}
function isValidURL(url) {
const pattern = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
return pattern.test(url);
}
export async function install_via_git_url(url) {
if(!url) {
return;
}
if(!isValidURL(url)) {
app.ui.dialog.show(`Invalid Git url '${url}'`);
app.ui.dialog.element.style.zIndex = 10010;
return;
}
app.ui.dialog.show(`Wait...<BR><BR>Installing '${url}'`);
app.ui.dialog.element.style.zIndex = 10010;
const res = await api.fetchApi(`/customnode/install/git_url?url=${url}`);
if(res.status == 200) {
app.ui.dialog.show(`'${url}' is installed<BR>To apply the installed/disabled/enabled custom node, please restart ComfyUI.`);
app.ui.dialog.element.style.zIndex = 10010;
}
else {
app.ui.dialog.show(`Failed to install '${url}'<BR>See terminal log.`);
app.ui.dialog.element.style.zIndex = 10010;
}
}