find-deps ช่วยให้คุณค้นหาการขึ้นต่อกันได้อย่างรวดเร็วผ่าน Clojars และ Maven search API ใช้ผ่านทางบรรทัดคำสั่งหรือจาก REPL
find-deps ใช้ clj-fuzzy เพื่อปรับแต่งผลการค้นหาที่ส่งคืนจาก API ของพื้นที่เก็บข้อมูล นอกจากนี้ยังคำนึงถึงความใหม่ของการอ้างอิง และความนิยมของ ID กลุ่มของการขึ้นต่อกันด้วย เราหวังว่านี่จะทำให้ได้รับคำแนะนำที่เกือบจะสมบูรณ์แบบทุกครั้ง!
ดูส่วนอนาคตด้านล่างเพื่อดูแนวคิดบางประการเกี่ยวกับสิ่งที่สามารถทำได้ โดยเฉพาะอย่างยิ่ง จะเป็นการดีอย่างยิ่งหากเปิดใช้งานการค้นหาไฟล์ deps.edn
บน github …
เพิ่มการพึ่งพาให้กับ 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 " ]}}}
คุณสามารถเรียกใช้ find-deps ด้วย -h
เพื่อดูตัวเลือกที่รองรับ:
% 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
ของโปรเจ็กต์ปัจจุบัน คุณยังสามารถ บันทึก ผลลัพธ์เหล่านี้ไปที่ deps.edn ได้โดยระบุ :save
แทน
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