1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/usr/bin/env python
import json
import os
import subprocess
CLIENT_TYPE = os.environ.get("TRAME_CLIENT_TYPE", "vue3")
def run(apps_path, out_path):
# Generate www content
cmd = [
"python",
"-m",
"trame.tools.www",
"--output",
out_path,
"--client-type",
CLIENT_TYPE,
]
subprocess.run(cmd)
# Generate app files index.html => {app_name}.html
with open(apps_path, "r") as rf:
apps_dict = json.load(rf) # noqa
for app_name, config in apps_dict.items():
# handle custom modules for www
web_modules = config.get("www_modules")
client_type = config.get("client_type", CLIENT_TYPE)
if web_modules is not None:
cmd = [
"python",
"-m",
"trame.tools.www",
"--output",
out_path,
"--client-type",
client_type,
*web_modules,
]
subprocess.run(cmd)
# Create app.html file from index.html
cmd = [
"python",
"-m",
"trame.tools.app",
"--input",
out_path,
"--name",
app_name,
]
subprocess.run(cmd)
if __name__ == "__main__":
apps_path = "/opt/trame/apps.json"
out_path = "/deploy/server/www"
run(apps_path, out_path)
|