-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for updating libraries to latest version. Issue #376.
- Loading branch information
1 parent
f85a99a
commit ab4f2f3
Showing
24 changed files
with
159 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
;; This interface has the name ifc, just to check that it's allowed! | ||
(ns ^:no-doc polylith.clj.core.antq.ifc | ||
(:require [polylith.clj.core.antq.core :as core])) | ||
(:require [polylith.clj.core.antq.latest :as latest] | ||
[polylith.clj.core.antq.upgrade :as upgrade])) | ||
|
||
(defn library->latest-version [configs] | ||
(core/library->latest-version configs)) | ||
(latest/library->latest-version configs)) | ||
|
||
(defn upgrade-all-libs! [workspace color-mode] | ||
(upgrade/upgrade-all-libs! workspace color-mode)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(ns ^:no-doc polylith.clj.core.antq.latest | ||
(:require [antq.api :as antq])) | ||
|
||
(defn truncate [version type] | ||
(if (= :git-sha type) | ||
(subs version 0 7) | ||
version)) | ||
|
||
(defn key-value [{:keys [name version latest-version type]}] | ||
[[name (truncate version type)] | ||
(truncate latest-version type)]) | ||
|
||
(defn configs [{:keys [configs]}] | ||
(let [{:keys [bases components projects]} configs] | ||
(concat bases components projects))) | ||
|
||
(defn library->latest-version | ||
"Returns a map where the key is [lib-name lib-version] | ||
and the value is the latest version of the library." | ||
[workspace] | ||
(into {} (map key-value) | ||
(antq/outdated-deps | ||
{:deps (apply merge (mapv #(-> % :deps :deps) | ||
(configs workspace)))}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(ns ^:no-doc polylith.clj.core.antq.upgrade | ||
(:require [antq.api :as antq] | ||
[clojure.set :as set] | ||
[polylith.clj.core.antq.latest :as latest] | ||
[polylith.clj.core.util.interface.color :as color])) | ||
|
||
(defn outdated-libs-in-config [config outdated-libs] | ||
(seq (set/intersection outdated-libs | ||
(-> config :deps :deps keys set)))) | ||
|
||
(defn keep? [entity-name lib entity-config] | ||
(contains? (set (get-in entity-config [entity-name :keep-lib-versions])) | ||
lib)) | ||
|
||
(defn keep-lib-version? [entity-name type lib {:keys [bricks projects]}] | ||
(if (= "project" type) | ||
(keep? entity-name lib projects) | ||
(keep? entity-name lib bricks))) | ||
|
||
(defn upgrade-dep-in-config [entity-name type filename lib lib->latest-version settings color-mode] | ||
(when-not (keep-lib-version? entity-name type lib settings) | ||
(let [[[_ version] latest-version] (first (filter #(= lib (-> % ffirst symbol)) | ||
lib->latest-version)) | ||
ok? (get (antq/upgrade-deps! [{:file filename | ||
:dependency {:project :clojure | ||
:type :java | ||
:name (str lib) | ||
:version version | ||
:latest-version latest-version}}]) | ||
true)] | ||
(when ok? | ||
(println (str " Updated " lib " to " latest-version " in " (color/entity type entity-name color-mode) ".")))))) | ||
|
||
(defn upgrade-deps-in-config [{:keys [name type] :as config} outdated-libs lib->latest-version ws-dir settings color-mode] | ||
(let [filename (str ws-dir "/" type "s/" name "/deps.edn")] | ||
(doseq [lib (outdated-libs-in-config config outdated-libs)] | ||
(upgrade-dep-in-config name type filename lib lib->latest-version settings color-mode)))) | ||
|
||
(defn upgrade-all-libs! [{:keys [ws-dir settings] :as workspace} color-mode] | ||
(let [lib->latest-version (latest/library->latest-version workspace) | ||
outdated-libs (set (mapv #(-> % first symbol) | ||
(keys lib->latest-version))) | ||
outdated-configs (filter #(outdated-libs-in-config % outdated-libs) | ||
(latest/configs workspace))] | ||
(doseq [outdated-config outdated-configs] | ||
(upgrade-deps-in-config outdated-config outdated-libs lib->latest-version ws-dir settings color-mode)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{:paths ["src"] | ||
:deps {djblue/portal {:mvn/version "0.48.0"}} | ||
:deps {djblue/portal {:mvn/version "0.49.1"}} | ||
:aliases {:test {:extra-paths [] | ||
:extra-deps {}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.