3 releases
Uses new Rust 2024
| 0.1.2 | Jan 13, 2026 |
|---|---|
| 0.1.1 | Jan 5, 2026 |
| 0.1.0 | Jan 5, 2026 |
#274 in FFI
88KB
2K
SLoC
Bridge CLI
Command-line interface for the BridgeRust framework - write Rust once, deploy to Python and Node.js.
Website: bridgerust.dev
Installation
cargo install bridge
Or from the workspace root:
cargo build --release --bin bridge
Commands
bridge init <name>
Initialize a new BridgeRust project with the proper structure.
bridge init my-project
This creates:
Cargo.tomlwith proper dependenciessrc/lib.rswith example functionsbridgerust.tomlconfiguration filepython/pyproject.tomlfor Python packagingnodejs/package.jsonfor Node.js packagingREADME.mdwith usage instructions
bridge integrate [--example]
Integrate BridgeRust into an existing Rust project.
# Integrate into current project
bridge integrate
# Integrate and add example code
bridge integrate --example
# Skip prompts
bridge integrate --yes
This command:
- Updates
Cargo.tomlwith BridgeRust dependencies and features - Creates
bridgerust.tomlconfiguration file - Creates
python/andnodejs/directories - Generates
python/pyproject.tomlandnodejs/package.json - Optionally adds example code to
src/lib.rs
Note: This command reads your existing Cargo.toml to get project name, version, and description. It won't overwrite existing files unless you confirm.
bridge build [--target <target>] [--release]
Build Python and/or Node.js bindings.
# Build for all targets (in parallel)
bridge build --all
# Build only Python
bridge build --target python
# Build only Node.js
bridge build --target nodejs
# Build in release mode
bridge build --all --release
Note:
- When building all targets (
--all), Python and Node.js builds run in parallel for faster builds. - Build caching is enabled for debug builds (not
--release). The CLI checks source file timestamps and skips rebuilds when nothing has changed.
bridge test [--target <target>]
Run tests for Rust, Python, and/or Node.js.
# Test all targets
bridge test --all
# Test only Python
bridge test --target python
# Test only Node.js
bridge test --target nodejs
# Test only Rust
bridge test --target rust
Note:
- Python tests use
pytest(must be installed:pip install pytest) - Node.js tests use
npm testif available, otherwise runs test files directly withnode - Rust tests use
cargo test - The command automatically finds test files in common locations
bridge publish [--target <target>] [--dry-run]
Publish packages to PyPI and/or npm.
# Publish to all registries
bridge publish --all
# Dry run (test without publishing)
bridge publish --all --dry-run
# Publish only Python
bridge publish --target python
# Publish only Node.js
bridge publish --target nodejs
Note:
- The command runs pre-publish validation checks before publishing
- Requires
maturinfor Python publishing (install with:pip install maturin) - Requires
npmfor Node.js publishing - Uses real-time output so you can see publish progress
- In dry-run mode, packages are validated but not uploaded
bridge workflows [--output <dir>]
Generate CI/CD workflow files for GitHub Actions.
# Generate workflows in default location (.github/workflows)
bridge workflows
# Generate workflows in custom location
bridge workflows --output .github/workflows
This command generates:
- CI workflow (
ci.yml): Runs on every push and PR- Rust tests (format, clippy, unit tests)
- Python tests (Python 3.10, 3.11, 3.12)
- Node.js tests (Node.js 20, 22)
- Release workflow (
release.yml): Runs on version tags- Builds all targets in release mode
- Publishes to PyPI and npm (requires secrets)
Note:
- After generating, add
PYPI_API_TOKENandNPM_TOKENsecrets to your GitHub repository - Optionally create a
publishenvironment for manual approval before publishing
bridge check [--verbose]
Validate project structure, configuration, and code without building.
# Check project
bridge check
# Check with verbose output
bridge check --verbose
This command verifies:
- Project structure (Cargo.toml, src/lib.rs, etc.)
- Configuration files (bridgerust.toml)
- Dependencies and features in Cargo.toml
- Source code for bridgerust usage (counts exports, checks for common issues)
- Python and Node.js setup
- Code compilation (cargo check)
Note:
- Use
--verboseto see detailed information about configuration and source code analysis - The command counts
#[export]and#[error]macro usage - In verbose mode, shows real-time compilation output
bridge clean [--target <target>] [--cache]
Clean build artifacts and optionally the build cache.
# Clean all build artifacts
bridge clean
# Clean specific target
bridge clean --target python
bridge clean --target nodejs
# Clean build cache
bridge clean --cache
# Clean everything including cache
bridge clean --all --cache
This command removes:
- Python wheels and dist directories
- Node.js native modules and type definitions
- Build cache (if
--cacheis specified)
Note: For Rust build artifacts, use cargo clean for more control.
bridge watch [--target <target>] [--test]
Watch for file changes and automatically rebuild (and optionally test) when files are modified.
# Watch all targets
bridge watch
# Watch only Python
bridge watch --target python
# Watch and run tests after each build
bridge watch --test
# Watch Node.js with tests
bridge watch --target nodejs --test
Features:
- Automatically watches
src/directory for.rsfile changes - Watches
Cargo.toml,pyproject.toml, andpackage.jsonfor config changes - Debounces file changes (500ms) to avoid excessive rebuilds
- Uses
maturin developfor Python (faster development builds) - Shows real-time build output
- Press Ctrl+C to stop watching
Note:
- This command is ideal for active development
- Python builds use
maturin developwhich installs the package in development mode - Node.js builds use
npm run build(make sure your package.json has a build script)
Configuration
BridgeRust uses a bridgerust.toml file for project configuration:
[package]
name = "my-project"
version = "0.1.0"
description = "My awesome project"
authors = ["Your Name"]
[python]
module_name = "my_project"
[nodejs]
package_name = "@bridgerust/my-project"
Examples
See the examples directory for complete examples of BridgeRust projects.
Dependencies
~9–22MB
~256K SLoC