@mandujs/core 0.2.1 → 0.2.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.
Files changed (3) hide show
  1. package/README.ko.md +191 -0
  2. package/README.md +52 -50
  3. package/package.json +1 -1
package/README.ko.md ADDED
@@ -0,0 +1,191 @@
1
+ # @mandujs/core
2
+
3
+ > **[English](./README.md)** | 한국어
4
+
5
+ Mandu Framework Core - Spec, Generator, Guard, Runtime
6
+
7
+ ## 설치
8
+
9
+ ```bash
10
+ bun add @mandujs/core
11
+ ```
12
+
13
+ > 일반적으로 `@mandujs/cli`를 통해 사용합니다. 직접 사용은 고급 사용 사례입니다.
14
+
15
+ ## 모듈 구조
16
+
17
+ ```
18
+ @mandujs/core
19
+ ├── spec/ # Spec 스키마 및 로딩
20
+ ├── generator/ # 코드 생성
21
+ ├── guard/ # 아키텍처 검사 및 자동 수정
22
+ ├── runtime/ # 서버 및 라우터
23
+ └── report/ # Guard 리포트 생성
24
+ ```
25
+
26
+ ## Spec 모듈
27
+
28
+ 라우트 manifest 스키마 정의 및 로딩.
29
+
30
+ ```typescript
31
+ import { loadManifest, RoutesManifest, RouteSpec } from "@mandujs/core";
32
+
33
+ // manifest 로드 및 검증
34
+ const result = await loadManifest("spec/routes.manifest.json");
35
+
36
+ if (result.success && result.data) {
37
+ const manifest: RoutesManifest = result.data;
38
+ manifest.routes.forEach((route: RouteSpec) => {
39
+ console.log(route.id, route.pattern, route.kind);
40
+ });
41
+ }
42
+ ```
43
+
44
+ ### Lock 파일
45
+
46
+ ```typescript
47
+ import { writeLock, readLock } from "@mandujs/core";
48
+
49
+ // lock 파일 쓰기
50
+ const lock = await writeLock("spec/spec.lock.json", manifest);
51
+ console.log(lock.routesHash);
52
+
53
+ // lock 파일 읽기
54
+ const existing = await readLock("spec/spec.lock.json");
55
+ ```
56
+
57
+ ## Generator 모듈
58
+
59
+ Spec 기반 코드 생성.
60
+
61
+ ```typescript
62
+ import { generateRoutes, GenerateResult } from "@mandujs/core";
63
+
64
+ const result: GenerateResult = await generateRoutes(manifest, "./");
65
+
66
+ console.log("생성됨:", result.created);
67
+ console.log("건너뜀:", result.skipped); // 이미 존재하는 slot 파일
68
+ ```
69
+
70
+ ### 템플릿 함수
71
+
72
+ ```typescript
73
+ import {
74
+ generateApiHandler,
75
+ generateApiHandlerWithSlot,
76
+ generateSlotLogic,
77
+ generatePageComponent
78
+ } from "@mandujs/core";
79
+
80
+ // API 핸들러 생성
81
+ const code = generateApiHandler(route);
82
+
83
+ // Slot이 있는 API 핸들러
84
+ const codeWithSlot = generateApiHandlerWithSlot(route);
85
+
86
+ // Slot 로직 파일
87
+ const slotCode = generateSlotLogic(route);
88
+ ```
89
+
90
+ ## Guard 모듈
91
+
92
+ 아키텍처 규칙 검사 및 자동 수정.
93
+
94
+ ```typescript
95
+ import {
96
+ runGuardCheck,
97
+ runAutoCorrect,
98
+ GuardResult,
99
+ GuardViolation
100
+ } from "@mandujs/core";
101
+
102
+ // 검사 실행
103
+ const result: GuardResult = await runGuardCheck(manifest, "./");
104
+
105
+ if (!result.passed) {
106
+ result.violations.forEach((v: GuardViolation) => {
107
+ console.log(`${v.rule}: ${v.message}`);
108
+ });
109
+
110
+ // 자동 수정 실행
111
+ const corrected = await runAutoCorrect(result.violations, manifest, "./");
112
+ console.log("수정됨:", corrected.steps);
113
+ console.log("남은 위반:", corrected.remainingViolations);
114
+ }
115
+ ```
116
+
117
+ ### Guard 규칙
118
+
119
+ | 규칙 ID | 설명 | 자동 수정 |
120
+ |---------|------|----------|
121
+ | `SPEC_HASH_MISMATCH` | spec과 lock 해시 불일치 | ✅ |
122
+ | `GENERATED_MANUAL_EDIT` | generated 파일 수동 수정 | ✅ |
123
+ | `HANDLER_NOT_FOUND` | 핸들러 파일 없음 | ❌ |
124
+ | `COMPONENT_NOT_FOUND` | 컴포넌트 파일 없음 | ❌ |
125
+ | `SLOT_NOT_FOUND` | slot 파일 없음 | ✅ |
126
+
127
+ ## Runtime 모듈
128
+
129
+ 서버 시작 및 라우팅.
130
+
131
+ ```typescript
132
+ import {
133
+ startServer,
134
+ registerApiHandler,
135
+ registerPageLoader
136
+ } from "@mandujs/core";
137
+
138
+ // API 핸들러 등록
139
+ registerApiHandler("getUsers", async (req) => {
140
+ return { users: [] };
141
+ });
142
+
143
+ // 페이지 로더 등록
144
+ registerPageLoader("homePage", () => import("./pages/Home"));
145
+
146
+ // 서버 시작
147
+ const server = startServer(manifest, { port: 3000 });
148
+
149
+ // 종료
150
+ server.stop();
151
+ ```
152
+
153
+ ## Report 모듈
154
+
155
+ Guard 결과 리포트 생성.
156
+
157
+ ```typescript
158
+ import { buildGuardReport } from "@mandujs/core";
159
+
160
+ const report = buildGuardReport(guardResult, lockPath);
161
+ console.log(report); // 포맷된 텍스트 리포트
162
+ ```
163
+
164
+ ## 타입
165
+
166
+ ```typescript
167
+ import type {
168
+ RoutesManifest,
169
+ RouteSpec,
170
+ RouteKind,
171
+ SpecLock,
172
+ GuardResult,
173
+ GuardViolation,
174
+ GenerateResult,
175
+ AutoCorrectResult,
176
+ } from "@mandujs/core";
177
+ ```
178
+
179
+ ## 요구 사항
180
+
181
+ - Bun >= 1.0.0
182
+ - React >= 18.0.0
183
+ - Zod >= 3.0.0
184
+
185
+ ## 관련 패키지
186
+
187
+ - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI 도구
188
+
189
+ ## 라이선스
190
+
191
+ MIT
package/README.md CHANGED
@@ -1,34 +1,36 @@
1
1
  # @mandujs/core
2
2
 
3
+ > English | **[한국어](./README.ko.md)**
4
+
3
5
  Mandu Framework Core - Spec, Generator, Guard, Runtime
4
6
 
5
- ## 설치
7
+ ## Installation
6
8
 
7
9
  ```bash
8
10
  bun add @mandujs/core
9
11
  ```
10
12
 
11
- > 일반적으로 `@mandujs/cli`를 통해 사용합니다. 직접 사용은 고급 사용 사례입니다.
13
+ > Typically used through `@mandujs/cli`. Direct usage is for advanced use cases.
12
14
 
13
- ## 모듈 구조
15
+ ## Module Structure
14
16
 
15
17
  ```
16
18
  @mandujs/core
17
- ├── spec/ # Spec 스키마 로딩
18
- ├── generator/ # 코드 생성
19
- ├── guard/ # 아키텍처 검사 자동 수정
20
- ├── runtime/ # 서버 라우터
21
- └── report/ # Guard 리포트 생성
19
+ ├── spec/ # Spec schema and loading
20
+ ├── generator/ # Code generation
21
+ ├── guard/ # Architecture checking and auto-correction
22
+ ├── runtime/ # Server and router
23
+ └── report/ # Guard report generation
22
24
  ```
23
25
 
24
- ## Spec 모듈
26
+ ## Spec Module
25
27
 
26
- 라우트 manifest 스키마 정의 로딩.
28
+ Route manifest schema definition and loading.
27
29
 
28
30
  ```typescript
29
31
  import { loadManifest, RoutesManifest, RouteSpec } from "@mandujs/core";
30
32
 
31
- // manifest 로드 검증
33
+ // Load and validate manifest
32
34
  const result = await loadManifest("spec/routes.manifest.json");
33
35
 
34
36
  if (result.success && result.data) {
@@ -39,33 +41,33 @@ if (result.success && result.data) {
39
41
  }
40
42
  ```
41
43
 
42
- ### Lock 파일
44
+ ### Lock File
43
45
 
44
46
  ```typescript
45
47
  import { writeLock, readLock } from "@mandujs/core";
46
48
 
47
- // lock 파일 쓰기
49
+ // Write lock file
48
50
  const lock = await writeLock("spec/spec.lock.json", manifest);
49
51
  console.log(lock.routesHash);
50
52
 
51
- // lock 파일 읽기
53
+ // Read lock file
52
54
  const existing = await readLock("spec/spec.lock.json");
53
55
  ```
54
56
 
55
- ## Generator 모듈
57
+ ## Generator Module
56
58
 
57
- Spec 기반 코드 생성.
59
+ Spec-based code generation.
58
60
 
59
61
  ```typescript
60
62
  import { generateRoutes, GenerateResult } from "@mandujs/core";
61
63
 
62
64
  const result: GenerateResult = await generateRoutes(manifest, "./");
63
65
 
64
- console.log("생성됨:", result.created);
65
- console.log("건너뜀:", result.skipped); // 이미 존재하는 slot 파일
66
+ console.log("Created:", result.created);
67
+ console.log("Skipped:", result.skipped); // Existing slot files
66
68
  ```
67
69
 
68
- ### 템플릿 함수
70
+ ### Template Functions
69
71
 
70
72
  ```typescript
71
73
  import {
@@ -75,19 +77,19 @@ import {
75
77
  generatePageComponent
76
78
  } from "@mandujs/core";
77
79
 
78
- // API 핸들러 생성
80
+ // Generate API handler
79
81
  const code = generateApiHandler(route);
80
82
 
81
- // Slot이 있는 API 핸들러
83
+ // API handler with slot
82
84
  const codeWithSlot = generateApiHandlerWithSlot(route);
83
85
 
84
- // Slot 로직 파일
86
+ // Slot logic file
85
87
  const slotCode = generateSlotLogic(route);
86
88
  ```
87
89
 
88
- ## Guard 모듈
90
+ ## Guard Module
89
91
 
90
- 아키텍처 규칙 검사 자동 수정.
92
+ Architecture rule checking and auto-correction.
91
93
 
92
94
  ```typescript
93
95
  import {
@@ -97,7 +99,7 @@ import {
97
99
  GuardViolation
98
100
  } from "@mandujs/core";
99
101
 
100
- // 검사 실행
102
+ // Run check
101
103
  const result: GuardResult = await runGuardCheck(manifest, "./");
102
104
 
103
105
  if (!result.passed) {
@@ -105,26 +107,26 @@ if (!result.passed) {
105
107
  console.log(`${v.rule}: ${v.message}`);
106
108
  });
107
109
 
108
- // 자동 수정 실행
110
+ // Run auto-correction
109
111
  const corrected = await runAutoCorrect(result.violations, manifest, "./");
110
- console.log("수정됨:", corrected.steps);
111
- console.log("남은 위반:", corrected.remainingViolations);
112
+ console.log("Fixed:", corrected.steps);
113
+ console.log("Remaining violations:", corrected.remainingViolations);
112
114
  }
113
115
  ```
114
116
 
115
- ### Guard 규칙
117
+ ### Guard Rules
116
118
 
117
- | 규칙 ID | 설명 | 자동 수정 |
118
- |---------|------|----------|
119
- | `SPEC_HASH_MISMATCH` | spec과 lock 해시 불일치 | ✅ |
120
- | `GENERATED_MANUAL_EDIT` | generated 파일 수동 수정 | ✅ |
121
- | `HANDLER_NOT_FOUND` | 핸들러 파일 없음 | ❌ |
122
- | `COMPONENT_NOT_FOUND` | 컴포넌트 파일 없음 | ❌ |
123
- | `SLOT_NOT_FOUND` | slot 파일 없음 | ✅ |
119
+ | Rule ID | Description | Auto-correctable |
120
+ |---------|-------------|------------------|
121
+ | `SPEC_HASH_MISMATCH` | Spec and lock hash mismatch | ✅ |
122
+ | `GENERATED_MANUAL_EDIT` | Manual edit to generated file | ✅ |
123
+ | `HANDLER_NOT_FOUND` | Handler file not found | ❌ |
124
+ | `COMPONENT_NOT_FOUND` | Component file not found | ❌ |
125
+ | `SLOT_NOT_FOUND` | Slot file not found | ✅ |
124
126
 
125
- ## Runtime 모듈
127
+ ## Runtime Module
126
128
 
127
- 서버 시작 라우팅.
129
+ Server startup and routing.
128
130
 
129
131
  ```typescript
130
132
  import {
@@ -133,33 +135,33 @@ import {
133
135
  registerPageLoader
134
136
  } from "@mandujs/core";
135
137
 
136
- // API 핸들러 등록
138
+ // Register API handler
137
139
  registerApiHandler("getUsers", async (req) => {
138
140
  return { users: [] };
139
141
  });
140
142
 
141
- // 페이지 로더 등록
143
+ // Register page loader
142
144
  registerPageLoader("homePage", () => import("./pages/Home"));
143
145
 
144
- // 서버 시작
146
+ // Start server
145
147
  const server = startServer(manifest, { port: 3000 });
146
148
 
147
- // 종료
149
+ // Stop
148
150
  server.stop();
149
151
  ```
150
152
 
151
- ## Report 모듈
153
+ ## Report Module
152
154
 
153
- Guard 결과 리포트 생성.
155
+ Guard result report generation.
154
156
 
155
157
  ```typescript
156
158
  import { buildGuardReport } from "@mandujs/core";
157
159
 
158
160
  const report = buildGuardReport(guardResult, lockPath);
159
- console.log(report); // 포맷된 텍스트 리포트
161
+ console.log(report); // Formatted text report
160
162
  ```
161
163
 
162
- ## 타입
164
+ ## Types
163
165
 
164
166
  ```typescript
165
167
  import type {
@@ -174,16 +176,16 @@ import type {
174
176
  } from "@mandujs/core";
175
177
  ```
176
178
 
177
- ## 요구 사항
179
+ ## Requirements
178
180
 
179
181
  - Bun >= 1.0.0
180
182
  - React >= 18.0.0
181
183
  - Zod >= 3.0.0
182
184
 
183
- ## 관련 패키지
185
+ ## Related Packages
184
186
 
185
- - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI 도구
187
+ - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI tool
186
188
 
187
- ## 라이선스
189
+ ## License
188
190
 
189
191
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",