WL-Theme CLI: White-Label Theming Toolkit
Overview
wl-theme is a Node.js CLI tool designed for seamless customer onboarding in white-label products. It automates the generation of brand manifests (design token configurations), token diffs (changes from a base theme), and integration tests (UI/component assertions).
This streamlines re-theming SaaS apps, design systems, or component libraries using design tokens (e.g., compatible with Style Dictionary, Tokens Studio, or CSS vars).
Key Benefits for Onboarding:
- Reduces manual config from days to minutes.
- Ensures theme consistency and regression-free updates.
- Provides auditable diffs for brand approval.
- Generates CI-ready tests for production handoff.
Supported Outputs:
- Brand manifests:
brand-manifest.json (tokens + metadata).
- Token diffs:
token-diff.json + token-diff.md (JSON patch + Markdown report).
- Integration tests: Jest/Vitest snapshots or Playwright E2E scripts.
Tech Stack & Installation
- Runtime: Node.js 18+.
- CLI Framework: Oclif (robust, extensible).
- Tokens: Style Dictionary (JSON/TS tokens to CSS/JS).
- Diffs:
json-diff + custom Markdown renderer.
- Tests: Jest for unit (token assertions) + Playwright for E2E (visual/component).
- Validation: AJV (JSON Schema) + Chroma.js (color validation).
npm install -g @wl-theme/cli # Hypothetical publish
wl-theme --version
Project Structure
Initialize a project to get started:
my-brand-theme/
├── base/ # Base theme tokens (git-ignored for customer projects)
│ ├── tokens.json # Default design tokens
│ └── style-dictionary/ # SD config
├── brands/
│ └── acme/ # Per-customer folder
│ ├── inputs/ # Customer uploads: colors.csv, logo.svg, guidelines.pdf (optional)
│ ├── brand-manifest.json
│ ├── token-diff.json
│ ├── token-diff.md
│ ├── dist/ # Generated: tokens.css, tokens.js
│ └── tests/ # Generated tests
├── wl-theme.config.js # CLI config (base path, test framework, etc.)
└── package.json # Dev deps for tests
Core Commands
1. wl-theme init [brandName]
Initializes a customer project folder with base theme copy and templates.
Usage:
wl-theme init acme --base ./base --framework web --testFramework jest
Outputs:
brands/acme/
├── wl-theme.config.js # Pre-filled
├── inputs/ # Empty dir for customer assets
└── base-tokens.json # Copied reference
Config Example (wl-theme.config.js):
module.exports = {
baseTokens: './base/tokens.json',
tokenSchema: './schemas/tokens.json', // AJV validation
platforms: ['css', 'js'], // Outputs
testPages: ['./tests/e2e/pages'], // For Playwright
colorSpaces: ['hsl', 'rgb'], // Validation
};
2. wl-theme generate-manifest [brandName]
Parses customer inputs (CSV/JSON guidelines, images) into a validated brand manifest.
Inputs:
--input colors.csv (e.g., primary,#007BFF;name=Primary Blue)
--logo path/to/logo.svg (extracts colors, sizes)
--guidelines json (structured brand book)
Usage:
wl-theme generate-manifest acme \
--input ./inputs/colors.csv \
--logo ./inputs/logo.svg \
--typography '{"fontFamily": "Inter", "sizes": {"h1": "2rem"}}'
Outputs (brand-manifest.json):
{
"$schema": "https://raw.githubusercontent.com/wl-theme/schemas/main/brand-manifest.json",
"brand": {
"name": "Acme Corp",
"logo": {"src": "logo.svg", "width": 120},
"metadata": {"version": "1.0", "approved": false}
},
"tokens": {
"color": {
"primary": {"value": "#007BFF", "hsl": [210, 100%, 50%], "type": "brand"},
"secondary": {"value": "#6C757D"}
},
"typography": {
"fontFamily": {"value": "Inter, sans-serif"},
"h1": {"value": {"fontSize": "2rem", "fontWeight": 700}}
},
"spacing": {"medium": {"value": "16px"}}
},
"overrides": ["color.primary", "typography.fontFamily"] // Explicit changes
}
- Validates colors (contrast ratios via
@accessible/colors), scales spacing, etc.
3. wl-theme diff [brandName]
Compares brand manifest against base tokens, generates diffs.
Usage:
wl-theme diff acme --format md,json --threshold 0.1 # Ignore <10% changes
Outputs:
token-diff.json: RFC 6902 JSON Patch.
[
{"op": "replace", "path": "/tokens/color/primary/value", "value": "#007BFF"}
]
token-diff.md: Human-readable report.
# Token Changes: Acme vs Base
## Colors (2 changes)
| Token | Base | Brand | Diff |
|-------|------|-------|------|
| color.primary | #4285F4 | #007BFF | HSL Δ: 20° hue shift |
## Approvals Needed
- High-impact: color.primary (used in 15 components)
4. wl-theme tests [brandName]
Generates integration tests for tokens, CSS vars, and UI components.
Usage:
wl-theme tests acme --type unit,e2e --framework jest --update # --update for snapshots
Outputs (tests/):
- Unit (
tokens.test.js): Jest assertions.
import { tokens } from '../dist/tokens.js';
describe('Acme Tokens', () => {
it('matches manifest', () => {
expect(tokens.color.primary.value).toBe('#007BFF');
});
});
- E2E (
playwright/theme.spec.js): Visual/component tests.
import { test, expect } from '@playwright/test';
test('Primary Button Theme', async ({ page }) => {
await page.goto('/components/button');
await expect(page.locator('button.primary')).toHaveCSS('--color-primary', 'rgb(0, 123, 255)');
await expect(page).toHaveScreenshot('button-primary.png');
});
- Runs on
dist/tokens.css injected into test env.
5. wl-theme build [brandName]
Full pipeline: manifest → diff → dist → tests.
Usage:
wl-theme build acme --watch # Dev mode
- Compiles tokens to
dist/ via Style Dictionary.
- Runs
npm test post-generation.
6. wl-theme validate [brandName]
Lint manifest/diffs/tests (contrast, WCAG, token completeness).
Onboarding Workflow
- Sales/Onboarder:
wl-theme init acme, share inputs/ folder.
- Customer: Uploads assets to
inputs/.
- Designer:
generate-manifest, review token-diff.md, approve.
- Dev:
build acme, merge dist/ + tests/ to app.
- CI/CD: Tests run on PRs; diffs block merges if unapproved.
Extensibility
- Plugins:
--plugin @wl-theme/react for RN tokens.
- Hooks:
wl-theme.config.js pre/post hooks (e.g., Figma import).
- Schemas: Customize
./schemas/ for your design system.
Roadmap
- Figma/CSV auto-import.
- AI color palette suggestions.
- Multi-brand manifests.
Get Started: Clone hypothetical repo, npm link. For customizations, open an issue! 🕵️♂️