tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2021-01-07T14:58:20.238900Z

I am using belman, so the dep setup is:

{:aliases
   :rebel
     {:extra-deps {com.bhauman/rebel-readline {:mvn/version "0.1.4"}}
      :main-opts  ["-m" "rebel-readline.main"]}
} ;

2021-01-07T14:58:47.239600Z

I want in every ns, I can access doc, and dir (which are from the namespace repl)

alexmiller 2021-01-07T15:01:59.240200Z

there isn't really any way to do this without making a customized repl

alexmiller 2021-01-07T15:02:13.240600Z

(which is not really that hard, but might be more than you want to do)

borkdude 2021-01-07T15:07:29.241Z

Maybe evaluating things from within user is an alternative approach?

borkdude 2021-01-07T15:08:00.241400Z

(I typically just require 'clojure.repl if I need it)

2021-01-07T15:11:03.242600Z

thought the repl should support such a feature.

alexmiller 2021-01-07T15:11:15.242800Z

yeah, I just use if I'm working at the repl

alexmiller 2021-01-07T15:12:09.243900Z

but I'm usually working in an editor-connected repl and leave the repl window in user, while sending expressions from whatever namespace I'm working in

alexmiller 2021-01-07T15:12:33.244200Z

and using editor tools for doc support etc

alexmiller 2021-01-07T15:13:47.244500Z

I dropped an example of making a repl to do this somewhere

alexmiller 2021-01-07T15:14:05.244800Z

oh hey, I even wrote it down... https://insideclojure.org/2020/02/11/custom-repl/

2021-01-07T15:14:20.245Z

You don’t drop in the repl window and switch to the current active buffer namespace for adhoc editting?

2021-01-07T15:15:08.245300Z

It is about clojure.main, so might not applicable to rebel

alexmiller 2021-01-07T15:15:27.245500Z

no, I write code in my editor and eval it

👌 1
alexmiller 2021-01-07T15:16:05.245700Z

the main thing I usually use the repl window for is just (pst *e) :)

borkdude 2021-01-07T15:20:28.245900Z

@alexmiller hah, I just tried this with bb and it also works there:

$ bb -e "(require '[clojure.main :as m]) \
        (m/repl :init #(apply require m/repl-requires) \
        :eval (fn [form] (do (require '[clojure.pprint :refer [pprint]]) \
        (eval form))))"
user=> (ns foo)
nil
foo=> (pprint {:a 1})
{:a 1}
nil
(only pp isn't available yet)

alexmiller 2021-01-07T15:23:40.246100Z

nice

borkdude 2021-01-07T15:24:17.246300Z

@i You should probably read the README of rebel read-line: https://github.com/bhauman/rebel-readline#quick-usage > The main way to utilize this readline editor is to replace the clojure.main/repl-read behavior in clojure.main/repl.

borkdude 2021-01-07T15:24:43.246800Z

It seems to offer integration with clojure.main

2021-01-07T15:33:04.247Z

which part are you referring to ?

borkdude 2021-01-07T15:34:43.247200Z

under quick usage

practicalli-john 2021-01-07T16:24:58.250800Z

@i I think I have missed something. If using rebel readline, you have docs and eldoc (function signatures) in every namespace as part of the default Rebel readline UI. Its easy to run other commands from the repl namespace by using the fully qualified name, which rebel readline keeps in its history so you only have to type once and even then TAB will auto-complete the name of namespaces and functions, so you dont even need to type it in full once. Eg. (clojure.repl/dir clojure.string)

practicalli-john 2021-01-07T16:27:11.251500Z

I did a short video of using REBL for a very simple project, showing eldoc and docs and tab completion of namespaces and function names http://practicalli.github.io/clojure/clojure-tools/repl/

alexmiller 2021-01-07T21:04:43.253400Z

for any of you toolsmiths looking for a project, it would be cool to see a tool that compared the APIs from two versions of a Clojure lib at the source level (like https://abi-laboratory.pro/?view=timeline&lang=java&l=clojure does for Java compatibility)

alexmiller 2021-01-07T21:06:56.255300Z

even knowing surface level add/remove/modify functions and add/modify arities would be a big help in detecting things (deeper level that understood keys in maps or coll types or whatever would be a harder task)

borkdude 2021-01-07T21:07:29.256Z

This is very easy to make using clj-kondo analysis. @lee didn't you make this kind of tools once for clj-doc?

borkdude 2021-01-07T21:08:34.256400Z

For anyone who wants to have a stab a it: https://github.com/borkdude/clj-kondo/blob/master/analysis/README.md

lread 2021-01-07T21:11:28.258800Z

We were talking about such a thing for cljdoc but never got to it. I did hack together something to compare rewrite-clj/rewrite-cljs/rewrite-cljc. It serves this purpose and but I am certainly not proud of its quality https://github.com/lread/diff-apis

borkdude 2021-01-07T21:13:20.260500Z

I can whip up something in an hour or so

lread 2021-01-07T21:15:26.261900Z

@borkdude, I think you might live in a different space/time continuum than me. :simple_smile: Or there are several of you “We are borkdude, resistance is futile”.

lread 2021-01-07T21:17:09.262700Z

Will your clj-kondo solution pick up potemkin and potemkin-like imports?

borkdude 2021-01-07T21:30:10.263400Z

@lee clj-kondo knows how to handle potemkin itself, but not sure about potemkin-likes

👍 1
vlaaad 2021-01-07T22:07:00.263600Z

Isn't it something Rich worked on? Codeq?

borkdude 2021-01-07T22:17:11.263800Z

@alexmiller Here's a first stab at it: https://gist.github.com/borkdude/2b963db1582654ec28bfd40b4dc35748

borkdude 2021-01-07T22:17:16.264Z

invokable as JVM script

borkdude 2021-01-07T22:19:45.264700Z

Usage: api_diff.clj lib1.jar lib2.jar (or api_diff.clj foo/src bar/src)

borkdude 2021-01-07T22:20:31.265300Z

There is also :private information in this analysis, I didn't take that into account, but small change.

borkdude 2021-01-07T22:26:33.266400Z

There might be other diffing libs out there that give a format that's better suited for what you want, this is just a start

alexmiller 2021-01-07T22:27:16.267100Z

pretty cool. would love to see something like this integrated that also used tools.deps so you could tell it a lib and two versions to compare

alexmiller 2021-01-07T22:27:46.267200Z

codeq is actually in this ballpark, but is actually more fine-grained

alexmiller 2021-01-07T22:28:12.267400Z

I think it's both more and less than what I'm saying although it could be a good substrate

alexmiller 2021-01-07T22:29:54.268Z

ultimately I wonder if you could say that a version has a breaking api change

borkdude 2021-01-07T22:39:05.268500Z

@alexmiller tda returns this for lib-location: {:base "/Users/borkdude/.m2/repository", :path "org/clojure/clojure/1.8.0", :classifier nil, :type :mvn}, is there anything I could use to resolve the full path to the jar?

alexmiller 2021-01-07T22:40:18.268800Z

I wouldn't use lib-location at all

alexmiller 2021-01-07T22:40:37.269200Z

better to resolve-deps or calc-basis and get the paths out of the result

borkdude 2021-01-07T22:41:45.270Z

I just want the location for this one thing, that's why I thought lib-location would be fitting

alexmiller 2021-01-07T22:42:41.270400Z

lib-location won't actually download it

borkdude 2021-01-07T22:42:43.270600Z

Ah I see:

#:org.clojure{clojure {:paths ["/Users/borkdude/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar"], :deps/manifest :mvn, :mvn/version "1.8.0", :parents #{[]}}}
I can work with that

borkdude 2021-01-07T22:42:53.270900Z

yeah, I did the downloading with resolve-deps already

alexmiller 2021-01-07T22:43:14.271300Z

for a maven dep, :paths should always have a single entry

alexmiller 2021-01-07T22:43:36.271700Z

(at least for now, maybe some future case to consider)

alexmiller 2021-01-07T22:44:40.272200Z

alternately, you could call org.clojure.tools.deps.alpha.extensions/coord-paths directly I guess

alexmiller 2021-01-07T22:45:36.272700Z

(ext/coord-paths 'org.clojure/clojure {:mvn/version "1.10.0"} :mvn {:mvn/repos maven/standard-repos})

alexmiller 2021-01-07T22:46:08.273100Z

probably the most direct but still most generic call you can make in the public api

borkdude 2021-01-07T22:46:35.273500Z

Gist updated, works for mvn deps:

api_diff.clj org.clojure/clojure "1.8.0" "1.10.1" > /tmp/diff.txt

borkdude 2021-01-07T22:46:53.273900Z

Detecting breaking changes is not something I will include today, it's getting too late ;)

borkdude 2021-01-07T22:47:42.274500Z

I guess the algorithm should look at things that were in v1 but were removed in v2, or arities that were removed in v2

borkdude 2021-01-07T22:48:45.274700Z

afk now, sleep

alexmiller 2021-01-07T22:51:38.274900Z

pretty sweet, nice hack

alexmiller 2021-01-07T22:58:11.275500Z

@borkdude there is one bug there - need to provide the standard maven repos if you don't have stuff locally

alexmiller 2021-01-07T22:58:23.275800Z

(require '[clojure.tools.deps.alpha.util.maven :as mvn])

alexmiller 2021-01-07T22:58:33.276100Z

then

(-> (tda/resolve-deps `{:deps {~lib {:mvn/version ~v}} :mvn/repos ~mvn/standard-repos} {})

borkdude 2021-01-07T23:04:52.276900Z

@alexmiller Thanks, updated. Also swapped out deep-diff with editscript, this prints things like:

[[[clojure.core into] :fixed-arities 0] :+ 0]
 [[[clojure.core into] :fixed-arities 1] :+ 1]
This makes it pretty easy to grep for :- for things that have disappeared.

borkdude 2021-01-07T23:05:54.277300Z

My grep for 1.8.0 ~ 1.10.1:

[[[clojure.pprint format-simple-number] :fixed-arities] :-]
 [[[clojure.core emit-method-builder] :fixed-arities 4] :-]
 [[[clojure.core.reducers compile-if]] :-]

borkdude 2021-01-07T23:08:12.277800Z

(some of these could be due to subpar analysis by clj-kondo)

borkdude 2021-01-07T23:09:49.278400Z

ah for emit-method-builder it correctly detected an API change: https://github.com/clojure/clojure/commit/2cc37bb56a9125a1829c73c505e32995e663059a but this function is private, so no problem

borkdude 2021-01-07T23:11:05.278700Z

and indeed, compile-if disappeared (also private)

borkdude 2021-01-07T23:11:20.279Z

so the only false positive seems to be the one in pprint

borkdude 2021-01-07T23:11:46.279300Z

gnite

alexmiller 2021-01-07T23:14:17.279500Z

thx!

alexmiller 2021-01-07T23:14:32.279900Z

just trying to help here man - you're already a week into the new year without publishing any new tools

🦜 1
8
borkdude 2021-01-07T23:15:09.280200Z

thanks ;)