metadatafy 1.0.1 → 1.0.3

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/dist/cli.cjs CHANGED
@@ -1,1283 +1,5 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
-
4
- var util = require('util');
5
- var path2 = require('path');
6
- var fs4 = require('fs/promises');
7
- var glob = require('glob');
8
- var ts3 = require('typescript');
9
- var fs = require('fs');
10
- var crypto = require('crypto');
11
-
12
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
-
14
- function _interopNamespace(e) {
15
- if (e && e.__esModule) return e;
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- }
28
- n.default = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
33
- var fs4__namespace = /*#__PURE__*/_interopNamespace(fs4);
34
- var ts3__default = /*#__PURE__*/_interopDefault(ts3);
35
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
36
- var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
37
-
38
- var TypeScriptParser = class {
39
- constructor() {
40
- this.compilerOptions = {
41
- target: ts3__default.default.ScriptTarget.ESNext,
42
- module: ts3__default.default.ModuleKind.ESNext,
43
- jsx: ts3__default.default.JsxEmit.React,
44
- esModuleInterop: true,
45
- allowSyntheticDefaultImports: true,
46
- strict: false
47
- };
48
- }
49
- /**
50
- * 소스 코드를 AST로 파싱
51
- */
52
- parse(content, filePath) {
53
- return ts3__default.default.createSourceFile(
54
- filePath,
55
- content,
56
- this.compilerOptions.target,
57
- true,
58
- this.getScriptKind(filePath)
59
- );
60
- }
61
- /**
62
- * 파일 확장자에 따른 ScriptKind 결정
63
- */
64
- getScriptKind(filePath) {
65
- const ext = filePath.toLowerCase();
66
- if (ext.endsWith(".tsx")) return ts3__default.default.ScriptKind.TSX;
67
- if (ext.endsWith(".ts")) return ts3__default.default.ScriptKind.TS;
68
- if (ext.endsWith(".jsx")) return ts3__default.default.ScriptKind.JSX;
69
- if (ext.endsWith(".js")) return ts3__default.default.ScriptKind.JS;
70
- return ts3__default.default.ScriptKind.Unknown;
71
- }
72
- /**
73
- * AST 노드 순회
74
- */
75
- traverse(node, visitor) {
76
- const shouldContinue = visitor(node);
77
- if (shouldContinue === false) return;
78
- ts3__default.default.forEachChild(node, (child) => this.traverse(child, visitor));
79
- }
80
- /**
81
- * 특정 조건을 만족하는 노드 수집
82
- */
83
- findNodes(sourceFile, predicate) {
84
- const results = [];
85
- this.traverse(sourceFile, (node) => {
86
- if (predicate(node)) {
87
- results.push(node);
88
- }
89
- });
90
- return results;
91
- }
92
- /**
93
- * 노드의 텍스트 추출
94
- */
95
- getNodeText(node, sourceFile) {
96
- return node.getText(sourceFile);
97
- }
98
- /**
99
- * JSDoc 코멘트 추출
100
- */
101
- getJSDocComment(node) {
102
- const jsDocNodes = ts3__default.default.getJSDocCommentsAndTags(node);
103
- if (jsDocNodes.length === 0) return void 0;
104
- return jsDocNodes.filter(ts3__default.default.isJSDoc).map((doc) => doc.comment).filter(Boolean).join("\n");
105
- }
106
- };
107
- new TypeScriptParser();
108
- var SQLParser = class {
109
- /**
110
- * SQL 파일 파싱
111
- */
112
- parse(content, relativePath) {
113
- const tables = this.extractTables(content);
114
- const tableName = tables[0]?.name || this.extractNameFromPath(relativePath);
115
- return {
116
- path: relativePath,
117
- type: "table",
118
- name: tableName,
119
- imports: [],
120
- exports: tables.map((t) => ({
121
- name: t.name,
122
- isDefault: false,
123
- isTypeOnly: false,
124
- kind: "variable"
125
- })),
126
- metadata: {
127
- tableName,
128
- columns: tables[0]?.columns || []
129
- }
130
- };
131
- }
132
- /**
133
- * CREATE TABLE 문에서 테이블 정보 추출
134
- */
135
- extractTables(content) {
136
- const tables = [];
137
- const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?["']?(\w+)["']?\s*\(([\s\S]*?)\);/gi;
138
- let match;
139
- while ((match = createTableRegex.exec(content)) !== null) {
140
- const tableName = match[1];
141
- const columnsBlock = match[2];
142
- const columns = this.parseColumns(columnsBlock);
143
- tables.push({ name: tableName, columns });
144
- }
145
- const alterTableRegex = /ALTER\s+TABLE\s+["']?(\w+)["']?\s+ADD\s+(?:COLUMN\s+)?["']?(\w+)["']?\s+(\w+)/gi;
146
- while ((match = alterTableRegex.exec(content)) !== null) {
147
- const tableName = match[1];
148
- const columnName = match[2];
149
- const columnType = match[3];
150
- let table = tables.find((t) => t.name === tableName);
151
- if (!table) {
152
- table = { name: tableName, columns: [] };
153
- tables.push(table);
154
- }
155
- table.columns.push({
156
- name: columnName,
157
- type: columnType,
158
- nullable: true,
159
- isPrimaryKey: false,
160
- isForeignKey: false
161
- });
162
- }
163
- return tables;
164
- }
165
- /**
166
- * 컬럼 정의 파싱
167
- */
168
- parseColumns(columnsBlock) {
169
- const columns = [];
170
- const lines = columnsBlock.split(",").map((line) => line.trim()).filter(
171
- (line) => line && !line.toUpperCase().startsWith("CONSTRAINT") && !line.toUpperCase().startsWith("PRIMARY KEY") && !line.toUpperCase().startsWith("FOREIGN KEY") && !line.toUpperCase().startsWith("UNIQUE") && !line.toUpperCase().startsWith("CHECK")
172
- );
173
- for (const line of lines) {
174
- const column = this.parseColumnDefinition(line);
175
- if (column) {
176
- columns.push(column);
177
- }
178
- }
179
- return columns;
180
- }
181
- /**
182
- * 단일 컬럼 정의 파싱
183
- */
184
- parseColumnDefinition(line) {
185
- const match = line.match(/^["']?(\w+)["']?\s+(\w+(?:\([^)]+\))?)/i);
186
- if (!match) return null;
187
- const [, name, type] = match;
188
- const upperLine = line.toUpperCase();
189
- return {
190
- name,
191
- type: type.toUpperCase(),
192
- nullable: !upperLine.includes("NOT NULL"),
193
- isPrimaryKey: upperLine.includes("PRIMARY KEY"),
194
- isForeignKey: upperLine.includes("REFERENCES"),
195
- references: this.extractReference(line)
196
- };
197
- }
198
- /**
199
- * REFERENCES 절에서 참조 정보 추출
200
- */
201
- extractReference(line) {
202
- const match = line.match(
203
- /REFERENCES\s+["']?(\w+)["']?\s*\(["']?(\w+)["']?\)/i
204
- );
205
- if (!match) return void 0;
206
- return {
207
- table: match[1],
208
- column: match[2]
209
- };
210
- }
211
- /**
212
- * 파일 경로에서 테이블 이름 추출
213
- */
214
- extractNameFromPath(filePath) {
215
- const filename = path2__namespace.basename(filePath);
216
- const match = filename.match(/create_(\w+)_table/i);
217
- return match ? match[1] : filename.replace(".sql", "");
218
- }
219
- };
220
- var ImportExtractor = class {
221
- /**
222
- * SourceFile에서 모든 import 정보 추출
223
- */
224
- extract(sourceFile) {
225
- const imports = [];
226
- ts3__default.default.forEachChild(sourceFile, (node) => {
227
- if (ts3__default.default.isImportDeclaration(node)) {
228
- const importInfo = this.parseImportDeclaration(node);
229
- if (importInfo) {
230
- imports.push(importInfo);
231
- }
232
- }
233
- });
234
- return imports;
235
- }
236
- /**
237
- * ImportDeclaration 노드를 ImportInfo로 변환
238
- */
239
- parseImportDeclaration(node) {
240
- const moduleSpecifier = node.moduleSpecifier;
241
- if (!ts3__default.default.isStringLiteral(moduleSpecifier)) {
242
- return null;
243
- }
244
- const source = moduleSpecifier.text;
245
- const specifiers = [];
246
- let isDefault = false;
247
- const isTypeOnly = node.importClause?.isTypeOnly || false;
248
- const importClause = node.importClause;
249
- if (!importClause) {
250
- return {
251
- source,
252
- specifiers: [],
253
- isDefault: false,
254
- isTypeOnly: false
255
- };
256
- }
257
- if (importClause.name) {
258
- specifiers.push(importClause.name.text);
259
- isDefault = true;
260
- }
261
- const namedBindings = importClause.namedBindings;
262
- if (namedBindings) {
263
- if (ts3__default.default.isNamespaceImport(namedBindings)) {
264
- specifiers.push(`* as ${namedBindings.name.text}`);
265
- } else if (ts3__default.default.isNamedImports(namedBindings)) {
266
- for (const element of namedBindings.elements) {
267
- const name = element.name.text;
268
- const propertyName = element.propertyName?.text;
269
- if (propertyName) {
270
- specifiers.push(`${propertyName} as ${name}`);
271
- } else {
272
- specifiers.push(name);
273
- }
274
- }
275
- }
276
- }
277
- return {
278
- source,
279
- specifiers,
280
- isDefault,
281
- isTypeOnly
282
- };
283
- }
284
- };
285
- var ExportExtractor = class {
286
- /**
287
- * SourceFile에서 모든 export 정보 추출
288
- */
289
- extract(sourceFile) {
290
- const exports$1 = [];
291
- ts3__default.default.forEachChild(sourceFile, (node) => {
292
- const exportInfos = this.extractFromNode(node, sourceFile);
293
- exports$1.push(...exportInfos);
294
- });
295
- return exports$1;
296
- }
297
- /**
298
- * 노드에서 export 정보 추출
299
- */
300
- extractFromNode(node, sourceFile) {
301
- const results = [];
302
- if (ts3__default.default.isFunctionDeclaration(node) && this.hasExportModifier(node)) {
303
- results.push({
304
- name: node.name?.text || "anonymous",
305
- isDefault: this.hasDefaultModifier(node),
306
- isTypeOnly: false,
307
- kind: "function"
308
- });
309
- }
310
- if (ts3__default.default.isClassDeclaration(node) && this.hasExportModifier(node)) {
311
- results.push({
312
- name: node.name?.text || "anonymous",
313
- isDefault: this.hasDefaultModifier(node),
314
- isTypeOnly: false,
315
- kind: "class"
316
- });
317
- }
318
- if (ts3__default.default.isVariableStatement(node) && this.hasExportModifier(node)) {
319
- for (const declaration of node.declarationList.declarations) {
320
- if (ts3__default.default.isIdentifier(declaration.name)) {
321
- results.push({
322
- name: declaration.name.text,
323
- isDefault: false,
324
- isTypeOnly: false,
325
- kind: "variable"
326
- });
327
- }
328
- }
329
- }
330
- if (ts3__default.default.isTypeAliasDeclaration(node) && this.hasExportModifier(node)) {
331
- results.push({
332
- name: node.name.text,
333
- isDefault: false,
334
- isTypeOnly: true,
335
- kind: "type"
336
- });
337
- }
338
- if (ts3__default.default.isInterfaceDeclaration(node) && this.hasExportModifier(node)) {
339
- results.push({
340
- name: node.name.text,
341
- isDefault: false,
342
- isTypeOnly: true,
343
- kind: "interface"
344
- });
345
- }
346
- if (ts3__default.default.isExportAssignment(node) && !node.isExportEquals) {
347
- const name = this.getExportDefaultName(node, sourceFile);
348
- results.push({
349
- name,
350
- isDefault: true,
351
- isTypeOnly: false,
352
- kind: "variable"
353
- });
354
- }
355
- if (ts3__default.default.isExportDeclaration(node)) {
356
- const exportClause = node.exportClause;
357
- if (exportClause && ts3__default.default.isNamedExports(exportClause)) {
358
- for (const element of exportClause.elements) {
359
- results.push({
360
- name: element.name.text,
361
- isDefault: false,
362
- isTypeOnly: node.isTypeOnly,
363
- kind: "variable"
364
- });
365
- }
366
- }
367
- }
368
- return results;
369
- }
370
- /**
371
- * export 키워드가 있는지 확인
372
- */
373
- hasExportModifier(node) {
374
- const modifiers = ts3__default.default.canHaveModifiers(node) ? ts3__default.default.getModifiers(node) : void 0;
375
- return modifiers?.some((m) => m.kind === ts3__default.default.SyntaxKind.ExportKeyword) || false;
376
- }
377
- /**
378
- * default 키워드가 있는지 확인
379
- */
380
- hasDefaultModifier(node) {
381
- const modifiers = ts3__default.default.canHaveModifiers(node) ? ts3__default.default.getModifiers(node) : void 0;
382
- return modifiers?.some((m) => m.kind === ts3__default.default.SyntaxKind.DefaultKeyword) || false;
383
- }
384
- /**
385
- * export default의 이름 추출
386
- */
387
- getExportDefaultName(node, _sourceFile) {
388
- const expr = node.expression;
389
- if (ts3__default.default.isIdentifier(expr)) {
390
- return expr.text;
391
- }
392
- if (ts3__default.default.isArrowFunction(expr) || ts3__default.default.isFunctionExpression(expr)) {
393
- return "default";
394
- }
395
- if (ts3__default.default.isCallExpression(expr) && ts3__default.default.isIdentifier(expr.expression)) {
396
- const firstArg = expr.arguments[0];
397
- if (firstArg && ts3__default.default.isIdentifier(firstArg)) {
398
- return firstArg.text;
399
- }
400
- }
401
- return "default";
402
- }
403
- };
404
- var PropsExtractor = class {
405
- /**
406
- * SourceFile에서 Props 정보 추출
407
- */
408
- extract(sourceFile) {
409
- const props = [];
410
- const propsType = this.findPropsType(sourceFile);
411
- if (propsType) {
412
- props.push(...this.extractFromTypeNode(propsType, sourceFile));
413
- }
414
- const componentFunction = this.findComponentFunction(sourceFile);
415
- if (componentFunction) {
416
- props.push(
417
- ...this.extractFromFunctionParams(componentFunction, sourceFile)
418
- );
419
- }
420
- return this.deduplicateProps(props);
421
- }
422
- /**
423
- * Props 타입 정의 찾기
424
- */
425
- findPropsType(sourceFile) {
426
- let propsType;
427
- ts3__default.default.forEachChild(sourceFile, (node) => {
428
- if (ts3__default.default.isInterfaceDeclaration(node) && node.name.text.endsWith("Props")) {
429
- propsType = node;
430
- }
431
- if (ts3__default.default.isTypeAliasDeclaration(node) && node.name.text.endsWith("Props")) {
432
- propsType = node.type;
433
- }
434
- });
435
- return propsType;
436
- }
437
- /**
438
- * 컴포넌트 함수 찾기
439
- */
440
- findComponentFunction(sourceFile) {
441
- let component;
442
- ts3__default.default.forEachChild(sourceFile, (node) => {
443
- if (ts3__default.default.isFunctionDeclaration(node) && this.isExported(node)) {
444
- component = node;
445
- }
446
- if (ts3__default.default.isVariableStatement(node) && this.isExported(node)) {
447
- for (const decl of node.declarationList.declarations) {
448
- if (decl.initializer && (ts3__default.default.isArrowFunction(decl.initializer) || ts3__default.default.isFunctionExpression(decl.initializer))) {
449
- component = decl.initializer;
450
- }
451
- }
452
- }
453
- });
454
- return component;
455
- }
456
- /**
457
- * 타입 노드에서 Props 추출
458
- */
459
- extractFromTypeNode(typeNode, sourceFile) {
460
- const props = [];
461
- if (ts3__default.default.isInterfaceDeclaration(typeNode)) {
462
- for (const member of typeNode.members) {
463
- const propInfo = this.extractMemberProp(member, sourceFile);
464
- if (propInfo) {
465
- props.push(propInfo);
466
- }
467
- }
468
- return props;
469
- }
470
- if (ts3__default.default.isTypeLiteralNode(typeNode)) {
471
- for (const member of typeNode.members) {
472
- const propInfo = this.extractMemberProp(member, sourceFile);
473
- if (propInfo) {
474
- props.push(propInfo);
475
- }
476
- }
477
- }
478
- if (ts3__default.default.isIntersectionTypeNode(typeNode)) {
479
- for (const type of typeNode.types) {
480
- props.push(...this.extractFromTypeNode(type, sourceFile));
481
- }
482
- }
483
- return props;
484
- }
485
- /**
486
- * 타입 멤버에서 PropInfo 추출
487
- */
488
- extractMemberProp(member, sourceFile) {
489
- if (!ts3__default.default.isPropertySignature(member)) {
490
- return null;
491
- }
492
- const name = member.name;
493
- if (!ts3__default.default.isIdentifier(name) && !ts3__default.default.isStringLiteral(name)) {
494
- return null;
495
- }
496
- const propName = ts3__default.default.isIdentifier(name) ? name.text : name.text;
497
- const required = !member.questionToken;
498
- const type = member.type ? member.type.getText(sourceFile) : "any";
499
- return {
500
- name: propName,
501
- type,
502
- required
503
- };
504
- }
505
- /**
506
- * 함수 매개변수에서 Props 추출
507
- */
508
- extractFromFunctionParams(func, sourceFile) {
509
- const props = [];
510
- const firstParam = func.parameters[0];
511
- if (!firstParam) return props;
512
- if (ts3__default.default.isObjectBindingPattern(firstParam.name)) {
513
- for (const element of firstParam.name.elements) {
514
- if (ts3__default.default.isBindingElement(element) && ts3__default.default.isIdentifier(element.name)) {
515
- props.push({
516
- name: element.name.text,
517
- type: "unknown",
518
- required: !element.initializer,
519
- defaultValue: element.initializer?.getText(sourceFile)
520
- });
521
- }
522
- }
523
- }
524
- return props;
525
- }
526
- /**
527
- * export 키워드가 있는지 확인
528
- */
529
- isExported(node) {
530
- const modifiers = ts3__default.default.canHaveModifiers(node) ? ts3__default.default.getModifiers(node) : void 0;
531
- return modifiers?.some((m) => m.kind === ts3__default.default.SyntaxKind.ExportKeyword) || false;
532
- }
533
- /**
534
- * 중복 Props 제거
535
- */
536
- deduplicateProps(props) {
537
- const seen = /* @__PURE__ */ new Set();
538
- return props.filter((prop) => {
539
- if (seen.has(prop.name)) return false;
540
- seen.add(prop.name);
541
- return true;
542
- });
543
- }
544
- };
545
-
546
- // src/utils/naming-utils.ts
547
- function splitCamelCase(str) {
548
- return str.replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").filter(Boolean);
549
- }
550
- function splitPascalCase(str) {
551
- return str.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").filter(Boolean);
552
- }
553
- function splitSnakeCase(str) {
554
- return str.split("_").filter(Boolean);
555
- }
556
- function extractAcronyms(str) {
557
- const acronyms = [];
558
- const matches = str.match(/[A-Z]{2,}/g);
559
- if (matches) {
560
- acronyms.push(...matches);
561
- }
562
- return acronyms;
563
- }
564
-
565
- // src/utils/korean-mapper.ts
566
- var KOREAN_KEYWORD_MAP = {
567
- // 공통 동작
568
- create: ["\uC0DD\uC131", "\uB9CC\uB4E4\uAE30", "\uCD94\uAC00"],
569
- read: ["\uC77D\uAE30", "\uC870\uD68C"],
570
- update: ["\uC218\uC815", "\uC5C5\uB370\uC774\uD2B8", "\uBCC0\uACBD"],
571
- delete: ["\uC0AD\uC81C", "\uC81C\uAC70"],
572
- list: ["\uBAA9\uB85D", "\uB9AC\uC2A4\uD2B8"],
573
- search: ["\uAC80\uC0C9", "\uCC3E\uAE30"],
574
- filter: ["\uD544\uD130", "\uD544\uD130\uB9C1"],
575
- sort: ["\uC815\uB82C"],
576
- submit: ["\uC81C\uCD9C", "\uC804\uC1A1"],
577
- cancel: ["\uCDE8\uC18C"],
578
- confirm: ["\uD655\uC778"],
579
- save: ["\uC800\uC7A5"],
580
- load: ["\uB85C\uB4DC", "\uBD88\uB7EC\uC624\uAE30"],
581
- fetch: ["\uAC00\uC838\uC624\uAE30", "\uBD88\uB7EC\uC624\uAE30"],
582
- // UI 요소
583
- button: ["\uBC84\uD2BC"],
584
- modal: ["\uBAA8\uB2EC", "\uD31D\uC5C5"],
585
- dialog: ["\uB2E4\uC774\uC5BC\uB85C\uADF8", "\uB300\uD654\uC0C1\uC790"],
586
- form: ["\uD3FC", "\uC591\uC2DD"],
587
- input: ["\uC785\uB825", "\uC778\uD48B"],
588
- select: ["\uC120\uD0DD", "\uC140\uB809\uD2B8", "\uB4DC\uB86D\uB2E4\uC6B4"],
589
- checkbox: ["\uCCB4\uD06C\uBC15\uC2A4", "\uCCB4\uD06C"],
590
- table: ["\uD14C\uC774\uBE14", "\uD45C"],
591
- card: ["\uCE74\uB4DC"],
592
- tab: ["\uD0ED"],
593
- menu: ["\uBA54\uB274"],
594
- header: ["\uD5E4\uB354", "\uBA38\uB9AC\uAE00"],
595
- footer: ["\uD478\uD130", "\uBC14\uB2E5\uAE00"],
596
- sidebar: ["\uC0AC\uC774\uB4DC\uBC14"],
597
- navbar: ["\uB124\uBE44\uAC8C\uC774\uC158", "\uB124\uBE44\uBC14"],
598
- // 인증/사용자
599
- auth: ["\uC778\uC99D", "\uB85C\uADF8\uC778"],
600
- login: ["\uB85C\uADF8\uC778"],
601
- logout: ["\uB85C\uADF8\uC544\uC6C3"],
602
- register: ["\uD68C\uC6D0\uAC00\uC785", "\uAC00\uC785"],
603
- signup: ["\uD68C\uC6D0\uAC00\uC785", "\uAC00\uC785"],
604
- user: ["\uC0AC\uC6A9\uC790", "\uC720\uC800", "\uD68C\uC6D0"],
605
- profile: ["\uD504\uB85C\uD544"],
606
- password: ["\uBE44\uBC00\uBC88\uD638", "\uC554\uD638"],
607
- permission: ["\uAD8C\uD55C"],
608
- // 비즈니스
609
- attendance: ["\uCD9C\uC11D", "\uCD9C\uACB0"],
610
- check: ["\uCCB4\uD06C", "\uD655\uC778"],
611
- schedule: ["\uC2A4\uCF00\uC904", "\uC77C\uC815"],
612
- calendar: ["\uCE98\uB9B0\uB354", "\uB2EC\uB825"],
613
- notification: ["\uC54C\uB9BC", "\uD1B5\uC9C0"],
614
- message: ["\uBA54\uC2DC\uC9C0", "\uC54C\uB9BC"],
615
- setting: ["\uC124\uC815"],
616
- settings: ["\uC124\uC815"],
617
- payment: ["\uACB0\uC81C", "\uC9C0\uBD88"],
618
- order: ["\uC8FC\uBB38"],
619
- product: ["\uC0C1\uD488", "\uC81C\uD488"],
620
- cart: ["\uC7A5\uBC14\uAD6C\uB2C8"],
621
- checkout: ["\uACB0\uC81C", "\uCCB4\uD06C\uC544\uC6C3"],
622
- invoice: ["\uC1A1\uC7A5", "\uCCAD\uAD6C\uC11C"],
623
- report: ["\uB9AC\uD3EC\uD2B8", "\uBCF4\uACE0\uC11C"],
624
- dashboard: ["\uB300\uC2DC\uBCF4\uB4DC"],
625
- analytics: ["\uBD84\uC11D", "\uD1B5\uACC4"],
626
- statistics: ["\uD1B5\uACC4"],
627
- // 상태
628
- status: ["\uC0C1\uD0DC"],
629
- pending: ["\uB300\uAE30\uC911", "\uB300\uAE30"],
630
- active: ["\uD65C\uC131", "\uD65C\uC131\uD654"],
631
- inactive: ["\uBE44\uD65C\uC131", "\uBE44\uD65C\uC131\uD654"],
632
- completed: ["\uC644\uB8CC"],
633
- error: ["\uC5D0\uB7EC", "\uC624\uB958"],
634
- success: ["\uC131\uACF5"],
635
- loading: ["\uB85C\uB529", "\uB85C\uB4DC\uC911"],
636
- // 기타
637
- date: ["\uB0A0\uC9DC"],
638
- time: ["\uC2DC\uAC04"],
639
- image: ["\uC774\uBBF8\uC9C0", "\uC0AC\uC9C4"],
640
- file: ["\uD30C\uC77C"],
641
- upload: ["\uC5C5\uB85C\uB4DC", "\uC62C\uB9AC\uAE30"],
642
- download: ["\uB2E4\uC6B4\uB85C\uB4DC", "\uB0B4\uB824\uBC1B\uAE30"],
643
- export: ["\uB0B4\uBCF4\uB0B4\uAE30", "\uC775\uC2A4\uD3EC\uD2B8"],
644
- import: ["\uAC00\uC838\uC624\uAE30", "\uC784\uD3EC\uD2B8"],
645
- api: ["API", "\uC5D0\uC774\uD53C\uC544\uC774"],
646
- service: ["\uC11C\uBE44\uC2A4"],
647
- hook: ["\uD6C5"],
648
- component: ["\uCEF4\uD3EC\uB10C\uD2B8"],
649
- page: ["\uD398\uC774\uC9C0"],
650
- route: ["\uB77C\uC6B0\uD2B8", "\uACBD\uB85C"]
651
- };
652
- function findKoreanKeywords(englishKeyword) {
653
- const lower = englishKeyword.toLowerCase();
654
- if (KOREAN_KEYWORD_MAP[lower]) {
655
- return KOREAN_KEYWORD_MAP[lower];
656
- }
657
- const results = [];
658
- for (const [key, values] of Object.entries(KOREAN_KEYWORD_MAP)) {
659
- if (lower.includes(key) || key.includes(lower)) {
660
- results.push(...values);
661
- }
662
- }
663
- return [...new Set(results)];
664
- }
665
-
666
- // src/core/extractors/keyword-extractor.ts
667
- var KeywordExtractor = class {
668
- constructor(customKoreanMap) {
669
- this.customKoreanMap = customKoreanMap || {};
670
- }
671
- /**
672
- * 다양한 소스에서 키워드 추출
673
- */
674
- extract(name, path6, exports$1 = [], props = []) {
675
- const keywords = /* @__PURE__ */ new Set();
676
- this.extractFromName(name, keywords);
677
- this.extractFromPath(path6, keywords);
678
- for (const exportName of exports$1) {
679
- this.extractFromName(exportName, keywords);
680
- }
681
- for (const propName of props) {
682
- this.extractFromName(propName, keywords);
683
- }
684
- const allEnglishKeywords = [...keywords];
685
- for (const keyword of allEnglishKeywords) {
686
- const koreanKeywords = this.findKorean(keyword);
687
- koreanKeywords.forEach((k) => keywords.add(k));
688
- }
689
- return [...keywords].filter((k) => k.length > 1);
690
- }
691
- /**
692
- * 이름에서 키워드 추출
693
- */
694
- extractFromName(name, keywords) {
695
- keywords.add(name.toLowerCase());
696
- const camelParts = splitCamelCase(name);
697
- camelParts.forEach((part) => keywords.add(part.toLowerCase()));
698
- const pascalParts = splitPascalCase(name);
699
- pascalParts.forEach((part) => keywords.add(part.toLowerCase()));
700
- const snakeParts = splitSnakeCase(name);
701
- snakeParts.forEach((part) => keywords.add(part.toLowerCase()));
702
- const acronyms = extractAcronyms(name);
703
- acronyms.forEach((acr) => keywords.add(acr.toLowerCase()));
704
- }
705
- /**
706
- * 경로에서 키워드 추출
707
- */
708
- extractFromPath(path6, keywords) {
709
- const excludeNames = /* @__PURE__ */ new Set([
710
- "src",
711
- "app",
712
- "components",
713
- "hooks",
714
- "services",
715
- "lib",
716
- "utils",
717
- "pages",
718
- "api"
719
- ]);
720
- const segments = path6.replace(/\.[^/.]+$/, "").split("/").filter((s) => !excludeNames.has(s));
721
- for (const segment of segments) {
722
- this.extractFromName(segment, keywords);
723
- }
724
- }
725
- /**
726
- * 영어 키워드에 대응하는 한글 키워드 찾기
727
- */
728
- findKorean(englishKeyword) {
729
- const customMatch = this.customKoreanMap[englishKeyword.toLowerCase()];
730
- if (customMatch) {
731
- return customMatch;
732
- }
733
- return findKoreanKeywords(englishKeyword);
734
- }
735
- };
736
- var DependencyResolver = class {
737
- constructor(aliasMap = {}, extensions = [".ts", ".tsx", ".js", ".jsx"]) {
738
- this.aliasMap = new Map(Object.entries(aliasMap));
739
- this.extensions = extensions;
740
- }
741
- /**
742
- * import 경로를 실제 파일 경로로 해석
743
- */
744
- resolve(importSource, importerPath, rootDir) {
745
- if (this.isExternalPackage(importSource)) {
746
- return null;
747
- }
748
- const aliasResolved = this.resolveAlias(importSource);
749
- let targetPath;
750
- if (aliasResolved.startsWith("./") || aliasResolved.startsWith("../")) {
751
- const importerDir = path2__namespace.dirname(path2__namespace.resolve(rootDir, importerPath));
752
- targetPath = path2__namespace.resolve(importerDir, aliasResolved);
753
- } else if (aliasResolved !== importSource) {
754
- targetPath = path2__namespace.resolve(rootDir, aliasResolved);
755
- } else {
756
- return null;
757
- }
758
- const resolvedPath = this.resolveWithExtensions(targetPath);
759
- if (resolvedPath) {
760
- return path2__namespace.relative(rootDir, resolvedPath);
761
- }
762
- return null;
763
- }
764
- /**
765
- * 외부 패키지인지 확인
766
- */
767
- isExternalPackage(source) {
768
- if (source.startsWith("./") || source.startsWith("../")) {
769
- return false;
770
- }
771
- for (const alias of this.aliasMap.keys()) {
772
- if (source.startsWith(alias)) {
773
- return false;
774
- }
775
- }
776
- return true;
777
- }
778
- /**
779
- * alias 해석
780
- */
781
- resolveAlias(source) {
782
- for (const [alias, target] of this.aliasMap.entries()) {
783
- if (source === alias) {
784
- return target;
785
- }
786
- if (source.startsWith(alias + "/")) {
787
- return source.replace(alias, target);
788
- }
789
- }
790
- return source;
791
- }
792
- /**
793
- * 확장자를 추가하여 파일 경로 해석
794
- */
795
- resolveWithExtensions(targetPath) {
796
- if (fs__namespace.existsSync(targetPath)) {
797
- try {
798
- const stat = fs__namespace.statSync(targetPath);
799
- if (stat.isFile()) {
800
- return targetPath;
801
- }
802
- if (stat.isDirectory()) {
803
- return this.findIndexFile(targetPath);
804
- }
805
- } catch {
806
- }
807
- }
808
- for (const ext of this.extensions) {
809
- const withExt = targetPath + ext;
810
- if (fs__namespace.existsSync(withExt)) {
811
- return withExt;
812
- }
813
- }
814
- return this.findIndexFile(targetPath);
815
- }
816
- /**
817
- * 디렉토리에서 index 파일 찾기
818
- */
819
- findIndexFile(dirPath) {
820
- for (const ext of this.extensions) {
821
- const indexPath = path2__namespace.join(dirPath, `index${ext}`);
822
- if (fs__namespace.existsSync(indexPath)) {
823
- return indexPath;
824
- }
825
- }
826
- return null;
827
- }
828
- };
829
-
830
- // src/core/resolvers/call-graph-builder.ts
831
- var CallGraphBuilder = class {
832
- constructor(aliasMap) {
833
- const defaultAliases = {
834
- "@": "src",
835
- "@/": "src/",
836
- "~": "src",
837
- "~/": "src/"
838
- };
839
- this.resolver = new DependencyResolver({
840
- ...defaultAliases,
841
- ...aliasMap
842
- });
843
- }
844
- /**
845
- * 파싱된 파일들로부터 호출 그래프 구축
846
- */
847
- build(parsedFiles, rootDir) {
848
- const graph = /* @__PURE__ */ new Map();
849
- const filePathSet = new Set(parsedFiles.map((f) => f.path));
850
- for (const file of parsedFiles) {
851
- const calls = this.resolveCalls(file, rootDir, filePathSet);
852
- graph.set(file.path, {
853
- calls,
854
- calledBy: []
855
- });
856
- }
857
- for (const [filePath, entry] of graph.entries()) {
858
- for (const calledPath of entry.calls) {
859
- const calledEntry = graph.get(calledPath);
860
- if (calledEntry) {
861
- calledEntry.calledBy.push(filePath);
862
- }
863
- }
864
- }
865
- return graph;
866
- }
867
- /**
868
- * 파일이 호출하는 다른 파일들을 해석
869
- */
870
- resolveCalls(file, rootDir, validPaths) {
871
- const calls = [];
872
- for (const imp of file.imports) {
873
- if (imp.isTypeOnly) continue;
874
- const resolvedPath = this.resolver.resolve(
875
- imp.source,
876
- file.path,
877
- rootDir
878
- );
879
- if (resolvedPath && validPaths.has(resolvedPath)) {
880
- calls.push(resolvedPath);
881
- }
882
- }
883
- return [...new Set(calls)];
884
- }
885
- };
886
-
887
- // src/core/config.ts
888
- var DEFAULT_FILE_TYPE_MAPPING = {
889
- // Next.js App Router
890
- "app/**/page.tsx": "route",
891
- "app/**/page.ts": "route",
892
- "app/**/layout.tsx": "route",
893
- "app/**/layout.ts": "route",
894
- "app/**/route.tsx": "api",
895
- "app/**/route.ts": "api",
896
- "app/api/**/*.ts": "api",
897
- "app/api/**/*.tsx": "api",
898
- // Pages Router (레거시)
899
- "pages/**/*.tsx": "route",
900
- "pages/**/*.ts": "route",
901
- "pages/api/**/*.ts": "api",
902
- // Components
903
- "components/**/*.tsx": "component",
904
- "components/**/*.ts": "component",
905
- "src/components/**/*.tsx": "component",
906
- "src/components/**/*.ts": "component",
907
- // Hooks
908
- "hooks/**/*.ts": "hook",
909
- "hooks/**/*.tsx": "hook",
910
- "src/hooks/**/*.ts": "hook",
911
- "src/hooks/**/*.tsx": "hook",
912
- // Services
913
- "services/**/*.ts": "service",
914
- "src/services/**/*.ts": "service",
915
- // Utilities
916
- "lib/**/*.ts": "utility",
917
- "src/lib/**/*.ts": "utility",
918
- "utils/**/*.ts": "utility",
919
- "src/utils/**/*.ts": "utility",
920
- // Database
921
- "supabase/migrations/*.sql": "table",
922
- "prisma/migrations/**/*.sql": "table"
923
- };
924
- var DEFAULT_INCLUDE_PATTERNS = [
925
- "app/**/*.{ts,tsx}",
926
- "pages/**/*.{ts,tsx}",
927
- "components/**/*.{ts,tsx}",
928
- "hooks/**/*.{ts,tsx}",
929
- "services/**/*.ts",
930
- "lib/**/*.ts",
931
- "utils/**/*.ts",
932
- "src/**/*.{ts,tsx}",
933
- "supabase/migrations/*.sql"
934
- ];
935
- var DEFAULT_EXCLUDE_PATTERNS = [
936
- "**/node_modules/**",
937
- "**/.next/**",
938
- "**/dist/**",
939
- "**/*.test.{ts,tsx}",
940
- "**/*.spec.{ts,tsx}",
941
- "**/__tests__/**",
942
- "**/*.d.ts",
943
- "**/coverage/**"
944
- ];
945
- function createDefaultConfig(overrides = {}) {
946
- return {
947
- projectId: overrides.projectId || "default",
948
- include: overrides.include || DEFAULT_INCLUDE_PATTERNS,
949
- exclude: overrides.exclude || DEFAULT_EXCLUDE_PATTERNS,
950
- fileTypeMapping: {
951
- ...DEFAULT_FILE_TYPE_MAPPING,
952
- ...overrides.fileTypeMapping
953
- },
954
- output: {
955
- file: {
956
- enabled: true,
957
- path: "project-metadata.json",
958
- ...overrides.output?.file
959
- },
960
- api: {
961
- enabled: false,
962
- endpoint: "",
963
- ...overrides.output?.api
964
- }
965
- },
966
- koreanKeywords: overrides.koreanKeywords,
967
- mode: overrides.mode || "production",
968
- verbose: overrides.verbose || false
969
- };
970
- }
971
- function globToRegex(pattern) {
972
- const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/{{GLOBSTAR}}/g, ".*").replace(/\{([^}]+)\}/g, (_, group) => {
973
- const alternatives = group.split(",").map((s) => s.trim());
974
- return `(${alternatives.join("|")})`;
975
- });
976
- return new RegExp(`^${escaped}$`);
977
- }
978
- function generateId(projectId, filePath) {
979
- const input = `${projectId}:${filePath}`;
980
- return crypto__namespace.createHash("sha256").update(input).digest("hex").slice(0, 16);
981
- }
982
-
983
- // src/core/analyzer.ts
984
- var ProjectAnalyzer = class {
985
- constructor(config) {
986
- this.config = config;
987
- this.tsParser = new TypeScriptParser();
988
- this.sqlParser = new SQLParser();
989
- this.importExtractor = new ImportExtractor();
990
- this.exportExtractor = new ExportExtractor();
991
- this.propsExtractor = new PropsExtractor();
992
- this.keywordExtractor = new KeywordExtractor(config.koreanKeywords);
993
- this.callGraphBuilder = new CallGraphBuilder();
994
- }
995
- /**
996
- * 프로젝트 분석 실행
997
- */
998
- async analyze(rootDir) {
999
- const startTime = Date.now();
1000
- const parseErrors = [];
1001
- const files = await this.collectFiles(rootDir);
1002
- if (this.config.verbose) {
1003
- console.log(`[metadata-plugin] Found ${files.length} files to analyze`);
1004
- }
1005
- const parsedFiles = [];
1006
- for (const filePath of files) {
1007
- try {
1008
- const parsed = await this.parseFile(filePath, rootDir);
1009
- if (parsed) {
1010
- parsedFiles.push(parsed);
1011
- }
1012
- } catch (error) {
1013
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
1014
- parseErrors.push(`${filePath}: ${errorMessage}`);
1015
- }
1016
- }
1017
- const callGraph = this.callGraphBuilder.build(parsedFiles, rootDir);
1018
- const items = parsedFiles.map(
1019
- (parsed) => this.createIndexItem(parsed, callGraph)
1020
- );
1021
- const stats = this.calculateStats(items, parseErrors);
1022
- if (this.config.verbose) {
1023
- console.log(
1024
- `[metadata-plugin] Analysis completed in ${Date.now() - startTime}ms`
1025
- );
1026
- console.log(`[metadata-plugin] Processed ${items.length} items`);
1027
- }
1028
- return {
1029
- items,
1030
- stats,
1031
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1032
- };
1033
- }
1034
- /**
1035
- * 대상 파일 수집
1036
- */
1037
- async collectFiles(rootDir) {
1038
- const allFiles = [];
1039
- for (const pattern of this.config.include) {
1040
- const matches = await glob.glob(pattern, {
1041
- cwd: rootDir,
1042
- ignore: this.config.exclude,
1043
- absolute: true
1044
- });
1045
- allFiles.push(...matches);
1046
- }
1047
- return [...new Set(allFiles)];
1048
- }
1049
- /**
1050
- * 단일 파일 파싱
1051
- */
1052
- async parseFile(filePath, rootDir) {
1053
- const relativePath = path2__namespace.relative(rootDir, filePath);
1054
- const fileType = this.determineFileType(relativePath);
1055
- if (!fileType) {
1056
- return null;
1057
- }
1058
- const content = await fs4__namespace.readFile(filePath, "utf-8");
1059
- const ext = path2__namespace.extname(filePath);
1060
- if (ext === ".sql") {
1061
- return this.sqlParser.parse(content, relativePath);
1062
- }
1063
- const sourceFile = this.tsParser.parse(content, filePath);
1064
- const imports = this.importExtractor.extract(sourceFile);
1065
- const exports$1 = this.exportExtractor.extract(sourceFile);
1066
- const props = fileType === "component" ? this.propsExtractor.extract(sourceFile) : void 0;
1067
- return {
1068
- path: relativePath,
1069
- type: fileType,
1070
- name: this.extractName(relativePath, exports$1),
1071
- imports,
1072
- exports: exports$1,
1073
- props
1074
- };
1075
- }
1076
- /**
1077
- * 파일 타입 결정
1078
- */
1079
- determineFileType(relativePath) {
1080
- const sortedPatterns = Object.entries(this.config.fileTypeMapping).sort(
1081
- ([a], [b]) => b.length - a.length
1082
- );
1083
- for (const [pattern, type] of sortedPatterns) {
1084
- const regex = globToRegex(pattern);
1085
- if (regex.test(relativePath)) {
1086
- return type;
1087
- }
1088
- }
1089
- return null;
1090
- }
1091
- /**
1092
- * 파일/컴포넌트 이름 추출
1093
- */
1094
- extractName(relativePath, exports$1) {
1095
- const defaultExport = exports$1.find((e) => e.isDefault);
1096
- if (defaultExport && defaultExport.name !== "default") {
1097
- return defaultExport.name;
1098
- }
1099
- const basename4 = path2__namespace.basename(relativePath, path2__namespace.extname(relativePath));
1100
- if (["index", "page", "layout", "route"].includes(basename4)) {
1101
- const dirname4 = path2__namespace.dirname(relativePath);
1102
- const parentName = path2__namespace.basename(dirname4);
1103
- return parentName !== "." ? parentName : basename4;
1104
- }
1105
- return basename4;
1106
- }
1107
- /**
1108
- * CodeIndexItem 생성
1109
- */
1110
- createIndexItem(parsed, callGraph) {
1111
- const graphEntry = callGraph.get(parsed.path) || {
1112
- calls: [],
1113
- calledBy: []
1114
- };
1115
- const keywords = this.keywordExtractor.extract(
1116
- parsed.name,
1117
- parsed.path,
1118
- parsed.exports.map((e) => e.name),
1119
- parsed.props?.map((p) => p.name)
1120
- );
1121
- const searchText = this.buildSearchText(parsed, keywords);
1122
- return {
1123
- id: generateId(this.config.projectId, parsed.path),
1124
- projectId: this.config.projectId,
1125
- type: parsed.type,
1126
- name: parsed.name,
1127
- path: parsed.path,
1128
- keywords,
1129
- searchText,
1130
- calls: graphEntry.calls,
1131
- calledBy: graphEntry.calledBy,
1132
- metadata: {
1133
- exports: parsed.exports.map((e) => e.name),
1134
- props: parsed.props?.map((p) => p.name),
1135
- ...parsed.metadata
1136
- }
1137
- };
1138
- }
1139
- /**
1140
- * 검색용 텍스트 생성
1141
- */
1142
- buildSearchText(parsed, keywords) {
1143
- const parts = [
1144
- parsed.name,
1145
- parsed.path,
1146
- ...keywords,
1147
- ...parsed.exports.map((e) => e.name),
1148
- ...parsed.props?.map((p) => p.name) || []
1149
- ];
1150
- return parts.join(" ").toLowerCase();
1151
- }
1152
- /**
1153
- * 분석 통계 계산
1154
- */
1155
- calculateStats(items, parseErrors) {
1156
- const byType = {
1157
- route: 0,
1158
- component: 0,
1159
- hook: 0,
1160
- service: 0,
1161
- api: 0,
1162
- table: 0,
1163
- utility: 0
1164
- };
1165
- for (const item of items) {
1166
- byType[item.type]++;
1167
- }
1168
- return {
1169
- totalFiles: items.length,
1170
- byType,
1171
- parseErrors
1172
- };
1173
- }
1174
- };
1175
- var FileWriter = class {
1176
- constructor(config) {
1177
- this.config = config;
1178
- }
1179
- /**
1180
- * 분석 결과를 파일로 저장
1181
- */
1182
- async write(result, outputPath) {
1183
- const dir = path2__namespace.dirname(outputPath);
1184
- await fs4__namespace.mkdir(dir, { recursive: true });
1185
- const output = this.formatOutput(result);
1186
- await fs4__namespace.writeFile(outputPath, output, "utf-8");
1187
- }
1188
- /**
1189
- * 출력 형식 생성
1190
- */
1191
- formatOutput(result) {
1192
- const output = {
1193
- version: "1.0.0",
1194
- projectId: this.config.projectId,
1195
- generatedAt: result.timestamp,
1196
- stats: result.stats,
1197
- items: result.items
1198
- };
1199
- if (this.config.mode === "production") {
1200
- return JSON.stringify(output);
1201
- }
1202
- return JSON.stringify(output, null, 2);
1203
- }
1204
- };
1205
-
1206
- // src/core/output/api-sender.ts
1207
- var ApiSender = class {
1208
- constructor(config, options = {}) {
1209
- this.config = config;
1210
- this.maxRetries = options.maxRetries ?? 3;
1211
- this.retryDelay = options.retryDelay ?? 1e3;
1212
- }
1213
- /**
1214
- * 분석 결과를 API로 전송
1215
- */
1216
- async send(result) {
1217
- const apiConfig = this.config.output.api;
1218
- if (!apiConfig?.enabled || !apiConfig.endpoint) {
1219
- return;
1220
- }
1221
- const payload = {
1222
- projectId: this.config.projectId,
1223
- timestamp: result.timestamp,
1224
- items: result.items,
1225
- stats: result.stats
1226
- };
1227
- let lastError = null;
1228
- for (let attempt = 0; attempt < this.maxRetries; attempt++) {
1229
- try {
1230
- await this.sendRequest(
1231
- apiConfig.endpoint,
1232
- payload,
1233
- apiConfig.headers
1234
- );
1235
- return;
1236
- } catch (error) {
1237
- lastError = error instanceof Error ? error : new Error(String(error));
1238
- if (this.config.verbose) {
1239
- console.warn(
1240
- `[metadata-plugin] API send attempt ${attempt + 1} failed:`,
1241
- lastError.message
1242
- );
1243
- }
1244
- if (attempt < this.maxRetries - 1) {
1245
- await this.delay(this.retryDelay * (attempt + 1));
1246
- }
1247
- }
1248
- }
1249
- throw new Error(
1250
- `Failed to send metadata after ${this.maxRetries} attempts: ${lastError?.message}`
1251
- );
1252
- }
1253
- /**
1254
- * HTTP POST 요청
1255
- */
1256
- async sendRequest(endpoint, payload, headers) {
1257
- const response = await fetch(endpoint, {
1258
- method: "POST",
1259
- headers: {
1260
- "Content-Type": "application/json",
1261
- ...headers
1262
- },
1263
- body: JSON.stringify(payload)
1264
- });
1265
- if (!response.ok) {
1266
- const errorText = await response.text();
1267
- throw new Error(`API request failed: ${response.status} ${errorText}`);
1268
- }
1269
- }
1270
- /**
1271
- * 지연 함수
1272
- */
1273
- delay(ms) {
1274
- return new Promise((resolve3) => setTimeout(resolve3, ms));
1275
- }
1276
- };
1277
-
1278
- // src/cli.ts
1279
- var VERSION = "1.0.1";
1280
- var HELP_TEXT = `
2
+ 'use strict';var chunkBT3J264A_cjs=require('./chunk-BT3J264A.cjs'),util=require('util'),a=require('path'),r=require('fs/promises');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var a__namespace=/*#__PURE__*/_interopNamespace(a);var r__namespace=/*#__PURE__*/_interopNamespace(r);var v="1.0.1",b=`
1281
3
  metadatafy - \uD504\uB85C\uC81D\uD2B8 \uBA54\uD0C0\uB370\uC774\uD130 \uCD94\uCD9C \uB3C4\uAD6C
1282
4
 
1283
5
  Usage:
@@ -1295,8 +17,7 @@ Examples:
1295
17
  metadatafy analyze
1296
18
  metadatafy analyze --project-id my-project --output ./metadata.json
1297
19
  metadatafy init
1298
- `;
1299
- var ANALYZE_HELP = `
20
+ `,P=`
1300
21
  Usage: metadatafy analyze [options]
1301
22
 
1302
23
  Options:
@@ -1305,174 +26,9 @@ Options:
1305
26
  -c, --config <path> \uC124\uC815 \uD30C\uC77C \uACBD\uB85C
1306
27
  --verbose \uC0C1\uC138 \uB85C\uADF8 \uCD9C\uB825
1307
28
  -h, --help \uB3C4\uC6C0\uB9D0 \uD45C\uC2DC
1308
- `;
1309
- async function main() {
1310
- const args = process.argv.slice(2);
1311
- if (args.length === 0 || args[0] === "-h" || args[0] === "--help") {
1312
- console.log(HELP_TEXT);
1313
- process.exit(0);
1314
- }
1315
- if (args[0] === "-v" || args[0] === "--version") {
1316
- console.log(VERSION);
1317
- process.exit(0);
1318
- }
1319
- const command = args[0];
1320
- switch (command) {
1321
- case "analyze":
1322
- await runAnalyze(args.slice(1));
1323
- break;
1324
- case "init":
1325
- await runInit();
1326
- break;
1327
- default:
1328
- console.error(`Unknown command: ${command}`);
1329
- console.log(HELP_TEXT);
1330
- process.exit(1);
1331
- }
1332
- }
1333
- async function runAnalyze(args) {
1334
- const { values } = util.parseArgs({
1335
- args,
1336
- options: {
1337
- "project-id": { type: "string", short: "p" },
1338
- output: { type: "string", short: "o" },
1339
- config: { type: "string", short: "c" },
1340
- verbose: { type: "boolean" },
1341
- help: { type: "boolean", short: "h" }
1342
- }
1343
- });
1344
- if (values.help) {
1345
- console.log(ANALYZE_HELP);
1346
- process.exit(0);
1347
- }
1348
- const rootDir = process.cwd();
1349
- const projectId = values["project-id"] || path2__namespace.basename(rootDir);
1350
- const outputPath = values.output || "project-metadata.json";
1351
- const verbose = values.verbose || false;
1352
- let configFromFile = {};
1353
- if (values.config) {
1354
- try {
1355
- const configContent = await fs4__namespace.readFile(values.config, "utf-8");
1356
- configFromFile = JSON.parse(configContent);
1357
- } catch (error) {
1358
- console.error(`Failed to load config file: ${values.config}`);
1359
- process.exit(1);
1360
- }
1361
- } else {
1362
- const defaultConfigPath = path2__namespace.join(rootDir, "metadata.config.json");
1363
- try {
1364
- const configContent = await fs4__namespace.readFile(defaultConfigPath, "utf-8");
1365
- configFromFile = JSON.parse(configContent);
1366
- if (verbose) {
1367
- console.log(`Loaded config from ${defaultConfigPath}`);
1368
- }
1369
- } catch {
1370
- }
1371
- }
1372
- const config = createDefaultConfig({
1373
- ...configFromFile,
1374
- projectId,
1375
- verbose,
1376
- output: {
1377
- file: {
1378
- enabled: true,
1379
- path: outputPath
1380
- },
1381
- ...configFromFile.output
1382
- }
1383
- });
1384
- console.log(`
1385
- \u{1F4E6} Analyzing project: ${projectId}`);
1386
- console.log(`\u{1F4C1} Root directory: ${rootDir}
1387
- `);
1388
- const analyzer = new ProjectAnalyzer(config);
1389
- const fileWriter = new FileWriter(config);
1390
- try {
1391
- const startTime = Date.now();
1392
- const result = await analyzer.analyze(rootDir);
1393
- const duration = Date.now() - startTime;
1394
- const fullOutputPath = path2__namespace.resolve(rootDir, outputPath);
1395
- await fileWriter.write(result, fullOutputPath);
1396
- if (config.output.api?.enabled && config.output.api.endpoint) {
1397
- const apiSender = new ApiSender(config);
1398
- await apiSender.send(result);
1399
- console.log(`\u2601\uFE0F Sent to API: ${config.output.api.endpoint}`);
1400
- }
1401
- console.log(`\u2705 Analysis completed in ${duration}ms
1402
- `);
1403
- console.log(`\u{1F4CA} Results:`);
1404
- console.log(` Total files: ${result.stats.totalFiles}`);
1405
- console.log(` - Routes: ${result.stats.byType.route}`);
1406
- console.log(` - Components: ${result.stats.byType.component}`);
1407
- console.log(` - Hooks: ${result.stats.byType.hook}`);
1408
- console.log(` - Services: ${result.stats.byType.service}`);
1409
- console.log(` - APIs: ${result.stats.byType.api}`);
1410
- console.log(` - Tables: ${result.stats.byType.table}`);
1411
- console.log(` - Utilities: ${result.stats.byType.utility}`);
1412
- console.log(`
1413
- \u{1F4C4} Output: ${fullOutputPath}`);
1414
- if (result.stats.parseErrors.length > 0) {
1415
- console.log(`
1416
- \u26A0\uFE0F Parse errors (${result.stats.parseErrors.length}):`);
1417
- result.stats.parseErrors.slice(0, 5).forEach((err) => {
1418
- console.log(` - ${err}`);
1419
- });
1420
- if (result.stats.parseErrors.length > 5) {
1421
- console.log(` ... and ${result.stats.parseErrors.length - 5} more`);
1422
- }
1423
- }
1424
- console.log("");
1425
- } catch (error) {
1426
- console.error("\u274C Analysis failed:", error);
1427
- process.exit(1);
1428
- }
1429
- }
1430
- async function runInit() {
1431
- const rootDir = process.cwd();
1432
- const configPath = path2__namespace.join(rootDir, "metadata.config.json");
1433
- try {
1434
- await fs4__namespace.access(configPath);
1435
- console.log(`\u26A0\uFE0F Config file already exists: ${configPath}`);
1436
- process.exit(1);
1437
- } catch {
1438
- }
1439
- const defaultConfig = {
1440
- projectId: path2__namespace.basename(rootDir),
1441
- include: [
1442
- "app/**/*.{ts,tsx}",
1443
- "pages/**/*.{ts,tsx}",
1444
- "components/**/*.{ts,tsx}",
1445
- "hooks/**/*.{ts,tsx}",
1446
- "services/**/*.ts",
1447
- "lib/**/*.ts",
1448
- "src/**/*.{ts,tsx}"
1449
- ],
1450
- exclude: [
1451
- "**/node_modules/**",
1452
- "**/.next/**",
1453
- "**/dist/**",
1454
- "**/*.test.{ts,tsx}",
1455
- "**/*.spec.{ts,tsx}"
1456
- ],
1457
- output: {
1458
- file: {
1459
- enabled: true,
1460
- path: "project-metadata.json"
1461
- },
1462
- api: {
1463
- enabled: false,
1464
- endpoint: ""
1465
- }
1466
- },
1467
- koreanKeywords: {},
1468
- verbose: false
1469
- };
1470
- await fs4__namespace.writeFile(configPath, JSON.stringify(defaultConfig, null, 2));
1471
- console.log(`\u2705 Created config file: ${configPath}`);
1472
- }
1473
- main().catch((error) => {
1474
- console.error("Fatal error:", error);
1475
- process.exit(1);
1476
- });
1477
- //# sourceMappingURL=cli.cjs.map
1478
- //# sourceMappingURL=cli.cjs.map
29
+ `;async function E(){let e=process.argv.slice(2);(e.length===0||e[0]==="-h"||e[0]==="--help")&&(console.log(b),process.exit(0)),(e[0]==="-v"||e[0]==="--version")&&(console.log(v),process.exit(0));let t=e[0];switch(t){case "analyze":await T(e.slice(1));break;case "init":await A();break;default:console.error(`Unknown command: ${t}`),console.log(b),process.exit(1);}}async function T(e){let{values:t}=util.parseArgs({args:e,options:{"project-id":{type:"string",short:"p"},output:{type:"string",short:"o"},config:{type:"string",short:"c"},verbose:{type:"boolean"},help:{type:"boolean",short:"h"}}});t.help&&(console.log(P),process.exit(0));let n=process.cwd(),l=t["project-id"]||a__namespace.basename(n),p=t.output||"project-metadata.json",f=t.verbose||false,c={};if(t.config)try{let s=await r__namespace.readFile(t.config,"utf-8");c=JSON.parse(s);}catch{console.error(`Failed to load config file: ${t.config}`),process.exit(1);}else {let s=a__namespace.join(n,"metadata.config.json");try{let o=await r__namespace.readFile(s,"utf-8");c=JSON.parse(o),f&&console.log(`Loaded config from ${s}`);}catch{}}let i=chunkBT3J264A_cjs.d({...c,projectId:l,verbose:f,output:{file:{enabled:true,path:p},...c.output}});console.log(`
30
+ \u{1F4E6} Analyzing project: ${l}`),console.log(`\u{1F4C1} Root directory: ${n}
31
+ `);let w=new chunkBT3J264A_cjs.y(i),$=new chunkBT3J264A_cjs.z(i);try{let s=Date.now(),o=await w.analyze(n),j=Date.now()-s,g=a__namespace.resolve(n,p);await $.write(o,g),i.output.api?.enabled&&i.output.api.endpoint&&(await new chunkBT3J264A_cjs.A(i).send(o),console.log(`\u2601\uFE0F Sent to API: ${i.output.api.endpoint}`)),console.log(`\u2705 Analysis completed in ${j}ms
32
+ `),console.log("\u{1F4CA} Results:"),console.log(` Total files: ${o.stats.totalFiles}`),console.log(` - Routes: ${o.stats.byType.route}`),console.log(` - Components: ${o.stats.byType.component}`),console.log(` - Hooks: ${o.stats.byType.hook}`),console.log(` - Services: ${o.stats.byType.service}`),console.log(` - APIs: ${o.stats.byType.api}`),console.log(` - Tables: ${o.stats.byType.table}`),console.log(` - Utilities: ${o.stats.byType.utility}`),console.log(`
33
+ \u{1F4C4} Output: ${g}`),o.stats.parseErrors.length>0&&(console.log(`
34
+ \u26A0\uFE0F Parse errors (${o.stats.parseErrors.length}):`),o.stats.parseErrors.slice(0,5).forEach(d=>{console.log(` - ${d}`);}),o.stats.parseErrors.length>5&&console.log(` ... and ${o.stats.parseErrors.length-5} more`)),console.log("");}catch(s){console.error("\u274C Analysis failed:",s),process.exit(1);}}async function A(){let e=process.cwd(),t=a__namespace.join(e,"metadata.config.json");try{await r__namespace.access(t),console.log(`\u26A0\uFE0F Config file already exists: ${t}`),process.exit(1);}catch{}let n={projectId:a__namespace.basename(e),include:["app/**/*.{ts,tsx}","pages/**/*.{ts,tsx}","components/**/*.{ts,tsx}","hooks/**/*.{ts,tsx}","services/**/*.ts","lib/**/*.ts","src/**/*.{ts,tsx}"],exclude:["**/node_modules/**","**/.next/**","**/dist/**","**/*.test.{ts,tsx}","**/*.spec.{ts,tsx}"],output:{file:{enabled:true,path:"project-metadata.json"},api:{enabled:false,endpoint:""}},koreanKeywords:{},verbose:false};await r__namespace.writeFile(t,JSON.stringify(n,null,2)),console.log(`\u2705 Created config file: ${t}`);}E().catch(e=>{console.error("Fatal error:",e),process.exit(1);});