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

CLI for listing available versions of a library #16

Closed
teodorlu opened this issue Apr 2, 2022 · 18 comments
Closed

CLI for listing available versions of a library #16

teodorlu opened this issue Apr 2, 2022 · 18 comments

Comments

@teodorlu
Copy link
Contributor

teodorlu commented Apr 2, 2022

WIP PR: #17

For example:

$ neil dep versions hiccup/hiccup
:lib hiccup/hiccup :version 2.0.0-alpha2
:lib hiccup/hiccup :version 2.0.0-alpha1
:lib hiccup/hiccup :version 1.0.5
:lib hiccup/hiccup :version 1.0.4
:lib hiccup/hiccup :version 1.0.3
:lib hiccup/hiccup :version 1.0.2
...

If we add this, we could create a one liner to add a specific version of a dependency to deps.edn. For example using fzf.

neil dep versions hiccup/hiccup | fzf | xargs neil add dep

Example grepping for version 1.0:

neil dep versions hiccup/hiccup | grep ":version 1.0" | fzf
@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Draft: https://github.com/teodorlu/neil

  • Supports version listing from Clojars only
  • Also contains some unrelated CLI additions (neil dep {add,versions)

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

Maybe:

neil dep versions :lib hiccup/hiccup

Two level subcommand + the rest kwargs?

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Keeping the existing :lib convention makes a lot of sense.

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Do you have a preference on neil dep ... vs neil deps ...?

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Looks like :lib is already working on my branch - I copied some of your code:

neil dep versions :lib hiccup/hiccup

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

deps does relate it to deps.edn and tools.deps so maybe that's nice? but dep is shorter to type which may be a good reason to go with that...

neil dep add ...
neil dep versions ...

I think I like that.

Maybe we should support also:

neil dep add hiccup/hiccup

without the :lib kw.

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

So when there is a single argument, :lib would be implied. Small UX tweak.

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Sounds good to me 👍

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Should the number of versions we print be configurable as an option? Does :count make sense as a key?

neil dep add :lib hiccup/hiccup :count 10

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

Yeah, I would say :limit 10 as SQL does.

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Any preference on how we should handle parsing :limit?

It doesn't strictly need to be parsed if we're just using it to create URLs. But passing around numbers as strings, and encoding that into option maps seems kind of dirty:

(defn mvn-versions [qlib {:keys [limit] :or {limit "10"}}]
  (let [payload
        (-> (curl/get (format "https://search.maven.org/solrsearch/select?q=g:%s+AND+a:%s&core=gav&rows=%s"
                              (namespace qlib)
                              (name qlib)
                              limit)
                      curl-opts)
            :body
            (cheshire/parse-string true))]
    (->> payload
         :response :docs
         (map :v))))

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

OK for now, we could parse as number whenever we need.

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

Crated a WIP PR from my current branch: #17

I've made a complete mess of the git history -- needs cleaning.

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

I'm honestly not sure about git deps. I rarely use git deps myself, so I don't feel like I know common use cases.

  • Do we ignore other forges than Github, like Gitlab and Sourcehut? Existing code seems to assume Github.
  • "Listing versions" makes sense in a Maven/Clojars world. Is a "version" a git ref? A content hash? A tag? I'm not sure.
  • What is the typical usage for Git deps?

If neil dep versions is a subcommand, does that subcommand make sense for Git?

🤔

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

We could possibly "construct" a list of options that make some kind of sense.

  1. SHA for HEAD
  2. Most recent tags

Then we'd have to print something - that ideally can be piped back into neil add dep (neil dep add if we change it).

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

@teodorlu We can ignore git deps for now.

@borkdude
Copy link
Contributor

borkdude commented Apr 2, 2022

The Clojure CLI has a way to list versions too btw, does it support git deps?

@teodorlu
Copy link
Contributor Author

teodorlu commented Apr 2, 2022

It does - it lists git tags:

clj -X:deps find-versions :lib io.github.clojure/tools.gitlibs
{:git/tag "tools.gitlibs-0.1.3"}
{:git/tag "tools.gitlibs-0.1.8"}
{:git/tag "tools.gitlibs-0.2.23"}
{:git/tag "tools.gitlibs-0.2.27"}
{:git/tag "tools.gitlibs-0.2.32"}
{:git/tag "tools.gitlibs-0.2.40"}
{:git/tag "tools.gitlibs-0.2.47"}
{:git/tag "tools.gitlibs-0.2.54"}
{:git/tag "tools.gitlibs-0.2.59"}
{:git/tag "tools.gitlibs-0.2.64"}
{:git/tag "tools.gitlibs-1.0.100"}
{:git/tag "tools.gitlibs-1.0.83"}
{:git/tag "tools.gitlibs-1.0.87"}
{:git/tag "tools.gitlibs-1.0.91"}
{:git/tag "tools.gitlibs-1.0.96"}
{:git/tag "tools.gitlibs-2.0.109"}
{:git/tag "tools.gitlibs-2.0.119"}
{:git/tag "tools.gitlibs-2.1.129"}
{:git/tag "tools.gitlibs-2.1.139"}
{:git/tag "tools.gitlibs-2.1.144"}
{:git/tag "tools.gitlibs-2.2.152"}
{:git/tag "tools.gitlibs-2.2.156"}
{:git/tag "tools.gitlibs-2.3.161"}
{:git/tag "v0.0"}
{:git/tag "v2.3.167"}
{:git/tag "v2.4.172"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants