Repository navigation
Expand file tree
/
Copy pathbb.edn
More file actions
88 lines (78 loc) · 4.96 KB
/
Copy pathbb.edn
File metadata and controls
88 lines (78 loc) · 4.96 KB
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
{:paths ["src" "scripts" "resources"]
:tasks
{;; The JVM side handles ingest, digest and expire:
;; clojure -M:run (single pass)
;; clojure -M:run -- --watch (daemon)
;; clojure -M:run -- --fetch 4d (recovery)
;;
;; Export and notify are read-only bb scripts:
:init (defn rm-rf [^java.io.File f]
(when (.isDirectory f)
(doseq [c (.listFiles f)] (rm-rf c)))
(.delete f))
export {:doc "Export reports: bb export [--force] [--index-only] [-n source] [-p 1|2|3] [-s 1-7]"
:task (apply shell "bb scripts/bone-export.clj" *command-line-args*)}
notify {:doc "Send notification emails: bb notify [--dry-run] [--debug]"
:task (apply shell "bb scripts/bone-notify.clj" *command-line-args*)}
clean {:doc "Remove public/ exports, stale AOT classes/, and reset the incremental-export watermark"
:task (do (doseq [f (.listFiles (clojure.java.io/file "public"))]
(rm-rf f)
(println "Deleted" (.getPath f)))
;; Wipe AOT artifacts: stale .class files (e.g. an
;; old datalevin compiled by `bb build-jar`) sit on
;; :paths and shadow bumped deps, breaking run/test.
(let [dir (clojure.java.io/file "classes")]
(when (.exists dir)
(rm-rf dir)
(println "Deleted classes/")))
;; Drop the incremental watermark so the next
;; export rebuilds everything. .failures.edn
;; and .last-notify-failures.edn are owned by
;; the daemon / notifier and survive.
(let [f (clojure.java.io/file "data/.last-export")]
(when (.exists f)
(.delete f)
(println "Deleted" (.getPath f)))))}
test-config {:doc "Validate config.edn (pass path as arg, default: ./config.edn)"
:task (apply shell "bb scripts/validate-config.clj" *command-line-args*)}
test-search {:doc "Run the search-engine conformance cases (needs node)"
:task (shell "node" "test/bone-search-conformance.js")}
maintenance {:doc "Purge orphan emails: bb maintenance [--delete] [--verbose] [-n source] [--retention 90d] [--failures]"
:task (apply shell "bb scripts/bone-maintenance.clj" *command-line-args*)}
build-jar {:doc "Build target/bone.jar + bin/bone wrapper (one-shot uberjar build)"
:task (do
(let [classes (clojure.java.io/file "classes")
bin (clojure.java.io/file "bin")
wrapper (clojure.java.io/file "bin/bone")]
;; Wipe stale .class files so a Clojure version bump
;; doesn't carry forward incompatible AOT artefacts.
(when (.exists classes) (rm-rf classes))
(.mkdirs classes)
(.mkdirs bin)
(shell "clojure" "-M" "-e" "(compile 'bone.main)")
(shell "clojure" "-M:uberdeps" "--main-class" "bone.main")
(spit wrapper
(str "#!/bin/sh\n"
"# Auto-generated by `bb build-jar`. Runs BONE via java\n"
"# with the JVM flags Datalevin requires.\n"
"# Resolve symlinks so the jar is found even when this\n"
"# wrapper is symlinked (e.g. /usr/local/bin/bone).\n"
"self=\"$0\"\n"
"while [ -h \"$self\" ]; do\n"
" link=$(readlink \"$self\")\n"
" case \"$link\" in\n"
" /*) self=\"$link\" ;;\n"
" *) self=\"$(dirname \"$self\")/$link\" ;;\n"
" esac\n"
"done\n"
"here=$(cd \"$(dirname \"$self\")\" && pwd)\n"
"exec java \\\n"
" --add-opens=java.base/java.nio=ALL-UNNAMED \\\n"
" --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \\\n"
" --enable-native-access=ALL-UNNAMED \\\n"
" -jar \"$here/../target/bone.jar\" \"$@\"\n"))
(.setExecutable wrapper true)
(println "Built target/bone.jar and bin/bone")))}
;; Integration tests: clojure -M:test
test-smtp {:doc "Test SMTP config: bb test-smtp [--to addr] [--send] (default = validate only)"
:task (apply shell "bb scripts/bone-email-test.clj" *command-line-args*)}}}