-
-
Notifications
You must be signed in to change notification settings - Fork 8
Contributing
Thank you for your interest in contributing to mage-db-sync! We welcome contributions from the community.
Before you begin:
- Read the documentation to understand what the project does
- Check existing issues to see if your contribution is already being discussed
- For major changes, open an issue first to discuss your proposed changes
- Basic understanding of TypeScript
- Basic understanding of SSH and database operations (for testing)
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/mage-db-sync.git cd mage-db-sync -
Add upstream remote:
git remote add upstream https://github.com/jellesiderius/mage-db-sync.git
-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Test your local version:
npm link # Now you can run mage-db-sync from anywhere -
Development workflow:
For active development, use TypeScript's watch mode for automatic compilation:
# In one terminal, start the TypeScript compiler in watch mode tsc --watchThis will automatically recompile your TypeScript files whenever you save changes, making development faster and more convenient. You can then test your changes immediately with
mage-db-syncin another terminal.
mage-db-sync/
├── src/
│ ├── controllers/ # Command controllers (start, open-folder, etc.)
│ ├── core/ # Core services (DI container, task factory)
│ ├── models/ # Data models
│ ├── questions/ # Interactive CLI questions
│ ├── services/ # Business logic services
│ ├── tasks/ # Task implementations (download, import, etc.)
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions and helpers
├── config/ # Configuration samples
├── scripts/ # Build and setup scripts
├── bin/ # CLI entry point
└── dist/ # Compiled JavaScript (generated)
-
src/mage-db-sync.ts- Main entry point -
src/controllers/StartController.ts- Main workflow orchestration -
src/tasks/DownloadTask.ts- Database download logic -
src/services/ConfigService.ts- Configuration management -
src/utils/ConfigPathResolver.ts- Config file resolution logic
- Use TypeScript for all new code
- Enable strict mode where possible
- Provide proper type definitions (avoid
anywhen possible) - Use meaningful variable and function names
- Use 4 spaces for indentation
- Follow existing code style in the project
- Run the linter before committing:
npm run lint
-
Error Handling: Provide clear, actionable error messages
- Include file paths when relevant
- Suggest solutions with
[TIP]hints - Don't show stack traces to end users (only in debug mode)
-
Logging: Use the logger service for important operations
const logger = this.services.getLogger(); logger.info('Operation completed', { component: 'YourComponent' });
-
User Experience:
- Keep CLI output clean and informative
- Use progress indicators for long operations
- Show clear success/error messages
-
Security:
- Never log sensitive data (passwords, SSH keys)
- Validate user input
- Use secure file permissions
- Write self-documenting code
- Add comments for complex logic
- Document public APIs with JSDoc:
/** * Resolves config file path with fallback mechanism * * @param relativePath - Relative path within config directory * @returns Full path to config file, or null if not found */ public static resolveConfigPath(relativePath: string): string | null { // ... }
Currently, the project relies on manual testing. When contributing:
-
Test your changes thoroughly:
- Test with different strip modes (stripped, full, custom)
- Test with and without import enabled
- Test error conditions and edge cases
-
Test in different scenarios:
- Fresh install
- Upgrade from previous version
- With and without
.mage-db-sync-config.json
-
Test the full workflow:
- Database download
- Database import
- Configuration resolution
Once you've completed your changes and tested them thoroughly, follow these steps to submit a pull request:
-
Commit your changes:
git add . git commit -m "Clear description of your changes"
-
Push to your fork:
git push origin your-branch-name
-
Create a Pull Request:
- Go to your fork on GitHub
- Click "Pull Request" or "Compare & pull request"
- Fill in a clear title and description
- Reference any related issues (e.g., "Fixes #123")
- Describe what you changed and why
-
PR Description Template:
## Description Brief description of the changes ## Changes Made - Change 1 - Change 2 ## Testing How you tested the changes ## Related Issues Fixes #123
-
Wait for review:
- Maintainers will review your PR
- Be responsive to feedback and questions
- Make any requested changes by pushing to the same branch
We welcome many types of contributions:
- New Features: Add new functionality
- Bug Fixes: Fix reported issues
- Performance: Improve speed or efficiency
- Refactoring: Improve code quality without changing behavior
- README: Improve main documentation
- Code Comments: Add or improve inline documentation
- Wiki: Add guides and tutorials
- Examples: Add example configurations
Thank you for contributing to mage-db-sync! 🎉