File size: 642 Bytes
a709b7a
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
"""Write app/manifest.json: the files index.html hands to stlite, plus a cache-busting build id."""
import hashlib, json
from pathlib import Path

APP = Path(__file__).resolve().parents[1] / "app"
files = sorted(str(p.relative_to(APP)) for p in APP.rglob("*")
               if p.is_file() and p.suffix in {".py", ".json", ".txt"} and "__pycache__" not in p.parts
               and p.name != "manifest.json")
h = hashlib.sha256(b"".join((APP / f).read_bytes() for f in files)).hexdigest()[:12]
(APP / "manifest.json").write_text(json.dumps({"build": h, "requirements": [], "files": files}, indent=1))
print(f"{len(files)} files, build {h}")