Skip to content

Commit

Permalink
0.0.6 - support project.clj for adding dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
somecho committed Jul 1, 2023
1 parent b0b11e3 commit 9273f07
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
6 changes: 3 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(defproject depo "0.0.5"
(defproject depo "0.0.6"
:description "Manage Clojure dependencies easily"
:url "https://github.com/somecho/depo"
:license {:name "Eclipse Public License, v2"
:url "http://www.eclipse.org/legal/epl-v20.html"})
:license {:name "Eclipse Public License, v2",
:url "http://www.eclipse.org/legal/epl-v20.html"})
3 changes: 1 addition & 2 deletions src/depo/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[depo.errors :as e]))

(defn add [{:keys [_arguments file]}]
(println file)
(let [args _arguments
config-path (if file file (rw/get-config))]
(if-not (empty? args)
Expand All @@ -18,7 +17,7 @@
(def CONFIGURATION
{:command "depo"
:description "manage Clojure dependencies easily"
:version "0.0.5"
:version "0.0.6"
:opts [{:as "path to configuration file"
:default nil
:option "file"
Expand Down
37 changes: 37 additions & 0 deletions src/depo/readwrite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,40 @@
(zp/zprint-str {:parse-string? true
:map {:sort? false}})
(as-> new-conf (spit config-path new-conf)))))

(defmethod write-dependency "project.clj"
[config-path arg]
(let [zloc (z/of-string (slurp config-path))
{:keys [groupID artifactID version]} (r/conform-version arg)
dep-sym (symbol (if (= groupID artifactID)
artifactID
(str groupID "/" artifactID)))
zipper (if (z/find-value zloc z/next :dependencies)
zloc
(-> zloc
(z/append-child :dependencies)
(z/append-child [])))]
(println (str "Adding " groupID "/" artifactID " v" version))
(-> zipper
(z/find-value z/next :dependencies)
(z/right)
(z/string)
(read-string)
(as-> dep-vec
(filter #(not= dep-sym (first %)) dep-vec))
(vec)
(conj [dep-sym version])
(as-> new-deps
(-> zipper
(z/find-value z/next :dependencies)
(z/right)
(z/replace new-deps)))
(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)))))

0 comments on commit 9273f07

Please sign in to comment.