Fork me on GitHub
#clojure
<
2021-09-24
>
practicalli-johnny08:09:28

Is there already a tool to detect the licenses from project dependencies for Clojure CLI tools (deps.edn) projects? https://github.com/technomancy/lein-licenses is a Leiningen plugin that I could hack into a separate project, if nothing exists already

maleghast08:09:38

I know that Snyk (which is a paid service) does kinda support this in Clojure. You can use their service to connect to Github repos (which will give you some basic code and Docker insights even with Clojure), and then if you use a Github action (other solutions exist) to create a temporary Maven POM from the project, you can "send" that POM to Snyk and it will figure out your License exposure / situation for you. It's not an ideal solution but we use it 'cos we use Snyk anyway for the Python and JS repos on the stack. Just a thought.

👍 1
practicalli-johnny08:09:37

Yes, that is the other option I had in mind. Will need to check with work if they are happy for me to run the Synk service over the company GitHub organisation 🙂

practicalli-johnny08:09:00

Ideally it would be nice to have a license tool working with the new tools.build (but I haven't started looking at that yet)

practicalli-johnny10:09:41

Oh, a http://Synx.io enterprise license is required to get a report on the licenses used in dependencies. So I guess I will be hacking the lein-licences plugin code...

Alex Miller (Clojure team)12:09:12

I've done a little hacking around on this, nothing worth using yet

practicalli-johnny16:09:10

Happy to collaborate or at least be able to test on our projects at work

Alex Miller (Clojure team)16:09:48

nothing worth sharing, and am happy to toss what I've done in the trash

Alex Miller (Clojure team)16:09:02

the signal you should take is - I think it's a useful thing to exist :)

👍 2
dominicm15:09:58

One downside to using via maven is that it doesn't quite match what classpath you get with tools.deps.

Drew Verlee16:09:43

is this valid clojure some how? (require '[schema.core :as s] bidi.schema)

seancorfield17:09:25

(require '[schema.core :as s]
         'bidi.schema)
;; or
(require '[schema.core :as s]
         '[bidi.schema])
They're not "unlisted args" but :require and require are variadic.

Drew Verlee16:09:12

my repl is saying no.

pez16:09:43

Trust your REPL. 😃

1
dpsutton16:09:46

You need to quote the second form

dpsutton16:09:13

Whats the error?

Drew Verlee16:09:49

failed to parse ns. reason "extra input"

dpsutton16:09:09

Oh that’s in a ns form? Use :require

dpsutton16:09:30

Why quote in the ns form?

Drew Verlee16:09:53

it was't presented in a ns form. It just called rquire directly.

dpsutton16:09:14

Then quote both forms.

Drew Verlee16:09:11

gotcha, i see the unlisted args to require so infrequently. i suppose it takes either and the list types can be used to pass more information :refer :as etc...

1
dgb2316:09:47

@drewverlee I found this blog post helpful here, maybe have a look: https://stuartsierra.com/2016/clojure-how-to-ns.html

🙂 2
dpsutton17:09:36

Require has to take symbols and imbue them with meaning thereafter. If they aren’t quoted they are attempted to be resolved as arguments and that would necessarily fail in the general case

Alex Miller (Clojure team)17:09:37

require is a function, args are evaluated before it's invoked, quoting is required to not evaluate them. :require is a clause in the ns macro where evaluation of args is not done, so quoting is not required

🎉 6
George Silva17:09:11

great TLDR.

😂 1
Alex Miller (Clojure team)17:09:06

confusingly, import is a macro and it works with either quoted or unquoted inputs (but I always quote, to make it work/look the same as require so that I don't have to remember the difference)

West17:09:02

Anyone have experience with swing/seesaw? How can I watch a JTextField or (seesaw.core/text) widget for text changes?

West17:09:12

Preferably, I’d like to call reset! on an atom with whatever I put in the text-field.

West18:09:38

(defn main-panel
  []
  (s/border-panel
   :center (s/canvas :id :canvas :background (c/color "white") :paint paint-canvas)
   :south (s/horizontal-panel
           :items [(s/action :name "Create Wallpaper"
                             :handler (try (make-wallpaper @wallpaper-width @wallpaper-height)
                                           (catch Exception e (.printStackTrace e))))
                   (s/label "Width:")
                   (s/text :listen [:document #(reset! wallpaper-width %&)])
                   (s/label "Height:")
                   (s/text)
                   (s/action :name "Apply"
                             :handler #(fn [_]
                                         (reset! wallpaper-width 150)
                                         (reset! wallpaper-height 150)))])))
Not really sure how to do it, at least this one doesn’t crash when I edit the text field, but it’s still not quite right.

West18:09:26

I got it working; Save this example for future reference:

(defn number-input-text
  [atom]
  (let [textfield (s/text :text @atom)]
    (b/bind
     textfield
     (b/transform #(try (reset! atom (Long/parseLong %))
                        (catch NumberFormatException e
                          (println "Not a number" %))
                        (catch Exception e
                          (println "Error:" e))))
     (b/bind
      (b/transform #(if (int? %)
                      "white" "lightcoral"))
      (b/property textfield :background)))
    textfield))

(defn main-panel
  []
  (s/border-panel
   :center (s/canvas :id :canvas :background (c/color "white") :paint paint-canvas)
   :south (s/horizontal-panel
           :items [(s/action :name "Create Wallpaper"
                             :handler (fn [_] (try (make-wallpaper @wallpaper-width @wallpaper-height)
                                                   (catch Exception e (.printStackTrace e)))))
                   (s/label "Width:")
                   (number-input-text wallpaper-width)
                   (s/label "Height:")
                   (number-input-text wallpaper-height)])))

West18:09:26

I got it working; Save this example for future reference:

(defn number-input-text
  [atom]
  (let [textfield (s/text :text @atom)]
    (b/bind
     textfield
     (b/transform #(try (reset! atom (Long/parseLong %))
                        (catch NumberFormatException e
                          (println "Not a number" %))
                        (catch Exception e
                          (println "Error:" e))))
     (b/bind
      (b/transform #(if (int? %)
                      "white" "lightcoral"))
      (b/property textfield :background)))
    textfield))

(defn main-panel
  []
  (s/border-panel
   :center (s/canvas :id :canvas :background (c/color "white") :paint paint-canvas)
   :south (s/horizontal-panel
           :items [(s/action :name "Create Wallpaper"
                             :handler (fn [_] (try (make-wallpaper @wallpaper-width @wallpaper-height)
                                                   (catch Exception e (.printStackTrace e)))))
                   (s/label "Width:")
                   (number-input-text wallpaper-width)
                   (s/label "Height:")
                   (number-input-text wallpaper-height)])))