{:min-bb-version "1.12.212" ;; we put path as bin, and everything is in the ./mage subdirectory, ;; so the namespaces are mage.cli, mage.format, etc. ;; dev/src is here for tasks whose logic is shared with JVM tests (e.g. dev.kondo-ratchet) ;; Let Mage use the same module-resolution rules as the Kondo hooks. :paths ["mage/src" "mage/test" "bin/lint-migrations-file/src" "dev/src" ".clj-kondo/src"] ;; use Git version of dep temporarily until a new release > 0.16.4 is cut :deps {dev.weavejester/cljfmt {:git/sha "075eae26e3c8dad433b88f05927bcd50e3571328" :git/url "https://github.com/weavejester/cljfmt"} ;; run cljfmt from bb io.github.paintparty/bling {:mvn/version "0.8.8"} ;; printing bells and whistles medley/medley {:mvn/version "1.3.0"} ;; utilities metosin/malli {:mvn/version "0.17.0"} ;; data validation mvxcvi/puget {:mvn/version "1.3.4"} ;; pretty printing org.babashka/json {:mvn/version "0.1.6"} ;; json parsing table/table {:mvn/version "0.5.0"} ;; table printing } ;; No :pods key on purpose: tasks lazily load only what they need. :tasks {:requires [[mage.cli :as cli] [mage.color :as c]] :init (do (defmacro task! "Binds the parsed command line arguments to `parsed`." [& body] ;; Can't use ` in this file because it is strictly edn! (list 'let (vector 'parsed (list 'cli/parse! (list 'current-task))) (cons 'do body)))) alias {:doc "Installs 'mage' alias and autocomplete" :examples [["./bin/mage alias" "Prints instructions to install the 'mage' alias and autocomplete"] ["./bin/mage alias install fish" "Installs mage alias for fish shell"] ["./bin/mage alias print zsh" "Prints shell script to put into .zshrc for zsh users"]] :requires [[mage.alias :as alias]] :arg-schema [:or [:tuple [:enum {:name "shell-type"} "bash" "zsh" "fish"]] [:tuple [:enum {:name "mode"} "install" "print"] [:enum {:name "shell-type"} "bash" "zsh" "fish"]]] :task (task! (alias/instructions parsed))} cljfmt-staged {:doc "Runs cljfmt on staged files" :requires [[mage.format :as format]] :examples [["./bin/mage cljfmt-staged" "Format staged files"] ["./bin/mage cljfmt-staged -c" "Check staged files"]] :options [["-c" "--force-check" "Check staged files"]] :task (task! (format/staged parsed))} cljfmt-files {:doc "Runs cljfmt on the given files/directories" :requires [[mage.format :as format]] :examples [["./bin/mage cljfmt-files src/metabase/events.clj" "Format events.clj"] ["./bin/mage cljfmt-files src" "Format all files in src"] ["./bin/mage cljfmt-files -c src" "Check all files in src"]] :options [["-c" "--force-check" "Check staged files"]] :arg-schema [:sequential [:string {:name "file-or-directory" :description "Files or directories to format."}]] :task (task! (format/files parsed))} cljfmt-all {:doc "Runs cljfmt on all (clojure) files" :requires [[mage.format :as format]] :examples [["./bin/mage cljfmt-all" "Format all files"]] :options [["-c" "--force-check" "Check staged files"]] :task (task! (format/all parsed))} cljfmt-updated {:doc "Runs cljfmt on all (Clojure) files relative to a git ref (default HEAD)" :requires [[mage.format :as format]] :examples [["./bin/mage cljfmt-updated" "Format updated files relative to HEAD"] ["./bin/mage cljfmt-updated master" "Format updated files relative to master"]] :options [["-c" "--force-check" "Check staged files"]] :arg-schema [:or [:tuple] [:tuple [:string {:name "git-ref" :description "Git ref to compare against"}]]] :task (task! (format/updated parsed))} kondo {:doc "Runs Kondo against a file, directory, or everything we usually lint" :examples [["./bin/mage kondo" "run Kondo against everything we usually lint"] ["./bin/mage kondo src/metabase/db.clj" "run Kondo against a file"] ["./bin/mage kondo src/metabase/db.clj src/metabase/config.clj" "run Kondo against 2 files"] ["./bin/mage kondo src/metabase/api/macros" "run Kondo against a directory"]] :requires [[mage.kondo :as kondo]] :task (task! (kondo/kondo (:arguments parsed)))} kondo-updated {:doc "Runs kondo against files changed compared to a git ref" :examples [["./bin/mage kondo-updated" "run Kondo on files with changes relative to HEAD"] ["./bin/mage kondo-updated master" "run Kondo on files with changes relative to master"]] :requires [[mage.kondo :as kondo]] :task (task! (kondo/kondo-updated (:arguments parsed)))} fix-unused-requires {:doc "Removes unused requires flagged by clj-kondo" :examples [["./bin/mage fix-unused-requires src/metabase/utils/validate.cljc" "Fix unused requires in a specific file"] ["./bin/mage fix-unused-requires src" "Fix unused requires in all files in src"]] :requires [[mage.fix-unused-requires :as fix]] :arg-schema [:sequential [:string {:name "file-or-directory" :description "Files or directories to fix unused requires in"}]] :task (task! (fix/fix-files parsed))} load-namespaces {:doc "Checks that every shipped namespace loads without :dev dependencies (and finds circular dependencies)" :examples [["./bin/mage load-namespaces"]] :requires [[mage.load-namespaces]] :arg-schema [:tuple] :task (task! (mage.load-namespaces/load-namespaces))} codespell {:doc "Check for misspellings in the source code." :examples [["./bin/mage codespell"]] :requires [[mage.codespell]] :task (task! (mage.codespell/codespell (:arguments parsed)))} codespell-interactive {:doc "Check for misspellings in the source code, and interactively prompt to fix them." :examples [["./bin/mage codespell-interactive"]] :requires [[mage.codespell]] :task (task! (mage.codespell/codespell-interactive (:arguments parsed)))} start-maildev {:doc "Start Maildev" :examples [["./bin/mage start-maildev -h" "print help for start-maildev"]] :requires [[mage.start-maildev :as start-maildev]] :task (task! (start-maildev/start-maildev!))} tail-d {:doc "Tail the #d debug log in real time (see dev.debug). Asks the running REPL for the exact path; falls back to DEV_DEBUG_LOG or /tmp/