dana-cli 0.0.0-stage → 0.0.26
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 +67 -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,87 @@
|
|
|
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 createComponent from "@/commands/addComponent/createComponent.js";
|
|
14
|
+
import { templateGenerator } from "@/common/helpers/handlebarsHelper.js";
|
|
15
|
+
import { beforeEach, expect, vi } from "vitest";
|
|
16
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
17
|
+
import { vol } from "memfs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { readFile } from "node:fs/promises";
|
|
20
|
+
import process from "node:process";
|
|
21
|
+
|
|
22
|
+
vi.mock("@/commands/addComponent/config/ComponentConfig");
|
|
23
|
+
vi.mock("@/commands/addComponent/helper/ComponentHelper");
|
|
24
|
+
vi.mock("@/common/helpers/handlebarsHelper");
|
|
25
|
+
vi.mock("@clack/prompts");
|
|
26
|
+
vi.mock("node:fs/promises");
|
|
27
|
+
|
|
28
|
+
const mockOutput = "A beautiful component from template";
|
|
29
|
+
const otherMockOutput = "Another beautiful component from template";
|
|
30
|
+
const mockData = {
|
|
31
|
+
name: "buttonComponent",
|
|
32
|
+
type: "button",
|
|
33
|
+
path: "/mock/current/directory",
|
|
34
|
+
};
|
|
35
|
+
const otherMockData = {
|
|
36
|
+
name: "scrollComponent",
|
|
37
|
+
type: "scrollView",
|
|
38
|
+
path: "/mock/current/directory",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
describe("createComponent", () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
vi.mocked(templateGenerator).mockResolvedValueOnce(mockOutput).mockResolvedValue(otherMockOutput);
|
|
44
|
+
vi.mocked(ComponentHelper.normalizeFileName)
|
|
45
|
+
.mockReturnValueOnce("buttonComponent.js")
|
|
46
|
+
.mockReturnValue("scrollComponent.js");
|
|
47
|
+
vi.mocked(ComponentHelper.getTemplatePath).mockReturnValue("/mock/template/index.js");
|
|
48
|
+
const mockCwd = "/mock/current/directory";
|
|
49
|
+
vi.spyOn(process, "cwd").mockReturnValue(mockCwd);
|
|
50
|
+
|
|
51
|
+
vol.fromJSON({
|
|
52
|
+
[mockCwd]: null,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
vol.reset();
|
|
57
|
+
vi.resetAllMocks();
|
|
58
|
+
});
|
|
59
|
+
it("should create a component successfully", async () => {
|
|
60
|
+
await createComponent([mockData]);
|
|
61
|
+
const copiedMock = await readFile(path.resolve(process.cwd(), "buttonComponent.js"), "utf-8");
|
|
62
|
+
expect(copiedMock).toBe(mockOutput);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should create as many components as required", async () => {
|
|
66
|
+
await createComponent([mockData, otherMockData]);
|
|
67
|
+
const copiedMock = await readFile(path.resolve(process.cwd(), "buttonComponent.js"), "utf-8");
|
|
68
|
+
expect(copiedMock).toBe(mockOutput);
|
|
69
|
+
const otherCopiedMock = await readFile(path.resolve(process.cwd(), "scrollComponent.js"), "utf-8");
|
|
70
|
+
expect(otherCopiedMock).toBe(otherMockOutput);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should exit with code 3 if command fails", async () => {
|
|
74
|
+
const exitSpy = vi.spyOn(process, "exit").mockImplementation(() => {
|
|
75
|
+
// Don't throw, just mock the exit
|
|
76
|
+
return undefined as never;
|
|
77
|
+
});
|
|
78
|
+
vi.mocked(templateGenerator)
|
|
79
|
+
.mockReset()
|
|
80
|
+
.mockImplementation(() => {
|
|
81
|
+
throw new Error("Template generation failed");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await createComponent([mockData]);
|
|
85
|
+
expect(exitSpy).toHaveBeenCalledWith(3);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
2
|
+
import * as navigationConst from "@/commands/addComponent/const/navigationConst.js";
|
|
3
|
+
import { afterEach, describe, expect, vi } from "vitest";
|
|
4
|
+
import * as prompts from "@clack/prompts";
|
|
5
|
+
import { RAIL, MENU, TILE_VIEW, SCROLL_VIEW } from "@/commands/addComponent/const/componentConst.js";
|
|
6
|
+
import { NAVIGATION_TYPES } from "@/commands/addComponent/const/navigationConst.js";
|
|
7
|
+
|
|
8
|
+
vi.mock("@clack/prompts");
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
vi.resetAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("selectionFactory", () => {
|
|
15
|
+
const NAVIGATION_LIST_MOCK = [
|
|
16
|
+
{
|
|
17
|
+
value: "MFixedNavigationType",
|
|
18
|
+
label: "Fixed",
|
|
19
|
+
command: "fixed",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "MLMRNavigationType",
|
|
23
|
+
label: "Left-Middle-Right",
|
|
24
|
+
command: "lmr",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
it("should return selected option", async () => {
|
|
28
|
+
const expectedOptions = [
|
|
29
|
+
{ value: "MFixedNavigationType", label: "Fixed" },
|
|
30
|
+
{ value: "MLMRNavigationType", label: "Left-Middle-Right" },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
vi.spyOn(navigationConst, "NAVIGATION_TYPES", "get").mockReturnValue(NAVIGATION_LIST_MOCK);
|
|
34
|
+
vi.mocked(prompts.select).mockResolvedValue(expectedOptions[0].value);
|
|
35
|
+
const result = await ComponentHelper.selectionFactory("test", NAVIGATION_TYPES, "element");
|
|
36
|
+
expect(vi.mocked(prompts.select).mock.calls[0][0].options).toEqual(expectedOptions);
|
|
37
|
+
expect(result).toBe("MFixedNavigationType");
|
|
38
|
+
});
|
|
39
|
+
it("should handle cancellation", async () => {
|
|
40
|
+
vi.mocked(prompts.select).mockResolvedValue("");
|
|
41
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
42
|
+
throw new Error("Project cancelled.");
|
|
43
|
+
});
|
|
44
|
+
await expect(ComponentHelper.selectionFactory("test", NAVIGATION_TYPES, "element")).rejects.toThrow(
|
|
45
|
+
"Project cancelled.",
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("checkOption", () => {
|
|
51
|
+
const OPTIONS_LIST_MOCK = [
|
|
52
|
+
{
|
|
53
|
+
value: "list",
|
|
54
|
+
label: "rail",
|
|
55
|
+
command: "r",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: "itemView",
|
|
59
|
+
label: "item",
|
|
60
|
+
command: "i",
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
it("should check the provided option and return corresponding value", () => {
|
|
64
|
+
const result = ComponentHelper.checkOption("i", OPTIONS_LIST_MOCK, "item");
|
|
65
|
+
expect(result).toBe("itemView");
|
|
66
|
+
});
|
|
67
|
+
it("should check the provided option and return empty string if no corresponding value", () => {
|
|
68
|
+
const result = ComponentHelper.checkOption("w", OPTIONS_LIST_MOCK, "item");
|
|
69
|
+
expect(vi.mocked(prompts.log.info)).toBeCalledWith(
|
|
70
|
+
'"w" does not match any item option. Please select one below:',
|
|
71
|
+
);
|
|
72
|
+
expect(result).toBe("");
|
|
73
|
+
});
|
|
74
|
+
it("should return empty string if option is not provided", () => {
|
|
75
|
+
const result = ComponentHelper.checkOption("", OPTIONS_LIST_MOCK, "item");
|
|
76
|
+
expect(result).toBe("");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe("normalizeFileName", () => {
|
|
81
|
+
it("should return a correct file name", () => {
|
|
82
|
+
const inputs = [
|
|
83
|
+
{
|
|
84
|
+
type: RAIL,
|
|
85
|
+
name: "myRail",
|
|
86
|
+
expected: "MyRailListView.js",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: MENU,
|
|
90
|
+
name: "home",
|
|
91
|
+
expected: "HomeListView.js",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: TILE_VIEW,
|
|
95
|
+
name: "mockTile",
|
|
96
|
+
expected: "MockTileListItemView.js",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: SCROLL_VIEW,
|
|
100
|
+
name: "vod",
|
|
101
|
+
expected: "VodScrollView.js",
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
inputs.forEach((input, index) => {
|
|
105
|
+
expect(ComponentHelper.normalizeFileName(inputs[index].type, inputs[index].name)).toBe(
|
|
106
|
+
inputs[index].expected,
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach, beforeEach } from "vitest";
|
|
2
|
+
import addDevice from "@/commands/addDevice/add-device.js";
|
|
3
|
+
import AddDeviceHelper from "@/commands/addDevice/helper/addDeviceHelper.js";
|
|
4
|
+
import UserInputGetter from "@/common/helpers/UserInputGetter.js";
|
|
5
|
+
import CreateAppHelper, { Spinner } from "@/commands/createApp/helpers/CreateAppHelper.js";
|
|
6
|
+
import { DEVICE_ERROR } from "@/common/const/exitCodeConst.js";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { AwsCredentials, CredentialsHelper, DanaToken } from "@/commands/authentication/helper/CredentialsHelper.js";
|
|
9
|
+
import * as prompts from "@clack/prompts";
|
|
10
|
+
import InstallHelper from "@/common/helpers/InstallHelper.js";
|
|
11
|
+
vi.mock("@clack/prompts");
|
|
12
|
+
vi.mock("@/helpers/createApp/ScriptHelper");
|
|
13
|
+
vi.mock("@/helpers/createApp/UserInputGetter");
|
|
14
|
+
vi.mock("@/helpers/CredentialsHelper.ts");
|
|
15
|
+
vi.mock("@/helpers/CliHelper");
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.resetAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("addDevice", () => {
|
|
22
|
+
const credentialResponse = {
|
|
23
|
+
aws: {} as AwsCredentials,
|
|
24
|
+
dana: {} as DanaToken,
|
|
25
|
+
org: "awsProfile",
|
|
26
|
+
isRemote: true,
|
|
27
|
+
};
|
|
28
|
+
const getDevicesResponse = {
|
|
29
|
+
availableDevices: [
|
|
30
|
+
{ label: "device1", value: "device1" },
|
|
31
|
+
{ label: "device2", value: "device2" },
|
|
32
|
+
],
|
|
33
|
+
unavailableDevices: ["device3"],
|
|
34
|
+
};
|
|
35
|
+
const installedDevices = ["device2"];
|
|
36
|
+
describe("success", () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
vi.spyOn(CredentialsHelper, "get").mockResolvedValue(credentialResponse);
|
|
39
|
+
vi.spyOn(UserInputGetter, "getAvailableDevices").mockResolvedValue(getDevicesResponse);
|
|
40
|
+
vi.spyOn(AddDeviceHelper, "getInstalledDevices").mockResolvedValue(installedDevices);
|
|
41
|
+
vi.spyOn(CreateAppHelper, "promptUnavailableDevices");
|
|
42
|
+
vi.spyOn(CreateAppHelper, "promptSelectDevices").mockResolvedValue(["device1"]);
|
|
43
|
+
vi.spyOn(UserInputGetter, "getDevicesConfig").mockResolvedValue({});
|
|
44
|
+
vi.spyOn(CreateAppHelper, "installation").mockResolvedValue();
|
|
45
|
+
vi.spyOn(InstallHelper, "getDependenciesList").mockResolvedValue(["dep1", "dep2"]);
|
|
46
|
+
const spinner = {
|
|
47
|
+
start: vi.fn(),
|
|
48
|
+
stop: vi.fn(),
|
|
49
|
+
message: vi.fn(),
|
|
50
|
+
} as unknown as Spinner;
|
|
51
|
+
vi.mocked(prompts.spinner).mockReturnValue(spinner);
|
|
52
|
+
});
|
|
53
|
+
it("should call functions with correct parameters", async () => {
|
|
54
|
+
await addDevice();
|
|
55
|
+
expect(vi.mocked(CreateAppHelper.promptUnavailableDevices)).toHaveBeenCalledWith(["device3"]);
|
|
56
|
+
expect(vi.mocked(CreateAppHelper.promptSelectDevices)).toHaveBeenCalledWith([
|
|
57
|
+
{ label: "device1", value: "device1" },
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("errors", () => {
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
vi.spyOn(process, "exit").mockImplementation(() => undefined as never);
|
|
65
|
+
vi.spyOn(AddDeviceHelper, "cleanOnError").mockReturnValue("cleaned");
|
|
66
|
+
const spinner = {
|
|
67
|
+
start: vi.fn(),
|
|
68
|
+
stop: vi.fn(),
|
|
69
|
+
message: vi.fn(),
|
|
70
|
+
} as unknown as Spinner;
|
|
71
|
+
vi.mocked(prompts.spinner).mockReturnValue(spinner);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should handle getAvailableDevices error", async () => {
|
|
75
|
+
vi.spyOn(UserInputGetter, "getAvailableDevices").mockImplementation(() => {
|
|
76
|
+
throw new Error("get devices");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
await addDevice();
|
|
80
|
+
expect(process.exit).toHaveBeenCalledWith(DEVICE_ERROR);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should handle promptSelectDevices error", async () => {
|
|
84
|
+
vi.spyOn(UserInputGetter, "getAvailableDevices").mockResolvedValue(getDevicesResponse);
|
|
85
|
+
vi.spyOn(CreateAppHelper, "promptSelectDevices").mockImplementation(() => {
|
|
86
|
+
throw new Error("select devices");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await addDevice();
|
|
90
|
+
expect(process.exit).toHaveBeenCalledWith(DEVICE_ERROR);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should handle getDevicesConfig error", async () => {
|
|
94
|
+
vi.spyOn(UserInputGetter, "getAvailableDevices").mockResolvedValue(getDevicesResponse);
|
|
95
|
+
vi.spyOn(CreateAppHelper, "promptSelectDevices").mockResolvedValue(["device1"]);
|
|
96
|
+
vi.spyOn(UserInputGetter, "getDevicesConfig").mockImplementation(() => {
|
|
97
|
+
throw new Error("getConfig");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await addDevice();
|
|
101
|
+
expect(process.exit).toHaveBeenCalledWith(DEVICE_ERROR);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("should handle installation error", async () => {
|
|
105
|
+
vi.spyOn(UserInputGetter, "getAvailableDevices").mockResolvedValue(getDevicesResponse);
|
|
106
|
+
vi.spyOn(CreateAppHelper, "promptSelectDevices").mockResolvedValue(["device1"]);
|
|
107
|
+
vi.spyOn(UserInputGetter, "getDevicesConfig").mockResolvedValue({});
|
|
108
|
+
|
|
109
|
+
vi.spyOn(CreateAppHelper, "installation").mockImplementation(() => {
|
|
110
|
+
throw new Error("installation");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
await addDevice();
|
|
114
|
+
expect(process.exit).toHaveBeenCalledWith(DEVICE_ERROR);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import AndroidtvConfig from "@/commands/addDevice/deviceConfig/androidtvConfig.js";
|
|
2
|
+
import { vol } from "memfs";
|
|
3
|
+
import * as prompts from "@clack/prompts";
|
|
4
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
5
|
+
import { DEFAULT_IMAGE_URL } from "@/commands/createApp/const/setupConst.js";
|
|
6
|
+
import androidtvConfig from "@/commands/addDevice/deviceConfig/androidtvConfig.js";
|
|
7
|
+
import { expect, vi } from "vitest";
|
|
8
|
+
import AddDeviceHelper from "@/commands/addDevice/helper/addDeviceHelper.js";
|
|
9
|
+
import addDeviceHelper from "@/commands/addDevice/helper/addDeviceHelper.js";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { readFile } from "node:fs/promises";
|
|
12
|
+
|
|
13
|
+
vi.mock("node:fs/promises");
|
|
14
|
+
vi.mock("@clack/prompts");
|
|
15
|
+
vi.mock("@/commands/addComponent/helper/ComponentHelper");
|
|
16
|
+
vi.mock("@/commands/addDevice/helper/addDeviceHelper");
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
vol.reset();
|
|
20
|
+
vi.resetAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("AndroidtvConfig", () => {
|
|
24
|
+
describe("_askAppIcon", () => {
|
|
25
|
+
it("should ask for app icon path", async () => {
|
|
26
|
+
vi.mocked(AddDeviceHelper.getAppIcon).mockResolvedValue(DEFAULT_IMAGE_URL);
|
|
27
|
+
const icon = await AddDeviceHelper.getAppIcon();
|
|
28
|
+
expect(icon).toBe(DEFAULT_IMAGE_URL);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("_askAppId", () => {
|
|
33
|
+
it("should ask for appId", async () => {
|
|
34
|
+
vi.mocked(prompts.text).mockResolvedValue("com.wiztivi.app");
|
|
35
|
+
const appId = await AndroidtvConfig._askAppId();
|
|
36
|
+
expect(appId).toBe("com.wiztivi.app");
|
|
37
|
+
});
|
|
38
|
+
it("should handle cancellation", async () => {
|
|
39
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
40
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
41
|
+
throw new Error("Project cancelled.");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await expect(AndroidtvConfig._askAppId()).rejects.toThrow("Project cancelled.");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("_askAppName", () => {
|
|
48
|
+
it("should ask for appName", async () => {
|
|
49
|
+
vi.mocked(prompts.text).mockResolvedValue("Lapin");
|
|
50
|
+
const appName = await AndroidtvConfig._askAppName();
|
|
51
|
+
expect(appName).toBe("Lapin");
|
|
52
|
+
});
|
|
53
|
+
it("should handle cancellation", async () => {
|
|
54
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
55
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
56
|
+
throw new Error("Project cancelled.");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await expect(AndroidtvConfig._askAppName()).rejects.toThrow("Project cancelled.");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe("_askAppVersion", () => {
|
|
63
|
+
it("should ask for appVersion", async () => {
|
|
64
|
+
vi.mocked(prompts.text).mockResolvedValue("1.0.0");
|
|
65
|
+
const appVersion = await AndroidtvConfig._askAppVersion();
|
|
66
|
+
expect(appVersion).toBe("1.0.0");
|
|
67
|
+
});
|
|
68
|
+
it("should handle cancellation", async () => {
|
|
69
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
70
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
71
|
+
throw new Error("Project cancelled.");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
await expect(AndroidtvConfig._askAppVersion()).rejects.toThrow("Project cancelled.");
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe("_askAppVersionCode", () => {
|
|
78
|
+
it("should ask for appVersionCode", async () => {
|
|
79
|
+
vi.mocked(prompts.text).mockResolvedValue("42");
|
|
80
|
+
const appVersionCode = await AndroidtvConfig._askAppVersionCode();
|
|
81
|
+
expect(appVersionCode).toBe(42);
|
|
82
|
+
});
|
|
83
|
+
it("should handle cancellation", async () => {
|
|
84
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
85
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
86
|
+
throw new Error("Project cancelled.");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await expect(AndroidtvConfig._askAppVersionCode()).rejects.toThrow("Project cancelled.");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe("getConfig", () => {
|
|
93
|
+
it("should return a config", async () => {
|
|
94
|
+
const mockDeviceConfig = { value1: true, value2: "appId", tvAndroidVersion: "7.244.0" };
|
|
95
|
+
const expectedConfig = {
|
|
96
|
+
device: mockDeviceConfig,
|
|
97
|
+
};
|
|
98
|
+
vi.mocked(prompts.group).mockResolvedValue(mockDeviceConfig);
|
|
99
|
+
const config = await AndroidtvConfig.getConfig();
|
|
100
|
+
expect(config).toEqual(expectedConfig);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe("updateProfileJson", () => {
|
|
104
|
+
it("should call writeFile with correct parameters", async () => {
|
|
105
|
+
const directory = "/directory";
|
|
106
|
+
const config = {
|
|
107
|
+
device: {
|
|
108
|
+
appName: "appName",
|
|
109
|
+
appId: "appId",
|
|
110
|
+
appVersion: "1.0.0",
|
|
111
|
+
appVersionCode: 1000,
|
|
112
|
+
icon: "icon.jpeg",
|
|
113
|
+
wtvAndroidVersion: "7.244.0",
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const initialJsonData = {
|
|
118
|
+
"base-android": {
|
|
119
|
+
device: {
|
|
120
|
+
type: "android",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const expectedJsonData = {
|
|
126
|
+
"base-android": {
|
|
127
|
+
device: {
|
|
128
|
+
type: "android",
|
|
129
|
+
...config.device,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const jsonPath = path.join(directory, "profiles", "app.config.androidtv.json");
|
|
134
|
+
vol.fromJSON({
|
|
135
|
+
[path.join(directory, "profiles")]: null, // Creates directory
|
|
136
|
+
[jsonPath]: JSON.stringify(initialJsonData),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const result = await AndroidtvConfig.updateProfileJson(directory, config);
|
|
140
|
+
|
|
141
|
+
const copiedMock = await readFile(jsonPath, "utf-8");
|
|
142
|
+
expect(copiedMock).toBe(JSON.stringify(expectedJsonData, null, 4));
|
|
143
|
+
expect(result).toEqual("Profile.json updated");
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("_getWtvAndroidVersion", () => {
|
|
148
|
+
it("should call helper with correct parameters", async () => {
|
|
149
|
+
vi.mocked(addDeviceHelper.getLatestPackageVersion).mockResolvedValueOnce("7.251.3");
|
|
150
|
+
|
|
151
|
+
const result: string = await AndroidtvConfig._getWtvAndroidVersion();
|
|
152
|
+
expect(result).toEqual("7.251.3");
|
|
153
|
+
expect(addDeviceHelper.getLatestPackageVersion).toHaveBeenCalledWith({
|
|
154
|
+
packageName: "v8-runtime",
|
|
155
|
+
repository: "internal-android-repository",
|
|
156
|
+
format: "maven",
|
|
157
|
+
namespace: "com.dana.androidtv",
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe("setConfig", () => {
|
|
163
|
+
const directory = "/directory";
|
|
164
|
+
const config = {
|
|
165
|
+
device: {
|
|
166
|
+
type: "android",
|
|
167
|
+
appName: "appName",
|
|
168
|
+
appId: "appId",
|
|
169
|
+
appVersion: "1.0.0",
|
|
170
|
+
appVersionCode: 1000,
|
|
171
|
+
icon: "icon.jpeg",
|
|
172
|
+
wtvAndroidVersion: "7.244.0",
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
it("should call updateProfileJson function with correct parameters", async () => {
|
|
177
|
+
const spy = vi.spyOn(androidtvConfig, "updateProfileJson").mockResolvedValue("");
|
|
178
|
+
|
|
179
|
+
await AndroidtvConfig.setConfig({ directory, config });
|
|
180
|
+
const [directoryParam, configParam] = spy.mock.calls[0];
|
|
181
|
+
expect(directoryParam).toMatch(directoryParam);
|
|
182
|
+
expect(configParam).toBe(config);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import DeviceConfig from "@/commands/addDevice/deviceConfig/deviceConfig.js";
|
|
3
|
+
|
|
4
|
+
describe("DeviceConfig", () => {
|
|
5
|
+
it("should resolve getConfig", async () => {
|
|
6
|
+
await expect(DeviceConfig.getConfig()).resolves.toEqual({});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should resolve setConfig", async () => {
|
|
10
|
+
await expect(DeviceConfig.setConfig({})).resolves.toBe("Device configuration done");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe("updateProfileJsonWithRenderers", () => {
|
|
14
|
+
it("should update jsonData with renderers configuration", () => {
|
|
15
|
+
const jsonData = { basicConfig: "value1" };
|
|
16
|
+
const renderers = ["css", "lightning"];
|
|
17
|
+
DeviceConfig.appConfig = {
|
|
18
|
+
css: { device_css: { vendors: ["v1", "v2"] } },
|
|
19
|
+
lightning: { device_lightning: { vendors: ["v3", "v4"] } },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const updatedJson = DeviceConfig.updateProfileJsonWithRenderers(jsonData, renderers);
|
|
23
|
+
expect(updatedJson).toEqual({
|
|
24
|
+
basicConfig: "value1",
|
|
25
|
+
device_css: { vendors: ["v1", "v2"] },
|
|
26
|
+
device_lightning: { vendors: ["v3", "v4"] },
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import TitanosConfig from "@/commands/addDevice/deviceConfig/titanosConfig.js";
|
|
3
|
+
|
|
4
|
+
describe("TitanosConfig", () => {
|
|
5
|
+
describe("getConfig", () => {
|
|
6
|
+
it("should return a config", async () => {
|
|
7
|
+
const expectedConfig = {
|
|
8
|
+
renderers: ["lightning", "css"],
|
|
9
|
+
};
|
|
10
|
+
const config = await TitanosConfig.getConfig();
|
|
11
|
+
expect(config).toEqual(expectedConfig);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("setConfig", () => {
|
|
16
|
+
it("should resolve", async () => {
|
|
17
|
+
await expect(TitanosConfig.setConfig()).resolves.toBe("TitanOS configuration done");
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import TizenConfig from "@/commands/addDevice/deviceConfig/tizenConfig.js";
|
|
2
|
+
import { expect, vi } from "vitest";
|
|
3
|
+
import { vol } from "memfs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
|
|
7
|
+
vi.mock("@/commands/addDevice/helper/addDeviceHelper.js");
|
|
8
|
+
vi.mock("node:fs/promises");
|
|
9
|
+
vi.mock("@/commands/addDevice/deviceConfig/deviceConfig.js");
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
vol.reset();
|
|
13
|
+
vi.resetAllMocks();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("getConfig", () => {
|
|
17
|
+
it("should return a config", async () => {
|
|
18
|
+
const expectedConfig = {
|
|
19
|
+
renderers: ["lightning"],
|
|
20
|
+
};
|
|
21
|
+
const config = await TizenConfig.getConfig();
|
|
22
|
+
expect(config).toEqual(expectedConfig);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("setConfig", () => {
|
|
27
|
+
it("should set a config", async () => {
|
|
28
|
+
const directory = "/directory";
|
|
29
|
+
const initialJsonData = {
|
|
30
|
+
tizen: {
|
|
31
|
+
device: {
|
|
32
|
+
type: "tizen",
|
|
33
|
+
profileName: "tv-samsung",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const config = {
|
|
39
|
+
renderers: ["lightning"],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updatedJsonData = {
|
|
43
|
+
tizen: {
|
|
44
|
+
device: {
|
|
45
|
+
type: "tizen",
|
|
46
|
+
profileName: "tv-samsung",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const jsonPath = path.join(directory, "profiles", "app.config.tizen.json");
|
|
52
|
+
vol.fromJSON({
|
|
53
|
+
[path.join(directory, "profiles")]: null, // Creates directory
|
|
54
|
+
[jsonPath]: JSON.stringify(initialJsonData),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const result = TizenConfig.setConfig({ directory, config });
|
|
58
|
+
|
|
59
|
+
const copiedMock = await readFile(jsonPath, "utf-8");
|
|
60
|
+
expect(copiedMock).toBe(JSON.stringify(updatedJsonData));
|
|
61
|
+
await expect(result).resolves.toBe("Tizen configuration done");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import TvosConfig from "@/commands/addDevice/deviceConfig/tvosConfig.js";
|
|
3
|
+
import { vol } from "memfs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import addDeviceHelper from "@/commands/addDevice/helper/addDeviceHelper.js";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
|
|
8
|
+
vi.mock("node:fs/promises");
|
|
9
|
+
vi.mock("@/commands/addDevice/helper/addDeviceHelper");
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
vi.resetAllMocks();
|
|
13
|
+
});
|
|
14
|
+
describe("TvosConf", () => {
|
|
15
|
+
describe("setConfig", () => {
|
|
16
|
+
it("should update the .gitignore file", async () => {
|
|
17
|
+
const directory = "/directory";
|
|
18
|
+
const initialData = "node_modules\n";
|
|
19
|
+
const updatedData = `${initialData}\n# For TVOS\napp_tvos/build \napp_tvos/libs`;
|
|
20
|
+
|
|
21
|
+
const ignorePath = path.join(directory, TvosConfig.GITIGNORE_PATH);
|
|
22
|
+
vol.fromJSON({
|
|
23
|
+
[path.join(directory, ".gitignore")]: null, // Creates directory
|
|
24
|
+
[ignorePath]: initialData,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const result = await TvosConfig.setConfig({ directory });
|
|
28
|
+
const copiedMock = await readFile(ignorePath, "utf-8");
|
|
29
|
+
expect(copiedMock).toBe(updatedData);
|
|
30
|
+
expect(result).toBe(".gitignore updated");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe("getJscVersion", () => {
|
|
35
|
+
it("should call helper with correct parameters", async () => {
|
|
36
|
+
vi.mocked(addDeviceHelper.getLatestPackageVersion).mockResolvedValueOnce("7.251.3");
|
|
37
|
+
|
|
38
|
+
const result: string = await TvosConfig.getJscVersion();
|
|
39
|
+
expect(result).toEqual("7.251.3");
|
|
40
|
+
expect(addDeviceHelper.getLatestPackageVersion).toHaveBeenCalledWith({
|
|
41
|
+
packageName: "jscmodule",
|
|
42
|
+
repository: "internal-apple-repository",
|
|
43
|
+
format: "swift",
|
|
44
|
+
namespace: "dana",
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|