Skip to content

Commit beaa226

Browse files
committed
refactor-nrepl.artifacts: increase resiliency
Fixes #382
1 parent c2f629d commit beaa226

File tree

6 files changed

+46
-32
lines changed

6 files changed

+46
-32
lines changed

.clj-kondo/config.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
:unresolved-symbol {:exclude [(refactor-nrepl.ns.ns-parser/with-libspecs-from [libspecs])
4242
(refactor-nrepl.middleware/set-descriptor! [set-descriptor!])]}
4343
:unresolved-namespace {:exclude [clojure.main]}
44+
:unresolved-var {:exclude [org.httpkit.client/get]}
4445
;; for integration tests:
4546
:unused-namespace {:exclude [sample.unused.namespace
4647
"more.unused.namespaces*"]}}}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## 3.5.3
6+
7+
* [#382](https://github.com/clojure-emacs/refactor-nrepl/issues/382): `refactor-nrepl.artifacts`: increase resiliency.
8+
59
## 3.5.2
610

711
* [#378](https://github.com/clojure-emacs/refactor-nrepl/issues/378): Fix `:as-alias` handling for .cljc files.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Be aware that this isn't the case if you connect to an already running REPL proc
2626
Add the following, either in your project's `project.clj`, or in the `:user` profile found at `~/.lein/profiles.clj`:
2727

2828
```clojure
29-
:plugins [[refactor-nrepl "3.5.2"]
29+
:plugins [[refactor-nrepl "3.5.3"]
3030
[cider/cider-nrepl "0.28.3"]]
3131
```
3232

@@ -360,12 +360,12 @@ If you want to use `mranderson` while developing locally with the REPL, the sour
360360

361361
When you want to release locally to the following:
362362

363-
PROJECT_VERSION=3.5.2 make install
363+
PROJECT_VERSION=3.5.3 make install
364364

365365
And here's how to deploy to Clojars:
366366

367367
```bash
368-
git tag -a v3.5.2 -m "3.5.2"
368+
git tag -a v3.5.3 -m "3.5.3"
369369
git push --tags
370370
```
371371

project.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@
6969
with-debug-bindings [[:inner 0]]
7070
merge-meta [[:inner 0]]
7171
try-if-let [[:block 1]]}}}]
72-
:eastwood {:plugins [[jonase/eastwood "1.2.2"]]
72+
:eastwood {:plugins [[jonase/eastwood "1.2.3"]]
7373
:eastwood {;; :implicit-dependencies would fail spuriously when the CI matrix runs for Clojure < 1.10,
7474
;; because :implicit-dependencies can only work for a certain corner case starting from 1.10.
7575
:exclude-linters [:implicit-dependencies]
7676
:exclude-namespaces [refactor-nrepl.plugin]
7777
:add-linters [:performance :boxed-math]
7878
:config-files ["eastwood.clj"]}}
7979
:clj-kondo [:test
80-
{:dependencies [[clj-kondo "2021.12.19"]]}]
80+
{:dependencies [[clj-kondo "2022.06.22"]]}]
8181

8282
:deploy {:source-paths [".circleci/deploy"]}}
8383

src/refactor_nrepl/artifacts.clj

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,50 @@
7272
(let [search-prefix "https://search.maven.org/solrsearch/select?q=g:%22"
7373
search-suffix "%22+AND+p:%22jar%22&rows=2000&wt=json"
7474
search-url (str search-prefix group-id search-suffix)
75-
{:keys [_ _ body _]} @(http/get search-url (assoc (get-proxy-opts) :as :text))
76-
search-result (json/read-str body :key-fn keyword)]
77-
(->> search-result
78-
:response
79-
:docs
80-
(keep :a))))
75+
p (http/get search-url (assoc (get-proxy-opts) :as :text))
76+
{:keys [_ _ body _]} (deref p 7000 {})]
77+
(if (empty? body)
78+
[]
79+
(->> (json/read-str body :key-fn keyword)
80+
:response
81+
:docs
82+
(keep :a)))))
8183

8284
(defn- get-mvn-versions!
8385
"Fetches all the versions of particular artifact from maven repository."
8486
[artifact]
8587
(let [[group-id artifact] (str/split artifact #"/")
8688
search-prefix "https://search.maven.org/solrsearch/select?q=g:%22"
87-
{:keys [_ _ body _]} @(http/get (str search-prefix
88-
group-id
89-
"%22+AND+a:%22"
90-
artifact
91-
"%22&core=gav&rows=100&wt=json")
92-
(assoc (get-proxy-opts) :as :text))]
93-
(->> (json/read-str body :key-fn keyword)
94-
:response
95-
:docs
96-
(keep :v))))
97-
98-
(defn- get-artifacts-from-mvn-central!
99-
[]
100-
(let [group-ids #{"com.cognitect" "org.clojure"}]
101-
(mapcat (fn [group-id]
102-
(->> (get-mvn-artifacts! group-id)
103-
(map #(vector (str group-id "/" %) nil))))
104-
group-ids)))
89+
p (http/get (str search-prefix
90+
group-id
91+
"%22+AND+a:%22"
92+
artifact
93+
"%22&core=gav&rows=100&wt=json")
94+
(assoc (get-proxy-opts) :as :text))
95+
{:keys [_ _ body _]} (deref p 7000 {})]
96+
(if (empty? body)
97+
[]
98+
(->> (json/read-str body :key-fn keyword)
99+
:response
100+
:docs
101+
(keep :v)))))
102+
103+
(defn- get-artifacts-from-mvn-central! []
104+
(->> ["org.clojure" "com.cognitect"]
105+
(pmap (fn [group-id]
106+
(->> group-id
107+
get-mvn-artifacts!
108+
(mapv (fn [artifact]
109+
[(str group-id "/" artifact),
110+
nil])))))
111+
(reduce into [])))
105112

106113
(defn get-clojars-versions!
107114
"Fetches all the versions of particular artifact from Clojars."
108115
[artifact]
109-
(let [{:keys [body status]} @(http/get (str "https://clojars.org/api/artifacts/"
110-
artifact))]
116+
(let [p (http/get (str "https://clojars.org/api/artifacts/"
117+
artifact))
118+
{:keys [body status]} (deref p 7000 {})]
111119
(when (= 200 status)
112120
(->> (json/read-str body :key-fn keyword)
113121
:recent_versions

src/refactor_nrepl/core.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,9 @@
435435
(catch Exception _e
436436
(throw (IllegalArgumentException. "Malformed ns form!")))))))
437437

438-
(defn ^String fully-qualify
438+
(defn fully-qualify
439439
"Create a fully qualified name from name and ns."
440+
^String
440441
[ns name]
441442
(let [prefix (str ns)
442443
suffix (suffix name)]

0 commit comments

Comments
 (0)