@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.
- package/CHANGELOG.md +39 -0
- package/README.md +2 -0
- package/build-tools/EXAMPLES.md +372 -0
- package/build-tools/README.md +242 -0
- package/build-tools/__tests__/error-handler.test.js +230 -0
- package/build-tools/__tests__/index.test.js +141 -0
- package/build-tools/__tests__/rollup-plugin.test.js +194 -0
- package/build-tools/__tests__/utils.test.js +161 -0
- package/build-tools/__tests__/vite-plugin.test.js +129 -0
- package/build-tools/__tests__/webpack-loader.test.js +190 -0
- package/build-tools/error-handler.js +308 -0
- package/build-tools/index.d.ts +43 -0
- package/build-tools/index.js +88 -0
- package/build-tools/package.json +67 -0
- package/build-tools/rollup-plugin.js +236 -0
- package/build-tools/types.d.ts +163 -0
- package/build-tools/utils.js +203 -0
- package/build-tools/vite-plugin.js +161 -0
- package/build-tools/webpack-loader.js +123 -0
- package/dist/atomix.css +298 -167
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +3 -3
- package/dist/atomix.min.css.map +1 -1
- package/dist/build-tools/EXAMPLES.md +372 -0
- package/dist/build-tools/README.md +242 -0
- package/dist/build-tools/__tests__/error-handler.test.js +230 -0
- package/dist/build-tools/__tests__/index.test.js +141 -0
- package/dist/build-tools/__tests__/rollup-plugin.test.js +194 -0
- package/dist/build-tools/__tests__/utils.test.js +161 -0
- package/dist/build-tools/__tests__/vite-plugin.test.js +129 -0
- package/dist/build-tools/__tests__/webpack-loader.test.js +190 -0
- package/dist/build-tools/error-handler.js +308 -0
- package/dist/build-tools/index.d.ts +43 -0
- package/dist/build-tools/index.js +88 -0
- package/dist/build-tools/package.json +67 -0
- package/dist/build-tools/rollup-plugin.js +236 -0
- package/dist/build-tools/types.d.ts +163 -0
- package/dist/build-tools/utils.js +203 -0
- package/dist/build-tools/vite-plugin.js +161 -0
- package/dist/build-tools/webpack-loader.js +123 -0
- package/dist/charts.d.ts +2 -2
- package/dist/charts.js +87 -58
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +42 -12
- package/dist/core.js +175 -135
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +30 -16
- package/dist/forms.js +146 -131
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +2 -2
- package/dist/heavy.js +151 -118
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +130 -106
- package/dist/index.esm.js +1083 -465
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1102 -483
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +27 -2
- package/dist/theme.js +721 -108
- package/dist/theme.js.map +1 -1
- package/package.json +23 -8
- package/scripts/atomix-cli.js +749 -1153
- package/scripts/cli/__tests__/README.md +81 -0
- package/scripts/cli/__tests__/basic.test.js +115 -0
- package/scripts/cli/__tests__/component-generator.test.js +332 -0
- package/scripts/cli/__tests__/integration.test.js +327 -0
- package/scripts/cli/__tests__/test-setup.js +133 -0
- package/scripts/cli/__tests__/token-manager.test.js +251 -0
- package/scripts/cli/__tests__/utils.test.js +78 -118
- package/scripts/cli/component-generator.js +564 -0
- package/scripts/cli/dependency-checker.js +355 -0
- package/scripts/cli/documentation-sync.js +542 -0
- package/scripts/cli/interactive-init.js +129 -292
- package/scripts/cli/mappings.js +211 -0
- package/scripts/cli/migration-tools.js +95 -288
- package/scripts/cli/template-manager.js +105 -0
- package/scripts/cli/templates/README.md +123 -0
- package/scripts/cli/templates/common-templates.js +636 -0
- package/scripts/cli/templates/composable-templates.js +171 -0
- package/scripts/cli/templates/config-templates.js +126 -0
- package/scripts/cli/templates/index.js +102 -0
- package/scripts/cli/templates/project-templates.js +342 -0
- package/scripts/cli/templates/react-templates.js +331 -0
- package/scripts/cli/templates/scss-templates.js +155 -0
- package/scripts/cli/templates/storybook-templates.js +236 -0
- package/scripts/cli/templates/testing-templates.js +224 -0
- package/scripts/cli/templates/testing-utils.js +278 -0
- package/scripts/cli/templates/token-templates.js +447 -0
- package/scripts/cli/templates/types-templates.js +147 -0
- package/scripts/cli/templates.js +35 -0
- package/scripts/cli/theme-bridge.js +28 -16
- package/scripts/cli/token-manager.js +432 -247
- package/scripts/cli/utils.js +37 -26
- package/src/components/Accordion/Accordion.stories.tsx +369 -870
- package/src/components/Accordion/Accordion.test.tsx +57 -0
- package/src/components/Accordion/Accordion.tsx +4 -0
- package/src/components/AtomixGlass/AtomixGlass.tsx +80 -39
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +103 -81
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +8 -7
- package/src/components/AtomixGlass/glass-utils.ts +2 -2
- package/src/components/AtomixGlass/shader-utils.ts +5 -0
- package/src/components/AtomixGlass/stories/Customization.stories.tsx +131 -0
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2965 -2861
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +1 -1
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +348 -0
- package/src/components/AtomixGlass/stories/Performance.stories.tsx +103 -0
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +73 -59
- package/src/components/AtomixGlass/stories/{ShaderVariants.stories.tsx ā Shaders.stories.tsx} +1 -1
- package/src/components/AtomixGlass/stories/shared-components.tsx +90 -190
- package/src/components/Avatar/Avatar.stories.tsx +239 -27
- package/src/components/Badge/Badge.stories.tsx +132 -373
- package/src/components/Badge/Badge.test.tsx +51 -0
- package/src/components/Badge/Badge.tsx +20 -1
- package/src/components/Block/Block.stories.tsx +26 -17
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +141 -23
- package/src/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +463 -1126
- package/src/components/Button/Button.test.tsx +107 -0
- package/src/components/Button/Button.tsx +50 -54
- package/src/components/Button/ButtonGroup.stories.tsx +373 -217
- package/src/components/Button/README.md +5 -0
- package/src/components/Callout/Callout.stories.tsx +299 -644
- package/src/components/Callout/Callout.test.tsx +10 -10
- package/src/components/Callout/Callout.tsx +7 -7
- package/src/components/Callout/README.md +9 -8
- package/src/components/Card/Card.stories.tsx +248 -68
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Chart/Chart.stories.tsx +156 -14
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +151 -69
- package/src/components/Countdown/Countdown.stories.tsx +115 -8
- package/src/components/DataTable/DataTable.stories.tsx +346 -146
- package/src/components/DataTable/DataTable.tsx +14 -12
- package/src/components/DatePicker/DatePicker.stories.tsx +325 -1066
- package/src/components/Dropdown/Dropdown.stories.tsx +157 -37
- package/src/components/EdgePanel/EdgePanel.stories.tsx +230 -21
- package/src/components/Footer/Footer.stories.tsx +392 -328
- package/src/components/Form/Checkbox.stories.tsx +143 -9
- package/src/components/Form/Checkbox.test.tsx +63 -0
- package/src/components/Form/Checkbox.tsx +90 -52
- package/src/components/Form/Form.stories.tsx +121 -22
- package/src/components/Form/FormGroup.stories.tsx +128 -5
- package/src/components/Form/Input.stories.tsx +28 -16
- package/src/components/Form/Input.test.tsx +59 -0
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +232 -97
- package/src/components/Form/Radio.tsx +2 -2
- package/src/components/Form/Select.stories.tsx +144 -12
- package/src/components/Form/Select.tsx +2 -2
- package/src/components/Form/Textarea.stories.tsx +171 -13
- package/src/components/Form/Textarea.test.tsx +45 -0
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/Hero/Hero.stories.tsx +333 -32
- package/src/components/List/List.stories.tsx +143 -5
- package/src/components/Modal/Modal.stories.tsx +185 -46
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +5 -5
- package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/Navigation/README.md +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +5 -2
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -10
- package/src/components/Popover/Popover.stories.tsx +449 -99
- package/src/components/ProductReview/ProductReview.tsx +1 -1
- package/src/components/Progress/Progress.stories.tsx +167 -5
- package/src/components/Progress/Progress.tsx +46 -46
- package/src/components/Rating/Rating.stories.tsx +4 -4
- package/src/components/Rating/Rating.tsx +8 -8
- package/src/components/River/River.stories.tsx +1 -1
- package/src/components/SectionIntro/SectionIntro.stories.tsx +240 -48
- package/src/components/Slider/Slider.stories.tsx +63 -63
- package/src/components/Spinner/Spinner.stories.tsx +104 -10
- package/src/components/Spinner/Spinner.test.tsx +35 -0
- package/src/components/Spinner/Spinner.tsx +9 -2
- package/src/components/Steps/Steps.stories.tsx +172 -43
- package/src/components/Tabs/Tabs.stories.tsx +136 -10
- package/src/components/Testimonial/Testimonial.stories.tsx +121 -4
- package/src/components/Todo/Todo.stories.tsx +198 -9
- package/src/components/Toggle/Toggle.stories.tsx +153 -43
- package/src/components/Toggle/Toggle.test.tsx +91 -0
- package/src/components/Toggle/Toggle.tsx +44 -27
- package/src/components/Tooltip/Tooltip.stories.tsx +194 -104
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/Upload/Upload.stories.tsx +113 -24
- package/src/layouts/Grid/Grid.stories.tsx +49 -49
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +2 -2
- package/src/lib/README.md +2 -2
- package/src/lib/__tests__/theme-tools.test.ts +193 -0
- package/src/lib/composables/index.ts +2 -2
- package/src/lib/composables/useAccordion.ts +12 -3
- package/src/lib/composables/useAtomixGlass.ts +28 -56
- package/src/lib/composables/useBreadcrumb.ts +2 -2
- package/src/lib/composables/useCallout.ts +7 -7
- package/src/lib/composables/useChartExport.ts +2 -7
- package/src/lib/composables/useDataTable.ts +46 -29
- package/src/lib/composables/useNavbar.ts +1 -1
- package/src/lib/constants/components.ts +10 -33
- package/src/lib/storybook/InteractiveDemo.tsx +113 -0
- package/src/lib/storybook/PreviewContainer.tsx +36 -0
- package/src/lib/storybook/VariantsGrid.tsx +21 -0
- package/src/lib/storybook/index.ts +3 -0
- package/src/lib/theme/core/createThemeObject.ts +9 -5
- package/src/lib/theme/devtools/CLI.ts +155 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +213 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.tsx +566 -0
- package/src/lib/theme/devtools/LiveEditor.tsx +2 -1
- package/src/lib/theme/devtools/index.ts +3 -0
- package/src/lib/theme/errors/errors.ts +8 -0
- package/src/lib/theme/runtime/ThemeProvider.tsx +117 -57
- package/src/lib/theme/runtime/__tests__/ThemeProvider.integration.test.tsx +305 -0
- package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +588 -0
- package/src/lib/theme/utils/__tests__/themeValidation.test.ts +264 -0
- package/src/lib/theme/utils/index.ts +1 -0
- package/src/lib/theme/utils/themeValidation.ts +501 -0
- package/src/lib/theme-tools.ts +32 -3
- package/src/lib/types/components.ts +82 -27
- package/src/lib/utils/__tests__/csv.test.ts +45 -0
- package/src/lib/utils/csv.ts +17 -0
- package/src/lib/utils/dataTableExport.ts +1 -10
- package/src/lib/utils/themeNaming.ts +1 -1
- package/src/styles/01-settings/_index.scss +2 -1
- package/src/styles/01-settings/_settings.accordion.scss +28 -7
- package/src/styles/01-settings/_settings.colors.scss +11 -11
- package/src/styles/01-settings/_settings.typography.scss +5 -5
- package/src/styles/02-tools/_tools.utility-api.scss +14 -0
- package/src/styles/06-components/_components.accordion.scss +56 -14
- package/src/styles/06-components/_components.callout.scss +29 -33
- package/src/styles/06-components/_components.checkbox.scss +23 -17
- package/src/styles/06-components/_index.scss +1 -1
- package/src/styles/99-utilities/_index.scss +2 -0
- package/src/styles/99-utilities/_utilities.display.scss +14 -3
- package/src/styles/99-utilities/_utilities.flex.scss +10 -10
- package/src/styles/99-utilities/_utilities.scss +3 -1
- package/src/styles/99-utilities/_utilities.text-gradient.scss +45 -0
- package/src/styles/99-utilities/_utilities.text.scss +28 -8
- package/themes/dark-complementary/README.md +98 -0
- package/themes/dark-complementary/index.scss +158 -0
- package/themes/default-light/README.md +81 -0
- package/themes/default-light/index.scss +154 -0
- package/themes/high-contrast/README.md +105 -0
- package/themes/high-contrast/index.scss +172 -0
- package/themes/test-theme/README.md +38 -0
- package/themes/test-theme/index.scss +47 -0
- package/scripts/cli/__tests__/cli-commands.test.js +0 -204
- package/scripts/cli/__tests__/vitest.config.js +0 -26
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +0 -1438
- package/src/lib/composables/useButton.ts +0 -93
- package/src/lib/composables/useCheckbox.ts +0 -70
|
@@ -7,242 +7,29 @@ import { readFile, writeFile, readdir, stat } from 'fs/promises';
|
|
|
7
7
|
import { join, extname, relative } from 'path';
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import ora from 'ora';
|
|
10
|
+
import { validatePath, sanitizeInput, AtomixCLIError } from './utils.js';
|
|
11
|
+
import {
|
|
12
|
+
tailwindToAtomix,
|
|
13
|
+
bootstrapToAtomix,
|
|
14
|
+
scssVariableMigration
|
|
15
|
+
} from './mappings.js';
|
|
10
16
|
|
|
11
|
-
/**
|
|
12
|
-
* Tailwind to Atomix mapping
|
|
13
|
-
*/
|
|
14
|
-
const tailwindToAtomix = {
|
|
15
|
-
// Colors
|
|
16
|
-
'bg-primary': 'c-bg-primary',
|
|
17
|
-
'text-primary': 'c-text-primary',
|
|
18
|
-
'border-primary': 'c-border-primary',
|
|
19
|
-
|
|
20
|
-
// Spacing
|
|
21
|
-
'p-0': 'u-p-0',
|
|
22
|
-
'p-1': 'u-p-1',
|
|
23
|
-
'p-2': 'u-p-2',
|
|
24
|
-
'p-3': 'u-p-3',
|
|
25
|
-
'p-4': 'u-p-4',
|
|
26
|
-
'p-5': 'u-p-5',
|
|
27
|
-
'p-6': 'u-p-6',
|
|
28
|
-
'p-8': 'u-p-8',
|
|
29
|
-
|
|
30
|
-
'm-0': 'u-m-0',
|
|
31
|
-
'm-1': 'u-m-1',
|
|
32
|
-
'm-2': 'u-m-2',
|
|
33
|
-
'm-3': 'u-m-3',
|
|
34
|
-
'm-4': 'u-m-4',
|
|
35
|
-
'm-auto': 'u-m-auto',
|
|
36
|
-
|
|
37
|
-
// Flexbox
|
|
38
|
-
'flex': 'u-flex',
|
|
39
|
-
'flex-row': 'u-flex-row',
|
|
40
|
-
'flex-col': 'u-flex-column',
|
|
41
|
-
'items-center': 'u-items-center',
|
|
42
|
-
'justify-center': 'u-justify-center',
|
|
43
|
-
'justify-between': 'u-justify-between',
|
|
44
|
-
'gap-1': 'u-gap-1',
|
|
45
|
-
'gap-2': 'u-gap-2',
|
|
46
|
-
'gap-4': 'u-gap-4',
|
|
47
|
-
|
|
48
|
-
// Display
|
|
49
|
-
'hidden': 'u-hidden',
|
|
50
|
-
'block': 'u-block',
|
|
51
|
-
'inline-block': 'u-inline-block',
|
|
52
|
-
'inline': 'u-inline',
|
|
53
|
-
'grid': 'u-grid',
|
|
54
|
-
|
|
55
|
-
// Typography
|
|
56
|
-
'text-xs': 'u-text-xs',
|
|
57
|
-
'text-sm': 'u-text-sm',
|
|
58
|
-
'text-base': 'u-text-base',
|
|
59
|
-
'text-lg': 'u-text-lg',
|
|
60
|
-
'text-xl': 'u-text-xl',
|
|
61
|
-
'text-2xl': 'u-text-2xl',
|
|
62
|
-
'font-bold': 'u-font-bold',
|
|
63
|
-
'font-semibold': 'u-font-semibold',
|
|
64
|
-
'font-normal': 'u-font-normal',
|
|
65
|
-
|
|
66
|
-
// Border
|
|
67
|
-
'border': 'u-border',
|
|
68
|
-
'border-2': 'u-border-2',
|
|
69
|
-
'rounded': 'u-rounded',
|
|
70
|
-
'rounded-md': 'u-rounded-md',
|
|
71
|
-
'rounded-lg': 'u-rounded-lg',
|
|
72
|
-
'rounded-full': 'u-rounded-full',
|
|
73
|
-
|
|
74
|
-
// Components
|
|
75
|
-
'btn': 'c-btn',
|
|
76
|
-
'btn-primary': 'c-btn c-btn-primary',
|
|
77
|
-
'btn-secondary': 'c-btn c-btn-secondary',
|
|
78
|
-
'card': 'c-card',
|
|
79
|
-
'badge': 'c-badge',
|
|
80
|
-
'alert': 'c-alert',
|
|
81
|
-
'input': 'c-input',
|
|
82
|
-
'select': 'c-select',
|
|
83
|
-
'checkbox': 'c-checkbox',
|
|
84
|
-
'radio': 'c-radio',
|
|
85
|
-
|
|
86
|
-
// Responsive prefixes
|
|
87
|
-
'sm:': '@sm:',
|
|
88
|
-
'md:': '@md:',
|
|
89
|
-
'lg:': '@lg:',
|
|
90
|
-
'xl:': '@xl:',
|
|
91
|
-
|
|
92
|
-
// States
|
|
93
|
-
'hover:': ':hover ',
|
|
94
|
-
'focus:': ':focus ',
|
|
95
|
-
'active:': ':active ',
|
|
96
|
-
'disabled:': ':disabled '
|
|
97
|
-
};
|
|
98
17
|
|
|
99
|
-
/**
|
|
100
|
-
* Bootstrap to Atomix mapping
|
|
101
|
-
*/
|
|
102
|
-
const bootstrapToAtomix = {
|
|
103
|
-
// Components
|
|
104
|
-
'btn': 'c-btn',
|
|
105
|
-
'btn-primary': 'c-btn c-btn-primary',
|
|
106
|
-
'btn-secondary': 'c-btn c-btn-secondary',
|
|
107
|
-
'btn-success': 'c-btn c-btn-success',
|
|
108
|
-
'btn-danger': 'c-btn c-btn-error',
|
|
109
|
-
'btn-warning': 'c-btn c-btn-warning',
|
|
110
|
-
'btn-info': 'c-btn c-btn-info',
|
|
111
|
-
'btn-lg': 'c-btn c-btn-lg',
|
|
112
|
-
'btn-sm': 'c-btn c-btn-sm',
|
|
113
|
-
|
|
114
|
-
'card': 'c-card',
|
|
115
|
-
'card-header': 'c-card__header',
|
|
116
|
-
'card-body': 'c-card__body',
|
|
117
|
-
'card-footer': 'c-card__footer',
|
|
118
|
-
'card-title': 'c-card__title',
|
|
119
|
-
'card-text': 'c-card__text',
|
|
120
|
-
|
|
121
|
-
'alert': 'c-alert',
|
|
122
|
-
'alert-primary': 'c-alert c-alert-primary',
|
|
123
|
-
'alert-success': 'c-alert c-alert-success',
|
|
124
|
-
'alert-danger': 'c-alert c-alert-error',
|
|
125
|
-
'alert-warning': 'c-alert c-alert-warning',
|
|
126
|
-
|
|
127
|
-
'badge': 'c-badge',
|
|
128
|
-
'badge-primary': 'c-badge c-badge-primary',
|
|
129
|
-
'badge-secondary': 'c-badge c-badge-secondary',
|
|
130
|
-
|
|
131
|
-
'form-control': 'c-input',
|
|
132
|
-
'form-select': 'c-select',
|
|
133
|
-
'form-check': 'c-form-check',
|
|
134
|
-
'form-check-input': 'c-checkbox',
|
|
135
|
-
'form-label': 'c-label',
|
|
136
|
-
|
|
137
|
-
'modal': 'c-modal',
|
|
138
|
-
'modal-dialog': 'c-modal__dialog',
|
|
139
|
-
'modal-content': 'c-modal__content',
|
|
140
|
-
'modal-header': 'c-modal__header',
|
|
141
|
-
'modal-body': 'c-modal__body',
|
|
142
|
-
'modal-footer': 'c-modal__footer',
|
|
143
|
-
|
|
144
|
-
// Grid
|
|
145
|
-
'container': 'o-container',
|
|
146
|
-
'container-fluid': 'o-container-fluid',
|
|
147
|
-
'row': 'o-row',
|
|
148
|
-
'col': 'o-col',
|
|
149
|
-
'col-sm': 'o-col-sm',
|
|
150
|
-
'col-md': 'o-col-md',
|
|
151
|
-
'col-lg': 'o-col-lg',
|
|
152
|
-
'col-xl': 'o-col-xl',
|
|
153
|
-
|
|
154
|
-
// Utilities
|
|
155
|
-
'd-none': 'u-hidden',
|
|
156
|
-
'd-block': 'u-block',
|
|
157
|
-
'd-inline': 'u-inline',
|
|
158
|
-
'd-inline-block': 'u-inline-block',
|
|
159
|
-
'd-flex': 'u-flex',
|
|
160
|
-
'd-grid': 'u-grid',
|
|
161
|
-
|
|
162
|
-
'text-center': 'u-text-center',
|
|
163
|
-
'text-left': 'u-text-left',
|
|
164
|
-
'text-right': 'u-text-right',
|
|
165
|
-
'text-justify': 'u-text-justify',
|
|
166
|
-
|
|
167
|
-
'text-primary': 'u-text-primary',
|
|
168
|
-
'text-success': 'u-text-success',
|
|
169
|
-
'text-danger': 'u-text-error',
|
|
170
|
-
'text-warning': 'u-text-warning',
|
|
171
|
-
'text-muted': 'u-text-muted',
|
|
172
|
-
|
|
173
|
-
'bg-primary': 'u-bg-primary',
|
|
174
|
-
'bg-success': 'u-bg-success',
|
|
175
|
-
'bg-danger': 'u-bg-error',
|
|
176
|
-
'bg-warning': 'u-bg-warning',
|
|
177
|
-
|
|
178
|
-
'p-0': 'u-p-0',
|
|
179
|
-
'p-1': 'u-p-1',
|
|
180
|
-
'p-2': 'u-p-2',
|
|
181
|
-
'p-3': 'u-p-3',
|
|
182
|
-
'p-4': 'u-p-4',
|
|
183
|
-
'p-5': 'u-p-5',
|
|
184
|
-
|
|
185
|
-
'm-0': 'u-m-0',
|
|
186
|
-
'm-1': 'u-m-1',
|
|
187
|
-
'm-2': 'u-m-2',
|
|
188
|
-
'm-3': 'u-m-3',
|
|
189
|
-
'm-4': 'u-m-4',
|
|
190
|
-
'm-5': 'u-m-5',
|
|
191
|
-
'm-auto': 'u-m-auto',
|
|
192
|
-
|
|
193
|
-
'rounded': 'u-rounded',
|
|
194
|
-
'rounded-circle': 'u-rounded-full',
|
|
195
|
-
'border': 'u-border',
|
|
196
|
-
|
|
197
|
-
'w-25': 'u-w-25',
|
|
198
|
-
'w-50': 'u-w-50',
|
|
199
|
-
'w-75': 'u-w-75',
|
|
200
|
-
'w-100': 'u-w-100',
|
|
201
|
-
'h-25': 'u-h-25',
|
|
202
|
-
'h-50': 'u-h-50',
|
|
203
|
-
'h-75': 'u-h-75',
|
|
204
|
-
'h-100': 'u-h-100'
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* SCSS Variable Migration
|
|
209
|
-
*/
|
|
210
|
-
const scssVariableMigration = {
|
|
211
|
-
// Colors
|
|
212
|
-
'$primary': 'var(--atomix-color-primary)',
|
|
213
|
-
'$secondary': 'var(--atomix-color-secondary)',
|
|
214
|
-
'$success': 'var(--atomix-color-success)',
|
|
215
|
-
'$danger': 'var(--atomix-color-error)',
|
|
216
|
-
'$warning': 'var(--atomix-color-warning)',
|
|
217
|
-
'$info': 'var(--atomix-color-info)',
|
|
218
|
-
'$light': 'var(--atomix-color-light)',
|
|
219
|
-
'$dark': 'var(--atomix-color-dark)',
|
|
220
|
-
|
|
221
|
-
// Spacing
|
|
222
|
-
'$spacer': 'var(--atomix-space-4)',
|
|
223
|
-
'$spacing-xs': 'var(--atomix-space-1)',
|
|
224
|
-
'$spacing-sm': 'var(--atomix-space-2)',
|
|
225
|
-
'$spacing-md': 'var(--atomix-space-4)',
|
|
226
|
-
'$spacing-lg': 'var(--atomix-space-6)',
|
|
227
|
-
'$spacing-xl': 'var(--atomix-space-8)',
|
|
228
|
-
|
|
229
|
-
// Typography
|
|
230
|
-
'$font-family-base': 'var(--atomix-font-family-base)',
|
|
231
|
-
'$font-size-base': 'var(--atomix-font-size-base)',
|
|
232
|
-
'$font-weight-normal': 'var(--atomix-font-weight-normal)',
|
|
233
|
-
'$font-weight-bold': 'var(--atomix-font-weight-bold)',
|
|
234
|
-
'$line-height-base': 'var(--atomix-line-height-base)',
|
|
235
|
-
|
|
236
|
-
// Border
|
|
237
|
-
'$border-radius': 'var(--atomix-radius-md)',
|
|
238
|
-
'$border-width': 'var(--atomix-border-width)',
|
|
239
|
-
'$border-color': 'var(--atomix-color-border)'
|
|
240
|
-
};
|
|
241
18
|
|
|
242
19
|
/**
|
|
243
20
|
* Migrate Tailwind classes to Atomix
|
|
244
21
|
*/
|
|
245
22
|
export async function migrateTailwind(sourcePath, options = {}) {
|
|
23
|
+
const sanitizedSource = sanitizeInput(sourcePath);
|
|
24
|
+
const sourceValidation = validatePath(sanitizedSource);
|
|
25
|
+
if (!sourceValidation.isValid) {
|
|
26
|
+
throw new AtomixCLIError(
|
|
27
|
+
sourceValidation.error,
|
|
28
|
+
'INVALID_PATH',
|
|
29
|
+
['Provide a valid path within the project', 'Check for typos']
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const safeSource = sourceValidation.safePath;
|
|
246
33
|
const spinner = ora('Migrating from Tailwind CSS...').start();
|
|
247
34
|
const report = {
|
|
248
35
|
filesProcessed: 0,
|
|
@@ -250,18 +37,18 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
250
37
|
warnings: [],
|
|
251
38
|
errors: []
|
|
252
39
|
};
|
|
253
|
-
|
|
40
|
+
|
|
254
41
|
try {
|
|
255
|
-
const files = await getAllFiles(
|
|
256
|
-
|
|
42
|
+
const files = await getAllFiles(safeSource, ['.jsx', '.tsx', '.js', '.ts', '.html']);
|
|
43
|
+
|
|
257
44
|
for (const file of files) {
|
|
258
45
|
spinner.text = `Processing ${relative(process.cwd(), file)}...`;
|
|
259
|
-
|
|
46
|
+
|
|
260
47
|
try {
|
|
261
48
|
let content = await readFile(file, 'utf8');
|
|
262
49
|
const originalContent = content;
|
|
263
50
|
let replacementCount = 0;
|
|
264
|
-
|
|
51
|
+
|
|
265
52
|
// Replace className attributes
|
|
266
53
|
content = content.replace(/className=["']([^"']+)["']/g, (match, classes) => {
|
|
267
54
|
const classList = classes.split(' ');
|
|
@@ -271,7 +58,7 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
271
58
|
replacementCount++;
|
|
272
59
|
return tailwindToAtomix[trimmed];
|
|
273
60
|
}
|
|
274
|
-
|
|
61
|
+
|
|
275
62
|
// Check for responsive prefixes
|
|
276
63
|
for (const [prefix, replacement] of Object.entries(tailwindToAtomix)) {
|
|
277
64
|
if (trimmed.startsWith(prefix)) {
|
|
@@ -282,7 +69,7 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
282
69
|
}
|
|
283
70
|
}
|
|
284
71
|
}
|
|
285
|
-
|
|
72
|
+
|
|
286
73
|
// If no mapping found, keep original
|
|
287
74
|
if (trimmed && !trimmed.startsWith('c-') && !trimmed.startsWith('u-') && !trimmed.startsWith('o-')) {
|
|
288
75
|
report.warnings.push({
|
|
@@ -291,13 +78,13 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
291
78
|
message: 'No Atomix equivalent found'
|
|
292
79
|
});
|
|
293
80
|
}
|
|
294
|
-
|
|
81
|
+
|
|
295
82
|
return trimmed;
|
|
296
83
|
});
|
|
297
|
-
|
|
84
|
+
|
|
298
85
|
return `className="${newClasses.join(' ')}"`;
|
|
299
86
|
});
|
|
300
|
-
|
|
87
|
+
|
|
301
88
|
// Replace class attributes in HTML
|
|
302
89
|
content = content.replace(/class=["']([^"']+)["']/g, (match, classes) => {
|
|
303
90
|
const classList = classes.split(' ');
|
|
@@ -309,10 +96,10 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
309
96
|
}
|
|
310
97
|
return trimmed;
|
|
311
98
|
});
|
|
312
|
-
|
|
99
|
+
|
|
313
100
|
return `class="${newClasses.join(' ')}"`;
|
|
314
101
|
});
|
|
315
|
-
|
|
102
|
+
|
|
316
103
|
if (content !== originalContent) {
|
|
317
104
|
if (options.dryRun) {
|
|
318
105
|
console.log(chalk.yellow(` Would update: ${file}`));
|
|
@@ -322,7 +109,7 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
322
109
|
report.classesReplaced += replacementCount;
|
|
323
110
|
}
|
|
324
111
|
}
|
|
325
|
-
|
|
112
|
+
|
|
326
113
|
} catch (error) {
|
|
327
114
|
report.errors.push({
|
|
328
115
|
file: relative(process.cwd(), file),
|
|
@@ -330,11 +117,11 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
330
117
|
});
|
|
331
118
|
}
|
|
332
119
|
}
|
|
333
|
-
|
|
120
|
+
|
|
334
121
|
spinner.succeed(chalk.green('Tailwind migration complete!'));
|
|
335
|
-
|
|
122
|
+
|
|
336
123
|
return report;
|
|
337
|
-
|
|
124
|
+
|
|
338
125
|
} catch (error) {
|
|
339
126
|
spinner.fail(chalk.red('Migration failed'));
|
|
340
127
|
throw error;
|
|
@@ -345,6 +132,16 @@ export async function migrateTailwind(sourcePath, options = {}) {
|
|
|
345
132
|
* Migrate Bootstrap classes to Atomix
|
|
346
133
|
*/
|
|
347
134
|
export async function migrateBootstrap(sourcePath, options = {}) {
|
|
135
|
+
const sanitizedSource = sanitizeInput(sourcePath);
|
|
136
|
+
const sourceValidation = validatePath(sanitizedSource);
|
|
137
|
+
if (!sourceValidation.isValid) {
|
|
138
|
+
throw new AtomixCLIError(
|
|
139
|
+
sourceValidation.error,
|
|
140
|
+
'INVALID_PATH',
|
|
141
|
+
['Provide a valid path within the project', 'Check for typos']
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
const safeSource = sourceValidation.safePath;
|
|
348
145
|
const spinner = ora('Migrating from Bootstrap...').start();
|
|
349
146
|
const report = {
|
|
350
147
|
filesProcessed: 0,
|
|
@@ -352,47 +149,47 @@ export async function migrateBootstrap(sourcePath, options = {}) {
|
|
|
352
149
|
warnings: [],
|
|
353
150
|
errors: []
|
|
354
151
|
};
|
|
355
|
-
|
|
152
|
+
|
|
356
153
|
try {
|
|
357
|
-
const files = await getAllFiles(
|
|
358
|
-
|
|
154
|
+
const files = await getAllFiles(safeSource, ['.jsx', '.tsx', '.js', '.ts', '.html']);
|
|
155
|
+
|
|
359
156
|
for (const file of files) {
|
|
360
157
|
spinner.text = `Processing ${relative(process.cwd(), file)}...`;
|
|
361
|
-
|
|
158
|
+
|
|
362
159
|
try {
|
|
363
160
|
let content = await readFile(file, 'utf8');
|
|
364
161
|
const originalContent = content;
|
|
365
162
|
let replacementCount = 0;
|
|
366
|
-
|
|
163
|
+
|
|
367
164
|
// Replace className/class attributes
|
|
368
165
|
const classPattern = /(className|class)=["']([^"']+)["']/g;
|
|
369
166
|
content = content.replace(classPattern, (match, attr, classes) => {
|
|
370
167
|
const classList = classes.split(' ');
|
|
371
168
|
const newClasses = classList.map(cls => {
|
|
372
169
|
const trimmed = cls.trim();
|
|
373
|
-
|
|
170
|
+
|
|
374
171
|
// Check direct mapping
|
|
375
172
|
if (bootstrapToAtomix[trimmed]) {
|
|
376
173
|
replacementCount++;
|
|
377
174
|
return bootstrapToAtomix[trimmed];
|
|
378
175
|
}
|
|
379
|
-
|
|
176
|
+
|
|
380
177
|
// Check for col-{breakpoint}-{size} pattern
|
|
381
178
|
const colPattern = /^col-(sm|md|lg|xl)-(\d+)$/;
|
|
382
179
|
const colMatch = trimmed.match(colPattern);
|
|
383
180
|
if (colMatch) {
|
|
384
181
|
replacementCount++;
|
|
385
|
-
return `
|
|
182
|
+
return `c-grid__item c-grid__item--${colMatch[2]}`;
|
|
386
183
|
}
|
|
387
|
-
|
|
184
|
+
|
|
388
185
|
// Check for offset pattern
|
|
389
186
|
const offsetPattern = /^offset-(sm|md|lg|xl)-(\d+)$/;
|
|
390
187
|
const offsetMatch = trimmed.match(offsetPattern);
|
|
391
188
|
if (offsetMatch) {
|
|
392
189
|
replacementCount++;
|
|
393
|
-
return `
|
|
190
|
+
return `c-grid__item c-grid__item--offset-${offsetMatch[2]}`;
|
|
394
191
|
}
|
|
395
|
-
|
|
192
|
+
|
|
396
193
|
// If no mapping found, keep original
|
|
397
194
|
if (trimmed && !trimmed.startsWith('c-') && !trimmed.startsWith('u-') && !trimmed.startsWith('o-')) {
|
|
398
195
|
report.warnings.push({
|
|
@@ -401,13 +198,13 @@ export async function migrateBootstrap(sourcePath, options = {}) {
|
|
|
401
198
|
message: 'No Atomix equivalent found'
|
|
402
199
|
});
|
|
403
200
|
}
|
|
404
|
-
|
|
201
|
+
|
|
405
202
|
return trimmed;
|
|
406
203
|
});
|
|
407
|
-
|
|
204
|
+
|
|
408
205
|
return `${attr}="${newClasses.join(' ')}"`;
|
|
409
206
|
});
|
|
410
|
-
|
|
207
|
+
|
|
411
208
|
if (content !== originalContent) {
|
|
412
209
|
if (options.dryRun) {
|
|
413
210
|
console.log(chalk.yellow(` Would update: ${file}`));
|
|
@@ -417,7 +214,7 @@ export async function migrateBootstrap(sourcePath, options = {}) {
|
|
|
417
214
|
report.classesReplaced += replacementCount;
|
|
418
215
|
}
|
|
419
216
|
}
|
|
420
|
-
|
|
217
|
+
|
|
421
218
|
} catch (error) {
|
|
422
219
|
report.errors.push({
|
|
423
220
|
file: relative(process.cwd(), file),
|
|
@@ -425,11 +222,11 @@ export async function migrateBootstrap(sourcePath, options = {}) {
|
|
|
425
222
|
});
|
|
426
223
|
}
|
|
427
224
|
}
|
|
428
|
-
|
|
225
|
+
|
|
429
226
|
spinner.succeed(chalk.green('Bootstrap migration complete!'));
|
|
430
|
-
|
|
227
|
+
|
|
431
228
|
return report;
|
|
432
|
-
|
|
229
|
+
|
|
433
230
|
} catch (error) {
|
|
434
231
|
spinner.fail(chalk.red('Migration failed'));
|
|
435
232
|
throw error;
|
|
@@ -440,6 +237,16 @@ export async function migrateBootstrap(sourcePath, options = {}) {
|
|
|
440
237
|
* Migrate SCSS variables to CSS custom properties
|
|
441
238
|
*/
|
|
442
239
|
export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
240
|
+
const sanitizedSource = sanitizeInput(sourcePath);
|
|
241
|
+
const sourceValidation = validatePath(sanitizedSource);
|
|
242
|
+
if (!sourceValidation.isValid) {
|
|
243
|
+
throw new AtomixCLIError(
|
|
244
|
+
sourceValidation.error,
|
|
245
|
+
'INVALID_PATH',
|
|
246
|
+
['Provide a valid path within the project', 'Check for typos']
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
const safeSource = sourceValidation.safePath;
|
|
443
250
|
const spinner = ora('Migrating SCSS variables to design tokens...').start();
|
|
444
251
|
const report = {
|
|
445
252
|
filesProcessed: 0,
|
|
@@ -447,18 +254,18 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
447
254
|
warnings: [],
|
|
448
255
|
errors: []
|
|
449
256
|
};
|
|
450
|
-
|
|
257
|
+
|
|
451
258
|
try {
|
|
452
|
-
const files = await getAllFiles(
|
|
453
|
-
|
|
259
|
+
const files = await getAllFiles(safeSource, ['.scss', '.sass', '.css']);
|
|
260
|
+
|
|
454
261
|
for (const file of files) {
|
|
455
262
|
spinner.text = `Processing ${relative(process.cwd(), file)}...`;
|
|
456
|
-
|
|
263
|
+
|
|
457
264
|
try {
|
|
458
265
|
let content = await readFile(file, 'utf8');
|
|
459
266
|
const originalContent = content;
|
|
460
267
|
let replacementCount = 0;
|
|
461
|
-
|
|
268
|
+
|
|
462
269
|
// Replace SCSS variables with CSS custom properties
|
|
463
270
|
for (const [scssVar, cssVar] of Object.entries(scssVariableMigration)) {
|
|
464
271
|
const regex = new RegExp(`\\${scssVar}(?![a-z-])`, 'g');
|
|
@@ -468,7 +275,7 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
468
275
|
content = content.replace(regex, cssVar);
|
|
469
276
|
}
|
|
470
277
|
}
|
|
471
|
-
|
|
278
|
+
|
|
472
279
|
// Find remaining SCSS variables that weren't migrated
|
|
473
280
|
const remainingVars = content.match(/\$[a-z-]+/gi);
|
|
474
281
|
if (remainingVars) {
|
|
@@ -482,7 +289,7 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
482
289
|
}
|
|
483
290
|
});
|
|
484
291
|
}
|
|
485
|
-
|
|
292
|
+
|
|
486
293
|
if (content !== originalContent) {
|
|
487
294
|
if (options.dryRun) {
|
|
488
295
|
console.log(chalk.yellow(` Would update: ${file}`));
|
|
@@ -492,7 +299,7 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
492
299
|
report.variablesReplaced += replacementCount;
|
|
493
300
|
}
|
|
494
301
|
}
|
|
495
|
-
|
|
302
|
+
|
|
496
303
|
} catch (error) {
|
|
497
304
|
report.errors.push({
|
|
498
305
|
file: relative(process.cwd(), file),
|
|
@@ -500,11 +307,11 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
500
307
|
});
|
|
501
308
|
}
|
|
502
309
|
}
|
|
503
|
-
|
|
310
|
+
|
|
504
311
|
spinner.succeed(chalk.green('SCSS variable migration complete!'));
|
|
505
|
-
|
|
312
|
+
|
|
506
313
|
return report;
|
|
507
|
-
|
|
314
|
+
|
|
508
315
|
} catch (error) {
|
|
509
316
|
spinner.fail(chalk.red('Migration failed'));
|
|
510
317
|
throw error;
|
|
@@ -516,14 +323,14 @@ export async function migrateSCSSVariables(sourcePath, options = {}) {
|
|
|
516
323
|
*/
|
|
517
324
|
async function getAllFiles(dir, extensions = []) {
|
|
518
325
|
const files = [];
|
|
519
|
-
|
|
326
|
+
|
|
520
327
|
async function walk(currentPath) {
|
|
521
328
|
const entries = await readdir(currentPath);
|
|
522
|
-
|
|
329
|
+
|
|
523
330
|
for (const entry of entries) {
|
|
524
331
|
const fullPath = join(currentPath, entry);
|
|
525
332
|
const stats = await stat(fullPath);
|
|
526
|
-
|
|
333
|
+
|
|
527
334
|
if (stats.isDirectory()) {
|
|
528
335
|
// Skip node_modules and hidden directories
|
|
529
336
|
if (!entry.startsWith('.') && entry !== 'node_modules') {
|
|
@@ -537,7 +344,7 @@ async function getAllFiles(dir, extensions = []) {
|
|
|
537
344
|
}
|
|
538
345
|
}
|
|
539
346
|
}
|
|
540
|
-
|
|
347
|
+
|
|
541
348
|
await walk(dir);
|
|
542
349
|
return files;
|
|
543
350
|
}
|
|
@@ -547,14 +354,14 @@ async function getAllFiles(dir, extensions = []) {
|
|
|
547
354
|
*/
|
|
548
355
|
export function displayMigrationReport(report) {
|
|
549
356
|
console.log(chalk.bold('\nš Migration Report\n'));
|
|
550
|
-
console.log(chalk.gray('='
|
|
551
|
-
|
|
357
|
+
console.log(chalk.gray('='.repeat(50)));
|
|
358
|
+
|
|
552
359
|
console.log(chalk.cyan(`Files processed: ${report.filesProcessed}`));
|
|
553
360
|
console.log(chalk.cyan(`Classes/Variables replaced: ${report.classesReplaced || report.variablesReplaced}`));
|
|
554
|
-
|
|
361
|
+
|
|
555
362
|
if (report.warnings.length > 0) {
|
|
556
363
|
console.log(chalk.yellow(`\nā ļø Warnings (${report.warnings.length}):\n`));
|
|
557
|
-
|
|
364
|
+
|
|
558
365
|
// Group warnings by type
|
|
559
366
|
const groupedWarnings = {};
|
|
560
367
|
report.warnings.forEach(warning => {
|
|
@@ -564,7 +371,7 @@ export function displayMigrationReport(report) {
|
|
|
564
371
|
}
|
|
565
372
|
groupedWarnings[key].push(warning.file);
|
|
566
373
|
});
|
|
567
|
-
|
|
374
|
+
|
|
568
375
|
Object.entries(groupedWarnings).forEach(([key, files]) => {
|
|
569
376
|
console.log(chalk.yellow(` ⢠${key}`));
|
|
570
377
|
console.log(chalk.gray(` Found in ${files.length} file(s)`));
|
|
@@ -573,7 +380,7 @@ export function displayMigrationReport(report) {
|
|
|
573
380
|
}
|
|
574
381
|
});
|
|
575
382
|
}
|
|
576
|
-
|
|
383
|
+
|
|
577
384
|
if (report.errors.length > 0) {
|
|
578
385
|
console.log(chalk.red(`\nā Errors (${report.errors.length}):\n`));
|
|
579
386
|
report.errors.forEach(error => {
|
|
@@ -581,16 +388,16 @@ export function displayMigrationReport(report) {
|
|
|
581
388
|
console.log(chalk.gray(` ${error.error}`));
|
|
582
389
|
});
|
|
583
390
|
}
|
|
584
|
-
|
|
585
|
-
console.log(chalk.gray('\n' + '='
|
|
586
|
-
|
|
391
|
+
|
|
392
|
+
console.log(chalk.gray('\n' + '='.repeat(50)));
|
|
393
|
+
|
|
587
394
|
if (report.warnings.length > 0) {
|
|
588
395
|
console.log(chalk.yellow('\nš” Suggestions:'));
|
|
589
396
|
console.log(chalk.gray(' 1. Review unmapped classes/variables'));
|
|
590
397
|
console.log(chalk.gray(' 2. Create custom mappings for your specific needs'));
|
|
591
398
|
console.log(chalk.gray(' 3. Consider using Atomix utilities for better compatibility'));
|
|
592
399
|
}
|
|
593
|
-
|
|
400
|
+
|
|
594
401
|
console.log(chalk.green('\nā
Migration complete!'));
|
|
595
402
|
console.log(chalk.gray('Please review the changes and test your application.\n'));
|
|
596
403
|
}
|