forked from nextjournal/clerk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
117 lines (93 loc) · 4.89 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
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
{:min-bb-version "0.9.159"
:paths ["bb"]
:deps {io.github.nextjournal/dejavu {:git/sha "4980e0cc18c9b09fb220874ace94ba6b57a749ca"}
io.github.nextjournal/cas-client {:git/sha "84ab35c3321c1e51a589fddbeee058aecd055bf8"}}
:tasks
{:requires
([tasks :as t]
[clojure.string :as str]
[babashka.process :as p]
[babashka.fs :as fs]
[babashka.cli :as cli])
yarn-install {:doc "Installs and updates npm dependencies"
:task (shell "yarn install")}
watch:cljs {:doc "Starts shadow-cljs & clerk"
:task (apply clojure "-X:build:test:sci:demo:dev" *command-line-args*)
:depends [yarn-install]}
build:js {:doc "Builds JS"
:depends [yarn-install]
:task (clojure "-M:sci:demo:dev release viewer")}
build+upload-viewer-resources {:doc "Refreshes assets stored on CDN (google storage)"
:extra-paths ["src"]
:task nextjournal.clerk.render.hashing/build+upload-viewer-resources}
lint {:doc "Lints project using clj-kondo"
:task (apply shell "clj-kondo --lint src test" *command-line-args*)}
build:static-app {:doc "Builds a static app with default notebooks"
:task (apply clojure "-X:demo:nextjournal/clerk" *command-line-args*)}
build:static-app-test-release
{:doc "Builds static app which uses output of build:js.
Run with additional --paths notebooks/cherry.clj to test single notebook."
:task (apply clojure "-M:demo:nextjournal/clerk:test-release-js" *command-line-args*)}
-check {:depends [lint test:clj]}
check {:doc "Check to run before pushing"
:task (run '-check {:parallel true})}
test:clj {:doc "Run clojure tests"
:task (apply clojure "-X:test" *command-line-args*)}
test:static-app {:doc "Run UI tests for current SHA. Provide SHA as command line arg."
:task (do (shell {:dir "ui_tests"} "yarn install")
(shell {:dir "ui_tests"} "yarn nbb -m playwright-tests"
(or (when-let [args (not-empty (cli/parse-opts *command-line-args*))]
(cond-> args
(contains? args :file)
(assoc :url (str "file://" (fs/cwd) fs/file-separator (:file args)))))
{:sha (-> (shell {:out :string} "git rev-parse HEAD")
:out
str/trim)})))}
update-meta {:doc "Updates meta.edn with current version (based on commit count currently)."
:task (t/update-meta)}
update-changelog
{:doc "Updates CHANGELOG.md with "
:task
(t/update-changelog)}
link-changelog {:doc "Turns the issue references in the changelog into links"
:task (do (defn tag->issue-link [s]
(clojure.string/replace s (re-pattern "(?<!\\[)#([0-9]+)") "[#$1](https://github.com/nextjournal/clerk/issues/$1)"))
(let [f "CHANGELOG.md"]
(spit f (tag->issue-link (slurp f)))))}
jar {:doc "Build jar"
:task (do
(println "Building jar")
(clojure "-T:build jar"))}
install-jar {:doc "Installs jar for local testing"
:task (clojure "-T:build install")}
tag {:doc "Tags release and pushes tag to Github."
:task (t/tag)}
clerk-version {:doc "Prints current version"
:task (println (t/version))}
publish {:doc "Prepares repo for publishing via CI"
:task (t/publish)}
-current-tag (->> (shell {:out :string} "git tag --points-at HEAD")
:out
str/trim
not-empty)
-current-branch (->> (shell {:out :string} "git branch --show-current")
:out
str/trim)
ci:publish {:doc "Publish task which will be run on CI"
:depends [-current-tag -current-branch]
:task (do
(prn :current-tag -current-tag)
(prn :current-branch -current-branch)
(if (and -current-tag (= "main" -current-branch))
(do
(println "Deploying to clojars")
(clojure "-T:build deploy"))
;; still build jar with updated commit count for artifact upload
(do
(run 'update-meta)
(run 'jar))))}
uninstall-git-hooks {:doc "Uninstall git hooks we installed previously and no longer need"
:task (fs/delete-if-exists ".git/hooks/pre-commit")}
-dev {:depends [uninstall-git-hooks watch:cljs]}
dev {:doc "Start app in dev mode, compiles cljs and css"
:task (run '-dev {:parallel true})}}}