@mandujs/cli 0.8.1 → 0.8.2

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.
@@ -1,35 +1,35 @@
1
- import React from "react";
2
- import type { ReactElement } from "react";
3
-
4
- export interface AppContext {
5
- routeId: string;
6
- url: string;
7
- params: Record<string, string>;
8
- }
9
-
10
- type RouteComponent = (props: { params: Record<string, string> }) => ReactElement;
11
-
12
- const routeComponents: Record<string, RouteComponent> = {};
13
-
14
- export function registerRoute(routeId: string, component: RouteComponent): void {
15
- routeComponents[routeId] = component;
16
- }
17
-
18
- export function createApp(context: AppContext): ReactElement {
19
- const Component = routeComponents[context.routeId];
20
-
21
- if (!Component) {
22
- return (
23
- <div>
24
- <h1>404 - Route Not Found</h1>
25
- <p>Route ID: {context.routeId}</p>
26
- </div>
27
- );
28
- }
29
-
30
- return <Component params={context.params} />;
31
- }
32
-
33
- export function getRegisteredRoutes(): string[] {
34
- return Object.keys(routeComponents);
35
- }
1
+ import React from "react";
2
+ import type { ReactElement } from "react";
3
+
4
+ export interface AppContext {
5
+ routeId: string;
6
+ url: string;
7
+ params: Record<string, string>;
8
+ }
9
+
10
+ type RouteComponent = (props: { params: Record<string, string> }) => ReactElement;
11
+
12
+ const routeComponents: Record<string, RouteComponent> = {};
13
+
14
+ export function registerRoute(routeId: string, component: RouteComponent): void {
15
+ routeComponents[routeId] = component;
16
+ }
17
+
18
+ export function createApp(context: AppContext): ReactElement {
19
+ const Component = routeComponents[context.routeId];
20
+
21
+ if (!Component) {
22
+ return (
23
+ <div>
24
+ <h1>404 - Route Not Found</h1>
25
+ <p>Route ID: {context.routeId}</p>
26
+ </div>
27
+ );
28
+ }
29
+
30
+ return <Component params={context.params} />;
31
+ }
32
+
33
+ export function getRegisteredRoutes(): string[] {
34
+ return Object.keys(routeComponents);
35
+ }
@@ -1,18 +1,18 @@
1
- {
2
- "version": 1,
3
- "routes": [
4
- {
5
- "id": "home",
6
- "pattern": "/",
7
- "kind": "page",
8
- "module": "apps/server/generated/routes/home.route.ts",
9
- "componentModule": "apps/web/generated/routes/home.route.tsx"
10
- },
11
- {
12
- "id": "health",
13
- "pattern": "/api/health",
14
- "kind": "api",
15
- "module": "apps/server/generated/routes/health.route.ts"
16
- }
17
- ]
18
- }
1
+ {
2
+ "version": 1,
3
+ "routes": [
4
+ {
5
+ "id": "home",
6
+ "pattern": "/",
7
+ "kind": "page",
8
+ "module": "apps/server/generated/routes/home.route.ts",
9
+ "componentModule": "apps/web/generated/routes/home.route.tsx"
10
+ },
11
+ {
12
+ "id": "health",
13
+ "pattern": "/api/health",
14
+ "kind": "api",
15
+ "module": "apps/server/generated/routes/health.route.ts"
16
+ }
17
+ ]
18
+ }
@@ -1,58 +1,58 @@
1
- // Mandu Example Test
2
- // 이 파일은 테스트 작성 방법을 보여주는 예제입니다.
3
-
4
- import { describe, it, expect } from "bun:test";
5
- import { createTestRequest, parseJsonResponse, assertStatus } from "./helpers";
6
-
7
- describe("Example Tests", () => {
8
- describe("Basic Assertions", () => {
9
- it("should pass basic equality test", () => {
10
- expect(1 + 1).toBe(2);
11
- });
12
-
13
- it("should pass object equality test", () => {
14
- const obj = { status: "ok", data: { message: "hello" } };
15
- expect(obj).toEqual({
16
- status: "ok",
17
- data: { message: "hello" },
18
- });
19
- });
20
- });
21
-
22
- describe("Test Helpers", () => {
23
- it("should create test request", () => {
24
- const req = createTestRequest("http://localhost:3000/api/test", {
25
- method: "POST",
26
- body: { name: "test" },
27
- });
28
-
29
- expect(req.method).toBe("POST");
30
- expect(req.url).toBe("http://localhost:3000/api/test");
31
- });
32
-
33
- it("should parse JSON response", async () => {
34
- const mockResponse = new Response(
35
- JSON.stringify({ status: "ok" }),
36
- { status: 200 }
37
- );
38
-
39
- const data = await parseJsonResponse<{ status: string }>(mockResponse);
40
- expect(data.status).toBe("ok");
41
- });
42
- });
43
- });
44
-
45
- // API 핸들러 테스트 예제 (실제 핸들러 import 후 사용)
46
- // import handler from "../apps/server/generated/routes/health.route";
47
- //
48
- // describe("API: GET /api/health", () => {
49
- // it("should return 200 with status ok", async () => {
50
- // const req = createTestRequest("http://localhost:3000/api/health");
51
- // const response = handler(req, {});
52
- //
53
- // assertStatus(response, 200);
54
- //
55
- // const data = await parseJsonResponse<{ status: string }>(response);
56
- // expect(data.status).toBe("ok");
57
- // });
58
- // });
1
+ // Mandu Example Test
2
+ // 이 파일은 테스트 작성 방법을 보여주는 예제입니다.
3
+
4
+ import { describe, it, expect } from "bun:test";
5
+ import { createTestRequest, parseJsonResponse, assertStatus } from "./helpers";
6
+
7
+ describe("Example Tests", () => {
8
+ describe("Basic Assertions", () => {
9
+ it("should pass basic equality test", () => {
10
+ expect(1 + 1).toBe(2);
11
+ });
12
+
13
+ it("should pass object equality test", () => {
14
+ const obj = { status: "ok", data: { message: "hello" } };
15
+ expect(obj).toEqual({
16
+ status: "ok",
17
+ data: { message: "hello" },
18
+ });
19
+ });
20
+ });
21
+
22
+ describe("Test Helpers", () => {
23
+ it("should create test request", () => {
24
+ const req = createTestRequest("http://localhost:3000/api/test", {
25
+ method: "POST",
26
+ body: { name: "test" },
27
+ });
28
+
29
+ expect(req.method).toBe("POST");
30
+ expect(req.url).toBe("http://localhost:3000/api/test");
31
+ });
32
+
33
+ it("should parse JSON response", async () => {
34
+ const mockResponse = new Response(
35
+ JSON.stringify({ status: "ok" }),
36
+ { status: 200 }
37
+ );
38
+
39
+ const data = await parseJsonResponse<{ status: string }>(mockResponse);
40
+ expect(data.status).toBe("ok");
41
+ });
42
+ });
43
+ });
44
+
45
+ // API 핸들러 테스트 예제 (실제 핸들러 import 후 사용)
46
+ // import handler from "../apps/server/generated/routes/health.route";
47
+ //
48
+ // describe("API: GET /api/health", () => {
49
+ // it("should return 200 with status ok", async () => {
50
+ // const req = createTestRequest("http://localhost:3000/api/health");
51
+ // const response = handler(req, {});
52
+ //
53
+ // assertStatus(response, 200);
54
+ //
55
+ // const data = await parseJsonResponse<{ status: string }>(response);
56
+ // expect(data.status).toBe("ok");
57
+ // });
58
+ // });
@@ -1,52 +1,52 @@
1
- // Mandu Test Helpers
2
- // 테스트에서 사용할 유틸리티 함수들
3
-
4
- import type { Request } from "bun";
5
-
6
- /**
7
- * API 핸들러 테스트용 Request 생성
8
- */
9
- export function createTestRequest(
10
- url: string,
11
- options?: {
12
- method?: string;
13
- body?: unknown;
14
- headers?: Record<string, string>;
15
- }
16
- ): Request {
17
- const { method = "GET", body, headers = {} } = options || {};
18
-
19
- return new Request(url, {
20
- method,
21
- headers: {
22
- "Content-Type": "application/json",
23
- ...headers,
24
- },
25
- body: body ? JSON.stringify(body) : undefined,
26
- });
27
- }
28
-
29
- /**
30
- * Response를 JSON으로 파싱
31
- */
32
- export async function parseJsonResponse<T = unknown>(response: Response): Promise<T> {
33
- return response.json() as Promise<T>;
34
- }
35
-
36
- /**
37
- * Response 상태 검증
38
- */
39
- export function assertStatus(response: Response, expectedStatus: number): void {
40
- if (response.status !== expectedStatus) {
41
- throw new Error(
42
- `Expected status ${expectedStatus}, got ${response.status}`
43
- );
44
- }
45
- }
46
-
47
- /**
48
- * 테스트용 라우트 파라미터 생성
49
- */
50
- export function createParams(params: Record<string, string>): Record<string, string> {
51
- return params;
52
- }
1
+ // Mandu Test Helpers
2
+ // 테스트에서 사용할 유틸리티 함수들
3
+
4
+ import type { Request } from "bun";
5
+
6
+ /**
7
+ * API 핸들러 테스트용 Request 생성
8
+ */
9
+ export function createTestRequest(
10
+ url: string,
11
+ options?: {
12
+ method?: string;
13
+ body?: unknown;
14
+ headers?: Record<string, string>;
15
+ }
16
+ ): Request {
17
+ const { method = "GET", body, headers = {} } = options || {};
18
+
19
+ return new Request(url, {
20
+ method,
21
+ headers: {
22
+ "Content-Type": "application/json",
23
+ ...headers,
24
+ },
25
+ body: body ? JSON.stringify(body) : undefined,
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Response를 JSON으로 파싱
31
+ */
32
+ export async function parseJsonResponse<T = unknown>(response: Response): Promise<T> {
33
+ return response.json() as Promise<T>;
34
+ }
35
+
36
+ /**
37
+ * Response 상태 검증
38
+ */
39
+ export function assertStatus(response: Response, expectedStatus: number): void {
40
+ if (response.status !== expectedStatus) {
41
+ throw new Error(
42
+ `Expected status ${expectedStatus}, got ${response.status}`
43
+ );
44
+ }
45
+ }
46
+
47
+ /**
48
+ * 테스트용 라우트 파라미터 생성
49
+ */
50
+ export function createParams(params: Record<string, string>): Record<string, string> {
51
+ return params;
52
+ }
@@ -1,9 +1,9 @@
1
- // Mandu Test Setup
2
- // Bun 테스트 환경 설정
3
-
4
- // 테스트 타임아웃 설정 (필요 시)
5
- // import { setDefaultTimeout } from "bun:test";
6
- // setDefaultTimeout(10000);
7
-
8
- // 환경 변수 설정
9
- process.env.NODE_ENV = "test";
1
+ // Mandu Test Setup
2
+ // Bun 테스트 환경 설정
3
+
4
+ // 테스트 타임아웃 설정 (필요 시)
5
+ // import { setDefaultTimeout } from "bun:test";
6
+ // setDefaultTimeout(10000);
7
+
8
+ // 환경 변수 설정
9
+ process.env.NODE_ENV = "test";
@@ -1,14 +1,14 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "esModuleInterop": true,
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "jsx": "react-jsx",
10
- "types": ["bun-types"]
11
- },
12
- "include": ["apps/**/*.ts", "apps/**/*.tsx"],
13
- "exclude": ["node_modules"]
14
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "jsx": "react-jsx",
10
+ "types": ["bun-types"]
11
+ },
12
+ "include": ["apps/**/*.ts", "apps/**/*.tsx"],
13
+ "exclude": ["node_modules"]
14
+ }