Thank you for your interest in contributing to Craft! This document provides guidelines and instructions for contributing.
- Pantry-managed stable Zig: run
eval "$(pantry env | sed -n '/^export /,$p')", then invokezig - Bun: Install from bun.sh
macOS:
# macOS has native WebKit support, no additional dependencies neededLinux:
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-devWindows:
# Windows support is in developmentgit clone https://github.com/craft-native/craft.git
cd craft# Debug build
zig build
# Release build
zig build -Doptimize=ReleaseSafe
# Run tests
zig build test
# Run example
zig build run
# Run the craft CLI
zig build runcraft/
├── src/ # Zig source code
│ ├── main.zig # Main library entry point
│ ├── api.zig # Public API
│ ├── macos.zig # macOS implementation
│ ├── linux.zig # Linux implementation
│ ├── windows.zig # Windows implementation
│ └── ... # Feature modules
├── build.zig # Zig build configuration
├── bin/ # CLI wrapper scripts
├── scripts/ # Build and release scripts
├── docs/ # Documentation
├── examples/ # Example applications
└── .github/ # CI/CD workflows
git checkout -b feature/your-feature-name- Write clean, well-documented code
- Follow Zig's style guide
- Add tests for new functionality
- Update documentation as needed
bun run fmt# Run all tests
bun run test
# Build and run
zig build
zig build rungit add .
git commit -m "feat: add your feature description"We follow Conventional Commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changeschore:- Maintenance tasksrefactor:- Code refactoringtest:- Test changesperf:- Performance improvements
git push origin feature/your-feature-nameThen open a Pull Request on GitHub.
- Use
zig fmtfor automatic formatting - Follow standard Zig naming conventions:
camelCasefor functions and variablesPascalCasefor types and structsSCREAMING_SNAKE_CASEfor constants
- Add doc comments for public APIs
Example:
/// Creates a new window with the given options.
/// Returns an error if the window cannot be created.
pub fn createWindow(options: WindowOptions) !Window {
// Implementation
}- Use Bun's built-in formatter
- Follow modern ES6+ conventions
- Use TypeScript types where applicable
Add tests in the same file as your implementation:
test "window creation" {
const window = try Window.create(.{
.title = "Test",
.width = 800,
.height = 600,
});
defer window.destroy();
try std.testing.expect(window.width == 800);
}Add examples in the examples/ directory to demonstrate new features.
- Add doc comments to all public APIs
- Include examples in doc comments
- Document edge cases and error conditions
- Update
README.mdfor user-facing changes - Update
API_REFERENCE.mdfor API changes - Add guides to
docs/for complex features
Platform-specific code should be isolated in dedicated files:
src/macos.zig- macOS implementationssrc/linux.zig- Linux implementationssrc/windows.zig- Windows implementations
Use compile-time conditionals in build.zig for platform detection.
Releases are automated through GitHub Actions:
-
Update version in
package.json -
Create and push a git tag:
git tag v0.2.0 git push origin v0.2.0
-
GitHub Actions will:
- Build binaries for all platforms
- Create GitHub release
- Publish to npm
- Generate changelog
- Questions: Open a Discussion
- Bugs: Open an Issue
- Chat: Join our community channels
By contributing to Craft, you agree that your contributions will be licensed under the MIT License.