From b2607b28ffcd973f7aeb54469ba4dbaf7dbfa07f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 6 Apr 2022 11:14:18 +0200 Subject: [PATCH] :tada: Add build date and changelog to the bundle --- backend/deps.edn | 3 +++ backend/scripts/build | 1 + backend/src/app/http.clj | 1 + backend/src/app/http/debug.clj | 18 +++++++++++++++++- frontend/resources/templates/index.mustache | 1 + frontend/scripts/build | 3 ++- frontend/src/app/config.cljs | 8 ++++++++ frontend/src/app/main.cljs | 5 ++++- 8 files changed, 37 insertions(+), 3 deletions(-) diff --git a/backend/deps.edn b/backend/deps.edn index 4b7b62eb0..34e62ccb9 100644 --- a/backend/deps.edn +++ b/backend/deps.edn @@ -42,6 +42,9 @@ io.sentry/sentry {:mvn/version "5.6.1"} + dawran6/emoji {:mvn/version "0.1.5"} + markdown-clj/markdown-clj {:mvn/version "1.11.0"} + ;; Pretty Print specs pretty-spec/pretty-spec {:mvn/version "0.1.4"} software.amazon.awssdk/s3 {:mvn/version "2.17.136"}} diff --git a/backend/scripts/build b/backend/scripts/build index d2b7b5966..1537b7f91 100755 --- a/backend/scripts/build +++ b/backend/scripts/build @@ -8,6 +8,7 @@ rm -rf target; mkdir -p target/classes; mkdir -p target/dist; echo "$CURRENT_VERSION" > target/classes/version.txt; +cp ../CHANGES.md target/classes/changelog.md; clojure -T:build jar; mv target/penpot.jar target/dist/penpot.jar diff --git a/backend/src/app/http.clj b/backend/src/app/http.clj index 282c286a5..95631738d 100644 --- a/backend/src/app/http.clj +++ b/backend/src/app/http.clj @@ -145,6 +145,7 @@ ["/dbg" {:middleware [(:middleware session)]} ["" {:handler (:index debug)}] + ["/changelog" {:handler (:changelog debug)}] ["/error-by-id/:id" {:handler (:retrieve-error debug)}] ["/error/:id" {:handler (:retrieve-error debug)}] ["/error" {:handler (:retrieve-error-list debug)}] diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 2a90ccf7f..f49c4347d 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -22,8 +22,11 @@ [clojure.spec.alpha :as s] [cuerdas.core :as str] [datoteka.core :as fs] + [emoji.core :as emj] [fipp.edn :as fpp] [integrant.core :as ig] + [markdown.core :as md] + [markdown.transformers :as mdt] [promesa.core :as p] [promesa.exec :as px] [yetti.request :as yrq] @@ -213,6 +216,18 @@ (db/exec-one! conn ["select count(*) as count from server_prop;"]) (yrs/response 200 "OK"))) +(defn changelog + [_ _] + (letfn [(transform-emoji [text state] + [(emj/emojify text) state]) + (md->html [text] + (md/md-to-html-string text :replacement-transformers (into [transform-emoji] mdt/transformer-vector)))] + (if-let [clog (io/resource "changelog.md")] + (yrs/response :status 200 + :headers {"content-type" "text/html; charset=utf-8"} + :body (-> clog slurp md->html)) + (yrs/response :status 404 :body "NOT FOUND")))) + (defn- wrap-async [{:keys [executor] :as cfg} f] (fn [request respond raise] @@ -230,4 +245,5 @@ :retrieve-file-changes (wrap-async cfg retrieve-file-changes) :retrieve-error (wrap-async cfg retrieve-error) :retrieve-error-list (wrap-async cfg retrieve-error-list) - :file-data (wrap-async cfg file-data)}) + :file-data (wrap-async cfg file-data) + :changelog (wrap-async cfg changelog)}) diff --git a/frontend/resources/templates/index.mustache b/frontend/resources/templates/index.mustache index 0b0dfd279..bf6ab809d 100644 --- a/frontend/resources/templates/index.mustache +++ b/frontend/resources/templates/index.mustache @@ -23,6 +23,7 @@ window.penpotTranslations = JSON.parse({{& translations}}); window.penpotThemes = {{& themes}}; window.penpotVersion = "%version%"; + window.penpotBuildDate = "%buildDate%"; {{# manifest}} diff --git a/frontend/scripts/build b/frontend/scripts/build index c7a45d1b4..434a261e8 100755 --- a/frontend/scripts/build +++ b/frontend/scripts/build @@ -3,6 +3,7 @@ set -ex CURRENT_VERSION=$1; +BUILD_DATE=$(date -R); CURRENT_HASH=${CURRENT_HASH:-$(git rev-parse --short HEAD)}; EXTRA_PARAMS=$SHADOWCLJS_EXTRA_PARAMS; @@ -14,4 +15,4 @@ npx gulp dist:clean || exit 1; npx gulp dist:copy || exit 1; sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./target/dist/index.html; - +sed -i -re "s/\%buildDate\%/$BUILD_DATE/g" ./target/dist/index.html; diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 96cd3baaf..7cf0ede1a 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -68,6 +68,13 @@ (-> (obj/get global "penpotVersion") (v/parse))) +(defn parse-build-date + [global] + (let [date (obj/get global "penpotBuildDate")] + (if (= date "%buildDate%") + "unknown" + date))) + ;; --- Globar Config Vars (def default-theme "default") @@ -83,6 +90,7 @@ (def sentry-dsn (obj/get global "penpotSentryDsn")) (def onboarding-form-id (obj/get global "penpotOnboardingQuestionsFormId")) +(def build-date (parse-build-date global)) (def flags (atom (parse-flags global))) (def version (atom (parse-version global))) (def target (atom (parse-target global))) diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index bddddc9bf..287e3fe03 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -33,7 +33,10 @@ (log/set-level! :app :info) (when (= :browser @cf/target) - (log/info :message "Welcome to penpot" :version (:full @cf/version) :public-uri (str cf/public-uri))) + (log/info :message "Welcome to penpot" + :version (:full @cf/version) + :build-date cf/build-date + :public-uri (str cf/public-uri))) (declare reinit)