Compare commits
86
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8203ca0c63 | ||
|
|
5e5492818a | ||
|
|
a6ec5f789d | ||
|
|
dade477b32 | ||
|
|
79f88dc3b8 | ||
|
|
4a12f8be61 | ||
|
|
044ad9edf9 | ||
|
|
57d2c6a7e1 | ||
|
|
46f6301fdd | ||
|
|
c3f300d87d | ||
|
|
1de558dd51 | ||
|
|
2711f3db13 | ||
|
|
ff3933b335 | ||
|
|
fa737638a8 | ||
|
|
97b7c417ab | ||
|
|
58d8005d38 | ||
|
|
507ac5181f | ||
|
|
b0cdb81533 | ||
|
|
fc0367a32f | ||
|
|
7cd30b640c | ||
|
|
a9855fe8d3 | ||
|
|
7a1272146c | ||
|
|
db61b6f390 | ||
|
|
887c294191 | ||
|
|
2f2a6291a2 | ||
|
|
1b3353118d | ||
|
|
e03f56ac31 | ||
|
|
d571a7f75e | ||
|
|
e3b765b9bd | ||
|
|
4da313826d | ||
|
|
948ed7a7fa | ||
|
|
f7fc64ebc4 | ||
|
|
b7f51d6f5c | ||
|
|
e185eeb6d7 | ||
|
|
90d703b870 | ||
|
|
75640f21e0 | ||
|
|
4aa43ae27a | ||
|
|
6b67671e29 | ||
|
|
220f361b69 | ||
|
|
a1d6457ced | ||
|
|
f7ade3c676 | ||
|
|
f656d9ca2d | ||
|
|
cefd90385d | ||
|
|
e5021b1d78 | ||
|
|
f0bd5132a3 | ||
|
|
d356fa41a0 | ||
|
|
a9e9ac1cfa | ||
|
|
1b3e720701 | ||
|
|
2461363d4f | ||
|
|
f29e74b6f4 | ||
|
|
89dfe82fe9 | ||
|
|
48a0f75c31 | ||
|
|
37103cf414 | ||
|
|
dec34916b2 | ||
|
|
64a4c196c0 | ||
|
|
41d596a1c9 | ||
|
|
bac0bc7b84 | ||
|
|
1ac6774821 | ||
|
|
7adb21ca59 | ||
|
|
4daf2729e5 | ||
|
|
1942c32128 | ||
|
|
b061a59433 | ||
|
|
ab867a9e50 | ||
|
|
968338aa97 | ||
|
|
b34102a973 | ||
|
|
378d1e1f1f | ||
|
|
3a8abe4415 | ||
|
|
6feb37dfd4 | ||
|
|
8042a18dc1 | ||
|
|
c78bf05fc3 | ||
|
|
c83fdb2a6e | ||
|
|
81fdd90e7a | ||
|
|
5ee84f8cf4 | ||
|
|
80d18bb10d | ||
|
|
2bb0f61da7 | ||
|
|
24386656fd | ||
|
|
453360fe61 | ||
|
|
beac1ed780 | ||
|
|
aa1b3810f1 | ||
|
|
ce3c1b6cc1 | ||
|
|
3f6b830f9b | ||
|
|
f0cb79799a | ||
|
|
7561462594 | ||
|
|
bfa8566284 | ||
|
|
a1aa5505a3 | ||
|
|
e77b9bb3d2 |
No files matched your search
+5
-1
@@ -9,4 +9,8 @@ README.md
|
|||||||
.git
|
.git
|
||||||
dev
|
dev
|
||||||
.build
|
.build
|
||||||
e2e
|
e2e
|
||||||
|
apps/nextjs/.next
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
+8
-4
@@ -12,10 +12,6 @@ AUTH_SECRET="supersecret"
|
|||||||
# or starting the project without any (which will show a randomly generated one).
|
# or starting the project without any (which will show a randomly generated one).
|
||||||
SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000
|
SECRET_ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
|
||||||
# Cron job API key is generated every time the container starts as it is required for communication between nextjs-api and tasks-api
|
|
||||||
# export CRON_JOB_API_KEY=$(openssl rand -base64 32)
|
|
||||||
# CRON_JOB_API_KEY="your-generated-api-key"
|
|
||||||
|
|
||||||
LOG_LEVEL='info'
|
LOG_LEVEL='info'
|
||||||
|
|
||||||
# This is how you can use the sqlite driver:
|
# This is how you can use the sqlite driver:
|
||||||
@@ -45,6 +41,14 @@ DB_URL='FULL_PATH_TO_YOUR_SQLITE_DB_FILE'
|
|||||||
|
|
||||||
TURBO_TELEMETRY_DISABLED=1
|
TURBO_TELEMETRY_DISABLED=1
|
||||||
|
|
||||||
|
# Turborepo remote cache (optional, for faster CI/local builds)
|
||||||
|
# Uncomment and fill in to enable remote caching locally.
|
||||||
|
# CI uses GitHub secrets for these values automatically.
|
||||||
|
# TURBO_API=https://your-cache-worker.workers.dev
|
||||||
|
# TURBO_TEAM=team_your_team
|
||||||
|
# TURBO_TOKEN=your-turbo-token
|
||||||
|
# TURBO_REMOTE_CACHE_SIGNATURE_KEY=your-signature-key
|
||||||
|
|
||||||
# Comma-separated paths to Docker-compatible Unix sockets.
|
# Comma-separated paths to Docker-compatible Unix sockets.
|
||||||
# Useful for connecting to multiple runtimes (Docker + Podman) simultaneously.
|
# Useful for connecting to multiple runtimes (Docker + Podman) simultaneously.
|
||||||
# When unset and no TCP hosts configured, defaults to /var/run/docker.sock.
|
# When unset and no TCP hosts configured, defaults to /var/run/docker.sock.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ body:
|
|||||||
options:
|
options:
|
||||||
# The below comment is used to insert a new version with on-release.yml
|
# The below comment is used to insert a new version with on-release.yml
|
||||||
#NEXT_VERSION#
|
#NEXT_VERSION#
|
||||||
|
- 1.61.0
|
||||||
- 1.60.1-beta.1
|
- 1.60.1-beta.1
|
||||||
- 1.60.0
|
- 1.60.0
|
||||||
- 1.59.3
|
- 1.59.3
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ concurrency:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: 3
|
FORCE_COLOR: 3
|
||||||
|
SKIP_ENV_VALIDATION: true
|
||||||
|
TURBO_API: ${{ secrets.TURBO_API }}
|
||||||
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||||
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
|
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
|
||||||
|
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha || github.event.before || 'HEAD~1' }}
|
||||||
|
TURBO_SCM_HEAD: ${{ github.sha }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
@@ -22,6 +29,8 @@ jobs:
|
|||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
@@ -31,31 +40,35 @@ jobs:
|
|||||||
run: cp .env.example .env
|
run: cp .env.example .env
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: pnpm lint && pnpm lint:ws
|
run: pnpm turbo lint --affected && pnpm lint:ws
|
||||||
|
|
||||||
format:
|
format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
|
|
||||||
- name: Format
|
- name: Format
|
||||||
run: pnpm format
|
run: pnpm turbo format --affected --continue -- --cache --cache-location node_modules/.cache/.prettiercache
|
||||||
|
|
||||||
typecheck:
|
typecheck:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
|
|
||||||
- name: Typecheck
|
- name: Typecheck
|
||||||
run: pnpm typecheck
|
run: pnpm turbo typecheck --affected
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -78,11 +91,12 @@ jobs:
|
|||||||
e2e:
|
e2e:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
id: build-docker-image
|
id: build-docker-image
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
@@ -90,8 +104,11 @@ jobs:
|
|||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
context: .
|
context: .
|
||||||
push: false
|
push: false
|
||||||
|
load: true
|
||||||
tags: homarr-e2e
|
tags: homarr-e2e
|
||||||
network: host
|
network: host
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
env:
|
env:
|
||||||
SKIP_ENV_VALIDATION: true
|
SKIP_ENV_VALIDATION: true
|
||||||
- name: Install playwright browsers
|
- name: Install playwright browsers
|
||||||
@@ -105,10 +122,12 @@ jobs:
|
|||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- name: Setup
|
- name: Setup
|
||||||
uses: ./tooling/github/setup
|
uses: ./tooling/github/setup
|
||||||
- name: Copy env
|
- name: Copy env
|
||||||
shell: bash
|
shell: bash
|
||||||
run: cp .env.example .env
|
run: cp .env.example .env
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build
|
run: pnpm turbo build --affected
|
||||||
@@ -5,6 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- beta
|
- beta
|
||||||
|
- next
|
||||||
- dev
|
- dev
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -34,7 +35,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
env:
|
env:
|
||||||
SKIP_RELEASE: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'dev' }}
|
SKIP_RELEASE: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'dev' || github.ref_name == 'next' }}
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.read-semver.outputs.version || steps.version-fallback.outputs.version }}
|
version: ${{ steps.read-semver.outputs.version || steps.version-fallback.outputs.version }}
|
||||||
git_ref: ${{ steps.read-git-ref.outputs.ref || github.ref }}
|
git_ref: ${{ steps.read-git-ref.outputs.ref || github.ref }}
|
||||||
@@ -54,7 +55,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
private-key: ${{ secrets.RENOVATE_MERGE_PRIVATE_KEY }}
|
||||||
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
client-id: ${{ secrets.RENOVATE_MERGE_APP_ID }}
|
||||||
permission-contents: write # required to commit package.json & changelog changes, merge them to dev and publish the release
|
permission-contents: write # required to commit package.json & changelog changes, merge them to dev / next and publish the release
|
||||||
|
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
@@ -66,7 +67,7 @@ jobs:
|
|||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
with:
|
with:
|
||||||
node-version: 24.15.0
|
node-version: 24.15.0
|
||||||
cache: "pnpm"
|
package-manager-cache: false
|
||||||
- run: npm i -g pnpm
|
- run: npm i -g pnpm
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -95,20 +96,21 @@ jobs:
|
|||||||
id: read-git-ref
|
id: read-git-ref
|
||||||
run: |
|
run: |
|
||||||
echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
echo "ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||||
- name: Update dev branch
|
- name: Update dev / next branch
|
||||||
if: env.SKIP_RELEASE == 'false'
|
if: env.SKIP_RELEASE == 'false'
|
||||||
continue-on-error: true # Prevent pipeline from failing when merge fails
|
continue-on-error: true # Prevent pipeline from failing when merge fails
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
||||||
|
UPSTREAM_BRANCH: ${{ github.ref_name == 'main' && 'dev' || 'next' }}
|
||||||
run: |
|
run: |
|
||||||
git config user.name "Releases Homarr"
|
git config user.name "Releases Homarr"
|
||||||
git config user.email "175486441+homarr-releases[bot]@users.noreply.github.com"
|
git config user.email "175486441+homarr-releases[bot]@users.noreply.github.com"
|
||||||
git remote set-url origin https://x-access-token:${{ steps.obtainToken.outputs.token }}@github.com/${{ github.repository }}.git
|
git remote set-url origin https://x-access-token:${{ steps.obtainToken.outputs.token }}@github.com/${{ github.repository }}.git
|
||||||
git fetch origin dev
|
git fetch origin ${{ env.UPSTREAM_BRANCH }}
|
||||||
git checkout dev
|
git checkout ${{ env.UPSTREAM_BRANCH }}
|
||||||
git pull origin dev
|
git pull origin ${{ env.UPSTREAM_BRANCH }}
|
||||||
git rebase ${{ github.ref_name }}
|
git rebase ${{ github.ref_name }}
|
||||||
git push origin dev
|
git push origin ${{ env.UPSTREAM_BRANCH }}
|
||||||
build-amd64:
|
build-amd64:
|
||||||
name: Build docker image for amd64
|
name: Build docker image for amd64
|
||||||
needs: release
|
needs: release
|
||||||
|
|||||||
+3854
-3841
File diff suppressed because it is too large.
Load diff
+1
-3
@@ -30,7 +30,7 @@ VOLUME /appdata
|
|||||||
|
|
||||||
# Enable homarr cli
|
# Enable homarr cli
|
||||||
COPY --from=builder /app/packages/cli/cli.cjs /app/apps/cli/cli.cjs
|
COPY --from=builder /app/packages/cli/cli.cjs /app/apps/cli/cli.cjs
|
||||||
RUN echo $'#!/bin/bash\nexport DISABLE_REDIS_LOGS=true\ncd /app/apps/cli && exec node ./cli.cjs "$@"' > /usr/bin/homarr
|
RUN echo $'#!/bin/bash\ncd /app/apps/cli && node ./cli.cjs "$@"' > /usr/bin/homarr
|
||||||
RUN chmod +x /usr/bin/homarr
|
RUN chmod +x /usr/bin/homarr
|
||||||
|
|
||||||
# Don't run production as root
|
# Don't run production as root
|
||||||
@@ -43,8 +43,6 @@ RUN mkdir -p /var/cache/nginx && \
|
|||||||
COPY --from=builder /app/apps/nextjs/next.config.ts .
|
COPY --from=builder /app/apps/nextjs/next.config.ts .
|
||||||
COPY --from=builder /app/apps/nextjs/package.json .
|
COPY --from=builder /app/apps/nextjs/package.json .
|
||||||
|
|
||||||
COPY --from=builder /app/apps/tasks/tasks.cjs ./apps/tasks/tasks.cjs
|
|
||||||
COPY --from=builder /app/apps/websocket/wssServer.cjs ./apps/websocket/wssServer.cjs
|
|
||||||
COPY --from=builder /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/build/better_sqlite3.node
|
COPY --from=builder /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/build/better_sqlite3.node
|
||||||
|
|
||||||
COPY --from=builder /app/packages/db/migrations ./db/migrations
|
COPY --from=builder /app/packages/db/migrations ./db/migrations
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import "@homarr/core/infrastructure/logs/env";
|
|||||||
import "@homarr/docker/env";
|
import "@homarr/docker/env";
|
||||||
|
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
import MillionLint from "@million/lint";
|
|
||||||
import createNextIntlPlugin from "next-intl/plugin";
|
import createNextIntlPlugin from "next-intl/plugin";
|
||||||
|
|
||||||
// Package path does not work... so we need to use relative path
|
// Package path does not work... so we need to use relative path
|
||||||
@@ -32,6 +31,8 @@ const nextConfig: NextConfig = {
|
|||||||
experimental: {
|
experimental: {
|
||||||
optimizePackageImports: ["@mantine/core", "@mantine/hooks", "@tabler/icons-react"],
|
optimizePackageImports: ["@mantine/core", "@mantine/hooks", "@tabler/icons-react"],
|
||||||
turbopackFileSystemCacheForDev: true,
|
turbopackFileSystemCacheForDev: true,
|
||||||
|
preloadEntriesOnStart: false,
|
||||||
|
webpackMemoryOptimizations: true,
|
||||||
},
|
},
|
||||||
transpilePackages: ["@homarr/ui", "@homarr/notifications", "@homarr/modals", "@homarr/spotlight", "@homarr/widgets"],
|
transpilePackages: ["@homarr/ui", "@homarr/notifications", "@homarr/modals", "@homarr/spotlight", "@homarr/widgets"],
|
||||||
images: {
|
images: {
|
||||||
@@ -83,8 +84,4 @@ const nextConfig: NextConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Skip transform is used because of webpack loader, without it for example 'Tooltip.Floating' will not work and show an error
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const withMillionLint = MillionLint.next({ rsc: true, skipTransform: true, telemetry: false });
|
|
||||||
|
|
||||||
export default withNextIntl(nextConfig);
|
export default withNextIntl(nextConfig);
|
||||||
@@ -44,9 +44,11 @@
|
|||||||
"@homarr/server-settings": "workspace:^0.1.0",
|
"@homarr/server-settings": "workspace:^0.1.0",
|
||||||
"@homarr/settings": "workspace:^0.1.0",
|
"@homarr/settings": "workspace:^0.1.0",
|
||||||
"@homarr/spotlight": "workspace:^0.1.0",
|
"@homarr/spotlight": "workspace:^0.1.0",
|
||||||
|
"@homarr/tasks": "workspace:^0.1.0",
|
||||||
"@homarr/translation": "workspace:^0.1.0",
|
"@homarr/translation": "workspace:^0.1.0",
|
||||||
"@homarr/ui": "workspace:^0.1.0",
|
"@homarr/ui": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
|
"@homarr/websocket": "workspace:^0.1.0",
|
||||||
"@homarr/widgets": "workspace:^0.1.0",
|
"@homarr/widgets": "workspace:^0.1.0",
|
||||||
"@mantine/colors-generator": "catalog:",
|
"@mantine/colors-generator": "catalog:",
|
||||||
"@mantine/core": "catalog:",
|
"@mantine/core": "catalog:",
|
||||||
@@ -54,7 +56,6 @@
|
|||||||
"@mantine/hooks": "catalog:",
|
"@mantine/hooks": "catalog:",
|
||||||
"@mantine/modals": "catalog:",
|
"@mantine/modals": "catalog:",
|
||||||
"@mantine/tiptap": "catalog:",
|
"@mantine/tiptap": "catalog:",
|
||||||
"@million/lint": "catalog:",
|
|
||||||
"@tabler/icons-react": "catalog:",
|
"@tabler/icons-react": "catalog:",
|
||||||
"@tanstack/react-query": "catalog:",
|
"@tanstack/react-query": "catalog:",
|
||||||
"@tanstack/react-query-devtools": "catalog:",
|
"@tanstack/react-query-devtools": "catalog:",
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export async function register() {
|
||||||
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||||
|
await import("@homarr/tasks");
|
||||||
|
await import("@homarr/websocket");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,12 +5,11 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/main.ts"
|
||||||
},
|
},
|
||||||
"main": "./src/main.ts",
|
"main": "./src/main.ts",
|
||||||
"types": "./src/main.ts",
|
"types": "./src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/main.ts --bundle --platform=node --loader:.scss=text --external:*.node --external:@opentelemetry/api --external:deasync --external:bcrypt --outfile=tasks.cjs",
|
|
||||||
"clean": "rm -rf .turbo node_modules",
|
"clean": "rm -rf .turbo node_modules",
|
||||||
"dev": "pnpm with-env tsx ./src/main.ts",
|
"dev": "pnpm with-env tsx ./src/main.ts",
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
@@ -24,7 +23,6 @@
|
|||||||
"@homarr/auth": "workspace:^0.1.0",
|
"@homarr/auth": "workspace:^0.1.0",
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/core": "workspace:^",
|
"@homarr/core": "workspace:^",
|
||||||
"@homarr/cron-job-api": "workspace:^0.1.0",
|
|
||||||
"@homarr/cron-jobs": "workspace:^0.1.0",
|
"@homarr/cron-jobs": "workspace:^0.1.0",
|
||||||
"@homarr/cron-jobs-core": "workspace:^0.1.0",
|
"@homarr/cron-jobs-core": "workspace:^0.1.0",
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import { handshakeAsync } from "@homarr/redis";
|
||||||
|
|
||||||
|
import { waitForRedisAsync } from "./main";
|
||||||
|
|
||||||
|
const { mockLogger } = vi.hoisted(() => ({
|
||||||
|
mockLogger: {
|
||||||
|
info: vi.fn(),
|
||||||
|
warn: vi.fn(),
|
||||||
|
error: vi.fn(),
|
||||||
|
debug: vi.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("./overrides", () => ({}));
|
||||||
|
|
||||||
|
vi.mock("@homarr/core/infrastructure/logs", () => ({
|
||||||
|
createLogger: () => mockLogger,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("@homarr/redis", () => ({
|
||||||
|
handshakeAsync: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("@homarr/cron-jobs", () => ({
|
||||||
|
jobGroup: {
|
||||||
|
initializeAsync: vi.fn().mockResolvedValue(undefined),
|
||||||
|
startAllAsync: vi.fn().mockResolvedValue(undefined),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("./on-start", () => ({
|
||||||
|
onStartAsync: vi.fn().mockResolvedValue(undefined),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("waitForRedisAsync", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
vi.useFakeTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("succeeds on first attempt", async () => {
|
||||||
|
vi.mocked(handshakeAsync).mockResolvedValueOnce(undefined);
|
||||||
|
|
||||||
|
await waitForRedisAsync();
|
||||||
|
|
||||||
|
expect(handshakeAsync).toHaveBeenCalledOnce();
|
||||||
|
expect(mockLogger.info).toHaveBeenCalledWith("Redis connection established");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("retries on failure then succeeds", async () => {
|
||||||
|
vi.mocked(handshakeAsync)
|
||||||
|
.mockRejectedValueOnce(new Error("ECONNREFUSED"))
|
||||||
|
.mockRejectedValueOnce(new Error("ECONNREFUSED"))
|
||||||
|
.mockResolvedValueOnce(undefined);
|
||||||
|
|
||||||
|
const promise = waitForRedisAsync();
|
||||||
|
|
||||||
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
expect(handshakeAsync).toHaveBeenCalledTimes(3);
|
||||||
|
expect(mockLogger.warn).toHaveBeenCalledTimes(2);
|
||||||
|
expect(mockLogger.info).toHaveBeenCalledWith("Redis connection established");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("logs error and proceeds after max retries exhausted", async () => {
|
||||||
|
vi.mocked(handshakeAsync).mockRejectedValue(new Error("ECONNREFUSED"));
|
||||||
|
|
||||||
|
const promise = waitForRedisAsync();
|
||||||
|
|
||||||
|
for (let index = 0; index < 10; index++) {
|
||||||
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
|
}
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
expect(handshakeAsync).toHaveBeenCalledTimes(10);
|
||||||
|
expect(mockLogger.error).toHaveBeenCalledWith("Redis did not become ready after retries, proceeding anyway");
|
||||||
|
expect(mockLogger.info).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("warns with attempt count on each retry", async () => {
|
||||||
|
vi.mocked(handshakeAsync).mockRejectedValueOnce(new Error("fail")).mockResolvedValueOnce(undefined);
|
||||||
|
|
||||||
|
const promise = waitForRedisAsync();
|
||||||
|
|
||||||
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
|
await promise;
|
||||||
|
|
||||||
|
expect(mockLogger.warn).toHaveBeenCalledWith("Redis not ready, retrying (1/10)...");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("does not retry after success", async () => {
|
||||||
|
vi.mocked(handshakeAsync).mockResolvedValueOnce(undefined);
|
||||||
|
|
||||||
|
await waitForRedisAsync();
|
||||||
|
|
||||||
|
expect(handshakeAsync).toHaveBeenCalledOnce();
|
||||||
|
expect(mockLogger.warn).not.toHaveBeenCalled();
|
||||||
|
expect(mockLogger.error).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
+19
-37
@@ -1,52 +1,34 @@
|
|||||||
// This import has to be the first import in the file so that the agent is overridden before any other modules are imported.
|
// This import has to be the first import in the file so that the agent is overridden before any other modules are imported.
|
||||||
import "./overrides";
|
import "./overrides";
|
||||||
|
|
||||||
import type { FastifyTRPCPluginOptions } from "@trpc/server/adapters/fastify";
|
|
||||||
import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify";
|
|
||||||
import fastify from "fastify";
|
|
||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
|
||||||
import type { JobRouter } from "@homarr/cron-job-api";
|
|
||||||
import { jobRouter } from "@homarr/cron-job-api";
|
|
||||||
import { CRON_JOB_API_KEY_HEADER, CRON_JOB_API_PATH, CRON_JOB_API_PORT } from "@homarr/cron-job-api/constants";
|
|
||||||
import { jobGroup } from "@homarr/cron-jobs";
|
import { jobGroup } from "@homarr/cron-jobs";
|
||||||
import { db } from "@homarr/db";
|
import { handshakeAsync } from "@homarr/redis";
|
||||||
|
|
||||||
import { JobManager } from "./job-manager";
|
|
||||||
import { onStartAsync } from "./on-start";
|
import { onStartAsync } from "./on-start";
|
||||||
|
|
||||||
const logger = createLogger({ module: "tasksMain" });
|
const logger = createLogger({ module: "tasks" });
|
||||||
|
|
||||||
const server = fastify({
|
const MAX_RETRIES = 10;
|
||||||
maxParamLength: 5000,
|
const RETRY_DELAY_MS = 500;
|
||||||
});
|
|
||||||
server.register(fastifyTRPCPlugin, {
|
export const waitForRedisAsync = async () => {
|
||||||
prefix: CRON_JOB_API_PATH,
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
||||||
trpcOptions: {
|
try {
|
||||||
router: jobRouter,
|
await handshakeAsync();
|
||||||
createContext: ({ req }) => ({
|
logger.info("Redis connection established");
|
||||||
manager: new JobManager(db, jobGroup),
|
return;
|
||||||
apiKey: req.headers[CRON_JOB_API_KEY_HEADER] as string | undefined,
|
} catch {
|
||||||
}),
|
logger.warn(`Redis not ready, retrying (${attempt}/${MAX_RETRIES})...`);
|
||||||
onError({ path, error }) {
|
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
||||||
logger.error(new ErrorWithMetadata("Error in tasks tRPC handler", { path }, { cause: error }));
|
}
|
||||||
},
|
}
|
||||||
} satisfies FastifyTRPCPluginOptions<JobRouter>["trpcOptions"],
|
logger.error("Redis did not become ready after retries, proceeding anyway");
|
||||||
});
|
};
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
|
await waitForRedisAsync();
|
||||||
await onStartAsync();
|
await onStartAsync();
|
||||||
await jobGroup.initializeAsync();
|
await jobGroup.initializeAsync();
|
||||||
await jobGroup.startAllAsync();
|
await jobGroup.startAllAsync();
|
||||||
|
|
||||||
try {
|
|
||||||
await server.listen({ port: CRON_JOB_API_PORT });
|
|
||||||
logger.info("Tasks web server started successfully", { port: CRON_JOB_API_PORT });
|
|
||||||
} catch (err) {
|
|
||||||
logger.error(
|
|
||||||
new ErrorWithMetadata("Failed to start tasks web server", { port: CRON_JOB_API_PORT }, { cause: err }),
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
@@ -9,5 +9,5 @@
|
|||||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||||
},
|
},
|
||||||
"include": ["."],
|
"include": ["."],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules", "*.cjs", "*.css"]
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,12 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/main.ts"
|
||||||
|
},
|
||||||
"main": "./src/main.ts",
|
"main": "./src/main.ts",
|
||||||
"types": "./src/main.ts",
|
"types": "./src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/main.ts --bundle --platform=node --outfile=wssServer.cjs --external:bcrypt --external:@opentelemetry/api --external:deasync --external:cpu-features --loader:.html=text --loader:.scss=text --loader:.node=text",
|
|
||||||
"clean": "rm -rf .turbo node_modules",
|
"clean": "rm -rf .turbo node_modules",
|
||||||
"dev": "pnpm with-env tsx ./src/main.ts",
|
"dev": "pnpm with-env tsx ./src/main.ts",
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||||
},
|
},
|
||||||
"include": ["."],
|
"include": ["."],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules", "*.cjs", "*.css"]
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
"name": "homarr-prebuilt-debian",
|
"name": "homarr-prebuilt-debian",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"better-sqlite3": "^12.9.0"
|
"better-sqlite3": "^12.10.0"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.33.2",
|
"packageManager": "pnpm@10.33.4",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.15.0",
|
"node": ">=24.15.0",
|
||||||
"pnpm": ">=10.33.2"
|
"pnpm": ">=10.33.4"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
|
|||||||
+6
-6
@@ -9,17 +9,17 @@ importers:
|
|||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
better-sqlite3:
|
better-sqlite3:
|
||||||
specifier: ^12.9.0
|
specifier: ^12.10.0
|
||||||
version: 12.9.0
|
version: 12.10.0
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
base64-js@1.5.1:
|
base64-js@1.5.1:
|
||||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||||
|
|
||||||
better-sqlite3@12.9.0:
|
better-sqlite3@12.10.0:
|
||||||
resolution: {integrity: sha512-wqUv4Gm3toFpHDQmaKD4QhZm3g1DjUBI0yzS4UBl6lElUmXFYdTQmmEDpAFa5o8FiFiymURypEnfVHzILKaxqQ==}
|
resolution: {integrity: sha512-CyzaZRQKyHkB2ZInfTTl2nvT33EbDpjkLEbE8/Zck3Ll6O0qqvuGdrJ45HgtH+HykRg88ITY3AdreBGN70aBSQ==}
|
||||||
engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x}
|
engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x || 26.x}
|
||||||
|
|
||||||
bindings@1.5.0:
|
bindings@1.5.0:
|
||||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
||||||
@@ -148,7 +148,7 @@ snapshots:
|
|||||||
|
|
||||||
base64-js@1.5.1: {}
|
base64-js@1.5.1: {}
|
||||||
|
|
||||||
better-sqlite3@12.9.0:
|
better-sqlite3@12.10.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
bindings: 1.5.0
|
bindings: 1.5.0
|
||||||
prebuild-install: 7.1.3
|
prebuild-install: 7.1.3
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { chromium } from "playwright";
|
import { chromium } from "@playwright/test";
|
||||||
import { GenericContainer } from "testcontainers";
|
import { GenericContainer } from "testcontainers";
|
||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { chromium } from "playwright";
|
import { chromium } from "@playwright/test";
|
||||||
import { describe, test } from "vitest";
|
import { describe, test } from "vitest";
|
||||||
|
|
||||||
import { OnboardingActions } from "./shared/actions/onboarding-actions";
|
import { OnboardingActions } from "./shared/actions/onboarding-actions";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createId } from "@paralleldrive/cuid2";
|
import { createId } from "@paralleldrive/cuid2";
|
||||||
import type { Page } from "playwright";
|
import type { Page } from "@playwright/test";
|
||||||
|
|
||||||
import * as sqliteSchema from "../../../packages/db/schema/sqlite";
|
import * as sqliteSchema from "../../../packages/db/schema/sqlite";
|
||||||
import type { SqliteDatabase } from "../e2e-db";
|
import type { SqliteDatabase } from "../e2e-db";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import type { Page } from "@playwright/test";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import type { Page } from "playwright";
|
|
||||||
import { expect } from "vitest";
|
import { expect } from "vitest";
|
||||||
|
|
||||||
import * as sqliteSchema from "../../../packages/db/schema/sqlite";
|
import * as sqliteSchema from "../../../packages/db/schema/sqlite";
|
||||||
|
|||||||
+14
-12
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "1.61.1",
|
"version": "1.61.1-beta.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env CI=true turbo build",
|
"build": "cross-env CI=true turbo build",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"db:migration:sqlite:run": "pnpm -F db migration:sqlite:run",
|
"db:migration:sqlite:run": "pnpm -F db migration:sqlite:run",
|
||||||
"db:push": "pnpm -F db push:sqlite",
|
"db:push": "pnpm -F db push:sqlite",
|
||||||
"db:studio": "pnpm -F db studio",
|
"db:studio": "pnpm -F db studio",
|
||||||
"dev": "turbo dev --parallel",
|
"dev": "pnpm -F nextjs dev",
|
||||||
"docker:dev": "docker compose -f ./development/development.docker-compose.yml up",
|
"docker:dev": "docker compose -f ./development/development.docker-compose.yml up",
|
||||||
"format": "turbo format --continue -- --cache --cache-location node_modules/.cache/.prettiercache",
|
"format": "turbo format --continue -- --cache --cache-location node_modules/.cache/.prettiercache",
|
||||||
"format:fix": "turbo format --continue -- --write --cache --cache-location node_modules/.cache/.prettiercache",
|
"format:fix": "turbo format --continue -- --write --cache --cache-location node_modules/.cache/.prettiercache",
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||||
|
"@playwright/test": "catalog:",
|
||||||
"@semantic-release/changelog": "catalog:",
|
"@semantic-release/changelog": "catalog:",
|
||||||
"@semantic-release/commit-analyzer": "catalog:",
|
"@semantic-release/commit-analyzer": "catalog:",
|
||||||
"@semantic-release/git": "catalog:",
|
"@semantic-release/git": "catalog:",
|
||||||
@@ -59,10 +60,10 @@
|
|||||||
"vite-tsconfig-paths": "catalog:",
|
"vite-tsconfig-paths": "catalog:",
|
||||||
"vitest": "catalog:"
|
"vitest": "catalog:"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.33.2",
|
"packageManager": "pnpm@10.33.4",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24.15.0",
|
"node": ">=24.15.0",
|
||||||
"pnpm": ">=10.33.2"
|
"pnpm": ">=10.33.4"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
@@ -79,23 +80,23 @@
|
|||||||
"overrides": {
|
"overrides": {
|
||||||
"@babel/helpers@<7.26.10": ">=7.29.2",
|
"@babel/helpers@<7.26.10": ">=7.29.2",
|
||||||
"@babel/runtime@<7.26.10": ">=7.29.2",
|
"@babel/runtime@<7.26.10": ">=7.29.2",
|
||||||
"axios@>=1.0.0 <1.8.2": ">=1.16.0",
|
"axios@>=1.0.0 <1.8.2": ">=1.16.1",
|
||||||
"brace-expansion@>=2.0.0 <=2.0.1": ">=5.0.5",
|
"brace-expansion@>=2.0.0 <=2.0.1": ">=5.0.6",
|
||||||
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.5",
|
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.6",
|
||||||
"esbuild@<=0.24.2": ">=0.28.0",
|
"esbuild@<=0.24.2": ">=0.28.0",
|
||||||
"form-data@>=4.0.0 <4.0.4": ">=4.0.5",
|
"form-data@>=4.0.0 <4.0.4": ">=4.0.5",
|
||||||
"hono@<4.6.5": ">=4.12.16",
|
"hono@<4.6.5": ">=4.12.19",
|
||||||
"linkifyjs@<4.3.2": ">=4.3.2",
|
"linkifyjs@<4.3.2": ">=4.3.3",
|
||||||
"nanoid@>=4.0.0 <5.0.9": ">=5.1.11",
|
"nanoid@>=4.0.0 <5.0.9": ">=5.1.11",
|
||||||
"prismjs@<1.30.0": ">=1.30.0",
|
"prismjs@<1.30.0": ">=1.30.0",
|
||||||
"proxmox-api>undici": "7.24.6",
|
"proxmox-api>undici": "7.24.6",
|
||||||
"react-is": "^19.2.5",
|
"react-is": "^19.2.6",
|
||||||
"rollup@>=4.0.0 <4.22.4": ">=4.60.2",
|
"rollup@>=4.0.0 <4.22.4": ">=4.60.4",
|
||||||
"sha.js@<=2.4.11": ">=2.4.12",
|
"sha.js@<=2.4.11": ">=2.4.12",
|
||||||
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2",
|
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2",
|
||||||
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2",
|
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2",
|
||||||
"tmp@<=0.2.3": ">=0.2.5",
|
"tmp@<=0.2.3": ">=0.2.5",
|
||||||
"vite@>=5.0.0 <=5.4.18": ">=8.0.10"
|
"vite@>=5.0.0 <=5.4.18": ">=8.0.13"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@types/node-unifi": "patches/@types__node-unifi.patch",
|
"@types/node-unifi": "patches/@types__node-unifi.patch",
|
||||||
@@ -104,6 +105,7 @@
|
|||||||
"allowUnusedPatches": true,
|
"allowUnusedPatches": true,
|
||||||
"ignoredBuiltDependencies": [
|
"ignoredBuiltDependencies": [
|
||||||
"@scarf/scarf",
|
"@scarf/scarf",
|
||||||
|
"@swc/core",
|
||||||
"core-js-pure",
|
"core-js-pure",
|
||||||
"protobufjs"
|
"protobufjs"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
"@homarr/auth": "workspace:^0.1.0",
|
"@homarr/auth": "workspace:^0.1.0",
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
"@homarr/core": "workspace:^0.1.0",
|
||||||
"@homarr/cron-job-api": "workspace:^0.1.0",
|
|
||||||
"@homarr/cron-job-status": "workspace:^0.1.0",
|
"@homarr/cron-job-status": "workspace:^0.1.0",
|
||||||
"@homarr/cron-jobs": "workspace:^0.1.0",
|
"@homarr/cron-jobs": "workspace:^0.1.0",
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
|
|||||||
@@ -2,33 +2,36 @@ import { observable } from "@trpc/server/observable";
|
|||||||
import z from "zod/v4";
|
import z from "zod/v4";
|
||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { jobGroupKeys, jobNameSchema } from "@homarr/cron-job-api";
|
|
||||||
import { cronJobApi } from "@homarr/cron-job-api/client";
|
|
||||||
import type { TaskStatus } from "@homarr/cron-job-status";
|
import type { TaskStatus } from "@homarr/cron-job-status";
|
||||||
import { createCronJobStatusChannel } from "@homarr/cron-job-status";
|
import { createCronJobStatusChannel } from "@homarr/cron-job-status";
|
||||||
|
import { jobGroup } from "@homarr/cron-jobs";
|
||||||
|
import { JobManager } from "@homarr/cron-jobs/job-manager";
|
||||||
|
|
||||||
import { createTRPCRouter, permissionRequiredProcedure } from "../trpc";
|
import { createTRPCRouter, permissionRequiredProcedure } from "../trpc";
|
||||||
|
|
||||||
|
const jobGroupKeys = jobGroup.getKeys();
|
||||||
|
const jobNameSchema = z.enum(jobGroup.getKeys());
|
||||||
|
|
||||||
const logger = createLogger({ module: "cronJobsRouter" });
|
const logger = createLogger({ module: "cronJobsRouter" });
|
||||||
|
|
||||||
export const cronJobsRouter = createTRPCRouter({
|
export const cronJobsRouter = createTRPCRouter({
|
||||||
triggerJob: permissionRequiredProcedure
|
triggerJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await cronJobApi.trigger.mutate(input);
|
await new JobManager(ctx.db, jobGroup).triggerAsync(input);
|
||||||
}),
|
}),
|
||||||
startJob: permissionRequiredProcedure
|
startJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await cronJobApi.start.mutate(input);
|
await new JobManager(ctx.db, jobGroup).startAsync(input);
|
||||||
}),
|
}),
|
||||||
stopJob: permissionRequiredProcedure
|
stopJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(({ input, ctx }) => {
|
||||||
await cronJobApi.stop.mutate(input);
|
new JobManager(ctx.db, jobGroup).stop(input);
|
||||||
}),
|
}),
|
||||||
updateJobInterval: permissionRequiredProcedure
|
updateJobInterval: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
@@ -38,23 +41,23 @@ export const cronJobsRouter = createTRPCRouter({
|
|||||||
cron: z.string(),
|
cron: z.string(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await cronJobApi.updateInterval.mutate(input);
|
await new JobManager(ctx.db, jobGroup).updateIntervalAsync(input.name, input.cron);
|
||||||
}),
|
}),
|
||||||
disableJob: permissionRequiredProcedure
|
disableJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await cronJobApi.disable.mutate(input);
|
await new JobManager(ctx.db, jobGroup).disableAsync(input);
|
||||||
}),
|
}),
|
||||||
enableJob: permissionRequiredProcedure
|
enableJob: permissionRequiredProcedure
|
||||||
.requiresPermission("admin")
|
.requiresPermission("admin")
|
||||||
.input(jobNameSchema)
|
.input(jobNameSchema)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
await cronJobApi.enable.mutate(input);
|
await new JobManager(ctx.db, jobGroup).enableAsync(input);
|
||||||
}),
|
}),
|
||||||
getJobs: permissionRequiredProcedure.requiresPermission("admin").query(async () => {
|
getJobs: permissionRequiredProcedure.requiresPermission("admin").query(async ({ ctx }) => {
|
||||||
return await cronJobApi.getAll.query();
|
return await new JobManager(ctx.db, jobGroup).getAllAsync();
|
||||||
}),
|
}),
|
||||||
subscribeToStatusUpdates: permissionRequiredProcedure.requiresPermission("admin").subscription(() => {
|
subscribeToStatusUpdates: permissionRequiredProcedure.requiresPermission("admin").subscription(() => {
|
||||||
return observable<TaskStatus>((emit) => {
|
return observable<TaskStatus>((emit) => {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --external:better-sqlite3 --external:mysql2 --external:pg --loader:.html=text --loader:.node=text",
|
"build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --loader:.html=text --loader:.node=text",
|
||||||
"clean": "rm -rf .turbo node_modules",
|
"clean": "rm -rf .turbo node_modules",
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
@@ -25,16 +25,12 @@
|
|||||||
},
|
},
|
||||||
"prettier": "@homarr/prettier-config",
|
"prettier": "@homarr/prettier-config",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@drizzle-team/brocli": "catalog:",
|
||||||
"@homarr/auth": "workspace:^0.1.0",
|
"@homarr/auth": "workspace:^0.1.0",
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
"@homarr/common": "workspace:^0.1.0",
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
|
||||||
"@homarr/db": "workspace:^0.1.0",
|
"@homarr/db": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"better-sqlite3": "catalog:",
|
"dotenv": "catalog:"
|
||||||
"dotenv": "catalog:",
|
|
||||||
"drizzle-orm": "catalog:",
|
|
||||||
"mysql2": "catalog:",
|
|
||||||
"pg": "catalog:"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
import Database from "better-sqlite3";
|
|
||||||
import { drizzle as drizzleSqlite } from "drizzle-orm/better-sqlite3";
|
|
||||||
import { drizzle as drizzleMysql } from "drizzle-orm/mysql2";
|
|
||||||
import { drizzle as drizzlePostgres } from "drizzle-orm/node-postgres";
|
|
||||||
import mysql from "mysql2";
|
|
||||||
import type { Pool as MysqlPool } from "mysql2";
|
|
||||||
import { Pool as PostgresPool } from "pg";
|
|
||||||
|
|
||||||
import { DB_CASING } from "@homarr/core/infrastructure/db/constants";
|
|
||||||
import { dbEnv } from "@homarr/core/infrastructure/db/env";
|
|
||||||
import { schema } from "@homarr/db/schema";
|
|
||||||
|
|
||||||
const CONNECT_TIMEOUT_MS = 10_000;
|
|
||||||
|
|
||||||
const dbConfig = {
|
|
||||||
schema,
|
|
||||||
casing: DB_CASING,
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CliDatabase = ReturnType<typeof drizzleSqlite<typeof schema>>;
|
|
||||||
|
|
||||||
type CliConnection =
|
|
||||||
| { driver: "better-sqlite3"; raw: Database.Database; db: CliDatabase }
|
|
||||||
| { driver: "mysql2"; raw: MysqlPool; db: CliDatabase }
|
|
||||||
| { driver: "node-postgres"; raw: PostgresPool; db: CliDatabase };
|
|
||||||
|
|
||||||
let connection: CliConnection | null = null;
|
|
||||||
|
|
||||||
const createMysqlPool = () => {
|
|
||||||
const poolOptions = {
|
|
||||||
maxIdle: 0,
|
|
||||||
idleTimeout: 60000,
|
|
||||||
enableKeepAlive: true,
|
|
||||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!dbEnv.HOST) {
|
|
||||||
return mysql.createPool({ ...poolOptions, uri: dbEnv.URL });
|
|
||||||
}
|
|
||||||
|
|
||||||
return mysql.createPool({
|
|
||||||
...poolOptions,
|
|
||||||
host: dbEnv.HOST,
|
|
||||||
port: dbEnv.PORT,
|
|
||||||
database: dbEnv.NAME,
|
|
||||||
user: dbEnv.USER,
|
|
||||||
password: dbEnv.PASSWORD,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const createPostgresPool = () => {
|
|
||||||
const poolOptions = {
|
|
||||||
max: 1,
|
|
||||||
idleTimeoutMillis: 60000,
|
|
||||||
connectionTimeoutMillis: CONNECT_TIMEOUT_MS,
|
|
||||||
allowExitOnIdle: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!dbEnv.HOST) {
|
|
||||||
return new PostgresPool({
|
|
||||||
...poolOptions,
|
|
||||||
connectionString: dbEnv.URL,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PostgresPool({
|
|
||||||
...poolOptions,
|
|
||||||
host: dbEnv.HOST,
|
|
||||||
port: dbEnv.PORT,
|
|
||||||
database: dbEnv.NAME,
|
|
||||||
user: dbEnv.USER,
|
|
||||||
password: dbEnv.PASSWORD,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const connectionFactories = {
|
|
||||||
"better-sqlite3": (): CliConnection => {
|
|
||||||
const raw = new Database(dbEnv.URL);
|
|
||||||
const db = drizzleSqlite(raw, dbConfig);
|
|
||||||
return { driver: "better-sqlite3", raw, db };
|
|
||||||
},
|
|
||||||
mysql2: (): CliConnection => {
|
|
||||||
const raw = createMysqlPool();
|
|
||||||
const db = drizzleMysql(raw, { ...dbConfig, mode: "default" }) as unknown as CliDatabase;
|
|
||||||
return { driver: "mysql2", raw, db };
|
|
||||||
},
|
|
||||||
"node-postgres": (): CliConnection => {
|
|
||||||
const raw = createPostgresPool();
|
|
||||||
const db = drizzlePostgres({ ...dbConfig, client: raw }) as unknown as CliDatabase;
|
|
||||||
return { driver: "node-postgres", raw, db };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeHandlers: Record<CliConnection["driver"], (entry: CliConnection) => Promise<void>> = {
|
|
||||||
"better-sqlite3": async (entry) => {
|
|
||||||
(entry as Extract<CliConnection, { driver: "better-sqlite3" }>).raw.close();
|
|
||||||
},
|
|
||||||
mysql2: (entry) => {
|
|
||||||
const pool = (entry as Extract<CliConnection, { driver: "mysql2" }>).raw;
|
|
||||||
return new Promise<void>((resolve, reject) => {
|
|
||||||
pool.end((err) => (err ? reject(err) : resolve()));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"node-postgres": async (entry) => {
|
|
||||||
await (entry as Extract<CliConnection, { driver: "node-postgres" }>).raw.end();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getCliDb = (): CliDatabase => {
|
|
||||||
if (connection) {
|
|
||||||
return connection.db;
|
|
||||||
}
|
|
||||||
|
|
||||||
const driver = dbEnv.DRIVER ?? "better-sqlite3";
|
|
||||||
connection = connectionFactories[driver]();
|
|
||||||
return connection.db;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const closeCliDbAsync = async (): Promise<void> => {
|
|
||||||
if (!connection) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const current = connection;
|
|
||||||
connection = null;
|
|
||||||
await closeHandlers[current.driver](current);
|
|
||||||
};
|
|
||||||
@@ -1,35 +1,36 @@
|
|||||||
import { eq } from "drizzle-orm";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db, eq } from "@homarr/db";
|
||||||
import { requireCredentialsProvider } from "../errors";
|
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
|
|
||||||
export async function fixUsernamesHandler(): Promise<number> {
|
export const fixUsernames = command({
|
||||||
requireCredentialsProvider();
|
name: "fix-usernames",
|
||||||
|
desc: "Changes all credentials usernames to lowercase",
|
||||||
const db = getCliDb();
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
const credentialUsers = await db.query.users.findMany({
|
handler: async () => {
|
||||||
where: eq(users.provider, "credentials"),
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
});
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
for (const user of credentialUsers) {
|
|
||||||
if (!user.name) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (user.name === user.name.toLowerCase()) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await db
|
const credentialUsers = await db.query.users.findMany({
|
||||||
.update(users)
|
where: eq(users.provider, "credentials"),
|
||||||
.set({
|
});
|
||||||
name: user.name.toLowerCase(),
|
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
console.log(`Changed username from ${user.name} to ${user.name.toLowerCase()}`);
|
for (const user of credentialUsers) {
|
||||||
}
|
if (!user.name) continue;
|
||||||
|
if (user.name === user.name.toLowerCase()) continue;
|
||||||
|
|
||||||
console.log("All usernames have been fixed");
|
await db
|
||||||
return 0;
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
name: user.name.toLowerCase(),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
|
console.log(`Changed username from ${user.name} to ${user.name.toLowerCase()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("All usernames have been fixed");
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,50 +1,39 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError } from "../errors";
|
|
||||||
import { integrations } from "@homarr/db/schema";
|
import { integrations } from "@homarr/db/schema";
|
||||||
|
|
||||||
const integrationLookup: Record<
|
export const integrationsDelete = command({
|
||||||
"id" | "name",
|
name: "delete",
|
||||||
(db: CliDatabase, value: string) => Promise<{ id: string; name: string } | undefined>
|
desc: "Delete an integration by id or name",
|
||||||
> = {
|
options: {
|
||||||
id: (db, value) =>
|
id: string("id").alias("i").desc("ID of the integration"),
|
||||||
db.query.integrations.findFirst({
|
name: string("name").alias("n").desc("Name of the integration"),
|
||||||
where: eq(integrations.id, value),
|
},
|
||||||
}),
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
name: (db, value) =>
|
handler: async (options) => {
|
||||||
db.query.integrations.findFirst({
|
if (!options.id && !options.name) {
|
||||||
where: eq(integrations.name, value),
|
console.error("Either --id or --name must be provided");
|
||||||
}),
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
export async function integrationsDeleteHandler(args: string[]): Promise<number> {
|
let entry;
|
||||||
const { values } = parseArgs({
|
if (options.id) {
|
||||||
args,
|
entry = await db.query.integrations.findFirst({
|
||||||
options: {
|
where: eq(integrations.id, options.id),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
name: { type: "string", short: "n" },
|
} else if (options.name) {
|
||||||
},
|
entry = await db.query.integrations.findFirst({
|
||||||
});
|
where: eq(integrations.name, options.name),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.name ? "name" : null;
|
if (!entry) {
|
||||||
const lookupValue = values.id ?? values.name;
|
console.error("Integration not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
||||||
throw new CliError("Either --id or --name must be provided", 2);
|
console.log(`Integration ${entry.name} (${entry.id}) deleted`);
|
||||||
}
|
},
|
||||||
|
});
|
||||||
const db = getCliDb();
|
|
||||||
const entry = await integrationLookup[lookupKey](db, lookupValue);
|
|
||||||
|
|
||||||
if (!entry) {
|
|
||||||
throw new CliError("Integration not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(integrations).where(eq(integrations.id, entry.id));
|
|
||||||
console.log(`Integration ${entry.name} (${entry.id}) deleted`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,21 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db } from "@homarr/db";
|
||||||
import { printTable } from "../utils";
|
|
||||||
|
|
||||||
export async function integrationsListHandler(args: string[] = []): Promise<number> {
|
export const integrationsList = command({
|
||||||
const { values } = parseArgs({
|
name: "list",
|
||||||
args,
|
desc: "List all integrations (id and name)",
|
||||||
options: {
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
json: { type: "boolean", default: false },
|
handler: async () => {
|
||||||
},
|
const all = await db.query.integrations.findMany();
|
||||||
strict: false,
|
if (all.length === 0) {
|
||||||
});
|
console.log("No integrations found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const db = getCliDb();
|
console.log("ID\t\t\t\tName");
|
||||||
const all = await db.query.integrations.findMany();
|
for (const i of all) {
|
||||||
|
console.log(`${i.id}\t${i.name}`);
|
||||||
if (values.json) {
|
}
|
||||||
const output = all.map((i) => ({ id: i.id, name: i.name, kind: i.kind, url: i.url }));
|
},
|
||||||
console.log(JSON.stringify(output, null, 2));
|
});
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (all.length === 0) {
|
|
||||||
console.log("No integrations found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printTable(
|
|
||||||
["ID", "Name", "Kind", "URL"],
|
|
||||||
all.map((i) => [i.id, i.name, i.kind, i.url]),
|
|
||||||
);
|
|
||||||
console.log(`\n${all.length} integration(s) total`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
|
import { integrationsDelete } from "./integrations-delete";
|
||||||
|
import { integrationsList } from "./integrations-list";
|
||||||
|
|
||||||
|
export const integrationsRoot = command({
|
||||||
|
name: "integrations",
|
||||||
|
desc: "Group of commands to manage integrations",
|
||||||
|
subcommands: [integrationsList, integrationsDelete],
|
||||||
|
});
|
||||||
@@ -1,98 +1,94 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { createId } from "@homarr/common";
|
import { createId } from "@homarr/common";
|
||||||
import { generateSecureRandomToken } from "../utils";
|
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||||
import { and, count, eq, max } from "drizzle-orm";
|
import { and, count, db, eq } from "@homarr/db";
|
||||||
|
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
|
||||||
import { usernameSchema } from "@homarr/validation/user";
|
import { usernameSchema } from "@homarr/validation/user";
|
||||||
|
|
||||||
export async function recreateAdminHandler(args: string[]): Promise<number> {
|
export const recreateAdmin = command({
|
||||||
requireCredentialsProvider();
|
name: "recreate-admin",
|
||||||
|
desc: "Recreate credentials admin user if none exists anymore",
|
||||||
|
options: {
|
||||||
|
username: string("username").required().alias("u").desc("Name of the admin"),
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
handler: async (options) => {
|
||||||
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const result = await usernameSchema.safeParseAsync(options.username);
|
||||||
args,
|
|
||||||
options: {
|
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!values.username) {
|
if (!result.success) {
|
||||||
throw new CliError("Missing required option: --username / -u", 2);
|
console.error("Invalid username:");
|
||||||
}
|
console.error(result.error.issues.map((error) => `- ${error.message}`).join("\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const result = await usernameSchema.safeParseAsync(values.username);
|
const totalCount = await db
|
||||||
if (!result.success) {
|
.select({
|
||||||
const messages = result.error.issues.map((issue) => `- ${issue.message}`).join("\n");
|
count: count(),
|
||||||
throw new CliError(`Invalid username:\n${messages}`, 2);
|
})
|
||||||
}
|
.from(groupPermissions)
|
||||||
|
.leftJoin(groupMembers, eq(groupMembers.groupId, groupPermissions.groupId))
|
||||||
|
.leftJoin(users, eq(users.id, groupMembers.userId))
|
||||||
|
.where(and(eq(groupPermissions.permission, "admin"), eq(users.provider, "credentials")))
|
||||||
|
.then((rows) => rows.at(0)?.count ?? 0);
|
||||||
|
|
||||||
const db = getCliDb();
|
if (totalCount > 0) {
|
||||||
|
console.error("Credentials admin user exists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const totalCount = await db
|
const existingUser = await db.query.users.findFirst({
|
||||||
.select({
|
where: eq(users.name, result.data),
|
||||||
count: count(),
|
});
|
||||||
})
|
|
||||||
.from(groupPermissions)
|
|
||||||
.leftJoin(groupMembers, eq(groupMembers.groupId, groupPermissions.groupId))
|
|
||||||
.leftJoin(users, eq(users.id, groupMembers.userId))
|
|
||||||
.where(and(eq(groupPermissions.permission, "admin"), eq(users.provider, "credentials")))
|
|
||||||
.then((rows: { count: number }[]) => rows.at(0)?.count ?? 0);
|
|
||||||
|
|
||||||
if (totalCount > 0) {
|
if (existingUser) {
|
||||||
throw new CliError("Credentials admin user exists");
|
console.error("User with this name already exists");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const existingUser = await db.query.users.findFirst({
|
const temporaryGroupId = createId();
|
||||||
where: eq(users.name, result.data),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (existingUser) {
|
const maxPosition = await getMaxGroupPositionAsync(db);
|
||||||
throw new CliError("User with this name already exists");
|
await db.insert(groups).values({
|
||||||
}
|
id: temporaryGroupId,
|
||||||
|
name: temporaryGroupId,
|
||||||
|
position: maxPosition + 1,
|
||||||
|
});
|
||||||
|
|
||||||
const temporaryGroupId = createId();
|
await db.insert(groupPermissions).values({
|
||||||
const maxPosition = await db
|
groupId: temporaryGroupId,
|
||||||
.select({ value: max(groups.position) })
|
permission: "admin",
|
||||||
.from(groups)
|
});
|
||||||
.then((result: { value: number | null }[]) => result[0]?.value ?? 1);
|
|
||||||
|
|
||||||
await db.insert(groups).values({
|
const password = generateSecureRandomToken(24);
|
||||||
id: temporaryGroupId,
|
const hashedPassword = await hashPasswordAsync(password);
|
||||||
name: temporaryGroupId,
|
|
||||||
position: maxPosition + 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
await db.insert(groupPermissions).values({
|
const userId = createId();
|
||||||
groupId: temporaryGroupId,
|
await db.insert(users).values({
|
||||||
permission: "admin",
|
id: userId,
|
||||||
});
|
name: result.data,
|
||||||
|
provider: "credentials",
|
||||||
|
password: hashedPassword,
|
||||||
|
});
|
||||||
|
|
||||||
const password = generateSecureRandomToken(24);
|
await db.insert(groupMembers).values({
|
||||||
const hashedPassword = await hashPasswordAsync(password);
|
groupId: temporaryGroupId,
|
||||||
const userId = createId();
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
await db.insert(users).values({
|
console.log(
|
||||||
id: userId,
|
"We created a new admin user for you. Please keep in mind, that the admin group of it has a temporary name. You should change it to something more meaningful.",
|
||||||
name: result.data,
|
);
|
||||||
provider: "credentials",
|
console.log(`\tUsername: ${result.data}`);
|
||||||
password: hashedPassword,
|
console.log(`\tPassword: ${password}`);
|
||||||
});
|
console.log(`\tGroup: ${temporaryGroupId}`);
|
||||||
|
console.log(""); // Empty line for better readability
|
||||||
await db.insert(groupMembers).values({
|
},
|
||||||
groupId: temporaryGroupId,
|
});
|
||||||
userId,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
"We created a new admin user for you. Please keep in mind, that the admin group of it has a temporary name. You should change it to something more meaningful.",
|
|
||||||
);
|
|
||||||
console.log(`\tUsername: ${result.data}`);
|
|
||||||
console.log(`\tPassword: ${password}`);
|
|
||||||
console.log(`\tGroup: ${temporaryGroupId}`);
|
|
||||||
console.log("");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,48 +1,46 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { generateSecureRandomToken } from "../utils";
|
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { sessions, users } from "@homarr/db/schema";
|
import { sessions, users } from "@homarr/db/schema";
|
||||||
|
|
||||||
export async function resetPasswordHandler(args: string[]): Promise<number> {
|
export const resetPassword = command({
|
||||||
requireCredentialsProvider();
|
name: "reset-password",
|
||||||
|
desc: "Reset password for a user",
|
||||||
|
options: {
|
||||||
|
username: string("username").required().alias("u").desc("Name of the user"),
|
||||||
|
},
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
handler: async (options) => {
|
||||||
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
|
console.error("Credentials provider is not enabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const user = await db.query.users.findFirst({
|
||||||
args,
|
where: and(eq(users.name, options.username), eq(users.provider, "credentials")),
|
||||||
options: {
|
});
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!values.username) {
|
if (!user?.password) {
|
||||||
throw new CliError("Missing required option: --username / -u", 2);
|
console.error(`User ${options.username} not found`);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const db = getCliDb();
|
// Generates a new password with 48 characters
|
||||||
const user = await db.query.users.findFirst({
|
const newPassword = generateSecureRandomToken(24);
|
||||||
where: and(eq(users.name, values.username), eq(users.provider, "credentials")),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!user?.password) {
|
await db
|
||||||
throw new CliError(`User ${values.username} not found`);
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
password: await hashPasswordAsync(newPassword),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
const newPassword = generateSecureRandomToken(24);
|
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
||||||
|
console.log(`All sessions for user ${options.username} have been deleted`);
|
||||||
|
|
||||||
await db
|
console.log("You can now login with the new password");
|
||||||
.update(users)
|
console.log(`New password for user ${options.username}: ${newPassword}`);
|
||||||
.set({
|
},
|
||||||
password: await hashPasswordAsync(newPassword),
|
});
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
|
||||||
console.log(`All sessions for user ${values.username} have been deleted`);
|
|
||||||
console.log("You can now login with the new password");
|
|
||||||
console.log(`New password for user ${values.username}: ${newPassword}`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,47 +1,39 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError } from "../errors";
|
|
||||||
import { users } from "@homarr/db/schema";
|
import { users } from "@homarr/db/schema";
|
||||||
|
|
||||||
const userLookup: Record<"id" | "username", (db: CliDatabase, value: string) => Promise<{ id: string; name: string | null } | undefined>> = {
|
export const usersDelete = command({
|
||||||
id: (db, value) =>
|
name: "delete",
|
||||||
db.query.users.findFirst({
|
desc: "Delete a user by id or username",
|
||||||
where: eq(users.id, value),
|
options: {
|
||||||
}),
|
id: string("id").alias("i").desc("ID of the user"),
|
||||||
username: (db, value) =>
|
username: string("username").alias("u").desc("Name of the user"),
|
||||||
db.query.users.findFirst({
|
},
|
||||||
where: eq(users.name, value),
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
}),
|
handler: async (options) => {
|
||||||
};
|
if (!options.id && !options.username) {
|
||||||
|
console.error("Either --id or --username must be provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
export async function usersDeleteHandler(args: string[]): Promise<number> {
|
let user;
|
||||||
const { values } = parseArgs({
|
if (options.id) {
|
||||||
args,
|
user = await db.query.users.findFirst({
|
||||||
options: {
|
where: eq(users.id, options.id),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
username: { type: "string", short: "u" },
|
} else if (options.username) {
|
||||||
},
|
user = await db.query.users.findFirst({
|
||||||
});
|
where: eq(users.name, options.username),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.username ? "username" : null;
|
if (!user) {
|
||||||
const lookupValue = values.id ?? values.username;
|
console.error("User not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db.delete(users).where(eq(users.id, user.id));
|
||||||
throw new CliError("Either --id or --username must be provided", 2);
|
console.log(`User ${user.name ?? user.id} (${user.id}) deleted`);
|
||||||
}
|
},
|
||||||
|
});
|
||||||
const db = getCliDb();
|
|
||||||
const user = await userLookup[lookupKey](db, lookupValue);
|
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
throw new CliError("User not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.delete(users).where(eq(users.id, user.id));
|
|
||||||
console.log(`User ${user.name ?? user.id} (${user.id}) deleted`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,22 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { getCliDb } from "../cli-db";
|
import { db } from "@homarr/db";
|
||||||
import { printTable } from "../utils";
|
|
||||||
|
|
||||||
export async function usersListHandler(args: string[] = []): Promise<number> {
|
export const usersList = command({
|
||||||
const { values } = parseArgs({
|
name: "list",
|
||||||
args,
|
desc: "List all users (id, username, email)",
|
||||||
options: {
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
json: { type: "boolean", default: false },
|
handler: async () => {
|
||||||
},
|
const allUsers = await db.query.users.findMany();
|
||||||
strict: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const db = getCliDb();
|
if (allUsers.length === 0) {
|
||||||
const allUsers = await db.query.users.findMany();
|
console.log("No users found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (values.json) {
|
console.log("ID\t\t\t\tUsername\tEmail");
|
||||||
const output = allUsers.map((u) => ({ id: u.id, name: u.name, email: u.email, provider: u.provider }));
|
for (const user of allUsers) {
|
||||||
console.log(JSON.stringify(output, null, 2));
|
console.log(`${user.id}\t${user.name ?? ""}\t${user.email ?? ""}`);
|
||||||
return 0;
|
}
|
||||||
}
|
},
|
||||||
|
});
|
||||||
if (allUsers.length === 0) {
|
|
||||||
console.log("No users found");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printTable(
|
|
||||||
["ID", "Username", "Email", "Provider"],
|
|
||||||
allUsers.map((u) => [u.id, u.name ?? "", u.email ?? "", u.provider]),
|
|
||||||
);
|
|
||||||
console.log(`\n${allUsers.length} user(s) total`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,66 +1,50 @@
|
|||||||
import { parseArgs } from "node:util";
|
import { command, string } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
import { hashPasswordAsync } from "@homarr/auth/security";
|
import { hashPasswordAsync } from "@homarr/auth";
|
||||||
import { eq } from "drizzle-orm";
|
import { db, eq } from "@homarr/db";
|
||||||
|
|
||||||
import type { CliDatabase } from "../cli-db";
|
|
||||||
import { getCliDb } from "../cli-db";
|
|
||||||
import { CliError, requireCredentialsProvider } from "../errors";
|
|
||||||
import { sessions, users } from "@homarr/db/schema";
|
import { sessions, users } from "@homarr/db/schema";
|
||||||
|
|
||||||
const userLookup: Record<
|
export const usersUpdatePassword = command({
|
||||||
"id" | "username",
|
name: "update-password",
|
||||||
(db: CliDatabase, value: string) => Promise<{ id: string; name: string | null; password: string | null } | undefined>
|
desc: "Update the password for a user (credentials provider only)",
|
||||||
> = {
|
options: {
|
||||||
id: (db, value) =>
|
id: string("id").alias("i").desc("ID of the user"),
|
||||||
db.query.users.findFirst({
|
username: string("username").alias("u").desc("Name of the user"),
|
||||||
where: eq(users.id, value),
|
password: string("password").alias("p").required().desc("New password"),
|
||||||
}),
|
},
|
||||||
username: (db, value) =>
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
db.query.users.findFirst({
|
handler: async (options) => {
|
||||||
where: eq(users.name, value),
|
if (!process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials")) {
|
||||||
}),
|
console.error("Credentials provider is not enabled");
|
||||||
};
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
export async function usersUpdatePasswordHandler(args: string[]): Promise<number> {
|
if (!options.id && !options.username) {
|
||||||
requireCredentialsProvider();
|
console.error("Either --id or --username must be provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { values } = parseArgs({
|
const user = await db.query.users.findFirst({
|
||||||
args,
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
options: {
|
where: options.id ? eq(users.id, options.id) : eq(users.name, options.username!),
|
||||||
id: { type: "string", short: "i" },
|
});
|
||||||
username: { type: "string", short: "u" },
|
|
||||||
password: { type: "string", short: "p" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const lookupKey = values.id ? "id" : values.username ? "username" : null;
|
if (!user?.password) {
|
||||||
const lookupValue = values.id ?? values.username;
|
console.error("User not found or has no credentials record");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lookupKey || !lookupValue) {
|
await db
|
||||||
throw new CliError("Either --id or --username must be provided", 2);
|
.update(users)
|
||||||
}
|
.set({
|
||||||
|
password: await hashPasswordAsync(options.password),
|
||||||
|
})
|
||||||
|
.where(eq(users.id, user.id));
|
||||||
|
|
||||||
if (!values.password) {
|
// invalidate existing sessions
|
||||||
throw new CliError("Missing required option: --password / -p", 2);
|
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
||||||
}
|
console.log(`All sessions for user ${user.name ?? user.id} have been deleted`);
|
||||||
|
|
||||||
const db = getCliDb();
|
console.log("Password updated successfully");
|
||||||
const user = await userLookup[lookupKey](db, lookupValue);
|
},
|
||||||
|
});
|
||||||
if (!user?.password) {
|
|
||||||
throw new CliError("User not found or has no credentials record");
|
|
||||||
}
|
|
||||||
|
|
||||||
await db
|
|
||||||
.update(users)
|
|
||||||
.set({
|
|
||||||
password: await hashPasswordAsync(values.password),
|
|
||||||
})
|
|
||||||
.where(eq(users.id, user.id));
|
|
||||||
|
|
||||||
await db.delete(sessions).where(eq(sessions.userId, user.id));
|
|
||||||
console.log(`All sessions for user ${user.name ?? user.id} have been deleted`);
|
|
||||||
console.log("Password updated successfully");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { command } from "@drizzle-team/brocli";
|
||||||
|
|
||||||
|
import { usersDelete } from "./users-delete";
|
||||||
|
import { usersList } from "./users-list";
|
||||||
|
import { usersUpdatePassword } from "./users-update-password";
|
||||||
|
|
||||||
|
export const usersRoot = command({
|
||||||
|
name: "users",
|
||||||
|
desc: "Group of commands to manage users",
|
||||||
|
subcommands: [usersList, usersDelete, usersUpdatePassword],
|
||||||
|
});
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
export class CliError extends Error {
|
|
||||||
constructor(
|
|
||||||
message: string,
|
|
||||||
readonly exitCode: 1 | 2 = 1,
|
|
||||||
) {
|
|
||||||
super(message);
|
|
||||||
this.name = "CliError";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const requireCredentialsProvider = () => {
|
|
||||||
const enabled = process.env.AUTH_PROVIDERS?.toLowerCase().includes("credentials") ?? false;
|
|
||||||
if (!enabled) {
|
|
||||||
throw new CliError("Credentials provider is not enabled");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+11
-38
@@ -1,41 +1,14 @@
|
|||||||
import { closeCliDbAsync } from "./cli-db";
|
import { run } from "@drizzle-team/brocli";
|
||||||
import { CliError } from "./errors";
|
|
||||||
import { runCliAsync } from "./router";
|
|
||||||
|
|
||||||
const mainAsync = async (): Promise<number> => {
|
import { fixUsernames } from "./commands/fix-usernames";
|
||||||
const argv = process.argv.slice(2);
|
import { integrationsRoot } from "./commands/integrations";
|
||||||
const start = performance.now();
|
import { recreateAdmin } from "./commands/recreate-admin";
|
||||||
|
import { resetPassword } from "./commands/reset-password";
|
||||||
|
import { usersRoot } from "./commands/users";
|
||||||
|
|
||||||
try {
|
const commands = [usersRoot, integrationsRoot, resetPassword, fixUsernames, recreateAdmin];
|
||||||
const code = await runCliAsync(argv);
|
|
||||||
if (code === 0) {
|
|
||||||
const elapsed = Math.round(performance.now() - start);
|
|
||||||
console.error(`\nDone in ${elapsed}ms`);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof CliError) {
|
|
||||||
console.error(error.message);
|
|
||||||
return error.exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error instanceof TypeError && error.message.startsWith("Unknown option")) {
|
void run(commands, {
|
||||||
console.error(error.message);
|
name: "homarr-cli",
|
||||||
return 2;
|
version: "1.0.0",
|
||||||
}
|
});
|
||||||
|
|
||||||
console.error(error instanceof Error ? error.message : error);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mainAsync()
|
|
||||||
.then(async (code) => {
|
|
||||||
await closeCliDbAsync();
|
|
||||||
process.exit(code);
|
|
||||||
})
|
|
||||||
.catch(async (error) => {
|
|
||||||
console.error(error instanceof Error ? error.message : error);
|
|
||||||
await closeCliDbAsync();
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
import { fixUsernamesHandler } from "./commands/fix-usernames";
|
|
||||||
import { integrationsDeleteHandler } from "./commands/integrations-delete";
|
|
||||||
import { integrationsListHandler } from "./commands/integrations-list";
|
|
||||||
import { recreateAdminHandler } from "./commands/recreate-admin";
|
|
||||||
import { resetPasswordHandler } from "./commands/reset-password";
|
|
||||||
import { usersDeleteHandler } from "./commands/users-delete";
|
|
||||||
import { usersListHandler } from "./commands/users-list";
|
|
||||||
import { usersUpdatePasswordHandler } from "./commands/users-update-password";
|
|
||||||
import { CliError } from "./errors";
|
|
||||||
|
|
||||||
const VERSION = "1.0.0";
|
|
||||||
|
|
||||||
type CommandHandler = (args: string[]) => Promise<number>;
|
|
||||||
|
|
||||||
interface CommandDef {
|
|
||||||
handler: CommandHandler;
|
|
||||||
desc: string;
|
|
||||||
usage: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type CommandGroup = Record<string, CommandDef>;
|
|
||||||
|
|
||||||
const topLevelCommands: Record<string, CommandDef> = {
|
|
||||||
"reset-password": {
|
|
||||||
handler: resetPasswordHandler,
|
|
||||||
desc: "Reset password for a credentials user",
|
|
||||||
usage: "homarr reset-password -u <username>",
|
|
||||||
},
|
|
||||||
"fix-usernames": {
|
|
||||||
handler: (args) => fixUsernamesHandler(),
|
|
||||||
desc: "Lowercase all credentials usernames",
|
|
||||||
usage: "homarr fix-usernames",
|
|
||||||
},
|
|
||||||
"recreate-admin": {
|
|
||||||
handler: recreateAdminHandler,
|
|
||||||
desc: "Create credentials admin if none exists",
|
|
||||||
usage: "homarr recreate-admin -u <username>",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const commandGroups: Record<string, CommandGroup> = {
|
|
||||||
users: {
|
|
||||||
list: {
|
|
||||||
handler: (args) => usersListHandler(args),
|
|
||||||
desc: "List all users",
|
|
||||||
usage: "homarr users list [--json]",
|
|
||||||
},
|
|
||||||
delete: {
|
|
||||||
handler: usersDeleteHandler,
|
|
||||||
desc: "Delete a user by id or username",
|
|
||||||
usage: "homarr users delete --id <id> | --username <name>",
|
|
||||||
},
|
|
||||||
"update-password": {
|
|
||||||
handler: usersUpdatePasswordHandler,
|
|
||||||
desc: "Set password for a credentials user",
|
|
||||||
usage: "homarr users update-password (--id <id> | --username <name>) --password <pw>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
integrations: {
|
|
||||||
list: {
|
|
||||||
handler: (args) => integrationsListHandler(args),
|
|
||||||
desc: "List all integrations",
|
|
||||||
usage: "homarr integrations list [--json]",
|
|
||||||
},
|
|
||||||
delete: {
|
|
||||||
handler: integrationsDeleteHandler,
|
|
||||||
desc: "Delete an integration by id or name",
|
|
||||||
usage: "homarr integrations delete --id <id> | --name <name>",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const HELP_TEXT = `homarr-cli ${VERSION}
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
homarr <command> [options]
|
|
||||||
|
|
||||||
Commands:
|
|
||||||
reset-password Reset password for a credentials user
|
|
||||||
recreate-admin Create credentials admin if none exists
|
|
||||||
fix-usernames Lowercase all credentials usernames
|
|
||||||
users list List all users
|
|
||||||
users delete Delete a user by id or username
|
|
||||||
users update-password Set password for a credentials user
|
|
||||||
integrations list List all integrations
|
|
||||||
integrations delete Delete an integration by id or name
|
|
||||||
|
|
||||||
Global Options:
|
|
||||||
-h, --help Show help (use after a command for command-specific help)
|
|
||||||
-v, --version Show CLI version
|
|
||||||
`;
|
|
||||||
|
|
||||||
const printHelp = () => {
|
|
||||||
console.log(HELP_TEXT);
|
|
||||||
};
|
|
||||||
|
|
||||||
const printCommandHelp = (def: CommandDef) => {
|
|
||||||
console.log(`${def.desc}\n`);
|
|
||||||
console.log(`Usage:\n ${def.usage}\n`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const resolveHandler = (argv: string[]): { handler: CommandHandler; args: string[] } => {
|
|
||||||
const [command, subcommand, ...rest] = argv;
|
|
||||||
|
|
||||||
if (!command) {
|
|
||||||
throw new CliError("Missing command", 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const group = commandGroups[command];
|
|
||||||
if (group) {
|
|
||||||
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
||||||
const subcommands = Object.entries(group)
|
|
||||||
.map(([name, def]) => ` ${name.padEnd(18)} ${def.desc}`)
|
|
||||||
.join("\n");
|
|
||||||
console.log(`Usage:\n homarr ${command} <subcommand> [options]\n\nSubcommands:\n${subcommands}\n`);
|
|
||||||
return { handler: async () => subcommand ? 0 : 2, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const def = group[subcommand];
|
|
||||||
if (!def) {
|
|
||||||
throw new CliError(`Unknown subcommand "${subcommand}" for "${command}"`, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFlag(rest, "--help", "-h")) {
|
|
||||||
printCommandHelp(def);
|
|
||||||
return { handler: async () => 0, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { handler: def.handler, args: rest };
|
|
||||||
}
|
|
||||||
|
|
||||||
const def = topLevelCommands[command];
|
|
||||||
if (!def) {
|
|
||||||
throw new CliError(`Unknown command "${command}"`, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const args = argv.slice(1);
|
|
||||||
if (hasFlag(args, "--help", "-h")) {
|
|
||||||
printCommandHelp(def);
|
|
||||||
return { handler: async () => 0, args: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { handler: def.handler, args };
|
|
||||||
};
|
|
||||||
|
|
||||||
const hasFlag = (argv: string[], flag: string, short: string) =>
|
|
||||||
argv.some((arg) => arg === flag || arg === short);
|
|
||||||
|
|
||||||
export const runCliAsync = async (argv: string[]): Promise<number> => {
|
|
||||||
if (hasFlag(argv, "--help", "-h") && argv.length === 1) {
|
|
||||||
printHelp();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasFlag(argv, "--version", "-v")) {
|
|
||||||
console.log(VERSION);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.length === 0) {
|
|
||||||
printHelp();
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { handler, args } = resolveHandler(argv);
|
|
||||||
return handler(args);
|
|
||||||
};
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { randomBytes } from "node:crypto";
|
|
||||||
|
|
||||||
export const generateSecureRandomToken = (size: number) => randomBytes(size).toString("hex");
|
|
||||||
|
|
||||||
export const printTable = (headers: string[], rows: string[][]) => {
|
|
||||||
const widths = headers.map((h, i) =>
|
|
||||||
Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)),
|
|
||||||
);
|
|
||||||
|
|
||||||
const formatRow = (cells: string[]) =>
|
|
||||||
cells.map((cell, i) => cell.padEnd(widths[i]!)).join(" ");
|
|
||||||
|
|
||||||
console.log(formatRow(headers));
|
|
||||||
console.log(widths.map((w) => "─".repeat(w)).join(" "));
|
|
||||||
for (const row of rows) {
|
|
||||||
console.log(formatRow(row));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -5,3 +5,26 @@ export const capitalize = <T extends string>(str: T) => {
|
|||||||
export const isNullOrWhitespace = (value: string | null): value is null => {
|
export const isNullOrWhitespace = (value: string | null): value is null => {
|
||||||
return value == null || value.trim() === "";
|
return value == null || value.trim() === "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const bestMatch = <TItem extends Record<string, unknown>>(
|
||||||
|
search: string,
|
||||||
|
options: TItem[],
|
||||||
|
by: (item: TItem) => string,
|
||||||
|
) => {
|
||||||
|
if (options.length === 0) return null;
|
||||||
|
|
||||||
|
const normalizedSearch = search.toLowerCase().trim();
|
||||||
|
|
||||||
|
return options.reduce<TItem | null>((best, current) => {
|
||||||
|
const currentMatchIndex = by(current).toLowerCase().indexOf(normalizedSearch);
|
||||||
|
|
||||||
|
if (currentMatchIndex === -1) return best;
|
||||||
|
if (best === null) return current;
|
||||||
|
|
||||||
|
const bestMatchIndex = by(best).toLowerCase().indexOf(normalizedSearch);
|
||||||
|
|
||||||
|
if (currentMatchIndex < bestMatchIndex) return current;
|
||||||
|
if (by(current).length < by(best).length && currentMatchIndex === bestMatchIndex) return current;
|
||||||
|
return best;
|
||||||
|
}, null);
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { capitalize } from "../string";
|
import { bestMatch, capitalize } from "../string";
|
||||||
|
|
||||||
const capitalizeTestCases = [
|
const capitalizeTestCases = [
|
||||||
["hello", "Hello"],
|
["hello", "Hello"],
|
||||||
@@ -12,8 +12,45 @@ const capitalizeTestCases = [
|
|||||||
|
|
||||||
describe("capitalize should capitalize the first letter of a string", () => {
|
describe("capitalize should capitalize the first letter of a string", () => {
|
||||||
capitalizeTestCases.forEach(([input, expected]) => {
|
capitalizeTestCases.forEach(([input, expected]) => {
|
||||||
it(`should capitalize ${input} to ${expected}`, () => {
|
test(`should capitalize ${input} to ${expected}`, () => {
|
||||||
expect(capitalize(input)).toEqual(expected);
|
expect(capitalize(input)).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("bestMatch should find the best match in an array of options", () => {
|
||||||
|
test("should find exact match for 'nginx'", () => {
|
||||||
|
const options = [
|
||||||
|
{ name: "my-nginx" },
|
||||||
|
{ name: "nginx-proxy" },
|
||||||
|
{ name: "nginx" },
|
||||||
|
{ name: "redis" },
|
||||||
|
{ name: "postgres" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const result = bestMatch("nginx", options, ({ name }) => name);
|
||||||
|
|
||||||
|
expect(result).toEqual({ name: "nginx" });
|
||||||
|
});
|
||||||
|
test("should find closest match for 'nginx' when exact match is not available", () => {
|
||||||
|
const options = [{ name: "redis" }, { name: "nginx-proxy" }, { name: "my-nginx" }, { name: "postgres" }];
|
||||||
|
|
||||||
|
const result = bestMatch("nginx", options, ({ name }) => name);
|
||||||
|
|
||||||
|
expect(result).toEqual({ name: "nginx-proxy" });
|
||||||
|
});
|
||||||
|
test("should return null if no match is found", () => {
|
||||||
|
const options = [{ name: "redis" }, { name: "postgres" }];
|
||||||
|
|
||||||
|
const result = bestMatch("nginx", options, ({ name }) => name);
|
||||||
|
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
test("should return null if options array is empty", () => {
|
||||||
|
const options: { name: string }[] = [];
|
||||||
|
|
||||||
|
const result = bestMatch("nginx", options, ({ name }) => name);
|
||||||
|
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, test } from "vitest";
|
import { describe, expect, test } from "vitest";
|
||||||
|
|
||||||
import { getPortFromUrl } from "../url";
|
import { getPortFromUrl, isAbsoluteUrl } from "../url.js";
|
||||||
|
|
||||||
describe("getPortFromUrl", () => {
|
describe("getPortFromUrl", () => {
|
||||||
test.each([
|
test.each([
|
||||||
@@ -38,3 +38,21 @@ describe("getPortFromUrl", () => {
|
|||||||
expect(act).toThrowError("Unsupported protocol: ftp:");
|
expect(act).toThrowError("Unsupported protocol: ftp:");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("isAbsoluteUrl", () => {
|
||||||
|
test.each([
|
||||||
|
["http://example.com", true],
|
||||||
|
["https://example.com", true],
|
||||||
|
["ftp://example.com", true],
|
||||||
|
["file:///path/to/file", true],
|
||||||
|
["mailto:johndoe@example.com", true],
|
||||||
|
["/relative/path", false],
|
||||||
|
["relative/path", false],
|
||||||
|
])("should return %s for URL: %s", (urlString, expected) => {
|
||||||
|
// Act
|
||||||
|
const result = isAbsoluteUrl(urlString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(result).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -38,3 +38,9 @@ export const getPortFromUrl = (url: URL): number => {
|
|||||||
|
|
||||||
throw new Error(`Unsupported protocol: ${url.protocol}`);
|
throw new Error(`Unsupported protocol: ${url.protocol}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const absoluteUrlRegex = /^[a-z]+:(\/\/)?/;
|
||||||
|
|
||||||
|
export const isAbsoluteUrl = (urlOrPath: string): boolean => {
|
||||||
|
return absoluteUrlRegex.test(urlOrPath.toLowerCase());
|
||||||
|
};
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
"./infrastructure/db": "./src/infrastructure/db/index.ts",
|
"./infrastructure/db": "./src/infrastructure/db/index.ts",
|
||||||
"./infrastructure/db/env": "./src/infrastructure/db/env.ts",
|
"./infrastructure/db/env": "./src/infrastructure/db/env.ts",
|
||||||
"./infrastructure/db/constants": "./src/infrastructure/db/constants.ts",
|
"./infrastructure/db/constants": "./src/infrastructure/db/constants.ts",
|
||||||
"./infrastructure/db/mapping": "./src/infrastructure/db/mapping.ts",
|
|
||||||
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { redisEnv } from "./env";
|
|||||||
|
|
||||||
const defaultRedisOptions = {
|
const defaultRedisOptions = {
|
||||||
connectionName: "homarr",
|
connectionName: "homarr",
|
||||||
|
lazyConnect: true,
|
||||||
} satisfies RedisOptions;
|
} satisfies RedisOptions;
|
||||||
|
|
||||||
export type { Redis as RedisClient } from "ioredis";
|
export type { Redis as RedisClient } from "ioredis";
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import baseConfig from "@homarr/eslint-config/base";
|
|
||||||
|
|
||||||
/** @type {import('typescript-eslint').Config} */
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
ignores: [],
|
|
||||||
},
|
|
||||||
...baseConfig,
|
|
||||||
];
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@homarr/cron-job-api",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"type": "module",
|
|
||||||
"exports": {
|
|
||||||
".": "./src/index.ts",
|
|
||||||
"./env": "./src/env.ts",
|
|
||||||
"./constants": "./src/constants.ts",
|
|
||||||
"./client": "./src/client.ts"
|
|
||||||
},
|
|
||||||
"typesVersions": {
|
|
||||||
"*": {
|
|
||||||
"*": [
|
|
||||||
"src/*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"clean": "rm -rf .turbo node_modules",
|
|
||||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
|
||||||
"lint": "eslint",
|
|
||||||
"typecheck": "tsc --noEmit"
|
|
||||||
},
|
|
||||||
"prettier": "@homarr/prettier-config",
|
|
||||||
"dependencies": {
|
|
||||||
"@homarr/common": "workspace:^0.1.0",
|
|
||||||
"@homarr/core": "workspace:^0.1.0",
|
|
||||||
"@homarr/cron-jobs": "workspace:^0.1.0",
|
|
||||||
"@tanstack/react-query": "catalog:",
|
|
||||||
"@trpc/client": "catalog:",
|
|
||||||
"@trpc/server": "catalog:",
|
|
||||||
"@trpc/tanstack-react-query": "catalog:",
|
|
||||||
"react": "catalog:",
|
|
||||||
"zod": "catalog:"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
|
||||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
|
||||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
|
||||||
"@types/react": "catalog:",
|
|
||||||
"eslint": "catalog:",
|
|
||||||
"typescript": "catalog:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import { createTRPCClient, httpLink } from "@trpc/client";
|
|
||||||
|
|
||||||
import type { JobRouter } from ".";
|
|
||||||
import { CRON_JOB_API_KEY_HEADER, CRON_JOB_API_PATH, CRON_JOB_API_PORT } from "./constants";
|
|
||||||
import { env } from "./env";
|
|
||||||
|
|
||||||
export const cronJobApi = createTRPCClient<JobRouter>({
|
|
||||||
links: [
|
|
||||||
httpLink({
|
|
||||||
url: `${getBaseUrl()}${CRON_JOB_API_PATH}`,
|
|
||||||
headers: {
|
|
||||||
[CRON_JOB_API_KEY_HEADER]: env.CRON_JOB_API_KEY,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
function getBaseUrl() {
|
|
||||||
return `http://localhost:${CRON_JOB_API_PORT}`;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export const CRON_JOB_API_PORT = 3002;
|
|
||||||
export const CRON_JOB_API_PATH = "/trpc";
|
|
||||||
export const CRON_JOB_API_KEY_HEADER = "cron-job-api-key";
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { z } from "zod/v4";
|
|
||||||
|
|
||||||
import { env as commonEnv } from "@homarr/common/env";
|
|
||||||
import { createEnv } from "@homarr/core/infrastructure/env";
|
|
||||||
|
|
||||||
export const env = createEnv({
|
|
||||||
server: {
|
|
||||||
CRON_JOB_API_KEY: commonEnv.NODE_ENV === "development" ? z.string().default("test") : z.string(),
|
|
||||||
},
|
|
||||||
experimental__runtimeEnv: process.env,
|
|
||||||
});
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
import { initTRPC, TRPCError } from "@trpc/server";
|
|
||||||
import { z } from "zod/v4";
|
|
||||||
|
|
||||||
import type { JobGroupKeys } from "@homarr/cron-jobs";
|
|
||||||
import { jobGroup } from "@homarr/cron-jobs";
|
|
||||||
|
|
||||||
import { env } from "./env";
|
|
||||||
|
|
||||||
export const jobGroupKeys = jobGroup.getKeys();
|
|
||||||
export const jobNameSchema = z.enum(jobGroup.getKeys());
|
|
||||||
|
|
||||||
export interface IJobManager {
|
|
||||||
startAsync(name: JobGroupKeys): Promise<void>;
|
|
||||||
triggerAsync(name: JobGroupKeys): Promise<void>;
|
|
||||||
stop(name: JobGroupKeys): void;
|
|
||||||
updateIntervalAsync(name: JobGroupKeys, cron: string): Promise<void>;
|
|
||||||
disableAsync(name: JobGroupKeys): Promise<void>;
|
|
||||||
enableAsync(name: JobGroupKeys): Promise<void>;
|
|
||||||
getAllAsync(): Promise<
|
|
||||||
{
|
|
||||||
name: JobGroupKeys;
|
|
||||||
cron: string;
|
|
||||||
preventManualExecution: boolean;
|
|
||||||
preventCustomInterval: boolean;
|
|
||||||
isEnabled: boolean;
|
|
||||||
}[]
|
|
||||||
>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const t = initTRPC
|
|
||||||
.context<{
|
|
||||||
manager: IJobManager;
|
|
||||||
apiKey?: string;
|
|
||||||
}>()
|
|
||||||
.create();
|
|
||||||
|
|
||||||
const createTrpcRouter = t.router;
|
|
||||||
const apiKeyProcedure = t.procedure.use(({ ctx, next }) => {
|
|
||||||
if (ctx.apiKey !== env.CRON_JOB_API_KEY) {
|
|
||||||
throw new TRPCError({
|
|
||||||
code: "FORBIDDEN",
|
|
||||||
message: "Missing or invalid API key",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return next({
|
|
||||||
ctx: {
|
|
||||||
...ctx,
|
|
||||||
apiKey: undefined, // Clear the API key after checking
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export const jobRouter = createTrpcRouter({
|
|
||||||
start: apiKeyProcedure.input(jobNameSchema).mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.manager.startAsync(input);
|
|
||||||
}),
|
|
||||||
trigger: apiKeyProcedure.input(jobNameSchema).mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.manager.triggerAsync(input);
|
|
||||||
}),
|
|
||||||
stop: apiKeyProcedure.input(jobNameSchema).mutation(({ input, ctx }) => {
|
|
||||||
ctx.manager.stop(input);
|
|
||||||
}),
|
|
||||||
updateInterval: apiKeyProcedure
|
|
||||||
.input(
|
|
||||||
z.object({
|
|
||||||
name: jobNameSchema,
|
|
||||||
cron: z.string(),
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.manager.updateIntervalAsync(input.name, input.cron);
|
|
||||||
}),
|
|
||||||
disable: apiKeyProcedure.input(jobNameSchema).mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.manager.disableAsync(input);
|
|
||||||
}),
|
|
||||||
enable: apiKeyProcedure.input(jobNameSchema).mutation(async ({ input, ctx }) => {
|
|
||||||
await ctx.manager.enableAsync(input);
|
|
||||||
}),
|
|
||||||
getAll: apiKeyProcedure.query(({ ctx }) => {
|
|
||||||
return ctx.manager.getAllAsync();
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type JobRouter = typeof jobRouter;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "@homarr/tsconfig/base.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
|
||||||
},
|
|
||||||
"include": ["*.ts", "src"],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts"
|
".": "./index.ts",
|
||||||
|
"./job-manager": "./src/job-manager.ts"
|
||||||
},
|
},
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
"*": {
|
"*": {
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"@homarr/server-settings": "workspace:^0.1.0",
|
"@homarr/server-settings": "workspace:^0.1.0",
|
||||||
"@homarr/translation": "workspace:^0.1.0",
|
"@homarr/translation": "workspace:^0.1.0",
|
||||||
"@homarr/validation": "workspace:^0.1.0",
|
"@homarr/validation": "workspace:^0.1.0",
|
||||||
"semver-parser": "catalog:"
|
"semver-parser": "catalog:",
|
||||||
|
"zod": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@homarr/eslint-config": "workspace:^0.2.0",
|
"@homarr/eslint-config": "workspace:^0.2.0",
|
||||||
|
|||||||
@@ -28,34 +28,45 @@ import { updateCheckerJob } from "./jobs/update-checker";
|
|||||||
import { weatherJob } from "./jobs/weather";
|
import { weatherJob } from "./jobs/weather";
|
||||||
import { createCronJobGroup } from "./lib";
|
import { createCronJobGroup } from "./lib";
|
||||||
|
|
||||||
export const jobGroup = createCronJobGroup({
|
const getJobGroup = () => {
|
||||||
analytics: analyticsJob,
|
return createCronJobGroup({
|
||||||
iconsUpdater: iconsUpdaterJob,
|
analytics: analyticsJob,
|
||||||
ping: pingJob,
|
iconsUpdater: iconsUpdaterJob,
|
||||||
smartHomeEntityState: smartHomeEntityStateJob,
|
ping: pingJob,
|
||||||
mediaServer: mediaServerJob,
|
smartHomeEntityState: smartHomeEntityStateJob,
|
||||||
mediaOrganizer: mediaOrganizerJob,
|
mediaServer: mediaServerJob,
|
||||||
downloads: downloadsJob,
|
mediaOrganizer: mediaOrganizerJob,
|
||||||
dnsHole: dnsHoleJob,
|
downloads: downloadsJob,
|
||||||
mediaRequestStats: mediaRequestStatsJob,
|
dnsHole: dnsHoleJob,
|
||||||
mediaRequestList: mediaRequestListJob,
|
mediaRequestStats: mediaRequestStatsJob,
|
||||||
rssFeeds: rssFeedsJob,
|
mediaRequestList: mediaRequestListJob,
|
||||||
indexerManager: indexerManagerJob,
|
rssFeeds: rssFeedsJob,
|
||||||
healthMonitoring: healthMonitoringJob,
|
indexerManager: indexerManagerJob,
|
||||||
updateChecker: updateCheckerJob,
|
healthMonitoring: healthMonitoringJob,
|
||||||
mediaTranscoding: mediaTranscodingJob,
|
updateChecker: updateCheckerJob,
|
||||||
minecraftServerStatus: minecraftServerStatusJob,
|
mediaTranscoding: mediaTranscodingJob,
|
||||||
dockerContainers: dockerContainersJob,
|
minecraftServerStatus: minecraftServerStatusJob,
|
||||||
networkController: networkControllerJob,
|
dockerContainers: dockerContainersJob,
|
||||||
firewallCpu: firewallCpuJob,
|
networkController: networkControllerJob,
|
||||||
firewallMemory: firewallMemoryJob,
|
firewallCpu: firewallCpuJob,
|
||||||
firewallVersion: firewallVersionJob,
|
firewallMemory: firewallMemoryJob,
|
||||||
firewallInterfaces: firewallInterfacesJob,
|
firewallVersion: firewallVersionJob,
|
||||||
refreshNotifications: refreshNotificationsJob,
|
firewallInterfaces: firewallInterfacesJob,
|
||||||
weather: weatherJob,
|
refreshNotifications: refreshNotificationsJob,
|
||||||
timetable: timetableJob,
|
weather: weatherJob,
|
||||||
tracearr: tracearrJob,
|
timetable: timetableJob,
|
||||||
umamiActiveVisitors: umamiActiveVisitorsJob,
|
tracearr: tracearrJob,
|
||||||
});
|
umamiActiveVisitors: umamiActiveVisitorsJob,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add global type augmentation for homarr
|
||||||
|
declare global {
|
||||||
|
var cronJobs: ReturnType<typeof getJobGroup> | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
global.cronJobs ??= getJobGroup();
|
||||||
|
|
||||||
|
export const jobGroup = global.cronJobs;
|
||||||
|
|
||||||
export type JobGroupKeys = ReturnType<(typeof jobGroup)["getKeys"]>[number];
|
export type JobGroupKeys = ReturnType<(typeof jobGroup)["getKeys"]>[number];
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Cron } from "croner";
|
import { Cron } from "croner";
|
||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import type { IJobManager } from "@homarr/cron-job-api";
|
|
||||||
import type { jobGroup as cronJobGroup, JobGroupKeys } from "@homarr/cron-jobs";
|
import type { jobGroup as cronJobGroup, JobGroupKeys } from "@homarr/cron-jobs";
|
||||||
import type { Database, InferInsertModel } from "@homarr/db";
|
import type { Database, InferInsertModel } from "@homarr/db";
|
||||||
import { eq } from "@homarr/db";
|
import { eq } from "@homarr/db";
|
||||||
@@ -9,7 +8,7 @@ import { cronJobConfigurations } from "@homarr/db/schema";
|
|||||||
|
|
||||||
const logger = createLogger({ module: "jobManager" });
|
const logger = createLogger({ module: "jobManager" });
|
||||||
|
|
||||||
export class JobManager implements IJobManager {
|
export class JobManager {
|
||||||
constructor(
|
constructor(
|
||||||
private db: Database,
|
private db: Database,
|
||||||
private jobGroup: typeof cronJobGroup,
|
private jobGroup: typeof cronJobGroup,
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createId, objectKeys } from "@homarr/common";
|
import { createId, objectKeys } from "@homarr/common";
|
||||||
import {
|
import {
|
||||||
createDocumentationLink,
|
createDocumentationLink,
|
||||||
|
credentialsAdminGroup,
|
||||||
everyoneGroup,
|
everyoneGroup,
|
||||||
getIntegrationDefaultUrl,
|
getIntegrationDefaultUrl,
|
||||||
getIntegrationName,
|
getIntegrationName,
|
||||||
@@ -11,12 +12,24 @@ import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server
|
|||||||
|
|
||||||
import type { Database } from "..";
|
import type { Database } from "..";
|
||||||
import { eq } from "..";
|
import { eq } from "..";
|
||||||
|
import { getMaxGroupPositionAsync } from "../queries";
|
||||||
import {
|
import {
|
||||||
getServerSettingByKeyAsync,
|
getServerSettingByKeyAsync,
|
||||||
insertServerSettingByKeyAsync,
|
insertServerSettingByKeyAsync,
|
||||||
updateServerSettingByKeyAsync,
|
updateServerSettingByKeyAsync,
|
||||||
} from "../queries/server-setting";
|
} from "../queries/server-setting";
|
||||||
import { groups, integrations, onboarding, searchEngines } from "../schema";
|
import {
|
||||||
|
boards,
|
||||||
|
groupMembers,
|
||||||
|
groupPermissions,
|
||||||
|
groups,
|
||||||
|
integrations,
|
||||||
|
layouts,
|
||||||
|
onboarding,
|
||||||
|
searchEngines,
|
||||||
|
sections,
|
||||||
|
users,
|
||||||
|
} from "../schema";
|
||||||
import type { Integration } from "../schema";
|
import type { Integration } from "../schema";
|
||||||
|
|
||||||
export const seedDataAsync = async (db: Database) => {
|
export const seedDataAsync = async (db: Database) => {
|
||||||
@@ -25,6 +38,10 @@ export const seedDataAsync = async (db: Database) => {
|
|||||||
await seedServerSettingsAsync(db);
|
await seedServerSettingsAsync(db);
|
||||||
await seedDefaultSearchEnginesAsync(db);
|
await seedDefaultSearchEnginesAsync(db);
|
||||||
await seedDefaultIntegrationsAsync(db);
|
await seedDefaultIntegrationsAsync(db);
|
||||||
|
|
||||||
|
if (process.env.DEMO_MODE === "true") {
|
||||||
|
await seedDemoUserAsync(db);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const seedEveryoneGroupAsync = async (db: Database) => {
|
const seedEveryoneGroupAsync = async (db: Database) => {
|
||||||
@@ -191,3 +208,72 @@ const seedDefaultIntegrationsAsync = async (db: Database) => {
|
|||||||
|
|
||||||
console.log(`Created ${createdCount} default integrations through seeding process`);
|
console.log(`Created ${createdCount} default integrations through seeding process`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const seedDemoUserAsync = async (db: Database) => {
|
||||||
|
const existingUser = await db.query.users.findFirst({
|
||||||
|
where: eq(users.name, "demo"),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (existingUser) {
|
||||||
|
console.log("Skipping seeding of demo user as it already exists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = createId();
|
||||||
|
|
||||||
|
await db.insert(users).values({
|
||||||
|
id: userId,
|
||||||
|
name: "demo",
|
||||||
|
email: "demo@example.com",
|
||||||
|
password: "$2b$10$c5AaQb0oj32/bui5Z55PyOb7pY.iEkXYqgdD8MjS9LjSjLMeOkZu2",
|
||||||
|
});
|
||||||
|
|
||||||
|
const maxPosition = await getMaxGroupPositionAsync(db);
|
||||||
|
const groupId = createId();
|
||||||
|
await db.insert(groups).values({
|
||||||
|
id: groupId,
|
||||||
|
name: credentialsAdminGroup,
|
||||||
|
ownerId: userId,
|
||||||
|
position: maxPosition + 1,
|
||||||
|
});
|
||||||
|
await db.insert(groupPermissions).values({
|
||||||
|
groupId,
|
||||||
|
permission: "admin",
|
||||||
|
});
|
||||||
|
await db.insert(groupMembers).values({
|
||||||
|
groupId,
|
||||||
|
userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
await db.update(onboarding).set({
|
||||||
|
step: "finish",
|
||||||
|
previousStep: "settings",
|
||||||
|
});
|
||||||
|
|
||||||
|
const boardId = createId();
|
||||||
|
await db.insert(boards).values({
|
||||||
|
id: boardId,
|
||||||
|
name: "default",
|
||||||
|
isPublic: false,
|
||||||
|
creatorId: userId,
|
||||||
|
});
|
||||||
|
await db.insert(sections).values({
|
||||||
|
id: createId(),
|
||||||
|
kind: "empty",
|
||||||
|
xOffset: 0,
|
||||||
|
yOffset: 0,
|
||||||
|
boardId,
|
||||||
|
});
|
||||||
|
await db.insert(layouts).values({
|
||||||
|
id: createId(),
|
||||||
|
name: "Base",
|
||||||
|
columnCount: 12,
|
||||||
|
breakpoint: 0,
|
||||||
|
boardId,
|
||||||
|
});
|
||||||
|
await db.update(users).set({ homeBoardId: boardId }).where(eq(users.id, userId));
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"Your instance has enabled demo mode. Homarr therefore created example data for your demo. You can disable demo mode anytime by setting the env 'DEMO_MODE' to 'false' or unset it.",
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { InferSelectModel } from "drizzle-orm";
|
import type { InferSelectModel } from "drizzle-orm";
|
||||||
|
|
||||||
import { createDbMapping as createSchema } from "@homarr/core/infrastructure/db/mapping";
|
import { createSchema } from "@homarr/core/infrastructure/db";
|
||||||
|
|
||||||
import * as mysqlSchema from "./mysql";
|
import * as mysqlSchema from "./mysql";
|
||||||
import * as pgSchema from "./postgresql";
|
import * as pgSchema from "./postgresql";
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ export type HomarrDocumentationPath =
|
|||||||
| "/docs/tags/roles"
|
| "/docs/tags/roles"
|
||||||
| "/docs/tags/search"
|
| "/docs/tags/search"
|
||||||
| "/docs/tags/search-engines"
|
| "/docs/tags/search-engines"
|
||||||
|
| "/docs/tags/secrets"
|
||||||
| "/docs/tags/security"
|
| "/docs/tags/security"
|
||||||
| "/docs/tags/self-signed"
|
| "/docs/tags/self-signed"
|
||||||
| "/docs/tags/seo"
|
| "/docs/tags/seo"
|
||||||
@@ -198,6 +199,7 @@ export type HomarrDocumentationPath =
|
|||||||
| "/docs/integrations/tracearr"
|
| "/docs/integrations/tracearr"
|
||||||
| "/docs/integrations/transmission"
|
| "/docs/integrations/transmission"
|
||||||
| "/docs/integrations/truenas"
|
| "/docs/integrations/truenas"
|
||||||
|
| "/docs/integrations/umami"
|
||||||
| "/docs/integrations/unifi-controller"
|
| "/docs/integrations/unifi-controller"
|
||||||
| "/docs/integrations/unraid"
|
| "/docs/integrations/unraid"
|
||||||
| "/docs/management/api"
|
| "/docs/management/api"
|
||||||
@@ -244,6 +246,7 @@ export type HomarrDocumentationPath =
|
|||||||
| "/docs/widgets/system-resources"
|
| "/docs/widgets/system-resources"
|
||||||
| "/docs/widgets/timetable"
|
| "/docs/widgets/timetable"
|
||||||
| "/docs/widgets/tracearr"
|
| "/docs/widgets/tracearr"
|
||||||
|
| "/docs/widgets/umami"
|
||||||
| "/docs/widgets/video"
|
| "/docs/widgets/video"
|
||||||
| "/docs/widgets/weather"
|
| "/docs/widgets/weather"
|
||||||
| ""
|
| ""
|
||||||
|
|||||||
@@ -376,7 +376,6 @@ export const integrationDefs = {
|
|||||||
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/umami.svg",
|
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/umami.svg",
|
||||||
category: ["analytics"],
|
category: ["analytics"],
|
||||||
defaultUrl: "https://api.umami.is/v1",
|
defaultUrl: "https://api.umami.is/v1",
|
||||||
// @ts-expect-error - docs page will be created when integration is merged
|
|
||||||
documentationUrl: createDocumentationLink("/docs/integrations/umami"),
|
documentationUrl: createDocumentationLink("/docs/integrations/umami"),
|
||||||
},
|
},
|
||||||
// This integration only returns mock data, it is used during development (but can also be used in production by directly going to the create page)
|
// This integration only returns mock data, it is used during development (but can also be used in production by directly going to the create page)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { isAbsoluteUrl } from "@homarr/common";
|
||||||
import { ResponseError } from "@homarr/common/server";
|
import { ResponseError } from "@homarr/common/server";
|
||||||
import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/http";
|
import { fetchWithTrustedCertificatesAsync } from "@homarr/core/infrastructure/http";
|
||||||
import { ImageProxy } from "@homarr/image-proxy";
|
import { ImageProxy } from "@homarr/image-proxy";
|
||||||
@@ -85,10 +86,10 @@ export class TracearrIntegration extends Integration {
|
|||||||
data: await Promise.all(
|
data: await Promise.all(
|
||||||
json.data.map(async (stream) => {
|
json.data.map(async (stream) => {
|
||||||
if (stream.userAvatarUrl) {
|
if (stream.userAvatarUrl) {
|
||||||
stream.userAvatarUrl = await this.proxyImageAsync(imageProxy, stream.userAvatarUrl, stream.id, "avatar");
|
stream.userAvatarUrl = await this.proxyImageAsync(imageProxy, stream.userAvatarUrl);
|
||||||
}
|
}
|
||||||
if (stream.posterUrl) {
|
if (stream.posterUrl) {
|
||||||
stream.posterUrl = await this.proxyImageAsync(imageProxy, stream.posterUrl, stream.id, "poster");
|
stream.posterUrl = await this.proxyImageAsync(imageProxy, stream.posterUrl);
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
}),
|
}),
|
||||||
@@ -120,12 +121,7 @@ export class TracearrIntegration extends Integration {
|
|||||||
...json,
|
...json,
|
||||||
data: await Promise.all(
|
data: await Promise.all(
|
||||||
json.data.map(async (violation) => {
|
json.data.map(async (violation) => {
|
||||||
violation.user.avatarUrl = await this.proxyImageAsync(
|
violation.user.avatarUrl = await this.proxyImageAsync(imageProxy, violation.user.avatarUrl);
|
||||||
imageProxy,
|
|
||||||
violation.user.avatarUrl,
|
|
||||||
violation.user.id,
|
|
||||||
"avatar",
|
|
||||||
);
|
|
||||||
return violation;
|
return violation;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -156,12 +152,7 @@ export class TracearrIntegration extends Integration {
|
|||||||
...json,
|
...json,
|
||||||
data: await Promise.all(
|
data: await Promise.all(
|
||||||
json.data.map(async (session) => {
|
json.data.map(async (session) => {
|
||||||
session.user.avatarUrl = await this.proxyImageAsync(
|
session.user.avatarUrl = await this.proxyImageAsync(imageProxy, session.user.avatarUrl);
|
||||||
imageProxy,
|
|
||||||
session.user.avatarUrl,
|
|
||||||
session.user.id,
|
|
||||||
"avatar",
|
|
||||||
);
|
|
||||||
return session;
|
return session;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -194,23 +185,12 @@ export class TracearrIntegration extends Integration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async proxyImageAsync(
|
private async proxyImageAsync(imageProxy: ImageProxy, urlOrPath: string | null | undefined): Promise<string | null> {
|
||||||
imageProxy: ImageProxy,
|
if (!urlOrPath) return null;
|
||||||
url: string | null | undefined,
|
|
||||||
uniqueId: string,
|
|
||||||
discriminator: string,
|
|
||||||
): Promise<string | null> {
|
|
||||||
if (!url) return null;
|
|
||||||
try {
|
try {
|
||||||
// ImageProxy doesn't support fallback urls so we need to remove them
|
// ImageProxy doesn't support fallback urls so we need to remove them
|
||||||
const cleanUrl = url.replace(/&fallback=[^&]+/, "").replace(/\?fallback=[^&]+&?/, "?");
|
const cleanUrl = urlOrPath.replace(/&fallback=[^&]+/, "").replace(/\?fallback=[^&]+&?/, "?");
|
||||||
// Build the full URL, then inject _uid as the FIRST query param.
|
const fullUrl = isAbsoluteUrl(urlOrPath) ? cleanUrl : this.url(cleanUrl as `/${string}`).toString();
|
||||||
// This is critical because ImageProxy uses bcrypt which truncates at 72 bytes.
|
|
||||||
// Without this, all long avatar/poster URLs from the same session hash identically
|
|
||||||
// since they share the same first 72+ bytes.
|
|
||||||
const baseUrl = this.url(cleanUrl as `/${string}`).toString();
|
|
||||||
const prefix = `_uid=${discriminator}_${uniqueId}&`;
|
|
||||||
const fullUrl = baseUrl.includes("?") ? baseUrl.replace("?", `?${prefix}`) : `${baseUrl}?${prefix}`;
|
|
||||||
|
|
||||||
return await imageProxy.createImageAsync(fullUrl, this.getAuthHeaders());
|
return await imageProxy.createImageAsync(fullUrl, this.getAuthHeaders());
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import { ChannelSubscriptionTracker } from "./channel-subscription-tracker";
|
||||||
|
import { createRedisConnection } from "./connection";
|
||||||
|
|
||||||
|
const mockRedisClient = {
|
||||||
|
subscribe: vi.fn().mockResolvedValue("OK"),
|
||||||
|
unsubscribe: vi.fn().mockResolvedValue("OK"),
|
||||||
|
on: vi.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mock("@homarr/core/infrastructure/logs", () => ({
|
||||||
|
createLogger: () => ({ debug: vi.fn(), warn: vi.fn() }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("./connection", () => ({
|
||||||
|
createRedisConnection: vi.fn(() => mockRedisClient),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("ChannelSubscriptionTracker", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
// Reset static state between tests
|
||||||
|
// @ts-expect-error accessing private static for test reset
|
||||||
|
ChannelSubscriptionTracker.subscriptions = new Map();
|
||||||
|
// @ts-expect-error accessing private static for test reset
|
||||||
|
ChannelSubscriptionTracker._redis = undefined;
|
||||||
|
// @ts-expect-error accessing private static for test reset
|
||||||
|
ChannelSubscriptionTracker.listenerActive = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
test("redis client is lazily created on first subscribe", () => {
|
||||||
|
vi.mocked(createRedisConnection).mockClear();
|
||||||
|
|
||||||
|
ChannelSubscriptionTracker.subscribe("channel-1", vi.fn());
|
||||||
|
|
||||||
|
expect(createRedisConnection).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("redis client is reused across multiple subscribes", () => {
|
||||||
|
vi.mocked(createRedisConnection).mockClear();
|
||||||
|
|
||||||
|
ChannelSubscriptionTracker.subscribe("channel-1", vi.fn());
|
||||||
|
ChannelSubscriptionTracker.subscribe("channel-2", vi.fn());
|
||||||
|
|
||||||
|
expect(createRedisConnection).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("subscribes to redis channel on first callback for a channel", () => {
|
||||||
|
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
|
||||||
|
expect(mockRedisClient.subscribe).toHaveBeenCalledWith("test-channel");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("does not re-subscribe when adding second callback to same channel", () => {
|
||||||
|
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
mockRedisClient.subscribe.mockClear();
|
||||||
|
|
||||||
|
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
|
||||||
|
expect(mockRedisClient.subscribe).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("unsubscribe function removes the callback", () => {
|
||||||
|
const unsubscribe = ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
|
||||||
|
unsubscribe();
|
||||||
|
|
||||||
|
expect(mockRedisClient.unsubscribe).toHaveBeenCalledWith("test-channel");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("does not unsubscribe from redis if other callbacks remain", () => {
|
||||||
|
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
const unsubscribe = ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
|
||||||
|
|
||||||
|
unsubscribe();
|
||||||
|
|
||||||
|
expect(mockRedisClient.unsubscribe).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("activates message listener only once", () => {
|
||||||
|
ChannelSubscriptionTracker.subscribe("ch-1", vi.fn());
|
||||||
|
ChannelSubscriptionTracker.subscribe("ch-2", vi.fn());
|
||||||
|
|
||||||
|
expect(mockRedisClient.on).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockRedisClient.on).toHaveBeenCalledWith("message", expect.any(Function));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("message listener dispatches to correct channel callbacks", () => {
|
||||||
|
const callback1 = vi.fn();
|
||||||
|
const callback2 = vi.fn();
|
||||||
|
ChannelSubscriptionTracker.subscribe("channel-a", callback1);
|
||||||
|
ChannelSubscriptionTracker.subscribe("channel-b", callback2);
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
const messageHandler = mockRedisClient.on.mock.calls[0]![1] as (channel: string, message: string) => void;
|
||||||
|
messageHandler("channel-a", "test-message");
|
||||||
|
|
||||||
|
expect(callback1).toHaveBeenCalledWith("test-message");
|
||||||
|
expect(callback2).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,6 +2,7 @@ import { randomUUID } from "crypto";
|
|||||||
|
|
||||||
import type { MaybePromise } from "@homarr/common/types";
|
import type { MaybePromise } from "@homarr/common/types";
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
import type { RedisClient } from "@homarr/core/infrastructure/redis";
|
||||||
|
|
||||||
import { createRedisConnection } from "./connection";
|
import { createRedisConnection } from "./connection";
|
||||||
|
|
||||||
@@ -18,7 +19,10 @@ type SubscriptionCallback = (message: string) => MaybePromise<void>;
|
|||||||
*/
|
*/
|
||||||
export class ChannelSubscriptionTracker {
|
export class ChannelSubscriptionTracker {
|
||||||
private static subscriptions = new Map<string, Map<string, SubscriptionCallback>>();
|
private static subscriptions = new Map<string, Map<string, SubscriptionCallback>>();
|
||||||
private static redis = createRedisConnection();
|
private static _redis: RedisClient | undefined;
|
||||||
|
private static get redis() {
|
||||||
|
return (this._redis ??= createRedisConnection());
|
||||||
|
}
|
||||||
private static listenerActive = false;
|
private static listenerActive = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createCacheChannel,
|
||||||
|
createGetSetChannel,
|
||||||
|
createListChannel,
|
||||||
|
createSubPubChannel,
|
||||||
|
handshakeAsync,
|
||||||
|
} from "./channel";
|
||||||
|
import { createRedisConnection } from "./connection";
|
||||||
|
|
||||||
|
const mockRedisClient = {
|
||||||
|
get: vi.fn().mockResolvedValue(null),
|
||||||
|
set: vi.fn().mockResolvedValue("OK"),
|
||||||
|
del: vi.fn().mockResolvedValue(1),
|
||||||
|
publish: vi.fn().mockResolvedValue(1),
|
||||||
|
lrange: vi.fn().mockResolvedValue([]),
|
||||||
|
lrem: vi.fn().mockResolvedValue(0),
|
||||||
|
lpush: vi.fn().mockResolvedValue(1),
|
||||||
|
ltrim: vi.fn().mockResolvedValue("OK"),
|
||||||
|
llen: vi.fn().mockResolvedValue(0),
|
||||||
|
hello: vi.fn().mockResolvedValue({}),
|
||||||
|
subscribe: vi.fn().mockResolvedValue("OK"),
|
||||||
|
on: vi.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mock("@homarr/core/infrastructure/logs", () => ({
|
||||||
|
createLogger: () => ({ debug: vi.fn(), warn: vi.fn(), error: vi.fn(), info: vi.fn() }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("./connection", () => ({
|
||||||
|
createRedisConnection: vi.fn(() => mockRedisClient),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("./channel-subscription-tracker", () => ({
|
||||||
|
ChannelSubscriptionTracker: {
|
||||||
|
subscribe: vi.fn(() => vi.fn()),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("channel lazy initialization", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.mocked(createRedisConnection).mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getSetClient is lazily created on first channel operation", async () => {
|
||||||
|
vi.mocked(createRedisConnection).mockClear();
|
||||||
|
|
||||||
|
const channel = createGetSetChannel<string>("test-lazy");
|
||||||
|
expect(createRedisConnection).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
await channel.getAsync();
|
||||||
|
|
||||||
|
expect(createRedisConnection).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("publisher is lazily created on first publish", async () => {
|
||||||
|
const channel = createSubPubChannel<string>("test-pub", { persist: false });
|
||||||
|
|
||||||
|
const callsBefore = vi.mocked(createRedisConnection).mock.calls.length;
|
||||||
|
await channel.publishAsync("hello");
|
||||||
|
|
||||||
|
expect(vi.mocked(createRedisConnection).mock.calls.length).toBeGreaterThan(callsBefore);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("handshakeAsync creates a client and calls hello", async () => {
|
||||||
|
await handshakeAsync();
|
||||||
|
|
||||||
|
expect(mockRedisClient.hello).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("createSubPubChannel", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("publishAsync persists data and publishes", async () => {
|
||||||
|
const channel = createSubPubChannel<{ value: number }>("test-channel");
|
||||||
|
|
||||||
|
await channel.publishAsync({ value: 42 });
|
||||||
|
|
||||||
|
expect(mockRedisClient.set).toHaveBeenCalledOnce();
|
||||||
|
expect(mockRedisClient.publish).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("publishAsync with persist:false skips set", async () => {
|
||||||
|
const channel = createSubPubChannel<string>("no-persist", { persist: false });
|
||||||
|
|
||||||
|
await channel.publishAsync("data");
|
||||||
|
|
||||||
|
expect(mockRedisClient.set).not.toHaveBeenCalled();
|
||||||
|
expect(mockRedisClient.publish).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getLastDataAsync returns null when no data", async () => {
|
||||||
|
const channel = createSubPubChannel<string>("empty");
|
||||||
|
|
||||||
|
const result = await channel.getLastDataAsync();
|
||||||
|
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("createListChannel", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("addAsync pushes to list", async () => {
|
||||||
|
const channel = createListChannel<string>("test-list");
|
||||||
|
|
||||||
|
await channel.addAsync("item1");
|
||||||
|
|
||||||
|
expect(mockRedisClient.lpush).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("clearAsync deletes the list", async () => {
|
||||||
|
const channel = createListChannel<string>("test-list");
|
||||||
|
|
||||||
|
await channel.clearAsync();
|
||||||
|
|
||||||
|
expect(mockRedisClient.del).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("createCacheChannel", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("invalidateAsync deletes the cache key", async () => {
|
||||||
|
const channel = createCacheChannel<string>("test-cache");
|
||||||
|
|
||||||
|
await channel.invalidateAsync();
|
||||||
|
|
||||||
|
expect(mockRedisClient.del).toHaveBeenCalledWith("cache:test-cache");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getAsync returns null when no cached data", async () => {
|
||||||
|
const channel = createCacheChannel<string>("test-cache");
|
||||||
|
|
||||||
|
const result = await channel.getAsync();
|
||||||
|
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,6 +2,7 @@ import superjson from "superjson";
|
|||||||
|
|
||||||
import { createId, hashObjectBase64 } from "@homarr/common";
|
import { createId, hashObjectBase64 } from "@homarr/common";
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
import type { RedisClient } from "@homarr/core/infrastructure/redis";
|
||||||
import type { WidgetKind } from "@homarr/definitions";
|
import type { WidgetKind } from "@homarr/definitions";
|
||||||
|
|
||||||
import { ChannelSubscriptionTracker } from "./channel-subscription-tracker";
|
import { ChannelSubscriptionTracker } from "./channel-subscription-tracker";
|
||||||
@@ -9,8 +10,11 @@ import { createRedisConnection } from "./connection";
|
|||||||
|
|
||||||
const logger = createLogger({ module: "redisChannel" });
|
const logger = createLogger({ module: "redisChannel" });
|
||||||
|
|
||||||
const publisher = createRedisConnection();
|
let _publisher: RedisClient | undefined;
|
||||||
const lastDataClient = createRedisConnection();
|
const getPublisher = () => (_publisher ??= createRedisConnection());
|
||||||
|
|
||||||
|
let _lastDataClient: RedisClient | undefined;
|
||||||
|
const getLastDataClient = () => (_lastDataClient ??= createRedisConnection());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new pub/sub channel.
|
* Creates a new pub/sub channel.
|
||||||
@@ -27,34 +31,33 @@ export const createSubPubChannel = <TData>(name: string, { persist }: { persist:
|
|||||||
*/
|
*/
|
||||||
subscribe: (callback: (data: TData) => void) => {
|
subscribe: (callback: (data: TData) => void) => {
|
||||||
if (persist) {
|
if (persist) {
|
||||||
void lastDataClient.get(lastChannelName).then((data) => {
|
void getLastDataClient()
|
||||||
if (data) {
|
.get(lastChannelName)
|
||||||
callback(superjson.parse(data));
|
.then((data) => {
|
||||||
}
|
if (data) {
|
||||||
});
|
callback(superjson.parse(data));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return ChannelSubscriptionTracker.subscribe(channelName, (message) => {
|
return ChannelSubscriptionTracker.subscribe(channelName, (message) => {
|
||||||
callback(superjson.parse(message));
|
callback(superjson.parse(message));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Publish data to the channel with last data saved.
|
|
||||||
* @param data data to be published
|
|
||||||
*/
|
|
||||||
publishAsync: async (data: TData) => {
|
publishAsync: async (data: TData) => {
|
||||||
if (persist) {
|
if (persist) {
|
||||||
await lastDataClient.set(lastChannelName, superjson.stringify(data));
|
await getLastDataClient().set(lastChannelName, superjson.stringify(data));
|
||||||
}
|
}
|
||||||
await publisher.publish(channelName, superjson.stringify(data));
|
await getPublisher().publish(channelName, superjson.stringify(data));
|
||||||
},
|
},
|
||||||
getLastDataAsync: async () => {
|
getLastDataAsync: async () => {
|
||||||
const data = await lastDataClient.get(lastChannelName);
|
const data = await getLastDataClient().get(lastChannelName);
|
||||||
return data ? superjson.parse<TData>(data) : null;
|
return data ? superjson.parse<TData>(data) : null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSetClient = createRedisConnection();
|
let _getSetClient: RedisClient | undefined;
|
||||||
|
const getSetClient = () => (_getSetClient ??= createRedisConnection());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new redis channel for a list
|
* Creates a new redis channel for a list
|
||||||
@@ -69,7 +72,7 @@ export const createListChannel = <TItem>(name: string) => {
|
|||||||
* @returns an array of all items
|
* @returns an array of all items
|
||||||
*/
|
*/
|
||||||
getAllAsync: async () => {
|
getAllAsync: async () => {
|
||||||
const items = await getSetClient.lrange(listChannelName, 0, -1);
|
const items = await getSetClient().lrange(listChannelName, 0, -1);
|
||||||
return items.map((item) => superjson.parse<TItem>(item));
|
return items.map((item) => superjson.parse<TItem>(item));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -77,20 +80,20 @@ export const createListChannel = <TItem>(name: string) => {
|
|||||||
* @param item item to remove
|
* @param item item to remove
|
||||||
*/
|
*/
|
||||||
removeAsync: async (item: TItem) => {
|
removeAsync: async (item: TItem) => {
|
||||||
await getSetClient.lrem(listChannelName, 0, superjson.stringify(item));
|
await getSetClient().lrem(listChannelName, 0, superjson.stringify(item));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Clear all items from the channels list
|
* Clear all items from the channels list
|
||||||
*/
|
*/
|
||||||
clearAsync: async () => {
|
clearAsync: async () => {
|
||||||
await getSetClient.del(listChannelName);
|
await getSetClient().del(listChannelName);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Add an item to the channels list
|
* Add an item to the channels list
|
||||||
* @param item item to add
|
* @param item item to add
|
||||||
*/
|
*/
|
||||||
addAsync: async (item: TItem) => {
|
addAsync: async (item: TItem) => {
|
||||||
await getSetClient.lpush(listChannelName, superjson.stringify(item));
|
await getSetClient().lpush(listChannelName, superjson.stringify(item));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -106,7 +109,7 @@ export const createGetSetChannel = <TData>(name: string) => {
|
|||||||
* @returns data or null if not found
|
* @returns data or null if not found
|
||||||
*/
|
*/
|
||||||
getAsync: async () => {
|
getAsync: async () => {
|
||||||
const data = await getSetClient.get(name);
|
const data = await getSetClient().get(name);
|
||||||
return data ? superjson.parse<TData>(data) : null;
|
return data ? superjson.parse<TData>(data) : null;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -114,13 +117,13 @@ export const createGetSetChannel = <TData>(name: string) => {
|
|||||||
* @param data data to be stored in the channel
|
* @param data data to be stored in the channel
|
||||||
*/
|
*/
|
||||||
setAsync: async (data: TData) => {
|
setAsync: async (data: TData) => {
|
||||||
await getSetClient.set(name, superjson.stringify(data));
|
await getSetClient().set(name, superjson.stringify(data));
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Remove data from the channel
|
* Remove data from the channel
|
||||||
*/
|
*/
|
||||||
removeAsync: async () => {
|
removeAsync: async () => {
|
||||||
await getSetClient.del(name);
|
await getSetClient().del(name);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -140,7 +143,7 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
|
|||||||
* @returns data or null if not found or expired
|
* @returns data or null if not found or expired
|
||||||
*/
|
*/
|
||||||
getAsync: async () => {
|
getAsync: async () => {
|
||||||
const data = await getSetClient.get(cacheChannelName);
|
const data = await getSetClient().get(cacheChannelName);
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
const parsedData = superjson.parse<{ data: TData; timestamp: Date }>(data);
|
const parsedData = superjson.parse<{ data: TData; timestamp: Date }>(data);
|
||||||
@@ -156,13 +159,13 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
|
|||||||
* @returns data or new data if not present or expired
|
* @returns data or new data if not present or expired
|
||||||
*/
|
*/
|
||||||
consumeAsync: async (callback: () => Promise<TData>) => {
|
consumeAsync: async (callback: () => Promise<TData>) => {
|
||||||
const data = await getSetClient.get(cacheChannelName);
|
const data = await getSetClient().get(cacheChannelName);
|
||||||
|
|
||||||
const getNewDataAsync = async () => {
|
const getNewDataAsync = async () => {
|
||||||
logger.debug(`Cache miss for channel '${cacheChannelName}'`);
|
logger.debug(`Cache miss for channel '${cacheChannelName}'`);
|
||||||
const newData = await callback();
|
const newData = await callback();
|
||||||
const result = { data: newData, timestamp: new Date() };
|
const result = { data: newData, timestamp: new Date() };
|
||||||
await getSetClient.set(cacheChannelName, superjson.stringify(result));
|
await getSetClient().set(cacheChannelName, superjson.stringify(result));
|
||||||
logger.debug(`Cache updated for channel '${cacheChannelName}'`);
|
logger.debug(`Cache updated for channel '${cacheChannelName}'`);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -187,14 +190,14 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
|
|||||||
* Invalidate the cache channels data.
|
* Invalidate the cache channels data.
|
||||||
*/
|
*/
|
||||||
invalidateAsync: async () => {
|
invalidateAsync: async () => {
|
||||||
await getSetClient.del(cacheChannelName);
|
await getSetClient().del(cacheChannelName);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Set the data in the cache channel.
|
* Set the data in the cache channel.
|
||||||
* @param data data to be stored in the cache channel
|
* @param data data to be stored in the cache channel
|
||||||
*/
|
*/
|
||||||
setAsync: async (data: TData) => {
|
setAsync: async (data: TData) => {
|
||||||
await getSetClient.set(cacheChannelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().set(cacheChannelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -236,12 +239,12 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
pushAsync: async (data: TData, options = { publish: false }) => {
|
pushAsync: async (data: TData, options = { publish: false }) => {
|
||||||
if (options.publish) await publisher.publish(channelName, superjson.stringify(data));
|
if (options.publish) await getPublisher().publish(channelName, superjson.stringify(data));
|
||||||
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
await getSetClient.ltrim(channelName, 0, maxElements);
|
await getSetClient().ltrim(channelName, 0, maxElements);
|
||||||
},
|
},
|
||||||
clearAsync: async () => {
|
clearAsync: async () => {
|
||||||
await getSetClient.del(channelName);
|
await getSetClient().del(channelName);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Returns a slice of the available data in the channel.
|
* Returns a slice of the available data in the channel.
|
||||||
@@ -250,17 +253,17 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
|
|||||||
* @param endIndex End index of the slice, negative values are counted from the end, defaults at end of range.
|
* @param endIndex End index of the slice, negative values are counted from the end, defaults at end of range.
|
||||||
*/
|
*/
|
||||||
getSliceAsync: async (startIndex = 0, endIndex = -1) => {
|
getSliceAsync: async (startIndex = 0, endIndex = -1) => {
|
||||||
const range = await getSetClient.lrange(channelName, startIndex, endIndex);
|
const range = await getSetClient().lrange(channelName, startIndex, endIndex);
|
||||||
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
|
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
|
||||||
},
|
},
|
||||||
getSliceUntilTimeAsync: async (time: Date) => {
|
getSliceUntilTimeAsync: async (time: Date) => {
|
||||||
const itemsInCollection = await getSetClient.lrange(channelName, 0, -1);
|
const itemsInCollection = await getSetClient().lrange(channelName, 0, -1);
|
||||||
return itemsInCollection
|
return itemsInCollection
|
||||||
.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item))
|
.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item))
|
||||||
.filter((item) => item.timestamp < time);
|
.filter((item) => item.timestamp < time);
|
||||||
},
|
},
|
||||||
getLengthAsync: async () => {
|
getLengthAsync: async () => {
|
||||||
return await getSetClient.llen(channelName);
|
return await getSetClient().llen(channelName);
|
||||||
},
|
},
|
||||||
name: channelName,
|
name: channelName,
|
||||||
};
|
};
|
||||||
@@ -271,11 +274,11 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
|
|||||||
*/
|
*/
|
||||||
export const createChannelEventHistoryOld = <TData>(channelName: string, maxElements = 15) => {
|
export const createChannelEventHistoryOld = <TData>(channelName: string, maxElements = 15) => {
|
||||||
const popElementsOverMaxAsync = async () => {
|
const popElementsOverMaxAsync = async () => {
|
||||||
const length = await getSetClient.llen(channelName);
|
const length = await getSetClient().llen(channelName);
|
||||||
if (length <= maxElements) {
|
if (length <= maxElements) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await getSetClient.ltrim(channelName, 0, maxElements - 1);
|
await getSetClient().ltrim(channelName, 0, maxElements - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -285,33 +288,33 @@ export const createChannelEventHistoryOld = <TData>(channelName: string, maxElem
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
publishAndPushAsync: async (data: TData) => {
|
publishAndPushAsync: async (data: TData) => {
|
||||||
await publisher.publish(channelName, superjson.stringify(data));
|
await getPublisher().publish(channelName, superjson.stringify(data));
|
||||||
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
await popElementsOverMaxAsync();
|
await popElementsOverMaxAsync();
|
||||||
},
|
},
|
||||||
pushAsync: async (data: TData) => {
|
pushAsync: async (data: TData) => {
|
||||||
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
await popElementsOverMaxAsync();
|
await popElementsOverMaxAsync();
|
||||||
},
|
},
|
||||||
clearAsync: async () => {
|
clearAsync: async () => {
|
||||||
await getSetClient.del(channelName);
|
await getSetClient().del(channelName);
|
||||||
},
|
},
|
||||||
getLastAsync: async () => {
|
getLastAsync: async () => {
|
||||||
const length = await getSetClient.llen(channelName);
|
const length = await getSetClient().llen(channelName);
|
||||||
const data = await getSetClient.lrange(channelName, length - 1, length);
|
const data = await getSetClient().lrange(channelName, length - 1, length);
|
||||||
if (data.length !== 1) return null;
|
if (data.length !== 1) return null;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return superjson.parse<{ data: TData; timestamp: Date }>(data[0]!);
|
return superjson.parse<{ data: TData; timestamp: Date }>(data[0]!);
|
||||||
},
|
},
|
||||||
getSliceAsync: async (startIndex: number, endIndex: number) => {
|
getSliceAsync: async (startIndex: number, endIndex: number) => {
|
||||||
const range = await getSetClient.lrange(channelName, startIndex, endIndex);
|
const range = await getSetClient().lrange(channelName, startIndex, endIndex);
|
||||||
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
|
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
|
||||||
},
|
},
|
||||||
getSliceUntilTimeAsync: async (time: Date) => {
|
getSliceUntilTimeAsync: async (time: Date) => {
|
||||||
const length = await getSetClient.llen(channelName);
|
const length = await getSetClient().llen(channelName);
|
||||||
const items: TData[] = [];
|
const items: TData[] = [];
|
||||||
const itemsInCollection = await getSetClient.lrange(channelName, 0, length - 1);
|
const itemsInCollection = await getSetClient().lrange(channelName, 0, length - 1);
|
||||||
|
|
||||||
for (let i = 0; i < length - 1; i++) {
|
for (let i = 0; i < length - 1; i++) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
@@ -324,7 +327,7 @@ export const createChannelEventHistoryOld = <TData>(channelName: string, maxElem
|
|||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
getLengthAsync: async () => {
|
getLengthAsync: async () => {
|
||||||
return await getSetClient.llen(channelName);
|
return await getSetClient().llen(channelName);
|
||||||
},
|
},
|
||||||
name: channelName,
|
name: channelName,
|
||||||
};
|
};
|
||||||
@@ -338,14 +341,14 @@ export const createChannelWithLatestAndEvents = <TData>(channelName: string) =>
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
publishAndUpdateLastStateAsync: async (data: TData) => {
|
publishAndUpdateLastStateAsync: async (data: TData) => {
|
||||||
await publisher.publish(channelName, superjson.stringify(data));
|
await getPublisher().publish(channelName, superjson.stringify(data));
|
||||||
await getSetClient.set(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().set(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
},
|
},
|
||||||
setAsync: async (data: TData) => {
|
setAsync: async (data: TData) => {
|
||||||
await getSetClient.set(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
await getSetClient().set(channelName, superjson.stringify({ data, timestamp: new Date() }));
|
||||||
},
|
},
|
||||||
getAsync: async () => {
|
getAsync: async () => {
|
||||||
const data = await getSetClient.get(channelName);
|
const data = await getSetClient().get(channelName);
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
return superjson.parse<{ data: TData; timestamp: Date }>(data);
|
return superjson.parse<{ data: TData; timestamp: Date }>(data);
|
||||||
@@ -354,7 +357,8 @@ export const createChannelWithLatestAndEvents = <TData>(channelName: string) =>
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const queueClient = createRedisConnection();
|
let _queueClient: RedisClient | undefined;
|
||||||
|
const getQueueClient = () => (_queueClient ??= createRedisConnection());
|
||||||
|
|
||||||
type WithId<TItem> = TItem & { _id: string };
|
type WithId<TItem> = TItem & { _id: string };
|
||||||
|
|
||||||
@@ -366,11 +370,11 @@ type WithId<TItem> = TItem & { _id: string };
|
|||||||
export const createQueueChannel = <TItem>(name: string) => {
|
export const createQueueChannel = <TItem>(name: string) => {
|
||||||
const queueChannelName = `queue:${name}`;
|
const queueChannelName = `queue:${name}`;
|
||||||
const getDataAsync = async () => {
|
const getDataAsync = async () => {
|
||||||
const data = await queueClient.get(queueChannelName);
|
const data = await getQueueClient().get(queueChannelName);
|
||||||
return data ? superjson.parse<WithId<TItem>[]>(data) : [];
|
return data ? superjson.parse<WithId<TItem>[]>(data) : [];
|
||||||
};
|
};
|
||||||
const setDataAsync = async (data: WithId<TItem>[]) => {
|
const setDataAsync = async (data: WithId<TItem>[]) => {
|
||||||
await queueClient.set(queueChannelName, superjson.stringify(data));
|
await getQueueClient().set(queueChannelName, superjson.stringify(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -417,5 +421,5 @@ export const createQueueChannel = <TItem>(name: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handshakeAsync = async () => {
|
export const handshakeAsync = async () => {
|
||||||
await getSetClient.hello();
|
await getSetClient().hello();
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { describe, expect, test, vi } from "vitest";
|
||||||
|
|
||||||
|
import { createRedisClient } from "@homarr/core/infrastructure/redis";
|
||||||
|
|
||||||
|
import { createRedisConnection } from "./connection";
|
||||||
|
|
||||||
|
const mockRedisInstance = { ping: vi.fn() };
|
||||||
|
|
||||||
|
vi.mock("@homarr/core/infrastructure/redis", () => ({
|
||||||
|
createRedisClient: vi.fn(() => mockRedisInstance),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("createRedisConnection", () => {
|
||||||
|
test("returns a redis client regardless of CI env", () => {
|
||||||
|
const original = process.env.CI;
|
||||||
|
process.env.CI = "true";
|
||||||
|
|
||||||
|
const client = createRedisConnection();
|
||||||
|
|
||||||
|
expect(client).toBe(mockRedisInstance);
|
||||||
|
expect(client).not.toBeNull();
|
||||||
|
|
||||||
|
process.env.CI = original;
|
||||||
|
});
|
||||||
|
|
||||||
|
test("returns a redis client when DISABLE_REDIS_LOGS is set", () => {
|
||||||
|
const original = process.env.DISABLE_REDIS_LOGS;
|
||||||
|
process.env.DISABLE_REDIS_LOGS = "true";
|
||||||
|
|
||||||
|
const client = createRedisConnection();
|
||||||
|
|
||||||
|
expect(client).toBe(mockRedisInstance);
|
||||||
|
expect(client).not.toBeNull();
|
||||||
|
|
||||||
|
process.env.DISABLE_REDIS_LOGS = original;
|
||||||
|
});
|
||||||
|
|
||||||
|
test("always delegates to createRedisClient", () => {
|
||||||
|
vi.mocked(createRedisClient).mockClear();
|
||||||
|
|
||||||
|
createRedisConnection();
|
||||||
|
|
||||||
|
expect(createRedisClient).toHaveBeenCalledOnce();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,15 +1,3 @@
|
|||||||
import type { RedisClient } from "@homarr/core/infrastructure/redis";
|
|
||||||
import { createRedisClient } from "@homarr/core/infrastructure/redis";
|
import { createRedisClient } from "@homarr/core/infrastructure/redis";
|
||||||
|
|
||||||
/**
|
export const createRedisConnection = () => createRedisClient();
|
||||||
* Creates a new Redis connection
|
|
||||||
* @returns redis client
|
|
||||||
*/
|
|
||||||
export const createRedisConnection = () => {
|
|
||||||
if (Boolean(process.env.CI) || Boolean(process.env.DISABLE_REDIS_LOGS)) {
|
|
||||||
// Return null if we are in CI as we don't want to connect to Redis
|
|
||||||
return null as unknown as RedisClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
return createRedisClient();
|
|
||||||
};
|
|
||||||
@@ -2,6 +2,7 @@ import dayjs from "dayjs";
|
|||||||
import type { ContainerInfo, ContainerStats } from "dockerode";
|
import type { ContainerInfo, ContainerStats } from "dockerode";
|
||||||
import type Dockerode from "dockerode";
|
import type Dockerode from "dockerode";
|
||||||
|
|
||||||
|
import { bestMatch } from "@homarr/common";
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
||||||
import { db, like, or } from "@homarr/db";
|
import { db, like, or } from "@homarr/db";
|
||||||
@@ -82,12 +83,7 @@ async function getContainersWithStatsAsync() {
|
|||||||
name: container.Names[0]?.split("/")[1] ?? "Unknown",
|
name: container.Names[0]?.split("/")[1] ?? "Unknown",
|
||||||
host: container.instance,
|
host: container.instance,
|
||||||
state: container.State as ContainerState,
|
state: container.State as ContainerState,
|
||||||
iconUrl:
|
iconUrl: bestMatch(extractImage(container), dbIcons, (icon) => icon.name)?.url ?? null,
|
||||||
dbIcons.find((icon) => {
|
|
||||||
const extractedImage = extractImage(container);
|
|
||||||
if (!extractedImage) return false;
|
|
||||||
return icon.name.toLowerCase().includes(extractedImage.toLowerCase());
|
|
||||||
})?.url ?? null,
|
|
||||||
cpuUsage,
|
cpuUsage,
|
||||||
memoryUsage,
|
memoryUsage,
|
||||||
image: container.Image,
|
image: container.Image,
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
"label": "在新标签页中打开搜索结果"
|
"label": "在新标签页中打开搜索结果"
|
||||||
},
|
},
|
||||||
"ddgBangs": {
|
"ddgBangs": {
|
||||||
"label": ""
|
"label": "启用 DuckDuckGo bangs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -252,10 +252,10 @@
|
|||||||
"changeDdgBangs": {
|
"changeDdgBangs": {
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"message": ""
|
"message": "DuckDuckGo bangs 切换成功"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": ""
|
"message": "无法切换 DuckDuckGo bangs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1093,7 +1093,7 @@
|
|||||||
},
|
},
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "自动",
|
||||||
"light": "日间",
|
"light": "日间",
|
||||||
"dark": "暗黑"
|
"dark": "暗黑"
|
||||||
}
|
}
|
||||||
@@ -1540,13 +1540,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"timetable": {
|
"timetable": {
|
||||||
"name": "",
|
"name": "时刻表",
|
||||||
"description": "",
|
"description": "显示车站的出发时间",
|
||||||
"title": "",
|
"title": "出发时间 {station}",
|
||||||
"noStation": "",
|
"noStation": "未选择车站",
|
||||||
"option": {
|
"option": {
|
||||||
"station": {
|
"station": {
|
||||||
"label": ""
|
"label": "车站"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1621,11 +1621,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"anchorNote": {
|
"anchorNote": {
|
||||||
"name": "",
|
"name": "锚点笔记",
|
||||||
"description": "",
|
"description": "显示来自锚点的所选笔记",
|
||||||
"option": {
|
"option": {
|
||||||
"noteId": {
|
"noteId": {
|
||||||
"label": ""
|
"label": "笔记"
|
||||||
},
|
},
|
||||||
"showTitle": {
|
"showTitle": {
|
||||||
"label": "显示标题"
|
"label": "显示标题"
|
||||||
@@ -1637,16 +1637,16 @@
|
|||||||
"empty": "选择要显示的笔记",
|
"empty": "选择要显示的笔记",
|
||||||
"emptyContent": "此笔记没有内容",
|
"emptyContent": "此笔记没有内容",
|
||||||
"notFound": "未找到笔记",
|
"notFound": "未找到笔记",
|
||||||
"noNotes": "",
|
"noNotes": "未找到笔记",
|
||||||
"integrationRequired": "",
|
"integrationRequired": "请先选择锚点集成",
|
||||||
"updatedAt": "更新时间:{date}",
|
"updatedAt": "更新时间:{date}",
|
||||||
"untitled": "未命名",
|
"untitled": "未命名",
|
||||||
"edit": "编辑",
|
"edit": "编辑",
|
||||||
"save": "保存",
|
"save": "保存",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"readOnlyViewer": "",
|
"readOnlyViewer": "您对该笔记只有查看权限,编辑已禁用。",
|
||||||
"saveForbidden": "",
|
"saveForbidden": "您没有编辑此笔记的权限。",
|
||||||
"saveFailed": ""
|
"saveFailed": "保存此笔记失败,请重试。"
|
||||||
},
|
},
|
||||||
"iframe": {
|
"iframe": {
|
||||||
"name": "iFrame",
|
"name": "iFrame",
|
||||||
@@ -1680,7 +1680,7 @@
|
|||||||
"label": "允许地理位置"
|
"label": "允许地理位置"
|
||||||
},
|
},
|
||||||
"allowModals": {
|
"allowModals": {
|
||||||
"label": ""
|
"label": "允许弹窗"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -2056,156 +2056,156 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tracearr": {
|
"tracearr": {
|
||||||
"name": "",
|
"name": "Tracearr",
|
||||||
"description": "",
|
"description": "增强型媒体服务器监控,提供详细的流与转码数据",
|
||||||
"option": {
|
"option": {
|
||||||
"showStreams": {
|
"showStreams": {
|
||||||
"label": ""
|
"label": "显示活跃流"
|
||||||
},
|
},
|
||||||
"showStats": {
|
"showStats": {
|
||||||
"label": ""
|
"label": "显示统计摘要"
|
||||||
},
|
},
|
||||||
"showRecentActivity": {
|
"showRecentActivity": {
|
||||||
"label": ""
|
"label": "显示近期活动"
|
||||||
},
|
},
|
||||||
"showViolations": {
|
"showViolations": {
|
||||||
"label": ""
|
"label": "显示违规记录"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"activeStreams": "",
|
"activeStreams": "活跃流",
|
||||||
"totalUsers": "",
|
"totalUsers": "总用户数",
|
||||||
"transcodes": "",
|
"transcodes": "转码数",
|
||||||
"bandwidth": ""
|
"bandwidth": "带宽"
|
||||||
},
|
},
|
||||||
"streams": {
|
"streams": {
|
||||||
"empty": "",
|
"empty": "无活跃流",
|
||||||
"user": "",
|
"user": "用户",
|
||||||
"media": "",
|
"media": "媒体",
|
||||||
"state": "",
|
"state": "状态",
|
||||||
"quality": "",
|
"quality": "画质",
|
||||||
"device": "",
|
"device": "设备",
|
||||||
"progress": "",
|
"progress": "进度",
|
||||||
"videoDecision": {
|
"videoDecision": {
|
||||||
"directPlay": "",
|
"directPlay": "直接播放",
|
||||||
"transcode": "",
|
"transcode": "转码",
|
||||||
"directStream": ""
|
"directStream": "直接串流"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recentActivity": {
|
"recentActivity": {
|
||||||
"title": "",
|
"title": "近期活动",
|
||||||
"empty": "",
|
"empty": "暂无近期活动",
|
||||||
"watched": "",
|
"watched": "已观看",
|
||||||
"partial": ""
|
"partial": "部分观看"
|
||||||
},
|
},
|
||||||
"violations": {
|
"violations": {
|
||||||
"title": "",
|
"title": "违规记录",
|
||||||
"empty": "",
|
"empty": "暂无近期违规",
|
||||||
"rule": "",
|
"rule": "规则",
|
||||||
"user": ""
|
"user": "用户"
|
||||||
},
|
},
|
||||||
"noSectionsEnabled": "",
|
"noSectionsEnabled": "未启用任何分区",
|
||||||
"error": {
|
"error": {
|
||||||
"noIntegration": "",
|
"noIntegration": "未配置 Tracearr 集成",
|
||||||
"internalServerError": ""
|
"internalServerError": "获取 Tracearr 数据失败"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"umami": {
|
"umami": {
|
||||||
"name": "",
|
"name": "Umami 分析",
|
||||||
"description": "",
|
"description": "显示来自 Umami 分析实例的访客统计",
|
||||||
"visitors": "",
|
"visitors": "访客",
|
||||||
"active": "",
|
"active": "活跃",
|
||||||
"pageviews": "",
|
"pageviews": "浏览量",
|
||||||
"visits": "",
|
"visits": "访问数",
|
||||||
"bounceRate": "",
|
"bounceRate": "跳出率",
|
||||||
"avgDuration": "",
|
"avgDuration": "平均",
|
||||||
"option": {
|
"option": {
|
||||||
"websiteId": {
|
"websiteId": {
|
||||||
"label": "",
|
"label": "网站",
|
||||||
"description": "",
|
"description": "选择您的 Umami 实例所追踪的网站",
|
||||||
"placeholder": "",
|
"placeholder": "选择一个网站",
|
||||||
"loading": "",
|
"loading": "正在加载网站……",
|
||||||
"noWebsites": "",
|
"noWebsites": "未找到网站",
|
||||||
"configureIntegrationFirst": ""
|
"configureIntegrationFirst": "请先添加 Umami 集成"
|
||||||
},
|
},
|
||||||
"timeFrame": {
|
"timeFrame": {
|
||||||
"label": "",
|
"label": "时间范围",
|
||||||
"description": "",
|
"description": "用于展示访客数据的时间段",
|
||||||
"option": {
|
"option": {
|
||||||
"today": "",
|
"today": "今天",
|
||||||
"24h": "",
|
"24h": "过去 24 小时",
|
||||||
"7d": "",
|
"7d": "过去 7 天",
|
||||||
"30d": "",
|
"30d": "过去 30 天",
|
||||||
"month": "",
|
"month": "本月",
|
||||||
"lastMonth": ""
|
"lastMonth": "上月"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventName": {
|
"eventName": {
|
||||||
"label": "",
|
"label": "事件",
|
||||||
"description": "",
|
"description": "显示特定事件的总发生次数",
|
||||||
"placeholder": "",
|
"placeholder": "选择一个事件",
|
||||||
"loading": "",
|
"loading": "正在加载事件……",
|
||||||
"noEvents": "",
|
"noEvents": "未找到事件",
|
||||||
"none": "",
|
"none": "无事件",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "请先选择网站以加载事件"
|
||||||
},
|
},
|
||||||
"chartType": {
|
"chartType": {
|
||||||
"label": "",
|
"label": "图表类型",
|
||||||
"description": "",
|
"description": "图表的显示样式",
|
||||||
"option": {
|
"option": {
|
||||||
"bar": "",
|
"bar": "条形图",
|
||||||
"sparkline": ""
|
"sparkline": "迷你趋势图"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chartStyle": {
|
"chartStyle": {
|
||||||
"label": "",
|
"label": "图表样式",
|
||||||
"description": "",
|
"description": "如何在图表中显示事件序列",
|
||||||
"option": {
|
"option": {
|
||||||
"grouped": "",
|
"grouped": "并排",
|
||||||
"overlay": ""
|
"overlay": "叠加(子集)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"viewMode": {
|
"viewMode": {
|
||||||
"label": "",
|
"label": "视图",
|
||||||
"description": "",
|
"description": "组件主体中要显示的内容",
|
||||||
"option": {
|
"option": {
|
||||||
"chart": "",
|
"chart": "图表",
|
||||||
"events": "",
|
"events": "事件图表",
|
||||||
"topPages": "",
|
"topPages": "热门页面",
|
||||||
"topReferrers": ""
|
"topReferrers": "热门来源"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventNames": {
|
"eventNames": {
|
||||||
"label": "",
|
"label": "事件",
|
||||||
"description": "",
|
"description": "选择一个或多个要图表化的事件",
|
||||||
"placeholder": "",
|
"placeholder": "选择事件……",
|
||||||
"loading": "",
|
"loading": "正在加载事件……",
|
||||||
"noEvents": "",
|
"noEvents": "未找到事件",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "请先选择网站以加载事件"
|
||||||
},
|
},
|
||||||
"topCount": {
|
"topCount": {
|
||||||
"label": "",
|
"label": "显示数量",
|
||||||
"description": ""
|
"description": "要显示的热门项目数量(最大 500)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event": {
|
"event": {
|
||||||
"occurrences": "",
|
"occurrences": "事件",
|
||||||
"label": ""
|
"label": "事件"
|
||||||
},
|
},
|
||||||
"topPages": {
|
"topPages": {
|
||||||
"direct": ""
|
"direct": "直接"
|
||||||
},
|
},
|
||||||
"topReferrers": {
|
"topReferrers": {
|
||||||
"direct": ""
|
"direct": "直接"
|
||||||
},
|
},
|
||||||
"events": {
|
"events": {
|
||||||
"selectPrompt": ""
|
"selectPrompt": "选择要图表化的事件"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"noIntegration": "",
|
"noIntegration": "未配置 Umami 集成",
|
||||||
"noWebsite": "",
|
"noWebsite": "未配置网站",
|
||||||
"noData": "",
|
"noData": "无可用数据",
|
||||||
"internalServerError": ""
|
"internalServerError": "获取 Umami 数据失败"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@@ -2304,50 +2304,50 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"immich-serverStats": {
|
"immich-serverStats": {
|
||||||
"name": "",
|
"name": "Immich 服务器统计",
|
||||||
"description": "",
|
"description": "有关您的 Immich 实例的信息",
|
||||||
"option": {
|
"option": {
|
||||||
"showUsers": {
|
"showUsers": {
|
||||||
"label": "",
|
"label": "显示用户",
|
||||||
"description": ""
|
"description": "显示实例上的用户数量"
|
||||||
},
|
},
|
||||||
"showPhotos": {
|
"showPhotos": {
|
||||||
"label": "显示图片",
|
"label": "显示图片",
|
||||||
"description": ""
|
"description": "显示实例上的照片数量"
|
||||||
},
|
},
|
||||||
"showVideos": {
|
"showVideos": {
|
||||||
"label": "显示视频",
|
"label": "显示视频",
|
||||||
"description": ""
|
"description": "显示实例上的视频数量"
|
||||||
},
|
},
|
||||||
"showStorage": {
|
"showStorage": {
|
||||||
"label": "显示存储",
|
"label": "显示存储",
|
||||||
"description": ""
|
"description": "显示已使用的总存储空间"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"users": "",
|
"users": "用户",
|
||||||
"photos": "",
|
"photos": "照片",
|
||||||
"videos": "",
|
"videos": "视频",
|
||||||
"storage": ""
|
"storage": "已用存储"
|
||||||
},
|
},
|
||||||
"immich-albumCarousel": {
|
"immich-albumCarousel": {
|
||||||
"name": "",
|
"name": "Immich 相册",
|
||||||
"option": {
|
"option": {
|
||||||
"albumId": {
|
"albumId": {
|
||||||
"label": "",
|
"label": "相册ID",
|
||||||
"description": ""
|
"description": "这是一个唯一标识符,用于指向您的 Immich 相册。您可以通过打开相册并从 URL 中复制那段唯一字符串来找到该 ID,例如:'a21aca09-9f05-47dc-b1a1-7b53c547226e'"
|
||||||
},
|
},
|
||||||
"rotationIntervalSeconds": {
|
"rotationIntervalSeconds": {
|
||||||
"label": "",
|
"label": "间隔(秒)",
|
||||||
"description": ""
|
"description": "每 X 秒切换一次相册中的图片。最小为 1,最大不得超过 3600。"
|
||||||
},
|
},
|
||||||
"showPhotoInfo": {
|
"showPhotoInfo": {
|
||||||
"label": "显示图片信息",
|
"label": "显示图片信息",
|
||||||
"description": ""
|
"description": "在幻灯片底部显示图片日期和当前索引"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "Immich 相册图片幻灯片",
|
||||||
"noAlbumSelected": "",
|
"noAlbumSelected": "未选择相册,请编辑组件并选择一个相册",
|
||||||
"noPhotos": ""
|
"noPhotos": "此相册中没有照片"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"name": "下载客户端",
|
"name": "下载客户端",
|
||||||
@@ -2658,7 +2658,7 @@
|
|||||||
"label": "隐藏描述"
|
"label": "隐藏描述"
|
||||||
},
|
},
|
||||||
"showPosterImage": {
|
"showPosterImage": {
|
||||||
"label": ""
|
"label": "显示封面图"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2873,28 +2873,28 @@
|
|||||||
"option": {}
|
"option": {}
|
||||||
},
|
},
|
||||||
"speedtestTracker": {
|
"speedtestTracker": {
|
||||||
"name": "",
|
"name": "网速测试追踪器",
|
||||||
"description": "",
|
"description": "显示 网速测试追踪器 实例中的测速结果。",
|
||||||
"option": {
|
"option": {
|
||||||
"showLatestResult": {
|
"showLatestResult": {
|
||||||
"label": ""
|
"label": "显示最新结果"
|
||||||
},
|
},
|
||||||
"showStats": {
|
"showStats": {
|
||||||
"label": ""
|
"label": "显示平均值"
|
||||||
},
|
},
|
||||||
"showRecentResults": {
|
"showRecentResults": {
|
||||||
"label": ""
|
"label": "显示近期结果"
|
||||||
},
|
},
|
||||||
"showPingGraph": {
|
"showPingGraph": {
|
||||||
"label": ""
|
"label": "显示 Ping 图表"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"latestResult": "",
|
"latestResult": "最新结果",
|
||||||
"averages": "",
|
"averages": "平均值",
|
||||||
"tests": "",
|
"tests": "{count}次测试",
|
||||||
"recentResults": "",
|
"recentResults": "近期结果",
|
||||||
"recentResultsSpeed": "",
|
"recentResultsSpeed": "速度",
|
||||||
"recentResultsPing": "",
|
"recentResultsPing": "Ping",
|
||||||
"download": "下载",
|
"download": "下载",
|
||||||
"upload": "上传",
|
"upload": "上传",
|
||||||
"ping": "Ping",
|
"ping": "Ping",
|
||||||
@@ -2902,13 +2902,13 @@
|
|||||||
"avgDownload": "平均下载",
|
"avgDownload": "平均下载",
|
||||||
"avgUpload": "平均上传",
|
"avgUpload": "平均上传",
|
||||||
"avgPing": "平均Ping",
|
"avgPing": "平均Ping",
|
||||||
"healthy": "",
|
"healthy": "健康",
|
||||||
"unhealthy": "",
|
"unhealthy": "不健康",
|
||||||
"ok": "",
|
"ok": "正常",
|
||||||
"fail": "失败",
|
"fail": "失败",
|
||||||
"noSectionsEnabled": "",
|
"noSectionsEnabled": "请在组件选项中至少启用一个模块。",
|
||||||
"error": {
|
"error": {
|
||||||
"internalServerError": ""
|
"internalServerError": "获取测速数据失败"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systemResources": {
|
"systemResources": {
|
||||||
@@ -3680,7 +3680,7 @@
|
|||||||
"defaultColorScheme": {
|
"defaultColorScheme": {
|
||||||
"label": "默认配色方案",
|
"label": "默认配色方案",
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "自动",
|
||||||
"light": "日间",
|
"light": "日间",
|
||||||
"dark": "暗黑"
|
"dark": "暗黑"
|
||||||
}
|
}
|
||||||
@@ -3708,7 +3708,7 @@
|
|||||||
"label": "Minecraft 服务状态"
|
"label": "Minecraft 服务状态"
|
||||||
},
|
},
|
||||||
"timetable": {
|
"timetable": {
|
||||||
"label": ""
|
"label": "时刻表"
|
||||||
},
|
},
|
||||||
"iconsUpdater": {
|
"iconsUpdater": {
|
||||||
"label": "图标更新"
|
"label": "图标更新"
|
||||||
@@ -3780,10 +3780,10 @@
|
|||||||
"label": "天气"
|
"label": "天气"
|
||||||
},
|
},
|
||||||
"tracearr": {
|
"tracearr": {
|
||||||
"label": ""
|
"label": "Tracearr"
|
||||||
},
|
},
|
||||||
"umamiActiveVisitors": {
|
"umamiActiveVisitors": {
|
||||||
"label": ""
|
"label": "Umami 活跃访客"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interval": {
|
"interval": {
|
||||||
@@ -3907,8 +3907,8 @@
|
|||||||
"subtitle": "在许多语言中,有{count}人贡献了翻译"
|
"subtitle": "在许多语言中,有{count}人贡献了翻译"
|
||||||
},
|
},
|
||||||
"sponsors": {
|
"sponsors": {
|
||||||
"title": "",
|
"title": "赞助商",
|
||||||
"subtitle": ""
|
"subtitle": "{count}人通过财务方式支持该项目"
|
||||||
},
|
},
|
||||||
"libraries": {
|
"libraries": {
|
||||||
"title": "相关的库",
|
"title": "相关的库",
|
||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "端口"
|
"label": "端口"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": "宿主机"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
@@ -4496,7 +4499,7 @@
|
|||||||
"title": "全局命令",
|
"title": "全局命令",
|
||||||
"option": {
|
"option": {
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"auto": "",
|
"auto": "切换外观模式",
|
||||||
"light": "切换到日间模式",
|
"light": "切换到日间模式",
|
||||||
"dark": "切换到暗黑模式"
|
"dark": "切换到暗黑模式"
|
||||||
},
|
},
|
||||||
@@ -4548,13 +4551,13 @@
|
|||||||
"group": {
|
"group": {
|
||||||
"searchEngine": {
|
"searchEngine": {
|
||||||
"title": "搜索引擎",
|
"title": "搜索引擎",
|
||||||
"tipDdgBangs": "",
|
"tipDdgBangs": "提示:你也可以在此使用任何 DuckDuckGo Bangs,例如 !something",
|
||||||
"bang": {
|
"bang": {
|
||||||
"searchWithQuery": "",
|
"searchWithQuery": "使用“‘’{query}”搜索“{label}”",
|
||||||
"pressEnterToOpen": "",
|
"pressEnterToOpen": "按 Enter 键打开",
|
||||||
"engineSelected": "",
|
"engineSelected": "已选择{label}({bang})",
|
||||||
"typeQueryToContinue": "",
|
"typeQueryToContinue": "输入搜索查询以继续",
|
||||||
"emptyBangHint": ""
|
"emptyBangHint": "输入 bang,例如 !yt,然后按空格键进行选择"
|
||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "crwdns1920:0crwdne1920:0"
|
"label": "crwdns1920:0crwdne1920:0"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": "crwdns4249:0crwdne4249:0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porty"
|
"label": "Porty"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porte"
|
"label": "Porte"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Ports"
|
"label": "Ports"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Θύρες"
|
"label": "Θύρες"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Puertos"
|
"label": "Puertos"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Ports"
|
"label": "Ports"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "יציאות"
|
"label": "יציאות"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Portovi"
|
"label": "Portovi"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
"label": "Nyissa meg a keresési eredményeket új ablakban"
|
"label": "Nyissa meg a keresési eredményeket új ablakban"
|
||||||
},
|
},
|
||||||
"ddgBangs": {
|
"ddgBangs": {
|
||||||
"label": ""
|
"label": "DuckDuckGo parancsok engedélyezése"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -252,10 +252,10 @@
|
|||||||
"changeDdgBangs": {
|
"changeDdgBangs": {
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"message": ""
|
"message": "DuckDuckGo parancsok sikeresen bekapcsolódott"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": ""
|
"message": "DuckDuckGo parancsokkat nem sikerült bekapcsolni"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1093,7 +1093,7 @@
|
|||||||
},
|
},
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "Automatikus",
|
||||||
"light": "Világos",
|
"light": "Világos",
|
||||||
"dark": "Sötét"
|
"dark": "Sötét"
|
||||||
}
|
}
|
||||||
@@ -2111,101 +2111,101 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"umami": {
|
"umami": {
|
||||||
"name": "",
|
"name": "Umami Analitika",
|
||||||
"description": "",
|
"description": "Umami elemzési rendszeréből származó látogatói statisztikák megjelenítése",
|
||||||
"visitors": "",
|
"visitors": "látogatók",
|
||||||
"active": "",
|
"active": "aktív",
|
||||||
"pageviews": "",
|
"pageviews": "oldalletöltések",
|
||||||
"visits": "",
|
"visits": "látogatások",
|
||||||
"bounceRate": "",
|
"bounceRate": "visszapattan",
|
||||||
"avgDuration": "",
|
"avgDuration": "átl",
|
||||||
"option": {
|
"option": {
|
||||||
"websiteId": {
|
"websiteId": {
|
||||||
"label": "",
|
"label": "Honlap",
|
||||||
"description": "",
|
"description": "Válasszon ki egy olyan webhelyet, amelyet az Ön Umami-példánya követ",
|
||||||
"placeholder": "",
|
"placeholder": "Válasszon ki egy weboldalt",
|
||||||
"loading": "",
|
"loading": "Weboldalak betöltése...",
|
||||||
"noWebsites": "",
|
"noWebsites": "Nem található weboldal",
|
||||||
"configureIntegrationFirst": ""
|
"configureIntegrationFirst": "Először csatlakoztassa az Umami integrációt"
|
||||||
},
|
},
|
||||||
"timeFrame": {
|
"timeFrame": {
|
||||||
"label": "",
|
"label": "Időkeret",
|
||||||
"description": "",
|
"description": "Látogatói adatok megjelenítésének időtartama",
|
||||||
"option": {
|
"option": {
|
||||||
"today": "",
|
"today": "Ma",
|
||||||
"24h": "",
|
"24h": "Elmúlt 24 óra",
|
||||||
"7d": "",
|
"7d": "Elmúlt 7 nap",
|
||||||
"30d": "",
|
"30d": "Elmúlt 30 nap",
|
||||||
"month": "",
|
"month": "Ez a hónap",
|
||||||
"lastMonth": ""
|
"lastMonth": "Előző hónap"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventName": {
|
"eventName": {
|
||||||
"label": "",
|
"label": "Esemény",
|
||||||
"description": "",
|
"description": "Egy adott esemény összes előfordulásának megjelenítése",
|
||||||
"placeholder": "",
|
"placeholder": "Válasszon ki egy eseményt",
|
||||||
"loading": "",
|
"loading": "Események betöltése...",
|
||||||
"noEvents": "",
|
"noEvents": "Nem található esemény",
|
||||||
"none": "",
|
"none": "Nincs esemény",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Először válasszon ki egy weboldalt az események betöltéséhez"
|
||||||
},
|
},
|
||||||
"chartType": {
|
"chartType": {
|
||||||
"label": "",
|
"label": "Diagramtípus",
|
||||||
"description": "",
|
"description": "A diagram megjelenítési stílusa",
|
||||||
"option": {
|
"option": {
|
||||||
"bar": "",
|
"bar": "Oszlopdiagram",
|
||||||
"sparkline": ""
|
"sparkline": "Mikrodiagram"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chartStyle": {
|
"chartStyle": {
|
||||||
"label": "",
|
"label": "Diagramstílus",
|
||||||
"description": "",
|
"description": "Hogyan jeleníthetjük meg az eseménysorozatot a diagramon",
|
||||||
"option": {
|
"option": {
|
||||||
"grouped": "",
|
"grouped": "Egymás mellett",
|
||||||
"overlay": ""
|
"overlay": "Átfedés (részhalmaz)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"viewMode": {
|
"viewMode": {
|
||||||
"label": "",
|
"label": "Megtekintés",
|
||||||
"description": "",
|
"description": "Mit jelenítsen meg a widget törzse",
|
||||||
"option": {
|
"option": {
|
||||||
"chart": "",
|
"chart": "Ábra",
|
||||||
"events": "",
|
"events": "Eseménynaptár",
|
||||||
"topPages": "",
|
"topPages": "Legnépszerűbb oldalak",
|
||||||
"topReferrers": ""
|
"topReferrers": "Legjobb hivatkozások"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventNames": {
|
"eventNames": {
|
||||||
"label": "",
|
"label": "Események",
|
||||||
"description": "",
|
"description": "Válasszon ki egy vagy több eseményt a grafikonhoz",
|
||||||
"placeholder": "",
|
"placeholder": "Események kiválasztása...",
|
||||||
"loading": "",
|
"loading": "Események betöltése...",
|
||||||
"noEvents": "",
|
"noEvents": "Nem található esemény",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Először válasszon ki egy weboldalt az események betöltéséhez"
|
||||||
},
|
},
|
||||||
"topCount": {
|
"topCount": {
|
||||||
"label": "",
|
"label": "Items to show",
|
||||||
"description": ""
|
"description": "Megjelenítendő legnépszerűbb elemek száma (max. 500)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event": {
|
"event": {
|
||||||
"occurrences": "",
|
"occurrences": "események",
|
||||||
"label": ""
|
"label": "események"
|
||||||
},
|
},
|
||||||
"topPages": {
|
"topPages": {
|
||||||
"direct": ""
|
"direct": "Közvetlen"
|
||||||
},
|
},
|
||||||
"topReferrers": {
|
"topReferrers": {
|
||||||
"direct": ""
|
"direct": "Közvetlen"
|
||||||
},
|
},
|
||||||
"events": {
|
"events": {
|
||||||
"selectPrompt": ""
|
"selectPrompt": "Válassza ki a grafikonra felveendő eseményeket"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"noIntegration": "",
|
"noIntegration": "Nincs beállítva az Umami-integráció",
|
||||||
"noWebsite": "",
|
"noWebsite": "Nincs beállított webhely",
|
||||||
"noData": "",
|
"noData": "Nincs elérhető adat",
|
||||||
"internalServerError": ""
|
"internalServerError": "Umami-adatok letöltése nem sikerült"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@@ -2745,15 +2745,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"importForm": {
|
"importForm": {
|
||||||
"title": ""
|
"title": "Importálás a Docker-ből"
|
||||||
},
|
},
|
||||||
"example": {
|
"example": {
|
||||||
"label": ""
|
"label": "Példa"
|
||||||
},
|
},
|
||||||
"invalid": "",
|
"invalid": "A tároló meghatározása érvénytelen, kérjük, ellenőrizze az értékeket",
|
||||||
"noProvider": {
|
"noProvider": {
|
||||||
"label": "",
|
"label": "Nincs Szolgáltató",
|
||||||
"tooltip": ""
|
"tooltip": "A szolgáltató adatai nem értelmezhetők; kérjük, az importálás után állítsa be azokat manuálisan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2826,34 +2826,34 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"integrationsDisconnected": "",
|
"integrationsDisconnected": "Nincs elérhető adat, az összes integráció le van választva",
|
||||||
"unknownContentOption": ""
|
"unknownContentOption": "A hálózati állapot-widget ismeretlen tartalmi beállítása: "
|
||||||
},
|
},
|
||||||
"name": "",
|
"name": "Hálózat állapota",
|
||||||
"description": ""
|
"description": "A hálózathoz csatlakozó eszközök megjelenítése"
|
||||||
},
|
},
|
||||||
"networkController": {
|
"networkController": {
|
||||||
"error": {
|
"error": {
|
||||||
"internalServerError": ""
|
"internalServerError": "A hálózati vezérlő összefoglalójának letöltése nem sikerült"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"firewall": {
|
"firewall": {
|
||||||
"name": "",
|
"name": "Tűzfal-felügyelet",
|
||||||
"description": "",
|
"description": "Megjeleníti a tűzfalak összefoglalóját",
|
||||||
"tab": {
|
"tab": {
|
||||||
"system": "",
|
"system": "Rendszer",
|
||||||
"interfaces": ""
|
"interfaces": "Interfészek"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"internalServerError": ""
|
"internalServerError": "Nem sikerült adatokat lekérni a tűzfalról"
|
||||||
},
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"interfaces": ""
|
"interfaces": "Megjelenítendő hálózati interfészek"
|
||||||
},
|
},
|
||||||
"widget": {
|
"widget": {
|
||||||
"fwname": "",
|
"fwname": "Név",
|
||||||
"version": "",
|
"version": "Verzió",
|
||||||
"versiontitle": "",
|
"versiontitle": "Verziók",
|
||||||
"cputitle": "CPU használat",
|
"cputitle": "CPU használat",
|
||||||
"memorytitle": "Memória használat",
|
"memorytitle": "Memória használat",
|
||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
@@ -2942,63 +2942,63 @@
|
|||||||
"cpu": "CPU",
|
"cpu": "CPU",
|
||||||
"memory": "RAM",
|
"memory": "RAM",
|
||||||
"gpu": "GPU",
|
"gpu": "GPU",
|
||||||
"network": "",
|
"network": "NET",
|
||||||
"up": "",
|
"up": "FÖNN",
|
||||||
"down": ""
|
"down": "LENN"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systemDisks": {
|
"systemDisks": {
|
||||||
"name": "",
|
"name": "Rendszer lemezek",
|
||||||
"description": "",
|
"description": "A rendszer lemezhasználata",
|
||||||
"option": {
|
"option": {
|
||||||
"showTemperatureIfAvailable": {
|
"showTemperatureIfAvailable": {
|
||||||
"label": ""
|
"label": "Ha elérhető, mutassa a hőmérsékletet"
|
||||||
},
|
},
|
||||||
"displayMode": {
|
"displayMode": {
|
||||||
"label": "",
|
"label": "Megjelenítési mód",
|
||||||
"option": {
|
"option": {
|
||||||
"percentage": {
|
"percentage": {
|
||||||
"label": ""
|
"label": "Százalék (pl: 76%)"
|
||||||
},
|
},
|
||||||
"absolute": {
|
"absolute": {
|
||||||
"label": ""
|
"label": "Abszolút értékek (pl. 800 Gb / 1 Tb)"
|
||||||
},
|
},
|
||||||
"free": {
|
"free": {
|
||||||
"label": ""
|
"label": "A szabad hely aránya (pl. 24% szabad)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"showBackgroundBar": {
|
"showBackgroundBar": {
|
||||||
"label": ""
|
"label": "Háttérhasználati sáv megjelenítése"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"unhealthy": ""
|
"unhealthy": "Hibás"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"widgetPreview": {
|
"widgetPreview": {
|
||||||
"toggle": {
|
"toggle": {
|
||||||
"enabled": "",
|
"enabled": "Szerkesztési mód engedélyezve",
|
||||||
"disabled": ""
|
"disabled": "Szerkesztési mód tiltva"
|
||||||
},
|
},
|
||||||
"dimensions": {
|
"dimensions": {
|
||||||
"title": ""
|
"title": "Dimenzió váltása"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"board": {
|
"board": {
|
||||||
"action": {
|
"action": {
|
||||||
"duplicate": {
|
"duplicate": {
|
||||||
"title": "",
|
"title": "Tábla duplikálása",
|
||||||
"message": "",
|
"message": "Ezzel a {name} tábla teljes tartalmával együtt duplikálódik. Ha a widgetek olyan integrációkra hivatkoznak, amelyek használata nem engedélyezett, azok eltávolításra kerülnek.",
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"title": "",
|
"title": "Tábla duplikálva",
|
||||||
"message": ""
|
"message": "A tábla sikeresen duplikálódott"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"title": "",
|
"title": "Nem lehet duplikálni a táblát",
|
||||||
"message": ""
|
"message": "Nem tudtam duplikálni a táblát"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3006,44 +3006,44 @@
|
|||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"title": "A módosítások sikeresen alkalmazva",
|
"title": "A módosítások sikeresen alkalmazva",
|
||||||
"message": ""
|
"message": "A tábla sikeresen elmentve"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"title": "Nem sikerült alkalmazni a változtatásokat",
|
"title": "Nem sikerült alkalmazni a változtatásokat",
|
||||||
"message": ""
|
"message": "A táblát nem sikerült elmenteni"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"confirmLeave": {
|
"confirmLeave": {
|
||||||
"title": "",
|
"title": "Mentetlen változtatások",
|
||||||
"message": ""
|
"message": "Nem mentett változtatásai vannak, biztosan el akarja hagyni az oldalt?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oldImport": {
|
"oldImport": {
|
||||||
"label": "",
|
"label": "Importálás a homarr 1.0.0 előtti verzióból",
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"title": "",
|
"title": "Sikeres importálás",
|
||||||
"message": ""
|
"message": "A tábla sikeresen importálva"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"title": "",
|
"title": "Importálás nem sikerült",
|
||||||
"message": ""
|
"message": "Táblát nem sikerült importálni; további részletekért nézd meg a naplófájlokat"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"file": {
|
"file": {
|
||||||
"label": "",
|
"label": "JSON fájl kiválasztása",
|
||||||
"invalidError": ""
|
"invalidError": "Érvénytelen konfigurációs fájl"
|
||||||
},
|
},
|
||||||
"apps": {
|
"apps": {
|
||||||
"label": "Alkalmazások",
|
"label": "Alkalmazások",
|
||||||
"avoidDuplicates": {
|
"avoidDuplicates": {
|
||||||
"label": "",
|
"label": "Kerülje az ismétlődéseket",
|
||||||
"description": ""
|
"description": "Nem veszi figyelembe azokat az alkalmazásokat, amelyeknél már létezik azonos href-vel rendelkező alkalmazás"
|
||||||
},
|
},
|
||||||
"onlyImportApps": {
|
"onlyImportApps": {
|
||||||
"label": "",
|
"label": "Csak alkalmazások importálása",
|
||||||
"description": ""
|
"description": "Csak az alkalmazásokat adja hozzá, a táblát manuálisan kell újra létrehozni"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
@@ -3272,15 +3272,15 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"private": {
|
"private": {
|
||||||
"title": "",
|
"title": "Nyilvános tábla készítése",
|
||||||
"description": ""
|
"description": "Biztosan nyilvánossá szeretnéd tenni ezt a fórumot? Ezzel a fórum mindenki számára elérhetővé válik."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"label": "",
|
"label": "Törölje ezt a táblát",
|
||||||
"description": "",
|
"description": "",
|
||||||
"button": "",
|
"button": "Törölje ezt a táblát",
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"title": "Tábla törlése",
|
"title": "Tábla törlése",
|
||||||
"description": ""
|
"description": ""
|
||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Portok"
|
"label": "Portok"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
"label": "Apri risultati di ricerca in una nuova scheda"
|
"label": "Apri risultati di ricerca in una nuova scheda"
|
||||||
},
|
},
|
||||||
"ddgBangs": {
|
"ddgBangs": {
|
||||||
"label": ""
|
"label": "Abilita bangs DuckDuckGo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -252,10 +252,10 @@
|
|||||||
"changeDdgBangs": {
|
"changeDdgBangs": {
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"message": ""
|
"message": "DuckDuckGo bangs attivato con successo"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": ""
|
"message": "Impossibile attivare i bangs DuckDuckGo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1093,7 +1093,7 @@
|
|||||||
},
|
},
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "Automatico",
|
||||||
"light": "Chiaro",
|
"light": "Chiaro",
|
||||||
"dark": "Scuro"
|
"dark": "Scuro"
|
||||||
}
|
}
|
||||||
@@ -2111,101 +2111,101 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"umami": {
|
"umami": {
|
||||||
"name": "",
|
"name": "Umami Analytics",
|
||||||
"description": "",
|
"description": "Visualizza le statistiche dei visitatori dall'istanza Umami analytics",
|
||||||
"visitors": "",
|
"visitors": "visitatori",
|
||||||
"active": "",
|
"active": "attivo",
|
||||||
"pageviews": "",
|
"pageviews": "pagine viste",
|
||||||
"visits": "",
|
"visits": "visite",
|
||||||
"bounceRate": "",
|
"bounceRate": "rimbalzo",
|
||||||
"avgDuration": "",
|
"avgDuration": "media",
|
||||||
"option": {
|
"option": {
|
||||||
"websiteId": {
|
"websiteId": {
|
||||||
"label": "",
|
"label": "Sito web",
|
||||||
"description": "",
|
"description": "Seleziona un sito web tracciato dalla tua istanza di Umami",
|
||||||
"placeholder": "",
|
"placeholder": "Seleziona un sito web",
|
||||||
"loading": "",
|
"loading": "Caricamento siti web...",
|
||||||
"noWebsites": "",
|
"noWebsites": "Nessun sito web trovato",
|
||||||
"configureIntegrationFirst": ""
|
"configureIntegrationFirst": "Connetti prima un'integrazione Umami"
|
||||||
},
|
},
|
||||||
"timeFrame": {
|
"timeFrame": {
|
||||||
"label": "",
|
"label": "Intervallo di tempo",
|
||||||
"description": "",
|
"description": "Il periodo di tempo per visualizzare i dati dei visitatori per",
|
||||||
"option": {
|
"option": {
|
||||||
"today": "",
|
"today": "Oggi",
|
||||||
"24h": "",
|
"24h": "Ultime 24 ore",
|
||||||
"7d": "",
|
"7d": "Ultimi 7 giorni",
|
||||||
"30d": "",
|
"30d": "Ultimi 30 giorni",
|
||||||
"month": "",
|
"month": "Questo mese",
|
||||||
"lastMonth": ""
|
"lastMonth": "Mese precedente"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventName": {
|
"eventName": {
|
||||||
"label": "",
|
"label": "Evento",
|
||||||
"description": "",
|
"description": "Mostra le occorrenze totali di un evento specifico",
|
||||||
"placeholder": "",
|
"placeholder": "Seleziona un evento",
|
||||||
"loading": "",
|
"loading": "Caricamento eventi...",
|
||||||
"noEvents": "",
|
"noEvents": "Nessun evento trovato",
|
||||||
"none": "",
|
"none": "Nessun evento",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Seleziona un sito web prima di caricare gli eventi"
|
||||||
},
|
},
|
||||||
"chartType": {
|
"chartType": {
|
||||||
"label": "",
|
"label": "Tipo di grafico",
|
||||||
"description": "",
|
"description": "Stile di visualizzazione del grafico",
|
||||||
"option": {
|
"option": {
|
||||||
"bar": "",
|
"bar": "Grafico a barre",
|
||||||
"sparkline": ""
|
"sparkline": "Grafico a linee compatto"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chartStyle": {
|
"chartStyle": {
|
||||||
"label": "",
|
"label": "Stile del grafico",
|
||||||
"description": "",
|
"description": "Come visualizzare la serie di eventi nel grafico",
|
||||||
"option": {
|
"option": {
|
||||||
"grouped": "",
|
"grouped": "Affiancati",
|
||||||
"overlay": ""
|
"overlay": "Sovrapponi (subset)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"viewMode": {
|
"viewMode": {
|
||||||
"label": "",
|
"label": "Vista",
|
||||||
"description": "",
|
"description": "Cosa mostrare nel corpo del widget",
|
||||||
"option": {
|
"option": {
|
||||||
"chart": "",
|
"chart": "Grafico",
|
||||||
"events": "",
|
"events": "Grafico degli eventi",
|
||||||
"topPages": "",
|
"topPages": "Pagine più visitate",
|
||||||
"topReferrers": ""
|
"topReferrers": "Referrer principali"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventNames": {
|
"eventNames": {
|
||||||
"label": "",
|
"label": "Eventi",
|
||||||
"description": "",
|
"description": "Scegli uno o più eventi per il grafico",
|
||||||
"placeholder": "",
|
"placeholder": "Seleziona eventi...",
|
||||||
"loading": "",
|
"loading": "Caricamento eventi...",
|
||||||
"noEvents": "",
|
"noEvents": "Nessun evento trovato",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Seleziona prima un sito web per caricare gli eventi"
|
||||||
},
|
},
|
||||||
"topCount": {
|
"topCount": {
|
||||||
"label": "",
|
"label": "Elementi da mostrare",
|
||||||
"description": ""
|
"description": "Numero di elementi principali da visualizzare (max 500)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event": {
|
"event": {
|
||||||
"occurrences": "",
|
"occurrences": "eventi",
|
||||||
"label": ""
|
"label": "eventi"
|
||||||
},
|
},
|
||||||
"topPages": {
|
"topPages": {
|
||||||
"direct": ""
|
"direct": "Diretto"
|
||||||
},
|
},
|
||||||
"topReferrers": {
|
"topReferrers": {
|
||||||
"direct": ""
|
"direct": "Diretto"
|
||||||
},
|
},
|
||||||
"events": {
|
"events": {
|
||||||
"selectPrompt": ""
|
"selectPrompt": "Seleziona gli eventi per il grafico"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"noIntegration": "",
|
"noIntegration": "Nessuna integrazione di Umami configurata",
|
||||||
"noWebsite": "",
|
"noWebsite": "Nessun sito web configurato",
|
||||||
"noData": "",
|
"noData": "Nessun dato disponibile",
|
||||||
"internalServerError": ""
|
"internalServerError": "Recupero dati Umami fallito"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@@ -3680,7 +3680,7 @@
|
|||||||
"defaultColorScheme": {
|
"defaultColorScheme": {
|
||||||
"label": "Schema colore predefinito",
|
"label": "Schema colore predefinito",
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "Automatico",
|
||||||
"light": "Chiaro",
|
"light": "Chiaro",
|
||||||
"dark": "Scuro"
|
"dark": "Scuro"
|
||||||
}
|
}
|
||||||
@@ -3783,7 +3783,7 @@
|
|||||||
"label": "Tracearr"
|
"label": "Tracearr"
|
||||||
},
|
},
|
||||||
"umamiActiveVisitors": {
|
"umamiActiveVisitors": {
|
||||||
"label": ""
|
"label": "Visitatori Attivi Umami"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interval": {
|
"interval": {
|
||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porte"
|
"label": "Porte"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": "Host"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
@@ -4496,7 +4499,7 @@
|
|||||||
"title": "Comandi generali",
|
"title": "Comandi generali",
|
||||||
"option": {
|
"option": {
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"auto": "",
|
"auto": "Attiva/Disattiva modalità aspetto",
|
||||||
"light": "Passa al tema chiaro",
|
"light": "Passa al tema chiaro",
|
||||||
"dark": "Passa al tema scuro"
|
"dark": "Passa al tema scuro"
|
||||||
},
|
},
|
||||||
@@ -4548,13 +4551,13 @@
|
|||||||
"group": {
|
"group": {
|
||||||
"searchEngine": {
|
"searchEngine": {
|
||||||
"title": "Motori di ricerca",
|
"title": "Motori di ricerca",
|
||||||
"tipDdgBangs": "",
|
"tipDdgBangs": "Suggerimento: puoi usare anche i bang di DuckDuckGo, ad esempio !qualcosa",
|
||||||
"bang": {
|
"bang": {
|
||||||
"searchWithQuery": "",
|
"searchWithQuery": "Cerca \"{query}\" con {label}",
|
||||||
"pressEnterToOpen": "",
|
"pressEnterToOpen": "Premere Invio per aprire",
|
||||||
"engineSelected": "",
|
"engineSelected": "{label} selezionato (!{bang})",
|
||||||
"typeQueryToContinue": "",
|
"typeQueryToContinue": "Digita la tua query di ricerca per continuare",
|
||||||
"emptyBangHint": ""
|
"emptyBangHint": "Digita un bang, ad es. !yt, poi premi Spazio per selezionare"
|
||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "ポート"
|
"label": "ポート"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "포트"
|
"label": "포트"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Prievadai"
|
"label": "Prievadai"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Poorten"
|
"label": "Poorten"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
"label": "Åpne søkeresultater i ny fane"
|
"label": "Åpne søkeresultater i ny fane"
|
||||||
},
|
},
|
||||||
"ddgBangs": {
|
"ddgBangs": {
|
||||||
"label": ""
|
"label": "Aktiver DuckDuckGo bangs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
@@ -252,10 +252,10 @@
|
|||||||
"changeDdgBangs": {
|
"changeDdgBangs": {
|
||||||
"notification": {
|
"notification": {
|
||||||
"success": {
|
"success": {
|
||||||
"message": ""
|
"message": "DuckDuckGo bangs er endret vellykket"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"message": ""
|
"message": "Kan ikke slå av/på DuckDuckGo bangs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1093,7 +1093,7 @@
|
|||||||
},
|
},
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "Auto",
|
||||||
"light": "Lys",
|
"light": "Lys",
|
||||||
"dark": "Mørk"
|
"dark": "Mørk"
|
||||||
}
|
}
|
||||||
@@ -2111,101 +2111,101 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"umami": {
|
"umami": {
|
||||||
"name": "",
|
"name": "Umami Analytics",
|
||||||
"description": "",
|
"description": "Vise besøkende statistikk fra din Umami-analyseinstans",
|
||||||
"visitors": "",
|
"visitors": "besøkende",
|
||||||
"active": "",
|
"active": "aktiv",
|
||||||
"pageviews": "",
|
"pageviews": "sidevisninger",
|
||||||
"visits": "",
|
"visits": "besøk",
|
||||||
"bounceRate": "",
|
"bounceRate": "tilbakesende",
|
||||||
"avgDuration": "",
|
"avgDuration": "gjennomsnitt",
|
||||||
"option": {
|
"option": {
|
||||||
"websiteId": {
|
"websiteId": {
|
||||||
"label": "",
|
"label": "Nettsted",
|
||||||
"description": "",
|
"description": "Velg et nettsted som spores av Umami-instansen din",
|
||||||
"placeholder": "",
|
"placeholder": "Velg en nettside",
|
||||||
"loading": "",
|
"loading": "Laster inn nettsteder...",
|
||||||
"noWebsites": "",
|
"noWebsites": "Ingen nettsteder ble funnet",
|
||||||
"configureIntegrationFirst": ""
|
"configureIntegrationFirst": "Koble til en Umami integrasjon først"
|
||||||
},
|
},
|
||||||
"timeFrame": {
|
"timeFrame": {
|
||||||
"label": "",
|
"label": "Tidsramme",
|
||||||
"description": "",
|
"description": "Tidsperiode som skal vise besøkende data for",
|
||||||
"option": {
|
"option": {
|
||||||
"today": "",
|
"today": "I dag",
|
||||||
"24h": "",
|
"24h": "Siste 24 timer",
|
||||||
"7d": "",
|
"7d": "Siste 7 dager",
|
||||||
"30d": "",
|
"30d": "Siste 30 dager",
|
||||||
"month": "",
|
"month": "Denne måneden",
|
||||||
"lastMonth": ""
|
"lastMonth": "Siste måned"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventName": {
|
"eventName": {
|
||||||
"label": "",
|
"label": "Hendelse",
|
||||||
"description": "",
|
"description": "Vis totale forekomster av en bestemt hendelse",
|
||||||
"placeholder": "",
|
"placeholder": "Velg en hendelse",
|
||||||
"loading": "",
|
"loading": "Laster inn hendelser...",
|
||||||
"noEvents": "",
|
"noEvents": "Ingen hendelser funnet",
|
||||||
"none": "",
|
"none": "Ingen hendelser",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Velg en nettside først for å laste inn hendelser"
|
||||||
},
|
},
|
||||||
"chartType": {
|
"chartType": {
|
||||||
"label": "",
|
"label": "Diagramtype",
|
||||||
"description": "",
|
"description": "Vis stil for diagrammet",
|
||||||
"option": {
|
"option": {
|
||||||
"bar": "",
|
"bar": "Søylediagram",
|
||||||
"sparkline": ""
|
"sparkline": "Minigraf"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"chartStyle": {
|
"chartStyle": {
|
||||||
"label": "",
|
"label": "Diagramtype",
|
||||||
"description": "",
|
"description": "Hvordan vise hendelsesserier i diagrammet",
|
||||||
"option": {
|
"option": {
|
||||||
"grouped": "",
|
"grouped": "Side om side",
|
||||||
"overlay": ""
|
"overlay": "Overlegg (delmengde)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"viewMode": {
|
"viewMode": {
|
||||||
"label": "",
|
"label": "Visning",
|
||||||
"description": "",
|
"description": "Hva skal vises i widgetkroppen",
|
||||||
"option": {
|
"option": {
|
||||||
"chart": "",
|
"chart": "Diagram",
|
||||||
"events": "",
|
"events": "Hendelser diagram",
|
||||||
"topPages": "",
|
"topPages": "Toppsider",
|
||||||
"topReferrers": ""
|
"topReferrers": "Topp referenter"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eventNames": {
|
"eventNames": {
|
||||||
"label": "",
|
"label": "Hendelser",
|
||||||
"description": "",
|
"description": "Velg ett eller flere hendelser i diagrammet",
|
||||||
"placeholder": "",
|
"placeholder": "Velg en hendelse...",
|
||||||
"loading": "",
|
"loading": "Laster inn hendelser...",
|
||||||
"noEvents": "",
|
"noEvents": "Ingen hendelser funnet",
|
||||||
"configureWebsiteFirst": ""
|
"configureWebsiteFirst": "Velg en nettside først for å laste inn hendelser"
|
||||||
},
|
},
|
||||||
"topCount": {
|
"topCount": {
|
||||||
"label": "",
|
"label": "Gjenstander å vise",
|
||||||
"description": ""
|
"description": "Antall oppføringer som skal vises (maks 500)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event": {
|
"event": {
|
||||||
"occurrences": "",
|
"occurrences": "hendelser",
|
||||||
"label": ""
|
"label": "hendelser"
|
||||||
},
|
},
|
||||||
"topPages": {
|
"topPages": {
|
||||||
"direct": ""
|
"direct": "Direkte"
|
||||||
},
|
},
|
||||||
"topReferrers": {
|
"topReferrers": {
|
||||||
"direct": ""
|
"direct": "Direkte"
|
||||||
},
|
},
|
||||||
"events": {
|
"events": {
|
||||||
"selectPrompt": ""
|
"selectPrompt": "Velg hendelser for å diagram"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"noIntegration": "",
|
"noIntegration": "Ingen Umami integrasjon konfigurert",
|
||||||
"noWebsite": "",
|
"noWebsite": "Ingen nettsted konfigurert",
|
||||||
"noData": "",
|
"noData": "Ingen data tilgjengelig",
|
||||||
"internalServerError": ""
|
"internalServerError": "Kunne ikke hente Umami data"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
@@ -3680,7 +3680,7 @@
|
|||||||
"defaultColorScheme": {
|
"defaultColorScheme": {
|
||||||
"label": "Standard fargetema",
|
"label": "Standard fargetema",
|
||||||
"options": {
|
"options": {
|
||||||
"auto": "",
|
"auto": "Auto",
|
||||||
"light": "Lys",
|
"light": "Lys",
|
||||||
"dark": "Mørk"
|
"dark": "Mørk"
|
||||||
}
|
}
|
||||||
@@ -3783,7 +3783,7 @@
|
|||||||
"label": "Tracearr"
|
"label": "Tracearr"
|
||||||
},
|
},
|
||||||
"umamiActiveVisitors": {
|
"umamiActiveVisitors": {
|
||||||
"label": ""
|
"label": "Umami Aktive Besøkende"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"interval": {
|
"interval": {
|
||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porter"
|
"label": "Porter"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": "Vert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
@@ -4496,7 +4499,7 @@
|
|||||||
"title": "Globale kommandoer",
|
"title": "Globale kommandoer",
|
||||||
"option": {
|
"option": {
|
||||||
"colorScheme": {
|
"colorScheme": {
|
||||||
"auto": "",
|
"auto": "Bytt visningsmodus",
|
||||||
"light": "Bytt til lys modus",
|
"light": "Bytt til lys modus",
|
||||||
"dark": "Bytt til mørk modus"
|
"dark": "Bytt til mørk modus"
|
||||||
},
|
},
|
||||||
@@ -4548,13 +4551,13 @@
|
|||||||
"group": {
|
"group": {
|
||||||
"searchEngine": {
|
"searchEngine": {
|
||||||
"title": "Søkemotorer",
|
"title": "Søkemotorer",
|
||||||
"tipDdgBangs": "",
|
"tipDdgBangs": "Tips: Du kan også bruke DuckDuckGo-bangs her, f.eks. !something",
|
||||||
"bang": {
|
"bang": {
|
||||||
"searchWithQuery": "",
|
"searchWithQuery": "Søk etter \"{query}\" med {label}",
|
||||||
"pressEnterToOpen": "",
|
"pressEnterToOpen": "Trykk på Enter for å åpne",
|
||||||
"engineSelected": "",
|
"engineSelected": "{label} valgt (!{bang})",
|
||||||
"typeQueryToContinue": "",
|
"typeQueryToContinue": "Skriv inn søkeordet for å fortsette",
|
||||||
"emptyBangHint": ""
|
"emptyBangHint": "Skriv inn en bang, f.eks. !yt, og trykk deretter på mellomrom for å velge"
|
||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porty"
|
"label": "Porty"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Portas"
|
"label": "Portas"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porturi"
|
"label": "Porturi"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Порты"
|
"label": "Порты"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Porty"
|
"label": "Porty"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Vrata"
|
"label": "Vrata"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Portar"
|
"label": "Portar"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -3970,6 +3970,9 @@
|
|||||||
},
|
},
|
||||||
"ports": {
|
"ports": {
|
||||||
"label": "Bağlantı noktaları"
|
"label": "Bağlantı noktaları"
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"label": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user