Skip to content

Commit 73cab59

Browse files
committed
Update to 0.1.1
I can build a reasonable graalvm native image now
1 parent 1c8e774 commit 73cab59

3 files changed

Lines changed: 28 additions & 16 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Download the application from the releases page.
1010

1111
```
1212
$ rp -s starship --with-repo chocolatey --with-repo scoop
13-
"rust:starship-module-config-derive" is in 0/4 repositories
14-
"starship" is in 3/20 repositories
13+
rust:starship-module-config-derive... 0/4 repos
14+
starship............................. 3/20 repos
1515
1616
$ rp -p starship --with-repo chocolatey --with-repo scoop
1717
| :repo | :subrepo | :name | :version | :status |
@@ -52,7 +52,7 @@ I wrote this in an afternoon. I had a vm with 4 non-language-specific package m
5252

5353
After writing it, I realized it's small enough (< 150 loc) to be an excellent project for playing around with lumo, babashka, graal native image, etc.
5454

55-
This has already been accomplished with graal native image. However, the image size is huge. I believe this is due to limitations with clj-http-lite.
55+
This has already been accomplished with graal native image.
5656

5757
## License
5858

project.clj

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
(defproject repoman "0.1.0-SNAPSHOT"
1+
(defproject repoman "0.1.1"
22
:description "Tiny tool to query repology"
33
:url "http://example.com/FIXME"
44
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
55
:url "https://www.eclipse.org/legal/epl-2.0/"}
6-
:dependencies [[org.clojure/clojure "1.10.1"]
6+
:dependencies [[org.clojure/clojure "1.10.2-alpha1"]
77
[org.clojure/tools.cli "1.0.194"]
88
;; clj-http incompatible with graal
9-
[org.martinklepsch/clj-http-lite "0.4.3"]
9+
;; 0.4.3-1 is built locally, using the latest commit
10+
[org.martinklepsch/clj-http-lite "0.4.3-1"]
1011
[cheshire "5.10.0"]
1112
[camel-snake-kebab "0.4.1"]]
1213
:plugins [[io.taylorwood/lein-native-image "0.3.1"]]
1314
:main ^:skip-aot repoman.core
1415
:target-path "target/%s"
16+
:java-cmd "C:\\Users\\doubl\\scoop\\apps\\openjdk15\\current\\bin\\java.exe"
17+
:javac-options ["-server"]
1518
:native-image
1619
{:name "rp"
1720
:graal-bin "C:\\Program Files\\GraalVM\\graalvm-ce-java11-20.1.0\\bin"
21+
;; :jvm-opts ["-Dclojure.compiler.direct-linking=true"]
1822
:opts ["--verbose"
19-
"--report-unsupported-elements-at-runtime"
23+
;; "--report-unsupported-elements-at-runtime"
2024
"--initialize-at-build-time"
21-
"--allow-incomplete-classpath" ;; clj-http-lite requires this
2225
"--enable-https"
2326
"--no-fallback"]}
2427
:profiles
2528
{:uberjar
2629
{:aot :all
27-
:native-image
28-
{:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}}})
30+
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})

src/repoman/core.clj

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
(:import [java.io File])
1212
(:gen-class))
1313

14-
;; (set! *warn-on-reflection* true)
14+
(set! *warn-on-reflection* true)
1515

1616
(def endpoint "https://repology.org/api/v1/")
1717
(def pkg-keys [:repo :subrepo :name :version :status])
@@ -76,8 +76,9 @@
7676
(fn [[k v]]
7777
(let [v (transform-keys ->kebab-case-keyword v)]
7878
{:prj k
79+
:prj-len (count k)
7980
:repos (count v)
80-
:avail? (count (filter (partial in-repos? repos) v))})))))
81+
:matches (count (filter (partial in-repos? repos) v))})))))
8182

8283
(defn project
8384
"Gets project information from repology
@@ -105,10 +106,19 @@
105106
[repos {:keys [search json]}]
106107
(let [xs (repoman.core/search repos search)]
107108
(if json
108-
(println (json/generate-string xs {:pretty true}))
109-
(doseq [m xs]
110-
(println (format "\"%s\" is in %d/%d repositories"
111-
(:prj m) (:avail? m) (:repos m)))))))
109+
(println
110+
(json/generate-string
111+
(map #(dissoc % :prj-len) xs)
112+
{:pretty true}))
113+
(let [max-len (apply max (map :prj-len xs))]
114+
(doseq [{:keys [prj prj-len repos matches]} xs]
115+
(println
116+
(format
117+
"%s...%s%3s/%s repos"
118+
prj
119+
(apply str (repeat (- max-len prj-len) \.))
120+
matches
121+
repos)))))))
112122

113123
(defn format-project
114124
"Prints project data to the screen.

0 commit comments

Comments
 (0)