@dsai-io/tools 1.1.0 → 1.2.1
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 +207 -438
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,438 +1,207 @@
|
|
|
1
|
-
# @dsai-io/tools
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@dsai-io/tools)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
RateLimiter,
|
|
209
|
-
SnapshotService
|
|
210
|
-
} from '@dsai-io/tools/tokens';
|
|
211
|
-
|
|
212
|
-
// Circuit breaker for external APIs
|
|
213
|
-
const breaker = new CircuitBreaker({
|
|
214
|
-
threshold: 5,
|
|
215
|
-
timeout: 30000,
|
|
216
|
-
resetTimeout: 60000,
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
const data = await breaker.execute(async () => {
|
|
220
|
-
return await fetchFromFigmaAPI();
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// Rate limiter for API protection
|
|
224
|
-
const limiter = new RateLimiter({
|
|
225
|
-
maxRequests: 10,
|
|
226
|
-
windowMs: 60000,
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
await limiter.acquire();
|
|
230
|
-
|
|
231
|
-
// Snapshot for rollback
|
|
232
|
-
const snapshotService = new SnapshotService('.snapshots');
|
|
233
|
-
const snapshot = await snapshotService.createSnapshot(
|
|
234
|
-
'tokens/',
|
|
235
|
-
'Before v2.0.0 migration'
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
// Restore if needed
|
|
239
|
-
await snapshotService.restoreSnapshot(snapshot.id, 'tokens/');
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
#### Configuration & Build
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
import { loadConfig, buildTokens, generateIcons } from '@dsai-io/tools';
|
|
246
|
-
|
|
247
|
-
// Load configuration
|
|
248
|
-
const config = await loadConfig();
|
|
249
|
-
|
|
250
|
-
// Build tokens
|
|
251
|
-
const tokenResult = await buildTokens(config.tokens);
|
|
252
|
-
console.log('Generated:', tokenResult.files);
|
|
253
|
-
|
|
254
|
-
// Generate icons
|
|
255
|
-
const iconResult = await generateIcons(config.icons);
|
|
256
|
-
console.log('Generated:', iconResult.files);
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
## API Reference
|
|
260
|
-
|
|
261
|
-
### Configuration
|
|
262
|
-
|
|
263
|
-
- `defineConfig(config)` - Helper for type-safe configuration
|
|
264
|
-
- `loadConfig(searchFrom?)` - Load configuration from filesystem
|
|
265
|
-
- `validateConfig(config)` - Validate configuration against schema
|
|
266
|
-
|
|
267
|
-
### Token Building
|
|
268
|
-
|
|
269
|
-
- `buildTokens(tokensDir, options)` - Build tokens with optional incremental mode
|
|
270
|
-
- `buildTokensCLI(args)` - CLI wrapper for token builds
|
|
271
|
-
- `runBuildCLI(args)` - Execute build from command line
|
|
272
|
-
|
|
273
|
-
**Options:**
|
|
274
|
-
|
|
275
|
-
- `incremental: boolean` - Enable incremental builds
|
|
276
|
-
- `force: boolean` - Force full rebuild
|
|
277
|
-
- `cacheDir: string` - Custom cache directory
|
|
278
|
-
- `clean: boolean` - Clean outputs before build
|
|
279
|
-
|
|
280
|
-
### Incremental Build System
|
|
281
|
-
|
|
282
|
-
- `CacheService` - SHA-256 content hashing and cache management
|
|
283
|
-
- `hashFile(filePath)` - Generate content hash
|
|
284
|
-
- `hasFileChanged(filePath, baseDir)` - Check if file changed
|
|
285
|
-
- `getChangedFiles(directory, pattern)` - Get all changed files
|
|
286
|
-
- `updateCacheEntry(filePath, baseDir)` - Update cache
|
|
287
|
-
- `getCacheStats()` - Get cache metrics
|
|
288
|
-
|
|
289
|
-
- `analyzeChanges(options)` - Analyze token changes
|
|
290
|
-
- `buildDependencyGraph(collections)` - Build dependency graph
|
|
291
|
-
- `getAffectedCollections(changed, graph)` - Get affected collections
|
|
292
|
-
- `generateIncrementalReport(result)` - Generate build report
|
|
293
|
-
|
|
294
|
-
### Changelog Generation
|
|
295
|
-
|
|
296
|
-
- `diffTokens(oldTokens, newTokens)` - Compare token collections
|
|
297
|
-
- `generateChangelog(diff, options)` - Generate Markdown changelog
|
|
298
|
-
- `writeChangelog(content, filePath)` - Write changelog to file
|
|
299
|
-
- `generateAndWriteChangelog(diff, filePath, options)` - Combined operation
|
|
300
|
-
- `generateChangelogCLI(oldPath, newPath, output, version)` - CLI wrapper
|
|
301
|
-
|
|
302
|
-
**Diff Result:**
|
|
303
|
-
|
|
304
|
-
- `added: TokenChange[]` - Added tokens
|
|
305
|
-
- `removed: TokenChange[]` - Removed tokens (breaking)
|
|
306
|
-
- `modified: TokenChange[]` - Modified tokens
|
|
307
|
-
- `typeChanged: TokenChange[]` - Type-changed tokens (breaking)
|
|
308
|
-
- `deprecated: TokenChange[]` - Deprecated tokens
|
|
309
|
-
- `totalChanges: number` - Total count
|
|
310
|
-
- `hasBreaking: boolean` - Breaking change flag
|
|
311
|
-
|
|
312
|
-
**Helper Functions:**
|
|
313
|
-
|
|
314
|
-
- `summarizeDiff(diff)` - Text summary of changes
|
|
315
|
-
- `filterDiff(diff, types)` - Filter by change types
|
|
316
|
-
- `getBreakingChanges(diff)` - Get only breaking changes
|
|
317
|
-
|
|
318
|
-
### Error Recovery
|
|
319
|
-
|
|
320
|
-
- `CircuitBreaker` - Prevent cascading failures
|
|
321
|
-
- `execute(fn)` - Execute with circuit breaker protection
|
|
322
|
-
- `getState()` - Get current state (CLOSED, OPEN, HALF_OPEN)
|
|
323
|
-
- `getMetrics()` - Get failure/success metrics
|
|
324
|
-
- `reset()` - Manually reset circuit
|
|
325
|
-
|
|
326
|
-
- `RateLimiter` - API rate limiting
|
|
327
|
-
- `acquire()` - Acquire rate limit slot
|
|
328
|
-
- `getMetrics()` - Get request metrics
|
|
329
|
-
- `reset()` - Reset rate limiter
|
|
330
|
-
|
|
331
|
-
- `SnapshotService` - Version snapshots for rollback
|
|
332
|
-
- `createSnapshot(dir, description)` - Create snapshot
|
|
333
|
-
- `listSnapshots()` - List all snapshots
|
|
334
|
-
- `getSnapshot(id)` - Get snapshot by ID
|
|
335
|
-
- `restoreSnapshot(id, targetDir)` - Restore snapshot
|
|
336
|
-
- `deleteSnapshot(id)` - Delete snapshot
|
|
337
|
-
- `cleanup(keepCount)` - Clean old snapshots
|
|
338
|
-
|
|
339
|
-
### Token Validation & Transformation
|
|
340
|
-
|
|
341
|
-
- `validateTokens(config, options)` - Validate against DTCG spec
|
|
342
|
-
- `validateFigmaExports(data)` - Validate Figma exports
|
|
343
|
-
- `transformTokens(options)` - Transform Figma to Style Dictionary
|
|
344
|
-
- `syncTokens(options)` - Sync to flat TypeScript file
|
|
345
|
-
- `cleanTokenOutputs(options)` - Clean output directories
|
|
346
|
-
- `postprocessCss(options)` - Post-process CSS theme files
|
|
347
|
-
|
|
348
|
-
### Schema Validation
|
|
349
|
-
|
|
350
|
-
- `validateDTCGFile(data)` - Validate DTCG file structure
|
|
351
|
-
- `validateDTCGTokens(tokens)` - Validate token collection
|
|
352
|
-
- `validateFigmaExport(data)` - Validate Figma export
|
|
353
|
-
- `validateStyleDictionaryInput(data)` - Validate SD input
|
|
354
|
-
|
|
355
|
-
### Icon Tools
|
|
356
|
-
|
|
357
|
-
- `generateIcons(config)` - Generate icon components from SVGs
|
|
358
|
-
- `optimizeSvg(source, options)` - Optimize SVG files
|
|
359
|
-
- `extractIconMetadata(svgPath)` - Extract metadata from SVG
|
|
360
|
-
|
|
361
|
-
### Type Guards & Utilities
|
|
362
|
-
|
|
363
|
-
- `isDTCGToken(obj)` - Check if DTCG format
|
|
364
|
-
- `isLegacyToken(obj)` - Check if legacy format
|
|
365
|
-
- `isToken(obj)` - Check if any token format
|
|
366
|
-
- `getTokenValue(token)` - Get value from any format
|
|
367
|
-
- `getTokenType(token)` - Get type from any format
|
|
368
|
-
- `toDTCGToken(legacy)` - Convert legacy to DTCG
|
|
369
|
-
|
|
370
|
-
## Configuration Options
|
|
371
|
-
|
|
372
|
-
### TokensConfig
|
|
373
|
-
|
|
374
|
-
| Option | Type | Description |
|
|
375
|
-
| ----------------- | ---------------- | -------------------------------------------------- |
|
|
376
|
-
| `source` | `string[]` | Source token file patterns |
|
|
377
|
-
| `output` | `string` | Output directory |
|
|
378
|
-
| `formats` | `string[]` | Output formats (`css`, `scss`, `ts`, `json`, `js`) |
|
|
379
|
-
| `prefix` | `string` | CSS custom property prefix |
|
|
380
|
-
| `themes` | `ThemeConfig[]` | Theme configurations |
|
|
381
|
-
| `styleDictionary` | `object` | Additional Style Dictionary config |
|
|
382
|
-
| `pipeline` | `PipelineConfig` | Build pipeline configuration (see below) |
|
|
383
|
-
|
|
384
|
-
### PipelineConfig
|
|
385
|
-
|
|
386
|
-
Customize the token build pipeline for your package:
|
|
387
|
-
|
|
388
|
-
| Option | Type | Description |
|
|
389
|
-
| ----------------------- | ---------- | -------------------------------------------- |
|
|
390
|
-
| `steps` | `string[]` | Build steps to execute (see available steps) |
|
|
391
|
-
| `paths` | `object` | Custom paths for SASS and sync operations |
|
|
392
|
-
| `styleDictionaryConfig` | `string` | Path to Style Dictionary config file |
|
|
393
|
-
|
|
394
|
-
**Available Pipeline Steps:**
|
|
395
|
-
|
|
396
|
-
- `validate` - Validate tokens against DTCG spec
|
|
397
|
-
- `transform` - Transform Figma exports to Style Dictionary format
|
|
398
|
-
- `style-dictionary` - Build Style Dictionary outputs
|
|
399
|
-
- `sync` - Sync tokens-flat.ts file
|
|
400
|
-
- `sass-theme` - Compile Bootstrap theme SCSS
|
|
401
|
-
- `sass-theme-minified` - Compile minified Bootstrap theme
|
|
402
|
-
- `postprocess` - Post-process theme CSS
|
|
403
|
-
- `sass-utilities` - Compile DSAi utilities SCSS
|
|
404
|
-
- `sass-utilities-minified` - Compile minified utilities
|
|
405
|
-
- `bundle` - Bundle with tsup
|
|
406
|
-
|
|
407
|
-
**Example (for a package that only needs validation, transform, and Style Dictionary):**
|
|
408
|
-
|
|
409
|
-
```javascript
|
|
410
|
-
// dsai.config.mjs
|
|
411
|
-
export default {
|
|
412
|
-
tokens: {
|
|
413
|
-
pipeline: {
|
|
414
|
-
steps: ['validate', 'transform', 'style-dictionary'],
|
|
415
|
-
styleDictionaryConfig: 'sd.config.mjs',
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
};
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
### IconsConfig
|
|
422
|
-
|
|
423
|
-
| Option | Type | Description |
|
|
424
|
-
| ------------ | --------- | ---------------------------------------------- |
|
|
425
|
-
| `source` | `string` | Source directory containing SVGs |
|
|
426
|
-
| `output` | `string` | Output directory for components |
|
|
427
|
-
| `framework` | `string` | Component framework (`react`, `vue`, `svelte`) |
|
|
428
|
-
| `prefix` | `string` | Icon component prefix |
|
|
429
|
-
| `typescript` | `boolean` | Generate TypeScript |
|
|
430
|
-
| `optimize` | `boolean` | Optimize SVGs with SVGO |
|
|
431
|
-
|
|
432
|
-
## Peer Dependencies
|
|
433
|
-
|
|
434
|
-
- `style-dictionary@^5.0.0` (optional) - Required for token building
|
|
435
|
-
|
|
436
|
-
## License
|
|
437
|
-
|
|
438
|
-
MIT © DSAi Design System
|
|
1
|
+
# @dsai-io/tools
|
|
2
|
+
|
|
3
|
+
> Build tooling, component registry, and CLI for the DSAi Design System
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@dsai-io/tools)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add -D @dsai-io/tools
|
|
11
|
+
# or
|
|
12
|
+
npm install -D @dsai-io/tools
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## CLI Commands
|
|
16
|
+
|
|
17
|
+
### Add Components
|
|
18
|
+
|
|
19
|
+
Install DSAi components, hooks, and utilities directly into your project source code.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Add UI components
|
|
23
|
+
dsai add button modal tabs
|
|
24
|
+
|
|
25
|
+
# Add hooks and utilities
|
|
26
|
+
dsai add use-focus-trap use-debounce cn keyboard
|
|
27
|
+
|
|
28
|
+
# Add all UI components
|
|
29
|
+
dsai add --all
|
|
30
|
+
|
|
31
|
+
# Add all hooks
|
|
32
|
+
dsai add --all --type hook
|
|
33
|
+
|
|
34
|
+
# List everything available
|
|
35
|
+
dsai add --list
|
|
36
|
+
|
|
37
|
+
# List only hooks
|
|
38
|
+
dsai add --list --type hook
|
|
39
|
+
|
|
40
|
+
# Preview without writing files
|
|
41
|
+
dsai add button --dry-run
|
|
42
|
+
|
|
43
|
+
# Overwrite existing files
|
|
44
|
+
dsai add button --overwrite
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Components are copied as source files into your project (not installed from `node_modules`). Dependencies are resolved automatically -- adding `modal` also installs `use-focus-trap`, `use-scroll-lock`, `cn`, `keyboard`, and the shared type definitions.
|
|
48
|
+
|
|
49
|
+
### Build Tokens
|
|
50
|
+
|
|
51
|
+
Transform and compile design tokens from Figma exports into CSS, SCSS, JS, TS, and JSON.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Full build pipeline
|
|
55
|
+
dsai tokens build
|
|
56
|
+
|
|
57
|
+
# Validate token structure
|
|
58
|
+
dsai tokens validate
|
|
59
|
+
|
|
60
|
+
# Transform Figma exports to DTCG collections
|
|
61
|
+
dsai tokens transform
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The pipeline is configured via `dsai.config.mjs` and supports multi-theme builds (light + dark), SCSS compilation with Bootstrap integration, and CSS postprocessing.
|
|
65
|
+
|
|
66
|
+
### Build Registry
|
|
67
|
+
|
|
68
|
+
Regenerate the component registry from `@dsai-io/react` source (monorepo maintainers only).
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
dsai registry build
|
|
72
|
+
dsai registry build --verbose
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Other Commands
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Initialize configuration
|
|
79
|
+
dsai init
|
|
80
|
+
|
|
81
|
+
# Show resolved configuration
|
|
82
|
+
dsai config
|
|
83
|
+
|
|
84
|
+
# Generate icon components from SVGs
|
|
85
|
+
dsai icons build --format react
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Configuration
|
|
89
|
+
|
|
90
|
+
Create `dsai.config.mjs` in your project root:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
import { defineConfig } from '@dsai-io/tools';
|
|
94
|
+
|
|
95
|
+
export default defineConfig({
|
|
96
|
+
tokens: {
|
|
97
|
+
source: 'theme',
|
|
98
|
+
sourceDir: './src/figma-exports',
|
|
99
|
+
collectionsDir: './src',
|
|
100
|
+
outputDir: './src/generated',
|
|
101
|
+
prefix: '--dsai-',
|
|
102
|
+
formats: ['css', 'scss', 'js', 'ts', 'json'],
|
|
103
|
+
separateThemeFiles: true,
|
|
104
|
+
scss: {
|
|
105
|
+
themeEntry: 'src/scss/dsai-theme-bs.scss',
|
|
106
|
+
cssOutputDir: 'src/generated/css',
|
|
107
|
+
framework: 'bootstrap',
|
|
108
|
+
},
|
|
109
|
+
themes: {
|
|
110
|
+
enabled: true,
|
|
111
|
+
default: 'light',
|
|
112
|
+
definitions: {
|
|
113
|
+
light: { isDefault: true, selector: ':root' },
|
|
114
|
+
dark: {
|
|
115
|
+
suffix: '-dark',
|
|
116
|
+
selector: '[data-dsai-theme="dark"]',
|
|
117
|
+
mediaQuery: '(prefers-color-scheme: dark)',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
pipeline: {
|
|
122
|
+
steps: ['validate', 'transform', 'multi-theme', 'sass-theme', 'postprocess'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
aliases: {
|
|
126
|
+
importAlias: '@/',
|
|
127
|
+
ui: 'src/components/ui',
|
|
128
|
+
hooks: 'src/hooks',
|
|
129
|
+
utils: 'src/lib/utils',
|
|
130
|
+
components: 'src/components',
|
|
131
|
+
lib: 'src/lib',
|
|
132
|
+
},
|
|
133
|
+
components: {
|
|
134
|
+
tsx: true,
|
|
135
|
+
overwrite: false,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Aliases
|
|
141
|
+
|
|
142
|
+
The `aliases` section controls where `dsai add` writes files:
|
|
143
|
+
|
|
144
|
+
| Alias | Default | Description |
|
|
145
|
+
|-------|---------|-------------|
|
|
146
|
+
| `importAlias` | `@/` | Import prefix used in tsconfig paths |
|
|
147
|
+
| `ui` | `src/components/ui` | UI component target directory |
|
|
148
|
+
| `hooks` | `src/hooks` | Hook target directory |
|
|
149
|
+
| `utils` | `src/lib/utils` | Utility target directory |
|
|
150
|
+
| `components` | `src/components` | Higher-level component directory |
|
|
151
|
+
| `lib` | `src/lib` | Library file directory |
|
|
152
|
+
|
|
153
|
+
### Pipeline Steps
|
|
154
|
+
|
|
155
|
+
| Step | Description |
|
|
156
|
+
|------|-------------|
|
|
157
|
+
| `validate` | Validate tokens against DTCG spec |
|
|
158
|
+
| `transform` | Transform Figma exports to DTCG collections |
|
|
159
|
+
| `style-dictionary` | Build Style Dictionary outputs |
|
|
160
|
+
| `multi-theme` | Generate light + dark theme outputs |
|
|
161
|
+
| `sync` | Sync tokens to flat TypeScript file |
|
|
162
|
+
| `sass-theme` | Compile Bootstrap theme SCSS |
|
|
163
|
+
| `sass-theme-minified` | Compile minified Bootstrap theme |
|
|
164
|
+
| `postprocess` | Post-process CSS (e.g., replace `data-bs-theme` with `data-dsai-theme`) |
|
|
165
|
+
| `sass-utilities` | Compile DSAi utilities SCSS |
|
|
166
|
+
| `sass-utilities-minified` | Compile minified utilities |
|
|
167
|
+
| `bundle` | Bundle with tsup |
|
|
168
|
+
|
|
169
|
+
## Component Registry
|
|
170
|
+
|
|
171
|
+
The registry contains 81 items:
|
|
172
|
+
|
|
173
|
+
- **33 UI components** -- Accordion, Alert, Avatar, Badge, Breadcrumb, Button, Card, Carousel, Checkbox, Dropdown, Icon, Input, ListGroup, Modal, Navbar, Pagination, Popover, Progress, Radio, Scrollspy, Select, Sheet, Spinner, Switch, Table, Tabs, Toast, Tooltip, Typography, and more
|
|
174
|
+
- **23 hooks** -- useAsync, useClickOutside, useControllableState, useDarkMode, useDebounce, useFocusTrap, useForm, useHover, useMediaQuery, useReducedMotion, useResizeObserver, useRovingFocus, useScrollLock, useThrottle, and more
|
|
175
|
+
- **24 utilities** -- cn, keyboard helpers, mergeRefs, browser detection, validation, string utils, accessibility helpers, and more
|
|
176
|
+
- **1 shared type system** -- SafeHTMLAttributes, ComponentSize, SemanticColorVariant, PolymorphicComponentProps
|
|
177
|
+
|
|
178
|
+
Each item declares its dependencies. When you add a component, all required hooks, utils, types, and npm packages are resolved and installed automatically.
|
|
179
|
+
|
|
180
|
+
## Programmatic API
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { loadConfig, buildRegistry, resolveTree, writeRegistryItems } from '@dsai-io/tools';
|
|
184
|
+
|
|
185
|
+
// Load configuration
|
|
186
|
+
const { config } = await loadConfig();
|
|
187
|
+
|
|
188
|
+
// Resolve dependencies for a set of components
|
|
189
|
+
const tree = resolveTree(['modal', 'tabs'], registryDir);
|
|
190
|
+
// tree.items: all items in install order
|
|
191
|
+
// tree.dependencies: npm packages needed
|
|
192
|
+
|
|
193
|
+
// Write files to a project
|
|
194
|
+
writeRegistryItems(tree, {
|
|
195
|
+
projectDir: process.cwd(),
|
|
196
|
+
aliases: config.aliases,
|
|
197
|
+
components: config.components,
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Peer Dependencies
|
|
202
|
+
|
|
203
|
+
- `style-dictionary@^5.0.0` (optional) -- required for token building
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsai-io/tools",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Build tooling and CLI for DSAi Design System",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"dsai": "
|
|
11
|
-
"dsai-tools": "
|
|
10
|
+
"dsai": "bin/dsai-tools.mjs",
|
|
11
|
+
"dsai-tools": "bin/dsai-tools.mjs"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"build-tools",
|
|
66
66
|
"dsai"
|
|
67
67
|
],
|
|
68
|
-
"license": "
|
|
68
|
+
"license": "MIT",
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=22.0.0"
|
|
71
71
|
},
|