-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
91 lines (78 loc) · 4.32 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
{:paths ["src/clj" "src/cljs"]
:pods {org.babashka/fswatcher {:version "0.0.5"}}
:deps {org.babashka/http-server {:mvn/version "0.1.11"}
org.babashka/cli {:mvn/version "0.2.23"}}
:tasks
{:requires ([babashka.cli :as cli])
:init (def cli-opts (cli/parse-opts *command-line-args* {:coerce {:port :int}}))
:enter (println (format "Entering: %s - %s %s" (:name (current-task)) (:doc (current-task))
(if *command-line-args*
(str " With args: " *command-line-args*)
"")))
nrepl
{:requires ([babashka.fs :as fs]
[babashka.nrepl.server :as srv])
:task (do (srv/start-server! {:host "localhost"
:port 1339})
(spit ".nrepl-port" "1339")
(-> (Runtime/getRuntime)
(.addShutdownHook
(Thread. (fn [] (fs/delete ".nrepl-port")))))
(deref (promise)))}
serve {:doc "Serve static assets"
:requires ([babashka.http-server :as server])
:task (server/exec (merge {:port 1337
:dir "./html/"}
cli-opts))}
prn {:task (clojure "-X clojure.core/prn" cli-opts)}
-dev {:depends [serve prn]}
dev {:task (run '-dev {:parallel true})}
beautify {:doc "pretty print html document."
:task (shell "npx js-beautify --type html html/*.html -r -s 2 -d")}
yaml-to-html {:doc "builds html/index.html"
;;TODO rename
:task (do (shell "bb -m yaml-to-edn")
(run 'beautify))}
to-pdf {:doc "prints to pdf"
:task (do (shell "npx nbb src/cljs/to_pdf.cljs")
(shell "qpdf --empty --pages pdf/page-one.pdf pdf/page-two.pdf -- pdf/resume.pdf "))}
build-css {:doc "produces html/global.css, accepts -m and --watch flags"
:task (apply shell "npx tailwindcss -i ./src/css/global.css -o ./html/global.css" *command-line-args*)}
hash-css-output {:doc "produces html/global-[content-hash].css once"
:task (do (let [css-file-hash (subs (:out (shell {:out :string} "md5sum ./html/global.css")) 0 6)]
(shell (format "mv ./html/global.css ./html/global-%s.css" css-file-hash))))}
watch-css {:requires ([pod.babashka.fswatcher :as fw]
[babashka.fs :as fs])
:doc "watch css"
:task (binding [*command-line-args* (list "--watch" "-m")]
(run 'build-css))}
builds-everything-once {:task
(do #_(shell "rm ./html/global*")
(binding [*command-line-args* (list "-m")]
(run 'build-css))
(run 'hash-css-output)
(run 'yaml-to-html)
(run 'to-pdf))}
watch-build {:requires ([pod.babashka.fswatcher :as fw]
[babashka.fs :as fs])
:doc "Watches clj and yaml files and produces html/index.html."
:task (do (run 'yaml-to-html)
(run 'to-pdf)
(println "CTRL-C to quit...")
(fw/watch "." (fn [{:keys [type path] :as ev}]
(when (or
(= path "./resume.yaml")
(= (fs/extension path) "clj"))
(println :building-after ev)
(run 'yaml-to-html)
(run 'to-pdf)))
{:recursive true
:delay-ms 50})
(deref (promise)))}
-watch-everything {:depends [watch-css watch-build]}
watch-everything {:task (run '-watch-everything {:parallel true})}
deploy {:doc "rsync html folder shared host"
:task (do (shell "cp pdf/resume.pdf html/resume.pdf")
(shell "git add html/resume.pdf")
(shell "git ci -m '[AUTOMATED] added resume.pdf to html folder'")
(shell "rsync -havz html/ hetzner:/usr/home/codecan/public_html/cv --include='**.gitignore' --exclude='/.git' --filter=':- .gitignore' --delete-after"))}}}