mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-18 02:43:00 +08:00
feat: Install via git url
This commit is contained in:
parent
78183e009d
commit
84979f6438
@ -198,7 +198,7 @@ NODE_CLASS_MAPPINGS.update({
|
|||||||
- [x] Specification scanner
|
- [x] Specification scanner
|
||||||
- [x] workflow download -> workflow gallery
|
- [x] workflow download -> workflow gallery
|
||||||
- [x] Search extension by node name -> [ltdrdata.github.io](https://ltdrdata.github.io)
|
- [x] Search extension by node name -> [ltdrdata.github.io](https://ltdrdata.github.io)
|
||||||
- [ ] installation from git url
|
- [x] installation from git url
|
||||||
|
|
||||||
|
|
||||||
# Disclaimer
|
# Disclaimer
|
||||||
|
|||||||
31
__init__.py
31
__init__.py
@ -11,8 +11,9 @@ import subprocess # don't remove this
|
|||||||
from tqdm.auto import tqdm
|
from tqdm.auto import tqdm
|
||||||
import concurrent
|
import concurrent
|
||||||
import ssl
|
import ssl
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
version = "V0.41"
|
version = "V0.42"
|
||||||
print(f"### Loading: ComfyUI-Manager ({version})")
|
print(f"### Loading: ComfyUI-Manager ({version})")
|
||||||
|
|
||||||
|
|
||||||
@ -990,10 +991,20 @@ class GitProgress(RemoteProgress):
|
|||||||
self.pbar.pos = 0
|
self.pbar.pos = 0
|
||||||
self.pbar.refresh()
|
self.pbar.refresh()
|
||||||
|
|
||||||
|
def is_valid_url(url):
|
||||||
|
try:
|
||||||
|
result = urlparse(url)
|
||||||
|
return all([result.scheme, result.netloc])
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
def gitclone_install(files):
|
def gitclone_install(files):
|
||||||
print(f"install: {files}")
|
print(f"install: {files}")
|
||||||
for url in files:
|
for url in files:
|
||||||
|
if not is_valid_url(url):
|
||||||
|
print(f"Invalid git url: '{url}'")
|
||||||
|
return False
|
||||||
|
|
||||||
if url.endswith("/"):
|
if url.endswith("/"):
|
||||||
url = url[:-1]
|
url = url[:-1]
|
||||||
try:
|
try:
|
||||||
@ -1003,7 +1014,9 @@ def gitclone_install(files):
|
|||||||
|
|
||||||
# Clone the repository from the remote URL
|
# Clone the repository from the remote URL
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
run_script([sys.executable, git_script_path, "--clone", custom_nodes_path, url])
|
res = run_script([sys.executable, git_script_path, "--clone", custom_nodes_path, url])
|
||||||
|
if res != 0:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress())
|
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress())
|
||||||
repo.git.clear_cache()
|
repo.git.clear_cache()
|
||||||
@ -1196,6 +1209,20 @@ async def install_custom_node(request):
|
|||||||
return web.Response(status=400)
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
|
||||||
|
@server.PromptServer.instance.routes.get("/customnode/install/git_url")
|
||||||
|
async def install_custom_node_git_url(request):
|
||||||
|
res = False
|
||||||
|
if "url" in request.rel_url.query:
|
||||||
|
url = request.rel_url.query['url']
|
||||||
|
res = gitclone_install([url])
|
||||||
|
|
||||||
|
if res:
|
||||||
|
print(f"After restarting ComfyUI, please refresh the browser.")
|
||||||
|
return web.Response(status=200)
|
||||||
|
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
|
||||||
@server.PromptServer.instance.routes.post("/customnode/uninstall")
|
@server.PromptServer.instance.routes.post("/customnode/uninstall")
|
||||||
async def uninstall_custom_node(request):
|
async def uninstall_custom_node(request):
|
||||||
json_data = await request.json()
|
json_data = await request.json()
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { CustomNodesInstaller } from "./custom-nodes-downloader.js";
|
|||||||
import { AlternativesInstaller } from "./a1111-alter-downloader.js";
|
import { AlternativesInstaller } from "./a1111-alter-downloader.js";
|
||||||
import { SnapshotManager } from "./snapshot.js";
|
import { SnapshotManager } from "./snapshot.js";
|
||||||
import { ModelInstaller } from "./model-downloader.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');
|
var style = document.createElement('style');
|
||||||
style.innerHTML = `
|
style.innerHTML = `
|
||||||
@ -372,6 +372,17 @@ class ManagerMenuDialog extends ComfyDialog {
|
|||||||
SnapshotManager.instance.show();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
31
js/common.js
31
js/common.js
@ -60,3 +60,34 @@ export var manager_instance = null;
|
|||||||
export function setManagerInstance(obj) {
|
export function setManagerInstance(obj) {
|
||||||
manager_instance = 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user