copy-trilium.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. if [[ $# -eq 0 ]] ; then
  3. echo "Missing argument of target directory"
  4. exit 1
  5. fi
  6. n exec 16.15.0 npm run webpack
  7. DIR=$1
  8. rm -rf $DIR
  9. mkdir $DIR
  10. echo "Copying Trilium to build directory $DIR"
  11. cp -r dump-db $DIR/
  12. rm -rf $DIR/dump-db/node_modules
  13. cp -r images $DIR/
  14. cp -r libraries $DIR/
  15. cp -r src $DIR/
  16. cp -r db $DIR/
  17. cp -r package.json $DIR/
  18. cp -r package-lock.json $DIR/
  19. cp -r README.md $DIR/
  20. cp -r LICENSE $DIR/
  21. cp -r config-sample.ini $DIR/
  22. cp -r electron.js $DIR/
  23. cp webpack-* $DIR/
  24. # run in subshell (so we return to original dir)
  25. (cd $DIR && n exec 16.15.0 npm install --only=prod)
  26. # cleanup of useless files in dependencies
  27. rm -r $DIR/node_modules/image-q/demo
  28. rm -r $DIR/node_modules/better-sqlite3/Release
  29. rm -r $DIR/node_modules/better-sqlite3/deps/sqlite3.tar.gz
  30. rm -r $DIR/node_modules/@jimp/plugin-print/fonts
  31. rm -r $DIR/node_modules/jimp/browser
  32. rm -r $DIR/node_modules/jimp/fonts
  33. # delete all tests (there are often large images as test file for jimp etc.)
  34. find $DIR/node_modules -name test -exec rm -rf {} \;
  35. find $DIR/node_modules -name docs -exec rm -rf {} \;
  36. find $DIR/node_modules -name demo -exec rm -rf {} \;
  37. find $DIR/libraries -name "*.map" -type f -delete
  38. cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/
  39. rm -rf $DIR/src/public/app
  40. sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' $DIR/src/views/desktop.ejs
  41. sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' $DIR/src/views/mobile.ejs
  42. sed -i -e 's/app\/setup.js/app-dist\/setup.js/g' $DIR/src/views/setup.ejs
  43. sed -i -e 's/app\/share.js/app-dist\/share.js/g' $DIR/src/views/share/*.ejs