#!/bin/python from pathlib import Path from json import loads from shutil import rmtree from shutil import copytree from shutil import copy from maketool import sass_compiler from maketool import esbuild_compiler from maketool import render from maketool import script from maketool import link root = Path(__file__).absolute().parent source = root / Path("application/") build = root / Path("static/") views = source / Path("views/") styles = source / Path("theme/") scripts = source / Path("scripts/") assets = source / Path("assets/") bundle = build / Path("bundle/") assets_output = build / Path("assets/") scripts_loader = scripts / Path("core.js") theme_loader = styles / Path("core.sass") script_bundle = bundle / Path("app.js") theme_bundle = bundle / Path("theme.css") if build.exists(): rmtree(build) build.mkdir() bundle.mkdir() sass_compiler(theme_loader).build(theme_bundle) esbuild_compiler(scripts_loader).build(script_bundle) copytree(assets, assets_output) for view in views.iterdir(): if not view.is_file(): continue if str(view.suffix) != ".html": continue copy(view, build / Path(view.name))