-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
217 lines (181 loc) · 8.37 KB
/
bb.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
{:paths ["src" "test" "resources"]
:deps {
org.babashka/cli {:mvn/version "0.7.53"}
babashka/fs {:mvn/version "0.4.19"}
metosin/malli {:mvn/version "0.13.0"}
com.lambdaisland/specmonstah-malli {:mvn/version "0.0.7"}
aero/aero {:mvn/version "1.1.6"}
teknql/systemic {:git/sha "2c0be3a90884f998a61f2a8174cff3c5a15a30bf"
:git/url "https://github.com/teknql/systemic"}
wing/wing {:git/sha "08288f4ae6837b5fe386a321361b7b910bc00660"
:git/url "https://github.com/teknql/wing"}
;; found these in specmonstah's bb.edn: https://github.com/reifyhealth/specmonstah/blob/develop/bb.edn
org.clojure/core.specs.alpha {:mvn/version "0.2.62"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
russmatney/org-crud {:git/url "https://github.com/russmatney/org-crud"
:git/sha "08279ca901ab6ec243faee1fb09442613999bd54"}
zprint/zprint {:mvn/version "1.2.7"}}
:tasks
{:requires ([clojure.string :as string]
[clojure.pprint :as pprint]
[clojure.tools.logging :as log]
[babashka.fs :as fs]
[babashka.process :as p]
[logger :refer [log]])
:enter (println "Entering:" (:name (current-task)))
:init
(do
(log "Clawe bb.edn running")
(def doctor-fe-url "http://localhost:3333")
(def clove-exec "clove") ;; installed from russmatney/clove
(defn env [s] (System/getenv s))
(defn home-dir []
(-> (shell {:out :string}
"zsh -c 'echo -n ~'")
:out))
(defn pp [x]
(binding [pprint/*print-right-margin* 130]
(pprint/pprint x)))
(defn shelll
([args]
(shelll nil args))
([opts args]
(pp args)
(shell opts args)))
(defn run-doctor-tauri-app
([name] (run-doctor-tauri-app nil name))
([opts name]
(let [url (:url opts (str doctor-fe-url "/" name))
title (str "tauri-doctor-" name)
label name
cmd (str clove-exec " create-window"
" --title " title " --label " label " --url " url
" --transparent"
(when (:decorations opts) " --decorations"))]
(pp (str "Running clove app: " cmd))
(shell {:dir (str (home-dir) "/russmatney/clawe")
:extra-env {"WEBKIT_DISABLE_DMABUF_RENDERER" "1"}} cmd)))))
home (pp (home-dir))
clj-kondo (shell "clj-kondo --lint src")
clj-kondo-test (shell "clj-kondo --lint test")
clj-kondo-all (shell "clj-kondo --lint src:test")
lint (shell "clj-kondo --lint src:test")
test-unit
{:doc "Run bb unit tests."
:task (shell "./test_runner.clj")}
test-jvm-unit
{:doc "Run jvm unit tests."
:task (shell "./bin/kaocha unit")}
test-cljs-unit
{:doc "Run cljs unit tests."
:task (clojure "-M:oli-test:full-stack-deps")}
test {:doc "Run all test suites"
:task
(do
(run 'test-unit)
(run 'test-jvm-unit)
(run 'test-cljs-unit))}
;; test-kaocha {:task (let [args *command-line-args*])}
clawe-install
{:doc "Rebuild the clawe uberjar"
:task (let [cp (-> ^{:out :string} (p/$ clojure -A:remove-clojure -Spath) p/check :out)]
(shell (str "bb -cp " cp " --uberjar clawe.jar -m clawe.core")))}
install-clawe {:depends [clawe-install]}
outdated (clojure "-M:full-stack-deps:outdated")
dev-doctor
{:doc "Assess the local environment for any issues"
:task
(do
(shell "systemctl --no-pager --user status doctor-be doctor-fe doctor-topbar")
(pp "TODO impl ensure local symlinks")
(pp "TODO impl ensure `clove` is installed"))}
dev-deps
{:doc "Perform any install and build steps required for development"
:task
;; build towards a dev-env doctor command
(do
;; install yarn deps
(shelll "yarn install")
;; local symlinks
(log/info "TODO impl ensure local symlinks (eg: ln -s ~/Screenshots public/assets/screenshots)")
(shelll "l public/assets"))}
doctor-be {:doc "Run the doctor backend."
:task
(shelll {:dir (str (home-dir) "/russmatney/clawe")}
"clj -M:dev:full-stack-deps:doctor-server")}
doctor-fe {:doc "Run the doctor frontend shadowcljs server."
:task
(shelll {:dir (str (home-dir) "/russmatney/clawe")}
"npx shadow-cljs watch doctor-app")}
clawe-be {:doc "Run the doctor backend."
:task
(run '-clawe-be {:parallel true})}
-clawe-be {:depends [doctor-be]}
clawe-fe {:doc "Run the doctor frontend via shadowcljs."
:task
(shelll {:dir (str (home-dir) "/russmatney/clawe")}
"npx shadow-cljs watch doctor-app")}
clawe-full-stack (run '-clawe-full-stack {:parallel true})
-clawe-full-stack {:depends [clawe-be clawe-fe]}
;; TODO dry up doctor-tauri with a more fully-featured api support (like quickblog)
topbar {:doc "Run the doctor topbar via tauri. Consumed from systemd service."
:task (run-doctor-tauri-app "topbar")}
dashboard {:doc "Run the doctor focus window via tauri."
:task (run-doctor-tauri-app {:decorations true} "dashboard")}
focus {:doc "Run the doctor focus window via tauri."
:task (run-doctor-tauri-app {:decorations true} "focus")}
restart-doctor (do
(shell "systemctl --user daemon-reload")
;; TODO osx: run as brew services with dedicated log files
(shell "systemctl --user restart doctor-be doctor-fe")
(log "Restarting doctor backend and frontend")
(log "Normally takes <10 seconds")
(log "Expect a popup from doctor-app when the frontend is ready for a re-render"))
doctor-restart (run 'restart-doctor)
restart-doctor-be (shell "systemctl --user restart doctor-be")
doctor-restart-be (run 'restart-doctor-be)
restart-doctor-fe (shell "systemctl --user restart doctor-fe")
doctor-restart-fe (run 'restart-doctor-fe)
restart-doctor-topbar (shell "systemctl --user restart doctor-topbar")
doctor-restart-topbar (run 'restart-doctor-topbar)
stop-doctor (shell "systemctl --user stop doctor-be doctor-fe doctor-topbar")
doctor-stop {:depends [stop-doctor]}
stop-doctor-be (shell "systemctl --user stop doctor-be")
doctor-stop-be {:depends [stop-doctor-be]}
;; TODO osx: pull from proper server/fe logs
log-doctor {:task (shell "journalctl --user -n 100 -f -u doctor-be -u doctor-fe -u doctor-topbar")
:doc "Tail the doctor logs. FE, BE, and topbar via journalctl"}
tail-doctor (run 'log-doctor)
doctor-log (run 'log-doctor)
doctor-tail (run 'log-doctor)
log-doctor-fe {:task (shell "journalctl --user -n 100 -f -u doctor-fe")}
tail-doctor-fe (run 'log-doctor-fe)
doctor-log-fe (run 'log-doctor-fe)
doctor-tail-fe (run 'log-doctor-fe)
log-doctor-be {:task (shell "journalctl --user -n 100 -f -u doctor-be")}
tail-doctor-be (run 'log-doctor-be)
doctor-log-be (run 'log-doctor-be)
doctor-tail-be (run 'log-doctor-be)
log-doctor-topbar {:task (shell "journalctl --user -n 100 -f -u doctor-topbar")}
tail-doctor-topbar (run 'log-doctor-topbar)
doctor-log-topbar (run 'log-doctor-topbar)
doctor-tail-topbar (run 'log-doctor-topbar)
log-awesome {:task (shell "tail -f /home/russ/.cache/awesome/logs")
:doc "Tail the awesome logs, via ~/.cache/awesome/logs"}
tail-awesome (run 'log-awesome)
awesome-tail (run 'log-awesome)
awesome-log (run 'log-awesome)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; i3
;; TODO wrap in something more verbose/loggy
check-i3-config
{:task
(do
(log "PERMISSION TO FIRE?")
(let [{:keys [exit out err] :as res} (shell "i3 -C")]
(if (= exit 0)
(log "FIRE AT WILL")
;; not relevant/necessary - shell throws when there's an error
(log "Error in i3 config" (slurp out) (slurp err)))))}
}}