|
72 | 72 | ["a" "b" "m" "rc" "cr"]))))))) |
73 | 73 |
|
74 | 74 | (defn- install-1 |
75 | | - [lib as master-edn] |
76 | | - (let [coord (->> (ext/find-all-versions lib nil master-edn) |
77 | | - (filter release-version?) |
78 | | - last)] |
| 75 | + [lib coord as master-edn] |
| 76 | + (let [current (tool/resolve-tool as) |
| 77 | + coord (or coord (->> (ext/find-all-versions lib (:coord current) master-edn) |
| 78 | + (filter release-version?) |
| 79 | + last |
| 80 | + (merge (:coord current))))] |
79 | 81 | (if coord |
80 | | - (let [current (tool/resolve-tool as)] |
81 | | - (if (and current (= lib (:lib current)) (zero? (ext/compare-versions lib (:coord current) coord master-edn))) |
82 | | - (println (str as ":") "Skipping, newest installed" (ext/coord-summary lib coord)) |
83 | | - (do |
84 | | - (tool/install-tool lib coord as) |
85 | | - (println (str as ":") "Installed" (ext/coord-summary lib coord) |
86 | | - (binding [*print-namespace-maps* false] |
87 | | - (pr-str coord)))))) |
| 82 | + (if (and current (= lib (:lib current)) (zero? (ext/compare-versions lib (:coord current) coord master-edn))) |
| 83 | + (println (str as ":") "Skipping, newest installed" (ext/coord-summary lib coord)) |
| 84 | + (do |
| 85 | + (tool/install-tool lib coord as) |
| 86 | + (println (str as ":") "Installed" (ext/coord-summary lib coord) |
| 87 | + (binding [*print-namespace-maps* false] |
| 88 | + (pr-str coord))))) |
88 | 89 | (println (str as ":") "Did not find versions for" lib)))) |
89 | 90 |
|
90 | 91 | (defn install-latest |
|
95 | 96 | If :lib and :as are provided, the latest version of that lib will be installed |
96 | 97 | with that tool name, replacing any existing tool by that name. |
97 | 98 | If no args are provided, install the newest version of all tools. |
| 99 | + Optionally :coord may be provided to accommodate privately hosted repositories |
| 100 | + or other unresolvable urls. |
98 | 101 |
|
99 | 102 | The latest version is determined by listing the versions in semver order, |
100 | 103 | filtering out versions with special strings, and choosing the last one. |
|
108 | 111 | Options: |
109 | 112 | :tool tool-name - currently installed tool |
110 | 113 | :lib lib-name - mvn lib or git lib with inferrable url |
| 114 | + :coord - map (git coords may omit sha) |
111 | 115 | :as - tool name |
112 | 116 |
|
113 | 117 | Example: |
|
118 | 122 | clj -X:deps find-versions :lib <lib> |
119 | 123 | clj -Ttools install <lib> <coord> :as tool-name" |
120 | 124 | [args] |
121 | | - (let [{:keys [lib as]} (parse-install-latest-args args) |
| 125 | + (let [{:keys [lib coord as]} (parse-install-latest-args args) |
122 | 126 | {:keys [root-edn user-edn]} (deps/find-edn-maps) |
123 | 127 | master-edn (deps/merge-edns [root-edn user-edn])] |
124 | 128 | (if lib |
125 | | - (install-1 lib as master-edn) |
| 129 | + (install-1 lib coord as master-edn) |
126 | 130 | (run! |
127 | 131 | (fn [tool-name] |
128 | 132 | (try |
129 | 133 | (let [{:keys [lib]} (tool/resolve-tool tool-name)] |
130 | | - (install-1 lib tool-name master-edn)) |
| 134 | + (install-1 lib coord tool-name master-edn)) |
131 | 135 | (catch Exception e |
132 | 136 | (println (str tool-name ":") "Failed:" (.getMessage e))))) |
133 | 137 | (tool/list-tools))))) |
|
0 commit comments