Skip to content

Commit

Permalink
v0.2.63
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 13, 2023
1 parent 03cc51e commit b4d329f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

See the [New Clojure project quickstart](https://blog.michielborkent.nl/new-clojure-project-quickstart.html) blog post for a gentle introduction into `neil`.

## Unreleased
## 0.2.63

- [#194](https://github.com/babashka/neil/issues/41): `dep search` in addition to Clojars, now also searches on Maven

Expand Down
14 changes: 7 additions & 7 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
:task (gen-script/gen-script)}

bump-version {:requires ([babashka.neil :as neil]
[clojure.edn :as edn])
:task (let [version (-> (slurp "deps.edn") edn/read-string
:aliases :neil :project :version)
[major minor patch] (str/split version (re-pattern "\\."))
version (str/join "." [major minor (inc (Integer/parseInt patch))])]
(binding [*command-line-args* ["version" "set" version "--no-tag"]]
(neil/-main)))}
[clojure.edn :as edn])
:task (let [version (-> (slurp "deps.edn") edn/read-string
:aliases :neil :project :version)
[major minor patch] (str/split version (re-pattern "\\."))
version (str/join "." [major minor (inc (Integer/parseInt patch))])]
(binding [*command-line-args* ["version" "set" version "--no-tag"]]
(neil/-main)))}

update-readme {:depends [gen-script]
:task (let [help (:out (shell {:out :string} "./neil"))]
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:tools/usage {:ns-default babashka.neil.api}
:aliases
{:neil
{:project {:version "0.2.62"}}
{:project {:version "0.2.63"}}

:test ;; added by neil
{:extra-paths ["test"]
Expand Down
71 changes: 53 additions & 18 deletions neil
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
org.babashka/http-client {:mvn/version "0.1.4"}}})

(ns babashka.neil.meta)
(def version "This def was generated by the neil build script." "0.2.62")
(def version "This def was generated by the neil build script." "0.2.63")
(ns babashka.neil.utils)

;; Workaround for pmap + require which doesn't work well in bb - 2023-02-04
Expand Down Expand Up @@ -1358,22 +1358,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"
(url-encode search-term))
keys-m {:g :group_name
:a :jar_name
:timestamp :created
:latestVersion :version}
add-desc (fn [{:keys [group_name jar_name] :as m}]
;; Maven doesn't provide package description through its API,
;; but that doesn't mean we should just leave it blank
(assoc
m :description
(format "%s/%s on Maven" group_name jar_name)))
res (->> url curl-get-json :response :docs
(map #(some->
%
(clojure.set/rename-keys keys-m)
(select-keys (vals keys-m))
add-desc)))]
(if (empty? res)
(binding [*out* *err*]
(println "Unable to find" search-term "on Maven."))
res)))

(defn dep-search-clojars [search-term]
(let [url (format
"https://clojars.org/search?format=json&q=%s"
(url-encode search-term))
{search-results :results
results-count :count} (curl-get-json url)]
(if (zero? results-count)
(binding [*out* *err*]
(println "Unable to find" search-term "on Clojars."))
search-results)))

(defn dep-search [{:keys [opts]}]
(if (or (:help opts) (not (:search-term opts)))
(print-dep-search-help)
(let [search-term (:search-term opts)
url (str "https://clojars.org/search?format=json&q=" (url-encode search-term))
{search-results :results
results-count :count} (curl-get-json url)]
(when (zero? results-count)
(binding [*out* *err*]
(println "Unable to find" search-term "on Clojars.")
(System/exit 1)))
(doseq [search-result search-results]
(prn :lib (symbol (:group_name search-result)
(:jar_name search-result))
:version (:version search-result)
:description (:description search-result))))))
(let [{:keys [search-term]} opts]
(if (or (:help opts)
(not (string? search-term))
(str/blank? search-term))
(print-dep-search-help)
(let [search-results (->> [dep-search-maven
dep-search-clojars]
(map #(% search-term))
(apply concat))]
(when (empty? search-results) (System/exit 1))
(doseq [search-result search-results]
(prn :lib (symbol (:group_name search-result)
(:jar_name search-result))
:version (:version search-result)
:description (:description search-result)))))))

(defn git-url->lib [git-url]
(when git-url
Expand Down Expand Up @@ -1531,7 +1567,7 @@ Examples:
neil dep upgrade ; upgrade all deps.
neil dep upgrade --dry-run ; print deps that would be upgraded.
neil dep upgrade --alias lint` ; update only deps for the `lint` alias.
neil dep upgrade --alias lint ; update only deps for the `lint` alias.
neil dep upgrade :lib clj-kondo/clj-kondo ; update a single dep.
"))
(System/exit 0))
Expand Down Expand Up @@ -1561,7 +1597,6 @@ Examples:

(doseq [dep-upgrade upgrades] (do-dep-upgrade opts dep-upgrade))))


(defn print-help [_]
(println (str/trim "
Usage: neil <subcommand> <options>
Expand Down

0 comments on commit b4d329f

Please sign in to comment.