A command-line interface for managing Contentstack Visual Builder configurations.
Install globally via npm:
npm install -g @contentstack/visual-builder-cli- This CLI is designed to work with Contentstack Visual Builder projects
- You need to have a
configs.jsonfile with your configurations - You must set the config file location before using other commands
visual-builder set "path/to/your/configs.json"The config file should follow this format:
{
"configs": {
"config-name-1": {
"API_KEY": "your-api-key",
"DELIVERY_TOKEN": "your-delivery-token",
"ENVIRONMENT": "development",
"API_HOST": "your-api-host",
"PREVIEW_TOKEN": "your-preview-token",
"APP_HOST": "your-app-host",
"TARGET_APP_URL": "http://localhost:3006",
"STACK_NAME": "Your Stack Name",
"ORG_UID": "your-org-uid",
"BRANCH": "main"
},
"config-name-2": {
// ... another configuration
}
}
}visual-builder set <config-file-path>Set the path to your configs.json file. This can be a relative or absolute path.
Examples:
visual-builder set "data/configs.json"
visual-builder set "/absolute/path/to/configs.json"
visual-builder set "../shared/configs.json"visual-builder csr listShows all available configurations with:
- A marker indicating the current active config (●) vs inactive (○)
- Stack name, environment, and API host for each config
visual-builder csr use "config-name"Examples:
visual-builder csr use "manual testing"
visual-builder csr use "idontknow"
visual-builder csr use "visual builder automation"
visual-builder csr use "manual testing (dev22)"visual-builder csr currentDisplays all the configuration values for the currently active config.
visual-builder --help- The CLI reads from a centralized
configs.jsonfile containing all available configurations - When you select a config, it generates a new
config.tsfile in your project - Your Visual Builder application reads from this generated
config.tsfile - The CLI can detect which configuration is currently active by comparing values
The CLI expects your project to have this structure:
your-project/
├── test-resources/
│ └── csr/
│ └── src/
│ └── config.ts (generated by this CLI)
To add new configurations:
- Edit your
configs.jsonfile (the one you set withvisual-builder set) - Add your new configuration following this format:
{
"configs": {
"your-config-name": {
"API_KEY": "your-api-key",
"DELIVERY_TOKEN": "your-delivery-token",
"ENVIRONMENT": "development",
"API_HOST": "your-api-host",
"PREVIEW_TOKEN": "your-preview-token",
"APP_HOST": "your-app-host",
"TARGET_APP_URL": "http://localhost:3006",
"STACK_NAME": "Your Stack Name",
"ORG_UID": "your-org-uid",
"BRANCH": "main"
}
}
}# Install the CLI globally
npm install -g @contentstack/visual-builder-cli
# Set your config file location (do this once)
visual-builder set "data/configs.json"
# Navigate to your Visual Builder project
cd /path/to/your/visual-builder-project
# List available configurations
visual-builder csr list
# Switch to a specific configuration
visual-builder csr use "manual testing"
# Check what's currently active
visual-builder csr current- 🟢 Green: Current active configuration
- 🟡 Yellow: Available configurations
- 🔵 Blue: Information text
- 🔴 Red: Error messages
- Node.js >= 14.0.0
- npm or yarn
MIT
For issues and questions, please visit the GitHub repository.