From 5f81822366cbbdf2b83f37b52047797862375401 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Tue, 17 Mar 2026 13:31:35 -0400 Subject: [PATCH] feat: correct package.json dependencies and remove libsql --- Dockerfile | 2 - app/server/db/client.server.ts | 3 +- app/server/hp-agent.ts | 7 ++- app/server/web/auth.ts | 4 +- nix/package.nix | 1 - package.json | 45 +++++++------ pnpm-lock.yaml | 111 +++++++++++++++++---------------- vite.config.ts | 6 +- 8 files changed, 86 insertions(+), 93 deletions(-) diff --git a/Dockerfile b/Dockerfile index f009f18..7d16c65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,6 @@ RUN HEADPLANE_VERSION=$HEADPLANE_VERSION ./build.sh --app FROM gcr.io/distroless/nodejs24-debian13:latest AS final COPY --from=js-base /run/build /app/build COPY --from=js-base /run/drizzle /app/drizzle -COPY --from=js-base /run/node_modules /app/node_modules COPY --from=go-base /bin/hp_agent /usr/libexec/headplane/agent COPY --from=go-base /var/lib/headplane /var/lib/headplane @@ -64,7 +63,6 @@ RUN apk add --no-cache bash curl COPY --from=js-base /run/build /app/build COPY --from=js-base /run/drizzle /app/drizzle -COPY --from=js-base /run/node_modules /app/node_modules COPY --from=go-base /bin/hp_agent /usr/libexec/headplane/agent COPY --from=go-base /var/lib/headplane /var/lib/headplane diff --git a/app/server/db/client.server.ts b/app/server/db/client.server.ts index a547a92..4a1b486 100644 --- a/app/server/db/client.server.ts +++ b/app/server/db/client.server.ts @@ -20,8 +20,7 @@ export async function createDbClient(path: string) { throw new Error(`Could not create directory for database at ${realPath}`); } - // Turn the path into a URL with the file protocol - const db = drizzle(`file://${realPath}`); + const db = drizzle(realPath); migrate(db, { migrationsFolder: "./drizzle", }); diff --git a/app/server/hp-agent.ts b/app/server/hp-agent.ts index bb08173..540b3d0 100644 --- a/app/server/hp-agent.ts +++ b/app/server/hp-agent.ts @@ -1,11 +1,12 @@ -import { inArray } from "drizzle-orm"; -import { LibSQLDatabase } from "drizzle-orm/libsql/driver-core"; import { ChildProcessWithoutNullStreams, spawn } from "node:child_process"; import EventEmitter from "node:events"; import { access, constants, mkdir, open } from "node:fs/promises"; import { getegid, geteuid } from "node:process"; import { createInterface, Interface } from "node:readline"; +import { inArray } from "drizzle-orm"; +import { NodeSQLiteDatabase } from "drizzle-orm/node-sqlite"; + import { HostInfo } from "~/types"; import log from "~/utils/log"; @@ -15,7 +16,7 @@ import { hostInfo } from "./db/schema"; export async function createHeadplaneAgent( config: NonNullable["agent"] | undefined, headscaleUrl: string, - db: LibSQLDatabase, + db: NodeSQLiteDatabase, ) { if (!config?.enabled) { return; diff --git a/app/server/web/auth.ts b/app/server/web/auth.ts index 0e71bee..9d790ad 100644 --- a/app/server/web/auth.ts +++ b/app/server/web/auth.ts @@ -1,7 +1,7 @@ import { createHash, createHmac } from "node:crypto"; import { eq, lt, sql } from "drizzle-orm"; -import { LibSQLDatabase } from "drizzle-orm/libsql/driver"; +import { NodeSQLiteDatabase } from "drizzle-orm/node-sqlite"; import { createCookie } from "react-router"; import { ulid } from "ulidx"; @@ -59,7 +59,7 @@ interface CookiePayload { export interface AuthServiceOptions { secret: string; - db: LibSQLDatabase; + db: NodeSQLiteDatabase; cookie: { name: string; secure: boolean; diff --git a/nix/package.nix b/nix/package.nix index 2429fa1..7b09aeb 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -44,7 +44,6 @@ in runHook preInstall mkdir -p $out/{bin,share/headplane} cp -r build $out/share/headplane/ - cp -r node_modules $out/share/headplane/ cp -r drizzle $out/share/headplane/ sed -i "s;$PWD;../..;" $out/share/headplane/build/server/index.js makeWrapper ${lib.getExe nodejs_24} $out/bin/headplane \ diff --git a/package.json b/package.json index 6f060c1..cfb6228 100644 --- a/package.json +++ b/package.json @@ -20,29 +20,18 @@ "format": "oxfmt" }, "dependencies": { - "@base-ui/react": "^1.2.0" - }, - "devDependencies": { + "@base-ui/react": "^1.2.0", "@dnd-kit/core": "^6.3.1", "@dnd-kit/modifiers": "^7.0.0", "@dnd-kit/sortable": "^8.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "10.3.0", "@fontsource-variable/inter": "^5.2.8", "@iconify/react": "^6.0.2", "@kubernetes/client-node": "^1.4.0", "@react-aria/toast": "3.0.10", - "@react-router/dev": "^7.13.1", "@react-router/node": "^7.13.1", "@react-stately/toast": "3.1.3", "@readme/openapi-parser": "^5.5.0", - "@shopify/lang-jsonc": "^1.0.1", - "@tailwindcss/vite": "^4.2.1", - "@types/js-yaml": "^4.0.9", - "@types/node": "^25.3.1", - "@types/react": "^19.2.14", - "@types/react-dom": "^19.2.3", - "@typescript/native-preview": "7.0.0-dev.20260225.1", "@uiw/codemirror-theme-github": "4.25.1", "@uiw/codemirror-theme-xcode": "4.25.5", "@uiw/react-codemirror": "4.25.5", @@ -53,20 +42,14 @@ "@xterm/xterm": "^6.0.0", "arktype": "^2.1.29", "clsx": "^2.1.1", - "drizzle-kit": "1.0.0-beta.16-c2458b2", "drizzle-orm": "1.0.0-beta.16-c2458b2", "isbot": "5.1.35", "jose": "6.2.1", "js-yaml": "^4.1.1", - "lefthook": "^2.1.1", "lucide-react": "^0.575.0", "mime": "^4.1.0", "openapi-types": "^12.1.3", "openid-client": "6.8.2", - "oxfmt": "^0.35.0", - "oxlint": "^1.50.0", - "oxlint-tsgolint": "^0.16.0", - "postcss": "^8.5.6", "react": "19.2.4", "react-aria": "3.46.0", "react-codemirror-merge": "4.25.5", @@ -78,19 +61,36 @@ "react-stately": "3.44.0", "remix-utils": "^9.0.1", "tailwind-merge": "3.5.0", + "ulidx": "2.4.1", + "undici": "7.22.0", + "yaml": "2.8.2" + }, + "devDependencies": { + "@faker-js/faker": "10.3.0", + "@react-router/dev": "^7.13.1", + "@shopify/lang-jsonc": "^1.0.1", + "@tailwindcss/vite": "^4.2.1", + "@types/js-yaml": "^4.0.9", + "@types/node": "^25.3.1", + "@types/react": "^19.2.14", + "@types/react-dom": "^19.2.3", + "@typescript/native-preview": "7.0.0-dev.20260225.1", + "drizzle-kit": "1.0.0-beta.16-c2458b2", + "lefthook": "^2.1.1", + "oxfmt": "^0.35.0", + "oxlint": "^1.50.0", + "oxlint-tsgolint": "^0.16.0", + "postcss": "^8.5.6", "tailwindcss": "^4.2.1", "tailwindcss-animate": "^1.0.7", "tailwindcss-react-aria-components": "^2.0.1", "testcontainers": "^11.12.0", "tsx": "^4.21.0", "typescript": "^5.9.3", - "ulidx": "2.4.1", - "undici": "7.22.0", "vite": "8.0.0-beta.0", "vite-tsconfig-paths": "^6.0.4", "vitepress": "next", - "vitest": "^4.0.18", - "yaml": "2.8.2" + "vitest": "^4.0.18" }, "engines": { "node": ">=24.2 <25", @@ -110,7 +110,6 @@ }, "onlyBuiltDependencies": [ "@tailwindcss/oxide", - "better-sqlite3", "esbuild", "lefthook" ], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d0b5593..3bf6dad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,7 +16,6 @@ importers: '@base-ui/react': specifier: ^1.2.0 version: 1.2.0(@types/react@19.2.14)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) - devDependencies: '@dnd-kit/core': specifier: ^6.3.1 version: 6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4) @@ -29,9 +28,6 @@ importers: '@dnd-kit/utilities': specifier: ^3.2.2 version: 3.2.2(react@19.2.4) - '@faker-js/faker': - specifier: 10.3.0 - version: 10.3.0 '@fontsource-variable/inter': specifier: ^5.2.8 version: 5.2.8 @@ -44,9 +40,6 @@ importers: '@react-aria/toast': specifier: 3.0.10 version: 3.0.10(react-dom@19.2.4(react@19.2.4))(react@19.2.4) - '@react-router/dev': - specifier: ^7.13.1 - version: 7.13.1(@types/node@25.3.1)(jiti@2.6.1)(lightningcss@1.31.1)(react-router@7.13.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(terser@5.39.0)(tsx@4.21.0)(typescript@5.9.3)(vite@8.0.0-beta.0(@types/node@25.3.1)(esbuild@0.25.12)(jiti@2.6.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2))(yaml@2.8.2) '@react-router/node': specifier: ^7.13.1 version: 7.13.1(react-router@7.13.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(typescript@5.9.3) @@ -56,27 +49,6 @@ importers: '@readme/openapi-parser': specifier: ^5.5.0 version: 5.5.0(openapi-types@12.1.3) - '@shopify/lang-jsonc': - specifier: ^1.0.1 - version: 1.0.1 - '@tailwindcss/vite': - specifier: ^4.2.1 - version: 4.2.1(vite@8.0.0-beta.0(@types/node@25.3.1)(esbuild@0.25.12)(jiti@2.6.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2)) - '@types/js-yaml': - specifier: ^4.0.9 - version: 4.0.9 - '@types/node': - specifier: ^25.3.1 - version: 25.3.1 - '@types/react': - specifier: ^19.2.14 - version: 19.2.14 - '@types/react-dom': - specifier: ^19.2.3 - version: 19.2.3(@types/react@19.2.14) - '@typescript/native-preview': - specifier: 7.0.0-dev.20260225.1 - version: 7.0.0-dev.20260225.1 '@uiw/codemirror-theme-github': specifier: 4.25.1 version: 4.25.1(@codemirror/language@6.12.2)(@codemirror/state@6.6.0)(@codemirror/view@6.39.15) @@ -107,9 +79,6 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 - drizzle-kit: - specifier: 1.0.0-beta.16-c2458b2 - version: 1.0.0-beta.16-c2458b2 drizzle-orm: specifier: 1.0.0-beta.16-c2458b2 version: 1.0.0-beta.16-c2458b2(@libsql/client@0.17.0(bufferutil@4.0.9)(utf-8-validate@5.0.10))(@types/better-sqlite3@7.6.13)(@types/mssql@9.1.9(@azure/core-client@1.10.1))(arktype@2.1.29)(better-sqlite3@11.10.0)(mssql@11.0.1(@azure/core-client@1.10.1))(valibot@1.2.0(typescript@5.9.3)) @@ -122,9 +91,6 @@ importers: js-yaml: specifier: ^4.1.1 version: 4.1.1 - lefthook: - specifier: ^2.1.1 - version: 2.1.1 lucide-react: specifier: ^0.575.0 version: 0.575.0(react@19.2.4) @@ -137,18 +103,6 @@ importers: openid-client: specifier: 6.8.2 version: 6.8.2 - oxfmt: - specifier: ^0.35.0 - version: 0.35.0 - oxlint: - specifier: ^1.50.0 - version: 1.50.0(oxlint-tsgolint@0.16.0) - oxlint-tsgolint: - specifier: ^0.16.0 - version: 0.16.0 - postcss: - specifier: ^8.5.6 - version: 8.5.6 react: specifier: 19.2.4 version: 19.2.4 @@ -182,6 +136,61 @@ importers: tailwind-merge: specifier: 3.5.0 version: 3.5.0 + ulidx: + specifier: 2.4.1 + version: 2.4.1 + undici: + specifier: 7.22.0 + version: 7.22.0 + yaml: + specifier: 2.8.2 + version: 2.8.2 + devDependencies: + '@faker-js/faker': + specifier: 10.3.0 + version: 10.3.0 + '@react-router/dev': + specifier: ^7.13.1 + version: 7.13.1(@types/node@25.3.1)(jiti@2.6.1)(lightningcss@1.31.1)(react-router@7.13.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(terser@5.39.0)(tsx@4.21.0)(typescript@5.9.3)(vite@8.0.0-beta.0(@types/node@25.3.1)(esbuild@0.25.12)(jiti@2.6.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2))(yaml@2.8.2) + '@shopify/lang-jsonc': + specifier: ^1.0.1 + version: 1.0.1 + '@tailwindcss/vite': + specifier: ^4.2.1 + version: 4.2.1(vite@8.0.0-beta.0(@types/node@25.3.1)(esbuild@0.25.12)(jiti@2.6.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2)) + '@types/js-yaml': + specifier: ^4.0.9 + version: 4.0.9 + '@types/node': + specifier: ^25.3.1 + version: 25.3.1 + '@types/react': + specifier: ^19.2.14 + version: 19.2.14 + '@types/react-dom': + specifier: ^19.2.3 + version: 19.2.3(@types/react@19.2.14) + '@typescript/native-preview': + specifier: 7.0.0-dev.20260225.1 + version: 7.0.0-dev.20260225.1 + drizzle-kit: + specifier: 1.0.0-beta.16-c2458b2 + version: 1.0.0-beta.16-c2458b2 + lefthook: + specifier: ^2.1.1 + version: 2.1.1 + oxfmt: + specifier: ^0.35.0 + version: 0.35.0 + oxlint: + specifier: ^1.50.0 + version: 1.50.0(oxlint-tsgolint@0.16.0) + oxlint-tsgolint: + specifier: ^0.16.0 + version: 0.16.0 + postcss: + specifier: ^8.5.6 + version: 8.5.6 tailwindcss: specifier: ^4.2.1 version: 4.2.1 @@ -200,12 +209,6 @@ importers: typescript: specifier: ^5.9.3 version: 5.9.3 - ulidx: - specifier: 2.4.1 - version: 2.4.1 - undici: - specifier: 7.22.0 - version: 7.22.0 vite: specifier: 8.0.0-beta.0 version: 8.0.0-beta.0(@types/node@25.3.1)(esbuild@0.25.12)(jiti@2.6.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2) @@ -218,9 +221,6 @@ importers: vitest: specifier: ^4.0.18 version: 4.0.18(@types/node@25.3.1)(jiti@2.6.1)(lightningcss@1.31.1)(terser@5.39.0)(tsx@4.21.0)(yaml@2.8.2) - yaml: - specifier: 2.8.2 - version: 2.8.2 packages: @@ -4040,6 +4040,7 @@ packages: libsql@0.5.22: resolution: {integrity: sha512-NscWthMQt7fpU8lqd7LXMvT9pi+KhhmTHAJWUB/Lj6MWa0MKFv0F2V4C6WKKpjCVZl0VwcDz4nOI3CyaT1DDiA==} + cpu: [x64, arm64, wasm32, arm] os: [darwin, linux, win32] lightningcss-android-arm64@1.31.1: diff --git a/vite.config.ts b/vite.config.ts index 9a5f61c..e4f9f11 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -53,9 +53,8 @@ export default defineConfig(({ command, isSsrBuild }) => ({ rolldownOptions: command === "build" ? { - // Exclude libsql from the server side since it's a native module // Exclude WASM from the client since it fetches from the server - external: isSsrBuild ? [/^@libsql\//] : [/\.wasm(\?url)?$/], + external: isSsrBuild ? [] : [/\.wasm(\?url)?$/], output: { manualChunks: undefined, inlineDynamicImports: isSsrBuild, @@ -67,9 +66,6 @@ export default defineConfig(({ command, isSsrBuild }) => ({ target: "node", noExternal: command === "build" ? true : undefined, }, - optimizeDeps: { - include: ["@libsql/client"], - }, define: { __VERSION__: JSON.stringify(isNext ? `${version}-next` : version), __PREFIX__: JSON.stringify(prefix),