From b4d329fc8d419d01b6290eb93343e16dcdcd088e Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 13 Nov 2023 11:35:42 +0100 Subject: [PATCH] v0.2.63 --- CHANGELOG.md | 2 +- bb.edn | 14 +++++------ deps.edn | 2 +- neil | 71 +++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 62 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f24edbd..d3836ec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bb.edn b/bb.edn index 0616ba34..c047576f 100644 --- a/bb.edn +++ b/bb.edn @@ -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"))] diff --git a/deps.edn b/deps.edn index b7bded2f..731b338e 100644 --- a/deps.edn +++ b/deps.edn @@ -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"] diff --git a/neil b/neil index 5f161e6d..44ff853d 100755 --- a/neil +++ b/neil @@ -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 @@ -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 @@ -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)) @@ -1561,7 +1597,6 @@ Examples: (doseq [dep-upgrade upgrades] (do-dep-upgrade opts dep-upgrade)))) - (defn print-help [_] (println (str/trim " Usage: neil