feat: add URL replacements feature with comprehensive debugging#57
Closed
feat: add URL replacements feature with comprehensive debugging#57
Conversation
6a3e1f0 to
a52c2ec
Compare
This commit implements comprehensive URL replacement functionality for enterprise environments, along with shell integration, environment management improvements, and enhanced test reliability. **URL Replacement Features:** - Global URL replacement configuration in ~/.mvx/config.json5 - Support for simple string replacements (github.com -> nexus.internal) - Support for regex replacements with capture groups - CLI commands for managing URL replacements - Automatic integration with all tool downloads - First-match-wins processing for predictable behavior - Comprehensive validation for regex patterns **New CLI Commands:** - mvx config show - Display current global configuration - mvx config set-url-replacement <pattern> <replacement> - mvx config remove-url-replacement <pattern> - mvx config clear-url-replacements - mvx config edit - Open config file in editor **Shell Integration Features:** - mvx shell command for executing commands in mvx environment - Shell activation support for automatic environment setup - Cross-platform shell hooks and activation scripts - mvx activate/deactivate commands for shell integration - mvx env command for environment variable management **Environment Management Improvements:** - Safe environment variable management with EnvironmentManager - Intelligent PATH handling with deduplication - Change detection to reduce verbose logging noise - Track original environment variable values - Only log actual environment changes, not passthrough values **Test Reliability Improvements:** - Fix Java executable detection to prevent bin/bin/java path errors - Add proper working directory restoration in test cleanup - Skip 'bin' directories when searching for nested Java installations - Add comprehensive Java installation debug test for CI troubleshooting - Improved test isolation to prevent cross-test contamination **Technical Implementation:** - Added pkg/config/global.go for global configuration management - Added pkg/tools/url_replacements.go for URL replacement logic - Added pkg/tools/environment.go for safe environment variable management - Added pkg/util/log.go for centralized logging utilities - Enhanced EnvironmentManager with change detection capabilities - Integrated URL replacements into pkg/tools/download.go - Added comprehensive test suites and documentation **Files Added/Modified:** - cmd/config.go - CLI commands for configuration management - cmd/shell.go - Shell command implementation - cmd/activate.go - Shell activation support - cmd/deactivate.go - Shell deactivation support - cmd/env.go - Environment variable management - cmd/root.go - Register new commands - pkg/config/global.go - Global configuration management - pkg/tools/url_replacements.go - URL replacement logic - pkg/tools/environment.go - Environment variable management - pkg/tools/download.go - Integration with URL replacements - pkg/tools/manager.go - Enhanced tool management - pkg/util/log.go - Centralized logging utilities - website/content/url-replacements.md - Documentation - test/integration_test.go - Enhanced integration tests - test/java_debug_test.go - CI debugging capabilities This implementation uses global-only configuration for security and simplicity, avoiding the complexity of project-level overrides while providing enterprise users with the flexibility they need for internal mirrors and proxies. Closes #40
a52c2ec to
7b7d40a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a comprehensive URL replacements feature to mvx, allowing users to redirect URLs for tools and dependencies to internal mirrors, proxies, or alternative sources. This is essential for enterprise environments with restricted internet access or custom artifact repositories.
Features Added
🔄 URL Replacements
📚 Documentation
/website/content/url-replacements.md🧪 Testing
Configuration Example
Implementation Details
Core Components
pkg/tools/url_replacements.go: Main implementation with URLReplacer structpkg/config/config.go: Configuration integrationProcessing Order
"github.com": "internal.com")"regex:^http://(.+)$": "https://$1")Testing Coverage
Unit Tests (
pkg/tools/url_replacements_test.go)Integration Tests
Debug Improvements
To help diagnose CI test failures, this PR also includes extensive debugging enhancements:
🔍 Comprehensive CI Debugging
🐛 Enhanced Test Output
Compatibility
Use Cases
Enterprise Environments
Development with Proxies
Mirror Repositories
Files Changed
Core Implementation
pkg/tools/url_replacements.go- Main URL replacement logicpkg/tools/url_replacements_test.go- Comprehensive test suitepkg/config/config.go- Configuration integrationDocumentation
website/content/url-replacements.md- Complete user guideREADME.md- Updated with URL replacements featureTesting & Debugging
test/integration_test.go- Enhanced debugging for CI environmentsBreaking Changes
None - This is a purely additive feature that maintains full backward compatibility.
Migration Guide
No migration required. To use URL replacements, simply add the
url_replacementssection to your.mvx/config.json5file.Future Enhancements
Ready for review! This PR provides a robust, well-tested URL replacements feature that will significantly improve mvx usability in enterprise and restricted network environments.
Pull Request opened by Augment Code with guidance from the PR author