create-warlock 4.0.152 → 4.0.153
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/package.json +1 -1
- package/templates/warlock/package.json +25 -9
- package/templates/warlock/src/app/auth/models/otp/otp.model.ts +2 -3
- package/templates/warlock/src/app/shared/tests/infrastructure.test.ts +22 -0
- package/templates/warlock/src/test-global-setup.ts +18 -0
- package/templates/warlock/src/test-setup.ts +13 -0
- package/templates/warlock/vite.config.ts +13 -0
package/package.json
CHANGED
|
@@ -12,28 +12,44 @@
|
|
|
12
12
|
"migrate.fresh": "warlock migrate --fresh",
|
|
13
13
|
"migrate.list": "warlock migrate --list",
|
|
14
14
|
"jwt": "warlock jwt.generate",
|
|
15
|
+
"gen": "warlock generate.module",
|
|
16
|
+
"gen.s": "warlock.generate.service",
|
|
17
|
+
"gen.m": "warlock.generate.model",
|
|
18
|
+
"gen.c": "warlock.generate.controller",
|
|
19
|
+
"gen.mig": "warlock generate.migration",
|
|
20
|
+
"gen.md": "warlock generate.model",
|
|
21
|
+
"gen.r": "warlock generate.repository",
|
|
22
|
+
"gen.rs": "warlock generate.resource",
|
|
23
|
+
"gen.v": "warlock generate.validation",
|
|
15
24
|
"serve": "yarn build && nohup warlock start > /dev/null 2>&1",
|
|
16
25
|
"lint": "npx eslint --fix ./src --max-warnings=0",
|
|
17
26
|
"format": "npx prettier --write ./src/**/*.{js,jsx,ts,tsx,css,md,json} --config ./.prettierrc.json",
|
|
18
27
|
"tsc": "npx tsc --noEmit",
|
|
19
28
|
"prepare": "huskier-init && husky install",
|
|
29
|
+
"test": "vitest",
|
|
30
|
+
"test:watch": "vitest --watch",
|
|
31
|
+
"test:coverage": "vitest --coverage",
|
|
32
|
+
"test:ui": "vitest --ui",
|
|
20
33
|
"lf": "find . -type d ( -name 'node_modules' -o -name '.git' ) -prune -o -type f -exec dos2unix {} ;"
|
|
21
34
|
},
|
|
22
35
|
"dependencies": {
|
|
23
36
|
"@mongez/reinforcements": "^2.3.17",
|
|
24
37
|
"@mongez/localization": "^3.2.1",
|
|
25
38
|
"@mongez/supportive-is": "^2.0.4",
|
|
26
|
-
"@warlock.js/auth": "4.0.
|
|
27
|
-
"@warlock.js/cache": "4.0.
|
|
28
|
-
"@warlock.js/cascade": "4.0.
|
|
29
|
-
"@warlock.js/scheduler": "4.0.
|
|
30
|
-
"@warlock.js/core": "4.0.
|
|
31
|
-
"@warlock.js/logger": "4.0.
|
|
32
|
-
"@warlock.js/seal": "4.0.
|
|
33
|
-
"dayjs": "^1.11.19"
|
|
34
|
-
"mongodb": "^7.0.0"
|
|
39
|
+
"@warlock.js/auth": "4.0.153",
|
|
40
|
+
"@warlock.js/cache": "4.0.153",
|
|
41
|
+
"@warlock.js/cascade": "4.0.153",
|
|
42
|
+
"@warlock.js/scheduler": "4.0.153",
|
|
43
|
+
"@warlock.js/core": "4.0.153",
|
|
44
|
+
"@warlock.js/logger": "4.0.153",
|
|
45
|
+
"@warlock.js/seal": "4.0.153",
|
|
46
|
+
"dayjs": "^1.11.19"
|
|
35
47
|
},
|
|
36
48
|
"devDependencies": {
|
|
49
|
+
"@mongez/vite": "^2.0.4",
|
|
50
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
51
|
+
"vite": "^7.3.1",
|
|
52
|
+
"vitest": "^4.0.16",
|
|
37
53
|
"@mongez/huskier": "^3.0.0",
|
|
38
54
|
"@types/node": "^25.0.3",
|
|
39
55
|
"@types/prettier": "^3.0.0",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Model, RegisterModel } from "@warlock.js/cascade";
|
|
2
|
-
import { type Infer
|
|
3
|
-
import { globalColumnsSchema } from "app/shared/utils/global-columns-schema";
|
|
2
|
+
import { v, type Infer } from "@warlock.js/seal";
|
|
4
3
|
|
|
5
|
-
const otpSchema =
|
|
4
|
+
const otpSchema = v.object({
|
|
6
5
|
code: v.string().required(),
|
|
7
6
|
type: v.string().required(),
|
|
8
7
|
target: v.string().required(),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample test to verify test infrastructure
|
|
3
|
+
*/
|
|
4
|
+
import { testGet } from "@warlock.js/core";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
describe("Test Infrastructure", () => {
|
|
8
|
+
it("should have database connection available", async () => {
|
|
9
|
+
// This test verifies the per-worker setup works
|
|
10
|
+
// The setupTest function should have initialized connectors
|
|
11
|
+
expect(true).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should be able to make HTTP requests to test server", async () => {
|
|
15
|
+
// This test verifies the global HTTP server is running
|
|
16
|
+
const response = await testGet("/");
|
|
17
|
+
|
|
18
|
+
// We expect some response (even 404 is fine - means server is reachable)
|
|
19
|
+
expect(response.status).toBeDefined();
|
|
20
|
+
expect(response.headers.get("content-type")).toBe("text/html");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Test Setup
|
|
3
|
+
*
|
|
4
|
+
* This file runs ONCE in the main process before all test workers start.
|
|
5
|
+
* It starts the HTTP server which all test workers can make requests to.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: The HTTP server has its OWN database connection, separate from
|
|
8
|
+
* the per-worker connections in setupFiles.
|
|
9
|
+
*/
|
|
10
|
+
import { startHttpTestServer, stopHttpTestServer } from "@warlock.js/core";
|
|
11
|
+
|
|
12
|
+
export async function setup() {
|
|
13
|
+
await startHttpTestServer();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function teardown() {
|
|
17
|
+
await stopHttpTestServer();
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-Worker Test Setup
|
|
3
|
+
*
|
|
4
|
+
* This file runs in EACH Vitest worker thread before tests execute.
|
|
5
|
+
* It sets up per-worker database and cache connections for direct
|
|
6
|
+
* service/repository testing (unit tests).
|
|
7
|
+
*
|
|
8
|
+
* NOTE: These connections are SEPARATE from the HTTP server's connections.
|
|
9
|
+
* Use direct calls for unit tests, HTTP requests for integration tests.
|
|
10
|
+
*/
|
|
11
|
+
import { setupTest } from "@warlock.js/core";
|
|
12
|
+
|
|
13
|
+
await setupTest({ connectors: true });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import mongezVite from "@mongez/vite";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [mongezVite()],
|
|
6
|
+
test: {
|
|
7
|
+
globalSetup: "./src/test-global-setup.ts", // HTTP server - runs once
|
|
8
|
+
setupFiles: ["./src/test-setup.ts"], // DB/cache - runs per worker
|
|
9
|
+
environment: "node",
|
|
10
|
+
globals: false,
|
|
11
|
+
include: ["src/app/**/*.test.ts"],
|
|
12
|
+
},
|
|
13
|
+
});
|