CLI interface to devhub
Install this tool using pip
:
pip install devhub-cli
Or just install and execute via uvx
uvx devhub-cli
For help, run:
devhub --help
You can also use:
python -m devhub --help
Via uvx
uvx devhub-cli
The DevHub CLI provides powerful theme management capabilities for synchronizing and managing your DevHub theme components locally.
Before using theme commands, you need to initialize your environment:
# Initialize in current directory
devhub theme init
# Initialize in a new directory
devhub theme init mybrand-corporate-theme
This command will:
- Create a
.env
file with your DevHub API credentials - Generate a
.gitignore
file with appropriate exclusions - Create a
devhub.conf.json
configuration file
When specifying a directory, the command will create the directory if it doesn't exist and initialize all configuration files within it.
You'll be prompted to enter:
DEVHUB_API_KEY
- Your OAuth1 API keyDEVHUB_API_SECRET
- Your OAuth1 API secretDEVHUB_BASE_URL
- Your DevHub instance URL (e.g., https://yourbrand.cloudfrontend.net)DEVHUB_SITE_ID
- Your site identifier
Lists all available theme templates and components that can be synchronized.
devhub theme list
Shows the synchronization status of all theme components, indicating which files have changes compared to the remote version.
devhub theme status
Synchronizes theme components from your DevHub instance to local files.
# Sync all components
devhub theme sync
# Sync specific components only
devhub theme sync layouts/headers/DefaultHeader.html components/HeroSection/HeroSection.jinja
The sync command will:
- Download theme files (CSS, headers, footers, localization) to the
layouts/
directory - Download template components to the
components/
directory as.jinja
files - Format templates using
djlint
with 2-space indentation - Convert component names from slug-case to PascalCase (e.g.,
hero-section
→HeroSection.jinja
) - Perform checksum comparison to detect conflicts between local and remote changes
After initialization and synchronization, your project structure will look like:
your-project/
├── .env # Environment variables (not committed)
├── .gitignore # Git exclusions
├── devhub.conf.json # CLI configuration
├── layouts/ # Theme templates (headers, footers, CSS)
│ ├── headers/DefaultHeader.jinja
│ ├── footers/DefaultFooter.jinja
├── styles/ # CSS styles
│ └── globals.css
└── components/ # Template components
├── HeroSection/HeroSection.jinja
├── ProductCard/ProductCard.jinja
└── NavigationMenu/NavigationMenu.jinja
The CLI uses OAuth1 authentication to connect to your DevHub instance. All sensitive credentials are stored in the .env
file, which should never be committed to version control.
Required environment variables:
DEVHUB_API_KEY
- OAuth1 API keyDEVHUB_API_SECRET
- OAuth1 API secretDEVHUB_BASE_URL
- Base URL for DevHub APIDEVHUB_SITE_ID
- Site identifier
The DevHub CLI includes AI toolkit management for setting up AI-powered development tools and templates.
Downloads and installs the DevHub AI toolkit to your current working directory.
devhub aikit init
This command will:
- Download the latest AI toolkit from the DevHub CLI AI Toolkit repository
- Extract all toolkit files to your current directory
- Skip existing files to avoid overwriting your customizations
- Provide feedback on extracted and skipped files
The AI toolkit includes templates, examples, and utilities for AI-powered development workflows with DevHub.
To contribute to this tool, first checkout the code. Then create a new virtual environment:
cd devhub-cli
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
python -m pytest
CLI click template based on https://github.com/simonw/click-app