Notes/bin/copy-trilium.sh

45 lines
1.4 KiB
Bash
Raw Normal View History

2019-10-11 21:22:59 +02:00
#!/usr/bin/env bash
set -e # Fail on any command error
shopt -s globstar
BUILD_DIR="./build"
if ! [[ $(which npm) ]]; then
echo "Missing npm"
exit 1
fi
2019-10-11 21:22:59 +02:00
# Trigger the build
echo Build start
npm run build:prepare-dist
echo Build finished
2024-07-21 09:12:46 +03:00
# Patch package.json main
sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json"
2024-07-21 09:12:46 +03:00
2019-10-11 21:22:59 +02:00
# run in subshell (so we return to original dir)
(cd $BUILD_DIR && npm ci --omit=dev)
2019-10-11 21:22:59 +02:00
if [[ -d "$BUILD_DIR"/node_modules ]]; then
2024-07-20 20:31:36 +03:00
# cleanup of useless files in dependencies
2024-07-20 20:39:18 +03:00
for d in 'image-q/demo' \
'@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
2024-07-20 20:39:18 +03:00
'mermaid/dist/mermaid.js' \
'boxicons/svg' 'boxicons/node_modules/react'/* \
2024-07-20 20:39:18 +03:00
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
[[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d"
done
2024-07-20 20:31:36 +03:00
# delete all tests (there are often large images as test file for jimp etc.)
2024-07-20 20:39:18 +03:00
for d in 'test' 'docs' 'demo' 'example'; do
find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} +
done
fi
find $BUILD_DIR/libraries -name "*.map" -type f -delete
find $BUILD_DIR/node_modules -name "*.map" -type f -delete
find $BUILD_DIR -name "*.ts" -type f -delete
2020-04-12 14:22:51 +02:00
unset f d BUILD_DIR