mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
Merge branch 'develop' of https://github.com/TriliumNext/Notes into develop
This commit is contained in:
commit
a694017c87
@ -1,10 +1,37 @@
|
||||
.git
|
||||
.idea
|
||||
# ignored Files
|
||||
.dockerignore
|
||||
.editorconfig
|
||||
.git*
|
||||
.prettier*
|
||||
electron*
|
||||
entitlements.plist
|
||||
forge.config.cjs
|
||||
nodemon.json
|
||||
renovate.json
|
||||
trilium.iml
|
||||
Dockerfile
|
||||
Dockerfile.*
|
||||
npm-debug.log
|
||||
/src/**/*.spec.ts
|
||||
|
||||
# ignored folders
|
||||
/.cache
|
||||
/.git
|
||||
/.github
|
||||
/.idea
|
||||
/.vscode
|
||||
/bin
|
||||
/build
|
||||
/dist
|
||||
/docs
|
||||
/npm-debug.log
|
||||
node_modules
|
||||
/dump-db
|
||||
/e2e
|
||||
/integration-tests
|
||||
/spec
|
||||
/test
|
||||
/test-etapi
|
||||
/node_modules
|
||||
|
||||
src/**/*.ts
|
||||
!src/services/asset_path.ts
|
||||
|
||||
# exceptions
|
||||
!/bin/copy-dist.ts
|
24
.github/workflows/dev.yml
vendored
24
.github/workflows/dev.yml
vendored
@ -44,16 +44,6 @@ jobs:
|
||||
- test_dev
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
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:
|
||||
@ -82,20 +72,6 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
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
|
||||
|
||||
- name: Build and export to Docker
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
|
15
.github/workflows/main-docker.yml
vendored
15
.github/workflows/main-docker.yml
vendored
@ -57,9 +57,6 @@ jobs:
|
||||
- name: Run the TypeScript build
|
||||
run: npx tsc
|
||||
|
||||
- name: Create server-package.json
|
||||
run: cat package.json | grep -v electron > server-package.json
|
||||
|
||||
- name: Build and export to Docker
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
@ -154,18 +151,6 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
|
||||
- name: Set up node & dependencies
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
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
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
72
Dockerfile
72
Dockerfile
@ -1,62 +1,46 @@
|
||||
# Build stage
|
||||
FROM node:22.14.0-bullseye-slim AS builder
|
||||
|
||||
# Configure build dependencies in a single layer
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
autoconf \
|
||||
automake \
|
||||
g++ \
|
||||
gcc \
|
||||
libtool \
|
||||
make \
|
||||
nasm \
|
||||
libpng-dev \
|
||||
python3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
WORKDIR /usr/src/app/build
|
||||
|
||||
# Copy only necessary files for build
|
||||
COPY . .
|
||||
COPY server-package.json package.json
|
||||
|
||||
# Build and cleanup in a single layer
|
||||
RUN cp -R build/src/* src/. && \
|
||||
cp build/docker_healthcheck.js . && \
|
||||
rm docker_healthcheck.ts && \
|
||||
npm install && \
|
||||
npm run build:webpack && \
|
||||
npm prune --omit=dev && \
|
||||
RUN npm ci && \
|
||||
npm run build:prepare-dist && \
|
||||
npm cache clean --force && \
|
||||
cp -r src/public/app/doc_notes src/public/app-dist/. && \
|
||||
rm -rf src/public/app/* && \
|
||||
mkdir -p src/public/app/services && \
|
||||
cp -r build/src/public/app/services/mime_type_definitions.js src/public/app/services/mime_type_definitions.js && \
|
||||
rm src/services/asset_path.ts && \
|
||||
rm -r build
|
||||
rm -rf dist/node_modules && \
|
||||
mv dist/* \
|
||||
start-docker.sh \
|
||||
/usr/src/app/ && \
|
||||
rm -rf \
|
||||
/usr/src/app/build \
|
||||
/tmp/node-compile-cache
|
||||
|
||||
#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
|
||||
|
||||
# Runtime stage
|
||||
FROM node:22.14.0-bullseye-slim
|
||||
|
||||
# Install only runtime dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
&& rm -rf /var/lib/apt/lists/* && \
|
||||
rm -rf /var/cache/apt/*
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy only necessary files from builder
|
||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||
COPY --from=builder /usr/src/app/src ./src
|
||||
COPY --from=builder /usr/src/app/db ./db
|
||||
COPY --from=builder /usr/src/app/docker_healthcheck.js .
|
||||
COPY --from=builder /usr/src/app/start-docker.sh .
|
||||
COPY --from=builder /usr/src/app/package.json .
|
||||
COPY --from=builder /usr/src/app/config-sample.ini .
|
||||
COPY --from=builder /usr/src/app/images ./images
|
||||
COPY --from=builder /usr/src/app/translations ./translations
|
||||
COPY --from=builder /usr/src/app/libraries ./libraries
|
||||
# Install only runtime dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gosu && \
|
||||
rm -rf \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/cache/apt/*
|
||||
|
||||
COPY --from=builder /usr/src/app ./
|
||||
|
||||
RUN sed -i "/electron/d" package.json && \
|
||||
npm ci --omit=dev && \
|
||||
npm cache clean --force && \
|
||||
rm -rf /tmp/node-compile-cache
|
||||
|
||||
# Configure container
|
||||
EXPOSE 8080
|
||||
|
@ -1,38 +1,26 @@
|
||||
# Build stage
|
||||
FROM node:22.14.0-alpine AS builder
|
||||
|
||||
# Configure build dependencies
|
||||
RUN apk add --no-cache --virtual .build-dependencies \
|
||||
autoconf \
|
||||
automake \
|
||||
g++ \
|
||||
gcc \
|
||||
libtool \
|
||||
make \
|
||||
nasm \
|
||||
libpng-dev \
|
||||
python3
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
WORKDIR /usr/src/app/build
|
||||
|
||||
# Copy only necessary files for build
|
||||
COPY . .
|
||||
COPY server-package.json package.json
|
||||
|
||||
# Build and cleanup in a single layer
|
||||
RUN cp -R build/src/* src/. && \
|
||||
cp build/docker_healthcheck.js . && \
|
||||
rm docker_healthcheck.ts && \
|
||||
npm install && \
|
||||
npm run build:webpack && \
|
||||
npm prune --omit=dev && \
|
||||
RUN npm ci && \
|
||||
npm run build:prepare-dist && \
|
||||
npm cache clean --force && \
|
||||
cp -r src/public/app/doc_notes src/public/app-dist/. && \
|
||||
rm -rf src/public/app && \
|
||||
mkdir -p src/public/app/services && \
|
||||
cp -r build/src/public/app/services/mime_type_definitions.js src/public/app/services/mime_type_definitions.js && \
|
||||
rm src/services/asset_path.ts && \
|
||||
rm -r build
|
||||
rm -rf dist/node_modules && \
|
||||
mv dist/* \
|
||||
start-docker.sh \
|
||||
/usr/src/app/ && \
|
||||
rm -rf \
|
||||
/usr/src/app/build \
|
||||
/tmp/node-compile-cache
|
||||
|
||||
#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
|
||||
|
||||
# Runtime stage
|
||||
FROM node:22.14.0-alpine
|
||||
@ -42,17 +30,12 @@ RUN apk add --no-cache su-exec shadow
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy only necessary files from builder
|
||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||
COPY --from=builder /usr/src/app/src ./src
|
||||
COPY --from=builder /usr/src/app/db ./db
|
||||
COPY --from=builder /usr/src/app/docker_healthcheck.js .
|
||||
COPY --from=builder /usr/src/app/start-docker.sh .
|
||||
COPY --from=builder /usr/src/app/package.json .
|
||||
COPY --from=builder /usr/src/app/config-sample.ini .
|
||||
COPY --from=builder /usr/src/app/images ./images
|
||||
COPY --from=builder /usr/src/app/translations ./translations
|
||||
COPY --from=builder /usr/src/app/libraries ./libraries
|
||||
COPY --from=builder /usr/src/app ./
|
||||
|
||||
RUN sed -i "/electron/d" package.json && \
|
||||
npm ci --omit=dev && \
|
||||
npm cache clean --force && \
|
||||
rm -rf /tmp/node-compile-cache
|
||||
|
||||
# Add application user
|
||||
RUN adduser -s /bin/false node; exit 0
|
||||
|
@ -5,11 +5,6 @@ set -e # Fail on any command error
|
||||
VERSION=`jq -r ".version" package.json`
|
||||
SERIES=${VERSION:0:4}-latest
|
||||
|
||||
cat package.json | grep -v electron > server-package.json
|
||||
|
||||
echo "Compiling typescript..."
|
||||
npx tsc
|
||||
|
||||
sudo docker build -t triliumnext/notes:$VERSION --network host -t triliumnext/notes:$SERIES .
|
||||
|
||||
if [[ $VERSION != *"beta"* ]]; then
|
||||
|
@ -2,8 +2,6 @@ import fs from "fs-extra";
|
||||
import path from "path";
|
||||
|
||||
const DEST_DIR = "./dist";
|
||||
const DEST_DIR_SRC = path.join(DEST_DIR, "src");
|
||||
const DEST_DIR_NODE_MODULES = path.join(DEST_DIR, "node_modules");
|
||||
|
||||
const VERBOSE = process.env.VERBOSE;
|
||||
|
||||
@ -13,43 +11,37 @@ function log(...args: any[]) {
|
||||
}
|
||||
}
|
||||
|
||||
async function copyNodeModuleFileOrFolder(source: string) {
|
||||
const adjustedSource = source.substring(13);
|
||||
const destination = path.join(DEST_DIR_NODE_MODULES, adjustedSource);
|
||||
|
||||
function copyNodeModuleFileOrFolder(source: string) {
|
||||
const destination = path.join(DEST_DIR, source);
|
||||
log(`Copying ${source} to ${destination}`);
|
||||
await fs.ensureDir(path.dirname(destination));
|
||||
await fs.copy(source, destination);
|
||||
fs.ensureDirSync(path.dirname(destination));
|
||||
fs.copySync(source, destination);
|
||||
}
|
||||
|
||||
const copy = async () => {
|
||||
for (const srcFile of fs.readdirSync("build")) {
|
||||
const destFile = path.join(DEST_DIR, path.basename(srcFile));
|
||||
log(`Copying source ${srcFile} -> ${destFile}.`);
|
||||
fs.copySync(path.join("build", srcFile), destFile, { recursive: true });
|
||||
}
|
||||
try {
|
||||
|
||||
const filesToCopy = [
|
||||
"config-sample.ini",
|
||||
"tsconfig.webpack.json",
|
||||
const assetsToCopy = new Set([
|
||||
"./images",
|
||||
"./libraries",
|
||||
"./translations",
|
||||
"./db",
|
||||
"./config-sample.ini",
|
||||
"./package-lock.json",
|
||||
"./package.json",
|
||||
"./src/views/",
|
||||
"./src/etapi/etapi.openapi.yaml",
|
||||
"./src/routes/api/openapi.json"
|
||||
];
|
||||
for (const file of filesToCopy) {
|
||||
log(`Copying ${file}`);
|
||||
await fs.copy(file, path.join(DEST_DIR, file));
|
||||
}
|
||||
"./src/routes/api/openapi.json",
|
||||
"./src/public/icon.png",
|
||||
"./src/public/manifest.webmanifest",
|
||||
"./src/public/robots.txt",
|
||||
"./src/public/fonts",
|
||||
"./src/public/stylesheets",
|
||||
"./src/public/translations"
|
||||
]);
|
||||
|
||||
const dirsToCopy = ["images", "libraries", "translations", "db"];
|
||||
for (const dir of dirsToCopy) {
|
||||
log(`Copying ${dir}`);
|
||||
await fs.copy(dir, path.join(DEST_DIR, dir));
|
||||
}
|
||||
|
||||
const srcDirsToCopy = ["./src/public", "./src/views", "./build"];
|
||||
for (const dir of srcDirsToCopy) {
|
||||
log(`Copying ${dir}`);
|
||||
await fs.copy(dir, path.join(DEST_DIR_SRC, path.basename(dir)));
|
||||
for (const asset of assetsToCopy) {
|
||||
log(`Copying ${asset}`);
|
||||
fs.copySync(asset, path.join(DEST_DIR, asset));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,10 +50,10 @@ const copy = async () => {
|
||||
const publicDirsToCopy = ["./src/public/app/doc_notes"];
|
||||
const PUBLIC_DIR = path.join(DEST_DIR, "src", "public", "app-dist");
|
||||
for (const dir of publicDirsToCopy) {
|
||||
await fs.copy(dir, path.join(PUBLIC_DIR, path.basename(dir)));
|
||||
fs.copySync(dir, path.join(PUBLIC_DIR, path.basename(dir)));
|
||||
}
|
||||
|
||||
const nodeModulesFile = [
|
||||
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",
|
||||
@ -71,13 +63,9 @@ const copy = async () => {
|
||||
"node_modules/katex/dist/contrib/auto-render.min.js",
|
||||
"node_modules/@highlightjs/cdn-assets/highlight.min.js",
|
||||
"node_modules/@mind-elixir/node-menu/dist/node-menu.umd.cjs"
|
||||
];
|
||||
]);
|
||||
|
||||
for (const file of nodeModulesFile) {
|
||||
await copyNodeModuleFileOrFolder(file);
|
||||
}
|
||||
|
||||
const nodeModulesFolder = [
|
||||
const nodeModulesFolder = new Set([
|
||||
"node_modules/@excalidraw/excalidraw/dist/",
|
||||
"node_modules/katex/dist/",
|
||||
"node_modules/dayjs/",
|
||||
@ -104,13 +92,15 @@ const copy = async () => {
|
||||
"node_modules/@highlightjs/cdn-assets/languages",
|
||||
"node_modules/@highlightjs/cdn-assets/styles",
|
||||
"node_modules/leaflet/dist"
|
||||
];
|
||||
]);
|
||||
|
||||
for (const folder of nodeModulesFolder) {
|
||||
await copyNodeModuleFileOrFolder(folder);
|
||||
|
||||
|
||||
for (const nodeModuleItem of [...nodeModulesFile, ...nodeModulesFolder]) {
|
||||
copyNodeModuleFileOrFolder(nodeModuleItem);
|
||||
}
|
||||
};
|
||||
console.log("Copying complete!")
|
||||
|
||||
copy()
|
||||
.then(() => console.log("Copying complete!"))
|
||||
.catch((err) => console.error("Error during copy:", err));
|
||||
} catch(err) {
|
||||
console.error("Error during copy:", err)
|
||||
}
|
@ -14,7 +14,7 @@ fi
|
||||
|
||||
# Trigger the TypeScript build
|
||||
echo TypeScript build start
|
||||
npx tsc
|
||||
npm run build:ts
|
||||
echo TypeScript build finished
|
||||
|
||||
# Copy the TypeScript artifacts
|
||||
|
@ -14,7 +14,7 @@ npm install
|
||||
|
||||
## Running
|
||||
|
||||
See output of `npx esrun dump.ts --help`:
|
||||
See output of `npx tsx dump.ts --help`:
|
||||
|
||||
```
|
||||
dump-db.ts <path_to_document> <target_directory>
|
||||
|
858
dump-db/package-lock.json
generated
858
dump-db/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -18,9 +18,9 @@
|
||||
"homepage": "https://github.com/TriliumNext/Notes/blob/master/dump-db/README.md",
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^11.1.2",
|
||||
"esrun": "^3.2.26",
|
||||
"mime-types": "^2.1.34",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"tsx": "^4.19.3",
|
||||
"yargs": "^17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
28
libraries/codemirror/eslint.js
vendored
28
libraries/codemirror/eslint.js
vendored
@ -35,39 +35,13 @@
|
||||
return [];
|
||||
}
|
||||
|
||||
await glob.requireLibrary(glob.ESLINT);
|
||||
|
||||
if (text.length > 20000) {
|
||||
console.log("Skipping linting because of large size: ", text.length);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
const errors = new eslint().verify(text, {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
ecmaVersion: "2019"
|
||||
},
|
||||
extends: ['eslint:recommended', 'airbnb-base'],
|
||||
env: {
|
||||
'browser': true,
|
||||
'node': true
|
||||
},
|
||||
rules: {
|
||||
'import/no-unresolved': 'off',
|
||||
'func-names': 'off',
|
||||
'comma-dangle': ['warn'],
|
||||
'padded-blocks': 'off',
|
||||
'linebreak-style': 'off',
|
||||
'class-methods-use-this': 'off',
|
||||
'no-unused-vars': ['warn', { vars: 'local', args: 'after-used' }],
|
||||
'no-nested-ternary': 'off',
|
||||
'no-underscore-dangle': ['error', {'allow': ['_super', '_lookupFactory']}]
|
||||
},
|
||||
globals: {
|
||||
"api": "readonly"
|
||||
}
|
||||
});
|
||||
const errors = await glob.linter(text);
|
||||
|
||||
console.log(errors);
|
||||
|
||||
|
112883
libraries/eslint/eslint.js
vendored
112883
libraries/eslint/eslint.js
vendored
File diff suppressed because one or more lines are too long
76
package-lock.json
generated
76
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.92.2-beta",
|
||||
"version": "0.92.3-beta",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trilium",
|
||||
"version": "0.92.2-beta",
|
||||
"version": "0.92.3-beta",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "7.1.1",
|
||||
@ -44,6 +44,7 @@
|
||||
"electron-squirrel-startup": "1.0.1",
|
||||
"electron-window-state": "5.0.3",
|
||||
"escape-html": "1.0.3",
|
||||
"eslint-linter-browserify": "9.22.0",
|
||||
"express": "4.21.2",
|
||||
"express-rate-limit": "7.5.0",
|
||||
"express-session": "1.18.1",
|
||||
@ -114,7 +115,7 @@
|
||||
"@electron-forge/maker-zip": "7.7.0",
|
||||
"@electron-forge/plugin-auto-unpack-natives": "7.7.0",
|
||||
"@electron/rebuild": "3.7.1",
|
||||
"@eslint/js": "9.21.0",
|
||||
"@eslint/js": "9.22.0",
|
||||
"@playwright/test": "1.51.0",
|
||||
"@popperjs/core": "2.11.8",
|
||||
"@types/archiver": "6.0.3",
|
||||
@ -163,9 +164,10 @@
|
||||
"cross-env": "7.0.3",
|
||||
"css-loader": "7.1.2",
|
||||
"electron": "34.3.1",
|
||||
"eslint": "9.21.0",
|
||||
"eslint": "9.22.0",
|
||||
"esm": "3.2.25",
|
||||
"happy-dom": "17.3.0",
|
||||
"globals": "16.0.0",
|
||||
"happy-dom": "17.4.0",
|
||||
"i18next-http-backend": "3.0.2",
|
||||
"jsdoc": "4.0.4",
|
||||
"knockout": "3.5.1",
|
||||
@ -2187,6 +2189,16 @@
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-helpers": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.1.0.tgz",
|
||||
"integrity": "sha512-kLrdPDJE1ckPo94kmPPf9Hfd0DU0Jw6oKYrhe+pwSC0iTUInmTa+w6fw8sGgcfkFJGNdWOUeOaDM4quW4a7OkA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/core": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.12.0.tgz",
|
||||
@ -2241,6 +2253,19 @@
|
||||
"url": "https://github.com/sponsors/epoberezkin"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/globals": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||
@ -2249,9 +2274,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@eslint/js": {
|
||||
"version": "9.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.21.0.tgz",
|
||||
"integrity": "sha512-BqStZ3HX8Yz6LvsF5ByXYrtigrV5AXADWLAGc7PH/1SxOb7/FIYYMszZZWiUou/GB9P2lXWk2SV4d+Z8h0nknw==",
|
||||
"version": "9.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.22.0.tgz",
|
||||
"integrity": "sha512-vLFajx9o8d1/oL2ZkpMYbkLv8nDB6yaIwFNt7nI4+I80U/z03SxmfOMsLbvWr3p7C+Wnoh//aOu2pQW8cS0HCQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@ -10058,18 +10083,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "9.21.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.21.0.tgz",
|
||||
"integrity": "sha512-KjeihdFqTPhOMXTt7StsDxriV4n66ueuF/jfPNC3j/lduHwr/ijDwJMsF+wyMJethgiKi5wniIE243vi07d3pg==",
|
||||
"version": "9.22.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.22.0.tgz",
|
||||
"integrity": "sha512-9V/QURhsRN40xuHXWjV64yvrzMjcz7ZyNoF2jJFmy9j/SLk0u1OLSZgXi28MrXjymnjEGSR80WCdab3RGMDveQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
"@eslint/config-array": "^0.19.2",
|
||||
"@eslint/config-helpers": "^0.1.0",
|
||||
"@eslint/core": "^0.12.0",
|
||||
"@eslint/eslintrc": "^3.3.0",
|
||||
"@eslint/js": "9.21.0",
|
||||
"@eslint/js": "9.22.0",
|
||||
"@eslint/plugin-kit": "^0.2.7",
|
||||
"@humanfs/node": "^0.16.6",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
@ -10081,7 +10107,7 @@
|
||||
"cross-spawn": "^7.0.6",
|
||||
"debug": "^4.3.2",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"eslint-scope": "^8.2.0",
|
||||
"eslint-scope": "^8.3.0",
|
||||
"eslint-visitor-keys": "^4.2.0",
|
||||
"espree": "^10.3.0",
|
||||
"esquery": "^1.5.0",
|
||||
@ -10117,6 +10143,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-linter-browserify": {
|
||||
"version": "9.22.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-linter-browserify/-/eslint-linter-browserify-9.22.0.tgz",
|
||||
"integrity": "sha512-b70x+ilh1XkugEZZvGJ6LNPE1+jxjsn4KIdj1OBMBGbzYj7l2lr3N/Y4NHKhFxq2a4v/J8WqojIOvy0AFDmrXw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/eslint-scope": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||
@ -10172,9 +10204,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint/node_modules/eslint-scope": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz",
|
||||
"integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==",
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.3.0.tgz",
|
||||
"integrity": "sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
@ -11598,9 +11630,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-16.0.0.tgz",
|
||||
"integrity": "sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@ -11684,9 +11716,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/happy-dom": {
|
||||
"version": "17.3.0",
|
||||
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-17.3.0.tgz",
|
||||
"integrity": "sha512-dTwlpUHrhE0usQOd1Df9k461SOYQUWNl0G31mXCDj+N9//oPcDb+cchrSJzrXN6qxZ5sZSrLf5AfY702Zvddfw==",
|
||||
"version": "17.4.0",
|
||||
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-17.4.0.tgz",
|
||||
"integrity": "sha512-LN2BIuvdFZ8snmF6LtQB2vYBzRmgCx+uqlFX9JpKVRHQ44NODNnOchB4ZW8404djHhdbQgEHRAkXCZ0zGOyzew==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
14
package.json
14
package.json
@ -43,8 +43,10 @@
|
||||
"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",
|
||||
"build:webpack": "tsx node_modules/webpack/bin/webpack.js -c webpack.config.ts",
|
||||
"build:prepare-dist": "npm run build:webpack && rimraf ./dist && tsc && tsx ./bin/copy-dist.ts",
|
||||
"build:webpack": "tsx node_modules/webpack/bin/webpack.js -c webpack.config.ts --progress",
|
||||
"build:ts": "tsc -p tsconfig.build.json",
|
||||
"build:clean": "rimraf ./dist ./build",
|
||||
"build:prepare-dist": "npm run build:clean && npm run build:ts && npm run build:webpack && tsx ./bin/copy-dist.ts",
|
||||
"test": "npm run client:test && npm run server:test",
|
||||
"server:test": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db TRILIUM_INTEGRATION_TEST=memory vitest",
|
||||
"server:coverage": "cross-env TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db TRILIUM_INTEGRATION_TEST=memory vitest --coverage",
|
||||
@ -100,6 +102,7 @@
|
||||
"electron-squirrel-startup": "1.0.1",
|
||||
"electron-window-state": "5.0.3",
|
||||
"escape-html": "1.0.3",
|
||||
"eslint-linter-browserify": "9.22.0",
|
||||
"express": "4.21.2",
|
||||
"express-rate-limit": "7.5.0",
|
||||
"express-session": "1.18.1",
|
||||
@ -167,7 +170,7 @@
|
||||
"@electron-forge/maker-zip": "7.7.0",
|
||||
"@electron-forge/plugin-auto-unpack-natives": "7.7.0",
|
||||
"@electron/rebuild": "3.7.1",
|
||||
"@eslint/js": "9.21.0",
|
||||
"@eslint/js": "9.22.0",
|
||||
"@playwright/test": "1.51.0",
|
||||
"@popperjs/core": "2.11.8",
|
||||
"@types/archiver": "6.0.3",
|
||||
@ -216,9 +219,10 @@
|
||||
"cross-env": "7.0.3",
|
||||
"css-loader": "7.1.2",
|
||||
"electron": "34.3.1",
|
||||
"eslint": "9.21.0",
|
||||
"eslint": "9.22.0",
|
||||
"esm": "3.2.25",
|
||||
"happy-dom": "17.3.0",
|
||||
"globals": "16.0.0",
|
||||
"happy-dom": "17.4.0",
|
||||
"i18next-http-backend": "3.0.2",
|
||||
"jsdoc": "4.0.4",
|
||||
"knockout": "3.5.1",
|
||||
|
48
src/public/app/services/eslint.spec.ts
Normal file
48
src/public/app/services/eslint.spec.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { lint } from "./eslint.js";
|
||||
import { trimIndentation } from "../../../../spec/support/utils.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Linter", () => {
|
||||
it("reports some basic errors", async () => {
|
||||
const result = await lint(trimIndentation`
|
||||
for (const i = 0; i<10; i++) {
|
||||
}
|
||||
`);
|
||||
expect(result).toMatchObject([
|
||||
{ message: "'i' is constant.", },
|
||||
{ message: "Empty block statement." }
|
||||
]);
|
||||
});
|
||||
|
||||
it("reports no error for correct script", async () => {
|
||||
const result = await lint(trimIndentation`
|
||||
const foo = "bar";
|
||||
console.log(foo.toString());
|
||||
for (const x of [ 1, 2, 3]) {
|
||||
console.log(x?.toString());
|
||||
}
|
||||
|
||||
api.showMessage("Hi");
|
||||
`);
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
|
||||
it("reports unused functions as warnings", async () => {
|
||||
const result = await lint(trimIndentation`
|
||||
function hello() { }
|
||||
function world() { }
|
||||
|
||||
console.log("Hello world");
|
||||
`);
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
message: "'hello' is defined but never used.",
|
||||
severity: 1
|
||||
},
|
||||
{
|
||||
message: "'world' is defined but never used.",
|
||||
severity: 1
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
25
src/public/app/services/eslint.ts
Normal file
25
src/public/app/services/eslint.ts
Normal file
@ -0,0 +1,25 @@
|
||||
export async function lint(code: string) {
|
||||
|
||||
const Linter = (await import("eslint-linter-browserify")).Linter;
|
||||
const js = (await import("@eslint/js"));
|
||||
const globals = (await import("globals"));
|
||||
|
||||
return new Linter().verify(code, [
|
||||
js.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
ecmaVersion: 2024
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
api: "readonly"
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"no-unused-vars": [ "warn", { vars: "local", args: "after-used" }]
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import libraryLoader from "./library_loader.js";
|
||||
import ws from "./ws.js";
|
||||
import froca from "./froca.js";
|
||||
import linkService from "./link.js";
|
||||
import { lint } from "./eslint.js";
|
||||
|
||||
function setupGlobs() {
|
||||
window.glob.isDesktop = utils.isDesktop;
|
||||
@ -18,7 +19,7 @@ function setupGlobs() {
|
||||
// required for ESLint plugin and CKEditor
|
||||
window.glob.getActiveContextNote = () => appContext.tabManager.getActiveContextNote();
|
||||
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
||||
window.glob.ESLINT = libraryLoader.ESLINT;
|
||||
window.glob.linter = lint;
|
||||
window.glob.appContext = appContext; // for debugging
|
||||
window.glob.froca = froca;
|
||||
window.glob.treeCache = froca; // compatibility for CKEditor builds for a while
|
||||
|
@ -42,10 +42,6 @@ const CODE_MIRROR: Library = {
|
||||
css: ["node_modules/codemirror/lib/codemirror.css", "node_modules/codemirror/addon/lint/lint.css"]
|
||||
};
|
||||
|
||||
const ESLINT: Library = {
|
||||
js: ["libraries/eslint/eslint.js"]
|
||||
};
|
||||
|
||||
const RELATION_MAP: Library = {
|
||||
js: ["node_modules/jsplumb/dist/js/jsplumb.min.js", "node_modules/panzoom/dist/panzoom.min.js"],
|
||||
css: ["stylesheets/relation_map.css"]
|
||||
@ -108,13 +104,17 @@ async function requireLibrary(library: Library) {
|
||||
}
|
||||
|
||||
if (library.js) {
|
||||
for (const scriptUrl of unwrapValue(library.js)) {
|
||||
for (const scriptUrl of await unwrapValue(library.js)) {
|
||||
await requireScript(scriptUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unwrapValue<T>(value: T | (() => T)) {
|
||||
async function unwrapValue<T>(value: T | (() => T) | Promise<(() => T)>) {
|
||||
if (value && typeof value === "object" && "then" in value) {
|
||||
return (await (value as Promise<() => T>))();
|
||||
}
|
||||
|
||||
if (typeof value === "function") {
|
||||
return (value as () => T)();
|
||||
}
|
||||
@ -183,7 +183,6 @@ export default {
|
||||
loadHighlightingTheme,
|
||||
CKEDITOR,
|
||||
CODE_MIRROR,
|
||||
ESLINT,
|
||||
RELATION_MAP,
|
||||
CALENDAR_WIDGET,
|
||||
KATEX,
|
||||
|
2
src/public/app/types.d.ts
vendored
2
src/public/app/types.d.ts
vendored
@ -6,6 +6,7 @@ import appContext from "./components/app_context.ts";
|
||||
import server from "./services/server.ts";
|
||||
import library_loader, { Library } from "./services/library_loader.ts";
|
||||
import type { init } from "i18next";
|
||||
import type { lint } from "./services/eslint.ts";
|
||||
|
||||
interface ElectronProcess {
|
||||
type: string;
|
||||
@ -44,6 +45,7 @@ interface CustomGlobals {
|
||||
triliumVersion: string;
|
||||
TRILIUM_SAFE_MODE: boolean;
|
||||
platform?: typeof process.platform;
|
||||
linter: typeof lint;
|
||||
}
|
||||
|
||||
type RequireMethod = (moduleName: string) => any;
|
||||
|
@ -353,7 +353,6 @@ export function processStringOrBuffer(data: string | Buffer | null) {
|
||||
}
|
||||
|
||||
const detectedEncoding = chardet.detect(data);
|
||||
console.log("Detected as ", detectedEncoding);
|
||||
switch (detectedEncoding) {
|
||||
case "UTF-16LE":
|
||||
return stripBom(data.toString("utf-16le"));
|
||||
|
@ -6,11 +6,11 @@
|
||||
<title><%= t("login.title") %></title>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="<%= assetPath %>/images/app-icons/ios/apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<% // TriliumNextTODO: move the css file to ${assetPath}/stylesheets/ %>
|
||||
<link rel="stylesheet" href="<%= appPath %>/login.css">
|
||||
<link rel="stylesheet" href="<%= assetPath %>/stylesheets/theme-light.css">
|
||||
<link rel="stylesheet" href="<%= assetPath %>/stylesheets/theme-next.css">
|
||||
<link rel="stylesheet" href="<%= assetPath %>/stylesheets/style.css">
|
||||
<% // TriliumNextTODO: move the css file to ${assetPath}/stylesheets/ %>
|
||||
<link rel="stylesheet" href="<%= appPath %>/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
24
tsconfig.build.json
Normal file
24
tsconfig.build.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "NodeNext",
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"lib": ["ES2023"],
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"include": ["./src/**/*.ts", "./src/**/*.js", "./*.ts"],
|
||||
"exclude": [
|
||||
"./**/*.spec.ts",
|
||||
"./src/public/**/*",
|
||||
"./*.config.ts",
|
||||
],
|
||||
"files": ["src/types.d.ts"]
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
"module": "NodeNext",
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
"outDir": "./build",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
|
@ -3,7 +3,7 @@
|
||||
"module": "NodeNext",
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
"outDir": "./build",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"resolveJsonModule": true,
|
||||
|
@ -19,7 +19,7 @@ const config: Configuration = {
|
||||
},
|
||||
output: {
|
||||
publicPath: `${assetPath}/app-dist/`,
|
||||
path: path.resolve(rootDir, "src/public/app-dist"),
|
||||
path: path.resolve(rootDir, "dist/src/public/app-dist"),
|
||||
filename: "[name].js"
|
||||
},
|
||||
plugins: [
|
||||
@ -75,7 +75,7 @@ const config: Configuration = {
|
||||
".mjs": [".mjs", ".mts"]
|
||||
}
|
||||
},
|
||||
devtool: "source-map",
|
||||
devtool: "nosources-source-map",
|
||||
target: "electron-renderer"
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user