Giter VIP home page Giter VIP logo

find-deps's Introduction

find-deps

What?

find-deps helps you quickly find dependencies via the Clojars and Maven search APIs. Use it via the command line, or from the REPL.

find-deps utilizes clj-fuzzy to refine the search results returned from repository APIs. It also factors in the freshness of the dependencies, and the popularity of the dependency’s group ID. We hope this results in a near-perfect suggestion every time!

See the Future section below for some ideas around where this can be taken. In particular, it would be great to enable searching for deps.edn files on github …

TL;DR

Add a dependency to your current deps.edn as easily as this:

clj -A:find-deps -F:save priority-map

Changelog

  • Note taken on [2018-06-25 Mon 10:39]
  • 2018-06-25
    • hide snapshot versions by default in clojars (fixes #2)
  • 2018-06-24
    • merged @pesterhazy’s README fix
  • 2018-06-23
    • fixed bug wherein it wasn’t possible to save deps without a preexisting deps.edn
    • added -F:cli format flag to print deps as command line option to `clojure` binary
  • 2018-06-17
    • change -S flag to -s to avoid conflict with tools.deps cli
    • enable piping of invocations together to produced merged deps.edn map
    • enable saving of deps.edn map with format :save
    • renamed :merged to :merge
  • 2018-06-16
    • Initial commit

CLI Usage

To use find-deps from the command line, create an alias in your ~/.clojure/deps.edn map:

{:aliases {:find-deps {:extra-deps
                         {find-deps
                            {:git/url "https://github.com/hagmonk/find-deps",
                             :sha "6fc73813aafdd2288260abb2160ce0d4cdbac8be"}},
                       :main-opts ["-m" "find-deps.core"]}}}

You can invoke find-deps with -h to see the supported options:

% 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

Examples

Search for a dependency like http-kit:

clj -A:find-deps http-kit
{:deps {http-kit/http-kit {:mvn/version "2.3.0"}}}

Search for multiple dependencies:

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"}}}

Chain together multiple invocations using different query arguments:

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"}}}

Merge the search results into the current project’s deps.edn. You can also save these results to deps.edn by specifying :save instead.

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
 }

String search returning multiple matches in a table:

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 |

Print out a command line invocation of the 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"}}}'

API

The find-deps.core namespace contains a number of helpers you can use from the REPL. Assuming you have an alias for 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"}}}

See the find-deps.core namespace for more helpers.

Future

  • [ ] search github for deps.edn files
  • [ ] search github for project.clj files
    • [ ] page rank deps based on dependency graph
    • [ ] recommended other dependencies based on clustering
  • [ ] incorporate download counts into weighting factor
  • [x] support writing directly into deps.edn
  • [ ] support add-lib
  • [ ] add validation support to cli parser

find-deps's People

Contributors

hagmonk avatar pesterhazy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

find-deps's Issues

Ignore empty deps.edn file

This would allow for supporting clojure -A:user/find-deps ring > deps.edn in a new directory as an empty file is created by bash immediately when this is run.

can not find re-frame

clj -A:find-deps re-frame
{:deps {re-frame-forms/re-frame-forms {:mvn/version "0.1.3"}}}

expecting -
re-frame {:mvn/version "0.10.5"}

Hide SNAPSHOT versions by default

Great project!

By default, find-deps returns SNAPSHOT versions:

$ clj -A:find-deps reagent
{:deps {reagent/reagent {:mvn/version "0.8.2-SNAPSHOT"}}}

These are mutable prereleases, and should be avoided unless you're know what you're doing. Maybe find-deps should hide SNAPSHOT versions by default, perhaps with an option to include them?

Java 11 issues (?)

❯ clojure -A:user/find-deps http-kit                                               Mon Feb 25 15:12:02 GMT 2019 [client-loop] ERROR - select exception, should not happen
java.lang.IllegalStateException: Client/Server mode has not yet been set.
        at java.base/sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:98)
        at org.httpkit.client.HttpClient.finishConnect(HttpClient.java:395)
        at org.httpkit.client.HttpClient.run(HttpClient.java:472)
        at java.base/java.lang.Thread.run(Thread.java:834)
Mon Feb 25 15:12:02 GMT 2019 [client-loop] ERROR - select exception, should not happen
java.lang.IllegalStateException: Client/Server mode has not yet been set.
        at java.base/sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:98)
        at org.httpkit.client.HttpClient.finishConnect(HttpClient.java:395)
        at org.httpkit.client.HttpClient.run(HttpClient.java:472)
        at java.base/java.lang.Thread.run(Thread.java:834)
Mon Feb 25 15:12:02 GMT 2019 [client-loop] ERROR - select exception, should not happen
java.lang.IllegalStateException: Client/Server mode has not yet been set.
        at java.base/sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:98)
        at org.httpkit.client.HttpClient.finishConnect(HttpClient.java:395)
        at org.httpkit.client.HttpClient.run(HttpClient.java:472)
        at java.base/java.lang.Thread.run(Thread.java:834)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.