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,59 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import addDeviceDefinition from "./commands/addDevice/addDeviceDefinition.js";
|
|
5
|
+
import addMenuDefinition from "./commands/addComponent/addMenu/addMenuDefinition.js";
|
|
6
|
+
import addRailDefinition from "./commands/addComponent/addRail/addRailDefinition.js";
|
|
7
|
+
import addScreenDefinition from "./commands/addComponent/addScreen/addScreenDefinition.js";
|
|
8
|
+
import addScrollViewDefinition from "./commands/addComponent/addScrollView/addScrollViewDefinition.js";
|
|
9
|
+
import addAuthDefinition from "./commands/authentication/authDefinition.js";
|
|
10
|
+
import customHelp from "./commands/commandHelp/customHelp.js";
|
|
11
|
+
import translation from "./common/translation/translation.js";
|
|
12
|
+
import createAppDefinition from "./commands/createApp/createAppDefinition.js";
|
|
13
|
+
import completionDefinition from "./commands/completion/completionDefinition.js";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { checkDanaProjectHook } from "./commands/hooks/checkDanaProjectHook.js";
|
|
16
|
+
import zipDefinition from "@/commands/zip/zipDefinition.js";
|
|
17
|
+
import addModuleDefinition from "./commands/addModule/addModuleDefinition.js";
|
|
18
|
+
import addDianaSkillsDefinition from "./commands/addDianaSkills/addDianaSkillsDefinition.js";
|
|
19
|
+
|
|
20
|
+
interface PackageJson {
|
|
21
|
+
name: string;
|
|
22
|
+
version: string;
|
|
23
|
+
}
|
|
24
|
+
export const makeProgram = async () => {
|
|
25
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const filePath: string = path.join(__dirname, "..", "package.json");
|
|
27
|
+
const rawJson = await readFile(filePath, "utf-8");
|
|
28
|
+
const packageJson = JSON.parse(rawJson) as PackageJson;
|
|
29
|
+
const program = new Command(packageJson.name);
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.usage(`${translation["program.usage"]}`)
|
|
33
|
+
.version(packageJson.version)
|
|
34
|
+
.addCommand(addRailDefinition())
|
|
35
|
+
.addCommand(addDeviceDefinition())
|
|
36
|
+
.addCommand(addMenuDefinition())
|
|
37
|
+
.addCommand(addAuthDefinition())
|
|
38
|
+
.addCommand(addScrollViewDefinition())
|
|
39
|
+
.addCommand(addScreenDefinition())
|
|
40
|
+
.addCommand(createAppDefinition())
|
|
41
|
+
.addCommand(completionDefinition())
|
|
42
|
+
.addCommand(zipDefinition())
|
|
43
|
+
.addCommand(addModuleDefinition())
|
|
44
|
+
.addCommand(addDianaSkillsDefinition())
|
|
45
|
+
.hook("preSubcommand", async (thisCommand, subCommand) => {
|
|
46
|
+
await checkDanaProjectHook(thisCommand, subCommand);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//help
|
|
50
|
+
program.helpInformation = () => customHelp(program);
|
|
51
|
+
program.addHelpText(
|
|
52
|
+
"afterAll",
|
|
53
|
+
`
|
|
54
|
+
${translation["program.help.footer"]}
|
|
55
|
+
`,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return program;
|
|
59
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import createComponent from "@/commands/addComponent/createComponent.js";
|
|
2
|
+
import addMenu from "@/commands/addComponent/addMenu/add-menu.js";
|
|
3
|
+
import ComponentConfig from "@/commands/addComponent/config/ComponentConfig.js";
|
|
4
|
+
import { afterEach, beforeEach, expect, vi } from "vitest";
|
|
5
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
6
|
+
import UpdateFileHelper from "@/common/helpers/UpdateFileHelper.js";
|
|
7
|
+
import CreateFileHelper from "@/common/helpers/CreateFileHelper.js";
|
|
8
|
+
import { vol } from "memfs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
|
|
11
|
+
vi.mock("@/commands/addComponent/createComponent");
|
|
12
|
+
vi.mock("@/common/helpers/UpdateFileHelper.js");
|
|
13
|
+
vi.mock("@/common/helpers/CreateFileHelper.js");
|
|
14
|
+
vi.mock("node:fs/promises", () => ({
|
|
15
|
+
readFile: vi.fn(),
|
|
16
|
+
cp: vi.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
const templatePath = ComponentHelper.getTemplatePath();
|
|
21
|
+
const mockPath = path.join(path.dirname(templatePath), "mocks", "menuMock.json");
|
|
22
|
+
const iconPath = path.join(path.dirname(templatePath), "icons");
|
|
23
|
+
|
|
24
|
+
vol.fromJSON({
|
|
25
|
+
[mockPath]: '{"mock": "data"}',
|
|
26
|
+
[path.join(iconPath, "icon.png")]: "icon-content",
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
vol.reset();
|
|
32
|
+
vi.resetAllMocks();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("add-menu", () => {
|
|
36
|
+
it("should create a component", async () => {
|
|
37
|
+
const conf = {
|
|
38
|
+
name: "myMenu",
|
|
39
|
+
itemView: "itemView",
|
|
40
|
+
itemMargin: 20,
|
|
41
|
+
direction: "horizontal",
|
|
42
|
+
type: "menu",
|
|
43
|
+
custom: true,
|
|
44
|
+
path: "path/to/component",
|
|
45
|
+
};
|
|
46
|
+
vi.spyOn(ComponentConfig, "menuConfig").mockResolvedValue(conf);
|
|
47
|
+
const expectedParam = [{ ...conf }];
|
|
48
|
+
|
|
49
|
+
await addMenu("myMenu", { itemView: "myItem", custom: "true" });
|
|
50
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith(expectedParam);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should create fully mocked components if no custom option", async () => {
|
|
54
|
+
const conf = {
|
|
55
|
+
name: "myMenu",
|
|
56
|
+
itemView: "itemView",
|
|
57
|
+
itemMargin: 20,
|
|
58
|
+
direction: "horizontal",
|
|
59
|
+
type: "menu",
|
|
60
|
+
path: "path/to/component",
|
|
61
|
+
};
|
|
62
|
+
const expectedParam = [
|
|
63
|
+
{
|
|
64
|
+
...conf,
|
|
65
|
+
},
|
|
66
|
+
{ type: "ButtonItemView", name: "ButtonItem", path: conf.path },
|
|
67
|
+
];
|
|
68
|
+
vi.spyOn(ComponentConfig, "menuConfig").mockResolvedValue(conf);
|
|
69
|
+
|
|
70
|
+
await addMenu("myMenu", { path: "path/to/component" });
|
|
71
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith(expectedParam);
|
|
72
|
+
expect(vi.mocked(CreateFileHelper.copyFontFile)).toHaveBeenCalledTimes(1);
|
|
73
|
+
expect(vi.mocked(UpdateFileHelper.updateAppTheme)).toHaveBeenCalledTimes(1);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should not copy the mock data and icons if custom option", async () => {
|
|
77
|
+
const conf = {
|
|
78
|
+
name: "myMenu",
|
|
79
|
+
itemView: "itemView",
|
|
80
|
+
itemMargin: 20,
|
|
81
|
+
direction: "horizontal",
|
|
82
|
+
type: "menu",
|
|
83
|
+
custom: true,
|
|
84
|
+
path: "path/to/component",
|
|
85
|
+
};
|
|
86
|
+
const expectedParam = [{ ...conf }];
|
|
87
|
+
vi.spyOn(ComponentConfig, "menuConfig").mockResolvedValue(conf);
|
|
88
|
+
|
|
89
|
+
await addMenu("myMenu", { custom: "true", path: "path/to/component" });
|
|
90
|
+
|
|
91
|
+
expect(() => vol.readFileSync(path.resolve(process.cwd(), "menuMock.json"))).toThrow(
|
|
92
|
+
"ENOENT: no such file or directory",
|
|
93
|
+
);
|
|
94
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith(expectedParam);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import addRail from "@/commands/addComponent/addRail/add-rail.js";
|
|
2
|
+
import createComponent from "@/commands/addComponent/createComponent.js";
|
|
3
|
+
import { beforeEach, expect, vi } from "vitest";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { vol } from "memfs";
|
|
6
|
+
import ComponentConfig from "@/commands/addComponent/config/ComponentConfig.js";
|
|
7
|
+
import { RailConfig } from "@/commands/addComponent/config/componentTypes.js";
|
|
8
|
+
import ComponentHelper from "../../../../src/commands/addComponent/helper/ComponentHelper.js";
|
|
9
|
+
|
|
10
|
+
vi.mock("@/commands/addComponent/createComponent");
|
|
11
|
+
vi.mock("node:fs/promises", () => ({
|
|
12
|
+
readFile: vi.fn(),
|
|
13
|
+
cp: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
const templatePath = ComponentHelper.getTemplatePath();
|
|
18
|
+
const mockPath = path.join(path.dirname(templatePath), "mocks", "railMock.json");
|
|
19
|
+
|
|
20
|
+
vol.fromJSON({
|
|
21
|
+
[mockPath]: '{"mock": "data"}',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
vol.reset();
|
|
26
|
+
vi.resetAllMocks();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("add-rail", () => {
|
|
30
|
+
it("should create fully mocked components if no custom option", async () => {
|
|
31
|
+
const conf = {
|
|
32
|
+
name: "myRail",
|
|
33
|
+
navigation: "FixedNavigationType",
|
|
34
|
+
cyclic: true,
|
|
35
|
+
itemView: "itemView",
|
|
36
|
+
isCyclic: true,
|
|
37
|
+
direction: "horizontal",
|
|
38
|
+
path: "path/to/component",
|
|
39
|
+
} as unknown as RailConfig;
|
|
40
|
+
vi.spyOn(ComponentConfig, "railConfig").mockResolvedValue(conf);
|
|
41
|
+
|
|
42
|
+
const expectedParam = [{ ...conf }, { type: "tileView", name: "mockTile", path: conf.path }];
|
|
43
|
+
await addRail("", { path: "path/to/component" });
|
|
44
|
+
expect(vi.mocked(createComponent).mock.calls[0][0]).toStrictEqual(expectedParam);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should not copy mock file if custom option", async () => {
|
|
48
|
+
vi.spyOn(ComponentConfig, "railConfig").mockResolvedValue({ name: "myRail" } as RailConfig);
|
|
49
|
+
|
|
50
|
+
const expectedParam = [{ name: "myRail", custom: "true", path: "path/to/component" }];
|
|
51
|
+
await addRail("myRail", { custom: "true", path: "path/to/component" });
|
|
52
|
+
expect(() => vol.readFileSync(path.resolve(process.cwd(), "railMock.json"))).toThrow(
|
|
53
|
+
"ENOENT: no such file or directory",
|
|
54
|
+
);
|
|
55
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith(expectedParam);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { afterEach, expect, vi } from "vitest";
|
|
2
|
+
import createComponent from "@/commands/addComponent/createComponent.js";
|
|
3
|
+
import addScreen from "@/commands/addComponent/addScreen/add-screen.js";
|
|
4
|
+
import addMenu from "@/commands/addComponent/addMenu/add-menu.js";
|
|
5
|
+
import addScrollView from "@/commands/addComponent/addScrollView/add-scrollView.js";
|
|
6
|
+
import { VOD_SCREEN } from "@/commands/addComponent/const/componentConst.js";
|
|
7
|
+
|
|
8
|
+
vi.mock("@/commands/addComponent/createComponent");
|
|
9
|
+
vi.mock("@/commands/addComponent/addMenu/add-menu");
|
|
10
|
+
vi.mock("@/commands/addComponent/addScrollView/add-scrollView");
|
|
11
|
+
vi.mock("@clack/prompts");
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.resetAllMocks();
|
|
14
|
+
});
|
|
15
|
+
describe("add-screen", () => {
|
|
16
|
+
it("should create a component", async () => {
|
|
17
|
+
vi.mocked(createComponent);
|
|
18
|
+
|
|
19
|
+
const expectedParam = {
|
|
20
|
+
name: "home",
|
|
21
|
+
type: "screen",
|
|
22
|
+
path: "path/to/component",
|
|
23
|
+
};
|
|
24
|
+
await addScreen("home", { path: "path/to/component" });
|
|
25
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith([expectedParam]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should use default name if name argument not provided", async () => {
|
|
29
|
+
vi.mocked(createComponent);
|
|
30
|
+
|
|
31
|
+
const expectedParam = {
|
|
32
|
+
name: "Mock",
|
|
33
|
+
type: "screen",
|
|
34
|
+
path: process.cwd(),
|
|
35
|
+
};
|
|
36
|
+
await addScreen();
|
|
37
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith([expectedParam]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should create a vod screen with all its components", async () => {
|
|
41
|
+
vi.mocked(addMenu);
|
|
42
|
+
vi.mocked(addScrollView);
|
|
43
|
+
vi.mocked(createComponent);
|
|
44
|
+
|
|
45
|
+
const expectedParamScreen = {
|
|
46
|
+
name: "Mock",
|
|
47
|
+
type: VOD_SCREEN,
|
|
48
|
+
path: "path/to/component",
|
|
49
|
+
};
|
|
50
|
+
await addScreen(undefined, { screenType: "vod", path: "path/to/component" });
|
|
51
|
+
expect(vi.mocked(addMenu)).toHaveBeenCalledExactlyOnceWith(VOD_SCREEN, { path: "path/to/component" });
|
|
52
|
+
expect(vi.mocked(addScrollView)).toHaveBeenCalledExactlyOnceWith(VOD_SCREEN, { path: "path/to/component" });
|
|
53
|
+
expect(vi.mocked(createComponent)).toHaveBeenCalledExactlyOnceWith([expectedParamScreen]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import addScroll from "@/commands/addComponent/addScrollView/add-scrollView.js";
|
|
2
|
+
import createComponent from "@/commands/addComponent/createComponent.js";
|
|
3
|
+
import { beforeEach, expect, vi } from "vitest";
|
|
4
|
+
import { vol } from "memfs";
|
|
5
|
+
import ComponentConfig from "@/commands/addComponent/config/ComponentConfig.js";
|
|
6
|
+
import { SCROLL_VIEW } from "@/commands/addComponent/const/componentConst.js";
|
|
7
|
+
import { ScrollViewConfig } from "@/commands/addComponent/config/componentTypes.js";
|
|
8
|
+
import { SCROLLVIEW_DEFAULT_CONFIG } from "@/commands/addComponent/const/defaultConfig.js";
|
|
9
|
+
import ComponentHelper from "../../../../src/commands/addComponent/helper/ComponentHelper.js";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
vi.mock("@/commands/addComponent/createComponent");
|
|
13
|
+
vi.mock("node:fs/promises", () => ({
|
|
14
|
+
readFile: vi.fn(),
|
|
15
|
+
cp: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
const templatePath = ComponentHelper.getTemplatePath();
|
|
20
|
+
const mockPath = path.join(path.dirname(templatePath), "mocks", "scrollViewMock.json");
|
|
21
|
+
|
|
22
|
+
vol.fromJSON({
|
|
23
|
+
[mockPath]: '{"mock": "data"}',
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
vol.reset();
|
|
28
|
+
vi.resetAllMocks();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("add-scrollView", () => {
|
|
32
|
+
it("should create a component", async () => {
|
|
33
|
+
const expectedParams = {
|
|
34
|
+
custom: true,
|
|
35
|
+
itemView: "itemView",
|
|
36
|
+
name: "myScroll",
|
|
37
|
+
path: "path/to/component",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
vi.spyOn(ComponentConfig, "scrollViewConfig").mockResolvedValue({} as ScrollViewConfig);
|
|
41
|
+
vi.mocked(createComponent);
|
|
42
|
+
|
|
43
|
+
await addScroll("myScroll", { itemView: "itemView", custom: true, path: "path/to/component" });
|
|
44
|
+
expect(vi.mocked(createComponent).mock.calls[0][0]).toStrictEqual([expectedParams]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should create fully mocked components if no custom option", async () => {
|
|
48
|
+
vi.spyOn(ComponentConfig, "scrollViewConfig").mockResolvedValue({
|
|
49
|
+
name: "myScroll",
|
|
50
|
+
itemMargin: 550,
|
|
51
|
+
itemView: "Rail",
|
|
52
|
+
type: SCROLL_VIEW,
|
|
53
|
+
path: "path/to/component",
|
|
54
|
+
});
|
|
55
|
+
const createMock = vi.mocked(createComponent);
|
|
56
|
+
|
|
57
|
+
const expectedParam1 = {
|
|
58
|
+
name: "myScroll",
|
|
59
|
+
itemMargin: 550,
|
|
60
|
+
itemView: "Rail",
|
|
61
|
+
type: SCROLL_VIEW,
|
|
62
|
+
path: "path/to/component",
|
|
63
|
+
};
|
|
64
|
+
const expectedParam2 = { type: "scrollItemView", name: "Rail", path: "path/to/component" };
|
|
65
|
+
const expectedParam3 = { type: "tileView", name: "mockTile", path: "path/to/component" };
|
|
66
|
+
await addScroll("myScroll", { path: "path/to/component" });
|
|
67
|
+
expect(createMock.mock.calls[0][0]).toStrictEqual([expectedParam1, expectedParam2, expectedParam3]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should create custom component if custom option", async () => {
|
|
71
|
+
const createMock = vi.mocked(createComponent);
|
|
72
|
+
|
|
73
|
+
await addScroll("myScroll", { itemView: "myItem", custom: true, itemMargin: 42, path: "path/to/component" });
|
|
74
|
+
expect(createMock.mock.calls[0][0]).toStrictEqual([
|
|
75
|
+
{
|
|
76
|
+
type: SCROLLVIEW_DEFAULT_CONFIG.type,
|
|
77
|
+
name: "myScroll",
|
|
78
|
+
itemView: "myItem",
|
|
79
|
+
custom: true,
|
|
80
|
+
itemMargin: 42,
|
|
81
|
+
addMock: false,
|
|
82
|
+
path: "path/to/component",
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
expect(() => vol.readFileSync(path.resolve(process.cwd(), "scrollViewMock.json"))).toThrow(
|
|
86
|
+
"ENOENT: no such file or directory",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { afterEach, describe, expect, vi } from "vitest";
|
|
2
|
+
import * as prompts from "@clack/prompts";
|
|
3
|
+
import ComponentConfig from "@/commands/addComponent/config/ComponentConfig.js";
|
|
4
|
+
import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
|
|
5
|
+
import {
|
|
6
|
+
RAIL_DEFAULT_CONFIG,
|
|
7
|
+
MENU_DEFAULT_CONFIG,
|
|
8
|
+
SCROLLVIEW_DEFAULT_CONFIG,
|
|
9
|
+
} from "@/commands/addComponent/const/defaultConfig.js";
|
|
10
|
+
import { ConfigOptions, OptionList } from "@/common/types/helperTypes.js";
|
|
11
|
+
vi.mock("@clack/prompts");
|
|
12
|
+
vi.mock("@/commands/addComponent/helper/ComponentHelper");
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.resetAllMocks();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("askName", () => {
|
|
19
|
+
it("should get user input and return a formatted string", async () => {
|
|
20
|
+
vi.mocked(prompts.text).mockResolvedValue("myRail ");
|
|
21
|
+
const result = await ComponentConfig.askName("rail");
|
|
22
|
+
expect(result).toBe("myRail");
|
|
23
|
+
});
|
|
24
|
+
it("should return trimmed command string", async () => {
|
|
25
|
+
const result = await ComponentConfig.askName("rail", "myOtherRail ");
|
|
26
|
+
expect(result).toBe("myOtherRail");
|
|
27
|
+
});
|
|
28
|
+
it("should handle cancellation", async () => {
|
|
29
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
30
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
31
|
+
throw new Error("Cancelled.");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return expect(ComponentConfig.askName("rail")).rejects.toThrow("Cancelled.");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("askNumber", () => {
|
|
39
|
+
it("should get user input and return a formatted string", async () => {
|
|
40
|
+
vi.mocked(prompts.text).mockResolvedValue("25 ");
|
|
41
|
+
const result = await ComponentConfig.askNumber("margin");
|
|
42
|
+
expect(result).toBe(25);
|
|
43
|
+
});
|
|
44
|
+
it("should return input as it is", async () => {
|
|
45
|
+
const result = await ComponentConfig.askNumber("margin", 42);
|
|
46
|
+
expect(result).toBe(42);
|
|
47
|
+
});
|
|
48
|
+
it("should handle cancellation", async () => {
|
|
49
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
50
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
51
|
+
throw new Error("Cancelled.");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return expect(ComponentConfig.askNumber("margin")).rejects.toThrow("Cancelled.");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("askComponentOption", () => {
|
|
59
|
+
const OPTION_MOCK: OptionList = [
|
|
60
|
+
{
|
|
61
|
+
value: "fixed",
|
|
62
|
+
label: "Fixed",
|
|
63
|
+
command: "fx",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: "other",
|
|
67
|
+
label: "Other",
|
|
68
|
+
command: "oz",
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
it("should return the option from command line if correct", async () => {
|
|
73
|
+
const data = {
|
|
74
|
+
componentOption: "fx",
|
|
75
|
+
optionList: OPTION_MOCK,
|
|
76
|
+
optionType: "option",
|
|
77
|
+
};
|
|
78
|
+
vi.mocked(ComponentHelper.checkOption).mockReturnValue("fixed");
|
|
79
|
+
const result = await ComponentConfig.askComponentOption(data);
|
|
80
|
+
expect(vi.mocked(ComponentHelper.checkOption)).toHaveBeenCalledWith("fx", OPTION_MOCK, "option");
|
|
81
|
+
expect(vi.mocked(ComponentHelper.selectionFactory)).not.toHaveBeenCalled();
|
|
82
|
+
expect(result).toBe("fixed");
|
|
83
|
+
});
|
|
84
|
+
it("should prompt user to select an option if command line is not correct", async () => {
|
|
85
|
+
const data = {
|
|
86
|
+
componentOption: "oops",
|
|
87
|
+
optionList: OPTION_MOCK,
|
|
88
|
+
optionType: "option",
|
|
89
|
+
};
|
|
90
|
+
vi.mocked(ComponentHelper.checkOption).mockReturnValue("");
|
|
91
|
+
vi.mocked(ComponentHelper.selectionFactory).mockResolvedValue("other");
|
|
92
|
+
|
|
93
|
+
const result = await ComponentConfig.askComponentOption(data);
|
|
94
|
+
expect(vi.mocked(ComponentHelper.checkOption)).toHaveBeenCalledWith("oops", OPTION_MOCK, "option");
|
|
95
|
+
expect(vi.mocked(ComponentHelper.selectionFactory)).toHaveBeenCalledWith(
|
|
96
|
+
"option",
|
|
97
|
+
OPTION_MOCK,
|
|
98
|
+
"Option option",
|
|
99
|
+
);
|
|
100
|
+
expect(result).toBe("other");
|
|
101
|
+
});
|
|
102
|
+
it("should prompt user to select an option if no option from command line", async () => {
|
|
103
|
+
const data = {
|
|
104
|
+
componentOption: "",
|
|
105
|
+
optionList: OPTION_MOCK,
|
|
106
|
+
optionType: "option",
|
|
107
|
+
};
|
|
108
|
+
vi.mocked(ComponentHelper.checkOption).mockReturnValue("");
|
|
109
|
+
vi.mocked(ComponentHelper.selectionFactory).mockResolvedValue("other");
|
|
110
|
+
|
|
111
|
+
const result = await ComponentConfig.askComponentOption(data);
|
|
112
|
+
expect(vi.mocked(ComponentHelper.checkOption)).toHaveBeenCalledWith("", OPTION_MOCK, "option");
|
|
113
|
+
expect(vi.mocked(ComponentHelper.selectionFactory)).toHaveBeenCalledWith(
|
|
114
|
+
"option",
|
|
115
|
+
OPTION_MOCK,
|
|
116
|
+
"Option option",
|
|
117
|
+
);
|
|
118
|
+
expect(result).toBe("other");
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("askCyclic", () => {
|
|
123
|
+
it("should return a boolean from command line", async () => {
|
|
124
|
+
const data = {
|
|
125
|
+
cyclic: true,
|
|
126
|
+
} as unknown as ConfigOptions;
|
|
127
|
+
expect(await ComponentConfig.askCyclic(data)).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
it("should return a boolean from prompt if no option provided", async () => {
|
|
130
|
+
const data = {} as unknown as ConfigOptions;
|
|
131
|
+
vi.mocked(prompts.confirm).mockResolvedValue(false);
|
|
132
|
+
expect(await ComponentConfig.askCyclic(data)).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
it("should handle cancellation", async () => {
|
|
135
|
+
vi.mocked(prompts.text).mockResolvedValue("");
|
|
136
|
+
vi.spyOn(ComponentHelper, "handleCancellation").mockImplementationOnce(() => {
|
|
137
|
+
throw new Error("Cyclic Cancelled.");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await expect(ComponentConfig.askCyclic({})).rejects.toThrow("Cyclic Cancelled.");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("railConfig", () => {
|
|
145
|
+
it("should return default config", async () => {
|
|
146
|
+
expect(await ComponentConfig.railConfig({})).toStrictEqual({ ...RAIL_DEFAULT_CONFIG });
|
|
147
|
+
});
|
|
148
|
+
it("should return default config for undefined options only", async () => {
|
|
149
|
+
const data = {
|
|
150
|
+
isCyclic: true,
|
|
151
|
+
direction: "vertical",
|
|
152
|
+
} as unknown as ConfigOptions;
|
|
153
|
+
expect(await ComponentConfig.railConfig(data)).toStrictEqual({
|
|
154
|
+
...RAIL_DEFAULT_CONFIG,
|
|
155
|
+
direction: "vertical",
|
|
156
|
+
isCyclic: true,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
it("should return custom config", async () => {
|
|
160
|
+
const data = {
|
|
161
|
+
custom: "true",
|
|
162
|
+
} as unknown as ConfigOptions;
|
|
163
|
+
const mockResults = {
|
|
164
|
+
name: "aName",
|
|
165
|
+
navigation: "fixed",
|
|
166
|
+
direction: "horizontal",
|
|
167
|
+
isCyclic: true,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
vi.spyOn(prompts, "group").mockResolvedValue(mockResults);
|
|
171
|
+
|
|
172
|
+
expect(await ComponentConfig.railConfig(data)).toStrictEqual({
|
|
173
|
+
...RAIL_DEFAULT_CONFIG,
|
|
174
|
+
...mockResults,
|
|
175
|
+
addMock: false,
|
|
176
|
+
custom: "true",
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe("menuConfig", () => {
|
|
182
|
+
it("should return default config", async () => {
|
|
183
|
+
expect(await ComponentConfig.menuConfig({})).toStrictEqual({ ...MENU_DEFAULT_CONFIG, addMock: true });
|
|
184
|
+
});
|
|
185
|
+
it("should return default config for undefined options only", async () => {
|
|
186
|
+
const param = {
|
|
187
|
+
direction: "v",
|
|
188
|
+
} as unknown as ConfigOptions;
|
|
189
|
+
expect(await ComponentConfig.menuConfig(param)).toStrictEqual({
|
|
190
|
+
...MENU_DEFAULT_CONFIG,
|
|
191
|
+
direction: "v",
|
|
192
|
+
addMock: true,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
it("should return custom config", async () => {
|
|
196
|
+
const param = {
|
|
197
|
+
custom: "true",
|
|
198
|
+
} as unknown as ConfigOptions;
|
|
199
|
+
const mockResults = {
|
|
200
|
+
name: "menuName",
|
|
201
|
+
itemMargin: 42,
|
|
202
|
+
itemView: "itemName",
|
|
203
|
+
direction: "vertical",
|
|
204
|
+
};
|
|
205
|
+
const expectedResults = {
|
|
206
|
+
name: "menuName",
|
|
207
|
+
itemMargin: 42,
|
|
208
|
+
itemView: "itemName",
|
|
209
|
+
direction: "vertical",
|
|
210
|
+
addMock: false,
|
|
211
|
+
custom: "true",
|
|
212
|
+
type: MENU_DEFAULT_CONFIG.type,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
vi.spyOn(prompts, "group").mockResolvedValue(mockResults);
|
|
216
|
+
const result = await ComponentConfig.menuConfig(param);
|
|
217
|
+
expect(result).toStrictEqual(expectedResults);
|
|
218
|
+
expect(vi.mocked(prompts.group)).toHaveBeenCalledTimes(1);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("scrollViewConfig", () => {
|
|
223
|
+
it("should return default config for undefined options", async () => {
|
|
224
|
+
const param: ConfigOptions = {
|
|
225
|
+
name: "myScroll",
|
|
226
|
+
};
|
|
227
|
+
expect(await ComponentConfig.scrollViewConfig(param)).toStrictEqual({
|
|
228
|
+
...SCROLLVIEW_DEFAULT_CONFIG,
|
|
229
|
+
name: "myScroll",
|
|
230
|
+
addMock: true,
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
it("should return default config", async () => {
|
|
234
|
+
expect(await ComponentConfig.scrollViewConfig({})).toStrictEqual({
|
|
235
|
+
...SCROLLVIEW_DEFAULT_CONFIG,
|
|
236
|
+
addMock: true,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
it("should return custom config", async () => {
|
|
240
|
+
const param = {
|
|
241
|
+
custom: "true",
|
|
242
|
+
} as unknown as ConfigOptions;
|
|
243
|
+
const mockResults = {
|
|
244
|
+
name: "customScroll",
|
|
245
|
+
itemView: "customRail",
|
|
246
|
+
itemMargin: 42,
|
|
247
|
+
};
|
|
248
|
+
const expectedResults = {
|
|
249
|
+
addMock: false,
|
|
250
|
+
type: SCROLLVIEW_DEFAULT_CONFIG.type,
|
|
251
|
+
name: "customScroll",
|
|
252
|
+
itemMargin: 42,
|
|
253
|
+
itemView: "customRail",
|
|
254
|
+
custom: "true",
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
vi.spyOn(prompts, "group").mockResolvedValue(mockResults);
|
|
258
|
+
|
|
259
|
+
expect(await ComponentConfig.scrollViewConfig(param)).toStrictEqual(expectedResults);
|
|
260
|
+
});
|
|
261
|
+
});
|