Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 4859de4

Browse files
authored
Merge branch 'develop' into renovate/apple-actions-import-codesign-certs-5.x
2 parents 6b12374 + 4ac52e1 commit 4859de4

37 files changed

+724
-283
lines changed

.dockerignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ npm-debug.log
3434

3535
# exceptions
3636
!/bin/copy-dist.ts
37-
!/bin/electron-forge/sign-windows.cjs
37+
!/bin/cleanupNodeModules.ts
3838

3939
# temporary exception to make copy-dist inside Docker build not fail
40-
# TriliumNextTODO: make copy-dist *not* requiring to copy this file for builds other than electron-forge
40+
# TriliumNextTODO: make copy-dist *not* requiring to copy these file for builds other than electron-forge
4141
!forge.config.cjs
4242
!/bin/tpl
43-
!/bin/electron-forge/desktop.ejs
43+
!/bin/electron-forge/desktop.ejs
44+
!/bin/electron-forge/sign-windows.cjs

.dprint.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"typescript": {
3+
"indentWidth": 4,
4+
"quoteStyle": "preferDouble",
5+
"semiColons": "prefer",
6+
"quoteProps": "asNeeded",
7+
"newLineKind": "lf",
8+
"lineWidth": 200,
9+
"trailingCommas": "never",
10+
"arrayPattern.spaceAround": true,
11+
"arrayExpression.spaceAround": true
12+
},
13+
"json": {
14+
},
15+
"markdown": {
16+
},
17+
"dockerfile": {
18+
},
19+
"malva": {
20+
},
21+
"markup": {
22+
},
23+
"yaml": {
24+
},
25+
"excludes": [
26+
"**/node_modules",
27+
"**/*-lock.json",
28+
"*.html",
29+
"*.md",
30+
"*.yml",
31+
"libraries/*",
32+
"docs/*",
33+
"src/public/app/doc_notes"
34+
],
35+
"plugins": [
36+
"https://plugins.dprint.dev/typescript-0.94.0.wasm",
37+
"https://plugins.dprint.dev/json-0.20.0.wasm",
38+
"https://plugins.dprint.dev/markdown-0.18.0.wasm",
39+
"https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
40+
"https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm",
41+
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm",
42+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm"
43+
]
44+
}

.github/actions/build-electron/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ runs:
8181
APPLE_ID: ${{ env.APPLE_ID }}
8282
APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }}
8383
WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }}
84-
TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes ${{ inputs.os }} ${{ inputs.arch }}
84+
TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
8585
run: |
8686
npm run electron-forge:make -- \
8787
--arch=${{ inputs.arch }} \

.prettierignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ COPY --from=builder /usr/src/app ./
3939

4040
RUN sed -i "/electron/d" package.json && \
4141
npm ci --omit=dev && \
42+
node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \
4243
npm cache clean --force && \
43-
rm -rf /tmp/node-compile-cache
44+
rm -rf \
45+
/tmp/node-compile-cache \
46+
/usr/src/app/bin/cleanupNodeModules.ts
4447

4548
# Configure container
4649
EXPOSE 8080

Dockerfile.alpine

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ COPY --from=builder /usr/src/app ./
3434

3535
RUN sed -i "/electron/d" package.json && \
3636
npm ci --omit=dev && \
37+
node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \
3738
npm cache clean --force && \
38-
rm -rf /tmp/node-compile-cache
39+
rm -rf \
40+
/tmp/node-compile-cache \
41+
/usr/src/app/bin/cleanupNodeModules.ts
3942

4043
# Add application user
4144
RUN adduser -s /bin/false node; exit 0

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ xattr -c "/path/to/Trilium Next.app"
7979

8080
### Mobile
8181

82-
To use TriliumNext on a mobile device:
82+
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).
8383

84-
* Use a mobile web browser to access the mobile interface of a server installation (see below)
85-
* Use of a mobile app is not yet supported ([see here](https://github.com/TriliumNext/Notes/issues/72)) to track mobile improvements.
84+
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).
85+
86+
See issue https://github.com/TriliumNext/Notes/issues/72 for more information on mobile app support.
8687

8788
### Server
8889

@@ -107,7 +108,8 @@ npm run server:start
107108

108109
### Documentation
109110

110-
Head on over to our [Docs repo](https://github.com/TriliumNext/Docs)
111+
We are currently transitioning to a new documentation mechanism.
112+
Meanwhile you can still view the [archived Docs repository](https://github.com/TriliumNext/Docs).
111113

112114
## 👏 Shoutouts
113115

bin/build-server.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ NODE_VERSION=22.14.0
2525

2626
BUILD_DIR="./build"
2727
DIST_DIR="./dist"
28+
CLEANUP_SCRIPT="./bin/cleanupNodeModules.ts"
2829

29-
./bin/copy-trilium.sh
30+
31+
# Trigger the build
32+
echo "Build start"
33+
npm run build:prepare-dist
34+
echo "Build finished"
35+
36+
# pruning of unnecessary files and devDeps in node_modules
37+
node --experimental-strip-types $CLEANUP_SCRIPT $BUILD_DIR
3038

3139
NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH}
3240

@@ -37,7 +45,9 @@ mv $NODE_FILENAME node
3745
cd ..
3846

3947

40-
rm -r $BUILD_DIR/node/lib/node_modules/npm \
48+
rm -r $BUILD_DIR/node/lib/node_modules/{npm,corepack} \
49+
$BUILD_DIR/node/bin/{npm,npx,corepack} \
50+
$BUILD_DIR/node/CHANGELOG.md \
4151
$BUILD_DIR/node/include/node \
4252
$BUILD_DIR/node_modules/electron* \
4353
$BUILD_DIR/electron*.{js,map}

bin/cleanupNodeModules.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import fs from "fs-extra";
2+
import path from "path";
3+
import type { Dirent } from "fs-extra";
4+
import { execSync } from "node:child_process";
5+
6+
/**
7+
* Example usage with node >= v22:
8+
* node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps]
9+
* Example usage with tsx:
10+
* tsx bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps]
11+
*/
12+
function main() {
13+
14+
if (process.argv.length > 4 || process.argv.length < 3) {
15+
console.error("Usage: cleanupNodeModules.ts [path-to-build-folder] [--skip-prune-dev-deps]");
16+
process.exit(1);
17+
}
18+
19+
const basePath = process.argv[2];
20+
const pruneDevDeps = process.argv[3] !== "--skip-prune-dev-deps";
21+
22+
if (!fs.existsSync(basePath)) {
23+
console.error(`Supplied path '${basePath}' does not exist. Aborting.`);
24+
process.exit(1);
25+
}
26+
27+
console.log(`Starting pruning of node_modules ${!pruneDevDeps ? '(skipping npm pruning)' : ''} in '${basePath}'...`);
28+
cleanupNodeModules(basePath, pruneDevDeps);
29+
console.log("Successfully pruned node_modules.");
30+
}
31+
32+
function cleanupNodeModules(basePath: string, pruneDevDeps: boolean = true) {
33+
34+
// This needs to run for the server and Docker build,
35+
// but needs to be skipped for electron-forge: its
36+
// built-in pruning takes care of it already
37+
if (pruneDevDeps) {
38+
execSync(`npm ci --omit=dev --prefix ${basePath}`);
39+
}
40+
41+
const nodeModulesDirPath = path.join(basePath, "node_modules");
42+
const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true });
43+
//const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true });
44+
45+
/**
46+
* Delete unnecessary folders
47+
*/
48+
const filterableDirs = new Set([
49+
"demo",
50+
"demos",
51+
"doc",
52+
"docs",
53+
"example",
54+
"examples",
55+
"test",
56+
"tests"
57+
]);
58+
59+
nodeModulesContent
60+
.filter(el => el.isDirectory() && filterableDirs.has(el.name))
61+
.forEach(dir => removeDirent(dir));
62+
63+
/**
64+
* Delete unnecessary files based on file extension
65+
* TODO filter out useless (README).md files
66+
*/
67+
const filterableFileExt = new Set([
68+
"ts",
69+
"map"
70+
]);
71+
72+
nodeModulesContent
73+
// TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency
74+
.filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || ""))
75+
.forEach(dir => removeDirent(dir));
76+
77+
78+
/**
79+
* Delete specific unnecessary folders
80+
* TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail
81+
*/
82+
const extraFoldersDelete = new Set([
83+
path.join(nodeModulesDirPath, ".bin"),
84+
path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"),
85+
path.join(nodeModulesDirPath, "boxicons", "svg"),
86+
path.join(nodeModulesDirPath, "boxicons", "node_modules"),
87+
path.join(nodeModulesDirPath, "boxicons", "src"),
88+
path.join(nodeModulesDirPath, "boxicons", "iconjar"),
89+
path.join(nodeModulesDirPath, "@jimp", "plugin-print", "fonts"),
90+
path.join(nodeModulesDirPath, "jimp", "dist", "browser") // missing "@" in front of jimp is not a typo here
91+
]);
92+
93+
nodeModulesContent
94+
.filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name)))
95+
.forEach(dir => removeDirent(dir))
96+
}
97+
98+
99+
function removeDirent(el: Dirent) {
100+
const elementToDelete = path.join(el.parentPath, el.name);
101+
fs.removeSync(elementToDelete);
102+
103+
if (process.env.VERBOSE) {
104+
console.log(`Deleted ${elementToDelete}`);
105+
}
106+
107+
}
108+
109+
main()

0 commit comments

Comments
 (0)