jsx-prop-lookup-mcp-server 1.0.0 → 1.0.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 +66 -1
- package/dist/index.js +57 -3
- package/dist/index.js.map +1 -1
- package/dist/jsx-analyzer.d.ts +14 -0
- package/dist/jsx-analyzer.d.ts.map +1 -1
- package/dist/jsx-analyzer.js +87 -0
- package/dist/jsx-analyzer.js.map +1 -1
- package/package.json +12 -2
- package/PUBLISH.md +0 -53
- package/RELEASE_NOTES.md +0 -38
- package/USAGE.md +0 -66
- package/examples/sample-components/App.tsx +0 -52
- package/examples/sample-components/Button.tsx +0 -31
- package/examples/sample-components/Card.tsx +0 -32
- package/mcp-config.json +0 -9
- package/src/index.ts +0 -183
- package/src/jsx-analyzer.ts +0 -361
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -12,14 +12,31 @@ An MCP (Model Context Protocol) server that analyzes JSX prop usage in React/Typ
|
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
+
### Option 1: Use with npx (Recommended)
|
|
16
|
+
No installation required! Use directly with npx:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx jsx-prop-lookup-mcp-server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Option 2: Install Globally
|
|
15
23
|
```bash
|
|
24
|
+
npm install -g jsx-prop-lookup-mcp-server
|
|
25
|
+
jsx-prop-lookup-mcp-server
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Option 3: Development Setup
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/your-username/jsx-prop-lookup-mcp-server.git
|
|
31
|
+
cd jsx-prop-lookup-mcp-server
|
|
16
32
|
npm install
|
|
17
33
|
npm run build
|
|
34
|
+
npm start
|
|
18
35
|
```
|
|
19
36
|
|
|
20
37
|
## Usage
|
|
21
38
|
|
|
22
|
-
The server provides
|
|
39
|
+
The server provides four main tools:
|
|
23
40
|
|
|
24
41
|
### 1. `analyze_jsx_props`
|
|
25
42
|
Analyze JSX prop usage in files or directories.
|
|
@@ -45,6 +62,14 @@ Get all props used by a specific component.
|
|
|
45
62
|
- `componentName` (required): Name of the component to analyze
|
|
46
63
|
- `directory` (optional): Directory to search in (default: ".")
|
|
47
64
|
|
|
65
|
+
### 4. `find_components_without_prop`
|
|
66
|
+
Find component instances that are missing a required prop (e.g., Select components without width prop).
|
|
67
|
+
|
|
68
|
+
**Parameters:**
|
|
69
|
+
- `componentName` (required): Name of the component to check (e.g., "Select")
|
|
70
|
+
- `requiredProp` (required): Name of the required prop (e.g., "width")
|
|
71
|
+
- `directory` (optional): Directory to search in (default: ".")
|
|
72
|
+
|
|
48
73
|
## Example Output
|
|
49
74
|
|
|
50
75
|
```json
|
|
@@ -90,6 +115,46 @@ Get all props used by a specific component.
|
|
|
90
115
|
- `.ts` - TypeScript
|
|
91
116
|
- `.tsx` - TypeScript with JSX
|
|
92
117
|
|
|
118
|
+
## MCP Client Configuration
|
|
119
|
+
|
|
120
|
+
### Using with npx (Recommended)
|
|
121
|
+
Add to your MCP client configuration:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"mcpServers": {
|
|
126
|
+
"jsx-prop-lookup": {
|
|
127
|
+
"command": "npx",
|
|
128
|
+
"args": ["jsx-prop-lookup-mcp-server"]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Using with global installation
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"jsx-prop-lookup": {
|
|
139
|
+
"command": "jsx-prop-lookup-mcp-server"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Using with local development
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"mcpServers": {
|
|
149
|
+
"jsx-prop-lookup": {
|
|
150
|
+
"command": "node",
|
|
151
|
+
"args": ["dist/index.js"],
|
|
152
|
+
"cwd": "/path/to/jsx-prop-lookup-mcp-server"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
93
158
|
## Development
|
|
94
159
|
|
|
95
160
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// Ensure we're using the correct Node.js version
|
|
3
|
+
if (process.version.split('.')[0].slice(1) < '18') {
|
|
4
|
+
console.error('Error: Node.js 18 or higher is required');
|
|
5
|
+
process.exit(1);
|
|
6
|
+
}
|
|
2
7
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
8
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
9
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -84,6 +89,29 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
84
89
|
required: ['componentName'],
|
|
85
90
|
},
|
|
86
91
|
},
|
|
92
|
+
{
|
|
93
|
+
name: 'find_components_without_prop',
|
|
94
|
+
description: 'Find component instances that are missing a required prop (e.g., Select components without width prop)',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
componentName: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Name of the component to check (e.g., "Select")',
|
|
101
|
+
},
|
|
102
|
+
requiredProp: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Name of the required prop (e.g., "width")',
|
|
105
|
+
},
|
|
106
|
+
directory: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Directory to search in',
|
|
109
|
+
default: '.',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
required: ['componentName', 'requiredProp'],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
87
115
|
],
|
|
88
116
|
};
|
|
89
117
|
});
|
|
@@ -128,6 +156,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
128
156
|
],
|
|
129
157
|
};
|
|
130
158
|
}
|
|
159
|
+
case 'find_components_without_prop': {
|
|
160
|
+
const result = await analyzer.findComponentsWithoutProp(args.componentName, args.requiredProp, args.directory ?? '.');
|
|
161
|
+
return {
|
|
162
|
+
content: [
|
|
163
|
+
{
|
|
164
|
+
type: 'text',
|
|
165
|
+
text: JSON.stringify(result, null, 2),
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
131
170
|
default:
|
|
132
171
|
throw new Error(`Unknown tool: ${name}`);
|
|
133
172
|
}
|
|
@@ -145,10 +184,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
145
184
|
}
|
|
146
185
|
});
|
|
147
186
|
async function main() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
187
|
+
try {
|
|
188
|
+
const transport = new StdioServerTransport();
|
|
189
|
+
await server.connect(transport);
|
|
190
|
+
console.error('JSX Prop Lookup MCP Server running on stdio');
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
console.error('Failed to start MCP server:', error);
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
151
196
|
}
|
|
197
|
+
// Handle process signals gracefully
|
|
198
|
+
process.on('SIGINT', () => {
|
|
199
|
+
console.error('Received SIGINT, shutting down gracefully...');
|
|
200
|
+
process.exit(0);
|
|
201
|
+
});
|
|
202
|
+
process.on('SIGTERM', () => {
|
|
203
|
+
console.error('Received SIGTERM, shutting down gracefully...');
|
|
204
|
+
process.exit(0);
|
|
205
|
+
});
|
|
152
206
|
main().catch((error) => {
|
|
153
207
|
console.error('Server error:', error);
|
|
154
208
|
process.exit(1);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.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H,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,oCAAoC;AACpC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/jsx-analyzer.d.ts
CHANGED
|
@@ -28,6 +28,20 @@ export declare class JSXPropAnalyzer {
|
|
|
28
28
|
analyzeProps(path: string, componentName?: string, propName?: string, includeTypes?: boolean): Promise<AnalysisResult>;
|
|
29
29
|
findPropUsage(propName: string, directory?: string, componentName?: string): Promise<PropUsage[]>;
|
|
30
30
|
getComponentProps(componentName: string, directory?: string): Promise<ComponentAnalysis[]>;
|
|
31
|
+
findComponentsWithoutProp(componentName: string, requiredProp: string, directory?: string): Promise<{
|
|
32
|
+
missingPropUsages: Array<{
|
|
33
|
+
componentName: string;
|
|
34
|
+
file: string;
|
|
35
|
+
line: number;
|
|
36
|
+
column: number;
|
|
37
|
+
existingProps: string[];
|
|
38
|
+
}>;
|
|
39
|
+
summary: {
|
|
40
|
+
totalInstances: number;
|
|
41
|
+
missingPropCount: number;
|
|
42
|
+
missingPropPercentage: number;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
31
45
|
private getFiles;
|
|
32
46
|
private analyzeFile;
|
|
33
47
|
private findPropsInFunctionBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-analyzer.d.ts","sourceRoot":"","sources":["../src/jsx-analyzer.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;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IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,YAAY,GAAE,OAAc,GAC3B,OAAO,CAAC,cAAc,CAAC;IA0BpB,aAAa,CACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAY,EACvB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,SAAS,EAAE,CAAC;IAKjB,iBAAiB,CACrB,aAAa,EAAE,MAAM,EACrB,SAAS,GAAE,MAAY,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAKzB,yBAAyB,CAC7B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,MAAY,GACtB,OAAO,CAAC;QACT,iBAAiB,EAAE,KAAK,CAAC;YACvB,aAAa,EAAE,MAAM,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;YACf,aAAa,EAAE,MAAM,EAAE,CAAC;SACzB,CAAC,CAAC;QACH,OAAO,EAAE;YACP,cAAc,EAAE,MAAM,CAAC;YACvB,gBAAgB,EAAE,MAAM,CAAC;YACzB,qBAAqB,EAAE,MAAM,CAAC;SAC/B,CAAC;KACH,CAAC;YAkGY,QAAQ;YAmBR,WAAW;IAuHzB,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,oBAAoB;IAyC5B,OAAO,CAAC,iBAAiB;CA+D1B"}
|
package/dist/jsx-analyzer.js
CHANGED
|
@@ -39,6 +39,93 @@ export class JSXPropAnalyzer {
|
|
|
39
39
|
const result = await this.analyzeProps(directory, componentName);
|
|
40
40
|
return result.components.filter(comp => comp.componentName === componentName);
|
|
41
41
|
}
|
|
42
|
+
async findComponentsWithoutProp(componentName, requiredProp, directory = '.') {
|
|
43
|
+
const files = await this.getFiles(directory);
|
|
44
|
+
const missingPropUsages = [];
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
try {
|
|
47
|
+
const content = readFileSync(file, 'utf-8');
|
|
48
|
+
let ast;
|
|
49
|
+
try {
|
|
50
|
+
ast = parse(content, {
|
|
51
|
+
sourceType: 'module',
|
|
52
|
+
plugins: [
|
|
53
|
+
'jsx',
|
|
54
|
+
'typescript',
|
|
55
|
+
'decorators-legacy',
|
|
56
|
+
'classProperties',
|
|
57
|
+
'objectRestSpread',
|
|
58
|
+
'functionBind',
|
|
59
|
+
'exportDefaultFrom',
|
|
60
|
+
'exportNamespaceFrom',
|
|
61
|
+
'dynamicImport',
|
|
62
|
+
'nullishCoalescingOperator',
|
|
63
|
+
'optionalChaining',
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error(`Failed to parse ${file}:`, error);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const traverseDefault = traverse.default || traverse;
|
|
72
|
+
traverseDefault(ast, {
|
|
73
|
+
JSXElement: (path) => {
|
|
74
|
+
const openingElement = path.node.openingElement;
|
|
75
|
+
if (!t.isJSXIdentifier(openingElement.name))
|
|
76
|
+
return;
|
|
77
|
+
const elementName = openingElement.name.name;
|
|
78
|
+
if (elementName !== componentName)
|
|
79
|
+
return;
|
|
80
|
+
// Get all props for this element
|
|
81
|
+
const existingProps = [];
|
|
82
|
+
let hasRequiredProp = false;
|
|
83
|
+
for (const attribute of openingElement.attributes) {
|
|
84
|
+
if (t.isJSXAttribute(attribute) && t.isJSXIdentifier(attribute.name)) {
|
|
85
|
+
const propName = attribute.name.name;
|
|
86
|
+
existingProps.push(propName);
|
|
87
|
+
if (propName === requiredProp) {
|
|
88
|
+
hasRequiredProp = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (t.isJSXSpreadAttribute(attribute)) {
|
|
92
|
+
existingProps.push('...spread');
|
|
93
|
+
// Note: We can't determine if spread contains the required prop
|
|
94
|
+
// so we'll assume it might and not flag this as missing
|
|
95
|
+
hasRequiredProp = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// If the required prop is missing, record this usage
|
|
99
|
+
if (!hasRequiredProp) {
|
|
100
|
+
const loc = openingElement.loc;
|
|
101
|
+
missingPropUsages.push({
|
|
102
|
+
componentName: elementName,
|
|
103
|
+
file,
|
|
104
|
+
line: loc?.start.line || 0,
|
|
105
|
+
column: loc?.start.column || 0,
|
|
106
|
+
existingProps,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.error(`Error analyzing file ${file}:`, error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Calculate summary statistics
|
|
117
|
+
const totalInstances = missingPropUsages.length;
|
|
118
|
+
const missingPropCount = missingPropUsages.length;
|
|
119
|
+
const missingPropPercentage = totalInstances > 0 ? (missingPropCount / totalInstances) * 100 : 0;
|
|
120
|
+
return {
|
|
121
|
+
missingPropUsages,
|
|
122
|
+
summary: {
|
|
123
|
+
totalInstances,
|
|
124
|
+
missingPropCount,
|
|
125
|
+
missingPropPercentage,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
42
129
|
async getFiles(path) {
|
|
43
130
|
try {
|
|
44
131
|
const stat = statSync(path);
|
package/dist/jsx-analyzer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-analyzer.js","sourceRoot":"","sources":["../src/jsx-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,aAAa;AACb,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAA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AAU,CAAC,EAAE,CAAC;4BACtC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC;wBACjC,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;gBAC1B,MAAM,SAAS,GAAc;oBAC3B,QAAQ;oBACR,aAAa;oBACb,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;oBAC1B,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC;oBAC9B,KAAK;iBACN,CAAC;gBAEF,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;iBAAM,IAAI,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC7C,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;gBAC1B,MAAM,SAAS,GAAc;oBAC3B,QAAQ,EAAE,WAAW;oBACrB,aAAa;oBACb,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;oBAC1B,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC;oBAC9B,QAAQ,EAAE,IAAI;iBACf,CAAC;gBAEF,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsx-prop-lookup-mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MCP server for analyzing JSX prop usage using AST",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,8 +18,18 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc",
|
|
20
20
|
"start": "node dist/index.js",
|
|
21
|
-
"dev": "tsx src/index.ts"
|
|
21
|
+
"dev": "tsx src/index.ts",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
22
23
|
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"jsx-prop-lookup-mcp-server": "dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"package.json"
|
|
32
|
+
],
|
|
23
33
|
"dependencies": {
|
|
24
34
|
"@modelcontextprotocol/sdk": "^0.4.0",
|
|
25
35
|
"@babel/parser": "^7.23.0",
|
package/PUBLISH.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Publishing Guide
|
|
2
|
-
|
|
3
|
-
## Git Repository Setup
|
|
4
|
-
|
|
5
|
-
1. **Create GitHub repository:**
|
|
6
|
-
```bash
|
|
7
|
-
# Go to GitHub and create a new repository named: jsx-prop-lookup-mcp-server
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
2. **Add remote and push:**
|
|
11
|
-
```bash
|
|
12
|
-
git remote add origin https://github.com/YOUR_USERNAME/jsx-prop-lookup-mcp-server.git
|
|
13
|
-
git branch -M main
|
|
14
|
-
git push -u origin main
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## NPM Publishing
|
|
18
|
-
|
|
19
|
-
1. **Login to NPM:**
|
|
20
|
-
```bash
|
|
21
|
-
npm login
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
2. **Update package.json with your GitHub username:**
|
|
25
|
-
- Replace `your-username` in the repository URLs with your actual GitHub username
|
|
26
|
-
|
|
27
|
-
3. **Publish to NPM:**
|
|
28
|
-
```bash
|
|
29
|
-
npm publish
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## MCP Registry (Optional)
|
|
33
|
-
|
|
34
|
-
Consider submitting to the MCP server registry once it's available.
|
|
35
|
-
|
|
36
|
-
## Post-Publishing
|
|
37
|
-
|
|
38
|
-
1. **Update README with installation instructions:**
|
|
39
|
-
```bash
|
|
40
|
-
npm install -g jsx-prop-lookup-mcp-server
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
2. **Create GitHub release:**
|
|
44
|
-
- Tag version v1.0.0
|
|
45
|
-
- Include release notes
|
|
46
|
-
|
|
47
|
-
## Current Status
|
|
48
|
-
|
|
49
|
-
✅ Code committed to git
|
|
50
|
-
✅ Built successfully
|
|
51
|
-
✅ Ready for publishing
|
|
52
|
-
|
|
53
|
-
**Next steps:** Update GitHub username in package.json and push to your repository!
|
package/RELEASE_NOTES.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Release Notes
|
|
2
|
-
|
|
3
|
-
## v1.0.0 - Initial Release
|
|
4
|
-
|
|
5
|
-
### Features
|
|
6
|
-
- ✅ **Complete MCP Server** for JSX prop analysis using AST parsing
|
|
7
|
-
- ✅ **Three Analysis Tools**:
|
|
8
|
-
- `analyze_jsx_props` - Comprehensive prop analysis
|
|
9
|
-
- `find_prop_usage` - Search specific prop usage
|
|
10
|
-
- `get_component_props` - Extract component props
|
|
11
|
-
- ✅ **React/TypeScript Support** - Full JSX/TSX parsing
|
|
12
|
-
- ✅ **Babel AST Parser** - Accurate code analysis
|
|
13
|
-
- ✅ **TypeScript Interface Detection** - Prop type information
|
|
14
|
-
- ✅ **Spread Operator Handling** - `...rest` and `...spread` props
|
|
15
|
-
- ✅ **Location Tracking** - Line/column information for all findings
|
|
16
|
-
- ✅ **Prop Value Extraction** - String literals, expressions, identifiers
|
|
17
|
-
|
|
18
|
-
### Technical Details
|
|
19
|
-
- Built with MCP SDK v0.4.0
|
|
20
|
-
- Babel parser with comprehensive plugin support
|
|
21
|
-
- TypeScript compilation target: ES2022
|
|
22
|
-
- Node.js ESM modules
|
|
23
|
-
|
|
24
|
-
### Tested With
|
|
25
|
-
- React functional components
|
|
26
|
-
- TypeScript interfaces
|
|
27
|
-
- Arrow functions and function declarations
|
|
28
|
-
- JSX prop destructuring
|
|
29
|
-
- Spread operators
|
|
30
|
-
- Complex component hierarchies
|
|
31
|
-
|
|
32
|
-
### Ready For
|
|
33
|
-
- Production use
|
|
34
|
-
- Integration with MCP clients
|
|
35
|
-
- Large React codebases
|
|
36
|
-
- Development tooling
|
|
37
|
-
|
|
38
|
-
**Installation:** `npm install jsx-prop-lookup-mcp-server`
|
package/USAGE.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# JSX Prop Lookup MCP Server Usage Guide
|
|
2
|
-
|
|
3
|
-
## Quick Start
|
|
4
|
-
|
|
5
|
-
1. **Install dependencies:**
|
|
6
|
-
```bash
|
|
7
|
-
npm install
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
2. **Build the server:**
|
|
11
|
-
```bash
|
|
12
|
-
npm run build
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
3. **Test the server:**
|
|
16
|
-
```bash
|
|
17
|
-
npm start
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Example Usage
|
|
21
|
-
|
|
22
|
-
The server successfully analyzes JSX prop usage as demonstrated with the sample components:
|
|
23
|
-
|
|
24
|
-
### Sample Analysis Results
|
|
25
|
-
|
|
26
|
-
**Button Component Props:**
|
|
27
|
-
- `children`, `onClick`, `disabled`, `variant`, `className`, `...rest`
|
|
28
|
-
- Includes TypeScript interface: `ButtonProps`
|
|
29
|
-
|
|
30
|
-
**onClick Prop Usage Found:**
|
|
31
|
-
- Button component definition (parameter destructuring)
|
|
32
|
-
- Button JSX element usage in App component
|
|
33
|
-
- Native button element in Button component
|
|
34
|
-
|
|
35
|
-
**Key Features Demonstrated:**
|
|
36
|
-
- ✅ AST-based parsing of JSX/TSX files
|
|
37
|
-
- ✅ Component prop extraction from function parameters
|
|
38
|
-
- ✅ JSX element prop usage tracking
|
|
39
|
-
- ✅ TypeScript interface detection
|
|
40
|
-
- ✅ Spread operator handling
|
|
41
|
-
- ✅ Line/column location tracking
|
|
42
|
-
- ✅ Prop value extraction (strings, expressions)
|
|
43
|
-
|
|
44
|
-
## MCP Integration
|
|
45
|
-
|
|
46
|
-
Add to your MCP client configuration:
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"mcpServers": {
|
|
51
|
-
"jsx-prop-lookup": {
|
|
52
|
-
"command": "node",
|
|
53
|
-
"args": ["dist/index.js"],
|
|
54
|
-
"cwd": "/path/to/jsx-prop-lookup-mcp-server"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Available Tools
|
|
61
|
-
|
|
62
|
-
1. **analyze_jsx_props** - Comprehensive analysis of JSX props in files/directories
|
|
63
|
-
2. **find_prop_usage** - Find specific prop usage across codebase
|
|
64
|
-
3. **get_component_props** - Get all props for a specific component
|
|
65
|
-
|
|
66
|
-
The server is ready for production use!
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import Button from './Button';
|
|
3
|
-
import Card from './Card';
|
|
4
|
-
|
|
5
|
-
const App: React.FC = () => {
|
|
6
|
-
const [count, setCount] = useState(0);
|
|
7
|
-
|
|
8
|
-
const handleIncrement = () => {
|
|
9
|
-
setCount(prev => prev + 1);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const handleReset = () => {
|
|
13
|
-
setCount(0);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div className="app">
|
|
18
|
-
<h1>Counter App</h1>
|
|
19
|
-
|
|
20
|
-
<Card title="Counter" className="counter-card">
|
|
21
|
-
<p>Current count: {count}</p>
|
|
22
|
-
|
|
23
|
-
<div className="button-group">
|
|
24
|
-
<Button
|
|
25
|
-
onClick={handleIncrement}
|
|
26
|
-
variant="primary"
|
|
27
|
-
className="increment-btn"
|
|
28
|
-
>
|
|
29
|
-
Increment
|
|
30
|
-
</Button>
|
|
31
|
-
|
|
32
|
-
<Button
|
|
33
|
-
onClick={handleReset}
|
|
34
|
-
variant="secondary"
|
|
35
|
-
disabled={count === 0}
|
|
36
|
-
>
|
|
37
|
-
Reset
|
|
38
|
-
</Button>
|
|
39
|
-
</div>
|
|
40
|
-
</Card>
|
|
41
|
-
|
|
42
|
-
<Card title="Info">
|
|
43
|
-
<p>This is a sample React application.</p>
|
|
44
|
-
<Button variant="primary">
|
|
45
|
-
Learn More
|
|
46
|
-
</Button>
|
|
47
|
-
</Card>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default App;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
interface ButtonProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
onClick?: () => void;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
variant?: 'primary' | 'secondary';
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Button: React.FC<ButtonProps> = ({
|
|
12
|
-
children,
|
|
13
|
-
onClick,
|
|
14
|
-
disabled = false,
|
|
15
|
-
variant = 'primary',
|
|
16
|
-
className,
|
|
17
|
-
...rest
|
|
18
|
-
}) => {
|
|
19
|
-
return (
|
|
20
|
-
<button
|
|
21
|
-
className={`btn btn-${variant} ${className || ''}`}
|
|
22
|
-
onClick={onClick}
|
|
23
|
-
disabled={disabled}
|
|
24
|
-
{...rest}
|
|
25
|
-
>
|
|
26
|
-
{children}
|
|
27
|
-
</button>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default Button;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
interface CardProps {
|
|
4
|
-
title?: string;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
className?: string;
|
|
7
|
-
footer?: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const Card: React.FC<CardProps> = ({ title, children, className, footer }) => {
|
|
11
|
-
return (
|
|
12
|
-
<div className={`card ${className || ''}`}>
|
|
13
|
-
{title && (
|
|
14
|
-
<div className="card-header">
|
|
15
|
-
<h3>{title}</h3>
|
|
16
|
-
</div>
|
|
17
|
-
)}
|
|
18
|
-
|
|
19
|
-
<div className="card-body">
|
|
20
|
-
{children}
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
{footer && (
|
|
24
|
-
<div className="card-footer">
|
|
25
|
-
{footer}
|
|
26
|
-
</div>
|
|
27
|
-
)}
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default Card;
|
package/mcp-config.json
DELETED
package/src/index.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
-
import {
|
|
6
|
-
CallToolRequestSchema,
|
|
7
|
-
ListToolsRequestSchema,
|
|
8
|
-
} from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
-
import { JSXPropAnalyzer } from './jsx-analyzer.js';
|
|
10
|
-
|
|
11
|
-
const server = new Server(
|
|
12
|
-
{
|
|
13
|
-
name: 'jsx-prop-lookup-server',
|
|
14
|
-
version: '1.0.0',
|
|
15
|
-
capabilities: {
|
|
16
|
-
tools: {},
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const analyzer = new JSXPropAnalyzer();
|
|
22
|
-
|
|
23
|
-
// List available tools
|
|
24
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
25
|
-
return {
|
|
26
|
-
tools: [
|
|
27
|
-
{
|
|
28
|
-
name: 'analyze_jsx_props',
|
|
29
|
-
description: 'Analyze JSX prop usage in files or directories',
|
|
30
|
-
inputSchema: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
path: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
description: 'File or directory path to analyze',
|
|
36
|
-
},
|
|
37
|
-
componentName: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
description: 'Optional: specific component name to analyze',
|
|
40
|
-
},
|
|
41
|
-
propName: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
description: 'Optional: specific prop name to search for',
|
|
44
|
-
},
|
|
45
|
-
includeTypes: {
|
|
46
|
-
type: 'boolean',
|
|
47
|
-
description: 'Include TypeScript type information',
|
|
48
|
-
default: true,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
required: ['path'],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'find_prop_usage',
|
|
56
|
-
description: 'Find all usages of a specific prop across JSX files',
|
|
57
|
-
inputSchema: {
|
|
58
|
-
type: 'object',
|
|
59
|
-
properties: {
|
|
60
|
-
propName: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
description: 'Name of the prop to search for',
|
|
63
|
-
},
|
|
64
|
-
directory: {
|
|
65
|
-
type: 'string',
|
|
66
|
-
description: 'Directory to search in',
|
|
67
|
-
default: '.',
|
|
68
|
-
},
|
|
69
|
-
componentName: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
description: 'Optional: limit search to specific component',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
required: ['propName'],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'get_component_props',
|
|
79
|
-
description: 'Get all props used by a specific component',
|
|
80
|
-
inputSchema: {
|
|
81
|
-
type: 'object',
|
|
82
|
-
properties: {
|
|
83
|
-
componentName: {
|
|
84
|
-
type: 'string',
|
|
85
|
-
description: 'Name of the component to analyze',
|
|
86
|
-
},
|
|
87
|
-
directory: {
|
|
88
|
-
type: 'string',
|
|
89
|
-
description: 'Directory to search in',
|
|
90
|
-
default: '.',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
required: ['componentName'],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Handle tool calls
|
|
101
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
102
|
-
const { name, arguments: args } = request.params;
|
|
103
|
-
|
|
104
|
-
if (!args) {
|
|
105
|
-
throw new Error('Missing arguments');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
switch (name) {
|
|
110
|
-
case 'analyze_jsx_props': {
|
|
111
|
-
const result = await analyzer.analyzeProps(
|
|
112
|
-
args.path as string,
|
|
113
|
-
args.componentName as string | undefined,
|
|
114
|
-
args.propName as string | undefined,
|
|
115
|
-
(args.includeTypes as boolean) ?? true
|
|
116
|
-
);
|
|
117
|
-
return {
|
|
118
|
-
content: [
|
|
119
|
-
{
|
|
120
|
-
type: 'text',
|
|
121
|
-
text: JSON.stringify(result, null, 2),
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
case 'find_prop_usage': {
|
|
128
|
-
const result = await analyzer.findPropUsage(
|
|
129
|
-
args.propName as string,
|
|
130
|
-
(args.directory as string) ?? '.',
|
|
131
|
-
args.componentName as string | undefined
|
|
132
|
-
);
|
|
133
|
-
return {
|
|
134
|
-
content: [
|
|
135
|
-
{
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: JSON.stringify(result, null, 2),
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
case 'get_component_props': {
|
|
144
|
-
const result = await analyzer.getComponentProps(
|
|
145
|
-
args.componentName as string,
|
|
146
|
-
(args.directory as string) ?? '.'
|
|
147
|
-
);
|
|
148
|
-
return {
|
|
149
|
-
content: [
|
|
150
|
-
{
|
|
151
|
-
type: 'text',
|
|
152
|
-
text: JSON.stringify(result, null, 2),
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
default:
|
|
159
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
160
|
-
}
|
|
161
|
-
} catch (error) {
|
|
162
|
-
return {
|
|
163
|
-
content: [
|
|
164
|
-
{
|
|
165
|
-
type: 'text',
|
|
166
|
-
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
isError: true,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
async function main() {
|
|
175
|
-
const transport = new StdioServerTransport();
|
|
176
|
-
await server.connect(transport);
|
|
177
|
-
console.error('JSX Prop Lookup MCP Server running on stdio');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
main().catch((error) => {
|
|
181
|
-
console.error('Server error:', error);
|
|
182
|
-
process.exit(1);
|
|
183
|
-
});
|
package/src/jsx-analyzer.ts
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { parse } from '@babel/parser';
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import traverse from '@babel/traverse';
|
|
4
|
-
import * as t from '@babel/types';
|
|
5
|
-
import { readFileSync, statSync } from 'fs';
|
|
6
|
-
import { glob } from 'glob';
|
|
7
|
-
import { join, extname } from 'path';
|
|
8
|
-
|
|
9
|
-
export interface PropUsage {
|
|
10
|
-
propName: string;
|
|
11
|
-
componentName: string;
|
|
12
|
-
file: string;
|
|
13
|
-
line: number;
|
|
14
|
-
column: number;
|
|
15
|
-
value?: string;
|
|
16
|
-
isSpread?: boolean;
|
|
17
|
-
type?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ComponentAnalysis {
|
|
21
|
-
componentName: string;
|
|
22
|
-
file: string;
|
|
23
|
-
props: PropUsage[];
|
|
24
|
-
propsInterface?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AnalysisResult {
|
|
28
|
-
summary: {
|
|
29
|
-
totalFiles: number;
|
|
30
|
-
totalComponents: number;
|
|
31
|
-
totalProps: number;
|
|
32
|
-
};
|
|
33
|
-
components: ComponentAnalysis[];
|
|
34
|
-
propUsages: PropUsage[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class JSXPropAnalyzer {
|
|
38
|
-
private readonly supportedExtensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
39
|
-
|
|
40
|
-
async analyzeProps(
|
|
41
|
-
path: string,
|
|
42
|
-
componentName?: string,
|
|
43
|
-
propName?: string,
|
|
44
|
-
includeTypes: boolean = true
|
|
45
|
-
): Promise<AnalysisResult> {
|
|
46
|
-
const files = await this.getFiles(path);
|
|
47
|
-
const components: ComponentAnalysis[] = [];
|
|
48
|
-
const allPropUsages: PropUsage[] = [];
|
|
49
|
-
|
|
50
|
-
for (const file of files) {
|
|
51
|
-
try {
|
|
52
|
-
const analysis = await this.analyzeFile(file, componentName, propName, includeTypes);
|
|
53
|
-
components.push(...analysis.components);
|
|
54
|
-
allPropUsages.push(...analysis.propUsages);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error(`Error analyzing file ${file}:`, error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
summary: {
|
|
62
|
-
totalFiles: files.length,
|
|
63
|
-
totalComponents: components.length,
|
|
64
|
-
totalProps: allPropUsages.length,
|
|
65
|
-
},
|
|
66
|
-
components,
|
|
67
|
-
propUsages: allPropUsages,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async findPropUsage(
|
|
72
|
-
propName: string,
|
|
73
|
-
directory: string = '.',
|
|
74
|
-
componentName?: string
|
|
75
|
-
): Promise<PropUsage[]> {
|
|
76
|
-
const result = await this.analyzeProps(directory, componentName, propName);
|
|
77
|
-
return result.propUsages.filter(usage => usage.propName === propName);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async getComponentProps(
|
|
81
|
-
componentName: string,
|
|
82
|
-
directory: string = '.'
|
|
83
|
-
): Promise<ComponentAnalysis[]> {
|
|
84
|
-
const result = await this.analyzeProps(directory, componentName);
|
|
85
|
-
return result.components.filter(comp => comp.componentName === componentName);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private async getFiles(path: string): Promise<string[]> {
|
|
89
|
-
try {
|
|
90
|
-
const stat = statSync(path);
|
|
91
|
-
|
|
92
|
-
if (stat.isFile()) {
|
|
93
|
-
return this.supportedExtensions.includes(extname(path)) ? [path] : [];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (stat.isDirectory()) {
|
|
97
|
-
const pattern = join(path, '**/*.{js,jsx,ts,tsx}');
|
|
98
|
-
return await glob(pattern, { ignore: ['**/node_modules/**', '**/dist/**', '**/build/**'] });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return [];
|
|
102
|
-
} catch (error) {
|
|
103
|
-
throw new Error(`Cannot access path: ${path}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private async analyzeFile(
|
|
108
|
-
filePath: string,
|
|
109
|
-
targetComponent?: string,
|
|
110
|
-
targetProp?: string,
|
|
111
|
-
includeTypes: boolean = true
|
|
112
|
-
): Promise<{ components: ComponentAnalysis[]; propUsages: PropUsage[] }> {
|
|
113
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
114
|
-
const components: ComponentAnalysis[] = [];
|
|
115
|
-
const propUsages: PropUsage[] = [];
|
|
116
|
-
|
|
117
|
-
let ast;
|
|
118
|
-
try {
|
|
119
|
-
ast = parse(content, {
|
|
120
|
-
sourceType: 'module',
|
|
121
|
-
plugins: [
|
|
122
|
-
'jsx',
|
|
123
|
-
'typescript',
|
|
124
|
-
'decorators-legacy',
|
|
125
|
-
'classProperties',
|
|
126
|
-
'objectRestSpread',
|
|
127
|
-
'functionBind',
|
|
128
|
-
'exportDefaultFrom',
|
|
129
|
-
'exportNamespaceFrom',
|
|
130
|
-
'dynamicImport',
|
|
131
|
-
'nullishCoalescingOperator',
|
|
132
|
-
'optionalChaining',
|
|
133
|
-
],
|
|
134
|
-
});
|
|
135
|
-
} catch (error) {
|
|
136
|
-
throw new Error(`Failed to parse ${filePath}: ${error}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Track component definitions and their prop interfaces
|
|
140
|
-
const componentInterfaces = new Map<string, string>();
|
|
141
|
-
|
|
142
|
-
// Handle default export from traverse
|
|
143
|
-
const traverseDefault = traverse.default || traverse;
|
|
144
|
-
traverseDefault(ast, {
|
|
145
|
-
// Handle TypeScript interfaces for props
|
|
146
|
-
TSInterfaceDeclaration: (path) => {
|
|
147
|
-
if (!includeTypes) return;
|
|
148
|
-
|
|
149
|
-
const interfaceName = path.node.id.name;
|
|
150
|
-
if (interfaceName.endsWith('Props')) {
|
|
151
|
-
const componentName = interfaceName.replace(/Props$/, '');
|
|
152
|
-
componentInterfaces.set(componentName, interfaceName);
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
// Handle function components
|
|
157
|
-
FunctionDeclaration: (path) => {
|
|
158
|
-
const functionName = path.node.id?.name;
|
|
159
|
-
if (!functionName) return;
|
|
160
|
-
|
|
161
|
-
if (targetComponent && functionName !== targetComponent) return;
|
|
162
|
-
|
|
163
|
-
const componentAnalysis: ComponentAnalysis = {
|
|
164
|
-
componentName: functionName,
|
|
165
|
-
file: filePath,
|
|
166
|
-
props: [],
|
|
167
|
-
propsInterface: componentInterfaces.get(functionName),
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// Analyze props parameter
|
|
171
|
-
const propsParam = path.node.params[0];
|
|
172
|
-
if (propsParam && t.isIdentifier(propsParam)) {
|
|
173
|
-
// Look for prop destructuring in function body
|
|
174
|
-
this.findPropsInFunctionBody(path, componentAnalysis, propUsages, targetProp);
|
|
175
|
-
} else if (propsParam && t.isObjectPattern(propsParam)) {
|
|
176
|
-
// Direct destructuring in parameters
|
|
177
|
-
this.analyzeObjectPattern(propsParam, functionName, filePath, componentAnalysis, propUsages, targetProp);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
components.push(componentAnalysis);
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
// Handle arrow function components
|
|
184
|
-
VariableDeclarator: (path) => {
|
|
185
|
-
if (!t.isIdentifier(path.node.id) || !t.isArrowFunctionExpression(path.node.init)) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const componentName = path.node.id.name;
|
|
190
|
-
if (targetComponent && componentName !== targetComponent) return;
|
|
191
|
-
|
|
192
|
-
const arrowFunc = path.node.init;
|
|
193
|
-
const componentAnalysis: ComponentAnalysis = {
|
|
194
|
-
componentName,
|
|
195
|
-
file: filePath,
|
|
196
|
-
props: [],
|
|
197
|
-
propsInterface: componentInterfaces.get(componentName),
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const propsParam = arrowFunc.params[0];
|
|
201
|
-
if (propsParam && t.isObjectPattern(propsParam)) {
|
|
202
|
-
this.analyzeObjectPattern(propsParam, componentName, filePath, componentAnalysis, propUsages, targetProp);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
components.push(componentAnalysis);
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
// Handle JSX elements and their props
|
|
209
|
-
JSXElement: (path) => {
|
|
210
|
-
this.analyzeJSXElement(path, filePath, propUsages, targetComponent, targetProp);
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
JSXFragment: (path) => {
|
|
214
|
-
// Handle fragments that might contain JSX elements
|
|
215
|
-
path.traverse({
|
|
216
|
-
JSXElement: (innerPath) => {
|
|
217
|
-
this.analyzeJSXElement(innerPath, filePath, propUsages, targetComponent, targetProp);
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return { components, propUsages };
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
private findPropsInFunctionBody(
|
|
227
|
-
functionPath: any,
|
|
228
|
-
componentAnalysis: ComponentAnalysis,
|
|
229
|
-
propUsages: PropUsage[],
|
|
230
|
-
targetProp?: string
|
|
231
|
-
) {
|
|
232
|
-
functionPath.traverse({
|
|
233
|
-
MemberExpression(path: any) {
|
|
234
|
-
if (
|
|
235
|
-
t.isIdentifier(path.node.object, { name: 'props' }) &&
|
|
236
|
-
t.isIdentifier(path.node.property)
|
|
237
|
-
) {
|
|
238
|
-
const propName = path.node.property.name;
|
|
239
|
-
if (targetProp && propName !== targetProp) return;
|
|
240
|
-
|
|
241
|
-
const loc = path.node.loc;
|
|
242
|
-
const propUsage: PropUsage = {
|
|
243
|
-
propName,
|
|
244
|
-
componentName: componentAnalysis.componentName,
|
|
245
|
-
file: componentAnalysis.file,
|
|
246
|
-
line: loc?.start.line || 0,
|
|
247
|
-
column: loc?.start.column || 0,
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
componentAnalysis.props.push(propUsage);
|
|
251
|
-
propUsages.push(propUsage);
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private analyzeObjectPattern(
|
|
258
|
-
pattern: t.ObjectPattern,
|
|
259
|
-
componentName: string,
|
|
260
|
-
filePath: string,
|
|
261
|
-
componentAnalysis: ComponentAnalysis,
|
|
262
|
-
propUsages: PropUsage[],
|
|
263
|
-
targetProp?: string
|
|
264
|
-
) {
|
|
265
|
-
for (const property of pattern.properties) {
|
|
266
|
-
if (t.isObjectProperty(property) && t.isIdentifier(property.key)) {
|
|
267
|
-
const propName = property.key.name;
|
|
268
|
-
if (targetProp && propName !== targetProp) continue;
|
|
269
|
-
|
|
270
|
-
const loc = property.loc;
|
|
271
|
-
const propUsage: PropUsage = {
|
|
272
|
-
propName,
|
|
273
|
-
componentName,
|
|
274
|
-
file: filePath,
|
|
275
|
-
line: loc?.start.line || 0,
|
|
276
|
-
column: loc?.start.column || 0,
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
componentAnalysis.props.push(propUsage);
|
|
280
|
-
propUsages.push(propUsage);
|
|
281
|
-
} else if (t.isRestElement(property)) {
|
|
282
|
-
const loc = property.loc;
|
|
283
|
-
const propUsage: PropUsage = {
|
|
284
|
-
propName: '...rest',
|
|
285
|
-
componentName,
|
|
286
|
-
file: filePath,
|
|
287
|
-
line: loc?.start.line || 0,
|
|
288
|
-
column: loc?.start.column || 0,
|
|
289
|
-
isSpread: true,
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
componentAnalysis.props.push(propUsage);
|
|
293
|
-
propUsages.push(propUsage);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
private analyzeJSXElement(
|
|
299
|
-
path: any,
|
|
300
|
-
filePath: string,
|
|
301
|
-
propUsages: PropUsage[],
|
|
302
|
-
targetComponent?: string,
|
|
303
|
-
targetProp?: string
|
|
304
|
-
) {
|
|
305
|
-
const openingElement = path.node.openingElement;
|
|
306
|
-
if (!t.isJSXIdentifier(openingElement.name)) return;
|
|
307
|
-
|
|
308
|
-
const componentName = openingElement.name.name;
|
|
309
|
-
if (targetComponent && componentName !== targetComponent) return;
|
|
310
|
-
|
|
311
|
-
for (const attribute of openingElement.attributes) {
|
|
312
|
-
if (t.isJSXAttribute(attribute) && t.isJSXIdentifier(attribute.name)) {
|
|
313
|
-
const propName = attribute.name.name;
|
|
314
|
-
if (targetProp && propName !== targetProp) continue;
|
|
315
|
-
|
|
316
|
-
let value: string | undefined;
|
|
317
|
-
if (attribute.value) {
|
|
318
|
-
if (t.isStringLiteral(attribute.value)) {
|
|
319
|
-
value = attribute.value.value;
|
|
320
|
-
} else if (t.isJSXExpressionContainer(attribute.value)) {
|
|
321
|
-
// Try to extract simple expression values
|
|
322
|
-
const expression = attribute.value.expression;
|
|
323
|
-
if (t.isStringLiteral(expression)) {
|
|
324
|
-
value = expression.value;
|
|
325
|
-
} else if (t.isNumericLiteral(expression)) {
|
|
326
|
-
value = expression.value.toString();
|
|
327
|
-
} else if (t.isBooleanLiteral(expression)) {
|
|
328
|
-
value = expression.value.toString();
|
|
329
|
-
} else if (t.isIdentifier(expression)) {
|
|
330
|
-
value = `{${expression.name}}`;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const loc = attribute.loc;
|
|
336
|
-
const propUsage: PropUsage = {
|
|
337
|
-
propName,
|
|
338
|
-
componentName,
|
|
339
|
-
file: filePath,
|
|
340
|
-
line: loc?.start.line || 0,
|
|
341
|
-
column: loc?.start.column || 0,
|
|
342
|
-
value,
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
propUsages.push(propUsage);
|
|
346
|
-
} else if (t.isJSXSpreadAttribute(attribute)) {
|
|
347
|
-
const loc = attribute.loc;
|
|
348
|
-
const propUsage: PropUsage = {
|
|
349
|
-
propName: '...spread',
|
|
350
|
-
componentName,
|
|
351
|
-
file: filePath,
|
|
352
|
-
line: loc?.start.line || 0,
|
|
353
|
-
column: loc?.start.column || 0,
|
|
354
|
-
isSpread: true,
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
propUsages.push(propUsage);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"noImplicitAny": false,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"outDir": "./dist",
|
|
13
|
-
"rootDir": "./src",
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"sourceMap": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|