test: 🧪 Fix failing tests due to incorrect cwd resolving
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 0s
Build Docker Images / lint (push) Failing after 6s
Build Docker Images / check (push) Failing after 6s
Build Docker Images / tests (push) Failing after 5s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 0s

This commit is contained in:
Jesse Wierzbinski 2025-04-14 17:30:01 +02:00
parent 1beb18e321
commit 37bc4458e5
No known key found for this signature in database
8 changed files with 13 additions and 22 deletions

6
app.ts
View file

@ -1,5 +1,6 @@
import { join } from "node:path";
/* import { prometheus } from "@hono/prometheus"; */ /* import { prometheus } from "@hono/prometheus"; */
import { resolve } from "node:path";
import { getLogger } from "@logtape/logtape"; import { getLogger } from "@logtape/logtape";
import { apiReference } from "@scalar/hono-api-reference"; import { apiReference } from "@scalar/hono-api-reference";
import chalk from "chalk"; import chalk from "chalk";
@ -27,7 +28,6 @@ import { routes } from "./routes.ts";
import type { ApiRouteExports, HonoEnv } from "./types/api.ts"; import type { ApiRouteExports, HonoEnv } from "./types/api.ts";
// Extends Zod with OpenAPI schema generation // Extends Zod with OpenAPI schema generation
import "zod-openapi/extend"; import "zod-openapi/extend";
import { cwdFromEntrypoint } from "@/lib.ts";
export const appFactory = async (): Promise<Hono<HonoEnv>> => { export const appFactory = async (): Promise<Hono<HonoEnv>> => {
await configureLoggers(); await configureLoggers();
@ -122,7 +122,7 @@ export const appFactory = async (): Promise<Hono<HonoEnv>> => {
const loader = new PluginLoader(); const loader = new PluginLoader();
const plugins = await loader.loadPlugins( const plugins = await loader.loadPlugins(
join(cwdFromEntrypoint(), "plugins"), resolve("./plugins"),
config.plugins?.autoload ?? true, config.plugins?.autoload ?? true,
config.plugins?.overrides.enabled, config.plugins?.overrides.enabled,
config.plugins?.overrides.disabled, config.plugins?.overrides.disabled,

View file

@ -95,6 +95,7 @@
"@badgateway/oauth2-client": "^2.4.2", "@badgateway/oauth2-client": "^2.4.2",
"iso-639-1": "^3.1.5", "iso-639-1": "^3.1.5",
"zod": "^3.24.2", "zod": "^3.24.2",
"zod-openapi": "^4.2.4",
}, },
}, },
"packages/plugin-kit": { "packages/plugin-kit": {

View file

@ -5,7 +5,6 @@ import { generateVAPIDKeys } from "web-push";
import { z } from "zod"; import { z } from "zod";
import { ZodError } from "zod"; import { ZodError } from "zod";
import { fromZodError } from "zod-validation-error"; import { fromZodError } from "zod-validation-error";
import { cwdFromEntrypoint } from "@/lib.ts";
import { ProxiableUrl } from "~/classes/media/url.ts"; import { ProxiableUrl } from "~/classes/media/url.ts";
import { RolePermission } from "~/packages/client/schemas/permissions.ts"; import { RolePermission } from "~/packages/client/schemas/permissions.ts";
@ -402,9 +401,7 @@ export const ConfigSchema = z
}), }),
frontend: z.strictObject({ frontend: z.strictObject({
enabled: z.boolean().default(true), enabled: z.boolean().default(true),
path: z path: z.string().default(env.VERSIA_FRONTEND_PATH || "frontend"),
.string()
.default(env.VERSIA_FRONTEND_PATH || cwdFromEntrypoint()),
routes: z.strictObject({ routes: z.strictObject({
home: urlPath.default("/"), home: urlPath.default("/"),
login: urlPath.default("/oauth/authorize"), login: urlPath.default("/oauth/authorize"),

View file

@ -65,6 +65,7 @@
"dependencies": { "dependencies": {
"@badgateway/oauth2-client": "^2.4.2", "@badgateway/oauth2-client": "^2.4.2",
"iso-639-1": "^3.1.5", "iso-639-1": "^3.1.5",
"zod": "^3.24.2" "zod": "^3.24.2",
"zod-openapi": "^4.2.4"
} }
} }

View file

@ -1,5 +1,6 @@
import ISO6391 from "iso-639-1"; import ISO6391 from "iso-639-1";
import { z } from "zod"; import { z } from "zod";
import "zod-openapi/extend";
export const Id = z.string().uuid(); export const Id = z.string().uuid();

View file

@ -257,6 +257,9 @@ importers:
zod: zod:
specifier: ^3.24.2 specifier: ^3.24.2
version: 3.24.2 version: 3.24.2
zod-openapi:
specifier: ^4.2.4
version: 4.2.4(zod@3.24.2)
packages/plugin-kit: packages/plugin-kit:
dependencies: dependencies:

View file

@ -1,18 +1,13 @@
import { join } from "node:path";
import { FileSystemRouter } from "bun"; import { FileSystemRouter } from "bun";
import { cwdFromEntrypoint } from "@/lib.ts";
// Returns the route filesystem path when given a URL // Returns the route filesystem path when given a URL
export const routeMatcher = new FileSystemRouter({ export const routeMatcher = new FileSystemRouter({
style: "nextjs", style: "nextjs",
dir: `${cwdFromEntrypoint()}/api`, dir: "api",
fileExtensions: [".ts", ".js"], fileExtensions: [".ts", ".js"],
}); });
export const routes = Object.fromEntries( export const routes = Object.fromEntries(
Object.entries(routeMatcher.routes) Object.entries(routeMatcher.routes)
.filter(([route]) => !route.endsWith(".test")) .filter(([route]) => !route.endsWith(".test"))
.map(([route, path]) => [ .map(([route, path]) => [route, path]),
route,
path.replace(join(cwdFromEntrypoint()), "."),
]),
) as Record<string, string>; ) as Record<string, string>;

View file

@ -1,6 +1,3 @@
import { dirname } from "node:path";
import { main } from "bun";
type ElementWithId = { id: string }; type ElementWithId = { id: string };
export const mergeAndDeduplicate = <T extends ElementWithId>( export const mergeAndDeduplicate = <T extends ElementWithId>(
@ -12,7 +9,3 @@ export const mergeAndDeduplicate = <T extends ElementWithId>(
(element, index, self) => (element, index, self) =>
index === self.findIndex((t) => t.id === element.id), index === self.findIndex((t) => t.id === element.id),
); );
export const cwdFromEntrypoint = (): string => {
return dirname(main);
};