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,262 @@
|
|
|
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 { exec, ChildProcess, spawn, execSync } from "node:child_process";
|
|
14
|
+
import * as deviceConst from "@/common/const/deviceConst.js";
|
|
15
|
+
import InstallHelper from "@/common/helpers/InstallHelper.js";
|
|
16
|
+
import { Config } from "@/common/types/helperTypes.js";
|
|
17
|
+
import { vi, afterEach, describe, it, expect, MockedFunction, beforeEach } from "vitest";
|
|
18
|
+
import { vol } from "memfs";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { readFile } from "node:fs/promises";
|
|
21
|
+
|
|
22
|
+
const PLATFORM_CONFIG = {
|
|
23
|
+
tvos: {
|
|
24
|
+
label: "TV OS",
|
|
25
|
+
package: "tvos1",
|
|
26
|
+
dependencies: ["tvos1", "tvos2"],
|
|
27
|
+
},
|
|
28
|
+
webos: {
|
|
29
|
+
label: "LG",
|
|
30
|
+
package: "webos1",
|
|
31
|
+
dependencies: ["webos1"],
|
|
32
|
+
renderers: {
|
|
33
|
+
css: ["webos-css"],
|
|
34
|
+
lightning: ["webos-lightning"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
tizen: {
|
|
38
|
+
label: "Samsung",
|
|
39
|
+
package: "tizen1",
|
|
40
|
+
dependencies: ["tizen1", "tizen2"],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
vi.mock("node:child_process", () => {
|
|
45
|
+
return {
|
|
46
|
+
execSync: vi.fn(),
|
|
47
|
+
spawn: vi.fn(),
|
|
48
|
+
exec: vi.fn(),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
vi.mock("node:fs/promises");
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
vi.resetAllMocks();
|
|
55
|
+
vi.restoreAllMocks();
|
|
56
|
+
vol.reset();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("getAllDependencies", () => {
|
|
60
|
+
it("should return an array of dependencies", () => {
|
|
61
|
+
vi.spyOn(deviceConst, "PLATFORM_CONFIG", "get").mockReturnValue(PLATFORM_CONFIG);
|
|
62
|
+
const expected = ["tvos1", "tvos2", "webos1", "webos-css"];
|
|
63
|
+
const selectedDevices = ["tvos", "webos"];
|
|
64
|
+
const config = { webos: { renderers: ["css"] } } as Config;
|
|
65
|
+
|
|
66
|
+
const result = InstallHelper.getAllDependencies(selectedDevices, config);
|
|
67
|
+
expect(result).toEqual(expected);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("installDependencies", () => {
|
|
72
|
+
const directory = "/directory",
|
|
73
|
+
allowBeta = false,
|
|
74
|
+
basicDepMock = ["@dana/engine-nodejs", "@wiztivi/dana-templates"],
|
|
75
|
+
allDepMock = ["@dana/engine-nodejs", "@wiztivi/dana-templates", "dep3"]; //returned by devDependencies = [...new Set(devDependencies)];
|
|
76
|
+
const mockJsonData = {
|
|
77
|
+
includes: {},
|
|
78
|
+
devDependencies: {
|
|
79
|
+
"@dana/engine-nodejs": "1.0.0",
|
|
80
|
+
"@wiztivi/dana-templates": "2.0.11",
|
|
81
|
+
dep3: "3.0.0",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const filePath = path.join(directory, "package.json");
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
vol.fromJSON({
|
|
88
|
+
[filePath]: JSON.stringify(mockJsonData),
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
it("should execute npm i with directory option", async () => {
|
|
92
|
+
const spawnMock = vi.mocked(spawn).mockReturnValue({
|
|
93
|
+
on: vi.fn((event: string, callback: (code: number) => void) => {
|
|
94
|
+
if (event === "close") callback(0);
|
|
95
|
+
}),
|
|
96
|
+
} as unknown as ChildProcess);
|
|
97
|
+
|
|
98
|
+
await InstallHelper.installDependencies({ directory, allowBeta }, basicDepMock);
|
|
99
|
+
expect(spawnMock).toHaveBeenCalledWith("npm", ["i", "--silent"], { shell: true, cwd: directory });
|
|
100
|
+
});
|
|
101
|
+
it("Should exec npm i for each dependency", async () => {
|
|
102
|
+
const expectedJsonData = {
|
|
103
|
+
includes: {},
|
|
104
|
+
devDependencies: {
|
|
105
|
+
"@dana/engine-nodejs": "1.0.x",
|
|
106
|
+
"@wiztivi/dana-templates": "2.0.11",
|
|
107
|
+
dep3: "3.0.0",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const spawnMock = vi.mocked(spawn).mockReturnValue({
|
|
111
|
+
on: vi.fn((event, callback: (code: number) => void) => {
|
|
112
|
+
if (event === "close") callback(0);
|
|
113
|
+
}),
|
|
114
|
+
} as unknown as ChildProcess);
|
|
115
|
+
|
|
116
|
+
const result = await InstallHelper.installDependencies({ directory, allowBeta }, allDepMock);
|
|
117
|
+
//call index is 1 because of cmd1 executed first
|
|
118
|
+
expect(spawnMock.mock.calls[1][0]).toBe("npm");
|
|
119
|
+
expect(spawnMock.mock.calls[1][1]).toEqual([
|
|
120
|
+
"i",
|
|
121
|
+
"@dana/engine-nodejs",
|
|
122
|
+
"@wiztivi/dana-templates",
|
|
123
|
+
"dep3",
|
|
124
|
+
"--save-dev",
|
|
125
|
+
"--save-exact",
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
expect(result).toBe("Dependencies updated");
|
|
129
|
+
const copiedMock = await readFile(filePath, "utf-8");
|
|
130
|
+
expect(JSON.parse(copiedMock)).toEqual(expectedJsonData);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("Should reject if a dependency installation failed", async () => {
|
|
134
|
+
vi.mocked(spawn).mockImplementation((_cmd, args) => {
|
|
135
|
+
const hasDep3 = args.includes("dep3");
|
|
136
|
+
return {
|
|
137
|
+
on: vi.fn((event, callback: (code: number) => void) => {
|
|
138
|
+
if (event === "close") callback(hasDep3 ? 1 : 0);
|
|
139
|
+
}),
|
|
140
|
+
} as unknown as ChildProcess;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return expect(InstallHelper.installDependencies({ directory, allowBeta }, allDepMock)).rejects.toThrow();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("Should reject if process failed", async () => {
|
|
147
|
+
vi.mocked(spawn).mockImplementation((_cmd, args) => {
|
|
148
|
+
const failCase = args.includes("dep3");
|
|
149
|
+
return {
|
|
150
|
+
on: vi.fn((event, callback: (error: Error | number) => void) => {
|
|
151
|
+
if (event === "error" && failCase) {
|
|
152
|
+
callback(new Error("nope"));
|
|
153
|
+
}
|
|
154
|
+
if (!failCase && event === "close") {
|
|
155
|
+
callback(0);
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
} as unknown as ChildProcess;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return expect(InstallHelper.installDependencies({ directory, allowBeta }, allDepMock)).rejects.toThrow(
|
|
162
|
+
"Dependencies update failed : FAILURE during dependency installation : nope",
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe("installGrunt", () => {
|
|
168
|
+
it("Should install grunt", async () => {
|
|
169
|
+
const mockedExec = exec as MockedFunction<typeof exec>;
|
|
170
|
+
mockedExec.mockImplementation((cmd: string, options, callback) => {
|
|
171
|
+
if (callback) {
|
|
172
|
+
callback(null, "Grunt installed", "");
|
|
173
|
+
}
|
|
174
|
+
return {} as ChildProcess;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const result = await InstallHelper.installGrunt();
|
|
178
|
+
|
|
179
|
+
expect(result).toBe("Grunt installed");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe("initGit", () => {
|
|
184
|
+
const directory = "/directory";
|
|
185
|
+
it("Should execute git command", async () => {
|
|
186
|
+
const spawnMock = vi.mocked(spawn).mockReturnValue({
|
|
187
|
+
on: vi.fn((event, callback: (code: number) => void) => {
|
|
188
|
+
if (event === "close") callback(0);
|
|
189
|
+
}),
|
|
190
|
+
} as unknown as ChildProcess);
|
|
191
|
+
await InstallHelper.initGit({ directory });
|
|
192
|
+
expect(spawnMock.mock.calls[0]).toEqual(["git", ["init"], { cwd: "/directory" }]);
|
|
193
|
+
expect(spawnMock.mock.calls[1]).toEqual(["git", ["add", "."], { cwd: "/directory" }]);
|
|
194
|
+
expect(spawnMock.mock.calls[2]).toEqual([
|
|
195
|
+
"git",
|
|
196
|
+
["commit", "-m", "Initial commit from Create DANA App"],
|
|
197
|
+
{ cwd: "/directory" },
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
it("Should resolve if success", async () => {
|
|
201
|
+
vi.mocked(spawn).mockReturnValue({
|
|
202
|
+
on: vi.fn((event, callback: (code: number) => void) => {
|
|
203
|
+
if (event === "close") callback(0);
|
|
204
|
+
}),
|
|
205
|
+
} as unknown as ChildProcess);
|
|
206
|
+
|
|
207
|
+
const result = await InstallHelper.initGit({ directory });
|
|
208
|
+
expect(result).toEqual("Git initialized");
|
|
209
|
+
});
|
|
210
|
+
it("Should reject if error code on close", async () => {
|
|
211
|
+
vi.mocked(spawn).mockImplementation((_cmd, args) => {
|
|
212
|
+
const failCase = args.includes("add");
|
|
213
|
+
return {
|
|
214
|
+
on: vi.fn((event, callback: (code: number) => void) => {
|
|
215
|
+
if (event === "close") callback(failCase ? 1 : 0);
|
|
216
|
+
}),
|
|
217
|
+
} as unknown as ChildProcess;
|
|
218
|
+
});
|
|
219
|
+
return expect(InstallHelper.initGit({ directory })).rejects.toThrow(
|
|
220
|
+
"Git hasn't been initialised: Git add failed",
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
it("Should reject if process error", async () => {
|
|
224
|
+
vi.mocked(spawn).mockImplementation((_cmd, args) => {
|
|
225
|
+
const failCase = args.includes("commit");
|
|
226
|
+
return {
|
|
227
|
+
on: vi.fn((event, callback: (error: Error | number) => void) => {
|
|
228
|
+
if (event === "error" && failCase) {
|
|
229
|
+
callback(new Error("nope"));
|
|
230
|
+
}
|
|
231
|
+
if (!failCase && event === "close") {
|
|
232
|
+
callback(0);
|
|
233
|
+
}
|
|
234
|
+
}),
|
|
235
|
+
} as unknown as ChildProcess;
|
|
236
|
+
});
|
|
237
|
+
return expect(InstallHelper.initGit({ directory })).rejects.toThrow(
|
|
238
|
+
"Git hasn't been initialised: Git commit failed: nope",
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe("getDependenceVersion", () => {
|
|
244
|
+
it("Should return version of a dependency", () => {
|
|
245
|
+
const depList = ["@dana/engine-nodejs", "@wiztivi/dana-templates", "dep3", "@wiztivi/dana-core"];
|
|
246
|
+
|
|
247
|
+
const expectedDepList = [
|
|
248
|
+
"@dana/engine-nodejs@latest",
|
|
249
|
+
"@wiztivi/dana-templates@beta",
|
|
250
|
+
"dep3",
|
|
251
|
+
"@wiztivi/dana-core",
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
vi.mocked(execSync)
|
|
255
|
+
.mockReturnValueOnce(JSON.stringify({ latest: " 7.251.0" }))
|
|
256
|
+
.mockReturnValueOnce(JSON.stringify({ latest: " 7.251.0", beta: "7.251.1" }))
|
|
257
|
+
.mockRejectedValueOnce(new Error());
|
|
258
|
+
|
|
259
|
+
const result = InstallHelper.getDependenceVersion(depList);
|
|
260
|
+
expect(result).toStrictEqual(expectedDepList);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
@@ -0,0 +1,288 @@
|
|
|
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 UpdateFileHelper from "@/common/helpers/UpdateFileHelper.js";
|
|
14
|
+
import CreateAppHelper from "@/commands/createApp/helpers/CreateAppHelper.js";
|
|
15
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { beforeEach, expect, MockedFunction, vi } from "vitest";
|
|
18
|
+
import { ANDROIDTV, WEBOS } from "@/common/const/deviceConst.js";
|
|
19
|
+
import WebosConfig from "@/commands/addDevice/deviceConfig/webosConfig.js";
|
|
20
|
+
import DeviceConfig from "@/commands/addDevice/deviceConfig/deviceConfig.js";
|
|
21
|
+
import { AndroidConfig, WebosConf } from "@/commands/addDevice/deviceConfig/configTypes.js";
|
|
22
|
+
import { Data } from "@/common/types/helperTypes.js";
|
|
23
|
+
import AndroidtvConfig from "@/commands/addDevice/deviceConfig/androidtvConfig.js";
|
|
24
|
+
import { templateGenerator } from "@/common/helpers/handlebarsHelper.js";
|
|
25
|
+
import { AwsCredentials, CredentialsHelper, DanaToken } from "@/commands/authentication/helper/CredentialsHelper.js";
|
|
26
|
+
import { getRepositoryEndpoint } from "@/commands/authentication/helper/CodeArtifactHelper.js";
|
|
27
|
+
import { REGISTRY_KEY } from "@/commands/createApp/const/setupConst.js";
|
|
28
|
+
import { vol } from "memfs";
|
|
29
|
+
|
|
30
|
+
vi.mock("node:fs/promises");
|
|
31
|
+
vi.mock("node:path", async () => {
|
|
32
|
+
const actual = await vi.importActual<typeof import("node:path")>("node:path");
|
|
33
|
+
return {
|
|
34
|
+
...actual,
|
|
35
|
+
resolve: vi.fn().mockReturnValue("/templates/mockTemplate"),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
vi.mock("@/commands/createApp/helpers/CreateAppHelper");
|
|
39
|
+
vi.mock("@/common/helpers/handlebarsHelper");
|
|
40
|
+
vi.mock("@/commands/authentication/helper/CredentialsHelper");
|
|
41
|
+
vi.mock("@/commands/authentication/helper/CodeArtifactHelper");
|
|
42
|
+
const directory = "/directory";
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
vi.resetAllMocks();
|
|
46
|
+
vol.reset();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("updateAppConfigFile", () => {
|
|
50
|
+
it("should update app.config.json with profile list", async () => {
|
|
51
|
+
const dirPath = path.join(directory, "profiles");
|
|
52
|
+
const filePath = path.join(directory, "app.config.json");
|
|
53
|
+
|
|
54
|
+
vol.fromJSON({
|
|
55
|
+
[dirPath]: null,
|
|
56
|
+
[filePath]: JSON.stringify({ includes: [] }),
|
|
57
|
+
[path.join(dirPath, "profile1.json")]: JSON.stringify({ name: "profile1.json" }),
|
|
58
|
+
[path.join(dirPath, "profile2.json")]: JSON.stringify({ name: "profile2.json" }),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const expectedResult = {
|
|
62
|
+
includes: [path.join("profiles", "profile1.json"), path.join("profiles", "profile2.json")],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const result = await UpdateFileHelper.updateAppConfigFile({ directory });
|
|
66
|
+
|
|
67
|
+
const copiedMock = await readFile(filePath, "utf-8");
|
|
68
|
+
expect(copiedMock).toBe(JSON.stringify(expectedResult, null, 4));
|
|
69
|
+
expect(result).toBe("Config file(s) updated");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("updateNpmrcFile", () => {
|
|
73
|
+
it("should update npmrc file", async () => {
|
|
74
|
+
const filePath = path.join(directory, ".npmrc");
|
|
75
|
+
vi.mocked(CredentialsHelper.get).mockResolvedValue({
|
|
76
|
+
aws: {} as AwsCredentials,
|
|
77
|
+
dana: {} as DanaToken,
|
|
78
|
+
org: "org",
|
|
79
|
+
isRemote: false,
|
|
80
|
+
});
|
|
81
|
+
vol.fromJSON({
|
|
82
|
+
[path.join(directory, ".npmrc")]: JSON.stringify({}),
|
|
83
|
+
});
|
|
84
|
+
vi.mocked(getRepositoryEndpoint).mockResolvedValue("@dana/test/dana-mock-repository");
|
|
85
|
+
|
|
86
|
+
const result = await UpdateFileHelper.updateNpmrcFile({ directory });
|
|
87
|
+
|
|
88
|
+
const copiedMock = await readFile(filePath, "utf-8");
|
|
89
|
+
expect(copiedMock).toBe(`${REGISTRY_KEY}=@dana/test/dana-mock-repository`);
|
|
90
|
+
expect(result).toBe("AWS profile updated");
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("updatePackageJson", () => {
|
|
95
|
+
const packageJsonMock = {
|
|
96
|
+
name: "Template project",
|
|
97
|
+
version: "1.0.0",
|
|
98
|
+
scripts: {},
|
|
99
|
+
};
|
|
100
|
+
const params = {
|
|
101
|
+
name: "~my/project",
|
|
102
|
+
directory,
|
|
103
|
+
selectedDevices: [ANDROIDTV, WEBOS],
|
|
104
|
+
config: {
|
|
105
|
+
androidtv: {},
|
|
106
|
+
webos: { renderers: ["css"] },
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const expectedParams = {
|
|
110
|
+
name: "myproject",
|
|
111
|
+
version: "1.0.0",
|
|
112
|
+
scripts: {
|
|
113
|
+
"start:androidtv": UpdateFileHelper.setScriptValue("androidtv"),
|
|
114
|
+
"start:webos_css": UpdateFileHelper.setScriptValue("webos_css"),
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
beforeEach(() => {
|
|
119
|
+
vol.fromJSON({
|
|
120
|
+
[path.join(directory, "package.json")]: JSON.stringify(packageJsonMock),
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("should update package.json", async () => {
|
|
125
|
+
const result = await UpdateFileHelper.updatePackageJson(params as Data);
|
|
126
|
+
expect(result).toBe("Package updated");
|
|
127
|
+
const copiedMock = await readFile(path.join(directory, "package.json"), "utf-8");
|
|
128
|
+
expect(copiedMock).toEqual(JSON.stringify(expectedParams, null, 4));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("should update package.json but not name if no name is provided", async () => {
|
|
132
|
+
const params = {
|
|
133
|
+
directory,
|
|
134
|
+
selectedDevices: [ANDROIDTV, WEBOS],
|
|
135
|
+
config: {
|
|
136
|
+
androidtv: {},
|
|
137
|
+
webos: { renderers: ["css"] },
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
expectedParams.name = "Template project";
|
|
141
|
+
|
|
142
|
+
const result = await UpdateFileHelper.updatePackageJson(params as Data);
|
|
143
|
+
expect(result).toBe("Package updated");
|
|
144
|
+
const copiedMock = await readFile(path.join(directory, "package.json"), "utf-8");
|
|
145
|
+
expect(copiedMock).toEqual(JSON.stringify(expectedParams, null, 4));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe("setDevicesConfig", () => {
|
|
149
|
+
const selectedDevices = ["androidtv", "webos"];
|
|
150
|
+
const config = {
|
|
151
|
+
androidtv: {} as AndroidConfig,
|
|
152
|
+
webos: {
|
|
153
|
+
appId: "webosId",
|
|
154
|
+
} as unknown as WebosConf,
|
|
155
|
+
};
|
|
156
|
+
const awsProfile = "awsProfile";
|
|
157
|
+
const directory = "/directory";
|
|
158
|
+
const params = { directory, config, selectedDevices, awsProfile };
|
|
159
|
+
|
|
160
|
+
let helperMock: MockedFunction<(device: string) => typeof DeviceConfig>;
|
|
161
|
+
beforeEach(() => {
|
|
162
|
+
helperMock = vi
|
|
163
|
+
.mocked(CreateAppHelper.getDeviceConfig)
|
|
164
|
+
.mockReturnValueOnce(AndroidtvConfig)
|
|
165
|
+
.mockReturnValue(WebosConfig);
|
|
166
|
+
vi.spyOn(AndroidtvConfig, "setConfig").mockResolvedValue("ok");
|
|
167
|
+
vi.spyOn(WebosConfig, "setConfig").mockResolvedValue("ok");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("should call getDeviceConfig for each selected device", async () => {
|
|
171
|
+
const result = await UpdateFileHelper.setDevicesConfig(params);
|
|
172
|
+
|
|
173
|
+
expect(helperMock).toHaveBeenCalledTimes(2);
|
|
174
|
+
expect(helperMock.mock.calls[0][0]).toMatch("androidtv");
|
|
175
|
+
expect(helperMock.mock.calls[1][0]).toMatch("webos");
|
|
176
|
+
expect(result).toEqual("Configuration done");
|
|
177
|
+
});
|
|
178
|
+
it("should call setConfig for each selected device", async () => {
|
|
179
|
+
await UpdateFileHelper.setDevicesConfig(params);
|
|
180
|
+
|
|
181
|
+
expect(vi.mocked(WebosConfig.setConfig)).toHaveBeenCalledExactlyOnceWith({
|
|
182
|
+
awsProfile,
|
|
183
|
+
config: config.webos,
|
|
184
|
+
directory,
|
|
185
|
+
});
|
|
186
|
+
expect(vi.mocked(AndroidtvConfig.setConfig)).toHaveBeenCalledExactlyOnceWith({
|
|
187
|
+
awsProfile,
|
|
188
|
+
config: config.androidtv,
|
|
189
|
+
directory,
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("applyTemplatesToFiles", () => {
|
|
195
|
+
const mockOutput = "A template";
|
|
196
|
+
const routesFilePath = path.join(directory, "scripts", "app");
|
|
197
|
+
|
|
198
|
+
beforeEach(() => {
|
|
199
|
+
vol.fromJSON({
|
|
200
|
+
[routesFilePath]: null,
|
|
201
|
+
[path.join(routesFilePath, "TemplateAppRoutes.js.hbs")]: JSON.stringify({}),
|
|
202
|
+
[path.join(routesFilePath, "app.js.hbs")]: JSON.stringify({}),
|
|
203
|
+
[path.join(directory, "tests", "unit", "app", "TemplateAppRoutes.js.hbs")]: JSON.stringify({}),
|
|
204
|
+
[path.join(directory, "gitignoreTemplate.hbs")]: JSON.stringify({}),
|
|
205
|
+
[path.join(directory, "editorconfigTemplate.hbs")]: JSON.stringify({}),
|
|
206
|
+
[path.join(directory, "eslintrc.jsonTemplate.hbs")]: JSON.stringify({}),
|
|
207
|
+
[path.join(directory, "nvmrcTemplate.hbs")]: JSON.stringify({}),
|
|
208
|
+
});
|
|
209
|
+
vi.mocked(templateGenerator).mockResolvedValue(mockOutput);
|
|
210
|
+
});
|
|
211
|
+
it("should update files", async () => {
|
|
212
|
+
const callNumber = 7;
|
|
213
|
+
const result = await UpdateFileHelper.applyTemplatesToFiles({ directory: "/directory", name: "test-app" });
|
|
214
|
+
expect(templateGenerator).toHaveBeenCalledTimes(callNumber);
|
|
215
|
+
expect(vi.mocked(templateGenerator).mock.calls[0][1]).toStrictEqual({ appName: "testApp" });
|
|
216
|
+
expect(result).toBe("Files templated");
|
|
217
|
+
const modifiedMock = await readdir(directory, "utf-8");
|
|
218
|
+
expect(modifiedMock.sort()).toStrictEqual([
|
|
219
|
+
".editorconfig",
|
|
220
|
+
".eslintrc.json",
|
|
221
|
+
".gitignore",
|
|
222
|
+
".nvmrc",
|
|
223
|
+
"scripts",
|
|
224
|
+
"tests",
|
|
225
|
+
]);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe("addModuleToAppConfig", () => {
|
|
230
|
+
const directory = "/directory";
|
|
231
|
+
const filePath = path.join(directory, "app.config.json");
|
|
232
|
+
const mockJsonData = {
|
|
233
|
+
default: {
|
|
234
|
+
base: {
|
|
235
|
+
modules: ["module1"],
|
|
236
|
+
},
|
|
237
|
+
AppTheme: {
|
|
238
|
+
fonts: {
|
|
239
|
+
MockIcons: "",
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
const testModules = ["module1", "module2"];
|
|
245
|
+
const expectedAppConfig = {
|
|
246
|
+
default: {
|
|
247
|
+
base: {
|
|
248
|
+
modules: ["module1", "module2"],
|
|
249
|
+
},
|
|
250
|
+
AppTheme: {
|
|
251
|
+
fonts: {
|
|
252
|
+
MockIcons: {
|
|
253
|
+
family: "fa-solid-900",
|
|
254
|
+
path: "styles/fonts/fa-solid-900.ttf",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
it("should add modules to app.config.json", async () => {
|
|
262
|
+
vol.fromJSON({
|
|
263
|
+
[filePath]: JSON.stringify(mockJsonData, null, 4),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const result = await UpdateFileHelper.addModuleToAppConfig(
|
|
267
|
+
{ directory },
|
|
268
|
+
{ modules: testModules, shouldAddIconFont: true },
|
|
269
|
+
);
|
|
270
|
+
expect(result).toBe("App config modules updated");
|
|
271
|
+
const modifiedMock = await readFile(filePath, "utf-8");
|
|
272
|
+
expect(modifiedMock).toBe(JSON.stringify(expectedAppConfig, null, 4));
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe("updateAppTheme", () => {
|
|
277
|
+
it("should update appTheme with icon fonts", async () => {
|
|
278
|
+
const filePath: string = path.join(directory, "scripts", "app", "theme", "AppTheme.js");
|
|
279
|
+
|
|
280
|
+
vol.fromJSON({
|
|
281
|
+
[filePath]: '{icons: ""}',
|
|
282
|
+
});
|
|
283
|
+
const result = await UpdateFileHelper.updateAppTheme({ directory: "/directory" }, "icons");
|
|
284
|
+
expect(result).toBe("AppTheme statics updated");
|
|
285
|
+
const modifiedMock = await readFile(filePath, "utf-8");
|
|
286
|
+
expect(modifiedMock).toBe('{icons: "icons"}');
|
|
287
|
+
});
|
|
288
|
+
});
|