japji/bb.edn
2025-09-01 12:49:14 +01:00

78 lines
3.2 KiB
Clojure

{:deps {io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}
io.github.babashka/http-server
{:git/tag "v0.1.14"
:git/sha "4af3c76"}
io.github.scittle/build
{:local/root "build"}}
:tasks
{:requires ([scittle.build :as build]
[babashka.fs :as fs]
[cheshire.core :as json]
[babashka.process :as p :refer [process]])
clean {:doc "Start from clean slate."
:task (do (fs/delete-tree (fs/file "resources" "public" "js"))
(fs/delete-tree ".cpcache")
(fs/delete-tree ".shadow-cljs"))}
shadow:watch {:doc "Development build. Starts webserver and watches for changes."
:task (build/build {:action "watch"
:args *command-line-args*})}
http-server {:doc "Starts http server for serving static files"
:requires ([babashka.http-server :as http])
:task (do (http/serve {:port 1341 :dir "resources/public"})
(println "Serving static assets at http://localhost:1341"))}
browser-nrepl {:doc "Start browser nREPL"
:requires ([sci.nrepl.browser-server :as bp])
:task (bp/start! {})}
-dev {:depends [shadow:watch browser-nrepl http-server]}
dev {:doc "Development build. Starts webserver and watches for changes."
:task (do (run '-dev {:parallel true})
(deref (promise)))}
prod {:doc "Builds production artifacts."
:task (build/build {})
:depends [clean]}
dist {:doc "Prepare dist folder for npm package"
:depends [prod]
:task (do
(fs/delete-tree "dist")
(fs/create-dirs "dist/dev")
(run! (fn [f] (fs/copy f "dist" {:replace-existing true}))
(fs/glob "resources/public/js" "*.{js,js.map}"))
(run! (fn [f] (fs/copy f "dist/dev" {:replace-existing true}))
(fs/glob "resources/public/js/dev" "*.{js,js.map}")))}
bump-version {:doc "Bumps package.json and pushes new git tag"
:task (do (shell "npm version patch")
(shell "git push --atomic origin main"
(str "v" (:version (json/parse-string (slurp "package.json") true)))))}
npm-publish {:doc "Updates NPM ibrary"
:task (do (run 'dist)
(run 'bump-version)
(shell "npm publish"))}
replace-version {:doc "Ported from bash one-liners. Expects two versions.
TODO: port to Clojure.
TODO: skip changelog.md
"
:task
(let [[prev next] *command-line-args*]
(-> (process ["bash" "-c"
(format "rg %s --files-with-matches -g '!/CHANGELOG.md' | xargs sed -i '' 's/%s/%s/g'"
prev prev next)]
{:inherit true})
p/check))}
gh-pages {:doc "Updates Github pages with new release build."
:task (shell "script/release.clj")}}}