@dsai-io/tools 0.0.1 → 1.1.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.
Files changed (44) hide show
  1. package/README.md +438 -186
  2. package/bin/dsai-tools.mjs +13 -13
  3. package/dist/cli/index.cjs +8192 -2757
  4. package/dist/cli/index.cjs.map +1 -1
  5. package/dist/cli/index.d.cts +4 -0
  6. package/dist/cli/index.d.ts +4 -0
  7. package/dist/cli/index.js +8190 -2757
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/config/index.cjs +264 -63
  10. package/dist/config/index.cjs.map +1 -1
  11. package/dist/config/index.d.cts +537 -1759
  12. package/dist/config/index.d.ts +537 -1759
  13. package/dist/config/index.js +259 -63
  14. package/dist/config/index.js.map +1 -1
  15. package/dist/icons/index.cjs +1 -1
  16. package/dist/icons/index.cjs.map +1 -1
  17. package/dist/icons/index.d.cts +1 -1
  18. package/dist/icons/index.d.ts +1 -1
  19. package/dist/icons/index.js +1 -1
  20. package/dist/icons/index.js.map +1 -1
  21. package/dist/index.cjs +8093 -3024
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +214 -5
  24. package/dist/index.d.ts +214 -5
  25. package/dist/index.js +8033 -3012
  26. package/dist/index.js.map +1 -1
  27. package/dist/tokens/index.cjs +4457 -737
  28. package/dist/tokens/index.cjs.map +1 -1
  29. package/dist/tokens/index.d.cts +1258 -17
  30. package/dist/tokens/index.d.ts +1258 -17
  31. package/dist/tokens/index.js +4368 -683
  32. package/dist/tokens/index.js.map +1 -1
  33. package/dist/{types-Idj08nad.d.cts → types-CtE9f0G0.d.cts} +293 -3
  34. package/dist/{types-Idj08nad.d.ts → types-CtE9f0G0.d.ts} +293 -3
  35. package/dist/utils/circuit-breaker.cjs +173 -0
  36. package/dist/utils/circuit-breaker.cjs.map +1 -0
  37. package/dist/utils/circuit-breaker.d.cts +123 -0
  38. package/dist/utils/circuit-breaker.d.ts +123 -0
  39. package/dist/utils/circuit-breaker.js +169 -0
  40. package/dist/utils/circuit-breaker.js.map +1 -0
  41. package/package.json +102 -97
  42. package/templates/.dsairc.json +37 -37
  43. package/templates/dsai-config.schema.json +618 -554
  44. package/templates/dsai.config.mjs +281 -221
@@ -11,6 +11,10 @@ interface DsaiConfig {
11
11
  tokens?: TokensConfig;
12
12
  /** Icon generation configuration */
13
13
  icons?: IconsConfig;
14
+ /** Path aliases for component installation */
15
+ aliases?: AliasesConfig;
16
+ /** Component distribution configuration */
17
+ components?: ComponentsConfig;
14
18
  /** Global settings */
15
19
  global?: GlobalConfig;
16
20
  }
@@ -130,6 +134,10 @@ interface TokensConfig {
130
134
  * @example '_variables.scss' or 'path/to/custom-base.scss'
131
135
  */
132
136
  scssImportHeader?: string;
137
+ /**
138
+ * SCSS/CSS output style options
139
+ */
140
+ scss?: ScssOutputConfig;
133
141
  /** Theme mode settings */
134
142
  themes?: ThemesConfig;
135
143
  /** Custom Style Dictionary transforms */
@@ -194,11 +202,33 @@ interface TokensConfig {
194
202
  * Controls which steps run and their paths
195
203
  */
196
204
  pipeline?: TokensBuildPipeline;
205
+ /**
206
+ * Postprocess configuration for CSS file transformations
207
+ * Applied after SASS compilation
208
+ */
209
+ postprocess?: PostprocessConfig;
210
+ }
211
+ /**
212
+ * Postprocess configuration for CSS file transformations
213
+ */
214
+ interface PostprocessConfig {
215
+ /** Whether postprocessing is enabled */
216
+ enabled?: boolean;
217
+ /** Directory containing CSS files to process */
218
+ cssDir?: string;
219
+ /** File names to process */
220
+ files?: string[];
221
+ /** Replacement rules to apply */
222
+ replacements?: Array<{
223
+ description?: string;
224
+ from: string | RegExp;
225
+ to: string;
226
+ }>;
197
227
  }
198
228
  /**
199
229
  * Build pipeline step names
200
230
  */
201
- type BuildPipelineStep = 'validate' | 'transform' | 'style-dictionary' | 'sync' | 'sass-theme' | 'sass-theme-minified' | 'postprocess' | 'sass-utilities' | 'sass-utilities-minified' | 'bundle';
231
+ type BuildPipelineStep = 'validate' | 'snapshot' | 'preprocess' | 'transform' | 'style-dictionary' | 'multi-theme' | 'sync' | 'sass-theme' | 'sass-theme-minified' | 'postprocess' | 'sass-utilities' | 'sass-utilities-minified' | 'bundle';
202
232
  /**
203
233
  * Build pipeline paths configuration
204
234
  */
@@ -263,18 +293,181 @@ interface BuildSummary {
263
293
  themes: string[];
264
294
  };
265
295
  }
296
+ /**
297
+ * CSS/SCSS output style options
298
+ * Controls whether to generate expanded, compressed, or both formats
299
+ */
300
+ interface ScssOutputConfig {
301
+ /**
302
+ * Output format styles to generate
303
+ * - 'expanded': Human-readable, formatted CSS
304
+ * - 'compressed': Minified CSS for production
305
+ * @default ['expanded']
306
+ */
307
+ outputStyles?: ('expanded' | 'compressed')[];
308
+ /**
309
+ * Generate source maps for debugging
310
+ * @default false
311
+ */
312
+ generateSourceMaps?: boolean;
313
+ /**
314
+ * Suffix for minified/compressed output files
315
+ * @default '.min'
316
+ * @example '.min' produces 'theme.min.css' alongside 'theme.css'
317
+ */
318
+ minifiedSuffix?: string;
319
+ /**
320
+ * Entry SCSS file for theme compilation
321
+ * Relative to config file location
322
+ * @example 'src/scss/dsai-theme-bs.scss'
323
+ */
324
+ themeEntry?: string;
325
+ /**
326
+ * Entry SCSS file for utilities compilation
327
+ * Relative to config file location
328
+ * @example 'src/scss/dsai-utilities.scss'
329
+ */
330
+ utilitiesEntry?: string;
331
+ /**
332
+ * Output directory for compiled CSS files
333
+ * Relative to config file location
334
+ * @default 'src/generated'
335
+ */
336
+ cssOutputDir?: string;
337
+ /**
338
+ * Additional Sass load paths for @use and @import resolution
339
+ * @default ['node_modules']
340
+ */
341
+ loadPaths?: string[];
342
+ /**
343
+ * Target CSS framework for variable naming conventions
344
+ * Controls how token names are mapped to framework-specific names
345
+ * @default 'bootstrap'
346
+ */
347
+ framework?: FrameworkTarget;
348
+ /**
349
+ * Custom name mappings for token → framework variable names
350
+ * Merged with framework defaults (custom mappings take precedence)
351
+ * @example { 'typography-text-base': 'font-size-base', 'typography-heading-h1': 'h1-font-size' }
352
+ */
353
+ nameMapping?: Record<string, string>;
354
+ /**
355
+ * Output path for generated SCSS variables file
356
+ * Relative to config file location
357
+ * @default 'src/scss/_variables.scss'
358
+ */
359
+ variablesOutput?: string;
360
+ }
361
+ /**
362
+ * Supported CSS framework targets
363
+ * Each framework has its own naming conventions for variables
364
+ */
365
+ type FrameworkTarget = 'bootstrap' | 'shadcn' | 'tailwind' | 'mui' | 'custom';
366
+ /**
367
+ * Framework mapping configuration
368
+ * Defines how Figma token names map to framework-specific variable names
369
+ */
370
+ interface FrameworkMappingConfig {
371
+ /**
372
+ * Framework identifier
373
+ */
374
+ framework: FrameworkTarget;
375
+ /**
376
+ * Token name → framework variable name mappings
377
+ * Keys are Figma/DTCG token names, values are framework variable names
378
+ */
379
+ mappings: Record<string, string>;
380
+ /**
381
+ * Pattern-based mappings using regex
382
+ * Applied after explicit mappings
383
+ * @example [{ pattern: /^typography-heading-(.+)$/, replacement: 'h$1-font-size' }]
384
+ */
385
+ patterns?: FrameworkMappingPattern[];
386
+ /**
387
+ * Variable prefix for this framework
388
+ * @example '$' for SCSS, '--' for CSS custom properties
389
+ */
390
+ variablePrefix?: string;
391
+ /**
392
+ * File header comment
393
+ */
394
+ header?: string;
395
+ }
396
+ /**
397
+ * Pattern-based name mapping rule
398
+ */
399
+ interface FrameworkMappingPattern {
400
+ /**
401
+ * Regex pattern to match token names
402
+ */
403
+ pattern: RegExp | string;
404
+ /**
405
+ * Replacement string (supports $1, $2, etc. for capture groups)
406
+ */
407
+ replacement: string;
408
+ /**
409
+ * Optional description for documentation
410
+ */
411
+ description?: string;
412
+ }
413
+ /**
414
+ * Individual theme definition
415
+ * Specifies how a theme is discovered and built
416
+ */
417
+ interface ThemeDefinition {
418
+ /**
419
+ * Whether this is the default theme (uses :root selector)
420
+ * Only one theme can be default
421
+ * @default false
422
+ */
423
+ isDefault?: boolean;
424
+ /**
425
+ * File suffix pattern for this theme
426
+ * null means files without any theme suffix (default theme)
427
+ * e.g., '-dark' matches files like 'foundation-dark.json'
428
+ * @default null for default theme, '-{themeName}' for others
429
+ */
430
+ suffix?: string | null;
431
+ /**
432
+ * CSS selector for this theme
433
+ * @example ':root' for default, '[data-dsai-theme="dark"]' for dark
434
+ */
435
+ selector: string;
436
+ /**
437
+ * Optional media query for automatic switching
438
+ * @example '(prefers-color-scheme: dark)'
439
+ */
440
+ mediaQuery?: string;
441
+ /**
442
+ * Optional data attribute (derived from selector if not specified)
443
+ */
444
+ dataAttribute?: string;
445
+ /**
446
+ * Custom output file names per format
447
+ * If not specified, uses default naming pattern with theme suffix
448
+ */
449
+ outputFiles?: Partial<Record<OutputFormat, string>>;
450
+ }
266
451
  /**
267
452
  * Theme configuration
268
453
  */
269
454
  interface ThemesConfig {
455
+ /**
456
+ * Enable/disable theme processing
457
+ * @default true
458
+ */
459
+ enabled?: boolean;
270
460
  /**
271
461
  * Auto-detect available modes from Figma export
462
+ * When true, scans for files with theme suffixes
463
+ * When false, only builds themes explicitly defined in definitions
272
464
  * @default true
273
465
  */
274
466
  autoDetect?: boolean;
275
467
  /**
276
468
  * Default theme mode (uses :root selector)
277
- * @default 'Light'
469
+ * @default 'light'
470
+ * @deprecated Use definitions with isDefault: true instead
278
471
  */
279
472
  default?: string;
280
473
  /**
@@ -286,6 +479,12 @@ interface ThemesConfig {
286
479
  * CSS selector patterns for themes
287
480
  */
288
481
  selectorPattern?: ThemeSelectorPattern;
482
+ /**
483
+ * Explicit theme definitions
484
+ * Key is theme name, value is theme configuration
485
+ * When specified, provides explicit control over theme builds
486
+ */
487
+ definitions?: Record<string, ThemeDefinition>;
289
488
  }
290
489
  /**
291
490
  * Theme selector pattern configuration
@@ -443,14 +642,70 @@ interface IconsConfig {
443
642
  */
444
643
  prefix?: string;
445
644
  }
645
+ /**
646
+ * Path aliases for component installation.
647
+ * Controls where `dsai add` writes files in the consumer's project.
648
+ */
649
+ interface AliasesConfig {
650
+ /** Import alias prefix used in tsconfig paths (e.g., "@/", "~/", "@dsai/") @default '@/' */
651
+ importAlias?: string;
652
+ /** Where UI components are installed @default 'src/components/ui' */
653
+ ui?: string;
654
+ /** Where shared hooks are installed @default 'src/hooks' */
655
+ hooks?: string;
656
+ /** Where utility functions are installed @default 'src/lib/utils' */
657
+ utils?: string;
658
+ /** Where higher-level composed components go @default 'src/components' */
659
+ components?: string;
660
+ /** Where lib files go @default 'src/lib' */
661
+ lib?: string;
662
+ }
663
+ /**
664
+ * Configuration for component distribution (shadcn-style).
665
+ */
666
+ interface ComponentsConfig {
667
+ /** Enable component distribution features @default true */
668
+ enabled?: boolean;
669
+ /** Registry URL or local path @default 'https://registry.dsai.dev' */
670
+ registryUrl?: string;
671
+ /** Whether to use TypeScript (.tsx) or JavaScript (.jsx) @default true */
672
+ tsx?: boolean;
673
+ /** Overwrite existing files when adding components @default false */
674
+ overwrite?: boolean;
675
+ }
676
+ /**
677
+ * Resolved theme definition with all required fields
678
+ */
679
+ interface ResolvedThemeDefinition {
680
+ /** Whether this is the default theme */
681
+ isDefault: boolean;
682
+ /** File suffix pattern (null for default theme) */
683
+ suffix: string | null;
684
+ /** CSS selector */
685
+ selector: string;
686
+ /** Optional media query */
687
+ mediaQuery?: string;
688
+ /** Optional data attribute */
689
+ dataAttribute?: string;
690
+ /** Output file names per format */
691
+ outputFiles: Record<OutputFormat, string>;
692
+ }
446
693
  /**
447
694
  * Resolved themes config with all defaults applied
448
695
  */
449
696
  interface ResolvedThemesConfig {
697
+ /** Whether themes are enabled */
698
+ enabled: boolean;
699
+ /** Auto-detect themes from files */
450
700
  autoDetect: boolean;
701
+ /** Default theme name (for backward compat) */
451
702
  default: string;
703
+ /** Modes to ignore */
452
704
  ignoreModes: string[];
705
+ /** Selector patterns */
453
706
  selectorPattern: Required<ThemeSelectorPattern>;
707
+ /** Resolved theme definitions */
708
+ definitions: Record<string, ResolvedThemeDefinition>;
454
709
  }
455
710
  /**
456
711
  * Resolved tokens config with all defaults applied
@@ -486,6 +741,19 @@ interface ResolvedTokensConfig {
486
741
  watch: boolean;
487
742
  watchDirectories: string[];
488
743
  pipeline?: TokensBuildPipeline;
744
+ scss?: {
745
+ cssOutputDir?: string;
746
+ };
747
+ postprocess?: {
748
+ enabled?: boolean;
749
+ cssDir?: string;
750
+ files?: string[];
751
+ replacements?: Array<{
752
+ description?: string;
753
+ from: string | RegExp;
754
+ to: string;
755
+ }>;
756
+ };
489
757
  }
490
758
  /**
491
759
  * Resolved icons config with all defaults applied
@@ -498,6 +766,26 @@ interface ResolvedIconsConfig {
498
766
  optimize: boolean;
499
767
  prefix: string;
500
768
  }
769
+ /**
770
+ * Resolved aliases config with all defaults applied
771
+ */
772
+ interface ResolvedAliasesConfig {
773
+ importAlias: string;
774
+ ui: string;
775
+ hooks: string;
776
+ utils: string;
777
+ components: string;
778
+ lib: string;
779
+ }
780
+ /**
781
+ * Resolved components config with all defaults applied
782
+ */
783
+ interface ResolvedComponentsConfig {
784
+ enabled: boolean;
785
+ registryUrl: string;
786
+ tsx: boolean;
787
+ overwrite: boolean;
788
+ }
501
789
  /**
502
790
  * Resolved global config with all defaults applied
503
791
  */
@@ -512,6 +800,8 @@ interface ResolvedGlobalConfig {
512
800
  interface ResolvedConfig {
513
801
  tokens: ResolvedTokensConfig;
514
802
  icons: ResolvedIconsConfig;
803
+ aliases: ResolvedAliasesConfig;
804
+ components: ResolvedComponentsConfig;
515
805
  global: ResolvedGlobalConfig;
516
806
  /** Absolute path to config file (if loaded from file) */
517
807
  configPath?: string;
@@ -543,4 +833,4 @@ interface LoadConfigResult {
543
833
  warnings: string[];
544
834
  }
545
835
 
546
- export type { BuildSummary as B, CustomTransform as C, DsaiConfig as D, FormatArgs as F, GlobalConfig as G, IconsConfig as I, LoadConfigOptions as L, OutputFormat as O, Platform as P, ResolvedConfig as R, TokensConfig as T, ThemesConfig as a, ThemeSelectorPattern as b, ResolvedGlobalConfig as c, ResolvedTokensConfig as d, ResolvedIconsConfig as e, ResolvedThemesConfig as f, CustomFormat as g, CustomPreprocessor as h, CustomFilter as i, TokenData as j, TransformOptions as k, Dictionary as l, FileConfig as m, LoadConfigResult as n, LogLevel as o, IconFramework as p };
836
+ export type { AliasesConfig as A, BuildSummary as B, ComponentsConfig as C, Dictionary as D, FileConfig as F, GlobalConfig as G, IconFramework as I, LoadConfigOptions as L, OutputFormat as O, Platform as P, ResolvedAliasesConfig as R, ScssOutputConfig as S, ThemeDefinition as T, ResolvedComponentsConfig as a, CustomFilter as b, CustomFormat as c, CustomPreprocessor as d, CustomTransform as e, DsaiConfig as f, FormatArgs as g, FrameworkMappingConfig as h, FrameworkMappingPattern as i, FrameworkTarget as j, IconsConfig as k, LoadConfigResult as l, LogLevel as m, ResolvedConfig as n, ResolvedGlobalConfig as o, ResolvedIconsConfig as p, ResolvedThemeDefinition as q, ResolvedThemesConfig as r, ResolvedTokensConfig as s, ThemeSelectorPattern as t, ThemesConfig as u, TokenData as v, TokensConfig as w, TransformOptions as x };