diff --git a/.dockerignore b/.dockerignore index 6c3840719..64bcb6983 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,6 @@ /docs /npm-debug.log node_modules + +src/**/*.ts +!src/services/asset_path.ts \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 000000000..392046d2c --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,25 @@ +name: Dev +on: + push: +jobs: + build_docker: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - name: Run the TypeScript build + run: npx tsc + - name: Create server-package.json + run: cat package.json | grep -v electron > server-package.json + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v6 + with: + context: . + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..be9306a02 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,147 @@ +name: Main +on: + push: + branches: + - 'develop' +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build_darwin-x64: + name: Build macOS x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-mac-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-mac-x64.zip + path: dist/trilium-mac-x64*.zip + build_darwin-arm64: + name: Build macOS aarch64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-mac-arm64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-mac-arm64.zip + path: dist/trilium-mac-arm64*.zip + build_linux-x64: + name: Build Linux x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-linux-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-linux-x64.tar.xz + path: dist/trilium-linux-x64-*.tar.xz + - uses: actions/upload-artifact@v4 + with: + name: trilium_amd64.deb + path: dist/trilium_*.deb + build_linux_server-x64: + name: Build Linux Server x86_64 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-server.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-linux-x64-server.tar.xz + path: dist/trilium-linux-x64-server-*.tar.xz + build_windows-x64: + name: Build Windows x86_64 + runs-on: ubuntu-latest + steps: + - name: Set up Wine + run: | + sudo dpkg --add-architecture i386 + wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - + sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport + sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main" + sudo apt install --install-recommends winehq-stable + - uses: actions/checkout@v4 + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - run: ./bin/build-win-x64.sh + - uses: actions/upload-artifact@v4 + with: + name: trilium-windows-x64.zip + path: dist/trilium-windows-x64-*.zip + build_docker: + name: Build Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Set up node & dependencies + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "npm" + - run: npm ci + - name: Run the TypeScript build + run: npx tsc + - name: Create server-package.json + run: cat package.json | grep -v electron > server-package.json + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v6 + id: push + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows_old/codeql-analysis.yml similarity index 100% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows_old/codeql-analysis.yml diff --git a/.github/workflows/docker.yaml b/.github/workflows_old/docker.yaml similarity index 100% rename from .github/workflows/docker.yaml rename to .github/workflows_old/docker.yaml diff --git a/.gitignore b/.gitignore index 0e095b075..2a427512e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store node_modules/ dist/ +build/ src/public/app-dist/ npm-debug.log yarn-error.log diff --git a/.vscode/settings.json b/.vscode/settings.json index 5e8ceecbf..1415c74fa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "editor.formatOnSave": true, + "editor.formatOnSave": false, "editor.defaultFormatter": "esbenp.prettier-vscode", "files.eol": "\n", "typescript.tsdk": "node_modules/typescript/lib" diff --git a/Dockerfile b/Dockerfile index d8cb9b0c3..78f058529 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,18 @@ # !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!! FROM node:18.18.2-alpine +# Configure system dependencies +RUN apk add --no-cache --virtual .build-dependencies \ + autoconf \ + automake \ + g++ \ + gcc \ + libtool \ + make \ + nasm \ + libpng-dev \ + python3 + # Create app directory WORKDIR /usr/src/app @@ -9,25 +21,21 @@ COPY . . COPY server-package.json package.json +# Copy TypeScript build artifacts into the original directory structure. +RUN ls +RUN cp -R build/src/* src/. +RUN rm -r build + # Install app dependencies RUN set -x \ - && apk add --no-cache --virtual .build-dependencies \ - autoconf \ - automake \ - g++ \ - gcc \ - libtool \ - make \ - nasm \ - libpng-dev \ - python3 \ && npm install \ && apk del .build-dependencies \ && npm run webpack \ && npm prune --omit=dev \ && cp src/public/app/share.js src/public/app-dist/. \ && cp -r src/public/app/doc_notes src/public/app-dist/. \ - && rm -rf src/public/app + && rm -rf src/public/app \ + && rm src/services/asset_path.ts # Some setup tools need to be kept RUN apk add --no-cache su-exec shadow diff --git a/README.md b/README.md index ffe231991..374197c3c 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,95 @@ -# Trilium Notes +# TriliumNext Notes -## Trilium is in maintenance mode - see details in https://github.com/zadam/trilium/issues/4620 +[English](https://github.com/TriliumNext/Notes/blob/master/README.md) | [Chinese](https://github.com/TriliumNext/Notes/blob/master/README-ZH_CN.md) | [Russian](https://github.com/TriliumNext/Notes/blob/master/README.ru.md) | [Japanese](https://github.com/TriliumNext/Notes/blob/master/README.ja.md) | [Italian](https://github.com/TriliumNext/Notes/blob/master/README.it.md) -Preliminary disccusions on the successor organization are taking place in [Trilium Next discussions](https://github.com/orgs/TriliumNext/discussions). +TriliumNext Notes is a hierarchical note taking application with focus on building large personal knowledge bases. -[English](https://github.com/zadam/trilium/blob/master/README.md) | [Chinese](https://github.com/zadam/trilium/blob/master/README-ZH_CN.md) | [Russian](https://github.com/zadam/trilium/blob/master/README.ru.md) | [Japanese](https://github.com/zadam/trilium/blob/master/README.ja.md) | [Italian](https://github.com/zadam/trilium/blob/master/README.it.md) +See [screenshots](https://triliumnext.github.io/Docs/Wiki/Screenshot%20tour) for quick overview: +Trilium Screenshot -Trilium Notes is a hierarchical note taking application with focus on building large personal knowledge bases. +## ⚠️ Why TriliumNext? -## Discuss with us +[The original Trilium project is in maintenance mode](https://github.com/zadam/trilium/issues/4620) -Feel free to join our discussions. +## 🗭 Discuss with us -- [XMPP](https://joinjabber.org/): [xmpp:discuss@trilium.thisgreat.party?join](xmpp:discuss@trilium.thisgreat.party?join) ([web link](https://anonymous.cheogram.com/discuss@trilium.thisgreat.party)) -- [Matrix](https://matrix.org/try-matrix/): #trilium:matrix.org ([web link](https://app.element.io/#/room/#trilium:matrix.org)) +Feel free to join our official discussions and community. We are focused on the development on Trilium, and would love to hear what features, suggestions, or issues you may have! -The two rooms are mirrored, so you can use the protocol of your choice, from the client you prefer, on pretty much any platform under the sun! +- [Matrix](https://matrix.to/#/#triliumnext:matrix.org) (For synchronous discussions) +- [Github Discussions](https://github.com/TriliumNext/Notes/discussions) (For Asynchronous discussions) +- [Wiki](https://github.com/zadam/trilium/wiki) (For common how-to questions and user guides) -See [screenshots](https://github.com/zadam/trilium/wiki/Screenshot-tour) for quick overview: +The two rooms linked above are mirrored, so you can use either XMPP or Matrix, from any client you prefer, on pretty much any platform under the sun! -Trilium Screenshot +### Unofficial Communities -Ukraine is currently defending itself from Russian aggression, please consider [donating to Ukrainian Army or humanitarian charities](https://standforukraine.com/). - -

- drawing - Trilium Notes supports Ukraine! -

+[Trilium Rocks](https://discord.gg/aqdX9mXX4r) ## 🎁 Features -* Notes can be arranged into arbitrarily deep tree. Single note can be placed into multiple places in the tree (see [cloning](https://github.com/zadam/trilium/wiki/Cloning-notes)) -* Rich WYSIWYG note editing including e.g. tables, images and [math](https://github.com/zadam/trilium/wiki/Text-notes#math-support) with markdown [autoformat](https://github.com/zadam/trilium/wiki/Text-notes#autoformat) -* Support for editing [notes with source code](https://github.com/zadam/trilium/wiki/Code-notes), including syntax highlighting -* Fast and easy [navigation between notes](https://github.com/zadam/trilium/wiki/Note-navigation), full text search and [note hoisting](https://github.com/zadam/trilium/wiki/Note-hoisting) -* Seamless [note versioning](https://github.com/zadam/trilium/wiki/Note-revisions) -* Note [attributes](https://github.com/zadam/trilium/wiki/Attributes) can be used for note organization, querying and advanced [scripting](https://github.com/zadam/trilium/wiki/Scripts) -* [Synchronization](https://github.com/zadam/trilium/wiki/Synchronization) with self-hosted sync server +* Notes can be arranged into arbitrarily deep tree. Single note can be placed into multiple places in the tree (see [cloning](https://triliumnext.github.io/Docs/Wiki/Cloning-notes)) +* Rich WYSIWYG note editing including e.g. tables, images and [math](https://triliumnext.github.io/Docs/Wiki/Text-notes) with markdown [autoformat](https://triliumnext.github.io/Docs/Wiki/Text-notes#autoformat) +* Support for editing [notes with source code](https://triliumnext.github.io/Docs/Wiki/Code-notes), including syntax highlighting +* Fast and easy [navigation between notes](https://triliumnext.github.io/Docs/Wiki/Note-navigation), full text search and [note hoisting](https://triliumnext.github.io/Docs/Wiki/Note-hoisting) +* Seamless [note versioning](https://triliumnext.github.io/Docs/Wiki/Note-revisions) +* Note [attributes](https://triliumnext.github.io/Docs/Wiki/Attributes) can be used for note organization, querying and advanced [scripting](https://triliumnext.github.io/Docs/Wiki/Scripts) +* [Synchronization](https://triliumnext.github.io/Docs/Wiki/Synchronization) with self-hosted sync server * there's a [3rd party service for hosting synchronisation server](https://trilium.cc/paid-hosting) -* [Sharing](https://github.com/zadam/trilium/wiki/Sharing) (publishing) notes to public internet -* Strong [note encryption](https://github.com/zadam/trilium/wiki/Protected-notes) with per-note granularity +* [Sharing](https://triliumnext.github.io/Docs/Wiki/Sharing) (publishing) notes to public internet +* Strong [note encryption](https://triliumnext.github.io/Docs/Wiki/Protected-notes) with per-note granularity * Sketching diagrams with built-in Excalidraw (note type "canvas") -* [Relation maps](https://github.com/zadam/trilium/wiki/Relation-map) and [link maps](https://github.com/zadam/trilium/wiki/Link-map) for visualizing notes and their relations -* [Scripting](https://github.com/zadam/trilium/wiki/Scripts) - see [Advanced showcases](https://github.com/zadam/trilium/wiki/Advanced-showcases) -* [REST API](https://github.com/zadam/trilium/wiki/ETAPI) for automation +* [Relation maps](https://triliumnext.github.io/Docs/Wiki/Relation-map) and [link maps](https://triliumnext.github.io/Docs/Wiki/Link-map) for visualizing notes and their relations +* [Scripting](https://triliumnext.github.io/Docs/Wiki/Scripts) - see [Advanced showcases](https://triliumnext.github.io/Docs/Wiki/Advanced-showcases) +* [REST API](https://triliumnext.github.io/Docs/Wiki/ETAPI) for automation * Scales well in both usability and performance upwards of 100 000 notes -* Touch optimized [mobile frontend](https://github.com/zadam/trilium/wiki/Mobile-frontend) for smartphones and tablets -* [Night theme](https://github.com/zadam/trilium/wiki/Themes) -* [Evernote](https://github.com/zadam/trilium/wiki/Evernote-import) and [Markdown import & export](https://github.com/zadam/trilium/wiki/Markdown) -* [Web Clipper](https://github.com/zadam/trilium/wiki/Web-clipper) for easy saving of web content +* Touch optimized [mobile frontend](https://triliumnext.github.io/Docs/Wiki/Mobile-frontend) for smartphones and tablets +* [Night theme](https://triliumnext.github.io/Docs/Wiki/Themes) +* [Evernote](https://triliumnext.github.io/Docs/Wiki/Evernote-import) and [Markdown import & export](https://triliumnext.github.io/Docs/Wiki/Markdown) +* [Web Clipper](https://triliumnext.github.io/Docs/Wiki/Web-clipper) for easy saving of web content -Check out [awesome-trilium](https://github.com/Nriver/awesome-trilium) for 3rd party themes, scripts, plugins and more. +✨ Check out the following third-party resources for more TriliumNext related goodies: + +- [awesome-trilium](https://github.com/Nriver/awesome-trilium) for 3rd party themes, scripts, plugins and more. +- [TriliumRocks!](https://trilium.rocks/) for tutorials, guides, and much more. ## 🏗 Builds -Trilium is provided as either desktop application (Linux and Windows) or web application hosted on your server (Linux). Mac OS desktop build is available, but it is [unsupported](https://github.com/zadam/trilium/wiki/FAQ#mac-os-support). +Trilium is provided as either desktop application (Linux and Windows) or web application hosted on your server (Linux). Mac OS desktop build is available, but it is [unsupported](https://triliumnext.github.io/Docs/Wiki/FAQ#mac-os-support). -* If you want to use Trilium on the desktop, download binary release for your platform from [latest release](https://github.com/zadam/trilium/releases/latest), unzip the package and run ```trilium``` executable. -* If you want to install Trilium on server, follow [this page](https://github.com/zadam/trilium/wiki/Server-installation). - * Currently only recent Chrome and Firefox are supported (tested) browsers. +* If you want to use TriliumNext on the desktop, download binary release for your platform from [latest release](https://github.com/TriliumNext/Notes/releases/latest), unzip the package and run ```trilium``` executable. +* If you want to install TriliumNext on your own server, follow [this page](https://triliumnext.github.io/Docs/Wiki/Server-installation). + * Currently only recent versions of Chrome and Firefox are supported (tested) browsers. -Trilium is also provided as a Flatpak: +TriliumNext will also provided as a Flatpak: -[](https://flathub.org/apps/details/com.github.zadam.trilium) + ## 📝 Documentation -[See wiki for complete list of documentation pages.](https://github.com/zadam/trilium/wiki/) +[See wiki for complete list of documentation pages.](https://triliumnext.github.io/Docs) -You can also read [Patterns of personal knowledge base](https://github.com/zadam/trilium/wiki/Patterns-of-personal-knowledge-base) to get some inspiration on how you might use Trilium. +You can also read [Patterns of personal knowledge base](https://triliumnext.github.io/Docs/Wiki/Patterns-of-personal-knowledge-base) to get some inspiration on how you might use Trilium. ## 💻 Contribute -Use a browser based dev environment - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/zadam/trilium) - -Or clone locally and run +Clone locally and run ``` npm install npm run start-server ``` -## 📢 Shoutouts +## 👏 Shoutouts * [CKEditor 5](https://github.com/ckeditor/ckeditor5) - best WYSIWYG editor on the market, very interactive and listening team * [FancyTree](https://github.com/mar10/fancytree) - very feature rich tree library without real competition. Trilium Notes would not be the same without it. * [CodeMirror](https://github.com/codemirror/CodeMirror) - code editor with support for huge amount of languages -* [jsPlumb](https://github.com/jsplumb/jsplumb) - visual connectivity library without competition. Used in [relation maps](https://github.com/zadam/trilium/wiki/Relation-map) and [link maps](https://github.com/zadam/trilium/wiki/Link-map) +* [jsPlumb](https://github.com/jsplumb/jsplumb) - visual connectivity library without competition. Used in [relation maps](https://triliumnext.github.io/Docs/Wiki/Relation-map) and [link maps](https://triliumnext.github.io/Docs/Wiki/Link-map) ## 🤝 Support -You can support Trilium using GitHub Sponsors, [PayPal](https://paypal.me/za4am) or Bitcoin (bitcoin:bc1qv3svjn40v89mnkre5vyvs2xw6y8phaltl385d2). +You can support the original Trilium developer using GitHub Sponsors, [PayPal](https://paypal.me/za4am) or Bitcoin (bitcoin:bc1qv3svjn40v89mnkre5vyvs2xw6y8phaltl385d2). +Support for the TriliumNext organization will be possible in the near future. ## 🔑 License diff --git a/bin/better-sqlite3/mac-arm64-better_sqlite3.node b/bin/better-sqlite3/mac-arm64-better_sqlite3.node new file mode 100644 index 000000000..9709dcd23 Binary files /dev/null and b/bin/better-sqlite3/mac-arm64-better_sqlite3.node differ diff --git a/bin/better-sqlite3/mac-better_sqlite3.node b/bin/better-sqlite3/mac-x64-better_sqlite3.node similarity index 100% rename from bin/better-sqlite3/mac-better_sqlite3.node rename to bin/better-sqlite3/mac-x64-better_sqlite3.node diff --git a/bin/build-debian.sh b/bin/build-debian.sh index 7f246ade3..d973d2f36 100755 --- a/bin/build-debian.sh +++ b/bin/build-debian.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +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 + echo "Packaging debian x64 distribution..." VERSION=`jq -r ".version" package.json` diff --git a/bin/build-docker.sh b/bin/build-docker.sh index c77850eba..2b3794677 100755 --- a/bin/build-docker.sh +++ b/bin/build-docker.sh @@ -5,6 +5,9 @@ SERIES=${VERSION:0:4}-latest cat package.json | grep -v electron > server-package.json +echo "Compiling typescript..." +npx tsc + sudo docker build -t zadam/trilium:$VERSION --network host -t zadam/trilium:$SERIES . if [[ $VERSION != *"beta"* ]]; then diff --git a/bin/build-linux-x64.sh b/bin/build-linux-x64.sh index 888720a19..e3e415355 100755 --- a/bin/build-linux-x64.sh +++ b/bin/build-linux-x64.sh @@ -1,5 +1,25 @@ #!/usr/bin/env bash +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 + SRC_DIR=./dist/trilium-linux-x64-src [ "$1" != "DONTCOPY" ] && ./bin/copy-trilium.sh "$SRC_DIR" diff --git a/bin/build-mac-arm64.sh b/bin/build-mac-arm64.sh new file mode 100755 index 000000000..8d1f595a6 --- /dev/null +++ b/bin/build-mac-arm64.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +SRC_DIR=./dist/trilium-mac-arm64-src + +if [ "$1" != "DONTCOPY" ] +then + ./bin/copy-trilium.sh $SRC_DIR +fi + +echo "Copying required mac arm64 binaries" + +cp -r bin/better-sqlite3/mac-arm64-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node + +rm -r $SRC_DIR/src/public/app-dist/*.mobile.* + +echo "Packaging mac arm64 electron build" + +./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=darwin --arch=arm64 --overwrite --icon=images/app-icons/mac/icon.icns + +BUILD_DIR=./dist/trilium-mac-arm64 +rm -rf $BUILD_DIR + +# Mac build has by default useless directory level +mv "./dist/Trilium Notes-darwin-arm64" $BUILD_DIR + +cp bin/tpl/anonymize-database.sql $BUILD_DIR/ + +cp -r dump-db $BUILD_DIR/ +rm -rf $BUILD_DIR/dump-db/node_modules + +echo "Zipping mac arm64 electron distribution..." + +VERSION=`jq -r ".version" package.json` + +cd dist + +rm trilium-mac-arm64-${VERSION}.zip +zip -r9 --symlinks trilium-mac-arm64-${VERSION}.zip trilium-mac-arm64 diff --git a/bin/build-mac-x64.sh b/bin/build-mac-x64.sh index 0e63c7fb2..8e560ba41 100755 --- a/bin/build-mac-x64.sh +++ b/bin/build-mac-x64.sh @@ -7,9 +7,9 @@ then ./bin/copy-trilium.sh $SRC_DIR fi -echo "Copying required mac binaries" +echo "Copying required mac x64 binaries" -cp -r bin/better-sqlite3/mac-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node +cp -r bin/better-sqlite3/mac-x64-better_sqlite3.node $SRC_DIR/node_modules/better-sqlite3/build/Release/better_sqlite3.node rm -r $SRC_DIR/src/public/app-dist/*.mobile.* diff --git a/bin/build-win-x64.sh b/bin/build-win-x64.sh index 37bc28137..ad359ccb6 100755 --- a/bin/build-win-x64.sh +++ b/bin/build-win-x64.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if ! command -v wine &> /dev/null; then + echo "Missing command: wine" + exit 1 +fi + SRC_DIR=./dist/trilium-windows-x64-src if [ "$1" != "DONTCOPY" ] diff --git a/bin/build.sh b/bin/build.sh index ff90c288d..513bd1129 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,5 +1,30 @@ #!/usr/bin/env bash +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/* @@ -13,11 +38,15 @@ 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 +set -e 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 diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 075fe19fa..3c80598c3 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,5 +1,5 @@ -const fs = require("fs-extra"); -const path = require("path"); +import fs from "fs-extra"; +import path from "path"; const DEST_DIR = "./dist"; const DEST_DIR_SRC = path.join(DEST_DIR, "src"); @@ -15,6 +15,12 @@ async function copyNodeModuleFileOrFolder(source: string) { } const copy = async () => { + for (const srcFile of fs.readdirSync("build")) { + const destFile = path.join(DEST_DIR, path.basename(srcFile)); + console.log(`Copying source ${srcFile} -> ${destFile}.`); + fs.copySync(path.join("build", srcFile), destFile, { recursive: true }); + } + const filesToCopy = ["config-sample.ini"]; for (const file of filesToCopy) { console.log(`Copying ${file}`); @@ -27,11 +33,11 @@ const copy = async () => { await fs.copy(dir, path.join(DEST_DIR, dir)); } - const srcDirsToCopy = ["./src/public", "./src/views"]; + const srcDirsToCopy = ["./src/public", "./src/views", "./build"]; for (const dir of srcDirsToCopy) { console.log(`Copying ${dir}`); await fs.copy(dir, path.join(DEST_DIR_SRC, path.basename(dir))); - } + } const nodeModulesFile = [ "node_modules/react/umd/react.production.min.js", diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 9fdfe0293..2936a925b 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +shopt -s globstar + if [[ $# -eq 0 ]] ; then echo "Missing argument of target directory" exit 1 @@ -9,25 +11,36 @@ if ! [[ $(which npm) ]]; then exit 1 fi -n exec 18.18.2 npm run webpack || npm run webpack +# Trigger the TypeScript build +echo TypeScript build start +npx tsc +echo TypeScript build finished +# Copy the TypeScript artifacts DIR="$1" - rm -rf "$DIR" mkdir -pv "$DIR" +echo Webpack start +npm run 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' 'electron.js'; do + +for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample.ini'; do cp "$f" "$DIR"/ done -cp webpack-* "$DIR"/ # here warning because there is no 'webpack-*', but webpack.config.js only + +script_dir=$(realpath $(dirname $0)) +cp -Rv "$script_dir/../build/src" "$DIR" +cp "$script_dir/../build/electron.js" "$DIR" # run in subshell (so we return to original dir) -(cd $DIR && n exec 18.18.2 npm install --only=prod) +(cd $DIR && npm install --only=prod) if [[ -d "$DIR"/node_modules ]]; then # cleanup of useless files in dependencies diff --git a/bin/release.sh b/bin/release.sh index 649a41437..41fdd073b 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -7,6 +7,11 @@ if [[ $# -eq 0 ]] ; then exit 1 fi +if ! command -v jq &> /dev/null; then + echo "Missing command: jq" + exit 1 +fi + VERSION=$1 if ! [[ ${VERSION} =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-.+)?$ ]] ; @@ -22,7 +27,8 @@ fi echo "Releasing Trilium $VERSION" -jq '.version = "'$VERSION'"' package.json|sponge package.json +jq '.version = "'$VERSION'"' package.json > package.json.tmp +mv package.json.tmp package.json git add package.json @@ -48,6 +54,7 @@ LINUX_X64_BUILD=trilium-linux-x64-$VERSION.tar.xz DEBIAN_X64_BUILD=trilium_${VERSION}_amd64.deb WINDOWS_X64_BUILD=trilium-windows-x64-$VERSION.zip MAC_X64_BUILD=trilium-mac-x64-$VERSION.zip +MAC_ARM64_BUILD=trilium-mac-arm64-$VERSION.zip SERVER_BUILD=trilium-linux-x64-server-$VERSION.tar.xz echo "Creating release in GitHub" @@ -68,4 +75,5 @@ gh release create "$TAG" \ "dist/$LINUX_X64_BUILD" \ "dist/$WINDOWS_X64_BUILD" \ "dist/$MAC_X64_BUILD" \ + "dist/$MAC_ARM64_BUILD" \ "dist/$SERVER_BUILD" diff --git a/package-lock.json b/package-lock.json index c39403b79..f76d6a643 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "trilium", - "version": "0.63.6", + "version": "0.90.0-beta", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "trilium", - "version": "0.63.6", + "version": "0.90.0-beta", "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { @@ -100,6 +100,7 @@ "@types/express-session": "^1.18.0", "@types/html": "^1.0.4", "@types/ini": "^4.1.0", + "@types/jasmine": "^5.1.4", "@types/jsdom": "^21.1.6", "@types/mime-types": "^2.1.4", "@types/multer": "^1.4.11", @@ -1408,6 +1409,12 @@ "integrity": "sha512-mTehMtc+xtnWBBvqizcqYCktKDBH2WChvx1GU3Sfe4PysFDXiNe+1YwtpVX1MDtCa4NQrSPw2+3HmvXHY3gt1w==", "dev": true }, + "node_modules/@types/jasmine": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-5.1.4.tgz", + "integrity": "sha512-px7OMFO/ncXxixDe1zR13V1iycqWae0MxTaw62RpFlksUi5QuNWgQJFkTQjIOvrmutJbI7Fp2Y2N1F6D2R4G6w==", + "dev": true + }, "node_modules/@types/jsdom": { "version": "21.1.6", "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-21.1.6.tgz", @@ -14458,6 +14465,12 @@ "integrity": "sha512-mTehMtc+xtnWBBvqizcqYCktKDBH2WChvx1GU3Sfe4PysFDXiNe+1YwtpVX1MDtCa4NQrSPw2+3HmvXHY3gt1w==", "dev": true }, + "@types/jasmine": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-5.1.4.tgz", + "integrity": "sha512-px7OMFO/ncXxixDe1zR13V1iycqWae0MxTaw62RpFlksUi5QuNWgQJFkTQjIOvrmutJbI7Fp2Y2N1F6D2R4G6w==", + "dev": true + }, "@types/jsdom": { "version": "21.1.6", "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-21.1.6.tgz", diff --git a/package.json b/package.json index 1ffcd9688..457b5f06b 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "@types/express-session": "^1.18.0", "@types/html": "^1.0.4", "@types/ini": "^4.1.0", + "@types/jasmine": "^5.1.4", "@types/jsdom": "^21.1.6", "@types/mime-types": "^2.1.4", "@types/multer": "^1.4.11", diff --git a/src/becca/entities/bnote.ts b/src/becca/entities/bnote.ts index a007f5278..edb7f67e3 100644 --- a/src/becca/entities/bnote.ts +++ b/src/becca/entities/bnote.ts @@ -1644,10 +1644,7 @@ class BNote extends AbstractBeccaEntity { position }); - if (!content) { - throw new Error("Attempted to save an attachment with no content."); - } - + content = content || ""; attachment.setContent(content, {forceSave: true}); return attachment; @@ -1669,7 +1666,7 @@ class BNote extends AbstractBeccaEntity { getPojo(): NotePojo { return { noteId: this.noteId, - title: this.title || undefined, + title: this.title, isProtected: this.isProtected, type: this.type, mime: this.mime, diff --git a/src/becca/entities/rows.ts b/src/becca/entities/rows.ts index 4428b6dde..119d392ec 100644 --- a/src/becca/entities/rows.ts +++ b/src/becca/entities/rows.ts @@ -91,7 +91,8 @@ export interface BranchRow { * end user. Those types should be used only for checking against, they are * not for direct use. */ -export type NoteType = ("file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code"); +export const ALLOWED_NOTE_TYPES = [ "file", "image", "search", "noteMap", "launcher", "doc", "contentWidget", "text", "relationMap", "render", "canvas", "mermaid", "book", "webView", "code" ] as const; +export type NoteType = typeof ALLOWED_NOTE_TYPES[number]; export interface NoteRow { noteId: string; @@ -106,5 +107,5 @@ export interface NoteRow { dateModified: string; utcDateCreated: string; utcDateModified: string; - content?: string; + content?: string | Buffer; } diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index 57c9c8c5c..861a54502 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -645,7 +645,7 @@ export default class TabManager extends Component { const titleFragments = [ // it helps to navigate in history if note title is included in the title await activeNoteContext.getNavigationTitle(), - "Trilium Notes" + "TriliumNext Notes" ].filter(Boolean); document.title = titleFragments.join(" - "); diff --git a/src/public/app/menus/tree_context_menu.js b/src/public/app/menus/tree_context_menu.js index feba6d69e..38c245251 100644 --- a/src/public/app/menus/tree_context_menu.js +++ b/src/public/app/menus/tree_context_menu.js @@ -50,10 +50,10 @@ export default class TreeContextMenu { { title: 'Open in a new tab Ctrl+Click', command: "openInTab", uiIcon: "bx bx-empty", enabled: noSelectedNotes }, { title: 'Open in a new split', command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, { title: 'Insert note after ', command: "insertNoteAfter", uiIcon: "bx bx-plus", - items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter", {removeDeprecatedTypes: true}) : null, + items: insertNoteAfterEnabled ? await noteTypesService.getNoteTypeItems("insertNoteAfter") : null, enabled: insertNoteAfterEnabled && noSelectedNotes }, { title: 'Insert child note ', command: "insertChildNote", uiIcon: "bx bx-plus", - items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote", {removeDeprecatedTypes: true}) : null, + items: notSearch ? await noteTypesService.getNoteTypeItems("insertChildNote") : null, enabled: notSearch && noSelectedNotes }, { title: 'Delete ', command: "deleteNotes", uiIcon: "bx bx-trash", enabled: isNotRoot && !isHoisted && parentNotSearch }, diff --git a/src/public/app/services/note_types.js b/src/public/app/services/note_types.js index 6a44e03b3..40bc4a88b 100644 --- a/src/public/app/services/note_types.js +++ b/src/public/app/services/note_types.js @@ -1,21 +1,19 @@ import server from "./server.js"; import froca from "./froca.js"; -async function getNoteTypeItems(command, opts = {}) { - const removeDeprecatedTypes = !!opts.removeDeprecatedTypes; - +async function getNoteTypeItems(command) { const items = [ { title: "Text", command: command, type: "text", uiIcon: "bx bx-note" }, { title: "Code", command: command, type: "code", uiIcon: "bx bx-code" }, { title: "Saved Search", command: command, type: "search", uiIcon: "bx bx-file-find" }, - { title: "Relation Map", command: command, type: "relationMap", uiIcon: "bx bx-map-alt", deprecated: true }, + { title: "Relation Map", command: command, type: "relationMap", uiIcon: "bx bx-map-alt" }, { title: "Note Map", command: command, type: "noteMap", uiIcon: "bx bx-map-alt" }, { title: "Render Note", command: command, type: "render", uiIcon: "bx bx-extension" }, { title: "Book", command: command, type: "book", uiIcon: "bx bx-book" }, { title: "Mermaid Diagram", command: command, type: "mermaid", uiIcon: "bx bx-selection" }, { title: "Canvas", command: command, type: "canvas", uiIcon: "bx bx-pen" }, { title: "Web View", command: command, type: "webView", uiIcon: "bx bx-globe-alt" }, - ].filter(item => !removeDeprecatedTypes || !item.deprecated); + ]; const templateNoteIds = await server.get("search-templates"); const templateNotes = await froca.getNotes(templateNoteIds); diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 35b88923f..162ad6149 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -204,7 +204,7 @@ const TPL = `