forked from andrewmcveigh/cljs-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.boot
127 lines (109 loc) · 4.06 KB
/
build.boot
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
(def +project+ 'com.andrewmcveigh/cljs-time)
(def +version+ "0.5.2-SNAPSHOT")
(def +description+ "A clj-time inspired date library for clojurescript.")
(def dependencies
'[[org.clojure/clojure "1.8.0" :scope "provided"]
[org.clojure/clojurescript "1.9.521" :scope "provided"]])
(def dev-dependencies
'[[org.clojure/tools.nrepl "0.2.12" :scope "test" :exclusions [org.clojure/clojure]]
[boot-codox "0.10.2" :scope "test"]
[codox-theme-rdash "0.1.1" :scope "test"]
[adzerk/boot-cljs "1.7.228-2" :scope "test"]
[crisptrutski/boot-cljs-test "0.3.4" :scope "test"]
[com.cemerick/piggieback "0.2.2" :scope "test"]])
(set-env!
:source-paths #{"src" "test" "compile" "perf"}
:resource-paths #{"src"}
:dependencies (vec (concat dependencies dev-dependencies)))
(require
'[adzerk.boot-cljs :refer [cljs]]
'[boot.core :as boot]
'[boot.repl :as repl]
'[boot.task.built-in :as task]
'[cljs.closure :as closure]
'[clojure.java.io :as io]
'[clojure.string :as string]
'[clojure.set :as set]
'[crisptrutski.boot-cljs-test :refer [test-cljs]]
'[codox.boot :refer [codox]]
'[parse-perf-test :as perf]
'cljs.repl 'cljs.repl.node 'cljs.repl.rhino)
(defn documentation-namespaces []
(->> "src"
(clojure.java.io/file)
(file-seq)
(map str)
(filter (partial re-matches #"^.*\.cljs$"))
(map (comp #(string/replace % #"/" ".")
#(string/replace % #"_" "-")
#(string/replace % #"^src/" "")
#(string/replace % #"\.cljs$" "")))
(remove (partial re-find #"^cljs-time.internal"))
(map symbol)
(set)))
(task-options!
pom {:project +project+
:version +version+
:description +description+
:license {"Eclipse Public License"
"http://www.eclipse.org/legal/epl-v10.html"}
:scm {:url "git@github.com:andrewmcveigh/cljs-time.git"}}
codox {:version +version+
:name (name +project+)
:description +description+
:source-paths #{"src"}
:filter-namespaces (documentation-namespaces)
:language :clojurescript
:metadata {:doc/format :markdown}
:themes [:rdash]
:source-uri "https://github.com/andrewmcveigh/cljs-time/blob/v{version}/{filepath}#L{line}"}
push {:repo "clojars"}
target {:dir #{"target"}})
(deftask compare-perf []
(println
"Average runs:"
(pr-str (perf/compare perf/old-version perf/new-version))))
;; ;;; CLJS
(defrecord SourcePaths [paths]
cljs.closure/Compilable
(closure/-compile [_ opts]
(mapcat #(closure/-compile % opts) paths))
(closure/-find-sources [_ opts]
(mapcat #(closure/-find-sources % opts) paths)))
(ns-unmap 'boot.user 'compile)
(defn compile
[optimizations & {:keys [out-dir] :or {out-dir "target"}}]
{:pre [(#{:none :whitespace :simple :advanced} optimizations)]}
(printf "Compiling with optimizations %s to %s...\n" optimizations out-dir)
(let [file (str (name optimizations) ".js")
output (-> (io/file out-dir file)
(.getCanonicalPath))]
(closure/build (SourcePaths. ["src" "test"])
{:cache-analysis true
:main 'cljs-time.test-runner
:output-to output
:optimizations optimizations}))
(println "Finished compiling"))
(deftask auto-test []
(comp (watch)
(speak)
(test-cljs :js-env :node)))
(ns-unmap 'boot.user 'test)
(deftask test []
(test-cljs :js-env :node :optimizations :simple))
(deftask test-optimized []
(test-cljs :js-env :node :optimizations :advanced))
(deftask test-all []
(comp (test-cljs :js-env :node :optimizations :simple)
(test-cljs :js-env :node :optimizations :advanced)))
(boot/deftask build []
(comp (pom) (jar) (target)))
(boot/deftask deploy []
(comp (build) (test-all) (install) (push)))
(defn add-piggieware []
(require 'cemerick.piggieback)
(swap! repl/*default-middleware* conj 'cemerick.piggieback/wrap-cljs-repl)
(swap! repl/*default-middleware* distinct))
(deftask node-repl []
(add-piggieware)
((resolve 'cemerick.piggieback/cljs-repl) (cljs.repl.node/repl-env)))