Skip to content
/ depify Public

Creates or updates your deps.edn file, based on your project’s project.clj

Notifications You must be signed in to change notification settings

hagmonk/depify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Depify

What?

depify reads your Leiningen project.clj configuration file and produces a deps.edn file suitable for the Clojure CLI tools.

deps.edn and the Clojure CLI tools have a narrower focus than Leiningen or Boot, but depify will do its best to produce a useful deps.edn replacement. This includes adding extra aliases to provide “missing” functionality. One such example is the addition of the :test and :runner aliases borrowed from Sean Corfield’s dot-clojure repo. Other aliases may be added in the future - PRs are always welcome!

Changelog

  • 2018-06-13
    • Add ability to read lein pprint output from stdin (actually fixes #2)
  • 2018-06-12
    • Add ability to read project.clj from stdin (fixes #2)
  • 2018-06-11
    • Hefty refactoring (fixes #1 and many other issues)

Usage

Create an alias in your ~/.clojure/deps.edn map:

:depify {:extra-deps {org.clojure/clojure {:mvn/version "1.9.0"}
                      depify              {:git/url "https://github.com/hagmonk/depify"
                                           :sha     "04329744872890711dbba8939a16e9987dd33bb3"}}
         :main-opts  ["-m" "depify.project"]}
:zprint {:extra-deps {org.clojure/clojure {:mvn/version "1.9.0"}
                      zprint              {:mvn/version "0.4.9"}}
         :main-opts  ["-m" "zprint.main"]}

Then, invoke depify in any folder that contains a project.clj:

clj -A:depify

depify will read any pre-existing deps.edn file in your project folder and use that as an initial starting point. The result of merging project.clj into deps.edn will be printed to standard out.

depify can also read project.clj files from stdin. This can be handy if, for instance, you want to import a pile of dependencies into your current deps.edn from a remote project.clj:

curl -L -o - "https://raw.githubusercontent.com/metasoarous/oz/master/project.clj" | clj -A:depify

depify can also interpret the output from lein pprint. This has the advantage of evaluating content inside project.clj - for instance, quoted variables are expanded, paths are resolved, etc.

lein pprint | clj -A:depify

lein pprint can be invoked with a list of keys in order to extract specific values from the project.clj data. depify can handle any key that returns a list of maven coordinates, which will be interpreted as simple dependencies. The following will result in a dependency set that is the union of both keys:

lein pprint :dependencies :plugins | clj -A:depify

Notice in my ~/.clojure/deps.edn I also have zprint as an alias, enabling this from your project folder:

clj -A:depify | clj -A:zprint > deps.edn.tmp ; mv deps.edn.tmp deps.edn

You may see a “Stream closed” exception emitted by zprint, which can be safely ignored.

Features

Based on the initial concept in this gist by Sean Walker. depify improves on it slightly:

Adds entries to the existing deps.edn, if available

deps.edn

{:deps {ding/dong {:mvn/version "1.0"}}}

project.clj

(defproject super-dooper "1.0"
  :dependencies [[tick/tock "1.0"]])

deps.edn

{:deps {ding/dong {:mvn/version "1.0"}, tick/tock {:mvn/version "1.0"}}}

Handles variable unquoting in project.clj

project.clj

(def something "0.1.2")
(defproject foobar "1.0"
  :dependencies [[something/gizmo ~something]])

deps.edn

{:deps {something/gizmo {:mvn/version "0.1.2"}}}

Places lein’s :main and :jvm-opts under an alias called :run

project.clj

(defproject super-dooper "1.0"
  :jvm-opts ["-XX:+EnormousBiceps"]
  :main super-dooper.core
  :dependencies [[ding/dong "1.0"]])

deps.edn

{:aliases
 {:run
  {:jvm-opts ["-XX:+EnormousBiceps"],
   :main-opts ["-m" "super-dooper.core"]}},
 :deps {ding/dong {:mvn/version "1.0"}}}

Creates aliases for any :profiles

project.clj

(defproject super-dooper "1.0"
  :jvm-opts ["-XX:+EnormousBiceps"]
  :main super-dooper.core
  :dependencies [[ding/dong "1.0"]]
  :profiles {:dev {:dependencies [[tick/tock "1.0"]]
                   :jvm-opts ["-XX:+CrashAndBurn"]}})

deps.edn

{:aliases
 {:run
  {:jvm-opts ["-XX:+EnormousBiceps"],
   :main-opts ["-m" "super-dooper.core"]},
  :dev
  {:jvm-opts ["-XX:+CrashAndBurn"],
   :extra-deps {tick/tock {:mvn/version "1.0"}}}},
 :deps {ding/dong {:mvn/version "1.0"}}}

Adds :test-paths to the :test alias

project.clj

(defproject super-dooper "1.0"
  :dependencies [[ding/dong "1.0"]]
  :test-paths ["testomatic"])

deps.edn

{:aliases
 {:test
  {:extra-paths ["test" "testomatic"],
   :extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}},
  :runner
  {:extra-deps
   {com.cognitect/test-runner
    {:git/url "https://github.com/cognitect-labs/test-runner",
     :sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
   :main-opts ["-m" "cognitect.test-runner" "-d" "test"]}},
 :deps {ding/dong {:mvn/version "1.0"}}}

Adds :source-paths and :resource-paths to :paths

project.clj

(defproject super-dooper "1.0"
  :dependencies [[ding/dong "1.0"]]
  :resource-paths ["more-resources"]
  :source-paths ["more-sources"])

deps.edn

{:deps  {ding/dong {:mvn/version "1.0"}},
 :paths ["src" "more-sources" "more-resources"]}

Adds :respositories to :mvn/repos

project.clj

(defproject super-dooper "1.0"
  :dependencies [[ding/dong "1.0"]]
  :repositories [["java.net" "https://download.java.net/maven/2"]
                 ["releases"
                  {:url      "https://blueant.com/archiva/internal"
                   :username "milgrim",
                   :password :env}]])

deps.edn

{:deps {ding/dong {:mvn/version "1.0"}},
 :mvn/repos
 {"java.net" {:url "https://download.java.net/maven/2"},
  "releases" {:url "https://blueant.com/archiva/internal"}}}

Testing

Tests can be invoked with:

clj -A:test

About

Creates or updates your deps.edn file, based on your project’s project.clj

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published