Repository navigation
Expand file tree
/
Copy pathbb.edn
More file actions
107 lines (85 loc) · 5.16 KB
/
Copy pathbb.edn
File metadata and controls
107 lines (85 loc) · 5.16 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{:paths ["src" "scripts" "resources"]
:min-bb-version "1.3.189"
:deps {dev.weavejester/cljfmt {:mvn/version "0.16.3"}}
:tasks
{:init (do
(def source-paths ["src" "test" "scripts" "pages/src"])
(defn normalize-build-args [args]
(let [args (vec args)]
(if (and (seq args)
(not (.startsWith ^String (first args) ":")))
(into [":version" (pr-str (first args))] (subvec args 1))
args)))
(defn required-version-arg [args]
(or (first args)
(throw (ex-info "Version argument is required."
{:example "bb release-check 0.4.0"}))))
(defn local-db-cli-args [command]
(into ["-M" "-m" "bisql.cli" command "--port" "15432"]
*command-line-args*))
(defn build-task [subcommand]
(apply clojure "-T:build" subcommand (normalize-build-args *command-line-args*))))
lint {:doc "Run clj-kondo on project sources"
:task (apply clojure "-M:lint" "--lint" source-paths)}
format {:doc "Fix Clojure formatting with cljfmt"
:requires ([cljfmt.report :as report]
[cljfmt.tool :as fmt])
:task (fmt/fix {:paths source-paths
:report report/clojure})}
format-check {:doc "Check Clojure formatting with cljfmt"
:requires ([cljfmt.report :as report]
[cljfmt.tool :as fmt])
:task (fmt/check {:paths source-paths
:report report/clojure})}
test {:doc "Run tests"
:task (clojure "-M:test")}
test-db {:doc "Reset sample schema and run integration tests against local PostgreSQL"
:depends [db-reset]
:task (clojure "-M:test-db")}
verify {:doc "Run format check, lint, and tests"
:depends [format-check lint test]}
fix {:doc "Run format, lint, and tests"
:depends [format lint test]}
db-reset {:doc "Reset local PostgreSQL sample schema and seed data"
:task (shell "bb scripts/db/reset_postgres_sample.bb")}
gen-config {:doc "Generate a bisql.edn config template"
:task (apply clojure "-M" "-m" "bisql.cli" "gen-config" *command-line-args*)}
gen-crud {:doc "Generate CRUD SQL files from local PostgreSQL"
:task (apply clojure (local-db-cli-args "gen-crud"))}
gen-functions {:doc "Generate function namespace files from local SQL templates"
:task (apply clojure "-M" "-m" "bisql.cli" "gen-functions" *command-line-args*)}
gen-crud-and-functions {:doc "Generate CRUD SQL files and function namespace files in sequence"
:task (apply clojure (local-db-cli-args "gen-crud-and-functions"))}
list-functions {:doc "List the Clojure functions resolved from a SQL file or directory"
:task (apply clojure "-M" "-m" "bisql.cli" "list-functions" *command-line-args*)}
jar {:doc "Build the jar via build.clj; accepts `bb jar x.x.x` or raw build args"
:task (build-task "jar")}
install {:doc "Install to local Maven cache via build.clj; accepts `bb install x.x.x` or raw build args"
:task (build-task "install")}
release {:doc "Release to Clojars via build.clj; accepts `bb release x.x.x` or raw build args"
:task (build-task "deploy")}
release-check {:doc "Verify a released version resolves from Clojars and loads bisql.core; accepts `bb release-check x.x.x`"
:task (let [version (required-version-arg *command-line-args*)
deps-edn (str "{:deps {io.github.hatappo/bisql {:mvn/version \"" version "\"}}}")]
(shell "clojure" "-Sdeps" deps-edn "-P")
(shell "clojure" "-Sdeps" deps-edn "-M" "-e" "(require 'bisql.core) (println :ok)"))}
token {:doc "Open ~/.m2/settings.xml for editing the temporary Clojars token"
:task (shell "open" (str (System/getProperty "user.home") "/.m2/settings.xml"))}
gen-examples {:doc "Generate docs/07-rendering-examples.md from docs/data/rendering-examples.edn"
:requires ([examples.markdown :as examples])
:task (do
(shell "mkdir" "-p" "docs")
(spit "docs/07-rendering-examples.md"
(examples/render-examples-markdown))
(shell "open" "docs/07-rendering-examples.md"))}
pages-clean {:doc "Remove generated Pages build outputs and shadow-cljs cache"
:task (do
(shell "rm" "-rf" "pages/dist")
(shell "rm" "-rf" "pages/.shadow-cljs"))}
pages-build {:doc "Build the static pages app into pages/dist/"
:task (do
(shell "rm" "-rf" "pages/dist")
(shell "bb" "scripts/pages/sync.bb")
(shell "sh" "-lc" "cd pages && clojure -J--enable-native-access=ALL-UNNAMED -J--sun-misc-unsafe-memory-access=allow -M -m shadow.cljs.devtools.cli release playground"))}
pages-dev {:doc "Start the shadow-cljs pages dev server on http://localhost:8000"
:task (shell "bb" "scripts/pages/dev.bb")}}}