Skip to content

Commit

Permalink
🆕 Improve counting of single- vs multi- licensed dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pmonks committed Jun 4, 2024
1 parent d807b3f commit 4b85aa3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{:deps
{jansi-clj/jansi-clj {:mvn/version "1.0.3"}
com.github.pmonks/clj-wcwidth {:mvn/version "1.0.85"}
com.github.pmonks/lice-comb {:mvn/version "2.0.292"}
com.github.pmonks/lice-comb {:mvn/version "2.0.311-SNAPSHOT"}
com.github.pmonks/asf-cat {:mvn/version "2.0.135"}
com.github.pmonks/tools-convenience {:mvn/version "1.0.151"}}
:aliases
Expand Down
15 changes: 8 additions & 7 deletions src/tools_licenses/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@
(let [proj-expressions (sort-license-expressions (keys proj-expressions-info))
freqs (frequencies (filter identity (mapcat #(keys (get % :lice-comb/license-info)) (vals deps-lib-map-with-info))))
deps-expressions (sort-license-expressions (keys freqs))
no-license-count (count (filter empty? (map #(:lice-comb/license-info (val %)) deps-lib-map-with-info)))
single-license-count (count (filter #(= (count %) 1) (map #(:lice-comb/license-info (val %)) deps-lib-map-with-info)))
multi-license-count (count (filter #(> (count %) 1) (map #(:lice-comb/license-info (val %)) deps-lib-map-with-info)))]
license-infos (map #(:lice-comb/license-info (val %)) deps-lib-map-with-info)
no-license-count (count (filter empty? license-infos))
single-license-count (count (filter #(and (= 1 (count (keys %))) (sexp/simple? (first (keys %)))) license-infos))
multi-license-count (count (filter #(or (> (count (keys %)) 1) (some sexp/compound? (keys %))) license-infos))]
(print (str "\n" (ansi/bold "This project: ")))
(if (seq proj-expressions)
(println (s/join ", " (map human-readable-expression proj-expressions)))
Expand All @@ -145,10 +146,10 @@
(println " - no dependencies found -"))
(println (str (ansi/bold "------------------------------------------------------------ ---------")
"\n"
"\n " (ansi/bold "Deps with no licensing: ") (fit-width 9 (str no-license-count) false)
"\n " (ansi/bold "Deps with 1 license expression: ") (fit-width 9 (str single-license-count) false)
"\n " (ansi/bold "Deps with multiple license expressions: ") (fit-width 9 (str multi-license-count) false)
"\n " (ansi/bold "TOTAL DEPS: " (fit-width 9 (str (+ no-license-count single-license-count multi-license-count)) false))
"\n " (ansi/bold "Deps with no detected licenses: ") (fit-width 9 (str no-license-count) false)
"\n " (ansi/bold "Deps with 1 license: ") (fit-width 9 (str single-license-count) false)
"\n " (ansi/bold "Deps with multiple licenses: ") (fit-width 9 (str multi-license-count) false)
"\n " (ansi/bold "TOTAL DEPS: " (fit-width 9 (str (count deps-lib-map-with-info)) false))
"\n"))))

(defn- detailed-output!
Expand Down

0 comments on commit 4b85aa3

Please sign in to comment.