find deps
1.0.0
find-deps可協助您透過 Clojars 和 Maven 搜尋 API 快速尋找依賴項。透過命令列或 REPL 使用它。
find-deps利用 clj-fuzzy 來優化從儲存庫 API 傳回的搜尋結果。它還考慮依賴項的新鮮度以及依賴項組 ID 的流行度。我們希望每次都能得到近乎完美的建議!
請參閱下面的“未來”部分,以了解可以採取哪些措施的一些想法。特別是,如果能夠在 github 上搜尋deps.edn
檔案就太好了…
在目前的 deps.edn 中新增依賴項,如下所示:
clj -A:find-deps -F:save priority-map
若要從命令列使用find-deps ,請在 ~/.clojure/deps.edn 映射中建立別名:
{ :aliases { :find-deps { :extra-deps
{find-deps
{ :git/url " https://github.com/hagmonk/find-deps " ,
:sha " 6fc73813aafdd2288260abb2160ce0d4cdbac8be " }},
:main-opts [ " -m " " find-deps.core " ]}}}
您可以使用-h
呼叫find-deps來查看支援的選項:
% clj -A:find-deps -h
find-deps
Usage: [options * ] [search-strings * ]
Options:
-s, --sources SOURCES :clojars:mvn Concatenated source types
-R, --rank METHOD :fuzzy Ranking method - :fuzzy, :regex
-F, --format FORMAT :deps Format for printing results - :deps, :merge, :table, :save, :cli
-l, --limit NUM 1 Limit per-search results to NUM
-h, --help
搜尋像 http-kit 這樣的依賴項:
clj -A:find-deps http-kit
{ :deps {http-kit/http-kit { :mvn/version " 2.3.0 " }}}
搜尋多個相依性:
clj -A:find-deps http-kit tools.logging priority-map
{ :deps
{http-kit/http-kit { :mvn/version " 2.3.0 " },
org.clojure/tools.logging { :mvn/version " 0.5.0-alpha " },
org.clojure/data.priority-map { :mvn/version " 0.0.9 " }}}
使用不同的查詢參數將多個呼叫連結在一起:
clj -A:find-deps -s:mvn roaringbitmap | clj -A:find-deps -s:clojars -R:regex -l 5 io.pedestal
{ :deps
{org.roaringbitmap/RoaringBitmap { :mvn/version " 0.7.13 " },
io.pedestal/pedestal.jetty { :mvn/version " 0.5.3 " },
io.pedestal/pedestal.tomcat { :mvn/version " 0.5.3 " },
io.pedestal/pedestal.log { :mvn/version " 0.5.3 " },
io.pedestal/pedestal.service { :mvn/version " 0.5.3 " },
io.pedestal/pedestal.interceptor { :mvn/version " 0.5.3 " }}}
將搜尋結果合併到目前項目的deps.edn
中。您也可以透過指定:save
將這些結果儲存到 deps.edn 中。
clj -A:find-deps -F:merge http-kit tools.logging priority-map
{ :paths [ " src " ],
:deps
{org.clojure/clojure { :mvn/version " 1.9.0 " },
org.clojure/tools.logging { :mvn/version " 0.5.0-alpha " },
org.clojure/spec.alpha { :mvn/version " 0.1.143 " },
clj-fuzzy { :mvn/version " 0.4.1 " },
http-kit { :mvn/version " 2.3.0 " },
tools.deps.alpha
{ :git/url " https://github.com/clojure/tools.deps.alpha " ,
:sha " 884d7ae5b9c228ff795e4385291708102f1cd46d " },
metosin/jsonista { :mvn/version " 0.1.1 " },
org.clojure/data.priority-map { :mvn/version " 0.0.9 " },
inflections { :mvn/version " 0.13.0 " },
http-kit/http-kit { :mvn/version " 2.3.0 " }}
; ; ... snip
}
字串搜尋傳回表中的多個符合項目:
clj -A:find-deps -F:table -l 10 " apache kafka "
| :lib | :version |
| -----------------------------------+---------- |
| org.apache.kafka/kafka-tools | 1.1.0 |
| org.apache.kafka/kafka_2.9.2 | 0.8.2.2 |
| org.apache.kafka/kafka_2.9.1 | 0.8.2.2 |
| org.apache.kafka/kafka_2.8.0 | 0.8.1.1 |
| org.apache.kafka/kafka_2.8.2 | 0.8.1 |
| org.apache.hadoop/hadoop-kafka | 3.1.0 |
| org.apache.kafka/kafka-streams | 1.1.0 |
| org.apache.kafka/kafka-clients | 1.1.0 |
| org.apache.kafka/kafka-examples | 1.1.0 |
| org.apache.kafka/kafka-perf_2.8.0 | 0.8.1.1 |
列印出 deps 的命令列呼叫:
clj -A:find-deps -F:cli http-kit jsonista
clojure -Sdeps ' {:deps {http-kit/http-kit {:mvn/version "2.3.0"}, metosin/jsonista {:mvn/version "0.2.1"}}} '
find-deps.core
命名空間包含許多可以從 REPL 使用的幫助程式。假設您有一個 Rebel-readline 的別名:
clj -A:rebel
[Rebel readline] Type :repl/help for online help info
user= > (use ' find-deps.core)
nil
user=> (print-deps "http-kit")
| :lib | :version |
|-------------------+----------|
| http-kit/http-kit | 2.3.0 |
nil
user=> (deps "http-kit")
{:deps #:http-kit{http-kit #:mvn{:version "2.3.0"}}}
有關更多幫助程序,請參閱find-deps.core
命名空間。
add-lib