@dsai-io/tools 1.0.7 → 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 +138 -369
- package/bin/dsai-tools.mjs +13 -13
- package/dist/cli/index.cjs +1942 -545
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +1944 -548
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.cjs +66 -2
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +50 -3
- package/dist/config/index.d.ts +50 -3
- package/dist/config/index.js +63 -3
- package/dist/config/index.js.map +1 -1
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.d.cts +1 -1
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js.map +1 -1
- package/dist/index.cjs +1241 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -4
- package/dist/index.d.ts +213 -4
- package/dist/index.js +1229 -19
- package/dist/index.js.map +1 -1
- package/dist/tokens/index.cjs +15 -15
- package/dist/tokens/index.cjs.map +1 -1
- package/dist/tokens/index.d.cts +1 -1
- package/dist/tokens/index.d.ts +1 -1
- package/dist/tokens/index.js +15 -15
- package/dist/tokens/index.js.map +1 -1
- package/dist/{types-DabOzcsj.d.cts → types-CtE9f0G0.d.cts} +58 -1
- package/dist/{types-DabOzcsj.d.ts → types-CtE9f0G0.d.ts} +58 -1
- package/dist/utils/circuit-breaker.cjs.map +1 -1
- package/dist/utils/circuit-breaker.js.map +1 -1
- package/package.json +102 -102
- package/templates/.dsairc.json +37 -37
- package/templates/dsai-config.schema.json +618 -554
- package/templates/dsai.config.mjs +281 -221
package/README.md
CHANGED
|
@@ -1,438 +1,207 @@
|
|
|
1
1
|
# @dsai-io/tools
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Build tooling, component registry, and CLI for the DSAi Design System
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@dsai-io/tools)
|
|
6
|
-
[](../../docs/coverage.md)
|
|
7
|
-
[](../../BUILD.md)
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
11
9
|
```bash
|
|
12
|
-
pnpm add @dsai-io/tools
|
|
13
|
-
|
|
14
|
-
# or
|
|
15
|
-
npm install @dsai-io/tools
|
|
16
|
-
|
|
10
|
+
pnpm add -D @dsai-io/tools
|
|
17
11
|
# or
|
|
18
|
-
|
|
12
|
+
npm install -D @dsai-io/tools
|
|
19
13
|
```
|
|
20
14
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
### 🚀 **Incremental Builds**
|
|
24
|
-
|
|
25
|
-
- SHA-256 content hashing for instant change detection
|
|
26
|
-
- Smart decision logic (10-100x faster than full rebuilds)
|
|
27
|
-
- Dependency graph analysis for minimal rebuilds
|
|
28
|
-
- Persistent caching in `.dsai-cache/`
|
|
29
|
-
|
|
30
|
-
### 📝 **Automatic Changelog Generation**
|
|
31
|
-
|
|
32
|
-
- Detects added, removed, modified, and type-changed tokens
|
|
33
|
-
- Breaking change identification and warnings
|
|
34
|
-
- Professional Markdown output with before/after values
|
|
35
|
-
- DTCG and legacy token format support
|
|
15
|
+
## CLI Commands
|
|
36
16
|
|
|
37
|
-
###
|
|
17
|
+
### Add Components
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
- Rate limiter protects external APIs (Figma)
|
|
41
|
-
- Snapshot service for version rollback
|
|
42
|
-
- Exponential backoff with jitter for retries
|
|
43
|
-
- Health monitoring and metrics
|
|
19
|
+
Install DSAi components, hooks, and utilities directly into your project source code.
|
|
44
20
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- Style Dictionary v5 integration
|
|
49
|
-
- Schema validation (Zod-based)
|
|
50
|
-
- Figma Variables API sync
|
|
51
|
-
- Multi-mode token support
|
|
21
|
+
```bash
|
|
22
|
+
# Add UI components
|
|
23
|
+
dsai add button modal tabs
|
|
52
24
|
|
|
53
|
-
|
|
25
|
+
# Add hooks and utilities
|
|
26
|
+
dsai add use-focus-trap use-debounce cn keyboard
|
|
54
27
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- Programmatic API for automation
|
|
58
|
-
- Icon component generation from SVGs
|
|
28
|
+
# Add all UI components
|
|
29
|
+
dsai add --all
|
|
59
30
|
|
|
60
|
-
|
|
31
|
+
# Add all hooks
|
|
32
|
+
dsai add --all --type hook
|
|
61
33
|
|
|
62
|
-
|
|
34
|
+
# List everything available
|
|
35
|
+
dsai add --list
|
|
63
36
|
|
|
64
|
-
|
|
37
|
+
# List only hooks
|
|
38
|
+
dsai add --list --type hook
|
|
65
39
|
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
# Preview without writing files
|
|
41
|
+
dsai add button --dry-run
|
|
68
42
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
source: ['tokens/**/*.json'],
|
|
72
|
-
output: 'dist/tokens',
|
|
73
|
-
formats: ['css', 'ts'],
|
|
74
|
-
prefix: 'ds',
|
|
75
|
-
},
|
|
76
|
-
icons: {
|
|
77
|
-
source: 'assets/icons',
|
|
78
|
-
output: 'src/components/icons',
|
|
79
|
-
framework: 'react',
|
|
80
|
-
typescript: true,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
43
|
+
# Overwrite existing files
|
|
44
|
+
dsai add button --overwrite
|
|
83
45
|
```
|
|
84
46
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
#### Token Building
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
# Full build
|
|
91
|
-
npx dsai-tools tokens build tokens/
|
|
92
|
-
|
|
93
|
-
# Incremental build (10-100x faster)
|
|
94
|
-
npx dsai-tools tokens build tokens/ --incremental
|
|
95
|
-
|
|
96
|
-
# Force full rebuild
|
|
97
|
-
npx dsai-tools tokens build tokens/ --force
|
|
98
|
-
|
|
99
|
-
# Custom cache directory
|
|
100
|
-
npx dsai-tools tokens build tokens/ --incremental --cache-dir .cache
|
|
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.
|
|
101
48
|
|
|
102
|
-
|
|
103
|
-
npx dsai-tools tokens build --clean
|
|
104
|
-
```
|
|
49
|
+
### Build Tokens
|
|
105
50
|
|
|
106
|
-
|
|
51
|
+
Transform and compile design tokens from Figma exports into CSS, SCSS, JS, TS, and JSON.
|
|
107
52
|
|
|
108
53
|
```bash
|
|
109
|
-
#
|
|
110
|
-
|
|
54
|
+
# Full build pipeline
|
|
55
|
+
dsai tokens build
|
|
111
56
|
|
|
112
|
-
#
|
|
113
|
-
|
|
57
|
+
# Validate token structure
|
|
58
|
+
dsai tokens validate
|
|
114
59
|
|
|
115
|
-
#
|
|
116
|
-
|
|
60
|
+
# Transform Figma exports to DTCG collections
|
|
61
|
+
dsai tokens transform
|
|
117
62
|
```
|
|
118
63
|
|
|
119
|
-
|
|
64
|
+
The pipeline is configured via `dsai.config.mjs` and supports multi-theme builds (light + dark), SCSS compilation with Bootstrap integration, and CSS postprocessing.
|
|
120
65
|
|
|
121
|
-
|
|
122
|
-
# Validate tokens against DTCG spec
|
|
123
|
-
npx dsai-tools tokens validate tokens/**/*.json
|
|
66
|
+
### Build Registry
|
|
124
67
|
|
|
125
|
-
|
|
126
|
-
npx dsai-tools tokens transform
|
|
127
|
-
|
|
128
|
-
# Sync tokens to flat TypeScript file
|
|
129
|
-
npx dsai-tools tokens sync
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### Figma Integration
|
|
68
|
+
Regenerate the component registry from `@dsai-io/react` source (monorepo maintainers only).
|
|
133
69
|
|
|
134
70
|
```bash
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# Validate Figma export
|
|
139
|
-
npx dsai-tools tokens validate-figma export.json
|
|
71
|
+
dsai registry build
|
|
72
|
+
dsai registry build --verbose
|
|
140
73
|
```
|
|
141
74
|
|
|
142
|
-
|
|
75
|
+
### Other Commands
|
|
143
76
|
|
|
144
77
|
```bash
|
|
145
|
-
#
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
# Post-process CSS theme files
|
|
149
|
-
npx dsai-tools tokens postprocess
|
|
78
|
+
# Initialize configuration
|
|
79
|
+
dsai init
|
|
150
80
|
|
|
151
|
-
#
|
|
152
|
-
|
|
81
|
+
# Show resolved configuration
|
|
82
|
+
dsai config
|
|
153
83
|
|
|
154
|
-
#
|
|
155
|
-
|
|
84
|
+
# Generate icon components from SVGs
|
|
85
|
+
dsai icons build --format react
|
|
156
86
|
```
|
|
157
87
|
|
|
158
|
-
|
|
88
|
+
## Configuration
|
|
159
89
|
|
|
160
|
-
|
|
90
|
+
Create `dsai.config.mjs` in your project root:
|
|
161
91
|
|
|
162
|
-
```
|
|
163
|
-
import {
|
|
92
|
+
```javascript
|
|
93
|
+
import { defineConfig } from '@dsai-io/tools';
|
|
164
94
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
},
|
|
170
137
|
});
|
|
171
|
-
|
|
172
|
-
console.log(`Built ${result.tokenCount} tokens`);
|
|
173
|
-
console.log(`Build time: ${result.duration}ms`);
|
|
174
|
-
console.log(`Cache hit rate: ${result.cacheStats?.hitRate}%`);
|
|
175
138
|
```
|
|
176
139
|
|
|
177
|
-
|
|
140
|
+
### Aliases
|
|
178
141
|
|
|
179
|
-
|
|
180
|
-
import { diffTokens, generateChangelog, writeChangelog } from '@dsai-io/tools/tokens';
|
|
142
|
+
The `aliases` section controls where `dsai add` writes files:
|
|
181
143
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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 |
|
|
185
152
|
|
|
186
|
-
|
|
187
|
-
const diff = diffTokens(oldTokens, newTokens);
|
|
153
|
+
### Pipeline Steps
|
|
188
154
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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 |
|
|
192
168
|
|
|
193
|
-
|
|
194
|
-
const result = generateChangelog(diff, {
|
|
195
|
-
version: '1.2.0',
|
|
196
|
-
includeDescriptions: true,
|
|
197
|
-
includeValues: true,
|
|
198
|
-
});
|
|
169
|
+
## Component Registry
|
|
199
170
|
|
|
200
|
-
|
|
201
|
-
```
|
|
171
|
+
The registry contains 81 items:
|
|
202
172
|
|
|
203
|
-
|
|
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
|
|
204
177
|
|
|
205
|
-
|
|
206
|
-
import {
|
|
207
|
-
CircuitBreaker,
|
|
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
|
-
});
|
|
178
|
+
Each item declares its dependencies. When you add a component, all required hooks, utils, types, and npm packages are resolved and installed automatically.
|
|
218
179
|
|
|
219
|
-
|
|
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
|
|
180
|
+
## Programmatic API
|
|
243
181
|
|
|
244
182
|
```typescript
|
|
245
|
-
import { loadConfig,
|
|
183
|
+
import { loadConfig, buildRegistry, resolveTree, writeRegistryItems } from '@dsai-io/tools';
|
|
246
184
|
|
|
247
185
|
// Load configuration
|
|
248
|
-
const config = await loadConfig();
|
|
249
|
-
|
|
250
|
-
//
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
};
|
|
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
|
+
});
|
|
419
199
|
```
|
|
420
200
|
|
|
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
201
|
## Peer Dependencies
|
|
433
202
|
|
|
434
|
-
- `style-dictionary@^5.0.0` (optional)
|
|
203
|
+
- `style-dictionary@^5.0.0` (optional) -- required for token building
|
|
435
204
|
|
|
436
205
|
## License
|
|
437
206
|
|
|
438
|
-
MIT
|
|
207
|
+
MIT
|
package/bin/dsai-tools.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* DSAi Tools CLI entry point
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { run } from '../dist/cli/index.js';
|
|
9
|
-
|
|
10
|
-
run().catch((error) => {
|
|
11
|
-
console.error('Fatal error:', error);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* DSAi Tools CLI entry point
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { run } from '../dist/cli/index.js';
|
|
9
|
+
|
|
10
|
+
run().catch((error) => {
|
|
11
|
+
console.error('Fatal error:', error);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|