babashka / neil

A CLI to add common aliases and features to deps.edn-based projects
MIT License
377 stars 27 forks source link

`neil add kaocha`: normalize alias indentation #216

Closed teodorlu closed 5 months ago

teodorlu commented 5 months ago

Please answer the following questions and leave the below in as part of your PR.

Problem

This PR addresses #215. Currently, neil add kaocha may add the :kaocha alias with one fewer indent than expected, leaving a deps.edn file like this:

{:paths ["src"]
 :deps {babashka/fs {:mvn/version "0.2.16"}
        babashka/process {:mvn/version "0.4.16"}
        borkdude/edamame {:mvn/version "1.4.25"}
        cheshire/cheshire {:mvn/version "5.11.0"}
        enlive/enlive {:mvn/version "1.1.6"}
        org.babashka/cli {:mvn/version "0.6.44"}
        org.clj-commons/hickory {:mvn/version "0.7.3"}
        org.clojure/data.xml {:mvn/version "0.0.8"}}
 :aliases
 {:dev
  {:extra-paths ["dev" "test"]
   :extra-deps {io.github.nextjournal/clerk {:mvn/version "0.13.842"}}}

 :kaocha ;; added by neil
 {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
  :main-opts ["-m" "kaocha.runner"]}}}

The :dev and :kaocha aliases don't line up.

Proposed solution

Tests

I've tried to write the tests so that it's easy to see visually how indents line up.

Future work

If we merge this PR, we may consider storing kaocha-alias and nrepl-alias as clojure data. Currently, they are strings:

https://github.com/teodorlu/neil/blob/02c0fc9c68db2e9f0cd876605eb1aca6ab7a013f/src/babashka/neil.clj#L205-L209

https://github.com/teodorlu/neil/blob/02c0fc9c68db2e9f0cd876605eb1aca6ab7a013f/src/babashka/neil.clj#L225-L229

borkdude commented 5 months ago

Thanks!