mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🐛 Fix config parsing on exporter
This commit is contained in:
parent
15faa57e01
commit
1c69a9fd8a
1 changed files with 26 additions and 18 deletions
|
@ -26,16 +26,24 @@
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
schema:config
|
schema:config
|
||||||
(sm/define
|
|
||||||
[:map {:title "config"}
|
[:map {:title "config"}
|
||||||
[:public-uri {:optional true} ::sm/uri]
|
[:public-uri {:optional true} ::sm/uri]
|
||||||
[:host {:optional true} :string]
|
[:host {:optional true} :string]
|
||||||
[:tenant {:optional true} :string]
|
[:tenant {:optional true} :string]
|
||||||
[:flags {:optional true} ::sm/set-of-keywords]
|
[:flags {:optional true} [::sm/set :keyword]]
|
||||||
[:redis-uri {:optional true} :string]
|
[:redis-uri {:optional true} :string]
|
||||||
[:tempdir {:optional true} :string]
|
[:tempdir {:optional true} :string]
|
||||||
[:browser-pool-max {:optional true} :int]
|
[:browser-pool-max {:optional true} ::sm/int]
|
||||||
[:browser-pool-min {:optional true} :int]]))
|
[:browser-pool-min {:optional true} ::sm/int]])
|
||||||
|
|
||||||
|
(def ^:private decode-config
|
||||||
|
(sm/decoder schema:config sm/string-transformer))
|
||||||
|
|
||||||
|
(def ^:private explain-config
|
||||||
|
(sm/explainer schema:config))
|
||||||
|
|
||||||
|
(def ^:private valid-config?
|
||||||
|
(sm/validator schema:config))
|
||||||
|
|
||||||
(defn- parse-flags
|
(defn- parse-flags
|
||||||
[config]
|
[config]
|
||||||
|
@ -60,15 +68,15 @@
|
||||||
[]
|
[]
|
||||||
(let [env (read-env "penpot")
|
(let [env (read-env "penpot")
|
||||||
env (d/without-nils env)
|
env (d/without-nils env)
|
||||||
data (merge defaults env)]
|
data (merge defaults env)
|
||||||
|
data (decode-config data)]
|
||||||
|
|
||||||
(try
|
(when-not (valid-config? data)
|
||||||
(sm/conform! schema:config data)
|
(let [explain (explain-config data)]
|
||||||
(catch :default cause
|
|
||||||
(if-let [explain (some->> cause ex-data ::sm/explain)]
|
|
||||||
(println (sm/humanize-explain explain))
|
(println (sm/humanize-explain explain))
|
||||||
(js/console.error cause))
|
(process/exit -1)))
|
||||||
(process/exit -1)))))
|
|
||||||
|
data))
|
||||||
|
|
||||||
(def config
|
(def config
|
||||||
(prepare-config))
|
(prepare-config))
|
||||||
|
|
Loading…
Add table
Reference in a new issue