Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
398c8c4adc | ||
|
|
2b265aaf40 | ||
|
|
9567209ce4 | ||
|
|
a83c0f82ea | ||
|
|
a13030b96b |
+41
@@ -2,6 +2,7 @@ import asyncio
|
||||
import filecmp
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -290,6 +291,46 @@ _LOCALES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "locale
|
||||
_ALLOWED_LOCALE_FILES = {"main.json", "settings.json"}
|
||||
|
||||
|
||||
def _get_extension_build_info():
|
||||
"""Read the package version and the checked-out Git commit for the About panel."""
|
||||
version = "unknown"
|
||||
commit = "unknown"
|
||||
|
||||
try:
|
||||
pyproject_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pyproject.toml")
|
||||
with open(pyproject_path, "r", encoding="utf-8") as f:
|
||||
pyproject = f.read()
|
||||
project_match = re.search(r"(?ms)^\[project\]\s*(.*?)(?=^\[|\Z)", pyproject)
|
||||
if project_match:
|
||||
version_match = re.search(r'(?m)^\s*version\s*=\s*"([^"]+)"', project_match.group(1))
|
||||
if version_match:
|
||||
version = version_match.group(1)
|
||||
except (OSError, UnicodeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", "rev-parse", "--short=7", "HEAD"],
|
||||
cwd=os.path.dirname(os.path.realpath(__file__)),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
timeout=2
|
||||
)
|
||||
candidate = result.stdout.strip()
|
||||
if re.fullmatch(r"[0-9a-fA-F]{7,40}", candidate):
|
||||
commit = candidate[:7]
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
pass
|
||||
|
||||
return {"version": version, "commit": commit}
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/comfy-sidebar/version")
|
||||
async def version_handler(request):
|
||||
return web.json_response(_get_extension_build_info())
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/comfy-sidebar/locales/{lang}/{filename}")
|
||||
async def locale_file_handler(request):
|
||||
lang = request.match_info.get("lang", "").strip()
|
||||
|
||||
@@ -19,6 +19,28 @@ import { getScrollContainer } from "./utils/utils.js";
|
||||
import { store } from "./core/store.js";
|
||||
import { getSetting, setSetting } from "./core/settings.js";
|
||||
|
||||
// The About panel supports extension-provided badges. Resolve build metadata before
|
||||
// registering the extension so the badge is part of its initial registration.
|
||||
let aboutPageBadges = [];
|
||||
try {
|
||||
const response = await fetch("/comfy-sidebar/version", { cache: "no-store" });
|
||||
if (response.ok) {
|
||||
const { version, commit } = await response.json();
|
||||
if (version && version !== "unknown") {
|
||||
const hasCommit = typeof commit === "string" && /^[0-9a-f]{7}$/i.test(commit);
|
||||
aboutPageBadges = [{
|
||||
label: `Comfy Sidebar v${version}${hasCommit ? ` (${commit})` : ""}`,
|
||||
url: hasCommit
|
||||
? `https://github.com/m0rtus59/ComfyUI-ComfySidebar/commit/${commit}`
|
||||
: "https://github.com/m0rtus59/ComfyUI-ComfySidebar",
|
||||
icon: "icon-[lucide--github]"
|
||||
}];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("[ComfySidebar] Could not load version information for the About panel:", error);
|
||||
}
|
||||
|
||||
let isInitialized = false;
|
||||
let activeKeydownHandler = null;
|
||||
let cleanupFns = [];
|
||||
@@ -301,6 +323,7 @@ function setupWorkflowTabsPositionWatcher() {
|
||||
|
||||
app.registerExtension({
|
||||
name: "ComfySidebar.ClassicRestore",
|
||||
aboutPageBadges,
|
||||
|
||||
async init() {
|
||||
await initI18n();
|
||||
|
||||
Reference in New Issue
Block a user