| Crates.io | spinne |
| lib.rs | spinne |
| version | 0.6.0 |
| created_at | 2024-08-15 18:19:10.734415+00 |
| updated_at | 2025-05-11 08:45:54.874695+00 |
| description | spinne is a cli tool that analyzes design system usage for react projects. |
| homepage | |
| repository | https://github.com/tim-richter/spinne |
| max_upload_size | |
| id | 1339081 |
| size | 59,852 |
Spins a web of component relationships for react projects
WIP: Spinne is in early development and report structure and cli options are subject to change.
Spinne is a CLI Tool, that analyzes react projects, and creates a component graph from all components that are used. This allows you to make some educated guesses about:
Spinne can analyze both single React projects and workspaces containing multiple projects. Here's an example output showing component relationships across multiple projects:
[
{
"name": "source-lib",
"graph": {
"components": [
{
"id": 11611080489164640768,
"name": "Button",
"path": "source-lib/src/components/Button.tsx",
"props": {
"label": 1,
"onClick": 1
}
}
],
"edges": []
}
},
{
"name": "consumer-app",
"graph": {
"components": [
{
"id": 14300231078674835378,
"name": "App",
"path": "consumer-app/src/App.tsx",
"props": {}
}
],
"edges": [
{
"from": 14300231078674835378,
"to": 11611080489164640768,
"project_context": "source-lib"
}
]
}
}
]
For the graph, we use a directed graph where relationships between components are represented by edges. Each component has a unique ID and belongs to a project (indicated by the outer name field). Edges can be within the same project or across projects, with the project_context field indicating when a component depends on a component from another project.
In this example:
Button component is defined in the source-lib projectApp component in consumer-app uses the Button componentApp to Button includes project_context: "source-lib" to indicate it's a cross-project dependency"label": 1 means the prop is used once)Spinne is a command line tool written in rust, so the easiest way to install it is via cargo:
cargo install spinne
To scan for components in your current directory:
spinne
This command will output the results in a file named 'spinne-report.json' by default.
If you want to output it directly to the console you can use -f console:
spinne -f console
To generate an interactive HTML visualization of the component graph:
spinne -f html
This will create 'spinne-report.html' and automatically open it in your default browser.
To analyze specific entry points for exports:
spinne --entry-points src/index.tsx,src/components/index.ts
This will analyze the specified files for exported components before performing the normal component graph analysis.
| Option | Description | Options | Default |
|---|---|---|---|
-e, --entry <path> |
Entry point directory | Path | current directory (./) |
-f, --format <format> |
Output format | file, console, html |
file |
--exclude <patterns> |
Glob patterns to exclude | comma separated patterns | **/node_modules/**,**/dist/**,**/build/**,**/*.stories.tsx,**/*.test.tsx |
--include <patterns> |
Glob patterns to include | comma separated patterns | **/*.tsx |
--entry-points <paths> |
Files to analyze for exports | comma separated paths | none |
-l |
Verbosity level | Use multiple times (-l, -ll, etc.) | 0 |
You can also configure Spinne using a spinne.json file in your project root. This file allows you to define persistent configuration options that will be used every time you run Spinne.
Example spinne.json:
{
"include": ["**/*.tsx", "**/*.ts"],
"exclude": ["**/node_modules/**", "**/dist/**", "**/*.test.tsx"],
"entry_points": ["src/index.tsx", "src/components/index.ts"]
}
| Option | Description | Type |
|---|---|---|
include |
Array of glob patterns for files to include in the analysis | string[] |
exclude |
Array of glob patterns for files to exclude from the analysis | string[] |
entry_points |
Array of file paths to analyze for exports | string[] |
The configuration file options will be merged with any command line arguments you provide. For example, if you specify both exclude patterns in your spinne.json and via the --exclude flag, both sets of patterns will be used.
Spinne automatically detects and analyzes all React projects within a workspace. A project is identified by the presence of both a package.json file and a .git directory. This means Spinne can:
When analyzing a workspace:
You can run Spinne at any level of your directory structure:
# Analyze a specific project
cd my-project && spinne
# Analyze multiple projects from a parent directory
cd dev/projects && spinne