diff --git a/bb.edn b/bb.edn index e42700a..0cf32eb 100644 --- a/bb.edn +++ b/bb.edn @@ -15,6 +15,7 @@ :enter (let [{:keys [name]} (current-task)] (status/line :head "TASK %s %s" name (string/join " " *command-line-args*))) :leave (let [{:keys [name]} (current-task)] (status/line :detail "\nTASK %s done." name)) ;; commands + clean {:task clean/-main :doc "delete all build work"} download-deps {:task download-deps/-main :doc "bring down Clojure deps"} apply-import-vars {:task apply-import-vars/-main :doc "(check|gen-code) - export APIs statically from templates"} dev-jvm {:task dev-repl/dev-jvm :doc "launch jvm nREPL for development, --help for usage"} diff --git a/doc/02-developer-guide.adoc b/doc/02-developer-guide.adoc index 99d7ed4..4cda414 100644 --- a/doc/02-developer-guide.adoc +++ b/doc/02-developer-guide.adoc @@ -95,6 +95,13 @@ bb lint --help Tasks are described throughout this document. +== Clean +Sometimes you want to turf any local build work and caches, you can do so via: + +---- +bb clean +---- + == Code Generation Rewrite-clj v0 used a version of potemkin import-vars. Potemkin import-vars copies specified vars from a specified namespace to the current namespace at load time. diff --git a/script/clean.clj b/script/clean.clj new file mode 100644 index 0000000..7e72e06 --- /dev/null +++ b/script/clean.clj @@ -0,0 +1,18 @@ +(ns clean + (:require [babashka.fs :as fs] + [helper.main :as main])) + +(defn -main [& args] + (when (main/doc-arg-opt args) + (println "Deleting (d=deleted -=did not exist)") + (run! (fn [d] + (println (format "[%s] %s" + (if (fs/exists? d) "d" "-") + d)) + (fs/delete-tree d {:force true})) + ["target" + ".cpcache" + ".clj-kondo/.cache" + ".lsp/.cache" + ".eastwood" + ".shadow-cljs"]))) diff --git a/script/download_deps.clj b/script/download_deps.clj index 688f76a..721a25c 100644 --- a/script/download_deps.clj +++ b/script/download_deps.clj @@ -1,9 +1,11 @@ (ns download-deps - (:require [babashka.tasks :as t])) + (:require [babashka.tasks :as t] + [helper.main :as main])) ;; clojure has a -P command, but to bring down all deps we need to specify all aliases ;; bb deps will be brought down just from running bb (which assumedly is how this code is run) -(defn -main [& _args] - ;; do all the work from build.clj to avoid repeated JVM launch costs - (t/clojure "-T:build download-deps")) +(defn -main [& args] + (when (main/doc-arg-opt args) + ;; do all the work from build.clj to avoid repeated JVM launch costs + (t/clojure "-T:build download-deps")))