meyvn.nrepl_middleware.state.clj Maven / Gradle / Ivy
The newest version!
(ns meyvn.nrepl-middleware.state
(:refer-clojure :exclude [update])
(:require [meyvn.nrepl-middleware.clojars :as clojars]
[meyvn.nrepl-middleware.maven :as maven]
[clojure.core.memoize :as memo]
[clojure.tools.logging :as log]
[clojure.string :as str]))
(def catalog (agent {:entries nil
:clojars {:count 0}
:maven {:count 0}}))
(add-watch catalog :watcher (fn [k _ _ n]
(log/info "Meyvn has updated the deps catalog." k "found" (+ (get-in n [:maven :count]) (get-in n [:clojars :count])) "deps.")))
(defn get-data []
(let [clojars (clojars/catalog)
maven (maven/catalog)]
{:clojars {:count (count clojars)}
:maven {:count (count maven)}
:entries (->> (concat maven clojars)
(str/join "\n"))}))
(def update #(send catalog merge (get-data)))
(defn get-versions [artifact]
(if (str/starts-with? artifact "org.clojure")
(maven/versions artifact)
(clojars/versions artifact)))
(def versions
(memo/ttl get-versions {} :ttl/threshold 3600000))
© 2015 - 2024 Weber Informatics LLC | Privacy Policy