dfxmon CLI
Command-line interface for dfxmon - the universal file watcher and auto-deployment tool for Internet Computer (ICP) projects.
Overview
The dfxmon CLI is a client tool that communicates with the dfxmon canister deployed on the Internet Computer. It provides a seamless interface for managing file watching and automatic deployment of your ICP projects.
Installation
From crates.io
From GitHub Releases
Download the latest binary for your platform from the GitHub Releases page.
Real-World Usage
Working with an Existing ICP Project
Assuming you have a typical ICP project structure:
my-dapp/
├── dfx.json
├── src/
│ ├── backend/
│ │ ├── main.mo # Motoko backend
│ │ └── types.mo
│ ├── frontend/
│ │ ├── src/
│ │ │ ├── App.tsx # React frontend
│ │ │ └── index.ts
│ │ └── package.json
│ └── shared/
│ └── types.did
└── canister_ids.json
Step 1: Register your project with dfxmon
Step 2: Start development with auto-deployment
Now when you edit files, dfxmon automatically handles deployments:
- Edit
src/backend/main.mo
→ Backend canister redeploys - Edit
src/frontend/src/App.tsx
→ Frontend assets redeploy - Edit
src/shared/types.did
→ Both canisters redeploy
Commands
dfxmon create
Create a new project in the dfxmon canister.
dfxmon watch
Start watching a project for file changes.
)
dfxmon deploy
Manually trigger deployment of a project or specific canister.
dfxmon status
Get the status of a project.
dfxmon list
List all projects managed by the dfxmon canister.
dfxmon history
View deployment history for a project.
dfxmon settings
View or update global settings.
)
Configuration
Canister ID
The CLI comes with embedded canister IDs for both local and mainnet networks:
- Local:
uxrrr-q7777-77774-qaaaq-cai
(automatically used with--network local
) - Mainnet:
yvfam-kiaaa-aaaag-aucfa-cai
(automatically used with--network mainnet
)
No configuration required! The CLI automatically selects the correct canister based on your network.
You can override the embedded IDs if needed:
-
Command line flag:
-
Environment variable:
-
Configuration file (
.dfxmon.toml
in current directory or home):= "your-custom-canister-id" = "local"
Network Configuration
The CLI supports convenient network shortcuts:
--network local
→http://localhost:4943
(default)--network mainnet
or--network ic
→https://ic0.app
- Custom URLs:
--network https://your-custom-replica.com
Examples:
# Local development (default)
# Mainnet
# Custom network
Or set the network in configuration:
= "mainnet" # or "local", "ic", or custom URL
File Watching
When you run dfxmon watch
, the CLI starts a local file watcher that monitors your project directory for changes. When changes are detected, it notifies the dfxmon canister, which then triggers the appropriate deployment.
Supported File Types
- Motoko:
.mo
files - Rust:
.rs
files - Frontend:
.js
,.ts
,.jsx
,.tsx
,.html
,.css
,.scss
- Configuration:
.json
,.toml
,.did
- Documentation:
.md
Ignored Patterns
The following files and directories are automatically ignored:
.dfx/
- DFX build artifactstarget/
- Rust build artifactsnode_modules/
- Node.js dependencies.git/
- Git repository filesdist/
,build/
- Build output directories- Temporary files (
*.tmp
,*.swp
,*~
)
Examples
Multi-Canister Rust Project
Working on a DeFi project with multiple Rust canisters:
# Project structure:
# defi-dapp/
# ├── src/
# │ ├── token/src/lib.rs # Token canister
# │ ├── exchange/src/lib.rs # Exchange canister
# │ ├── governance/src/lib.rs # Governance canister
# │ └── frontend/src/App.tsx # React frontend
# └── dfx.json
# Now edit src/token/src/lib.rs
# → Only the token canister rebuilds and redeploys
# → Other canisters remain untouched
Frontend-Heavy Development
Working on a social media dapp with frequent UI changes:
# Focus only on frontend changes
# Edit src/frontend/components/Feed.tsx
# → Frontend assets rebuild and redeploy instantly
# → Backend canisters stay running without interruption
Motoko Backend with TypeScript Frontend
Typical full-stack development workflow:
# Project: chat-app
# Terminal 1: dfxmon watching
# Terminal 2: Your editor
# Edit src/backend/main.mo (add new message type)
# → Backend redeploys, Candid interface updates
# → dfxmon detects interface change, triggers frontend rebuild
# Edit src/frontend/src/types.ts (update types)
# → Frontend rebuilds with new types
# → Hot reload in browser shows changes immediately
Production Deployment Monitoring
Using dfxmon to track deployments on mainnet:
# Connect to mainnet dfxmon canister
# Check production deployment history
# Monitor deployment status
Troubleshooting
Common Issues
-
"Canister ID not provided"
- Set the canister ID via
--canister-id
, environment variable, or config file
- Set the canister ID via
-
"Failed to connect to replica"
- Ensure your local replica is running (
dfx start
) - Check network configuration
- Ensure your local replica is running (
-
"Permission denied"
- Ensure you have the necessary permissions to interact with the canister
- For local development, make sure you're using the correct identity
-
"File watching not working"
- Check that you're in the correct project directory
- Verify the project exists in the dfxmon canister (
dfxmon list
)
Debug Mode
Enable verbose logging for troubleshooting:
RUST_LOG=debug
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Author
Created by Dedan Okware (softengdedan@gmail.com)