copy-trilium.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 18.18.2 npm run webpack
  7. DIR=$1
  8. rm -rf $DIR
  9. mkdir $DIR
  10. echo "Copying Trilium to build directory $DIR"
  11. cp -r images $DIR/
  12. cp -r libraries $DIR/
  13. cp -r src $DIR/
  14. cp -r db $DIR/
  15. cp -r package.json $DIR/
  16. cp -r package-lock.json $DIR/
  17. cp -r README.md $DIR/
  18. cp -r LICENSE $DIR/
  19. cp -r config-sample.ini $DIR/
  20. cp -r electron.js $DIR/
  21. cp webpack-* $DIR/
  22. # run in subshell (so we return to original dir)
  23. (cd $DIR && n exec 18.18.2 npm install --only=prod)
  24. # cleanup of useless files in dependencies
  25. rm -r $DIR/node_modules/image-q/demo
  26. rm -r $DIR/node_modules/better-sqlite3/Release
  27. rm -r $DIR/node_modules/better-sqlite3/deps/sqlite3.tar.gz
  28. rm -r $DIR/node_modules/@jimp/plugin-print/fonts
  29. rm -r $DIR/node_modules/jimp/browser
  30. rm -r $DIR/node_modules/jimp/fonts
  31. # delete all tests (there are often large images as test file for jimp etc.)
  32. find $DIR/node_modules -name test -exec rm -rf {} \;
  33. find $DIR/node_modules -name docs -exec rm -rf {} \;
  34. find $DIR/node_modules -name demo -exec rm -rf {} \;
  35. find $DIR/libraries -name "*.map" -type f -delete
  36. cp $DIR/src/public/app/share.js $DIR/src/public/app-dist/
  37. cp -r $DIR/src/public/app/doc_notes $DIR/src/public/app-dist/
  38. rm -rf $DIR/src/public/app