-
Notifications
You must be signed in to change notification settings - Fork 12
/
api.clj
116 lines (78 loc) · 3.38 KB
/
api.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
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
(ns metav.api
(:require
[clojure.spec.alpha :as s]
[clojure.data.json :as json]
[metav.utils :as utils]
[metav.domain.context :as context]
[metav.domain.display :as display]
[metav.domain.git-operations :as git-ops]
[metav.domain.metadata :as metadata]
[metav.domain.pom :as pom]
[metav.domain.release :as release]
[metav.domain.spit :as spit]))
(defn make-context
([]
(make-context {}))
([opts]
(let [working-dir (:metav/working-dir opts)
opts (cond-> opts
(not working-dir) (assoc :metav/working-dir (utils/pwd)))]
(context/make-context opts))))
(defn check-context [context]
(utils/check-spec :metav/context context))
(def metadata-as-edn metadata/metadata-as-edn)
;;----------------------------------------------------------------------------------------------------------------------
;; Display
;;----------------------------------------------------------------------------------------------------------------------
(defmulti display* :metav.display/output-format)
(defmethod display* :edn [context]
(println (metadata/metadata-as-edn context)))
(defmethod display* :json [context]
(println (json/write-str (metadata/metadata-as-edn context))))
(defmethod display* :tab [{:metav/keys [artefact-name version]}];default is tab separated module-name and version
(println (str artefact-name "\t" (str version))))
(defn display
([] (display (make-context)))
([context]
(-> context
(utils/merge&validate display/default-options
(s/merge :metav/context
:metav.display/options))
(display*))
context))
;;----------------------------------------------------------------------------------------------------------------------
;; Spit!
;;----------------------------------------------------------------------------------------------------------------------
(defn spit!
([] (spit! (make-context)))
([context]
(spit/spit! context)))
(defn git-add-spitted! [context]
(spit/git-add-spitted! context))
;;----------------------------------------------------------------------------------------------------------------------
;; Pom!
;;----------------------------------------------------------------------------------------------------------------------
(defn sync-pom! [context]
(pom/sync-pom! context))
(defn git-add-pom! [context]
(pom/git-add-pom! context))
;;----------------------------------------------------------------------------------------------------------------------
;; git!
;;----------------------------------------------------------------------------------------------------------------------
(defn check-commited [context]
(git-ops/check-committed? context))
(defn tag-repo! [context]
(git-ops/tag-repo! context))
(defn commit! [context msg]
(git-ops/commit! context msg))
(defn push! [context]
(git-ops/push! context))
;;----------------------------------------------------------------------------------------------------------------------
;; Release!
;;----------------------------------------------------------------------------------------------------------------------
(defn bump [context]
(release/bump-context context))
(defn release!
([] (release! (make-context)))
([context]
(release/release! context)))