2022-06-06 05:07:10 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-06-03 21:05:39 +02:00
|
|
|
echo clean
|
|
|
|
rm -rf dist
|
|
|
|
mkdir -p dist/fonts
|
|
|
|
cp \
|
|
|
|
src/scss/fonts/XRXV3I6Li01BKofINeaE.ttf \
|
|
|
|
src/scss/fonts/materialdesignicons-webfont-4.9.95.ttf \
|
|
|
|
src/scss/fonts/materialdesignicons-webfont-4.9.95.woff \
|
|
|
|
src/scss/fonts/materialdesignicons-webfont-4.9.95.woff2 \
|
|
|
|
dist/fonts
|
|
|
|
|
2022-06-27 20:12:44 +02:00
|
|
|
VERSION=$(jq -r .version package.json)
|
|
|
|
GIT_HASH=$(git rev-parse --short HEAD)
|
|
|
|
|
2022-06-08 20:18:41 +02:00
|
|
|
function build_css() {
|
|
|
|
pnpm exec sass -I . ./src/scss/main.scss dist/main.css
|
|
|
|
}
|
|
|
|
function build_js() {
|
2022-06-27 20:12:44 +02:00
|
|
|
pnpm exec esbuild --log-level=error --define:process.env.__VERSION__=\"${VERSION}\" --define:process.env.__GIT_HASH__=\"${GIT_HASH}\" --bundle $1 --outdir=dist --target=es6 --loader:.svg=dataurl --format=iife --sourcemap --jsx-factory=h --jsx-fragment=Fragment --platform=browser --minify
|
2022-06-08 20:18:41 +02:00
|
|
|
}
|
|
|
|
|
2022-06-29 16:53:59 +02:00
|
|
|
function build_html() {
|
2022-06-08 20:18:41 +02:00
|
|
|
cat html/$1.html \
|
|
|
|
| sed -e '/ANASTASIS_SCRIPT_CONTENT/ {' -e 'r dist/main.js' -e 'd' -e '}' \
|
|
|
|
| sed -e '/ANASTASIS_STYLE_CONTENT/ {' -e 'r dist/main.css' -e 'd' -e '}' \
|
|
|
|
>dist/$1.html
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup {
|
|
|
|
trap - SIGHUP SIGINT SIGTERM SIGQUIT
|
|
|
|
echo -n "Cleaning up... "
|
2022-06-27 20:12:44 +02:00
|
|
|
wait
|
2022-06-08 20:18:41 +02:00
|
|
|
kill -- -$$
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT
|
|
|
|
|
2022-06-27 20:12:44 +02:00
|
|
|
set -e
|
2022-06-08 20:18:41 +02:00
|
|
|
echo compile
|
|
|
|
build_css &
|
|
|
|
build_js src/main.ts &
|
2022-08-26 17:59:00 +02:00
|
|
|
build_js src/stories.tsx &
|
2022-06-08 20:18:41 +02:00
|
|
|
build_js src/main.test.ts &
|
2022-06-12 00:10:26 +02:00
|
|
|
for file in $(find src/ -name test.ts); do build_js $file; done &
|
|
|
|
wait -n
|
2022-06-03 21:05:39 +02:00
|
|
|
wait -n
|
|
|
|
wait -n
|
2022-06-08 20:18:41 +02:00
|
|
|
wait -n
|
2022-08-26 17:59:00 +02:00
|
|
|
wait -n
|
2022-06-08 20:18:41 +02:00
|
|
|
pnpm run --silent test -- -R dot
|
2022-06-03 21:05:39 +02:00
|
|
|
|
|
|
|
echo html
|
2022-06-29 16:53:59 +02:00
|
|
|
build_html ui
|
|
|
|
build_html ui-dev
|
2022-08-26 17:59:00 +02:00
|
|
|
build_html stories
|
2022-06-08 20:18:41 +02:00
|
|
|
|
|
|
|
if [ "WATCH" == "$1" ]; then
|
|
|
|
|
|
|
|
echo watch mode
|
2022-06-26 20:52:32 +02:00
|
|
|
echo Writing any file in the src directory will trigger a browser reload.
|
2022-06-09 21:11:49 +02:00
|
|
|
echo Be sure that the watcher server is running.
|
2022-06-24 18:27:39 +02:00
|
|
|
echo ./watch/serve.sh
|
2022-06-08 20:18:41 +02:00
|
|
|
inotifywait -e close_write -r src -q -m | while read line; do
|
2022-06-09 21:11:49 +02:00
|
|
|
echo $(date) $line
|
2022-06-08 20:18:41 +02:00
|
|
|
build_js src/main.ts
|
2022-06-29 16:53:59 +02:00
|
|
|
build_html ui-dev
|
2022-08-26 17:59:00 +02:00
|
|
|
build_js src/stories.tsx
|
|
|
|
build_html stories
|
2022-06-09 21:11:49 +02:00
|
|
|
./watch/send.sh '{"type":"RELOAD"}'
|
2022-06-08 20:18:41 +02:00
|
|
|
done;
|
|
|
|
fi
|