From 17d5fdb4b000481eb78d6efead400abc5ad15176 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 15 Mar 2025 13:41:58 +0100 Subject: [PATCH 01/47] build(copy-dist): get rid of manual node_module copying this is useless at the moment, as all build processes are running "npm ci --omit=dev" anyways, i.e. they will just install everything remaining again --- bin/copy-dist.ts | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index eaa79808e..67c3579a6 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -11,13 +11,6 @@ function log(...args: any[]) { } } -function copyNodeModuleFileOrFolder(source: string) { - const destination = path.join(DEST_DIR, source); - log(`Copying ${source} to ${destination}`); - fs.ensureDirSync(path.dirname(destination)); - fs.copySync(source, destination); -} - try { const assetsToCopy = new Set([ @@ -61,47 +54,6 @@ try { fs.copySync(dir, path.join(PUBLIC_DIR, path.basename(dir))); } - const nodeModulesFile = new Set([ - "node_modules/react/umd/react.production.min.js", - "node_modules/react/umd/react.development.js", - "node_modules/react-dom/umd/react-dom.production.min.js", - "node_modules/react-dom/umd/react-dom.development.js", - "node_modules/katex/dist/katex.min.js", - "node_modules/katex/dist/contrib/mhchem.min.js", - "node_modules/katex/dist/contrib/auto-render.min.js", - "node_modules/@highlightjs/cdn-assets/highlight.min.js", - ]); - - const nodeModulesFolder = new Set([ - "node_modules/@excalidraw/excalidraw/dist/prod/fonts/", - "node_modules/katex/dist/", - "node_modules/dayjs/", - "node_modules/boxicons/css/", - "node_modules/boxicons/fonts/", - "node_modules/jquery/dist/", - "node_modules/jquery-hotkeys/", - "node_modules/split.js/dist/", - "node_modules/i18next/", - "node_modules/i18next-http-backend/", - "node_modules/vanilla-js-wheel-zoom/dist/", - "node_modules/mark.js/dist/", - "node_modules/normalize.css/", - "node_modules/jquery.fancytree/dist/", - "node_modules/autocomplete.js/dist/", - "node_modules/codemirror/lib/", - "node_modules/codemirror/addon/", - "node_modules/codemirror/mode/", - "node_modules/codemirror/keymap/", - "node_modules/@highlightjs/cdn-assets/languages", - "node_modules/@highlightjs/cdn-assets/styles", - "node_modules/leaflet/dist" - ]); - - - - for (const nodeModuleItem of [...nodeModulesFile, ...nodeModulesFolder]) { - copyNodeModuleFileOrFolder(nodeModuleItem); - } console.log("Copying complete!") } catch(err) { From 164000029110227fb94c71ed5e245ffa321df30b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:04:17 +0100 Subject: [PATCH 02/47] build(build-server): move "build:prepare-dist" call to build-server from copy-trilium in preparation to get rid of the file altogether - rest of the functionality will be merged into copy-dist.ts --- bin/build-server.sh | 6 ++++++ bin/copy-trilium.sh | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 052a8131b..fc1807ee0 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -26,6 +26,12 @@ NODE_VERSION=22.14.0 BUILD_DIR="./build" DIST_DIR="./dist" + +# Trigger the build +echo "Build start" +npm run build:prepare-dist +echo "Build finished" + ./bin/copy-trilium.sh NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 55c5cf6de..b80c97632 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -10,11 +10,6 @@ if ! [[ $(which npm) ]]; then exit 1 fi -# 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' "$BUILD_DIR/package.json" From 89774929811ab3da35b3eaeb359f4cd26a77bc59 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:12:55 +0100 Subject: [PATCH 03/47] build(copy-dist): move "pruning" to copy-dist from copy-trilium.sh --- bin/copy-dist.ts | 4 ++++ bin/copy-trilium.sh | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 67c3579a6..2505c31c3 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,5 +1,6 @@ import fs from "fs-extra"; import path from "path"; +import { execSync } from "node:child_process"; const DEST_DIR = "./build"; @@ -56,6 +57,9 @@ try { console.log("Copying complete!") + // TriliumNextTODO: for Docker this needs to run separately *after* build-stage + console.log("Pruning npm packages...") + execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); } catch(err) { console.error("Error during copy:", err) process.exit(1) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index b80c97632..515c3ccc6 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -13,9 +13,6 @@ fi # Patch package.json main 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) - if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies for d in 'image-q/demo' \ From 6fb270e4f8d8ed5c8a0367fb47ea59463b0bfade Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:17:46 +0100 Subject: [PATCH 04/47] build(copy-dist): copy over existing node_modules helps avoiding downloading the packages a 2nd time during our prune stage --- bin/copy-dist.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 2505c31c3..6d9fcf0e0 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -15,6 +15,7 @@ function log(...args: any[]) { try { const assetsToCopy = new Set([ + // copy node_module, to avoid downloading packages a 2nd time during pruning "./node_modules", "./images", "./libraries", From 8feb201d3d0c7a0490b8467fbdf006b5b3f7dbe2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:21:21 +0100 Subject: [PATCH 05/47] build(electron-forge): set prune to false since we our own more "sophisticated" pruning during copy-dist, we need to set this to false, as otherwise build will fail --- forge.config.cjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/forge.config.cjs b/forge.config.cjs index ba3d8c3ff..763cb80e8 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -18,6 +18,8 @@ module.exports = { // we run electron-forge inside the ./build folder, // to have it output to ./dist, we need to go up a directory first outDir: "../dist", + // we prune ourselves via copy-dist + prune: false, packagerConfig: { executableName: "trilium", name: APP_NAME, From bee7793d32a5dc01b2342d5caee075afa3b03174 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:30:52 +0100 Subject: [PATCH 06/47] build(copy-trilium): remove now unnecessary package.json patching this is not needed anymore since commit 6b9d8f0d677763f29d29abd0816b1a5d40e858c8 --- bin/copy-trilium.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 515c3ccc6..629138048 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -10,9 +10,6 @@ if ! [[ $(which npm) ]]; then exit 1 fi -# Patch package.json main -sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json" - if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies for d in 'image-q/demo' \ From 6260ea1532e284c67b450f20fd80808063a94f8b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:50:59 +0100 Subject: [PATCH 07/47] build(copy-dist): add initial cleanupNodeModules functionality adapted from copy-trilium.sh --- bin/copy-dist.ts | 23 +++++++++++++++++++++++ bin/copy-trilium.sh | 5 ----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 6d9fcf0e0..f5901225b 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -61,7 +61,30 @@ try { // TriliumNextTODO: for Docker this needs to run separately *after* build-stage console.log("Pruning npm packages...") execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); + + cleanupNodeModules(); + } catch(err) { console.error("Error during copy:", err) process.exit(1) } +function cleanupNodeModules() { + const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); + + const filterableDirs = new Set([ + "test", + "docs", + "demo", + "example", + ]); + + const filteredDirs = nodeDir + .filter(el => el.isDirectory() && filterableDirs.has(el.name)) + .map(el => path.join(DEST_DIR, el.parentPath, el.name)); + + filteredDirs.forEach(dir => { + fs.removeSync(dir); + }) + +} + diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 629138048..e99bf08b9 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -19,11 +19,6 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do [[ -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 "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} + - done fi find $BUILD_DIR/libraries -name "*.map" -type f -delete From a9643174ccc5b990e9b846abe90e36e4ec000780 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:53:14 +0100 Subject: [PATCH 08/47] build(copy-dist): add further folders to list of filterableDirs same as before, but some of the modules use singular/plural, so just check for both --- bin/copy-dist.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index f5901225b..586650811 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -72,10 +72,14 @@ function cleanupNodeModules() { const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); const filterableDirs = new Set([ - "test", - "docs", "demo", + "demos", + "doc", + "docs", "example", + "examples", + "test", + "tests" ]); const filteredDirs = nodeDir From 8275f3c867fff674db44e938f96ce059fa3002df Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:10:47 +0100 Subject: [PATCH 09/47] build(copy-dist): execute filterableDirs cleanup in one chain --- bin/copy-dist.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 586650811..38413b1b9 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -82,13 +82,10 @@ function cleanupNodeModules() { "tests" ]); - const filteredDirs = nodeDir + nodeDir .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .map(el => path.join(DEST_DIR, el.parentPath, el.name)); - - filteredDirs.forEach(dir => { - fs.removeSync(dir); - }) + .map(el => path.join(DEST_DIR, el.parentPath, el.name)) + .forEach(dir => fs.removeSync(dir)); } From 6749d8084bb6f8b56aa330ef6d7d0d0790f3a29c Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:15:17 +0100 Subject: [PATCH 10/47] build(copy-dist): add further cleanupNodeModules functionality deleting of ts and map files from node_modules folder, adapted from copy-trilium.sh. --- bin/copy-dist.ts | 13 +++++++++++++ bin/copy-trilium.sh | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 38413b1b9..9fb520907 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -87,5 +87,18 @@ function cleanupNodeModules() { .map(el => path.join(DEST_DIR, el.parentPath, el.name)) .forEach(dir => fs.removeSync(dir)); + + // Delete unnecessary files based on file extension + const filterableFileExt = new Set([ + "ts", + "map" + ]) + + nodeDir + // TriliumNextTODO: check if we can improve this naive file ext matching + .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) + .map(file => path.join(DEST_DIR, file.parentPath, file.name)) + .forEach(file => fs.removeSync(file)); + } diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index e99bf08b9..6aea1175c 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -22,7 +22,5 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then 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 unset f d BUILD_DIR From cd8401089d19532d1fa2dc5ebdea79200ec34630 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:33:27 +0100 Subject: [PATCH 11/47] build(copy-trilium): update list of useless deps paths * image-q/demo -> doesn't exist anymore (and even if it did - previous cleanup step, would've removed this anyways) * @excalidraw/excalidraw/dist/* -> updated to point to the dev folder * boxicons -> only fonts and css folders are used, so remove the other ones * jimp -> updated paths and removed non-existent path fixing here for historical reasons, next step is to move these over to copy-dist.ts --- bin/copy-trilium.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 6aea1175c..f6030a6ec 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -12,11 +12,11 @@ fi 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' \ + for d in \ + '@excalidraw/excalidraw/dist/dev' \ 'mermaid/dist/mermaid.js' \ - 'boxicons/svg' 'boxicons/node_modules/react'/* \ - '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do + 'boxicons/svg' 'boxicons/node_modules' 'boxicons/src' 'boxicons/iconjar' \ + '@jimp/plugin-print/fonts' 'jimp/dist/browser'; do [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" done fi From 1ceaafa1e88323eb106f00a451515f34d1e62bb2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:02:03 +0100 Subject: [PATCH 12/47] build: move cleanupNodeModules to its own file this is necessary, since for Docker and electron-forge, we need to run this as an extra step after copy-dist for electron-forge: after it is done with its own "pruning", as we otherwise would need to also take care of certain electron related pruning for Docker: as a last step in the build stage --- Dockerfile | 1 + Dockerfile.alpine | 1 + bin/cleanupNodeModules.ts | 87 +++++++++++++++++++++++++++++++++++++++ bin/copy-dist.ts | 41 ++---------------- forge.config.cjs | 19 ++++++++- 5 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 bin/cleanupNodeModules.ts diff --git a/Dockerfile b/Dockerfile index 4aac3160f..538f3e58f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache +#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/Dockerfile.alpine b/Dockerfile.alpine index f83789399..595d21561 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -18,6 +18,7 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache +#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts new file mode 100644 index 000000000..2daf7c01b --- /dev/null +++ b/bin/cleanupNodeModules.ts @@ -0,0 +1,87 @@ +import fs from "fs-extra"; +import path from "path"; + +function main() { + if (process.argv.length !== 3) { + console.error("More than one path was supplied as argument. Aborting."); + process.exit(1); + } + + const basePath = process.argv[2]; + + if (!fs.existsSync(basePath)) { + console.error(`Supplied path '${basePath}' does not exist. Aborting.`) + process.exit(1); + } + + cleanupNodeModules(basePath); +} + +function cleanupNodeModules(basePath: string) { + const nodeDir = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); + + /** + * Delete unnecessary folders + */ + const filterableDirs = new Set([ + "demo", + "demos", + "doc", + "docs", + "example", + "examples", + "test", + "tests" + ]); + + nodeDir + .filter(el => el.isDirectory() && filterableDirs.has(el.name)) + .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); + + + /** + * Delete unnecessary files based on file extension + * TODO filter out useless (README).md files + */ + const filterableFileExt = new Set([ + "ts", + "map" + ]); + + nodeDir + // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency + .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) + .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); + + + /** + * Delete specific unnecessary folders + * TODO: use basePath + * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail + */ + const extraFoldersDelete = new Set([ + 'build/node_modules/@excalidraw/excalidraw/dist/dev', + 'build/node_modules/boxicons/svg', + 'build/node_modules/boxicons/node_modules', + 'build/node_modules/boxicons/src', + 'build/node_modules/boxicons/iconjar', + 'build/node_modules/@jimp/plugin-print/fonts', + 'build/node_modules/jimp/dist/browser' + // "node_modules/@excalidraw/excalidraw/dist/dev", + // "node_modules/jimp/browser", + // "node_modules/@jimp/plugin-print/fonts", + // "node_modules/jimp/dist/browser", + // "node_modules/jimp/fonts", + // "node_modules/boxicons/svg", + // "node_modules/boxicons/node_modules/react", + // "node_modules/mermaid/dist/mermaid.js" + ]); + + nodeDir + .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) + .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) + +} + +main() \ No newline at end of file diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 9fb520907..e04edee0c 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -28,6 +28,7 @@ try { "./README.md", "./forge.config.cjs", "./bin/tpl/", + "./bin/cleanupNodeModules.ts", "./bin/electron-forge/desktop.ejs", "./bin/electron-forge/sign-windows.cjs", "./src/views/", @@ -59,46 +60,12 @@ try { console.log("Copying complete!") // TriliumNextTODO: for Docker this needs to run separately *after* build-stage - console.log("Pruning npm packages...") - execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); - - cleanupNodeModules(); + // Disable for now, because this messes with electron-forge as well + //console.log("Pruning npm packages...") + //execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); } catch(err) { console.error("Error during copy:", err) process.exit(1) } -function cleanupNodeModules() { - const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); - - const filterableDirs = new Set([ - "demo", - "demos", - "doc", - "docs", - "example", - "examples", - "test", - "tests" - ]); - - nodeDir - .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .map(el => path.join(DEST_DIR, el.parentPath, el.name)) - .forEach(dir => fs.removeSync(dir)); - - - // Delete unnecessary files based on file extension - const filterableFileExt = new Set([ - "ts", - "map" - ]) - - nodeDir - // TriliumNextTODO: check if we can improve this naive file ext matching - .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) - .map(file => path.join(DEST_DIR, file.parentPath, file.name)) - .forEach(file => fs.removeSync(file)); - -} diff --git a/forge.config.cjs b/forge.config.cjs index 763cb80e8..1a7e5a3c6 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -1,5 +1,6 @@ const path = require("path"); const fs = require("fs-extra"); +const { execSync } = require("child_process"); const APP_NAME = "TriliumNext Notes"; const BIN_PATH = path.normalize("./bin/electron-forge"); @@ -18,8 +19,6 @@ module.exports = { // we run electron-forge inside the ./build folder, // to have it output to ./dist, we need to go up a directory first outDir: "../dist", - // we prune ourselves via copy-dist - prune: false, packagerConfig: { executableName: "trilium", name: APP_NAME, @@ -41,6 +40,22 @@ module.exports = { "translations/", "node_modules/@highlightjs/cdn-assets/styles" ], + afterPrune: [ + (buildPath, _electronVersion, _platform, _arch, callback) => { + // buildPath is a temporary directory that electron-packager creates - it's in the form of + // /tmp/electron-packager/tmp-SjJl0s/resources/app + try { + const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); + // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}'`; + // execSync throws, if above returns any non-zero exit code + execSync(command); + callback() + } catch(err) { + callback(err) + } + } + ], afterComplete: [ (buildPath, _electronVersion, platform, _arch, callback) => { // Only move resources on non-macOS platforms From 3e3344b3294a6ba70460ee94474a3083d7c130d1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:03:54 +0100 Subject: [PATCH 13/47] chore(scripts): remove now unneeded electron-forge:prepare --- package.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ec931d8bb..7d998ee90 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,9 @@ "electron:switch": "electron-rebuild", "docs:edit": "cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data-docs TRILIUM_ENV=dev TRILIUM_PORT=37741 electron ./electron-docs-main.ts .", "docs:edit-nix": "electron-rebuild --version 33.3.1 && cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data-docs TRILIUM_PORT=37741 TRILIUM_ENV=dev nix-shell -p electron_33 --run \"electron ./electron-docs-main.ts .\"", - "electron-forge:prepare": "npm run build:prepare-dist", - "electron-forge:start": "npm run electron-forge:prepare && cd ./build && electron-forge start", - "electron-forge:make": "npm run electron-forge:prepare && cross-env DEBUG=electron-windows-installer:* electron-forge make ./build", - "electron-forge:package": "npm run electron-forge:prepare && cd ./build && electron-forge package", + "electron-forge:start": "npm run build:prepare-dist && cd ./build && electron-forge start", + "electron-forge:make": "npm run build:prepare-dist && cross-env DEBUG=electron-windows-installer:* electron-forge make ./build", + "electron-forge:package": "npm run build:prepare-dist && cd ./build && electron-forge package", "docs:build-backend": "rimraf ./docs/backend_api && typedoc ./docs/backend_api src/becca/entities/*.ts src/services/backend_script_api.ts src/services/sql.ts", "docs:build-frontend": "rimraf ./docs/frontend_api && jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/basic_widget.js src/public/app/widgets/note_context_aware_widget.js src/public/app/widgets/right_panel_widget.js", "docs:build": "npm run docs:build-backend && npm run docs:build-frontend", @@ -232,7 +231,6 @@ "lorem-ipsum": "2.0.8", "mind-elixir": "4.4.3", "mini-css-extract-plugin": "2.9.2", - "node-abi": "4.2.0", "nodemon": "3.1.9", "postcss-loader": "8.1.1", "prettier": "3.5.3", From f79b925e490c962296a6521ba0fda09d404471f1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:18:41 +0100 Subject: [PATCH 14/47] build(server): use cleanupNodeModules script --- bin/build-server.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index fc1807ee0..26dc19ad3 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -25,6 +25,7 @@ NODE_VERSION=22.14.0 BUILD_DIR="./build" DIST_DIR="./dist" +CLEANUP_SCRIPT="./bin/cleanupNodeModules.ts" # Trigger the build @@ -32,7 +33,7 @@ echo "Build start" npm run build:prepare-dist echo "Build finished" -./bin/copy-trilium.sh +node --experimental-strip-types $CLEANUP_SCRIPT $BUILD_DIR NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} From 57ee61938d2abb5f40dd22aa902fcd2bda633fd5 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:19:48 +0100 Subject: [PATCH 15/47] build(copy-trilium): delete now unused script all of its functionality has been "absorbed" by the cross-platform copy-dist and cleanupNodeModules scripts, that can be used for all of our builds now --- bin/copy-trilium.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100755 bin/copy-trilium.sh diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh deleted file mode 100755 index f6030a6ec..000000000 --- a/bin/copy-trilium.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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 - -if [[ -d "$BUILD_DIR"/node_modules ]]; then - # cleanup of useless files in dependencies - for d in \ - '@excalidraw/excalidraw/dist/dev' \ - 'mermaid/dist/mermaid.js' \ - 'boxicons/svg' 'boxicons/node_modules' 'boxicons/src' 'boxicons/iconjar' \ - '@jimp/plugin-print/fonts' 'jimp/dist/browser'; do - [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" - done -fi - -find $BUILD_DIR/libraries -name "*.map" -type f -delete - -unset f d BUILD_DIR From 83da24b38d8a23d78ff8f607264390bbb1cd80ae Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:21:40 +0100 Subject: [PATCH 16/47] build(dockerignore): add cleanupNodeModules as exception --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 2ceb847c9..32795ae0a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -35,6 +35,7 @@ npm-debug.log # exceptions !/bin/copy-dist.ts !/bin/electron-forge/sign-windows.cjs +!/bin/cleanupNodeModules.ts # temporary exception to make copy-dist inside Docker build not fail # TriliumNextTODO: make copy-dist *not* requiring to copy this file for builds other than electron-forge From b457fa2e874fafd65e1c539092f8c239c19a74f7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:12:22 +0100 Subject: [PATCH 17/47] chore(cleanupNodeModules): rename nodeDir to nodeModulesContent --- bin/cleanupNodeModules.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 2daf7c01b..072214ce9 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -18,7 +18,7 @@ function main() { } function cleanupNodeModules(basePath: string) { - const nodeDir = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + const nodeModulesContent = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); /** @@ -35,7 +35,7 @@ function cleanupNodeModules(basePath: string) { "tests" ]); - nodeDir + nodeModulesContent .filter(el => el.isDirectory() && filterableDirs.has(el.name)) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); @@ -49,7 +49,7 @@ function cleanupNodeModules(basePath: string) { "map" ]); - nodeDir + nodeModulesContent // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); @@ -78,7 +78,7 @@ function cleanupNodeModules(basePath: string) { // "node_modules/mermaid/dist/mermaid.js" ]); - nodeDir + nodeModulesContent .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) From 6fe23f9a136713f10c0b0bff541bb173b60cf579 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:15:33 +0100 Subject: [PATCH 18/47] chore(cleanupNodeModules): remove commented out paths extra note on mermaid: that should be packed by webpack now, so we just need to move it to devDeps and and we should be good --- bin/cleanupNodeModules.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 072214ce9..975b83af3 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -68,14 +68,6 @@ function cleanupNodeModules(basePath: string) { 'build/node_modules/boxicons/iconjar', 'build/node_modules/@jimp/plugin-print/fonts', 'build/node_modules/jimp/dist/browser' - // "node_modules/@excalidraw/excalidraw/dist/dev", - // "node_modules/jimp/browser", - // "node_modules/@jimp/plugin-print/fonts", - // "node_modules/jimp/dist/browser", - // "node_modules/jimp/fonts", - // "node_modules/boxicons/svg", - // "node_modules/boxicons/node_modules/react", - // "node_modules/mermaid/dist/mermaid.js" ]); nodeModulesContent From 1150f78b158b93ac1329b9d35c82ad3537c5facd Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:18:16 +0100 Subject: [PATCH 19/47] build(cleanupNodeModules): use path.join and basePath for extraFoldersDelete --- bin/cleanupNodeModules.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 975b83af3..2885f1484 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -18,7 +18,8 @@ function main() { } function cleanupNodeModules(basePath: string) { - const nodeModulesContent = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + const nodeModulesDirPath = path.join(basePath, "node_modules"); + const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); /** @@ -39,7 +40,6 @@ function cleanupNodeModules(basePath: string) { .filter(el => el.isDirectory() && filterableDirs.has(el.name)) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); - /** * Delete unnecessary files based on file extension * TODO filter out useless (README).md files @@ -57,17 +57,16 @@ function cleanupNodeModules(basePath: string) { /** * Delete specific unnecessary folders - * TODO: use basePath * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail */ const extraFoldersDelete = new Set([ - 'build/node_modules/@excalidraw/excalidraw/dist/dev', - 'build/node_modules/boxicons/svg', - 'build/node_modules/boxicons/node_modules', - 'build/node_modules/boxicons/src', - 'build/node_modules/boxicons/iconjar', - 'build/node_modules/@jimp/plugin-print/fonts', - 'build/node_modules/jimp/dist/browser' + path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"), + path.join(nodeModulesDirPath, "boxicons", "svg"), + path.join(nodeModulesDirPath, "boxicons", "node_modules"), + path.join(nodeModulesDirPath, "boxicons", "src"), + path.join(nodeModulesDirPath, "boxicons", "iconjar"), + path.join(nodeModulesDirPath, "@jimp", "plugin-print", "fonts"), + path.join(nodeModulesDirPath, "jimp", "dist", "browser") // missing "@" in front of jimp is not a typo here ]); nodeModulesContent From 1528703ed98a7ce8ab6c259eb9bd0cec8911b84f Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:26:22 +0100 Subject: [PATCH 20/47] build(cleanupNodeModules): add some minimalistic logging --- bin/cleanupNodeModules.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 2885f1484..e20004747 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -1,6 +1,12 @@ import fs from "fs-extra"; import path from "path"; +/** + * Example usage with node >= v22: + * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder + * Example usage with tsx: + * tsx bin/cleanupNodeModules.ts /path/to/build/folder + */ function main() { if (process.argv.length !== 3) { console.error("More than one path was supplied as argument. Aborting."); @@ -13,8 +19,9 @@ function main() { console.error(`Supplied path '${basePath}' does not exist. Aborting.`) process.exit(1); } - + console.log(`Starting node_modules pruning in '${basePath}'...`) cleanupNodeModules(basePath); + console.log("Successfully pruned node_modules.") } function cleanupNodeModules(basePath: string) { From 51f2e23c2f88631a2465de143500d1bbb7367cec Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:28:50 +0100 Subject: [PATCH 21/47] build(cleanupNodeModules): delete .bin folder this is only needed for executing package scripts -> which we don't do in production fixes #1499 --- bin/cleanupNodeModules.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index e20004747..c5df07da9 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -67,6 +67,7 @@ function cleanupNodeModules(basePath: string) { * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail */ const extraFoldersDelete = new Set([ + path.join(nodeModulesDirPath, ".bin"), path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"), path.join(nodeModulesDirPath, "boxicons", "svg"), path.join(nodeModulesDirPath, "boxicons", "node_modules"), From 0b428035ae0254642b101d0fc402f3e03aa9534a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:47:06 +0100 Subject: [PATCH 22/47] build(cleanupNodeModules): move removal of elements to its own function also added a logging function for debugging purposes --- bin/cleanupNodeModules.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index c5df07da9..d811c95a1 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -45,7 +45,7 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); + .forEach(dir => removeDirent(dir)); /** * Delete unnecessary files based on file extension @@ -59,7 +59,7 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) - .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); + .forEach(dir => removeDirent(dir)); /** @@ -79,7 +79,17 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) - .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) + .forEach(dir => removeDirent(dir)) +} + +function removeDirent(el: Dirent) { + const elementToDelete = path.join(el.parentPath, el.name); + fs.removeSync(elementToDelete); + + if (process.env.VERBOSE) { + console.log(`Deleted ${elementToDelete}`); + } + } From 75431ca634860d6b0af15b434b209cc47e81f521 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 00:00:41 +0100 Subject: [PATCH 23/47] build: make running of npm ci in build scripts configurable * moved the running of npm ci from copy-dist to cleanupNodeModules * added flag to disable it (necessary for electron-forge) --- Dockerfile | 1 + Dockerfile.alpine | 5 ++++- bin/build-server.sh | 1 + bin/cleanupNodeModules.ts | 33 +++++++++++++++++++++++---------- bin/copy-dist.ts | 6 ------ forge.config.cjs | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 538f3e58f..0ee13f25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,7 @@ COPY --from=builder /usr/src/app ./ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ + node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ rm -rf /tmp/node-compile-cache diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 595d21561..943030943 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -35,8 +35,11 @@ COPY --from=builder /usr/src/app ./ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ + node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf /tmp/node-compile-cache + rm -rf \ + /tmp/node-compile-cache \ + ./bin/cleanupNodeModules.ts # Add application user RUN adduser -s /bin/false node; exit 0 diff --git a/bin/build-server.sh b/bin/build-server.sh index 26dc19ad3..6677d7c19 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -33,6 +33,7 @@ echo "Build start" npm run build:prepare-dist echo "Build finished" +# pruning of unnecessary files and devDeps in node_modules node --experimental-strip-types $CLEANUP_SCRIPT $BUILD_DIR NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index d811c95a1..bb3e90331 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -1,30 +1,43 @@ import fs from "fs-extra"; import path from "path"; +import type { Dirent } from "fs-extra"; +import { execSync } from "node:child_process"; /** * Example usage with node >= v22: - * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder + * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps] * Example usage with tsx: - * tsx bin/cleanupNodeModules.ts /path/to/build/folder + * tsx bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps] */ function main() { - if (process.argv.length !== 3) { - console.error("More than one path was supplied as argument. Aborting."); + + if (process.argv.length > 4 || process.argv.length < 3) { + console.error("Usage: cleanupNodeModules.ts [path-to-build-folder] [--skip-prune-dev-deps]"); process.exit(1); } const basePath = process.argv[2]; + const pruneDevDeps = process.argv[3] !== "--skip-prune-dev-deps"; if (!fs.existsSync(basePath)) { - console.error(`Supplied path '${basePath}' does not exist. Aborting.`) + console.error(`Supplied path '${basePath}' does not exist. Aborting.`); process.exit(1); } - console.log(`Starting node_modules pruning in '${basePath}'...`) - cleanupNodeModules(basePath); - console.log("Successfully pruned node_modules.") + + console.log(`Starting pruning of node_modules ${!pruneDevDeps ? '(skipping npm pruning)' : ''} in '${basePath}'...`); + cleanupNodeModules(basePath, pruneDevDeps); + console.log("Successfully pruned node_modules."); } -function cleanupNodeModules(basePath: string) { +function cleanupNodeModules(basePath: string, pruneDevDeps: boolean = true) { + + // This needs to run for the server and Docker build, + // but needs to be skipped for electron-forge: its + // built-in pruning takes care of it already + if (pruneDevDeps) { + execSync(`npm ci --omit=dev --prefix ${basePath}`); + } + const nodeModulesDirPath = path.join(basePath, "node_modules"); const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); @@ -82,6 +95,7 @@ function cleanupNodeModules(basePath: string) { .forEach(dir => removeDirent(dir)) } + function removeDirent(el: Dirent) { const elementToDelete = path.join(el.parentPath, el.name); fs.removeSync(elementToDelete); @@ -90,7 +104,6 @@ function removeDirent(el: Dirent) { console.log(`Deleted ${elementToDelete}`); } - } main() \ No newline at end of file diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index e04edee0c..404cf0991 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,6 +1,5 @@ import fs from "fs-extra"; import path from "path"; -import { execSync } from "node:child_process"; const DEST_DIR = "./build"; @@ -59,11 +58,6 @@ try { console.log("Copying complete!") - // TriliumNextTODO: for Docker this needs to run separately *after* build-stage - // Disable for now, because this messes with electron-forge as well - //console.log("Pruning npm packages...") - //execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); - } catch(err) { console.error("Error during copy:", err) process.exit(1) diff --git a/forge.config.cjs b/forge.config.cjs index 1a7e5a3c6..b94b2756e 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -47,7 +47,7 @@ module.exports = { try { const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead - const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}'`; + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}' --skip-prune-dev-deps`; // execSync throws, if above returns any non-zero exit code execSync(command); callback() From e9fa37c4eeecdc2fc6fb65d6fdd02774262300cc Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:04:10 +0100 Subject: [PATCH 24/47] chore(docker): remove TODO --- Dockerfile | 1 - Dockerfile.alpine | 1 - 2 files changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ee13f25d..abf8b0920 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,6 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache -#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 943030943..40b00c48f 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -18,7 +18,6 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache -#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways From d5bc9841e3e9bc76521221638dfa309f93b9ed7a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:05:17 +0100 Subject: [PATCH 25/47] build(docker): use absolute path to stay consistent --- Dockerfile.alpine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 40b00c48f..88a450723 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -36,9 +36,9 @@ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf \ + rm -rf \ /tmp/node-compile-cache \ - ./bin/cleanupNodeModules.ts + /usr/src/app/bin/cleanupNodeModules.ts # Add application user RUN adduser -s /bin/false node; exit 0 From fa0358662a39716eb69178602c1419bb018798d6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:06:09 +0100 Subject: [PATCH 26/47] build(docker): add missing cleanupNodeModules removal to Dockerfile previously forgot to add this here as well -> had it only in the Dockerfile.alpine --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index abf8b0920..635a44d3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,9 @@ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf /tmp/node-compile-cache + rm -rf \ + /tmp/node-compile-cache \ + /usr/src/app/bin/cleanupNodeModules.ts # Configure container EXPOSE 8080 From 6218ae6cd7a8919db248061a6ead505f2acd72b3 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:07:29 +0100 Subject: [PATCH 27/47] chore(docker): move exception below TODO comment --- .dockerignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 32795ae0a..1ca391a43 100644 --- a/.dockerignore +++ b/.dockerignore @@ -34,11 +34,11 @@ npm-debug.log # exceptions !/bin/copy-dist.ts -!/bin/electron-forge/sign-windows.cjs !/bin/cleanupNodeModules.ts # temporary exception to make copy-dist inside Docker build not fail -# TriliumNextTODO: make copy-dist *not* requiring to copy this file for builds other than electron-forge +# TriliumNextTODO: make copy-dist *not* requiring to copy these file for builds other than electron-forge !forge.config.cjs !/bin/tpl -!/bin/electron-forge/desktop.ejs \ No newline at end of file +!/bin/electron-forge/desktop.ejs +!/bin/electron-forge/sign-windows.cjs \ No newline at end of file From 9fe37465c73ef9675b3e3168f0e53d22116d2fb3 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:35:48 +0100 Subject: [PATCH 28/47] build(electron-forge): use double quotes for the buildPath in afterPrune attempt to fix failing Windows build in CI, which uses cmd shell, which apparently treats single apostrophes differently --- forge.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge.config.cjs b/forge.config.cjs index b94b2756e..8d5b5d22e 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -47,7 +47,7 @@ module.exports = { try { const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead - const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}' --skip-prune-dev-deps`; + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} "${buildPath}" --skip-prune-dev-deps`; // execSync throws, if above returns any non-zero exit code execSync(command); callback() From a7d6f1e4d1cd966b751e998c26c7d54483aeef1c Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 27 Mar 2025 12:50:39 +0100 Subject: [PATCH 29/47] README.md: TriliumDroid link, documentation update --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0170c8135..aed59f2a7 100644 --- a/README.md +++ b/README.md @@ -79,10 +79,11 @@ xattr -c "/path/to/Trilium Next.app" ### Mobile -To use TriliumNext on a mobile device: +To use TriliumNext on a mobile device, you can use a mobile web browser to access the mobile interface of a server installation (see below). -* Use a mobile web browser to access the mobile interface of a server installation (see below) -* Use of a mobile app is not yet supported ([see here](https://github.com/TriliumNext/Notes/issues/72)) to track mobile improvements. +If you prefer a native Android app, you can use [TriliumDroid](https://apt.izzysoft.de/fdroid/index/apk/eu.fliegendewurst.triliumdroid). Report bugs and missing features at [their repository](https://github.com/FliegendeWurst/TriliumDroid). + +See issue https://github.com/TriliumNext/Notes/issues/72 for more information on mobile app support. ### Server @@ -107,7 +108,7 @@ npm run server:start ### Documentation -Head on over to our [Docs repo](https://github.com/TriliumNext/Docs) +We are currently transitioning to a new documentation mechanism, please check back later. ## 👏 Shoutouts From 8c4e504cd4448d5c95e9b65c51613408d029ff34 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 27 Mar 2025 14:23:55 +0100 Subject: [PATCH 30/47] README.md: link to old docs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aed59f2a7..428e832fa 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,8 @@ npm run server:start ### Documentation -We are currently transitioning to a new documentation mechanism, please check back later. +We are currently transitioning to a new documentation mechanism. +Meanwhile you can still view the [archived Docs repository](https://github.com/TriliumNext/Docs). ## 👏 Shoutouts From 99bdf332365528ed13733fcccdb97778dadcc8d2 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 15:41:24 +0200 Subject: [PATCH 31/47] style(next): fix scrollbar appearance in code blocks --- src/public/stylesheets/theme-next/notes/text.css | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/public/stylesheets/theme-next/notes/text.css b/src/public/stylesheets/theme-next/notes/text.css index cf8aa4760..ac712c251 100644 --- a/src/public/stylesheets/theme-next/notes/text.css +++ b/src/public/stylesheets/theme-next/notes/text.css @@ -42,14 +42,9 @@ html .note-detail-editable-text :not(figure, .include-note, hr):first-child { overflow: auto; } -.ck-content pre code::-webkit-scrollbar { - height: 6px; -} - -.ck-content pre code::-webkit-scrollbar-thumb { - height: 4px; - border: none !important; - background: gray !important; +.ck-content pre code { + --scrollbar-thumb-color: gray; + --scrollbar-thumb-color-hover: gray; } .ck-content pre code::-webkit-scrollbar-track, From 4ab70fcb8add5672e8e9912926f2408b5559ae01 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 15:43:33 +0200 Subject: [PATCH 32/47] style(next): rename CSS variable --- src/public/stylesheets/theme-next-dark.css | 2 +- src/public/stylesheets/theme-next-light.css | 2 +- src/public/stylesheets/theme-next/forms.css | 4 ++-- src/public/stylesheets/theme-next/notes/text.css | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/public/stylesheets/theme-next-dark.css b/src/public/stylesheets/theme-next-dark.css index 84a0e0eb9..40740acd8 100644 --- a/src/public/stylesheets/theme-next-dark.css +++ b/src/public/stylesheets/theme-next-dark.css @@ -191,7 +191,7 @@ --right-pane-item-hover-color: white; --scrollbar-thumb-color: #fdfdfd5c; - --scrollbar-thumb-color-hover: #ffffff7d; + --scrollbar-thumb-hover-color: #ffffff7d; --scrollbar-border-color: unset; /* Deprecated */ --scrollbar-background-color: unset; /* Deprecated */ diff --git a/src/public/stylesheets/theme-next-light.css b/src/public/stylesheets/theme-next-light.css index 781a34a2b..3bfe849ee 100644 --- a/src/public/stylesheets/theme-next-light.css +++ b/src/public/stylesheets/theme-next-light.css @@ -190,7 +190,7 @@ --right-pane-item-hover-color: inherit; --scrollbar-thumb-color: #0000005c; - --scrollbar-thumb-color-hover: #00000066; + --scrollbar-thumb-hover-color: #00000066; --scrollbar-border-color: unset; /* Deprecated */ --scrollbar-background-color: unset; /* Deprecated */ diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index 1c3945154..09dc1408c 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -707,7 +707,7 @@ input[type="range"] { ::-webkit-scrollbar-thumb:hover { --s-thumb-thickness: var(--scrollbar-thumb-hover-thickness); - --s-thumb-color: var(--scrollbar-thumb-color-hover); + --s-thumb-color: var(--scrollbar-thumb-hover-color); } /* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap) */ @@ -724,7 +724,7 @@ input[type="range"] { * Firefox scrollbars * * Unsupported features: --scrollbar-thumb-thickness, --scrollbar-thumb-hover-thickness, - * --scrollbar-start-end-gap, --scrollbar-thumb-color-hover. + * --scrollbar-start-end-gap, --scrollbar-thumb-hover-color. */ :root { diff --git a/src/public/stylesheets/theme-next/notes/text.css b/src/public/stylesheets/theme-next/notes/text.css index ac712c251..9d1c20e88 100644 --- a/src/public/stylesheets/theme-next/notes/text.css +++ b/src/public/stylesheets/theme-next/notes/text.css @@ -44,7 +44,7 @@ html .note-detail-editable-text :not(figure, .include-note, hr):first-child { .ck-content pre code { --scrollbar-thumb-color: gray; - --scrollbar-thumb-color-hover: gray; + --scrollbar-thumb-hover-color: gray; } .ck-content pre code::-webkit-scrollbar-track, From 10ea58a3686a97eccde50a9ff40bed631e6e6217 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:06:53 +0200 Subject: [PATCH 33/47] style(next)/scrollbars: restore the support for custom background color --- src/public/stylesheets/theme-next-dark.css | 2 +- src/public/stylesheets/theme-next-light.css | 2 +- src/public/stylesheets/theme-next/forms.css | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next-dark.css b/src/public/stylesheets/theme-next-dark.css index 40740acd8..2dbeb525c 100644 --- a/src/public/stylesheets/theme-next-dark.css +++ b/src/public/stylesheets/theme-next-dark.css @@ -192,8 +192,8 @@ --scrollbar-thumb-color: #fdfdfd5c; --scrollbar-thumb-hover-color: #ffffff7d; + --scrollbar-background-color: transparent; --scrollbar-border-color: unset; /* Deprecated */ - --scrollbar-background-color: unset; /* Deprecated */ --link-color: lightskyblue; diff --git a/src/public/stylesheets/theme-next-light.css b/src/public/stylesheets/theme-next-light.css index 3bfe849ee..46c116e39 100644 --- a/src/public/stylesheets/theme-next-light.css +++ b/src/public/stylesheets/theme-next-light.css @@ -191,8 +191,8 @@ --scrollbar-thumb-color: #0000005c; --scrollbar-thumb-hover-color: #00000066; + --scrollbar-background-color: transparent; --scrollbar-border-color: unset; /* Deprecated */ - --scrollbar-background-color: unset; /* Deprecated */ --link-color: blue; diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index 09dc1408c..ce6663380 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -674,6 +674,10 @@ input[type="range"] { /* Scrollbar's body */ +::-webkit-scrollbar-track { + background-color: var(--scrollbar-background-color); +} + ::-webkit-scrollbar:vertical { width: var(--scrollbar-thickness) !important; } From 25d83752e54cad5171fad50eb8688c500c927420 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:08:34 +0200 Subject: [PATCH 34/47] style(next): refactor --- src/public/stylesheets/theme-next/base.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next/base.css b/src/public/stylesheets/theme-next/base.css index 888b83ca9..aced7ab5d 100644 --- a/src/public/stylesheets/theme-next/base.css +++ b/src/public/stylesheets/theme-next/base.css @@ -95,8 +95,8 @@ font-size: 0.9rem !important; } -.dropdown-menu::-webkit-scrollbar-track { - background: var(--menu-background-color); +.dropdown-menu { + --scrollbar-background-color: var(--menu-background-color); } body.mobile .dropdown-menu { From 66cebf4ebfc8f6b7945b167ac1d0bec274f2c2b9 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:12:51 +0200 Subject: [PATCH 35/47] style(next)/scrollbars: add a remark --- src/public/stylesheets/theme-next/forms.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index ce6663380..30e8eec22 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -714,7 +714,9 @@ input[type="range"] { --s-thumb-color: var(--scrollbar-thumb-hover-color); } -/* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap) */ +/* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap). + * This gap is useful also to avoid breaking the rounded corners of a container when a + * custom scrollbar background color is used. */ ::-webkit-scrollbar-button:vertical { height: var(--scrollbar-start-end-gap); From b9c4d8322360f7260fa68eb0700925a54090dd9b Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:26:21 +0200 Subject: [PATCH 36/47] style(next): improve the window dragging functionality for the horizontal toolbar layout --- src/public/stylesheets/theme-next/shell.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 11958d494..446b5466c 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -895,6 +895,11 @@ body.layout-vertical.electron.platform-darwin .tab-row-container { body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); + -webkit-app-region: drag; +} + +body.layout-horizontal .tab-row-container > * { + -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } body.layout-horizontal .tab-row-widget-container { From b6565c3b13711422b96e86781ef471bc74c9cab9 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:40:49 +0200 Subject: [PATCH 37/47] style(next): improve the window dragging functionality also for the vertical toolbar layout --- src/public/stylesheets/theme-next/shell.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 446b5466c..85b15557c 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -895,13 +895,20 @@ body.layout-vertical.electron.platform-darwin .tab-row-container { body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); +} + +body.layout-horizontal .tab-row-container, +body.layout-vertical .tab-row-widget { -webkit-app-region: drag; } -body.layout-horizontal .tab-row-container > * { +body.layout-horizontal .tab-row-container > *, +body.layout-vertical .tab-row-widget > * { -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } + + body.layout-horizontal .tab-row-widget-container { margin-top: 0; position: relative; From 63efa8ffe48fac8b994218ca355f13ab589309d8 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:46:03 +0200 Subject: [PATCH 38/47] style(next): improve the window dragging functionality for the vertical toolbar layout --- src/public/stylesheets/theme-next/shell.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 85b15557c..dbb0fd354 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -898,12 +898,14 @@ body.layout-horizontal .tab-row-container { } body.layout-horizontal .tab-row-container, -body.layout-vertical .tab-row-widget { +body.layout-vertical .tab-row-widget, +body.layout-vertical #left-pane .quick-search { -webkit-app-region: drag; } body.layout-horizontal .tab-row-container > *, -body.layout-vertical .tab-row-widget > * { +body.layout-vertical .tab-row-widget > *, +body.layout-vertical #left-pane .quick-search > * { -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } From 04a41ca5f492809b78feb9ffe43660579b4af734 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:50:26 +0200 Subject: [PATCH 39/47] style(next): add some remarks --- src/public/stylesheets/theme-next/shell.css | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index dbb0fd354..3183f3ea3 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -897,20 +897,21 @@ body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); } +/* Define extra drag areas for Electron windows */ body.layout-horizontal .tab-row-container, body.layout-vertical .tab-row-widget, body.layout-vertical #left-pane .quick-search { -webkit-app-region: drag; } +/* Limit the drag area for the previous elements to include just to the element itself + and not its descendants also */ body.layout-horizontal .tab-row-container > *, body.layout-vertical .tab-row-widget > *, body.layout-vertical #left-pane .quick-search > * { - -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ + -webkit-app-region: no-drag; } - - body.layout-horizontal .tab-row-widget-container { margin-top: 0; position: relative; From cbf3ee9f6e957086134a464eeed46a3809f19058 Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 27 Mar 2025 19:03:44 +0200 Subject: [PATCH 40/47] fix(ci): bring back ref name in artifact (fixes #1532) --- .github/actions/build-electron/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-electron/action.yml b/.github/actions/build-electron/action.yml index 6c1b6d819..ccd7f93ff 100644 --- a/.github/actions/build-electron/action.yml +++ b/.github/actions/build-electron/action.yml @@ -81,7 +81,7 @@ runs: APPLE_ID: ${{ env.APPLE_ID }} APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }} WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }} - TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes ${{ inputs.os }} ${{ inputs.arch }} + TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }} run: | npm run electron-forge:make -- \ --arch=${{ inputs.arch }} \ From 1b6ab7e7f29a3bc88aff256148ee6d1596264221 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 27 Mar 2025 19:36:45 +0200 Subject: [PATCH 41/47] fix(dropdowns): overlap with quick search results --- src/public/stylesheets/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 1cfcd6c90..c6ae45c3a 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -307,6 +307,7 @@ button kbd { background-color: var(--menu-background-color) !important; user-select: none; -webkit-user-select: none; + --bs-dropdown-zindex: 999; } body.desktop .dropdown-menu { From 91242b6cab9d0b3c90e052054978bfca3accfdf6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 27 Mar 2025 19:55:06 +0200 Subject: [PATCH 42/47] fix(next): regression in mica dark --- src/public/stylesheets/theme-next/shell.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 3183f3ea3..5552e482d 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -46,7 +46,7 @@ body.background-effects.platform-win32 { } @media (prefers-color-scheme: dark) { - body.background-effects.platform-win32 #launcher-pane { + body.background-effects.platform-win32 { --launcher-pane-horiz-border-color: rgba(0, 0, 0, 0.5); --launcher-pane-horiz-background-color: rgba(255, 255, 255, 0.09); } From 6336699618fa99a19ff9117094bd74bd71d6e56a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:06:35 +0100 Subject: [PATCH 43/47] build(server): improve "node" folder cleanup * remove useless symlinks to non-existing files (npm, npx -> the actual file gets deleted by "rm -r $BUILD_DIR/node/lib/node_modules/npm" => fixes #1499 (this time fully ;-)) * remove unused corepack * remove useless CHANGELOG.md (LICENSE and README.md should of course still remain) --- bin/build-server.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 6677d7c19..e89c72d5a 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -45,7 +45,9 @@ mv $NODE_FILENAME node cd .. -rm -r $BUILD_DIR/node/lib/node_modules/npm \ +rm -r $BUILD_DIR/node/lib/node_modules/{npm,corepack} \ + $BUILD_DIR/node/bin/{npm,npx,corepack} \ + $BUILD_DIR/node/CHANGELOG.md \ $BUILD_DIR/node/include/node \ $BUILD_DIR/node_modules/electron* \ $BUILD_DIR/electron*.{js,map} From 1c04aa99634d11d2e6dfffcaf55fc5a39ee2b6a6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 2 Mar 2025 23:00:15 +0100 Subject: [PATCH 44/47] chore: add dprint config add initial dprint configuration, settings partially taken from the prettier config, still might need some finetuning --- .dprint.json | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .dprint.json diff --git a/.dprint.json b/.dprint.json new file mode 100644 index 000000000..21e6f8585 --- /dev/null +++ b/.dprint.json @@ -0,0 +1,44 @@ +{ + "typescript": { + "indentWidth": 4, + "quoteStyle": "preferDouble", + "semiColons": "prefer", + "quoteProps": "asNeeded", + "newLineKind": "lf", + "lineWidth": 200, + "trailingCommas": "never", + "arrayPattern.spaceAround": true, + "arrayExpression.spaceAround": true + }, + "json": { + }, + "markdown": { + }, + "dockerfile": { + }, + "malva": { + }, + "markup": { + }, + "yaml": { + }, + "excludes": [ + "**/node_modules", + "**/*-lock.json", + "*.html", + "*.md", + "*.yml", + "libraries/*", + "docs/*", + "src/public/app/doc_notes" + ], + "plugins": [ + "https://plugins.dprint.dev/typescript-0.94.0.wasm", + "https://plugins.dprint.dev/json-0.20.0.wasm", + "https://plugins.dprint.dev/markdown-0.18.0.wasm", + "https://plugins.dprint.dev/dockerfile-0.3.2.wasm", + "https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm", + "https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" + ] +} From f965be9f8f77a38fb32eca7a17f4b1c8782500e1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:24:51 +0100 Subject: [PATCH 45/47] deps: add dprint as devDep --- package-lock.json | 163 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 1 + 2 files changed, 150 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index b8c7e54aa..b68b7c5d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -164,6 +164,7 @@ "bootstrap": "5.3.3", "cross-env": "7.0.3", "css-loader": "7.1.2", + "dprint": "0.49.1", "electron": "35.0.3", "eslint": "9.23.0", "esm": "3.2.25", @@ -175,7 +176,6 @@ "lorem-ipsum": "2.0.8", "mind-elixir": "4.4.3", "mini-css-extract-plugin": "2.9.2", - "node-abi": "4.2.0", "nodemon": "3.1.9", "postcss-loader": "8.1.1", "prettier": "3.5.3", @@ -568,6 +568,132 @@ "node": ">=14.17.0" } }, + "node_modules/@dprint/darwin-arm64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/darwin-arm64/-/darwin-arm64-0.49.1.tgz", + "integrity": "sha512-ib6KcJWo/M5RJWXOQKhP664FG1hAvG7nrbkh+j8n+oXdzmbyDdXTP+zW+aM3/sIQUkGaZky1xy1j2VeScMEEHQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@dprint/darwin-x64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/darwin-x64/-/darwin-x64-0.49.1.tgz", + "integrity": "sha512-vIVgnYxV7YYa1d6Uyz707RbgB9rwefGPam+rzaueFNPQjdOxPOTQDuMEJDS+Z3BlI00MfeoupIfIUGsXoM4dpQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@dprint/linux-arm64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-glibc/-/linux-arm64-glibc-0.49.1.tgz", + "integrity": "sha512-ZeIh6qMPWLBBifDtU0XadpK36b4WoaTqCOt0rWKfoTjq1RAt78EgqETWp43Dbr6et/HvTgYdoWF0ZNEu2FJFFA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-arm64-musl": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-musl/-/linux-arm64-musl-0.49.1.tgz", + "integrity": "sha512-/nuRyx+TykN6MqhlSCRs/t3o1XXlikiwTc9emWdzMeLGllYvJrcht9gRJ1/q1SqwCFhzgnD9H7roxxfji1tc+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-riscv64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-riscv64-glibc/-/linux-riscv64-glibc-0.49.1.tgz", + "integrity": "sha512-RHBqrnvGO+xW4Oh0QuToBqWtkXMcfjqa1TqbBFF03yopFzZA2oRKX83PhjTWgd/IglaOns0BgmaLJy/JBSxOfQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-x64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-glibc/-/linux-x64-glibc-0.49.1.tgz", + "integrity": "sha512-MjFE894mIQXOKBencuakKyzAI4KcDe/p0Y9lRp9YSw/FneR4QWH9VBH90h8fRxcIlWMArjFFJJAtsBnn5qgxeg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-x64-musl": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-musl/-/linux-x64-musl-0.49.1.tgz", + "integrity": "sha512-CvGBWOksHgrL1uzYqtPFvZz0+E82BzgoCIEHJeuYaveEn37qWZS5jqoCm/vz6BfoivE1dVuyyOT78Begj9KxkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/win32-arm64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/win32-arm64/-/win32-arm64-0.49.1.tgz", + "integrity": "sha512-gQa4s82lMcXjfdxjWBQun6IJlXdPZZaIj2/2cqXWVEOYPKxAZ/JvGzt2pPG+i73h9KHjNLIV8M9ckqEH3oHufg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@dprint/win32-x64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/win32-x64/-/win32-x64-0.49.1.tgz", + "integrity": "sha512-nPU6+hoVze5JJlgET7woYWElBw0IUaB/9XKTaglknQuUUfsmD75D9pkgJTxdIxl9Bg/i5O7c9wb3Nj4XNiTIfw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@electron-forge/cli": { "version": "7.8.0", "resolved": "https://registry.npmjs.org/@electron-forge/cli/-/cli-7.8.0.tgz", @@ -10087,6 +10213,28 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dprint": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/dprint/-/dprint-0.49.1.tgz", + "integrity": "sha512-pO9XH79SyXybj2Vhc9ITZMEI8cJkdlQQRoD8oEfPH6Jjpp/7WX5kIgECVd3DBOjjAdCSiW6R47v3gJBx/qZVkw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "dprint": "bin.js" + }, + "optionalDependencies": { + "@dprint/darwin-arm64": "0.49.1", + "@dprint/darwin-x64": "0.49.1", + "@dprint/linux-arm64-glibc": "0.49.1", + "@dprint/linux-arm64-musl": "0.49.1", + "@dprint/linux-riscv64-glibc": "0.49.1", + "@dprint/linux-x64-glibc": "0.49.1", + "@dprint/linux-x64-musl": "0.49.1", + "@dprint/win32-arm64": "0.49.1", + "@dprint/win32-x64": "0.49.1" + } + }, "node_modules/draggabilly": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/draggabilly/-/draggabilly-3.0.0.tgz", @@ -15977,19 +16125,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-abi": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.2.0.tgz", - "integrity": "sha512-admQxilhDcmFJbUl4LQzGu+QyEijW9rctKRH2P7LNavAvln1bdK9OcujM3yi2KysKI41dxTrDtp6QfGEZeCbkg==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.6.3" - }, - "engines": { - "node": ">=22.12.0" - } - }, "node_modules/node-addon-api": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", diff --git a/package.json b/package.json index 57141ffa8..55ea7a87d 100644 --- a/package.json +++ b/package.json @@ -220,6 +220,7 @@ "bootstrap": "5.3.3", "cross-env": "7.0.3", "css-loader": "7.1.2", + "dprint": "0.49.1", "electron": "35.0.3", "eslint": "9.23.0", "esm": "3.2.25", From cdc6ce2118ffd72b0aeef35144159c93d6cd9bcb Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:26:39 +0100 Subject: [PATCH 46/47] chore: remove prettier replaced by dprint due to its configurability --- .prettierignore | 6 ------ .prettierrc | 22 ---------------------- package-lock.json | 17 ----------------- package.json | 1 - 4 files changed, 46 deletions(-) delete mode 100644 .prettierignore delete mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 5e1d8fad5..000000000 --- a/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -*.html -*.md -*.yml -libraries/* -docs/* -src/public/app/doc_notes/**/* \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 036c81de1..000000000 --- a/.prettierrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "printWidth": 200, - "tabWidth": 4, - "useTabs": false, - "semi": true, - "singleQuote": false, - "quoteProps": "as-needed", - "trailingComma": "none", - "bracketSpacing": true, - "arrowParens": "always", - "proseWrap": "preserve", - "htmlWhitespaceSensitivity": "css", - "endOfLine": "lf", - "overrides": [ - { - "files": ["*.json"], - "options": { - "tabWidth": 2 - } - } - ] -} diff --git a/package-lock.json b/package-lock.json index b68b7c5d6..1d6021055 100644 --- a/package-lock.json +++ b/package-lock.json @@ -178,7 +178,6 @@ "mini-css-extract-plugin": "2.9.2", "nodemon": "3.1.9", "postcss-loader": "8.1.1", - "prettier": "3.5.3", "rcedit": "4.0.1", "rimraf": "6.0.1", "sass": "1.86.0", @@ -17535,22 +17534,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prettier": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", - "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/proc-log": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz", diff --git a/package.json b/package.json index 55ea7a87d..7a31dbe84 100644 --- a/package.json +++ b/package.json @@ -234,7 +234,6 @@ "mini-css-extract-plugin": "2.9.2", "nodemon": "3.1.9", "postcss-loader": "8.1.1", - "prettier": "3.5.3", "rcedit": "4.0.1", "rimraf": "6.0.1", "sass": "1.86.0", From e95172e2db4f9366514d69513730a646ed782f88 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:29:18 +0100 Subject: [PATCH 47/47] build(scripts): replace prettier with dprint also renaming the script from "dev:prettier" to a more "generic" term "dev:format" --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a31dbe84..7ef7a8055 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "test:integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "test:integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "dev:watch-dist": "tsx ./bin/watch-dist.ts", - "dev:prettier-check": "prettier . --check", - "dev:prettier-fix": "prettier . --write", + "dev:format-check": "dprint check", + "dev:format-fix": "dprint fmt", "dev:linter-check": "eslint .", "dev:linter-fix": "eslint . --fix", "chore:update-build-info": "tsx bin/update-build-info.ts",