mirror of
https://github.com/penpot/penpot.git
synced 2025-08-02 08:10:10 +02:00
✨ Add the ability to access libraries from file migrations
This commit is contained in:
parent
c7c8e91183
commit
443cabe94e
12 changed files with 109 additions and 102 deletions
|
@ -58,18 +58,21 @@
|
|||
(map :name))
|
||||
|
||||
(defn migrate
|
||||
[{:keys [id] :as file}]
|
||||
[{:keys [id] :as file} libs]
|
||||
|
||||
(let [diff
|
||||
(set/difference available-migrations (:migrations file))
|
||||
|
||||
data (-> (:data file)
|
||||
(assoc :libs libs))
|
||||
|
||||
data
|
||||
(reduce migrate-data (:data file) diff)
|
||||
(reduce migrate-data data diff)
|
||||
|
||||
data
|
||||
(-> data
|
||||
(assoc :id id)
|
||||
(dissoc :version))]
|
||||
(dissoc :version :libs))]
|
||||
|
||||
(-> file
|
||||
(assoc :data data)
|
||||
|
@ -88,7 +91,7 @@
|
|||
result))
|
||||
|
||||
(defn migrate-file
|
||||
[file]
|
||||
[file libs]
|
||||
(binding [cfeat/*new* (atom #{})]
|
||||
(let [version (or (:version file)
|
||||
(-> file :data :version))]
|
||||
|
@ -104,7 +107,7 @@
|
|||
;; this code from this function that executes on
|
||||
;; each file migration operation
|
||||
(update :features cfeat/migrate-legacy-features)
|
||||
(migrate)
|
||||
(migrate libs)
|
||||
(update :features (fnil into #{}) (deref cfeat/*new*))))))
|
||||
|
||||
(defn migrated?
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
(let [file {:data {:sum 1}
|
||||
:id 1
|
||||
:migrations (d/ordered-set "test/1")}
|
||||
file' (cfm/migrate file)]
|
||||
file' (cfm/migrate file nil)]
|
||||
(t/is (= cfm/available-migrations (:migrations file')))
|
||||
(t/is (= 3 (:sum (:data file'))))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue