[ANN] lein-plz 0.1.1 - Add dependencies quickly

476 views
Skip to first unread message

john walker

unread,
Aug 16, 2014, 8:19:42 PM8/16/14
to clo...@googlegroups.com
Hello everyone.

This is a lein plugin that helps you add dependencies to projects pretty quickly. The git repo is here: https://github.com/johnwalker/lein-plz

Basically, you write something like this:


lein
new foo
cd foo
lein plz add cljs async match jdbc

and get this:

(defproject foo "0.1.0-SNAPSHOT"
 
:description "FIXME: write description"
 
:url "http://example.com/FIXME"
 
:license {:name "Eclipse Public License"
           
:url "http://www.eclipse.org/legal/epl-v10.html"}
 
:dependencies [[org.clojure/clojure "1.6.0"]
                 
[org.clojure/clojurescript "0.0-2311"]
                 
[org.clojure/core.async "0.1.319.0-6b1aca-alpha"]
                 
[org.clojure/core.match "0.2.2"]
                 
[org.clojure/java.jdbc "0.3.5"]])

I hope it's useful.

-- John

Ashton Kemerling

unread,
Aug 17, 2014, 6:46:52 PM8/17/14
to clo...@googlegroups.com
Ahh, I just had a coworker who is used to NPM complain about leiningen not having this, thank you!

--
Ashton

john walker

unread,
Aug 17, 2014, 9:07:42 PM8/17/14
to clo...@googlegroups.com
Great! I hope he likes it :)

Ivan L

unread,
Aug 18, 2014, 10:18:52 AM8/18/14
to clo...@googlegroups.com
This doesn't overwrite the current project.clj correct?  It just generates text for a new file?

Dylan Butman

unread,
Aug 18, 2014, 12:24:00 PM8/18/14
to clo...@googlegroups.com
It looks like it walks the file and injects new lines. 

Are you planning on adding a "remove" task?

Also, it'd be great if you define groups of dependencies by giving multiple dependencies the same key. For example, I want something like

{
  om                                #{"om frontend"}
  prismatic/om-tools        #{"om-tools frontend"}
  sablono                        #{"sablono frontend"}
}

where "lein plz add frontend" would add all three deps.

Also, it seems like the task takes quite a while, and there's no debug output to indicate why, is this because you're fetching a lot of things behind the scenes?

Ivan L

unread,
Aug 18, 2014, 4:08:42 PM8/18/14
to clo...@googlegroups.com
I ran it on windows 7 via lein 2.4.3 and it just prints out a new project.clj.  It didn't alter the project.clj for me.  
I ran: lein plz add match

john walker

unread,
Aug 18, 2014, 6:00:39 PM8/18/14
to clo...@googlegroups.com
Thats really strange. I don't know why thats happening, but it should overwrite the project.clj

The only i/o relevant to this is over here. It's a combination of with-out-str and spit.

https://github.com/johnwalker/lein-plz/blob/master/src/leiningen/plz.clj#L149

john walker

unread,
Aug 18, 2014, 6:28:22 PM8/18/14
to clo...@googlegroups.com
I hadn't planned on adding remove, but with groups of dependencies, it makes sense. I like it

Dependencies that will surely be added get lookups, but no one else. I'm going to play with exclusions to see if I can make it launch faster, but I suspect that it's largely a clojure issue in general. Another way that it can be sped up is by switching from rewrite-clj to the built-in lein change.

One way that you might be able to eyeball the task's performance is by doing

lein do help, plz add cljs match

and eyeballing the gap? I bet there are problems with this approach, though.

Something I'm interested in is a lein task for switching directories like this:

lein do new baz, cd baz, plz add cljs

if there were, then you could save some calls to lein.

The right answer is probably here. I'll look through it and figure something out. https://github.com/technomancy/leiningen/wiki/Faster

Sean Corfield

unread,
Aug 18, 2014, 9:59:08 PM8/18/14
to clo...@googlegroups.com
Just wanted to say "thank you!" for this. It certainly is useful!

A possible enhancement: to try to locate and add dependencies that are not known as abbreviations. For example, `lein plz add om` doesn't do anything (and doesn't tell you!) so you have to edit your .edn file and add {om #{"om"}} making the addition of the abbreviation substantially longer than the full dependency name :)

Sean
signature.asc

Dylan Butman

unread,
Aug 18, 2014, 11:49:36 PM8/18/14
to clo...@googlegroups.com
It'd be great if you could chain lein take like that to take advantage of having already spun up the jvm. 

I've been thinking a lot lately about scaffolding for clojure projects, and while lein templates are a nice start, what I want to work towards is modular templates that can add (and maybe remove, although that's much harder) functionality where you need it. 

Modular deps would be a great start! I'm almost done with an automatic template generator (also using re that's at least very helpful for template development. 
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/f5avH92IkBA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

john walker

unread,
Aug 19, 2014, 1:01:35 AM8/19/14
to clo...@googlegroups.com
Thanks Sean!

I've thought about this issue for a while. arrdem suggested a clojars search fallback. Maybe someone has pageranked clojure libraries? crossclj?

I agree. The editing is sort of silly, especially for om (well, that m looks really expensive to me.. ). Still, there isn't a risk of adding some weird library that hasn't been user-approved. I want to address the inconvenience by prompting when dependencies aren't found.

In the next feature release, maps will probably be specified like this:

:plz [["my-om-dependencies.edn" :as "foo"] ["my-gui-dependencies.edn" :as "bar"]]

Each edn file will look the same, and the merging is still in order (so there's still a global map of abbreviations), but then you can do

lein plz add cljs bar

where the cljs dependency comes from the global map (probably merged from om-dependencies), and bar includes each dependency in "my-gui-dependencies.edn".

When an abbreviation isn't found, there will be some call to the outside world (clojars/crossclj search?) for relevant information to display to the user, followed by

Which dependency do you want to add? [the-number/s(kip)/q(uit)]

If the dependency corresponding to the-number is added, then:

Do you want to file it to a group? [the-number/c(reate-group)/no]
What abbreviations should it have?

Let me know what you think.

john walker

unread,
Aug 19, 2014, 1:07:34 AM8/19/14
to clo...@googlegroups.com
Is there a link to your work? I'm very interested in this.

Dylan Butman

unread,
Aug 19, 2014, 9:03:59 AM8/19/14
to clo...@googlegroups.com
I'm going to tie a bow on it today and I'll get back to you

Dylan Butman

unread,
Aug 19, 2014, 4:43:48 PM8/19/14
to clo...@googlegroups.com
Here you go! https://github.com/pleasetrythisathome/lein-templater

I'm sure there are some kinks to iron out, give it a try!

Kyle Cordes

unread,
Aug 23, 2014, 11:21:38 AM8/23/14
to clo...@googlegroups.com
On Saturday, August 16, 2014 at 7:19 PM, john walker wrote:
> Hello everyone.
>
> This is a lein plugin that helps you add dependencies to projects pretty quickly. The git repo is here: https://github.com/johnwalker/lein-plz
>
> Basically, you write something like this:
>
>
> lein new foo
> cd foo
> lein plz add cljs async match jdbc
>


This is excellent addition.

Once it is complete and polished, I wonder what it would take to persuade the lein project (is it still just Phil in charge?) to include it in the box.

I have noticed working with a variety of different package management tools, that there is a union of features that would be nice if all of them have, but each one has a subset. For example, almost all of them have a command line way of adding dependency except lein... and this solves that problem. But it doesn’t solve the problem for everyone, it only solves the problem for people who hear about and grab the plug-in. So for the vast majority of all users, from their point of view lein is still behind the competition in this way.

It would also be very nice to have the “tell me about upgrades available to my packages” in the box, that is also a plug-in for lein but already there in some other tools (though notably not NPM! http://kylecordes.com/2013/update-obsolete-packages )

--
Kyle Cordes
http://kylecordes.com



john walker

unread,
Aug 24, 2014, 12:00:52 AM8/24/14
to clo...@googlegroups.com, ky...@kylecordes.com
I don't think this should be included in lein, but thanks Kyle :)

I haven't had a lot of trouble finding or installing lein plugins, but it might be the
case that a lot of useful ones are obscure. Do you think a clojure-toolbox
dedicated to lein would be helpful?

- John

Uday Verma

unread,
Aug 24, 2014, 7:39:43 PM8/24/14
to clo...@googlegroups.com
This is awesome! I have attempted to write one and failed, this is much better than what I could have possibly done.  Thanks!  Added to profile!

Sean Corfield

unread,
Aug 25, 2014, 10:39:23 PM8/25/14
to clo...@googlegroups.com
On Aug 18, 2014, at 10:01 PM, john walker <john.lo...@gmail.com> wrote:
> Thanks Sean!
>
> I've thought about this issue for a while. arrdem suggested a clojars search fallback. Maybe someone has pageranked clojure libraries? crossclj?

Well, what caused me to suggest it was that lein-try already does something similar:

lein try om

That figures out the latest version of Om (by searching Clojars and Maven I believe?).

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



signature.asc

john walker

unread,
Aug 26, 2014, 12:39:31 AM8/26/14
to clo...@googlegroups.com
You're welcome Uday!

Sean, you're right. I'll add it and the remove task to the next feature release.

Ivan, have you tried out a recent version? I haven't heard from other Windows users ;/. Would you comment on issue #3 ?

Dylan, I've added groups. They're a little different from your suggestion - you basically add nicknames for files, and the keys get inserted.
Reply all
Reply to author
Forward
0 new messages