Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use merged deps config by default, optionally specify --no-merge-config #14

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions src/cambada/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
[["-d" "--deps FILE_PATH" "Location of deps.edn file"
:default "deps.edn"]

[nil "--[no-]merge-config" "Merges various deps.edn files according to tools.deps by default"
:default true]

["-o" "--out PATH" "Output directory"
:default "target"]

Expand All @@ -55,27 +58,25 @@
[args cli-options]
(cli/parse-opts args cli-options))

(defn ^:private conj-default-paths [{:keys [paths] :as m}]
(assoc m :paths
(-> paths
set
(conj "src")
vec)))
(defn ^:private config-files
"Read clojure env to get config files and append deps if not already present.
Returns a vector of strings which represent the config files"
[deps]
(let [{:keys [config-files]} (deps.reader/clojure-env)]
(cond-> config-files
(not= deps (last config-files)) (conj deps))))

(defn ^:private assoc-default-deps [{:keys [deps] :or {deps {}} :as m}]
(cond-> m
(nil? (get deps 'org.clojure/clojure))
(assoc :deps (assoc deps 'org.clojure/clojure {:mvn/version "1.9.0"}))))
(defn ^:private cli-options->deps-map
[{:keys [deps merge-config]}]
(if merge-config
(deps.reader/read-deps (config-files deps))
(-> deps io/file deps.reader/slurp-deps)))

(defn ^:private parsed-opts->task
[{{:keys [deps main aot] :as options} :options
:keys [summary errors]}]
(try
(let [deps-map (-> deps
io/file
deps.reader/slurp-deps
conj-default-paths
assoc-default-deps)
(let [deps-map (cli-options->deps-map options)
opts (cond-> options
;; if main is not nil, it needs to be added to aot
;; unless user chose all or main has been added
Expand Down