Context
Our lein-template adds ;; Please keep the dependencies sorted a-z. before the :dependencies-key in project.clj.
There's benefits for sorting this list (friction-free merges, improves readability, ..)
Task
We need a formatter to sort the dependency list
Acceptance criteria
dependency sorting:
(defproject corpus "unreleased"
:dependencies [[c]
[a]])
should be formatted to
(defproject corpus "unreleased"
:dependencies [[a]
[c]])
:exclusion sorting
(defproject corpus "unreleased"
:dependencies [[a
:exclusions [c b]])
should be formatted to
(defproject corpus "unreleased"
:dependencies [[a
:exclusions [b
c]])
note the formatted newlines
Additional resources
inspiration for replacement of the :dependencies can be found here:
|
(speced/defn replace-ns-form! |
sorting might be something like:
(let [deps '[[c]
[a :exclusions [c b]]]]
(->> deps
(mapv (fn [clause]
(let [exclusion-index (.indexOf clause :exclusions)]
(if (> 0 exclusion-index)
clause
(update clause (inc exclusion-index) (comp vec sort))))))
(sort-by first)
(vec)))
=> [[a :exclusions [b c]] [c]]
Context
Our lein-template adds
;; Please keep the dependencies sorted a-z.before the:dependencies-key in project.clj.There's benefits for sorting this list (friction-free merges, improves readability, ..)
Task
We need a formatter to sort the dependency list
Acceptance criteria
dependency sorting:
should be formatted to
:exclusionsortingshould be formatted to
note the formatted newlines
Additional resources
inspiration for replacement of the :dependencies can be found here:
formatting-stack/src/formatting_stack/util/ns.clj
Line 59 in 2b7f0e5
sorting might be something like: