mirror of
https://github.com/zadam/trilium.git
synced 2025-11-08 23:49:00 +01:00
Merge branch 'main' into renovate/ckeditor-monorepo
This commit is contained in:
commit
4e8ddef915
2
.github/actions/build-electron/action.yml
vendored
2
.github/actions/build-electron/action.yml
vendored
@ -85,7 +85,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-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
|
||||
TRILIUM_ARTIFACT_NAME_HINT: TriliumNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }}
|
||||
run: pnpm nx --project=desktop electron-forge:make -- --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }}
|
||||
|
||||
# Add DMG signing step
|
||||
|
||||
2
.github/actions/build-server/action.yml
vendored
2
.github/actions/build-server/action.yml
vendored
@ -30,4 +30,4 @@ runs:
|
||||
mkdir -p upload
|
||||
file=$(find ./apps/server/out -name '*.tar.xz' -print -quit)
|
||||
name=${{ github.ref_name }}
|
||||
cp "$file" "upload/TriliumNextNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"
|
||||
cp "$file" "upload/TriliumNotes-Server-${name//\//-}-${{ inputs.os }}-${{ inputs.arch }}.tar.xz"
|
||||
|
||||
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
@ -92,7 +92,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
with:
|
||||
name: TriliumNextNotes ${{ matrix.os.name }} ${{ matrix.arch }}
|
||||
name: TriliumNotes ${{ matrix.os.name }} ${{ matrix.arch }}
|
||||
path: apps/desktop/upload
|
||||
|
||||
nightly-server:
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
"@playwright/test": "1.53.1",
|
||||
"@stylistic/eslint-plugin": "5.0.0",
|
||||
"@types/express": "5.0.3",
|
||||
"@types/node": "22.15.32",
|
||||
"@types/node": "22.15.33",
|
||||
"@types/yargs": "17.0.33",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"eslint": "9.29.0",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:22.16.0-bullseye-slim AS builder
|
||||
FROM node:22.17.0-bullseye-slim AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:22.16.0-bullseye-slim
|
||||
FROM node:22.17.0-bullseye-slim
|
||||
# Install only runtime dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:22.16.0-alpine AS builder
|
||||
FROM node:22.17.0-alpine AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:22.16.0-alpine
|
||||
FROM node:22.17.0-alpine
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache su-exec shadow
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:22.16.0-alpine AS builder
|
||||
FROM node:22.17.0-alpine AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:22.16.0-alpine
|
||||
FROM node:22.17.0-alpine
|
||||
# Create a non-root user with configurable UID/GID
|
||||
ARG USER=trilium
|
||||
ARG UID=1001
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
FROM node:22.16.0-bullseye-slim AS builder
|
||||
FROM node:22.17.0-bullseye-slim AS builder
|
||||
RUN corepack enable
|
||||
|
||||
# Install native dependencies since we might be building cross-platform.
|
||||
@ -7,7 +7,7 @@ COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
|
||||
# We have to use --no-frozen-lockfile due to CKEditor patches
|
||||
RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
|
||||
|
||||
FROM node:22.16.0-bullseye-slim
|
||||
FROM node:22.17.0-bullseye-slim
|
||||
# Create a non-root user with configurable UID/GID
|
||||
ARG USER=trilium
|
||||
ARG UID=1001
|
||||
|
||||
@ -48,7 +48,7 @@ chmod 755 $BUILD_DIR/trilium.sh
|
||||
|
||||
VERSION=`jq -r ".version" package.json`
|
||||
|
||||
ARCHIVE_NAME="TriliumNextNotes-Server-${VERSION}-linux-${ARCH}"
|
||||
ARCHIVE_NAME="TriliumNotes-Server-${VERSION}-linux-${ARCH}"
|
||||
echo "Creating Archive $ARCHIVE_NAME..."
|
||||
|
||||
mkdir $DIST_DIR
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
<h2>Steps</h2>
|
||||
<ul>
|
||||
<li>SSH into your server</li>
|
||||
<li>use <code>wget</code> (or <code>curl</code>) to download latest <code>TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz</code> (copy
|
||||
<li>use <code>wget</code> (or <code>curl</code>) to download latest <code>TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code> (copy
|
||||
link from <a href="https://github.com/TriliumNext/Notes/releases">release page</a>,
|
||||
notice <code>-Server</code> suffix) on your server.</li>
|
||||
<li>unpack the archive, e.g. using <code>tar -xf -d TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz</code>
|
||||
<li>unpack the archive, e.g. using <code>tar -xf -d TriliumNotes-Server-[VERSION]-linux-x64.tar.xz</code>
|
||||
</li>
|
||||
<li><code>cd trilium-linux-x64-server</code>
|
||||
</li>
|
||||
@ -27,7 +27,7 @@
|
||||
<h2>Configure Trilium to auto-run on boot with systemd</h2>
|
||||
<ul>
|
||||
<li>After downloading, extract and move Trilium:</li>
|
||||
</ul><pre><code class="language-text-x-trilium-auto">tar -xvf TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz
|
||||
</ul><pre><code class="language-text-x-trilium-auto">tar -xvf TriliumNotes-Server-[VERSION]-linux-x64.tar.xz
|
||||
sudo mv trilium-linux-x64-server /opt/trilium</code></pre>
|
||||
<ul>
|
||||
<li>Create the service:</li>
|
||||
|
||||
@ -36,6 +36,17 @@ import type Becca from "../becca/becca-interface.js";
|
||||
import type { NoteParams } from "./note-interface.js";
|
||||
import type { ApiParams } from "./backend_script_api_interface.js";
|
||||
|
||||
// Dayjs plugins
|
||||
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
||||
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
||||
import isBetween from "dayjs/plugin/isBetween";
|
||||
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
||||
|
||||
dayjs.extend(isSameOrBefore);
|
||||
dayjs.extend(isSameOrAfter);
|
||||
dayjs.extend(isBetween);
|
||||
dayjs.extend(advancedFormat);
|
||||
|
||||
/**
|
||||
* A whole number
|
||||
* @typedef {number} int
|
||||
|
||||
114
apps/server/src/services/script.spec.ts
Normal file
114
apps/server/src/services/script.spec.ts
Normal file
@ -0,0 +1,114 @@
|
||||
import becca from "../becca/becca.js";
|
||||
import { note, NoteBuilder } from "../test/becca_mocking.js";
|
||||
import cls from "./cls.js";
|
||||
import { executeBundle, getScriptBundle } from "./script.js";
|
||||
import BBranch from "../becca/entities/bbranch.js";
|
||||
import BNote from "../becca/entities/bnote.js";
|
||||
|
||||
|
||||
describe("Script", () => {
|
||||
let rootNote!: NoteBuilder;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
becca.reset();
|
||||
|
||||
rootNote = new NoteBuilder(
|
||||
new BNote({
|
||||
noteId: "root",
|
||||
title: "root",
|
||||
type: "text"
|
||||
})
|
||||
);
|
||||
new BBranch({
|
||||
branchId: "none_root",
|
||||
noteId: "root",
|
||||
parentNoteId: "none",
|
||||
notePosition: 10
|
||||
});
|
||||
|
||||
vi.mock("./sql.js", () => {
|
||||
return {
|
||||
default: {
|
||||
transactional: (cb: Function) => {
|
||||
cb();
|
||||
},
|
||||
execute: () => {},
|
||||
replace: () => {},
|
||||
getMap: () => {}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./sql_init.js", () => {
|
||||
return {
|
||||
dbReady: () => {
|
||||
console.log("Hello world");
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it("returns result from script", () => {
|
||||
cls.init(() => {
|
||||
const result = executeBundle({
|
||||
script: `return "world";`,
|
||||
html: "",
|
||||
});
|
||||
expect(result).toBe("world");
|
||||
});
|
||||
});
|
||||
|
||||
describe("dayjs", () => {
|
||||
const scriptNote = note("dayjs", {
|
||||
type: "code",
|
||||
mime: "application/javascript;env=backend",
|
||||
});
|
||||
|
||||
it("dayjs is available", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs().format("YYYY-MM-DD");`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-same-or-before", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-01").isSameOrBefore(api.dayjs("2023-10-02"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-same-or-after", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-02").isSameOrAfter(api.dayjs("2023-10-01"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("dayjs is-between", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-02").isBetween(api.dayjs("2023-10-01"), api.dayjs("2023-10-03"));`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// advanced format
|
||||
it("dayjs advanced format", () => {
|
||||
cls.init(() => {
|
||||
const bundle = getScriptBundle(scriptNote.note, true, "backend", [], `return api.dayjs("2023-10-01").format("Q");`);
|
||||
expect(bundle).toBeDefined();
|
||||
const result = executeBundle(bundle!);
|
||||
expect(result).not.toBe("Q");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -39,7 +39,7 @@ function executeNoteNoException(note: BNote, apiParams: ApiParams) {
|
||||
}
|
||||
}
|
||||
|
||||
function executeBundle(bundle: Bundle, apiParams: ApiParams = {}) {
|
||||
export function executeBundle(bundle: Bundle, apiParams: ApiParams = {}) {
|
||||
if (!apiParams.startNote) {
|
||||
// this is the default case, the only exception is when we want to preserve frontend startNote
|
||||
apiParams.startNote = bundle.note;
|
||||
@ -140,7 +140,7 @@ function getScriptBundleForFrontend(note: BNote, script?: string, params?: Scrip
|
||||
return bundle;
|
||||
}
|
||||
|
||||
function getScriptBundle(note: BNote, root: boolean = true, scriptEnv: string | null = null, includedNoteIds: string[] = [], overrideContent: string | null = null): Bundle | undefined {
|
||||
export function getScriptBundle(note: BNote, root: boolean = true, scriptEnv: string | null = null, includedNoteIds: string[] = [], overrideContent: string | null = null): Bundle | undefined {
|
||||
if (!note.isContentAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,11 +117,11 @@ export const downloadMatrix: DownloadMatrix = {
|
||||
},
|
||||
tarX64: {
|
||||
name: "x86 (.tar.xz)",
|
||||
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-x64.tar.xz`
|
||||
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-x64.tar.xz`
|
||||
},
|
||||
tarArm64: {
|
||||
name: "ARM (.tar.xz)",
|
||||
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-arm64.tar.xz`
|
||||
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNotes-Server-v${version}-linux-arm64.tar.xz`
|
||||
},
|
||||
nixos: {
|
||||
name: "NixOS module",
|
||||
@ -150,7 +150,7 @@ export const downloadMatrix: DownloadMatrix = {
|
||||
export function buildDownloadUrl(app: App, platform: Platform, format: string, architecture: Architecture): string {
|
||||
if (app === "desktop") {
|
||||
return downloadMatrix.desktop[platform]?.downloads[format].url ??
|
||||
`https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;
|
||||
`https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNotes-v${version}-${platform}-${architecture}.${format}`;
|
||||
} else if (app === "server") {
|
||||
return downloadMatrix.server[platform]?.downloads[format].url ?? "#";
|
||||
} else {
|
||||
|
||||
@ -4,7 +4,7 @@ On Ubuntu:
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
|
||||
name=TriliumNextNotes-linux-x64-nightly.deb
|
||||
name=TriliumNotes-linux-x64-nightly.deb
|
||||
rm -f $name*
|
||||
wget https://github.com/TriliumNext/Notes/releases/download/nightly/$name
|
||||
sudo apt-get install ./$name
|
||||
|
||||
@ -4,8 +4,8 @@ This is essentially Trilium sources + node modules + node.js runtime packaged in
|
||||
## Steps
|
||||
|
||||
* SSH into your server
|
||||
* use `wget` (or `curl`) to download latest `TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz` (copy link from [release page](https://github.com/TriliumNext/Notes/releases), notice `-Server` suffix) on your server.
|
||||
* unpack the archive, e.g. using `tar -xf -d TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz`
|
||||
* use `wget` (or `curl`) to download latest `TriliumNotes-Server-[VERSION]-linux-x64.tar.xz` (copy link from [release page](https://github.com/TriliumNext/Notes/releases), notice `-Server` suffix) on your server.
|
||||
* unpack the archive, e.g. using `tar -xf -d TriliumNotes-Server-[VERSION]-linux-x64.tar.xz`
|
||||
* `cd trilium-linux-x64-server`
|
||||
* `./trilium.sh`
|
||||
* you can open the browser and open http://\[your-server-hostname\]:8080 and you should see Trilium initialization page
|
||||
@ -20,7 +20,7 @@ The problem with above steps is that once you close the SSH connection, the Tril
|
||||
* After downloading, extract and move Trilium:
|
||||
|
||||
```
|
||||
tar -xvf TriliumNextNotes-Server-[VERSION]-linux-x64.tar.xz
|
||||
tar -xvf TriliumNotes-Server-[VERSION]-linux-x64.tar.xz
|
||||
sudo mv trilium-linux-x64-server /opt/trilium
|
||||
```
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
"@playwright/test": "^1.36.0",
|
||||
"@triliumnext/server": "workspace:*",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/node": "22.15.32",
|
||||
"@types/node": "22.15.33",
|
||||
"@vitest/coverage-v8": "^3.0.5",
|
||||
"@vitest/ui": "^3.0.0",
|
||||
"chalk": "5.4.1",
|
||||
|
||||
377
pnpm-lock.yaml
generated
377
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user