From 607f9096aa5cb373632b355cc70a6c91bad8c3b6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 08:29:03 +0100 Subject: [PATCH 01/20] =?UTF-8?q?build:=20output=20into=20"build"=20folder?= =?UTF-8?q?=20again=20=E2=86=92=20"dist"=20will=20be=20used=20for=20the=20?= =?UTF-8?q?final=20output=20in=20archive=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this will allow for cleaner separation -> build for the output from the build stage (i.e. TS/Webpack + asset copying) and dist for the archive format of the build folder --- Dockerfile | 4 ++-- Dockerfile.alpine | 4 ++-- bin/copy-dist.ts | 2 +- tsconfig.build.json | 2 +- tsconfig.json | 2 +- tsconfig.webpack.json | 2 +- webpack.config.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2436a8124..4aac3160f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ COPY . . RUN npm ci && \ npm run build:prepare-dist && \ npm cache clean --force && \ - rm -rf dist/node_modules && \ - mv dist/* \ + rm -rf build/node_modules && \ + mv build/* \ start-docker.sh \ /usr/src/app/ && \ rm -rf \ diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 9370bd6da..f83789399 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -10,8 +10,8 @@ COPY . . RUN npm ci && \ npm run build:prepare-dist && \ npm cache clean --force && \ - rm -rf dist/node_modules && \ - mv dist/* \ + rm -rf build/node_modules && \ + mv build/* \ start-docker.sh \ /usr/src/app/ && \ rm -rf \ diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 289334321..19a48eaf0 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,7 +1,7 @@ import fs from "fs-extra"; import path from "path"; -const DEST_DIR = "./dist"; +const DEST_DIR = "./build"; const VERBOSE = process.env.VERBOSE; diff --git a/tsconfig.build.json b/tsconfig.build.json index 4d4ffd342..1987c96c0 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -3,7 +3,7 @@ "module": "NodeNext", "declaration": false, "sourceMap": true, - "outDir": "./dist", + "outDir": "./build", "strict": true, "noImplicitAny": true, "resolveJsonModule": true, diff --git a/tsconfig.json b/tsconfig.json index d94fcef82..c1f3ef48b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "module": "NodeNext", "declaration": false, "sourceMap": true, - "outDir": "./dist", + "outDir": "./build", "strict": true, "noImplicitAny": true, "resolveJsonModule": true, diff --git a/tsconfig.webpack.json b/tsconfig.webpack.json index cbfe8cbdb..ed622818b 100644 --- a/tsconfig.webpack.json +++ b/tsconfig.webpack.json @@ -3,7 +3,7 @@ "module": "NodeNext", "declaration": false, "sourceMap": true, - "outDir": "./dist", + "outDir": "./build", "strict": true, "noImplicitAny": true, "resolveJsonModule": true, diff --git a/webpack.config.ts b/webpack.config.ts index 207ff2fcf..82439ea6d 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -19,7 +19,7 @@ const config: Configuration = { }, output: { publicPath: `${assetPath}/app-dist/`, - path: path.resolve(rootDir, "dist/src/public/app-dist"), + path: path.resolve(rootDir, "build/src/public/app-dist"), filename: "[name].js" }, plugins: [ From d65281bfa56040c7994b043f8cdc352ea49ede94 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 09:50:05 +0100 Subject: [PATCH 02/20] build(copy-trilium): use npm ci --- bin/copy-trilium.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index f62b180a0..05bb4dee9 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -44,7 +44,7 @@ cp -R "$script_dir/../build/src" "$DIR" cp "$script_dir/../build/electron-main.js" "$DIR" # run in subshell (so we return to original dir) -(cd $DIR && npm install --omit=dev --legacy-peer-deps) +(cd $DIR && npm ci --omit=dev) if [[ -d "$DIR"/node_modules ]]; then # cleanup of useless files in dependencies From c89d86acb188fa7fb178b8b1a26ec7be3dd8d5e6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 09:54:26 +0100 Subject: [PATCH 03/20] build(copy-trilium): use "build:prepare-dist" build script --- bin/copy-trilium.sh | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 05bb4dee9..e9f733cea 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -12,29 +12,10 @@ if ! [[ $(which npm) ]]; then exit 1 fi -# Trigger the TypeScript build -echo TypeScript build start -npm run build:ts -echo TypeScript build finished - -# Copy the TypeScript artifacts -DIR="$1" -rm -rf "$DIR" -mkdir -pv "$DIR" - -echo Webpack start -npm run build:webpack -echo Webpack finish - -echo "Copying Trilium to build directory $DIR" - -for d in 'images' 'libraries' 'src' 'db'; do - cp -r "$d" "$DIR"/ -done - -for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample.ini'; do - cp "$f" "$DIR"/ -done +# Trigger the build +echo Build start +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" From 930be2de05d4a48fbaa0b093700f4502e5231066 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 09:57:35 +0100 Subject: [PATCH 04/20] build(copy-dist): copy LICENSE and README as well copied over from copy-trilium.sh script --- bin/copy-dist.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 19a48eaf0..0f9e62c99 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -28,6 +28,8 @@ try { "./config-sample.ini", "./package-lock.json", "./package.json", + "./LICENSE", + "./README.md", "./src/views/", "./src/etapi/etapi.openapi.yaml", "./src/routes/api/openapi.json", From f8b06f063472574166689d65a7e4b2e9912047b0 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 10:00:29 +0100 Subject: [PATCH 05/20] build(copy-trilium): get rid of unecessary copying of files -> already handled by "build:prepare-dist" step --- bin/copy-trilium.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index e9f733cea..bd3bd4a5a 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -20,10 +20,6 @@ echo Build finished # Patch package.json main sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$DIR/package.json" -script_dir=$(realpath $(dirname $0)) -cp -R "$script_dir/../build/src" "$DIR" -cp "$script_dir/../build/electron-main.js" "$DIR" - # run in subshell (so we return to original dir) (cd $DIR && npm ci --omit=dev) @@ -47,9 +43,4 @@ find $DIR/libraries -name "*.map" -type f -delete find $DIR/node_modules -name "*.map" -type f -delete find $DIR -name "*.ts" -type f -delete -d="$DIR"/src/public -[[ -d "$d"/app-dist ]] || mkdir -pv "$d"/app-dist -cp -r "$d"/app/doc_notes "$d"/app-dist/ - -rm -rf "$d"/app unset f d DIR From 1ae5c430106ae5354801e0e3314660b1e8799f70 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 10:05:00 +0100 Subject: [PATCH 06/20] 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 From 9bd31698e144c0703994dad948482136165192bb Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 10:06:55 +0100 Subject: [PATCH 07/20] build(copy-trilium): use "|" as sed separator allows us to avoid having to escape "/" --- bin/copy-trilium.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index e7e688bff..55c5cf6de 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -16,7 +16,7 @@ npm run build:prepare-dist echo Build finished # Patch package.json main -sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$BUILD_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 $BUILD_DIR && npm ci --omit=dev) From 19abd1405830dd5e845da983ab606667f528f85b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:43:01 +0100 Subject: [PATCH 08/20] build(build-server): use build dir for build and dist for final archive output --- bin/build-server.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 17a50929b..905aeaf37 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -37,8 +37,8 @@ fi # Debug output echo "Node filename: $NODE_FILENAME" -PKG_DIR=dist/trilium-linux-${ARCH}-server -echo "Package directory: $PKG_DIR" +BUILD_DIR="./build" +DIST_DIR="./dist" if [ "$1" != "DONTCOPY" ] then @@ -46,29 +46,30 @@ then ./bin/copy-trilium.sh fi -cd dist +cd $BUILD_DIR wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz tar xfJ node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz rm node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz +mv node-v${NODE_VERSION}-linux-${NODE_FILENAME} node cd .. -mv dist/node-v${NODE_VERSION}-linux-${NODE_FILENAME} $PKG_DIR/node -rm -r $PKG_DIR/node/lib/node_modules/npm -rm -r $PKG_DIR/node/include/node +rm -r $BUILD_DIR/node/lib/node_modules/npm +rm -r $BUILD_DIR/node/include/node -rm -r $PKG_DIR/node_modules/electron* -rm -r $PKG_DIR/electron*.js +rm -r $BUILD_DIR/node_modules/electron* +rm -r $BUILD_DIR/electron*.js -printf "#!/bin/sh\n./node/bin/node src/main" > $PKG_DIR/trilium.sh -chmod 755 $PKG_DIR/trilium.sh +printf "#!/bin/sh\n./node/bin/node src/main" > $BUILD_DIR/trilium.sh +chmod 755 $BUILD_DIR/trilium.sh -cp bin/tpl/anonymize-database.sql $PKG_DIR/ +cp bin/tpl/anonymize-database.sql $BUILD_DIR/ -cp -r translations $PKG_DIR/ +cp -r translations $BUILD_DIR/ VERSION=`jq -r ".version" package.json` -cd dist - +mkdir $DIST_DIR +cp -r "$BUILD_DIR" "$DIST_DIR/trilium-linux-${ARCH}-server" +cd $DIST_DIR tar cJf trilium-linux-${ARCH}-server-${VERSION}.tar.xz trilium-linux-${ARCH}-server From e0413b528f0bbffe5848909407fa53705e659619 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:44:21 +0100 Subject: [PATCH 09/20] build(build-server): use a single "rm" command --- bin/build-server.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 905aeaf37..030c2f78d 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -54,11 +54,10 @@ mv node-v${NODE_VERSION}-linux-${NODE_FILENAME} node cd .. -rm -r $BUILD_DIR/node/lib/node_modules/npm -rm -r $BUILD_DIR/node/include/node - -rm -r $BUILD_DIR/node_modules/electron* -rm -r $BUILD_DIR/electron*.js +rm -r $BUILD_DIR/node/lib/node_modules/npm \ + $BUILD_DIR/node/include/node \ + $BUILD_DIR/node_modules/electron* \ + $BUILD_DIR/electron*.js printf "#!/bin/sh\n./node/bin/node src/main" > $BUILD_DIR/trilium.sh chmod 755 $BUILD_DIR/trilium.sh From 80d6cd0356b58fce4a4eb6fad95bae71dde6aa16 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:47:16 +0100 Subject: [PATCH 10/20] build(build-server): delete temp build dir copy in dist folder --- bin/build-server.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/build-server.sh b/bin/build-server.sh index 030c2f78d..0d5df00a1 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -72,3 +72,4 @@ mkdir $DIST_DIR cp -r "$BUILD_DIR" "$DIST_DIR/trilium-linux-${ARCH}-server" cd $DIST_DIR tar cJf trilium-linux-${ARCH}-server-${VERSION}.tar.xz trilium-linux-${ARCH}-server +rm -rf trilium-linux-${ARCH}-server \ No newline at end of file From 1324cc2e53ef2b21fcbb3d4fb7596b20344dd2f7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:48:32 +0100 Subject: [PATCH 11/20] build(build-server): add TODO remark --- bin/build-server.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/build-server.sh b/bin/build-server.sh index 0d5df00a1..2bcc5098e 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -62,6 +62,7 @@ rm -r $BUILD_DIR/node/lib/node_modules/npm \ printf "#!/bin/sh\n./node/bin/node src/main" > $BUILD_DIR/trilium.sh chmod 755 $BUILD_DIR/trilium.sh +# TriliumNextTODO: is this still required? If yes → move to copy-dist/copy-trilium cp bin/tpl/anonymize-database.sql $BUILD_DIR/ cp -r translations $BUILD_DIR/ From 87d37366e4548e70e30d4d529198fe73abc761d8 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:50:51 +0100 Subject: [PATCH 12/20] build(build-server): remove unnecessary copying of translations already happens during build:prepare-dist step --- bin/build-server.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 2bcc5098e..7f043bfe5 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -65,8 +65,6 @@ chmod 755 $BUILD_DIR/trilium.sh # TriliumNextTODO: is this still required? If yes → move to copy-dist/copy-trilium cp bin/tpl/anonymize-database.sql $BUILD_DIR/ -cp -r translations $BUILD_DIR/ - VERSION=`jq -r ".version" package.json` mkdir $DIST_DIR From 4bba061629864bb663d8ae7d63fade9293a87fa0 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 17:57:30 +0100 Subject: [PATCH 13/20] build(build-server): get rid of now unnecessary arch handling for node directly use "ARCH" instead of creating 2 variables with the identical content as "ARCH" --- bin/build-server.sh | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 7f043bfe5..101c55170 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -22,20 +22,6 @@ echo "Selected Arch: $ARCH" # Set Node.js version and architecture-specific filename NODE_VERSION=20.15.1 -NODE_ARCH=$ARCH - -# Debug output -echo "Node arch: $NODE_ARCH" - -# Special case for x64 in Node.js downloads -if [ "$NODE_ARCH" = "x64" ]; then - NODE_FILENAME="x64" -elif [ "$NODE_ARCH" = "arm64" ]; then - NODE_FILENAME="arm64" -fi - -# Debug output -echo "Node filename: $NODE_FILENAME" BUILD_DIR="./build" DIST_DIR="./dist" @@ -47,10 +33,10 @@ then fi cd $BUILD_DIR -wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz -tar xfJ node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz -rm node-v${NODE_VERSION}-linux-${NODE_FILENAME}.tar.xz -mv node-v${NODE_VERSION}-linux-${NODE_FILENAME} node +wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz +tar xfJ node-v${NODE_VERSION}-linux-${ARCH}.tar.xz +rm node-v${NODE_VERSION}-linux-${ARCH}.tar.xz +mv node-v${NODE_VERSION}-linux-${ARCH} node cd .. From 33de3428423255d5211ca9ffcf27687f30b53635 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:04:05 +0100 Subject: [PATCH 14/20] build(build-server): download and extract node in a single step --- bin/build-server.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 101c55170..f85acf2a7 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -33,9 +33,7 @@ then fi cd $BUILD_DIR -wget https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz -tar xfJ node-v${NODE_VERSION}-linux-${ARCH}.tar.xz -rm node-v${NODE_VERSION}-linux-${ARCH}.tar.xz +wget -qO- https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz | tar xfJ - mv node-v${NODE_VERSION}-linux-${ARCH} node cd .. From d8ad018819f756ac394b6a6f4098a12a4b7c0be8 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:04:29 +0100 Subject: [PATCH 15/20] build(build-server): also delete electron map files --- bin/build-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index f85acf2a7..a18090fb0 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -41,7 +41,7 @@ cd .. rm -r $BUILD_DIR/node/lib/node_modules/npm \ $BUILD_DIR/node/include/node \ $BUILD_DIR/node_modules/electron* \ - $BUILD_DIR/electron*.js + $BUILD_DIR/electron*.{js,map} printf "#!/bin/sh\n./node/bin/node src/main" > $BUILD_DIR/trilium.sh chmod 755 $BUILD_DIR/trilium.sh From d110c8b067229083352ce52210f1aa6ab7144738 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:11:53 +0100 Subject: [PATCH 16/20] build(build-server): add some status "echo"s --- bin/build-server.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index a18090fb0..ba2db5958 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -32,6 +32,7 @@ then ./bin/copy-trilium.sh fi +echo "Downloading Node.js runtime..." cd $BUILD_DIR wget -qO- https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz | tar xfJ - mv node-v${NODE_VERSION}-linux-${ARCH} node @@ -51,8 +52,10 @@ cp bin/tpl/anonymize-database.sql $BUILD_DIR/ VERSION=`jq -r ".version" package.json` +echo "Creating Archive..." mkdir $DIST_DIR cp -r "$BUILD_DIR" "$DIST_DIR/trilium-linux-${ARCH}-server" cd $DIST_DIR tar cJf trilium-linux-${ARCH}-server-${VERSION}.tar.xz trilium-linux-${ARCH}-server -rm -rf trilium-linux-${ARCH}-server \ No newline at end of file +rm -rf trilium-linux-${ARCH}-server +echo "Server Build Completed!" \ No newline at end of file From 56340009cae4d00285e3c645898c32ee0adc9bf1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:13:49 +0100 Subject: [PATCH 17/20] build(build-server): remove now unused DONTCOPY check --- bin/build-server.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index ba2db5958..55a082462 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -26,11 +26,7 @@ NODE_VERSION=20.15.1 BUILD_DIR="./build" DIST_DIR="./dist" -if [ "$1" != "DONTCOPY" ] -then - # Need to modify copy-trilium.sh to accept the target directory - ./bin/copy-trilium.sh -fi +./bin/copy-trilium.sh echo "Downloading Node.js runtime..." cd $BUILD_DIR From 36fad35be51c6d663024f7992813e7a8e8ff8ca7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:25:46 +0100 Subject: [PATCH 18/20] build(build-server): rename archive name to the same naming scheme used in the Github CI --- bin/build-server.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 55a082462..40a84e382 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -49,9 +49,13 @@ cp bin/tpl/anonymize-database.sql $BUILD_DIR/ VERSION=`jq -r ".version" package.json` echo "Creating Archive..." + +ARCHIVE_NAME="TriliumNextNotes-Server-${VERSION}-linux-${ARCH}" + mkdir $DIST_DIR -cp -r "$BUILD_DIR" "$DIST_DIR/trilium-linux-${ARCH}-server" +cp -r "$BUILD_DIR" "$DIST_DIR/$ARCHIVE_NAME" cd $DIST_DIR -tar cJf trilium-linux-${ARCH}-server-${VERSION}.tar.xz trilium-linux-${ARCH}-server -rm -rf trilium-linux-${ARCH}-server +tar cJf "$ARCHIVE_NAME.tar.xz" "$ARCHIVE_NAME" +rm -rf "$ARCHIVE_NAME" + echo "Server Build Completed!" \ No newline at end of file From 3450066214507354786c5a22349ba4f8baecc85a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:36:01 +0100 Subject: [PATCH 19/20] build(build.sh): remove unused build script this is not used anymore at all, it was replaced by GitHub CI Actions it even mentions several other scripts, that got removed in the meantime as well --- bin/build.sh | 53 ---------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100755 bin/build.sh diff --git a/bin/build.sh b/bin/build.sh deleted file mode 100755 index 7fb41cfcb..000000000 --- a/bin/build.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -set -e # Fail on any command error - -if ! command -v jq &> /dev/null; then - echo "Missing command: jq" - exit 1 -fi - -if ! command -v fakeroot &> /dev/null; then - echo "Missing command: fakeroot" - exit 1 -fi - -if ! command -v dpkg-deb &> /dev/null; then - echo "Missing command: dpkg-deb" - exit 1 -fi - -if dpkg-deb 2>&1 | grep BusyBox &> /dev/null; then - echo "The dpkg-deb binary provided by BusyBox is not compatible. The Debian tool needs to be used instead." - exit 1 -fi - -if ! command -v wine &> /dev/null; then - echo "Missing command: wine" - exit 1 -fi - -echo "Deleting existing builds" - -rm -rf dist/* - -SRC_DIR=dist/trilium-src - -bin/copy-trilium.sh $SRC_DIR - -# we'll just copy the same SRC dir to all the builds so we don't have to do npm install in each separately -cp -r $SRC_DIR ./dist/trilium-linux-x64-src -cp -r $SRC_DIR ./dist/trilium-linux-x64-server -cp -r $SRC_DIR ./dist/trilium-windows-x64-src -cp -r $SRC_DIR ./dist/trilium-mac-x64-src -cp -r $SRC_DIR ./dist/trilium-mac-arm64-src - -bin/build-win-x64.sh DONTCOPY - -bin/build-mac-x64.sh DONTCOPY - -bin/build-mac-arm64.sh DONTCOPY - -bin/build-linux-x64.sh DONTCOPY - -bin/build-server.sh DONTCOPY From afe4fc2d1a50f6a16c951935cc610d767fc97792 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Mar 2025 18:58:56 +0100 Subject: [PATCH 20/20] build(build-server): add more detail to status "echo"s --- bin/build-server.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 40a84e382..3af7ec9f5 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -28,10 +28,12 @@ DIST_DIR="./dist" ./bin/copy-trilium.sh -echo "Downloading Node.js runtime..." +NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} + +echo "Downloading Node.js runtime $NODE_FILENAME..." cd $BUILD_DIR -wget -qO- https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${ARCH}.tar.xz | tar xfJ - -mv node-v${NODE_VERSION}-linux-${ARCH} node +wget -qO- https://nodejs.org/dist/v${NODE_VERSION}/${NODE_FILENAME}.tar.xz | tar xfJ - +mv $NODE_FILENAME node cd .. @@ -48,9 +50,9 @@ cp bin/tpl/anonymize-database.sql $BUILD_DIR/ VERSION=`jq -r ".version" package.json` -echo "Creating Archive..." ARCHIVE_NAME="TriliumNextNotes-Server-${VERSION}-linux-${ARCH}" +echo "Creating Archive $ARCHIVE_NAME..." mkdir $DIST_DIR cp -r "$BUILD_DIR" "$DIST_DIR/$ARCHIVE_NAME"