make.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/python
  2. from pathlib import Path
  3. from json import loads
  4. from shutil import rmtree
  5. from shutil import copytree
  6. from cx_maketool import sass_compiler
  7. from cx_maketool import esbuild_compiler
  8. from cx_maketool import render
  9. from cx_maketool import script
  10. from cx_maketool import link
  11. root = Path(__file__).absolute().parent
  12. source = root / Path("source/")
  13. build = root / Path("./")
  14. styles = source / Path("stylesheet/")
  15. scripts = source / Path("scripts/")
  16. assets = source / Path("assets/")
  17. assets_output = build / Path("assets/")
  18. scripts_loader = scripts / Path("core.js")
  19. theme_loader = styles / Path("core.sass")
  20. info_file = source / Path("about.txt")
  21. script_bundle = build / Path("script.js")
  22. theme_bundle = build / Path("style.css")
  23. if theme_bundle.is_file():
  24. theme_bundle.unlink()
  25. if script_bundle.is_file():
  26. script_bundle.unlink()
  27. sass_compiler(theme_loader).build(theme_bundle)
  28. esbuild_compiler(scripts_loader).build(script_bundle)
  29. if assets_output.exists():
  30. rmtree(assets_output)
  31. copytree(assets, assets_output)
  32. with info_file.open() as info:
  33. info_content = info.read()
  34. with theme_bundle.open() as theme:
  35. content = theme.read()
  36. with theme_bundle.open("w") as theme:
  37. theme.write(info_content + content)