|
1 | 1 | {:min-bb-version "0.9.162" |
2 | | - :paths ["bb"] |
| 2 | + :paths ["."] |
3 | 3 | :deps {escherize/bask {:git/url "https://github.com/escherize/bask.git" |
4 | 4 | :git/sha "81cc9af3021d7689cfbddf0518a1e828f785f006"} |
5 | 5 | table/table {:mvn/version "0.5.0"}} |
6 | | - :tasks {:requires [[bask.colors :as c] |
| 6 | + :tasks {:requires [[babashka.process :refer [shell]] |
| 7 | + [bask.colors :as c] |
7 | 8 | [bb.cli :as cli] |
8 | 9 | [bb.tasks :as t] |
9 | 10 | [clojure.string :as str]] |
|
28 | 29 | {:id :port :msg "What port should we run it on?" :short "-p" :long "--port PORT" :prompt :number :default 3337} |
29 | 30 | {:id :socket-repl :msg "What port shall we open a socket repl on?" :short "-s" :long "--socket-repl SOCKETPORT"}))))} |
30 | 31 |
|
31 | | - check-branch |
32 | | - {:requires [[bb.dl-and-run :as dl]] |
33 | | - :doc "Check the status of a branch in CI." |
34 | | - :examples [["bb check-branch --branch master" "Check master branch github checks"]] |
35 | | - :task |
36 | | - (do (dl/check-gh-token!) |
37 | | - (let [branch-info (cli/menu! (current-task) |
38 | | - {:id :branch |
39 | | - :msg "What branch should we check?" |
40 | | - :short "-b" |
41 | | - :long "--branch BRANCH" |
42 | | - :choices (delay (t/list-branches (t/mb-env))) |
43 | | - :choices-doc "list of branches" |
44 | | - :prompt :select} |
45 | | - {:id :watch? |
46 | | - :msg "Watch until success?" |
47 | | - :short "-w" |
48 | | - :long "--watch"})] |
49 | | - (if (:watch? branch-info) |
50 | | - (loop [] |
51 | | - (let [check (dl/checks-for-branch branch-info)] |
52 | | - (println (str "\n----------[ " |
53 | | - (.format (java.text.SimpleDateFormat. "hh:mm:ss a") (java.util.Date.)) |
54 | | - " ]")) |
55 | | - (doseq [[s c] check] |
56 | | - (println (dl/pretty s) s (str "(" c ") "))) |
57 | | - (when-not (= (keys check) [:success]) |
58 | | - (Thread/sleep 5000) |
59 | | - (recur)))) |
60 | | - (doseq [[s c] (dl/checks-for-branch branch-info)] |
61 | | - (println (dl/pretty s) s (str "(" c ") "))))))} |
62 | | - |
63 | 32 | metabuild |
64 | 33 | {:doc "Starts metabase locally in dev mode. Set FORCE_MB_DB_CONNECTION_URI to override connection string building" |
65 | 34 | :requires [[bb.meta :as meta]] |
66 | 35 | :examples [["FORCE_MB_DB_CONNECTION_URI=mysql://localhost:3308/metabase_test?user=root bb metabuild -d mysql" |
67 | 36 | "Connect to MYSQL, running against run-mariadb-latest.sh"]] |
68 | | - :task (let [{:keys [app-db user-name password extensions] :as p} |
| 37 | + :task (let [_ (println (c/red "Welcome to " (c/on-white (c/blue " MetaBuilder ")))) |
| 38 | + {:keys [app-db user-name password extensions] :as p} |
69 | 39 | (cli/menu! (current-task) |
70 | | - {:id :app-db :short "-d" :long "--database-type DB" :title "Which DB should we use for metabase's data?" :choices ["postgres" "h2" "mysql"] :required? true :prompt :select} |
71 | | - {:id :user-name :short "-u" :long "--username USER" :default (t/whoami)} |
72 | | - {:id :password :short "-p" :long "--pw PW" :default "password"} |
73 | | - {:id :extensions :short "-e" :long "--exensions EXT" :default ["dev" "ee" "ee-dev" "drivers" "drivers-dev" "cider/nrepl"] :prompt :multi} |
74 | | - {:id :db-name :short "-n" :long "--name DB_NAME" :default "metabase" :required? true :title "Name of the database to connect to." :prompt :text})] |
| 40 | + {:id :app-db |
| 41 | + :short "-d" |
| 42 | + :long "--database-type DB" |
| 43 | + :title "Pick Metabase's app-db" |
| 44 | + :choices ["postgres" "h2" "mysql"] |
| 45 | + :prompt :select} |
| 46 | + {:id :user-name :short "-u" :long "--username USER" :default (t/whoami)} |
| 47 | + {:id :password :short "-p" :long "--pw PW" :default "password"} |
| 48 | + {:id :extensions :short "-e" :long "--extensions EXT" :default ["dev" "ee" "ee-dev" "drivers" "drivers-dev" "cider/nrepl"] :prompt :multi} |
| 49 | + {:id :db-name |
| 50 | + :short "-n" |
| 51 | + :long "--name DB_NAME" |
| 52 | + :default "metabase" |
| 53 | + :title "Name of the database to connect to." |
| 54 | + :prompt :text})] |
75 | 55 | ;; (prn p) |
76 | 56 | (meta/build app-db user-name password extensions))} |
77 | 57 |
|
78 | | - quick-test {:doc "Quickly run a test against a namespace." |
79 | | - :requires [[bb.quick-test :as qt]] |
80 | | - :task (qt/go! |
81 | | - (:test-namespaces (cli/menu! (current-task) |
82 | | - {:id :test-namespaces |
83 | | - :msg "What namespace(s) to test?" |
84 | | - :long "--ns NS" |
85 | | - :required? true |
86 | | - :prompt :multi |
87 | | - :choices (delay (qt/test-nss)) |
88 | | - :choices-doc "a list of clojure test namespaces"})))} |
| 58 | + quick-test |
| 59 | + {:doc "Quickly run a test against a namespace." |
| 60 | + :requires [[bb.quick-test :as qt]] |
| 61 | + :task (qt/go! |
| 62 | + (:test-namespaces (cli/menu! (current-task) |
| 63 | + {:id :test-namespaces |
| 64 | + :msg "What namespace(s) to test?" |
| 65 | + :long "--ns NS" |
| 66 | + :prompt :multi |
| 67 | + :choices (delay (qt/test-nss)) |
| 68 | + :choices-doc "a list of clojure test namespaces"})))} |
| 69 | + |
| 70 | + watch-ci |
| 71 | + {:requires [[bb.dl-and-run :as dl] |
| 72 | + [clojure.pprint :as pp]] |
| 73 | + :doc "Watch the CI status for a branch until it passes." |
| 74 | + :examples [["bb watch-ci --branch current" "Check currently checked out branch in MB_DIR repo"]] |
| 75 | + :task |
| 76 | + (do (dl/check-gh-token!) |
| 77 | + (let [{:keys [branch]} (cli/menu! (current-task) |
| 78 | + {:id :branch |
| 79 | + :msg "What branch should we check?" |
| 80 | + :short "-b" |
| 81 | + :long "--branch BRANCH" |
| 82 | + :choices (delay (t/list-branches (t/mb-env))) |
| 83 | + :choices-doc "list of branches" |
| 84 | + :prompt :select}) |
| 85 | + branch (if (= "current" branch) |
| 86 | + (let [current (str/trim |
| 87 | + (:out (shell {:dir (t/env "MB_DIR" (fn [] |
| 88 | + (println "Please set MB_DIR to your metabase repo!") |
| 89 | + (System/exit 1))) :out :string} |
| 90 | + "git rev-parse --abbrev-ref HEAD")))] |
| 91 | + (do (println (c/green (c/bold "Checking current branch: " current))) |
| 92 | + current)) |
| 93 | + branch)] |
| 94 | + (pp/pprint dl/pretty) |
| 95 | + (loop [] |
| 96 | + (let [check (dl/checks-for-branch branch)] |
| 97 | + (print (str "\n[ " (.format (java.text.SimpleDateFormat. "hh:mm:ss a") (java.util.Date.)) " ]")) |
| 98 | + (doseq [[status count] check] (print (str/join (repeat count (dl/pretty status)))) (print "|")) (flush) |
| 99 | + (when-not (= (keys check) [:success]) |
| 100 | + (Thread/sleep 10000) (recur))))))} |
89 | 101 |
|
90 | 102 | install-autotab {:doc "Prints shell code to autocomplete tasks using bb. |
91 | 103 | Note: for fish shell please make sure ~/.config/fish/completions exists." |
|
96 | 108 | (cli/menu! (current-task) |
97 | 109 | {:id :shell-type |
98 | 110 | :long "--shell SHELL" |
99 | | - :required? true |
100 | 111 | :title "What kind of shell?" |
101 | 112 | :choices ["zsh" "bash" "fish"] |
102 | 113 | :prompt :select})] |
|
0 commit comments