Improve build system and watch script
This commit is contained in:
parent
4f0546cfd5
commit
20ae7df57d
18
Makefile
18
Makefile
@ -1,11 +1,21 @@
|
|||||||
.PHONY: tailwind build publish
|
.PHONY: watch clean tailwind static build publish
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build/*
|
||||||
|
|
||||||
tailwind:
|
tailwind:
|
||||||
npx @tailwindcss/cli -i ./resources/input.css -o ./resources/static/output.css
|
npx @tailwindcss/cli -i ./resources/input.css -o ./resources/static/output.css
|
||||||
|
|
||||||
build: tailwind
|
static:
|
||||||
rsync -av --delete resources/static/ build/static/
|
rsync -av resources/static/ build/static/
|
||||||
|
|
||||||
|
build:
|
||||||
clj -M:build
|
clj -M:build
|
||||||
|
|
||||||
publish: build
|
org: ./org/*
|
||||||
|
emacs -Q --script build-org.el
|
||||||
|
|
||||||
|
watch: tailwind static build
|
||||||
|
|
||||||
|
publish: build-org tailwind static build
|
||||||
rsync -av --delete build/ joe-vps:/home/josephferano/websites/ferano.io/
|
rsync -av --delete build/ joe-vps:/home/josephferano/websites/ferano.io/
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Wait for DevTools to start listening on websocket
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
BRAVE_PORT=9222
|
|
||||||
brave-browser --new-window --user-data-dir=/tmp/brave-dev --remote-debugging-port=${BRAVE_PORT} &
|
|
||||||
BRAVE_PID=$!
|
|
||||||
echo "Wait 2 seconds, then go..."
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
TAB_ID=$(curl -s http://localhost:${BRAVE_PORT}/json | jq -r '.[] | .id')
|
|
||||||
echo "Got Tab ID: $TAB_ID"
|
|
||||||
|
|
||||||
HTTP_PORT=$(grep "python -m http.server 3000" watch.sh | grep -o -e "[[:digit:]]\+")
|
|
||||||
echo "Found Jetty Port: $HTTP_PORT"
|
|
||||||
JS_NAV=$(cat <<EOF
|
|
||||||
{"id":1,"method":"Page.navigate","params":{"url":"http://localhost:${HTTP_PORT}"}}
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
echo $TAB_ID > .tab-id
|
|
||||||
echo "Open http://localhost:${HTTP_PORT}"
|
|
||||||
echo $JS_NAV | websocat ws://localhost:9222/devtools/page/${TAB_ID} > /dev/null
|
|
39
watch.sh
39
watch.sh
@ -1,34 +1,43 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
python -m http.server 3000 --directory build &
|
BRAVE_PORT=9222
|
||||||
|
HTTP_PORT=${1:-3000}
|
||||||
|
|
||||||
|
brave-browser --new-window --user-data-dir=/tmp/brave-dev --remote-debugging-port=${BRAVE_PORT} &
|
||||||
|
BRAVE_PID=$!
|
||||||
|
echo "Wait 1 seconds, then go..."
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
TAB_ID=$(curl -s http://localhost:${BRAVE_PORT}/json | jq -r '.[] | .id')
|
||||||
|
echo "Got Tab ID: $TAB_ID"
|
||||||
|
|
||||||
|
JS_NAV=$(cat <<EOF
|
||||||
|
{"id":1,"method":"Page.navigate","params":{"url":"http://localhost:${HTTP_PORT}"}}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
echo $TAB_ID > .tab-id
|
||||||
|
echo "Open http://localhost:${HTTP_PORT}"
|
||||||
|
echo $JS_NAV | websocat ws://localhost:${BRAVE_PORT}/devtools/page/${TAB_ID} > /dev/null
|
||||||
|
|
||||||
|
python -m http.server $HTTP_PORT --directory build &
|
||||||
PID_HTTP=$!
|
PID_HTTP=$!
|
||||||
|
|
||||||
sleep 2
|
sleep 1
|
||||||
if ! kill -0 $PID_HTTP 2>/dev/null; then
|
if ! kill -0 $PID_HTTP 2>/dev/null; then
|
||||||
echo "Failed to start HTTP server"
|
echo "Failed to start HTTP server"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# When using the -d flag, entr will exist, so just keep looping with a function to get it to relaunch
|
|
||||||
watch_static() {
|
|
||||||
while true; do
|
|
||||||
echo resources/static/ | entr -dp rsync -av --delete resources/static/ build/static/
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
watch_static &
|
|
||||||
PID_WATCH_STATIC=$!
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
echo "Shutting down..."
|
echo "Shutting down..."
|
||||||
kill $PID_HTTP 2>/dev/null
|
kill $PID_HTTP 2>/dev/null
|
||||||
kill $PID_WATCH_STATIC 2>/dev/null
|
kill $BRAVE_PID 2>/dev/null
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup SIGINT SIGTERM
|
trap cleanup SIGINT SIGTERM
|
||||||
|
|
||||||
find src/ resources/ -name "*.clj" -o -name "*.edn" | entr -r clj -M:build
|
find src/ resources/ -name "*.clj" -o -name "*.edn" | entr -r make -j3 watch
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user