-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_file.clj
49 lines (41 loc) · 1.37 KB
/
version_file.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
(ns ^{:author "Jeremy Schoffen"
:doc "
Api used to generate version files.
"}
fr.jeremyschoffen.mbt.alpha.default.versioning.version-file
(:require
[clojure.string :as string]
[fr.jeremyschoffen.java.nio.alpha.file :as fs]
[fr.jeremyschoffen.mbt.alpha.core.specs]
[fr.jeremyschoffen.mbt.alpha.default.specs]
[fr.jeremyschoffen.mbt.alpha.utils :as u]))
(u/pseudo-nss
project
versioning
version-file)
(defn version-file-content
"Make the string content of a version file."
[{v ::project/version
ns ::version-file/ns}]
(string/join "\n" [(format "(ns %s)" ns)
""
(format "(def version \"%s\")" v)
""]))
(u/spec-op version-file-content
:param {:req [::project/version
::version-file/ns]
:opt [::versioning/stable
::versioning/major]})
(defn write-version-file!
"Make the string content of a version file and spit it at the destination specified under the key
`:version-file/path`."
[{dest ::version-file/path
:as param}]
(u/ensure-parent! dest)
(spit dest (version-file-content param))
dest)
(u/spec-op write-version-file!
:param {:req [::project/version
::version-file/path
::version-file/ns]}
:ret fs/path?)