Fix electron dependency issue and improve CLI UX#37
Conversation
- Move electron from dependencies to optionalDependencies in package.json - Add emojis and improved error messages in CLI for better user experience - Enhance error handling when electron module fails to load - Provide clear troubleshooting steps in error messages This fixes the CI/CD electron-builder dependency conflict and resolves the global install issue where users had to separately install electron. Fixes #25 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. WalkthroughUpdates the CLI entrypoint to lazily require Electron with guarded error handling, differentiate global vs local installs to decide launch strategy, and revise CLI/help messaging. Adds electron as an optionalDependency in package.json to support global installations without hard failure. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant CLI as ccusage-widget (CLI)
participant E as Electron (optional)
participant N as npm start (app)
U->>CLI: Run ccusage-widget [args]
alt --help / unknown options
CLI-->>U: Print help or error message
else Normal launch
CLI->>CLI: Detect install type (global vs local)
CLI->>CLI: Try require('electron')
alt Electron available
alt Global install
CLI->>E: Spawn Electron with app path
E-->>U: App UI launches
else Local install
CLI->>N: Run npm start in app directory
N-->>U: App starts via dev script
end
else Electron missing
CLI-->>U: Print diagnostic and remediation steps
CLI->>CLI: Exit with non-zero code
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Claude finished @JeongJaeSoon's task —— View job PR Review: Fix electron dependency issue and improve CLI UXReview Checklist:
📋 Code Review SummaryThis PR addresses two important issues: CI/CD compatibility with electron-builder and improved user experience for global installations. The changes are well-implemented and solve real problems. ✅ Positive Aspects1. Smart Dependency Management (
2. Enhanced Error Handling (
3. Improved User Experience
🔍 Code Quality AssessmentStrengths:
Security: ✅ No security concerns identified
Performance: ✅ No performance issues
🐛 Minor Issues & Suggestions1. Error Message Accuracy ( Suggestion: Update the comment to be more precise: // Electron not found - can happen on unsupported platforms or failed installs2. Local Execution Logic ( Suggestion: Consider using spawn for consistency: const child = spawn('npm', ['start'], {
cwd: appPath,
stdio: 'inherit'
});
child.on('close', (code) => process.exit(code));3. Missing Launch Message Consistency 📊 Test Coverage ImpactCurrent State: No automated tests for the CLI script
🎯 Final Recommendation: APPROVE ✅This PR successfully solves the stated problems and significantly improves the user experience. The code is well-written, secure, and follows best practices. The minor suggestions above are enhancements rather than blockers. Key Benefits Delivered:
The implementation is production-ready and addresses the core issues effectively. |
Summary
dependenciestooptionalDependenciesin package.jsonProblem
This addresses two critical issues:
devDependencies, causing build failures when electron is listed independenciesnpm install -g ccusage-widgethad to separately install electron, creating friction (issue [Bug] #25)Solution
Moving electron to
optionalDependenciesprovides the best of both worlds:Benefits for Users
Test Plan
Fixes #25
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores