-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.boot
134 lines (119 loc) · 3.91 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
128
129
130
131
132
133
134
(set-env!
:dependencies '[[org.clojure/clojurescript "1.9.76" :scope "test"]
[org.clojure/clojure "1.8.0" :scope "test"]
[binaryage/devtools "0.7.0" :scope "test"]
[adzerk/boot-cljs "1.7.228-1" :scope "test"]
[adzerk/boot-reload "0.4.8" :scope "test"]
[cirru/boot-cirru-sepal "0.1.8" :scope "test"]
[adzerk/boot-test "1.1.1" :scope "test"]
[mvc-works/hsl "0.1.2"]
[cumulo/client "0.1.0"]
[mvc-works/respo "0.2.2"]])
(require '[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-reload :refer [reload]]
'[cirru-sepal.core :refer [transform-cirru]]
'[respo.alias :refer [html head title script style meta' div link body]]
'[respo.render.static-html :refer [make-html]]
'[adzerk.boot-test :refer :all]
'[clojure.java.io :as io])
(def +version+ "0.1.0")
(task-options!
pom {:project 'Topix/topic-tag
:version +version+
:description "Workflow"
:url "https://github.com/Topix/topic-tag"
:scm {:url "https://github.com/Topix/topic-tag"}
:license {"MIT" "http://opensource.org/licenses/mit-license.php"}})
(deftask compile-cirru []
(set-env!
:source-paths #{"cirru/"})
(comp
(transform-cirru)
(target :dir #{"compiled/"})))
(defn use-text [x] {:attrs {:innerHTML x}})
(defn html-dsl [data fileset]
(make-html
(html {}
(head {}
(title (use-text "Topix Tag"))
(link {:attrs {:rel "icon" :type "image/png" :href "topic-tag.png"}})
(if (:build? data)
(link (:attrs {:rel "manifest" :href "manifest.json"})))
(meta'{:attrs {:charset "utf-8"}})
(meta' {:attrs {:name "viewport" :content "width=device-width, initial-scale=1"}})
(style (use-text "body {margin: 0;}"))
(style (use-text "body * {box-sizing: border-box;}"))
(script {:attrs {:id "config" :type "text/edn" :innerHTML (pr-str data)}}))
(body {}
(div {:attrs {:id "app"}})
(script {:attrs {:src "main.js"}})))))
(deftask html-file
"task to generate HTML file"
[d data VAL edn "data piece for rendering"]
(with-pre-wrap fileset
(let [tmp (tmp-dir!)
out (io/file tmp "index.html")]
(empty-dir! tmp)
(spit out (html-dsl data fileset))
(-> fileset
(add-resource tmp)
(commit!)))))
(deftask dev []
(set-env!
:asset-paths #{"assets"}
:source-paths #{"cirru/src"})
(comp
(html-file :data {:build? false})
(watch)
(transform-cirru)
(reload :on-jsload 'topic-tag.core/on-jsload)
(cljs)
(target)))
(deftask build-simple []
(set-env!
:asset-paths #{"assets"}
:source-paths #{"cirru/src"})
(comp
(transform-cirru)
(cljs :optimizations :simple)
(html-file :data {:build? false})
(target)))
(deftask build-advanced []
(set-env!
:asset-paths #{"assets"}
:source-paths #{"cirru/src"})
(comp
(transform-cirru)
(cljs :optimizations :advanced)
(html-file :data {:build? true})
(target)))
(deftask rsync []
(with-pre-wrap fileset
(sh "rsync" "-r" "target/" "tiye:repo/Topix/topic-tag" "--exclude" "main.out" "--delete")
fileset))
(deftask send-tiye []
(comp
(build-simple)
(rsync)))
(deftask build []
(set-env!
:source-paths #{"cirru/src"})
(comp
(transform-cirru)
(pom)
(jar)
(install)
(target)))
(deftask deploy []
(set-env!
:repositories #(conj % ["clojars" {:url "https://clojars.org/repo/"}]))
(comp
(build)
(push :repo "clojars" :gpg-sign (not (.endsWith +version+ "-SNAPSHOT")))))
(deftask watch-test []
(set-env!
:source-paths #{"cirru/src" "cirru/test"})
(comp
(watch)
(transform-cirru)
(test :namespaces '#{boot-workflow.test})))