react-file-analyzer
v1.0.1
Published
A comprehensive NPM package for analyzing React and Next.js files, including dependency graphs, component insights, and project structure visualization.
Maintainers
Readme
react-file-analyzer
A powerful NPM package for analyzing React and Next.js projects. It provides tools for file insights, dependency graphs, directory structures, and more. Can be used as a CLI or via an HTTP server.
Installation
npm install react-file-analyzerUsage
CLI Examples
Comprehensive file analysis:
react-file-analyzer --analyze-comprehensive path/to/file.tsx --jsonDependency analysis:
react-file-analyzer --analyze-deps --diagram-type flowchartRead file contents:
react-file-analyzer --read-files file1.tsx,file2.tsx --jsonDirectory tree:
react-file-analyzer --dir-tree . --depth 3 --jsonStart server:
react-file-analyzer --serve --port 3000 --token mysecret
Server Endpoints
- POST /analyze-comprehensive { "filePath": "path/to/file.tsx" } - Comprehensive insights.
- POST /analyze-deps { "includePatterns": [...], ... } - Dependency graph.
- POST /read-files { "files": ["file1.tsx", "file2.tsx"] } - File contents.
- GET /dir-structure?dir=. - Directory structure.
- GET /dir-tree?dir=.&depth=3 - Directory tree.
- POST /analyze-simple { "filePath": "path/to/file.tsx" } - Simple insights.
- POST /clean { "dir": "path/to/dir" } - Clean directory.
All endpoints require Bearer token if set.
Features
- Babel-powered AST analysis for components, hooks, props, state, functions.
- Dependency graph with circular detection and Mermaid diagrams.
- Secure server with path traversal protection.
- Directory traversal and cleaning utilities.
For more details, see the source code or run --help.
