nativescript 8.7.0-rc.0 → 8.7.0-rc.2

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 (324) hide show
  1. package/lib/android-tools-info.js +12 -0
  2. package/lib/base-package-manager.js +7 -0
  3. package/lib/bootstrap.js +7 -1
  4. package/lib/color.js +3 -0
  5. package/lib/commands/add-platform.js +1 -0
  6. package/lib/commands/apple-login.js +1 -0
  7. package/lib/commands/appstore-list.js +1 -0
  8. package/lib/commands/appstore-upload.js +4 -0
  9. package/lib/commands/build.js +20 -3
  10. package/lib/commands/clean.js +22 -1
  11. package/lib/commands/command-base.js +1 -0
  12. package/lib/commands/config.js +3 -0
  13. package/lib/commands/create-project.js +34 -19
  14. package/lib/commands/debug.js +6 -1
  15. package/lib/commands/deploy.js +3 -2
  16. package/lib/commands/extensibility/install-extension.js +1 -0
  17. package/lib/commands/extensibility/list-extensions.js +1 -0
  18. package/lib/commands/extensibility/uninstall-extension.js +1 -0
  19. package/lib/commands/fonts.js +1 -0
  20. package/lib/commands/generate-assets.js +1 -0
  21. package/lib/commands/generate-help.js +1 -0
  22. package/lib/commands/generate.js +12 -2
  23. package/lib/commands/info.js +1 -0
  24. package/lib/commands/install.js +1 -0
  25. package/lib/commands/list-platforms.js +1 -0
  26. package/lib/commands/migrate.js +1 -0
  27. package/lib/commands/platform-clean.js +1 -0
  28. package/lib/commands/plugin/add-plugin.js +1 -0
  29. package/lib/commands/plugin/build-plugin.js +1 -0
  30. package/lib/commands/plugin/create-plugin.js +5 -0
  31. package/lib/commands/plugin/list-plugins.js +1 -0
  32. package/lib/commands/plugin/remove-plugin.js +2 -0
  33. package/lib/commands/plugin/update-plugin.js +1 -0
  34. package/lib/commands/post-install.js +6 -0
  35. package/lib/commands/prepare.js +3 -2
  36. package/lib/commands/preview.js +2 -0
  37. package/lib/commands/remove-platform.js +1 -0
  38. package/lib/commands/resources/resources-update.js +2 -0
  39. package/lib/commands/run.js +1 -0
  40. package/lib/commands/setup.js +1 -0
  41. package/lib/commands/start.js +1 -0
  42. package/lib/commands/test-init.js +4 -0
  43. package/lib/commands/test.js +9 -2
  44. package/lib/commands/typings.js +1 -0
  45. package/lib/commands/update-platform.js +5 -0
  46. package/lib/commands/update.js +2 -0
  47. package/lib/common/bootstrap.js +1 -0
  48. package/lib/common/child-process.js +3 -0
  49. package/lib/common/codeGeneration/code-entity.js +1 -0
  50. package/lib/common/codeGeneration/code-printer.js +1 -0
  51. package/lib/common/command-params.js +1 -0
  52. package/lib/common/commands/analytics.js +3 -0
  53. package/lib/common/commands/autocompletion.js +3 -0
  54. package/lib/common/commands/device/device-log-stream.js +1 -0
  55. package/lib/common/commands/device/get-file.js +2 -0
  56. package/lib/common/commands/device/list-applications.js +1 -0
  57. package/lib/common/commands/device/list-devices.js +3 -0
  58. package/lib/common/commands/device/list-files.js +2 -0
  59. package/lib/common/commands/device/put-file.js +2 -0
  60. package/lib/common/commands/device/run-application.js +1 -0
  61. package/lib/common/commands/device/stop-application.js +1 -0
  62. package/lib/common/commands/device/uninstall-application.js +1 -0
  63. package/lib/common/commands/doctor.js +3 -2
  64. package/lib/common/commands/generate-messages.js +1 -0
  65. package/lib/common/commands/help.js +1 -0
  66. package/lib/common/commands/package-manager-get.js +1 -0
  67. package/lib/common/commands/package-manager-set.js +1 -0
  68. package/lib/common/commands/post-install.js +1 -0
  69. package/lib/common/commands/preuninstall.js +11 -2
  70. package/lib/common/commands/proxy/proxy-base.js +4 -0
  71. package/lib/common/commands/proxy/proxy-clear.js +1 -0
  72. package/lib/common/commands/proxy/proxy-get.js +1 -0
  73. package/lib/common/commands/proxy/proxy-set.js +1 -0
  74. package/lib/common/common-lib.js +1 -0
  75. package/lib/common/constants.js +11 -0
  76. package/lib/common/decorators.js +48 -0
  77. package/lib/common/definitions/mobile.d.ts +1 -1
  78. package/lib/common/dispatchers.js +10 -1
  79. package/lib/common/errors.js +13 -3
  80. package/lib/common/file-system.js +13 -2
  81. package/lib/common/header.js +3 -0
  82. package/lib/common/helpers.js +89 -3
  83. package/lib/common/host-info.js +4 -0
  84. package/lib/common/http-client.js +20 -0
  85. package/lib/common/logger/appenders/cli-appender.js +4 -0
  86. package/lib/common/logger/appenders/emit-appender.js +4 -0
  87. package/lib/common/logger/layouts/cli-layout.js +1 -0
  88. package/lib/common/logger/logger.js +5 -0
  89. package/lib/common/messages/messages.js +6 -0
  90. package/lib/common/mobile/android/android-application-manager.js +20 -1
  91. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -0
  92. package/lib/common/mobile/android/android-debug-bridge.js +6 -0
  93. package/lib/common/mobile/android/android-device-file-system.js +4 -0
  94. package/lib/common/mobile/android/android-device-hash-service.js +3 -0
  95. package/lib/common/mobile/android/android-device.js +8 -0
  96. package/lib/common/mobile/android/android-emulator-services.js +2 -1
  97. package/lib/common/mobile/android/android-ini-file-parser.js +9 -0
  98. package/lib/common/mobile/android/android-log-filter.js +4 -0
  99. package/lib/common/mobile/android/android-virtual-device-service.js +26 -0
  100. package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
  101. package/lib/common/mobile/android/genymotion/genymotion-service.js +5 -0
  102. package/lib/common/mobile/android/genymotion/virtualbox-service.js +11 -0
  103. package/lib/common/mobile/android/logcat-helper.js +20 -1
  104. package/lib/common/mobile/application-manager-base.js +6 -0
  105. package/lib/common/mobile/device-emitter.js +4 -0
  106. package/lib/common/mobile/device-log-emitter.js +1 -0
  107. package/lib/common/mobile/device-log-provider-base.js +1 -0
  108. package/lib/common/mobile/device-log-provider.js +23 -0
  109. package/lib/common/mobile/device-platforms-constants.js +1 -0
  110. package/lib/common/mobile/emulator-helper.js +3 -0
  111. package/lib/common/mobile/ios/device/ios-application-manager.js +3 -0
  112. package/lib/common/mobile/ios/device/ios-device-file-system.js +1 -0
  113. package/lib/common/mobile/ios/device/ios-device-operations.js +4 -0
  114. package/lib/common/mobile/ios/device/ios-device.js +4 -0
  115. package/lib/common/mobile/ios/ios-device-base.js +1 -0
  116. package/lib/common/mobile/ios/ios-device-product-name-mapper.js +2 -0
  117. package/lib/common/mobile/ios/ios-log-filter.js +1 -0
  118. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +4 -0
  119. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -0
  120. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +6 -0
  121. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +5 -0
  122. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +1 -0
  123. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +1 -0
  124. package/lib/common/mobile/local-to-device-path-data-factory.js +1 -0
  125. package/lib/common/mobile/log-filter.js +2 -0
  126. package/lib/common/mobile/logging-levels.js +1 -0
  127. package/lib/common/mobile/mobile-core/android-device-discovery.js +2 -0
  128. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +3 -0
  129. package/lib/common/mobile/mobile-core/android-process-service.js +32 -0
  130. package/lib/common/mobile/mobile-core/device-discovery.js +1 -0
  131. package/lib/common/mobile/mobile-core/devices-service.js +72 -3
  132. package/lib/common/mobile/mobile-core/ios-device-discovery.js +3 -1
  133. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +3 -0
  134. package/lib/common/mobile/mobile-helper.js +2 -1
  135. package/lib/common/mobile/wp8/wp8-emulator-services.js +1 -0
  136. package/lib/common/opener.js +1 -0
  137. package/lib/common/os-info.js +1 -0
  138. package/lib/common/plist-parser.js +1 -0
  139. package/lib/common/project-helper.js +1 -0
  140. package/lib/common/prompter.js +9 -1
  141. package/lib/common/queue.js +1 -0
  142. package/lib/common/resource-loader.js +1 -0
  143. package/lib/common/services/auto-completion-service.js +12 -1
  144. package/lib/common/services/cancellation.js +2 -1
  145. package/lib/common/services/commands-service.js +17 -6
  146. package/lib/common/services/help-service.js +11 -3
  147. package/lib/common/services/hooks-service.js +13 -0
  148. package/lib/common/services/ios-notification-service.js +1 -0
  149. package/lib/common/services/json-file-settings-service.js +6 -0
  150. package/lib/common/services/lock-service.js +6 -0
  151. package/lib/common/services/message-contract-generator.js +1 -0
  152. package/lib/common/services/messages-service.js +1 -0
  153. package/lib/common/services/micro-templating-service.js +6 -0
  154. package/lib/common/services/net-service.js +3 -0
  155. package/lib/common/services/project-files-manager.js +5 -0
  156. package/lib/common/services/project-files-provider-base.js +1 -0
  157. package/lib/common/services/proxy-service.js +1 -0
  158. package/lib/common/services/qr.js +1 -0
  159. package/lib/common/services/settings-service.js +1 -0
  160. package/lib/common/services/xcode-select-service.js +1 -0
  161. package/lib/common/utils.js +1 -0
  162. package/lib/common/validators/project-name-validator.js +1 -0
  163. package/lib/common/validators/validation-result.js +1 -0
  164. package/lib/common/verify-node-version.js +8 -1
  165. package/lib/common/yok.js +32 -11
  166. package/lib/config.js +22 -1
  167. package/lib/constants-provider.js +1 -0
  168. package/lib/constants.js +58 -5
  169. package/lib/controllers/build-controller.js +4 -3
  170. package/lib/controllers/debug-controller.js +8 -3
  171. package/lib/controllers/deploy-controller.js +1 -0
  172. package/lib/controllers/migrate-controller.js +91 -3
  173. package/lib/controllers/platform-controller.js +9 -1
  174. package/lib/controllers/prepare-controller.js +15 -5
  175. package/lib/controllers/run-controller.js +17 -1
  176. package/lib/controllers/update-controller-base.js +1 -0
  177. package/lib/controllers/update-controller.js +11 -0
  178. package/lib/data/build-data.js +1 -0
  179. package/lib/data/controller-data-base.js +1 -0
  180. package/lib/data/debug-data.js +1 -0
  181. package/lib/data/platform-data.js +1 -0
  182. package/lib/data/prepare-data.js +1 -0
  183. package/lib/data/run-data.js +1 -0
  184. package/lib/detached-processes/cleanup-js-subprocess.js +8 -2
  185. package/lib/detached-processes/cleanup-process.js +18 -14
  186. package/lib/detached-processes/file-log-service.js +2 -1
  187. package/lib/device-path-provider.js +3 -2
  188. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +7 -0
  189. package/lib/device-sockets/ios/notification.js +3 -0
  190. package/lib/device-sockets/ios/socket-request-executor.js +3 -0
  191. package/lib/helpers/android-bundle-validator-helper.js +2 -1
  192. package/lib/helpers/deploy-command-helper.js +1 -0
  193. package/lib/helpers/key-command-helper.js +4 -2
  194. package/lib/helpers/livesync-command-helper.js +5 -2
  195. package/lib/helpers/network-connectivity-validator.js +1 -0
  196. package/lib/helpers/options-track-helper.js +3 -2
  197. package/lib/helpers/package-path-helper.js +1 -0
  198. package/lib/helpers/platform-command-helper.js +7 -2
  199. package/lib/helpers/version-validator-helper.js +1 -0
  200. package/lib/key-commands/bootstrap.js +3 -2
  201. package/lib/key-commands/index.js +5 -4
  202. package/lib/nativescript-cli-lib-bootstrap.js +4 -0
  203. package/lib/nativescript-cli-lib.js +1 -0
  204. package/lib/nativescript-cli.js +10 -1
  205. package/lib/node/pbxproj-dom-xcode.js +1 -0
  206. package/lib/node/xcode.js +1 -0
  207. package/lib/node-package-manager.js +11 -1
  208. package/lib/options.js +141 -115
  209. package/lib/package-installation-manager.js +8 -1
  210. package/lib/package-manager.js +2 -0
  211. package/lib/platform-command-param.js +1 -0
  212. package/lib/pnpm-package-manager.js +4 -1
  213. package/lib/project-data.js +12 -0
  214. package/lib/providers/project-files-provider.js +1 -0
  215. package/lib/resolvers/livesync-service-resolver.js +2 -1
  216. package/lib/services/analytics/analytics-broker-process.js +10 -6
  217. package/lib/services/analytics/analytics-broker.js +2 -1
  218. package/lib/services/analytics/analytics-service.js +29 -25
  219. package/lib/services/analytics/google-analytics-provider.js +13 -12
  220. package/lib/services/analytics-settings-service.js +5 -0
  221. package/lib/services/android/android-bundle-tool-service.js +1 -0
  222. package/lib/services/android/gradle-build-args-service.js +3 -0
  223. package/lib/services/android/gradle-build-service.js +1 -0
  224. package/lib/services/android/gradle-command-service.js +1 -0
  225. package/lib/services/android-device-debug-service.js +6 -0
  226. package/lib/services/android-plugin-build-service.js +28 -0
  227. package/lib/services/android-project-service.js +71 -4
  228. package/lib/services/android-resources-migration-service.js +7 -0
  229. package/lib/services/apple-portal/apple-portal-application-service.js +1 -0
  230. package/lib/services/apple-portal/apple-portal-cookie-service.js +1 -0
  231. package/lib/services/apple-portal/apple-portal-session-service.js +6 -4
  232. package/lib/services/assets-generation/assets-generation-service.js +16 -5
  233. package/lib/services/build-artifacts-service.js +2 -1
  234. package/lib/services/build-data-service.js +2 -1
  235. package/lib/services/build-info-file-service.js +1 -0
  236. package/lib/services/cleanup-service.js +13 -9
  237. package/lib/services/cocoapods-platform-manager.js +9 -0
  238. package/lib/services/cocoapods-service.js +21 -1
  239. package/lib/services/debug-data-service.js +1 -0
  240. package/lib/services/debug-service-base.js +7 -0
  241. package/lib/services/device/device-install-app-service.js +2 -1
  242. package/lib/services/doctor-service.js +21 -6
  243. package/lib/services/extensibility-service.js +8 -0
  244. package/lib/services/files-hash-service.js +1 -0
  245. package/lib/services/hmr-status-service.js +2 -0
  246. package/lib/services/info-service.js +1 -0
  247. package/lib/services/initialize-service.js +5 -1
  248. package/lib/services/ios/export-options-plist-service.js +4 -0
  249. package/lib/services/ios/ios-signing-service.js +4 -0
  250. package/lib/services/ios/spm-service.js +10 -1
  251. package/lib/services/ios/xcodebuild-args-service.js +13 -4
  252. package/lib/services/ios/xcodebuild-command-service.js +1 -0
  253. package/lib/services/ios/xcodebuild-service.js +1 -0
  254. package/lib/services/ios-debugger-port-service.js +1 -0
  255. package/lib/services/ios-device-debug-service.js +1 -0
  256. package/lib/services/ios-entitlements-service.js +1 -0
  257. package/lib/services/ios-extensions-service.js +1 -0
  258. package/lib/services/ios-log-filter.js +20 -0
  259. package/lib/services/ios-native-target-service.js +6 -4
  260. package/lib/services/ios-project-service.js +29 -7
  261. package/lib/services/ios-provision-service.js +3 -0
  262. package/lib/services/ios-watch-app-service.js +1 -0
  263. package/lib/services/ip-service.js +2 -0
  264. package/lib/services/itmstransporter-service.js +1 -0
  265. package/lib/services/karma-execution.js +2 -0
  266. package/lib/services/livesync/android-device-livesync-service-base.js +1 -0
  267. package/lib/services/livesync/android-device-livesync-service.js +2 -0
  268. package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -0
  269. package/lib/services/livesync/android-livesync-service.js +1 -0
  270. package/lib/services/livesync/android-livesync-tool.js +4 -0
  271. package/lib/services/livesync/device-livesync-service-base.js +2 -0
  272. package/lib/services/livesync/ios-device-livesync-service.js +7 -0
  273. package/lib/services/livesync/ios-livesync-service.js +2 -0
  274. package/lib/services/livesync/livesync-socket.js +1 -0
  275. package/lib/services/livesync/platform-livesync-service-base.js +5 -0
  276. package/lib/services/livesync-process-data-service.js +1 -0
  277. package/lib/services/log-parser-service.js +1 -0
  278. package/lib/services/log-source-map-service.js +15 -0
  279. package/lib/services/marking-mode-service.js +8 -5
  280. package/lib/services/metadata-filtering-service.js +1 -0
  281. package/lib/services/npm-config-service.js +4 -0
  282. package/lib/services/pacote-service.js +7 -0
  283. package/lib/services/performance-service.js +3 -1
  284. package/lib/services/platform/add-platform-service.js +47 -2
  285. package/lib/services/platform/platform-validation-service.js +1 -0
  286. package/lib/services/platform/prepare-native-platform-service.js +5 -2
  287. package/lib/services/platform-environment-requirements.js +8 -3
  288. package/lib/services/platform-project-service-base.js +1 -0
  289. package/lib/services/platforms-data-service.js +1 -0
  290. package/lib/services/plugins-service.js +18 -2
  291. package/lib/services/prepare-data-service.js +2 -1
  292. package/lib/services/project-backup-service.js +4 -0
  293. package/lib/services/project-changes-service.js +12 -3
  294. package/lib/services/project-cleanup-service.js +2 -0
  295. package/lib/services/project-config-service.js +18 -1
  296. package/lib/services/project-data-service.js +36 -7
  297. package/lib/services/project-name-service.js +1 -0
  298. package/lib/services/project-service.js +10 -0
  299. package/lib/services/project-templates-service.js +3 -2
  300. package/lib/services/qr-code-terminal-service.js +1 -0
  301. package/lib/services/require-service.js +1 -0
  302. package/lib/services/start-service.js +1 -0
  303. package/lib/services/temp-service.js +1 -0
  304. package/lib/services/terminal-spinner-service.js +2 -0
  305. package/lib/services/test-execution-service.js +9 -2
  306. package/lib/services/test-initialization-service.js +4 -0
  307. package/lib/services/timeline-profiler-service.js +1 -0
  308. package/lib/services/user-settings-service.js +1 -0
  309. package/lib/services/versions-service.js +6 -4
  310. package/lib/services/watch-ignore-list-service.js +1 -0
  311. package/lib/services/webpack/webpack-compiler-service.js +42 -1
  312. package/lib/services/xcconfig-service.js +2 -0
  313. package/lib/services/xcproj-service.js +1 -0
  314. package/lib/shared-event-bus.js +6 -0
  315. package/lib/sys-info.js +2 -1
  316. package/lib/tools/config-manipulation/config-transformer.js +12 -0
  317. package/lib/tools/node-modules/node-modules-builder.js +1 -0
  318. package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
  319. package/lib/yarn-package-manager.js +1 -0
  320. package/lib/yarn2-package-manager.js +3 -0
  321. package/node_modules/@npmcli/move-file/node_modules/mkdirp/CHANGELOG.md +15 -0
  322. package/node_modules/rimraf/CHANGELOG.md +65 -0
  323. package/node_modules/stringify-package/CHANGELOG.md +16 -0
  324. package/package.json +1 -1
@@ -72,6 +72,7 @@ class DevicesService extends events_1.EventEmitter {
72
72
  const device = yield this.getDevice(options.deviceId);
73
73
  return device;
74
74
  }
75
+ // Now let's take data for each device:
75
76
  const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
76
77
  (!this.platform ||
77
78
  d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
@@ -94,6 +95,8 @@ class DevicesService extends events_1.EventEmitter {
94
95
  const devices = sortedInstances.filter((d) => !d.isEmulator);
95
96
  let selectedInstance;
96
97
  if (options.onlyEmulators || options.onlyDevices) {
98
+ // When --emulator or --forDevice is passed, the instances are already filtered
99
+ // So we are sure we have exactly the type we need and we can safely return the last one (highest OS version).
97
100
  selectedInstance = _.last(sortedInstances);
98
101
  }
99
102
  else {
@@ -156,6 +159,7 @@ class DevicesService extends events_1.EventEmitter {
156
159
  ...additionalErrors,
157
160
  ];
158
161
  }
162
+ // emulator is already running
159
163
  if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
160
164
  return null;
161
165
  }
@@ -188,9 +192,11 @@ class DevicesService extends events_1.EventEmitter {
188
192
  return !!(this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) &&
189
193
  device.isEmulator);
190
194
  }
195
+ /* tslint:disable:no-unused-variable */
191
196
  setLogLevel(logLevel, deviceIdentifier) {
192
197
  this.$deviceLogProvider.setLogLevel(logLevel, deviceIdentifier);
193
198
  }
199
+ /* tslint:enable:no-unused-variable */
194
200
  isAppInstalledOnDevices(deviceIdentifiers, appId, projectName, projectDir) {
195
201
  this.$logger.trace(`Called isInstalledOnDevices for identifiers ${deviceIdentifiers}. AppIdentifier is ${appId}.`);
196
202
  return _.map(deviceIdentifiers, (deviceIdentifier) => this.isApplicationInstalledOnDevice(deviceIdentifier, {
@@ -264,6 +270,9 @@ class DevicesService extends events_1.EventEmitter {
264
270
  delete this._availableEmulators[emulator.imageIdentifier];
265
271
  this.emit(constants.EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator);
266
272
  }
273
+ /**
274
+ * Starts looking for devices. Any found devices are pushed to "_devices" variable.
275
+ */
267
276
  detectCurrentlyAttachedDevices(deviceInitOpts) {
268
277
  return __awaiter(this, void 0, void 0, function* () {
269
278
  const options = this.getDeviceLookingOptions(deviceInitOpts);
@@ -336,9 +345,14 @@ class DevicesService extends events_1.EventEmitter {
336
345
  clearInterval(this.emulatorDetectionInterval);
337
346
  }
338
347
  }
348
+ /**
349
+ * Returns device that matches an identifier.
350
+ * The identifier is expected to be the same as the running device declares it (emulator-5554 for android or GUID for ios).
351
+ * @param identifier running emulator or device identifier
352
+ */
339
353
  getDeviceByIdentifier(identifier) {
340
354
  const searchedDevice = _.find(this.getDeviceInstances(), (device) => {
341
- if (this.$mobileHelper.isApplePlatfrom(device.deviceInfo.platform) &&
355
+ if (this.$mobileHelper.isApplePlatform(device.deviceInfo.platform) &&
342
356
  device.isEmulator) {
343
357
  return (device.deviceInfo.identifier === identifier ||
344
358
  device.deviceInfo.displayName === identifier);
@@ -351,6 +365,9 @@ class DevicesService extends events_1.EventEmitter {
351
365
  }
352
366
  return searchedDevice;
353
367
  }
368
+ /**
369
+ * Starts looking for running devices. All found devices are pushed to _devices variable.
370
+ */
354
371
  startLookingForDevices(deviceInitOpts) {
355
372
  return __awaiter(this, void 0, void 0, function* () {
356
373
  this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
@@ -362,10 +379,20 @@ class DevicesService extends events_1.EventEmitter {
362
379
  yield this.startDeviceDetectionInterval(deviceInitOpts);
363
380
  });
364
381
  }
382
+ /**
383
+ * Returns device depending on the passed index.
384
+ * The index refers to assigned number to listed devices by tns device command.
385
+ * @param index assigned device number
386
+ */
365
387
  getDeviceByIndex(index) {
366
388
  this.validateIndex(index - 1);
367
389
  return this.getDeviceInstances()[index - 1];
368
390
  }
391
+ /**
392
+ * Returns running device for specified --device <DeviceId>.
393
+ * Method expects running devices.
394
+ * @param deviceOption parameter passed by the user to --device flag. Can be name, identifier or imageIdentifier.
395
+ */
369
396
  getDevice(deviceOption) {
370
397
  return __awaiter(this, void 0, void 0, function* () {
371
398
  let device = null;
@@ -387,6 +414,11 @@ class DevicesService extends events_1.EventEmitter {
387
414
  return device;
388
415
  });
389
416
  }
417
+ /**
418
+ * Method runs action for a --device (value), specified by the user.
419
+ * @param action action to be executed if canExecute returns true
420
+ * @param canExecute predicate to decide whether the command can be ran
421
+ */
390
422
  executeOnDevice(action, canExecute) {
391
423
  return __awaiter(this, void 0, void 0, function* () {
392
424
  if (!canExecute || canExecute(this._device)) {
@@ -397,6 +429,11 @@ class DevicesService extends events_1.EventEmitter {
397
429
  }
398
430
  });
399
431
  }
432
+ /**
433
+ * Executes passed action for each found device.
434
+ * @param action action to be executed if canExecute returns true
435
+ * @param canExecute predicate to decide whether the command can be ran
436
+ */
400
437
  executeOnAllConnectedDevices(action, canExecute) {
401
438
  return __awaiter(this, void 0, void 0, function* () {
402
439
  const devices = this.filterDevicesByPlatform();
@@ -450,6 +487,12 @@ class DevicesService extends events_1.EventEmitter {
450
487
  });
451
488
  }));
452
489
  }
490
+ /**
491
+ * Runs the passed action if the predicate "canExecute" returns true
492
+ * @param action action to be executed if canExecute returns true.
493
+ * @param canExecute predicate to decide whether the command can be ran
494
+ * @param options all possible options that can be passed to the command.
495
+ */
453
496
  execute(action, canExecute, options) {
454
497
  return __awaiter(this, void 0, void 0, function* () {
455
498
  assert.ok(this._isInitialized, "Devices services not initialized!");
@@ -459,6 +502,7 @@ class DevicesService extends events_1.EventEmitter {
459
502
  this.$mobileHelper.isiOSPlatform(this._platform) &&
460
503
  this.$options.emulator &&
461
504
  !this.isOnlyiOSSimultorRunning()) {
505
+ // Executes the command only on iOS simulator
462
506
  const originalCanExecute = canExecute;
463
507
  canExecute = (dev) => this.isiOSSimulator(dev) &&
464
508
  (!originalCanExecute || !!originalCanExecute(dev));
@@ -483,6 +527,11 @@ class DevicesService extends events_1.EventEmitter {
483
527
  }
484
528
  });
485
529
  }
530
+ /**
531
+ * Starts emulator or simulator if necessary depending on --device or --emulator flags.
532
+ * If no options are passed runs default emulator/simulator if no devices are connected.
533
+ * @param deviceInitOpts mainly contains information about --emulator and --deviceId flags.
534
+ */
486
535
  startEmulatorIfNecessary(deviceInitOpts) {
487
536
  return __awaiter(this, void 0, void 0, function* () {
488
537
  if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
@@ -492,6 +541,7 @@ class DevicesService extends events_1.EventEmitter {
492
541
  if (deviceInitOpts &&
493
542
  deviceInitOpts.platform &&
494
543
  !deviceInitOpts.skipEmulatorStart) {
544
+ // are there any running devices
495
545
  this._platform = deviceInitOpts.platform;
496
546
  try {
497
547
  yield this.startLookingForDevices(deviceInitOpts);
@@ -502,7 +552,7 @@ class DevicesService extends events_1.EventEmitter {
502
552
  const deviceInstances = this.getDeviceInstances();
503
553
  if (!deviceInitOpts.deviceId && _.isEmpty(deviceInstances)) {
504
554
  if (!this.$hostInfo.isDarwin &&
505
- this.$mobileHelper.isApplePlatfrom(deviceInitOpts.platform)) {
555
+ this.$mobileHelper.isApplePlatform(deviceInitOpts.platform)) {
506
556
  this.$errors.fail(constants.ERROR_NO_DEVICES_CANT_USE_IOS_SIMULATOR);
507
557
  }
508
558
  }
@@ -519,9 +569,11 @@ class DevicesService extends events_1.EventEmitter {
519
569
  _startEmulatorIfNecessary(data) {
520
570
  return __awaiter(this, void 0, void 0, function* () {
521
571
  const deviceInstances = this.getDeviceInstances();
572
+ //if no --device is passed and no devices are found, the default emulator is started
522
573
  if (!data.deviceId && _.isEmpty(deviceInstances)) {
523
574
  return this.startEmulatorCore(data);
524
575
  }
576
+ //check if --device(value) is running, if it's not or it's not the same as is specified, start with name from --device(value)
525
577
  if (data.deviceId) {
526
578
  if (!helpers.isNumberWithoutExponent(data.deviceId)) {
527
579
  const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
@@ -530,6 +582,7 @@ class DevicesService extends events_1.EventEmitter {
530
582
  }
531
583
  }
532
584
  }
585
+ // make sure if the target platform is visionOS we don't try to run it on an already running iOS simulator...
533
586
  if (data.platform === this.$devicePlatformsConstants.visionOS &&
534
587
  deviceInstances.length) {
535
588
  const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform === this.$devicePlatformsConstants.visionOS);
@@ -537,6 +590,7 @@ class DevicesService extends events_1.EventEmitter {
537
590
  return this.startEmulatorCore(data);
538
591
  }
539
592
  }
593
+ // if only emulator flag is passed and no other emulators are running, start default emulator
540
594
  if (data.emulator && deviceInstances.length) {
541
595
  const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
542
596
  if (!runningDeviceInstance) {
@@ -545,6 +599,12 @@ class DevicesService extends events_1.EventEmitter {
545
599
  }
546
600
  });
547
601
  }
602
+ /**
603
+ * Takes care of gathering information about all running devices.
604
+ * Sets "_isInitialized" to true after infomation is present.
605
+ * Method expects running devices.
606
+ * @param data mainly contains information about --emulator and --deviceId flags.
607
+ */
548
608
  initialize(data) {
549
609
  return __awaiter(this, void 0, void 0, function* () {
550
610
  if (!this._deviceInitializePromise) {
@@ -554,6 +614,7 @@ class DevicesService extends events_1.EventEmitter {
554
614
  yield this._deviceInitializePromise;
555
615
  }
556
616
  catch (err) {
617
+ // In case the initalization fails, we want to allow calling `initlialize` again with other arguments for example, so remove the cached promise value.
557
618
  this.$logger.trace(`Error while initializing devicesService: ${err}`);
558
619
  this._deviceInitializePromise = null;
559
620
  throw err;
@@ -579,6 +640,7 @@ class DevicesService extends events_1.EventEmitter {
579
640
  deviceInitOpts = deviceInitOpts || {};
580
641
  this._data = deviceInitOpts;
581
642
  if (!deviceInitOpts.skipEmulatorStart) {
643
+ // TODO: Remove from here as it calls startLookingForDevices, so we double the calls to specific device detection services
582
644
  yield this.startEmulatorIfNecessary(deviceInitOpts);
583
645
  }
584
646
  const platform = deviceInitOpts.platform;
@@ -609,6 +671,7 @@ class DevicesService extends events_1.EventEmitter {
609
671
  yield this.startLookingForDevices(deviceLookingOptions);
610
672
  }
611
673
  else {
674
+ // platform and deviceId are not specified
612
675
  if (deviceInitOpts.skipInferPlatform) {
613
676
  if (deviceInitOpts.skipDeviceDetectionInterval) {
614
677
  yield this.detectCurrentlyAttachedDevices(deviceLookingOptions);
@@ -715,7 +778,7 @@ class DevicesService extends events_1.EventEmitter {
715
778
  }
716
779
  resolveEmulatorServices(platform) {
717
780
  platform = platform || this._platform;
718
- if (this.$mobileHelper.isApplePlatfrom(platform)) {
781
+ if (this.$mobileHelper.isApplePlatform(platform)) {
719
782
  return this.$injector.resolve("iOSEmulatorServices");
720
783
  }
721
784
  else if (this.$mobileHelper.isAndroidPlatform(platform)) {
@@ -723,6 +786,11 @@ class DevicesService extends events_1.EventEmitter {
723
786
  }
724
787
  return null;
725
788
  }
789
+ /**
790
+ * Starts emulator for platform and makes sure started devices/emulators/simulators are in _devices array before finishing.
791
+ * @param platform (optional) platform to start emulator/simulator for
792
+ * @param emulatorIdOrName (optional) emulator/simulator image identifier or name
793
+ */
726
794
  startEmulatorCore(deviceInitOpts = {}) {
727
795
  return __awaiter(this, void 0, void 0, function* () {
728
796
  const { deviceId } = deviceInitOpts;
@@ -852,3 +920,4 @@ __decorate([
852
920
  ], DevicesService.prototype, "getDebuggableViews", null);
853
921
  exports.DevicesService = DevicesService;
854
922
  yok_1.injector.register("devicesService", DevicesService);
923
+ //# sourceMappingURL=devices-service.js.map
@@ -27,11 +27,12 @@ class IOSDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
27
27
  this.$logger.trace("Options for ios-device-discovery", options);
28
28
  if (options &&
29
29
  options.platform &&
30
- (!this.$mobileHelper.isApplePlatfrom(options.platform) ||
30
+ (!this.$mobileHelper.isApplePlatform(options.platform) ||
31
31
  options.emulator)) {
32
32
  return;
33
33
  }
34
34
  if (this.$mobileHelper.isvisionOSPlatform(options.platform)) {
35
+ // look for ios devices - same logic.
35
36
  options.platform = this.$devicePlatformsConstants.iOS;
36
37
  }
37
38
  yield this.$iosDeviceOperations.startLookingForDevices((deviceInfo) => {
@@ -61,3 +62,4 @@ class IOSDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
61
62
  }
62
63
  exports.IOSDeviceDiscovery = IOSDeviceDiscovery;
63
64
  yok_1.injector.register("iOSDeviceDiscovery", IOSDeviceDiscovery);
65
+ //# sourceMappingURL=ios-device-discovery.js.map
@@ -40,12 +40,14 @@ class IOSSimulatorDiscovery extends device_discovery_1.DeviceDiscovery {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  if (this.$hostInfo.isDarwin) {
42
42
  const currentSimulators = yield this.$iOSSimResolver.iOSSim.getRunningSimulators();
43
+ // Remove old simulators
43
44
  _(this.cachedSimulators)
44
45
  .reject((s) => _.some(currentSimulators, (simulator) => simulator &&
45
46
  s &&
46
47
  simulator.id === s.id &&
47
48
  simulator.state === s.state))
48
49
  .each((s) => this.deleteAndRemoveDevice(s));
50
+ // Add new simulators
49
51
  _(currentSimulators)
50
52
  .reject((s) => _.some(this.cachedSimulators, (simulator) => simulator &&
51
53
  s &&
@@ -107,3 +109,4 @@ class IOSSimulatorDiscovery extends device_discovery_1.DeviceDiscovery {
107
109
  }
108
110
  exports.IOSSimulatorDiscovery = IOSSimulatorDiscovery;
109
111
  yok_1.injector.register("iOSSimulatorDiscovery", IOSSimulatorDiscovery);
112
+ //# sourceMappingURL=ios-simulator-discovery.js.map
@@ -43,7 +43,7 @@ class MobileHelper {
43
43
  this.$devicePlatformsConstants.visionOS.toLowerCase() ===
44
44
  platform.toLowerCase());
45
45
  }
46
- isApplePlatfrom(platform) {
46
+ isApplePlatform(platform) {
47
47
  return this.isiOSPlatform(platform) || this.isvisionOSPlatform(platform);
48
48
  }
49
49
  normalizePlatformName(platform) {
@@ -100,3 +100,4 @@ class MobileHelper {
100
100
  MobileHelper.DEVICE_PATH_SEPARATOR = "/";
101
101
  exports.MobileHelper = MobileHelper;
102
102
  yok_1.injector.register("mobileHelper", MobileHelper);
103
+ //# sourceMappingURL=mobile-helper.js.map
@@ -80,3 +80,4 @@ class Wp8EmulatorServices {
80
80
  Wp8EmulatorServices.WP8_LAUNCHER = "XapDeployCmd.exe";
81
81
  Wp8EmulatorServices.WP8_LAUNCHER_PATH = "Microsoft SDKs\\Windows Phone\\v8.0\\Tools\\XAP Deployment";
82
82
  yok_1.injector.register("wp8EmulatorServices", Wp8EmulatorServices);
83
+ //# sourceMappingURL=wp8-emulator-services.js.map
@@ -14,3 +14,4 @@ class Opener {
14
14
  }
15
15
  exports.Opener = Opener;
16
16
  yok_1.injector.register("opener", Opener);
17
+ //# sourceMappingURL=opener.js.map
@@ -19,3 +19,4 @@ class OsInfo {
19
19
  }
20
20
  exports.OsInfo = OsInfo;
21
21
  yok_1.injector.register("osInfo", OsInfo);
22
+ //# sourceMappingURL=os-info.js.map
@@ -22,3 +22,4 @@ class PlistParser {
22
22
  }
23
23
  exports.PlistParser = PlistParser;
24
24
  yok_1.injector.register("plistParser", PlistParser);
25
+ //# sourceMappingURL=plist-parser.js.map
@@ -68,3 +68,4 @@ class ProjectHelper {
68
68
  }
69
69
  exports.ProjectHelper = ProjectHelper;
70
70
  yok_1.injector.register("projectHelper", ProjectHelper);
71
+ //# sourceMappingURL=project-helper.js.map
@@ -36,6 +36,7 @@ class Prompter {
36
36
  else {
37
37
  const result = {};
38
38
  _.each(questions, (s) => {
39
+ // Curly brackets needed because s.default() may return false and break the loop
39
40
  result[s.name] = s.default();
40
41
  });
41
42
  return result;
@@ -137,7 +138,9 @@ class Prompter {
137
138
  }
138
139
  muteStdout() {
139
140
  if (helpers.isInteractive()) {
140
- process.stdin.setRawMode(true);
141
+ process.stdin.setRawMode(true); // After setting rawMode to true, Ctrl+C doesn't work for non node.js events loop i.e device log command
142
+ // We need to create mute-stream and to pass it as output to ctrlcReader
143
+ // This will prevent the prompter to show the user's text twice on the console
141
144
  this.muteStreamInstance = new MuteStream();
142
145
  this.muteStreamInstance.pipe(process.stdout);
143
146
  this.muteStreamInstance.mute();
@@ -146,6 +149,7 @@ class Prompter {
146
149
  output: this.muteStreamInstance,
147
150
  });
148
151
  this.ctrlcReader.on("SIGINT", () => {
152
+ // enable terminal cursor
149
153
  process.stdout.write("\x1B[?25h");
150
154
  process.exit();
151
155
  });
@@ -155,6 +159,7 @@ class Prompter {
155
159
  if (helpers.isInteractive()) {
156
160
  process.stdin.setRawMode(false);
157
161
  if (this.muteStreamInstance) {
162
+ // We need to clean the event listeners from the process.stdout because the MuteStream.pipe function calls the pipe function of the Node js Stream which adds event listeners and this can cause memory leak if we display more than ~10 prompts.
158
163
  this.cleanEventListeners(process.stdout);
159
164
  this.muteStreamInstance.unmute();
160
165
  this.muteStreamInstance = null;
@@ -163,6 +168,8 @@ class Prompter {
163
168
  }
164
169
  }
165
170
  cleanEventListeners(stream) {
171
+ // The events names and listeners names can be found here https://github.com/nodejs/node/blob/master/lib/stream.js
172
+ // Which event cause memory leak can be tested with stream.listeners("event-name") and if the listeners count keeps increasing with each prompt we need to remove the listener.
166
173
  const memoryLeakEvents = [
167
174
  {
168
175
  eventName: "close",
@@ -189,3 +196,4 @@ class Prompter {
189
196
  }
190
197
  exports.Prompter = Prompter;
191
198
  yok_1.injector.register("prompter", Prompter);
199
+ //# sourceMappingURL=prompter.js.map
@@ -35,3 +35,4 @@ class Queue {
35
35
  }
36
36
  }
37
37
  exports.Queue = Queue;
38
+ //# sourceMappingURL=queue.js.map
@@ -23,3 +23,4 @@ class ResourceLoader {
23
23
  }
24
24
  exports.ResourceLoader = ResourceLoader;
25
25
  yok_1.injector.register("resources", ResourceLoader);
26
+ //# sourceMappingURL=resource-loader.js.map
@@ -36,12 +36,15 @@ class AutoCompletionService {
36
36
  get shellProfiles() {
37
37
  return [
38
38
  this.getHomePath(".bashrc"),
39
- this.getHomePath(".zshrc"),
39
+ this.getHomePath(".zshrc"), // zsh - http://www.acm.uiuc.edu/workshops/zsh/startup_files.html
40
40
  ];
41
41
  }
42
42
  get cliRunCommandsFile() {
43
43
  let cliRunCommandsFile = this.getHomePath(util.format(".%src", this.$staticConfig.CLIENT_NAME.toLowerCase()));
44
44
  if (this.$hostInfo.isWindows) {
45
+ // on Windows bash, file is incorrectly written as C:\Users\<username>, which leads to errors when trying to execute the script:
46
+ // $ source ~/.bashrc
47
+ // sh.exe": C:Usersusername.appbuilderrc: No such file or directory
45
48
  cliRunCommandsFile = cliRunCommandsFile.replace(/\\/g, "/");
46
49
  }
47
50
  return cliRunCommandsFile;
@@ -53,7 +56,9 @@ class AutoCompletionService {
53
56
  return tabTabRegex;
54
57
  }
55
58
  removeObsoleteAutoCompletion() {
59
+ // In previous releases we were writing directly in .bash_profile, .bashrc, .zshrc and .profile - remove this old code
56
60
  const shellProfilesToBeCleared = this.shellProfiles;
61
+ // Add .profile only here as we do not want new autocompletion in this file, but we have to remove our old code from it.
57
62
  shellProfilesToBeCleared.push(this.getHomePath(".profile"));
58
63
  shellProfilesToBeCleared.forEach((file) => {
59
64
  try {
@@ -87,6 +92,7 @@ class AutoCompletionService {
87
92
  this.isNewAutoCompletionEnabledInFile(filePath) ||
88
93
  this.isObsoleteAutoCompletionEnabledInFile(filePath);
89
94
  if (!result) {
95
+ // break each
90
96
  return false;
91
97
  }
92
98
  });
@@ -114,6 +120,7 @@ class AutoCompletionService {
114
120
  _.each(this.shellProfiles, (shellProfile) => {
115
121
  result = this.isObsoleteAutoCompletionEnabledInFile(shellProfile);
116
122
  if (!result) {
123
+ // break each
117
124
  return false;
118
125
  }
119
126
  });
@@ -152,6 +159,8 @@ class AutoCompletionService {
152
159
  }
153
160
  catch (err) {
154
161
  this.$logger.info("Unable to update %s. Command-line completion might not work.", fileName);
162
+ // When npm is installed with sudo, in some cases the installation cannot write to shell profiles
163
+ // Advise the user how to enable autocompletion after the installation is completed.
155
164
  if ((err.code === "EPERM" || err.code === "EACCES") &&
156
165
  !this.$hostInfo.isWindows &&
157
166
  process.env.SUDO_USER) {
@@ -172,6 +181,7 @@ class AutoCompletionService {
172
181
  }
173
182
  }
174
183
  catch (err) {
184
+ // If file does not exist, autocompletion was not working for it, so ignore this error.
175
185
  if (err.code !== "ENOENT") {
176
186
  this.$logger.info("Failed to update %s. Auto-completion may still work or work incorrectly. ", fileName);
177
187
  this.$logger.info(err);
@@ -230,3 +240,4 @@ __decorate([
230
240
  ], AutoCompletionService.prototype, "completionShellScriptContent", null);
231
241
  exports.AutoCompletionService = AutoCompletionService;
232
242
  yok_1.injector.register("autoCompletionService", AutoCompletionService);
243
+ //# sourceMappingURL=auto-completion-service.js.map
@@ -38,7 +38,7 @@ class CancellationService {
38
38
  .watch(triggerFile, { ignoreInitial: true })
39
39
  .on("unlink", (filePath) => {
40
40
  this.$logger.info(`Exiting process as the file ${filePath} has been deleted. Probably reinstalling CLI while there's a working instance.`);
41
- process.exit(132);
41
+ process.exit(132 /* ErrorCodes.DELETED_KILL_FILE */);
42
42
  });
43
43
  if (watcher) {
44
44
  this.watches[name] = watcher;
@@ -65,3 +65,4 @@ class CancellationService {
65
65
  }
66
66
  }
67
67
  yok_1.injector.register("cancellation", CancellationService);
68
+ //# sourceMappingURL=cancellation.js.map
@@ -48,11 +48,11 @@ class CommandsService {
48
48
  if (!this.$staticConfig.disableAnalytics &&
49
49
  !command.disableAnalytics &&
50
50
  !this.$options.disableAnalytics) {
51
- const analyticsService = this.$injector.resolve("analyticsService");
51
+ const analyticsService = this.$injector.resolve("analyticsService"); // This should be resolved here due to cyclic dependency
52
52
  yield analyticsService.checkConsent();
53
53
  const beautifiedCommandName = this.beautifyCommandName(commandName).replace(/\|/g, " ");
54
54
  const googleAnalyticsPageData = {
55
- googleAnalyticsDataType: "pageview",
55
+ googleAnalyticsDataType: "pageview" /* GoogleAnalyticsDataType.Page */,
56
56
  path: beautifiedCommandName,
57
57
  title: beautifiedCommandName,
58
58
  };
@@ -62,10 +62,11 @@ class CommandsService {
62
62
  const shouldExecuteHooks = !this.$staticConfig.disableCommandHooks &&
63
63
  (command.enableHooks === undefined || command.enableHooks === true);
64
64
  if (shouldExecuteHooks) {
65
+ // Handle correctly hierarchical commands
65
66
  const hierarchicalCommandName = this.$injector.buildHierarchicalCommand(commandName, commandArguments);
66
67
  if (hierarchicalCommandName) {
67
- commandName = helpers.stringReplaceAll(hierarchicalCommandName.commandName, "|*", "-");
68
- commandName = helpers.stringReplaceAll(commandName, "|", "-");
68
+ commandName = helpers.stringReplaceAll(hierarchicalCommandName.commandName, "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */, "-" /* CommandsDelimiters.HooksCommand */);
69
+ commandName = helpers.stringReplaceAll(commandName, "|" /* CommandsDelimiters.HierarchicalCommand */, "-" /* CommandsDelimiters.HooksCommand */);
69
70
  }
70
71
  yield this.$hooksService.executeBeforeHooks(commandName);
71
72
  }
@@ -116,6 +117,7 @@ class CommandsService {
116
117
  yield this.executeCommandAction(commandName, commandArguments, this.executeCommandUnchecked);
117
118
  }
118
119
  else {
120
+ // If canExecuteCommand returns false, the command cannot be executed or there's no such command at all.
119
121
  const command = this.$injector.resolveCommand(commandName);
120
122
  if (command) {
121
123
  let commandWithArgs = commandName;
@@ -133,12 +135,15 @@ class CommandsService {
133
135
  const command = this.$injector.resolveCommand(commandName);
134
136
  const beautifiedName = helpers.stringReplaceAll(commandName, "|", " ");
135
137
  if (command) {
138
+ // Verify command is enabled
136
139
  if (command.isDisabled) {
137
140
  this.$errors.fail("This command is not applicable to your environment.");
138
141
  }
142
+ // If command wants to handle canExecute logic on its own.
139
143
  if (command.canExecute) {
140
144
  return yield command.canExecute(commandArguments);
141
145
  }
146
+ // First part of hierarchical commands should be validated in specific way.
142
147
  if (yield this.$injector.isValidHierarchicalCommand(commandName, commandArguments)) {
143
148
  return true;
144
149
  }
@@ -150,8 +155,8 @@ class CommandsService {
150
155
  }
151
156
  const commandInfo = {
152
157
  inputStrings: [commandName, ...commandArguments],
153
- commandDelimiter: "|",
154
- defaultCommandDelimiter: "|*",
158
+ commandDelimiter: "|" /* CommandsDelimiters.HierarchicalCommand */,
159
+ defaultCommandDelimiter: "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */,
155
160
  };
156
161
  const extensionData = yield this.$extensibilityService.getExtensionNameWhereCommandIsRegistered(commandInfo);
157
162
  if (extensionData) {
@@ -169,11 +174,13 @@ class CommandsService {
169
174
  return __awaiter(this, void 0, void 0, function* () {
170
175
  const commandArgsHelper = new CommandArgumentsValidationHelper(true, commandArguments);
171
176
  if (mandatoryParams.length > 0) {
177
+ // If command has more mandatory params than the passed ones, we shouldn't execute it
172
178
  if (mandatoryParams.length > commandArguments.length) {
173
179
  const customErrorMessages = _.map(mandatoryParams, (mp) => mp.errorMessage);
174
180
  customErrorMessages.splice(0, 0, "You need to provide all the required parameters.");
175
181
  this.$errors.failWithHelp(customErrorMessages.join(os_1.EOL));
176
182
  }
183
+ // If we reach here, the commandArguments are at least as much as mandatoryParams. Now we should verify that we have each of them.
177
184
  for (let mandatoryParamIndex = 0; mandatoryParamIndex < mandatoryParams.length; ++mandatoryParamIndex) {
178
185
  const mandatoryParam = mandatoryParams[mandatoryParamIndex];
179
186
  let argument = null;
@@ -202,12 +209,14 @@ class CommandsService {
202
209
  if (!commandArgsHelper.isValid) {
203
210
  return false;
204
211
  }
212
+ // Command doesn't have any allowedParameters
205
213
  if (!command.allowedParameters || command.allowedParameters.length === 0) {
206
214
  if (commandArguments.length > 0) {
207
215
  this.$errors.failWithHelp("This command doesn't accept parameters.");
208
216
  }
209
217
  }
210
218
  else {
219
+ // Exclude mandatory params, we've already checked them
211
220
  const unverifiedAllowedParams = command.allowedParameters.filter((param) => !param.mandatory);
212
221
  for (let remainingArgsIndex = 0; remainingArgsIndex < commandArgsHelper.remainingArguments.length; ++remainingArgsIndex) {
213
222
  const argument = commandArgsHelper.remainingArguments[remainingArgsIndex];
@@ -221,6 +230,7 @@ class CommandsService {
221
230
  }
222
231
  if (parameter) {
223
232
  const index = unverifiedAllowedParams.indexOf(parameter);
233
+ // Remove the matched parameter from unverifiedAllowedParams collection, so it will not be used to verify another argument.
224
234
  unverifiedAllowedParams.splice(index, 1);
225
235
  }
226
236
  else {
@@ -266,3 +276,4 @@ class CommandsService {
266
276
  }
267
277
  exports.CommandsService = CommandsService;
268
278
  yok_1.injector.register("commandsService", CommandsService);
279
+ //# sourceMappingURL=commands-service.js.map
@@ -52,6 +52,7 @@ class HelpService {
52
52
  this.$logger.trace("Opening help for command '%s'. FileName is '%s'.", commandName, htmlPage);
53
53
  this.$fs.ensureDirectoryExists(this.pathToHtmlPages);
54
54
  if (!this.tryOpeningSelectedPage(htmlPage)) {
55
+ // HTML pages may have been skipped on post-install, lets generate them.
55
56
  this.$logger.trace("Required HTML file '%s' is missing. Let's try generating HTML files and see if we'll find it.", htmlPage);
56
57
  yield this.generateHtmlPages();
57
58
  if (!this.tryOpeningSelectedPage(htmlPage)) {
@@ -113,6 +114,11 @@ class HelpService {
113
114
  this.$logger.printMarkdown(help);
114
115
  });
115
116
  }
117
+ /**
118
+ * Gets the help content for a specific command that should be shown on the terminal.
119
+ * @param {string} commandName Name of the command for which to read the help.
120
+ * @returns {Promise<string>} Help content of the command parsed with all terminal rules applied (stripped content that should be shown only for html help).
121
+ */
116
122
  getCommandLineHelpForCommand(commandData) {
117
123
  return __awaiter(this, void 0, void 0, function* () {
118
124
  const helpText = yield this.readMdFileForCommand(commandData);
@@ -126,6 +132,7 @@ class HelpService {
126
132
  return commandLineHelp;
127
133
  });
128
134
  }
135
+ // This method should return Promise in order to generate all html pages simultaneously.
129
136
  createHtmlPage(htmlPageGenerationData) {
130
137
  return __awaiter(this, void 0, void 0, function* () {
131
138
  const { basicHtmlPage, pathToMdFile, pathToMdPages, pathToHtmlPages, extensionName, } = htmlPageGenerationData;
@@ -177,8 +184,8 @@ class HelpService {
177
184
  const commandName = commandData.commandName;
178
185
  const commandInfo = {
179
186
  inputStrings: [commandName, ...commandData.commandArguments],
180
- commandDelimiter: "|",
181
- defaultCommandDelimiter: "|*",
187
+ commandDelimiter: "|" /* CommandsDelimiters.HierarchicalCommand */,
188
+ defaultCommandDelimiter: "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */,
182
189
  };
183
190
  const extensionData = yield this.$extensibilityService.getExtensionNameWhereCommandIsRegistered(commandInfo);
184
191
  if (extensionData) {
@@ -247,6 +254,7 @@ HelpService.RELATIVE_PATH_TO_INDEX_REGEX = /@RELATIVE_PATH_TO_INDEX@/g;
247
254
  HelpService.EXTENSION_NAME_REGEX = /@EXTENSION_NAME@/g;
248
255
  HelpService.MARKDOWN_LINK_REGEX = /\[([\w \-\`\<\>\*\:\\]+?)\]\([\s\S]+?\)/g;
249
256
  HelpService.SPAN_REGEX = /([\s\S]*?)(?:\r?\n)?<span.*?>([\s\S]*?)<\/span>(?:\r?\n)*/g;
250
- HelpService.NEW_LINE_REGEX = /<\/?\s*?br\s*?\/?>/g;
257
+ HelpService.NEW_LINE_REGEX = /<\/?\s*?br\s*?\/?>/g; // <br>, <br > <br/> <br />
251
258
  exports.HelpService = HelpService;
252
259
  yok_1.injector.register("helpService", HelpService);
260
+ //# sourceMappingURL=help-service.js.map