tridactyl/scripts/build.sh

118 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/sh
2017-11-20 18:13:26 +00:00
set -e
for arg in "$@"
do
case $arg in
--quick)
QUICK_BUILD=1
shift
;;
--old-native)
OLD_NATIVE=1
shift
;;
esac
done
2018-03-04 14:15:26 +01:00
CLEANSLATE="node_modules/cleanslate/docs/files/cleanslate.css"
2018-05-16 01:52:03 +10:00
isWindowsMinGW() {
2019-03-24 17:29:42 +01:00
is_mingw="False"
2018-05-28 13:06:45 +10:00
if [ "$(uname | cut -c 1-5)" = "MINGW" ] \
|| [ "$(uname | cut -c 1-4)" = "MSYS" ]; then
is_mingw="True"
fi
2019-03-24 17:29:42 +01:00
printf "%s" "${is_mingw}"
}
if [ "$(isWindowsMinGW)" = "True" ]; then
WIN_PYTHON="py -3"
2019-05-31 16:48:53 +01:00
YARN_BIN_DIR="$(cygpath "$(yarn bin)")"
2019-05-31 18:44:40 +01:00
PATH=$YARN_BIN_DIR:$PATH
else
2019-05-31 16:48:53 +01:00
PATH="$(yarn bin):$PATH"
fi
export PATH
mkdir -p build
mkdir -p build/static
mkdir -p generated/static
mkdir -p generated/static/clippy
if [ "$(isWindowsMinGW)" = "True" ]; then
2018-05-16 04:39:32 +10:00
$WIN_PYTHON scripts/excmds_macros.py
else
2018-05-16 04:39:32 +10:00
scripts/excmds_macros.py
fi
# You can use `--quick` to test out small changes without updating docs / metadata etc.
# If you get weird behaviour just run a full build
if [ "$QUICK_BUILD" != "1" ]; then
# .bracketexpr.generated.ts is needed for metadata generation
"$(yarn bin)/nearleyc" src/grammars/bracketexpr.ne > \
src/grammars/.bracketexpr.generated.ts
# It's important to generate the metadata before the documentation because
# missing imports might break documentation generation on clean builds
"$(yarn bin)/tsc" compiler/gen_metadata.ts -m commonjs --target es2017 \
&& node compiler/gen_metadata.js \
--out src/.metadata.generated.ts \
--themeDir src/static/themes \
src/excmds.ts src/lib/config.ts
scripts/newtab.md.sh
scripts/make_tutorial.sh
scripts/make_docs.sh
2021-05-05 13:04:14 +02:00
tsc --project tsconfig.json --noEmit
2021-04-10 21:28:44 +02:00
else
echo "Warning: dirty rebuild. Skipping docs, metadata and type checking..."
2021-04-10 21:28:44 +02:00
fi
2021-05-05 13:04:14 +02:00
# Actually build the thing
mkdir -p buildtemp
node scripts/esbuild.js
mv buildtemp/* build/
rmdir buildtemp
# Copy extra static files across
cp src/manifest.json build/
cp -r src/static build
cp -r generated/static build
cp issue_template.md build/
2021-05-05 18:14:17 +02:00
# Remove large unused files
rm build/static/logo/Tridactyl.psd
rm build/static/logo/Tridactyl_1024px.png
# "temporary" fix until we can install new native on CI: install the old native messenger
if [ "$OLD_NATIVE" = "1" ]; then
if [ "$(isWindowsMinGW)" = "True" ]; then
powershell \
-NoProfile \
-InputFormat None \
-ExecutionPolicy Bypass \
native/win_install.ps1 -DebugDirBase native
else
native/install.sh local
fi
fi
scripts/authors.sh
if [ -e "$CLEANSLATE" ] ; then
2018-05-20 13:17:28 +01:00
cp -v "$CLEANSLATE" build/static/css/cleanslate.css
else
2019-05-31 16:48:53 +01:00
echo "Couldn't find cleanslate.css. Try running 'yarn install'"
fi