Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
superalex committed Apr 11, 2024
2 parents 5c51889 + ac835bb commit f97b705
Show file tree
Hide file tree
Showing 37 changed files with 342 additions and 566 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ enableImmutableInstalls: false

enableTelemetry: false

httpTimeout: 600000

nodeLinker: node-modules
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
- Fix problem with fix scrolling on nested elements [Github #3508](https://github.com/penpot/penpot/issues/3508)
- Fix problem when changing typography assets [Github #3683](https://github.com/penpot/penpot/issues/3683)
- Internal error when you copy and paste some main components between files [Taiga #7397](https://tree.taiga.io/project/penpot/issue/7397)

- Fix toolbar disappearing [Taiga #7411](https://tree.taiga.io/project/penpot/issue/7411)
- Fix long text on tab breaks UI [Taiga Issue #7421](https://tree.taiga.io/project/penpot/issue/7421)

## 1.19.5

Expand Down
4 changes: 0 additions & 4 deletions backend/scripts/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def migrate_components_v2():
"delete-profile",
"search-profile",
"derive-password",
"migrate-components-v2",
)

parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -233,7 +232,4 @@ def migrate_components_v2():

search_profile(email)

elif args.action == "migrate-components-v2":
migrate_components_v2()


2 changes: 2 additions & 0 deletions backend/scripts/repl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export PENPOT_FLAGS="\
enable-file-validation \
enable-file-schema-validation";

# Default deletion delay for devenv
export PENPOT_DELETION_DELAY="24h"

# Setup default upload media file size to 100MiB
export PENPOT_MEDIA_MAX_FILE_SIZE=104857600
Expand Down
8 changes: 5 additions & 3 deletions backend/scripts/run.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ if [ -f ./environ ]; then
source ./environ
fi

export JVM_OPTS="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -Dlog4j2.configurationFile=log4j2.xml -XX:-OmitStackTraceInFastThrow --enable-preview $JVM_OPTS"
export JVM_OPTS="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -Dlog4j2.configurationFile=log4j2.xml -XX:-OmitStackTraceInFastThrow -Dpolyglot.engine.WarnInterpreterOnly=false --enable-preview $JVM_OPTS"

set -x
exec $JAVA_CMD $JVM_OPTS "$@" -jar penpot.jar -m app.main
ENTRYPOINT=${1:-app.main};

set -ex
exec $JAVA_CMD $JVM_OPTS "$@" -jar penpot.jar -m $ENTRYPOINT
45 changes: 6 additions & 39 deletions backend/scripts/start-dev
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,18 @@ export OPTIONS="
-J-XX:+UnlockDiagnosticVMOptions \
-J-XX:+DebugNonSafepoints"

# Default deletion delay for devenv
export PENPOT_DELETION_DELAY="24h"

# Setup default upload media file size to 100MiB
export PENPOT_MEDIA_MAX_FILE_SIZE=104857600

# Setup default multipart upload size to 300MiB
export PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE=314572800

# Setup HEAP
# export OPTIONS="$OPTIONS -J-Xms50m -J-Xmx1024m"
# export OPTIONS="$OPTIONS -J-Xms1100m -J-Xmx1100m -J-XX:+AlwaysPreTouch"

# Increase virtual thread pool size
# export OPTIONS="$OPTIONS -J-Djdk.virtualThreadScheduler.parallelism=16"

# Disable C2 Compiler
# export OPTIONS="$OPTIONS -J-XX:TieredStopAtLevel=1"

# Disable all compilers
# export OPTIONS="$OPTIONS -J-Xint"

# Setup GC
# export OPTIONS="$OPTIONS -J-XX:+UseG1GC"

# Setup GC
# export OPTIONS="$OPTIONS -J-XX:+UseZGC"

# Enable ImageMagick v7.x support
# export OPTIONS="-J-Dim4java.useV7=true $OPTIONS";


# Initialize MINIO config
mc alias set penpot-s3/ http://minio:9000 minioadmin minioadmin -q
mc admin user add penpot-s3 penpot-devenv penpot-devenv -q
Expand All @@ -76,24 +59,8 @@ export PENPOT_ASSETS_STORAGE_BACKEND=assets-s3
export PENPOT_STORAGE_ASSETS_S3_ENDPOINT=http://minio:9000
export PENPOT_STORAGE_ASSETS_S3_BUCKET=penpot

if [ "$1" = "--watch" ]; then
trap "exit" INT TERM ERR
trap "kill 0" EXIT

echo "Start Watch..."
entrypoint=${1:-app.main};

clojure $OPTIONS -A:dev -M -m app.main &
set -ex

npx nodemon \
--watch src \
--watch ../common \
--ext "clj" \
--signal SIGKILL \
--exec 'echo "(app.main/stop)\n\r(repl/refresh)\n\r(app.main/start)\n" | nc -N localhost 6062'

wait;

else
set -x
clojure $OPTIONS -A:dev -M -m app.main;
fi
clojure $OPTIONS -A:dev -M -m $entrypoint;
9 changes: 7 additions & 2 deletions backend/src/app/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
(s/def ::audit-log-archive-uri ::us/string)
(s/def ::audit-log-http-handler-concurrency ::us/integer)

(s/def ::deletion-delay ::dt/duration)

(s/def ::admins ::us/set-of-valid-emails)
(s/def ::file-change-snapshot-every ::us/integer)
(s/def ::file-change-snapshot-timeout ::dt/duration)
Expand Down Expand Up @@ -214,6 +216,7 @@
(s/keys :opt-un [::secret-key
::flags
::admins
::deletion-delay
::allow-demo-users
::audit-log-archive-uri
::audit-log-http-handler-concurrency
Expand Down Expand Up @@ -335,7 +338,8 @@
:enable-backend-openapi-doc
:enable-backend-worker
:enable-secure-session-cookies
:enable-email-verification])
:enable-email-verification
:enable-v2-migration])

(defn- parse-flags
[config]
Expand Down Expand Up @@ -380,7 +384,8 @@
(defonce ^:dynamic flags (parse-flags config))

(def deletion-delay
(dt/duration {:days 7}))
(or (c/get config :deletion-delay)
(dt/duration {:days 7})))

(defn get
"A configuration getter. Helps code be more testable."
Expand Down
23 changes: 4 additions & 19 deletions backend/src/app/features/components_v2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
[app.storage.tmp :as tmp]
[app.svgo :as svgo]
[app.util.blob :as blob]
[app.util.events :as events]
[app.util.pointer-map :as pmap]
[app.util.time :as dt]
[buddy.core.codecs :as bc]
Expand Down Expand Up @@ -1196,9 +1195,6 @@
add-instance-grid
(fn [fdata frame-id grid assets]
(reduce (fn [result [component position]]
(events/tap :progress {:op :migrate-component
:id (:id component)
:name (:name component)})
(add-main-instance result component frame-id (gpt/add position
(gpt/point grid-gap grid-gap))))
fdata
Expand Down Expand Up @@ -1518,9 +1514,6 @@

(->> (d/zip media-group grid)
(reduce (fn [fdata [mobj position]]
(events/tap :progress {:op :migrate-graphic
:id (:id mobj)
:name (:name mobj)})
(or (process fdata mobj position) fdata))
(assoc-in fdata [:options :components-v2] true)))))

Expand Down Expand Up @@ -1759,11 +1752,6 @@
(let [file (get-file system file-id)
file (process-file! system file :validate? validate?)]

(events/tap :progress
{:op :migrate-file
:name (:name file)
:id (:id file)})

(persist-file! system file)))))

(catch Throwable cause
Expand Down Expand Up @@ -1791,10 +1779,11 @@
(some-> *team-stats* (swap! update :processed-files (fnil inc 0)))))))))

(defn migrate-team!
[system team-id & {:keys [validate? skip-on-graphic-error? label]}]
[system team-id & {:keys [validate? rown skip-on-graphic-error? label]}]

(l/dbg :hint "migrate:team:start"
:team-id (dm/str team-id))
:team-id (dm/str team-id)
:rown rown)

(let [tpoint (dt/tpoint)
err (volatile! false)
Expand All @@ -1816,11 +1805,6 @@
(conj "layout/grid")
(conj "styles/v2"))]

(events/tap :progress
{:op :migrate-team
:name (:name team)
:id id})

(run! (partial migrate-file system)
(get-and-lock-team-files conn id))

Expand Down Expand Up @@ -1849,6 +1833,7 @@

(l/dbg :hint "migrate:team:end"
:team-id (dm/str team-id)
:rown rown
:files files
:components components
:graphics graphics
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app/http/errors.clj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
(= code :invalid-image)
(binding [l/*context* (request->context request)]
(let [cause (or parent-cause err)]
(l/error :hint "unexpected error on processing image" :cause cause)
(l/warn :hint "unexpected error on processing image" :cause cause)
{::rres/status 400 ::rres/body data}))

:else
Expand Down
10 changes: 7 additions & 3 deletions backend/src/app/loggers/mattermost.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@

(defn- send-mattermost-notification!
[cfg {:keys [id public-uri] :as report}]


(let [text (str "Exception: " public-uri "/dbg/error/" id " "
(when-let [pid (:profile-id report)]
(str "(pid: #uuid-" pid ")"))
"\n"
"```\n"
"- host: `" (:host report) "`\n"
"- tenant: `" (:tenant report) "`\n"
"- host: #" (:host report) "\n"
"- tenant: #" (:tenant report) "\n"
"- logger: #" (:logger report) "\n"
"- request-path: `" (:request-path report) "`\n"
"- frontend-version: `" (:frontend-version report) "`\n"
"- backend-version: `" (:backend-version report) "`\n"
"\n"
"```\n"
"Trace:\n"
(:trace report)
"```")
Expand All @@ -60,6 +63,7 @@
:frontend-version (:version/frontend context)
:profile-id (:request/profile-id context)
:request-path (:request/path context)
:logger (::l/logger record)
:trace (ex/format-throwable cause :detail? false :header? false)})

(defn handle-event
Expand Down
26 changes: 12 additions & 14 deletions backend/src/app/loggers/webhooks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
[app.config :as cf]
[app.db :as db]
[app.http.client :as http]
[app.util.json :as json]
[app.util.time :as dt]
[app.worker :as wrk]
[clojure.data.json :as json]
[clojure.spec.alpha :as s]
[cuerdas.core :as str]
[integrant.core :as ig]))
Expand Down Expand Up @@ -86,11 +86,9 @@
(declare interpret-exception)
(declare interpret-response)

(def ^:private json-mapper
(json/mapper
{:encode-key-fn str/camel
:decode-key-fn (comp keyword str/kebab)
:pretty true}))
(def json-write-opts
{:key-fn str/camel
:indent true})

(defmethod ig/pre-init-spec ::run-webhook-handler [_]
(s/keys :req [::http/client ::db/pool]))
Expand Down Expand Up @@ -134,15 +132,15 @@
whook (::config props)

body (case (:mtype whook)
"application/json" (json/encode-str event json-mapper)
"application/json" (json/write-str event json-write-opts)
"application/transit+json" (t/encode-str event)
"application/x-www-form-urlencoded" (uri/map->query-string event))]

(l/debug :hint "run webhook"
:event-name (:name event)
:webhook-id (:id whook)
:webhook-uri (:uri whook)
:webhook-mtype (:mtype whook))
(l/dbg :hint "run webhook"
:event-name (:name event)
:webhook-id (:id whook)
:webhook-uri (:uri whook)
:webhook-mtype (:mtype whook))

(let [req {:uri (:uri whook)
:headers {"content-type" (:mtype whook)
Expand All @@ -160,8 +158,8 @@
(report-delivery! whook req nil err)
(update-webhook! whook err)
(when (= err "unknown")
(l/error :hint "unknown error on webhook request"
:cause cause))))))))))
(l/err :hint "unknown error on webhook request"
:cause cause))))))))))

(defn interpret-response
[{:keys [status] :as response}]
Expand Down
15 changes: 15 additions & 0 deletions backend/src/app/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
[app.loggers.webhooks :as-alias webhooks]
[app.metrics :as-alias mtx]
[app.metrics.definition :as-alias mdef]
[app.migrations.v2 :as migrations.v2]
[app.msgbus :as-alias mbus]
[app.redis :as-alias rds]
[app.rpc :as-alias rpc]
Expand Down Expand Up @@ -527,6 +528,15 @@
:worker? (contains? cf/flags :backend-worker)
:version (:full cf/version)))

(defn start-custom
[config]
(ig/load-namespaces config)
(alter-var-root #'system (fn [sys]
(when sys (ig/halt! sys))
(-> config
(ig/prep)
(ig/init)))))

(defn stop
[]
(alter-var-root #'system (fn [sys]
Expand Down Expand Up @@ -573,6 +583,11 @@
(nrepl/start-server :bind "0.0.0.0" :port 6064 :handler cider-nrepl-handler))

(start)

(when (contains? cf/flags :v2-migration)
(px/sleep 5000)
(migrations.v2/migrate app.main/system))

(deref p))
(catch Throwable cause
(binding [*out* *err*]
Expand Down

0 comments on commit f97b705

Please sign in to comment.