From 1ae5c430106ae5354801e0e3314660b1e8799f70 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 10:05:00 +0100 Subject: [PATCH] build(copy-trilium): do all the work inside build dir, no target directory needed anymore -> all of these steps will eventually be merged with copy-dist script to have a unified copying script --- bin/build-server.sh | 2 +- bin/copy-trilium.sh | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index ff2912470..17a50929b 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -43,7 +43,7 @@ echo "Package directory: $PKG_DIR" if [ "$1" != "DONTCOPY" ] then # Need to modify copy-trilium.sh to accept the target directory - ./bin/copy-trilium.sh "$PKG_DIR" + ./bin/copy-trilium.sh fi cd dist diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index bd3bd4a5a..e7e688bff 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -3,10 +3,8 @@ set -e # Fail on any command error shopt -s globstar -if [[ $# -eq 0 ]] ; then - echo "Missing argument of target directory" - exit 1 -fi +BUILD_DIR="./build" + if ! [[ $(which npm) ]]; then echo "Missing npm" exit 1 @@ -18,29 +16,29 @@ npm run build:prepare-dist echo Build finished # Patch package.json main -sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$DIR/package.json" +sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$BUILD_DIR/package.json" # run in subshell (so we return to original dir) -(cd $DIR && npm ci --omit=dev) +(cd $BUILD_DIR && npm ci --omit=dev) -if [[ -d "$DIR"/node_modules ]]; then +if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies 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' \ 'mermaid/dist/mermaid.js' \ 'boxicons/svg' 'boxicons/node_modules/react'/* \ '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do - [[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d" + [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" done # delete all tests (there are often large images as test file for jimp etc.) for d in 'test' 'docs' 'demo' 'example'; do - find "$DIR"/node_modules -name "$d" -exec rm -rf {} + + find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} + done fi -find $DIR/libraries -name "*.map" -type f -delete -find $DIR/node_modules -name "*.map" -type f -delete -find $DIR -name "*.ts" -type f -delete +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 -unset f d DIR +unset f d BUILD_DIR