scittle/bb.edn
Michiel Borkent a049c8eddb Bump version
2022-08-31 17:32:52 +02:00

69 lines
2.9 KiB
Clojure

{:deps {io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/sha "c14b5b4ef4390ff206cdb71f763f327799f5e853"}
io.github.babashka/http-server
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
:tasks
{:requires ([babashka.fs :as fs]
[cheshire.core :as json]
[babashka.process :as p :refer [process]])
clean {:doc "Start from clean slate."
:task (do (run! fs/delete (fs/list-dir (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 (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
"-M:dev -m shadow.cljs.devtools.cli watch main")}
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 (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
"-M:dev -m shadow.cljs.devtools.cli release main")}
dist {:doc "Prepare dist folder for npm package"
:depends [prod]
:task (do
(fs/delete-tree "dist")
(fs/create-dirs "dist")
(run! (fn [f] (fs/copy f "dist"))
(fs/glob "resources/public/js" "*.js")))}
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."
:task
(let [[prev next] *command-line-args*]
(-> (process ["bash" "-c"
(format "rg %s --files-with-matches | 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")}}}