-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.clj
69 lines (61 loc) · 2.41 KB
/
build.clj
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
(ns build
(:require [clojure.tools.build.api :as b]
[clojure.string :as str]))
(def lib 'isthereafuckingbroncosgame.web.dynamic)
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s.jar" (name lib)))
(defn clean [_]
(b/delete {:path "target"})
(b/delete {:path "public"}))
(defn uber [_]
(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis basis
:src-dirs ["src"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file jar-file
:basis basis
:main lib}))
(defn html [_]
(clean nil)
(b/process {:command-args ["clojure" "-X:html"]}))
(defn dhtml [_]
(clean nil)
(b/process {:command-args ["clojure" "-X:dhtml"]}))
(defn ipfs-update [{:keys [remote quiet? web-ns] :or {web-ns :static}}]
(html nil)
(let [remote (name remote)
web-ns (name web-ns)
{:keys [exit out err]} (b/process {:command-args
["ipfs" "add" "-Q"
(str "public/" web-ns
"/index.html")]
:out :capture
:err :capture})
_ (when-not (zero? exit)
(when-not quiet? (println "Error adding file to IPFS:"
out "\n" err))
(System/exit exit))
ipfs-hash (str/trim out)]
(if quiet?
(do (print ipfs-hash) (flush))
(println "Added IPFS hash:" ipfs-hash))
(b/process {:command-args ["ipfs" "pin" "add" ipfs-hash]
:out (if quiet? :ignore :inherit)
:err (if quiet? :ignore :inherit)})
(when remote
(b/process {:command-args ["ipfs" "pin" "remote" "add"
(str "--service=" remote)
(str "--name=isthereafuckingbroncosga.me")
ipfs-hash]
:out (if quiet? :ignore :inherit)
:err (if quiet? :ignore :inherit)}))))
#_(defn cloudflare-dnslink-update [{:keys [ipfs-hash]}]
(let [client (cfd/api-client)
zone-id (cfd/zone-name->id "isthereafuckingbroncosga.me")]
(cfd/set-dnslink-record)))
(defn deploy [_]
(ipfs-update :pinata))