nativescript 8.9.0-alpha.2 → 8.9.0-dev.0

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 (345) hide show
  1. package/config/test-deps-versions-generated.json +1 -1
  2. package/lib/android-tools-info.js +9 -20
  3. package/lib/base-package-manager.js +47 -64
  4. package/lib/bun-package-manager.js +65 -88
  5. package/lib/color.js +2 -2
  6. package/lib/commands/add-platform.js +14 -30
  7. package/lib/commands/apple-login.js +18 -29
  8. package/lib/commands/appstore-list.js +34 -45
  9. package/lib/commands/appstore-upload.js +52 -65
  10. package/lib/commands/build.js +55 -87
  11. package/lib/commands/clean.js +161 -176
  12. package/lib/commands/command-base.js +14 -27
  13. package/lib/commands/config.js +48 -67
  14. package/lib/commands/create-project.js +211 -230
  15. package/lib/commands/debug.js +66 -88
  16. package/lib/commands/deploy.js +28 -44
  17. package/lib/commands/embedding/embed.js +33 -52
  18. package/lib/commands/extensibility/install-extension.js +5 -16
  19. package/lib/commands/extensibility/list-extensions.js +13 -24
  20. package/lib/commands/extensibility/uninstall-extension.js +4 -15
  21. package/lib/commands/fonts.js +30 -41
  22. package/lib/commands/generate-assets.js +13 -28
  23. package/lib/commands/generate-help.js +2 -13
  24. package/lib/commands/generate.js +12 -60
  25. package/lib/commands/info.js +2 -13
  26. package/lib/commands/install.js +34 -49
  27. package/lib/commands/list-platforms.js +14 -25
  28. package/lib/commands/migrate.js +15 -26
  29. package/lib/commands/native-add.js +23 -46
  30. package/lib/commands/platform-clean.js +19 -32
  31. package/lib/commands/plugin/add-plugin.js +12 -25
  32. package/lib/commands/plugin/build-plugin.js +31 -44
  33. package/lib/commands/plugin/create-plugin.js +110 -133
  34. package/lib/commands/plugin/list-plugins.js +22 -33
  35. package/lib/commands/plugin/remove-plugin.js +20 -33
  36. package/lib/commands/plugin/update-plugin.js +20 -33
  37. package/lib/commands/post-install.js +20 -33
  38. package/lib/commands/prepare.js +19 -35
  39. package/lib/commands/preview.js +49 -62
  40. package/lib/commands/remove-platform.js +7 -18
  41. package/lib/commands/resources/resources-update.js +13 -26
  42. package/lib/commands/run.js +55 -76
  43. package/lib/commands/start.js +6 -19
  44. package/lib/commands/test-init.js +123 -134
  45. package/lib/commands/test.js +66 -89
  46. package/lib/commands/typings.js +126 -142
  47. package/lib/commands/update-platform.js +22 -35
  48. package/lib/commands/update.js +30 -43
  49. package/lib/common/child-process.js +53 -72
  50. package/lib/common/codeGeneration/code-entity.js +1 -1
  51. package/lib/common/codeGeneration/code-printer.js +1 -1
  52. package/lib/common/command-params.js +7 -18
  53. package/lib/common/commands/analytics.js +27 -40
  54. package/lib/common/commands/autocompletion.js +39 -56
  55. package/lib/common/commands/device/device-log-stream.js +12 -23
  56. package/lib/common/commands/device/get-file.js +22 -33
  57. package/lib/common/commands/device/list-applications.js +12 -23
  58. package/lib/common/commands/device/list-devices.js +72 -87
  59. package/lib/common/commands/device/list-files.js +23 -34
  60. package/lib/common/commands/device/put-file.js +22 -33
  61. package/lib/common/commands/device/run-application.js +12 -25
  62. package/lib/common/commands/device/stop-application.js +11 -22
  63. package/lib/common/commands/device/uninstall-application.js +6 -17
  64. package/lib/common/commands/generate-messages.js +17 -28
  65. package/lib/common/commands/help.js +20 -33
  66. package/lib/common/commands/package-manager-get.js +6 -17
  67. package/lib/common/commands/package-manager-set.js +9 -20
  68. package/lib/common/commands/post-install.js +2 -13
  69. package/lib/common/commands/preuninstall.js +23 -38
  70. package/lib/common/commands/proxy/proxy-base.js +8 -19
  71. package/lib/common/commands/proxy/proxy-clear.js +4 -15
  72. package/lib/common/commands/proxy/proxy-get.js +3 -14
  73. package/lib/common/commands/proxy/proxy-set.js +87 -100
  74. package/lib/common/constants.js +11 -11
  75. package/lib/common/decorators.js +10 -22
  76. package/lib/common/dispatchers.js +79 -96
  77. package/lib/common/errors.js +89 -104
  78. package/lib/common/file-system.js +108 -130
  79. package/lib/common/header.js +1 -2
  80. package/lib/common/helpers.js +149 -178
  81. package/lib/common/host-info.js +37 -50
  82. package/lib/common/http-client.js +93 -108
  83. package/lib/common/logger/appenders/cli-appender.js +1 -2
  84. package/lib/common/logger/appenders/emit-appender.js +1 -2
  85. package/lib/common/logger/layouts/cli-layout.js +1 -2
  86. package/lib/common/logger/logger.js +4 -4
  87. package/lib/common/mobile/android/android-application-manager.js +121 -142
  88. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -1
  89. package/lib/common/mobile/android/android-debug-bridge.js +87 -112
  90. package/lib/common/mobile/android/android-device-file-system.js +98 -131
  91. package/lib/common/mobile/android/android-device-hash-service.js +50 -75
  92. package/lib/common/mobile/android/android-device.js +68 -85
  93. package/lib/common/mobile/android/android-emulator-services.js +105 -130
  94. package/lib/common/mobile/android/android-ini-file-parser.js +8 -6
  95. package/lib/common/mobile/android/android-log-filter.js +1 -1
  96. package/lib/common/mobile/android/android-virtual-device-service.js +76 -97
  97. package/lib/common/mobile/android/device-android-debug-bridge.js +13 -29
  98. package/lib/common/mobile/android/genymotion/genymotion-service.js +91 -118
  99. package/lib/common/mobile/android/genymotion/virtualbox-service.js +64 -81
  100. package/lib/common/mobile/android/logcat-helper.js +108 -127
  101. package/lib/common/mobile/application-manager-base.js +84 -107
  102. package/lib/common/mobile/device-log-provider-base.js +7 -18
  103. package/lib/common/mobile/ios/device/ios-application-manager.js +79 -108
  104. package/lib/common/mobile/ios/device/ios-device-file-system.js +78 -105
  105. package/lib/common/mobile/ios/device/ios-device-operations.js +105 -142
  106. package/lib/common/mobile/ios/device/ios-device.js +20 -36
  107. package/lib/common/mobile/ios/ios-device-base.js +58 -81
  108. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +63 -92
  109. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -1
  110. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +60 -89
  111. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +27 -43
  112. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +37 -62
  113. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +24 -35
  114. package/lib/common/mobile/mobile-core/android-device-discovery.js +43 -62
  115. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +21 -32
  116. package/lib/common/mobile/mobile-core/android-process-service.js +143 -182
  117. package/lib/common/mobile/mobile-core/device-discovery.js +2 -13
  118. package/lib/common/mobile/mobile-core/devices-service.js +386 -436
  119. package/lib/common/mobile/mobile-core/ios-device-discovery.js +24 -35
  120. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +47 -62
  121. package/lib/common/mobile/mobile-helper.js +15 -26
  122. package/lib/common/mobile/wp8/wp8-emulator-services.js +25 -52
  123. package/lib/common/opener.js +2 -2
  124. package/lib/common/prompter.js +90 -105
  125. package/lib/common/queue.js +9 -20
  126. package/lib/common/services/auto-completion-service.js +39 -52
  127. package/lib/common/services/cancellation.js +17 -28
  128. package/lib/common/services/commands-service.js +146 -169
  129. package/lib/common/services/help-service.js +132 -157
  130. package/lib/common/services/hooks-service.js +93 -108
  131. package/lib/common/services/ios-notification-service.js +21 -34
  132. package/lib/common/services/json-file-settings-service.js +52 -71
  133. package/lib/common/services/lock-service.js +35 -52
  134. package/lib/common/services/message-contract-generator.js +35 -46
  135. package/lib/common/services/micro-templating-service.js +4 -15
  136. package/lib/common/services/net-service.js +90 -107
  137. package/lib/common/services/project-files-manager.js +10 -23
  138. package/lib/common/services/proxy-service.js +13 -24
  139. package/lib/common/services/qr.js +13 -24
  140. package/lib/common/services/settings-service.js +1 -1
  141. package/lib/common/services/xcode-select-service.js +20 -35
  142. package/lib/common/utils.js +2 -2
  143. package/lib/common/validators/project-name-validator.js +1 -1
  144. package/lib/common/validators/validation-result.js +1 -1
  145. package/lib/common/verify-node-version.js +2 -3
  146. package/lib/common/yok.js +23 -36
  147. package/lib/config.js +36 -51
  148. package/lib/constants.js +24 -24
  149. package/lib/controllers/build-controller.js +82 -99
  150. package/lib/controllers/debug-controller.js +107 -128
  151. package/lib/controllers/deploy-controller.js +15 -23
  152. package/lib/controllers/migrate-controller.js +722 -795
  153. package/lib/controllers/platform-controller.js +70 -85
  154. package/lib/controllers/prepare-controller.js +232 -261
  155. package/lib/controllers/run-controller.js +397 -411
  156. package/lib/controllers/update-controller-base.js +16 -29
  157. package/lib/controllers/update-controller.js +94 -119
  158. package/lib/data/prepare-data.js +4 -1
  159. package/lib/definitions/ios.d.ts +9 -1
  160. package/lib/detached-processes/cleanup-js-subprocess.js +3 -12
  161. package/lib/detached-processes/cleanup-process.js +16 -25
  162. package/lib/device-path-provider.js +23 -34
  163. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +149 -164
  164. package/lib/device-sockets/ios/notification.js +1 -1
  165. package/lib/device-sockets/ios/socket-request-executor.js +24 -39
  166. package/lib/helpers/android-bundle-validator-helper.js +1 -1
  167. package/lib/helpers/deploy-command-helper.js +44 -49
  168. package/lib/helpers/key-command-helper.js +4 -13
  169. package/lib/helpers/livesync-command-helper.js +137 -152
  170. package/lib/helpers/network-connectivity-validator.js +6 -17
  171. package/lib/helpers/options-track-helper.js +6 -17
  172. package/lib/helpers/platform-command-helper.js +99 -120
  173. package/lib/key-commands/index.js +150 -200
  174. package/lib/nativescript-cli.js +5 -14
  175. package/lib/node-package-manager.js +81 -104
  176. package/lib/options.js +3 -12
  177. package/lib/package-installation-manager.js +130 -165
  178. package/lib/package-manager.js +63 -86
  179. package/lib/platform-command-param.js +4 -15
  180. package/lib/pnpm-package-manager.js +59 -78
  181. package/lib/project-data.js +1 -1
  182. package/lib/providers/project-files-provider.js +1 -1
  183. package/lib/services/analytics/analytics-broker-process.js +13 -22
  184. package/lib/services/analytics/analytics-broker.js +17 -30
  185. package/lib/services/analytics/analytics-service.js +163 -199
  186. package/lib/services/analytics/google-analytics-provider.js +41 -56
  187. package/lib/services/analytics-settings-service.js +15 -32
  188. package/lib/services/android/android-bundle-tool-service.js +43 -60
  189. package/lib/services/android/gradle-build-args-service.js +9 -20
  190. package/lib/services/android/gradle-build-service.js +22 -35
  191. package/lib/services/android/gradle-command-service.js +22 -35
  192. package/lib/services/android-device-debug-service.js +90 -117
  193. package/lib/services/android-plugin-build-service.js +205 -231
  194. package/lib/services/android-project-service.js +126 -171
  195. package/lib/services/android-resources-migration-service.js +51 -64
  196. package/lib/services/apple-portal/apple-portal-application-service.js +46 -63
  197. package/lib/services/apple-portal/apple-portal-session-service.js +195 -214
  198. package/lib/services/apple-portal/srp/srp-wrapper.js +43 -58
  199. package/lib/services/assets-generation/assets-generation-service.js +103 -117
  200. package/lib/services/build-artifacts-service.js +9 -20
  201. package/lib/services/build-info-file-service.js +20 -35
  202. package/lib/services/cleanup-service.js +47 -76
  203. package/lib/services/cocoapods-service.js +111 -132
  204. package/lib/services/device/device-install-app-service.js +54 -71
  205. package/lib/services/doctor-service.js +99 -118
  206. package/lib/services/extensibility-service.js +81 -100
  207. package/lib/services/files-hash-service.js +26 -43
  208. package/lib/services/hmr-status-service.js +1 -1
  209. package/lib/services/initialize-service.js +37 -50
  210. package/lib/services/ios/export-options-plist-service.js +38 -51
  211. package/lib/services/ios/ios-signing-service.js +168 -187
  212. package/lib/services/ios/spm-service.js +43 -53
  213. package/lib/services/ios/xcodebuild-args-service.js +77 -94
  214. package/lib/services/ios/xcodebuild-command-service.js +14 -25
  215. package/lib/services/ios/xcodebuild-service.js +52 -71
  216. package/lib/services/ios-debugger-port-service.js +24 -37
  217. package/lib/services/ios-device-debug-service.js +75 -102
  218. package/lib/services/ios-entitlements-service.js +31 -42
  219. package/lib/services/ios-extensions-service.js +18 -29
  220. package/lib/services/ios-project-service.js +419 -460
  221. package/lib/services/ios-provision-service.js +108 -129
  222. package/lib/services/ios-watch-app-service.js +21 -32
  223. package/lib/services/ip-service.js +38 -53
  224. package/lib/services/itmstransporter-service.js +129 -152
  225. package/lib/services/livesync/android-device-livesync-service-base.js +31 -48
  226. package/lib/services/livesync/android-device-livesync-service.js +120 -149
  227. package/lib/services/livesync/android-device-livesync-sockets-service.js +121 -152
  228. package/lib/services/livesync/android-livesync-service.js +14 -35
  229. package/lib/services/livesync/android-livesync-tool.js +90 -113
  230. package/lib/services/livesync/device-livesync-service-base.js +15 -28
  231. package/lib/services/livesync/ios-device-livesync-service.js +114 -143
  232. package/lib/services/livesync/ios-livesync-service.js +42 -58
  233. package/lib/services/livesync/platform-livesync-service-base.js +94 -119
  234. package/lib/services/log-parser-service.js +1 -1
  235. package/lib/services/log-source-map-service.js +30 -41
  236. package/lib/services/marking-mode-service.js +15 -28
  237. package/lib/services/npm-config-service.js +1 -1
  238. package/lib/services/pacote-service.js +51 -66
  239. package/lib/services/performance-service.js +1 -1
  240. package/lib/services/platform/add-platform-service.js +50 -71
  241. package/lib/services/platform/platform-validation-service.js +22 -33
  242. package/lib/services/platform/prepare-native-platform-service.js +49 -62
  243. package/lib/services/platform-environment-requirements.js +26 -37
  244. package/lib/services/plugins-service.js +122 -147
  245. package/lib/services/project-backup-service.js +1 -1
  246. package/lib/services/project-changes-service.js +124 -141
  247. package/lib/services/project-cleanup-service.js +64 -77
  248. package/lib/services/project-config-service.js +71 -80
  249. package/lib/services/project-data-service.js +101 -118
  250. package/lib/services/project-name-service.js +28 -43
  251. package/lib/services/project-service.js +84 -103
  252. package/lib/services/project-templates-service.js +52 -67
  253. package/lib/services/start-service.js +41 -59
  254. package/lib/services/temp-service.js +8 -21
  255. package/lib/services/terminal-spinner-service.js +15 -26
  256. package/lib/services/test-execution-service.js +59 -72
  257. package/lib/services/test-initialization-service.js +2 -2
  258. package/lib/services/timeline-profiler-service.js +1 -1
  259. package/lib/services/versions-service.js +119 -138
  260. package/lib/services/webpack/webpack-compiler-service.js +214 -234
  261. package/lib/services/xcconfig-service.js +8 -19
  262. package/lib/sys-info.js +45 -62
  263. package/lib/tools/node-modules/node-modules-builder.js +16 -27
  264. package/lib/yarn-package-manager.js +59 -78
  265. package/lib/yarn2-package-manager.js +60 -79
  266. package/package.json +66 -81
  267. package/node_modules/@npmcli/move-file/LICENSE.md +0 -22
  268. package/node_modules/@npmcli/move-file/README.md +0 -69
  269. package/node_modules/@npmcli/move-file/lib/index.js +0 -185
  270. package/node_modules/@npmcli/move-file/node_modules/mkdirp/CHANGELOG.md +0 -15
  271. package/node_modules/@npmcli/move-file/node_modules/mkdirp/LICENSE +0 -21
  272. package/node_modules/@npmcli/move-file/node_modules/mkdirp/bin/cmd.js +0 -68
  273. package/node_modules/@npmcli/move-file/node_modules/mkdirp/index.js +0 -31
  274. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/find-made.js +0 -29
  275. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
  276. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
  277. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/opts-arg.js +0 -23
  278. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/path-arg.js +0 -29
  279. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/use-native.js +0 -10
  280. package/node_modules/@npmcli/move-file/node_modules/mkdirp/package.json +0 -44
  281. package/node_modules/@npmcli/move-file/node_modules/mkdirp/readme.markdown +0 -266
  282. package/node_modules/@npmcli/move-file/package.json +0 -47
  283. package/node_modules/balanced-match/.github/FUNDING.yml +0 -2
  284. package/node_modules/balanced-match/LICENSE.md +0 -21
  285. package/node_modules/balanced-match/README.md +0 -97
  286. package/node_modules/balanced-match/index.js +0 -62
  287. package/node_modules/balanced-match/package.json +0 -48
  288. package/node_modules/concat-map/.travis.yml +0 -4
  289. package/node_modules/concat-map/LICENSE +0 -18
  290. package/node_modules/concat-map/README.markdown +0 -62
  291. package/node_modules/concat-map/example/map.js +0 -6
  292. package/node_modules/concat-map/index.js +0 -13
  293. package/node_modules/concat-map/package.json +0 -43
  294. package/node_modules/concat-map/test/map.js +0 -39
  295. package/node_modules/fs.realpath/LICENSE +0 -43
  296. package/node_modules/fs.realpath/README.md +0 -33
  297. package/node_modules/fs.realpath/index.js +0 -66
  298. package/node_modules/fs.realpath/old.js +0 -303
  299. package/node_modules/fs.realpath/package.json +0 -26
  300. package/node_modules/inflight/LICENSE +0 -15
  301. package/node_modules/inflight/README.md +0 -37
  302. package/node_modules/inflight/inflight.js +0 -54
  303. package/node_modules/inflight/package.json +0 -29
  304. package/node_modules/inherits/LICENSE +0 -16
  305. package/node_modules/inherits/README.md +0 -42
  306. package/node_modules/inherits/inherits.js +0 -9
  307. package/node_modules/inherits/inherits_browser.js +0 -27
  308. package/node_modules/inherits/package.json +0 -29
  309. package/node_modules/once/LICENSE +0 -15
  310. package/node_modules/once/README.md +0 -79
  311. package/node_modules/once/once.js +0 -42
  312. package/node_modules/once/package.json +0 -33
  313. package/node_modules/path-is-absolute/index.js +0 -20
  314. package/node_modules/path-is-absolute/license +0 -21
  315. package/node_modules/path-is-absolute/package.json +0 -43
  316. package/node_modules/path-is-absolute/readme.md +0 -59
  317. package/node_modules/rimraf/CHANGELOG.md +0 -65
  318. package/node_modules/rimraf/LICENSE +0 -15
  319. package/node_modules/rimraf/README.md +0 -101
  320. package/node_modules/rimraf/bin.js +0 -68
  321. package/node_modules/rimraf/node_modules/brace-expansion/LICENSE +0 -21
  322. package/node_modules/rimraf/node_modules/brace-expansion/README.md +0 -129
  323. package/node_modules/rimraf/node_modules/brace-expansion/index.js +0 -201
  324. package/node_modules/rimraf/node_modules/brace-expansion/package.json +0 -47
  325. package/node_modules/rimraf/node_modules/glob/LICENSE +0 -21
  326. package/node_modules/rimraf/node_modules/glob/README.md +0 -378
  327. package/node_modules/rimraf/node_modules/glob/common.js +0 -238
  328. package/node_modules/rimraf/node_modules/glob/glob.js +0 -790
  329. package/node_modules/rimraf/node_modules/glob/package.json +0 -55
  330. package/node_modules/rimraf/node_modules/glob/sync.js +0 -486
  331. package/node_modules/rimraf/node_modules/minimatch/LICENSE +0 -15
  332. package/node_modules/rimraf/node_modules/minimatch/README.md +0 -230
  333. package/node_modules/rimraf/node_modules/minimatch/minimatch.js +0 -947
  334. package/node_modules/rimraf/node_modules/minimatch/package.json +0 -33
  335. package/node_modules/rimraf/package.json +0 -32
  336. package/node_modules/rimraf/rimraf.js +0 -360
  337. package/node_modules/stringify-package/CHANGELOG.md +0 -16
  338. package/node_modules/stringify-package/LICENSE +0 -13
  339. package/node_modules/stringify-package/README.md +0 -55
  340. package/node_modules/stringify-package/index.js +0 -18
  341. package/node_modules/stringify-package/package.json +0 -38
  342. package/node_modules/wrappy/LICENSE +0 -15
  343. package/node_modules/wrappy/README.md +0 -36
  344. package/node_modules/wrappy/package.json +0 -29
  345. package/node_modules/wrappy/wrappy.js +0 -33
@@ -5,15 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
8
  Object.defineProperty(exports, "__esModule", { value: true });
18
9
  exports.DevicesService = void 0;
19
10
  const assert = require("assert");
@@ -63,107 +54,101 @@ class DevicesService extends events_1.EventEmitter {
63
54
  this.$iOSSimulatorDiscovery,
64
55
  ];
65
56
  }
66
- pickSingleDevice(options) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (options.onlyDevices && options.onlyEmulators) {
69
- this.$errors.fail(constants_1.DebugCommandErrors.UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR);
70
- }
71
- if (options.deviceId) {
72
- const device = yield this.getDevice(options.deviceId);
73
- return device;
57
+ async pickSingleDevice(options) {
58
+ if (options.onlyDevices && options.onlyEmulators) {
59
+ this.$errors.fail(constants_1.DebugCommandErrors.UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR);
60
+ }
61
+ if (options.deviceId) {
62
+ const device = await this.getDevice(options.deviceId);
63
+ return device;
64
+ }
65
+ const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
66
+ (!this.platform ||
67
+ d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
68
+ const selectedDevices = availableDevicesAndEmulators.filter((d) => options.onlyEmulators
69
+ ? d.isEmulator
70
+ : options.onlyDevices
71
+ ? !d.isEmulator
72
+ : true);
73
+ if (selectedDevices.length > 1) {
74
+ if ((0, helpers_1.isInteractive)()) {
75
+ const choices = selectedDevices.map((e) => `${e.deviceInfo.identifier} - ${e.deviceInfo.displayName}`);
76
+ const selectedDeviceString = await this.$prompter.promptForChoice("Select device for debugging", choices);
77
+ const selectedDevice = _.find(selectedDevices, (d) => `${d.deviceInfo.identifier} - ${d.deviceInfo.displayName}` ===
78
+ selectedDeviceString);
79
+ return selectedDevice;
74
80
  }
75
- const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
76
- (!this.platform ||
77
- d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
78
- const selectedDevices = availableDevicesAndEmulators.filter((d) => options.onlyEmulators
79
- ? d.isEmulator
80
- : options.onlyDevices
81
- ? !d.isEmulator
82
- : true);
83
- if (selectedDevices.length > 1) {
84
- if ((0, helpers_1.isInteractive)()) {
85
- const choices = selectedDevices.map((e) => `${e.deviceInfo.identifier} - ${e.deviceInfo.displayName}`);
86
- const selectedDeviceString = yield this.$prompter.promptForChoice("Select device for debugging", choices);
87
- const selectedDevice = _.find(selectedDevices, (d) => `${d.deviceInfo.identifier} - ${d.deviceInfo.displayName}` ===
88
- selectedDeviceString);
89
- return selectedDevice;
81
+ else {
82
+ const sortedInstances = _.sortBy(selectedDevices, (e) => e.deviceInfo.version);
83
+ const emulators = sortedInstances.filter((e) => e.isEmulator);
84
+ const devices = sortedInstances.filter((d) => !d.isEmulator);
85
+ let selectedInstance;
86
+ if (options.onlyEmulators || options.onlyDevices) {
87
+ selectedInstance = _.last(sortedInstances);
90
88
  }
91
89
  else {
92
- const sortedInstances = _.sortBy(selectedDevices, (e) => e.deviceInfo.version);
93
- const emulators = sortedInstances.filter((e) => e.isEmulator);
94
- const devices = sortedInstances.filter((d) => !d.isEmulator);
95
- let selectedInstance;
96
- if (options.onlyEmulators || options.onlyDevices) {
97
- selectedInstance = _.last(sortedInstances);
90
+ if (emulators.length) {
91
+ selectedInstance = _.last(emulators);
98
92
  }
99
93
  else {
100
- if (emulators.length) {
101
- selectedInstance = _.last(emulators);
102
- }
103
- else {
104
- selectedInstance = _.last(devices);
105
- }
94
+ selectedInstance = _.last(devices);
106
95
  }
107
- this.$logger.warn(`Multiple devices/emulators found. Starting debugger on ${selectedInstance.deviceInfo.identifier}. ` +
108
- "If you want to debug on specific device/emulator, you can specify it with --device option.");
109
- return selectedInstance;
110
96
  }
97
+ this.$logger.warn(`Multiple devices/emulators found. Starting debugger on ${selectedInstance.deviceInfo.identifier}. ` +
98
+ "If you want to debug on specific device/emulator, you can specify it with --device option.");
99
+ return selectedInstance;
111
100
  }
112
- else if (selectedDevices.length === 1) {
113
- return _.head(selectedDevices);
114
- }
115
- this.$errors.fail(constants_1.DebugCommandErrors.NO_DEVICES_EMULATORS_FOUND_FOR_OPTIONS);
116
- });
101
+ }
102
+ else if (selectedDevices.length === 1) {
103
+ return _.head(selectedDevices);
104
+ }
105
+ this.$errors.fail(constants_1.DebugCommandErrors.NO_DEVICES_EMULATORS_FOUND_FOR_OPTIONS);
117
106
  }
118
- getEmulatorImages(options) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const result = Object.create(null);
121
- if (this.$hostInfo.isDarwin &&
122
- (!options ||
123
- !options.platform ||
124
- this.$mobileHelper.isiOSPlatform(options.platform))) {
125
- result.ios = yield this.$iOSEmulatorServices.getEmulatorImages();
126
- }
127
- if (!options ||
107
+ async getEmulatorImages(options) {
108
+ const result = Object.create(null);
109
+ if (this.$hostInfo.isDarwin &&
110
+ (!options ||
128
111
  !options.platform ||
129
- this.$mobileHelper.isAndroidPlatform(options.platform)) {
130
- result.android = yield this.$androidEmulatorServices.getEmulatorImages();
131
- }
132
- return result;
133
- });
112
+ this.$mobileHelper.isiOSPlatform(options.platform))) {
113
+ result.ios = await this.$iOSEmulatorServices.getEmulatorImages();
114
+ }
115
+ if (!options ||
116
+ !options.platform ||
117
+ this.$mobileHelper.isAndroidPlatform(options.platform)) {
118
+ result.android = await this.$androidEmulatorServices.getEmulatorImages();
119
+ }
120
+ return result;
134
121
  }
135
- startEmulator(options) {
136
- return __awaiter(this, void 0, void 0, function* () {
137
- if (!options || (!options.imageIdentifier && !options.emulatorIdOrName)) {
138
- return ["Missing mandatory image identifier or name option."];
139
- }
140
- const availableEmulatorsOutput = yield this.getEmulatorImages({
141
- platform: options.platform,
142
- });
143
- const emulators = this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
144
- const errors = this.$emulatorHelper.getErrorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
145
- let emulator = null;
146
- if (options.imageIdentifier) {
147
- emulator = this.$emulatorHelper.getEmulatorByImageIdentifier(options.imageIdentifier, emulators);
148
- }
149
- else if (options.emulatorIdOrName) {
150
- emulator = this.$emulatorHelper.getEmulatorByIdOrName(options.emulatorIdOrName, emulators);
151
- }
152
- if (!emulator) {
153
- const additionalErrors = errors && errors.length ? errors : [];
154
- return [
155
- `Unable to find emulator with provided options: ${options}`,
156
- ...additionalErrors,
157
- ];
158
- }
159
- if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
160
- return null;
161
- }
162
- options.emulator = emulator;
163
- const emulatorService = this.resolveEmulatorServices(emulator.platform);
164
- const result = yield emulatorService.startEmulator(options);
165
- return result.errors && result.errors.length ? result.errors : null;
122
+ async startEmulator(options) {
123
+ if (!options || (!options.imageIdentifier && !options.emulatorIdOrName)) {
124
+ return ["Missing mandatory image identifier or name option."];
125
+ }
126
+ const availableEmulatorsOutput = await this.getEmulatorImages({
127
+ platform: options.platform,
166
128
  });
129
+ const emulators = this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
130
+ const errors = this.$emulatorHelper.getErrorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
131
+ let emulator = null;
132
+ if (options.imageIdentifier) {
133
+ emulator = this.$emulatorHelper.getEmulatorByImageIdentifier(options.imageIdentifier, emulators);
134
+ }
135
+ else if (options.emulatorIdOrName) {
136
+ emulator = this.$emulatorHelper.getEmulatorByIdOrName(options.emulatorIdOrName, emulators);
137
+ }
138
+ if (!emulator) {
139
+ const additionalErrors = errors && errors.length ? errors : [];
140
+ return [
141
+ `Unable to find emulator with provided options: ${options}`,
142
+ ...additionalErrors,
143
+ ];
144
+ }
145
+ if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
146
+ return null;
147
+ }
148
+ options.emulator = emulator;
149
+ const emulatorService = this.resolveEmulatorServices(emulator.platform);
150
+ const result = await emulatorService.startEmulator(options);
151
+ return result.errors && result.errors.length ? result.errors : null;
167
152
  }
168
153
  get platform() {
169
154
  return this._platform;
@@ -207,11 +192,9 @@ class DevicesService extends events_1.EventEmitter {
207
192
  return device;
208
193
  });
209
194
  }
210
- getInstalledApplications(deviceIdentifier) {
211
- return __awaiter(this, void 0, void 0, function* () {
212
- const device = yield this.getDevice(deviceIdentifier);
213
- return device.applicationManager.getInstalledApplications();
214
- });
195
+ async getInstalledApplications(deviceIdentifier) {
196
+ const device = await this.getDevice(deviceIdentifier);
197
+ return device.applicationManager.getInstalledApplications();
215
198
  }
216
199
  addDeviceDiscovery(deviceDiscovery) {
217
200
  this._otherDeviceDiscoveries.push(deviceDiscovery);
@@ -264,66 +247,62 @@ class DevicesService extends events_1.EventEmitter {
264
247
  delete this._availableEmulators[emulator.imageIdentifier];
265
248
  this.emit(constants.EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator);
266
249
  }
267
- detectCurrentlyAttachedDevices(deviceInitOpts) {
268
- return __awaiter(this, void 0, void 0, function* () {
269
- const options = this.getDeviceLookingOptions(deviceInitOpts);
270
- for (const deviceDiscovery of this._allDeviceDiscoveries) {
271
- try {
272
- yield deviceDiscovery.startLookingForDevices(options);
273
- }
274
- catch (err) {
275
- this.$logger.trace("Error while checking for devices.", err);
276
- }
277
- }
278
- });
279
- }
280
- detectCurrentlyAvailableEmulators() {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- try {
283
- yield this.$androidEmulatorDiscovery.startLookingForDevices();
284
- }
285
- catch (err) {
286
- this.$logger.trace(`Error while checking for Android emulators. ${err}`);
287
- }
250
+ async detectCurrentlyAttachedDevices(deviceInitOpts) {
251
+ const options = this.getDeviceLookingOptions(deviceInitOpts);
252
+ for (const deviceDiscovery of this._allDeviceDiscoveries) {
288
253
  try {
289
- yield this.$iOSSimulatorDiscovery.checkForAvailableSimulators();
254
+ await deviceDiscovery.startLookingForDevices(options);
290
255
  }
291
256
  catch (err) {
292
- this.$logger.trace(`Error while checking for iOS simulators. ${err}`);
257
+ this.$logger.trace("Error while checking for devices.", err);
293
258
  }
294
- });
259
+ }
260
+ }
261
+ async detectCurrentlyAvailableEmulators() {
262
+ try {
263
+ await this.$androidEmulatorDiscovery.startLookingForDevices();
264
+ }
265
+ catch (err) {
266
+ this.$logger.trace(`Error while checking for Android emulators. ${err}`);
267
+ }
268
+ try {
269
+ await this.$iOSSimulatorDiscovery.checkForAvailableSimulators();
270
+ }
271
+ catch (err) {
272
+ this.$logger.trace(`Error while checking for iOS simulators. ${err}`);
273
+ }
295
274
  }
296
275
  startDeviceDetectionInterval(deviceInitOpts = {}) {
297
276
  if (!this.deviceDetectionInterval) {
298
277
  let isDeviceDetectionIntervalInProgress = false;
299
- this.deviceDetectionInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
278
+ this.deviceDetectionInterval = setInterval(async () => {
300
279
  if (isDeviceDetectionIntervalInProgress) {
301
280
  return;
302
281
  }
303
282
  isDeviceDetectionIntervalInProgress = true;
304
- yield this.detectCurrentlyAttachedDevices(deviceInitOpts);
283
+ await this.detectCurrentlyAttachedDevices(deviceInitOpts);
305
284
  try {
306
285
  const trustedDevices = _.filter(this._devices, (device) => device.deviceInfo.status === constants.CONNECTED_STATUS);
307
- yield (0, helpers_1.settlePromises)(_.map(trustedDevices, (device) => device.applicationManager.checkForApplicationUpdates()));
286
+ await (0, helpers_1.settlePromises)(_.map(trustedDevices, (device) => device.applicationManager.checkForApplicationUpdates()));
308
287
  }
309
288
  catch (err) {
310
289
  this.$logger.trace("Error checking for application updates on devices.", err);
311
290
  }
312
291
  isDeviceDetectionIntervalInProgress = false;
313
- }), deviceInitOpts.detectionInterval || DevicesService.DEVICE_LOOKING_INTERVAL);
292
+ }, deviceInitOpts.detectionInterval || DevicesService.DEVICE_LOOKING_INTERVAL);
314
293
  this.deviceDetectionInterval.unref();
315
294
  }
316
295
  }
317
296
  startEmulatorDetectionInterval(opts = {}) {
318
297
  let isEmulatorDetectionIntervalRunning = false;
319
- this.emulatorDetectionInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
298
+ this.emulatorDetectionInterval = setInterval(async () => {
320
299
  if (isEmulatorDetectionIntervalRunning) {
321
300
  return;
322
301
  }
323
302
  isEmulatorDetectionIntervalRunning = true;
324
- yield this.detectCurrentlyAvailableEmulators();
303
+ await this.detectCurrentlyAvailableEmulators();
325
304
  isEmulatorDetectionIntervalRunning = false;
326
- }), opts.detectionInterval || DevicesService.EMULATOR_IMAGES_DETECTION_INTERVAL);
305
+ }, opts.detectionInterval || DevicesService.EMULATOR_IMAGES_DETECTION_INTERVAL);
327
306
  this.emulatorDetectionInterval.unref();
328
307
  }
329
308
  stopDeviceDetectionInterval() {
@@ -351,89 +330,81 @@ class DevicesService extends events_1.EventEmitter {
351
330
  }
352
331
  return searchedDevice;
353
332
  }
354
- startLookingForDevices(deviceInitOpts) {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
357
- if (this._platform) {
358
- return this.detectCurrentlyAttachedDevices(deviceInitOpts);
359
- }
360
- yield this.detectCurrentlyAttachedDevices(deviceInitOpts);
361
- yield this.detectCurrentlyAvailableEmulators();
362
- yield this.startDeviceDetectionInterval(deviceInitOpts);
363
- });
333
+ async startLookingForDevices(deviceInitOpts) {
334
+ this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
335
+ if (this._platform) {
336
+ return this.detectCurrentlyAttachedDevices(deviceInitOpts);
337
+ }
338
+ await this.detectCurrentlyAttachedDevices(deviceInitOpts);
339
+ await this.detectCurrentlyAvailableEmulators();
340
+ await this.startDeviceDetectionInterval(deviceInitOpts);
364
341
  }
365
342
  getDeviceByIndex(index) {
366
343
  this.validateIndex(index - 1);
367
344
  return this.getDeviceInstances()[index - 1];
368
345
  }
369
- getDevice(deviceOption) {
370
- return __awaiter(this, void 0, void 0, function* () {
371
- let device = null;
372
- if (!device) {
373
- device = _.find(this.getDeviceInstances(), (d) => (d.deviceInfo.identifier &&
374
- d.deviceInfo.identifier === deviceOption) ||
375
- (d.deviceInfo.displayName &&
376
- d.deviceInfo.displayName === deviceOption) ||
377
- (d.deviceInfo.imageIdentifier &&
378
- d.deviceInfo.imageIdentifier === deviceOption));
379
- }
380
- if (!device && helpers.isNumberWithoutExponent(deviceOption)) {
381
- device = this.getDeviceByIndex(parseInt(deviceOption, 10));
382
- }
383
- if (!device) {
384
- this.$errors.fail(this.$messages.Devices
385
- .NotFoundDeviceByIdentifierErrorMessageWithIdentifier, deviceOption, this.$staticConfig.CLIENT_NAME.toLowerCase());
386
- }
387
- return device;
388
- });
346
+ async getDevice(deviceOption) {
347
+ let device = null;
348
+ if (!device) {
349
+ device = _.find(this.getDeviceInstances(), (d) => (d.deviceInfo.identifier &&
350
+ d.deviceInfo.identifier === deviceOption) ||
351
+ (d.deviceInfo.displayName &&
352
+ d.deviceInfo.displayName === deviceOption) ||
353
+ (d.deviceInfo.imageIdentifier &&
354
+ d.deviceInfo.imageIdentifier === deviceOption));
355
+ }
356
+ if (!device && helpers.isNumberWithoutExponent(deviceOption)) {
357
+ device = this.getDeviceByIndex(parseInt(deviceOption, 10));
358
+ }
359
+ if (!device) {
360
+ this.$errors.fail(this.$messages.Devices
361
+ .NotFoundDeviceByIdentifierErrorMessageWithIdentifier, deviceOption, this.$staticConfig.CLIENT_NAME.toLowerCase());
362
+ }
363
+ return device;
389
364
  }
390
- executeOnDevice(action, canExecute) {
391
- return __awaiter(this, void 0, void 0, function* () {
392
- if (!canExecute || canExecute(this._device)) {
393
- return {
394
- deviceIdentifier: this._device.deviceInfo.identifier,
395
- result: yield action(this._device),
396
- };
397
- }
398
- });
365
+ async executeOnDevice(action, canExecute) {
366
+ if (!canExecute || canExecute(this._device)) {
367
+ return {
368
+ deviceIdentifier: this._device.deviceInfo.identifier,
369
+ result: await action(this._device),
370
+ };
371
+ }
399
372
  }
400
- executeOnAllConnectedDevices(action, canExecute) {
401
- return __awaiter(this, void 0, void 0, function* () {
402
- const devices = this.filterDevicesByPlatform();
403
- const sortedDevices = _.sortBy(devices, (device) => device.deviceInfo.platform);
404
- const result = [];
405
- const errors = [];
406
- for (const device of sortedDevices) {
407
- try {
408
- if (!canExecute || canExecute(device)) {
409
- result.push({
410
- deviceIdentifier: device.deviceInfo.identifier,
411
- result: yield action(device),
412
- });
413
- }
414
- }
415
- catch (err) {
416
- err.deviceIdentifier = device.deviceInfo.identifier;
417
- this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is`, err);
418
- errors.push(err);
373
+ async executeOnAllConnectedDevices(action, canExecute) {
374
+ const devices = this.filterDevicesByPlatform();
375
+ const sortedDevices = _.sortBy(devices, (device) => device.deviceInfo.platform);
376
+ const result = [];
377
+ const errors = [];
378
+ for (const device of sortedDevices) {
379
+ try {
380
+ if (!canExecute || canExecute(device)) {
381
+ result.push({
382
+ deviceIdentifier: device.deviceInfo.identifier,
383
+ result: await action(device),
384
+ });
419
385
  }
420
386
  }
421
- if (errors.length) {
422
- let preErrorMsg = "";
423
- if (errors.length > 1) {
424
- preErrorMsg = "Multiple errors were thrown:" + os_1.EOL;
425
- }
426
- const errorMessage = `${preErrorMsg}${errors
427
- .map((e) => e.message || e)
428
- .join(os_1.EOL)}`;
429
- this.$errors.fail(errorMessage);
387
+ catch (err) {
388
+ err.deviceIdentifier = device.deviceInfo.identifier;
389
+ this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is`, err);
390
+ errors.push(err);
430
391
  }
431
- return result;
432
- });
392
+ }
393
+ if (errors.length) {
394
+ let preErrorMsg = "";
395
+ if (errors.length > 1) {
396
+ preErrorMsg = "Multiple errors were thrown:" + os_1.EOL;
397
+ }
398
+ const errorMessage = `${preErrorMsg}${errors
399
+ .map((e) => e.message || e)
400
+ .join(os_1.EOL)}`;
401
+ this.$errors.fail(errorMessage);
402
+ }
403
+ return result;
433
404
  }
434
405
  deployOnDevices(deviceIdentifiers, packagePath, appId, projectName, projectDir) {
435
406
  this.$logger.trace(`Called deployOnDevices for identifiers ${deviceIdentifiers} for packageFile: ${packagePath}. Application identifier is ${appId}. Project Name is: ${projectName}`);
436
- return _.map(deviceIdentifiers, (deviceIdentifier) => __awaiter(this, void 0, void 0, function* () {
407
+ return _.map(deviceIdentifiers, async (deviceIdentifier) => {
437
408
  const device = this.getDeviceByIdentifier(deviceIdentifier);
438
409
  let identifier;
439
410
  if (typeof appId === "string") {
@@ -448,117 +419,110 @@ class DevicesService extends events_1.EventEmitter {
448
419
  projectName,
449
420
  projectDir,
450
421
  });
451
- }));
422
+ });
452
423
  }
453
- execute(action, canExecute, options) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- assert.ok(this._isInitialized, "Devices services not initialized!");
456
- if (this.hasDevices) {
457
- if (this.$hostInfo.isDarwin &&
458
- this._platform &&
459
- this.$mobileHelper.isiOSPlatform(this._platform) &&
460
- this.$options.emulator &&
461
- !this.isOnlyiOSSimultorRunning()) {
462
- const originalCanExecute = canExecute;
463
- canExecute = (dev) => this.isiOSSimulator(dev) &&
464
- (!originalCanExecute || !!originalCanExecute(dev));
465
- }
466
- return this.executeCore(action, canExecute);
424
+ async execute(action, canExecute, options) {
425
+ assert.ok(this._isInitialized, "Devices services not initialized!");
426
+ if (this.hasDevices) {
427
+ if (this.$hostInfo.isDarwin &&
428
+ this._platform &&
429
+ this.$mobileHelper.isiOSPlatform(this._platform) &&
430
+ this.$options.emulator &&
431
+ !this.isOnlyiOSSimultorRunning()) {
432
+ const originalCanExecute = canExecute;
433
+ canExecute = (dev) => this.isiOSSimulator(dev) &&
434
+ (!originalCanExecute || !!originalCanExecute(dev));
435
+ }
436
+ return this.executeCore(action, canExecute);
437
+ }
438
+ else {
439
+ const message = constants.ERROR_NO_DEVICES;
440
+ if (options && options.allowNoDevices) {
441
+ this.$logger.info(message);
467
442
  }
468
443
  else {
469
- const message = constants.ERROR_NO_DEVICES;
470
- if (options && options.allowNoDevices) {
471
- this.$logger.info(message);
444
+ if (!this.$hostInfo.isDarwin &&
445
+ this._platform &&
446
+ this.$mobileHelper.isiOSPlatform(this._platform)) {
447
+ this.$errors.fail(message);
472
448
  }
473
449
  else {
474
- if (!this.$hostInfo.isDarwin &&
475
- this._platform &&
476
- this.$mobileHelper.isiOSPlatform(this._platform)) {
477
- this.$errors.fail(message);
478
- }
479
- else {
480
- return this.executeCore(action, canExecute);
481
- }
450
+ return this.executeCore(action, canExecute);
482
451
  }
483
452
  }
484
- });
453
+ }
485
454
  }
486
- startEmulatorIfNecessary(deviceInitOpts) {
487
- return __awaiter(this, void 0, void 0, function* () {
488
- if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
489
- this.$errors.fail(`--device and --emulator are incompatible options.
455
+ async startEmulatorIfNecessary(deviceInitOpts) {
456
+ if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
457
+ this.$errors.fail(`--device and --emulator are incompatible options.
490
458
  If you are trying to run on specific emulator, use "${this.$staticConfig.CLIENT_NAME} run --device <DeviceID>`);
459
+ }
460
+ if (deviceInitOpts &&
461
+ deviceInitOpts.platform &&
462
+ !deviceInitOpts.skipEmulatorStart) {
463
+ this._platform = deviceInitOpts.platform;
464
+ try {
465
+ await this.startLookingForDevices(deviceInitOpts);
491
466
  }
492
- if (deviceInitOpts &&
493
- deviceInitOpts.platform &&
494
- !deviceInitOpts.skipEmulatorStart) {
495
- this._platform = deviceInitOpts.platform;
496
- try {
497
- yield this.startLookingForDevices(deviceInitOpts);
498
- }
499
- catch (err) {
500
- this.$logger.trace("Error while checking for devices.", err);
501
- }
502
- const deviceInstances = this.getDeviceInstances();
503
- if (!deviceInitOpts.deviceId && _.isEmpty(deviceInstances)) {
504
- if (!this.$hostInfo.isDarwin &&
505
- this.$mobileHelper.isApplePlatform(deviceInitOpts.platform)) {
506
- this.$errors.fail(constants.ERROR_NO_DEVICES_CANT_USE_IOS_SIMULATOR);
507
- }
508
- }
509
- try {
510
- yield this._startEmulatorIfNecessary(deviceInitOpts);
511
- }
512
- catch (err) {
513
- const errorMessage = this.getEmulatorError(err, deviceInitOpts.platform);
514
- this.$errors.fail(errorMessage);
515
- }
467
+ catch (err) {
468
+ this.$logger.trace("Error while checking for devices.", err);
516
469
  }
517
- });
518
- }
519
- _startEmulatorIfNecessary(data) {
520
- return __awaiter(this, void 0, void 0, function* () {
521
470
  const deviceInstances = this.getDeviceInstances();
522
- if (!data.deviceId && _.isEmpty(deviceInstances)) {
523
- return this.startEmulatorCore(data);
524
- }
525
- if (data.deviceId) {
526
- if (!helpers.isNumberWithoutExponent(data.deviceId)) {
527
- const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
528
- if (!activeDeviceInstance) {
529
- return this.startEmulatorCore(data);
530
- }
471
+ if (!deviceInitOpts.deviceId && _.isEmpty(deviceInstances)) {
472
+ if (!this.$hostInfo.isDarwin &&
473
+ this.$mobileHelper.isApplePlatform(deviceInitOpts.platform)) {
474
+ this.$errors.fail(constants.ERROR_NO_DEVICES_CANT_USE_IOS_SIMULATOR);
531
475
  }
532
476
  }
533
- if (data.platform === this.$devicePlatformsConstants.visionOS &&
534
- deviceInstances.length) {
535
- const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform === this.$devicePlatformsConstants.visionOS);
536
- if (!runningDeviceInstance) {
537
- return this.startEmulatorCore(data);
538
- }
477
+ try {
478
+ await this._startEmulatorIfNecessary(deviceInitOpts);
539
479
  }
540
- if (data.emulator && deviceInstances.length) {
541
- const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
542
- if (!runningDeviceInstance) {
543
- return this.startEmulatorCore(data);
544
- }
480
+ catch (err) {
481
+ const errorMessage = this.getEmulatorError(err, deviceInitOpts.platform);
482
+ this.$errors.fail(errorMessage);
545
483
  }
546
- });
484
+ }
547
485
  }
548
- initialize(data) {
549
- return __awaiter(this, void 0, void 0, function* () {
550
- if (!this._deviceInitializePromise) {
551
- this._deviceInitializePromise = this.initializeCore(data);
486
+ async _startEmulatorIfNecessary(data) {
487
+ const deviceInstances = this.getDeviceInstances();
488
+ if (!data.deviceId && _.isEmpty(deviceInstances)) {
489
+ return this.startEmulatorCore(data);
490
+ }
491
+ if (data.deviceId) {
492
+ if (!helpers.isNumberWithoutExponent(data.deviceId)) {
493
+ const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
494
+ if (!activeDeviceInstance) {
495
+ return this.startEmulatorCore(data);
496
+ }
552
497
  }
553
- try {
554
- yield this._deviceInitializePromise;
498
+ }
499
+ if (data.platform === this.$devicePlatformsConstants.visionOS &&
500
+ deviceInstances.length) {
501
+ const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform ===
502
+ this.$devicePlatformsConstants.visionOS);
503
+ if (!runningDeviceInstance) {
504
+ return this.startEmulatorCore(data);
555
505
  }
556
- catch (err) {
557
- this.$logger.trace(`Error while initializing devicesService: ${err}`);
558
- this._deviceInitializePromise = null;
559
- throw err;
506
+ }
507
+ if (data.emulator && deviceInstances.length) {
508
+ const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
509
+ if (!runningDeviceInstance) {
510
+ return this.startEmulatorCore(data);
560
511
  }
561
- });
512
+ }
513
+ }
514
+ async initialize(data) {
515
+ if (!this._deviceInitializePromise) {
516
+ this._deviceInitializePromise = this.initializeCore(data);
517
+ }
518
+ try {
519
+ await this._deviceInitializePromise;
520
+ }
521
+ catch (err) {
522
+ this.$logger.trace(`Error while initializing devicesService: ${err}`);
523
+ this._deviceInitializePromise = null;
524
+ throw err;
525
+ }
562
526
  }
563
527
  getPlatformsFromDeviceDescriptors(deviceDescriptors) {
564
528
  const platforms = _(deviceDescriptors)
@@ -568,91 +532,89 @@ class DevicesService extends events_1.EventEmitter {
568
532
  .value();
569
533
  return platforms;
570
534
  }
571
- initializeCore(deviceInitOpts) {
572
- return __awaiter(this, void 0, void 0, function* () {
573
- if (this._isInitialized) {
574
- return;
575
- }
576
- if (!this.$options.json) {
577
- this.$logger.info("Searching for devices...");
578
- }
579
- deviceInitOpts = deviceInitOpts || {};
580
- this._data = deviceInitOpts;
581
- if (!deviceInitOpts.skipEmulatorStart) {
582
- yield this.startEmulatorIfNecessary(deviceInitOpts);
583
- }
584
- const platform = deviceInitOpts.platform;
585
- const deviceOption = deviceInitOpts.deviceId;
586
- const deviceLookingOptions = {
587
- emulator: deviceInitOpts.emulator,
588
- platform: deviceInitOpts.platform,
589
- shouldReturnImmediateResult: deviceInitOpts.shouldReturnImmediateResult,
590
- detectionInterval: deviceInitOpts.detectionInterval,
591
- fullDiscovery: deviceInitOpts.fullDiscovery,
592
- };
593
- if (platform && deviceOption) {
594
- this._platform = this.$mobileHelper.validatePlatformName(deviceInitOpts.platform);
595
- yield this.startLookingForDevices(deviceLookingOptions);
596
- this._device = yield this.getDevice(deviceOption);
597
- if (this._device.deviceInfo.platform !== this._platform) {
598
- this.$errors.fail(constants.ERROR_CANNOT_RESOLVE_DEVICE);
535
+ async initializeCore(deviceInitOpts) {
536
+ if (this._isInitialized) {
537
+ return;
538
+ }
539
+ if (!this.$options.json) {
540
+ this.$logger.info("Searching for devices...");
541
+ }
542
+ deviceInitOpts = deviceInitOpts || {};
543
+ this._data = deviceInitOpts;
544
+ if (!deviceInitOpts.skipEmulatorStart) {
545
+ await this.startEmulatorIfNecessary(deviceInitOpts);
546
+ }
547
+ const platform = deviceInitOpts.platform;
548
+ const deviceOption = deviceInitOpts.deviceId;
549
+ const deviceLookingOptions = {
550
+ emulator: deviceInitOpts.emulator,
551
+ platform: deviceInitOpts.platform,
552
+ shouldReturnImmediateResult: deviceInitOpts.shouldReturnImmediateResult,
553
+ detectionInterval: deviceInitOpts.detectionInterval,
554
+ fullDiscovery: deviceInitOpts.fullDiscovery,
555
+ };
556
+ if (platform && deviceOption) {
557
+ this._platform = this.$mobileHelper.validatePlatformName(deviceInitOpts.platform);
558
+ await this.startLookingForDevices(deviceLookingOptions);
559
+ this._device = await this.getDevice(deviceOption);
560
+ if (this._device.deviceInfo.platform !== this._platform) {
561
+ this.$errors.fail(constants.ERROR_CANNOT_RESOLVE_DEVICE);
562
+ }
563
+ this.$logger.warn("Your application will be deployed only on the device specified by the provided index or identifier.");
564
+ }
565
+ else if (!platform && deviceOption) {
566
+ await this.startLookingForDevices(deviceLookingOptions);
567
+ this._device = await this.getDevice(deviceOption);
568
+ this._platform = this._device.deviceInfo.platform;
569
+ }
570
+ else if (platform && !deviceOption) {
571
+ this._platform = this.$mobileHelper.validatePlatformName(platform);
572
+ await this.startLookingForDevices(deviceLookingOptions);
573
+ }
574
+ else {
575
+ if (deviceInitOpts.skipInferPlatform) {
576
+ if (deviceInitOpts.skipDeviceDetectionInterval) {
577
+ await this.detectCurrentlyAttachedDevices(deviceLookingOptions);
578
+ }
579
+ else {
580
+ deviceInitOpts.shouldReturnImmediateResult = true;
581
+ await this.startLookingForDevices(deviceLookingOptions);
599
582
  }
600
- this.$logger.warn("Your application will be deployed only on the device specified by the provided index or identifier.");
601
- }
602
- else if (!platform && deviceOption) {
603
- yield this.startLookingForDevices(deviceLookingOptions);
604
- this._device = yield this.getDevice(deviceOption);
605
- this._platform = this._device.deviceInfo.platform;
606
- }
607
- else if (platform && !deviceOption) {
608
- this._platform = this.$mobileHelper.validatePlatformName(platform);
609
- yield this.startLookingForDevices(deviceLookingOptions);
610
583
  }
611
584
  else {
612
- if (deviceInitOpts.skipInferPlatform) {
613
- if (deviceInitOpts.skipDeviceDetectionInterval) {
614
- yield this.detectCurrentlyAttachedDevices(deviceLookingOptions);
585
+ await this.startLookingForDevices(deviceLookingOptions);
586
+ const devices = this.getDeviceInstances();
587
+ const platforms = _(devices)
588
+ .map((device) => device.deviceInfo.platform)
589
+ .filter((pl) => {
590
+ try {
591
+ return !!this.$mobileHelper.validatePlatformName(pl);
615
592
  }
616
- else {
617
- deviceInitOpts.shouldReturnImmediateResult = true;
618
- yield this.startLookingForDevices(deviceLookingOptions);
593
+ catch (err) {
594
+ this.$logger.warn(err.message);
595
+ return null;
619
596
  }
597
+ })
598
+ .uniq()
599
+ .value();
600
+ if (platforms.length === 1) {
601
+ this._platform = platforms[0];
602
+ }
603
+ else if (platforms.length === 0) {
604
+ this.$errors.fail(constants.ERROR_NO_DEVICES);
620
605
  }
621
606
  else {
622
- yield this.startLookingForDevices(deviceLookingOptions);
623
- const devices = this.getDeviceInstances();
624
- const platforms = _(devices)
625
- .map((device) => device.deviceInfo.platform)
626
- .filter((pl) => {
627
- try {
628
- return !!this.$mobileHelper.validatePlatformName(pl);
629
- }
630
- catch (err) {
631
- this.$logger.warn(err.message);
632
- return null;
633
- }
634
- })
635
- .uniq()
636
- .value();
637
- if (platforms.length === 1) {
638
- this._platform = platforms[0];
639
- }
640
- else if (platforms.length === 0) {
641
- this.$errors.fail(constants.ERROR_NO_DEVICES);
642
- }
643
- else {
644
- this.$errors.fail("Multiple device platforms detected (%s). Specify platform or device on command line.", helpers.formatListOfNames(platforms, "and"));
645
- }
607
+ this.$errors.fail("Multiple device platforms detected (%s). Specify platform or device on command line.", helpers.formatListOfNames(platforms, "and"));
646
608
  }
647
609
  }
648
- if (!this.$hostInfo.isDarwin &&
649
- this._platform &&
650
- this.$mobileHelper.isiOSPlatform(this._platform) &&
651
- this.$options.emulator) {
652
- this.$errors.fail(constants.ERROR_CANT_USE_SIMULATOR);
653
- }
654
- this._isInitialized = true;
655
- });
610
+ }
611
+ if (!this.$hostInfo.isDarwin &&
612
+ this._platform &&
613
+ this.$mobileHelper.isiOSPlatform(this._platform) &&
614
+ this.$options.emulator) {
615
+ this.$errors.fail(constants.ERROR_CANT_USE_SIMULATOR);
616
+ }
617
+ this._isInitialized = true;
656
618
  }
657
619
  get hasDevices() {
658
620
  if (!this._platform) {
@@ -672,30 +634,24 @@ class DevicesService extends events_1.EventEmitter {
672
634
  getDeviceByDeviceOption() {
673
635
  return this._device;
674
636
  }
675
- mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework) {
676
- return __awaiter(this, void 0, void 0, function* () {
677
- return this.$androidProcessService.mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework);
678
- });
637
+ async mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework) {
638
+ return this.$androidProcessService.mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework);
679
639
  }
680
640
  getDebuggableApps(deviceIdentifiers) {
681
641
  return _.map(deviceIdentifiers, (deviceIdentifier) => this.getDebuggableAppsCore(deviceIdentifier));
682
642
  }
683
- getDebuggableViews(deviceIdentifier, appIdentifier) {
684
- return __awaiter(this, void 0, void 0, function* () {
685
- const device = this.getDeviceByIdentifier(deviceIdentifier), debuggableViewsPerApp = yield device.applicationManager.getDebuggableAppViews([appIdentifier]);
686
- return debuggableViewsPerApp && debuggableViewsPerApp[appIdentifier];
687
- });
643
+ async getDebuggableViews(deviceIdentifier, appIdentifier) {
644
+ const device = this.getDeviceByIdentifier(deviceIdentifier), debuggableViewsPerApp = await device.applicationManager.getDebuggableAppViews([appIdentifier]);
645
+ return debuggableViewsPerApp && debuggableViewsPerApp[appIdentifier];
688
646
  }
689
647
  getDebuggableAppsCore(deviceIdentifier) {
690
648
  const device = this.getDeviceByIdentifier(deviceIdentifier);
691
649
  return device.applicationManager.getDebuggableApps();
692
650
  }
693
- deployOnDevice(device, appData) {
694
- return __awaiter(this, void 0, void 0, function* () {
695
- yield device.applicationManager.reinstallApplication(appData.appId, appData.packagePath);
696
- this.$logger.info(`Successfully deployed on device with identifier '${device.deviceInfo.identifier}'.`);
697
- yield device.applicationManager.tryStartApplication(appData);
698
- });
651
+ async deployOnDevice(device, appData) {
652
+ await device.applicationManager.reinstallApplication(appData.appId, appData.packagePath);
653
+ this.$logger.info(`Successfully deployed on device with identifier '${device.deviceInfo.identifier}'.`);
654
+ await device.applicationManager.tryStartApplication(appData);
699
655
  }
700
656
  filterDevicesByPlatform() {
701
657
  return _.filter(this.getDeviceInstances(), (device) => {
@@ -723,58 +679,52 @@ class DevicesService extends events_1.EventEmitter {
723
679
  }
724
680
  return null;
725
681
  }
726
- startEmulatorCore(deviceInitOpts = {}) {
727
- return __awaiter(this, void 0, void 0, function* () {
728
- const { deviceId } = deviceInitOpts;
729
- const platform = deviceInitOpts.platform || this._platform;
730
- const emulatorServices = this.resolveEmulatorServices(platform);
731
- if (!emulatorServices) {
732
- this.$errors.fail("Unable to detect platform for which to start emulator.");
733
- }
734
- const result = yield emulatorServices.startEmulator({
735
- emulatorIdOrName: deviceId,
736
- imageIdentifier: deviceId,
737
- platform: platform,
738
- sdk: this._data && this._data.sdk,
739
- });
740
- if (result && result.errors && result.errors.length) {
741
- this.$errors.fail(result.errors.join("\n"));
742
- }
743
- const deviceLookingOptions = this.getDeviceLookingOptions(deviceInitOpts);
744
- if (this.$mobileHelper.isAndroidPlatform(platform)) {
745
- yield this.$androidDeviceDiscovery.startLookingForDevices(deviceLookingOptions);
746
- }
747
- else if (this.$mobileHelper.isiOSPlatform(platform) &&
748
- this.$hostInfo.isDarwin) {
749
- yield this.$iOSSimulatorDiscovery.startLookingForDevices(deviceLookingOptions);
750
- }
682
+ async startEmulatorCore(deviceInitOpts = {}) {
683
+ const { deviceId } = deviceInitOpts;
684
+ const platform = deviceInitOpts.platform || this._platform;
685
+ const emulatorServices = this.resolveEmulatorServices(platform);
686
+ if (!emulatorServices) {
687
+ this.$errors.fail("Unable to detect platform for which to start emulator.");
688
+ }
689
+ const result = await emulatorServices.startEmulator({
690
+ emulatorIdOrName: deviceId,
691
+ imageIdentifier: deviceId,
692
+ platform: platform,
693
+ sdk: this._data && this._data.sdk,
751
694
  });
695
+ if (result && result.errors && result.errors.length) {
696
+ this.$errors.fail(result.errors.join("\n"));
697
+ }
698
+ const deviceLookingOptions = this.getDeviceLookingOptions(deviceInitOpts);
699
+ if (this.$mobileHelper.isAndroidPlatform(platform)) {
700
+ await this.$androidDeviceDiscovery.startLookingForDevices(deviceLookingOptions);
701
+ }
702
+ else if (this.$mobileHelper.isiOSPlatform(platform) &&
703
+ this.$hostInfo.isDarwin) {
704
+ await this.$iOSSimulatorDiscovery.startLookingForDevices(deviceLookingOptions);
705
+ }
752
706
  }
753
- executeCore(action, canExecute) {
754
- return __awaiter(this, void 0, void 0, function* () {
755
- if (this._device) {
756
- return [yield this.executeOnDevice(action, canExecute)];
757
- }
758
- return this.executeOnAllConnectedDevices(action, canExecute);
759
- });
707
+ async executeCore(action, canExecute) {
708
+ if (this._device) {
709
+ return [await this.executeOnDevice(action, canExecute)];
710
+ }
711
+ return this.executeOnAllConnectedDevices(action, canExecute);
760
712
  }
761
- isApplicationInstalledOnDevice(deviceIdentifier, appData) {
762
- return __awaiter(this, void 0, void 0, function* () {
763
- let isInstalled = false;
764
- const device = this.getDeviceByIdentifier(deviceIdentifier);
765
- try {
766
- isInstalled = yield device.applicationManager.isApplicationInstalled(appData.appId);
767
- yield device.applicationManager.tryStartApplication(appData);
768
- }
769
- catch (err) {
770
- this.$logger.trace("Error while checking is application installed. Error is: ", err);
771
- }
772
- return {
773
- appIdentifier: appData.appId,
774
- deviceIdentifier,
775
- isInstalled,
776
- };
777
- });
713
+ async isApplicationInstalledOnDevice(deviceIdentifier, appData) {
714
+ let isInstalled = false;
715
+ const device = this.getDeviceByIdentifier(deviceIdentifier);
716
+ try {
717
+ isInstalled = await device.applicationManager.isApplicationInstalled(appData.appId);
718
+ await device.applicationManager.tryStartApplication(appData);
719
+ }
720
+ catch (err) {
721
+ this.$logger.trace("Error while checking is application installed. Error is: ", err);
722
+ }
723
+ return {
724
+ appIdentifier: appData.appId,
725
+ deviceIdentifier,
726
+ isInstalled,
727
+ };
778
728
  }
779
729
  getDeviceLookingOptions(deviceInitOpts = {}) {
780
730
  const { shouldReturnImmediateResult, emulator } = deviceInitOpts;
@@ -797,6 +747,7 @@ class DevicesService extends events_1.EventEmitter {
797
747
  `To list available ${emulatorName.toLowerCase()} images, run '${this.$staticConfig.CLIENT_NAME.toLowerCase()} device <Platform> --available-devices'.`);
798
748
  }
799
749
  }
750
+ exports.DevicesService = DevicesService;
800
751
  DevicesService.DEVICE_LOOKING_INTERVAL = 200;
801
752
  DevicesService.EMULATOR_IMAGES_DETECTION_INTERVAL = 60 * 1000;
802
753
  __decorate([
@@ -850,5 +801,4 @@ __decorate([
850
801
  __decorate([
851
802
  (0, decorators_1.exported)("devicesService")
852
803
  ], DevicesService.prototype, "getDebuggableViews", null);
853
- exports.DevicesService = DevicesService;
854
804
  yok_1.injector.register("devicesService", DevicesService);