@shohojdhara/atomix 0.3.13 → 0.3.15

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 (249) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +2 -0
  3. package/build-tools/EXAMPLES.md +372 -0
  4. package/build-tools/README.md +242 -0
  5. package/build-tools/__tests__/error-handler.test.js +230 -0
  6. package/build-tools/__tests__/index.test.js +141 -0
  7. package/build-tools/__tests__/rollup-plugin.test.js +194 -0
  8. package/build-tools/__tests__/utils.test.js +161 -0
  9. package/build-tools/__tests__/vite-plugin.test.js +129 -0
  10. package/build-tools/__tests__/webpack-loader.test.js +190 -0
  11. package/build-tools/error-handler.js +308 -0
  12. package/build-tools/index.d.ts +43 -0
  13. package/build-tools/index.js +88 -0
  14. package/build-tools/package.json +67 -0
  15. package/build-tools/rollup-plugin.js +236 -0
  16. package/build-tools/types.d.ts +163 -0
  17. package/build-tools/utils.js +203 -0
  18. package/build-tools/vite-plugin.js +161 -0
  19. package/build-tools/webpack-loader.js +123 -0
  20. package/dist/atomix.css +298 -167
  21. package/dist/atomix.css.map +1 -1
  22. package/dist/atomix.min.css +3 -3
  23. package/dist/atomix.min.css.map +1 -1
  24. package/dist/build-tools/EXAMPLES.md +372 -0
  25. package/dist/build-tools/README.md +242 -0
  26. package/dist/build-tools/__tests__/error-handler.test.js +230 -0
  27. package/dist/build-tools/__tests__/index.test.js +141 -0
  28. package/dist/build-tools/__tests__/rollup-plugin.test.js +194 -0
  29. package/dist/build-tools/__tests__/utils.test.js +161 -0
  30. package/dist/build-tools/__tests__/vite-plugin.test.js +129 -0
  31. package/dist/build-tools/__tests__/webpack-loader.test.js +190 -0
  32. package/dist/build-tools/error-handler.js +308 -0
  33. package/dist/build-tools/index.d.ts +43 -0
  34. package/dist/build-tools/index.js +88 -0
  35. package/dist/build-tools/package.json +67 -0
  36. package/dist/build-tools/rollup-plugin.js +236 -0
  37. package/dist/build-tools/types.d.ts +163 -0
  38. package/dist/build-tools/utils.js +203 -0
  39. package/dist/build-tools/vite-plugin.js +161 -0
  40. package/dist/build-tools/webpack-loader.js +123 -0
  41. package/dist/charts.d.ts +2 -2
  42. package/dist/charts.js +87 -58
  43. package/dist/charts.js.map +1 -1
  44. package/dist/core.d.ts +42 -12
  45. package/dist/core.js +175 -135
  46. package/dist/core.js.map +1 -1
  47. package/dist/forms.d.ts +30 -16
  48. package/dist/forms.js +146 -131
  49. package/dist/forms.js.map +1 -1
  50. package/dist/heavy.d.ts +2 -2
  51. package/dist/heavy.js +151 -118
  52. package/dist/heavy.js.map +1 -1
  53. package/dist/index.d.ts +130 -106
  54. package/dist/index.esm.js +1083 -465
  55. package/dist/index.esm.js.map +1 -1
  56. package/dist/index.js +1102 -483
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.min.js +1 -1
  59. package/dist/index.min.js.map +1 -1
  60. package/dist/theme.d.ts +27 -2
  61. package/dist/theme.js +721 -108
  62. package/dist/theme.js.map +1 -1
  63. package/package.json +23 -8
  64. package/scripts/atomix-cli.js +749 -1153
  65. package/scripts/cli/__tests__/README.md +81 -0
  66. package/scripts/cli/__tests__/basic.test.js +115 -0
  67. package/scripts/cli/__tests__/component-generator.test.js +332 -0
  68. package/scripts/cli/__tests__/integration.test.js +327 -0
  69. package/scripts/cli/__tests__/test-setup.js +133 -0
  70. package/scripts/cli/__tests__/token-manager.test.js +251 -0
  71. package/scripts/cli/__tests__/utils.test.js +78 -118
  72. package/scripts/cli/component-generator.js +564 -0
  73. package/scripts/cli/dependency-checker.js +355 -0
  74. package/scripts/cli/documentation-sync.js +542 -0
  75. package/scripts/cli/interactive-init.js +129 -292
  76. package/scripts/cli/mappings.js +211 -0
  77. package/scripts/cli/migration-tools.js +95 -288
  78. package/scripts/cli/template-manager.js +105 -0
  79. package/scripts/cli/templates/README.md +123 -0
  80. package/scripts/cli/templates/common-templates.js +636 -0
  81. package/scripts/cli/templates/composable-templates.js +171 -0
  82. package/scripts/cli/templates/config-templates.js +126 -0
  83. package/scripts/cli/templates/index.js +102 -0
  84. package/scripts/cli/templates/project-templates.js +342 -0
  85. package/scripts/cli/templates/react-templates.js +331 -0
  86. package/scripts/cli/templates/scss-templates.js +155 -0
  87. package/scripts/cli/templates/storybook-templates.js +236 -0
  88. package/scripts/cli/templates/testing-templates.js +224 -0
  89. package/scripts/cli/templates/testing-utils.js +278 -0
  90. package/scripts/cli/templates/token-templates.js +447 -0
  91. package/scripts/cli/templates/types-templates.js +147 -0
  92. package/scripts/cli/templates.js +35 -0
  93. package/scripts/cli/theme-bridge.js +28 -16
  94. package/scripts/cli/token-manager.js +432 -247
  95. package/scripts/cli/utils.js +37 -26
  96. package/src/components/Accordion/Accordion.stories.tsx +369 -870
  97. package/src/components/Accordion/Accordion.test.tsx +57 -0
  98. package/src/components/Accordion/Accordion.tsx +4 -0
  99. package/src/components/AtomixGlass/AtomixGlass.tsx +80 -39
  100. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +103 -81
  101. package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +8 -7
  102. package/src/components/AtomixGlass/glass-utils.ts +2 -2
  103. package/src/components/AtomixGlass/shader-utils.ts +5 -0
  104. package/src/components/AtomixGlass/stories/Customization.stories.tsx +131 -0
  105. package/src/components/AtomixGlass/stories/Examples.stories.tsx +2965 -2861
  106. package/src/components/AtomixGlass/stories/Modes.stories.tsx +1 -1
  107. package/src/components/AtomixGlass/stories/Overview.stories.tsx +348 -0
  108. package/src/components/AtomixGlass/stories/Performance.stories.tsx +103 -0
  109. package/src/components/AtomixGlass/stories/Playground.stories.tsx +73 -59
  110. package/src/components/AtomixGlass/stories/{ShaderVariants.stories.tsx → Shaders.stories.tsx} +1 -1
  111. package/src/components/AtomixGlass/stories/shared-components.tsx +90 -190
  112. package/src/components/Avatar/Avatar.stories.tsx +239 -27
  113. package/src/components/Badge/Badge.stories.tsx +132 -373
  114. package/src/components/Badge/Badge.test.tsx +51 -0
  115. package/src/components/Badge/Badge.tsx +20 -1
  116. package/src/components/Block/Block.stories.tsx +26 -17
  117. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +141 -23
  118. package/src/components/Breadcrumb/Breadcrumb.tsx +2 -2
  119. package/src/components/Button/Button.stories.tsx +463 -1126
  120. package/src/components/Button/Button.test.tsx +107 -0
  121. package/src/components/Button/Button.tsx +50 -54
  122. package/src/components/Button/ButtonGroup.stories.tsx +373 -217
  123. package/src/components/Button/README.md +5 -0
  124. package/src/components/Callout/Callout.stories.tsx +299 -644
  125. package/src/components/Callout/Callout.test.tsx +10 -10
  126. package/src/components/Callout/Callout.tsx +7 -7
  127. package/src/components/Callout/README.md +9 -8
  128. package/src/components/Card/Card.stories.tsx +248 -68
  129. package/src/components/Card/Card.tsx +2 -2
  130. package/src/components/Chart/Chart.stories.tsx +156 -14
  131. package/src/components/Chart/Chart.tsx +1 -1
  132. package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +151 -69
  133. package/src/components/Countdown/Countdown.stories.tsx +115 -8
  134. package/src/components/DataTable/DataTable.stories.tsx +346 -146
  135. package/src/components/DataTable/DataTable.tsx +14 -12
  136. package/src/components/DatePicker/DatePicker.stories.tsx +325 -1066
  137. package/src/components/Dropdown/Dropdown.stories.tsx +157 -37
  138. package/src/components/EdgePanel/EdgePanel.stories.tsx +230 -21
  139. package/src/components/Footer/Footer.stories.tsx +392 -328
  140. package/src/components/Form/Checkbox.stories.tsx +143 -9
  141. package/src/components/Form/Checkbox.test.tsx +63 -0
  142. package/src/components/Form/Checkbox.tsx +90 -52
  143. package/src/components/Form/Form.stories.tsx +121 -22
  144. package/src/components/Form/FormGroup.stories.tsx +128 -5
  145. package/src/components/Form/Input.stories.tsx +28 -16
  146. package/src/components/Form/Input.test.tsx +59 -0
  147. package/src/components/Form/Input.tsx +97 -95
  148. package/src/components/Form/Radio.stories.tsx +232 -97
  149. package/src/components/Form/Radio.tsx +2 -2
  150. package/src/components/Form/Select.stories.tsx +144 -12
  151. package/src/components/Form/Select.tsx +2 -2
  152. package/src/components/Form/Textarea.stories.tsx +171 -13
  153. package/src/components/Form/Textarea.test.tsx +45 -0
  154. package/src/components/Form/Textarea.tsx +88 -86
  155. package/src/components/Hero/Hero.stories.tsx +333 -32
  156. package/src/components/List/List.stories.tsx +143 -5
  157. package/src/components/Modal/Modal.stories.tsx +185 -46
  158. package/src/components/Navigation/Navbar/Navbar.stories.tsx +5 -5
  159. package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
  160. package/src/components/Navigation/README.md +1 -1
  161. package/src/components/Pagination/Pagination.stories.tsx +5 -2
  162. package/src/components/Pagination/Pagination.tsx +1 -1
  163. package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -10
  164. package/src/components/Popover/Popover.stories.tsx +449 -99
  165. package/src/components/ProductReview/ProductReview.tsx +1 -1
  166. package/src/components/Progress/Progress.stories.tsx +167 -5
  167. package/src/components/Progress/Progress.tsx +46 -46
  168. package/src/components/Rating/Rating.stories.tsx +4 -4
  169. package/src/components/Rating/Rating.tsx +8 -8
  170. package/src/components/River/River.stories.tsx +1 -1
  171. package/src/components/SectionIntro/SectionIntro.stories.tsx +240 -48
  172. package/src/components/Slider/Slider.stories.tsx +63 -63
  173. package/src/components/Spinner/Spinner.stories.tsx +104 -10
  174. package/src/components/Spinner/Spinner.test.tsx +35 -0
  175. package/src/components/Spinner/Spinner.tsx +9 -2
  176. package/src/components/Steps/Steps.stories.tsx +172 -43
  177. package/src/components/Tabs/Tabs.stories.tsx +136 -10
  178. package/src/components/Testimonial/Testimonial.stories.tsx +121 -4
  179. package/src/components/Todo/Todo.stories.tsx +198 -9
  180. package/src/components/Toggle/Toggle.stories.tsx +153 -43
  181. package/src/components/Toggle/Toggle.test.tsx +91 -0
  182. package/src/components/Toggle/Toggle.tsx +44 -27
  183. package/src/components/Tooltip/Tooltip.stories.tsx +194 -104
  184. package/src/components/Tooltip/Tooltip.tsx +1 -1
  185. package/src/components/Upload/Upload.stories.tsx +113 -24
  186. package/src/layouts/Grid/Grid.stories.tsx +49 -49
  187. package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +2 -2
  188. package/src/lib/README.md +2 -2
  189. package/src/lib/__tests__/theme-tools.test.ts +193 -0
  190. package/src/lib/composables/index.ts +2 -2
  191. package/src/lib/composables/useAccordion.ts +12 -3
  192. package/src/lib/composables/useAtomixGlass.ts +28 -56
  193. package/src/lib/composables/useBreadcrumb.ts +2 -2
  194. package/src/lib/composables/useCallout.ts +7 -7
  195. package/src/lib/composables/useChartExport.ts +2 -7
  196. package/src/lib/composables/useDataTable.ts +46 -29
  197. package/src/lib/composables/useNavbar.ts +1 -1
  198. package/src/lib/constants/components.ts +10 -33
  199. package/src/lib/storybook/InteractiveDemo.tsx +113 -0
  200. package/src/lib/storybook/PreviewContainer.tsx +36 -0
  201. package/src/lib/storybook/VariantsGrid.tsx +21 -0
  202. package/src/lib/storybook/index.ts +3 -0
  203. package/src/lib/theme/core/createThemeObject.ts +9 -5
  204. package/src/lib/theme/devtools/CLI.ts +155 -0
  205. package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +213 -0
  206. package/src/lib/theme/devtools/DesignTokensCustomizer.tsx +566 -0
  207. package/src/lib/theme/devtools/LiveEditor.tsx +2 -1
  208. package/src/lib/theme/devtools/index.ts +3 -0
  209. package/src/lib/theme/errors/errors.ts +8 -0
  210. package/src/lib/theme/runtime/ThemeProvider.tsx +117 -57
  211. package/src/lib/theme/runtime/__tests__/ThemeProvider.integration.test.tsx +305 -0
  212. package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +588 -0
  213. package/src/lib/theme/utils/__tests__/themeValidation.test.ts +264 -0
  214. package/src/lib/theme/utils/index.ts +1 -0
  215. package/src/lib/theme/utils/themeValidation.ts +501 -0
  216. package/src/lib/theme-tools.ts +32 -3
  217. package/src/lib/types/components.ts +82 -27
  218. package/src/lib/utils/__tests__/csv.test.ts +45 -0
  219. package/src/lib/utils/csv.ts +17 -0
  220. package/src/lib/utils/dataTableExport.ts +1 -10
  221. package/src/lib/utils/themeNaming.ts +1 -1
  222. package/src/styles/01-settings/_index.scss +2 -1
  223. package/src/styles/01-settings/_settings.accordion.scss +28 -7
  224. package/src/styles/01-settings/_settings.colors.scss +11 -11
  225. package/src/styles/01-settings/_settings.typography.scss +5 -5
  226. package/src/styles/02-tools/_tools.utility-api.scss +14 -0
  227. package/src/styles/06-components/_components.accordion.scss +56 -14
  228. package/src/styles/06-components/_components.callout.scss +29 -33
  229. package/src/styles/06-components/_components.checkbox.scss +23 -17
  230. package/src/styles/06-components/_index.scss +1 -1
  231. package/src/styles/99-utilities/_index.scss +2 -0
  232. package/src/styles/99-utilities/_utilities.display.scss +14 -3
  233. package/src/styles/99-utilities/_utilities.flex.scss +10 -10
  234. package/src/styles/99-utilities/_utilities.scss +3 -1
  235. package/src/styles/99-utilities/_utilities.text-gradient.scss +45 -0
  236. package/src/styles/99-utilities/_utilities.text.scss +28 -8
  237. package/themes/dark-complementary/README.md +98 -0
  238. package/themes/dark-complementary/index.scss +158 -0
  239. package/themes/default-light/README.md +81 -0
  240. package/themes/default-light/index.scss +154 -0
  241. package/themes/high-contrast/README.md +105 -0
  242. package/themes/high-contrast/index.scss +172 -0
  243. package/themes/test-theme/README.md +38 -0
  244. package/themes/test-theme/index.scss +47 -0
  245. package/scripts/cli/__tests__/cli-commands.test.js +0 -204
  246. package/scripts/cli/__tests__/vitest.config.js +0 -26
  247. package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +0 -1438
  248. package/src/lib/composables/useButton.ts +0 -93
  249. package/src/lib/composables/useCheckbox.ts +0 -70
@@ -0,0 +1,542 @@
1
+ /**
2
+ * Documentation Sync Module
3
+ * Syncs CLI documentation with component guidelines
4
+ */
5
+
6
+ import { readFile, writeFile, mkdir } from 'fs/promises';
7
+ import { existsSync } from 'fs';
8
+ import { join, dirname, relative } from 'path';
9
+ import chalk from 'chalk';
10
+ import ora from 'ora';
11
+ import boxen from 'boxen';
12
+
13
+ /**
14
+ * Documentation sources and destinations
15
+ * This mapping is used for future extensibility of the sync system
16
+ * @type {Record<string, {destinations: string[]}>}
17
+ */
18
+ // eslint-disable-next-line no-unused-vars
19
+ const DOCS_MAPPING = {
20
+ // Component guidelines
21
+ 'src/components/*/README.md': {
22
+ destinations: [
23
+ 'docs/components/{component}.md',
24
+ 'docs/api/{component}.md'
25
+ ]
26
+ },
27
+ // Storybook stories
28
+ 'src/components/*/*.stories.tsx': {
29
+ destinations: [
30
+ 'docs/examples/{component}.md'
31
+ ]
32
+ },
33
+ // Type definitions
34
+ 'src/lib/types/components.ts': {
35
+ destinations: [
36
+ 'docs/api/component-props.md'
37
+ ]
38
+ },
39
+ // Constants
40
+ 'src/lib/constants/components.ts': {
41
+ destinations: [
42
+ 'docs/api/component-constants.md'
43
+ ]
44
+ }
45
+ };
46
+
47
+ /**
48
+ * Extract component documentation from README
49
+ */
50
+ async function extractFromReadme(readmePath) {
51
+ const content = await readFile(readmePath, 'utf8');
52
+
53
+ const docs = {
54
+ name: '',
55
+ description: '',
56
+ usage: '',
57
+ examples: [],
58
+ props: [],
59
+ api: {}
60
+ };
61
+
62
+ // Extract component name
63
+ const nameMatch = content.match(/^# (.+)$/m);
64
+ if (nameMatch) {
65
+ docs.name = nameMatch[1];
66
+ }
67
+
68
+ // Extract description
69
+ const descMatch = content.match(/## Description\s*\n([\s\S]+?)\n##/);
70
+ if (descMatch) {
71
+ docs.description = descMatch[1].trim();
72
+ }
73
+
74
+ // Extract usage
75
+ const usageMatch = content.match(/## Usage\s*\n([\s\S]+?)\n##/);
76
+ if (usageMatch) {
77
+ docs.usage = usageMatch[1].trim();
78
+ }
79
+
80
+ // Extract examples (code blocks)
81
+ const exampleMatches = content.matchAll(/```(?:tsx|typescript|jsx|javascript)\n([\s\S]+?)```/g);
82
+ for (const match of exampleMatches) {
83
+ docs.examples.push(match[1].trim());
84
+ }
85
+
86
+ // Extract props (from TypeScript interfaces)
87
+ const propsMatch = content.match(/## Props\s*\n([\s\S]+?)\n##/);
88
+ if (propsMatch) {
89
+ const propLines = propsMatch[1].trim().split('\n');
90
+ propLines.forEach(line => {
91
+ const propMatch = line.match(/\*\s+`(\w+)`:\s+(.+?)\s*-\s*(.+)/);
92
+ if (propMatch) {
93
+ docs.props.push({
94
+ name: propMatch[1],
95
+ type: propMatch[2].trim(),
96
+ description: propMatch[3].trim()
97
+ });
98
+ }
99
+ });
100
+ }
101
+
102
+ return docs;
103
+ }
104
+
105
+ /**
106
+ * Extract component API from types
107
+ */
108
+ async function extractFromTypes(typesPath) {
109
+ const content = await readFile(typesPath, 'utf8');
110
+
111
+ const components = {};
112
+
113
+ // Extract interface definitions
114
+ const interfaceMatches = content.matchAll(/export\s+interface\s+(\w+Props)\s*{([^}]+)}/g);
115
+ for (const match of interfaceMatches) {
116
+ const componentName = match[1].replace('Props', '');
117
+ const props = [];
118
+
119
+ // Parse properties
120
+ const propMatches = match[2].matchAll(/(\w+)(\?)?:\s+([^;]+);/g);
121
+ for (const prop of propMatches) {
122
+ props.push({
123
+ name: prop[1],
124
+ optional: !!prop[2],
125
+ type: prop[3].trim()
126
+ });
127
+ }
128
+
129
+ components[componentName] = { props };
130
+ }
131
+
132
+ return components;
133
+ }
134
+
135
+ /**
136
+ * Generate Markdown documentation
137
+ */
138
+ function generateMarkdown(docs, template = 'component') {
139
+ const templates = {
140
+ component: `# ${docs.name}
141
+
142
+ ${docs.description ? `## Description\n\n${docs.description}\n\n` : ''}
143
+
144
+ ## Installation
145
+
146
+ \`\`\`bash
147
+ npm install @shohojdhara/atomix
148
+ \`\`\`
149
+
150
+ ## Usage
151
+
152
+ ${docs.usage || 'Basic usage example:'}
153
+
154
+ \`\`\`tsx
155
+ import { ${docs.name} } from '@shohojdhara/atomix';
156
+
157
+ function App() {
158
+ return (
159
+ <${docs.name}>
160
+ Content
161
+ </${docs.name}>
162
+ );
163
+ }
164
+ \`\`\`
165
+
166
+ ${docs.examples.length > 0 ? `## Examples\n\n${docs.examples.map((ex, i) => `### Example ${i + 1}\n\n\`\`\`tsx\n${ex}\n\`\`\`\n`).join('\n')}\n` : ''}
167
+
168
+ ${docs.props.length > 0 ? `## Props\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n${docs.props.map(p => `| \`${p.name}\` | ${p.type} | - | ${p.description} |`).join('\n')}\n` : ''}
169
+
170
+ ## API Reference
171
+
172
+ See [API Documentation](/docs/api/${docs.name.toLowerCase()}.md) for detailed API reference.
173
+
174
+ ## Accessibility
175
+
176
+ This component follows WCAG 2.1 AA guidelines:
177
+ - Keyboard navigation support
178
+ - ARIA attributes included
179
+ - Screen reader friendly
180
+
181
+ ## License
182
+
183
+ MIT
184
+ `,
185
+
186
+ api: `# ${docs.name} API Reference
187
+
188
+ ## Props
189
+
190
+ | Prop | Type | Default | Description |
191
+ |------|------|---------|-------------|
192
+ ${docs.props.length > 0 ? docs.props.map(p => `| \`${p.name}\` | \`${p.type}\` | - | ${p.description} |`).join('\n') : '| - | - | - | - |'}
193
+
194
+ ## Types
195
+
196
+ \`\`\`typescript
197
+ export interface ${docs.name}Props {
198
+ ${docs.props.length > 0 ? docs.props.map(p => ` /** ${p.description} */\n ${p.name}?: ${p.type};`).join('\n') : ' // Component props here'}
199
+ }
200
+ \`\`\`
201
+
202
+ ## Examples
203
+
204
+ See [Component Documentation](/docs/components/${docs.name.toLowerCase()}.md) for usage examples.
205
+ `,
206
+
207
+ 'component-props': `# Component Props Reference
208
+
209
+ This document contains all component props exported from the design system.
210
+
211
+ ## Components
212
+
213
+ ${Object.keys(docs).map(name => `### ${name}\n\nSee [${name} API](/docs/api/${name.toLowerCase()}.md)\n`).join('\n')}
214
+ `,
215
+
216
+ 'component-constants': `# Component Constants Reference
217
+
218
+ This document contains all component constants and enums.
219
+
220
+ ## Constants
221
+
222
+ Exported from \`src/lib/constants/components.ts\`.
223
+
224
+ ## Usage
225
+
226
+ \`\`\`typescript
227
+ import {
228
+ BUTTON_SIZES,
229
+ BUTTON_VARIANTS
230
+ } from '@shohojdhara/atomix';
231
+
232
+ const size = BUTTON_SIZES.MD;
233
+ \`\`\`
234
+ `
235
+ };
236
+
237
+ return templates[template] || templates.component;
238
+ }
239
+
240
+ /**
241
+ * Sync documentation from source files
242
+ * @param {object} options - Configuration options for documentation sync
243
+ * @param {boolean} options.verbose - Enable verbose logging
244
+ * @param {string[]} options.components - Specific components to sync (optional)
245
+ */
246
+ export async function syncDocumentation(options = {}) {
247
+ const { verbose = false, components: targetComponents = null } = options;
248
+ const spinner = ora('Syncing documentation...').start();
249
+
250
+ try {
251
+ const docsPath = join(process.cwd(), 'docs');
252
+ const componentsPath = join(process.cwd(), 'src/components');
253
+
254
+ // Check if components directory exists
255
+ if (!existsSync(componentsPath)) {
256
+ spinner.fail('Components directory not found');
257
+ return {
258
+ success: false,
259
+ message: 'Please run this command from an Atomix project root'
260
+ };
261
+ }
262
+
263
+ const syncResults = [];
264
+
265
+ // Sync each component
266
+ let componentDirs = await getDirectories(componentsPath);
267
+
268
+ // Filter components if specified
269
+ if (targetComponents && targetComponents.length > 0) {
270
+ componentDirs = componentDirs.filter(name => targetComponents.includes(name));
271
+ }
272
+
273
+ for (const componentName of componentDirs) {
274
+ const componentPath = join(componentsPath, componentName);
275
+
276
+ // Check for README
277
+ const readmePath = join(componentPath, 'README.md');
278
+ if (existsSync(readmePath)) {
279
+ const docs = await extractFromReadme(readmePath);
280
+
281
+ // Generate component documentation
282
+ const componentDocPath = join(docsPath, 'components', `${componentName}.md`);
283
+ const componentContent = generateMarkdown(docs, 'component');
284
+
285
+ await mkdir(dirname(componentDocPath), { recursive: true });
286
+ await writeFile(componentDocPath, componentContent, 'utf8');
287
+
288
+ syncResults.push({
289
+ component: componentName,
290
+ status: 'synced',
291
+ file: relative(process.cwd(), componentDocPath)
292
+ });
293
+
294
+ if (verbose) {
295
+ console.log(chalk.gray(` → Component doc: ${relative(process.cwd(), componentDocPath)}`));
296
+ }
297
+
298
+ // Generate API documentation
299
+ const apiDocPath = join(docsPath, 'api', `${componentName}.md`);
300
+ const apiContent = generateMarkdown(docs, 'api');
301
+
302
+ await writeFile(apiDocPath, apiContent, 'utf8');
303
+
304
+ syncResults.push({
305
+ component: `${componentName} (API)`,
306
+ status: 'synced',
307
+ file: relative(process.cwd(), apiDocPath)
308
+ });
309
+
310
+ if (verbose) {
311
+ console.log(chalk.gray(` → API doc: ${relative(process.cwd(), apiDocPath)}`));
312
+ }
313
+ }
314
+ }
315
+
316
+ // Sync types documentation
317
+ const typesPath = join(process.cwd(), 'src/lib/types/components.ts');
318
+ if (existsSync(typesPath)) {
319
+ const typeDocs = await extractFromTypes(typesPath);
320
+
321
+ const typesDocPath = join(docsPath, 'api', 'component-props.md');
322
+ const typesContent = generateMarkdown(typeDocs, 'component-props');
323
+
324
+ await mkdir(dirname(typesDocPath), { recursive: true });
325
+ await writeFile(typesDocPath, typesContent, 'utf8');
326
+
327
+ syncResults.push({
328
+ component: 'Type Definitions',
329
+ status: 'synced',
330
+ file: relative(process.cwd(), typesDocPath)
331
+ });
332
+
333
+ if (verbose) {
334
+ console.log(chalk.gray(` → Types doc: ${relative(process.cwd(), typesDocPath)}`));
335
+ }
336
+ }
337
+
338
+ spinner.succeed(chalk.green('Documentation synced successfully'));
339
+
340
+ // Display results
341
+ console.log(chalk.bold.cyan('\n📄 Sync Summary:\n'));
342
+ syncResults.forEach(result => {
343
+ console.log(chalk.green(` ✓ ${result.component}`));
344
+ console.log(chalk.gray(` ${result.file}\n`));
345
+ });
346
+
347
+ return {
348
+ success: true,
349
+ synced: syncResults.length,
350
+ results: syncResults
351
+ };
352
+
353
+ } catch (error) {
354
+ spinner.fail('Documentation sync failed');
355
+ throw error;
356
+ }
357
+ }
358
+
359
+ /**
360
+ * Validate documentation completeness
361
+ */
362
+ export async function validateDocumentation() {
363
+ const spinner = ora('Validating documentation...').start();
364
+
365
+ try {
366
+ const issues = [];
367
+ const warnings = [];
368
+
369
+ // Check for missing component docs
370
+ const componentsPath = join(process.cwd(), 'src/components');
371
+ const docsPath = join(process.cwd(), 'docs/components');
372
+
373
+ if (existsSync(componentsPath) && existsSync(docsPath)) {
374
+ const componentDirs = await getDirectories(componentsPath);
375
+
376
+ for (const componentName of componentDirs) {
377
+ const docPath = join(docsPath, `${componentName}.md`);
378
+
379
+ if (!existsSync(docPath)) {
380
+ issues.push({
381
+ component: componentName,
382
+ issue: 'Missing documentation file',
383
+ suggestion: 'Run: atomix docs sync'
384
+ });
385
+ } else {
386
+ const content = await readFile(docPath, 'utf8');
387
+
388
+ // Check for required sections
389
+ const requiredSections = ['Usage', 'Props', 'Examples'];
390
+ for (const section of requiredSections) {
391
+ if (!content.includes(`## ${section}`)) {
392
+ warnings.push({
393
+ component: componentName,
394
+ issue: `Missing "${section}" section`,
395
+ suggestion: 'Add the missing section to the documentation'
396
+ });
397
+ }
398
+ }
399
+
400
+ // Check for code examples
401
+ if (!content.match(/```/)) {
402
+ warnings.push({
403
+ component: componentName,
404
+ issue: 'No code examples found',
405
+ suggestion: 'Add usage examples with code blocks'
406
+ });
407
+ }
408
+ }
409
+ }
410
+ }
411
+
412
+ spinner.stop();
413
+
414
+ // Display results
415
+ if (issues.length === 0 && warnings.length === 0) {
416
+ console.log(boxen(
417
+ chalk.bold.green('✅ Documentation validation passed!\n\n') +
418
+ chalk.gray('All component documentation is complete and up to date.'),
419
+ {
420
+ padding: 1,
421
+ margin: 1,
422
+ borderStyle: 'round',
423
+ borderColor: 'green'
424
+ }
425
+ ));
426
+ return { valid: true, issues: [], warnings: [] };
427
+ }
428
+
429
+ if (issues.length > 0) {
430
+ console.log(chalk.bold.red(`\n❌ Found ${issues.length} issue(s):\n`));
431
+ issues.forEach((issue, index) => {
432
+ console.log(chalk.red(` ${index + 1}. ${issue.component}`));
433
+ console.log(chalk.gray(` Issue: ${issue.issue}`));
434
+ console.log(chalk.yellow(` Suggestion: ${issue.suggestion}\n`));
435
+ });
436
+ }
437
+
438
+ if (warnings.length > 0) {
439
+ console.log(chalk.bold.yellow(`\n⚠️ Found ${warnings.length} warning(s):\n`));
440
+ warnings.forEach((warning, index) => {
441
+ console.log(chalk.yellow(` ${index + 1}. ${warning.component}`));
442
+ console.log(chalk.gray(` Warning: ${warning.issue}`));
443
+ console.log(chalk.cyan(` Suggestion: ${warning.suggestion}\n`));
444
+ });
445
+ }
446
+
447
+ return { valid: issues.length === 0, issues, warnings };
448
+
449
+ } catch (error) {
450
+ spinner.fail('Documentation validation failed');
451
+ throw error;
452
+ }
453
+ }
454
+
455
+ /**
456
+ * Helper function to get directories
457
+ */
458
+ async function getDirectories(path) {
459
+ const { readdir } = await import('fs/promises');
460
+ const entries = await readdir(path, { withFileTypes: true });
461
+ return entries
462
+ .filter(entry => entry.isDirectory())
463
+ .map(entry => entry.name);
464
+ }
465
+
466
+ /**
467
+ * Generate CLI documentation from commands
468
+ */
469
+ export async function generateCLIDocumentation() {
470
+ const cliPath = join(process.cwd(), 'scripts/atomix-cli.js');
471
+ const docsPath = join(process.cwd(), 'docs');
472
+
473
+ if (!existsSync(cliPath)) {
474
+ throw new Error('CLI file not found');
475
+ }
476
+
477
+ const content = await readFile(cliPath, 'utf8');
478
+
479
+ // Extract commands
480
+ const commands = [];
481
+ const commandMatches = content.matchAll(/program\.command\(['"]([^'"]+)['"]\)/g);
482
+ for (const match of commandMatches) {
483
+ commands.push(match[1]);
484
+ }
485
+
486
+ // Generate CLI documentation
487
+ let cliDocs = `# CLI Documentation
488
+
489
+ The Atomix CLI provides commands for managing your design system.
490
+
491
+ ## Installation
492
+
493
+ \`\`\`bash
494
+ npm install -g @shohojdhara/atomix
495
+ \`\`\`
496
+
497
+ ## Commands
498
+
499
+ `;
500
+
501
+ commands.forEach(cmd => {
502
+ cliDocs += `### ${cmd}\n\nCommand description and usage.\n\n`;
503
+ });
504
+
505
+ cliDocs += `## Examples
506
+
507
+ Initialize a new project:
508
+ \`\`\`bash
509
+ atomix init
510
+ \`\`\`
511
+
512
+ Generate a component:
513
+ \`\`\`bash
514
+ atomix generate component MyComponent
515
+ \`\`\`
516
+
517
+ Build a theme:
518
+ \`\`\`bash
519
+ atomix build-theme themes/custom
520
+ \`\`\`
521
+
522
+ Validate your design system:
523
+ \`\`\`bash
524
+ atomix validate --tokens --theme
525
+ \`\`\`
526
+ `;
527
+
528
+ const cliDocPath = join(docsPath, 'cli.md');
529
+ await mkdir(dirname(cliDocPath), { recursive: true });
530
+ await writeFile(cliDocPath, cliDocs, 'utf8');
531
+
532
+ return {
533
+ success: true,
534
+ file: cliDocPath
535
+ };
536
+ }
537
+
538
+ export default {
539
+ syncDocumentation,
540
+ validateDocumentation,
541
+ generateCLIDocumentation
542
+ };