Git Product home page Git Product logo

Comments (14)

xsc avatar xsc commented on August 26, 2024

That's obviously a good idea. However, it would require rewriting the "project.clj" which poses a few problems:

  • Currently, lein-ancient gets a preprocessed project map (that contains everything in "project.clj" extended by things like default values or plugins specified in "~/.lein/profiles.clj"), so what exactly should be written back into "project.clj"? This can be solved by not relying on the preprocessed map anymore and instead parsing "project.clj"/"profiles.clj" directly - losing the advantage of having Leiningen do all the heavy lifting I/O-wise.
  • Comments and indentation have to be preserved. This is the only thing I found remotely capable of doing that and it looks rather complicated...

So, do you know of any plugins that rewrite source files? I could use some inspiration here. :)

from lein-ancient.

trevor avatar trevor commented on August 26, 2024

re space preservation - I was going to recommend whatever https://github.com/lynaghk/cljx uses, turns out to be the same as what you've already found. :)

from lein-ancient.

xsc avatar xsc commented on August 26, 2024

Thanks, @trevor, that will at least give me some hints on usage. I'll play around with it once I find some time and then address the enhancement.

from lein-ancient.

xsc avatar xsc commented on August 26, 2024

Okay, so I wrote my own rewrite library and used it to implement this enhancement. I'd be very glad for feedback before I release it officially; so use the latest snapshot version to try it out:

[lein-ancient "0.4.3-SNAPSHOT"]

You can then run:

  • lein ancient :upgrade (to automatically upgrade all dependencies)
  • lein ancient :upgrade :interactive (to have lein-ancient prompt you for input before changing something)
  • lein ancient :upgrade :print (to print the resulting project.clj instead of writing it to disk)

Options can be freely combined and include the ones for the standard "check" task, so the following is possible, too:

lein ancient :upgrade :interactive :print :plugins :allow-snapshots

That about what you imagined?

from lein-ancient.

tsdh avatar tsdh commented on August 26, 2024

@xsc Not sure if it fits here, but I've just tested lein ancient for the first time. lein ancient :upgrade :interactive worked smoothly and did what it advertised. Very, very nice!

One minor problem, though. My project.clj's :description string was spanning multiple lines, and it became converted to a all-on-one-line string with \n line breaks. I'd prefer "real" line breaks in the file, I mean, that's why clojure's strings can span multiple lines.

from lein-ancient.

firesofmay avatar firesofmay commented on August 26, 2024

Looks really good! And I confirm what @tsdh said. If the description is in newlines after doing :upgrade it becomes "First line\n Second line."

Everything else is working great. It even preserved the comments.
Tried on 3 different projects.
Thank you for your efforts :)

from lein-ancient.

xsc avatar xsc commented on August 26, 2024

I'll look into fixing the string issue. That's a problem in rewrite-clj's parser/printer implementation.

Glad you like it so far. :-)

from lein-ancient.

firesofmay avatar firesofmay commented on August 26, 2024

Btw any idea if this will work for plugins as well?

from lein-ancient.

tsdh avatar tsdh commented on August 26, 2024

@firesofmay I've just tried it out. It works with plugins declared in your project.clj, but not those declared user-wide in ~/.lein/profiles.clj.

lein ancient :upgrade :plugins :interactive

It would be nice if it also had a :user-profiles option to check those instead of the current project.

from lein-ancient.

xsc avatar xsc commented on August 26, 2024

I'll add a user profile upgrade mechanism after my next round of refactoring. Gotta clean up a little first. ;-)

from lein-ancient.

firesofmay avatar firesofmay commented on August 26, 2024

@yannick
Awesome! Thanks a lot! :)

On Fri, Jul 26, 2013 at 1:28 PM, Yannick Scherer
[email protected]:

I'll add a user profile upgrade mechanism after my next round of
refactoring. Gotta clean up a little first. ;-)


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-21606660
.

Regards,
Mayank.

from lein-ancient.

xsc avatar xsc commented on August 26, 2024

rewrite-clj should now support multi-line strings; lein-ancient should thus now create the expected output. You might have to force the download of the latest rewrite-clj SNAPSHOT:

rm -rf ~/.m2/repository/rewrite-clj

I'll close this issue if everything works as expected and open a new one for the whole "profiles.clj" thing.

from lein-ancient.

tsdh avatar tsdh commented on August 26, 2024

@xsc Yes, now the multi-line strings work. Thanks.

from lein-ancient.

firesofmay avatar firesofmay commented on August 26, 2024

Yup, multi-line strings is working! :)

On Fri, Jul 26, 2013 at 7:28 PM, Tassilo Horn [email protected]:

@xsc https://github.com/xsc Yes, now the multi-line strings work.
Thanks.


Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-21622226
.

Regards,
Mayank.

from lein-ancient.

Related Issues (20)

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.