Skip to content

Commit

Permalink
0.2.27 - clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
somecho committed Jul 5, 2023
1 parent d51bd5c commit 1354b90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 137 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.2.26")
(def version "0.2.27")
(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
2 changes: 1 addition & 1 deletion src/depo/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
(def CONFIGURATION
{:command "depo"
:description "Manage dependencies for Clojure projects easily"
:version "0.2.26"
:version "0.2.27"
:opts [{:as "path to configuration file"
:default nil
:option "file"
Expand Down
137 changes: 2 additions & 135 deletions src/depo/readwrite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
(.exists (io/file "shadow-cljs.edn")) "shadow-cljs.edn"
(.exists (io/file "bb.edn")) "bb.edn"))

(defn get-dependency-data
[deps identifier]
(cond
(map? deps) (get deps identifier)
(vector? deps) (-> #(= identifier (first %))
(filter deps)
(first)
(rest))))

(defn get-dependency-type
[deps]
(cond
Expand All @@ -72,21 +63,6 @@
(rest keys))
zloc)))

(defn get-dep-vec-map
[{:keys [zloc keys project-type]}]
(-> zloc
(as-> zipper
(case project-type
:lein (-> (z/find-value zipper z/next (first keys))
(z/next)
(as-> zpos
(if (not-empty (rest keys))
(traverse-zip-map zpos (rest keys))
zpos)))
(traverse-zip-map zipper keys)))
(z/string)
(read-string)))

(defn get-project-type
"- `config-path` - the full path to the config file as a string
Expand Down Expand Up @@ -125,111 +101,6 @@
:map (keys vec-map)
:vector (map #(str (first %)) vec-map))))))

; (defn add-dependency
; [{:keys [deps id]}]
; (let [{:keys [groupID artifactID version]} (r/conform-version id)
; dep-type (get-dependency-type deps)
; identifier (create-identifier groupID
; artifactID
; dep-type)]
; (println "Adding" identifier version)
; (case dep-type
; :map (assoc deps (symbol identifier) {:mvn/version version})
; :vector (let [dep-exists? (-> #(= (symbol identifier) (first %))
; (filter deps)
; (seq))]
; (if dep-exists?
; (vec (map #(if (= (symbol identifier) (first %))
; (vec (concat [(symbol identifier) version] (rest (rest %))))
; %) deps))
; (-> (conj deps [(symbol identifier) version])
; (distinct)
; (vec)))))))

; (defn remove-dependency
; [{:keys [deps id]}]
; (let [{:keys [groupID artifactID version]} (r/conform-version id)
; dep-type (get-dependency-type deps)
; identifier (create-identifier groupID
; artifactID
; dep-type)]
; (println "Removing" identifier version)
; (case dep-type
; :map (dissoc deps (symbol identifier))
; :vector (vec (filter #(not= (symbol identifier) (first %)) deps)))))

(defn get-current-version
[deps identifier]
(cond
(map? deps)
(:mvn/version (get-dependency-data deps identifier))
(vector? deps)
(first (get-dependency-data deps identifier))))

; (defn update-dependency
; [{:keys [deps id]}]
; (let [{:keys [groupID artifactID version]} (r/conform-version id)
; identifier (create-identifier groupID
; artifactID
; (get-dependency-type deps))
; current-version (get-current-version deps (symbol identifier))]
; (if (= current-version version)
; (do
; (println identifier current-version "is up-to-date. Skipping.")
; deps)
; (do
; (println "Updating" identifier current-version "->" version)
; (cond
; (map? deps) (assoc deps (symbol identifier) {:mvn/version version})
; (vector? deps) (mapv
; #(if (= (symbol identifier) (first %))
; (vec (concat [(symbol identifier) version]
; (rest (rest %))))
; %)
; deps))))))

(defn zip-vec-add-newlines
"- `zloc` - a zipper object of a vector created by rewrite-clj
Splits up a vector of vectors (dependencies) into multiple lines.
Indentation is not considered."
[zloc]
(z/map (fn [z] (if (z/rightmost? z)
z
(z/insert-newline-right z))) zloc))

; (defn replace-dependencies
; "Takes in a map with the following keys
; - `:project-type` - `:lein`, `:shadow` or `:default`
; - `:zloc` - zipper object of config file created by rewrite-clj
; - `:keys` - a vector of keys telling Depo which dependencies to replace
; - `:new-deps` - a vector or map of the newly written dependencies

; Replaces the specified dependencies in a map and returns
; a string formatted by zprint"
; [{:keys [zloc keys new-deps project-type]}]
; (-> zloc
; (as-> zipper
; (case project-type
; :lein (-> zipper
; (z/find-value z/next (first keys))
; (z/next))
; (traverse-zip-map zipper keys)))
; (z/replace new-deps)
; (as-> zipper
; (case project-type
; :default zipper
; (zip-vec-add-newlines zipper)))
; (z/root-string)
; (zp/zprint-str {:parse-string? true
; :style (case project-type
; :default :map-nl
; :indent-only)
; :map {:sort? false
; :hang? false}
; :vector {:hang? false
; :wrap-coll? nil}})))

(defn get-deps
[zloc keys project-type]
(case project-type
Expand Down Expand Up @@ -397,12 +268,8 @@
[{:keys [config-path id operation]}]
(let [config-zip (z/of-string (slurp config-path))
project-type (get-project-type config-path)
access-keys [(create-keys project-type)]
dep-vec-map (get-dep-vec-map {:zloc config-zip
:keys access-keys
:project-type project-type})]
(-> (operate operation {:deps dep-vec-map
:id id
access-keys [(create-keys project-type)]]
(-> (operate operation {:id id
:zloc config-zip
:project-type project-type
:keys access-keys})
Expand Down

0 comments on commit 1354b90

Please sign in to comment.