babashka / neil

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

`neil new` puts `:neil :project :name ,,,` indented behind `:aliases :build :nsdefault` #169

Open teodorlu opened 1 year ago

teodorlu commented 1 year ago

Hi!

When I run neil new mylib, I get this deps.edn:

{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.11.1"}}
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
                io.github.cognitect-labs/test-runner
                {:git/tag "v0.5.1" :git/sha "dfb30dd"}}}
  :build {:deps {io.github.clojure/tools.build
                 {:git/tag "v0.9.2" :git/sha "fe6b140"}
                 slipset/deps-deploy {:mvn/version "0.2.0"}}
          :ns-default build} :neil {:project {:name mylib/mylib}}}}

I'd prefer if :neil {:project {:name mylib/mylib}} was on its own line, like this:

{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.11.1"}}
 :aliases
 {:test
  {:extra-paths ["test"]
   :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
                io.github.cognitect-labs/test-runner
                {:git/tag "v0.5.1" :git/sha "dfb30dd"}}}
  :build {:deps {io.github.clojure/tools.build
                 {:git/tag "v0.9.2" :git/sha "fe6b140"}
                 slipset/deps-deploy {:mvn/version "0.2.0"}}
          :ns-default build}
  :neil {:project {:name mylib/mylib}}}}

Thoughts?

$ neil --version
neil 0.1.56

Log

I'm taking some notes as I go along. I don't want to create notifications for each edit, so I batch these together in the original post rather than create comments for each step.

2023-02-21

The call that puts :neil {:project {:name ,,,}} on the end of another line rather than on its own line appears to be:

(r/assoc-in nodes [:aliases :neil :project k] v)

https://github.com/babashka/neil/blob/65a078a24462ab06fc7bc3bd5e240f4adfaa7f8a/src/babashka/neil/project.clj#L29-L38

borkdude commented 1 year ago

I'd prefer that too. Not sure why it happens, but might be something in borkdude/rewrite-edn as well. Feel free to have a peek!

agorgl commented 1 year ago

Just noticed this too!

borkdude commented 1 year ago

Feel free to post an issue + minimal repro at borkdude/rewrite-edn

teodorlu commented 1 year ago

I started to explore this with a Clerk notebook, but I didn't really get anywhere (no repro).

I believe the relevant neil function for this behavior is babashka.neil.project/assoc-project-meta!.

Happy to discuss in Slack if someone wants to give it a shot.

borkdude commented 1 year ago

I mean a repro using rewrite-edn.

teodorlu commented 11 months ago

Made an issue now. I didn't understand what you meant at first --- that this is actually something rewrite-edn is meant to handle!