Skip to content

Commit

Permalink
Add dependencies to artifact payload
Browse files Browse the repository at this point in the history
  • Loading branch information
opoku committed Nov 11, 2024
1 parent 9c1b9c7 commit a915680
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
15 changes: 15 additions & 0 deletions dev-resources/test-0.0.3-SNAPSHOT/test.pom
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@
<url>https://github.com/fake/test</url>
</scm>

<dependencies>
<dependency>
<groupId>org.pokustan</groupId>
<artifactId>pokure</artifactId>
<version>0.10.1</version>
</dependency>
<dependency>
<groupId>clj-jarjar</groupId>
<artifactId>clj-jarjar</artifactId>
<version>6.5.4</version>
<scope>test</scope>
</dependency>
</dependencies>


</project>
10 changes: 10 additions & 0 deletions src/clojars/routes/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[db :as db]
[stats :as stats]
[http-utils :refer [wrap-cors-headers]]]
[clojure
[set :as set]]
[compojure
[core :as compojure :refer [ANY context GET]]
[route :refer [not-found]]]
Expand All @@ -22,6 +24,14 @@
(assoc version
:downloads (stats/download-count stats group-id artifact-id (:version version))))
versions)))
(assoc :dependencies
(->> (db/find-dependencies db group-id artifact-id (:latest_version artifact))
(map #(-> %
(select-keys [:dep_group_name :dep_jar_name :dep_version :dep_scope])
(set/rename-keys {:dep_group_name :group_name
:dep_jar_name :jar_name
:dep_version :version
:dep_scope :scope})))))
response)
(not-found nil)))

Expand Down
10 changes: 9 additions & 1 deletion test/clojars/integration/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
:downloads 0
:recent_versions [{:downloads 0 :version "0.0.3-SNAPSHOT"}
{:downloads 0 :version "0.0.2"}
{:downloads 0 :version "0.0.1"}]}
{:downloads 0 :version "0.0.1"}]
:dependencies [{:group_name "org.pokustan",
:jar_name "pokure",
:version "0.10.1",
:scope "compile"}
{:group_name "clj-jarjar",
:jar_name "clj-jarjar",
:version "6.5.4",
:scope "test"}]}
body))))

(testing "get non-existent artifact"
Expand Down

0 comments on commit a915680

Please sign in to comment.