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.
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 +66 -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,46 @@
1
+ import { findUp } from "find-up";
2
+ import { resolve, dirname, join } from "node:path";
3
+ import { access, cp } from "node:fs/promises";
4
+ import ComponentHelper from "@/commands/addComponent/helper/ComponentHelper.js";
5
+ import { MODULE_ERROR } from "@/common/const/exitCodeConst.js";
6
+ import * as prompts from "@clack/prompts";
7
+ import process from "node:process";
8
+ import { MODULES, MODULES_WITH_FONT_ICON, ModuleType } from "./moduleConst.js";
9
+ import CreateFileHelper from "@/common/helpers/CreateFileHelper.js";
10
+ import UpdateFileHelper from "@/common/helpers/UpdateFileHelper.js";
11
+
12
+ const addModule = async (name: string) => {
13
+ const modulesPath = await findUp(".dana", { type: "directory" });
14
+ const projectRoot = dirname(modulesPath!);
15
+ try {
16
+ await access(resolve(projectRoot, MODULES, name));
17
+ prompts.log.error(`The ${name} module already exist`);
18
+ process.exit(MODULE_ERROR);
19
+ } catch {
20
+ try {
21
+ const templateDir: string = resolve(dirname(ComponentHelper.getTemplatePath()), "modules", name);
22
+
23
+ await cp(templateDir, join(projectRoot, MODULES, name), { recursive: true });
24
+ const shouldCopyMenu = name === (ModuleType.HOME as string) || name === (ModuleType.VOD as string);
25
+ if (shouldCopyMenu) {
26
+ const menuDir = resolve(dirname(ComponentHelper.getTemplatePath()), "modules", ModuleType.MENU);
27
+ await cp(menuDir, join(projectRoot, MODULES, ModuleType.MENU), {
28
+ recursive: true,
29
+ });
30
+ }
31
+ if (MODULES_WITH_FONT_ICON.has(name as ModuleType)) {
32
+ await CreateFileHelper.copyFontFile(projectRoot);
33
+ await UpdateFileHelper.updateAppTheme({ directory: projectRoot }, "MockIcons");
34
+ }
35
+ const addMenuInProfile = shouldCopyMenu ? " and menu" : "";
36
+ prompts.log.success(
37
+ `The ${name} module has been created\n Don't forget to add ${name}${addMenuInProfile} in the desired profile(s)`,
38
+ );
39
+ } catch (e) {
40
+ prompts.log.error(`An error occurred : ${e}`);
41
+ process.exit(MODULE_ERROR);
42
+ }
43
+ }
44
+ };
45
+
46
+ export default addModule;
@@ -0,0 +1,17 @@
1
+ import { Argument, Command } from "commander";
2
+ import addModule from "./add-module.js";
3
+ import translation from "@/common/translation/translation.js";
4
+ import { ModuleType } from "./moduleConst.js";
5
+
6
+ const addModuleDefinition = () => {
7
+ const command = new Command("add-module");
8
+
9
+ command
10
+ .description(translation["command.module"])
11
+ .addArgument(new Argument("name", translation["command.module.name"]).choices(Object.values(ModuleType)))
12
+ .action(addModule);
13
+
14
+ return command;
15
+ };
16
+
17
+ export default addModuleDefinition;
@@ -0,0 +1,18 @@
1
+ export const MODULES = "modules";
2
+ export enum ModuleType {
3
+ MENU = "menu",
4
+ VOD = "vod",
5
+ FIP = "fip",
6
+ SETTINGS = "settings",
7
+ HOME = "home",
8
+ SEARCH = "search",
9
+ PLAYER = "player",
10
+ }
11
+ export const MODULES_WITH_FONT_ICON = new Set<ModuleType>([
12
+ ModuleType.MENU,
13
+ ModuleType.VOD,
14
+ ModuleType.SETTINGS,
15
+ ModuleType.HOME,
16
+ ModuleType.SEARCH,
17
+ ModuleType.PLAYER,
18
+ ]);
@@ -0,0 +1,255 @@
1
+ import getPort from "get-port";
2
+ import express from "express";
3
+ import { AwsCredentials, CodeArtifactToken, CredentialsHelper, DanaToken } from "./helper/CredentialsHelper.js";
4
+ import { log } from "@clack/prompts";
5
+ import translation from "@/common/translation/translation.js";
6
+ import open from "open";
7
+ import jwt, { JwtPayload } from "jsonwebtoken";
8
+ import {
9
+ createCodeArtifactClient,
10
+ formatRepositoryString,
11
+ getRepositoryEndpoint,
12
+ } from "./helper/CodeArtifactHelper.js";
13
+ import { GetAuthorizationTokenCommand } from "@aws-sdk/client-codeartifact";
14
+ import { DEFAULT_PORT_1, DEFAULT_PORT_2, DOMAIN, DOMAIN_OWNER } from "./authentConst.js";
15
+ import { execSync } from "node:child_process";
16
+ import { writeFile, mkdir, readFile } from "node:fs/promises";
17
+ import path from "node:path";
18
+ import { ensureSPMDirectoriesExists, updateSPMRegistries, updateSPMToken } from "./helper/SPM.js";
19
+
20
+ export interface CognitoIdToken extends JwtPayload {
21
+ given_name: string;
22
+ family_name: string;
23
+ email: string;
24
+ }
25
+
26
+ export interface AuthCredentials {
27
+ aws: AwsCredentials;
28
+ dana?: DanaToken;
29
+ codeArtifact?: CodeArtifactToken;
30
+ org: string;
31
+ isRemote: boolean;
32
+ port?: number;
33
+ patToken?: string;
34
+ }
35
+
36
+ export class AuthenticationManager {
37
+ private static getAPIURL(organization: string) {
38
+ return `https://api.${organization}.dana-framework.com`; // Or http://localhost:3001
39
+ }
40
+
41
+ static async login(params: {
42
+ organization: string;
43
+ isRemote: boolean;
44
+ userPort?: number;
45
+ patToken?: string;
46
+ }): Promise<AuthCredentials> {
47
+ const { organization, isRemote, userPort, patToken } = { ...params };
48
+ if (patToken) {
49
+ return AuthenticationManager._patLogin({ organization, isRemote, userPort, patToken });
50
+ }
51
+
52
+ const app = express();
53
+ app.disable("x-powered-by");
54
+
55
+ const promise = new Promise<AuthCredentials>((resolve, reject) => {
56
+ const timeout = setTimeout(
57
+ () => {
58
+ reject(new Error("Login timed out."));
59
+ },
60
+ 5 * 60 * 1000, // 5 minutes
61
+ );
62
+ app.get("/callback", async (req, res) => {
63
+ clearTimeout(timeout);
64
+ try {
65
+ if (req.query.error) {
66
+ res.send("Login failed. Check the CLI for details.");
67
+ return reject(new Error(req.query.error as string));
68
+ }
69
+
70
+ const token = JSON.parse(req.query.token as string) as DanaToken;
71
+ const awsCredentials = JSON.parse(req.query.aws as string) as AwsCredentials;
72
+ const creds = { aws: awsCredentials, dana: token, org: organization, isRemote, port: userPort };
73
+
74
+ res.send("Login successful! You can close this window.");
75
+ await CredentialsHelper.store(creds, isRemote, userPort);
76
+ resolve(creds);
77
+ } catch (err) {
78
+ res.send("Login failed. Check the CLI for details.");
79
+ reject(err as Error);
80
+ }
81
+ });
82
+ });
83
+ const defaultPortList = [DEFAULT_PORT_1, DEFAULT_PORT_2];
84
+ const portList = userPort ? [userPort].concat(defaultPortList) : defaultPortList;
85
+ const port = await getPort({ port: portList });
86
+ const server = app.listen(port);
87
+ if (isRemote) {
88
+ log.info(translation["command.auth.remoteMode"] + `Port: ${port}`);
89
+ log.info(
90
+ translation["command.auth.accessBrowserUrl"] +
91
+ ` ${AuthenticationManager.getAPIURL(organization)}/login?port=${port}`,
92
+ );
93
+ } else {
94
+ await open(`${AuthenticationManager.getAPIURL(organization)}/login?port=${port}`);
95
+ }
96
+ return promise.finally(() => {
97
+ server.closeAllConnections();
98
+ server.close();
99
+ });
100
+ }
101
+
102
+ static async logout(organization: string, creds?: Partial<DanaToken>, isRemote?: boolean) {
103
+ const url = new URL(`${AuthenticationManager.getAPIURL(organization)}/logout`);
104
+ if (creds?.id_token) {
105
+ url.searchParams.append("id_token", creds.id_token);
106
+ }
107
+ if (creds?.refresh_token) {
108
+ url.searchParams.append("refresh_token", creds.refresh_token);
109
+ }
110
+
111
+ if (isRemote) {
112
+ log.info(translation["command.auth.remoteMode"]);
113
+ log.info(translation["command.auth.accessBrowserUrl"] + `${url.toString()}`);
114
+ } else {
115
+ await open(url.toString());
116
+ }
117
+
118
+ await CredentialsHelper.delete(organization);
119
+ }
120
+
121
+ static async refresh(organization: string, token: string, isRemote: boolean, port?: number) {
122
+ const data = await fetch(`${AuthenticationManager.getAPIURL(organization)}/login?refresh_token=${token}`);
123
+ if (!data.ok) {
124
+ return AuthenticationManager.login({ organization, isRemote, userPort: port });
125
+ }
126
+
127
+ const refreshedCreds = (await data.json()) as { aws: AwsCredentials; token: DanaToken };
128
+ const creds = {
129
+ aws: refreshedCreds.aws,
130
+ dana: {
131
+ ...refreshedCreds.token,
132
+ refresh_token: token,
133
+ },
134
+ org: organization,
135
+ isRemote,
136
+ port,
137
+ };
138
+
139
+ await CredentialsHelper.store(creds, isRemote, port);
140
+ return creds;
141
+ }
142
+
143
+ static isTokenExpired(token: string) {
144
+ const payload = jwt.decode(token) as JwtPayload;
145
+ if (!payload.exp) {
146
+ return true;
147
+ }
148
+ const expirationDate = new Date(payload.exp * 1000);
149
+ return expirationDate <= new Date();
150
+ }
151
+
152
+ static async loginCodeArtifact(organization: string, credentials: AwsCredentials): Promise<CodeArtifactToken> {
153
+ // Create CodeArtifact client with credentials
154
+ const client = createCodeArtifactClient(credentials);
155
+
156
+ // Get authorization token
157
+ const tokenCommand = new GetAuthorizationTokenCommand({
158
+ domain: DOMAIN,
159
+ domainOwner: DOMAIN_OWNER,
160
+ });
161
+
162
+ const { authorizationToken, expiration } = await client.send(tokenCommand);
163
+
164
+ if (!authorizationToken) {
165
+ throw new Error("Authorization token not found");
166
+ }
167
+ const codeArtifactToken: CodeArtifactToken = {
168
+ token: authorizationToken,
169
+ expiration: expiration!,
170
+ };
171
+
172
+ await CredentialsHelper.updateCodeArtifactToken(organization, codeArtifactToken);
173
+
174
+ await AuthenticationManager.loginNPM(organization, credentials, codeArtifactToken);
175
+ await AuthenticationManager.loginGradle(organization, codeArtifactToken);
176
+ if (process.platform === "darwin") {
177
+ await AuthenticationManager.loginSPM(organization, credentials, codeArtifactToken);
178
+ }
179
+
180
+ return codeArtifactToken;
181
+ }
182
+
183
+ static async loginNPM(organization: string, credentials: AwsCredentials, token: CodeArtifactToken): Promise<void> {
184
+ // Create CodeArtifact client with credentials
185
+ const client = createCodeArtifactClient(credentials);
186
+
187
+ // Get repository endpoint
188
+ const repositoryEndpoint = await getRepositoryEndpoint({ organization, credentials, client, format: "npm" });
189
+ // Configure npm with the repository and token
190
+ execSync(`npm config set @dana:registry=${repositoryEndpoint}`);
191
+ execSync(`npm config set //${repositoryEndpoint.replace(/^https?:\/\//, "")}:_authToken=${token.token}`);
192
+ }
193
+
194
+ static async loginGradle(organization: string, token: CodeArtifactToken) {
195
+ const repository = formatRepositoryString(organization);
196
+ const gradleDir = path.join(process.env.HOME!, ".gradle");
197
+
198
+ await mkdir(gradleDir, { recursive: true });
199
+
200
+ const gradlePropertiesFilePath = path.join(gradleDir, "gradle.properties");
201
+ const gradlePropertiesFile = await readFile(gradlePropertiesFilePath, "utf-8").catch(() => "");
202
+
203
+ const key = `dana.${repository}.token`;
204
+ let replaced = false;
205
+ let lastEmptyLine = 0;
206
+ const lines = gradlePropertiesFile.split("\n").reduce((lines, line, index) => {
207
+ if (line.startsWith(key + "=")) {
208
+ line = `${key}=${token.token}`;
209
+ replaced = true;
210
+ } else if (line === "" && index > lastEmptyLine) {
211
+ lastEmptyLine = index;
212
+ }
213
+ lines.push(line);
214
+ return lines;
215
+ }, [] as string[]);
216
+ if (!replaced) {
217
+ lines.splice(lastEmptyLine, 0, `${key}=${token.token}`);
218
+ }
219
+ await writeFile(gradlePropertiesFilePath, lines.join("\n"));
220
+ }
221
+
222
+ static async loginSPM(organization: string, credentials: AwsCredentials, token: CodeArtifactToken): Promise<void> {
223
+ const userSPMRegistriesPath = ensureSPMDirectoriesExists();
224
+
225
+ const client = createCodeArtifactClient(credentials);
226
+ const repositoryEndpoint = await getRepositoryEndpoint({ organization, credentials, client, format: "swift" });
227
+
228
+ await updateSPMRegistries(await userSPMRegistriesPath, "dana", repositoryEndpoint);
229
+ updateSPMToken(repositoryEndpoint, token.token);
230
+ }
231
+
232
+ private static async _patLogin(params: {
233
+ organization: string;
234
+ isRemote: boolean;
235
+ userPort?: number;
236
+ patToken: string;
237
+ }): Promise<AuthCredentials> {
238
+ const { organization, isRemote, userPort, patToken } = { ...params };
239
+ const response = await fetch(
240
+ `${AuthenticationManager.getAPIURL(organization)}/login?patToken=${encodeURIComponent(patToken)}`,
241
+ );
242
+ if (!response.ok) {
243
+ throw new Error(`PAT authentication failed: ${response.statusText}`);
244
+ }
245
+ const { aws } = (await response.json()) as { aws: AwsCredentials };
246
+
247
+ return {
248
+ aws,
249
+ org: organization,
250
+ isRemote,
251
+ port: userPort,
252
+ patToken,
253
+ };
254
+ }
255
+ }
@@ -0,0 +1,51 @@
1
+ import { Command, Option } from "commander";
2
+ import translation from "@/common/translation/translation.js";
3
+ import login from "./commands/login.js";
4
+ import { statusAction } from "./commands/status.js";
5
+ import logout from "./commands/logout.js";
6
+ import { getPackagesToken } from "./commands/get-packages-token.js";
7
+ import { authHook } from "./authHook.js";
8
+ import { tokenHook } from "@/commands/authentication/tokenHook.js";
9
+
10
+ const addAuthDefinition = () => {
11
+ const command = new Command("auth").description(translation["command.auth.description"]);
12
+
13
+ const loginCmd = new Command("login")
14
+ .description(translation["command.auth.login.description"])
15
+ .option("-o, --org <organization>", translation["command.auth.login.option.org"])
16
+ .option("-r, --remote", translation["command.auth.login.option.remote"])
17
+ .option("-p, --port <port>", translation["command.auth.login.option.port"])
18
+ .option("-t, --token <patToken>", translation["command.auth.login.option.token"])
19
+ .hook("preAction", (_thisCommand, actionCommand) => tokenHook(_thisCommand, actionCommand))
20
+ .action(login);
21
+
22
+ command.addCommand(loginCmd);
23
+
24
+ const logoutCmd = new Command("logout")
25
+ .description(translation["command.auth.logout.description"])
26
+ .option("-o, --org <organization>", translation["command.auth.login.option.org"])
27
+ .action(logout);
28
+
29
+ command.addCommand(logoutCmd);
30
+
31
+ const statusCmd = new Command("status")
32
+ .description(translation["command.auth.status.description"])
33
+ .action(statusAction);
34
+
35
+ command.addCommand(statusCmd);
36
+
37
+ const getPackagesTokenCmd = new Command("get-packages-token")
38
+ .description(translation["command.auth.get-packages-token.description"])
39
+ .addOption(
40
+ new Option("-t, --target <target>", "Packages target").makeOptionMandatory(true).choices(["android"]),
41
+ )
42
+ .option("-o, --org <organization>", translation["command.auth.login.option.org"])
43
+ .hook("preAction", authHook)
44
+ .action(getPackagesToken);
45
+
46
+ command.addCommand(getPackagesTokenCmd);
47
+
48
+ return command;
49
+ };
50
+
51
+ export default addAuthDefinition;
@@ -0,0 +1,50 @@
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
+ import * as prompts from "@clack/prompts";
13
+ import { CredentialsHelper } from "./helper/CredentialsHelper.js";
14
+ import { AuthenticationManager } from "./AuthenticationManager.js";
15
+ import { LOGIN_ERROR } from "@/common/const/exitCodeConst.js";
16
+
17
+ export const authHook = async () => {
18
+ const credentials = await CredentialsHelper.get();
19
+
20
+ try {
21
+ if (!credentials.dana?.id_token || !credentials.dana?.refresh_token) {
22
+ await AuthenticationManager.login({
23
+ organization: credentials.org,
24
+ isRemote: credentials.isRemote,
25
+ userPort: credentials?.port,
26
+ });
27
+ return;
28
+ }
29
+ if (
30
+ AuthenticationManager.isTokenExpired(credentials.dana.id_token) ||
31
+ (credentials.aws && new Date(credentials.aws.expiration) < new Date())
32
+ ) {
33
+ await AuthenticationManager.refresh(
34
+ credentials.org,
35
+ credentials.dana.refresh_token,
36
+ credentials.isRemote,
37
+ credentials?.port,
38
+ );
39
+ }
40
+ if (
41
+ !credentials.codeArtifact?.token ||
42
+ (credentials.codeArtifact && credentials.codeArtifact.expiration < new Date())
43
+ ) {
44
+ await AuthenticationManager.loginCodeArtifact(credentials.org, credentials.aws!);
45
+ }
46
+ } catch (error) {
47
+ prompts.log.error((error as Error).message);
48
+ process.exit(LOGIN_ERROR);
49
+ }
50
+ };
@@ -0,0 +1,6 @@
1
+ export const DOMAIN = "dana";
2
+ export const DOMAIN_OWNER = "733912940672";
3
+ export const REGION = "eu-central-1";
4
+ export const DEFAULT_ORG = "public";
5
+ export const DEFAULT_PORT_1 = 10032;
6
+ export const DEFAULT_PORT_2 = 10064;
@@ -0,0 +1,40 @@
1
+ import { AwsCredentials, CredentialsHelper } from "@/commands/authentication/helper/CredentialsHelper.js";
2
+ import { createCodeArtifactClient } from "@/commands/authentication/helper/CodeArtifactHelper.js";
3
+ import { GetAuthorizationTokenCommand } from "@aws-sdk/client-codeartifact";
4
+ import * as prompts from "@clack/prompts";
5
+ import { GET_PACKAGES_TOKEN_ERROR } from "@/common/const/exitCodeConst.js";
6
+ import { DOMAIN, DOMAIN_OWNER } from "@/commands/authentication/authentConst.js";
7
+
8
+ interface GetPackageTokenOptions {
9
+ target: "android";
10
+ org?: string;
11
+ }
12
+
13
+ const getAndroidToken = async (creds: AwsCredentials) => {
14
+ const client = createCodeArtifactClient(creds);
15
+
16
+ const command = new GetAuthorizationTokenCommand({
17
+ domain: DOMAIN,
18
+ domainOwner: DOMAIN_OWNER,
19
+ });
20
+
21
+ try {
22
+ const result = await client.send(command);
23
+
24
+ console.log(result.authorizationToken);
25
+ } catch (error) {
26
+ prompts.log.error((error as Error).message);
27
+ process.exit(GET_PACKAGES_TOKEN_ERROR);
28
+ }
29
+ };
30
+
31
+ const getPackagesToken = async (options: GetPackageTokenOptions) => {
32
+ const creds = await CredentialsHelper.get(options.org);
33
+
34
+ switch (options.target) {
35
+ case "android":
36
+ // authHook ensure credentials are valid
37
+ return getAndroidToken(creds.aws!);
38
+ }
39
+ };
40
+ export { getPackagesToken };
@@ -0,0 +1,63 @@
1
+ import * as prompts from "@clack/prompts";
2
+ import colors from "picocolors";
3
+ import { CredentialsHelper } from "@/commands/authentication/helper/CredentialsHelper.js";
4
+ import { AuthCredentials, AuthenticationManager } from "@/commands/authentication/AuthenticationManager.js";
5
+ import { handleError } from "@/commands/authentication/helper/CommandHelper.js";
6
+
7
+ interface LoginOptions {
8
+ org?: string;
9
+ port?: number;
10
+ remote?: boolean;
11
+ token?: string;
12
+ }
13
+
14
+ /*
15
+ Login to DANA backend (with aws and cognito or with PAT) and connect to npm codeartifact
16
+ More info: https://github.com/wiztivi-rd/dana-cli/wiki/Login
17
+ */
18
+ const login = async ({ org, port, remote = false, token }: LoginOptions) => {
19
+ const credentials = await CredentialsHelper.get(org);
20
+
21
+ try {
22
+ let validCredentials: AuthCredentials;
23
+ if (token) {
24
+ prompts.intro(` PAT login to organization ${credentials.org}...`);
25
+ validCredentials = await AuthenticationManager.login({
26
+ organization: credentials.org,
27
+ isRemote: remote,
28
+ userPort: port,
29
+ patToken: token,
30
+ });
31
+ } else {
32
+ if (!credentials.dana?.id_token || !credentials.dana?.refresh_token) {
33
+ prompts.intro(`Credentials login to organization ${credentials.org} ...`);
34
+ validCredentials = await AuthenticationManager.login({
35
+ organization: credentials.org,
36
+ isRemote: remote,
37
+ userPort: port,
38
+ });
39
+ } else if (
40
+ AuthenticationManager.isTokenExpired(credentials.dana.id_token) ||
41
+ (credentials.aws && new Date(credentials.aws.expiration) < new Date())
42
+ ) {
43
+ prompts.intro(`Refreshing credentials for organization ${credentials.org}`);
44
+ validCredentials = await AuthenticationManager.refresh(
45
+ credentials.org,
46
+ credentials.dana.refresh_token,
47
+ remote,
48
+ port,
49
+ );
50
+ } else {
51
+ validCredentials = credentials as AuthCredentials;
52
+ }
53
+ prompts.outro(colors.green("✓") + ` Login successful`);
54
+ }
55
+ const codeArtifactAuth = await AuthenticationManager.loginCodeArtifact(credentials.org, validCredentials.aws);
56
+
57
+ prompts.log.step(`Login expires in 12 hours at: ${codeArtifactAuth.expiration.toLocaleString()}`);
58
+ } catch (error) {
59
+ handleError(error);
60
+ }
61
+ };
62
+
63
+ export default login;
@@ -0,0 +1,26 @@
1
+ import * as prompts from "@clack/prompts";
2
+ import colors from "picocolors";
3
+ import { CredentialsHelper } from "@/commands/authentication/helper/CredentialsHelper.js";
4
+ import { AuthenticationManager } from "@/commands/authentication/AuthenticationManager.js";
5
+ import { handleError } from "@/commands/authentication/helper/CommandHelper.js";
6
+
7
+ interface LogoutOptions {
8
+ org?: string;
9
+ }
10
+
11
+ /*
12
+ Logout from DANA backend
13
+ */
14
+ const logout = async ({ org }: LogoutOptions) => {
15
+ const credentials = await CredentialsHelper.get(org);
16
+
17
+ try {
18
+ prompts.intro(`Logout from ${credentials.org}...`);
19
+ await AuthenticationManager.logout(credentials.org, credentials.dana, credentials.isRemote);
20
+ prompts.outro(colors.green("✓") + ` Logout successful. You are now being logged out in your browser.`);
21
+ } catch (error) {
22
+ handleError(error);
23
+ }
24
+ };
25
+
26
+ export default logout;
@@ -0,0 +1,47 @@
1
+ import * as prompts from "@clack/prompts";
2
+ import jwt from "jsonwebtoken";
3
+ import colors from "picocolors";
4
+ import { CredentialsHelper } from "@/commands/authentication/helper/CredentialsHelper.js";
5
+ import translation from "@/common/translation/translation.js";
6
+ import { CognitoIdToken } from "@/commands/authentication/AuthenticationManager.js";
7
+
8
+ enum LOGIN_STATUS {
9
+ LOGGED = 1,
10
+ NOT_LOGGED = 2,
11
+ TOKEN_EXPIRED = 3,
12
+ }
13
+
14
+ const status = async (): Promise<LOGIN_STATUS> => {
15
+ const credentials = await CredentialsHelper.get();
16
+
17
+ if (!credentials?.dana?.id_token) {
18
+ prompts.log.error(`${translation["login.error.not_logged"]} ${translation["login.info.please_login"]}`);
19
+ return LOGIN_STATUS.NOT_LOGGED;
20
+ }
21
+
22
+ const id_token: string = credentials.dana.id_token;
23
+ const { given_name, family_name, email, exp } = jwt.decode(id_token) as CognitoIdToken;
24
+
25
+ const expiration = exp && new Date(exp * 1000);
26
+
27
+ if (expiration && new Date() > expiration) {
28
+ prompts.log.error(`${translation["login.info.token_expired"]} ${translation["login.info.please_login"]}`);
29
+ return LOGIN_STATUS.TOKEN_EXPIRED;
30
+ }
31
+
32
+ const expStr = expiration ? `\nToken expires on ${expiration.toUTCString()}` : "";
33
+ prompts.log.success(
34
+ `${translation["login.info.logged"]} ${colors.bold(credentials.org)}: ${colors.bold(given_name + " " + family_name)} (${email})${expStr}
35
+ `,
36
+ );
37
+ return LOGIN_STATUS.LOGGED;
38
+ };
39
+
40
+ /**
41
+ * Sends void intentionally to be used a Commander acceptable command
42
+ */
43
+ const statusAction = async () => {
44
+ await status();
45
+ };
46
+
47
+ export { LOGIN_STATUS, status, statusAction };