Command-line tools for theme development
Validate, inspect, compare, and export themes from the command line. Integrate theme tools into your build process and CI/CD pipeline.
# Install globally
npm install -g @shohojdhara/atomix
# Verify installation
atomix-theme --version# Install as dev dependency
npm install --save-dev @shohojdhara/atomix
# Use with npx
npx atomix-theme --help| Command | Description | Options |
|---|---|---|
validate | Validate theme configuration | --config, --strict |
list | List all available themes | - |
inspect | Inspect a specific theme | --theme, --json |
compare | Compare two themes | --theme1, --theme2 |
export | Export theme to JSON | --theme, --output |
help | Show help information | - |
Validate a theme configuration file:
# Validate default config
atomix-theme validate
# Validate specific config file
atomix-theme validate --config ./my-theme.json
# Strict mode (fail on warnings)
atomix-theme validate --strictDisplay all available themes:
# List all themes
atomix-theme list
# Output:
# Available themes:
# - light (Light Theme)
# - dark (Dark Theme)
# - custom (Custom Theme)Get detailed information about a theme:
# Inspect theme (human-readable)
atomix-theme inspect --theme light
# Inspect theme (JSON output)
atomix-theme inspect --theme light --json
# Pipe to file
atomix-theme inspect --theme light --json > theme-info.jsonCompare two themes and show differences:
# Compare two themes
atomix-theme compare --theme1 light --theme2 dark
# Compare theme files
atomix-theme compare --theme1 ./v1.json --theme2 ./v2.json
# Output differences only
atomix-theme compare --theme1 light --theme2 dark --diff-onlyExport a theme to JSON file:
# Export to default location
atomix-theme export --theme light
# Export to specific file
atomix-theme export --theme light --output ./themes/light.json
# Export with formatting
atomix-theme export --theme light --output ./light.json --prettyValidate themes in your CI pipeline:
1name: Validate Themes
2
3on: [push, pull_request]
4
5jobs:
6 validate:
7 runs-on: ubuntu-latest
8 steps:
9 - uses: actions/checkout@v3
10
11 - name: Setup Node.js
12 uses: actions/setup-node@v3
13 with:
14 node-version: '18'
15
16 - name: Install dependencies
17 run: npm install
18
19 - name: Validate themes
20 run: npx atomix-theme validate --strict
21
22 - name: Compare with main
23 if: github.event_name == 'pull_request'
24 run: |
25 git fetch origin main
26 npx atomix-theme compare \
27 --theme1 ./themes/current.json \
28 --theme2 ./themes/new.jsonAdd theme validation to package.json:
1{
2 "scripts": {
3 "theme:validate": "atomix-theme validate",
4 "theme:validate:strict": "atomix-theme validate --strict",
5 "theme:list": "atomix-theme list",
6 "theme:export": "atomix-theme export --theme custom --output ./dist/theme.json",
7 "pretest": "npm run theme:validate"
8 }
9}Validate themes before committing:
1# .husky/pre-commit
2#!/bin/sh
3. "$(dirname "$0")/_/husky.sh"
4
5# Validate theme files
6npx atomix-theme validate --strict
7
8# Exit if validation fails
9if [ $? -ne 0 ]; then
10 echo "Theme validation failed. Please fix errors before committing."
11 exit 1
12fiCreate atomix.config.ts in your project root:
1import { defineConfig } from '@shohojdhara/atomix/config';
2
3export default defineConfig({
4 theme: {
5 themes: {
6 'my-theme': {
7 type: 'css',
8 name: 'My Theme',
9 description: 'Custom theme',
10 version: '1.0.0',
11 },
12 },
13 },
14});Configure CLI behavior with environment variables:
# Set config file path
export ATOMIX_CONFIG=./config/atomix.config.ts
# Set theme directory
export ATOMIX_THEME_DIR=./src/themes
# Enable debug mode
export ATOMIX_DEBUG=trueIf atomix-theme command is not found:
# Use npx instead
npx atomix-theme --help
# Or install globally
npm install -g @shohojdhara/atomixEnsure atomix.config.ts exists in project root:
# Check if config exists
ls atomix.config.ts
# Specify config path
atomix-theme validate --config ./path/to/config.tsRun validation with verbose output:
# Verbose validation
atomix-theme validate --verbose
# Debug mode
ATOMIX_DEBUG=true atomix-theme validateThe CLI complements the React devtools components: