@rayburst/cli 0.1.0 → 0.1.7

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 CHANGED
@@ -1,258 +1,329 @@
1
1
  # Rayburst CLI
2
2
 
3
- A Module Federation host application that loads the Rayburst frontend application dynamically from different environments.
4
-
5
- ## Overview
6
-
7
- The Rayburst CLI is an npm-installable package that serves as a Module Federation host. It dynamically loads the Rayburst application from:
8
-
9
- - **Development**: `http://localhost:3000` (local development)
10
- - **Staging**: `https://dev.rayburst.app` (staging environment)
11
- - **Production**: `https://www.rayburst.app` (production environment)
12
-
13
- The CLI runs on **port 3105** by default.
3
+ A powerful CLI tool for analyzing and visualizing TypeScript/JavaScript project dependencies and architecture.
14
4
 
15
5
  ## Installation
16
6
 
17
- ### Local Development Setup
7
+ Install globally via npm:
18
8
 
19
- 1. Install dependencies:
20
9
  ```bash
21
- cd cli
22
- npm install
10
+ npm install -g rayburst
23
11
  ```
24
12
 
25
- 2. Build the CLI:
26
- ```bash
27
- npm run build
28
- ```
13
+ ## Quick Start
29
14
 
30
- 3. Link the CLI globally for testing:
31
15
  ```bash
32
- npm link
33
- ```
16
+ # Register your project
17
+ rayburst register /path/to/your/project
34
18
 
35
- ### Publishing to npm (Future)
19
+ # Analyze the project
20
+ rayburst analyze
36
21
 
37
- Once ready for production:
38
- ```bash
39
- npm publish
22
+ # Start the dashboard
23
+ rayburst start
40
24
  ```
41
25
 
42
- Then users can install globally:
26
+ Open your browser to `http://localhost:3105` to view the interactive dashboard.
27
+
28
+ ## Commands
29
+
30
+ ### `rayburst register [path]`
31
+
32
+ Register a project for analysis.
33
+
43
34
  ```bash
44
- npm install -g rayburst-cli
35
+ # Register current directory
36
+ rayburst register
37
+
38
+ # Register specific path
39
+ rayburst register /path/to/project
40
+
41
+ # Register with custom name
42
+ rayburst register --name "My Project"
45
43
  ```
46
44
 
47
- ## Usage
45
+ **Options:**
46
+ - `[path]` - Path to project directory (default: current directory)
47
+ - `-n, --name <name>` - Custom project name
48
48
 
49
- ### Starting the CLI
49
+ ### `rayburst list`
50
+
51
+ List all registered projects.
50
52
 
51
53
  ```bash
52
- rayburst start
54
+ rayburst list
53
55
  ```
54
56
 
55
- This will start the CLI server on port 3105 in development mode, loading the app from `localhost:3000`.
57
+ Shows:
58
+ - Project name
59
+ - Path
60
+ - Last analyzed timestamp
61
+ - Number of branches
62
+
63
+ ### `rayburst analyze [path]`
56
64
 
57
- ### Command Options
65
+ Analyze a registered project and generate dependency graphs.
58
66
 
59
67
  ```bash
60
- rayburst start [options]
68
+ # Analyze current directory
69
+ rayburst analyze
61
70
 
62
- Options:
63
- -p, --port <port> Port to run the server on (default: 3105)
64
- -e, --env <environment> Environment: development|staging|production (default: development)
65
- -h, --help Display help for command
71
+ # Analyze specific project by path
72
+ rayburst analyze /path/to/project
73
+
74
+ # Analyze specific project by ID
75
+ rayburst analyze abc-123
66
76
  ```
67
77
 
68
- ### Examples
78
+ **Options:**
79
+ - `[path]` - Project path or ID (default: current directory)
69
80
 
70
- Start on custom port:
71
- ```bash
72
- rayburst start --port 4000
73
- ```
81
+ **What it analyzes:**
82
+ - Function and class relationships
83
+ - Import/export dependencies
84
+ - Git branches
85
+ - File structure
86
+ - Code architecture
74
87
 
75
- Start in staging mode:
76
- ```bash
77
- rayburst start --env staging
78
- ```
88
+ ### `rayburst start`
89
+
90
+ Start the interactive dashboard server.
79
91
 
80
- Start in production mode:
81
92
  ```bash
82
- rayburst start --env production --port 8080
93
+ # Start on default port (3105)
94
+ rayburst start
95
+
96
+ # Start on custom port
97
+ rayburst start --port 4000
98
+
99
+ # Start in production mode
100
+ rayburst start --env production
83
101
  ```
84
102
 
85
- ## Development Workflow
103
+ **Options:**
104
+ - `-p, --port <port>` - Server port (default: 3105)
105
+ - `-e, --env <environment>` - Environment: development|staging|production (default: production)
86
106
 
87
- ### 1. Build the Main App (Remote)
107
+ ### `rayburst unregister <id>`
88
108
 
89
- The main Rayburst app must be built first to generate the `remoteEntry.js`:
109
+ Unregister a project.
90
110
 
91
111
  ```bash
92
- # From the root of the rayburst project
93
- npm run build
112
+ # Unregister by project ID
113
+ rayburst unregister abc-123
94
114
  ```
95
115
 
96
- This creates:
97
- - `dist/assets/remoteEntry.js` - Module federation remote entry
98
- - All other bundled assets
116
+ ## Features
99
117
 
100
- ### 2. Start the Main App
118
+ ### 📊 Interactive Dependency Graphs
119
+ - Visual representation of code dependencies
120
+ - Function and class relationships
121
+ - Import/export connections
122
+ - Interactive node exploration
101
123
 
102
- Start the main app on port 3000:
124
+ ### 🔍 Git Integration
125
+ - Multi-branch support
126
+ - Filter by uncommitted changes
127
+ - Branch comparison
128
+ - Track changes over time
103
129
 
104
- ```bash
105
- npm run start
106
- ```
130
+ ### 🎨 Rich Visualization
131
+ - React Flow-based graphs
132
+ - Collapsible node groups
133
+ - Search and filter
134
+ - Auto-layout options
135
+
136
+ ### 🔄 Real-time Updates
137
+ - File watching (coming soon)
138
+ - Incremental analysis (coming soon)
139
+ - Live graph updates (coming soon)
107
140
 
108
- The app will be available at `http://localhost:3000` and expose its remote entry at `http://localhost:3000/assets/remoteEntry.js`.
141
+ ## Usage Workflow
109
142
 
110
- ### 3. Build the CLI
143
+ ### 1. Register Your Projects
111
144
 
112
145
  ```bash
113
- cd cli
114
- npm run build
146
+ cd /path/to/project1
147
+ rayburst register
148
+
149
+ cd /path/to/project2
150
+ rayburst register
115
151
  ```
116
152
 
117
- ### 4. Start the CLI
153
+ ### 2. Analyze Projects
118
154
 
119
155
  ```bash
120
- rayburst start
156
+ rayburst analyze project1
157
+ rayburst analyze project2
121
158
  ```
122
159
 
123
- or directly:
160
+ ### 3. Explore in Dashboard
124
161
 
125
162
  ```bash
126
- cd cli
127
- npm run dev
163
+ rayburst start
128
164
  ```
129
165
 
130
- The CLI will now be running at `http://localhost:3105` and loading the app from `http://localhost:3000`.
166
+ Navigate to `http://localhost:3105` and:
167
+ - Browse registered projects
168
+ - Select branches to view
169
+ - Explore dependency graphs
170
+ - Compare branches
171
+ - Filter by changed files
172
+
173
+ ## Dashboard Features
174
+
175
+ ### Project Management
176
+ - View all registered projects
177
+ - See analysis status
178
+ - Browse branches
179
+ - Open multiple tabs
180
+
181
+ ### Workspace
182
+ - Interactive dependency graphs
183
+ - Node details sidebar
184
+ - Command palette (⌘K)
185
+ - Multi-tab support
186
+
187
+ ### Filtering
188
+ - **All Files**: Show complete dependency graph
189
+ - **Changes Only**: Filter to show only uncommitted changes
190
+ - Custom visibility controls
191
+ - Search functionality
131
192
 
132
193
  ## Architecture
133
194
 
134
- ### Module Federation Setup
195
+ ### Module Federation
135
196
 
136
- **Main App (Remote)**
137
- - Name: `rayburstApp`
138
- - Port: 3000
139
- - Exposes: `./App` → `./src/main.tsx`
140
- - Shared: `react`, `react-dom`
197
+ The CLI uses Module Federation to load the dashboard UI dynamically:
141
198
 
142
- **CLI (Host)**
143
- - Name: `rayburstCli`
144
- - Port: 3105
145
- - Remotes: `rayburstApp` from environment-specific URL
146
- - Shared: `react`, `react-dom`
199
+ - **CLI (Host)**: Port 3105
200
+ - **Dashboard (Remote)**: Loaded from rayburst.app
201
+ - **Shared**: React, React-DOM
147
202
 
148
- ### File Structure
203
+ ### Data Storage
149
204
 
150
- ```
151
- cli/
152
- ├── bin/
153
- │ └── rayburst.js # CLI entry point
154
- ├── src/
155
- │ └── main.tsx # React shell that loads remote
156
- ├── dist/ # Built files (generated)
157
- ├── index.html # HTML shell with loading state
158
- ├── server.js # Express server
159
- ├── vite.config.ts # Vite + Module Federation config
160
- ├── package.json
161
- └── README.md
162
- ```
205
+ - **Registry**: `~/.rayburst/projects.json`
206
+ - **Analysis Data**: `~/.rayburst/analysis/<project-id>.json`
163
207
 
164
208
  ## Environment Configuration
165
209
 
166
- The CLI automatically determines which remote URL to use based on the environment:
167
-
168
210
  | Environment | Remote URL | Use Case |
169
211
  |------------|-----------|----------|
170
212
  | development | http://localhost:3000 | Local development |
171
213
  | staging | https://dev.rayburst.app | Staging/testing |
172
- | production | https://www.rayburst.app | Production |
214
+ | production | https://www.rayburst.app | Production (default) |
173
215
 
174
- ## Troubleshooting
175
-
176
- ### Port 3000 Already in Use
216
+ ## Examples
177
217
 
178
- If port 3000 is already in use, find and kill the process:
218
+ ### Analyze Multiple Projects
179
219
 
180
220
  ```bash
181
- lsof -i :3000
182
- kill <PID>
221
+ # Register projects
222
+ rayburst register ~/projects/frontend --name "Frontend"
223
+ rayburst register ~/projects/backend --name "Backend"
224
+ rayburst register ~/projects/shared --name "Shared Lib"
225
+
226
+ # Analyze all
227
+ rayburst list | xargs -I {} rayburst analyze {}
228
+
229
+ # Start dashboard
230
+ rayburst start
183
231
  ```
184
232
 
185
- ### Port 3105 Already in Use
233
+ ### Daily Workflow
234
+
235
+ ```bash
236
+ # Morning: Start dashboard
237
+ rayburst start
238
+
239
+ # After changes: Re-analyze
240
+ rayburst analyze
241
+
242
+ # View only your changes
243
+ # (Use "Changes Only" toggle in dashboard)
244
+ ```
186
245
 
187
- Similarly for port 3105:
246
+ ### Custom Port Setup
188
247
 
189
248
  ```bash
190
- lsof -i :3105
191
- kill <PID>
249
+ # If port 3105 is in use
250
+ rayburst start --port 8080
192
251
  ```
193
252
 
194
- ### Remote Entry Not Found
253
+ ## Troubleshooting
195
254
 
196
- Make sure the main app is **built** and running the **preview server** (not dev server):
255
+ ### Port Already in Use
197
256
 
198
257
  ```bash
199
- # 1. Build the app first
200
- npm run build
201
-
202
- # 2. Start the preview server (serves built files)
203
- npm run start
258
+ # Find process using port
259
+ lsof -i :3105
204
260
 
205
- # 3. Verify remoteEntry.js is accessible
206
- curl -I http://localhost:3000/assets/remoteEntry.js
261
+ # Kill process
262
+ kill <PID>
207
263
  ```
208
264
 
209
- Should return `200 OK` with `Content-Type: text/javascript`.
265
+ ### Analysis Fails
210
266
 
211
- **Important**: The dev server (`npm run dev`) does NOT generate the `remoteEntry.js` file. You must:
212
- 1. Build the app with `npm run build`
213
- 2. Serve built files with `npm run start` (vite preview)
267
+ - Ensure project has a `package.json`
268
+ - Check for TypeScript/JavaScript files
269
+ - Verify git repository (for branch support)
270
+ - Check file permissions
214
271
 
215
- If you see `Content-Type: text/html` instead of `text/javascript`, you're running the dev server instead of the preview server.
272
+ ### Dashboard Not Loading
216
273
 
217
- ### Module Federation Loading Errors
274
+ - Verify internet connection (loads remote from rayburst.app)
275
+ - Check firewall settings
276
+ - Try `--env development` for local testing
218
277
 
219
- 1. Ensure both apps share the same major versions of React and React DOM
220
- 2. Check browser console for detailed error messages
221
- 3. Verify the remote URL is accessible from the host
222
- 4. Check CORS headers if loading from different domains
278
+ ### No Projects Listed
223
279
 
224
- ## Testing Different Environments
225
-
226
- ### Local Testing
227
280
  ```bash
228
- # Terminal 1: Start main app
229
- npm run start
281
+ # Check registry location
282
+ rayburst list
230
283
 
231
- # Terminal 2: Start CLI
232
- rayburst start
284
+ # Re-register project
285
+ rayburst register /path/to/project
233
286
  ```
234
287
 
235
- Visit: `http://localhost:3105`
288
+ ## Development
289
+
290
+ ### Local Setup
236
291
 
237
- ### Staging Testing
238
292
  ```bash
239
- rayburst start --env staging
240
- ```
293
+ # Clone repository
294
+ git clone https://github.com/your-org/rayburst-cli.git
295
+ cd rayburst-cli
241
296
 
242
- Visit: `http://localhost:3105` (loads from dev.rayburst.app)
297
+ # Install dependencies
298
+ npm install
243
299
 
244
- ### Production Testing
245
- ```bash
246
- rayburst start --env production
247
- ```
300
+ # Build
301
+ npm run build
302
+
303
+ # Link for local testing
304
+ npm link
248
305
 
249
- Visit: `http://localhost:3105` (loads from www.rayburst.app)
306
+ # Test commands
307
+ rayburst --help
308
+ ```
250
309
 
251
- ## Scripts
310
+ ### Project Structure
252
311
 
253
- - `npm run dev` - Start CLI in development mode
254
- - `npm run build` - Build the CLI for production
255
- - `npm run start` - Start the CLI server (requires build first)
312
+ ```
313
+ rayburst-cli/
314
+ ├── bin/
315
+ │ └── rayburst.js # CLI entry point
316
+ ├── src/
317
+ │ ├── registry.js # Project registry
318
+ │ ├── git-utils.js # Git operations
319
+ │ ├── file-watcher.js # File watching
320
+ │ └── main.tsx # Dashboard loader
321
+ ├── scripts/
322
+ │ └── analyze-project.js # Analysis engine
323
+ ├── server.js # Express server
324
+ ├── vite.config.ts # Build config
325
+ └── package.json
326
+ ```
256
327
 
257
328
  ## Tech Stack
258
329
 
@@ -262,12 +333,20 @@ Visit: `http://localhost:3105` (loads from www.rayburst.app)
262
333
  - **Express** - Production server
263
334
  - **Commander** - CLI framework
264
335
  - **Chalk** - Terminal styling
336
+ - **ts-morph** - TypeScript analysis
337
+ - **chokidar** - File watching
338
+
339
+ ## Contributing
340
+
341
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests.
342
+
343
+ ## License
344
+
345
+ MIT
265
346
 
266
- ## Future Enhancements
347
+ ## Links
267
348
 
268
- - [ ] Auto-detect if remote is available and fallback
269
- - [ ] Support for custom remote URLs via config file
270
- - [ ] Health check endpoint
271
- - [ ] Hot reload support for development
272
- - [ ] Docker support
273
- - [ ] CI/CD integration examples
349
+ - [Documentation](https://rayburst.app/docs)
350
+ - [GitHub Repository](https://github.com/your-org/rayburst)
351
+ - [Issue Tracker](https://github.com/your-org/rayburst/issues)
352
+ - [Changelog](https://github.com/your-org/rayburst/releases)
package/bin/rayburst.js CHANGED
@@ -4,7 +4,16 @@ import { Command } from 'commander';
4
4
  import chalk from 'chalk';
5
5
  import { spawn } from 'child_process';
6
6
  import { fileURLToPath } from 'url';
7
- import { dirname, join } from 'path';
7
+ import { dirname, join, resolve } from 'path';
8
+ import {
9
+ registerProject,
10
+ unregisterProject,
11
+ listProjects,
12
+ getRegistryPaths,
13
+ writeAnalysisData,
14
+ updateProjectAnalysis,
15
+ } from '../src/registry.js';
16
+ import { analyzeProject } from '../scripts/analyze-project.js';
8
17
 
9
18
  const __filename = fileURLToPath(import.meta.url);
10
19
  const __dirname = dirname(__filename);
@@ -58,4 +67,150 @@ program
58
67
  });
59
68
  });
60
69
 
70
+ program
71
+ .command('register')
72
+ .description('Register the current directory as a Rayburst project')
73
+ .argument('[path]', 'Path to register (defaults to current directory)', '.')
74
+ .option('--no-analyze', 'Skip automatic code analysis')
75
+ .action((projectPath, options) => {
76
+ try {
77
+ console.log(chalk.blue('📦 Registering project...'));
78
+ const project = registerProject(projectPath);
79
+ console.log(chalk.green('✓ Project registered successfully!'));
80
+ console.log(chalk.gray(` Name: ${project.name}`));
81
+ console.log(chalk.gray(` Path: ${project.path}`));
82
+ console.log(chalk.gray(` ID: ${project.id}`));
83
+ console.log();
84
+
85
+ // Run analysis by default
86
+ if (options.analyze !== false) {
87
+ console.log(chalk.blue('🔍 Analyzing project...'));
88
+ try {
89
+ const analysisData = analyzeProject(project.path);
90
+ writeAnalysisData(project.id, analysisData);
91
+ updateProjectAnalysis(project.id);
92
+ console.log(chalk.green('✓ Analysis complete!'));
93
+ console.log(chalk.gray(` Nodes: ${analysisData.planData[Object.keys(analysisData.planData)[0]]?.nodes?.length || 0}`));
94
+ console.log(chalk.gray(` Edges: ${analysisData.planData[Object.keys(analysisData.planData)[0]]?.edges?.length || 0}`));
95
+ } catch (error) {
96
+ console.warn(chalk.yellow('⚠ Analysis failed:'), error.message);
97
+ console.warn(chalk.dim(' Project registered but without analysis data'));
98
+ }
99
+ }
100
+
101
+ console.log();
102
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst list'), chalk.dim('to see all registered projects'));
103
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst start'), chalk.dim('to open the Rayburst dashboard'));
104
+ } catch (error) {
105
+ console.error(chalk.red('✗ Registration failed:'), error.message);
106
+ process.exit(1);
107
+ }
108
+ });
109
+
110
+ program
111
+ .command('unregister')
112
+ .description('Unregister a Rayburst project')
113
+ .argument('[path]', 'Path or project ID to unregister (defaults to current directory)', '.')
114
+ .action((projectPath) => {
115
+ try {
116
+ console.log(chalk.blue('📦 Unregistering project...'));
117
+ const project = unregisterProject(projectPath);
118
+ console.log(chalk.green('✓ Project unregistered successfully!'));
119
+ console.log(chalk.gray(` Name: ${project.name}`));
120
+ console.log(chalk.gray(` Path: ${project.path}`));
121
+ } catch (error) {
122
+ console.error(chalk.red('✗ Unregistration failed:'), error.message);
123
+ process.exit(1);
124
+ }
125
+ });
126
+
127
+ program
128
+ .command('list')
129
+ .description('List all registered Rayburst projects')
130
+ .action(() => {
131
+ try {
132
+ const projects = listProjects();
133
+
134
+ if (projects.length === 0) {
135
+ console.log(chalk.yellow('No projects registered yet.'));
136
+ console.log();
137
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst register'), chalk.dim('in a project directory to register it'));
138
+ return;
139
+ }
140
+
141
+ console.log(chalk.blue(`📦 Registered Projects (${projects.length}):\n`));
142
+
143
+ projects.forEach((project, index) => {
144
+ console.log(chalk.bold(`${index + 1}. ${project.name}`));
145
+ console.log(chalk.gray(` Path: ${project.path}`));
146
+ console.log(chalk.gray(` ID: ${project.id}`));
147
+ console.log(chalk.gray(` Version: ${project.packageJson?.version || 'N/A'}`));
148
+ console.log(chalk.gray(` Registered: ${new Date(project.registeredAt).toLocaleString()}`));
149
+ if (project.lastAnalyzed) {
150
+ console.log(chalk.gray(` Last Analyzed: ${new Date(project.lastAnalyzed).toLocaleString()}`));
151
+ }
152
+ console.log();
153
+ });
154
+
155
+ const paths = getRegistryPaths();
156
+ console.log(chalk.dim(`Registry location: ${paths.projectsFile}`));
157
+ } catch (error) {
158
+ console.error(chalk.red('✗ Failed to list projects:'), error.message);
159
+ process.exit(1);
160
+ }
161
+ });
162
+
163
+ program
164
+ .command('analyze')
165
+ .description('Analyze a registered Rayburst project')
166
+ .argument('[path]', 'Path or project ID to analyze (defaults to current directory)', '.')
167
+ .action((projectPath) => {
168
+ try {
169
+ // Find the project by path or ID
170
+ const projects = listProjects();
171
+ const absolutePath = resolve(projectPath);
172
+
173
+ let project = projects.find(p => p.path === absolutePath);
174
+ if (!project) {
175
+ // Try to find by ID
176
+ project = projects.find(p => p.id === projectPath);
177
+ }
178
+
179
+ if (!project) {
180
+ console.error(chalk.red('✗ Project not found. Make sure it\'s registered first.'));
181
+ console.log();
182
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst list'), chalk.dim('to see registered projects'));
183
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst register'), chalk.dim('to register a new project'));
184
+ process.exit(1);
185
+ }
186
+
187
+ console.log(chalk.blue('🔍 Analyzing project...'));
188
+ console.log(chalk.gray(` Name: ${project.name}`));
189
+ console.log(chalk.gray(` Path: ${project.path}`));
190
+ console.log();
191
+
192
+ const analysisData = analyzeProject(project.path);
193
+ writeAnalysisData(project.id, analysisData);
194
+ updateProjectAnalysis(project.id);
195
+
196
+ console.log(chalk.green('✓ Analysis complete!'));
197
+
198
+ // Show stats for each branch
199
+ const branchIds = Object.keys(analysisData.planData);
200
+ console.log(chalk.gray(` Branches analyzed: ${branchIds.length}`));
201
+
202
+ branchIds.forEach(branchId => {
203
+ const planData = analysisData.planData[branchId];
204
+ const branch = analysisData.branches.find(b => b.id === branchId);
205
+ console.log(chalk.gray(` - ${branch?.name || branchId}: ${planData.nodes.length} nodes, ${planData.edges.length} edges`));
206
+ });
207
+
208
+ console.log();
209
+ console.log(chalk.dim('💡 Run'), chalk.cyan('rayburst start'), chalk.dim('to view the analysis in the dashboard'));
210
+ } catch (error) {
211
+ console.error(chalk.red('✗ Analysis failed:'), error.message);
212
+ process.exit(1);
213
+ }
214
+ });
215
+
61
216
  program.parse();