mirror of
https://github.com/penpot/penpot.git
synced 2025-04-12 23:11:23 -05:00
🎉 Add version string parsing.
This commit is contained in:
parent
ac2310f71f
commit
28a2df96ff
6 changed files with 72 additions and 29 deletions
|
@ -11,6 +11,7 @@
|
|||
"A configuration management."
|
||||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.common.version :as v]
|
||||
[app.util.time :as dt]
|
||||
[clojure.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
|
@ -197,6 +198,9 @@
|
|||
(def default-deletion-delay
|
||||
(dt/duration {:hours 48}))
|
||||
|
||||
(def version
|
||||
(delay (v/parse "%version%")))
|
||||
|
||||
(defn smtp
|
||||
[cfg]
|
||||
{:host (:smtp-host cfg "localhost")
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
(ns app.main
|
||||
(:require
|
||||
[app.config :as cfg]
|
||||
[clojure.tools.logging :as log]
|
||||
[mount.core :as mount]))
|
||||
|
||||
(defn- enable-asserts
|
||||
|
@ -26,15 +28,13 @@
|
|||
|
||||
(defn run
|
||||
[_params]
|
||||
(require 'app.config
|
||||
'app.srepl.server
|
||||
(require 'app.srepl.server
|
||||
'app.migrations
|
||||
'app.worker
|
||||
'app.media
|
||||
'app.http)
|
||||
(mount/start))
|
||||
|
||||
|
||||
(mount/start)
|
||||
(log/infof "Welcome to penpot! Version: '%s'." (:full @cfg/version)))
|
||||
|
||||
(defn -main
|
||||
[& _args]
|
||||
|
|
18
common/app/common/version.cljc
Normal file
18
common/app/common/version.cljc
Normal file
|
@ -0,0 +1,18 @@
|
|||
(ns app.common.version
|
||||
"A version parsing helper."
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(defn parse
|
||||
[version]
|
||||
(if (= version "%version%")
|
||||
{:full "develop"
|
||||
:base "develop"
|
||||
:build 0
|
||||
:commit nil}
|
||||
(let [[base build commit] (str/split version #"-" 3)]
|
||||
{:full version
|
||||
:base base
|
||||
:build (d/parse-integer build)
|
||||
:commit commit})))
|
|
@ -6,21 +6,27 @@
|
|||
<title>PENPOT - The Open-Source prototyping tool</title>
|
||||
<link id="theme" href="/css/main-{{& th}}.css?ts={{& ts}}"
|
||||
rel="stylesheet" type="text/css" />
|
||||
|
||||
<link rel="icon" href="/images/favicon.png" />
|
||||
</head>
|
||||
<body>
|
||||
{{>../public/images/sprites/symbol/svg/sprite.symbol.svg}}
|
||||
<section id="app" tabindex="1"></section>
|
||||
<section id="modal"></section>
|
||||
|
||||
<script>
|
||||
window.appTranslations = JSON.parse({{& translations}});
|
||||
window.appThemes = {{& themes}};
|
||||
window.appTranslations = JSON.parse({{& translations}});
|
||||
window.appThemes = {{& themes}};
|
||||
window.appVersion = "%version%";
|
||||
</script>
|
||||
|
||||
{{# manifest}}
|
||||
<script>window.appWorkerURI="{{& worker}}"</script>
|
||||
<script src="{{& config}}"></script>
|
||||
<script src="{{& polyfills}}"></script>
|
||||
{{/manifest}}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
{{>../public/images/sprites/symbol/svg/sprite.symbol.svg}}
|
||||
<section id="app" tabindex="1"></section>
|
||||
<section id="modal"></section>
|
||||
{{# manifest}}
|
||||
<script src="{{& shared}}"></script>
|
||||
<script src="{{& main}}"></script>
|
||||
{{/manifest}}
|
||||
|
|
|
@ -10,15 +10,19 @@
|
|||
(ns app.config
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[app.common.data :as d]
|
||||
[app.common.spec :as us]
|
||||
[app.common.version :as v]
|
||||
[app.util.object :as obj]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
;; --- Auxiliar Functions
|
||||
|
||||
(s/def ::platform #{:windows :linux :macos :other})
|
||||
(s/def ::browser #{:chrome :mozilla :safari :edge :other})
|
||||
|
||||
(defn parse-browser
|
||||
(defn- parse-browser
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-chrome? (fn [] (str/includes? user-agent "chrom"))
|
||||
|
@ -32,7 +36,7 @@
|
|||
(check-safari?) :safari
|
||||
:else :other)))
|
||||
|
||||
(defn parse-platform
|
||||
(defn- parse-platform
|
||||
[]
|
||||
(let [user-agent (-> (dom/get-user-agent) str/lower)
|
||||
check-windows? (fn [] (str/includes? user-agent "windows"))
|
||||
|
@ -44,6 +48,10 @@
|
|||
(check-macos?) :macos
|
||||
:else :other)))
|
||||
|
||||
;; --- Globar Config Vars
|
||||
|
||||
(def default-theme "default")
|
||||
|
||||
(this-as global
|
||||
(def default-language "en")
|
||||
(def demo-warning (obj/get global "appDemoWarning" false))
|
||||
|
@ -53,10 +61,18 @@
|
|||
(def worker-uri (obj/get global "appWorkerURI" "/js/worker.js"))
|
||||
(def public-uri (or (obj/get global "appPublicURI")
|
||||
(.-origin ^js js/location)))
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def default-theme "default")
|
||||
(def browser (parse-browser))
|
||||
(def platform (parse-platform)))
|
||||
(def version (v/parse (obj/get global "appVersion"))))
|
||||
|
||||
|
||||
(def media-uri (str public-uri "/media"))
|
||||
(def browser (parse-browser))
|
||||
(def platform (parse-platform))
|
||||
|
||||
(js/console.log
|
||||
(str/format "Welcome to pentpot! Version: '%s'" (:full version)))
|
||||
|
||||
;; --- Helper Functions
|
||||
|
||||
|
||||
(defn ^boolean check-browser? [candidate]
|
||||
(us/verify ::browser candidate)
|
||||
|
|
21
manage.sh
21
manage.sh
|
@ -6,7 +6,7 @@ export DEVENV_IMGNAME="$ORGANIZATION/devenv";
|
|||
export DEVENV_PNAME="penpotdev";
|
||||
|
||||
export CURRENT_USER_ID=$(id -u);
|
||||
export CURRENT_GIT_TAG=$(git describe --tags);
|
||||
export CURRENT_VERSION=$(git describe --tags);
|
||||
export CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
|
||||
|
||||
function build-devenv {
|
||||
|
@ -95,12 +95,11 @@ function build-bundle {
|
|||
mv ./backend/target/dist ./bundle/backend
|
||||
mv ./exporter/target ./bundle/exporter
|
||||
|
||||
local name="penpot-$CURRENT_GIT_TAG";
|
||||
local name="penpot-$CURRENT_VERSION";
|
||||
echo $CURRENT_VERSION > ./bundle/version.txt
|
||||
|
||||
echo $CURRENT_GIT_TAG > ./bundle/frontend/version.txt
|
||||
echo $CURRENT_GIT_TAG > ./bundle/backend/main/version.txt
|
||||
echo $CURRENT_GIT_TAG > ./bundle/exporter/version.txt
|
||||
echo $CURRENT_GIT_TAG > ./bundle/version.txt
|
||||
sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./bundle/frontend/index.html;
|
||||
sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./bundle/backend/main/app/config.clj;
|
||||
|
||||
local generate_tar=${PENPOT_BUILD_GENERATE_TAR:-"true"};
|
||||
|
||||
|
@ -124,12 +123,12 @@ function build-image {
|
|||
|
||||
pushd ./docker/images;
|
||||
local docker_image="$ORGANIZATION/$image";
|
||||
docker build -t $docker_image:$CURRENT_GIT_TAG -f Dockerfile.$image .;
|
||||
docker build -t $docker_image:$CURRENT_VERSION -f Dockerfile.$image .;
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-images {
|
||||
local bundle_file="penpot-$CURRENT_GIT_TAG.tar.xz";
|
||||
local bundle_file="penpot-$CURRENT_VERSION.tar.xz";
|
||||
|
||||
if [ ! -f $bundle_file ]; then
|
||||
echo "File '$bundle_file' does not exists.";
|
||||
|
@ -153,9 +152,9 @@ function build-images {
|
|||
|
||||
function publish-snapshot {
|
||||
set -x
|
||||
docker tag $ORGANIZATION/frontend:$CURRENT_GIT_TAG $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH
|
||||
docker tag $ORGANIZATION/backend:$CURRENT_GIT_TAG $ORGANIZATION/backend:$CURRENT_GIT_BRANCH
|
||||
docker tag $ORGANIZATION/exporter:$CURRENT_GIT_TAG $ORGANIZATION/exporter:$CURRENT_GIT_BRANCH
|
||||
docker tag $ORGANIZATION/frontend:$CURRENT_VERSION $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH
|
||||
docker tag $ORGANIZATION/backend:$CURRENT_VERSION $ORGANIZATION/backend:$CURRENT_GIT_BRANCH
|
||||
docker tag $ORGANIZATION/exporter:$CURRENT_VERSION $ORGANIZATION/exporter:$CURRENT_GIT_BRANCH
|
||||
|
||||
docker push $ORGANIZATION/frontend:$CURRENT_GIT_BRANCH;
|
||||
docker push $ORGANIZATION/backend:$CURRENT_GIT_BRANCH;
|
||||
|
|
Loading…
Add table
Reference in a new issue