xertica-ui 2.2.1 → 2.4.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.
- package/CHANGELOG.md +564 -525
- package/README.md +417 -382
- package/bin/cli.ts +1244 -748
- package/bin/generate-tokens.ts +262 -262
- package/bin/language-config.ts +5 -8
- package/components/assets/xertica-orbe-animation.ts +1162 -1162
- package/components/assistant/code-block/CodeBlock.tsx +268 -268
- package/components/assistant/code-block/code-block.stories.tsx +57 -57
- package/components/assistant/code-block/code-block.test.tsx +44 -44
- package/components/assistant/code-block/index.ts +1 -1
- package/components/assistant/formatted-document/FormattedDocument.tsx +147 -147
- package/components/assistant/formatted-document/formatted-document.stories.tsx +51 -51
- package/components/assistant/formatted-document/formatted-document.test.tsx +42 -42
- package/components/assistant/formatted-document/index.ts +1 -1
- package/components/assistant/index.ts +6 -6
- package/components/assistant/markdown-message/MarkdownMessage.tsx +152 -152
- package/components/assistant/markdown-message/index.ts +1 -1
- package/components/assistant/markdown-message/markdown-message.stories.tsx +50 -50
- package/components/assistant/markdown-message/markdown-message.test.tsx +33 -33
- package/components/assistant/modern-chat-input/ModernChatInput.tsx +17 -7
- package/components/assistant/modern-chat-input/index.ts +1 -1
- package/components/assistant/modern-chat-input/modern-chat-input.stories.tsx +131 -131
- package/components/assistant/modern-chat-input/modern-chat-input.test.tsx +79 -79
- package/components/assistant/xertica-assistant/index.ts +3 -3
- package/components/assistant/xertica-assistant/parts/AssistantCollapsedView.tsx +99 -99
- package/components/assistant/xertica-assistant/parts/AssistantConversationList.tsx +104 -106
- package/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.tsx +81 -81
- package/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.tsx +88 -78
- package/components/assistant/xertica-assistant/parts/AssistantHeader.tsx +75 -75
- package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +564 -560
- package/components/assistant/xertica-assistant/parts/AssistantTabBar.tsx +67 -67
- package/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.tsx +41 -41
- package/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.tsx +103 -103
- package/components/assistant/xertica-assistant/parts/index.ts +16 -16
- package/components/assistant/xertica-assistant/types.ts +134 -134
- package/components/assistant/xertica-assistant/use-assistant.ts +615 -615
- package/components/assistant/xertica-assistant/xertica-assistant.stories.tsx +407 -407
- package/components/assistant/xertica-assistant/xertica-assistant.test.tsx +65 -65
- package/components/assistant/xertica-assistant/xertica-assistant.tsx +611 -613
- package/components/blocks/card-patterns/ActivityCard.tsx +100 -100
- package/components/blocks/card-patterns/FeatureCard.tsx +109 -109
- package/components/blocks/card-patterns/FeatureCardSkeleton.tsx +1 -6
- package/components/blocks/card-patterns/NotificationCard.tsx +140 -140
- package/components/blocks/card-patterns/ProfileCard.tsx +112 -114
- package/components/blocks/card-patterns/ProjectCard.tsx +123 -123
- package/components/blocks/card-patterns/ProjectCardSkeleton.tsx +1 -6
- package/components/blocks/card-patterns/QuickActionCard.tsx +68 -68
- package/components/blocks/card-patterns/card-patterns.mdx +123 -123
- package/components/blocks/card-patterns/card-patterns.stories.tsx +594 -594
- package/components/blocks/card-patterns/index.ts +29 -29
- package/components/blocks/index.ts +1 -1
- package/components/brand/branding/branding.stories.tsx +57 -57
- package/components/brand/index.ts +6 -6
- package/components/brand/language-selector/index.ts +1 -1
- package/components/brand/language-selector/language-selector.mdx +126 -126
- package/components/brand/language-selector/language-selector.stories.tsx +1 -4
- package/components/brand/theme-toggle/ThemeToggle.tsx +74 -70
- package/components/brand/theme-toggle/index.ts +1 -1
- package/components/brand/theme-toggle/theme-toggle.stories.tsx +34 -34
- package/components/brand/theme-toggle/theme-toggle.test.tsx +34 -34
- package/components/brand/xertica-logo/XerticaLogo.stories.tsx +82 -82
- package/components/brand/xertica-logo/XerticaLogo.tsx +104 -104
- package/components/brand/xertica-logo/index.ts +1 -1
- package/components/brand/xertica-logo/xertica-logo.test.tsx +26 -26
- package/components/brand/xertica-orbe/XerticaOrbe.tsx +1927 -1927
- package/components/brand/xertica-orbe/index.ts +1 -1
- package/components/brand/xertica-orbe/xertica-orbe.stories.tsx +40 -40
- package/components/brand/xertica-orbe/xertica-orbe.test.tsx +19 -19
- package/components/brand/xertica-provider/XerticaProvider.tsx +1 -4
- package/components/brand/xertica-provider/index.ts +1 -1
- package/components/brand/xertica-provider/xertica-provider.test.tsx +74 -74
- package/components/brand/xertica-xlogo/XerticaXLogo.stories.tsx +79 -79
- package/components/brand/xertica-xlogo/XerticaXLogo.tsx +65 -65
- package/components/brand/xertica-xlogo/index.ts +1 -1
- package/components/brand/xertica-xlogo/xertica-xlogo.test.tsx +16 -16
- package/components/examples/ApiKeyMapExample.tsx +71 -71
- package/components/examples/DrawingMapExample.tsx +565 -565
- package/components/examples/FilterableMapExample.tsx +393 -393
- package/components/examples/LocationPickerExample.tsx +348 -348
- package/components/examples/MapExamples.tsx +268 -268
- package/components/examples/MapGmpExample.tsx +169 -169
- package/components/examples/MapShowcase.tsx +471 -471
- package/components/examples/RouteMapExamples.tsx +329 -329
- package/components/examples/SidebarLogoExample.tsx +65 -65
- package/components/examples/SimpleFilterableMap.tsx +219 -219
- package/components/examples/index.ts +45 -45
- package/components/figma/ImageWithFallback.tsx +27 -27
- package/components/hooks/index.ts +13 -13
- package/components/hooks/use-layout-shortcuts.ts +43 -43
- package/components/index.ts +86 -90
- package/components/layout/header/header.stories.tsx +204 -204
- package/components/layout/header/header.test.tsx +75 -75
- package/components/layout/header/header.tsx +349 -349
- package/components/layout/header/index.ts +1 -1
- package/components/layout/index.ts +2 -2
- package/components/layout/sidebar/index.ts +3 -3
- package/components/layout/sidebar/sidebar.stories.tsx +586 -586
- package/components/layout/sidebar/sidebar.test.tsx +76 -76
- package/components/layout/sidebar/sidebar.tsx +1079 -1073
- package/components/layout/sidebar/use-sidebar.ts +104 -104
- package/components/media/FloatingMediaWrapper.tsx +371 -371
- package/components/media/audio-player/AudioPlayer.stories.tsx +124 -124
- package/components/media/audio-player/AudioPlayer.test.tsx +106 -106
- package/components/media/audio-player/AudioPlayer.tsx +767 -765
- package/components/media/audio-player/index.ts +1 -1
- package/components/media/audio-player/use-audio-player.ts +312 -312
- package/components/media/index.ts +3 -3
- package/components/media/video-player/VideoPlayer.stories.tsx +98 -98
- package/components/media/video-player/VideoPlayer.test.tsx +73 -73
- package/components/media/video-player/VideoPlayer.tsx +310 -310
- package/components/media/video-player/index.ts +1 -1
- package/components/pages/forgot-password-page/ForgotPasswordPage.stories.tsx +24 -24
- package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +188 -188
- package/components/pages/forgot-password-page/forgot-password-page.test.tsx +45 -45
- package/components/pages/forgot-password-page/index.ts +1 -1
- package/components/pages/home-content/HomeContent.stories.tsx +43 -43
- package/components/pages/home-content/HomeContent.tsx +120 -120
- package/components/pages/home-content/index.ts +1 -1
- package/components/pages/home-page/HomePage.stories.tsx +39 -39
- package/components/pages/home-page/HomePage.tsx +78 -74
- package/components/pages/home-page/home-page.test.tsx +53 -53
- package/components/pages/home-page/index.ts +1 -1
- package/components/pages/index.ts +8 -8
- package/components/pages/login-page/LoginPage.stories.tsx +39 -39
- package/components/pages/login-page/LoginPage.tsx +218 -216
- package/components/pages/login-page/index.ts +1 -1
- package/components/pages/login-page/login-page.test.tsx +63 -63
- package/components/pages/reset-password-page/ResetPasswordPage.stories.tsx +24 -24
- package/components/pages/reset-password-page/ResetPasswordPage.tsx +243 -239
- package/components/pages/reset-password-page/index.ts +1 -1
- package/components/pages/template-content/TemplateContent.stories.tsx +43 -43
- package/components/pages/template-content/TemplateContent.tsx +1354 -1235
- package/components/pages/template-content/index.ts +1 -1
- package/components/pages/template-page/TemplatePage.stories.tsx +39 -39
- package/components/pages/template-page/TemplatePage.tsx +62 -62
- package/components/pages/template-page/index.ts +1 -1
- package/components/pages/template-page/template-page.test.tsx +52 -52
- package/components/pages/verify-email-page/VerifyEmailPage.stories.tsx +41 -41
- package/components/pages/verify-email-page/VerifyEmailPage.tsx +206 -206
- package/components/pages/verify-email-page/index.ts +1 -1
- package/components/public-api-smoke.test.tsx +52 -52
- package/components/shared/CustomTooltipContent.tsx +48 -48
- package/components/shared/assistant-utils.test.ts +16 -16
- package/components/shared/assistant-utils.ts +225 -225
- package/components/shared/error-boundary.stories.tsx +114 -132
- package/components/shared/error-boundary.tsx +150 -154
- package/components/shared/error-fallbacks.tsx +222 -226
- package/components/shared/layout-constants.ts +8 -8
- package/components/shared/navigation.ts +35 -35
- package/components/shared/use-mobile.test.ts +16 -16
- package/components/shared/use-mobile.ts +36 -36
- package/components/shared/utils.test.ts +14 -14
- package/components/shared/utils.ts +6 -6
- package/components/ui/accordion/accordion.stories.tsx +105 -105
- package/components/ui/accordion/accordion.test.tsx +59 -59
- package/components/ui/accordion/accordion.tsx +77 -77
- package/components/ui/accordion/index.ts +1 -1
- package/components/ui/alert/alert.stories.tsx +86 -86
- package/components/ui/alert/alert.test.tsx +53 -53
- package/components/ui/alert/alert.tsx +93 -93
- package/components/ui/alert/index.ts +1 -1
- package/components/ui/alert-dialog/alert-dialog.stories.tsx +84 -84
- package/components/ui/alert-dialog/alert-dialog.test.tsx +70 -70
- package/components/ui/alert-dialog/alert-dialog.tsx +149 -149
- package/components/ui/alert-dialog/index.ts +1 -1
- package/components/ui/aspect-ratio/aspect-ratio.stories.tsx +46 -46
- package/components/ui/aspect-ratio/aspect-ratio.test.tsx +28 -28
- package/components/ui/aspect-ratio/aspect-ratio.tsx +20 -20
- package/components/ui/aspect-ratio/index.ts +1 -1
- package/components/ui/assistant-chart/AssistantChart.tsx +64 -64
- package/components/ui/assistant-chart/assistant-chart.stories.tsx +44 -44
- package/components/ui/assistant-chart/assistant-chart.test.tsx +46 -46
- package/components/ui/assistant-chart/index.ts +1 -1
- package/components/ui/avatar/avatar.stories.tsx +86 -86
- package/components/ui/avatar/avatar.test.tsx +55 -55
- package/components/ui/avatar/avatar.tsx +71 -71
- package/components/ui/avatar/index.ts +1 -1
- package/components/ui/badge/badge.stories.tsx +72 -72
- package/components/ui/badge/badge.test.tsx +40 -40
- package/components/ui/badge/badge.tsx +58 -58
- package/components/ui/badge/index.ts +1 -1
- package/components/ui/breadcrumb/breadcrumb.stories.tsx +123 -123
- package/components/ui/breadcrumb/breadcrumb.test.tsx +70 -70
- package/components/ui/breadcrumb/breadcrumb.tsx +114 -114
- package/components/ui/breadcrumb/index.ts +1 -1
- package/components/ui/button/button.stories.tsx +183 -183
- package/components/ui/button/button.test.tsx +64 -64
- package/components/ui/button/button.tsx +98 -98
- package/components/ui/button/index.ts +1 -1
- package/components/ui/calendar/calendar.stories.tsx +108 -108
- package/components/ui/calendar/calendar.test.tsx +53 -53
- package/components/ui/calendar/calendar.tsx +230 -230
- package/components/ui/calendar/index.ts +1 -1
- package/components/ui/card/card.stories.tsx +301 -301
- package/components/ui/card/card.test.tsx +55 -55
- package/components/ui/card/card.tsx +83 -83
- package/components/ui/card/index.ts +1 -1
- package/components/ui/carousel/carousel.stories.tsx +80 -80
- package/components/ui/carousel/carousel.test.tsx +75 -75
- package/components/ui/carousel/carousel.tsx +242 -242
- package/components/ui/carousel/index.ts +1 -1
- package/components/ui/chart/chart.stories.tsx +1328 -1328
- package/components/ui/chart/chart.test.tsx +178 -178
- package/components/ui/chart/chart.tsx +2232 -2232
- package/components/ui/chart/index.ts +1 -1
- package/components/ui/checkbox/checkbox.stories.tsx +109 -109
- package/components/ui/checkbox/checkbox.test.tsx +49 -49
- package/components/ui/checkbox/checkbox.tsx +68 -68
- package/components/ui/checkbox/index.ts +1 -1
- package/components/ui/collapsible/collapsible.stories.tsx +45 -45
- package/components/ui/collapsible/collapsible.test.tsx +51 -51
- package/components/ui/collapsible/collapsible.tsx +32 -32
- package/components/ui/collapsible/index.ts +1 -1
- package/components/ui/command/command.stories.tsx +134 -134
- package/components/ui/command/command.test.tsx +48 -48
- package/components/ui/command/command.tsx +163 -163
- package/components/ui/command/index.ts +1 -1
- package/components/ui/context-menu/context-menu.stories.tsx +76 -76
- package/components/ui/context-menu/context-menu.test.tsx +61 -61
- package/components/ui/context-menu/context-menu.tsx +236 -236
- package/components/ui/context-menu/index.ts +1 -1
- package/components/ui/dialog/dialog.stories.tsx +174 -174
- package/components/ui/dialog/dialog.test.tsx +78 -78
- package/components/ui/dialog/dialog.tsx +189 -189
- package/components/ui/dialog/index.ts +1 -1
- package/components/ui/drawer/drawer.stories.tsx +71 -71
- package/components/ui/drawer/drawer.test.tsx +67 -67
- package/components/ui/drawer/drawer.tsx +146 -146
- package/components/ui/drawer/index.ts +1 -1
- package/components/ui/dropdown-menu/dropdown-menu.stories.tsx +156 -156
- package/components/ui/dropdown-menu/dropdown-menu.test.tsx +62 -62
- package/components/ui/dropdown-menu/dropdown-menu.tsx +240 -240
- package/components/ui/dropdown-menu/index.ts +1 -1
- package/components/ui/empty/empty.stories.tsx +85 -85
- package/components/ui/empty/empty.test.tsx +31 -31
- package/components/ui/empty/empty.tsx +88 -88
- package/components/ui/empty/index.ts +1 -1
- package/components/ui/file-upload/file-upload.stories.tsx +144 -144
- package/components/ui/file-upload/file-upload.test.tsx +65 -65
- package/components/ui/file-upload/file-upload.tsx +142 -142
- package/components/ui/file-upload/index.ts +2 -2
- package/components/ui/file-upload/use-file-upload.ts +177 -177
- package/components/ui/form/form.stories.tsx +85 -85
- package/components/ui/form/form.test.tsx +75 -75
- package/components/ui/form/form.tsx +163 -163
- package/components/ui/form/index.ts +1 -1
- package/components/ui/google-maps-loader/google-maps-loader.test.tsx +35 -35
- package/components/ui/google-maps-loader/google-maps-loader.tsx +465 -465
- package/components/ui/google-maps-loader/index.ts +1 -1
- package/components/ui/hover-card/hover-card.stories.tsx +61 -61
- package/components/ui/hover-card/hover-card.test.tsx +48 -48
- package/components/ui/hover-card/hover-card.tsx +50 -50
- package/components/ui/hover-card/index.ts +1 -1
- package/components/ui/index.ts +400 -400
- package/components/ui/input/index.ts +1 -1
- package/components/ui/input/input.stories.tsx +153 -153
- package/components/ui/input/input.test.tsx +47 -47
- package/components/ui/input/input.tsx +57 -57
- package/components/ui/input-otp/index.ts +1 -1
- package/components/ui/input-otp/input-otp.stories.tsx +120 -120
- package/components/ui/input-otp/input-otp.test.tsx +74 -74
- package/components/ui/input-otp/input-otp.tsx +101 -101
- package/components/ui/label/index.ts +1 -1
- package/components/ui/label/label.stories.tsx +74 -74
- package/components/ui/label/label.test.tsx +45 -45
- package/components/ui/label/label.tsx +53 -53
- package/components/ui/map/index.ts +1 -1
- package/components/ui/map/map.stories.tsx +86 -86
- package/components/ui/map/map.test.tsx +82 -82
- package/components/ui/map/map.tsx +506 -506
- package/components/ui/map/mock.test.tsx +13 -13
- package/components/ui/map-config/index.ts +1 -1
- package/components/ui/map-config/map-config.ts +18 -18
- package/components/ui/map-layers/index.ts +1 -1
- package/components/ui/map-layers/map-layers.test.tsx +48 -48
- package/components/ui/map-layers/map-layers.tsx +126 -126
- package/components/ui/map.exports/index.ts +1 -1
- package/components/ui/map.exports/map.exports.ts +31 -31
- package/components/ui/menubar/index.ts +1 -1
- package/components/ui/menubar/menubar.stories.tsx +130 -130
- package/components/ui/menubar/menubar.test.tsx +53 -53
- package/components/ui/menubar/menubar.tsx +265 -265
- package/components/ui/navigation-menu/index.ts +1 -1
- package/components/ui/navigation-menu/navigation-menu.stories.tsx +126 -126
- package/components/ui/navigation-menu/navigation-menu.test.tsx +47 -47
- package/components/ui/navigation-menu/navigation-menu.tsx +165 -165
- package/components/ui/notification-badge/index.ts +1 -1
- package/components/ui/notification-badge/notification-badge.stories.tsx +66 -66
- package/components/ui/notification-badge/notification-badge.test.tsx +61 -61
- package/components/ui/notification-badge/notification-badge.tsx +91 -91
- package/components/ui/page-header/index.ts +1 -1
- package/components/ui/page-header/page-header.stories.tsx +69 -69
- package/components/ui/page-header/page-header.test.tsx +37 -37
- package/components/ui/page-header/page-header.tsx +124 -124
- package/components/ui/pagination/index.ts +3 -3
- package/components/ui/pagination/pagination.stories.tsx +210 -210
- package/components/ui/pagination/pagination.test.tsx +63 -63
- package/components/ui/pagination/pagination.tsx +140 -140
- package/components/ui/pagination/use-pagination.ts +173 -173
- package/components/ui/popover/index.ts +1 -1
- package/components/ui/popover/popover.stories.tsx +73 -73
- package/components/ui/popover/popover.test.tsx +48 -48
- package/components/ui/popover/popover.tsx +54 -54
- package/components/ui/progress/index.ts +1 -1
- package/components/ui/progress/progress.stories.tsx +55 -55
- package/components/ui/progress/progress.test.tsx +23 -23
- package/components/ui/progress/progress.tsx +68 -68
- package/components/ui/radio-group/index.ts +1 -1
- package/components/ui/radio-group/radio-group.stories.tsx +114 -114
- package/components/ui/radio-group/radio-group.test.tsx +78 -78
- package/components/ui/radio-group/radio-group.tsx +93 -93
- package/components/ui/rating/index.ts +1 -1
- package/components/ui/rating/rating.stories.tsx +50 -50
- package/components/ui/rating/rating.test.tsx +48 -48
- package/components/ui/rating/rating.tsx +145 -145
- package/components/ui/resizable/index.ts +1 -1
- package/components/ui/resizable/resizable.stories.tsx +88 -88
- package/components/ui/resizable/resizable.test.tsx +61 -61
- package/components/ui/resizable/resizable.tsx +452 -452
- package/components/ui/rich-text-editor/index.ts +7 -7
- package/components/ui/rich-text-editor/rich-text-editor.stories.tsx +290 -290
- package/components/ui/rich-text-editor/rich-text-editor.test.tsx +86 -86
- package/components/ui/rich-text-editor/rich-text-editor.tsx +634 -634
- package/components/ui/rich-text-editor/use-rich-text-editor.ts +453 -453
- package/components/ui/route-map/index.ts +1 -1
- package/components/ui/route-map/route-map.stories.tsx +48 -48
- package/components/ui/route-map/route-map.test.tsx +108 -108
- package/components/ui/route-map/route-map.tsx +349 -349
- package/components/ui/scroll-area/index.ts +1 -1
- package/components/ui/scroll-area/scroll-area.stories.tsx +31 -31
- package/components/ui/scroll-area/scroll-area.test.tsx +27 -27
- package/components/ui/scroll-area/scroll-area.tsx +70 -70
- package/components/ui/search/index.ts +1 -1
- package/components/ui/search/search.stories.tsx +107 -107
- package/components/ui/search/search.test.tsx +67 -67
- package/components/ui/search/search.tsx +141 -141
- package/components/ui/select/index.ts +1 -1
- package/components/ui/select/select.stories.tsx +163 -163
- package/components/ui/select/select.test.tsx +99 -99
- package/components/ui/select/select.tsx +195 -195
- package/components/ui/separator/index.ts +1 -1
- package/components/ui/separator/separator.stories.tsx +55 -55
- package/components/ui/separator/separator.test.tsx +23 -23
- package/components/ui/separator/separator.tsx +39 -39
- package/components/ui/sheet/index.ts +1 -1
- package/components/ui/sheet/sheet.stories.tsx +93 -93
- package/components/ui/sheet/sheet.test.tsx +62 -62
- package/components/ui/sheet/sheet.tsx +149 -149
- package/components/ui/simple-map/index.ts +1 -1
- package/components/ui/simple-map/simple-map.stories.tsx +44 -44
- package/components/ui/simple-map/simple-map.test.tsx +36 -36
- package/components/ui/simple-map/simple-map.tsx +92 -92
- package/components/ui/skeleton/index.ts +1 -1
- package/components/ui/skeleton/skeleton.stories.tsx +36 -36
- package/components/ui/skeleton/skeleton.test.tsx +19 -19
- package/components/ui/skeleton/skeleton.tsx +25 -25
- package/components/ui/slider/index.ts +1 -1
- package/components/ui/slider/slider.stories.tsx +44 -44
- package/components/ui/slider/slider.test.tsx +25 -25
- package/components/ui/slider/slider.tsx +66 -66
- package/components/ui/sonner/index.ts +1 -1
- package/components/ui/sonner/sonner.stories.tsx +41 -41
- package/components/ui/sonner/sonner.test.tsx +24 -24
- package/components/ui/sonner/sonner.tsx +74 -74
- package/components/ui/stats-card/index.ts +2 -2
- package/components/ui/stats-card/stats-card-skeleton.tsx +1 -3
- package/components/ui/stats-card/stats-card.stories.tsx +99 -99
- package/components/ui/stats-card/stats-card.test.tsx +34 -34
- package/components/ui/stats-card/stats-card.tsx +93 -93
- package/components/ui/stepper/index.ts +3 -3
- package/components/ui/stepper/stepper.stories.tsx +171 -171
- package/components/ui/stepper/stepper.test.tsx +47 -47
- package/components/ui/stepper/stepper.tsx +190 -190
- package/components/ui/stepper/use-stepper.ts +139 -139
- package/components/ui/switch/index.ts +1 -1
- package/components/ui/switch/switch.stories.tsx +93 -93
- package/components/ui/switch/switch.test.tsx +44 -44
- package/components/ui/switch/switch.tsx +70 -70
- package/components/ui/table/index.ts +1 -1
- package/components/ui/table/table.stories.tsx +114 -114
- package/components/ui/table/table.test.tsx +43 -43
- package/components/ui/table/table.tsx +104 -104
- package/components/ui/tabs/index.ts +1 -1
- package/components/ui/tabs/tabs.stories.tsx +140 -140
- package/components/ui/tabs/tabs.test.tsx +50 -50
- package/components/ui/tabs/tabs.tsx +66 -66
- package/components/ui/textarea/index.ts +1 -1
- package/components/ui/textarea/textarea.stories.tsx +69 -69
- package/components/ui/textarea/textarea.test.tsx +41 -41
- package/components/ui/textarea/textarea.tsx +61 -61
- package/components/ui/timeline/index.ts +1 -1
- package/components/ui/timeline/timeline.stories.tsx +97 -97
- package/components/ui/timeline/timeline.test.tsx +53 -53
- package/components/ui/timeline/timeline.tsx +124 -124
- package/components/ui/toggle/index.ts +1 -1
- package/components/ui/toggle/toggle.stories.tsx +56 -56
- package/components/ui/toggle/toggle.test.tsx +32 -32
- package/components/ui/toggle/toggle.tsx +55 -55
- package/components/ui/toggle-group/index.ts +1 -1
- package/components/ui/toggle-group/toggle-group.stories.tsx +66 -66
- package/components/ui/toggle-group/toggle-group.test.tsx +47 -47
- package/components/ui/toggle-group/toggle-group.tsx +79 -79
- package/components/ui/tooltip/index.ts +1 -1
- package/components/ui/tooltip/tooltip.stories.tsx +83 -83
- package/components/ui/tooltip/tooltip.test.tsx +39 -39
- package/components/ui/tooltip/tooltip.tsx +69 -69
- package/components/ui/tree-view/index.ts +4 -4
- package/components/ui/tree-view/tree-view.stories.tsx +154 -154
- package/components/ui/tree-view/tree-view.test.tsx +58 -58
- package/components/ui/tree-view/tree-view.tsx +171 -171
- package/components/ui/tree-view/use-tree-view.ts +237 -237
- package/components.json +892 -892
- package/contexts/ApiKeyContext.test.tsx +26 -26
- package/contexts/ApiKeyContext.tsx +196 -196
- package/contexts/AssistenteContext.test.tsx +17 -17
- package/contexts/AssistenteContext.tsx +113 -113
- package/contexts/AuthContext.tsx +121 -118
- package/contexts/BrandColorsContext.test.tsx +21 -21
- package/contexts/BrandColorsContext.tsx +251 -251
- package/contexts/LanguageContext.tsx +1 -2
- package/contexts/LayoutContext.test.tsx +29 -29
- package/contexts/LayoutContext.tsx +140 -140
- package/contexts/ThemeContext.test.tsx +38 -38
- package/contexts/ThemeContext.tsx +111 -111
- package/contexts/index.ts +8 -8
- package/contexts/theme-data.ts +340 -340
- package/dist/AssistantChart-COGiOV-g.cjs +3541 -0
- package/dist/AssistantChart-CWX1OWNM.js +3373 -0
- package/dist/AudioPlayer-9psiEucT.cjs +1282 -0
- package/dist/AudioPlayer-Dp2bD1Gk.js +1278 -0
- package/dist/BrandColorsContext-DZT7JjeD.js +659 -0
- package/dist/BrandColorsContext-awnBCmC4.cjs +666 -0
- package/dist/CodeBlock-DYkTfR0f.js +221 -0
- package/dist/CodeBlock-EOvp9cVu.cjs +223 -0
- package/dist/CustomTooltipContent-BhdIeBEg.cjs +54 -0
- package/dist/CustomTooltipContent-CNbVB2NS.js +33 -0
- package/dist/FeatureCard-BZ4CYxFf.cjs +497 -0
- package/dist/FeatureCard-DNycVGwT.js +485 -0
- package/dist/FeatureCardSkeleton-DZqc96mt.js +27 -0
- package/dist/FeatureCardSkeleton-pTa0YNKP.cjs +29 -0
- package/dist/LayoutContext-BEq_-n98.cjs +96 -0
- package/dist/LayoutContext-DNl1xSoX.js +92 -0
- package/dist/ThemeContext-CMD3z2Dz.cjs +1930 -0
- package/dist/ThemeContext-x_F2zsnv.js +1923 -0
- package/dist/VerifyEmailPage-BJjAMUTW.js +3223 -0
- package/dist/VerifyEmailPage-Bv8Ah_TK.cjs +3235 -0
- package/dist/VerifyEmailPage-CkBYfsNy.cjs +3232 -0
- package/dist/VerifyEmailPage-Cyl55sJb.js +3226 -0
- package/dist/VerifyEmailPage-X14vhdyl.js +3296 -0
- package/dist/VerifyEmailPage-u_Dn7t1U.cjs +3305 -0
- package/dist/XerticaOrbe-Uk2JML1-.cjs +1927 -0
- package/dist/XerticaOrbe-jA5T2iOk.js +1925 -0
- package/dist/XerticaProvider-BErr83Bg.js +42 -0
- package/dist/XerticaProvider-CwOkHxiT.cjs +44 -0
- package/dist/XerticaProvider-DUOJg9iX.js +49 -0
- package/dist/XerticaProvider-Dl_b72_l.cjs +51 -0
- package/dist/XerticaXLogo-BX3ueACh.js +255 -0
- package/dist/XerticaXLogo-mqjoBiLI.js +252 -0
- package/dist/XerticaXLogo-qBPhwK3g.cjs +260 -0
- package/dist/XerticaXLogo-uQgwns_E.cjs +257 -0
- package/dist/alert-dialog-DhwPioBa.cjs +885 -0
- package/dist/alert-dialog-DqlRW_An.js +831 -0
- package/dist/assistant.cjs.js +8 -4
- package/dist/assistant.es.js +5 -11
- package/dist/avatar-3kO2Anrp.js +54 -0
- package/dist/avatar-BCM7YQRC.cjs +77 -0
- package/dist/blocks.cjs.js +9 -4
- package/dist/blocks.es.js +2 -16
- package/dist/brand.cjs.js +10 -5
- package/dist/brand.es.js +3 -11
- package/dist/breadcrumb-BKtHF4gk.cjs +98 -0
- package/dist/breadcrumb-ifNsA7Zl.js +90 -0
- package/dist/button-0BlA47It.cjs +85 -0
- package/dist/button-DZHzN1Gd.js +62 -0
- package/dist/cli.js +471 -93
- package/dist/components/brand/theme-toggle/ThemeToggle.d.ts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/dropdown-menu-BMcykFDf.cjs +225 -0
- package/dist/dropdown-menu-Dn_eV2Xb.js +190 -0
- package/dist/google-maps-loader-BCe58h9D.js +308 -0
- package/dist/google-maps-loader-casMyxlo.cjs +316 -0
- package/dist/hooks.cjs.js +12 -8
- package/dist/hooks.es.js +10 -27
- package/dist/index-9GWd0qxq.cjs +12 -0
- package/dist/index-BabBx2pa.js +6 -0
- package/dist/index.cjs.js +37 -32
- package/dist/index.es.js +30 -363
- package/dist/input-C_UiS2Py.cjs +152 -0
- package/dist/input-cc-PTD4R.js +123 -0
- package/dist/layout.cjs.js +10 -6
- package/dist/layout.es.js +7 -9
- package/dist/media.cjs.js +8 -3
- package/dist/media.es.js +1 -6
- package/dist/pages.cjs.js +8 -3
- package/dist/pages.es.js +1 -11
- package/dist/progress-C7Lti5wo.js +80 -0
- package/dist/progress-Cqwxbqs1.cjs +103 -0
- package/dist/rich-text-editor-DqLICivI.js +2832 -0
- package/dist/rich-text-editor-DxO1Hz3a.cjs +2903 -0
- package/dist/select-CH6v_KcQ.cjs +161 -0
- package/dist/select-D-xvCZK2.js +130 -0
- package/dist/sidebar-3XyzjVBw.js +792 -0
- package/dist/sidebar-B4ZWaMrE.js +792 -0
- package/dist/sidebar-BS1p2V7t.cjs +795 -0
- package/dist/sidebar-DyYvgyBj.cjs +795 -0
- package/dist/skeleton-DjiHerJn.cjs +87 -0
- package/dist/skeleton-DtR5tkYe.js +78 -0
- package/dist/slider-B00b9SVK.cjs +78 -0
- package/dist/slider-DQCNUUMj.js +56 -0
- package/dist/sonner-B-jWlik1.cjs +68 -0
- package/dist/sonner-C9tiqj4f.js +47 -0
- package/dist/tooltip-D8n9UYoU.cjs +72 -0
- package/dist/tooltip-RtbSmPYJ.js +48 -0
- package/dist/ui.cjs.js +23 -18
- package/dist/ui.es.js +16 -303
- package/dist/use-audio-player-B78fd2ct.js +188 -0
- package/dist/use-audio-player-DGvhPrgR.cjs +190 -0
- package/dist/use-mobile-BdXTRb0Z.cjs +51 -0
- package/dist/use-mobile-Ce2cBAQe.js +29 -0
- package/dist/xertica-assistant-B1NaSFFj.js +2173 -0
- package/dist/xertica-assistant-B687qEPU.js +2165 -0
- package/dist/xertica-assistant-CIaUlbIt.cjs +2180 -0
- package/dist/xertica-assistant-sOHwTgIP.cjs +2172 -0
- package/dist/xertica-ui.css +1 -1
- package/docs/ai-usage.md +195 -195
- package/docs/architecture-improvements.md +456 -456
- package/docs/architecture.md +312 -306
- package/docs/components/accordion.md +109 -109
- package/docs/components/alert-dialog.md +127 -127
- package/docs/components/alert.md +106 -106
- package/docs/components/aspect-ratio.md +58 -58
- package/docs/components/assistant-chart.md +47 -47
- package/docs/components/assistant.md +428 -426
- package/docs/components/audio-player.md +167 -167
- package/docs/components/avatar.md +101 -101
- package/docs/components/badge.md +84 -84
- package/docs/components/branding.md +252 -252
- package/docs/components/breadcrumb.md +104 -104
- package/docs/components/button.md +156 -156
- package/docs/components/calendar.md +141 -141
- package/docs/components/card-patterns.md +447 -445
- package/docs/components/card.md +245 -245
- package/docs/components/carousel.md +100 -100
- package/docs/components/chart.md +638 -638
- package/docs/components/checkbox.md +88 -88
- package/docs/components/code-block.md +105 -105
- package/docs/components/collapsible.md +86 -86
- package/docs/components/command.md +113 -113
- package/docs/components/context-menu.md +81 -81
- package/docs/components/dialog.md +198 -198
- package/docs/components/drawer.md +105 -105
- package/docs/components/dropdown-menu.md +127 -127
- package/docs/components/empty.md +127 -127
- package/docs/components/error-boundary.md +201 -191
- package/docs/components/file-upload.md +189 -189
- package/docs/components/floating-media-wrapper.md +63 -63
- package/docs/components/form.md +177 -177
- package/docs/components/formatted-document.md +105 -105
- package/docs/components/google-maps-loader.md +44 -44
- package/docs/components/header.md +177 -177
- package/docs/components/hooks.md +432 -430
- package/docs/components/hover-card.md +86 -86
- package/docs/components/image-with-fallback.md +107 -107
- package/docs/components/input-otp.md +95 -95
- package/docs/components/input.md +130 -130
- package/docs/components/label.md +69 -69
- package/docs/components/language-selector.md +20 -16
- package/docs/components/map-layers.md +138 -138
- package/docs/components/map.md +84 -84
- package/docs/components/markdown-message.md +47 -47
- package/docs/components/menubar.md +89 -89
- package/docs/components/modern-chat-input.md +164 -164
- package/docs/components/navigation-menu.md +83 -83
- package/docs/components/notification-badge.md +78 -78
- package/docs/components/page-header.md +93 -93
- package/docs/components/pages.md +323 -309
- package/docs/components/pagination.md +334 -334
- package/docs/components/popover.md +116 -116
- package/docs/components/progress.md +103 -103
- package/docs/components/radio-group.md +133 -133
- package/docs/components/rating.md +77 -77
- package/docs/components/resizable.md +84 -84
- package/docs/components/rich-text-editor.md +255 -255
- package/docs/components/route-map.md +124 -124
- package/docs/components/scroll-area.md +58 -58
- package/docs/components/search.md +87 -87
- package/docs/components/select.md +144 -144
- package/docs/components/separator.md +58 -58
- package/docs/components/sheet.md +122 -122
- package/docs/components/sidebar.md +314 -314
- package/docs/components/simple-map.md +51 -51
- package/docs/components/skeleton.md +99 -99
- package/docs/components/slider.md +84 -84
- package/docs/components/sonner.md +115 -115
- package/docs/components/stats-card.md +120 -120
- package/docs/components/stepper.md +268 -268
- package/docs/components/switch.md +106 -106
- package/docs/components/table.md +138 -138
- package/docs/components/tabs.md +117 -117
- package/docs/components/textarea.md +86 -86
- package/docs/components/theme-toggle.md +73 -73
- package/docs/components/timeline.md +121 -121
- package/docs/components/toggle-group.md +68 -68
- package/docs/components/toggle.md +62 -62
- package/docs/components/tooltip.md +116 -116
- package/docs/components/tree-view.md +238 -238
- package/docs/components/use-mobile.md +96 -96
- package/docs/components/video-player.md +68 -68
- package/docs/components/xertica-logo.md +36 -36
- package/docs/components/xertica-orbe.md +35 -35
- package/docs/components/xertica-provider.md +65 -65
- package/docs/components/xertica-xlogo.md +35 -35
- package/docs/decision-tree.md +293 -293
- package/docs/doc-audit.md +244 -243
- package/docs/form-sizing.md +162 -162
- package/docs/getting-started.md +616 -591
- package/docs/guidelines.md +330 -328
- package/docs/i18n.md +61 -57
- package/docs/installation.md +268 -267
- package/docs/layout.md +143 -143
- package/docs/llms.md +295 -295
- package/docs/patterns/analytics.md +194 -194
- package/docs/patterns/crud.md +149 -149
- package/docs/patterns/dashboard.md +138 -138
- package/docs/patterns/detail-page.md +296 -296
- package/docs/patterns/form.md +241 -241
- package/docs/patterns/login.md +156 -156
- package/docs/patterns/settings.md +368 -368
- package/docs/patterns/wizard.md +213 -213
- package/docs/state-management.md +289 -289
- package/guidelines/Guidelines.md +409 -406
- package/hooks/useTheme.test.tsx +16 -16
- package/hooks/useTheme.ts +4 -4
- package/imports/Podcast.tsx +540 -540
- package/imports/XerticaAi.tsx +46 -46
- package/imports/XerticaX.tsx +15 -15
- package/imports/svg-aueiaqngck.ts +20 -20
- package/imports/svg-v9krss1ozd.ts +23 -23
- package/imports/svg-vhrdofe3qe.ts +6 -6
- package/llms-compact.txt +2 -1
- package/llms.txt +2 -1
- package/mcp/resources.json +22 -22
- package/mcp/tools.json +35 -35
- package/package.json +219 -213
- package/scripts/ai-validator.ts +91 -91
- package/scripts/cleanup-case-dupes.ts +62 -62
- package/scripts/generate-ai-manifests.ts +107 -107
- package/styles/globals.css +13 -13
- package/styles/xertica/app-overrides/chat.css +61 -61
- package/styles/xertica/app-overrides/scrollbar.css +33 -33
- package/styles/xertica/base.css +90 -71
- package/styles/xertica/integrations/google-maps.css +76 -76
- package/styles/xertica/integrations/sonner.css +73 -73
- package/styles/xertica/theme-map.css +102 -99
- package/styles/xertica/tokens.css +240 -236
- package/templates/CLAUDE.md +16 -1
- package/templates/eslint.config.js +26 -26
- package/templates/guidelines/Guidelines.md +577 -553
- package/templates/package.json +69 -69
- package/templates/postcss.config.js +6 -6
- package/templates/src/app/App.tsx +46 -46
- package/templates/src/app/components/AppLayout.tsx +55 -55
- package/templates/src/app/components/AuthGuard.tsx +131 -82
- package/templates/src/app/context/AuthContext.tsx +108 -108
- package/templates/src/features/assistant/index.ts +5 -5
- package/templates/src/features/auth/index.ts +4 -4
- package/templates/src/features/auth/ui/AuthPageShell.tsx +32 -32
- package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +70 -72
- package/templates/src/features/auth/ui/LoginContent.tsx +92 -92
- package/templates/src/features/auth/ui/ResetPasswordContent.tsx +6 -2
- package/templates/src/features/auth/ui/SocialLoginButtons.tsx +78 -78
- package/templates/src/features/auth/ui/VerifyEmailContent.tsx +2 -6
- package/templates/src/features/home/data/mock.ts +41 -35
- package/templates/src/features/home/index.ts +11 -11
- package/templates/src/features/home/store/dashboardStore.ts +25 -25
- package/templates/src/features/home/ui/HomeContent.tsx +117 -119
- package/templates/src/features/template/index.ts +5 -5
- package/templates/src/features/template/ui/CrudTemplate.tsx +1 -4
- package/templates/src/features/template/ui/LoginTemplate.tsx +1 -1
- package/templates/src/features/template/ui/TemplateContent.tsx +29 -21
- package/templates/src/locales/en/pages/templates.json +17 -17
- package/templates/src/locales/es/pages/templates.json +17 -17
- package/templates/src/locales/pt-BR/pages/templates.json +17 -17
- package/templates/src/main.tsx +11 -11
- package/templates/src/pages/AssistantPage.tsx +26 -20
- package/templates/src/pages/ForgotPasswordPage.tsx +6 -6
- package/templates/src/pages/HomePage.tsx +53 -49
- package/templates/src/pages/LoginPage.tsx +10 -10
- package/templates/src/pages/ResetPasswordPage.tsx +6 -6
- package/templates/src/pages/TemplatePage.tsx +28 -28
- package/templates/src/pages/VerifyEmailPage.tsx +6 -6
- package/templates/src/shared/config/navigation.ts +19 -19
- package/templates/src/shared/error-boundary.tsx +150 -154
- package/templates/src/shared/error-fallbacks.tsx +222 -226
- package/templates/src/shared/lib/auth.ts +20 -20
- package/templates/src/shared/types/auth.ts +3 -3
- package/templates/src/styles/index.css +95 -95
- package/templates/src/styles/xertica/tokens.css +240 -236
- package/templates/tsconfig.json +25 -25
- package/templates/tsconfig.node.json +12 -12
- package/templates/vite-env.d.ts +1 -1
- package/templates/vite.config.js +20 -20
- package/templates/vite.config.ts +54 -51
- package/utils/color-utils.ts +72 -72
- package/utils/demo-responses.test.ts +10 -10
- package/utils/demo-responses.ts +151 -151
- package/utils/gemini.test.ts +25 -25
- package/utils/gemini.ts +155 -155
package/bin/cli.ts
CHANGED
|
@@ -1,748 +1,1244 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import prompts from 'prompts';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import ora from 'ora';
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import { execa } from 'execa';
|
|
10
|
-
import { colorThemes } from '../contexts/theme-data';
|
|
11
|
-
import { generateTokensCss } from './generate-tokens';
|
|
12
|
-
import {
|
|
13
|
-
SUPPORTED_LANGUAGES,
|
|
14
|
-
DEFAULT_SELECTION,
|
|
15
|
-
readLanguagesConfig,
|
|
16
|
-
writeLanguagesConfig,
|
|
17
|
-
syncLocaleFiles,
|
|
18
|
-
generateI18nFile,
|
|
19
|
-
generateAppTsx,
|
|
20
|
-
} from './language-config';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
path
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
]
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
//
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
//
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
{
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { execa } from 'execa';
|
|
10
|
+
import { colorThemes } from '../contexts/theme-data';
|
|
11
|
+
import { generateTokensCss } from './generate-tokens';
|
|
12
|
+
import {
|
|
13
|
+
SUPPORTED_LANGUAGES,
|
|
14
|
+
DEFAULT_SELECTION,
|
|
15
|
+
readLanguagesConfig,
|
|
16
|
+
writeLanguagesConfig,
|
|
17
|
+
syncLocaleFiles,
|
|
18
|
+
generateI18nFile,
|
|
19
|
+
generateAppTsx,
|
|
20
|
+
} from './language-config';
|
|
21
|
+
|
|
22
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
// Project config helpers (.xertica.json)
|
|
24
|
+
// Persists per-project feature flags so `update` can read them later.
|
|
25
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
const XERTICA_CONFIG_FILE = '.xertica.json';
|
|
28
|
+
|
|
29
|
+
interface XerticaConfig {
|
|
30
|
+
version: 1;
|
|
31
|
+
hasAssistant: boolean;
|
|
32
|
+
disableDarkMode?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function readXerticaConfig(targetDir: string): Promise<XerticaConfig | null> {
|
|
36
|
+
const configPath = path.join(targetDir, XERTICA_CONFIG_FILE);
|
|
37
|
+
if (!(await fs.pathExists(configPath))) return null;
|
|
38
|
+
try {
|
|
39
|
+
return (await fs.readJson(configPath)) as XerticaConfig;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function writeXerticaConfig(
|
|
46
|
+
targetDir: string,
|
|
47
|
+
config: Partial<XerticaConfig>
|
|
48
|
+
): Promise<void> {
|
|
49
|
+
const configPath = path.join(targetDir, XERTICA_CONFIG_FILE);
|
|
50
|
+
const existing = (await readXerticaConfig(targetDir)) ?? {
|
|
51
|
+
version: 1 as const,
|
|
52
|
+
hasAssistant: false,
|
|
53
|
+
};
|
|
54
|
+
await fs.writeJson(configPath, { ...existing, ...config, version: 1 }, { spaces: 2 });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
58
|
+
const __dirname = path.dirname(__filename);
|
|
59
|
+
|
|
60
|
+
// Read CLI version from package.json so it always matches the published one,
|
|
61
|
+
// instead of hardcoding a literal that drifts on every version bump.
|
|
62
|
+
const pkgJson = JSON.parse(
|
|
63
|
+
fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf-8')
|
|
64
|
+
) as { version: string };
|
|
65
|
+
|
|
66
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
67
|
+
// AuthGuard generator
|
|
68
|
+
// Generates src/app/components/AuthGuard.tsx based on the selected features.
|
|
69
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
function generateAuthGuard({
|
|
72
|
+
hasLogin,
|
|
73
|
+
hasHome,
|
|
74
|
+
hasTemplate,
|
|
75
|
+
hasAssistant,
|
|
76
|
+
firstProtectedPath,
|
|
77
|
+
}: {
|
|
78
|
+
hasLogin: boolean;
|
|
79
|
+
hasHome: boolean;
|
|
80
|
+
hasTemplate: boolean;
|
|
81
|
+
hasAssistant: boolean;
|
|
82
|
+
firstProtectedPath: string;
|
|
83
|
+
}): string {
|
|
84
|
+
return `import React from 'react';
|
|
85
|
+
import { Routes, Route, Navigate } from 'react-router-dom';
|
|
86
|
+
import { useAuth } from '../context/AuthContext';
|
|
87
|
+
|
|
88
|
+
// ─── Lazy page imports ────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
${
|
|
91
|
+
hasLogin
|
|
92
|
+
? `const LoginPage = React.lazy(() => import('../../pages/LoginPage').then(m => ({ default: m.LoginPage })));
|
|
93
|
+
const ForgotPasswordPage = React.lazy(() => import('../../pages/ForgotPasswordPage').then(m => ({ default: m.ForgotPasswordPage })));
|
|
94
|
+
const VerifyEmailPage = React.lazy(() => import('../../pages/VerifyEmailPage').then(m => ({ default: m.VerifyEmailPage })));
|
|
95
|
+
const ResetPasswordPage = React.lazy(() => import('../../pages/ResetPasswordPage').then(m => ({ default: m.ResetPasswordPage })));`
|
|
96
|
+
: ''
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
${hasHome ? `const HomePage = React.lazy(() => import('../../pages/HomePage').then(m => ({ default: m.HomePage })));` : ''}
|
|
100
|
+
${hasTemplate ? `const TemplatePage = React.lazy(() => import('../../pages/TemplatePage').then(m => ({ default: m.TemplatePage })));` : ''}
|
|
101
|
+
${hasAssistant ? `const AssistantPage = React.lazy(() => import('../../pages/AssistantPage').then(m => ({ default: m.AssistantPage })));` : ''}
|
|
102
|
+
|
|
103
|
+
// ─── Route guards ─────────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
106
|
+
const { user, isLoading } = useAuth();
|
|
107
|
+
if (isLoading) return null;
|
|
108
|
+
if (!user) return <Navigate to="${hasLogin ? '/login' : firstProtectedPath}" replace />;
|
|
109
|
+
return <>{children}</>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
${
|
|
113
|
+
hasLogin
|
|
114
|
+
? `function GuestRoute({ children }: { children: React.ReactNode }) {
|
|
115
|
+
const { user, isLoading } = useAuth();
|
|
116
|
+
if (isLoading) return null;
|
|
117
|
+
if (user) return <Navigate to="${firstProtectedPath}" replace />;
|
|
118
|
+
return <>{children}</>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function LoginPageWithAuth() {
|
|
122
|
+
const { login } = useAuth();
|
|
123
|
+
return <LoginPage onLogin={login} />;
|
|
124
|
+
}`
|
|
125
|
+
: ''
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ─── Route tree ───────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
export function AuthGuard() {
|
|
131
|
+
const { user } = useAuth();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div className="min-h-screen bg-muted overflow-x-hidden max-w-full">
|
|
135
|
+
<Routes>
|
|
136
|
+
${
|
|
137
|
+
hasLogin
|
|
138
|
+
? ` <Route path="/login" element={<GuestRoute><LoginPageWithAuth /></GuestRoute>} />
|
|
139
|
+
<Route path="/forgot-password" element={<GuestRoute><ForgotPasswordPage /></GuestRoute>} />
|
|
140
|
+
<Route path="/verify-email" element={<GuestRoute><VerifyEmailPage /></GuestRoute>} />
|
|
141
|
+
<Route path="/reset-password" element={<GuestRoute><ResetPasswordPage /></GuestRoute>} />`
|
|
142
|
+
: ''
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
${hasHome ? ` <Route path="/home" element={<ProtectedRoute><HomePage /></ProtectedRoute>} />` : ''}
|
|
146
|
+
${hasTemplate ? ` <Route path="/template" element={<ProtectedRoute><TemplatePage /></ProtectedRoute>} />` : ''}
|
|
147
|
+
${hasAssistant ? ` <Route path="/assistente" element={<ProtectedRoute><AssistantPage /></ProtectedRoute>} />` : ''}
|
|
148
|
+
|
|
149
|
+
<Route path="/" element={<Navigate to={user ? '${firstProtectedPath}' : '${hasLogin ? '/login' : firstProtectedPath}'} replace />} />
|
|
150
|
+
<Route path="*" element={<Navigate to={user ? '${firstProtectedPath}' : '${hasLogin ? '/login' : firstProtectedPath}'} replace />} />
|
|
151
|
+
</Routes>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
159
|
+
// Page generators
|
|
160
|
+
// Generate page files that vary based on whether the assistant is included.
|
|
161
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
162
|
+
|
|
163
|
+
function generateHomePage(hasAssistant: boolean): string {
|
|
164
|
+
if (hasAssistant) {
|
|
165
|
+
return `import React from 'react';
|
|
166
|
+
import { XerticaAssistant, generateDemoResponse } from 'xertica-ui/assistant';
|
|
167
|
+
import { useLayout } from 'xertica-ui/hooks';
|
|
168
|
+
import { useNavigate } from 'react-router-dom';
|
|
169
|
+
import { AppLayout } from '../app/components/AppLayout';
|
|
170
|
+
import { HomeContent } from '../features/home';
|
|
171
|
+
import { useAssistantConfig, getMockRichSuggestions, getMockFeedbackOptions } from '../features/assistant';
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Home page — thin layout shell.
|
|
175
|
+
*
|
|
176
|
+
* Assistant config (suggestions, feedback options) is fetched via React Query.
|
|
177
|
+
* To connect to a real API replace \`fetchAssistantConfig\` in
|
|
178
|
+
* \`features/assistant/data/mock.ts\`.
|
|
179
|
+
*/
|
|
180
|
+
export function HomePage() {
|
|
181
|
+
const { assistenteExpanded, toggleAssistente } = useLayout();
|
|
182
|
+
const navigate = useNavigate();
|
|
183
|
+
|
|
184
|
+
const { data: assistantConfig } = useAssistantConfig();
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<AppLayout
|
|
188
|
+
assistant={
|
|
189
|
+
<XerticaAssistant
|
|
190
|
+
isExpanded={assistenteExpanded}
|
|
191
|
+
onToggle={toggleAssistente}
|
|
192
|
+
defaultTab="chat"
|
|
193
|
+
demoMode={true}
|
|
194
|
+
userName="Ariel Santos"
|
|
195
|
+
responseGenerator={generateDemoResponse}
|
|
196
|
+
suggestions={assistantConfig?.suggestions}
|
|
197
|
+
richSuggestions={assistantConfig?.richSuggestions ?? getMockRichSuggestions()}
|
|
198
|
+
feedbackOptions={assistantConfig?.feedbackOptions ?? getMockFeedbackOptions()}
|
|
199
|
+
showHistory={false}
|
|
200
|
+
showFavorites={false}
|
|
201
|
+
onNavigateSettings={() => navigate('/settings')}
|
|
202
|
+
onNavigateFullPage={() => navigate('/assistente')}
|
|
203
|
+
onEvaluation={(messageId, type, reason) => {
|
|
204
|
+
// Wire your feedback persistence logic here
|
|
205
|
+
console.log(\`Avaliação: \${type} na mensagem \${messageId}. Motivo: \${reason}\`);
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
}
|
|
209
|
+
>
|
|
210
|
+
<HomeContent />
|
|
211
|
+
</AppLayout>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return `import React from 'react';
|
|
218
|
+
import { AppLayout } from '../app/components/AppLayout';
|
|
219
|
+
import { HomeContent } from '../features/home';
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Home page — thin layout shell.
|
|
223
|
+
*/
|
|
224
|
+
export function HomePage() {
|
|
225
|
+
return (
|
|
226
|
+
<AppLayout>
|
|
227
|
+
<HomeContent />
|
|
228
|
+
</AppLayout>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function generateTemplatePage(hasAssistant: boolean): string {
|
|
235
|
+
if (hasAssistant) {
|
|
236
|
+
return `import React from 'react';
|
|
237
|
+
import { XerticaAssistant } from 'xertica-ui/assistant';
|
|
238
|
+
import { useLayout } from 'xertica-ui/hooks';
|
|
239
|
+
import { AppLayout } from '../app/components/AppLayout';
|
|
240
|
+
import { TemplateContent } from '../features/template';
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Template page — thin layout shell.
|
|
244
|
+
*
|
|
245
|
+
* Auth state is consumed from \`AuthContext\` via \`AppLayout\` — no props needed.
|
|
246
|
+
*/
|
|
247
|
+
export function TemplatePage() {
|
|
248
|
+
const { assistenteExpanded, toggleAssistente } = useLayout();
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<AppLayout
|
|
252
|
+
assistant={
|
|
253
|
+
<XerticaAssistant
|
|
254
|
+
isExpanded={assistenteExpanded}
|
|
255
|
+
onToggle={toggleAssistente}
|
|
256
|
+
onEvaluation={(id, type, reason) => console.log('Feedback:', id, type, reason)}
|
|
257
|
+
/>
|
|
258
|
+
}
|
|
259
|
+
>
|
|
260
|
+
<TemplateContent />
|
|
261
|
+
</AppLayout>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
`;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return `import React from 'react';
|
|
268
|
+
import { AppLayout } from '../app/components/AppLayout';
|
|
269
|
+
import { TemplateContent } from '../features/template';
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Template page — thin layout shell.
|
|
273
|
+
*
|
|
274
|
+
* Auth state is consumed from \`AuthContext\` via \`AppLayout\` — no props needed.
|
|
275
|
+
*/
|
|
276
|
+
export function TemplatePage() {
|
|
277
|
+
return (
|
|
278
|
+
<AppLayout>
|
|
279
|
+
<TemplateContent />
|
|
280
|
+
</AppLayout>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const program = new Command();
|
|
287
|
+
|
|
288
|
+
program
|
|
289
|
+
.name('xertica-ui')
|
|
290
|
+
.description('CLI to initialize Xertica UI projects')
|
|
291
|
+
.version(pkgJson.version);
|
|
292
|
+
|
|
293
|
+
program
|
|
294
|
+
.command('init')
|
|
295
|
+
.description('Initialize a new Xertica UI project')
|
|
296
|
+
.argument('[directory]', 'Directory to initialize in', '.')
|
|
297
|
+
.action(async directory => {
|
|
298
|
+
const targetDir = path.resolve(process.cwd(), directory);
|
|
299
|
+
const templatesDir = path.resolve(__dirname, '../templates');
|
|
300
|
+
|
|
301
|
+
console.log(chalk.blue(`🚀 Welcome to Xertica UI CLI! ${chalk.dim(`v${pkgJson.version}`)}`));
|
|
302
|
+
|
|
303
|
+
const response = await prompts([
|
|
304
|
+
{
|
|
305
|
+
type: 'multiselect',
|
|
306
|
+
name: 'pages',
|
|
307
|
+
message: 'Which pages/templates to include?',
|
|
308
|
+
choices: [
|
|
309
|
+
{
|
|
310
|
+
title: 'Login Page (+ Forgot / Verify / Reset Password)',
|
|
311
|
+
value: 'login',
|
|
312
|
+
selected: true,
|
|
313
|
+
},
|
|
314
|
+
{ title: 'Home Page', value: 'home', selected: true },
|
|
315
|
+
{ title: 'Template Page (components showcase)', value: 'template', selected: true },
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
type: 'multiselect',
|
|
320
|
+
name: 'languages',
|
|
321
|
+
message: 'Which languages should the app support?',
|
|
322
|
+
instructions: false,
|
|
323
|
+
hint: 'Select at least 1. Single-language apps auto-hide the LanguageSelector.',
|
|
324
|
+
min: 1,
|
|
325
|
+
choices: SUPPORTED_LANGUAGES.map(l => ({
|
|
326
|
+
title: l.label,
|
|
327
|
+
value: l.code,
|
|
328
|
+
selected: true,
|
|
329
|
+
})),
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
type: 'select',
|
|
333
|
+
name: 'theme',
|
|
334
|
+
message: 'Select the default color theme for your project:',
|
|
335
|
+
choices: colorThemes.map(t => ({
|
|
336
|
+
title: t.name,
|
|
337
|
+
description: t.description,
|
|
338
|
+
value: t.id,
|
|
339
|
+
})),
|
|
340
|
+
initial: 0,
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
type: 'confirm',
|
|
344
|
+
name: 'hasAssistant',
|
|
345
|
+
message: 'Include AI Assistant? (XerticaAssistant chat page + sidebar variant)',
|
|
346
|
+
initial: true,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
type: 'confirm',
|
|
350
|
+
name: 'enableDarkMode',
|
|
351
|
+
message: 'Enable dark mode support?',
|
|
352
|
+
initial: true,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
type: 'confirm',
|
|
356
|
+
name: 'install',
|
|
357
|
+
message: 'Install dependencies automatically?',
|
|
358
|
+
initial: true,
|
|
359
|
+
},
|
|
360
|
+
]);
|
|
361
|
+
|
|
362
|
+
// Abort if the user cancelled any prompt (prompts returns undefined on Ctrl+C)
|
|
363
|
+
if (!response.pages || !response.languages || !response.theme) return;
|
|
364
|
+
|
|
365
|
+
const spinner = ora('Initializing project...').start();
|
|
366
|
+
|
|
367
|
+
try {
|
|
368
|
+
await fs.ensureDir(targetDir);
|
|
369
|
+
|
|
370
|
+
const pages = response.pages || [];
|
|
371
|
+
const hasLogin = pages.includes('login');
|
|
372
|
+
const hasHome = pages.includes('home');
|
|
373
|
+
const hasTemplate = pages.includes('template');
|
|
374
|
+
const hasAssistant = response.hasAssistant ?? true;
|
|
375
|
+
|
|
376
|
+
// Resolve selected languages — fall back to all defaults if the user
|
|
377
|
+
// somehow ended up with an empty array (the prompt's min:1 should prevent
|
|
378
|
+
// this, but we defend defensively).
|
|
379
|
+
const selectedLanguages: string[] =
|
|
380
|
+
Array.isArray(response.languages) && response.languages.length > 0
|
|
381
|
+
? response.languages
|
|
382
|
+
: DEFAULT_SELECTION;
|
|
383
|
+
|
|
384
|
+
// 1. Copy root config files
|
|
385
|
+
const rootFilesToCopy = [
|
|
386
|
+
'index.html',
|
|
387
|
+
'vite.config.ts',
|
|
388
|
+
'tsconfig.json',
|
|
389
|
+
'tsconfig.node.json',
|
|
390
|
+
'postcss.config.js',
|
|
391
|
+
'vite-env.d.ts',
|
|
392
|
+
'eslint.config.js',
|
|
393
|
+
'.env.example',
|
|
394
|
+
'guidelines',
|
|
395
|
+
'CLAUDE.md',
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
for (const file of rootFilesToCopy) {
|
|
399
|
+
const srcPath = path.join(templatesDir, file);
|
|
400
|
+
if (await fs.pathExists(srcPath)) {
|
|
401
|
+
await fs.copy(srcPath, path.join(targetDir, file));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// 2. Copy package.json
|
|
406
|
+
const pkgTemplatePath = path.join(templatesDir, 'package.json');
|
|
407
|
+
if (await fs.pathExists(pkgTemplatePath)) {
|
|
408
|
+
const pkgContent = await fs.readJson(pkgTemplatePath);
|
|
409
|
+
const projectName = path.basename(targetDir) || 'my-xertica-app';
|
|
410
|
+
pkgContent.name = projectName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
411
|
+
await fs.writeJson(path.join(targetDir, 'package.json'), pkgContent, { spaces: 2 });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// 3. Copy src/main.tsx
|
|
415
|
+
await fs.copy(
|
|
416
|
+
path.join(templatesDir, 'src', 'main.tsx'),
|
|
417
|
+
path.join(targetDir, 'src', 'main.tsx')
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
const disableDarkMode = response.enableDarkMode === false;
|
|
421
|
+
|
|
422
|
+
// 4. Generate src/app/App.tsx with the user's language selection
|
|
423
|
+
// (instead of copying the static template, we inject `availableLanguages`)
|
|
424
|
+
await fs.ensureDir(path.join(targetDir, 'src', 'app'));
|
|
425
|
+
await fs.writeFile(
|
|
426
|
+
path.join(targetDir, 'src', 'app', 'App.tsx'),
|
|
427
|
+
generateAppTsx(selectedLanguages, disableDarkMode)
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
// 5. Copy src/app/components/AppLayout.tsx (always needed)
|
|
431
|
+
await fs.ensureDir(path.join(targetDir, 'src', 'app', 'components'));
|
|
432
|
+
await fs.copy(
|
|
433
|
+
path.join(templatesDir, 'src', 'app', 'components', 'AppLayout.tsx'),
|
|
434
|
+
path.join(targetDir, 'src', 'app', 'components', 'AppLayout.tsx')
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
// 6. Copy src/shared/ (always needed — auth helpers, navigation config, types)
|
|
438
|
+
await fs.copy(
|
|
439
|
+
path.join(templatesDir, 'src', 'shared'),
|
|
440
|
+
path.join(targetDir, 'src', 'shared')
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
// 6.1 Generate i18n.ts with only the imports/resources for selected languages
|
|
444
|
+
await fs.writeFile(
|
|
445
|
+
path.join(targetDir, 'src', 'i18n.ts'),
|
|
446
|
+
generateI18nFile(selectedLanguages)
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
// 6.2 Copy only the selected locale JSON files (no orphan locales)
|
|
450
|
+
await syncLocaleFiles(templatesDir, targetDir, selectedLanguages, { pruneOthers: true });
|
|
451
|
+
|
|
452
|
+
// 6.3 Persist the language selection so `update` can remember it
|
|
453
|
+
await writeLanguagesConfig(targetDir, selectedLanguages);
|
|
454
|
+
|
|
455
|
+
// 6.5 Persist project feature flags (.xertica.json)
|
|
456
|
+
await writeXerticaConfig(targetDir, { hasAssistant, disableDarkMode });
|
|
457
|
+
|
|
458
|
+
// 6.4 Copy context
|
|
459
|
+
await fs.ensureDir(path.join(targetDir, 'src', 'app', 'context'));
|
|
460
|
+
await fs.copy(
|
|
461
|
+
path.join(templatesDir, 'src', 'app', 'context', 'AuthContext.tsx'),
|
|
462
|
+
path.join(targetDir, 'src', 'app', 'context', 'AuthContext.tsx')
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
// 7. Copy features based on selections
|
|
466
|
+
if (hasLogin) {
|
|
467
|
+
await fs.copy(
|
|
468
|
+
path.join(templatesDir, 'src', 'features', 'auth'),
|
|
469
|
+
path.join(targetDir, 'src', 'features', 'auth')
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
if (hasHome) {
|
|
473
|
+
await fs.copy(
|
|
474
|
+
path.join(templatesDir, 'src', 'features', 'home'),
|
|
475
|
+
path.join(targetDir, 'src', 'features', 'home')
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
if (hasTemplate) {
|
|
479
|
+
await fs.copy(
|
|
480
|
+
path.join(templatesDir, 'src', 'features', 'template'),
|
|
481
|
+
path.join(targetDir, 'src', 'features', 'template')
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
// Copy assistant feature only if selected
|
|
485
|
+
if (hasAssistant) {
|
|
486
|
+
await fs.copy(
|
|
487
|
+
path.join(templatesDir, 'src', 'features', 'assistant'),
|
|
488
|
+
path.join(targetDir, 'src', 'features', 'assistant')
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// 8. Copy pages based on selections
|
|
493
|
+
await fs.ensureDir(path.join(targetDir, 'src', 'pages'));
|
|
494
|
+
|
|
495
|
+
const pagesToCopy: string[] = [];
|
|
496
|
+
if (hasLogin)
|
|
497
|
+
pagesToCopy.push(
|
|
498
|
+
'LoginPage.tsx',
|
|
499
|
+
'ForgotPasswordPage.tsx',
|
|
500
|
+
'VerifyEmailPage.tsx',
|
|
501
|
+
'ResetPasswordPage.tsx'
|
|
502
|
+
);
|
|
503
|
+
if (hasHome) pagesToCopy.push('HomePage.tsx');
|
|
504
|
+
if (hasTemplate) pagesToCopy.push('TemplatePage.tsx');
|
|
505
|
+
if (hasAssistant) pagesToCopy.push('AssistantPage.tsx');
|
|
506
|
+
|
|
507
|
+
for (const pageFile of pagesToCopy) {
|
|
508
|
+
// HomePage and TemplatePage are generated (they vary by hasAssistant)
|
|
509
|
+
if (pageFile === 'HomePage.tsx') {
|
|
510
|
+
await fs.writeFile(
|
|
511
|
+
path.join(targetDir, 'src', 'pages', 'HomePage.tsx'),
|
|
512
|
+
generateHomePage(hasAssistant)
|
|
513
|
+
);
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (pageFile === 'TemplatePage.tsx') {
|
|
517
|
+
await fs.writeFile(
|
|
518
|
+
path.join(targetDir, 'src', 'pages', 'TemplatePage.tsx'),
|
|
519
|
+
generateTemplatePage(hasAssistant)
|
|
520
|
+
);
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
const src = path.join(templatesDir, 'src', 'pages', pageFile);
|
|
524
|
+
if (await fs.pathExists(src)) {
|
|
525
|
+
await fs.copy(src, path.join(targetDir, 'src', 'pages', pageFile));
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// 9. Generate AuthGuard.tsx based on selected pages
|
|
530
|
+
const firstProtectedPath = hasHome ? '/home' : hasTemplate ? '/template' : '/login';
|
|
531
|
+
const authGuardContent = generateAuthGuard({
|
|
532
|
+
hasLogin,
|
|
533
|
+
hasHome,
|
|
534
|
+
hasTemplate,
|
|
535
|
+
hasAssistant,
|
|
536
|
+
firstProtectedPath,
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
await fs.writeFile(
|
|
540
|
+
path.join(targetDir, 'src', 'app', 'components', 'AuthGuard.tsx'),
|
|
541
|
+
authGuardContent
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
// 10. Generate theme tokens
|
|
545
|
+
const selectedTheme = colorThemes.find(t => t.id === response.theme) || colorThemes[0];
|
|
546
|
+
const tokensDir = path.join(targetDir, 'src', 'styles', 'xertica');
|
|
547
|
+
await fs.ensureDir(tokensDir);
|
|
548
|
+
await fs.copy(
|
|
549
|
+
path.join(templatesDir, 'src', 'styles', 'index.css'),
|
|
550
|
+
path.join(targetDir, 'src', 'styles', 'index.css')
|
|
551
|
+
);
|
|
552
|
+
await fs.writeFile(path.join(tokensDir, 'tokens.css'), generateTokensCss(selectedTheme));
|
|
553
|
+
|
|
554
|
+
spinner.succeed('Project initialized successfully!');
|
|
555
|
+
|
|
556
|
+
if (response.install) {
|
|
557
|
+
const installSpinner = ora('Installing dependencies...').start();
|
|
558
|
+
await execa('npm', ['install'], { cwd: targetDir });
|
|
559
|
+
installSpinner.succeed('Dependencies installed!');
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
console.log(chalk.green('\n✅ Done! Your Xertica UI project is ready.'));
|
|
563
|
+
console.log(chalk.cyan(`\n cd ${directory}`));
|
|
564
|
+
if (!response.install) {
|
|
565
|
+
console.log(chalk.cyan(' npm install'));
|
|
566
|
+
}
|
|
567
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
568
|
+
console.log();
|
|
569
|
+
console.log(chalk.gray(' Components are imported from the xertica-ui package.'));
|
|
570
|
+
console.log(chalk.gray(' Customize the theme in src/styles/xertica/tokens.css'));
|
|
571
|
+
const langLabels = SUPPORTED_LANGUAGES.filter(l => selectedLanguages.includes(l.code))
|
|
572
|
+
.map(l => l.label)
|
|
573
|
+
.join(', ');
|
|
574
|
+
console.log(
|
|
575
|
+
chalk.gray(
|
|
576
|
+
` Languages: ${langLabels}${selectedLanguages.length === 1 ? ' (monolingual — LanguageSelector hidden)' : ''}`
|
|
577
|
+
)
|
|
578
|
+
);
|
|
579
|
+
console.log(chalk.gray(' To add/remove languages later: npx xertica-ui update → Languages'));
|
|
580
|
+
console.log(
|
|
581
|
+
chalk.gray(` AI Assistant: ${hasAssistant ? 'included (/assistente)' : 'not included'}`)
|
|
582
|
+
);
|
|
583
|
+
if (!hasAssistant) {
|
|
584
|
+
console.log(chalk.gray(' To add the assistant later: npx xertica-ui update → Assistant'));
|
|
585
|
+
}
|
|
586
|
+
} catch (error) {
|
|
587
|
+
spinner.fail('Failed to initialize project');
|
|
588
|
+
console.error(error);
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
program
|
|
593
|
+
.command('update')
|
|
594
|
+
.alias('update-theme')
|
|
595
|
+
.description('Update theme or project files to the latest version')
|
|
596
|
+
.action(async () => {
|
|
597
|
+
const targetDir = process.cwd();
|
|
598
|
+
|
|
599
|
+
console.log(chalk.blue(`🔧 Xertica UI CLI ${chalk.dim(`v${pkgJson.version}`)}`));
|
|
600
|
+
|
|
601
|
+
const currentConfig = await readXerticaConfig(targetDir);
|
|
602
|
+
|
|
603
|
+
const { updateType } = await prompts({
|
|
604
|
+
type: 'select',
|
|
605
|
+
name: 'updateType',
|
|
606
|
+
message: 'What do you want to update?',
|
|
607
|
+
choices: [
|
|
608
|
+
{
|
|
609
|
+
title: 'Theme only',
|
|
610
|
+
description: 'Change the color tokens (tokens.css)',
|
|
611
|
+
value: 'theme',
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
title: 'Languages',
|
|
615
|
+
description: 'Add or remove supported languages (pt-BR, en, es, …)',
|
|
616
|
+
value: 'languages',
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
title: 'Assistant',
|
|
620
|
+
description: currentConfig?.hasAssistant
|
|
621
|
+
? 'Remove the AI Assistant from your project'
|
|
622
|
+
: 'Add the AI Assistant to your project',
|
|
623
|
+
value: 'assistant',
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
title: 'Dark Mode',
|
|
627
|
+
description: currentConfig?.disableDarkMode
|
|
628
|
+
? 'Enable dark mode support in your project'
|
|
629
|
+
: 'Disable dark mode support in your project',
|
|
630
|
+
value: 'darkmode',
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
title: 'Project files',
|
|
634
|
+
description: 'Update app shell, shared, features and pages to a specific version',
|
|
635
|
+
value: 'project',
|
|
636
|
+
},
|
|
637
|
+
],
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
if (!updateType) return;
|
|
641
|
+
|
|
642
|
+
// ── Theme update ─────────────────────────────────────────────────────────
|
|
643
|
+
if (updateType === 'theme') {
|
|
644
|
+
const { theme } = await prompts({
|
|
645
|
+
type: 'select',
|
|
646
|
+
name: 'theme',
|
|
647
|
+
message: 'Select the new color theme:',
|
|
648
|
+
choices: colorThemes.map(t => ({
|
|
649
|
+
title: t.name,
|
|
650
|
+
description: t.description,
|
|
651
|
+
value: t.id,
|
|
652
|
+
})),
|
|
653
|
+
initial: 0,
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
if (!theme) return;
|
|
657
|
+
|
|
658
|
+
const spinner = ora('Updating theme...').start();
|
|
659
|
+
try {
|
|
660
|
+
const tokensPath = path.join(targetDir, 'src', 'styles', 'xertica', 'tokens.css');
|
|
661
|
+
const selectedTheme = colorThemes.find(t => t.id === theme);
|
|
662
|
+
if (selectedTheme) {
|
|
663
|
+
await fs.ensureDir(path.dirname(tokensPath));
|
|
664
|
+
await fs.writeFile(tokensPath, generateTokensCss(selectedTheme));
|
|
665
|
+
spinner.succeed(`Theme updated to "${selectedTheme.name}" successfully!`);
|
|
666
|
+
} else {
|
|
667
|
+
spinner.fail('Theme not found.');
|
|
668
|
+
}
|
|
669
|
+
} catch (error) {
|
|
670
|
+
spinner.fail('Failed to update theme');
|
|
671
|
+
console.error(error);
|
|
672
|
+
}
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// ── Languages update (add / remove) ──────────────────────────────────────
|
|
677
|
+
if (updateType === 'languages') {
|
|
678
|
+
// Resolve current selection — read from .languages.json if present,
|
|
679
|
+
// else inspect the locales/ folder to infer it (for projects scaffolded
|
|
680
|
+
// before this feature shipped).
|
|
681
|
+
const persistedCodes = await readLanguagesConfig(targetDir);
|
|
682
|
+
let currentCodes: string[] = persistedCodes ?? [];
|
|
683
|
+
if (currentCodes.length === 0) {
|
|
684
|
+
const localesDir = path.join(targetDir, 'src', 'locales');
|
|
685
|
+
if (await fs.pathExists(localesDir)) {
|
|
686
|
+
const entries = await fs.readdir(localesDir);
|
|
687
|
+
// Accept both the new folder layout (locales/<code>/) and the legacy
|
|
688
|
+
// flat layout (locales/<code>.json) when inferring the current set.
|
|
689
|
+
currentCodes = SUPPORTED_LANGUAGES.filter(
|
|
690
|
+
l => entries.includes(l.jsonFile) || entries.includes(`${l.jsonFile}.json`)
|
|
691
|
+
).map(l => l.code);
|
|
692
|
+
}
|
|
693
|
+
if (currentCodes.length === 0) currentCodes = DEFAULT_SELECTION;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
console.log(
|
|
697
|
+
chalk.cyan(
|
|
698
|
+
`\nCurrent languages: ${
|
|
699
|
+
SUPPORTED_LANGUAGES.filter(l => currentCodes.includes(l.code))
|
|
700
|
+
.map(l => l.label)
|
|
701
|
+
.join(', ') || '(none)'
|
|
702
|
+
}\n`
|
|
703
|
+
)
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
const { newCodes } = await prompts({
|
|
707
|
+
type: 'multiselect',
|
|
708
|
+
name: 'newCodes',
|
|
709
|
+
message: 'Select the languages this project should support:',
|
|
710
|
+
instructions: false,
|
|
711
|
+
hint: 'Press SPACE to toggle. At least 1 required. Single-language apps auto-hide the LanguageSelector.',
|
|
712
|
+
min: 1,
|
|
713
|
+
choices: SUPPORTED_LANGUAGES.map(l => ({
|
|
714
|
+
title: l.label,
|
|
715
|
+
value: l.code,
|
|
716
|
+
selected: currentCodes.includes(l.code),
|
|
717
|
+
})),
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
if (!Array.isArray(newCodes) || newCodes.length === 0) {
|
|
721
|
+
console.log(chalk.gray('Update cancelled.'));
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// Compute add/remove diff for the user-facing summary
|
|
726
|
+
const toAdd = newCodes.filter((c: string) => !currentCodes.includes(c));
|
|
727
|
+
const toRemove = currentCodes.filter(c => !newCodes.includes(c));
|
|
728
|
+
|
|
729
|
+
if (toAdd.length === 0 && toRemove.length === 0) {
|
|
730
|
+
console.log(chalk.gray('No changes — selection matches the current set.'));
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
const summary: string[] = [];
|
|
735
|
+
if (toAdd.length > 0) summary.push(chalk.green(` + ${toAdd.join(', ')}`));
|
|
736
|
+
if (toRemove.length > 0) summary.push(chalk.red(` - ${toRemove.join(', ')}`));
|
|
737
|
+
console.log(`\n${summary.join('\n')}\n`);
|
|
738
|
+
|
|
739
|
+
const { confirmed } = await prompts({
|
|
740
|
+
type: 'confirm',
|
|
741
|
+
name: 'confirmed',
|
|
742
|
+
message: chalk.yellow(
|
|
743
|
+
`⚠️ This will regenerate src/app/App.tsx and src/i18n.ts (preserving language-only changes). Continue?`
|
|
744
|
+
),
|
|
745
|
+
initial: true,
|
|
746
|
+
});
|
|
747
|
+
if (!confirmed) {
|
|
748
|
+
console.log(chalk.gray('Update cancelled.'));
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const spinner = ora('Updating languages...').start();
|
|
753
|
+
try {
|
|
754
|
+
// The freshly-installed library may not be present in this flow, so we
|
|
755
|
+
// read locale JSON sources from `node_modules/xertica-ui/templates`
|
|
756
|
+
// (installed when the project was created) — fallback to package
|
|
757
|
+
// directory lookup.
|
|
758
|
+
const installedTemplatesDir = path.join(
|
|
759
|
+
targetDir,
|
|
760
|
+
'node_modules',
|
|
761
|
+
'xertica-ui',
|
|
762
|
+
'templates'
|
|
763
|
+
);
|
|
764
|
+
const templatesSourceDir = (await fs.pathExists(installedTemplatesDir))
|
|
765
|
+
? installedTemplatesDir
|
|
766
|
+
: path.resolve(__dirname, '../templates');
|
|
767
|
+
|
|
768
|
+
// 1) Sync locale JSON files: copy newly-added, prune removed
|
|
769
|
+
const { copied, removed } = await syncLocaleFiles(templatesSourceDir, targetDir, newCodes, {
|
|
770
|
+
pruneOthers: true,
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
// 2) Regenerate i18n.ts so imports/resources reflect the new set
|
|
774
|
+
await fs.writeFile(path.join(targetDir, 'src', 'i18n.ts'), generateI18nFile(newCodes));
|
|
775
|
+
|
|
776
|
+
// 3) Regenerate App.tsx so the `availableLanguages` prop matches
|
|
777
|
+
await fs.writeFile(
|
|
778
|
+
path.join(targetDir, 'src', 'app', 'App.tsx'),
|
|
779
|
+
generateAppTsx(newCodes, currentConfig?.disableDarkMode ?? false)
|
|
780
|
+
);
|
|
781
|
+
|
|
782
|
+
// 4) Persist the new selection
|
|
783
|
+
await writeLanguagesConfig(targetDir, newCodes);
|
|
784
|
+
|
|
785
|
+
spinner.succeed('Languages updated successfully!');
|
|
786
|
+
|
|
787
|
+
if (copied.length > 0) console.log(chalk.green(` Copied: ${copied.join(', ')}`));
|
|
788
|
+
if (removed.length > 0) console.log(chalk.red(` Removed: ${removed.join(', ')}`));
|
|
789
|
+
if (newCodes.length === 1) {
|
|
790
|
+
console.log(
|
|
791
|
+
chalk.gray(` Project is now monolingual — the LanguageSelector will auto-hide.`)
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
} catch (error) {
|
|
795
|
+
spinner.fail('Failed to update languages');
|
|
796
|
+
console.error(error);
|
|
797
|
+
}
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// ── Assistant add / remove ────────────────────────────────────────────────
|
|
802
|
+
if (updateType === 'assistant') {
|
|
803
|
+
// Determine current state: prefer persisted config, fall back to file presence
|
|
804
|
+
// (handles projects scaffolded before .xertica.json existed).
|
|
805
|
+
let currentlyHas: boolean;
|
|
806
|
+
if (currentConfig !== null) {
|
|
807
|
+
currentlyHas = currentConfig.hasAssistant;
|
|
808
|
+
} else {
|
|
809
|
+
const assistantFeatureDir = path.join(targetDir, 'src', 'features', 'assistant');
|
|
810
|
+
const assistantPage = path.join(targetDir, 'src', 'pages', 'AssistantPage.tsx');
|
|
811
|
+
currentlyHas =
|
|
812
|
+
(await fs.pathExists(assistantFeatureDir)) || (await fs.pathExists(assistantPage));
|
|
813
|
+
// Persist the inferred state so future runs don't need to infer again
|
|
814
|
+
await writeXerticaConfig(targetDir, { hasAssistant: currentlyHas });
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
console.log(
|
|
818
|
+
chalk.cyan(
|
|
819
|
+
`\nAI Assistant is currently: ${currentlyHas ? chalk.green('enabled') : chalk.red('disabled')}\n`
|
|
820
|
+
)
|
|
821
|
+
);
|
|
822
|
+
|
|
823
|
+
const { action } = await prompts({
|
|
824
|
+
type: 'select',
|
|
825
|
+
name: 'action',
|
|
826
|
+
message: currentlyHas
|
|
827
|
+
? 'Remove the AI Assistant from your project?'
|
|
828
|
+
: 'Add the AI Assistant to your project?',
|
|
829
|
+
choices: currentlyHas
|
|
830
|
+
? [
|
|
831
|
+
{
|
|
832
|
+
title: 'Remove assistant',
|
|
833
|
+
description: 'Deletes AssistantPage and assistant feature files',
|
|
834
|
+
value: 'remove',
|
|
835
|
+
},
|
|
836
|
+
{ title: 'Cancel', value: 'cancel' },
|
|
837
|
+
]
|
|
838
|
+
: [
|
|
839
|
+
{
|
|
840
|
+
title: 'Add assistant',
|
|
841
|
+
description: 'Copies AssistantPage and assistant feature files',
|
|
842
|
+
value: 'add',
|
|
843
|
+
},
|
|
844
|
+
{ title: 'Cancel', value: 'cancel' },
|
|
845
|
+
],
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
if (!action || action === 'cancel') {
|
|
849
|
+
console.log(chalk.gray('Update cancelled.'));
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
const { confirmed } = await prompts({
|
|
854
|
+
type: 'confirm',
|
|
855
|
+
name: 'confirmed',
|
|
856
|
+
message: chalk.yellow(
|
|
857
|
+
action === 'remove'
|
|
858
|
+
? '⚠️ This will delete src/features/assistant/ and src/pages/AssistantPage.tsx and regenerate AuthGuard.tsx. Continue?'
|
|
859
|
+
: '⚠️ This will copy src/features/assistant/ and src/pages/AssistantPage.tsx and regenerate AuthGuard.tsx. Continue?'
|
|
860
|
+
),
|
|
861
|
+
initial: action === 'add',
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
if (!confirmed) {
|
|
865
|
+
console.log(chalk.gray('Update cancelled.'));
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
const spinner = ora(
|
|
870
|
+
action === 'add' ? 'Adding assistant...' : 'Removing assistant...'
|
|
871
|
+
).start();
|
|
872
|
+
|
|
873
|
+
try {
|
|
874
|
+
const installedTemplatesDir = path.join(
|
|
875
|
+
targetDir,
|
|
876
|
+
'node_modules',
|
|
877
|
+
'xertica-ui',
|
|
878
|
+
'templates'
|
|
879
|
+
);
|
|
880
|
+
const templatesSourceDir = (await fs.pathExists(installedTemplatesDir))
|
|
881
|
+
? installedTemplatesDir
|
|
882
|
+
: path.resolve(__dirname, '../templates');
|
|
883
|
+
|
|
884
|
+
// Infer current page set from the pages directory
|
|
885
|
+
const pagesDir = path.join(targetDir, 'src', 'pages');
|
|
886
|
+
const existingPages = (await fs.pathExists(pagesDir)) ? await fs.readdir(pagesDir) : [];
|
|
887
|
+
const hasLogin = existingPages.includes('LoginPage.tsx');
|
|
888
|
+
const hasHome = existingPages.includes('HomePage.tsx');
|
|
889
|
+
const hasTemplate = existingPages.includes('TemplatePage.tsx');
|
|
890
|
+
const firstProtectedPath = hasHome ? '/home' : hasTemplate ? '/template' : '/login';
|
|
891
|
+
|
|
892
|
+
// Read persisted language selection so AuthGuard can be regenerated correctly
|
|
893
|
+
const persistedCodes = await readLanguagesConfig(targetDir);
|
|
894
|
+
const selectedCodes =
|
|
895
|
+
persistedCodes && persistedCodes.length > 0 ? persistedCodes : DEFAULT_SELECTION;
|
|
896
|
+
|
|
897
|
+
if (action === 'add') {
|
|
898
|
+
// Copy assistant feature
|
|
899
|
+
await fs.copy(
|
|
900
|
+
path.join(templatesSourceDir, 'src', 'features', 'assistant'),
|
|
901
|
+
path.join(targetDir, 'src', 'features', 'assistant'),
|
|
902
|
+
{ overwrite: true }
|
|
903
|
+
);
|
|
904
|
+
// Copy AssistantPage
|
|
905
|
+
await fs.copy(
|
|
906
|
+
path.join(templatesSourceDir, 'src', 'pages', 'AssistantPage.tsx'),
|
|
907
|
+
path.join(targetDir, 'src', 'pages', 'AssistantPage.tsx'),
|
|
908
|
+
{ overwrite: true }
|
|
909
|
+
);
|
|
910
|
+
} else {
|
|
911
|
+
// Remove assistant feature
|
|
912
|
+
await fs.remove(path.join(targetDir, 'src', 'features', 'assistant'));
|
|
913
|
+
await fs.remove(path.join(targetDir, 'src', 'pages', 'AssistantPage.tsx'));
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Regenerate pages and AuthGuard reflecting the new assistant state
|
|
917
|
+
const newHasAssistant = action === 'add';
|
|
918
|
+
|
|
919
|
+
if (hasHome) {
|
|
920
|
+
await fs.writeFile(
|
|
921
|
+
path.join(targetDir, 'src', 'pages', 'HomePage.tsx'),
|
|
922
|
+
generateHomePage(newHasAssistant)
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
if (hasTemplate) {
|
|
926
|
+
await fs.writeFile(
|
|
927
|
+
path.join(targetDir, 'src', 'pages', 'TemplatePage.tsx'),
|
|
928
|
+
generateTemplatePage(newHasAssistant)
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
await fs.writeFile(
|
|
933
|
+
path.join(targetDir, 'src', 'app', 'components', 'AuthGuard.tsx'),
|
|
934
|
+
generateAuthGuard({
|
|
935
|
+
hasLogin,
|
|
936
|
+
hasHome,
|
|
937
|
+
hasTemplate,
|
|
938
|
+
hasAssistant: newHasAssistant,
|
|
939
|
+
firstProtectedPath,
|
|
940
|
+
})
|
|
941
|
+
);
|
|
942
|
+
|
|
943
|
+
// Persist the updated flag
|
|
944
|
+
await writeXerticaConfig(targetDir, { hasAssistant: newHasAssistant });
|
|
945
|
+
|
|
946
|
+
spinner.succeed(
|
|
947
|
+
action === 'add'
|
|
948
|
+
? 'AI Assistant added successfully!'
|
|
949
|
+
: 'AI Assistant removed successfully!'
|
|
950
|
+
);
|
|
951
|
+
|
|
952
|
+
if (action === 'add') {
|
|
953
|
+
console.log(chalk.gray('\n Route /assistente is now available.'));
|
|
954
|
+
console.log(chalk.gray(' Configure your Gemini API key in VITE_GEMINI_API_KEY.'));
|
|
955
|
+
} else {
|
|
956
|
+
console.log(chalk.gray('\n Assistant files removed and AuthGuard updated.'));
|
|
957
|
+
}
|
|
958
|
+
} catch (error) {
|
|
959
|
+
spinner.fail('Failed to update assistant');
|
|
960
|
+
console.error(error);
|
|
961
|
+
}
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// ── Dark Mode update (enable / disable) ──────────────────────────────────
|
|
966
|
+
if (updateType === 'darkmode') {
|
|
967
|
+
const currentlyDisabled = currentConfig?.disableDarkMode ?? false;
|
|
968
|
+
const { enableDarkMode } = await prompts({
|
|
969
|
+
type: 'confirm',
|
|
970
|
+
name: 'enableDarkMode',
|
|
971
|
+
message: currentlyDisabled
|
|
972
|
+
? 'Enable dark mode support in your project?'
|
|
973
|
+
: 'Disable dark mode support in your project? (This will hide the toggle and force light mode)',
|
|
974
|
+
initial: !currentlyDisabled,
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
if (enableDarkMode === undefined) return;
|
|
978
|
+
|
|
979
|
+
const newDisableDarkMode = !enableDarkMode;
|
|
980
|
+
|
|
981
|
+
const spinner = ora(
|
|
982
|
+
newDisableDarkMode ? 'Disabling dark mode...' : 'Enabling dark mode...'
|
|
983
|
+
).start();
|
|
984
|
+
try {
|
|
985
|
+
// Persist the selection
|
|
986
|
+
await writeXerticaConfig(targetDir, { disableDarkMode: newDisableDarkMode });
|
|
987
|
+
|
|
988
|
+
// Regenerate App.tsx with the new dark mode flag
|
|
989
|
+
const persistedCodes = await readLanguagesConfig(targetDir);
|
|
990
|
+
const selectedCodes =
|
|
991
|
+
persistedCodes && persistedCodes.length > 0 ? persistedCodes : DEFAULT_SELECTION;
|
|
992
|
+
|
|
993
|
+
await fs.writeFile(
|
|
994
|
+
path.join(targetDir, 'src', 'app', 'App.tsx'),
|
|
995
|
+
generateAppTsx(selectedCodes, newDisableDarkMode)
|
|
996
|
+
);
|
|
997
|
+
|
|
998
|
+
spinner.succeed(
|
|
999
|
+
newDisableDarkMode
|
|
1000
|
+
? 'Dark mode disabled successfully! (Locked to Light Mode)'
|
|
1001
|
+
: 'Dark mode enabled successfully!'
|
|
1002
|
+
);
|
|
1003
|
+
} catch (error) {
|
|
1004
|
+
spinner.fail('Failed to update dark mode configuration');
|
|
1005
|
+
console.error(error);
|
|
1006
|
+
}
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// ── Project files update ──────────────────────────────────────────────────
|
|
1011
|
+
const { versionType } = await prompts({
|
|
1012
|
+
type: 'select',
|
|
1013
|
+
name: 'versionType',
|
|
1014
|
+
message: 'Which version do you want to update to?',
|
|
1015
|
+
choices: [
|
|
1016
|
+
{ title: 'Latest', description: 'Install the latest published version', value: 'latest' },
|
|
1017
|
+
{
|
|
1018
|
+
title: 'Specific version',
|
|
1019
|
+
description: 'Enter a version number (e.g. 2.0.2)',
|
|
1020
|
+
value: 'specific',
|
|
1021
|
+
},
|
|
1022
|
+
],
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
if (!versionType) return;
|
|
1026
|
+
|
|
1027
|
+
let targetVersion = 'latest';
|
|
1028
|
+
if (versionType === 'specific') {
|
|
1029
|
+
const { version } = await prompts({
|
|
1030
|
+
type: 'text',
|
|
1031
|
+
name: 'version',
|
|
1032
|
+
message: 'Enter the version (e.g. 2.0.2):',
|
|
1033
|
+
validate: v =>
|
|
1034
|
+
/^\d+\.\d+\.\d+/.test(v.trim()) ? true : 'Enter a valid semver (e.g. 2.0.2)',
|
|
1035
|
+
});
|
|
1036
|
+
if (!version) return;
|
|
1037
|
+
targetVersion = version.trim();
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
const { filesToUpdate } = await prompts({
|
|
1041
|
+
type: 'multiselect',
|
|
1042
|
+
name: 'filesToUpdate',
|
|
1043
|
+
message: 'Select which parts of the project to update:',
|
|
1044
|
+
choices: [
|
|
1045
|
+
{
|
|
1046
|
+
title: 'App shell (src/app/)',
|
|
1047
|
+
description: 'App.tsx, AppLayout.tsx',
|
|
1048
|
+
value: 'app',
|
|
1049
|
+
selected: true,
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
title: 'Shared utilities (src/shared/)',
|
|
1053
|
+
description: 'auth.ts, navigation.ts, types',
|
|
1054
|
+
value: 'shared',
|
|
1055
|
+
selected: true,
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
title: 'Features (src/features/)',
|
|
1059
|
+
description: 'auth, home, template UI components',
|
|
1060
|
+
value: 'features',
|
|
1061
|
+
selected: true,
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
title: 'Pages (src/pages/)',
|
|
1065
|
+
description: 'Thin page wrapper components',
|
|
1066
|
+
value: 'pages',
|
|
1067
|
+
selected: true,
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
title: 'Root config files',
|
|
1071
|
+
description: 'vite.config.ts, tsconfig.json, etc.',
|
|
1072
|
+
value: 'config',
|
|
1073
|
+
selected: false,
|
|
1074
|
+
},
|
|
1075
|
+
],
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
if (!filesToUpdate || filesToUpdate.length === 0) return;
|
|
1079
|
+
|
|
1080
|
+
const { confirmed } = await prompts({
|
|
1081
|
+
type: 'confirm',
|
|
1082
|
+
name: 'confirmed',
|
|
1083
|
+
message: chalk.yellow(
|
|
1084
|
+
`⚠️ This will overwrite the selected files. Local changes will be lost. Continue?`
|
|
1085
|
+
),
|
|
1086
|
+
initial: false,
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
if (!confirmed) {
|
|
1090
|
+
console.log(chalk.gray('Update cancelled.'));
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
const spinner = ora(`Installing xertica-ui@${targetVersion}...`).start();
|
|
1095
|
+
|
|
1096
|
+
try {
|
|
1097
|
+
// Install the target version in the consumer project
|
|
1098
|
+
await execa('npm', ['install', `xertica-ui@${targetVersion}`], { cwd: targetDir });
|
|
1099
|
+
spinner.text = 'Copying updated files...';
|
|
1100
|
+
|
|
1101
|
+
// Templates now come from the freshly installed version
|
|
1102
|
+
const updatedTemplatesDir = path.join(targetDir, 'node_modules', 'xertica-ui', 'templates');
|
|
1103
|
+
|
|
1104
|
+
if (filesToUpdate.includes('app')) {
|
|
1105
|
+
// AppLayout is always safe to overwrite (no per-project config baked in)
|
|
1106
|
+
await fs.copy(
|
|
1107
|
+
path.join(updatedTemplatesDir, 'src', 'app', 'components', 'AppLayout.tsx'),
|
|
1108
|
+
path.join(targetDir, 'src', 'app', 'components', 'AppLayout.tsx'),
|
|
1109
|
+
{ overwrite: true }
|
|
1110
|
+
);
|
|
1111
|
+
|
|
1112
|
+
// For App.tsx and i18n.ts we must preserve the user's language selection.
|
|
1113
|
+
// Read it from .languages.json (or fall back to inspecting locales/ for
|
|
1114
|
+
// projects scaffolded before the file existed).
|
|
1115
|
+
const persistedCodes = await readLanguagesConfig(targetDir);
|
|
1116
|
+
let selectedCodes: string[] = persistedCodes ?? [];
|
|
1117
|
+
if (selectedCodes.length === 0) {
|
|
1118
|
+
const localesDir = path.join(targetDir, 'src', 'locales');
|
|
1119
|
+
if (await fs.pathExists(localesDir)) {
|
|
1120
|
+
const entries = await fs.readdir(localesDir);
|
|
1121
|
+
// Accept both the new folder layout and the legacy flat layout
|
|
1122
|
+
selectedCodes = SUPPORTED_LANGUAGES.filter(
|
|
1123
|
+
l => entries.includes(l.jsonFile) || entries.includes(`${l.jsonFile}.json`)
|
|
1124
|
+
).map(l => l.code);
|
|
1125
|
+
}
|
|
1126
|
+
if (selectedCodes.length === 0) selectedCodes = DEFAULT_SELECTION;
|
|
1127
|
+
// Persist the inferred selection so future updates have it cached
|
|
1128
|
+
await writeLanguagesConfig(targetDir, selectedCodes);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
const projectConfig = await readXerticaConfig(targetDir);
|
|
1132
|
+
|
|
1133
|
+
// Regenerate App.tsx and i18n.ts honoring the persisted language set
|
|
1134
|
+
await fs.writeFile(
|
|
1135
|
+
path.join(targetDir, 'src', 'app', 'App.tsx'),
|
|
1136
|
+
generateAppTsx(selectedCodes, projectConfig?.disableDarkMode ?? false)
|
|
1137
|
+
);
|
|
1138
|
+
await fs.writeFile(path.join(targetDir, 'src', 'i18n.ts'), generateI18nFile(selectedCodes));
|
|
1139
|
+
|
|
1140
|
+
// Refresh locale JSON files for the selected languages (keys grow over
|
|
1141
|
+
// library updates) — but prune any orphans from prior selections.
|
|
1142
|
+
await syncLocaleFiles(updatedTemplatesDir, targetDir, selectedCodes, {
|
|
1143
|
+
pruneOthers: true,
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// Regenerate AuthGuard preserving the current page set and assistant flag
|
|
1147
|
+
const pagesDir = path.join(targetDir, 'src', 'pages');
|
|
1148
|
+
const existingPages = (await fs.pathExists(pagesDir)) ? await fs.readdir(pagesDir) : [];
|
|
1149
|
+
const hasLoginP = existingPages.includes('LoginPage.tsx');
|
|
1150
|
+
const hasHomeP = existingPages.includes('HomePage.tsx');
|
|
1151
|
+
const hasTemplateP = existingPages.includes('TemplatePage.tsx');
|
|
1152
|
+
const hasAssistantP =
|
|
1153
|
+
projectConfig?.hasAssistant ?? existingPages.includes('AssistantPage.tsx');
|
|
1154
|
+
const firstProtectedP = hasHomeP ? '/home' : hasTemplateP ? '/template' : '/login';
|
|
1155
|
+
await fs.writeFile(
|
|
1156
|
+
path.join(targetDir, 'src', 'app', 'components', 'AuthGuard.tsx'),
|
|
1157
|
+
generateAuthGuard({
|
|
1158
|
+
hasLogin: hasLoginP,
|
|
1159
|
+
hasHome: hasHomeP,
|
|
1160
|
+
hasTemplate: hasTemplateP,
|
|
1161
|
+
hasAssistant: hasAssistantP,
|
|
1162
|
+
firstProtectedPath: firstProtectedP,
|
|
1163
|
+
})
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
if (filesToUpdate.includes('shared')) {
|
|
1168
|
+
await fs.copy(
|
|
1169
|
+
path.join(updatedTemplatesDir, 'src', 'shared'),
|
|
1170
|
+
path.join(targetDir, 'src', 'shared'),
|
|
1171
|
+
{ overwrite: true }
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
if (filesToUpdate.includes('features')) {
|
|
1176
|
+
// Only update feature directories that already exist in the project.
|
|
1177
|
+
// 'assistant' is only present if it was included during init (or added via update → Assistant).
|
|
1178
|
+
for (const feature of ['auth', 'home', 'template', 'assistant']) {
|
|
1179
|
+
const destFeature = path.join(targetDir, 'src', 'features', feature);
|
|
1180
|
+
const srcFeature = path.join(updatedTemplatesDir, 'src', 'features', feature);
|
|
1181
|
+
if ((await fs.pathExists(destFeature)) && (await fs.pathExists(srcFeature))) {
|
|
1182
|
+
await fs.copy(srcFeature, destFeature, { overwrite: true });
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
if (filesToUpdate.includes('pages')) {
|
|
1188
|
+
const pagesDir = path.join(targetDir, 'src', 'pages');
|
|
1189
|
+
const srcPagesDir = path.join(updatedTemplatesDir, 'src', 'pages');
|
|
1190
|
+
if ((await fs.pathExists(pagesDir)) && (await fs.pathExists(srcPagesDir))) {
|
|
1191
|
+
const projectCfg = await readXerticaConfig(targetDir);
|
|
1192
|
+
const existingPages = await fs.readdir(pagesDir);
|
|
1193
|
+
const assistantEnabled =
|
|
1194
|
+
projectCfg?.hasAssistant ?? existingPages.includes('AssistantPage.tsx');
|
|
1195
|
+
|
|
1196
|
+
for (const pageFile of existingPages) {
|
|
1197
|
+
// Generated pages: regenerate instead of copy so assistant imports stay correct
|
|
1198
|
+
if (pageFile === 'HomePage.tsx') {
|
|
1199
|
+
await fs.writeFile(
|
|
1200
|
+
path.join(pagesDir, 'HomePage.tsx'),
|
|
1201
|
+
generateHomePage(assistantEnabled)
|
|
1202
|
+
);
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
if (pageFile === 'TemplatePage.tsx') {
|
|
1206
|
+
await fs.writeFile(
|
|
1207
|
+
path.join(pagesDir, 'TemplatePage.tsx'),
|
|
1208
|
+
generateTemplatePage(assistantEnabled)
|
|
1209
|
+
);
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
const src = path.join(srcPagesDir, pageFile);
|
|
1213
|
+
if (await fs.pathExists(src)) {
|
|
1214
|
+
await fs.copy(src, path.join(pagesDir, pageFile), { overwrite: true });
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
if (filesToUpdate.includes('config')) {
|
|
1221
|
+
// Config files are inside the templates/ directory (same level as src/)
|
|
1222
|
+
const configFiles = [
|
|
1223
|
+
'vite.config.ts',
|
|
1224
|
+
'tsconfig.json',
|
|
1225
|
+
'tsconfig.node.json',
|
|
1226
|
+
'postcss.config.js',
|
|
1227
|
+
];
|
|
1228
|
+
for (const file of configFiles) {
|
|
1229
|
+
const src = path.join(updatedTemplatesDir, file);
|
|
1230
|
+
if (await fs.pathExists(src)) {
|
|
1231
|
+
await fs.copy(src, path.join(targetDir, file), { overwrite: true });
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
spinner.succeed(`Project updated to xertica-ui@${targetVersion} successfully!`);
|
|
1237
|
+
console.log(chalk.gray('\n Run npm run dev to start the development server.'));
|
|
1238
|
+
} catch (error) {
|
|
1239
|
+
spinner.fail('Failed to update project');
|
|
1240
|
+
console.error(error);
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
program.parse();
|