0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 00:01:51 -05:00

Merge pull request #1290 from penpot/devenv-improvements

Dev Environment improvements
This commit is contained in:
Andrey Antukh 2021-10-20 16:03:24 +02:00 committed by GitHub
commit 1573d794b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1233 additions and 337 deletions

View file

@ -10,6 +10,23 @@ if [ ! -e ~/.fixtures-loaded ]; then
touch ~/.fixtures-loaded touch ~/.fixtures-loaded
fi fi
if [ "$1" = "--watch" ]; then
echo "Start Watch..."
clojure -A:dev -M -m app.main &
PID=$!
npx nodemon \
--watch src \
--watch ../common \
--ext "clj" \
--signal SIGKILL \
--exec 'echo "(user/restart)" | nc -N localhost 6062'
kill -9 $PID
else
clojure -A:dev -M -m app.main clojure -A:dev -M -m app.main
fi

View file

@ -83,8 +83,7 @@
:ldap-attrs-photo "jpegPhoto" :ldap-attrs-photo "jpegPhoto"
;; a server prop key where initial project is stored. ;; a server prop key where initial project is stored.
:initial-project-skey "initial-project" :initial-project-skey "initial-project"})
})
(s/def ::flags ::us/words) (s/def ::flags ::us/words)

View file

@ -141,7 +141,8 @@
["/webhooks" ["/webhooks"
["/sns" {:post (:sns-webhook cfg)}]] ["/sns" {:post (:sns-webhook cfg)}]]
["/api" {:middleware [[middleware/etag] ["/api" {:middleware [[middleware/cors]
[middleware/etag]
[middleware/format-response-body] [middleware/format-response-body]
[middleware/params] [middleware/params]
[middleware/multipart-params] [middleware/multipart-params]

View file

@ -8,6 +8,7 @@
(:require (:require
[app.common.logging :as l] [app.common.logging :as l]
[app.common.transit :as t] [app.common.transit :as t]
[app.config :as cf]
[app.metrics :as mtx] [app.metrics :as mtx]
[app.util.json :as json] [app.util.json :as json]
[buddy.core.codecs :as bc] [buddy.core.codecs :as bc]
@ -176,3 +177,29 @@
:uri (str (:uri request) (when qstring (str "?" qstring))) :uri (str (:uri request) (when qstring (str "?" qstring)))
:method (name (:request-method request))) :method (name (:request-method request)))
(handler request))))) (handler request)))))
(defn- wrap-cors
[handler]
(if-not (contains? cf/flags :cors)
handler
(letfn [(add-cors-headers [response request]
(-> response
(update
:headers
(fn [headers]
(-> headers
(assoc "access-control-allow-origin" (get-in request [:headers "origin"]))
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
(assoc "access-control-allow-credentials" "true")
(assoc "access-control-expose-headers" "x-requested-with, content-type, cookie")
(assoc "access-control-allow-headers" "x-frontend-version, content-type, accept, x-requested-width"))))))]
(fn [request]
(if (= (:request-method request) :options)
(-> {:status 200 :body ""}
(add-cors-headers request))
(let [response (handler request)]
(add-cors-headers response request)))))))
(def cors
{:name ::cors
:compile (constantly wrap-cors)})

View file

@ -28,6 +28,7 @@ RUN set -ex; \
rlwrap \ rlwrap \
unzip \ unzip \
fakeroot \ fakeroot \
netcat \
; \ ; \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen; \ locale-gen; \
@ -173,6 +174,7 @@ COPY files/tmux.conf /root/.tmux.conf
COPY files/sudoers /etc/sudoers COPY files/sudoers /etc/sudoers
COPY files/start-tmux.sh /home/start-tmux.sh COPY files/start-tmux.sh /home/start-tmux.sh
COPY files/start-tmux-back.sh /home/start-tmux-back.sh
COPY files/entrypoint.sh /home/entrypoint.sh COPY files/entrypoint.sh /home/entrypoint.sh
COPY files/init.sh /home/init.sh COPY files/init.sh /home/init.sh

View file

@ -13,6 +13,7 @@ volumes:
services: services:
main: main:
profiles: ["full"]
privileged: true privileged: true
image: "penpotapp/devenv:latest" image: "penpotapp/devenv:latest"
build: build:
@ -49,6 +50,57 @@ services:
- PENPOT_SMTP_PASSWORD= - PENPOT_SMTP_PASSWORD=
- PENPOT_SMTP_SSL=false - PENPOT_SMTP_SSL=false
- PENPOT_SMTP_TLS=false - PENPOT_SMTP_TLS=false
- PENPOT_FLAGS="enable-cors"
# LDAP setup
- PENPOT_LDAP_HOST=ldap
- PENPOT_LDAP_PORT=10389
- PENPOT_LDAP_SSL=false
- PENPOT_LDAP_STARTTLS=false
- PENPOT_LDAP_BASE_DN=ou=people,dc=planetexpress,dc=com
- PENPOT_LDAP_BIND_DN=cn=admin,dc=planetexpress,dc=com
- PENPOT_LDAP_BIND_PASSWORD=GoodNewsEveryone
- PENPOT_LDAP_ATTRS_USERNAME=uid
- PENPOT_LDAP_ATTRS_EMAIL=mail
- PENPOT_LDAP_ATTRS_FULLNAME=cn
- PENPOT_LDAP_ATTRS_PHOTO=jpegPhoto
backend:
profiles: ["backend"]
privileged: true
image: "penpotapp/devenv:latest"
build:
context: "."
container_name: "penpot-backend"
stop_signal: SIGINT
depends_on:
- postgres
- redis
volumes:
- "user_data:/home/penpot/"
- "${PWD}:/home/penpot/penpot"
ports:
- 6060:6060
- 6061:6061
- 9090:9090
environment:
- EXTERNAL_UID=${CURRENT_USER_ID}
- PENPOT_SECRET_KEY=super-secret-devenv-key
# STMP setup
- PENPOT_SMTP_ENABLED=true
- PENPOT_SMTP_DEFAULT_FROM=no-reply@example.com
- PENPOT_SMTP_DEFAULT_REPLY_TO=no-reply@example.com
- PENPOT_SMTP_HOST=mailer
- PENPOT_SMTP_PORT=1025
- PENPOT_SMTP_USERNAME=
- PENPOT_SMTP_PASSWORD=
- PENPOT_SMTP_SSL=false
- PENPOT_SMTP_TLS=false
- PENPOT_FLAGS="enable-cors"
# LDAP setup # LDAP setup
- PENPOT_LDAP_HOST=ldap - PENPOT_LDAP_HOST=ldap

View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
sudo chown penpot:users /home/penpot
cd ~;
source ~/.bashrc
set -e;
echo "[start-tmux.sh] Installing node dependencies"
pushd ~/penpot/exporter/
yarn install
popd
tmux -2 new-session -d -s penpot
tmux rename-window -t penpot:0 'exporter'
tmux select-window -t penpot:0
tmux send-keys -t penpot 'cd penpot/exporter' enter C-l
tmux send-keys -t penpot 'rm -f target/app.js*' enter C-l
tmux send-keys -t penpot 'clojure -M:dev:shadow-cljs watch main' enter
tmux split-window -v
tmux send-keys -t penpot 'cd penpot/exporter' enter C-l
tmux send-keys -t penpot './scripts/wait-and-start.sh' enter
tmux new-window -t penpot:1 -n 'backend'
tmux select-window -t penpot:1
tmux send-keys -t penpot 'cd penpot/backend' enter C-l
tmux send-keys -t penpot './scripts/start-dev' enter
tmux -2 attach-session -t penpot

View file

@ -18,6 +18,11 @@ popd
tmux -2 new-session -d -s penpot tmux -2 new-session -d -s penpot
tmux rename-window -t penpot:0 'gulp'
tmux select-window -t penpot:0
tmux send-keys -t penpot 'cd penpot/frontend' enter C-l
tmux send-keys -t penpot 'npx gulp watch' enter
tmux new-window -t penpot:1 -n 'shadow watch' tmux new-window -t penpot:1 -n 'shadow watch'
tmux select-window -t penpot:1 tmux select-window -t penpot:1
tmux send-keys -t penpot 'cd penpot/frontend' enter C-l tmux send-keys -t penpot 'cd penpot/frontend' enter C-l
@ -38,9 +43,4 @@ tmux select-window -t penpot:3
tmux send-keys -t penpot 'cd penpot/backend' enter C-l tmux send-keys -t penpot 'cd penpot/backend' enter C-l
tmux send-keys -t penpot './scripts/start-dev' enter tmux send-keys -t penpot './scripts/start-dev' enter
tmux rename-window -t penpot:0 'gulp'
tmux select-window -t penpot:0
tmux send-keys -t penpot 'cd penpot/frontend' enter C-l
tmux send-keys -t penpot 'npx gulp watch' enter
tmux -2 attach-session -t penpot tmux -2 attach-session -t penpot

View file

@ -12,7 +12,15 @@
"defaults" "defaults"
], ],
"scripts": { "scripts": {
"validate-translations": "node ./scripts/validate-translations.js" "validate-translations": "node ./scripts/validate-translations.js",
"watch-main": "shadow-cljs watch main",
"watch-gulp": "gulp watch",
"test-watch-compile": "shadow-cljs watch test",
"test-run": "node target/tests.js",
"test-watch-run": "nodemon --signal SIGKILL --watch target --exec npm run test-run",
"test-watch": "npm-run-all --parallel test-watch-compile test-watch-run",
"test": "npm run test-watch",
"start": "npm-run-all --parallel watch-gulp watch-main"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^10.2.4", "autoprefixer": "^10.2.4",
@ -29,6 +37,8 @@
"map-stream": "0.0.7", "map-stream": "0.0.7",
"marked": "^3.0.4", "marked": "^3.0.4",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
"nodemon": "^2.0.13",
"npm-run-all": "^4.1.5",
"postcss": "^8.3.5", "postcss": "^8.3.5",
"postcss-clean": "^1.2.2", "postcss-clean": "^1.2.2",
"rimraf": "^3.0.0", "rimraf": "^3.0.0",

View file

@ -93,7 +93,8 @@
(when (false? registration) (when (false? registration)
(swap! flags disj :registration))) (swap! flags disj :registration)))
(def public-uri (defn get-public-uri
[]
(let [uri (u/uri (or (obj/get global "penpotPublicURI") (let [uri (u/uri (or (obj/get global "penpotPublicURI")
(.-origin ^js location)))] (.-origin ^js location)))]
;; Ensure that the path always ends with "/"; this ensures that ;; Ensure that the path always ends with "/"; this ensures that
@ -102,6 +103,8 @@
(not (str/ends-with? (:path uri) "/")) (not (str/ends-with? (:path uri) "/"))
(update :path #(str % "/"))))) (update :path #(str % "/")))))
(def public-uri (get-public-uri))
;; --- Helper Functions ;; --- Helper Functions
(defn ^boolean check-browser? [candidate] (defn ^boolean check-browser? [candidate]

View file

@ -48,6 +48,7 @@
[id params] [id params]
(->> (http/send! {:method :get (->> (http/send! {:method :get
:uri (u/join base-uri "api/rpc/query/" (name id)) :uri (u/join base-uri "api/rpc/query/" (name id))
:credentials "include"
:query params}) :query params})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response))) (rx/mapcat handle-response)))
@ -58,6 +59,7 @@
[id params] [id params]
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join base-uri "api/rpc/mutation/" (name id)) :uri (u/join base-uri "api/rpc/mutation/" (name id))
:credentials "include"
:body (http/transit-data params)}) :body (http/transit-data params)})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response))) (rx/mapcat handle-response)))
@ -87,7 +89,10 @@
[_ {:keys [provider] :as params}] [_ {:keys [provider] :as params}]
(let [uri (u/join base-uri "api/auth/oauth/" (d/name provider)) (let [uri (u/join base-uri "api/auth/oauth/" (d/name provider))
params (dissoc params :provider)] params (dissoc params :provider)]
(->> (http/send! {:method :post :uri uri :query params}) (->> (http/send! {:method :post
:uri uri
:credentials "include"
:query params})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))
@ -95,6 +100,7 @@
[_ params] [_ params]
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join base-uri "api/feedback") :uri (u/join base-uri "api/feedback")
:credentials "include"
:body (http/transit-data params)}) :body (http/transit-data params)})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response))) (rx/mapcat handle-response)))
@ -104,6 +110,7 @@
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join base-uri "export") :uri (u/join base-uri "export")
:body (http/transit-data params) :body (http/transit-data params)
:credentials "include"
:response-type :blob}) :response-type :blob})
(rx/mapcat handle-response))) (rx/mapcat handle-response)))
@ -112,6 +119,7 @@
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join base-uri "export-frames") :uri (u/join base-uri "export-frames")
:body (http/transit-data params) :body (http/transit-data params)
:credentials "include"
:response-type :blob}) :response-type :blob})
(rx/mapcat handle-response))) (rx/mapcat handle-response)))
@ -123,6 +131,7 @@
[id params] [id params]
(->> (http/send! {:method :post (->> (http/send! {:method :post
:uri (u/join base-uri "api/rpc/mutation/" (name id)) :uri (u/join base-uri "api/rpc/mutation/" (name id))
:credentials "include"
:body (http/form-data params)}) :body (http/form-data params)})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response))) (rx/mapcat handle-response)))

View file

@ -54,8 +54,10 @@
{"x-frontend-version" (:full @cfg/version)}) {"x-frontend-version" (:full @cfg/version)})
(defn fetch (defn fetch
[{:keys [method uri query headers body mode omit-default-headers] [{:keys [method uri query headers body mode omit-default-headers credentials]
:or {mode :cors headers {}}}] :or {mode :cors
headers {}
credentials "same-origin"}}]
(rx/Observable.create (rx/Observable.create
(fn [subscriber] (fn [subscriber]
(let [controller (js/AbortController.) (let [controller (js/AbortController.)
@ -83,7 +85,7 @@
:body body :body body
:mode (d/name mode) :mode (d/name mode)
:redirect "follow" :redirect "follow"
:credentials "same-origin" :credentials credentials
:referrerPolicy "no-referrer" :referrerPolicy "no-referrer"
:signal signal}] :signal signal}]
(-> (js/fetch (str uri) params) (-> (js/fetch (str uri) params)
@ -165,7 +167,6 @@
:uri uri :uri uri
:response-type :blob :response-type :blob
:omit-default-headers true}) :omit-default-headers true})
(rx/filter #(= 200 (:status %))) (rx/filter #(= 200 (:status %)))
(rx/map :body) (rx/map :body)
(rx/mapcat wapi/read-file-as-data-url) (rx/mapcat wapi/read-file-as-data-url)

View file

@ -9,6 +9,8 @@
(:require (:require
[app.common.transit :as t] [app.common.transit :as t]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.util.globals :refer [global]]
[app.util.object :as obj]
[beicon.core :as rx])) [beicon.core :as rx]))
(declare handle-response) (declare handle-response)
@ -28,11 +30,13 @@
data (t/encode-str message) data (t/encode-str message)
instance (:instance worker)] instance (:instance worker)]
(.postMessage instance data) (if (some? instance)
(do (.postMessage instance data)
(->> (:stream worker) (->> (:stream worker)
(rx/filter #(= (:reply-to %) sender-id)) (rx/filter #(= (:reply-to %) sender-id))
(take-messages) (take-messages)
(rx/map handle-response))))) (rx/map handle-response)))
(rx/empty)))))
(defn ask! (defn ask!
[worker message] [worker message]
@ -79,6 +83,11 @@
(.addEventListener instance "message" handle-message) (.addEventListener instance "message" handle-message)
(.addEventListener instance "error" handle-error) (.addEventListener instance "error" handle-error)
(ask! worker
{:cmd :configure
:params
{"penpotPublicURI" (obj/get global "penpotPublicURI")}})
worker)) worker))
(defn- handle-response (defn- handle-response

View file

@ -7,6 +7,8 @@
(ns app.worker.impl (ns app.worker.impl
(:require (:require
[app.common.pages.changes :as ch] [app.common.pages.changes :as ch]
[app.util.globals :refer [global]]
[app.util.object :as obj]
[okulary.core :as l])) [okulary.core :as l]))
(enable-console-print!) (enable-console-print!)
@ -50,3 +52,8 @@
(assoc :cmd :selection/update-index))) (assoc :cmd :selection/update-index)))
(handler (-> message (handler (-> message
(assoc :cmd :snaps/update-index)))))) (assoc :cmd :snaps/update-index))))))
(defmethod handler :configure
[{:keys [params]}]
(doseq [[param-key param-value] params]
(obj/set! global param-key param-value)))

View file

@ -7,6 +7,8 @@
(ns app.worker.thumbnails (ns app.worker.thumbnails
(:require (:require
["react-dom/server" :as rds] ["react-dom/server" :as rds]
[app.common.uri :as u]
[app.config :as cfg]
[app.main.exports :as exports] [app.main.exports :as exports]
[app.main.fonts :as fonts] [app.main.fonts :as fonts]
[app.util.http :as http] [app.util.http :as http]
@ -29,11 +31,15 @@
(defn- request-page (defn- request-page
[file-id page-id] [file-id page-id]
(let [uri "/api/rpc/query/page"] (let [uri (u/join (cfg/get-public-uri) "api/rpc/query/page")
params {:file-id file-id
:id page-id
:strip-thumbnails true}]
(->> (http/send! (->> (http/send!
{:uri uri {:method :get
:query {:file-id file-id :id page-id :strip-thumbnails true} :uri uri
:method :get}) :credentials "include"
:query params})
(rx/map http/conditional-decode-transit) (rx/map http/conditional-decode-transit)
(rx/mapcat handle-response)))) (rx/mapcat handle-response))))

View file

@ -19,9 +19,54 @@
(t/use-fixtures :each (t/use-fixtures :each
{:before thp/reset-idmap!}) {:before thp/reset-idmap!})
(t/deftest test-add-component-from-single-shape ;; Test using potok
(t/async done #_(t/deftest test-add-component-from-single-shape
(try (t/testing "test-add-component-from-single-shape"
(t/async
done
(let [state (-> thp/initial-state
(thp/sample-page)
(thp/sample-shape :shape1 :rect
{:name "Rect 1"}))
store (ptk/store {:state state})
stream (ptk/input-stream store)
end? (->> stream (rx/filter #(= ::end %)))]
(->> stream
(rx/take-until end?)
(rx/last)
(rx/do
(fn []
(let [new-state @store
shape1 (thp/get-shape new-state :shape1)
[[group shape1] [c-group c-shape1] component]
(thl/resolve-instance-and-main
new-state
(:parent-id shape1))
file (dwlh/get-local-file new-state)]
(t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name group) "Component-1"))
(t/is (= (:name component) "Component-1"))
(t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-group) "Component-1"))
(thl/is-from-file group file))))
(rx/subs done #(throw %)))
(ptk/emit!
store
(dw/select-shape (thp/id :shape1))
(dwl/add-component)
::end)))))
;; FAILING
#_(t/deftest test-add-component-from-single-shape
(t/async
done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -49,19 +94,12 @@
(thl/is-from-file group file)))) (thl/is-from-file group file))))
(rx/subs (rx/subs done #(throw %))))))
;; FAILING
#_(t/deftest test-add-component-from-several-shapes
(t/async
done done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-add-component-from-several-shapes
(t/async done
(try
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -99,20 +137,12 @@
(thl/is-from-file group file)))) (thl/is-from-file group file))))
(rx/subs (rx/subs done #(throw %))))))
#_(t/deftest test-add-component-from-group
(t/async
done done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-add-component-from-group
(t/async done
(try
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -147,19 +177,11 @@
(thl/is-from-file group file)))) (thl/is-from-file group file))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-rename-component (t/deftest test-rename-component
(t/async done (t/async
(try done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -185,19 +207,11 @@
(t/is (= (:name component) (t/is (= (:name component)
"Renamed component"))))) "Renamed component")))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-duplicate-component (t/deftest test-duplicate-component
(t/async done (t/async
(try done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -236,19 +250,11 @@
(t/is (= (:name component2) (t/is (= (:name component2)
"Component-2"))))) "Component-2")))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-delete-component (t/deftest test-delete-component
(t/async done (t/async
(try done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -278,19 +284,11 @@
(t/is (nil? component))))) (t/is (nil? component)))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-instantiate-component (t/deftest test-instantiate-component
(t/async done (t/async
(try done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -327,19 +325,11 @@
(t/is (= (:name c-instance2) "Component-1")) (t/is (= (:name c-instance2) "Component-1"))
(t/is (= (:name c-shape2) "Rect 1"))))) (t/is (= (:name c-shape2) "Rect 1")))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))
(t/deftest test-detach-component (t/deftest test-detach-component
(t/async done (t/async
(try done
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
@ -362,13 +352,5 @@
(t/is (= (:name "Rect 1")))))) (t/is (= (:name "Rect 1"))))))
(rx/subs (rx/subs done #(throw %))))))
done
#(do
(println (.-stack %))
(done)))))
(catch :default e
(println (.-stack e))
(done)))))

File diff suppressed because it is too large Load diff

View file

@ -44,15 +44,32 @@ function pull-devenv-if-not-exists {
function start-devenv { function start-devenv {
pull-devenv-if-not-exists $@; pull-devenv-if-not-exists $@;
docker-compose -p $DEVENV_PNAME -f docker/devenv/docker-compose.yaml up -d;
# Check if the "backend-only" container is running. If it is, we need tot stop it first
if [[ ! $(docker ps -f "name=penpot-backend" -q) ]]; then
docker-compose -p $DEVENV_PNAME --profile backend -f docker/devenv/docker-compose.yaml stop -t 2 backend;
fi
docker-compose -p $DEVENV_PNAME --profile full -f docker/devenv/docker-compose.yaml up -d;
}
function start-backend {
pull-devenv-if-not-exists $@;
# Check if the "devenv" container is running. If it is, we need tot stop it first because conflicts with the backend
if [[ ! $(docker ps -f "name=penpot-devenv-main" -q) ]]; then
docker-compose -p $DEVENV_PNAME --profile full -f docker/devenv/docker-compose.yaml stop -t 2 main;
fi
docker-compose -p $DEVENV_PNAME --profile backend -f docker/devenv/docker-compose.yaml up -d;
} }
function stop-devenv { function stop-devenv {
docker-compose -p $DEVENV_PNAME -f docker/devenv/docker-compose.yaml stop -t 2; docker-compose -p $DEVENV_PNAME --profile full --profile backend -f docker/devenv/docker-compose.yaml stop -t 2;
} }
function drop-devenv { function drop-devenv {
docker-compose -p $DEVENV_PNAME -f docker/devenv/docker-compose.yaml down -t 2 -v; docker-compose -p $DEVENV_PNAME --profile full --profile backend -f docker/devenv/docker-compose.yaml down -t 2 -v;
echo "Clean old development image $DEVENV_IMGNAME..." echo "Clean old development image $DEVENV_IMGNAME..."
docker images $DEVENV_IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi docker images $DEVENV_IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi
@ -70,6 +87,14 @@ function run-devenv {
docker exec -ti penpot-devenv-main sudo -EH -u penpot /home/start-tmux.sh docker exec -ti penpot-devenv-main sudo -EH -u penpot /home/start-tmux.sh
} }
function run-backend {
if [[ ! $(docker ps -f "name=penpot-backend" -q) ]]; then
start-backend
fi
docker exec -ti penpot-backend sudo -EH -u penpot /home/start-tmux-back.sh
}
function build { function build {
echo ">> build start: $1" echo ">> build start: $1"
local version=$(print-current-version); local version=$(print-current-version);
@ -175,6 +200,8 @@ function usage {
echo "- stop-devenv Stops the development oriented docker-compose service." echo "- stop-devenv Stops the development oriented docker-compose service."
echo "- drop-devenv Remove the development oriented docker-compose containers, volumes and clean images." echo "- drop-devenv Remove the development oriented docker-compose containers, volumes and clean images."
echo "- run-devenv Attaches to the running devenv container and starts development environment" echo "- run-devenv Attaches to the running devenv container and starts development environment"
echo "- start-backend Start the backend only service."
echo "- run-backend Starts a backend-only instance and attach tmux to it"
echo " based on tmux (frontend at localhost:3449, backend at localhost:6060)." echo " based on tmux (frontend at localhost:3449, backend at localhost:6060)."
echo "" echo ""
} }
@ -196,9 +223,15 @@ case $1 in
start-devenv) start-devenv)
start-devenv ${@:2} start-devenv ${@:2}
;; ;;
start-backend)
start-backend ${@:2}
;;
run-devenv) run-devenv)
run-devenv ${@:2} run-devenv ${@:2}
;; ;;
run-backend)
run-backend ${@:2}
;;
stop-devenv) stop-devenv)
stop-devenv ${@:2} stop-devenv ${@:2}
;; ;;