chore: add bb.edn task runner

Tasks: server, cljs, cljs:watch, test, dev (tmux), dev:stop, dev:restart
This commit is contained in:
Florian Schroedl
2026-04-04 16:48:29 +02:00
parent ab68a21dd6
commit d5a0082b67

34
bb.edn Normal file
View File

@@ -0,0 +1,34 @@
{:tasks
{server {:doc "Start the Pocketbook sync server"
:task (shell "clj" "-M:server")}
cljs {:doc "Compile ClojureScript (one-shot)"
:task (shell "clj" "-M:cljs")}
cljs:watch {:doc "Compile ClojureScript (watch mode)"
:task (shell "clj" "-M:cljs-dev")}
test {:doc "Run all server tests"
:task (let [expr (str "(require 'pocketbook.db-test 'pocketbook.transit-test"
" 'pocketbook.server-test 'pocketbook.auth-test)"
" (let [r (clojure.test/run-all-tests #\"pocketbook\\..*\")]"
" (System/exit (if (and (zero? (:fail r)) (zero? (:error r))) 0 1)))")]
(shell "clj" "-M:dev" "-e" expr))}
dev {:doc "Start server and CLJS watch in tmux"
:task (let [dir (System/getProperty "user.dir")]
(shell {:dir dir} "tmux new-session -d -s pocketbook-dev -n server -c" dir)
(shell {:dir dir} "tmux send-keys -t pocketbook-dev:server" "bb server" "Enter")
(shell {:dir dir} "tmux new-window -t pocketbook-dev -n cljs -c" dir)
(shell {:dir dir} "tmux send-keys -t pocketbook-dev:cljs" "bb cljs:watch" "Enter")
(println "🔶 tmux session 'pocketbook-dev' started")
(println " App: http://localhost:8090")
(println " Server: http://localhost:8090/sync")
(println " Attach: tmux attach -t pocketbook-dev"))}
dev:stop {:doc "Stop the dev tmux session"
:task (shell "tmux kill-session -t pocketbook-dev")}
dev:restart {:doc "Restart the dev tmux session"
:task (do (shell {:continue true} "tmux kill-session -t pocketbook-dev")
(run 'dev))}}}