|
58 | 58 | (throw (ex-info (str "Tool not found: " tool) {})))) |
59 | 59 | :else (throw (ex-info "Missing required args, install-latest requires either :tool or both :lib and :as" (or args {}))))) |
60 | 60 |
|
| 61 | +(defn- release-version? |
| 62 | + "Release version does not contain any of: |
| 63 | + a, alpha, b, beta, m, milestone, rc, cr, snapshot" |
| 64 | + [{:keys [git/tag mvn/version]}] |
| 65 | + (let [v (or tag version)] |
| 66 | + (when v |
| 67 | + (let [vl (str/lower-case v)] |
| 68 | + (not |
| 69 | + (boolean |
| 70 | + (some (fn [s] (str/includes? vl s)) |
| 71 | + ;; check subset of list in docstring as a is in alpha and snapshot, etc |
| 72 | + ["a" "b" "m" "rc" "cr"]))))))) |
| 73 | + |
61 | 74 | (defn- install-1 |
62 | 75 | [lib as master-edn] |
63 | 76 | (let [coord (->> (ext/find-all-versions lib nil master-edn) |
64 | | - (clojure.core/remove #(let [mv (:mvn/version %)] (and mv (str/ends-with? mv "-SNAPSHOT")))) |
| 77 | + (filter release-version?) |
65 | 78 | last)] |
66 | 79 | (if coord |
67 | 80 | (let [current (tool/resolve-tool as)] |
|
80 | 93 | Either :tool or both :lib and :as are required to install a single tool. |
81 | 94 | If neither is provided, install the newest version of all tools. |
82 | 95 |
|
| 96 | + The latest version is determined by listing the versions in semver order, |
| 97 | + filtering out versions with special strings, and choosing the last one. |
| 98 | + Special strings that cause a version to be ignored are: |
| 99 | + alpha a beta b miletone m rc cr snapshot |
| 100 | +
|
| 101 | + It is recommended that Maven tool releases use Maven release version |
| 102 | + conventions, and that git tool releases use tags in the format \"vA.B.C\". |
| 103 | +
|
83 | 104 | Options: |
84 | 105 | :tool tool-name - currently installed tool |
85 | 106 | :lib lib-name - mvn lib or git lib with inferrable url |
|
121 | 142 | (install {'org.clojure/data.json {:mvn/version "0.2.0"} :as "json"}) |
122 | 143 | (tool/resolve-tool "json") |
123 | 144 | (install-latest {:tool "json"}) |
| 145 | + |
| 146 | + (filter release-version? (ext/find-all-versions 'io.github.clj-holmes/clj-watson nil master-edn)) |
| 147 | + (filter release-version? (ext/find-all-versions 'org.clojure/clojure nil master-edn)) |
| 148 | + (filter release-version? (ext/find-all-versions 'io.github.clojure/data.json nil master-edn)) |
124 | 149 | ) |
125 | 150 |
|
126 | 151 | (defn- max-len |
|
0 commit comments