108 lines
3.2 KiB
Python
108 lines
3.2 KiB
Python
"""Fetch only fixed official source text and identities; never import upstream."""
|
|
|
|
import hashlib
|
|
import json
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
OUT = Path(__file__).resolve().parent.parent / "sdpose-reference"
|
|
FILES = {
|
|
"core0150": (
|
|
"ComfyUI",
|
|
"v0.15.0",
|
|
[
|
|
"LICENSE",
|
|
"nodes.py",
|
|
"comfy_extras/nodes_post_processing.py",
|
|
"comfy_api/latest/_io.py",
|
|
"comfy/utils.py",
|
|
],
|
|
),
|
|
"core0151": (
|
|
"ComfyUI",
|
|
"v0.15.1",
|
|
[
|
|
"LICENSE",
|
|
"comfy_extras/nodes_video.py",
|
|
"comfy_api/latest/_util/video_types.py",
|
|
"comfy_api/latest/_util/__init__.py",
|
|
"comfy_api/latest/_input_impl/video_types.py",
|
|
"comfy_api/latest/_input/video_types.py",
|
|
"folder_paths.py",
|
|
],
|
|
),
|
|
"frontend": (
|
|
"ComfyUI_frontend",
|
|
"v1.39.19",
|
|
[
|
|
"LICENSE",
|
|
"src/lib/litegraph/src/LGraphNode.ts",
|
|
"src/utils/executionUtil.ts",
|
|
"src/core/graph/widgets/dynamicWidgets.ts",
|
|
"src/renderer/extensions/vueNodes/widgets/composables/useImageUploadWidget.ts",
|
|
"src/extensions/core/noteNode.ts",
|
|
"src/lib/litegraph/src/widgets/BaseWidget.ts",
|
|
],
|
|
),
|
|
}
|
|
|
|
|
|
def get(url):
|
|
return urllib.request.urlopen(
|
|
urllib.request.Request(url, headers={"User-Agent": "source-reference"}), timeout=30
|
|
).read()
|
|
|
|
|
|
def write(name, data):
|
|
(OUT / name).write_bytes(data)
|
|
return hashlib.sha256(data).hexdigest()
|
|
|
|
|
|
def main():
|
|
identities = []
|
|
sources = []
|
|
for key, (repo, tag, files) in FILES.items():
|
|
url = f"https://api.github.com/repos/Comfy-Org/{repo}/git/ref/tags/{tag}"
|
|
raw = get(url)
|
|
data = json.loads(raw)
|
|
commit = data["object"]["sha"]
|
|
assert data["object"]["type"] == "commit"
|
|
sh = write(key + "-tag.json", raw)
|
|
cu = f"https://api.github.com/repos/Comfy-Org/{repo}/git/commits/{commit}"
|
|
ch = write(key + "-commit.json", get(cu))
|
|
identities.append(
|
|
dict(
|
|
repo=key,
|
|
upstream=repo,
|
|
tag=tag,
|
|
commit=commit,
|
|
tag_url=url,
|
|
tag_sha256=sh,
|
|
commit_url=cu,
|
|
commit_record_sha256=ch,
|
|
installed_or_executed=False,
|
|
)
|
|
)
|
|
for file in files:
|
|
url = f"https://raw.githubusercontent.com/Comfy-Org/{repo}/{commit}/{file}"
|
|
local = key + "__" + file.replace("/", "__")
|
|
sha = write(local, get(url))
|
|
sources.append(
|
|
dict(
|
|
id=key,
|
|
repo="Comfy-Org/" + repo,
|
|
file=file,
|
|
commit=commit,
|
|
url=url,
|
|
local_file=local,
|
|
sha256=sha,
|
|
)
|
|
)
|
|
print(key, tag, commit, flush=True)
|
|
(OUT / "identity.json").write_text(json.dumps(identities, indent=2) + "\n")
|
|
(OUT / "sources.json").write_text(json.dumps(dict(sources=sources), indent=2) + "\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|