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.
Files changed (288) hide show
  1. package/.github/dependabot.yml +43 -0
  2. package/.github/labeler.yml +30 -0
  3. package/.github/workflows/bump.yml +51 -0
  4. package/.github/workflows/ci-cd.yml +110 -0
  5. package/.github/workflows/dependabot-automerge-call.yml +13 -0
  6. package/.nvmrc +1 -0
  7. package/.prettierignore +4 -0
  8. package/.prettierrc +4 -0
  9. package/CODEOWNERS +5 -0
  10. package/README.md +50 -2
  11. package/bin/bump.js +48 -0
  12. package/eslint.config.mjs +12 -0
  13. package/images/vodScreen1.png +0 -0
  14. package/package.json +53 -5
  15. package/sonar-project.properties +20 -0
  16. package/tools/cli/README.md +51 -0
  17. package/tools/cli/__mocks__/fs/promises.cjs +4 -0
  18. package/tools/cli/bin/dana.js +3 -0
  19. package/tools/cli/dana_completion.sh +156 -0
  20. package/tools/cli/eslint.config.mjs +14 -0
  21. package/tools/cli/package.json +67 -0
  22. package/tools/cli/rollup.config.mjs +26 -0
  23. package/tools/cli/src/commands/addComponent/addMenu/add-menu.ts +65 -0
  24. package/tools/cli/src/commands/addComponent/addMenu/addMenuDefinition.ts +21 -0
  25. package/tools/cli/src/commands/addComponent/addRail/add-rail.ts +59 -0
  26. package/tools/cli/src/commands/addComponent/addRail/addRailDefinition.ts +34 -0
  27. package/tools/cli/src/commands/addComponent/addScreen/add-screen.ts +42 -0
  28. package/tools/cli/src/commands/addComponent/addScreen/addScreenDefinition.ts +17 -0
  29. package/tools/cli/src/commands/addComponent/addScrollView/add-scrollView.ts +48 -0
  30. package/tools/cli/src/commands/addComponent/addScrollView/addScrollViewDefinition.ts +16 -0
  31. package/tools/cli/src/commands/addComponent/config/ComponentConfig.ts +169 -0
  32. package/tools/cli/src/commands/addComponent/config/componentTypes.ts +38 -0
  33. package/tools/cli/src/commands/addComponent/const/componentConst.ts +20 -0
  34. package/tools/cli/src/commands/addComponent/const/defaultConfig.ts +28 -0
  35. package/tools/cli/src/commands/addComponent/const/navigationConst.ts +36 -0
  36. package/tools/cli/src/commands/addComponent/createComponent.ts +45 -0
  37. package/tools/cli/src/commands/addComponent/helper/ComponentHelper.ts +98 -0
  38. package/tools/cli/src/commands/addDevice/add-device.ts +106 -0
  39. package/tools/cli/src/commands/addDevice/addDeviceDefinition.ts +13 -0
  40. package/tools/cli/src/commands/addDevice/deviceConfig/androidtvConfig.ts +142 -0
  41. package/tools/cli/src/commands/addDevice/deviceConfig/configTypes.ts +44 -0
  42. package/tools/cli/src/commands/addDevice/deviceConfig/deviceConfig.ts +38 -0
  43. package/tools/cli/src/commands/addDevice/deviceConfig/titanosConfig.ts +17 -0
  44. package/tools/cli/src/commands/addDevice/deviceConfig/tizenConfig.ts +64 -0
  45. package/tools/cli/src/commands/addDevice/deviceConfig/tvosConfig.ts +50 -0
  46. package/tools/cli/src/commands/addDevice/deviceConfig/vidaaConfig.ts +17 -0
  47. package/tools/cli/src/commands/addDevice/deviceConfig/webosConfig.ts +64 -0
  48. package/tools/cli/src/commands/addDevice/helper/addDeviceHelper.ts +121 -0
  49. package/tools/cli/src/commands/addDianaSkills/add-dianaSkills.ts +55 -0
  50. package/tools/cli/src/commands/addDianaSkills/addDianaSkillsDefinition.ts +13 -0
  51. package/tools/cli/src/commands/addDianaSkills/dianaDependencies.ts +15 -0
  52. package/tools/cli/src/commands/addModule/add-module.ts +46 -0
  53. package/tools/cli/src/commands/addModule/addModuleDefinition.ts +17 -0
  54. package/tools/cli/src/commands/addModule/moduleConst.ts +18 -0
  55. package/tools/cli/src/commands/authentication/AuthenticationManager.ts +255 -0
  56. package/tools/cli/src/commands/authentication/authDefinition.ts +51 -0
  57. package/tools/cli/src/commands/authentication/authHook.ts +50 -0
  58. package/tools/cli/src/commands/authentication/authentConst.ts +6 -0
  59. package/tools/cli/src/commands/authentication/commands/get-packages-token.ts +40 -0
  60. package/tools/cli/src/commands/authentication/commands/login.ts +63 -0
  61. package/tools/cli/src/commands/authentication/commands/logout.ts +26 -0
  62. package/tools/cli/src/commands/authentication/commands/status.ts +47 -0
  63. package/tools/cli/src/commands/authentication/helper/CodeArtifactHelper.ts +66 -0
  64. package/tools/cli/src/commands/authentication/helper/CommandHelper.ts +9 -0
  65. package/tools/cli/src/commands/authentication/helper/CredentialsHelper.ts +176 -0
  66. package/tools/cli/src/commands/authentication/helper/SPM.ts +95 -0
  67. package/tools/cli/src/commands/authentication/tokenHook.ts +30 -0
  68. package/tools/cli/src/commands/commandHelp/customHelp.ts +31 -0
  69. package/tools/cli/src/commands/completion/completion.ts +53 -0
  70. package/tools/cli/src/commands/completion/completionDefinition.ts +16 -0
  71. package/tools/cli/src/commands/createApp/const/createAppTasks.ts +133 -0
  72. package/tools/cli/src/commands/createApp/const/setupConst.ts +16 -0
  73. package/tools/cli/src/commands/createApp/const/templateConst.ts +10 -0
  74. package/tools/cli/src/commands/createApp/createApp.ts +60 -0
  75. package/tools/cli/src/commands/createApp/createAppDefinition.ts +26 -0
  76. package/tools/cli/src/commands/createApp/helpers/CreateAppHelper.ts +167 -0
  77. package/tools/cli/src/commands/createApp/helpers/SetupChecker.ts +98 -0
  78. package/tools/cli/src/commands/hooks/checkDanaProjectHook.ts +30 -0
  79. package/tools/cli/src/commands/zip/zip.ts +26 -0
  80. package/tools/cli/src/commands/zip/zipDefinition.ts +13 -0
  81. package/tools/cli/src/common/commonConst.ts +1 -0
  82. package/tools/cli/src/common/const/deviceConst.ts +110 -0
  83. package/tools/cli/src/common/const/exitCodeConst.ts +12 -0
  84. package/tools/cli/src/common/helpers/CreateArchiveHelper.ts +55 -0
  85. package/tools/cli/src/common/helpers/CreateFileHelper.ts +199 -0
  86. package/tools/cli/src/common/helpers/InputValidator.ts +58 -0
  87. package/tools/cli/src/common/helpers/InstallHelper.ts +202 -0
  88. package/tools/cli/src/common/helpers/UpdateFileHelper.ts +239 -0
  89. package/tools/cli/src/common/helpers/UserInputGetter.ts +145 -0
  90. package/tools/cli/src/common/helpers/handlebarsHelper.ts +31 -0
  91. package/tools/cli/src/common/helpers/stringHelper.ts +25 -0
  92. package/tools/cli/src/common/translation/en.json +87 -0
  93. package/tools/cli/src/common/translation/translation.ts +6 -0
  94. package/tools/cli/src/common/types/helperTypes.ts +79 -0
  95. package/tools/cli/src/index.ts +16 -0
  96. package/tools/cli/src/program.ts +59 -0
  97. package/tools/cli/tests/commands/addComponent/addMenu/add-menu.test.ts +96 -0
  98. package/tools/cli/tests/commands/addComponent/addRail/add-rail.test.ts +57 -0
  99. package/tools/cli/tests/commands/addComponent/addScreen/add-screen.test.ts +55 -0
  100. package/tools/cli/tests/commands/addComponent/addScrollView/add-scrollView.test.ts +89 -0
  101. package/tools/cli/tests/commands/addComponent/config/ComponentConfig.test.ts +261 -0
  102. package/tools/cli/tests/commands/addComponent/createComponent.test.ts +87 -0
  103. package/tools/cli/tests/commands/addComponent/helper/ComponentHelper.test.ts +110 -0
  104. package/tools/cli/tests/commands/addDevice/add-device.test.ts +117 -0
  105. package/tools/cli/tests/commands/addDevice/deviceConfig/androidtvConfig.test.ts +184 -0
  106. package/tools/cli/tests/commands/addDevice/deviceConfig/deviceConfig.test.ts +30 -0
  107. package/tools/cli/tests/commands/addDevice/deviceConfig/titanosConfig.test.ts +20 -0
  108. package/tools/cli/tests/commands/addDevice/deviceConfig/tizenConfig.test.ts +63 -0
  109. package/tools/cli/tests/commands/addDevice/deviceConfig/tvosConfig.test.ts +47 -0
  110. package/tools/cli/tests/commands/addDevice/deviceConfig/vidaaConfig.test.ts +20 -0
  111. package/tools/cli/tests/commands/addDevice/deviceConfig/webosConfig.test.ts +74 -0
  112. package/tools/cli/tests/commands/addDevice/helper/addDeviceHelper.test.ts +144 -0
  113. package/tools/cli/tests/commands/addDianaSkills/add-dianaSkills.test.ts +72 -0
  114. package/tools/cli/tests/commands/addModule/add-module.test.ts +108 -0
  115. package/tools/cli/tests/commands/authentication/AuthenticationManager.test.ts +756 -0
  116. package/tools/cli/tests/commands/authentication/commands/authDefinition.test.ts +53 -0
  117. package/tools/cli/tests/commands/authentication/commands/authHook.test.ts +94 -0
  118. package/tools/cli/tests/commands/authentication/commands/get-packages-token.test.ts +69 -0
  119. package/tools/cli/tests/commands/authentication/commands/login.test.ts +170 -0
  120. package/tools/cli/tests/commands/authentication/commands/logout.test.ts +77 -0
  121. package/tools/cli/tests/commands/authentication/commands/status.test.ts +73 -0
  122. package/tools/cli/tests/commands/authentication/helper/CredentialsHelper.test.ts +352 -0
  123. package/tools/cli/tests/commands/authentication/helper/SPM.test.ts +229 -0
  124. package/tools/cli/tests/commands/cliHelp/customHelp.test.ts +24 -0
  125. package/tools/cli/tests/commands/completion/completion.test.ts +76 -0
  126. package/tools/cli/tests/commands/createApp/const/createAppTasks.test.ts +70 -0
  127. package/tools/cli/tests/commands/createApp/createApp.test.ts +116 -0
  128. package/tools/cli/tests/commands/createApp/helpers/CreateAppHelper.test.ts +197 -0
  129. package/tools/cli/tests/commands/createApp/helpers/SetupChecker.test.ts +152 -0
  130. package/tools/cli/tests/commands/createApp/helpers/fixtures/myApp/scripts/app/ui/screens/SplashScreen.js +70 -0
  131. package/tools/cli/tests/commands/hooks/checkDanaProjectHook.test.ts +55 -0
  132. package/tools/cli/tests/commands/zip/zip.test.ts +51 -0
  133. package/tools/cli/tests/common/helpers/CreateArchiveHelper.test.ts +69 -0
  134. package/tools/cli/tests/common/helpers/CreateFileHelper.test.ts +359 -0
  135. package/tools/cli/tests/common/helpers/InputValidator.test.ts +93 -0
  136. package/tools/cli/tests/common/helpers/InstallHelper.test.ts +262 -0
  137. package/tools/cli/tests/common/helpers/UpdateFileHelper.test.ts +288 -0
  138. package/tools/cli/tests/common/helpers/UserInputGetter.test.ts +182 -0
  139. package/tools/cli/tests/common/helpers/handlebarsHelper.test.ts +87 -0
  140. package/tools/cli/tests/common/helpers/stringHelper.test.ts +35 -0
  141. package/tools/cli/tests/program.test.ts +215 -0
  142. package/tools/cli/tsconfig.json +19 -0
  143. package/tools/cli/tsconfig.test.json +4 -0
  144. package/tools/cli/vitest.config.ts +4 -0
  145. package/tools/templates/app-template/.dana/.gitkeep +0 -0
  146. package/tools/templates/app-template/Gruntfile.js +31 -0
  147. package/tools/templates/app-template/README.md +17 -0
  148. package/tools/templates/app-template/app.config.json +56 -0
  149. package/tools/templates/app-template/editorconfigTemplate.hbs +18 -0
  150. package/tools/templates/app-template/eslintrc.jsonTemplate.hbs +5 -0
  151. package/tools/templates/app-template/gitignoreTemplate.hbs +27 -0
  152. package/tools/templates/app-template/i18n/LocaleStringEnUS.json +7 -0
  153. package/tools/templates/app-template/i18n/README.md +32 -0
  154. package/tools/templates/app-template/images/dana.png +0 -0
  155. package/tools/templates/app-template/images/dana_logo.png +0 -0
  156. package/tools/templates/app-template/images/dana_logo_light.png +0 -0
  157. package/tools/templates/app-template/images/loading.png +0 -0
  158. package/tools/templates/app-template/nvmrcTemplate.hbs +1 -0
  159. package/tools/templates/app-template/package.json +33 -0
  160. package/tools/templates/app-template/profiles/app.config.browser-css.json +16 -0
  161. package/tools/templates/app-template/profiles/app.config.browser-lightning.json +16 -0
  162. package/tools/templates/app-template/scripts/app/README.md +6 -0
  163. package/tools/templates/app-template/scripts/app/TemplateAppRoutes.js.hbs +18 -0
  164. package/tools/templates/app-template/scripts/app/app.js.hbs +17 -0
  165. package/tools/templates/app-template/scripts/app/theme/AppTheme.js +57 -0
  166. package/tools/templates/app-template/scripts/app/ui/screens/AppScreen.js +106 -0
  167. package/tools/templates/app-template/scripts/app/ui/screens/SplashScreen.js +70 -0
  168. package/tools/templates/app-template/scripts/app/ui/views/LoaderView.js +31 -0
  169. package/tools/templates/app-template/styles/fonts/Roboto-Bold.ttf +0 -0
  170. package/tools/templates/app-template/styles/fonts/Roboto-Regular.ttf +0 -0
  171. package/tools/templates/app-template/tests/README.md +70 -0
  172. package/tools/templates/app-template/tests/automation/features/splash.feature +5 -0
  173. package/tools/templates/app-template/tests/automation/init.js +20 -0
  174. package/tools/templates/app-template/tests/automation/steps-definitions/dictionary.js +31 -0
  175. package/tools/templates/app-template/tests/automation/steps-definitions/helpers.js +9 -0
  176. package/tools/templates/app-template/tests/unit/README.md +7 -0
  177. package/tools/templates/app-template/tests/unit/app/TemplateAppRoutes.js.hbs +24 -0
  178. package/tools/templates/assets/fonts/fa-solid-900.ttf +0 -0
  179. package/tools/templates/components/ButtonItemView.js.hbs +69 -0
  180. package/tools/templates/components/ButtonView.js.hbs +65 -0
  181. package/tools/templates/components/ScrollItemView.js.hbs +53 -0
  182. package/tools/templates/components/ScrollView.js.hbs +43 -0
  183. package/tools/templates/components/TileView.js.hbs +55 -0
  184. package/tools/templates/components/screen.js.hbs +74 -0
  185. package/tools/templates/components/settings.js.hbs +74 -0
  186. package/tools/templates/components/vod.js.hbs +104 -0
  187. package/tools/templates/components/wtvMenuListView.js.hbs +38 -0
  188. package/tools/templates/components/wtvRailListView.js.hbs +44 -0
  189. package/tools/templates/index.ts +3 -0
  190. package/tools/templates/mocks/menuMock.json +29 -0
  191. package/tools/templates/mocks/railMock.json +101 -0
  192. package/tools/templates/mocks/scrollViewMock.json +165 -0
  193. package/tools/templates/modules/fip/images/12.png +0 -0
  194. package/tools/templates/modules/fip/images/audioD.png +0 -0
  195. package/tools/templates/modules/fip/package.json +5 -0
  196. package/tools/templates/modules/fip/scripts/FipModule.js +19 -0
  197. package/tools/templates/modules/fip/scripts/FipRoutes.js +19 -0
  198. package/tools/templates/modules/fip/scripts/services/mock/fipMock.json +12 -0
  199. package/tools/templates/modules/fip/scripts/ui/screens/FipScreen.js +169 -0
  200. package/tools/templates/modules/fip/scripts/ui/views/FipContentInfoView.js +77 -0
  201. package/tools/templates/modules/fip/scripts/ui/views/InfoDetailImageView.js +35 -0
  202. package/tools/templates/modules/fip/scripts/ui/views/InfoDetailTextView.js +39 -0
  203. package/tools/templates/modules/fip/scripts/ui/views/InfoListView.js +57 -0
  204. package/tools/templates/modules/fip/scripts/ui/views/PlayButtonView.js +63 -0
  205. package/tools/templates/modules/home/package.json +5 -0
  206. package/tools/templates/modules/home/scripts/HomeModule.js +19 -0
  207. package/tools/templates/modules/home/scripts/HomeRoutes.js +19 -0
  208. package/tools/templates/modules/home/scripts/services/mock/highlightMock.json +40 -0
  209. package/tools/templates/modules/home/scripts/services/mock/homeScrollViewMock.json +170 -0
  210. package/tools/templates/modules/home/scripts/ui/screens/HomeScreen.js +258 -0
  211. package/tools/templates/modules/home/scripts/ui/views/highlight/DotsListItemView.js +37 -0
  212. package/tools/templates/modules/home/scripts/ui/views/highlight/DotsListView.js +22 -0
  213. package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightContentDescriptionView.js +99 -0
  214. package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightPlayButtonView.js +63 -0
  215. package/tools/templates/modules/home/scripts/ui/views/highlight/HighlightRailItemView.js +186 -0
  216. package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeMockTileView.js +67 -0
  217. package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeRailScrollView.js +53 -0
  218. package/tools/templates/modules/home/scripts/ui/views/scrollview/HomeScrollView.js +22 -0
  219. package/tools/templates/modules/menu/images/profile.png +0 -0
  220. package/tools/templates/modules/menu/package.json +5 -0
  221. package/tools/templates/modules/menu/scripts/MenuModule.js +18 -0
  222. package/tools/templates/modules/menu/scripts/MenuRoutes.js +14 -0
  223. package/tools/templates/modules/menu/scripts/services/menuMock.json +24 -0
  224. package/tools/templates/modules/menu/scripts/ui/const/MenuIcons.js +16 -0
  225. package/tools/templates/modules/menu/scripts/ui/views/MenuButtonView.js +101 -0
  226. package/tools/templates/modules/menu/scripts/ui/views/MenuListView.js +60 -0
  227. package/tools/templates/modules/menu/scripts/ui/views/MenuView.js +87 -0
  228. package/tools/templates/modules/menu/scripts/ui/views/ProfileImageView.js +30 -0
  229. package/tools/templates/modules/player/package.json +5 -0
  230. package/tools/templates/modules/player/scripts/PlayerModule.js +19 -0
  231. package/tools/templates/modules/player/scripts/PlayerRoutes.js +19 -0
  232. package/tools/templates/modules/player/scripts/ui/const/PlayerIcons.js +19 -0
  233. package/tools/templates/modules/player/scripts/ui/screens/PlayerScreen.js +361 -0
  234. package/tools/templates/modules/player/scripts/ui/views/PlayerControlButtonView.js +69 -0
  235. package/tools/templates/modules/player/scripts/ui/views/PlayerControlsView.js +173 -0
  236. package/tools/templates/modules/player/scripts/ui/views/ProgressBarView.js +53 -0
  237. package/tools/templates/modules/search/package.json +5 -0
  238. package/tools/templates/modules/search/scripts/SearchModule.js +18 -0
  239. package/tools/templates/modules/search/scripts/SearchRoutes.js +16 -0
  240. package/tools/templates/modules/search/scripts/ui/const/EnglishKeyboardData.js +31 -0
  241. package/tools/templates/modules/search/scripts/ui/const/SearchIcons.js +14 -0
  242. package/tools/templates/modules/search/scripts/ui/const/SearchKeyboardLayout.js +19 -0
  243. package/tools/templates/modules/search/scripts/ui/primitives/SearchTextPrimitive.js +36 -0
  244. package/tools/templates/modules/search/scripts/ui/screens/SearchScreen.js +234 -0
  245. package/tools/templates/modules/search/scripts/ui/services/MockSearchService.js +39 -0
  246. package/tools/templates/modules/search/scripts/ui/services/SearchVirtualKeyboardService.js +33 -0
  247. package/tools/templates/modules/search/scripts/ui/services/mock/searchMock.json +172 -0
  248. package/tools/templates/modules/search/scripts/ui/views/SearchView.js +62 -0
  249. package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardRowItemView.js +92 -0
  250. package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardRowListView.js +33 -0
  251. package/tools/templates/modules/search/scripts/ui/views/keyboard/SearchKeyboardView.js +63 -0
  252. package/tools/templates/modules/search/scripts/ui/views/rail/SearchScrollRailView.js +53 -0
  253. package/tools/templates/modules/search/scripts/ui/views/rail/SearchScrollView.js +22 -0
  254. package/tools/templates/modules/search/scripts/ui/views/rail/SearchTileView.js +68 -0
  255. package/tools/templates/modules/search/styles/styles/fonts/fa-solid-900.ttf +0 -0
  256. package/tools/templates/modules/settings/package.json +5 -0
  257. package/tools/templates/modules/settings/scripts/SettingsModule.js +19 -0
  258. package/tools/templates/modules/settings/scripts/SettingsRoutes.js +19 -0
  259. package/tools/templates/modules/settings/scripts/ui/screens/SettingsScreen.js +200 -0
  260. package/tools/templates/modules/settings/scripts/ui/views/SettingsListItemView.js +85 -0
  261. package/tools/templates/modules/settings/scripts/ui/views/SettingsListView.js +56 -0
  262. package/tools/templates/modules/vod/package.json +5 -0
  263. package/tools/templates/modules/vod/scripts/VodModule.js +19 -0
  264. package/tools/templates/modules/vod/scripts/VodRoutes.js +19 -0
  265. package/tools/templates/modules/vod/scripts/services/mock/scrollViewMock.json +172 -0
  266. package/tools/templates/modules/vod/scripts/ui/screens/VodScreen.js +204 -0
  267. package/tools/templates/modules/vod/scripts/ui/views/MockTileView.js +69 -0
  268. package/tools/templates/modules/vod/scripts/ui/views/RailScrollItemView.js +53 -0
  269. package/tools/templates/modules/vod/scripts/ui/views/VodScrollView.js +22 -0
  270. package/tools/templates/package.json +14 -0
  271. package/tools/templates/profiles/app.config.androidtv.json +17 -0
  272. package/tools/templates/profiles/app.config.titanos.json +24 -0
  273. package/tools/templates/profiles/app.config.tizen.json +52 -0
  274. package/tools/templates/profiles/app.config.tvos.json +18 -0
  275. package/tools/templates/profiles/app.config.vidaa.json +24 -0
  276. package/tools/templates/profiles/app.config.webos.json +21 -0
  277. package/tools/templates/tutorial/modules/fip/package.json +4 -0
  278. package/tools/templates/tutorial/modules/fip/scripts/FipModule.js +18 -0
  279. package/tools/templates/tutorial/modules/fip/scripts/FipRoutes.js +19 -0
  280. package/tools/templates/tutorial/modules/fip/scripts/ui/screens/FipContentScreen.js +146 -0
  281. package/tools/templates/tutorial/modules/fip/scripts/ui/views/ElevatorView.js +66 -0
  282. package/tools/templates/tutorial/modules/fip/scripts/ui/views/FipContentInfoView.js +90 -0
  283. package/tools/templates/tutorial/modules/fip/scripts/ui/views/PlayButtonView.js +58 -0
  284. package/tools/templates/tutorial/vendors/customBE/package.json +5 -0
  285. package/tools/templates/tutorial/vendors/customBE/scripts/datas/contents.json +749 -0
  286. package/tools/templates/tutorial/vendors/customBE/scripts/services/CustomBEVodService.js +70 -0
  287. package/tsconfig.json +8 -0
  288. package/vitest.config.ts +19 -0
@@ -0,0 +1,51 @@
1
+ import { beforeEach, vi } from "vitest";
2
+ import process from "node:process";
3
+ import { generateArchive } from "@/common/helpers/CreateArchiveHelper.js";
4
+ import zipCommand from "@/commands/zip/zip.js";
5
+ import { GENERATE_ARCHIVE_ERROR } from "@/common/const/exitCodeConst.js";
6
+ import { Spinner } from "@/commands/createApp/helpers/CreateAppHelper.js";
7
+ import * as prompts from "@clack/prompts";
8
+ import translation from "@/common/translation/translation.js";
9
+
10
+ vi.mock("@clack/prompts");
11
+ vi.mock("@/common/helpers/CreateArchiveHelper.js");
12
+
13
+ afterEach(() => {
14
+ vi.resetAllMocks();
15
+ });
16
+
17
+ describe("zipCommand", () => {
18
+ let spinner: Spinner;
19
+ beforeEach(() => {
20
+ vi.spyOn(process, "exit").mockImplementation(() => undefined as never);
21
+ spinner = {
22
+ start: vi.fn(),
23
+ stop: vi.fn(),
24
+ message: vi.fn(),
25
+ } as unknown as Spinner;
26
+ vi.mocked(prompts.spinner).mockReturnValue(spinner);
27
+ });
28
+
29
+ it("should exit if zipping folder failed", async () => {
30
+ vi.mocked(generateArchive).mockImplementationOnce(() => {
31
+ throw new Error("error");
32
+ });
33
+
34
+ await zipCommand();
35
+
36
+ expect(spinner.start).toHaveBeenCalledOnce();
37
+ expect(spinner.stop).toHaveBeenCalledOnce();
38
+ expect(vi.mocked(process.exit)).toHaveBeenCalledExactlyOnceWith(GENERATE_ARCHIVE_ERROR);
39
+ });
40
+
41
+ it("should generate an archive", async () => {
42
+ vi.mocked(generateArchive).mockResolvedValueOnce("zipFile.zip");
43
+
44
+ await zipCommand();
45
+
46
+ expect(spinner.start).toHaveBeenCalledOnce();
47
+ expect(spinner.stop).toHaveBeenCalledExactlyOnceWith(translation["command.zip.creation.end"] + "zipFile.zip");
48
+ expect(vi.mocked(generateArchive)).toHaveBeenCalledOnce();
49
+ expect(vi.mocked(process.exit)).not.toHaveBeenCalled();
50
+ });
51
+ });
@@ -0,0 +1,69 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { generateArchive } from "@/common/helpers/CreateArchiveHelper.js";
3
+ import AdmZip from "adm-zip";
4
+ import { findUp } from "find-up";
5
+ import { basename, dirname, join } from "node:path";
6
+
7
+ vi.mock("adm-zip");
8
+ vi.mock("find-up");
9
+ vi.mock("node:path", async () => {
10
+ const originalModule = await vi.importActual("node:path");
11
+
12
+ return { ...originalModule, basename: vi.fn(), dirname: vi.fn() };
13
+ });
14
+
15
+ afterEach(() => {
16
+ vi.resetAllMocks();
17
+ });
18
+
19
+ describe("generateArchive", () => {
20
+ it("should throw if the directory name failed to be retrieved", async () => {
21
+ vi.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z"));
22
+
23
+ vi.mocked(findUp).mockResolvedValue("");
24
+ vi.mocked(dirname).mockReturnValue("");
25
+
26
+ let error: unknown;
27
+ try {
28
+ await generateArchive();
29
+ } catch (err: unknown) {
30
+ error = err;
31
+ }
32
+
33
+ expect(error).toBeInstanceOf(Error);
34
+ expect((error as Error)?.message).toBe(
35
+ "Unable to get your dana project directory name. Please run the command from the root directory of the project",
36
+ );
37
+ });
38
+
39
+ it("should build a zip from the current folder", async () => {
40
+ vi.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z"));
41
+
42
+ vi.mocked(findUp).mockResolvedValue("/my-projects/some-project/.dana");
43
+ vi.mocked(dirname).mockReturnValue("/my-projects/some-project");
44
+ vi.mocked(basename).mockReturnValue("some-project");
45
+
46
+ let mockExcludeFunction: (filename: string) => boolean = () => true;
47
+ const mockAddLocalFolder = vi
48
+ .fn()
49
+ .mockImplementation((path, zipEntryName, excludeFunction: (filename: string) => boolean) => {
50
+ mockExcludeFunction = excludeFunction;
51
+ });
52
+ const mockWriteZip = vi.fn();
53
+
54
+ vi.mocked(AdmZip).mockImplementation(function (this: AdmZip) {
55
+ this.addLocalFolder = mockAddLocalFolder;
56
+ this.writeZip = mockWriteZip;
57
+ return this;
58
+ });
59
+
60
+ await generateArchive();
61
+
62
+ expect(mockAddLocalFolder.mock.calls[0][0]).toBe("/my-projects/some-project");
63
+ expect(mockWriteZip).toHaveBeenCalledExactlyOnceWith("archive-some-project-1672531200000.zip");
64
+
65
+ expect(mockExcludeFunction(join("app_android", "build", "outputs", "apk", "debug"))).toBe(false);
66
+ expect(mockExcludeFunction(join("anotherZip.zip"))).toBe(false);
67
+ expect(mockExcludeFunction(join("anyOther"))).toBe(true);
68
+ });
69
+ });
@@ -0,0 +1,359 @@
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 CreateFileHelper from "@/common/helpers/CreateFileHelper.js";
14
+ import { access, copyFile, cp, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
15
+ import { spawnSync, SpawnSyncReturns } from "node:child_process";
16
+ import { ANDROIDTV, TVOS } from "@/common/const/deviceConst.js";
17
+ import { vi, afterEach, describe, it, expect, beforeEach } from "vitest";
18
+ import { Dirent } from "node:fs";
19
+ import { AwsCredentials, CredentialsHelper, DanaToken } from "@/commands/authentication/helper/CredentialsHelper.js";
20
+ import { getRepositoryEndpoint } from "@/commands/authentication/helper/CodeArtifactHelper.js";
21
+
22
+ vi.mock("node:child_process");
23
+ vi.mock("@/commands/authentication/helper/CredentialsHelper");
24
+ vi.mock("@/commands/authentication/helper/CodeArtifactHelper");
25
+ vi.mock("@/commands/addComponent/helper/ComponentHelper", () => ({
26
+ default: {
27
+ getTemplatePath: vi.fn().mockReturnValue("/mock/template/path"),
28
+ },
29
+ }));
30
+
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
+ join: vi.fn().mockImplementation((...args) => args.join("/")),
37
+ dirname: vi.fn().mockReturnValue("/my-projects/node_modules"),
38
+ };
39
+ });
40
+
41
+ vi.mock("node:module", async () => {
42
+ const actual = await vi.importActual<typeof import("node:module")>("node:module");
43
+ return {
44
+ ...actual,
45
+ createRequire: vi.fn(() => ({
46
+ resolve: vi.fn().mockReturnValue("/my-projects/node_modules/@dana/ai-skills/package.json"),
47
+ })),
48
+ };
49
+ });
50
+
51
+ vi.mock("node:fs/promises", () => ({
52
+ mkdir: vi.fn(),
53
+ readdir: vi.fn(),
54
+ access: vi.fn(),
55
+ cp: vi.fn(),
56
+ readFile: vi.fn(),
57
+ writeFile: vi.fn(),
58
+ copyFile: vi.fn(),
59
+ }));
60
+
61
+ afterEach(() => {
62
+ vi.clearAllMocks();
63
+ vi.restoreAllMocks();
64
+ });
65
+
66
+ describe("copyTemplate", () => {
67
+ it("copyTemplate: call cp with correct args", async () => {
68
+ const directory = "/mock-directory";
69
+ const result = await CreateFileHelper.copyTemplate({ directory });
70
+
71
+ expect(vi.mocked(mkdir)).toHaveBeenCalledWith(directory, { recursive: true });
72
+ expect(vi.mocked(cp).mock.calls[0][0]).toBe("/templates/mockTemplate");
73
+ expect(vi.mocked(cp).mock.calls[0][1]).toBe("/mock-directory");
74
+ expect(result).toBe("Template copied");
75
+ });
76
+ });
77
+
78
+ describe("copyForTutorial", () => {
79
+ it("copyForTutorial: call cp with correct args", async () => {
80
+ const directory = "/mock-directory";
81
+ const cpMock = vi.mocked(cp).mockImplementation(() => Promise.resolve());
82
+
83
+ const result = await CreateFileHelper.copyForTutorial({ directory });
84
+ expect(cpMock.mock.calls[0][0]).toBe("/templates/mockTemplate");
85
+ expect(result).toBe("Tutorial files copied");
86
+ });
87
+ });
88
+
89
+ describe("copyForTemplatedApp", () => {
90
+ const directory = "/mock-directory";
91
+ const templateDir = "/templates/mockTemplate";
92
+
93
+ beforeEach(() => {
94
+ // for test, FIP has images,settings don't
95
+ vi.mocked(access).mockImplementation((path) => {
96
+ if (String(path).includes("fip/images")) {
97
+ return Promise.resolve();
98
+ }
99
+ return Promise.reject(new Error("ENOENT"));
100
+ });
101
+ vi.mocked(cp).mockImplementation(() => Promise.resolve());
102
+ vi.spyOn(CreateFileHelper, "copyFontFile").mockResolvedValue();
103
+ });
104
+
105
+ it("copyForTemplatedApp: call cp with correct args", async () => {
106
+ const availableModules = ["fip", "settings"];
107
+
108
+ const result = await CreateFileHelper.copyForTemplatedApp(
109
+ { directory },
110
+ { availableModules, templateDir, shouldAddIconFont: false },
111
+ );
112
+
113
+ expect(vi.mocked(cp)).toHaveBeenCalledTimes(3);
114
+ expect(vi.mocked(cp).mock.calls[0][0]).toBe("/templates/mockTemplate/fip");
115
+ expect(vi.mocked(cp).mock.calls[0][1]).toBe("/mock-directory/modules/fip");
116
+ expect(vi.mocked(cp).mock.calls[1][0]).toBe("/templates/mockTemplate/fip/images");
117
+ expect(vi.mocked(cp).mock.calls[1][1]).toBe("/mock-directory/images");
118
+ expect(vi.mocked(cp).mock.calls[2][0]).toBe("/templates/mockTemplate/settings");
119
+ expect(vi.mocked(cp).mock.calls[2][1]).toBe("/mock-directory/modules/settings");
120
+ expect(result).toBe("Modules files copied");
121
+ });
122
+ it("call copy font file", async () => {
123
+ const availableModules = ["settings"];
124
+
125
+ const result = await CreateFileHelper.copyForTemplatedApp(
126
+ { directory },
127
+ { availableModules, templateDir, shouldAddIconFont: true },
128
+ );
129
+
130
+ expect(vi.spyOn(CreateFileHelper, "copyFontFile")).toHaveBeenCalledTimes(1);
131
+ expect(result).toBe("Modules files copied");
132
+ });
133
+ it("call copy images", async () => {
134
+ const availableModules = ["fip"];
135
+
136
+ const result = await CreateFileHelper.copyForTemplatedApp(
137
+ { directory },
138
+ { availableModules, templateDir, shouldAddIconFont: false },
139
+ );
140
+ expect(vi.mocked(cp).mock.calls[0][0]).toBe("/templates/mockTemplate/fip");
141
+ expect(vi.mocked(cp).mock.calls[1][1]).toBe(`/mock-directory/images`);
142
+ expect(vi.mocked(cp)).toHaveBeenCalledTimes(2);
143
+ expect(result).toBe("Modules files copied");
144
+ });
145
+ it("call NOT copy images NOR icons", async () => {
146
+ const availableModules = ["settings"];
147
+
148
+ const result = await CreateFileHelper.copyForTemplatedApp(
149
+ { directory },
150
+ { availableModules, templateDir, shouldAddIconFont: false },
151
+ );
152
+ expect(vi.spyOn(CreateFileHelper, "copyFontFile")).toHaveBeenCalledTimes(0);
153
+ expect(vi.mocked(cp)).toHaveBeenCalledTimes(1);
154
+ expect(result).toBe("Modules files copied");
155
+ });
156
+ });
157
+
158
+ describe("copyAppConfigFiles", () => {
159
+ it("copyAppConfigFiles: call cp with correct args", async () => {
160
+ const directory = "/mock-directory";
161
+ const selectedDevices = ["tvos"];
162
+ vi.mocked(readdir).mockResolvedValue(["app.config.tvos.json", "app.config.android.json"] as unknown as Dirent<
163
+ Buffer<ArrayBuffer>
164
+ >[]);
165
+ vi.mocked(cp).mockImplementation(() => Promise.resolve());
166
+
167
+ const result = await CreateFileHelper.copyAppConfigFiles({ selectedDevices, directory });
168
+
169
+ expect(cp).toHaveBeenCalledTimes(1);
170
+ expect(vi.mocked(cp).mock.calls[0][0]).toMatch("app.config.tvos.json");
171
+ expect(vi.mocked(cp).mock.calls[0][1]).toMatch(directory);
172
+ expect(result).toBe("Config file(s) copied");
173
+ });
174
+ });
175
+
176
+ describe("copyFontFile", () => {
177
+ it("should copy font file and update app.config.json", async () => {
178
+ const directory = "/mock-directory";
179
+ const mockConfig = {
180
+ default: {
181
+ AppTheme: {
182
+ fonts: {},
183
+ },
184
+ },
185
+ };
186
+
187
+ vi.mocked(readFile).mockResolvedValue(Buffer.from(JSON.stringify(mockConfig)));
188
+ vi.mocked(writeFile).mockResolvedValue();
189
+ vi.mocked(cp).mockResolvedValue();
190
+
191
+ await CreateFileHelper.copyFontFile(directory);
192
+
193
+ expect(cp).toHaveBeenCalledTimes(1);
194
+ expect(readFile).toHaveBeenCalledTimes(1);
195
+ expect(writeFile).toHaveBeenCalledTimes(1);
196
+ });
197
+ });
198
+
199
+ describe("copySkillsFile", () => {
200
+ it("calls cp with correct args", async () => {
201
+ const directory = "/my-projects";
202
+ const result = await CreateFileHelper.copySkillsFiles({ directory });
203
+ const calls = vi.mocked(cp).mock.calls;
204
+ //first call
205
+ expect(calls[0][0]).toBe("/my-projects/node_modules/agents/docs");
206
+ expect(calls[0][1]).toBe("/my-projects/docs");
207
+ //second call
208
+ expect(calls[1][0]).toBe("/my-projects/node_modules/skills");
209
+ expect(calls[1][1]).toBe("/my-projects/.agents/skills");
210
+ //third call
211
+ expect(vi.mocked(copyFile).mock.calls[0][0]).toBe("/my-projects/node_modules/agents/AGENTS.md");
212
+ expect(vi.mocked(copyFile).mock.calls[0][1]).toBe("/my-projects/AGENTS.md");
213
+
214
+ expect(result).toBe("Diana AI skill file(s) copied");
215
+ });
216
+ });
217
+
218
+ describe("executeGruntTasks", () => {
219
+ const config = {
220
+ androidtv: {
221
+ device: {
222
+ appId: "com.name.id",
223
+ appName: "dana",
224
+ appVersion: "1.0.0",
225
+ appVersionCode: 1000,
226
+ icon: "images/1080p/components/logo/dana.png",
227
+ wtvAndroidtvVersion: "7.244.1",
228
+ },
229
+ },
230
+ tvos: {
231
+ jscVersion: "0.0.1",
232
+ },
233
+ };
234
+ const directory = "/mock-directory";
235
+ const params = {
236
+ directory,
237
+ config,
238
+ };
239
+
240
+ describe("Android device is selected", () => {
241
+ const selectedDevices = [ANDROIDTV];
242
+ it("call spawnSync with correct arguments", async () => {
243
+ vi.mocked(CredentialsHelper.get).mockResolvedValue({
244
+ aws: { accessKeyId: "key", secretAccessKey: "secret", sessionToken: "token" } as AwsCredentials,
245
+ dana: { id_token: "token" } as DanaToken,
246
+ org: "org",
247
+ isRemote: false,
248
+ });
249
+ vi.mocked(getRepositoryEndpoint).mockResolvedValue("@dana/maven/dana-org-repository");
250
+ const spawnSyncMock = vi.mocked(spawnSync).mockReturnValue({
251
+ status: 0,
252
+ } as SpawnSyncReturns<string>);
253
+
254
+ const expectedOptions = [
255
+ "--appUrl=@dana/maven/dana-org-repository",
256
+ "--organization=org",
257
+ "--appId=com.name.id",
258
+ "--appName=dana",
259
+ "--appVersion=1.0.0",
260
+ "--appVersionCode=1000",
261
+ "--wtvAndroidtvVersion=7.244.1",
262
+ ];
263
+ const result = await CreateFileHelper.executeGruntTasks({ ...params, selectedDevices });
264
+
265
+ expect(spawnSyncMock).toHaveBeenCalledTimes(1);
266
+ expect(spawnSyncMock.mock.calls[0][0]).toMatch("grunt");
267
+ expect(spawnSyncMock.mock.calls[0][1]).toEqual(["copyProjectAndroidTv", ...expectedOptions]);
268
+ expect(result).toBe("Grunt task(s) done");
269
+ });
270
+ it("handle error", async () => {
271
+ vi.mocked(CredentialsHelper.get).mockResolvedValue({
272
+ aws: { accessKeyId: "key", secretAccessKey: "secret", sessionToken: "token" } as AwsCredentials,
273
+ dana: { id_token: "token" } as DanaToken,
274
+ org: "org",
275
+ isRemote: false,
276
+ });
277
+ vi.mocked(getRepositoryEndpoint).mockResolvedValue("@dana/maven/dana-org-repository");
278
+ vi.mocked(spawnSync).mockReturnValue({
279
+ status: 1,
280
+ } as SpawnSyncReturns<string>);
281
+
282
+ return expect(CreateFileHelper.executeGruntTasks({ ...params, selectedDevices })).rejects.toThrow(
283
+ "Failed to execute grunt tasks: Grunt task(s) failed",
284
+ );
285
+ });
286
+ });
287
+
288
+ it("does not call execSync if androidTV device is NOT selected", async () => {
289
+ const spawnSyncMock = vi.mocked(spawnSync).mockReturnValue({
290
+ status: 0,
291
+ } as SpawnSyncReturns<string>);
292
+ const selectedDevices: string[] = [];
293
+ const result = await CreateFileHelper.executeGruntTasks({ selectedDevices, directory, config });
294
+
295
+ expect(spawnSyncMock).toHaveBeenCalledTimes(0);
296
+ expect(result).toBe("Grunt task(s) done");
297
+ });
298
+
299
+ describe("TVOS device", () => {
300
+ it("call execSync with correct arguments", async () => {
301
+ const selectedDevices = [TVOS];
302
+ vi.mocked(getRepositoryEndpoint).mockResolvedValue("@dana/maven/dana-org-repository");
303
+ const spawnSyncMock = vi.mocked(spawnSync).mockReturnValue({
304
+ status: 0,
305
+ } as SpawnSyncReturns<string>);
306
+
307
+ const result = await CreateFileHelper.executeGruntTasks({ selectedDevices, directory, config });
308
+
309
+ expect(spawnSyncMock).toHaveBeenCalledTimes(1);
310
+ expect(spawnSyncMock.mock.calls[0]).toEqual([
311
+ "grunt",
312
+ ["copyProjectTvos", `--jscVersion=0.0.1`],
313
+ { cwd: directory, shell: true },
314
+ ]);
315
+ expect(result).toBe("Grunt task(s) done");
316
+ });
317
+ it("handle error", async () => {
318
+ const selectedDevices = [TVOS];
319
+
320
+ vi.mocked(spawnSync).mockReturnValue({
321
+ status: 1,
322
+ } as SpawnSyncReturns<string>);
323
+
324
+ return expect(CreateFileHelper.executeGruntTasks({ ...params, selectedDevices })).rejects.toThrow(
325
+ "Failed to execute grunt tasks: Grunt task(s) failed",
326
+ );
327
+ });
328
+
329
+ it("should handle both ANDROIDTV and TVOS devices", async () => {
330
+ const selectedDevices = [ANDROIDTV, TVOS];
331
+ vi.mocked(CredentialsHelper.get).mockResolvedValue({
332
+ aws: { accessKeyId: "key", secretAccessKey: "secret", sessionToken: "token" } as AwsCredentials,
333
+ dana: { id_token: "token" } as DanaToken,
334
+ org: "org",
335
+ isRemote: false,
336
+ });
337
+ vi.mocked(getRepositoryEndpoint).mockResolvedValue("@dana/maven/dana-org-repository");
338
+ vi.mocked(spawnSync).mockReturnValue({
339
+ status: 0,
340
+ } as SpawnSyncReturns<string>);
341
+
342
+ const result = await CreateFileHelper.executeGruntTasks({ ...params, selectedDevices });
343
+
344
+ expect(spawnSync).toHaveBeenCalledTimes(2);
345
+ expect(result).toBe("Grunt task(s) done");
346
+ });
347
+
348
+ it("does not call execSync if androidTV device is NOT selected", async () => {
349
+ const selectedDevices = [];
350
+ const spawnSyncMock = vi.mocked(spawnSync).mockReturnValue({
351
+ status: 0,
352
+ } as SpawnSyncReturns<string>);
353
+ const result = await CreateFileHelper.executeGruntTasks({ selectedDevices, directory, config });
354
+
355
+ expect(spawnSyncMock).toHaveBeenCalledTimes(0);
356
+ expect(result).toBe("Grunt task(s) done");
357
+ });
358
+ });
359
+ });
@@ -0,0 +1,93 @@
1
+ /*
2
+ * Copyright (c) 2014-2025 Wiztivi - contact@wiztivi.com
3
+ * All Rights Reserved
4
+ *
5
+ * All information contained herein is proprietary and confidential.
6
+ * Dissemination of this information or reproduction of this file or material, via any medium is strictly forbidden unless
7
+ * prior written permission is obtained from Wiztivi.
8
+ * No warranty, explicit or implicit, provided.
9
+ * This software MAY NOT be used, modified or rewritten without prior written permission from Wiztivi.
10
+ *
11
+ */
12
+
13
+ import * as validator from "@/common/helpers/InputValidator.js";
14
+ import { describe, test, expect } from "vitest";
15
+
16
+ describe("validInputLength", () => {
17
+ test("should validate input length", () => {
18
+ const errorMessage = "Size matters !";
19
+ const inputs = [
20
+ { value: "", expected: errorMessage },
21
+ { value: " ", expected: errorMessage },
22
+ { value: "chaton", expected: "" },
23
+ ];
24
+
25
+ inputs.forEach((input) => {
26
+ expect(validator.validInputLength(errorMessage, input.value)).toBe(input.expected);
27
+ });
28
+ });
29
+ });
30
+
31
+ describe("validAppVersion", () => {
32
+ test("should validate app version format", () => {
33
+ const inputs = [
34
+ { value: "=v1.2.3 ", expected: "" },
35
+ { value: "1.2.3 ", expected: "" },
36
+ { value: "", expected: "App version is required" },
37
+ { value: "1.2 ", expected: "App version format should be x.x.x" },
38
+ ];
39
+
40
+ inputs.forEach((input) => {
41
+ expect(validator.validAppVersion(input.value)).toBe(input.expected);
42
+ });
43
+ });
44
+ });
45
+
46
+ describe("validAppVersionCode", () => {
47
+ test("should validate app version code as an integer", () => {
48
+ const inputs = [
49
+ { value: "", expected: "App version code is required" },
50
+ { value: "1.0.O", expected: "App version code has to be an Integer" },
51
+ { value: "1000", expected: "" },
52
+ { value: 1000, expected: "" },
53
+ ];
54
+
55
+ inputs.forEach((input) => {
56
+ expect(validator.validAppVersionCode(input.value)).toBe(input.expected);
57
+ });
58
+ });
59
+ });
60
+
61
+ describe("validAppId", () => {
62
+ test("should validate app ID to follow android spec", () => {
63
+ const inputs = [
64
+ { value: "", expected: "AppId is required !" },
65
+ { value: "1a", expected: "AppId should be in the following format: com.example.myapp !" },
66
+ { value: "aa.2", expected: "AppId should be in the following format: com.example.myapp !" },
67
+ { value: "aa-a", expected: "AppId should be in the following format: com.example.myapp !" },
68
+ { value: "aa-a", expected: "AppId should be in the following format: com.example.myapp !" },
69
+ { value: "aa.a", expected: "" },
70
+ { value: "AA.a2", expected: "" },
71
+ { value: "aA.a2.com", expected: "" },
72
+ ];
73
+
74
+ inputs.forEach((input) => {
75
+ expect(validator.validAppId(input.value)).toBe(input.expected);
76
+ });
77
+ });
78
+ });
79
+
80
+ describe("validNumber", () => {
81
+ it("should check that input is a number", () => {
82
+ const errorMessage = "Number, not dumber!";
83
+ const inputs = [
84
+ { value: "", expected: errorMessage },
85
+ { value: " ", expected: errorMessage },
86
+ { value: "ten", expected: errorMessage },
87
+ { value: "30", expected: "" },
88
+ ];
89
+ inputs.forEach((input) => {
90
+ expect(validator.validNumber(input.value, errorMessage)).toBe(input.expected);
91
+ });
92
+ });
93
+ });