0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

💄 Fix linter issues on exporter

This commit is contained in:
Andrey Antukh 2022-06-29 14:53:57 +02:00
parent 9c194ee3cb
commit bfb0ba47f5
15 changed files with 23 additions and 59 deletions

View file

@ -9,10 +9,8 @@
["generic-pool" :as gp]
["generic-pool/lib/errors" :as gpe]
["playwright" :as pw]
[app.common.data :as d]
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.util.object :as obj]
[promesa.core :as p]))

View file

@ -7,13 +7,10 @@
(ns app.config
(:refer-clojure :exclude [get])
(:require
["fs" :as fs]
["process" :as process]
[app.common.exceptions :as ex]
[app.common.data :as d]
[app.common.spec :as us]
[app.common.version :as v]
[app.common.uri :as u]
[cljs.core :as c]
[cljs.pprint]
[cljs.spec.alpha :as s]

View file

@ -18,7 +18,7 @@
(l/initialize!)
(defn start
[& args]
[& _]
(l/info :msg "initializing")
(p/do!
(bwr/init)

View file

@ -10,22 +10,18 @@
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.spec :as us]
[app.common.uri :as u]
[app.config :as cf]
[app.handlers.export-frames :as export-frames]
[app.handlers.export-shapes :as export-shapes]
[app.handlers.resources :as resources]
[app.util.transit :as t]
[clojure.spec.alpha :as s]
[cuerdas.core :as str]
[promesa.core :as p]
[reitit.core :as r]))
[cuerdas.core :as str]))
(l/set-level! :debug)
(defn on-error
[error exchange]
(let [{:keys [type message code] :as data} (ex-data error)]
(let [{:keys [type code] :as data} (ex-data error)]
(cond
(or (= :validation type)
(= :assertion type))

View file

@ -6,13 +6,10 @@
(ns app.handlers.export-frames
(:require
["path" :as path]
[app.common.logging :as l]
[app.common.exceptions :as exc]
[app.common.spec :as us]
[app.common.pprint :as pp]
[app.handlers.resources :as rsc]
[app.handlers.export-shapes :refer [prepare-exports]]
[app.handlers.resources :as rsc]
[app.redis :as redis]
[app.renderer :as rd]
[app.util.shell :as sh]
@ -41,7 +38,7 @@
:opt-un [::name]))
(defn handler
[{:keys [:request/auth-token] :as exchange} {:keys [exports profile-id] :as params}]
[{:keys [:request/auth-token] :as exchange} {:keys [exports] :as params}]
;; NOTE: we need to have the `:type` prop because the exports
;; datastructure preparation uses it for creating the groups.
(let [exports (-> (map #(assoc % :type :pdf :scale 1 :suffix "") exports)
@ -111,7 +108,8 @@
(-> (p/loop [exports (seq exports)]
(when-let [export (first exports)]
(p/let [proc (rd/render export on-object)]
(p/do
(rd/render export on-object)
(p/recur (rest exports)))))
(p/then (fn [_] (deref result)))
@ -122,7 +120,7 @@
(-> (sh/stat (:path resource))
(p/then #(merge resource %)))))
(p/catch on-error)
(p/finally (fn [result cause]
(p/finally (fn [_ cause]
(when-not cause
(on-complete)))))))

View file

@ -6,9 +6,7 @@
(ns app.handlers.export-shapes
(:require
["path" :as path]
[app.common.data :as d]
[app.common.exceptions :as exc]
[app.common.logging :as l]
[app.common.spec :as us]
[app.handlers.resources :as rsc]
@ -140,7 +138,8 @@
proc (-> (p/do
(p/loop [exports (seq exports)]
(when-let [export (first exports)]
(p/let [proc (rd/render export append)]
(p/do
(rd/render export append)
(p/recur (rest exports)))))
(.finalize zip))
(p/then (constantly resource))

View file

@ -9,9 +9,7 @@
(:require
["archiver" :as arc]
["fs" :as fs]
["os" :as os]
["path" :as path]
[app.common.data :as d]
[app.common.exceptions :as ex]
[app.common.uuid :as uuid]
[app.util.mime :as mime]
@ -49,7 +47,7 @@
"content-length" (:size stat)}}))
(defn handler
[{:keys [:request/params response] :as exchange}]
[{:keys [:request/params] :as exchange}]
(when-not (contains? params :id)
(ex/raise :type :validation
:code :missing-id))

View file

@ -12,7 +12,6 @@
["raw-body" :as raw-body]
["stream" :as stream]
[app.common.logging :as l]
[app.common.spec :as us]
[app.common.transit :as t]
[app.config :as cf]
[app.handlers :as handlers]

View file

@ -28,7 +28,7 @@
(.on client "reconnect"
(fn [ms] (l/warn :hint "reconnecting to redis" :ms ms)))
(.on client "end"
(fn [ms] (l/warn :hint "client ended, no more connections will be attempted")))
(fn [] (l/warn :hint "client ended, no more connections will be attempted")))
client))
(defn init

View file

@ -31,7 +31,7 @@
(s/def ::render-params
(s/keys :req-un [::file-id ::page-id ::scale ::token ::type ::objects]))
(defn- render
(defn render
[{:keys [type] :as params} on-object]
(us/verify ::render-params params)
(us/verify fn? on-object)

View file

@ -7,19 +7,12 @@
(ns app.renderer.bitmap
"A bitmap renderer."
(:require
["path" :as path]
[app.browser :as bw]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.pages :as cp]
[app.common.spec :as us]
[app.common.uri :as u]
[app.config :as cf]
[app.util.mime :as mime]
[app.util.shell :as sh]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[promesa.core :as p]))

View file

@ -7,18 +7,13 @@
(ns app.renderer.pdf
"A pdf renderer."
(:require
["path" :as path]
[app.browser :as bw]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex :include-macros true]
[app.common.logging :as l]
[app.common.spec :as us]
[app.common.uri :as u]
[app.config :as cf]
[app.util.mime :as mime]
[app.util.shell :as sh]
[cuerdas.core :as str]
[cljs.spec.alpha :as s]
[promesa.core :as p]))
(defn render
@ -57,8 +52,7 @@
(render [base-uri page]
(p/loop [objects (seq objects)]
(when-let [object (first objects)]
(p/let [uri (prepare-uri base-uri (:id object))
path (render-object page base-uri object)]
(p/let [path (render-object page base-uri object)]
(on-object (assoc object :path path))
(p/recur (rest objects))))))]

View file

@ -6,20 +6,14 @@
(ns app.renderer.svg
(:require
["path" :as path]
["xml-js" :as xml]
[app.browser :as bw]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex :include-macros true]
[app.common.logging :as l]
[app.common.pages :as cp]
[app.common.spec :as us]
[app.common.uri :as u]
[app.config :as cf]
[app.util.mime :as mime]
[app.util.shell :as sh]
[cljs.spec.alpha :as s]
[clojure.walk :as walk]
[cuerdas.core :as str]
[promesa.core :as p]))
@ -184,7 +178,7 @@
(get-gradients [id mapping]
(->> mapping
(filter (fn [[color data]]
(filter (fn [[_color data]]
(= (get data "type") "gradient")))
(mapv (partial data->gradient-def id))))
@ -227,7 +221,7 @@
elements (cond->> elements
(not (empty? gradient-defs))
(seq gradient-defs)
(into [{"type" "element" "name" "defs" "attributes" {}
"elements" gradient-defs}]))]

View file

@ -8,7 +8,6 @@
"Mimetype and file extension helpers."
(:refer-clojure :exclude [get])
(:require
[app.common.data :as d]
[cljs.core :as c]))
(defn get-extension
@ -20,7 +19,7 @@
:pdf ".pdf"
:zip ".zip"))
(defn- get
(defn get
[type]
(case type
:zip "application/zip"

View file

@ -11,9 +11,9 @@
["fs" :as fs]
["os" :as os]
["path" :as path]
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.uuid :as uuid]
[app.common.exceptions :as ex]
[cuerdas.core :as str]
[promesa.core :as p]))
@ -34,11 +34,10 @@
(when (fs/existsSync path)
(l/trace :hint "permanently remove tempfile" :path path)
(fs/rmSync path #js {:recursive true})))]
(let [ts (js/Date.now)]
(l/trace :hint "schedule tempfile deletion"
:path path
:scheduled-at (.. (js/Date. (+ (js/Date.now) tempfile-minage)) toString))
(js/setTimeout remote-tempfile tempfile-minage))))
(l/trace :hint "schedule tempfile deletion"
:path path
:scheduled-at (.. (js/Date. (+ (js/Date.now) tempfile-minage)) toString))
(js/setTimeout remote-tempfile tempfile-minage)))
(defn tempfile
[& {:keys [prefix suffix]
@ -86,7 +85,7 @@
(fn [resolve reject]
(l/trace :fn :run-cmd :cmd cmd)
(proc/exec cmd #js {:encoding "buffer"}
(fn [error stdout stderr]
(fn [error stdout _stderr]
;; (l/trace :fn :run-cmd :stdout stdout)
(if error
(reject error)