mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 23:19:38 +00:00
* Validate localStorage with spec This will help get at the source of errors like #4706 quicker * Fix settings bugs Close #4679 as shortcut tooltip setting is now visible. No need to js/alert when a setting is changed. Probably leftover bugging * Add docs and example of reusing specs in bb task Co-authored-by: Andelf <andelf@gmail.com>
20 lines
804 B
Clojure
20 lines
804 B
Clojure
(ns logseq.tasks.spec
|
|
"Clojure spec related tasks"
|
|
(:require [clojure.spec.alpha :as s]
|
|
[cheshire.core :as json]
|
|
[frontend.spec.storage :as storage-spec]
|
|
[clojure.edn :as edn]))
|
|
|
|
;; To create file for validation, `JSON.stringify(localStorage)` in the js
|
|
;; console and copy string to file
|
|
(defn validate-local-storage
|
|
"Validate a localStorage json file"
|
|
[file]
|
|
(let [local-storage
|
|
(update-vals (json/parse-string (slurp file) keyword)
|
|
;; Not all localStorage values are edn so gracefully return.
|
|
;; For example, logseq-plugin-tabs stores data as json
|
|
#(try (edn/read-string %) (catch Throwable _ %)))]
|
|
(s/assert ::storage-spec/local-storage local-storage)
|
|
(println "Success!")))
|