Skip to content

Commit

Permalink
0.0.19 - implement project.clj multimethod for updating dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
somecho committed Jul 2, 2023
1 parent ebd4916 commit d496831
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[deps-deploy.deps-deploy :as dd]))

(def lib 'org.clojars.some/depo)
(def version "0.0.18")
(def version "0.0.19")
(def jar-file (format "target/%s-%s.jar" (name lib) version))
(def class-dir "target/classes")
(def url "https://github.com/somecho/depo")
Expand Down
3 changes: 3 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(defproject depo "0.0.1"
:dependencies [[reagent "1.2.0"]
[metosin/malli "0.11.0"]])
2 changes: 1 addition & 1 deletion src/depo/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(def CONFIGURATION
{:command "depo"
:description "Manage dependencies for Clojure projects easily"
:version "0.0.18"
:version "0.0.19"
:opts [{:as "path to configuration file"
:default nil
:option "file"
Expand Down
44 changes: 43 additions & 1 deletion src/depo/readwrite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,46 @@
:map {:sort? false
:hang? false}})
(as-> new-conf (spit config-path new-conf))))
(println (str identifier) current-version "is up to date. Skipping")))))
(println (str identifier) current-version "is up to date. Skipping.")))))

(defmethod update-dependency "project.clj"
[config-path arg]
(let [zloc (z/of-string (slurp config-path))
{:keys [groupID artifactID version]} (dp/parse arg)
identifier (symbol (if (= groupID artifactID)
artifactID
(str groupID "/" artifactID)))
dep-vec (-> zloc
(z/find-value z/next :dependencies)
(z/next)
(z/string)
(read-string))
dep-item (first (filter #(= (first %) identifier) dep-vec))
current-version (second dep-item)
dependency-exists? (seq dep-item)
{:keys [groupID artifactID version]} (if dependency-exists?
(r/conform-version arg)
nil)]
(if-not dependency-exists?
(println arg "isn't a dependency. Skipping.")
(if-not (= current-version version)
(do
(println "Updating" (str identifier))
(println "Current version:" current-version)
(println "Latest version:" version)
(-> zloc
(z/find-value z/next :dependencies)
(z/next)
(z/replace (vec (map #(if (= (first %) identifier)
[identifier version]
%) dep-vec)))
(as-> veczip
(z/map (fn [z] (if (z/rightmost? z)
z
(z/insert-newline-right z))) veczip))
(z/root-string)
(zp/zprint-str {:parse-string? true
:vector {:respect-nl? true
:wrap-coll? nil}})
(as-> new-conf (spit config-path new-conf))))
(println (str identifier) current-version "is up to date. Skipping.")))))

0 comments on commit d496831

Please sign in to comment.