keryx 0.30.0 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/classes/API.ts CHANGED
@@ -26,7 +26,7 @@ export enum RUN_MODE {
26
26
  export class API {
27
27
  /** The root directory of the user's application. Set this before calling `initialize()`. */
28
28
  rootDir: string;
29
- /** The root directory of the keryx package itself (auto-resolved from `import.meta.path`). */
29
+ /** The root directory of the keryx package itself (auto-resolved from `import.meta.filename`). */
30
30
  packageDir: string;
31
31
  /** Whether `initialize()` has completed successfully. */
32
32
  initialized: boolean;
@@ -50,7 +50,7 @@ export class API {
50
50
 
51
51
  constructor() {
52
52
  this.bootTime = new Date().getTime();
53
- this.packageDir = path.join(import.meta.path, "..", "..");
53
+ this.packageDir = path.join(import.meta.filename, "..", "..");
54
54
  this.rootDir = this.packageDir;
55
55
  this.logger = new Logger(config.logger);
56
56
 
@@ -10,7 +10,7 @@ import { globLoader } from "../util/glob";
10
10
 
11
11
  const namespace = "channels";
12
12
  const PRESENCE_KEY_PREFIX = "presence:";
13
- const LUA_DIR = join(import.meta.dir, "..", "lua");
13
+ const LUA_DIR = join(import.meta.dirname, "..", "lua");
14
14
 
15
15
  const ADD_PRESENCE_LUA = await Bun.file(
16
16
  join(LUA_DIR, "add-presence.lua"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keryx",
3
- "version": "0.30.0",
3
+ "version": "0.31.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -77,7 +77,7 @@
77
77
  "start": "bun keryx.ts start",
78
78
  "dev": "bun --watch keryx.ts start",
79
79
  "migrations": "bun run migrations.ts",
80
- "test": "tsc && bun test",
80
+ "test": "tsc && bunx --bun vitest run",
81
81
  "compile": "bun build keryx.ts --compile --outfile keryx",
82
82
  "lint": "tsc && biome check .",
83
83
  "format": "tsc && biome check --write .",
@@ -100,11 +100,18 @@
100
100
  "peerDependencies": {
101
101
  "drizzle-orm": "^0.45.2",
102
102
  "drizzle-zod": "^0.8.3",
103
+ "vitest": "^4.1.9",
103
104
  "zod": "^4.3.6"
104
105
  },
106
+ "peerDependenciesMeta": {
107
+ "vitest": {
108
+ "optional": true
109
+ }
110
+ },
105
111
  "devDependencies": {
106
112
  "@types/bun": "^1.3.12",
107
113
  "drizzle-kit": "^0.31.10",
108
- "drizzle-zod": "^0.8.3"
114
+ "drizzle-zod": "^0.8.3",
115
+ "vitest": "^4.1.9"
109
116
  }
110
117
  }
@@ -1,4 +1,4 @@
1
- import { afterAll, beforeAll, describe, expect, test } from "bun:test";
1
+ import { afterAll, beforeAll, describe, expect, test } from "vitest";
2
2
  import { api } from "keryx";
3
3
 
4
4
  beforeAll(async () => {
@@ -4,7 +4,7 @@ import { api } from "keryx";
4
4
  // actions, initializers, channels, etc. from this directory.
5
5
  // Every entry point (keryx.ts, migrations.ts, test setup) should
6
6
  // `import "./index"` to ensure rootDir is set before anything runs.
7
- api.rootDir = import.meta.dir;
7
+ api.rootDir = import.meta.dirname;
8
8
 
9
9
  // Re-export everything from keryx for convenience
10
10
  export * from "keryx";
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ["__tests__/**/*.test.ts"],
6
+ globals: false,
7
+ // Run on the Bun runtime via `bunx --bun vitest`. The forks pool keeps
8
+ // Node/Bun process APIs available; file parallelism is disabled so test
9
+ // files that boot the server don't race on the shared database/Redis.
10
+ pool: "forks",
11
+ fileParallelism: false,
12
+ testTimeout: 15_000,
13
+ hookTimeout: 60_000,
14
+ // zod (and other CJS deps consumed via named imports) must be transformed
15
+ // by Vite so the named-export interop works under the Bun runtime.
16
+ server: { deps: { inline: ["zod"] } },
17
+ },
18
+ });
package/testing/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { afterAll, beforeAll } from "bun:test";
1
+ import { afterAll, beforeAll } from "vitest";
2
2
  import { api } from "../api";
3
3
  import type { WebServer } from "../servers/web";
4
4
 
@@ -1,4 +1,4 @@
1
- import { expect } from "bun:test";
1
+ import { expect } from "vitest";
2
2
  import { api } from "../api";
3
3
  import type { WebServer } from "../servers/web";
4
4
 
@@ -24,13 +24,13 @@ export interface ComponentDef {
24
24
  }
25
25
 
26
26
  const generateTemplatesDir = path.join(
27
- import.meta.dir,
27
+ import.meta.dirname,
28
28
  "..",
29
29
  "templates",
30
30
  "generate",
31
31
  );
32
32
  const scaffoldTemplatesDir = path.join(
33
- import.meta.dir,
33
+ import.meta.dirname,
34
34
  "..",
35
35
  "templates",
36
36
  "scaffold",
@@ -20,7 +20,7 @@ export type OAuthTemplates = {
20
20
  lionSvg: string;
21
21
  };
22
22
 
23
- const frameworkTemplatesDir = import.meta.dir + "/../templates";
23
+ const frameworkTemplatesDir = import.meta.dirname + "/../templates";
24
24
 
25
25
  /**
26
26
  * Resolve a template file, checking the user's rootDir first, then falling back
package/util/scaffold.ts CHANGED
@@ -66,7 +66,7 @@ export async function generateOAuthTemplateContents(): Promise<
66
66
  "oauth-common.css",
67
67
  "lion.svg",
68
68
  ];
69
- const sourceDir = path.join(import.meta.dir, "..", "templates");
69
+ const sourceDir = path.join(import.meta.dirname, "..", "templates");
70
70
 
71
71
  for (const file of oauthTemplates) {
72
72
  const content = await Bun.file(path.join(sourceDir, file)).text();
@@ -85,7 +85,7 @@ export async function generateConfigFileContents(): Promise<
85
85
  Map<string, string>
86
86
  > {
87
87
  const result = new Map<string, string>();
88
- const configDir = path.join(import.meta.dir, "..", "config");
88
+ const configDir = path.join(import.meta.dirname, "..", "config");
89
89
  const glob = new Glob("**/*.ts");
90
90
 
91
91
  for await (const file of glob.scan(configDir)) {
@@ -140,7 +140,7 @@ export async function generateBuiltinActionContents(): Promise<
140
140
  > {
141
141
  const result = new Map<string, string>();
142
142
  const builtinActions = ["status.ts", "swagger.ts"];
143
- const actionsDir = path.join(import.meta.dir, "..", "actions");
143
+ const actionsDir = path.join(import.meta.dirname, "..", "actions");
144
144
 
145
145
  for (const file of builtinActions) {
146
146
  let content = await Bun.file(path.join(actionsDir, file)).text();
@@ -318,6 +318,7 @@ export async function scaffoldProject(
318
318
  start: "bun keryx.ts start",
319
319
  dev: "bun --watch keryx.ts start",
320
320
  ...(options.includeDb ? { migrations: "bun run migrations.ts" } : {}),
321
+ test: "tsc && bunx --bun vitest run",
321
322
  lint: "tsc && biome check .",
322
323
  format: "tsc && biome check --write .",
323
324
  },
@@ -334,6 +335,7 @@ export async function scaffoldProject(
334
335
  devDependencies: {
335
336
  "@biomejs/biome": "^2.4.8",
336
337
  "@types/bun": "latest",
338
+ vitest: "^4.1.9",
337
339
  ...(options.includeDb ? { "drizzle-kit": "^0.20.18" } : {}),
338
340
  },
339
341
  },
@@ -343,6 +345,7 @@ export async function scaffoldProject(
343
345
  );
344
346
 
345
347
  await write("tsconfig.json", generateTsconfigContents());
348
+ await writeTemplate("vitest.config.ts", "vitest.config.ts.mustache");
346
349
  await write(
347
350
  "biome.json",
348
351
  JSON.stringify(