Create a globally installable Ruby gem swap-shakacode-deps that provides the dependency swapping functionality currently in react_on_rails_demo_common, making it available for use in any repository.
- Rationale: Ruby ecosystem provides better file manipulation, process management, and cross-platform compatibility
- Global Installation:
gem install swap-shakacode-deps - Command:
swap-shakacode-deps [options]
-
Local Path Swapping
--shakapacker PATH--react-on-rails PATH--cypress-on-rails PATH
-
GitHub Repository Swapping
--github user/repo#branch--github user/repo@tag
-
Configuration File Support
.swap-deps.ymlin project root--applyto use config file
-
Backup & Restore
- Automatic backup creation
--restoreto revert changes
-
Build Management
--build/--skip-build--watchfor auto-rebuild
-
Watch Process Management
--list-watch--kill-watch
-
Cache Management
--show-cache--clean-cache [GEM]
-
Status Reporting
--statusto show current swaps
-
Dry Run & Verbose Modes
--dry-run--verbose
swap-shakacode-deps/
├── bin/
│ └── swap-shakacode-deps # Executable
├── lib/
│ ├── swap_shakacode_deps.rb # Main entry
│ ├── swap_shakacode_deps/
│ │ ├── version.rb
│ │ ├── cli.rb # CLI parser
│ │ ├── swapper.rb # Core swapping logic
│ │ ├── gem_swapper.rb # Gemfile manipulation
│ │ ├── npm_swapper.rb # package.json manipulation
│ │ ├── github_handler.rb # GitHub repo management
│ │ ├── cache_manager.rb # Cache operations
│ │ ├── watch_manager.rb # Watch process management
│ │ ├── backup_manager.rb # Backup/restore logic
│ │ └── config_loader.rb # YAML config handling
├── spec/ # Tests
├── README.md
├── CHANGELOG.md
├── LICENSE
├── Gemfile
├── Rakefile
└── swap-shakacode-deps.gemspec
The gem will detect project type by looking for:
Gemfile(Ruby project)package.json(Node project).swap-deps.yml(Configuration file)
Unlike the current implementation that works with demos/ directories, the global tool will:
- Work in the current directory by default
- Support
--pathoption to specify target directory - Support
--recursiveto process subdirectories
- Clear error messages for missing dependencies
- Validation before making changes
- Rollback on partial failures
- macOS (primary)
- Linux
- Windows (WSL)
- Extract core logic from
demo_scripts - Remove demo-specific assumptions
- Generalize for any project structure
- Create gem with full feature parity
- Test with various project types
- Publish to RubyGems
- Add gem as dependency
- Create wrapper script that delegates to gem
- Maintain backward compatibility
# Global installation
gem install swap-shakacode-deps
# Or add to Gemfile for project-specific use
gem 'swap-shakacode-deps'# Swap to local shakapacker
swap-shakacode-deps --shakapacker ~/dev/shakapacker
# Use GitHub branch
swap-shakacode-deps --github shakacode/react_on_rails#feature-x
# Apply from config
swap-shakacode-deps --apply
# Restore originals
swap-shakacode-deps --restore# .swap-deps.yml
gems:
shakapacker: ~/dev/shakapacker
react_on_rails: ~/dev/react_on_rails
github:
shakapacker:
repo: shakacode/shakapacker
branch: main- Global Availability: Use in any project, not just react_on_rails_demo_common
- Simplified Maintenance: Single source of truth for the tool
- Better Testing: Isolated gem with its own test suite
- Version Management: Semantic versioning for the tool
- Documentation: Dedicated docs for the tool
- Community Contribution: Easier for others to contribute
- Week 1: Core gem structure and logic extraction
- Week 2: Feature implementation and testing
- Week 3: Documentation and publishing
- Week 4: Integration with react_on_rails_demo_common
- All current swap-deps features work globally
- No breaking changes for existing users
- Clear upgrade path
- Comprehensive documentation
- Published to RubyGems
- Works with any Shakacode project