Update generate_helpers_cache.py

This commit is contained in:
MacRimi 2025-06-04 23:25:29 +02:00 committed by GitHub
parent b8bdcf4c71
commit 9f2fc40c76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,8 +40,17 @@ for item in data:
notes = [note.get("text", "") for note in raw.get("notes", []) if isinstance(note, dict)] notes = [note.get("text", "") for note in raw.get("notes", []) if isinstance(note, dict)]
full_script_url = f"{SCRIPT_BASE}/{script}" full_script_url = f"{SCRIPT_BASE}/{script}"
# Append the script metadata to the cache
cache.append({ credentials = raw.get("default_credentials", {})
cred_username = credentials.get("username")
cred_password = credentials.get("password")
add_credentials = (
(cred_username is not None and str(cred_username).strip() != "") or
(cred_password is not None and str(cred_password).strip() != "")
)
entry = {
"name": name, "name": name,
"slug": slug, "slug": slug,
"desc": desc, "desc": desc,
@ -50,7 +59,15 @@ for item in data:
"categories": categories, "categories": categories,
"notes": notes, "notes": notes,
"type": type_ "type": type_
}) }
if add_credentials:
entry["default_credentials"] = {
"username": cred_username,
"password": cred_password
}
cache.append(entry)
# Write the JSON cache to disk # Write the JSON cache to disk
with open(OUTPUT_FILE, "w", encoding="utf-8") as f: with open(OUTPUT_FILE, "w", encoding="utf-8") as f: