nativescript 9.0.4-dev.1 → 9.0.4-dev.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 (329) 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 +5 -1
  4. package/lib/bun-package-manager.js +14 -1
  5. package/lib/color.js +4 -0
  6. package/lib/commands/add-platform.js +1 -0
  7. package/lib/commands/apple-login.js +1 -0
  8. package/lib/commands/appstore-list.js +1 -0
  9. package/lib/commands/appstore-upload.js +3 -0
  10. package/lib/commands/build.js +3 -2
  11. package/lib/commands/clean.js +22 -1
  12. package/lib/commands/command-base.js +1 -0
  13. package/lib/commands/config.js +5 -0
  14. package/lib/commands/create-project.js +6 -0
  15. package/lib/commands/debug.js +6 -1
  16. package/lib/commands/deploy.js +3 -2
  17. package/lib/commands/embedding/embed.js +7 -0
  18. package/lib/commands/extensibility/install-extension.js +1 -0
  19. package/lib/commands/extensibility/list-extensions.js +1 -0
  20. package/lib/commands/extensibility/uninstall-extension.js +1 -0
  21. package/lib/commands/fonts.js +1 -0
  22. package/lib/commands/generate-assets.js +1 -0
  23. package/lib/commands/generate-help.js +1 -0
  24. package/lib/commands/generate.js +48 -1
  25. package/lib/commands/hooks/common.js +2 -1
  26. package/lib/commands/hooks/hooks-lock.js +1 -0
  27. package/lib/commands/hooks/hooks.js +1 -0
  28. package/lib/commands/info.js +1 -0
  29. package/lib/commands/install.js +1 -0
  30. package/lib/commands/list-platforms.js +1 -0
  31. package/lib/commands/migrate.js +1 -0
  32. package/lib/commands/native-add.js +5 -0
  33. package/lib/commands/platform-clean.js +1 -0
  34. package/lib/commands/plugin/add-plugin.js +1 -0
  35. package/lib/commands/plugin/build-plugin.js +1 -0
  36. package/lib/commands/plugin/create-plugin.js +5 -0
  37. package/lib/commands/plugin/list-plugins.js +1 -0
  38. package/lib/commands/plugin/remove-plugin.js +2 -0
  39. package/lib/commands/plugin/update-plugin.js +1 -0
  40. package/lib/commands/post-install.js +6 -0
  41. package/lib/commands/prepare.js +4 -3
  42. package/lib/commands/preview.js +2 -0
  43. package/lib/commands/remove-platform.js +1 -0
  44. package/lib/commands/resources/resources-update.js +2 -0
  45. package/lib/commands/run.js +1 -0
  46. package/lib/commands/setup.js +1 -0
  47. package/lib/commands/start.js +1 -0
  48. package/lib/commands/test-init.js +4 -0
  49. package/lib/commands/test.js +9 -2
  50. package/lib/commands/typings.js +2 -1
  51. package/lib/commands/update-platform.js +5 -0
  52. package/lib/commands/update.js +2 -0
  53. package/lib/commands/widget.js +20 -1
  54. package/lib/common/bootstrap.js +1 -0
  55. package/lib/common/child-process.js +3 -0
  56. package/lib/common/codeGeneration/code-entity.js +1 -0
  57. package/lib/common/codeGeneration/code-printer.js +1 -0
  58. package/lib/common/command-params.js +1 -0
  59. package/lib/common/commands/analytics.js +3 -0
  60. package/lib/common/commands/autocompletion.js +3 -0
  61. package/lib/common/commands/device/device-log-stream.js +1 -0
  62. package/lib/common/commands/device/get-file.js +2 -0
  63. package/lib/common/commands/device/list-applications.js +1 -0
  64. package/lib/common/commands/device/list-devices.js +3 -0
  65. package/lib/common/commands/device/list-files.js +2 -0
  66. package/lib/common/commands/device/put-file.js +2 -0
  67. package/lib/common/commands/device/run-application.js +1 -0
  68. package/lib/common/commands/device/stop-application.js +1 -0
  69. package/lib/common/commands/device/uninstall-application.js +1 -0
  70. package/lib/common/commands/doctor.js +3 -2
  71. package/lib/common/commands/generate-messages.js +1 -0
  72. package/lib/common/commands/help.js +1 -0
  73. package/lib/common/commands/package-manager-get.js +1 -0
  74. package/lib/common/commands/package-manager-set.js +1 -0
  75. package/lib/common/commands/post-install.js +1 -0
  76. package/lib/common/commands/preuninstall.js +11 -2
  77. package/lib/common/commands/proxy/proxy-base.js +4 -0
  78. package/lib/common/commands/proxy/proxy-clear.js +1 -0
  79. package/lib/common/commands/proxy/proxy-get.js +1 -0
  80. package/lib/common/commands/proxy/proxy-set.js +1 -0
  81. package/lib/common/common-lib.js +1 -0
  82. package/lib/common/constants.js +11 -0
  83. package/lib/common/decorators.js +48 -0
  84. package/lib/common/dispatchers.js +10 -1
  85. package/lib/common/errors.js +13 -3
  86. package/lib/common/file-system.js +13 -2
  87. package/lib/common/header.js +3 -0
  88. package/lib/common/helpers.js +89 -3
  89. package/lib/common/host-info.js +4 -0
  90. package/lib/common/http-client.js +20 -0
  91. package/lib/common/logger/appenders/cli-appender.js +4 -0
  92. package/lib/common/logger/appenders/emit-appender.js +4 -0
  93. package/lib/common/logger/layouts/cli-layout.js +1 -0
  94. package/lib/common/logger/logger.js +5 -0
  95. package/lib/common/messages/messages.js +6 -0
  96. package/lib/common/mobile/android/android-application-manager.js +20 -1
  97. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -0
  98. package/lib/common/mobile/android/android-debug-bridge.js +6 -0
  99. package/lib/common/mobile/android/android-device-file-system.js +4 -0
  100. package/lib/common/mobile/android/android-device-hash-service.js +3 -0
  101. package/lib/common/mobile/android/android-device.js +8 -0
  102. package/lib/common/mobile/android/android-emulator-services.js +2 -1
  103. package/lib/common/mobile/android/android-ini-file-parser.js +9 -0
  104. package/lib/common/mobile/android/android-log-filter.js +4 -0
  105. package/lib/common/mobile/android/android-virtual-device-service.js +26 -0
  106. package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
  107. package/lib/common/mobile/android/genymotion/genymotion-service.js +6 -1
  108. package/lib/common/mobile/android/genymotion/virtualbox-service.js +11 -0
  109. package/lib/common/mobile/android/logcat-helper.js +13 -0
  110. package/lib/common/mobile/application-manager-base.js +6 -0
  111. package/lib/common/mobile/device-emitter.js +4 -0
  112. package/lib/common/mobile/device-log-emitter.js +1 -0
  113. package/lib/common/mobile/device-log-provider-base.js +1 -0
  114. package/lib/common/mobile/device-log-provider.js +23 -0
  115. package/lib/common/mobile/device-platforms-constants.js +1 -0
  116. package/lib/common/mobile/emulator-helper.js +3 -0
  117. package/lib/common/mobile/ios/device/ios-application-manager.js +3 -0
  118. package/lib/common/mobile/ios/device/ios-device-file-system.js +1 -0
  119. package/lib/common/mobile/ios/device/ios-device-operations.js +4 -0
  120. package/lib/common/mobile/ios/device/ios-device.js +4 -0
  121. package/lib/common/mobile/ios/ios-device-base.js +1 -0
  122. package/lib/common/mobile/ios/ios-device-product-name-mapper.js +2 -0
  123. package/lib/common/mobile/ios/ios-log-filter.js +1 -0
  124. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +4 -0
  125. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -0
  126. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +6 -0
  127. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +5 -0
  128. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +1 -0
  129. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +1 -0
  130. package/lib/common/mobile/local-to-device-path-data-factory.js +1 -0
  131. package/lib/common/mobile/log-filter.js +2 -0
  132. package/lib/common/mobile/logging-levels.js +1 -0
  133. package/lib/common/mobile/mobile-core/android-device-discovery.js +2 -0
  134. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +3 -0
  135. package/lib/common/mobile/mobile-core/android-process-service.js +32 -0
  136. package/lib/common/mobile/mobile-core/device-discovery.js +1 -0
  137. package/lib/common/mobile/mobile-core/devices-service.js +69 -0
  138. package/lib/common/mobile/mobile-core/ios-device-discovery.js +2 -0
  139. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +3 -0
  140. package/lib/common/mobile/mobile-helper.js +1 -0
  141. package/lib/common/mobile/wp8/wp8-emulator-services.js +1 -0
  142. package/lib/common/opener.js +1 -0
  143. package/lib/common/os-info.js +1 -0
  144. package/lib/common/plist-parser.js +1 -0
  145. package/lib/common/project-helper.js +1 -0
  146. package/lib/common/prompter.js +9 -1
  147. package/lib/common/queue.js +1 -0
  148. package/lib/common/resource-loader.js +1 -0
  149. package/lib/common/services/auto-completion-service.js +13 -1
  150. package/lib/common/services/cancellation.js +2 -1
  151. package/lib/common/services/commands-service.js +17 -6
  152. package/lib/common/services/help-service.js +11 -3
  153. package/lib/common/services/hooks-service.js +13 -0
  154. package/lib/common/services/ios-notification-service.js +1 -0
  155. package/lib/common/services/json-file-settings-service.js +6 -0
  156. package/lib/common/services/lock-service.js +6 -0
  157. package/lib/common/services/message-contract-generator.js +1 -0
  158. package/lib/common/services/messages-service.js +1 -0
  159. package/lib/common/services/micro-templating-service.js +6 -0
  160. package/lib/common/services/net-service.js +3 -0
  161. package/lib/common/services/project-files-manager.js +5 -0
  162. package/lib/common/services/project-files-provider-base.js +1 -0
  163. package/lib/common/services/proxy-service.js +1 -0
  164. package/lib/common/services/qr.js +1 -0
  165. package/lib/common/services/settings-service.js +1 -0
  166. package/lib/common/services/xcode-select-service.js +1 -0
  167. package/lib/common/utils.js +1 -0
  168. package/lib/common/validators/project-name-validator.js +1 -0
  169. package/lib/common/validators/validation-result.js +1 -0
  170. package/lib/common/verify-node-version.js +8 -1
  171. package/lib/common/yok.js +32 -11
  172. package/lib/config.js +22 -1
  173. package/lib/constants-provider.js +1 -0
  174. package/lib/constants.js +53 -0
  175. package/lib/controllers/build-controller.js +4 -3
  176. package/lib/controllers/debug-controller.js +8 -3
  177. package/lib/controllers/deploy-controller.js +1 -0
  178. package/lib/controllers/migrate-controller.js +90 -4
  179. package/lib/controllers/platform-controller.js +9 -1
  180. package/lib/controllers/prepare-controller.js +17 -4
  181. package/lib/controllers/run-controller.js +17 -1
  182. package/lib/controllers/update-controller-base.js +1 -0
  183. package/lib/controllers/update-controller.js +11 -0
  184. package/lib/data/build-data.js +1 -0
  185. package/lib/data/controller-data-base.js +1 -0
  186. package/lib/data/debug-data.js +1 -0
  187. package/lib/data/platform-data.js +1 -0
  188. package/lib/data/prepare-data.js +1 -0
  189. package/lib/data/run-data.js +1 -0
  190. package/lib/detached-processes/cleanup-js-subprocess.js +8 -2
  191. package/lib/detached-processes/cleanup-process.js +18 -14
  192. package/lib/detached-processes/file-log-service.js +2 -1
  193. package/lib/device-path-provider.js +1 -0
  194. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +7 -0
  195. package/lib/device-sockets/ios/notification.js +3 -0
  196. package/lib/device-sockets/ios/socket-request-executor.js +3 -0
  197. package/lib/helpers/android-bundle-validator-helper.js +2 -1
  198. package/lib/helpers/deploy-command-helper.js +1 -0
  199. package/lib/helpers/key-command-helper.js +4 -2
  200. package/lib/helpers/livesync-command-helper.js +4 -1
  201. package/lib/helpers/network-connectivity-validator.js +1 -0
  202. package/lib/helpers/options-track-helper.js +3 -2
  203. package/lib/helpers/package-path-helper.js +1 -0
  204. package/lib/helpers/platform-command-helper.js +7 -2
  205. package/lib/helpers/version-validator-helper.js +1 -0
  206. package/lib/key-commands/bootstrap.js +3 -2
  207. package/lib/key-commands/index.js +5 -4
  208. package/lib/nativescript-cli-lib-bootstrap.js +4 -0
  209. package/lib/nativescript-cli-lib.js +1 -0
  210. package/lib/nativescript-cli.js +11 -1
  211. package/lib/node/pbxproj-dom-xcode.js +1 -0
  212. package/lib/node/xcode.js +1 -0
  213. package/lib/node-package-manager.js +11 -1
  214. package/lib/options.js +144 -119
  215. package/lib/package-installation-manager.js +8 -1
  216. package/lib/package-manager.js +2 -0
  217. package/lib/platform-command-param.js +1 -0
  218. package/lib/pnpm-package-manager.js +4 -1
  219. package/lib/project-data.js +12 -0
  220. package/lib/providers/project-files-provider.js +1 -0
  221. package/lib/resolvers/livesync-service-resolver.js +1 -0
  222. package/lib/services/analytics/analytics-broker-process.js +10 -6
  223. package/lib/services/analytics/analytics-broker.js +2 -1
  224. package/lib/services/analytics/analytics-service.js +29 -25
  225. package/lib/services/analytics/google-analytics-provider.js +13 -12
  226. package/lib/services/analytics-settings-service.js +5 -0
  227. package/lib/services/android/android-bundle-tool-service.js +1 -0
  228. package/lib/services/android/gradle-build-args-service.js +3 -0
  229. package/lib/services/android/gradle-build-service.js +1 -0
  230. package/lib/services/android/gradle-command-service.js +1 -0
  231. package/lib/services/android-device-debug-service.js +6 -0
  232. package/lib/services/android-plugin-build-service.js +31 -2
  233. package/lib/services/android-project-service.js +71 -4
  234. package/lib/services/android-resources-migration-service.js +7 -0
  235. package/lib/services/apple-portal/apple-portal-application-service.js +1 -0
  236. package/lib/services/apple-portal/apple-portal-cookie-service.js +1 -0
  237. package/lib/services/apple-portal/apple-portal-session-service.js +6 -4
  238. package/lib/services/apple-portal/srp/srp-wrapper.js +4 -1
  239. package/lib/services/assets-generation/assets-generation-service.js +10 -5
  240. package/lib/services/build-artifacts-service.js +2 -1
  241. package/lib/services/build-data-service.js +1 -0
  242. package/lib/services/build-info-file-service.js +1 -0
  243. package/lib/services/bundler/bundler-compiler-service.js +68 -1
  244. package/lib/services/bundler/bundler.js +1 -0
  245. package/lib/services/cleanup-service.js +13 -9
  246. package/lib/services/cocoapods-platform-manager.js +9 -0
  247. package/lib/services/cocoapods-service.js +21 -1
  248. package/lib/services/debug-data-service.js +1 -0
  249. package/lib/services/debug-service-base.js +7 -0
  250. package/lib/services/device/device-install-app-service.js +2 -1
  251. package/lib/services/doctor-service.js +21 -6
  252. package/lib/services/extensibility-service.js +8 -0
  253. package/lib/services/files-hash-service.js +1 -0
  254. package/lib/services/hmr-status-service.js +2 -0
  255. package/lib/services/info-service.js +1 -0
  256. package/lib/services/initialize-service.js +5 -1
  257. package/lib/services/ios/export-options-plist-service.js +4 -0
  258. package/lib/services/ios/ios-signing-service.js +4 -0
  259. package/lib/services/ios/spm-service.js +18 -0
  260. package/lib/services/ios/xcodebuild-args-service.js +11 -0
  261. package/lib/services/ios/xcodebuild-command-service.js +1 -0
  262. package/lib/services/ios/xcodebuild-service.js +2 -1
  263. package/lib/services/ios-debugger-port-service.js +1 -0
  264. package/lib/services/ios-device-debug-service.js +1 -0
  265. package/lib/services/ios-entitlements-service.js +1 -0
  266. package/lib/services/ios-extensions-service.js +1 -0
  267. package/lib/services/ios-log-filter.js +20 -0
  268. package/lib/services/ios-native-target-service.js +6 -4
  269. package/lib/services/ios-project-service.js +100 -1
  270. package/lib/services/ios-provision-service.js +3 -0
  271. package/lib/services/ios-watch-app-service.js +1 -0
  272. package/lib/services/ip-service.js +2 -0
  273. package/lib/services/itmstransporter-service.js +1 -0
  274. package/lib/services/karma-execution.js +2 -0
  275. package/lib/services/livesync/android-device-livesync-service-base.js +1 -0
  276. package/lib/services/livesync/android-device-livesync-service.js +2 -0
  277. package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -0
  278. package/lib/services/livesync/android-livesync-service.js +1 -0
  279. package/lib/services/livesync/android-livesync-tool.js +4 -0
  280. package/lib/services/livesync/device-livesync-service-base.js +2 -0
  281. package/lib/services/livesync/ios-device-livesync-service.js +7 -0
  282. package/lib/services/livesync/ios-livesync-service.js +2 -0
  283. package/lib/services/livesync/livesync-socket.js +1 -0
  284. package/lib/services/livesync/platform-livesync-service-base.js +5 -0
  285. package/lib/services/livesync-process-data-service.js +1 -0
  286. package/lib/services/log-parser-service.js +1 -0
  287. package/lib/services/log-source-map-service.js +15 -0
  288. package/lib/services/marking-mode-service.js +8 -5
  289. package/lib/services/metadata-filtering-service.js +1 -0
  290. package/lib/services/npm-config-service.js +4 -0
  291. package/lib/services/pacote-service.js +7 -0
  292. package/lib/services/performance-service.js +3 -1
  293. package/lib/services/platform/add-platform-service.js +49 -2
  294. package/lib/services/platform/platform-validation-service.js +1 -0
  295. package/lib/services/platform/prepare-native-platform-service.js +5 -2
  296. package/lib/services/platform-environment-requirements.js +8 -3
  297. package/lib/services/platform-project-service-base.js +1 -0
  298. package/lib/services/platforms-data-service.js +1 -0
  299. package/lib/services/plugins-service.js +20 -2
  300. package/lib/services/prepare-data-service.js +1 -0
  301. package/lib/services/project-backup-service.js +4 -0
  302. package/lib/services/project-changes-service.js +14 -3
  303. package/lib/services/project-cleanup-service.js +2 -0
  304. package/lib/services/project-config-service.js +21 -2
  305. package/lib/services/project-data-service.js +36 -7
  306. package/lib/services/project-name-service.js +1 -0
  307. package/lib/services/project-service.js +10 -0
  308. package/lib/services/project-templates-service.js +3 -2
  309. package/lib/services/qr-code-terminal-service.js +1 -0
  310. package/lib/services/require-service.js +1 -0
  311. package/lib/services/start-service.js +1 -0
  312. package/lib/services/temp-service.js +3 -0
  313. package/lib/services/terminal-spinner-service.js +2 -0
  314. package/lib/services/test-execution-service.js +9 -2
  315. package/lib/services/test-initialization-service.js +4 -0
  316. package/lib/services/timeline-profiler-service.js +1 -0
  317. package/lib/services/user-settings-service.js +1 -0
  318. package/lib/services/versions-service.js +6 -4
  319. package/lib/services/watch-ignore-list-service.js +1 -0
  320. package/lib/services/xcconfig-service.js +2 -0
  321. package/lib/services/xcproj-service.js +1 -0
  322. package/lib/shared-event-bus.js +6 -0
  323. package/lib/sys-info.js +2 -1
  324. package/lib/tools/config-manipulation/config-transformer.js +12 -0
  325. package/lib/tools/node-modules/node-modules-builder.js +1 -0
  326. package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
  327. package/lib/yarn-package-manager.js +1 -0
  328. package/lib/yarn2-package-manager.js +3 -0
  329. package/package.json +1 -1
@@ -71,6 +71,19 @@ class AndroidProcessService {
71
71
  async getDebuggableApps(deviceIdentifier) {
72
72
  const adb = this.getAdb(deviceIdentifier);
73
73
  const androidWebViewPortInformation = (await this.getAbstractPortsInformation(adb)).split(os_1.EOL);
74
+ // TODO: Add tests and make sure only unique names are returned. Input before groupBy is:
75
+ // [ { deviceIdentifier: 'SH26BW100473',
76
+ // appIdentifier: 'com.telerik.EmptyNS',
77
+ // framework: 'NativeScript' },
78
+ // { deviceIdentifier: 'SH26BW100473',
79
+ // appIdentifier: 'com.telerik.EmptyNS',
80
+ // framework: 'Cordova' },
81
+ // { deviceIdentifier: 'SH26BW100473',
82
+ // appIdentifier: 'chrome',
83
+ // framework: 'Cordova' },
84
+ // { deviceIdentifier: 'SH26BW100473',
85
+ // appIdentifier: 'chrome',
86
+ // framework: 'Cordova' } ]
74
87
  const portInformation = await Promise.all(_.map(androidWebViewPortInformation, async (line) => (await this.getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, line)) ||
75
88
  (await this.getNativeScriptApplicationInformation(adb, deviceIdentifier, line))));
76
89
  return _(portInformation)
@@ -109,6 +122,7 @@ class AndroidProcessService {
109
122
  return adb;
110
123
  }
111
124
  async getApplicationInfoFromWebViewPortInformation(adb, deviceIdentifier, information) {
125
+ // Need to search by processId to check for old Android webviews (@webview_devtools_remote_<processId>).
112
126
  const processIdRegExp = /@webview_devtools_remote_(.+)/g;
113
127
  const processIdMatches = processIdRegExp.exec(information);
114
128
  let cordovaAppIdentifier;
@@ -117,6 +131,7 @@ class AndroidProcessService {
117
131
  cordovaAppIdentifier = await this.getApplicationIdentifierFromPid(adb, processId);
118
132
  }
119
133
  else {
134
+ // Search for appIdentifier (@<appIdentifier>_devtools_remote).
120
135
  const chromeAppIdentifierRegExp = /@(.+)_devtools_remote\s?/g;
121
136
  const chromeAppIdentifierMatches = chromeAppIdentifierRegExp.exec(information);
122
137
  if (chromeAppIdentifierMatches && chromeAppIdentifierMatches.length > 0) {
@@ -133,6 +148,7 @@ class AndroidProcessService {
133
148
  return null;
134
149
  }
135
150
  async getNativeScriptApplicationInformation(adb, deviceIdentifier, information) {
151
+ // Search for appIdentifier (@<appIdentifier-debug>).
136
152
  const nativeScriptAppIdentifierRegExp = /@(.+)-(debug|inspectorServer)/g;
137
153
  const nativeScriptAppIdentifierMatches = nativeScriptAppIdentifierRegExp.exec(information);
138
154
  if (nativeScriptAppIdentifierMatches &&
@@ -147,6 +163,10 @@ class AndroidProcessService {
147
163
  return null;
148
164
  }
149
165
  async getAbstractPortForApplication(adb, processId, appIdentifier, abstractPortsInformation, framework) {
166
+ // The result will look like this (without the columns names):
167
+ // Num RefCount Protocol Flags Type St Inode Path
168
+ // 0000000000000000: 00000002 00000000 00010000 0001 01 189004 @webview_devtools_remote_25512
169
+ // The Path column is the abstract port.
150
170
  framework = framework || "";
151
171
  switch (framework.toLowerCase()) {
152
172
  case constants_1.TARGET_FRAMEWORK_IDENTIFIERS.Cordova.toLowerCase():
@@ -173,6 +193,9 @@ class AndroidProcessService {
173
193
  return match && match[1];
174
194
  }
175
195
  async getProcessIds(adb, appIdentifiers) {
196
+ // Process information will look like this (without the columns names):
197
+ // USER PID PPID VSIZE RSS WCHAN PC NAME
198
+ // u0_a63 25512 1334 1519560 96040 ffffffff f76a8f75 S com.telerik.appbuildertabstest
176
199
  const result = {};
177
200
  const processIdInformation = await adb.executeShellCommand(["ps"]);
178
201
  _.each(appIdentifiers, (appIdentifier) => {
@@ -183,6 +206,11 @@ class AndroidProcessService {
183
206
  }
184
207
  async getAlreadyMappedPort(adb, deviceIdentifier, abstractPort, adbForwardList) {
185
208
  const allForwardedPorts = adbForwardList || (await adb.executeCommand(["forward", "--list"])) || "";
209
+ // Sample output:
210
+ // 5e2e580b tcp:62503 localabstract:webview_devtools_remote_7985
211
+ // 5e2e580b tcp:62524 localabstract:webview_devtools_remote_7986
212
+ // 5e2e580b tcp:63160 localabstract:webview_devtools_remote_7987
213
+ // 5e2e580b tcp:57577 localabstract:com.telerik.nrel-debug
186
214
  const regex = new RegExp(`${deviceIdentifier}\\s+?tcp:(\\d+?)\\s+?.*?${abstractPort}$`);
187
215
  return this.getFirstMatchingGroupFromMultilineResult(allForwardedPorts, regex);
188
216
  }
@@ -196,6 +224,9 @@ class AndroidProcessService {
196
224
  }
197
225
  async getApplicationIdentifierFromPid(adb, pid, psData) {
198
226
  psData = psData || (await adb.executeShellCommand(["ps"]));
227
+ // Process information will look like this (without the columns names):
228
+ // USER PID PPID VSIZE RSS WCHAN PC NAME
229
+ // u0_a63 25512 1334 1519560 96040 ffffffff f76a8f75 S com.telerik.appbuildertabstest
199
230
  return this.getFirstMatchingGroupFromMultilineResult(psData, new RegExp(`\\s+${pid}(?:\\s+\\d+){3}\\s+.*\\s+(.*?)$`));
200
231
  }
201
232
  getFirstMatchingGroupFromMultilineResult(input, regex) {
@@ -218,3 +249,4 @@ __decorate([
218
249
  (0, decorators_1.exported)("androidProcessService")
219
250
  ], AndroidProcessService.prototype, "getAppProcessId", null);
220
251
  yok_1.injector.register("androidProcessService", AndroidProcessService);
252
+ //# sourceMappingURL=android-process-service.js.map
@@ -51,3 +51,4 @@ class DeviceDiscovery extends events_1.EventEmitter {
51
51
  }
52
52
  exports.DeviceDiscovery = DeviceDiscovery;
53
53
  yok_1.injector.register("deviceDiscovery", DeviceDiscovery);
54
+ //# sourceMappingURL=device-discovery.js.map
@@ -62,6 +62,7 @@ class DevicesService extends events_1.EventEmitter {
62
62
  const device = await this.getDevice(options.deviceId);
63
63
  return device;
64
64
  }
65
+ // Now let's take data for each device:
65
66
  const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
66
67
  (!this.platform ||
67
68
  d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
@@ -84,6 +85,8 @@ class DevicesService extends events_1.EventEmitter {
84
85
  const devices = sortedInstances.filter((d) => !d.isEmulator);
85
86
  let selectedInstance;
86
87
  if (options.onlyEmulators || options.onlyDevices) {
88
+ // When --emulator or --forDevice is passed, the instances are already filtered
89
+ // So we are sure we have exactly the type we need and we can safely return the last one (highest OS version).
87
90
  selectedInstance = _.last(sortedInstances);
88
91
  }
89
92
  else {
@@ -142,6 +145,7 @@ class DevicesService extends events_1.EventEmitter {
142
145
  ...additionalErrors,
143
146
  ];
144
147
  }
148
+ // emulator is already running
145
149
  if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
146
150
  return null;
147
151
  }
@@ -173,9 +177,11 @@ class DevicesService extends events_1.EventEmitter {
173
177
  return !!(this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) &&
174
178
  device.isEmulator);
175
179
  }
180
+ /* tslint:disable:no-unused-variable */
176
181
  setLogLevel(logLevel, deviceIdentifier) {
177
182
  this.$deviceLogProvider.setLogLevel(logLevel, deviceIdentifier);
178
183
  }
184
+ /* tslint:enable:no-unused-variable */
179
185
  isAppInstalledOnDevices(deviceIdentifiers, appId, projectName, projectDir) {
180
186
  this.$logger.trace(`Called isInstalledOnDevices for identifiers ${deviceIdentifiers}. AppIdentifier is ${appId}.`);
181
187
  return _.map(deviceIdentifiers, (deviceIdentifier) => this.isApplicationInstalledOnDevice(deviceIdentifier, {
@@ -247,6 +253,9 @@ class DevicesService extends events_1.EventEmitter {
247
253
  delete this._availableEmulators[emulator.imageIdentifier];
248
254
  this.emit(constants.EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator);
249
255
  }
256
+ /**
257
+ * Starts looking for devices. Any found devices are pushed to "_devices" variable.
258
+ */
250
259
  async detectCurrentlyAttachedDevices(deviceInitOpts) {
251
260
  const options = this.getDeviceLookingOptions(deviceInitOpts);
252
261
  for (const deviceDiscovery of this._allDeviceDiscoveries) {
@@ -315,6 +324,11 @@ class DevicesService extends events_1.EventEmitter {
315
324
  clearInterval(this.emulatorDetectionInterval);
316
325
  }
317
326
  }
327
+ /**
328
+ * Returns device that matches an identifier.
329
+ * The identifier is expected to be the same as the running device declares it (emulator-5554 for android or GUID for ios).
330
+ * @param identifier running emulator or device identifier
331
+ */
318
332
  getDeviceByIdentifier(identifier) {
319
333
  const searchedDevice = _.find(this.getDeviceInstances(), (device) => {
320
334
  if (this.$mobileHelper.isApplePlatform(device.deviceInfo.platform) &&
@@ -330,6 +344,9 @@ class DevicesService extends events_1.EventEmitter {
330
344
  }
331
345
  return searchedDevice;
332
346
  }
347
+ /**
348
+ * Starts looking for running devices. All found devices are pushed to _devices variable.
349
+ */
333
350
  async startLookingForDevices(deviceInitOpts) {
334
351
  this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
335
352
  if (this._platform) {
@@ -339,10 +356,20 @@ class DevicesService extends events_1.EventEmitter {
339
356
  await this.detectCurrentlyAvailableEmulators();
340
357
  await this.startDeviceDetectionInterval(deviceInitOpts);
341
358
  }
359
+ /**
360
+ * Returns device depending on the passed index.
361
+ * The index refers to assigned number to listed devices by ns device command.
362
+ * @param index assigned device number
363
+ */
342
364
  getDeviceByIndex(index) {
343
365
  this.validateIndex(index - 1);
344
366
  return this.getDeviceInstances()[index - 1];
345
367
  }
368
+ /**
369
+ * Returns running device for specified --device <DeviceId>.
370
+ * Method expects running devices.
371
+ * @param deviceOption parameter passed by the user to --device flag. Can be name, identifier or imageIdentifier.
372
+ */
346
373
  async getDevice(deviceOption) {
347
374
  let device = null;
348
375
  if (!device) {
@@ -362,6 +389,11 @@ class DevicesService extends events_1.EventEmitter {
362
389
  }
363
390
  return device;
364
391
  }
392
+ /**
393
+ * Method runs action for a --device (value), specified by the user.
394
+ * @param action action to be executed if canExecute returns true
395
+ * @param canExecute predicate to decide whether the command can be ran
396
+ */
365
397
  async executeOnDevice(action, canExecute) {
366
398
  if (!canExecute || canExecute(this._device)) {
367
399
  return {
@@ -370,6 +402,11 @@ class DevicesService extends events_1.EventEmitter {
370
402
  };
371
403
  }
372
404
  }
405
+ /**
406
+ * Executes passed action for each found device.
407
+ * @param action action to be executed if canExecute returns true
408
+ * @param canExecute predicate to decide whether the command can be ran
409
+ */
373
410
  async executeOnAllConnectedDevices(action, canExecute) {
374
411
  const devices = this.filterDevicesByPlatform();
375
412
  const sortedDevices = _.sortBy(devices, (device) => device.deviceInfo.platform);
@@ -421,6 +458,12 @@ class DevicesService extends events_1.EventEmitter {
421
458
  });
422
459
  });
423
460
  }
461
+ /**
462
+ * Runs the passed action if the predicate "canExecute" returns true
463
+ * @param action action to be executed if canExecute returns true.
464
+ * @param canExecute predicate to decide whether the command can be ran
465
+ * @param options all possible options that can be passed to the command.
466
+ */
424
467
  async execute(action, canExecute, options) {
425
468
  assert.ok(this._isInitialized, "Devices services not initialized!");
426
469
  if (this.hasDevices) {
@@ -429,6 +472,7 @@ class DevicesService extends events_1.EventEmitter {
429
472
  this.$mobileHelper.isiOSPlatform(this._platform) &&
430
473
  this.$options.emulator &&
431
474
  !this.isOnlyiOSSimultorRunning()) {
475
+ // Executes the command only on iOS simulator
432
476
  const originalCanExecute = canExecute;
433
477
  canExecute = (dev) => this.isiOSSimulator(dev) &&
434
478
  (!originalCanExecute || !!originalCanExecute(dev));
@@ -452,6 +496,11 @@ class DevicesService extends events_1.EventEmitter {
452
496
  }
453
497
  }
454
498
  }
499
+ /**
500
+ * Starts emulator or simulator if necessary depending on --device or --emulator flags.
501
+ * If no options are passed runs default emulator/simulator if no devices are connected.
502
+ * @param deviceInitOpts mainly contains information about --emulator and --deviceId flags.
503
+ */
455
504
  async startEmulatorIfNecessary(deviceInitOpts) {
456
505
  if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
457
506
  this.$errors.fail(`--device and --emulator are incompatible options.
@@ -460,6 +509,7 @@ class DevicesService extends events_1.EventEmitter {
460
509
  if (deviceInitOpts &&
461
510
  deviceInitOpts.platform &&
462
511
  !deviceInitOpts.skipEmulatorStart) {
512
+ // are there any running devices
463
513
  this._platform = deviceInitOpts.platform;
464
514
  try {
465
515
  await this.startLookingForDevices(deviceInitOpts);
@@ -485,9 +535,11 @@ class DevicesService extends events_1.EventEmitter {
485
535
  }
486
536
  async _startEmulatorIfNecessary(data) {
487
537
  const deviceInstances = this.getDeviceInstances();
538
+ //if no --device is passed and no devices are found, the default emulator is started
488
539
  if (!data.deviceId && _.isEmpty(deviceInstances)) {
489
540
  return this.startEmulatorCore(data);
490
541
  }
542
+ //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)
491
543
  if (data.deviceId) {
492
544
  if (!helpers.isNumberWithoutExponent(data.deviceId)) {
493
545
  const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
@@ -496,6 +548,7 @@ class DevicesService extends events_1.EventEmitter {
496
548
  }
497
549
  }
498
550
  }
551
+ // make sure if the target platform is visionOS we don't try to run it on an already running iOS simulator...
499
552
  if (data.platform === this.$devicePlatformsConstants.visionOS &&
500
553
  deviceInstances.length) {
501
554
  const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform ===
@@ -504,6 +557,7 @@ class DevicesService extends events_1.EventEmitter {
504
557
  return this.startEmulatorCore(data);
505
558
  }
506
559
  }
560
+ // if only emulator flag is passed and no other emulators are running, start default emulator
507
561
  if (data.emulator && deviceInstances.length) {
508
562
  const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
509
563
  if (!runningDeviceInstance) {
@@ -511,6 +565,12 @@ class DevicesService extends events_1.EventEmitter {
511
565
  }
512
566
  }
513
567
  }
568
+ /**
569
+ * Takes care of gathering information about all running devices.
570
+ * Sets "_isInitialized" to true after infomation is present.
571
+ * Method expects running devices.
572
+ * @param data mainly contains information about --emulator and --deviceId flags.
573
+ */
514
574
  async initialize(data) {
515
575
  if (!this._deviceInitializePromise) {
516
576
  this._deviceInitializePromise = this.initializeCore(data);
@@ -519,6 +579,7 @@ class DevicesService extends events_1.EventEmitter {
519
579
  await this._deviceInitializePromise;
520
580
  }
521
581
  catch (err) {
582
+ // In case the initalization fails, we want to allow calling `initlialize` again with other arguments for example, so remove the cached promise value.
522
583
  this.$logger.trace(`Error while initializing devicesService: ${err}`);
523
584
  this._deviceInitializePromise = null;
524
585
  throw err;
@@ -542,6 +603,7 @@ class DevicesService extends events_1.EventEmitter {
542
603
  deviceInitOpts = deviceInitOpts || {};
543
604
  this._data = deviceInitOpts;
544
605
  if (!deviceInitOpts.skipEmulatorStart) {
606
+ // TODO: Remove from here as it calls startLookingForDevices, so we double the calls to specific device detection services
545
607
  await this.startEmulatorIfNecessary(deviceInitOpts);
546
608
  }
547
609
  const platform = deviceInitOpts.platform;
@@ -572,6 +634,7 @@ class DevicesService extends events_1.EventEmitter {
572
634
  await this.startLookingForDevices(deviceLookingOptions);
573
635
  }
574
636
  else {
637
+ // platform and deviceId are not specified
575
638
  if (deviceInitOpts.skipInferPlatform) {
576
639
  if (deviceInitOpts.skipDeviceDetectionInterval) {
577
640
  await this.detectCurrentlyAttachedDevices(deviceLookingOptions);
@@ -679,6 +742,11 @@ class DevicesService extends events_1.EventEmitter {
679
742
  }
680
743
  return null;
681
744
  }
745
+ /**
746
+ * Starts emulator for platform and makes sure started devices/emulators/simulators are in _devices array before finishing.
747
+ * @param platform (optional) platform to start emulator/simulator for
748
+ * @param emulatorIdOrName (optional) emulator/simulator image identifier or name
749
+ */
682
750
  async startEmulatorCore(deviceInitOpts = {}) {
683
751
  const { deviceId } = deviceInitOpts;
684
752
  const platform = deviceInitOpts.platform || this._platform;
@@ -802,3 +870,4 @@ __decorate([
802
870
  (0, decorators_1.exported)("devicesService")
803
871
  ], DevicesService.prototype, "getDebuggableViews", null);
804
872
  yok_1.injector.register("devicesService", DevicesService);
873
+ //# sourceMappingURL=devices-service.js.map
@@ -22,6 +22,7 @@ class IOSDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
22
22
  return;
23
23
  }
24
24
  if (this.$mobileHelper.isvisionOSPlatform(options.platform)) {
25
+ // look for ios devices - same logic.
25
26
  options.platform = this.$devicePlatformsConstants.iOS;
26
27
  }
27
28
  await this.$iosDeviceOperations.startLookingForDevices((deviceInfo) => {
@@ -50,3 +51,4 @@ class IOSDeviceDiscovery extends device_discovery_1.DeviceDiscovery {
50
51
  }
51
52
  exports.IOSDeviceDiscovery = IOSDeviceDiscovery;
52
53
  yok_1.injector.register("iOSDeviceDiscovery", IOSDeviceDiscovery);
54
+ //# sourceMappingURL=ios-device-discovery.js.map
@@ -28,12 +28,14 @@ class IOSSimulatorDiscovery extends device_discovery_1.DeviceDiscovery {
28
28
  async checkForDevices() {
29
29
  if (this.$hostInfo.isDarwin) {
30
30
  const currentSimulators = await this.$iOSSimResolver.iOSSim.getRunningSimulators();
31
+ // Remove old simulators
31
32
  _(this.cachedSimulators)
32
33
  .reject((s) => _.some(currentSimulators, (simulator) => simulator &&
33
34
  s &&
34
35
  simulator.id === s.id &&
35
36
  simulator.state === s.state))
36
37
  .each((s) => this.deleteAndRemoveDevice(s));
38
+ // Add new simulators
37
39
  _(currentSimulators)
38
40
  .reject((s) => _.some(this.cachedSimulators, (simulator) => simulator &&
39
41
  s &&
@@ -92,3 +94,4 @@ class IOSSimulatorDiscovery extends device_discovery_1.DeviceDiscovery {
92
94
  }
93
95
  exports.IOSSimulatorDiscovery = IOSSimulatorDiscovery;
94
96
  yok_1.injector.register("iOSSimulatorDiscovery", IOSSimulatorDiscovery);
97
+ //# sourceMappingURL=ios-simulator-discovery.js.map
@@ -89,3 +89,4 @@ class MobileHelper {
89
89
  exports.MobileHelper = MobileHelper;
90
90
  MobileHelper.DEVICE_PATH_SEPARATOR = "/";
91
91
  yok_1.injector.register("mobileHelper", MobileHelper);
92
+ //# sourceMappingURL=mobile-helper.js.map
@@ -53,3 +53,4 @@ class Wp8EmulatorServices {
53
53
  Wp8EmulatorServices.WP8_LAUNCHER = "XapDeployCmd.exe";
54
54
  Wp8EmulatorServices.WP8_LAUNCHER_PATH = "Microsoft SDKs\\Windows Phone\\v8.0\\Tools\\XAP Deployment";
55
55
  yok_1.injector.register("wp8EmulatorServices", Wp8EmulatorServices);
56
+ //# 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
@@ -26,6 +26,7 @@ class Prompter {
26
26
  else {
27
27
  const result = {};
28
28
  _.each(questions, (s) => {
29
+ // Curly brackets needed because s.default() may return false and break the loop
29
30
  result[s.name] = s.default();
30
31
  });
31
32
  return result;
@@ -122,7 +123,9 @@ class Prompter {
122
123
  }
123
124
  muteStdout() {
124
125
  if (helpers.isInteractive()) {
125
- process.stdin.setRawMode(true);
126
+ 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
127
+ // We need to create mute-stream and to pass it as output to ctrlcReader
128
+ // This will prevent the prompter to show the user's text twice on the console
126
129
  this.muteStreamInstance = new MuteStream();
127
130
  this.muteStreamInstance.pipe(process.stdout);
128
131
  this.muteStreamInstance.mute();
@@ -131,6 +134,7 @@ class Prompter {
131
134
  output: this.muteStreamInstance,
132
135
  });
133
136
  this.ctrlcReader.on("SIGINT", () => {
137
+ // enable terminal cursor
134
138
  process.stdout.write("\x1B[?25h");
135
139
  process.exit();
136
140
  });
@@ -140,6 +144,7 @@ class Prompter {
140
144
  if (helpers.isInteractive()) {
141
145
  process.stdin.setRawMode(false);
142
146
  if (this.muteStreamInstance) {
147
+ // 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.
143
148
  this.cleanEventListeners(process.stdout);
144
149
  this.muteStreamInstance.unmute();
145
150
  this.muteStreamInstance = null;
@@ -148,6 +153,8 @@ class Prompter {
148
153
  }
149
154
  }
150
155
  cleanEventListeners(stream) {
156
+ // The events names and listeners names can be found here https://github.com/nodejs/node/blob/master/lib/stream.js
157
+ // 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.
151
158
  const memoryLeakEvents = [
152
159
  {
153
160
  eventName: "close",
@@ -174,3 +181,4 @@ class Prompter {
174
181
  }
175
182
  exports.Prompter = Prompter;
176
183
  yok_1.injector.register("prompter", Prompter);
184
+ //# sourceMappingURL=prompter.js.map
@@ -24,3 +24,4 @@ class Queue {
24
24
  }
25
25
  }
26
26
  exports.Queue = Queue;
27
+ //# 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
@@ -27,12 +27,15 @@ class AutoCompletionService {
27
27
  get shellProfiles() {
28
28
  return [
29
29
  this.getHomePath(".bashrc"),
30
- this.getHomePath(".zshrc"),
30
+ this.getHomePath(".zshrc"), // zsh - http://www.acm.uiuc.edu/workshops/zsh/startup_files.html
31
31
  ];
32
32
  }
33
33
  get cliRunCommandsFile() {
34
34
  let cliRunCommandsFile = this.getHomePath(util.format(".%src", this.$staticConfig.CLIENT_NAME.toLowerCase()));
35
35
  if (this.$hostInfo.isWindows) {
36
+ // on Windows bash, file is incorrectly written as C:\Users\<username>, which leads to errors when trying to execute the script:
37
+ // $ source ~/.bashrc
38
+ // sh.exe": C:Usersusername.appbuilderrc: No such file or directory
36
39
  cliRunCommandsFile = cliRunCommandsFile.replace(/\\/g, "/");
37
40
  }
38
41
  return cliRunCommandsFile;
@@ -47,7 +50,9 @@ class AutoCompletionService {
47
50
  return new RegExp(util.format("%s[\\s\\S]*%s", AutoCompletionService.GENERATED_TABTAB_COMPLETION_START, AutoCompletionService.GENERATED_TABTAB_COMPLETION_END));
48
51
  }
49
52
  removeObsoleteAutoCompletion() {
53
+ // In previous releases we were writing directly in .bash_profile, .bashrc, .zshrc and .profile - remove this old code
50
54
  const shellProfilesToBeCleared = this.shellProfiles;
55
+ // Add .profile only here as we do not want new autocompletion in this file, but we have to remove our old code from it.
51
56
  shellProfilesToBeCleared.push(this.getHomePath(".profile"));
52
57
  shellProfilesToBeCleared.forEach((file) => {
53
58
  try {
@@ -100,6 +105,7 @@ class AutoCompletionService {
100
105
  this.isNewAutoCompletionEnabledInFile(filePath) ||
101
106
  this.isObsoleteAutoCompletionEnabledInFile(filePath);
102
107
  if (!result) {
108
+ // break each
103
109
  return false;
104
110
  }
105
111
  });
@@ -125,6 +131,7 @@ class AutoCompletionService {
125
131
  _.each(this.shellProfiles, (shellProfile) => {
126
132
  result = this.isObsoleteAutoCompletionEnabledInFile(shellProfile);
127
133
  if (!result) {
134
+ // break each
128
135
  return false;
129
136
  }
130
137
  });
@@ -163,6 +170,8 @@ class AutoCompletionService {
163
170
  }
164
171
  catch (err) {
165
172
  this.$logger.info("Unable to update %s. Command-line completion might not work.", fileName);
173
+ // When npm is installed with sudo, in some cases the installation cannot write to shell profiles
174
+ // Advise the user how to enable autocompletion after the installation is completed.
166
175
  if ((err.code === "EPERM" || err.code === "EACCES") &&
167
176
  !this.$hostInfo.isWindows &&
168
177
  process.env.SUDO_USER) {
@@ -183,6 +192,7 @@ class AutoCompletionService {
183
192
  }
184
193
  }
185
194
  catch (err) {
195
+ // If file does not exist, autocompletion was not working for it, so ignore this error.
186
196
  if (err.code !== "ENOENT") {
187
197
  this.$logger.info("Failed to update %s. Auto-completion may still work or work incorrectly. ", fileName);
188
198
  this.$logger.info(err);
@@ -214,6 +224,7 @@ class AutoCompletionService {
214
224
  this.$fs.writeFile(filePath, newText);
215
225
  }
216
226
  }
227
+ // The generated seems to be inconsistent in it's start/end markers so adding our own.
217
228
  this.$fs.appendFile(filePath, `\n${AutoCompletionService.GENERATED_TABTAB_COMPLETION_START}\n`);
218
229
  await this.$childProcess.exec(`"${process.argv[0]}" "${pathToExecutableFile}" completion_generate_script >> "${filePath}"`);
219
230
  this.$fs.appendFile(filePath, this.completionAliasDefinition);
@@ -250,3 +261,4 @@ __decorate([
250
261
  (0, decorators_1.cache)()
251
262
  ], AutoCompletionService.prototype, "completionShellScriptContent", null);
252
263
  yok_1.injector.register("autoCompletionService", AutoCompletionService);
264
+ //# sourceMappingURL=auto-completion-service.js.map
@@ -28,7 +28,7 @@ class CancellationService {
28
28
  .watch(triggerFile, { ignoreInitial: true })
29
29
  .on("unlink", (filePath) => {
30
30
  this.$logger.info(`Exiting process as the file ${filePath} has been deleted. Probably reinstalling CLI while there's a working instance.`);
31
- process.exit(132);
31
+ process.exit(132 /* ErrorCodes.DELETED_KILL_FILE */);
32
32
  });
33
33
  if (watcher) {
34
34
  this.watches[name] = watcher;
@@ -54,3 +54,4 @@ class CancellationService {
54
54
  }
55
55
  }
56
56
  yok_1.injector.register("cancellation", CancellationService);
57
+ //# sourceMappingURL=cancellation.js.map
@@ -38,11 +38,11 @@ class CommandsService {
38
38
  if (!this.$staticConfig.disableAnalytics &&
39
39
  !command.disableAnalytics &&
40
40
  !this.$options.disableAnalytics) {
41
- const analyticsService = this.$injector.resolve("analyticsService");
41
+ const analyticsService = this.$injector.resolve("analyticsService"); // This should be resolved here due to cyclic dependency
42
42
  await analyticsService.checkConsent();
43
43
  const beautifiedCommandName = this.beautifyCommandName(commandName).replace(/\|/g, " ");
44
44
  const googleAnalyticsPageData = {
45
- googleAnalyticsDataType: "pageview",
45
+ googleAnalyticsDataType: "pageview" /* GoogleAnalyticsDataType.Page */,
46
46
  path: beautifiedCommandName,
47
47
  title: beautifiedCommandName,
48
48
  };
@@ -52,10 +52,11 @@ class CommandsService {
52
52
  const shouldExecuteHooks = !this.$staticConfig.disableCommandHooks &&
53
53
  (command.enableHooks === undefined || command.enableHooks === true);
54
54
  if (shouldExecuteHooks) {
55
+ // Handle correctly hierarchical commands
55
56
  const hierarchicalCommandName = this.$injector.buildHierarchicalCommand(commandName, commandArguments);
56
57
  if (hierarchicalCommandName) {
57
- commandName = helpers.stringReplaceAll(hierarchicalCommandName.commandName, "|*", "-");
58
- commandName = helpers.stringReplaceAll(commandName, "|", "-");
58
+ commandName = helpers.stringReplaceAll(hierarchicalCommandName.commandName, "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */, "-" /* CommandsDelimiters.HooksCommand */);
59
+ commandName = helpers.stringReplaceAll(commandName, "|" /* CommandsDelimiters.HierarchicalCommand */, "-" /* CommandsDelimiters.HooksCommand */);
59
60
  }
60
61
  await this.$hooksService.executeBeforeHooks(commandName);
61
62
  }
@@ -100,6 +101,7 @@ class CommandsService {
100
101
  await this.executeCommandAction(commandName, commandArguments, this.executeCommandUnchecked);
101
102
  }
102
103
  else {
104
+ // If canExecuteCommand returns false, the command cannot be executed or there's no such command at all.
103
105
  const command = this.$injector.resolveCommand(commandName);
104
106
  if (command) {
105
107
  let commandWithArgs = commandName;
@@ -115,12 +117,15 @@ class CommandsService {
115
117
  const command = this.$injector.resolveCommand(commandName);
116
118
  const beautifiedName = helpers.stringReplaceAll(commandName, "|", " ");
117
119
  if (command) {
120
+ // Verify command is enabled
118
121
  if (command.isDisabled) {
119
122
  this.$errors.fail("This command is not applicable to your environment.");
120
123
  }
124
+ // If command wants to handle canExecute logic on its own.
121
125
  if (command.canExecute) {
122
126
  return await command.canExecute(commandArguments);
123
127
  }
128
+ // First part of hierarchical commands should be validated in specific way.
124
129
  if (await this.$injector.isValidHierarchicalCommand(commandName, commandArguments)) {
125
130
  return true;
126
131
  }
@@ -132,8 +137,8 @@ class CommandsService {
132
137
  }
133
138
  const commandInfo = {
134
139
  inputStrings: [commandName, ...commandArguments],
135
- commandDelimiter: "|",
136
- defaultCommandDelimiter: "|*",
140
+ commandDelimiter: "|" /* CommandsDelimiters.HierarchicalCommand */,
141
+ defaultCommandDelimiter: "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */,
137
142
  };
138
143
  const extensionData = await this.$extensibilityService.getExtensionNameWhereCommandIsRegistered(commandInfo);
139
144
  if (extensionData) {
@@ -149,11 +154,13 @@ class CommandsService {
149
154
  async validateMandatoryParams(commandArguments, mandatoryParams) {
150
155
  const commandArgsHelper = new CommandArgumentsValidationHelper(true, commandArguments);
151
156
  if (mandatoryParams.length > 0) {
157
+ // If command has more mandatory params than the passed ones, we shouldn't execute it
152
158
  if (mandatoryParams.length > commandArguments.length) {
153
159
  const customErrorMessages = _.map(mandatoryParams, (mp) => mp.errorMessage);
154
160
  customErrorMessages.splice(0, 0, "You need to provide all the required parameters.");
155
161
  this.$errors.failWithHelp(customErrorMessages.join(os_1.EOL));
156
162
  }
163
+ // If we reach here, the commandArguments are at least as much as mandatoryParams. Now we should verify that we have each of them.
157
164
  for (let mandatoryParamIndex = 0; mandatoryParamIndex < mandatoryParams.length; ++mandatoryParamIndex) {
158
165
  const mandatoryParam = mandatoryParams[mandatoryParamIndex];
159
166
  let argument = null;
@@ -180,12 +187,14 @@ class CommandsService {
180
187
  if (!commandArgsHelper.isValid) {
181
188
  return false;
182
189
  }
190
+ // Command doesn't have any allowedParameters
183
191
  if (!command.allowedParameters || command.allowedParameters.length === 0) {
184
192
  if (commandArguments.length > 0) {
185
193
  this.$errors.failWithHelp("This command doesn't accept parameters.");
186
194
  }
187
195
  }
188
196
  else {
197
+ // Exclude mandatory params, we've already checked them
189
198
  const unverifiedAllowedParams = command.allowedParameters.filter((param) => !param.mandatory);
190
199
  for (let remainingArgsIndex = 0; remainingArgsIndex < commandArgsHelper.remainingArguments.length; ++remainingArgsIndex) {
191
200
  const argument = commandArgsHelper.remainingArguments[remainingArgsIndex];
@@ -199,6 +208,7 @@ class CommandsService {
199
208
  }
200
209
  if (parameter) {
201
210
  const index = unverifiedAllowedParams.indexOf(parameter);
211
+ // Remove the matched parameter from unverifiedAllowedParams collection, so it will not be used to verify another argument.
202
212
  unverifiedAllowedParams.splice(index, 1);
203
213
  }
204
214
  else {
@@ -243,3 +253,4 @@ class CommandsService {
243
253
  }
244
254
  exports.CommandsService = CommandsService;
245
255
  yok_1.injector.register("commandsService", CommandsService);
256
+ //# sourceMappingURL=commands-service.js.map