-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
301 lines (257 loc) · 13.6 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
{:paths ["src" "test" "resources"]
:deps {
org.babashka/cli {:mvn/version "0.8.61"}
babashka/fs {:mvn/version "0.5.22"}
metosin/malli {:mvn/version "0.16.4"}
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 "dce19ab8897dc4fbd98ac8ec3b0995a54a2f17bb"
: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.9"}}
: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 hostname []
(-> (shell {:out :string} "zsh -c 'hostname'") :out string/trim))
(defn home-dir []
(-> (shell {:out :string} "zsh -c 'echo -n ~'") :out string/trim))
(defn is-mac? []
(boolean (#{"Mac OS X"} (System/getProperty "os.name"))))
(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
(when (:transparent opts) " --transparent")
(when (:decorations opts) " --decorations"))]
(pp (str "Running clove app: " cmd))
(shelll {:dir (str (home-dir) "/russmatney/clawe")
:extra-env {"WEBKIT_DISABLE_DMABUF_RENDERER" "1"}} cmd)))))
home (pp (home-dir))
hostname (pp (hostname))
is-mac (pp (is-mac?))
clj-kondo (shelll "clj-kondo --lint src")
clj-kondo-test (shelll "clj-kondo --lint test")
clj-kondo-all (shelll "clj-kondo --lint src:test")
lint (shelll "clj-kondo --lint src:test")
test-unit
{:doc "Run bb unit tests."
:task (shelll "./test_runner.clj")}
test-jvm-unit
{:doc "Run jvm unit tests."
:task (shelll "./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)]
(shelll (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
(when-not (is-mac?)
(shelll "systemctl --no-pager --user status doctor-be doctor-fe doctor-topbar"))
(pp "TODO impl ensure `clove` is installed")
(pp "TODO impl ensure local symlinks")
(shelll "l public/assets")
(log/info "TODO add other css needs (chessground?)")
(shelll "l public/css")
)}
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 "npm install")
;; local symlinks
(log/info "TODO impl ensure local symlinks!")
(log/info "ln -s ~/Screenshots public/assets/screenshots")
(log/info "ln -s ~/Dropbox/wallpapers public/assets/wallpapers")
(log/info "ln -s ~/Dropbox/game-assets/game-clips public/assets/game-clips")
(shelll "ls public/assets")
(log/info "TODO add other css needs (chessground)")
(log/info "cp node_modules/chessground/assets/* public/css/.")
(shelll "ls public/css")
)}
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")}
;; 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 {:transparent true} "topbar")}
dashboard {:doc "Run the doctor dashboard via tauri."
:task (run-doctor-tauri-app {:decorations true
:transparent true} "dashboard")}
focus {:doc "Run the doctor focus via tauri."
:task (run-doctor-tauri-app {:decorations true
:transparent true} "focus")}
restart-doctor (do
(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")
(when-not (is-mac?)
(shelll "systemctl --user daemon-reload")
(shelll "systemctl --user restart doctor-be doctor-fe"))
(when (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")))
doctor-restart (run 'restart-doctor)
restart-doctor-be (do
(when-not (is-mac?)
(shelll "systemctl --user restart doctor-be"))
(when (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")))
doctor-restart-be (run 'restart-doctor-be)
restart-doctor-fe (do
(when-not (is-mac?)
(shelll "systemctl --user restart doctor-fe"))
(when (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")))
doctor-restart-fe (run 'restart-doctor-fe)
restart-doctor-clients (do (run 'restart-doctor-topbar)
(run 'restart-doctor-dashboard))
doctor-restart-clients (run 'restart-doctor-clients)
restart-doctor-topbar (do
(when-not (is-mac?)
(shelll "systemctl --user restart doctor-topbar"))
(when (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.topbar.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.topbar.plist")))
doctor-restart-topbar (run 'restart-doctor-topbar)
restart-doctor-dashboard (do
(when-not (is-mac?)
(shelll "systemctl --user restart doctor-dashboard"))
(when (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.dashboard.plist")
(shelll "launchctl load /Users/russ/Library/LaunchAgents/com.clawe.dashboard.plist")))
doctor-restart-dashboard (run 'restart-doctor-dashboard)
stop-doctor (if (is-mac?)
(do
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.topbar.plist")
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.dashboard.plist"))
(shelll "systemctl --user stop doctor-be doctor-fe doctor-topbar doctor-dashboard"))
doctor-stop {:depends [stop-doctor]}
stop-doctor-be (if (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-be.plist")
(shelll "systemctl --user stop doctor-be"))
doctor-stop-be {:depends [stop-doctor-be]}
stop-doctor-fe (if (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.doctor-fe.plist")
(shelll "systemctl --user stop doctor-fe"))
doctor-stop-fe {:depends [stop-doctor-fe]}
stop-doctor-topbar (if (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.topbar.plist")
(shelll "systemctl --user stop doctor-topbar"))
doctor-stop-topbar {:depends [stop-doctor-topbar]}
stop-doctor-dashboard (if (is-mac?)
(shelll "launchctl unload /Users/russ/Library/LaunchAgents/com.clawe.dashboard.plist")
(shelll "systemctl --user stop doctor-dashboard"))
doctor-stop-dashboard {:depends [stop-doctor-dashboard]}
log-doctor {:task (do
(if (is-mac?)
(shelll "tail -f /Users/russ/.log/clawe/doctor-be.out.log /Users/russ/.log/clawe/doctor-fe.out.log")
(shelll "journalctl --user -n 100 -f -u doctor-be -u doctor-fe -u doctor-topbar -u doctor-dashboard --all --no-hostname")))
: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 (do
(if (is-mac?)
(shelll "tail -f /Users/russ/.log/clawe/doctor-fe.out.log -n 500")
(shelll "journalctl --user -n 100 -f -u doctor-fe --all --no-hostname")))}
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 (do
(if (is-mac?)
(shelll "tail -f /Users/russ/.log/clawe/doctor-be.out.log -n 500")
(shelll "journalctl --user -n 100 -f -u doctor-be --all --no-hostname")))}
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
(if (is-mac?)
(shelll "tail -f /Users/russ/.log/clawe/doctor-topbar.out.log -n 500")
(shelll "journalctl --user -n 100 -f -u doctor-topbar --all --no-hostname"))}
tail-doctor-topbar (run 'log-doctor-topbar)
doctor-log-topbar (run 'log-doctor-topbar)
doctor-tail-topbar (run 'log-doctor-topbar)
log-doctor-dashboard {:task
(if (is-mac?)
(shelll "tail -f /Users/russ/.log/clawe/doctor-dashboard.out.log -n 500")
(shelll "journalctl --user -n 100 -f -u doctor-dashboard --all --no-hostname"))}
tail-doctor-dashboard (run 'log-doctor-dashboard)
doctor-log-dashboard (run 'log-doctor-dashboard)
doctor-tail-dashboard (run 'log-doctor-dashboard)
log-awesome {:task (shelll "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} (shelll "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)))))}
}}