Thank you for your interest in contributing to UTPM! This document provides guidelines and standards for contributing to the project.
UTPM uses rustfmt to ensure consistent code formatting across the project.
Before submitting a PR:
# Format your code
cargo fmt --all
# Or use just
just fmtTo check formatting without changes:
cargo fmt --all -- --check
# Or
just fmt-checkConfiguration is in rustfmt.toml.
UTPM uses Clippy to catch common mistakes and enforce best practices.
Run Clippy:
cargo clippy --all-targets --all-features -- -D warnings
# Or
just clippyAuto-fix Clippy issues:
cargo clippy --all-targets --all-features --fix --allow-dirty
# Or
just clippy-fixConfiguration is in clippy.toml.
All new features and bug fixes should include tests.
Run tests:
cargo test --all-features
# Or
just testRun tests with output:
cargo test --all-features -- --nocapture
# Or
just test-verboseSee Testing Guide for comprehensive testing documentation, including:
- Test structure and categories
- Writing new tests
- Running specific test suites
- Test helpers and utilities
- Debugging tests
# Clone the repository
git clone https://github.com/typst-community/utpm.git
cd utpm
# Install git hooks (optional but recommended)
just setup-hooksThe git hooks will automatically run formatting checks, Clippy, and tests before each commit.
-
Create a new branch for your feature/fix:
git checkout -b feature/my-awesome-feature
-
Make your changes following the code standards
-
Format and lint your code:
just fix # Auto-format and fix Clippy issues -
Run tests:
just test -
Commit your changes:
git add . git commit -m "feat: add my awesome feature"
Run all checks to ensure your code is ready:
just ciThis will run:
- Format check (
cargo fmt -- --check) - Clippy (
cargo clippy) - Tests (
cargo test)
-
Push your branch:
git push origin feature/my-awesome-feature
-
Open a Pull Request on GitHub
-
Ensure all CI checks pass
-
Address any review feedback
We follow Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, missing semicolons, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testschore: Maintenance tasksci: CI/CD changes
Examples:
feat(metadata): add command to extract typst.toml metadata
fix(link): respect typst_ignore flag when linking packages
docs: update README with metadata command examples
chore: add rustfmt and clippy configuration
See the source code and comments for detailed project architecture and patterns.
Key principles:
- All commands are in
src/commands/ - Utilities are in
src/utils/ - Use
utpm_log!for logging - Use
utpm_bail!for errors - Check
get_dry_run()before file operations - All command functions are
async
- Create
src/commands/new_command.rs - Add to
src/commands.rs(module declaration and args struct) - Add to command enum in
src/commands.rs - Add dispatcher in
src/main.rs - Add tests
- Update documentation (README.md, CONTRIBUTING.md, DEVELOPMENT.md)
See the Metadata command as a reference implementation.
We use just as a command runner. Install it:
cargo install justAvailable commands:
just --list # Show all available commands
just fmt # Format code
just clippy # Run Clippy
just test # Run tests
just ci # Run all CI checks
just fix # Auto-fix formatting and Clippy issues
just build-release # Build in release mode
just install-local # Install to ~/.cargo/bin
just setup-hooks # Setup git hooksAn .editorconfig file is provided for consistent editor settings. Most modern editors support EditorConfig automatically or via plugins.
- Issues: Open an issue on GitHub for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Documentation: Check the source code for technical details
By contributing to UTPM, you agree that your contributions will be licensed under the MIT License.