From 6193634a337b38e335a7ff5ead9ca5c18c3413df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 13 Sep 2017 00:38:59 +0200 Subject: [PATCH] split build script for easier use with phpstorm file watchers --- _build_assets.sh | 16 ++++++++++++++++ _build_common.sh | 3 +++ _build_css.sh | 7 +++++++ _build_html.sh | 6 ++++++ _build_js.sh | 22 +++++++++++++++++++++ build.sh | 50 ++++++------------------------------------------ 6 files changed, 60 insertions(+), 44 deletions(-) create mode 100755 _build_assets.sh create mode 100755 _build_common.sh create mode 100755 _build_css.sh create mode 100755 _build_html.sh create mode 100755 _build_js.sh diff --git a/_build_assets.sh b/_build_assets.sh new file mode 100755 index 0000000..2056499 --- /dev/null +++ b/_build_assets.sh @@ -0,0 +1,16 @@ +#!/bin/bash +source "_build_common.sh" + +echo 'Copying resources...' + +cp -r img out/img +cp favicon.ico out/ + +if [[ $ESP_PROD ]]; then + echo 'Cleaning junk files...' + find out/ -name "*.orig" -delete + find out/ -name "*.xcf" -delete + find out/ -name "*~" -delete + find out/ -name "*.bak" -delete + find out/ -name "*.map" -delete +fi diff --git a/_build_common.sh b/_build_common.sh new file mode 100755 index 0000000..833611b --- /dev/null +++ b/_build_common.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +export FRONT_END_HASH=$(git rev-parse --short HEAD) diff --git a/_build_css.sh b/_build_css.sh new file mode 100755 index 0000000..1cfa157 --- /dev/null +++ b/_build_css.sh @@ -0,0 +1,7 @@ +#!/bin/bash +source "_build_common.sh" + +echo 'Building CSS...' + +mkdir -p out/css +npm run sass -- --output-style compressed sass/app.scss "out/css/app.$FRONT_END_HASH.css" diff --git a/_build_html.sh b/_build_html.sh new file mode 100755 index 0000000..a4f869d --- /dev/null +++ b/_build_html.sh @@ -0,0 +1,6 @@ +#!/bin/bash +source "_build_common.sh" + +echo 'Building HTML...' + +php ./compile_html.php diff --git a/_build_js.sh b/_build_js.sh new file mode 100755 index 0000000..dc5c65b --- /dev/null +++ b/_build_js.sh @@ -0,0 +1,22 @@ +#!/bin/bash +source "_build_common.sh" + +mkdir -p out/js +echo 'Generating lang.js...' +php ./dump_js_lang.php + +echo 'Processing JS...' +npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" --source-maps js/lib \ + js/lib/chibi.js \ + js/lib/keymaster.js \ + js/lib/polyfills.js \ + js/utils.js \ + js/modal.js \ + js/notif.js \ + js/appcommon.js \ + js/lang.js \ + js/wifi.js \ + js/term_* \ + js/debug_screen.js \ + js/soft_keyboard.js \ + js/term.js diff --git a/build.sh b/build.sh index 7f10082..75ac53f 100755 --- a/build.sh +++ b/build.sh @@ -2,51 +2,13 @@ cd $(dirname $0) -FRONT_END_HASH=$(git rev-parse --short HEAD) +source "_build_common.sh" -rm -r out/* -mkdir out/js -mkdir out/css +rm -fr out/* -echo 'Generating lang.js...' -php ./dump_js_lang.php - -echo 'Packing JS...' -npm run babel -- -o "out/js/app.$FRONT_END_HASH.js" --source-maps js/lib \ - js/lib/chibi.js \ - js/lib/keymaster.js \ - js/lib/polyfills.js \ - js/utils.js \ - js/modal.js \ - js/notif.js \ - js/appcommon.js \ - js/lang.js \ - js/wifi.js \ - js/term_* \ - js/debug_screen.js \ - js/soft_keyboard.js \ - js/term.js - -echo 'Building CSS...' - -npm run sass -- --output-style compressed sass/app.scss "out/css/app.$FRONT_END_HASH.css" - -echo 'Building HTML...' - -php ./compile_html.php - -echo 'Copying resources...' - -cp -r img out/img -cp favicon.ico out/ - -if [[ $ESP_PROD ]]; then - echo 'Cleaning junk files...' - find out/ -name "*.orig" -delete - find out/ -name "*.xcf" -delete - find out/ -name "*~" -delete - find out/ -name "*.bak" -delete - find out/ -name "*.map" -delete -fi +./_build_css.sh +./_build_js.sh +./_build_html.sh +./_build_assets.sh echo 'ESPTerm front-end ready'