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

adds maven for dep search #194

Merged
merged 12 commits into from
Nov 12, 2023
Merged

Conversation

agzam
Copy link
Contributor

@agzam agzam commented Nov 11, 2023

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

Aww. Only after figuring this out I just realized there's #162 with a comment. Just following and grabbing that code would've been maybe simpler 🤦

Tested with the following:

$> ./neil dep search clojure
./neil dep search clojure
;; Tons of results from both Maven and Clojars

$> ./neil dep search "org.clojure/clojurescript"

./neil dep search "org.clojure/clojurescript"
Unable to find org.clojure/clojurescript on Clojars.
:lib org.clojure/clojurescript :version "1.11.121" :description "org.clojure/clojurescript on Maven"


$> ./neil dep search "org.clojure/clojure"

./neil dep search "org.clojure/clojure"
Unable to find org.clojure/clojure on Clojars.
:lib org.clojure/clojure-install :version "0.1.21" :description "org.clojure/clojure-install on Maven"
:lib org.clojure/clojure-contrib :version "1.2.0" :description "org.clojure/clojure-contrib on Maven"
:lib org.clojure/clojure :version "1.12.0-alpha5" :description "org.clojure/clojure on Maven"


$> ./neil dep search "clojurefoo"
./neil dep search "clojurefoo"
Unable to find clojurefoo on Maven.
Unable to find clojurefoo on Clojars.


$> ./neil dep search ""
;; produces help info

$> ./neil dep search 123
;; produces help info

$> ./neil dep search '123'
;; produces help info

Also neil.el was adjusted for the changes

src/babashka/neil.clj Outdated Show resolved Hide resolved
@agzam agzam marked this pull request as ready for review November 11, 2023 21:09
@agzam agzam force-pushed the add-maven-for-dep-search branch from c6bcddd to 68a6789 Compare November 11, 2023 21:21
@borkdude
Copy link
Contributor

If this is still a work in progress, can you mark the PR as draft? And then ping me for a review when done?

previously, it would yank search results like this:

```
org.clojure/clojure {:mvn/version \"1.12.0-alpha5\"}
```
@agzam agzam marked this pull request as draft November 11, 2023 21:37
previously if would fail if nothing found on Clojars, even if there are
some packages found on Maven
@agzam agzam force-pushed the add-maven-for-dep-search branch from 0bb7f7d to e19b34c Compare November 11, 2023 22:06
@agzam agzam force-pushed the add-maven-for-dep-search branch from 07a1cef to f102a03 Compare November 11, 2023 22:20
@agzam agzam force-pushed the add-maven-for-dep-search branch from 5b6efc7 to 1a46637 Compare November 11, 2023 22:39
@agzam agzam marked this pull request as ready for review November 11, 2023 22:42
@agzam agzam requested a review from borkdude November 11, 2023 22:42
@agzam
Copy link
Contributor Author

agzam commented Nov 11, 2023

If this is still a work in progress, can you mark the PR as draft? And then ping me for a review when done?

Apologies for constantly buzzing you with change notifications. I thought I was done, but then I realized that Emacs counterpart needs updating too.
Seemingly small change turned out to be a bit tricky. It's all good now - I checked it with different inputs. Thank you for your patience.

@borkdude
Copy link
Contributor

Great, I'll have a look tomorrow!

previously it would use the list of packages pulled from examples in
help screen
@borkdude
Copy link
Contributor

Aww. Only after figuring this out I just realized there's #162 with a comment. Just following and grabbing that code would've been maybe simpler 🤦

Do you still want give action to this or keep your current code?

@agzam
Copy link
Contributor Author

agzam commented Nov 12, 2023

Do you still want give action to this or keep your current code?

I glanced over it, looks like it does pretty much almost the same thing. Either way, the bottom line - it works. If you have no objections, perhaps let's merge it and close both tickets. wdyt?

Oh wait. I stand corrected. It also adds GitHub too. We can leave "improve search" ticket open. I may take a look and try adding GH at some point.

@@ -500,22 +500,58 @@ will return libraries with 'test framework' in their description.
See http://github.com/clojars/clojars-web/wiki/Search-Query-Syntax for
details on the search syntax.")))

(defn dep-search-maven [search-term]
(let [url (format
"https://search.maven.org/solrsearch/select?q=%s&rows=20&wt=json"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number may seem speculative, no? I copypasted it as is from the documentation. Should we leave it at that or maybe increase it, I don't know to 50 or even more? But is it even sensible to try to get more results than this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know to be honest

@borkdude
Copy link
Contributor

I think adding a test here would be in order:

neil/tests.clj

Lines 78 to 91 in ff7aca4

(deftest dep-search-test
(is (thrown? java.lang.Exception (run-dep-subcommand "search" "someBougusLibThatDoesntExist")))
(is (not-empty (run-dep-subcommand "search" "hiccups")))
(is (some #(str/starts-with? % ":lib hiccups/hiccups")
(run-dep-subcommand "search" "hiccups")))
(is (some #(re-matches #":lib hiccups/hiccups :version \"\d+(\.\d+)+\" :description .*" %)
(run-dep-subcommand "search" "hiccups")))
(is (some #(re-matches #":lib macchiato/hiccups :version \"\d+(\.\d+)+\" :description .*" %)
(run-dep-subcommand "search" "hiccups")))
; tests for no NPEs/json parsing exceptions
#_(is (any? (run-dep-subcommand "search" "org.clojure/tools.cli")))
(is (any? (run-dep-subcommand "search" "babashka nrepl")))
(is (thrown-with-msg? Exception #"Unable to find"
(run-dep-subcommand "search" "%22searchTermThatIsn'tFound"))))

E.g. a test which searches for clojure on maven. After that, I think it'd be good to merge.

Suggested-by: Michiel Borkent <[email protected]>
@borkdude borkdude merged commit 03cc51e into babashka:main Nov 12, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants