-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbb.edn
More file actions
107 lines (102 loc) · 7.05 KB
/
bb.edn
File metadata and controls
107 lines (102 loc) · 7.05 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
{:min-bb-version "0.9.162"
:paths ["."]
:deps {escherize/bask {:git/url "https://github.com/escherize/bask.git"
:git/sha "81cc9af3021d7689cfbddf0518a1e828f785f006"}
table/table {:mvn/version "0.5.0"}}
:tasks {:requires [[babashka.process :refer [shell]]
[bask.colors :as c]
[bb.cli :as cli]
[bb.tasks :as t]
[clojure.string :as str]]
run-branch
{:requires [[bb.dl-and-run :as dl]]
:doc "Download and run a jar for a branch, on a port. Respects MB_DB_CONNECTION_URI."
:examples [["bb run-branch --branch master --port 4445" "Run master branch on port 4445"]
["bb run-branch" "Pick branch and port, and run branch on port"]
["bb run-branch -p 9939 -s 9938" "Pick a branch, and run it on port 4445 with a socket repl on 9938"]]
:task
(do (dl/check-gh-token!)
(dl/download-and-run-latest-jar!
(let [list-branches (delay ;; choices can be a delay -- we dont want to grab theese unless we need them.
(t/list-branches
(t/env "MB_DIR" (fn []
(println (c/red "Please put the path of your metabase repository into the MB_DIR env variable like so:"))
(println (c/white "export MB_DIR=path/to/metabase"))
(System/exit 1)))))]
(cli/menu! (current-task)
{:id :branch :msg "What branch should we run?" :short "-b" :long "--branch BRANCH" :choices list-branches :choices-doc "list of branches" :prompt :select}
{:id :port :msg "What port should we run it on?" :short "-p" :long "--port PORT" :prompt :number :default 3337}
{:id :socket-repl :msg "What port shall we open a socket repl on?" :short "-s" :long "--socket-repl SOCKETPORT"}))))}
metabuild
{:doc "Starts metabase locally in dev mode. Set FORCE_MB_DB_CONNECTION_URI to override connection string building"
:requires [[bb.meta :as meta]]
:examples [["FORCE_MB_DB_CONNECTION_URI=mysql://localhost:3308/metabase_test?user=root bb metabuild -d mysql"
"Connect to MYSQL, running against run-mariadb-latest.sh"]]
:task (let [_ (println (c/red "Welcome to " (c/on-white (c/blue " MetaBuilder "))))
{:keys [app-db user-name password extensions db-name db-port] :as p}
(cli/menu! (current-task)
{:id :app-db
:short "-d"
:long "--database-type DB"
:title "Pick Metabase's app-db"
:choices ["postgres" "h2" "mysql"]
:prompt :select}
{:id :user-name :short "-u" :long "--username USER" :default (t/whoami)}
{:id :password :short "-p" :long "--pw PW" :default "password"}
{:id :extensions :short "-e" :long "--extensions EXT" :default ["dev" "ee" "ee-dev" "drivers" "drivers-dev" "nrepl"] :prompt :multi}
{:id :db-name
:short "-n"
:long "--name DB_NAME"
:default "metabase"
:title "Name of the database to connect to."
:prompt :text}
;; `nil` port signals intent to use default port number for a database type
{:id :db-port :title "Port the database is running on" :long "--port NUMBER" :default nil})]
;; (prn p)
(meta/build app-db user-name password extensions db-name db-port))}
quick-test
{:doc "Quickly run a test against a namespace."
:requires [[bb.quick-test :as qt]]
:task (qt/go!
(:test-namespaces (cli/menu! (current-task)
{:id :test-namespaces
:msg "What namespace(s) to test?"
:long "--ns NS"
:prompt :multi
:choices (delay (qt/test-nss))
:choices-doc "a list of clojure test namespaces"})))}
watch-ci
{:requires [[bb.dl-and-run :as dl]
[bb.watch-ci :as watch-ci]]
:doc "Watch the CI status for a branch until it passes."
:examples [["bb watch-ci --branch current" "Check currently checked out branch in MB_DIR repo"]]
:task
(do (dl/check-gh-token!)
(let [{:keys [branch]} (cli/menu! (current-task)
{:id :branch
:msg "What branch should we check?"
:short "-b"
:long "--branch BRANCH"
:choices (delay (t/list-branches (t/mb-dir)))
:choices-doc "list of branches"
:prompt :select})
branch (if (= "current" branch)
(let [current (t/current-branch)]
(do (println (c/green (c/bold "Using current branch: " (t/current-branch))))
current))
branch)]
(watch-ci/branch branch)))}
install-autotab {:doc "Prints shell code to autocomplete tasks using bb.
Note: for fish shell please make sure ~/.config/fish/completions exists."
:examples [["bb install-autotab --shell bash >> ~/.bashrc" "Bash ^"]
["bb install-autotab --shell zsh >> ~/.zshrc" "Zsh ^"]
["bb install-autotab --shell fish >> ~/.config/fish/completions/bb.fish" "Fish ^"]]
:task (let [{:keys [shell-type] :as x}
(cli/menu! (current-task)
{:id :shell-type
:long "--shell SHELL"
:title "What kind of shell?"
:choices ["zsh" "bash" "fish"]
:prompt :select})]
(println (str "\n# --- bb autocomplete follows ---\n"
(slurp (str "./bb/" shell-type "_completion.sh")))))}}}