karax_components.nimble 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Package
  2. version = "0.1.0"
  3. author = "NerdRat"
  4. description = "A reservoir of useful karax components for SPA's."
  5. license = "GPL-3.0"
  6. srcDir = "src"
  7. bin = @["karax_components"]
  8. # Dependencies
  9. requires "nim >= 1.0.0", "karax >= 1.1.0", "jester >= 0.4.3"
  10. proc logMessage(message: string) =
  11. echo "\e[1;37m[\e[m\e[1;32mINFO\e[m\e[1;37m]\e[m: $1." % [message]
  12. task clean, "Clean all produced files and directories.":
  13. logMessage("Cleaning build files")
  14. if dirExists("public"):
  15. rmDir("public")
  16. logMessage("Removed dir public")
  17. if fileExists(bin[0]):
  18. rmFile(bin[0])
  19. logMessage("Removed binary $1" % [bin[0]])
  20. if fileExists("assets"):
  21. rmFile("assets")
  22. logMessage("Removed assets")
  23. task getAssets, "Install external frontend assets.":
  24. logMessage("Getting external assets")
  25. exec "nimble c src/assets.nim -d:ssl -o:./assets"
  26. exec "./assets"
  27. logMessage("Finished downloading assets")
  28. task buildFrontend, "Build frontend files.":
  29. logMessage("Building frontend")
  30. if not dirExists("public"):
  31. getAssetsTask()
  32. # Build frontend files in src dir.
  33. exec "nimble js --o:public/js/app.js src/client/index.nim"
  34. logMessage("Finished building frontend")
  35. task buildAll, "Build backend and frontend.":
  36. logMessage("Building everything")
  37. cleanTask()
  38. buildFrontendTask()
  39. exec("nimble build")
  40. logMessage("Built everything")