metadatafy 1.5.0 → 1.5.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.
- package/README.md +243 -304
- package/dist/cli.cjs +68 -51
- package/dist/cli.js +68 -51
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,8 @@ A build plugin for extracting project metadata from your codebase. Supports Vite
|
|
|
12
12
|
- **Import/Export extraction** - Tracks file dependencies and call graphs
|
|
13
13
|
- **Component props detection** - Extracts React component props
|
|
14
14
|
- **Korean keyword mapping** - Automatic English-Korean keyword translation
|
|
15
|
-
- **Multiple output formats** - JSON file,
|
|
15
|
+
- **Multiple output formats** - JSON file, Supabase, or custom API server
|
|
16
|
+
- **Global CLI** - Install once, use everywhere
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
@@ -22,102 +23,196 @@ A build plugin for extracting project metadata from your codebase. Supports Vite
|
|
|
22
23
|
- **Import/Export 추출** - 파일 의존성 및 호출 그래프 추적
|
|
23
24
|
- **컴포넌트 Props 감지** - React 컴포넌트 props 추출
|
|
24
25
|
- **한글 키워드 매핑** - 영어-한글 키워드 자동 변환
|
|
25
|
-
- **다양한 출력 형식** - JSON 파일,
|
|
26
|
+
- **다양한 출력 형식** - JSON 파일, Supabase, 또는 커스텀 API 서버
|
|
27
|
+
- **글로벌 CLI** - 한 번 설치로 어디서나 사용
|
|
26
28
|
|
|
27
29
|
## Installation / 설치
|
|
28
30
|
|
|
31
|
+
### Global CLI (Recommended) / 글로벌 CLI (권장)
|
|
32
|
+
|
|
29
33
|
```bash
|
|
30
|
-
npm install metadatafy
|
|
34
|
+
npm install -g metadatafy
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Now you can use `metadatafy` command anywhere:
|
|
38
|
+
|
|
39
|
+
이제 어디서나 `metadatafy` 명령어를 사용할 수 있습니다:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
metadatafy --help
|
|
43
|
+
metadatafy config setup
|
|
44
|
+
metadatafy analyze
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Per-project / 프로젝트별 설치
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -D metadatafy
|
|
31
51
|
# or
|
|
32
|
-
yarn add metadatafy
|
|
52
|
+
yarn add -D metadatafy
|
|
33
53
|
# or
|
|
34
|
-
pnpm add metadatafy
|
|
54
|
+
pnpm add -D metadatafy
|
|
35
55
|
```
|
|
36
56
|
|
|
37
57
|
## Quick Start / 빠른 시작
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
### 1. Global Setup (One-time) / 글로벌 설정 (1회)
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
```bash
|
|
62
|
+
# Install globally
|
|
63
|
+
npm install -g metadatafy
|
|
64
|
+
|
|
65
|
+
# Configure upload destination (Supabase or API server)
|
|
66
|
+
metadatafy config setup
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Project Setup / 프로젝트 설정
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# In your project directory
|
|
73
|
+
metadatafy init
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Analyze & Upload / 분석 및 업로드
|
|
42
77
|
|
|
43
78
|
```bash
|
|
44
|
-
|
|
79
|
+
# Analyze only (generates local JSON file)
|
|
80
|
+
metadatafy analyze
|
|
81
|
+
|
|
82
|
+
# Analyze + upload to configured destination
|
|
83
|
+
metadatafy analyze --upload
|
|
45
84
|
```
|
|
46
85
|
|
|
47
|
-
|
|
48
|
-
- Auto-detect your project type (Next.js, Vite, CRA, etc.)
|
|
49
|
-
- Detect your package manager (npm, yarn, pnpm)
|
|
50
|
-
- Create a `metadata.config.json` with optimized settings
|
|
51
|
-
- Optionally add the plugin to your build config (vite.config.ts or next.config.js)
|
|
52
|
-
- Optionally configure Supabase integration for automatic uploads
|
|
86
|
+
## CLI Commands / CLI 명령어
|
|
53
87
|
|
|
54
|
-
|
|
55
|
-
- 프로젝트 타입 자동 감지 (Next.js, Vite, CRA 등)
|
|
56
|
-
- 패키지 매니저 감지 (npm, yarn, pnpm)
|
|
57
|
-
- 최적화된 설정으로 `metadata.config.json` 생성
|
|
58
|
-
- 선택적으로 빌드 설정에 플러그인 추가 (vite.config.ts 또는 next.config.js)
|
|
59
|
-
- 선택적으로 Supabase 연동 설정 (자동 업로드)
|
|
88
|
+
### Global Config / 글로벌 설정
|
|
60
89
|
|
|
61
|
-
|
|
90
|
+
Settings are stored in `~/.metadatafy/` and shared across all projects.
|
|
62
91
|
|
|
63
|
-
|
|
92
|
+
설정은 `~/.metadatafy/`에 저장되며 모든 프로젝트에서 공유됩니다.
|
|
64
93
|
|
|
65
94
|
```bash
|
|
66
|
-
# Interactive setup
|
|
67
|
-
|
|
68
|
-
npx metadatafy init
|
|
95
|
+
# Interactive setup wizard
|
|
96
|
+
metadatafy config setup
|
|
69
97
|
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
npx metadatafy analyze
|
|
98
|
+
# Show current config
|
|
99
|
+
metadatafy config show
|
|
73
100
|
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
# Set individual values
|
|
102
|
+
metadatafy config set database.provider supabase
|
|
103
|
+
metadatafy config set api.serverUrl https://my-server.com
|
|
77
104
|
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
# Reset all config
|
|
106
|
+
metadatafy config reset
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Authentication (for API server mode) / 인증 (API 서버 모드용)
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Login via browser (OAuth)
|
|
113
|
+
metadatafy login
|
|
81
114
|
|
|
82
|
-
#
|
|
83
|
-
|
|
84
|
-
npx metadatafy upload
|
|
115
|
+
# Check login status
|
|
116
|
+
metadatafy whoami
|
|
85
117
|
|
|
86
|
-
#
|
|
87
|
-
|
|
118
|
+
# Logout
|
|
119
|
+
metadatafy logout
|
|
88
120
|
```
|
|
89
121
|
|
|
90
|
-
|
|
122
|
+
### Project Commands / 프로젝트 명령어
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Initialize project config
|
|
126
|
+
metadatafy init
|
|
127
|
+
|
|
128
|
+
# Analyze project
|
|
129
|
+
metadatafy analyze
|
|
130
|
+
|
|
131
|
+
# Analyze with upload
|
|
132
|
+
metadatafy analyze --upload
|
|
133
|
+
|
|
134
|
+
# Upload existing metadata file
|
|
135
|
+
metadatafy upload
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Command Reference / 명령어 레퍼런스
|
|
91
139
|
|
|
92
140
|
| Command | Description |
|
|
93
141
|
|---------|-------------|
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
|
|
99
|
-
|
|
142
|
+
| `config setup` | Interactive global config wizard / 대화형 글로벌 설정 |
|
|
143
|
+
| `config show` | Display current config / 현재 설정 표시 |
|
|
144
|
+
| `config set <key> <value>` | Set config value / 설정값 변경 |
|
|
145
|
+
| `config reset` | Reset all config / 모든 설정 초기화 |
|
|
146
|
+
| `login` | OAuth login to API server / API 서버 로그인 |
|
|
147
|
+
| `logout` | Clear login session / 로그아웃 |
|
|
148
|
+
| `whoami` | Show login status / 로그인 상태 확인 |
|
|
149
|
+
| `init` | Initialize project config / 프로젝트 설정 초기화 |
|
|
150
|
+
| `analyze` | Analyze project and generate metadata / 분석 및 메타데이터 생성 |
|
|
151
|
+
| `upload` | Upload existing metadata file / 기존 메타데이터 업로드 |
|
|
152
|
+
|
|
153
|
+
### Analyze Options / Analyze 옵션
|
|
100
154
|
|
|
101
155
|
| Option | Short | Description |
|
|
102
156
|
|--------|-------|-------------|
|
|
103
|
-
| `--project-id` | `-p` | Project ID (default: folder name) |
|
|
104
157
|
| `--output` | `-o` | Output file path (default: project-metadata.json) |
|
|
105
158
|
| `--config` | `-c` | Config file path |
|
|
106
|
-
| `--upload` | |
|
|
107
|
-
| `--no-upload` | | Skip DB upload / DB 업로드 스킵 |
|
|
159
|
+
| `--upload` | | Upload to configured destination |
|
|
108
160
|
| `--verbose` | | Enable detailed logging |
|
|
109
161
|
| `--help` | `-h` | Show help |
|
|
110
162
|
|
|
111
|
-
|
|
163
|
+
## Upload Modes / 업로드 모드
|
|
164
|
+
|
|
165
|
+
metadatafy supports 3 upload modes:
|
|
166
|
+
|
|
167
|
+
metadatafy는 3가지 업로드 모드를 지원합니다:
|
|
168
|
+
|
|
169
|
+
### 1. Local File Only / 로컬 파일만
|
|
170
|
+
|
|
171
|
+
No upload, just generate `project-metadata.json`:
|
|
172
|
+
|
|
173
|
+
업로드 없이 `project-metadata.json`만 생성:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
metadatafy analyze
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 2. Supabase Direct / Supabase 직접 연결
|
|
180
|
+
|
|
181
|
+
Connect to your own Supabase instance:
|
|
182
|
+
|
|
183
|
+
자신의 Supabase 인스턴스에 직접 연결:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
metadatafy config setup
|
|
187
|
+
# Select: 1) Supabase 직접 연결
|
|
188
|
+
# Enter: Supabase URL, Service Role Key, Table name
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 3. API Server / API 서버
|
|
192
|
+
|
|
193
|
+
Upload via API server (requires login):
|
|
194
|
+
|
|
195
|
+
API 서버를 통해 업로드 (로그인 필요):
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
metadatafy config setup
|
|
199
|
+
# Select: 2) API 서버
|
|
200
|
+
|
|
201
|
+
metadatafy login
|
|
202
|
+
metadatafy init # Select project from server
|
|
203
|
+
metadatafy analyze --upload
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Vite Plugin
|
|
112
207
|
|
|
113
208
|
```typescript
|
|
114
209
|
// vite.config.ts
|
|
115
210
|
import { defineConfig } from 'vite';
|
|
116
|
-
import
|
|
211
|
+
import metadatafy from 'metadatafy/vite';
|
|
117
212
|
|
|
118
213
|
export default defineConfig({
|
|
119
214
|
plugins: [
|
|
120
|
-
|
|
215
|
+
metadatafy({
|
|
121
216
|
projectId: 'my-project',
|
|
122
217
|
output: {
|
|
123
218
|
file: {
|
|
@@ -130,158 +225,102 @@ export default defineConfig({
|
|
|
130
225
|
});
|
|
131
226
|
```
|
|
132
227
|
|
|
133
|
-
|
|
228
|
+
## Next.js Plugin
|
|
134
229
|
|
|
135
|
-
|
|
230
|
+
### Next.js 15+ with Turbopack
|
|
136
231
|
|
|
137
|
-
|
|
138
|
-
// metadata-adapter.js
|
|
139
|
-
const { createMetadataAdapter } = require('metadatafy/next');
|
|
232
|
+
For Next.js 15+ with Turbopack, use CLI instead of webpack plugin:
|
|
140
233
|
|
|
141
|
-
|
|
142
|
-
projectId: 'my-project',
|
|
143
|
-
verbose: true,
|
|
144
|
-
output: {
|
|
145
|
-
file: { enabled: true, path: 'project-metadata.json' },
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
```
|
|
234
|
+
Next.js 15+ Turbopack 환경에서는 webpack 플러그인 대신 CLI를 사용하세요:
|
|
149
235
|
|
|
150
|
-
```
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export default nextConfig;
|
|
236
|
+
```json
|
|
237
|
+
// package.json
|
|
238
|
+
{
|
|
239
|
+
"scripts": {
|
|
240
|
+
"build": "next build && metadatafy analyze --upload"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
161
243
|
```
|
|
162
244
|
|
|
163
|
-
|
|
245
|
+
### Next.js 14 or Earlier (Webpack)
|
|
164
246
|
|
|
165
247
|
```javascript
|
|
166
248
|
// next.config.js
|
|
167
|
-
const {
|
|
249
|
+
const { withMetadatafy } = require('metadatafy/next');
|
|
168
250
|
|
|
169
251
|
/** @type {import('next').NextConfig} */
|
|
170
252
|
const nextConfig = {};
|
|
171
253
|
|
|
172
|
-
module.exports =
|
|
173
|
-
projectId: 'my-project',
|
|
174
|
-
})(nextConfig);
|
|
254
|
+
module.exports = withMetadatafy()(nextConfig);
|
|
175
255
|
```
|
|
176
256
|
|
|
177
|
-
## File
|
|
178
|
-
|
|
179
|
-
metadatafy uses a **hybrid detection system** that combines multiple approaches:
|
|
180
|
-
|
|
181
|
-
metadatafy는 여러 접근 방식을 결합한 **하이브리드 감지 시스템**을 사용합니다:
|
|
257
|
+
## Configuration File / 설정 파일
|
|
182
258
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
1. **Next.js special files** - `page.tsx`, `layout.tsx`, `route.ts` → route/api
|
|
186
|
-
2. **Path segments** - `/api/` in path → api
|
|
187
|
-
3. **Folder names** - `components/`, `hooks/`, `utils/`, `lib/` → corresponding type
|
|
188
|
-
4. **Code pattern analysis** - AST-based detection of actual code patterns
|
|
189
|
-
5. **Glob patterns** - User-defined patterns in config
|
|
259
|
+
Project-level config is stored in `metadata.config.json`:
|
|
190
260
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
When folder/path detection fails, metadatafy analyzes the actual code:
|
|
194
|
-
|
|
195
|
-
폴더/경로 감지가 실패하면 실제 코드를 분석합니다:
|
|
196
|
-
|
|
197
|
-
| Type | Detection Pattern |
|
|
198
|
-
|------|-------------------|
|
|
199
|
-
| **hook** | Uses `useState`, `useEffect`, etc. / Function starts with `use` |
|
|
200
|
-
| **component** | Returns JSX / Has `props` parameter |
|
|
201
|
-
| **api** | Exports `GET`, `POST`, etc. / Uses `NextRequest`/`NextResponse` |
|
|
202
|
-
| **service** | Uses `fetch`, `axios` / Multiple async functions / `*Service` class |
|
|
203
|
-
| **utility** | Multiple exported functions / No React dependencies |
|
|
204
|
-
|
|
205
|
-
### Supported Naming Conventions / 지원하는 네이밍 컨벤션
|
|
206
|
-
|
|
207
|
-
All naming conventions are supported:
|
|
208
|
-
|
|
209
|
-
모든 네이밍 컨벤션을 지원합니다:
|
|
210
|
-
|
|
211
|
-
| Type | Examples |
|
|
212
|
-
|------|----------|
|
|
213
|
-
| **hook** | `useAuth.ts`, `use-auth.ts`, `use_auth.ts` |
|
|
214
|
-
| **service** | `AuthService.ts`, `auth-service.ts`, `auth.service.ts` |
|
|
215
|
-
| **utility** | `string-utils.ts`, `date_helper.ts`, `formatUtil.ts` |
|
|
216
|
-
| **component** | `Button.tsx`, `auth-modal.tsx`, `user_profile.tsx` |
|
|
217
|
-
|
|
218
|
-
### Auto Pattern Expansion / 자동 패턴 확장
|
|
219
|
-
|
|
220
|
-
Include patterns are automatically expanded to match nested structures:
|
|
221
|
-
|
|
222
|
-
include 패턴은 중첩 구조에 맞게 자동 확장됩니다:
|
|
223
|
-
|
|
224
|
-
```json
|
|
225
|
-
{
|
|
226
|
-
"include": ["hooks/**/*.ts"]
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
This will match both:
|
|
231
|
-
- `hooks/useAuth.ts`
|
|
232
|
-
- `src/hooks/useAuth.ts`
|
|
233
|
-
- `src/features/auth/hooks/useAuth.ts`
|
|
234
|
-
|
|
235
|
-
## Configuration / 설정
|
|
236
|
-
|
|
237
|
-
Create `metadata.config.json` in your project root:
|
|
238
|
-
|
|
239
|
-
프로젝트 루트에 `metadata.config.json` 파일을 생성하세요:
|
|
261
|
+
프로젝트 레벨 설정은 `metadata.config.json`에 저장됩니다:
|
|
240
262
|
|
|
241
263
|
```json
|
|
242
264
|
{
|
|
243
265
|
"projectId": "my-project",
|
|
266
|
+
"projectUuid": "uuid-from-server",
|
|
244
267
|
"include": [
|
|
245
268
|
"app/**/*.{ts,tsx}",
|
|
246
269
|
"components/**/*.{ts,tsx}",
|
|
247
|
-
"hooks/**/*.{ts,tsx}"
|
|
248
|
-
"services/**/*.ts",
|
|
249
|
-
"lib/**/*.ts"
|
|
270
|
+
"hooks/**/*.{ts,tsx}"
|
|
250
271
|
],
|
|
251
272
|
"exclude": [
|
|
252
273
|
"**/node_modules/**",
|
|
253
|
-
"**/*.test.{ts,tsx}"
|
|
254
|
-
"**/*.spec.{ts,tsx}"
|
|
274
|
+
"**/*.test.{ts,tsx}"
|
|
255
275
|
],
|
|
256
276
|
"output": {
|
|
257
277
|
"file": {
|
|
258
278
|
"enabled": true,
|
|
259
279
|
"path": "project-metadata.json"
|
|
260
|
-
},
|
|
261
|
-
"database": {
|
|
262
|
-
"enabled": true,
|
|
263
|
-
"provider": "supabase",
|
|
264
|
-
"supabase": {
|
|
265
|
-
"url": "${SUPABASE_URL}",
|
|
266
|
-
"serviceRoleKey": "${SUPABASE_SERVICE_ROLE_KEY}",
|
|
267
|
-
"tableName": "code_index"
|
|
268
|
-
}
|
|
269
280
|
}
|
|
270
281
|
},
|
|
271
282
|
"koreanKeywords": {
|
|
272
|
-
"attendance": ["출석", "출결"]
|
|
273
|
-
"student": ["학생", "수강생"]
|
|
283
|
+
"attendance": ["출석", "출결"]
|
|
274
284
|
},
|
|
275
285
|
"verbose": false
|
|
276
286
|
}
|
|
277
287
|
```
|
|
278
288
|
|
|
289
|
+
## Database Schema / 데이터베이스 스키마
|
|
290
|
+
|
|
291
|
+
If using Supabase direct mode, create this table:
|
|
292
|
+
|
|
293
|
+
Supabase 직접 연결 모드 사용 시 이 테이블을 생성하세요:
|
|
294
|
+
|
|
295
|
+
```sql
|
|
296
|
+
CREATE TABLE code_index (
|
|
297
|
+
id TEXT PRIMARY KEY,
|
|
298
|
+
project_id TEXT NOT NULL,
|
|
299
|
+
file_type TEXT NOT NULL,
|
|
300
|
+
name TEXT NOT NULL,
|
|
301
|
+
path TEXT NOT NULL,
|
|
302
|
+
keywords TEXT[] DEFAULT '{}',
|
|
303
|
+
search_text TEXT,
|
|
304
|
+
calls TEXT[] DEFAULT '{}',
|
|
305
|
+
called_by TEXT[] DEFAULT '{}',
|
|
306
|
+
metadata JSONB DEFAULT '{}',
|
|
307
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
308
|
+
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
309
|
+
UNIQUE(project_id, path)
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
-- Indexes
|
|
313
|
+
CREATE INDEX idx_code_index_project_id ON code_index(project_id);
|
|
314
|
+
CREATE INDEX idx_code_index_file_type ON code_index(file_type);
|
|
315
|
+
CREATE INDEX idx_code_index_keywords ON code_index USING GIN(keywords);
|
|
316
|
+
```
|
|
317
|
+
|
|
279
318
|
## Output Format / 출력 형식
|
|
280
319
|
|
|
281
320
|
```json
|
|
282
321
|
{
|
|
283
322
|
"projectId": "my-project",
|
|
284
|
-
"timestamp": "2025-01-
|
|
323
|
+
"timestamp": "2025-01-11T12:00:00Z",
|
|
285
324
|
"stats": {
|
|
286
325
|
"totalFiles": 150,
|
|
287
326
|
"byType": {
|
|
@@ -302,7 +341,7 @@ Create `metadata.config.json` in your project root:
|
|
|
302
341
|
"path": "components/attendance/AttendanceModal.tsx",
|
|
303
342
|
"keywords": ["attendance", "modal", "출석", "모달"],
|
|
304
343
|
"searchText": "attendancemodal components attendance ...",
|
|
305
|
-
"calls": ["hooks/useAttendance.ts"
|
|
344
|
+
"calls": ["hooks/useAttendance.ts"],
|
|
306
345
|
"calledBy": ["app/attendance/page.tsx"],
|
|
307
346
|
"metadata": {
|
|
308
347
|
"exports": ["AttendanceModal"],
|
|
@@ -313,147 +352,36 @@ Create `metadata.config.json` in your project root:
|
|
|
313
352
|
}
|
|
314
353
|
```
|
|
315
354
|
|
|
316
|
-
##
|
|
317
|
-
|
|
318
|
-
### Supabase Table Schema / Supabase 테이블 스키마
|
|
319
|
-
|
|
320
|
-
metadatafy stores each file as an individual row for better queryability:
|
|
321
|
-
|
|
322
|
-
metadatafy는 더 나은 쿼리를 위해 각 파일을 개별 row로 저장합니다:
|
|
323
|
-
|
|
324
|
-
```sql
|
|
325
|
-
-- File type enum
|
|
326
|
-
CREATE TYPE file_type AS ENUM (
|
|
327
|
-
'route', 'component', 'hook', 'service', 'api', 'table', 'utility'
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
-- Main table: individual code file metadata
|
|
331
|
-
CREATE TABLE code_index (
|
|
332
|
-
id TEXT PRIMARY KEY,
|
|
333
|
-
project_id TEXT NOT NULL,
|
|
334
|
-
file_type file_type NOT NULL,
|
|
335
|
-
name TEXT NOT NULL,
|
|
336
|
-
path TEXT NOT NULL,
|
|
337
|
-
keywords TEXT[] DEFAULT '{}',
|
|
338
|
-
search_text TEXT,
|
|
339
|
-
calls TEXT[] DEFAULT '{}',
|
|
340
|
-
called_by TEXT[] DEFAULT '{}',
|
|
341
|
-
metadata JSONB DEFAULT '{}',
|
|
342
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
343
|
-
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
344
|
-
UNIQUE(project_id, path)
|
|
345
|
-
);
|
|
346
|
-
|
|
347
|
-
-- Analysis log table
|
|
348
|
-
CREATE TABLE code_analysis_log (
|
|
349
|
-
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
350
|
-
project_id TEXT NOT NULL,
|
|
351
|
-
total_files INTEGER NOT NULL,
|
|
352
|
-
stats JSONB NOT NULL,
|
|
353
|
-
parse_errors TEXT[] DEFAULT '{}',
|
|
354
|
-
analyzed_at TIMESTAMPTZ NOT NULL,
|
|
355
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
-- Indexes for search optimization
|
|
359
|
-
CREATE INDEX idx_code_index_project_id ON code_index(project_id);
|
|
360
|
-
CREATE INDEX idx_code_index_file_type ON code_index(file_type);
|
|
361
|
-
CREATE INDEX idx_code_index_keywords ON code_index USING GIN(keywords);
|
|
362
|
-
CREATE INDEX idx_code_index_search_text ON code_index USING GIN(to_tsvector('simple', search_text));
|
|
363
|
-
|
|
364
|
-
-- RLS Policies
|
|
365
|
-
ALTER TABLE code_index ENABLE ROW LEVEL SECURITY;
|
|
366
|
-
ALTER TABLE code_analysis_log ENABLE ROW LEVEL SECURITY;
|
|
367
|
-
|
|
368
|
-
-- Read access for authenticated users
|
|
369
|
-
CREATE POLICY "Authenticated users can read code_index"
|
|
370
|
-
ON code_index FOR SELECT TO authenticated USING (true);
|
|
371
|
-
|
|
372
|
-
-- Write access for service role only
|
|
373
|
-
CREATE POLICY "Service role can manage code_index"
|
|
374
|
-
ON code_index FOR ALL TO service_role USING (true) WITH CHECK (true);
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
### Configuration / 설정
|
|
378
|
-
|
|
379
|
-
```json
|
|
380
|
-
{
|
|
381
|
-
"output": {
|
|
382
|
-
"database": {
|
|
383
|
-
"enabled": true,
|
|
384
|
-
"provider": "supabase",
|
|
385
|
-
"supabase": {
|
|
386
|
-
"url": "${SUPABASE_URL}",
|
|
387
|
-
"serviceRoleKey": "${SUPABASE_SERVICE_ROLE_KEY}",
|
|
388
|
-
"tableName": "code_index"
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
### Environment Variables / 환경변수
|
|
355
|
+
## CI/CD Integration / CI/CD 연동
|
|
396
356
|
|
|
397
|
-
|
|
398
|
-
SUPABASE_URL=https://your-project.supabase.co
|
|
399
|
-
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
### How It Works / 작동 방식
|
|
403
|
-
|
|
404
|
-
1. **Delete existing project data** - Removes all rows with matching `project_id`
|
|
405
|
-
2. **Bulk insert new data** - Inserts all files in chunks of 500
|
|
406
|
-
3. **Log analysis run** - Records stats in `code_analysis_log` table
|
|
407
|
-
|
|
408
|
-
---
|
|
409
|
-
|
|
410
|
-
1. **기존 프로젝트 데이터 삭제** - 동일한 `project_id`의 모든 row 삭제
|
|
411
|
-
2. **새 데이터 일괄 삽입** - 500개 단위로 모든 파일 삽입
|
|
412
|
-
3. **분석 로그 기록** - `code_analysis_log` 테이블에 통계 기록
|
|
413
|
-
|
|
414
|
-
### Querying Code / 코드 쿼리 예시
|
|
415
|
-
|
|
416
|
-
```sql
|
|
417
|
-
-- Find all hooks in a project
|
|
418
|
-
SELECT * FROM code_index
|
|
419
|
-
WHERE project_id = 'my-project' AND file_type = 'hook';
|
|
420
|
-
|
|
421
|
-
-- Full-text search
|
|
422
|
-
SELECT * FROM code_index
|
|
423
|
-
WHERE project_id = 'my-project'
|
|
424
|
-
AND search_text ILIKE '%authentication%';
|
|
425
|
-
|
|
426
|
-
-- Find files that call a specific file
|
|
427
|
-
SELECT * FROM code_index
|
|
428
|
-
WHERE 'hooks/useAuth.ts' = ANY(calls);
|
|
429
|
-
|
|
430
|
-
-- Get analysis history
|
|
431
|
-
SELECT * FROM code_analysis_log
|
|
432
|
-
WHERE project_id = 'my-project'
|
|
433
|
-
ORDER BY analyzed_at DESC;
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### Recommended Workflow / 권장 워크플로우
|
|
437
|
-
|
|
438
|
-
```bash
|
|
439
|
-
# Generate metadata + upload
|
|
440
|
-
npx metadatafy analyze --upload
|
|
441
|
-
|
|
442
|
-
# Or in CI/CD
|
|
443
|
-
npx metadatafy analyze --upload
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**GitHub Actions:**
|
|
357
|
+
### GitHub Actions
|
|
447
358
|
|
|
448
359
|
```yaml
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
360
|
+
name: Analyze Code
|
|
361
|
+
on:
|
|
362
|
+
push:
|
|
363
|
+
branches: [main]
|
|
364
|
+
|
|
365
|
+
jobs:
|
|
366
|
+
analyze:
|
|
367
|
+
runs-on: ubuntu-latest
|
|
368
|
+
steps:
|
|
369
|
+
- uses: actions/checkout@v4
|
|
370
|
+
- uses: actions/setup-node@v4
|
|
371
|
+
with:
|
|
372
|
+
node-version: '20'
|
|
373
|
+
|
|
374
|
+
- run: npm ci
|
|
375
|
+
- run: npm run build
|
|
376
|
+
|
|
377
|
+
# Using Supabase direct
|
|
378
|
+
- run: npx metadatafy analyze --upload
|
|
379
|
+
env:
|
|
380
|
+
METADATAFY_DB_URL: ${{ secrets.SUPABASE_URL }}
|
|
381
|
+
METADATAFY_DB_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
|
|
454
382
|
```
|
|
455
383
|
|
|
456
|
-
## API / 프로그래밍 방식 사용
|
|
384
|
+
## API Usage / 프로그래밍 방식 사용
|
|
457
385
|
|
|
458
386
|
```typescript
|
|
459
387
|
import { ProjectAnalyzer, createDefaultConfig } from 'metadatafy';
|
|
@@ -470,11 +398,26 @@ console.log(result.stats);
|
|
|
470
398
|
console.log(result.items);
|
|
471
399
|
```
|
|
472
400
|
|
|
473
|
-
##
|
|
401
|
+
## File Type Detection / 파일 타입 감지
|
|
402
|
+
|
|
403
|
+
metadatafy uses a hybrid detection system:
|
|
404
|
+
|
|
405
|
+
1. **Next.js special files** - `page.tsx`, `layout.tsx`, `route.ts` → route/api
|
|
406
|
+
2. **Path segments** - `/api/` in path → api
|
|
407
|
+
3. **Folder names** - `components/`, `hooks/`, `utils/` → corresponding type
|
|
408
|
+
4. **Code pattern analysis** - AST-based detection
|
|
409
|
+
|
|
410
|
+
| Type | Detection Pattern |
|
|
411
|
+
|------|-------------------|
|
|
412
|
+
| **hook** | Uses `useState`, `useEffect` / Function starts with `use` |
|
|
413
|
+
| **component** | Returns JSX / Has `props` parameter |
|
|
414
|
+
| **api** | Exports `GET`, `POST` / Uses `NextRequest` |
|
|
415
|
+
| **service** | Uses `fetch`, `axios` / `*Service` class |
|
|
416
|
+
| **utility** | Multiple exported functions / No React |
|
|
474
417
|
|
|
475
|
-
|
|
418
|
+
## Korean Keyword Mapping / 한글 키워드 매핑
|
|
476
419
|
|
|
477
|
-
|
|
420
|
+
Built-in mappings:
|
|
478
421
|
|
|
479
422
|
| English | Korean |
|
|
480
423
|
|---------|--------|
|
|
@@ -485,9 +428,7 @@ Built-in mappings include common development terms:
|
|
|
485
428
|
| login | 로그인 |
|
|
486
429
|
| user | 사용자, 유저, 회원 |
|
|
487
430
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
설정에서 커스텀 매핑을 추가할 수 있습니다.
|
|
431
|
+
Extend with custom mappings in `metadata.config.json`.
|
|
491
432
|
|
|
492
433
|
## License / 라이선스
|
|
493
434
|
|
|
@@ -497,6 +438,4 @@ MIT
|
|
|
497
438
|
|
|
498
439
|
Issues and pull requests are welcome!
|
|
499
440
|
|
|
500
|
-
이슈와 풀 리퀘스트를 환영합니다!
|
|
501
|
-
|
|
502
441
|
GitHub: https://github.com/rungchan2/metadatafy
|