babashka / neil

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

`neil dep add`: add latest unstable version if no stable versions are found #178

Closed teodorlu closed 1 year ago

teodorlu commented 1 year ago

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


Semantics

$ ls
$ neil-dev dep search ham-fisted
:lib com.cnuernber/ham-fisted :version "1.000-beta-90" :description nil
$ neil-dev dep add com.cnuernber/ham-fisted
$ cat deps.edn
{:deps {com.cnuernber/ham-fisted {:mvn/version "1.000-beta-90"}}
 :aliases {}}

Considerations

I renamed the old neil/latest-clojars-version to neil/latest-stable-clojars-version, and added a new neil/latest-clojars-version that accepts both stable and unstable versions.

The fallback logic as implemented increases the time a neil dep add call takes, by introducing two extra network requests:

:else
(or
 (when-let [v (:version opts)]
   [v :mvn])
 (when-let [v (latest-stable-clojars-version lib)]
   [v :mvn])
 (when-let [v (latest-stable-mvn-version lib)]
   [v :mvn])
 (when-let [v (git/latest-github-sha lib)]
   [v :git/sha])
 (when-let [v (latest-clojars-version lib)]
   [v :mvn])
 (when-let [v (latest-mvn-version lib)]
   [v :mvn]))