-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
202 lines (103 loc) · 4.89 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
{:tasks {cp
{:doc "Print the classpath"
:task (do
(println "Computing and printing classpath...\n")
(doseq [line (sort (clojure.string/split (cp-string)
(re-pattern ":")))]
(println line)))}
cp:del
{:doc "Delete cached classpath"
:task (fs/delete-tree ".cpcache")}
deploy
{:depends [jar]
:doc "Deploy this project to Clojars ; need username and path to file with Clojars token"
:task (clojure {:extra-env {"CLOJARS_USERNAME" (first *command-line-args*)
"CLOJARS_PASSWORD" (slurp (second *command-line-args*))}}
"-X:deploy")}
dev:clojure
{:doc "Start Clojure JVM dev environment (NREPL on port 14563)"
:task (clojure "-M:dev:test:nrepl")}
dev:cljs
{:doc "Start CLJS dev environment (NREPL on port 14563, server on port 8000)"
:task (clojure "-M:cljs:dev:test watch dev")}
fcss:release
{:doc ""
:task (clojure {:extra-env {"FCSS_MODE" :release}}
"-M:cljs:dev release release")}
fcss:release-report
{:doc "Like 'fcss:release' but generates a Shadow-CLJS report"
:task (clojure {:extra-env {"FCSS_MODE" :release}}
"-M:cljs:dev run shadow.cljs.build-report release fcss/optimized/shadow_report.html")}
fcss:optimize
{:doc ""
:task (clojure "-X:fcss-optimize")}
install
{:depends [jar]
:doc "Install jar to local Maven repo"
:task (clojure "-X:install")}
jar
{:doc "Build a jar for this project"
:task (clojure "-X:jar")}
lint
{:doc "Start Clj-kondo on './src' (further path can be provided as command-line argument)"
:task (shell (str "clj-kondo --lint src/"
(first *command-line-args*)))}
lint:import
{:doc "Initialize Clj-kondo and copy configuration files from dependencies"
:task (shell (format "clj-kondo --lint '%s' --dependencies --parallel --copy-configs"
(cp-string)))}
pom
{:doc "Sync POM file with 'deps.edn'"
:task (clojure "-Spom")}
shadow:clean
{:doc "Remove the given profile from Shadow-CLJS cache (for full recompilation)"
:task (shadow-clean (first *command-line-args*))}
shadow:clean-test
{:doc "Like 'shadow:clean' but for the ':test-node' profile"
:task (shadow-clean "test-node")}
test:jvm
{:doc "Run tests on the JVM once ; accepts Kaocha CLI arguments"
:task (test-jvm nil)}
test:jvm:watch
{:doc "Run tests on the JVM everytime a file is changed ; accepts Kaocha CLI arguments"
:task (test-jvm ["--watch"])}
test:node
{:doc "Run tests on NodeJS after unoptimized compilation"
:task (test-node false)}
test:node:optimize
{:doc "Run tests on NodeJS after advanced compilation"
:task (test-node true)}
:requires ([babashka.fs :as fs])
:init
(do
(defn cp-string
;; Returns the classpath as a string, reading profiles from CLI args.
[]
(with-out-str (clojure (str "-Spath "
(when (some? *command-line-args*)
(str "-A"
(clojure.string/join ""
*command-line-args*)))))))
(defn shadow-clean
;; Deletes a Shadow-CLJS profile.
[profile]
(when (empty? profile)
(println "A Shadow-CLJS profile must be provided.")
(System/exit 42))
(fs/delete-tree (str ".shadow-cljs/builds/"
profile)))
(defn test-jvm
;; Concats CLI args with the given ones.
[arg+]
(clojure (str "-M:kaocha:test -m kaocha.runner --config-file kaocha.edn :jvm "
(clojure.string/join " "
(concat arg+
*command-line-args*)))))
(defn test-node
[optimize?]
(clojure (format "-M:cljs:test %s test-node"
(if optimize?
"release"
"compile")))
(shell "node ./compiled/node/test.js"))
)}}