Merge branch 'dev' into remove-million-lint
This commit is contained in:
26 files changed
+683
-266
No files matched your search
@@ -45,6 +45,12 @@ DB_URL='FULL_PATH_TO_YOUR_SQLITE_DB_FILE'
|
||||
|
||||
TURBO_TELEMETRY_DISABLED=1
|
||||
|
||||
# Comma-separated paths to Docker-compatible Unix sockets.
|
||||
# Useful for connecting to multiple runtimes (Docker + Podman) simultaneously.
|
||||
# When unset and no TCP hosts configured, defaults to /var/run/docker.sock.
|
||||
# Example: DOCKER_SOCKET_PATHS=/var/run/docker.sock,/run/user/1000/podman/podman.sock
|
||||
# DOCKER_SOCKET_PATHS=
|
||||
|
||||
# Enable kubernetes tool
|
||||
# ENABLE_KUBERNETES=true
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
automerge: true,
|
||||
},
|
||||
{
|
||||
// disallow automerge for dependencies requiring postinstall scripts
|
||||
// disallow automerge for onlyBuiltDependencies
|
||||
matchPackageNames: [
|
||||
"@tree-sitter-grammars/tree-sitter-yaml",
|
||||
"bcrypt",
|
||||
@@ -39,7 +39,7 @@
|
||||
],
|
||||
// Updates lockfile for prebuilt-debian after if package.json is updated, otherwise only root lockfile is updated
|
||||
postUpgradeTasks: {
|
||||
commands: ["cd deployments/prebuilt-debian && pnpm install --lockfile-only"],
|
||||
commands: ["cd deployments/prebuilt-debian && pnpm install --ignore-workspace --lockfile-only"],
|
||||
fileFilters: ["deployments/prebuilt-debian/pnpm-lock.yaml"],
|
||||
executionMode: "update",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Expo doesn't play nice with pnpm by default.
|
||||
# The symbolic links of pnpm break the rules of Expo monorepos.
|
||||
# @link https://docs.expo.dev/guides/monorepos/#common-issues
|
||||
node-linker=hoisted
|
||||
strict-peer-dependencies=false
|
||||
engine-strict=true
|
||||
@@ -3,7 +3,11 @@
|
||||
|
||||
# Exempt Renovate‑managed files (no owners)
|
||||
package.json
|
||||
**/package.json
|
||||
package-lock.json
|
||||
**/package-lock.json
|
||||
pnpm-lock.yaml
|
||||
**/pnpm-lock.yaml
|
||||
pnpm-workspace.yaml
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
@@ -58,6 +58,18 @@ const createColumns = (
|
||||
return <ContainerStateBadge state={cell.row.original.state} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "host",
|
||||
header: t("docker.field.host.label"),
|
||||
size: 140,
|
||||
Cell({ row }) {
|
||||
return (
|
||||
<Text truncate="end" title={row.original.host}>
|
||||
{row.original.host}
|
||||
</Text>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "image",
|
||||
header: t("docker.field.containerImage.label"),
|
||||
|
||||
@@ -2,6 +2,5 @@ FROM node:24.15.0-trixie AS base
|
||||
WORKDIR /app
|
||||
COPY package.json .
|
||||
COPY pnpm-lock.yaml .
|
||||
COPY pnpm-workspace.yaml .
|
||||
RUN corepack enable pnpm && pnpm install --frozen-lockfile
|
||||
CMD ["sleep", "60s"]
|
||||
@@ -4,9 +4,14 @@
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.9.0"
|
||||
},
|
||||
"packageManager": "pnpm@11.0.4",
|
||||
"packageManager": "pnpm@10.33.2",
|
||||
"engines": {
|
||||
"node": ">=24.15.0",
|
||||
"pnpm": ">=11.0.4"
|
||||
"pnpm": ">=10.33.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"better-sqlite3"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
allowBuilds:
|
||||
better-sqlite3: true
|
||||
+47
-4
@@ -57,12 +57,55 @@
|
||||
"turbo": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vite-tsconfig-paths": "catalog:",
|
||||
"vitest": "catalog:",
|
||||
"yaml": "catalog:"
|
||||
"vitest": "catalog:"
|
||||
},
|
||||
"packageManager": "pnpm@11.0.4",
|
||||
"packageManager": "pnpm@10.33.2",
|
||||
"engines": {
|
||||
"node": ">=24.15.0",
|
||||
"pnpm": ">=11.0.4"
|
||||
"pnpm": ">=10.33.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@tree-sitter-grammars/tree-sitter-yaml",
|
||||
"bcrypt",
|
||||
"better-sqlite3",
|
||||
"cpu-features",
|
||||
"esbuild",
|
||||
"sharp",
|
||||
"ssh2",
|
||||
"tree-sitter",
|
||||
"tree-sitter-json"
|
||||
],
|
||||
"overrides": {
|
||||
"@babel/helpers@<7.26.10": ">=7.29.2",
|
||||
"@babel/runtime@<7.26.10": ">=7.29.2",
|
||||
"axios@>=1.0.0 <1.8.2": ">=1.16.0",
|
||||
"brace-expansion@>=2.0.0 <=2.0.1": ">=5.0.5",
|
||||
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.5",
|
||||
"esbuild@<=0.24.2": ">=0.28.0",
|
||||
"form-data@>=4.0.0 <4.0.4": ">=4.0.5",
|
||||
"hono@<4.6.5": ">=4.12.16",
|
||||
"linkifyjs@<4.3.2": ">=4.3.2",
|
||||
"nanoid@>=4.0.0 <5.0.9": ">=5.1.11",
|
||||
"prismjs@<1.30.0": ">=1.30.0",
|
||||
"proxmox-api>undici": "7.24.6",
|
||||
"react-is": "^19.2.5",
|
||||
"rollup@>=4.0.0 <4.22.4": ">=4.60.2",
|
||||
"sha.js@<=2.4.11": ">=2.4.12",
|
||||
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2",
|
||||
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2",
|
||||
"tmp@<=0.2.3": ">=0.2.5",
|
||||
"vite@>=5.0.0 <=5.4.18": ">=8.0.10"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"@types/node-unifi": "patches/@types__node-unifi.patch",
|
||||
"trpc-to-openapi": "patches/trpc-to-openapi.patch"
|
||||
},
|
||||
"allowUnusedPatches": true,
|
||||
"ignoredBuiltDependencies": [
|
||||
"@scarf/scarf",
|
||||
"core-js-pure",
|
||||
"protobufjs"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,7 @@ const getContainerOrThrowAsync = async (id: string) => {
|
||||
interface DockerContainer {
|
||||
name: string;
|
||||
id: string;
|
||||
host: string;
|
||||
state: ContainerState;
|
||||
image: string;
|
||||
ports: Port[] | undefined;
|
||||
|
||||
@@ -61,7 +61,7 @@ export const integrationDefs = {
|
||||
},
|
||||
qBittorrent: {
|
||||
name: "qBittorrent",
|
||||
secretKinds: [["username", "password"]],
|
||||
secretKinds: [["apiKey"], ["username", "password"]],
|
||||
iconUrl: "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@master/svg/qbittorrent.svg",
|
||||
category: ["downloadClient", "torrent"],
|
||||
documentationUrl: createDocumentationLink("/docs/integrations/q-bittorent"),
|
||||
|
||||
@@ -4,9 +4,11 @@ import { createBooleanSchema, createEnv } from "@homarr/core/infrastructure/env"
|
||||
|
||||
export const env = createEnv({
|
||||
server: {
|
||||
// Comma separated list of docker hostnames that can be used to connect to query the docker endpoints (localhost:2375,host.docker.internal:2375, ...)
|
||||
// Comma separated list of docker hostnames that can be used to connect to query the docker endpoints (localhost,host.docker.internal, ...)
|
||||
DOCKER_HOSTNAMES: z.string().optional(),
|
||||
DOCKER_PORTS: z.string().optional(),
|
||||
// Comma separated paths to Docker-compatible Unix sockets (e.g., /var/run/docker.sock,/run/user/1000/podman/podman.sock)
|
||||
DOCKER_SOCKET_PATHS: z.string().optional(),
|
||||
ENABLE_DOCKER: createBooleanSchema(true),
|
||||
ENABLE_KUBERNETES: createBooleanSchema(false),
|
||||
},
|
||||
|
||||
@@ -11,31 +11,43 @@ export class DockerSingleton {
|
||||
private static instances: DockerInstance[] | null = null;
|
||||
|
||||
private createInstances() {
|
||||
const socketPaths = env.DOCKER_SOCKET_PATHS;
|
||||
const hostVariable = env.DOCKER_HOSTNAMES;
|
||||
const portVariable = env.DOCKER_PORTS;
|
||||
if (hostVariable === undefined || portVariable === undefined) {
|
||||
|
||||
// Socket instances from DOCKER_SOCKET_PATHS
|
||||
const socketInstances: DockerInstance[] = socketPaths
|
||||
? socketPaths.split(",").map((socketPath) => ({
|
||||
host: socketPath,
|
||||
instance: new Docker({ socketPath }),
|
||||
}))
|
||||
: [];
|
||||
|
||||
// TCP instances from existing DOCKER_HOSTNAMES/DOCKER_PORTS
|
||||
let tcpInstances: DockerInstance[] = [];
|
||||
if (hostVariable !== undefined && portVariable !== undefined) {
|
||||
const hostnames = hostVariable.split(",");
|
||||
const ports = portVariable.split(",");
|
||||
|
||||
if (hostnames.length !== ports.length) {
|
||||
throw new Error("The number of hosts and ports must match");
|
||||
}
|
||||
|
||||
tcpInstances = hostnames.map((host, i) => ({
|
||||
host: `${host}:${ports[i]}`,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
instance: new Docker({ host, port: parseInt(ports[i]!, 10) }),
|
||||
}));
|
||||
}
|
||||
|
||||
const instances = [...socketInstances, ...tcpInstances];
|
||||
|
||||
// Default: local socket if nothing else configured
|
||||
if (instances.length === 0) {
|
||||
return [{ host: "socket", instance: new Docker() }];
|
||||
}
|
||||
const hostnames = hostVariable.split(",");
|
||||
const ports = portVariable.split(",");
|
||||
|
||||
if (hostnames.length !== ports.length) {
|
||||
throw new Error("The number of hosts and ports must match");
|
||||
}
|
||||
|
||||
return hostnames.map((host, i) => {
|
||||
// Check above ensures that ports[i] is not undefined
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const port = ports[i]!;
|
||||
|
||||
return {
|
||||
host: `${host}:${port}`,
|
||||
instance: new Docker({
|
||||
host,
|
||||
port: parseInt(port, 10),
|
||||
}),
|
||||
};
|
||||
});
|
||||
return instances;
|
||||
}
|
||||
|
||||
public static findInstance(host: string): DockerInstance | undefined {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||
|
||||
import { DockerSingleton } from "../singleton";
|
||||
|
||||
const mockEnv = vi.hoisted(() => ({
|
||||
DOCKER_SOCKET_PATHS: undefined as string | undefined,
|
||||
DOCKER_HOSTNAMES: undefined as string | undefined,
|
||||
DOCKER_PORTS: undefined as string | undefined,
|
||||
ENABLE_DOCKER: true,
|
||||
ENABLE_KUBERNETES: false,
|
||||
}));
|
||||
|
||||
vi.mock("dockerode", () => {
|
||||
return {
|
||||
default: class MockDocker {
|
||||
constructor(public opts?: Record<string, unknown>) {}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../env", () => ({
|
||||
env: mockEnv,
|
||||
}));
|
||||
|
||||
describe("DockerSingleton", () => {
|
||||
beforeEach(() => {
|
||||
// Reset singleton cache between tests
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
||||
(DockerSingleton as any).instances = null;
|
||||
|
||||
// Reset env to defaults
|
||||
mockEnv.DOCKER_SOCKET_PATHS = undefined;
|
||||
mockEnv.DOCKER_HOSTNAMES = undefined;
|
||||
mockEnv.DOCKER_PORTS = undefined;
|
||||
});
|
||||
|
||||
test("should return default socket when no env vars set", () => {
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(1);
|
||||
expect(instances[0]?.host).toBe("socket");
|
||||
});
|
||||
|
||||
test("should return TCP instances only when DOCKER_HOSTNAMES and DOCKER_PORTS set", () => {
|
||||
mockEnv.DOCKER_HOSTNAMES = "remote-host";
|
||||
mockEnv.DOCKER_PORTS = "2375";
|
||||
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(1);
|
||||
expect(instances[0]?.host).toBe("remote-host:2375");
|
||||
});
|
||||
|
||||
test("should return multiple TCP instances", () => {
|
||||
mockEnv.DOCKER_HOSTNAMES = "host1,host2";
|
||||
mockEnv.DOCKER_PORTS = "2375,2376";
|
||||
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(2);
|
||||
expect(instances[0]?.host).toBe("host1:2375");
|
||||
expect(instances[1]?.host).toBe("host2:2376");
|
||||
});
|
||||
|
||||
test("should throw when hostname and port counts do not match", () => {
|
||||
mockEnv.DOCKER_HOSTNAMES = "host1,host2";
|
||||
mockEnv.DOCKER_PORTS = "2375";
|
||||
|
||||
expect(() => DockerSingleton.getInstances()).toThrow("The number of hosts and ports must match");
|
||||
});
|
||||
|
||||
test("should return socket instances when DOCKER_SOCKET_PATHS set", () => {
|
||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock";
|
||||
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(1);
|
||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
||||
});
|
||||
|
||||
test("should return multiple socket instances", () => {
|
||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock,/run/user/1000/podman/podman.sock";
|
||||
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(2);
|
||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
||||
expect(instances[1]?.host).toBe("/run/user/1000/podman/podman.sock");
|
||||
});
|
||||
|
||||
test("should combine socket and TCP instances", () => {
|
||||
mockEnv.DOCKER_SOCKET_PATHS = "/var/run/docker.sock,/run/user/1000/podman/podman.sock";
|
||||
mockEnv.DOCKER_HOSTNAMES = "remote-host";
|
||||
mockEnv.DOCKER_PORTS = "2375";
|
||||
|
||||
const instances = DockerSingleton.getInstances();
|
||||
|
||||
expect(instances).toHaveLength(3);
|
||||
expect(instances[0]?.host).toBe("/var/run/docker.sock");
|
||||
expect(instances[1]?.host).toBe("/run/user/1000/podman/podman.sock");
|
||||
expect(instances[2]?.host).toBe("remote-host:2375");
|
||||
});
|
||||
|
||||
test("should cache instances on subsequent calls", () => {
|
||||
const first = DockerSingleton.getInstances();
|
||||
const second = DockerSingleton.getInstances();
|
||||
|
||||
expect(first).toBe(second);
|
||||
});
|
||||
});
|
||||
@@ -90,10 +90,18 @@ export class QBitTorrentIntegration extends Integration implements IDownloadClie
|
||||
}
|
||||
|
||||
private async getClientAsync(dispatcher?: Dispatcher) {
|
||||
const credentials = this.hasSecretValue("apiKey")
|
||||
? {
|
||||
apiKey: this.getSecretValue("apiKey"),
|
||||
}
|
||||
: {
|
||||
username: this.getSecretValue("username"),
|
||||
password: this.getSecretValue("password"),
|
||||
};
|
||||
|
||||
return new QBittorrent({
|
||||
...credentials,
|
||||
baseUrl: this.url("/").toString(),
|
||||
username: this.getSecretValue("username"),
|
||||
password: this.getSecretValue("password"),
|
||||
dispatcher: dispatcher ?? (await createCertificateAgentAsync()),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import dayjs from "dayjs";
|
||||
import type { ContainerInfo, ContainerStats } from "dockerode";
|
||||
import type Dockerode from "dockerode";
|
||||
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
||||
import { db, like, or } from "@homarr/db";
|
||||
import { icons } from "@homarr/db/schema";
|
||||
import type { ContainerState } from "@homarr/docker";
|
||||
@@ -9,6 +11,8 @@ import { dockerLabels, DockerSingleton } from "@homarr/docker";
|
||||
|
||||
import { createCachedWidgetRequestHandler } from "./lib/cached-widget-request-handler";
|
||||
|
||||
const logger = createLogger({ module: "dockerRequestHandler" });
|
||||
|
||||
export const dockerContainersRequestHandler = createCachedWidgetRequestHandler({
|
||||
queryKey: "dockerContainersResult",
|
||||
widgetKind: "dockerContainers",
|
||||
@@ -18,19 +22,34 @@ export const dockerContainersRequestHandler = createCachedWidgetRequestHandler({
|
||||
cacheDuration: dayjs.duration(20, "seconds"),
|
||||
});
|
||||
|
||||
const dockerInstances = DockerSingleton.getInstances();
|
||||
|
||||
const extractImage = (container: ContainerInfo) => container.Image.split("/").at(-1)?.split(":").at(0) ?? "";
|
||||
|
||||
async function getContainersWithStatsAsync() {
|
||||
const containers = await Promise.all(
|
||||
const dockerInstances = DockerSingleton.getInstances();
|
||||
const results = await Promise.allSettled(
|
||||
dockerInstances.map(async ({ instance, host }) => {
|
||||
const instanceContainers = await instance.listContainers({ all: true });
|
||||
return instanceContainers
|
||||
.filter((container) => !(dockerLabels.hide in container.Labels))
|
||||
.map((container) => ({ ...container, instance: host }));
|
||||
}),
|
||||
).then((res) => res.flat());
|
||||
);
|
||||
|
||||
const containers = results.flatMap((result, index) => {
|
||||
if (result.status === "fulfilled") return result.value;
|
||||
logger.warn(
|
||||
new ErrorWithMetadata(
|
||||
"Failed to list containers from Docker host",
|
||||
{
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
host: dockerInstances[index]!.host,
|
||||
},
|
||||
{ cause: result.reason },
|
||||
),
|
||||
);
|
||||
|
||||
return [];
|
||||
});
|
||||
const likeQueries = containers.map((container) => like(icons.name, `%${extractImage(container)}%`));
|
||||
|
||||
const dbIcons =
|
||||
@@ -44,8 +63,6 @@ async function getContainersWithStatsAsync() {
|
||||
const instance = dockerInstances.find(({ host }) => host === container.instance)?.instance;
|
||||
if (!instance) return null;
|
||||
|
||||
// Get stats, falling back to an empty stats object if fetch fails
|
||||
// calculateCpuUsage and calculateMemoryUsage will return 0 for invalid/missing stats
|
||||
const stats = await instance
|
||||
.getContainer(container.Id)
|
||||
.stats({ stream: false, "one-shot": true })
|
||||
@@ -63,6 +80,7 @@ async function getContainersWithStatsAsync() {
|
||||
return {
|
||||
id: container.Id,
|
||||
name: container.Names[0]?.split("/")[1] ?? "Unknown",
|
||||
host: container.instance,
|
||||
state: container.State as ContainerState,
|
||||
iconUrl:
|
||||
dbIcons.find((icon) => {
|
||||
@@ -80,9 +98,10 @@ async function getContainersWithStatsAsync() {
|
||||
return (await Promise.all(containerStatsPromises)).filter((container) => container !== null);
|
||||
}
|
||||
|
||||
function calculateCpuUsage(stats: ContainerStats): number {
|
||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers)
|
||||
if (!stats.cpu_stats.online_cpus || stats.cpu_stats.online_cpus === 0 || !stats.cpu_stats.cpu_usage.total_usage) {
|
||||
export function calculateCpuUsage(stats: ContainerStats): number {
|
||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers, Podman responses)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (!stats.cpu_stats?.online_cpus || stats.cpu_stats.online_cpus === 0 || !stats.cpu_stats.cpu_usage?.total_usage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,9 +114,10 @@ function calculateCpuUsage(stats: ContainerStats): number {
|
||||
return (stats.cpu_stats.cpu_usage.total_usage / usage) * numberOfCpus * 100;
|
||||
}
|
||||
|
||||
function calculateMemoryUsage(stats: ContainerStats): number {
|
||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers)
|
||||
if (!stats.memory_stats.usage) {
|
||||
export function calculateMemoryUsage(stats: ContainerStats): number {
|
||||
// Handle containers with missing or invalid stats (e.g., exited, dead containers, Podman responses)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
if (!stats.memory_stats?.usage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import type { ContainerStats } from "dockerode";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
|
||||
import { createDb } from "@homarr/db/test";
|
||||
|
||||
import { calculateCpuUsage, calculateMemoryUsage } from "../docker";
|
||||
|
||||
vi.mock("@homarr/db", async (importActual) => {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
const actual = await importActual<typeof import("@homarr/db")>();
|
||||
return {
|
||||
...actual,
|
||||
db: createDb(),
|
||||
};
|
||||
});
|
||||
|
||||
// Helper to create a partial stats object, cast to ContainerStats.
|
||||
// This mirrors what Podman and other Docker-compatible runtimes may return
|
||||
// at runtime, even though @types/dockerode declares all fields as required.
|
||||
const createStats = (overrides: Record<string, unknown> = {}) => overrides as unknown as ContainerStats;
|
||||
|
||||
describe("calculateCpuUsage", () => {
|
||||
test("should return 0 when cpu_stats is undefined (Podman)", () => {
|
||||
const stats = createStats({ cpu_stats: undefined });
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when online_cpus is 0", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 0, cpu_usage: { total_usage: 1000 }, system_cpu_usage: 5000 },
|
||||
});
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when online_cpus is undefined", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { cpu_usage: { total_usage: 1000 }, system_cpu_usage: 5000 },
|
||||
});
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when cpu_usage is undefined", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 4, system_cpu_usage: 5000 },
|
||||
});
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when total_usage is 0", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 0 }, system_cpu_usage: 5000 },
|
||||
});
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when system_cpu_usage is 0", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 1000 }, system_cpu_usage: 0 },
|
||||
});
|
||||
expect(calculateCpuUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should calculate correct CPU percentage for valid stats", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 4, cpu_usage: { total_usage: 2000 }, system_cpu_usage: 10000 },
|
||||
});
|
||||
// (2000 / 10000) * 4 * 100 = 80
|
||||
expect(calculateCpuUsage(stats)).toBe(80);
|
||||
});
|
||||
|
||||
test("should handle fractional CPU usage", () => {
|
||||
const stats = createStats({
|
||||
cpu_stats: { online_cpus: 2, cpu_usage: { total_usage: 500 }, system_cpu_usage: 100000 },
|
||||
});
|
||||
// (500 / 100000) * 2 * 100 = 1
|
||||
expect(calculateCpuUsage(stats)).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("calculateMemoryUsage", () => {
|
||||
test("should return 0 when memory_stats is undefined (Podman)", () => {
|
||||
const stats = createStats({ memory_stats: undefined });
|
||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when memory_stats.usage is 0", () => {
|
||||
const stats = createStats({ memory_stats: { usage: 0 } });
|
||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should return 0 when memory_stats.usage is undefined", () => {
|
||||
const stats = createStats({ memory_stats: {} });
|
||||
expect(calculateMemoryUsage(stats)).toBe(0);
|
||||
});
|
||||
|
||||
test("should subtract cache from usage", () => {
|
||||
const stats = createStats({
|
||||
memory_stats: { usage: 1000, stats: { cache: 200 } },
|
||||
});
|
||||
expect(calculateMemoryUsage(stats)).toBe(800);
|
||||
});
|
||||
|
||||
test("should use total_inactive_file when cache is absent", () => {
|
||||
const stats = createStats({
|
||||
memory_stats: { usage: 1000, stats: { total_inactive_file: 300 } },
|
||||
});
|
||||
expect(calculateMemoryUsage(stats)).toBe(700);
|
||||
});
|
||||
|
||||
test("should use inactive_file as last fallback", () => {
|
||||
const stats = createStats({
|
||||
memory_stats: { usage: 1000, stats: { inactive_file: 150 } },
|
||||
});
|
||||
expect(calculateMemoryUsage(stats)).toBe(850);
|
||||
});
|
||||
|
||||
test("should return raw usage when memory_stats.stats is undefined", () => {
|
||||
const stats = createStats({ memory_stats: { usage: 512 } });
|
||||
expect(calculateMemoryUsage(stats)).toBe(512);
|
||||
});
|
||||
});
|
||||
@@ -3970,6 +3970,9 @@
|
||||
},
|
||||
"ports": {
|
||||
"label": "Ports"
|
||||
},
|
||||
"host": {
|
||||
"label": "Host"
|
||||
}
|
||||
},
|
||||
"action": {
|
||||
|
||||
@@ -79,6 +79,19 @@ const createColumns = (
|
||||
return <ContainerStateBadge state={row.original.state} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "host",
|
||||
accessorKey: "host",
|
||||
size: 100,
|
||||
header: t("field.host.label"),
|
||||
Cell({ row }) {
|
||||
return (
|
||||
<Text size="xs" truncate="end">
|
||||
{row.original.host}
|
||||
</Text>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "cpuUsage",
|
||||
sortingFn: (rowA, rowB) => {
|
||||
|
||||
Generated
+243
-154
File diff suppressed because it is too large.
Load diff
+10
-51
@@ -2,35 +2,19 @@ packages:
|
||||
- apps/*
|
||||
- packages/*
|
||||
- tooling/*
|
||||
allowBuilds:
|
||||
"@scarf/scarf": false
|
||||
"@swc/core": false
|
||||
"@tree-sitter-grammars/tree-sitter-yaml": true
|
||||
bcrypt: true
|
||||
better-sqlite3: true
|
||||
core-js-pure: false
|
||||
cpu-features: true
|
||||
esbuild: true
|
||||
protobufjs: false
|
||||
sharp: true
|
||||
ssh2: true
|
||||
tree-sitter: true
|
||||
tree-sitter-json: true
|
||||
nice-napi: false
|
||||
allowUnusedPatches: true
|
||||
catalog:
|
||||
"@auth/core": ^0.41.2
|
||||
"@auth/drizzle-adapter": ^1.11.2
|
||||
"@ctrl/deluge": ^8.0.0
|
||||
"@ctrl/qbittorrent": ^9.11.2
|
||||
"@ctrl/qbittorrent": ^9.12.1
|
||||
"@ctrl/transmission": ^7.4.0
|
||||
"@dnd-kit/core": ^6.3.1
|
||||
"@dnd-kit/modifiers": ^9.0.0
|
||||
"@dnd-kit/sortable": ^10.0.0
|
||||
"@dnd-kit/utilities": ^3.2.2
|
||||
"@drizzle-team/brocli": ^0.12.0
|
||||
"@eslint/js": 10.0.1
|
||||
"@extractus/feed-extractor": 7.1.7
|
||||
'@eslint/js': 10.0.1
|
||||
"@extractus/feed-extractor": 7.2.1
|
||||
"@gitbeaker/rest": ^43.8.0
|
||||
"@homarr/gridstack": ^1.12.0
|
||||
"@homarr/node-unifi": ^2.6.0
|
||||
@@ -60,9 +44,9 @@ catalog:
|
||||
"@semantic-release/release-notes-generator": ^14.1.0
|
||||
"@t3-oss/env-nextjs": ^0.13.11
|
||||
"@tabler/icons-react": ^3.41.1
|
||||
"@tanstack/react-query": ^5.100.8
|
||||
"@tanstack/react-query-devtools": ^5.100.8
|
||||
"@tanstack/react-query-next-experimental": ^5.100.8
|
||||
"@tanstack/react-query": ^5.100.9
|
||||
"@tanstack/react-query-devtools": ^5.100.9
|
||||
"@tanstack/react-query-next-experimental": ^5.100.9
|
||||
"@testcontainers/mysql": ^11.14.0
|
||||
"@testcontainers/postgresql": ^11.14.0
|
||||
"@testcontainers/redis": ^11.14.0
|
||||
@@ -87,7 +71,7 @@ catalog:
|
||||
"@trpc/react-query": ^11.17.0
|
||||
"@trpc/server": ^11.17.0
|
||||
"@trpc/tanstack-react-query": ^11.17.0
|
||||
"@turbo/gen": ^2.9.7
|
||||
"@turbo/gen": ^2.9.8
|
||||
"@types/adm-zip": 0.5.8
|
||||
"@types/bcrypt": 6.0.0
|
||||
"@types/better-sqlite3": 7.6.13
|
||||
@@ -138,7 +122,7 @@ catalog:
|
||||
esbuild: ^0.28.0
|
||||
eslint: ^10.3.0
|
||||
eslint-config-prettier: ^10.1.8
|
||||
eslint-config-turbo: ^2.9.7
|
||||
eslint-config-turbo: ^2.9.8
|
||||
eslint-plugin-import: ^2.32.0
|
||||
eslint-plugin-jsx-a11y: ^6.10.2
|
||||
eslint-plugin-react: ^7.37.5
|
||||
@@ -188,7 +172,7 @@ catalog:
|
||||
trpc-to-openapi: ^3.2.0
|
||||
tsdav: ^2.2.0
|
||||
tsx: 4.20.4
|
||||
turbo: ^2.9.7
|
||||
turbo: ^2.9.8
|
||||
typescript: ^5.9.3
|
||||
typescript-eslint: ^8.58.2
|
||||
undici: 7.24.6
|
||||
@@ -200,36 +184,11 @@ catalog:
|
||||
ws: ^8.20.0
|
||||
xml2js: ^0.6.2
|
||||
yaml: 2.8.4
|
||||
zod: ^4.4.2
|
||||
zod: ^4.4.3
|
||||
zod-form-data: ^3.0.1
|
||||
zod-validation-error: ^5.0.0
|
||||
catalogMode: strict
|
||||
engineStrict: true
|
||||
minimumReleaseAge: 4320
|
||||
minimumReleaseAgeExclude:
|
||||
- next
|
||||
- "@next/*"
|
||||
nodeLinker: hoisted
|
||||
overrides:
|
||||
"@babel/helpers@<7.26.10": ">=7.29.2"
|
||||
"@babel/runtime@<7.26.10": ">=7.29.2"
|
||||
"axios@>=1.0.0 <1.8.2": ">=1.16.0"
|
||||
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.5"
|
||||
"brace-expansion@>=2.0.0 <=2.0.1": ">=5.0.5"
|
||||
"esbuild@<=0.24.2": ">=0.28.0"
|
||||
"form-data@>=4.0.0 <4.0.4": ">=4.0.5"
|
||||
"hono@<4.6.5": ">=4.12.16"
|
||||
"linkifyjs@<4.3.2": ">=4.3.2"
|
||||
"nanoid@>=4.0.0 <5.0.9": ">=5.1.11"
|
||||
"prismjs@<1.30.0": ">=1.30.0"
|
||||
"proxmox-api>undici": "7.24.6"
|
||||
"react-is": "^19.2.5"
|
||||
"rollup@>=4.0.0 <4.22.4": ">=4.60.2"
|
||||
"sha.js@<=2.4.11": ">=2.4.12"
|
||||
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2"
|
||||
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2"
|
||||
"tmp@<=0.2.3": ">=0.2.5"
|
||||
"vite@>=5.0.0 <=5.4.18": ">=8.0.10"
|
||||
patchedDependencies:
|
||||
"@types/node-unifi": "patches/@types__node-unifi.patch"
|
||||
trpc-to-openapi: "patches/trpc-to-openapi.patch"
|
||||
@@ -18,6 +18,19 @@ if [ "${PUID}" != "0" ] || [ "${PGID}" != "0" ]; then
|
||||
echo "Changing owner to $PUID:$PGID, done."
|
||||
fi
|
||||
|
||||
# support _FILE Suffix for environment variables
|
||||
for file_var in $(env | cut -d '=' -f 1 | grep "_FILE$"); do
|
||||
target_var=$(echo "$file_var" | cut -d'=' -f1 | sed 's/_FILE//')
|
||||
file_path=$(printenv "$file_var")
|
||||
|
||||
if [ -f "$file_path" ]; then
|
||||
export "$target_var"=$(cat "$file_path" | tr -d '\n\r')
|
||||
echo "Info: Loaded secret for $target_var from $file_path"
|
||||
else
|
||||
echo "Warning: Secret file $file_path not found for $target_var"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${PUID}" != "0" ]; then
|
||||
exec su-exec $PUID:$PGID "$@"
|
||||
else
|
||||
|
||||
@@ -19,11 +19,6 @@ export AUTH_SECRET=$(openssl rand -base64 32)
|
||||
# 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)
|
||||
|
||||
# Support secret file for encryption key (is not empty and file exists)
|
||||
if [ -n "$SECRET_ENCRYPTION_KEY_FILE" ] && [ -f "$SECRET_ENCRYPTION_KEY_FILE" ]; then
|
||||
export SECRET_ENCRYPTION_KEY=$(cat $SECRET_ENCRYPTION_KEY_FILE)
|
||||
fi
|
||||
|
||||
# Start nginx proxy
|
||||
# 1. Replace the HOSTNAME in the nginx template file
|
||||
# 2. Create the nginx configuration file from the template
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"login":"ajnart","avatar_url":"https://avatars.githubusercontent.com/u/49837342?v=4"},{"login":"manuel-rw","avatar_url":"https://avatars.githubusercontent.com/u/30572287?v=4"},{"login":"Meierschlumpf","avatar_url":"https://avatars.githubusercontent.com/u/63781622?v=4"},{"login":"SeDemal","avatar_url":"https://avatars.githubusercontent.com/u/26098587?v=4"},{"login":"lammersbjorn","avatar_url":"https://avatars.githubusercontent.com/u/71191962?v=4"},{"login":"LarveyOfficial","avatar_url":"https://avatars.githubusercontent.com/u/39219859?v=4"},{"login":"c00ldude1oo","avatar_url":"https://avatars.githubusercontent.com/u/15677803?v=4"},{"login":"InterN0te","avatar_url":"https://avatars.githubusercontent.com/u/10882916?v=4"},{"login":"Aimsucks","avatar_url":"https://avatars.githubusercontent.com/u/1828486?v=4"},{"login":"JannesV","avatar_url":"https://avatars.githubusercontent.com/u/5984244?v=4"},{"login":"MauriceNino","avatar_url":"https://avatars.githubusercontent.com/u/18658092?v=4"},{"login":"hillaliy","avatar_url":"https://avatars.githubusercontent.com/u/950010?v=4"},{"login":"Skeeww","avatar_url":"https://avatars.githubusercontent.com/u/9639992?v=4"},{"login":"RichyHBM","avatar_url":"https://avatars.githubusercontent.com/u/5472275?v=4"},{"login":"Bonfire","avatar_url":"https://avatars.githubusercontent.com/u/5704760?v=4"},{"login":"wieli99","avatar_url":"https://avatars.githubusercontent.com/u/46794825?v=4"},{"login":"ishaanparlikar","avatar_url":"https://avatars.githubusercontent.com/u/43013132?v=4"},{"login":"Zareix","avatar_url":"https://avatars.githubusercontent.com/u/29818713?v=4"},{"login":"tuggan","avatar_url":"https://avatars.githubusercontent.com/u/4325608?v=4"},{"login":"Spillebulle","avatar_url":"https://avatars.githubusercontent.com/u/46653946?v=4"},{"login":"spkesDE","avatar_url":"https://avatars.githubusercontent.com/u/1682314?v=4"},{"login":"j3lte","avatar_url":"https://avatars.githubusercontent.com/u/2557568?v=4"},{"login":"dslatt","avatar_url":"https://avatars.githubusercontent.com/u/5211001?v=4"},{"login":"Malong11-007","avatar_url":"https://avatars.githubusercontent.com/u/40298510?v=4"},{"login":"StefanB7","avatar_url":"https://avatars.githubusercontent.com/u/22056509?v=4"},{"login":"souravghosh01","avatar_url":"https://avatars.githubusercontent.com/u/37548139?v=4"},{"login":"SR3u","avatar_url":"https://avatars.githubusercontent.com/u/2380522?v=4"},{"login":"Rikpat","avatar_url":"https://avatars.githubusercontent.com/u/33869814?v=4"},{"login":"NormanJS","avatar_url":"https://avatars.githubusercontent.com/u/83409549?v=4"},{"login":"No-Maines-Land","avatar_url":"https://avatars.githubusercontent.com/u/20687725?v=4"},{"login":"stark1tty","avatar_url":"https://avatars.githubusercontent.com/u/69326376?v=4"},{"login":"Momcilo42","avatar_url":"https://avatars.githubusercontent.com/u/10118137?v=4"},{"login":"marius-arch","avatar_url":"https://avatars.githubusercontent.com/u/72494359?v=4"},{"login":"Lumilias","avatar_url":"https://avatars.githubusercontent.com/u/10852161?v=4"},{"login":"Havock94","avatar_url":"https://avatars.githubusercontent.com/u/7635248?v=4"},{"login":"Lollyde","avatar_url":"https://avatars.githubusercontent.com/u/11347524?v=4"},{"login":"krishnamuppaneni","avatar_url":"https://avatars.githubusercontent.com/u/4703366?v=4"},{"login":"devtobi","avatar_url":"https://avatars.githubusercontent.com/u/28538704?v=4"},{"login":"TyxTang","avatar_url":"https://avatars.githubusercontent.com/u/90897955?v=4"},{"login":"alotlikebeans","avatar_url":"https://avatars.githubusercontent.com/u/19630511?v=4"},{"login":"WillyJL","avatar_url":"https://avatars.githubusercontent.com/u/49810075?v=4"},{"login":"anonysoul","avatar_url":"https://avatars.githubusercontent.com/u/105715150?v=4"},{"login":"cospeedster","avatar_url":"https://avatars.githubusercontent.com/u/52749645?v=4"},{"login":"diederbert","avatar_url":"https://avatars.githubusercontent.com/u/162878798?v=4"},{"login":"digdilem","avatar_url":"https://avatars.githubusercontent.com/u/4052275?v=4"},{"login":"dinghino","avatar_url":"https://avatars.githubusercontent.com/u/14729459?v=4"},{"login":"gfomichev","avatar_url":"https://avatars.githubusercontent.com/u/1596146?v=4"},{"login":"gnattu","avatar_url":"https://avatars.githubusercontent.com/u/12995396?v=4"},{"login":"tuxpizza","avatar_url":"https://avatars.githubusercontent.com/u/84710786?v=4"},{"login":"xmarkurion","avatar_url":"https://avatars.githubusercontent.com/u/46654687?v=4"},{"login":"huanga","avatar_url":"https://avatars.githubusercontent.com/u/732970?v=4"},{"login":"taos15","avatar_url":"https://avatars.githubusercontent.com/u/122130728?v=4"},{"login":"arghyadipchak","avatar_url":"https://avatars.githubusercontent.com/u/32430374?v=4"},{"login":"AuthorShin","avatar_url":"https://avatars.githubusercontent.com/u/4959043?v=4"},{"login":"benniblot","avatar_url":"https://avatars.githubusercontent.com/u/47495914?v=4"},{"login":"bebsworthy","avatar_url":"https://avatars.githubusercontent.cLine truncated
|
||||
[{"login":"ajnart","avatar_url":"https://avatars.githubusercontent.com/u/49837342?v=4"},{"login":"manuel-rw","avatar_url":"https://avatars.githubusercontent.com/u/30572287?v=4"},{"login":"Meierschlumpf","avatar_url":"https://avatars.githubusercontent.com/u/63781622?v=4"},{"login":"SeDemal","avatar_url":"https://avatars.githubusercontent.com/u/26098587?v=4"},{"login":"lammersbjorn","avatar_url":"https://avatars.githubusercontent.com/u/71191962?v=4"},{"login":"LarveyOfficial","avatar_url":"https://avatars.githubusercontent.com/u/39219859?v=4"},{"login":"c00ldude1oo","avatar_url":"https://avatars.githubusercontent.com/u/15677803?v=4"},{"login":"InterN0te","avatar_url":"https://avatars.githubusercontent.com/u/10882916?v=4"},{"login":"Aimsucks","avatar_url":"https://avatars.githubusercontent.com/u/1828486?v=4"},{"login":"JannesV","avatar_url":"https://avatars.githubusercontent.com/u/5984244?v=4"},{"login":"MauriceNino","avatar_url":"https://avatars.githubusercontent.com/u/18658092?v=4"},{"login":"hillaliy","avatar_url":"https://avatars.githubusercontent.com/u/950010?v=4"},{"login":"Skeeww","avatar_url":"https://avatars.githubusercontent.com/u/9639992?v=4"},{"login":"RichyHBM","avatar_url":"https://avatars.githubusercontent.com/u/5472275?v=4"},{"login":"Bonfire","avatar_url":"https://avatars.githubusercontent.com/u/5704760?v=4"},{"login":"wieli99","avatar_url":"https://avatars.githubusercontent.com/u/46794825?v=4"},{"login":"ishaanparlikar","avatar_url":"https://avatars.githubusercontent.com/u/43013132?v=4"},{"login":"Zareix","avatar_url":"https://avatars.githubusercontent.com/u/29818713?v=4"},{"login":"tuggan","avatar_url":"https://avatars.githubusercontent.com/u/4325608?v=4"},{"login":"Spillebulle","avatar_url":"https://avatars.githubusercontent.com/u/46653946?v=4"},{"login":"spkesDE","avatar_url":"https://avatars.githubusercontent.com/u/1682314?v=4"},{"login":"j3lte","avatar_url":"https://avatars.githubusercontent.com/u/2557568?v=4"},{"login":"dslatt","avatar_url":"https://avatars.githubusercontent.com/u/5211001?v=4"},{"login":"Malong11-007","avatar_url":"https://avatars.githubusercontent.com/u/40298510?v=4"},{"login":"StefanB7","avatar_url":"https://avatars.githubusercontent.com/u/22056509?v=4"},{"login":"souravghosh01","avatar_url":"https://avatars.githubusercontent.com/u/37548139?v=4"},{"login":"SR3u","avatar_url":"https://avatars.githubusercontent.com/u/2380522?v=4"},{"login":"Rikpat","avatar_url":"https://avatars.githubusercontent.com/u/33869814?v=4"},{"login":"NormanJS","avatar_url":"https://avatars.githubusercontent.com/u/83409549?v=4"},{"login":"No-Maines-Land","avatar_url":"https://avatars.githubusercontent.com/u/20687725?v=4"},{"login":"stark1tty","avatar_url":"https://avatars.githubusercontent.com/u/69326376?v=4"},{"login":"Momcilo42","avatar_url":"https://avatars.githubusercontent.com/u/10118137?v=4"},{"login":"marius-arch","avatar_url":"https://avatars.githubusercontent.com/u/72494359?v=4"},{"login":"Lumilias","avatar_url":"https://avatars.githubusercontent.com/u/10852161?v=4"},{"login":"Havock94","avatar_url":"https://avatars.githubusercontent.com/u/7635248?v=4"},{"login":"Lollyde","avatar_url":"https://avatars.githubusercontent.com/u/11347524?v=4"},{"login":"krishnamuppaneni","avatar_url":"https://avatars.githubusercontent.com/u/4703366?v=4"},{"login":"devtobi","avatar_url":"https://avatars.githubusercontent.com/u/28538704?v=4"},{"login":"TyxTang","avatar_url":"https://avatars.githubusercontent.com/u/90897955?v=4"},{"login":"alotlikebeans","avatar_url":"https://avatars.githubusercontent.com/u/19630511?v=4"},{"login":"WillyJL","avatar_url":"https://avatars.githubusercontent.com/u/49810075?v=4"},{"login":"anonysoul","avatar_url":"https://avatars.githubusercontent.com/u/105715150?v=4"},{"login":"cospeedster","avatar_url":"https://avatars.githubusercontent.com/u/52749645?v=4"},{"login":"diederbert","avatar_url":"https://avatars.githubusercontent.com/u/162878798?v=4"},{"login":"digdilem","avatar_url":"https://avatars.githubusercontent.com/u/4052275?v=4"},{"login":"dinghino","avatar_url":"https://avatars.githubusercontent.com/u/14729459?v=4"},{"login":"gfomichev","avatar_url":"https://avatars.githubusercontent.com/u/1596146?v=4"},{"login":"gnattu","avatar_url":"https://avatars.githubusercontent.com/u/12995396?v=4"},{"login":"tuxpizza","avatar_url":"https://avatars.githubusercontent.com/u/84710786?v=4"},{"login":"xmarkurion","avatar_url":"https://avatars.githubusercontent.com/u/46654687?v=4"},{"login":"huanga","avatar_url":"https://avatars.githubusercontent.com/u/732970?v=4"},{"login":"taos15","avatar_url":"https://avatars.githubusercontent.com/u/122130728?v=4"},{"login":"arghyadipchak","avatar_url":"https://avatars.githubusercontent.com/u/32430374?v=4"},{"login":"AuthorShin","avatar_url":"https://avatars.githubusercontent.com/u/4959043?v=4"},{"login":"benniblot","avatar_url":"https://avatars.githubusercontent.com/u/47495914?v=4"},{"login":"bebsworthy","avatar_url":"https://avatars.githubusercontent.cLine truncated
|
||||
@@ -2,24 +2,21 @@ import fs from "fs/promises";
|
||||
import { join } from "path";
|
||||
import json5 from "json5";
|
||||
import { describe, test } from "vitest";
|
||||
import { parse as parseYaml } from "yaml";
|
||||
|
||||
describe("Renovate configuration tests", () => {
|
||||
test("automerge should be disabled for built dependencies", async () => {
|
||||
const pnpmConfig = await fs.readFile(join(__dirname, "../pnpm-workspace.yaml"), "utf-8").then(parseYaml);
|
||||
test("automerge should be disabled for onlyBuiltDependencies", async () => {
|
||||
const packageJson = await import("../package.json");
|
||||
const renovateConfig = await fs.readFile(join(__dirname, "../.github/renovate.json5"), "utf-8").then(json5.parse);
|
||||
const dependenciesWithBuilt = Object.entries(pnpmConfig.allowBuilds)
|
||||
.filter(([_, value]) => value === true)
|
||||
.map(([key, _]) => key);
|
||||
const onlyBuiltDependencies = packageJson.pnpm.onlyBuiltDependencies;
|
||||
const automergeDisabledDeps = renovateConfig.packageRules
|
||||
.filter((rule: any) => rule.automerge === false)
|
||||
.flatMap((rule: any) => rule.matchPackageNames || []);
|
||||
|
||||
const missingDeps = dependenciesWithBuilt.filter((dep: string) => !automergeDisabledDeps.includes(dep));
|
||||
const missingDeps = onlyBuiltDependencies.filter((dep: string) => !automergeDisabledDeps.includes(dep));
|
||||
|
||||
if (missingDeps.length > 0) {
|
||||
throw new Error(
|
||||
`The following built dependencies are missing automerge disable rules in renovate.json5: ${missingDeps.join(", ")}`,
|
||||
`The following onlyBuiltDependencies are missing automerge disable rules in renovate.json5: ${missingDeps.join(", ")}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
"DB_DRIVER",
|
||||
"DOCKER_HOSTNAMES",
|
||||
"DOCKER_PORTS",
|
||||
"DOCKER_SOCKET_PATHS",
|
||||
"NODE_ENV",
|
||||
"PORT",
|
||||
"LOCAL_CERTIFICATE_PATH",
|
||||
|
||||
Reference in new issue
Block a user