tokvista 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,12 @@ Zero configuration. Multiple formats. One command.
22
22
  - 🔄 **Multi-format support** - Token Studio, W3C, Style Dictionary, Supernova, Figma API
23
23
  - 📋 **Smart copy** - CSS Variables, SCSS, or Tailwind with one click
24
24
  - 🔍 **Instant search** - `Cmd+K` / `Ctrl+K` to find any token
25
- - 🎯 **Zero config** - Works out of the box with any token format
25
+ - 🔗 **Deep linking** - Share direct URLs to specific tokens
26
+ - 🔬 **Token scanner** - Find unused tokens and hardcoded values
27
+ - ✅ **Validation** - Check token structure and catch errors
28
+ - 🔄 **Format conversion** - Convert between token formats
29
+ - 📤 **Export** - Generate CSS, SCSS, JS, or Tailwind config
30
+ - 🎯 **Zero config** - Works out of the box
26
31
  - ⚡ **Two modes** - CLI for quick preview or React component for apps
27
32
  - 🔥 **Live reload** - Auto-refresh on file changes
28
33
 
@@ -72,139 +77,159 @@ No configuration needed - just pass your tokens.
72
77
 
73
78
  ---
74
79
 
75
- ## CLI Usage
80
+ ## CLI Commands
76
81
 
77
- ### Basic
82
+ ### Preview & Documentation
78
83
 
79
84
  ```bash
80
- # Use default tokens.json
81
- npx tokvista
82
-
83
- # Specify token file
84
- npx tokvista ./design-tokens.json
85
+ # Start interactive documentation
86
+ npx tokvista tokens.json
85
87
 
86
88
  # Custom port
87
89
  npx tokvista tokens.json --port 4000
88
90
 
89
91
  # Don't open browser
90
92
  npx tokvista tokens.json --no-open
93
+
94
+ # Disable live reload
95
+ npx tokvista tokens.json --no-watch
91
96
  ```
92
97
 
93
- ### Export Tokens
98
+ ### Setup & Configuration
94
99
 
95
100
  ```bash
96
- # Export to CSS
97
- npx tokvista export tokens.json --format css --output tokens.css
101
+ # Interactive setup wizard
102
+ npx tokvista init
98
103
 
99
- # Export to SCSS
100
- npx tokvista export tokens.json --format scss --output _tokens.scss
104
+ # Force overwrite existing config
105
+ npx tokvista init --force
101
106
 
102
- # Export to JavaScript
103
- npx tokvista export tokens.json --format json --output tokens.js
107
+ # Skip preview after setup
108
+ npx tokvista init --no-preview
109
+ ```
104
110
 
105
- # Export to Tailwind config
106
- npx tokvista export tokens.json --format tailwind --output tailwind.config.js
111
+ ### Scan & Analyze
107
112
 
108
- # Print to stdout (for piping)
109
- npx tokvista export tokens.json --format css
113
+ ```bash
114
+ # Scan for token usage and issues
115
+ npx tokvista scan tokens.json
116
+
117
+ # Scan specific directory
118
+ npx tokvista scan ./src --tokens tokens.json
119
+
120
+ # Finds:
121
+ # - Unused tokens (safe to remove)
122
+ # - Hardcoded colors that should use tokens
123
+ # - Hardcoded spacing values
124
+ # - Semantic tokens with hardcoded values
110
125
  ```
111
126
 
112
- ### Validate Tokens
127
+ ### Validate & Quality
113
128
 
114
129
  ```bash
115
- # Check for errors
130
+ # Validate token structure
116
131
  npx tokvista validate tokens.json
117
132
 
118
- # Use in CI/CD (exits with code 1 on errors)
119
- npm run validate-tokens
133
+ # Checks for:
134
+ # - Invalid color values
135
+ # - Invalid dimension values
136
+ # - Broken token aliases
137
+ # - Missing type fields
138
+ # Exit code 1 on errors (perfect for CI/CD)
120
139
  ```
121
140
 
122
- ### Compare Tokens
141
+ ### Compare & Diff
123
142
 
124
143
  ```bash
125
144
  # Compare two token files
126
145
  npx tokvista diff tokens-v1.json tokens-v2.json
127
146
 
128
- # Perfect for:
129
- # - Version control reviews
130
- # - Release changelogs
131
- # - Migration tracking
147
+ # Shows:
148
+ # - Added tokens
149
+ # - Removed tokens
150
+ # - Modified tokens with old/new values
151
+ # - Unchanged count
152
+ ```
153
+
154
+ ### Export & Generate
155
+
156
+ ```bash
157
+ # Export to CSS
158
+ npx tokvista export tokens.json --format css --output tokens.css
159
+
160
+ # Export to SCSS
161
+ npx tokvista export tokens.json --format scss --output _tokens.scss
162
+
163
+ # Export to JavaScript
164
+ npx tokvista export tokens.json --format json --output tokens.js
165
+
166
+ # Export to Tailwind
167
+ npx tokvista export tokens.json --format tailwind --output tailwind.config.js
168
+
169
+ # Print to stdout (for piping)
170
+ npx tokvista export tokens.json --format css
132
171
  ```
133
172
 
134
173
  ### Convert Formats
135
174
 
136
175
  ```bash
137
- # Convert to W3C DTCG format
176
+ # Convert to W3C DTCG
138
177
  npx tokvista convert tokens.json --to w3c --output tokens-w3c.json
139
178
 
140
179
  # Convert to Style Dictionary
141
180
  npx tokvista convert tokens.json --to style-dictionary --output tokens-sd.json
142
181
 
143
- # Convert to Supernova array format
182
+ # Convert to Supernova
144
183
  npx tokvista convert tokens.json --to supernova --output tokens-sn.json
145
184
 
146
- # Print to stdout
147
- npx tokvista convert tokens.json --to w3c
185
+ # Convert to Token Studio
186
+ npx tokvista convert tokens.json --to token-studio --output tokens-ts.json
148
187
  ```
149
188
 
150
- ### Build All Formats
189
+ ### Build Pipeline
151
190
 
152
191
  ```bash
153
- # Build everything in one command
192
+ # Build all formats at once
154
193
  npx tokvista build tokens.json --output-dir ./dist
155
194
 
156
195
  # Creates:
157
- # - tokens.css
158
- # - tokens.scss
159
- # - tokens.js
160
- # - tailwind.config.js
196
+ # - tokens.css (CSS Variables)
197
+ # - tokens.scss (SCSS Variables)
198
+ # - tokens.js (JavaScript/TypeScript)
199
+ # - tailwind.config.js (Tailwind Config)
161
200
 
162
201
  # Skip validation for faster builds
163
202
  npx tokvista build tokens.json --output-dir ./dist --skip-validation
164
203
  ```
165
204
 
166
- ### Interactive Setup
205
+ ### CLI Options Reference
167
206
 
168
- ```bash
169
- npx tokvista init
170
- ```
171
-
172
- Creates `tokvista.config.ts` with your branding:
173
-
174
- ```ts
175
- export default {
176
- title: 'Acme Design System',
177
- subtitle: 'Design tokens documentation',
178
- logo: './logo.svg',
179
- tokens: './tokens.json',
180
- theme: 'system',
181
- brandColor: '#6366f1',
182
- categories: ['foundation', 'semantic', 'components'],
183
- }
184
- ```
185
-
186
- Then run `npx tokvista` to use your config.
187
-
188
- ### CLI Options
207
+ | Command | Description |
208
+ |---------|-------------|
209
+ | `tokvista [file]` | Start documentation server |
210
+ | `tokvista init` | Interactive configuration setup |
211
+ | `tokvista scan <dir\|file>` | Analyze token usage and find issues |
212
+ | `tokvista validate <file>` | Validate token structure |
213
+ | `tokvista diff <old> <new>` | Compare two token files |
214
+ | `tokvista export <file>` | Export tokens to various formats |
215
+ | `tokvista convert <file>` | Convert between token formats |
216
+ | `tokvista build <file>` | Build all formats (validate + export) |
189
217
 
190
218
  | Option | Description |
191
219
  |--------|-------------|
192
- | `tokvista [file]` | Token file path (default: `./tokens.json`) |
193
- | `tokvista init` | Interactive config setup |
194
- | `tokvista export <file> --format <type>` | Export tokens (css, scss, json, tailwind) |
195
- | `tokvista validate <file>` | Validate token structure and values |
196
- | `tokvista diff <old> <new>` | Compare two token files |
197
- | `tokvista convert <file> --to <format>` | Convert between token formats |
198
- | `tokvista build <file> --output-dir <dir>` | Build all formats (validate + export) |
199
- | `--config`, `-c` | Config file path |
200
- | `--port`, `-p` | Server port (default: `3000`) |
201
- | `--format` | Export format (export only) |
202
- | `--output`, `-o` | Output file path (export only) |
203
- | `--no-open` | Don't open browser |
220
+ | `--config`, `-c` | Path to config file |
221
+ | `--port`, `-p` | Server port (default: 3000) |
222
+ | `--format` | Export format: css, scss, json, tailwind |
223
+ | `--output`, `-o` | Output file path |
224
+ | `--output-dir` | Output directory for build command |
225
+ | `--to` | Target format for convert command |
226
+ | `--tokens` | Token file path for scan command |
227
+ | `--no-open` | Don't open browser automatically |
204
228
  | `--no-watch` | Disable live reload |
205
229
  | `--no-preview` | Skip preview after init |
206
- | `--force`, `-f` | Overwrite existing config |
207
- | `--help`, `-h` | Show help |
230
+ | `--skip-validation` | Skip validation in build command |
231
+ | `--force`, `-f` | Overwrite existing files |
232
+ | `--help`, `-h` | Show help message |
208
233
 
209
234
  ---
210
235
 
@@ -327,6 +352,13 @@ See [GUIDE.md](./GUIDE.md) for complete setup instructions.
327
352
  - Keyboard navigation
328
353
  - Click result to copy
329
354
 
355
+ ### 🔗 Deep Linking
356
+
357
+ - Share direct links to tokens
358
+ - URL updates when clicking tokens
359
+ - Auto-scroll and highlight on page load
360
+ - Example: `https://yoursite.com/tokens#color-primary-500`
361
+
330
362
  ### 📤 Code Export
331
363
 
332
364
  Export all tokens as:
@@ -1099,18 +1099,19 @@ function isTokenLike5(obj) {
1099
1099
  }
1100
1100
  function validateTokenStructure(tokens) {
1101
1101
  const issues = [];
1102
- function walk(node, path2 = [], level = 0) {
1102
+ function walk(node, path2 = [], category = "") {
1103
1103
  if (!isRecord7(node)) return;
1104
1104
  if (path2.length === 0 && Object.keys(node).some((k) => k.includes("/"))) {
1105
- Object.values(node).forEach((val) => walk(val, [], level));
1105
+ Object.entries(node).forEach(([key, val]) => {
1106
+ const cat = key.toLowerCase().includes("semantic") ? "semantic" : key.toLowerCase().includes("component") ? "component" : "";
1107
+ walk(val, [], cat);
1108
+ });
1106
1109
  return;
1107
1110
  }
1108
1111
  if (isTokenLike5(node)) {
1109
1112
  const tokenPath = path2.join(".");
1110
1113
  const value = String(node.value || "");
1111
- const isSemanticToken = path2.some(
1112
- (p) => p.toLowerCase().includes("semantic") || p.toLowerCase().includes("component")
1113
- );
1114
+ const isSemanticToken = category === "semantic" || category === "component";
1114
1115
  if (isSemanticToken && !value.startsWith("{")) {
1115
1116
  if (/#[0-9A-Fa-f]{3,8}/.test(value) || /rgba?\(/.test(value)) {
1116
1117
  issues.push({
@@ -1130,7 +1131,7 @@ function validateTokenStructure(tokens) {
1130
1131
  return;
1131
1132
  }
1132
1133
  Object.entries(node).forEach(([key, val]) => {
1133
- walk(val, [...path2, key], level + 1);
1134
+ walk(val, [...path2, key], category);
1134
1135
  });
1135
1136
  }
1136
1137
  walk(tokens);