dana-cli 0.0.0-stage → 0.0.25
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/.github/dependabot.yml +43 -0
- package/.github/labeler.yml +30 -0
- package/.github/workflows/bump.yml +51 -0
- package/.github/workflows/ci-cd.yml +110 -0
- package/.github/workflows/dependabot-automerge-call.yml +13 -0
- package/.nvmrc +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc +4 -0
- package/CODEOWNERS +5 -0
- package/README.md +50 -2
- package/bin/bump.js +48 -0
- package/eslint.config.mjs +12 -0
- package/images/vodScreen1.png +0 -0
- package/package.json +53 -5
- package/sonar-project.properties +20 -0
- package/tools/cli/README.md +51 -0
- package/tools/cli/__mocks__/fs/promises.cjs +4 -0
- package/tools/cli/bin/dana.js +3 -0
- package/tools/cli/dana_completion.sh +156 -0
- package/tools/cli/eslint.config.mjs +14 -0
- package/tools/cli/package.json +66 -0
- package/tools/cli/rollup.config.mjs +26 -0
- package/tools/cli/src/commands/addComponent/addMenu/add-menu.ts +65 -0
- package/tools/cli/src/commands/addComponent/addMenu/addMenuDefinition.ts +21 -0
- package/tools/cli/src/commands/addComponent/addRail/add-rail.ts +59 -0
- package/tools/cli/src/commands/addComponent/addRail/addRailDefinition.ts +34 -0
- package/tools/cli/src/commands/addComponent/addScreen/add-screen.ts +42 -0
- package/tools/cli/src/commands/addComponent/addScreen/addScreenDefinition.ts +17 -0
- package/tools/cli/src/commands/addComponent/addScrollView/add-scrollView.ts +48 -0
- package/tools/cli/src/commands/addComponent/addScrollView/addScrollViewDefinition.ts +16 -0
- package/tools/cli/src/commands/addComponent/config/ComponentConfig.ts +169 -0
- package/tools/cli/src/commands/addComponent/config/componentTypes.ts +38 -0
- package/tools/cli/src/commands/addComponent/const/componentConst.ts +20 -0
- package/tools/cli/src/commands/addComponent/const/defaultConfig.ts +28 -0
- package/tools/cli/src/commands/addComponent/const/navigationConst.ts +36 -0
- package/tools/cli/src/commands/addComponent/createComponent.ts +45 -0
- package/tools/cli/src/commands/addComponent/helper/ComponentHelper.ts +98 -0
- package/tools/cli/src/commands/addDevice/add-device.ts +106 -0
- package/tools/cli/src/commands/addDevice/addDeviceDefinition.ts +13 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/androidtvConfig.ts +142 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/configTypes.ts +44 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/deviceConfig.ts +38 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/titanosConfig.ts +17 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/tizenConfig.ts +64 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/tvosConfig.ts +50 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/vidaaConfig.ts +17 -0
- package/tools/cli/src/commands/addDevice/deviceConfig/webosConfig.ts +64 -0
- package/tools/cli/src/commands/addDevice/helper/addDeviceHelper.ts +121 -0
- package/tools/cli/src/commands/addDianaSkills/add-dianaSkills.ts +55 -0
- package/tools/cli/src/commands/addDianaSkills/addDianaSkillsDefinition.ts +13 -0
- package/tools/cli/src/commands/addDianaSkills/dianaDependencies.ts +15 -0
- package/tools/cli/src/commands/addModule/add-module.ts +46 -0
- package/tools/cli/src/commands/addModule/addModuleDefinition.ts +17 -0
- package/tools/cli/src/commands/addModule/moduleConst.ts +18 -0
- package/tools/cli/src/commands/authentication/AuthenticationManager.ts +255 -0
- package/tools/cli/src/commands/authentication/authDefinition.ts +51 -0
- package/tools/cli/src/commands/authentication/authHook.ts +50 -0
- package/tools/cli/src/commands/authentication/authentConst.ts +6 -0
- package/tools/cli/src/commands/authentication/commands/get-packages-token.ts +40 -0
- package/tools/cli/src/commands/authentication/commands/login.ts +63 -0
- package/tools/cli/src/commands/authentication/commands/logout.ts +26 -0
- package/tools/cli/src/commands/authentication/commands/status.ts +47 -0
- package/tools/cli/src/commands/authentication/helper/CodeArtifactHelper.ts +66 -0
- package/tools/cli/src/commands/authentication/helper/CommandHelper.ts +9 -0
- package/tools/cli/src/commands/authentication/helper/CredentialsHelper.ts +176 -0
- package/tools/cli/src/commands/authentication/helper/SPM.ts +95 -0
- package/tools/cli/src/commands/authentication/tokenHook.ts +30 -0
- package/tools/cli/src/commands/commandHelp/customHelp.ts +31 -0
- package/tools/cli/src/commands/completion/completion.ts +53 -0
- package/tools/cli/src/commands/completion/completionDefinition.ts +16 -0
- package/tools/cli/src/commands/createApp/const/createAppTasks.ts +133 -0
- package/tools/cli/src/commands/createApp/const/setupConst.ts +16 -0
- package/tools/cli/src/commands/createApp/const/templateConst.ts +10 -0
- package/tools/cli/src/commands/createApp/createApp.ts +60 -0
- package/tools/cli/src/commands/createApp/createAppDefinition.ts +26 -0
- package/tools/cli/src/commands/createApp/helpers/CreateAppHelper.ts +167 -0
- package/tools/cli/src/commands/createApp/helpers/SetupChecker.ts +98 -0
- package/tools/cli/src/commands/hooks/checkDanaProjectHook.ts +30 -0
- package/tools/cli/src/commands/zip/zip.ts +26 -0
- package/tools/cli/src/commands/zip/zipDefinition.ts +13 -0
- package/tools/cli/src/common/commonConst.ts +1 -0
- package/tools/cli/src/common/const/deviceConst.ts +110 -0
- package/tools/cli/src/common/const/exitCodeConst.ts +12 -0
- package/tools/cli/src/common/helpers/CreateArchiveHelper.ts +55 -0
- package/tools/cli/src/common/helpers/CreateFileHelper.ts +199 -0
- package/tools/cli/src/common/helpers/InputValidator.ts +58 -0
- package/tools/cli/src/common/helpers/InstallHelper.ts +202 -0
- package/tools/cli/src/common/helpers/UpdateFileHelper.ts +239 -0
- package/tools/cli/src/common/helpers/UserInputGetter.ts +145 -0
- package/tools/cli/src/common/helpers/handlebarsHelper.ts +31 -0
- package/tools/cli/src/common/helpers/stringHelper.ts +25 -0
- package/tools/cli/src/common/translation/en.json +87 -0
- package/tools/cli/src/common/translation/translation.ts +6 -0
- package/tools/cli/src/common/types/helperTypes.ts +79 -0
- package/tools/cli/src/index.ts +16 -0
- package/tools/cli/src/program.ts +59 -0
- package/tools/cli/tests/commands/addComponent/addMenu/add-menu.test.ts +96 -0
- package/tools/cli/tests/commands/addComponent/addRail/add-rail.test.ts +57 -0
- package/tools/cli/tests/commands/addComponent/addScreen/add-screen.test.ts +55 -0
- package/tools/cli/tests/commands/addComponent/addScrollView/add-scrollView.test.ts +89 -0
- package/tools/cli/tests/commands/addComponent/config/ComponentConfig.test.ts +261 -0
- package/tools/cli/tests/commands/addComponent/createComponent.test.ts +87 -0
- package/tools/cli/tests/commands/addComponent/helper/ComponentHelper.test.ts +110 -0
- package/tools/cli/tests/commands/addDevice/add-device.test.ts +117 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/androidtvConfig.test.ts +184 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/deviceConfig.test.ts +30 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/titanosConfig.test.ts +20 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/tizenConfig.test.ts +63 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/tvosConfig.test.ts +47 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/vidaaConfig.test.ts +20 -0
- package/tools/cli/tests/commands/addDevice/deviceConfig/webosConfig.test.ts +74 -0
- package/tools/cli/tests/commands/addDevice/helper/addDeviceHelper.test.ts +144 -0
- package/tools/cli/tests/commands/addDianaSkills/add-dianaSkills.test.ts +72 -0
- package/tools/cli/tests/commands/addModule/add-module.test.ts +108 -0
- package/tools/cli/tests/commands/authentication/AuthenticationManager.test.ts +756 -0
- package/tools/cli/tests/commands/authentication/commands/authDefinition.test.ts +53 -0
- package/tools/cli/tests/commands/authentication/commands/authHook.test.ts +94 -0
- package/tools/cli/tests/commands/authentication/commands/get-packages-token.test.ts +69 -0
- package/tools/cli/tests/commands/authentication/commands/login.test.ts +170 -0
- package/tools/cli/tests/commands/authentication/commands/logout.test.ts +77 -0
- package/tools/cli/tests/commands/authentication/commands/status.test.ts +73 -0
- package/tools/cli/tests/commands/authentication/helper/CredentialsHelper.test.ts +352 -0
- package/tools/cli/tests/commands/authentication/helper/SPM.test.ts +229 -0
- package/tools/cli/tests/commands/cliHelp/customHelp.test.ts +24 -0
- package/tools/cli/tests/commands/completion/completion.test.ts +76 -0
- package/tools/cli/tests/commands/createApp/const/createAppTasks.test.ts +70 -0
- package/tools/cli/tests/commands/createApp/createApp.test.ts +116 -0
- package/tools/cli/tests/commands/createApp/helpers/CreateAppHelper.test.ts +197 -0
- package/tools/cli/tests/commands/createApp/helpers/SetupChecker.test.ts +152 -0
- package/tools/cli/tests/commands/createApp/helpers/fixtures/myApp/scripts/app/ui/screens/SplashScreen.js +70 -0
- package/tools/cli/tests/commands/hooks/checkDanaProjectHook.test.ts +55 -0
- package/tools/cli/tests/commands/zip/zip.test.ts +51 -0
- package/tools/cli/tests/common/helpers/CreateArchiveHelper.test.ts +69 -0
- package/tools/cli/tests/common/helpers/CreateFileHelper.test.ts +359 -0
- package/tools/cli/tests/common/helpers/InputValidator.test.ts +93 -0
- package/tools/cli/tests/common/helpers/InstallHelper.test.ts +262 -0
- package/tools/cli/tests/common/helpers/UpdateFileHelper.test.ts +288 -0
- package/tools/cli/tests/common/helpers/UserInputGetter.test.ts +182 -0
- package/tools/cli/tests/common/helpers/handlebarsHelper.test.ts +87 -0
- package/tools/cli/tests/common/helpers/stringHelper.test.ts +35 -0
- package/tools/cli/tests/program.test.ts +215 -0
- package/tools/cli/tsconfig.json +19 -0
- package/tools/cli/tsconfig.test.json +4 -0
- package/tools/cli/vitest.config.ts +4 -0
- package/tools/templates/app-template/.dana/.gitkeep +0 -0
- package/tools/templates/app-template/Gruntfile.js +31 -0
- package/tools/templates/app-template/README.md +17 -0
- package/tools/templates/app-template/app.config.json +56 -0
- package/tools/templates/app-template/editorconfigTemplate.hbs +18 -0
- package/tools/templates/app-template/eslintrc.jsonTemplate.hbs +5 -0
- package/tools/templates/app-template/gitignoreTemplate.hbs +27 -0
- package/tools/templates/app-template/i18n/LocaleStringEnUS.json +7 -0
- package/tools/templates/app-template/i18n/README.md +32 -0
- package/tools/templates/app-template/images/dana.png +0 -0
- package/tools/templates/app-template/images/dana_logo.png +0 -0
- package/tools/templates/app-template/images/dana_logo_light.png +0 -0
- package/tools/templates/app-template/images/loading.png +0 -0
- package/tools/templates/app-template/nvmrcTemplate.hbs +1 -0
- package/tools/templates/app-template/package.json +33 -0
- package/tools/templates/app-template/profiles/app.config.browser-css.json +16 -0
- package/tools/templates/app-template/profiles/app.config.browser-lightning.json +16 -0
- package/tools/templates/app-template/scripts/app/README.md +6 -0
- package/tools/templates/app-template/scripts/app/TemplateAppRoutes.js.hbs +18 -0
- package/tools/templates/app-template/scripts/app/app.js.hbs +17 -0
- package/tools/templates/app-template/scripts/app/theme/AppTheme.js +57 -0
- package/tools/templates/app-template/scripts/app/ui/screens/AppScreen.js +106 -0
- package/tools/templates/app-template/scripts/app/ui/screens/SplashScreen.js +70 -0
- package/tools/templates/app-template/scripts/app/ui/views/LoaderView.js +31 -0
- package/tools/templates/app-template/styles/fonts/Roboto-Bold.ttf +0 -0
- package/tools/templates/app-template/styles/fonts/Roboto-Regular.ttf +0 -0
- package/tools/templates/app-template/tests/README.md +70 -0
- package/tools/templates/app-template/tests/automation/features/splash.feature +5 -0
- package/tools/templates/app-template/tests/automation/init.js +20 -0
- package/tools/templates/app-template/tests/automation/steps-definitions/dictionary.js +31 -0
- package/tools/templates/app-template/tests/automation/steps-definitions/helpers.js +9 -0
- package/tools/templates/app-template/tests/unit/README.md +7 -0
- package/tools/templates/app-template/tests/unit/app/TemplateAppRoutes.js.hbs +24 -0
- package/tools/templates/assets/fonts/fa-solid-900.ttf +0 -0
- package/tools/templates/components/ButtonItemView.js.hbs +69 -0
- package/tools/templates/components/ButtonView.js.hbs +65 -0
- package/tools/templates/components/ScrollItemView.js.hbs +53 -0
- package/tools/templates/components/ScrollView.js.hbs +43 -0
- package/tools/templates/components/TileView.js.hbs +55 -0
- package/tools/templates/components/screen.js.hbs +74 -0
- package/tools/templates/components/settings.js.hbs +74 -0
- package/tools/templates/components/vod.js.hbs +104 -0
- package/tools/templates/components/wtvMenuListView.js.hbs +38 -0
- package/tools/templates/components/wtvRailListView.js.hbs +44 -0
- package/tools/templates/index.ts +3 -0
- package/tools/templates/mocks/menuMock.json +29 -0
- package/tools/templates/mocks/railMock.json +101 -0
- package/tools/templates/mocks/scrollViewMock.json +165 -0
- package/tools/templates/modules/fip/images/12.png +0 -0
- package/tools/templates/modules/fip/images/audioD.png +0 -0
- package/tools/templates/modules/fip/package.json +5 -0
- package/tools/templates/modules/fip/scripts/FipModule.js +19 -0
- package/tools/templates/modules/fip/scripts/FipRoutes.js +19 -0
- package/tools/templates/modules/fip/scripts/services/mock/fipMock.json +12 -0
- package/tools/templates/modules/fip/scripts/ui/screens/FipScreen.js +169 -0
- package/tools/templates/modules/fip/scripts/ui/views/FipContentInfoView.js +77 -0
- package/tools/templates/modules/fip/scripts/ui/views/InfoDetailImageView.js +35 -0
- package/tools/templates/modules/fip/scripts/ui/views/InfoDetailTextView.js +39 -0
- package/tools/templates/modules/fip/scripts/ui/views/InfoListView.js +57 -0
- package/tools/templates/modules/fip/scripts/ui/views/PlayButtonView.js +63 -0
- package/tools/templates/modules/home/package.json +5 -0
- package/tools/templates/modules/home/scripts/HomeModule.js +19 -0
- package/tools/templates/modules/home/scripts/HomeRoutes.js +19 -0
- package/tools/templates/modules/home/scripts/services/mock/highlightMock.json +40 -0
- package/tools/templates/modules/home/scripts/services/mock/homeScrollViewMock.json +170 -0
- package/tools/templates/modules/home/scripts/ui/screens/HomeScreen.js +258 -0
- package/tools/templates/modules/home/scripts/ui/views/highlight/DotsListItemView.js +37 -0
- package/tools/templates/modules/home/scripts/ui/views/highlight/DotsListView.js +22 -0
- package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightContentDescriptionView.js +99 -0
- package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightPlayButtonView.js +63 -0
- package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightRailItemView.js +186 -0
- package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeMockTileView.js +67 -0
- package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeRailScrollView.js +53 -0
- package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeScrollView.js +22 -0
- package/tools/templates/modules/menu/images/profile.png +0 -0
- package/tools/templates/modules/menu/package.json +5 -0
- package/tools/templates/modules/menu/scripts/MenuModule.js +18 -0
- package/tools/templates/modules/menu/scripts/MenuRoutes.js +14 -0
- package/tools/templates/modules/menu/scripts/services/menuMock.json +24 -0
- package/tools/templates/modules/menu/scripts/ui/const/MenuIcons.js +16 -0
- package/tools/templates/modules/menu/scripts/ui/views/MenuButtonView.js +101 -0
- package/tools/templates/modules/menu/scripts/ui/views/MenuListView.js +60 -0
- package/tools/templates/modules/menu/scripts/ui/views/MenuView.js +87 -0
- package/tools/templates/modules/menu/scripts/ui/views/ProfileImageView.js +30 -0
- package/tools/templates/modules/player/package.json +5 -0
- package/tools/templates/modules/player/scripts/PlayerModule.js +19 -0
- package/tools/templates/modules/player/scripts/PlayerRoutes.js +19 -0
- package/tools/templates/modules/player/scripts/ui/const/PlayerIcons.js +19 -0
- package/tools/templates/modules/player/scripts/ui/screens/PlayerScreen.js +361 -0
- package/tools/templates/modules/player/scripts/ui/views/PlayerControlButtonView.js +69 -0
- package/tools/templates/modules/player/scripts/ui/views/PlayerControlsView.js +173 -0
- package/tools/templates/modules/player/scripts/ui/views/ProgressBarView.js +53 -0
- package/tools/templates/modules/search/package.json +5 -0
- package/tools/templates/modules/search/scripts/SearchModule.js +18 -0
- package/tools/templates/modules/search/scripts/SearchRoutes.js +16 -0
- package/tools/templates/modules/search/scripts/ui/const/EnglishKeyboardData.js +31 -0
- package/tools/templates/modules/search/scripts/ui/const/SearchIcons.js +14 -0
- package/tools/templates/modules/search/scripts/ui/const/SearchKeyboardLayout.js +19 -0
- package/tools/templates/modules/search/scripts/ui/primitives/SearchTextPrimitive.js +36 -0
- package/tools/templates/modules/search/scripts/ui/screens/SearchScreen.js +234 -0
- package/tools/templates/modules/search/scripts/ui/services/MockSearchService.js +39 -0
- package/tools/templates/modules/search/scripts/ui/services/SearchVirtualKeyboardService.js +33 -0
- package/tools/templates/modules/search/scripts/ui/services/mock/searchMock.json +172 -0
- package/tools/templates/modules/search/scripts/ui/views/SearchView.js +62 -0
- package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardRowItemView.js +92 -0
- package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardRowListView.js +33 -0
- package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardView.js +63 -0
- package/tools/templates/modules/search/scripts/ui/views/rail/SearchScrollRailView.js +53 -0
- package/tools/templates/modules/search/scripts/ui/views/rail/SearchScrollView.js +22 -0
- package/tools/templates/modules/search/scripts/ui/views/rail/SearchTileView.js +68 -0
- package/tools/templates/modules/search/styles/styles/fonts/fa-solid-900.ttf +0 -0
- package/tools/templates/modules/settings/package.json +5 -0
- package/tools/templates/modules/settings/scripts/SettingsModule.js +19 -0
- package/tools/templates/modules/settings/scripts/SettingsRoutes.js +19 -0
- package/tools/templates/modules/settings/scripts/ui/screens/SettingsScreen.js +200 -0
- package/tools/templates/modules/settings/scripts/ui/views/SettingsListItemView.js +85 -0
- package/tools/templates/modules/settings/scripts/ui/views/SettingsListView.js +56 -0
- package/tools/templates/modules/vod/package.json +5 -0
- package/tools/templates/modules/vod/scripts/VodModule.js +19 -0
- package/tools/templates/modules/vod/scripts/VodRoutes.js +19 -0
- package/tools/templates/modules/vod/scripts/services/mock/scrollViewMock.json +172 -0
- package/tools/templates/modules/vod/scripts/ui/screens/VodScreen.js +204 -0
- package/tools/templates/modules/vod/scripts/ui/views/MockTileView.js +69 -0
- package/tools/templates/modules/vod/scripts/ui/views/RailScrollItemView.js +53 -0
- package/tools/templates/modules/vod/scripts/ui/views/VodScrollView.js +22 -0
- package/tools/templates/package.json +14 -0
- package/tools/templates/profiles/app.config.androidtv.json +17 -0
- package/tools/templates/profiles/app.config.titanos.json +24 -0
- package/tools/templates/profiles/app.config.tizen.json +52 -0
- package/tools/templates/profiles/app.config.tvos.json +18 -0
- package/tools/templates/profiles/app.config.vidaa.json +24 -0
- package/tools/templates/profiles/app.config.webos.json +21 -0
- package/tools/templates/tutorial/modules/fip/package.json +4 -0
- package/tools/templates/tutorial/modules/fip/scripts/FipModule.js +18 -0
- package/tools/templates/tutorial/modules/fip/scripts/FipRoutes.js +19 -0
- package/tools/templates/tutorial/modules/fip/scripts/ui/screens/FipContentScreen.js +146 -0
- package/tools/templates/tutorial/modules/fip/scripts/ui/views/ElevatorView.js +66 -0
- package/tools/templates/tutorial/modules/fip/scripts/ui/views/FipContentInfoView.js +90 -0
- package/tools/templates/tutorial/modules/fip/scripts/ui/views/PlayButtonView.js +58 -0
- package/tools/templates/tutorial/vendors/customBE/package.json +5 -0
- package/tools/templates/tutorial/vendors/customBE/scripts/datas/contents.json +749 -0
- package/tools/templates/tutorial/vendors/customBE/scripts/services/CustomBEVodService.js +70 -0
- package/tsconfig.json +8 -0
- package/vitest.config.ts +19 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
+
* All Rights Reserved
|
|
4
|
+
*
|
|
5
|
+
* All information contained herein is proprietary and confidential.
|
|
6
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
+
* prior written permission is obtained from Wiztivi.
|
|
8
|
+
* No warranty, explicit or implicit, provided.
|
|
9
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as prompts from "@clack/prompts";
|
|
14
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
15
|
+
import { DIRECTION_TYPES, NAVIGATION_TYPES } from "@/commands/addComponent/const/navigationConst.js";
|
|
16
|
+
import { CANCEL } from "@/common/const/exitCodeConst.js";
|
|
17
|
+
import { validInputLength, validNumber } from "@/common/helpers/InputValidator.js";
|
|
18
|
+
import { RailConfig, MenuConfig, ScreenConfig, ScrollViewConfig } from "./componentTypes.js";
|
|
19
|
+
import {
|
|
20
|
+
RAIL_DEFAULT_CONFIG,
|
|
21
|
+
MENU_DEFAULT_CONFIG,
|
|
22
|
+
SCROLLVIEW_DEFAULT_CONFIG,
|
|
23
|
+
} from "@/commands/addComponent/const/defaultConfig.js";
|
|
24
|
+
import { ConfigOptions, OptionList } from "@/common/types/helperTypes.js";
|
|
25
|
+
import { capitalizeFirstLetter } from "@/common/helpers/stringHelper.js";
|
|
26
|
+
|
|
27
|
+
interface AskComponentParam {
|
|
28
|
+
componentOption: string;
|
|
29
|
+
optionList: OptionList;
|
|
30
|
+
optionType: string;
|
|
31
|
+
}
|
|
32
|
+
type DefaultConfig = RailConfig | MenuConfig | ScrollViewConfig;
|
|
33
|
+
|
|
34
|
+
const ComponentConfig = class {
|
|
35
|
+
/**
|
|
36
|
+
* Get component or element name from user
|
|
37
|
+
*/
|
|
38
|
+
static readonly askName = async (componentType: string, name?: string): Promise<string> => {
|
|
39
|
+
if (!name) {
|
|
40
|
+
const errorMessage = `${componentType} name is mandatory !`;
|
|
41
|
+
name = (await prompts.text({
|
|
42
|
+
message: `${componentType} name`,
|
|
43
|
+
placeholder: "Placeholder Name",
|
|
44
|
+
validate: (value) => validInputLength(errorMessage, value),
|
|
45
|
+
})) as string;
|
|
46
|
+
ComponentHelper.handleCancellation(name);
|
|
47
|
+
}
|
|
48
|
+
return name.trim();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
static readonly askNumber = async (valueType: string, numberValue?: number): Promise<number> => {
|
|
52
|
+
const errorMessage = `${valueType} should be a number`;
|
|
53
|
+
const basicMessage = `Enter a value for ${valueType}`;
|
|
54
|
+
const message =
|
|
55
|
+
numberValue && Number.isNaN(numberValue) ? `${numberValue} is not a number. ${basicMessage}` : basicMessage;
|
|
56
|
+
if (!numberValue || Number.isNaN(numberValue)) {
|
|
57
|
+
const numberValue = (await prompts.text({
|
|
58
|
+
message,
|
|
59
|
+
placeholder: "00",
|
|
60
|
+
validate: (value): string => validNumber(value!, errorMessage),
|
|
61
|
+
})) as string;
|
|
62
|
+
ComponentHelper.handleCancellation(numberValue);
|
|
63
|
+
return +numberValue;
|
|
64
|
+
}
|
|
65
|
+
return numberValue;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Generic function to get option value from command line or user input
|
|
69
|
+
* @param allData
|
|
70
|
+
* @param allData.componentOption - option from command line
|
|
71
|
+
* @param allData.optionList - list of all possible values for the option
|
|
72
|
+
* @param allData.optionType - option type to be used in all prompt messages
|
|
73
|
+
*/
|
|
74
|
+
static readonly askComponentOption = async (dataOption: AskComponentParam): Promise<string> => {
|
|
75
|
+
const { componentOption, optionList, optionType } = dataOption;
|
|
76
|
+
let finalOption = ComponentHelper.checkOption(componentOption, optionList, optionType);
|
|
77
|
+
if (!finalOption) {
|
|
78
|
+
const selectionMessage = `${capitalizeFirstLetter(optionType)} option`;
|
|
79
|
+
finalOption = await ComponentHelper.selectionFactory(optionType, optionList, selectionMessage);
|
|
80
|
+
}
|
|
81
|
+
return finalOption;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
static readonly askCyclic = async (data: ConfigOptions): Promise<boolean> => {
|
|
85
|
+
if (!data.cyclic) {
|
|
86
|
+
const cyclic = (await prompts.confirm({
|
|
87
|
+
message: "Cyclic list ?",
|
|
88
|
+
})) as boolean;
|
|
89
|
+
ComponentHelper.handleCancellation(cyclic);
|
|
90
|
+
return cyclic;
|
|
91
|
+
}
|
|
92
|
+
return data.cyclic;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
static readonly handlePromptCancel = () => {
|
|
96
|
+
prompts.cancel("Operation cancelled.");
|
|
97
|
+
process.exit(CANCEL);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
static readonly getDefaultConfig = <T extends DefaultConfig>(data: ConfigOptions, defaultConfig: T): T => {
|
|
101
|
+
return { ...defaultConfig, ...data, addMock: !data.custom };
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
static readonly railConfig = async (data: ConfigOptions): Promise<RailConfig> => {
|
|
105
|
+
const config: RailConfig = ComponentConfig.getDefaultConfig(data, RAIL_DEFAULT_CONFIG);
|
|
106
|
+
|
|
107
|
+
const customConfig = await prompts.group(
|
|
108
|
+
{
|
|
109
|
+
name: async () => await this.askName("rail", data.name),
|
|
110
|
+
navigation: async () =>
|
|
111
|
+
await this.askComponentOption({
|
|
112
|
+
componentOption: data.navigation,
|
|
113
|
+
optionList: NAVIGATION_TYPES,
|
|
114
|
+
optionType: "navigation",
|
|
115
|
+
}),
|
|
116
|
+
direction: async () =>
|
|
117
|
+
await this.askComponentOption({
|
|
118
|
+
componentOption: data.direction,
|
|
119
|
+
optionList: DIRECTION_TYPES,
|
|
120
|
+
optionType: "direction",
|
|
121
|
+
}),
|
|
122
|
+
isCyclic: async () => await this.askCyclic(data),
|
|
123
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
124
|
+
},
|
|
125
|
+
{ onCancel: () => ComponentConfig.handlePromptCancel() },
|
|
126
|
+
);
|
|
127
|
+
return { ...config, ...customConfig };
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
static readonly menuConfig = async (data: ConfigOptions) => {
|
|
131
|
+
const config: MenuConfig = ComponentConfig.getDefaultConfig(data, MENU_DEFAULT_CONFIG);
|
|
132
|
+
const customConfig = await prompts.group(
|
|
133
|
+
{
|
|
134
|
+
name: async () => await this.askName("menu", data.name),
|
|
135
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
136
|
+
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
137
|
+
direction: async () =>
|
|
138
|
+
await this.askComponentOption({
|
|
139
|
+
componentOption: data.direction,
|
|
140
|
+
optionList: DIRECTION_TYPES,
|
|
141
|
+
optionType: "direction",
|
|
142
|
+
}),
|
|
143
|
+
},
|
|
144
|
+
{ onCancel: () => ComponentConfig.handlePromptCancel() },
|
|
145
|
+
);
|
|
146
|
+
return { ...config, ...customConfig };
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
static readonly scrollViewConfig = async (data: ConfigOptions) => {
|
|
150
|
+
const config: ScrollViewConfig = ComponentConfig.getDefaultConfig(data, SCROLLVIEW_DEFAULT_CONFIG);
|
|
151
|
+
const customConfig = await prompts.group(
|
|
152
|
+
{
|
|
153
|
+
name: async () => await this.askName("scrollView", data.name),
|
|
154
|
+
itemView: async () => await this.askName("itemView", data.itemView),
|
|
155
|
+
itemMargin: async () => await this.askNumber("item margin", data.itemMargin),
|
|
156
|
+
},
|
|
157
|
+
{ onCancel: () => ComponentConfig.handlePromptCancel() },
|
|
158
|
+
);
|
|
159
|
+
return { ...config, ...customConfig };
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
static readonly screenConfig = async (data: ConfigOptions): Promise<ScreenConfig> => {
|
|
163
|
+
return {
|
|
164
|
+
name: data.name ?? (await this.askName("screen")),
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default ComponentConfig;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface RailConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
navigation: string;
|
|
4
|
+
direction: string;
|
|
5
|
+
isCyclic: boolean;
|
|
6
|
+
itemView: string;
|
|
7
|
+
addMock: boolean;
|
|
8
|
+
type: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DefaultConfig {
|
|
12
|
+
type: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MenuConfig {
|
|
16
|
+
name: string;
|
|
17
|
+
itemView: string;
|
|
18
|
+
itemMargin: number;
|
|
19
|
+
direction: string;
|
|
20
|
+
addMock?: boolean;
|
|
21
|
+
type: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ScrollViewConfig {
|
|
26
|
+
name: string;
|
|
27
|
+
itemView: string;
|
|
28
|
+
itemMargin: number;
|
|
29
|
+
addMock?: boolean;
|
|
30
|
+
custom?: boolean;
|
|
31
|
+
type?: string;
|
|
32
|
+
path?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ScreenConfig {
|
|
36
|
+
name: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
+
* All Rights Reserved
|
|
4
|
+
*
|
|
5
|
+
* All information contained herein is proprietary and confidential.
|
|
6
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
+
* prior written permission is obtained from Wiztivi.
|
|
8
|
+
* No warranty, explicit or implicit, provided.
|
|
9
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const MENU = "wtvMenuListView";
|
|
14
|
+
export const RAIL = "wtvRailListView";
|
|
15
|
+
export const TILE_VIEW = "tileView";
|
|
16
|
+
export const SCROLL_VIEW = "scrollView";
|
|
17
|
+
export const SCROLL_ITEM = "scrollItemView";
|
|
18
|
+
export const BUTTON_ITEM_VIEW = "ButtonItemView";
|
|
19
|
+
export const SCREEN = "screen";
|
|
20
|
+
export const VOD_SCREEN = "vod";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MenuConfig, RailConfig, ScrollViewConfig } from "@/commands/addComponent/config/componentTypes.js";
|
|
2
|
+
import { MENU, SCROLL_VIEW, RAIL } from "./componentConst.js";
|
|
3
|
+
|
|
4
|
+
export const RAIL_DEFAULT_CONFIG: RailConfig = {
|
|
5
|
+
navigation: "FixedNavigationType",
|
|
6
|
+
isCyclic: false,
|
|
7
|
+
direction: "horizontal",
|
|
8
|
+
name: "mockRail",
|
|
9
|
+
itemView: "mockTile",
|
|
10
|
+
type: RAIL,
|
|
11
|
+
addMock: true,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const MENU_DEFAULT_CONFIG: MenuConfig = {
|
|
15
|
+
name: "mockMenu",
|
|
16
|
+
itemMargin: 20,
|
|
17
|
+
itemView: "ButtonItem",
|
|
18
|
+
direction: "horizontal",
|
|
19
|
+
addMock: true,
|
|
20
|
+
type: MENU,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const SCROLLVIEW_DEFAULT_CONFIG: ScrollViewConfig = {
|
|
24
|
+
name: "mock",
|
|
25
|
+
itemMargin: 550,
|
|
26
|
+
itemView: "Rail",
|
|
27
|
+
type: SCROLL_VIEW,
|
|
28
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import colors from "picocolors";
|
|
2
|
+
import { OptionList } from "@/common/types/helperTypes.js";
|
|
3
|
+
|
|
4
|
+
export const NAVIGATION_TYPES: OptionList = [
|
|
5
|
+
{
|
|
6
|
+
value: "MFixedNavigationType",
|
|
7
|
+
label: colors.bold("Fixed. ") + "Focus is fixed on the left side of the list.",
|
|
8
|
+
command: "fixed",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
value: "MLMRNavigationType",
|
|
12
|
+
label:
|
|
13
|
+
colors.bold("Left-Middle-Right. ") +
|
|
14
|
+
"Focus starts on the left side, then moves and stays to the middle, then goes to the right side when the list ends",
|
|
15
|
+
command: "lmr",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "MLRNavigationType",
|
|
19
|
+
label:
|
|
20
|
+
colors.bold("Left-Right. ") +
|
|
21
|
+
" Focus moves in the chosen direction to the edge of the list. Then the list scrolls to show the next items.",
|
|
22
|
+
command: "lr",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "MPaginateNavigationType",
|
|
26
|
+
label:
|
|
27
|
+
colors.bold("Paginated. ") +
|
|
28
|
+
" Focus moves to the end of the visible items. Then, all items are replaced by new ones.",
|
|
29
|
+
command: "paginated",
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const DIRECTION_TYPES: OptionList = [
|
|
34
|
+
{ value: `HORIZONTAL`, label: "HORIZONTAL", command: "h" },
|
|
35
|
+
{ value: `VERTICAL`, label: "VERTICAL", command: "v" },
|
|
36
|
+
];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
+
* All Rights Reserved
|
|
4
|
+
*
|
|
5
|
+
* All information contained herein is proprietary and confidential.
|
|
6
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
+
* prior written permission is obtained from Wiztivi.
|
|
8
|
+
* No warranty, explicit or implicit, provided.
|
|
9
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import ComponentHelper from "./helper/ComponentHelper.js";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { writeFile } from "node:fs/promises";
|
|
16
|
+
import { templateGenerator } from "@/common/helpers/handlebarsHelper.js";
|
|
17
|
+
import { ConfigOptions } from "@/common/types/helperTypes.js";
|
|
18
|
+
import * as prompts from "@clack/prompts";
|
|
19
|
+
import { COMPONENT_ERROR } from "@/common/const/exitCodeConst.js";
|
|
20
|
+
import translation from "@/common/translation/translation.js";
|
|
21
|
+
|
|
22
|
+
const createSingleComponent = async (data: ConfigOptions, modulePath: string) => {
|
|
23
|
+
try {
|
|
24
|
+
const templatePath = path.join(path.dirname(modulePath), "components", `${data.type}.js.hbs`);
|
|
25
|
+
const output = await templateGenerator(templatePath, data);
|
|
26
|
+
const finalPath = path.resolve(data.path, ComponentHelper.normalizeFileName(data.type, data.name));
|
|
27
|
+
await writeFile(finalPath, output, { encoding: "utf-8" });
|
|
28
|
+
prompts.log.success(`${data.name} ${translation["component.creation.success"]}`);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
const simpleMessage = `Failed to create component ${data.name}`;
|
|
31
|
+
const message = e instanceof Error ? `${simpleMessage}: ${e.message}` : simpleMessage;
|
|
32
|
+
prompts.log.error(message);
|
|
33
|
+
process.exit(COMPONENT_ERROR);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const createComponent = async (componentList: ConfigOptions[]) => {
|
|
38
|
+
const modulePath = ComponentHelper.getTemplatePath();
|
|
39
|
+
|
|
40
|
+
for (const data of componentList) {
|
|
41
|
+
await createSingleComponent(data, modulePath);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default createComponent;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
+
* All Rights Reserved
|
|
4
|
+
*
|
|
5
|
+
* All information contained herein is proprietary and confidential.
|
|
6
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
+
* prior written permission is obtained from Wiztivi.
|
|
8
|
+
* No warranty, explicit or implicit, provided.
|
|
9
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as prompts from "@clack/prompts";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import {
|
|
16
|
+
RAIL,
|
|
17
|
+
MENU,
|
|
18
|
+
TILE_VIEW,
|
|
19
|
+
SCREEN,
|
|
20
|
+
SCROLL_VIEW,
|
|
21
|
+
SCROLL_ITEM,
|
|
22
|
+
VOD_SCREEN,
|
|
23
|
+
BUTTON_ITEM_VIEW,
|
|
24
|
+
} from "@/commands/addComponent/const/componentConst.js";
|
|
25
|
+
import { capitalizeFirstLetter } from "@/common/helpers/stringHelper.js";
|
|
26
|
+
import { CANCEL } from "@/common/const/exitCodeConst.js";
|
|
27
|
+
import { OptionList, SelectionArray } from "@/common/types/helperTypes.js";
|
|
28
|
+
import { TEMPLATE_MODULE } from "@/common/commonConst.js";
|
|
29
|
+
import { fileURLToPath } from "node:url";
|
|
30
|
+
|
|
31
|
+
const ComponentHelper = class {
|
|
32
|
+
static readonly selectionFactory = async (
|
|
33
|
+
name: string,
|
|
34
|
+
options: SelectionArray,
|
|
35
|
+
message: string,
|
|
36
|
+
): Promise<string> => {
|
|
37
|
+
options = options.map((el) => {
|
|
38
|
+
return { value: el.value, label: el.label };
|
|
39
|
+
});
|
|
40
|
+
const result = (await prompts.select({
|
|
41
|
+
message,
|
|
42
|
+
options,
|
|
43
|
+
})) as string;
|
|
44
|
+
ComponentHelper.handleCancellation(name);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
static readonly checkOption = (option: string, optionList: OptionList, title: string) => {
|
|
49
|
+
if (!option) {
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const found = optionList.find((o) => o.command === option);
|
|
54
|
+
if (found) {
|
|
55
|
+
return found.value;
|
|
56
|
+
}
|
|
57
|
+
prompts.log.info(`"${option}" does not match any ${title} option. Please select one below:`);
|
|
58
|
+
return "";
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
static readonly normalizeFileName = (type: string, name: string): string => {
|
|
62
|
+
const uppercaseName = capitalizeFirstLetter(name);
|
|
63
|
+
switch (type) {
|
|
64
|
+
case RAIL:
|
|
65
|
+
case MENU:
|
|
66
|
+
return `${uppercaseName}ListView.js`;
|
|
67
|
+
case TILE_VIEW:
|
|
68
|
+
return `${uppercaseName}ListItemView.js`;
|
|
69
|
+
case SCROLL_VIEW:
|
|
70
|
+
return `${uppercaseName}ScrollView.js`;
|
|
71
|
+
case SCROLL_ITEM:
|
|
72
|
+
return `${uppercaseName}ScrollItemView.js`;
|
|
73
|
+
case SCREEN:
|
|
74
|
+
case VOD_SCREEN:
|
|
75
|
+
return `${uppercaseName}Screen.js`;
|
|
76
|
+
case BUTTON_ITEM_VIEW:
|
|
77
|
+
return `${uppercaseName}View.js`;
|
|
78
|
+
default:
|
|
79
|
+
return `${uppercaseName}.js`;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Manage cancellation with CTRL+C
|
|
85
|
+
*/
|
|
86
|
+
static readonly handleCancellation = function (value: unknown) {
|
|
87
|
+
if (prompts.isCancel(value)) {
|
|
88
|
+
prompts.cancel("Operation cancelled.");
|
|
89
|
+
process.exit(CANCEL);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
static readonly getTemplatePath = function (): string {
|
|
94
|
+
const require = createRequire(fileURLToPath(import.meta.url));
|
|
95
|
+
return require.resolve(TEMPLATE_MODULE);
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export default ComponentHelper;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
|
|
3
|
+
* All Rights Reserved
|
|
4
|
+
*
|
|
5
|
+
* All information contained herein is proprietary and confidential.
|
|
6
|
+
* Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
|
|
7
|
+
* prior written permission is obtained from Wiztivi.
|
|
8
|
+
* No warranty, explicit or implicit, provided.
|
|
9
|
+
* This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import UserInputGetter from "@/common/helpers/UserInputGetter.js";
|
|
14
|
+
import UpdateFileHelper from "@/common/helpers/UpdateFileHelper.js";
|
|
15
|
+
import InstallHelper from "@/common/helpers/InstallHelper.js";
|
|
16
|
+
import CreateAppHelper from "@/commands/createApp/helpers/CreateAppHelper.js";
|
|
17
|
+
import CreateFileHelper from "@/common/helpers/CreateFileHelper.js";
|
|
18
|
+
import AddDeviceHelper from "./helper/addDeviceHelper.js";
|
|
19
|
+
import * as prompts from "@clack/prompts";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import colors from "picocolors";
|
|
22
|
+
import { Data } from "@/common/types/helperTypes.js";
|
|
23
|
+
import { DEVICE_ERROR } from "@/common/const/exitCodeConst.js";
|
|
24
|
+
import process from "node:process";
|
|
25
|
+
import translation from "@/common/translation/translation.js";
|
|
26
|
+
import { CredentialsHelper } from "@/commands/authentication/helper/CredentialsHelper.js";
|
|
27
|
+
|
|
28
|
+
const addDevice = async () => {
|
|
29
|
+
prompts.intro(`Add device(s) to ${path.basename(process.cwd())} !`);
|
|
30
|
+
const spinner = prompts.spinner();
|
|
31
|
+
const data = {} as Data;
|
|
32
|
+
try {
|
|
33
|
+
data.directory = "./";
|
|
34
|
+
data.awsProfile = (await CredentialsHelper.get()).org;
|
|
35
|
+
const { availableDevices, unavailableDevices } = await UserInputGetter.getAvailableDevices();
|
|
36
|
+
const installedDevices: string[] = await AddDeviceHelper.getInstalledDevices(data.directory);
|
|
37
|
+
const filteredAvailableDevices = availableDevices.filter((el) => !installedDevices.includes(el.value));
|
|
38
|
+
const filteredUnavailableDevices = unavailableDevices.filter((el) => !installedDevices.includes(el));
|
|
39
|
+
if (filteredUnavailableDevices.length) {
|
|
40
|
+
CreateAppHelper.promptUnavailableDevices(filteredUnavailableDevices);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
prompts.log.info(
|
|
44
|
+
`${colors.bold(translation["command.device.installed_devices"])}\n ${installedDevices.join("\n ")}\n\n ${translation["command.device.profiles.tips"]}`,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (filteredAvailableDevices.length) {
|
|
48
|
+
data.selectedDevices = await CreateAppHelper.promptSelectDevices(filteredAvailableDevices);
|
|
49
|
+
} else {
|
|
50
|
+
prompts.outro(`${colors.bold(translation["command.device.all_already_installed"])}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!data.selectedDevices?.length) {
|
|
55
|
+
prompts.outro(translation["command.device.no_selection"]);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
data.config = await UserInputGetter.getDevicesConfig(data);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
const message = e instanceof Error ? e.message : (e as string);
|
|
61
|
+
prompts.outro(colors.red(`An issue occurred :` + message));
|
|
62
|
+
process.exit(DEVICE_ERROR);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
spinner.start(translation["task.installation.start"]);
|
|
66
|
+
const devDependencies = InstallHelper.getDependenciesList(data.selectedDevices, data.config, false);
|
|
67
|
+
|
|
68
|
+
await CreateAppHelper.installation(
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
title: "Update package.json",
|
|
72
|
+
task: async () => UpdateFileHelper.updatePackageJson(data),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: "Copy app.config files",
|
|
76
|
+
task: async () => CreateFileHelper.copyAppConfigFiles(data),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: "Update app.config.json",
|
|
80
|
+
task: async () => UpdateFileHelper.updateAppConfigFile(data),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: "Install dependencies with npm",
|
|
84
|
+
task: async () => InstallHelper.installDependencies(data, devDependencies),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
title: "Execute grunt tasks",
|
|
88
|
+
task: async () => CreateFileHelper.executeGruntTasks(data),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: "Execute devices config",
|
|
92
|
+
task: async () => UpdateFileHelper.setDevicesConfig(data),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
spinner,
|
|
96
|
+
);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
spinner.stop();
|
|
99
|
+
const message = e instanceof Error ? e.message : (e as string);
|
|
100
|
+
prompts.outro(colors.red(`${translation["error.common.start.message"]} ${message}`));
|
|
101
|
+
process.exit(DEVICE_ERROR);
|
|
102
|
+
}
|
|
103
|
+
spinner.stop(translation["task.installation.end"]);
|
|
104
|
+
prompts.outro("Everything is ready ! Don't forget to commit your change.");
|
|
105
|
+
};
|
|
106
|
+
export default addDevice;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import addDevice from "./add-device.js";
|
|
3
|
+
import translation from "@/common/translation/translation.js";
|
|
4
|
+
import { authHook } from "@/commands/authentication/authHook.js";
|
|
5
|
+
|
|
6
|
+
const addDeviceDefinition = () => {
|
|
7
|
+
return new Command("add-device")
|
|
8
|
+
.description(translation["command.device.description"])
|
|
9
|
+
.hook("preAction", authHook)
|
|
10
|
+
.action(addDevice);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default addDeviceDefinition;
|