@dsai-io/tools 0.0.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 ADDED
@@ -0,0 +1,186 @@
1
+ # @DSAi/tools
2
+
3
+ > Enterprise-grade build tools for the DSAi Design System
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @dsai-io/tools
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - 🎨 **Token Management** - Build and validate design tokens using Style Dictionary
14
+ - 🔧 **Configuration** - Type-safe configuration with `dsai.config.ts`
15
+ - 🖼️ **Icon Generation** - Generate icon components from SVG files
16
+ - 📦 **CLI** - Command-line interface for build automation
17
+
18
+ ## Quick Start
19
+
20
+ ### Configuration
21
+
22
+ Create a `dsai.config.ts` in your project root:
23
+
24
+ ```typescript
25
+ import { defineConfig } from '@dsai-io/tools';
26
+
27
+ export default defineConfig({
28
+ tokens: {
29
+ source: ['tokens/**/*.json'],
30
+ output: 'dist/tokens',
31
+ formats: ['css', 'ts'],
32
+ prefix: 'ds',
33
+ },
34
+ icons: {
35
+ source: 'assets/icons',
36
+ output: 'src/components/icons',
37
+ framework: 'react',
38
+ typescript: true,
39
+ },
40
+ });
41
+ ```
42
+
43
+ ### CLI Usage
44
+
45
+ ```bash
46
+ # Build all tokens and icons
47
+ npx dsai-tools build
48
+
49
+ # Build only tokens
50
+ npx dsai-tools build --tokens
51
+
52
+ # Build tokens with clean (removes old outputs first)
53
+ npx dsai-tools tokens build --clean
54
+
55
+ # Build only icons
56
+ npx dsai-tools build --icons
57
+
58
+ # Validate token files
59
+ npx dsai-tools validate tokens/**/*.json
60
+
61
+ # Transform Figma token exports
62
+ npx dsai-tools tokens transform
63
+
64
+ # Sync tokens flat file
65
+ npx dsai-tools tokens sync
66
+
67
+ # Initialize configuration
68
+ npx dsai-tools init
69
+ ```
70
+
71
+ ### Programmatic Usage
72
+
73
+ ```typescript
74
+ import { buildTokens, generateIcons, loadConfig } from '@dsai-io/tools';
75
+
76
+ // Load configuration
77
+ const config = await loadConfig();
78
+
79
+ // Build tokens
80
+ const tokenResult = await buildTokens(config.tokens);
81
+ console.log('Generated:', tokenResult.files);
82
+
83
+ // Generate icons
84
+ const iconResult = await generateIcons(config.icons);
85
+ console.log('Generated:', iconResult.files);
86
+ ```
87
+
88
+ ## API Reference
89
+
90
+ ### Configuration
91
+
92
+ - `defineConfig(config)` - Helper for type-safe configuration
93
+ - `loadConfig(searchFrom?)` - Load configuration from filesystem
94
+ - `validateConfig(config)` - Validate configuration against schema
95
+
96
+ ### Token Tools
97
+
98
+ - `validateTokens(config, options)` - Validate token files against DTCG spec
99
+ - `transformTokens(options)` - Transform Figma token exports to Style Dictionary format
100
+ - `buildTokens(tokensDir, toolsDir, options)` - Build tokens from source to output formats
101
+ - `syncTokens(options)` - Sync tokens to flat TypeScript file
102
+ - `cleanTokenOutputs(options)` - Clean output directories before build
103
+ - `postprocessCss(options)` - Post-process CSS theme files
104
+
105
+ ### Icon Tools
106
+
107
+ - `generateIcons(config)` - Generate icon components from SVGs
108
+ - `optimizeSvg(source, options)` - Optimize SVG files
109
+ - `extractIconMetadata(svgPath)` - Extract metadata from SVG
110
+
111
+ ### Utilities
112
+
113
+ - `logger` - Colored console logging utilities
114
+ - `resolvePath(...segments)` - Resolve path relative to cwd
115
+ - `fileExists(path)` - Check if file exists
116
+ - `formatDuration(ms)` - Format milliseconds to readable string
117
+
118
+ ## Configuration Options
119
+
120
+ ### TokensConfig
121
+
122
+ | Option | Type | Description |
123
+ | ----------------- | ---------------- | -------------------------------------------------- |
124
+ | `source` | `string[]` | Source token file patterns |
125
+ | `output` | `string` | Output directory |
126
+ | `formats` | `string[]` | Output formats (`css`, `scss`, `ts`, `json`, `js`) |
127
+ | `prefix` | `string` | CSS custom property prefix |
128
+ | `themes` | `ThemeConfig[]` | Theme configurations |
129
+ | `styleDictionary` | `object` | Additional Style Dictionary config |
130
+ | `pipeline` | `PipelineConfig` | Build pipeline configuration (see below) |
131
+
132
+ ### PipelineConfig
133
+
134
+ Customize the token build pipeline for your package:
135
+
136
+ | Option | Type | Description |
137
+ | ----------------------- | ---------- | -------------------------------------------- |
138
+ | `steps` | `string[]` | Build steps to execute (see available steps) |
139
+ | `paths` | `object` | Custom paths for SASS and sync operations |
140
+ | `styleDictionaryConfig` | `string` | Path to Style Dictionary config file |
141
+
142
+ **Available Pipeline Steps:**
143
+
144
+ - `validate` - Validate tokens against DTCG spec
145
+ - `transform` - Transform Figma exports to Style Dictionary format
146
+ - `style-dictionary` - Build Style Dictionary outputs
147
+ - `sync` - Sync tokens-flat.ts file
148
+ - `sass-theme` - Compile Bootstrap theme SCSS
149
+ - `sass-theme-minified` - Compile minified Bootstrap theme
150
+ - `postprocess` - Post-process theme CSS
151
+ - `sass-utilities` - Compile DSAi utilities SCSS
152
+ - `sass-utilities-minified` - Compile minified utilities
153
+ - `bundle` - Bundle with tsup
154
+
155
+ **Example (for a package that only needs validation, transform, and Style Dictionary):**
156
+
157
+ ```javascript
158
+ // dsai.config.mjs
159
+ export default {
160
+ tokens: {
161
+ pipeline: {
162
+ steps: ['validate', 'transform', 'style-dictionary'],
163
+ styleDictionaryConfig: 'sd.config.mjs',
164
+ },
165
+ },
166
+ };
167
+ ```
168
+
169
+ ### IconsConfig
170
+
171
+ | Option | Type | Description |
172
+ | ------------ | --------- | ---------------------------------------------- |
173
+ | `source` | `string` | Source directory containing SVGs |
174
+ | `output` | `string` | Output directory for components |
175
+ | `framework` | `string` | Component framework (`react`, `vue`, `svelte`) |
176
+ | `prefix` | `string` | Icon component prefix |
177
+ | `typescript` | `boolean` | Generate TypeScript |
178
+ | `optimize` | `boolean` | Optimize SVGs with SVGO |
179
+
180
+ ## Peer Dependencies
181
+
182
+ - `style-dictionary@^5.0.0` (optional) - Required for token building
183
+
184
+ ## License
185
+
186
+ MIT © DSAi Design System
@@ -0,0 +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
+ });