File: examples/companions/bundle-store/build_store.py (75 lines)
#!/usr/bin/env python3
"""Build store.json for the bundle-store example from plugin folders.
usage:
build_store.py PLUGINS_DIR BASE_URL > store.json
PLUGINS_DIR folder containing one subfolder per plugin (like examples/plugins)
BASE_URL public URL of PLUGINS_DIR, e.g.
https://raw.githubusercontent.com/YOU/YOUR-REPO/main/examples/plugins
(pin it to a tag or commit for immutable releases)
Each plugin needs a manifest.json with name == folder name and an X.Y.Z version.
"files" in the manifest lists what gets installed; without it, the standard
files that exist are used.
"""
import json
import pathlib
import re
import sys
STANDARD = ["manifest.json", "device.json", "plugin.js", "README.md"]
VERSION = re.compile(r"^\d+\.\d+\.\d+$")
def as_csv(value):
"""Catalog rows want comma-separated strings, manifests may use arrays."""
if isinstance(value, list):
return ",".join(str(v) for v in value)
return value