nativescript 9.0.4-dev.1 → 9.0.4-dev.3

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 +16 -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
@@ -19,6 +19,7 @@ class ProjectData {
19
19
  this.warnProjectId();
20
20
  return this.projectIdentifiers.ios;
21
21
  }
22
+ //just in case hook/extension modifies it.
22
23
  set projectId(identifier) {
23
24
  this.warnProjectId();
24
25
  this.projectIdentifiers.ios = identifier;
@@ -44,6 +45,7 @@ class ProjectData {
44
45
  return;
45
46
  }
46
47
  projectDir = projectDir || this.$projectHelper.projectDir;
48
+ // If no project found, projectDir should be null
47
49
  if (projectDir) {
48
50
  const projectFilePath = this.getProjectFilePath(projectDir);
49
51
  if (this.$fs.exists(projectFilePath)) {
@@ -116,6 +118,7 @@ class ProjectData {
116
118
  errorInvalidProject(projectDir) {
117
119
  const currentDir = path.resolve(".");
118
120
  this.$logger.trace(`Unable to find project. projectDir: ${projectDir}, options.path: ${this.$options.path}, ${currentDir}`);
121
+ // This is the case when no project file found
119
122
  this.$errors.fail("No project found at or above '%s' and neither was a --path specified.", projectDir || this.$options.path || currentDir);
120
123
  }
121
124
  getProjectFilePath(projectDir) {
@@ -131,6 +134,10 @@ class ProjectData {
131
134
  return this.nsConfig[constants.CONFIG_NS_APP_RESOURCES_ENTRY];
132
135
  }
133
136
  return constants.APP_RESOURCES_FOLDER_NAME;
137
+ // return path.join(
138
+ // this.getAppDirectoryRelativePath(),
139
+ // constants.APP_RESOURCES_FOLDER_NAME
140
+ // );
134
141
  }
135
142
  getAppDirectoryPath(projectDir) {
136
143
  const appRelativePath = this.getAppDirectoryRelativePath();
@@ -144,6 +151,7 @@ class ProjectData {
144
151
  return constants.SRC_DIR;
145
152
  }
146
153
  else {
154
+ // legacy project setup often uses app folder
147
155
  return constants.APP_FOLDER_NAME;
148
156
  }
149
157
  }
@@ -201,6 +209,9 @@ class ProjectData {
201
209
  }
202
210
  }
203
211
  exports.ProjectData = ProjectData;
212
+ /**
213
+ * NOTE: Order of the elements is important as the TypeScript dependencies are commonly included in Angular project as well.
214
+ */
204
215
  ProjectData.PROJECT_TYPES = [
205
216
  {
206
217
  type: constants.ProjectTypes.JsFlavorName,
@@ -238,3 +249,4 @@ __decorate([
238
249
  (0, decorators_1.cache)()
239
250
  ], ProjectData.prototype, "warnProjectId", null);
240
251
  yok_1.injector.register("projectData", ProjectData, true);
252
+ //# sourceMappingURL=project-data.js.map
@@ -44,3 +44,4 @@ class ProjectFilesProvider extends project_files_provider_base_1.ProjectFilesPro
44
44
  exports.ProjectFilesProvider = ProjectFilesProvider;
45
45
  ProjectFilesProvider.INTERNAL_NONPROJECT_FILES = ["**/*.ts"];
46
46
  yok_1.injector.register("projectFilesProvider", ProjectFilesProvider);
47
+ //# sourceMappingURL=project-files-provider.js.map
@@ -20,3 +20,4 @@ class LiveSyncServiceResolver {
20
20
  }
21
21
  exports.LiveSyncServiceResolver = LiveSyncServiceResolver;
22
22
  yok_1.injector.register("liveSyncServiceResolver", LiveSyncServiceResolver);
23
+ //# sourceMappingURL=livesync-service-resolver.js.map
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // NOTE: This file is used to track data in a separate process.
4
+ // The instances here are not shared with the ones in main CLI process.
3
5
  const fs = require("fs");
4
6
  const analytics_broker_1 = require("./analytics-broker");
5
7
  const file_log_service_1 = require("../../detached-processes/file-log-service");
@@ -9,6 +11,7 @@ if (!pathToBootstrap || !fs.existsSync(pathToBootstrap)) {
9
11
  throw new Error("Invalid path to bootstrap.");
10
12
  }
11
13
  const logFile = process.argv[3];
14
+ // After requiring the bootstrap we can use $injector
12
15
  require(pathToBootstrap);
13
16
  const analyticsLoggingService = yok_1.injector.resolve(file_log_service_1.FileLogService, { logFile });
14
17
  analyticsLoggingService.logData({ message: "Initializing AnalyticsBroker." });
@@ -38,15 +41,15 @@ process.on("message", async (data) => {
38
41
  analyticsLoggingService.logData({
39
42
  message: `analytics-broker-process received message of type: ${JSON.stringify(data)}`,
40
43
  });
41
- if (data.type === "FinishTracking") {
44
+ if (data.type === "FinishTracking" /* TrackingTypes.FinishTracking */) {
42
45
  await finishTracking();
43
46
  if (process.connected) {
44
47
  analyticsLoggingService.logData({
45
- message: `analytics-broker-process will send ${"ProcessFinishedTasks"} message`,
48
+ message: `analytics-broker-process will send ${"ProcessFinishedTasks" /* DetachedProcessMessages.ProcessFinishedTasks */} message`,
46
49
  });
47
- process.send("ProcessFinishedTasks", null, null, () => {
50
+ process.send("ProcessFinishedTasks" /* DetachedProcessMessages.ProcessFinishedTasks */, null, null, () => {
48
51
  analyticsLoggingService.logData({
49
- message: `analytics-broker-process sent ${"ProcessFinishedTasks"} message and will exit gracefully now`,
52
+ message: `analytics-broker-process sent ${"ProcessFinishedTasks" /* DetachedProcessMessages.ProcessFinishedTasks */} message and will exit gracefully now`,
50
53
  });
51
54
  killCurrentProcessGracefully();
52
55
  });
@@ -63,6 +66,7 @@ process.on("disconnect", async () => {
63
66
  killCurrentProcessGracefully();
64
67
  });
65
68
  analyticsLoggingService.logData({
66
- message: `analytics-broker-process will send ${"ProcessReadyToReceive"} message`,
69
+ message: `analytics-broker-process will send ${"ProcessReadyToReceive" /* DetachedProcessMessages.ProcessReadyToReceive */} message`,
67
70
  });
68
- process.send("ProcessReadyToReceive");
71
+ process.send("ProcessReadyToReceive" /* DetachedProcessMessages.ProcessReadyToReceive */);
72
+ //# sourceMappingURL=analytics-broker-process.js.map
@@ -29,7 +29,7 @@ class AnalyticsBroker {
29
29
  catch (err) {
30
30
  this.analyticsLoggingService.logData({
31
31
  message: `AnalyticsBroker unable to execute action in sendDataForTracking: ${err}`,
32
- type: "Error",
32
+ type: "Error" /* FileLogMessageType.Error */,
33
33
  });
34
34
  }
35
35
  }
@@ -38,3 +38,4 @@ exports.AnalyticsBroker = AnalyticsBroker;
38
38
  __decorate([
39
39
  (0, decorators_1.cache)()
40
40
  ], AnalyticsBroker.prototype, "getGoogleAnalyticsProvider", null);
41
+ //# sourceMappingURL=analytics-broker.js.map
@@ -34,7 +34,7 @@ class AnalyticsService {
34
34
  async checkConsent() {
35
35
  if (await this.$analyticsSettingsService.canDoRequest()) {
36
36
  const initialTrackFeatureUsageStatus = await this.getStatus(this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME);
37
- let trackFeatureUsage = initialTrackFeatureUsageStatus === "enabled";
37
+ let trackFeatureUsage = initialTrackFeatureUsageStatus === "enabled" /* AnalyticsStatus.enabled */;
38
38
  if ((await this.isNotConfirmed(this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME)) &&
39
39
  (0, helpers_1.isInteractive)()) {
40
40
  const message = `Do you want to help us improve ${this.$analyticsSettingsService.getClientName()} by automatically sending anonymous usage statistics? We will not use this information to identify or contact you.`;
@@ -53,13 +53,13 @@ class AnalyticsService {
53
53
  }
54
54
  async setStatus(settingName, enabled) {
55
55
  this.analyticsStatuses[settingName] = enabled
56
- ? "enabled"
57
- : "disabled";
56
+ ? "enabled" /* AnalyticsStatus.enabled */
57
+ : "disabled" /* AnalyticsStatus.disabled */;
58
58
  await this.$userSettingsService.saveSetting(settingName, enabled.toString());
59
59
  }
60
60
  async isEnabled(settingName) {
61
61
  const analyticsStatus = await this.getStatus(settingName);
62
- return analyticsStatus === "enabled";
62
+ return analyticsStatus === "enabled" /* AnalyticsStatus.enabled */;
63
63
  }
64
64
  getStatusMessage(settingName, jsonFormat, readableSettingName) {
65
65
  if (jsonFormat) {
@@ -70,8 +70,8 @@ class AnalyticsService {
70
70
  async trackAcceptFeatureUsage(settings) {
71
71
  const acceptTracking = !!(settings && settings.acceptTrackFeatureUsage);
72
72
  const googleAnalyticsEventData = {
73
- googleAnalyticsDataType: "event",
74
- action: "Accept Tracking",
73
+ googleAnalyticsDataType: "event" /* GoogleAnalyticsDataType.Event */,
74
+ action: "Accept Tracking" /* TrackActionNames.AcceptTracking */,
75
75
  label: acceptTracking.toString(),
76
76
  };
77
77
  await this.forcefullyTrackInGoogleAnalytics(googleAnalyticsEventData);
@@ -79,7 +79,7 @@ class AnalyticsService {
79
79
  async trackInGoogleAnalytics(gaSettings) {
80
80
  await this.initAnalyticsStatuses();
81
81
  if (!this.$staticConfig.disableAnalytics &&
82
- this.analyticsStatuses[this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME] === "enabled") {
82
+ this.analyticsStatuses[this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME] === "enabled" /* AnalyticsStatus.enabled */) {
83
83
  return this.forcefullyTrackInGoogleAnalytics(gaSettings);
84
84
  }
85
85
  }
@@ -92,6 +92,8 @@ class AnalyticsService {
92
92
  const isForDevice = device ? !device.isEmulator : data.isForDevice;
93
93
  let label = "";
94
94
  label = this.addDataToLabel(label, normalizedPlatform);
95
+ // In some cases (like in case action is Build and platform is Android), we do not know if the deviceType is emulator or device.
96
+ // Just exclude the device_type in this case.
95
97
  if (isForDevice !== null && isForDevice !== undefined) {
96
98
  const deviceType = isForDevice
97
99
  ? constants_1.DeviceTypes.Device
@@ -109,7 +111,7 @@ class AnalyticsService {
109
111
  const customDimensions = {};
110
112
  this.setProjectRelatedCustomDimensions(customDimensions, data.projectDir);
111
113
  const googleAnalyticsEventData = {
112
- googleAnalyticsDataType: "event",
114
+ googleAnalyticsDataType: "event" /* GoogleAnalyticsDataType.Event */,
113
115
  action: data.action,
114
116
  label,
115
117
  customDimensions,
@@ -122,7 +124,7 @@ class AnalyticsService {
122
124
  if (this.brokerProcess && this.brokerProcess.connected) {
123
125
  let timer;
124
126
  const handler = (data) => {
125
- if (data === "ProcessFinishedTasks") {
127
+ if (data === "ProcessFinishedTasks" /* DetachedProcessMessages.ProcessFinishedTasks */) {
126
128
  this.brokerProcess.removeListener("message", handler);
127
129
  clearTimeout(timer);
128
130
  resolve();
@@ -133,7 +135,7 @@ class AnalyticsService {
133
135
  resolve();
134
136
  }, 3000);
135
137
  this.brokerProcess.on("message", handler);
136
- const msg = { type: "FinishTracking" };
138
+ const msg = { type: "FinishTracking" /* TrackingTypes.FinishTracking */ };
137
139
  this.brokerProcess.send(msg, (err) => this.$logger.trace(`Error while sending ${JSON.stringify(msg)}`));
138
140
  }
139
141
  else {
@@ -143,13 +145,13 @@ class AnalyticsService {
143
145
  }
144
146
  forcefullyTrackInGoogleAnalytics(gaSettings) {
145
147
  gaSettings.customDimensions = gaSettings.customDimensions || {};
146
- gaSettings.customDimensions["cd5"] =
148
+ gaSettings.customDimensions["cd5" /* GoogleAnalyticsCustomDimensions.client */] =
147
149
  this.$options.analyticsClient ||
148
- ((0, helpers_1.isInteractive)() ? "CLI" : "Unknown");
150
+ ((0, helpers_1.isInteractive)() ? "CLI" /* AnalyticsClients.Cli */ : "Unknown" /* AnalyticsClients.Unknown */);
149
151
  this.setProjectRelatedCustomDimensions(gaSettings.customDimensions);
150
152
  const googleAnalyticsData = _.merge({
151
- type: "googleAnalyticsData",
152
- category: "CLI",
153
+ type: "googleAnalyticsData" /* TrackingTypes.GoogleAnalyticsData */,
154
+ category: "CLI" /* AnalyticsClients.Cli */,
153
155
  }, gaSettings);
154
156
  this.$logger.trace("Will send the following information to Google Analytics:", googleAnalyticsData);
155
157
  return this.sendMessageToBroker(googleAnalyticsData);
@@ -160,14 +162,15 @@ class AnalyticsService {
160
162
  projectDir = this.$projectHelper.projectDir;
161
163
  }
162
164
  catch (err) {
165
+ // In case there's no project dir here, the above getter will fail.
163
166
  this.$logger.trace("Unable to get the projectDir from projectHelper", err);
164
167
  }
165
168
  }
166
169
  if (projectDir) {
167
170
  const projectData = this.$projectDataService.getProjectData(projectDir);
168
- customDimensions["cd2"] =
171
+ customDimensions["cd2" /* GoogleAnalyticsCustomDimensions.projectType */] =
169
172
  projectData.projectType;
170
- customDimensions["cd9"] =
173
+ customDimensions["cd9" /* GoogleAnalyticsCustomDimensions.isShared */] =
171
174
  projectData.isShared.toString();
172
175
  }
173
176
  return customDimensions;
@@ -205,7 +208,7 @@ class AnalyticsService {
205
208
  }
206
209
  });
207
210
  broker.on("message", (data) => {
208
- if (data === "ProcessReadyToReceive") {
211
+ if (data === "ProcessReadyToReceive" /* DetachedProcessMessages.ProcessReadyToReceive */) {
209
212
  clearTimeout(timeoutId);
210
213
  if (!isSettled) {
211
214
  isSettled = true;
@@ -229,7 +232,7 @@ class AnalyticsService {
229
232
  async sendInfoForTracking(trackingInfo, settingName) {
230
233
  await this.initAnalyticsStatuses();
231
234
  if (!this.$staticConfig.disableAnalytics &&
232
- this.analyticsStatuses[settingName] === "enabled") {
235
+ this.analyticsStatuses[settingName] === "enabled" /* AnalyticsStatus.enabled */) {
233
236
  return this.sendMessageToBroker(trackingInfo);
234
237
  }
235
238
  }
@@ -277,21 +280,21 @@ class AnalyticsService {
277
280
  if (settingValue) {
278
281
  const isEnabled = (0, helpers_1.toBoolean)(settingValue);
279
282
  if (isEnabled) {
280
- this.analyticsStatuses[settingName] = "enabled";
283
+ this.analyticsStatuses[settingName] = "enabled" /* AnalyticsStatus.enabled */;
281
284
  }
282
285
  else {
283
- this.analyticsStatuses[settingName] = "disabled";
286
+ this.analyticsStatuses[settingName] = "disabled" /* AnalyticsStatus.disabled */;
284
287
  }
285
288
  }
286
289
  else {
287
- this.analyticsStatuses[settingName] = "not confirmed";
290
+ this.analyticsStatuses[settingName] = "not confirmed" /* AnalyticsStatus.notConfirmed */;
288
291
  }
289
292
  }
290
293
  return this.analyticsStatuses[settingName];
291
294
  }
292
295
  async isNotConfirmed(settingName) {
293
296
  const analyticsStatus = await this.getStatus(settingName);
294
- return analyticsStatus === "not confirmed";
297
+ return analyticsStatus === "not confirmed" /* AnalyticsStatus.notConfirmed */;
295
298
  }
296
299
  async getHumanReadableStatusMessage(settingName, readableSettingName) {
297
300
  let status = null;
@@ -305,14 +308,14 @@ class AnalyticsService {
305
308
  }
306
309
  async getJsonStatusMessage(settingName) {
307
310
  const status = await this.getStatus(settingName);
308
- const enabled = status === "not confirmed"
311
+ const enabled = status === "not confirmed" /* AnalyticsStatus.notConfirmed */
309
312
  ? null
310
- : status === "enabled";
313
+ : status === "enabled" /* AnalyticsStatus.enabled */;
311
314
  return JSON.stringify({ enabled });
312
315
  }
313
316
  trackException(exception, message) {
314
317
  const data = {
315
- type: "exception",
318
+ type: "exception" /* TrackingTypes.Exception */,
316
319
  exception,
317
320
  message,
318
321
  };
@@ -328,3 +331,4 @@ __decorate([
328
331
  (0, decorators_1.cache)()
329
332
  ], AnalyticsService.prototype, "initAnalyticsStatuses", null);
330
333
  yok_1.injector.register("analyticsService", AnalyticsService);
334
+ //# sourceMappingURL=analytics-service.js.map
@@ -29,7 +29,7 @@ class GoogleAnalyticsProvider {
29
29
  }
30
30
  catch (e) {
31
31
  this.analyticsLoggingService.logData({
32
- type: "Error",
32
+ type: "Error" /* FileLogMessageType.Error */,
33
33
  message: `Unable to track information ${JSON.stringify(trackInfo)}. Error is: ${e}`,
34
34
  });
35
35
  this.$logger.trace("Analytics exception: ", e);
@@ -61,23 +61,23 @@ class GoogleAnalyticsProvider {
61
61
  const visitor = this.getVisitor(gaTrackingId, proxy);
62
62
  await this.setCustomDimensions(visitor, trackInfo.customDimensions, sessionId);
63
63
  switch (trackInfo.googleAnalyticsDataType) {
64
- case "pageview":
64
+ case "pageview" /* GoogleAnalyticsDataType.Page */:
65
65
  await this.trackPageView(visitor, trackInfo);
66
66
  break;
67
- case "event":
67
+ case "event" /* GoogleAnalyticsDataType.Event */:
68
68
  await this.trackEvent(visitor, trackInfo);
69
69
  break;
70
70
  }
71
71
  }
72
72
  async setCustomDimensions(visitor, customDimensions, sessionId) {
73
73
  const defaultValues = {
74
- ["cd1"]: this.$staticConfig.version,
75
- ["cd6"]: process.version,
76
- ["cd3"]: this.clientId,
77
- ["cd2"]: null,
78
- ["cd9"]: null,
79
- ["cd4"]: sessionId,
80
- ["cd5"]: "Unknown",
74
+ ["cd1" /* GoogleAnalyticsCustomDimensions.cliVersion */]: this.$staticConfig.version,
75
+ ["cd6" /* GoogleAnalyticsCustomDimensions.nodeVersion */]: process.version,
76
+ ["cd3" /* GoogleAnalyticsCustomDimensions.clientID */]: this.clientId,
77
+ ["cd2" /* GoogleAnalyticsCustomDimensions.projectType */]: null,
78
+ ["cd9" /* GoogleAnalyticsCustomDimensions.isShared */]: null,
79
+ ["cd4" /* GoogleAnalyticsCustomDimensions.sessionID */]: sessionId,
80
+ ["cd5" /* GoogleAnalyticsCustomDimensions.client */]: "Unknown" /* AnalyticsClients.Unknown */,
81
81
  };
82
82
  customDimensions = _.merge(defaultValues, customDimensions);
83
83
  _.each(customDimensions, (value, key) => {
@@ -94,7 +94,7 @@ class GoogleAnalyticsProvider {
94
94
  this.analyticsLoggingService.logData({
95
95
  message: `Unable to track event with category: '${trackInfo.category}', action: '${trackInfo.action}', label: '${trackInfo.label}', ` +
96
96
  `value: '${trackInfo.value}' attached page: ${this.currentPage}. Error is: ${err}.`,
97
- type: "Error",
97
+ type: "Error" /* FileLogMessageType.Error */,
98
98
  });
99
99
  reject(err);
100
100
  return;
@@ -117,7 +117,7 @@ class GoogleAnalyticsProvider {
117
117
  if (err) {
118
118
  this.analyticsLoggingService.logData({
119
119
  message: `Unable to track pageview with path '${trackInfo.path}' and title: '${trackInfo.title}' Error is: ${err}.`,
120
- type: "Error",
120
+ type: "Error" /* FileLogMessageType.Error */,
121
121
  });
122
122
  reject(err);
123
123
  return;
@@ -135,3 +135,4 @@ __decorate([
135
135
  (0, decorators_1.cache)()
136
136
  ], GoogleAnalyticsProvider.prototype, "getVisitor", null);
137
137
  yok_1.injector.register("googleAnalyticsProvider", GoogleAnalyticsProvider);
138
+ //# sourceMappingURL=google-analytics-provider.js.map
@@ -62,6 +62,10 @@ class AnalyticsSettingsService {
62
62
  return userAgent;
63
63
  }
64
64
  getMacOSReleaseVersion(osRelease) {
65
+ // https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
66
+ // Each macOS version is labeled 10.<version>, where it looks like <versions> is taken from the major version returned by os.release() (16.x.x for example) and subtracting 4 from it.
67
+ // So the version becomes "10.12" in this case.
68
+ // Could be improved by spawning `system_profiler SPSoftwareDataType` and getting the System Version line from the result.
65
69
  const majorVersion = osRelease && _.first(osRelease.split("."));
66
70
  return majorVersion && `10.${+majorVersion - 4}`;
67
71
  }
@@ -86,3 +90,4 @@ __decorate([
86
90
  (0, decorators_1.exported)("analyticsSettingsService")
87
91
  ], AnalyticsSettingsService.prototype, "getUserAgentString", null);
88
92
  yok_1.injector.register("analyticsSettingsService", AnalyticsSettingsService);
93
+ //# sourceMappingURL=analytics-settings-service.js.map
@@ -62,3 +62,4 @@ class AndroidBundleToolService {
62
62
  }
63
63
  exports.AndroidBundleToolService = AndroidBundleToolService;
64
64
  yok_1.injector.register("androidBundleToolService", AndroidBundleToolService);
65
+ //# sourceMappingURL=android-bundle-tool-service.js.map
@@ -18,6 +18,7 @@ class GradleBuildArgsService {
18
18
  if (await this.$analyticsService.isEnabled(this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME)) {
19
19
  args.push("-PgatherAnalyticsData=true");
20
20
  }
21
+ // allow modifying gradle args from a `before-build-task-args` hook
21
22
  await this.$hooksService.executeBeforeHooks("build-task-args", {
22
23
  hookArgs: { args },
23
24
  });
@@ -30,6 +31,7 @@ class GradleBuildArgsService {
30
31
  }
31
32
  getBaseTaskArgs(buildData) {
32
33
  const args = this.getBuildLoggingArgs();
34
+ // ensure we initialize project data
33
35
  this.$projectData.initializeProjectData(buildData.projectDir);
34
36
  args.push(`-PappPath=${this.$projectData.getAppDirectoryPath()}`, `-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`);
35
37
  if (buildData.gradleArgs) {
@@ -61,3 +63,4 @@ class GradleBuildArgsService {
61
63
  }
62
64
  exports.GradleBuildArgsService = GradleBuildArgsService;
63
65
  yok_1.injector.register("gradleBuildArgsService", GradleBuildArgsService);
66
+ //# sourceMappingURL=gradle-build-args-service.js.map
@@ -39,3 +39,4 @@ class GradleBuildService extends events_1.EventEmitter {
39
39
  }
40
40
  exports.GradleBuildService = GradleBuildService;
41
41
  yok_1.injector.register("gradleBuildService", GradleBuildService);
42
+ //# sourceMappingURL=gradle-build-service.js.map
@@ -38,3 +38,4 @@ class GradleCommandService {
38
38
  }
39
39
  exports.GradleCommandService = GradleCommandService;
40
40
  yok_1.injector.register("gradleCommandService", GradleCommandService);
41
+ //# sourceMappingURL=gradle-command-service.js.map
@@ -33,6 +33,7 @@ class AndroidDeviceDebugService extends debug_service_base_1.DebugServiceBase {
33
33
  async debug(debugData, debugOptions) {
34
34
  this._packageName = debugData.applicationIdentifier;
35
35
  const result = await this.debugCore(debugData.applicationIdentifier, debugOptions);
36
+ // TODO: extract this logic outside the debug service
36
37
  if (debugOptions.start && !debugOptions.justlaunch) {
37
38
  const pid = await this.$androidProcessService.getAppProcessId(this.deviceIdentifier, debugData.applicationIdentifier);
38
39
  if (pid) {
@@ -55,6 +56,7 @@ class AndroidDeviceDebugService extends debug_service_base_1.DebugServiceBase {
55
56
  `tcp:${port}`,
56
57
  ]);
57
58
  }
59
+ // TODO: Remove this method and reuse logic from androidProcessService
58
60
  async getForwardedDebugPort(deviceId, packageName) {
59
61
  let port = -1;
60
62
  const forwardsResult = await this.device.adb.executeCommand([
@@ -62,6 +64,7 @@ class AndroidDeviceDebugService extends debug_service_base_1.DebugServiceBase {
62
64
  "--list",
63
65
  ]);
64
66
  const unixSocketName = `${packageName}-inspectorServer`;
67
+ //matches 123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug
65
68
  const regexp = new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${unixSocketName})`, "g");
66
69
  const match = regexp.exec(forwardsResult);
67
70
  if (match) {
@@ -77,6 +80,7 @@ class AndroidDeviceDebugService extends debug_service_base_1.DebugServiceBase {
77
80
  });
78
81
  return port;
79
82
  }
83
+ // TODO: Remove this method and reuse logic from androidProcessService
80
84
  async unixSocketForward(local, remote) {
81
85
  await this.device.adb.executeCommand([
82
86
  "forward",
@@ -102,6 +106,7 @@ class AndroidDeviceDebugService extends debug_service_base_1.DebugServiceBase {
102
106
  async printDebugPort(deviceId, port) {
103
107
  this.$logger.info("device: " + deviceId + " debug port: " + port + "\n");
104
108
  }
109
+ // TODO: extract this logic outside the debug service
105
110
  async validateRunningApp(deviceId, packageName) {
106
111
  if (!(await this.isAppRunning(packageName, deviceId))) {
107
112
  this.$errors.fail(`The application ${packageName} does not appear to be running on ${deviceId} or is not built with debugging enabled. Try starting the application manually.`);
@@ -144,3 +149,4 @@ __decorate([
144
149
  (0, decorators_1.performanceLog)()
145
150
  ], AndroidDeviceDebugService.prototype, "debugCore", null);
146
151
  yok_1.injector.register("androidDeviceDebugService", AndroidDeviceDebugService, false);
152
+ //# sourceMappingURL=android-device-debug-service.js.map
@@ -54,12 +54,15 @@ class AndroidPluginBuildService {
54
54
  async updateManifestContent(oldManifestContent, defaultPackageName) {
55
55
  let xml = await this.getXml(oldManifestContent);
56
56
  let packageName = defaultPackageName;
57
+ // if the manifest file is full-featured and declares settings inside the manifest scope
57
58
  if (xml["manifest"]) {
58
59
  if (xml["manifest"]["$"]["package"]) {
59
60
  packageName = xml["manifest"]["$"]["package"];
60
61
  }
62
+ // set the xml as the value to iterate over its properties
61
63
  xml = xml["manifest"];
62
64
  }
65
+ // if the manifest file doesn't have a <manifest> scope, only the first setting will be picked up
63
66
  const newManifest = { manifest: {} };
64
67
  for (const prop in xml) {
65
68
  newManifest.manifest[prop] = xml[prop];
@@ -132,6 +135,14 @@ class AndroidPluginBuildService {
132
135
  }
133
136
  return result;
134
137
  }
138
+ /**
139
+ * Returns whether the build has completed or not
140
+ * @param {Object} options
141
+ * @param {string} options.pluginName - The name of the plugin. E.g. 'nativescript-barcodescanner'
142
+ * @param {string} options.platformsAndroidDirPath - The path to the 'plugin/src/platforms/android' directory.
143
+ * @param {string} options.aarOutputDir - The path where the aar should be copied after a successful build.
144
+ * @param {string} options.tempPluginDirPath - The path where the android plugin will be built.
145
+ */
135
146
  async buildAar(options) {
136
147
  this.validateOptions(options);
137
148
  const manifestFilePath = this.getManifest(options.platformsAndroidDirPath);
@@ -167,6 +178,7 @@ class AndroidPluginBuildService {
167
178
  return shouldBuildAar;
168
179
  }
169
180
  cleanPluginDir(pluginTempDir) {
181
+ // In case plugin was already built in the current process, we need to clean the old sources as they may break the new build.
170
182
  this.$fs.deleteDirectory(pluginTempDir);
171
183
  this.$fs.ensureDirectoryExists(pluginTempDir);
172
184
  }
@@ -240,6 +252,7 @@ class AndroidPluginBuildService {
240
252
  this.replaceGradleAndroidPluginVersion(buildGradlePath, runtimeGradleVersions.gradleAndroidPluginVersion);
241
253
  this.replaceFileContent(buildGradlePath, "{{pluginName}}", pluginName);
242
254
  this.replaceFileContent(settingsGradlePath, "{{pluginName}}", pluginName);
255
+ // gets the package from the AndroidManifest to use as the namespace or fallback to the `org.nativescript.${shortPluginName}`
243
256
  const shortPluginName = (0, helpers_1.getShortPluginName)(pluginName);
244
257
  const manifestPath = path.join(pluginTempDir, "src", "main", "AndroidManifest.xml");
245
258
  const manifestContent = this.$fs.readText(manifestPath);
@@ -286,6 +299,7 @@ class AndroidPluginBuildService {
286
299
  return runtimeVersion;
287
300
  }
288
301
  getLocalGradleVersions() {
302
+ // try reading from installed runtime first before reading from the npm registry...
289
303
  const installedRuntimePackageJSONPath = (0, resolve_package_path_1.resolvePackageJSONPath)(constants_1.SCOPED_ANDROID_RUNTIME_NAME, {
290
304
  paths: [this.$projectData.projectDir],
291
305
  });
@@ -319,13 +333,23 @@ class AndroidPluginBuildService {
319
333
  if (localVersionInfo) {
320
334
  return localVersionInfo;
321
335
  }
336
+ // fallback to reading from npm...
322
337
  try {
323
338
  let output = await this.$packageManager.view(`${constants_1.SCOPED_ANDROID_RUNTIME_NAME}@${runtimeVersion}`, { version_info: true });
324
339
  output = (_a = output === null || output === void 0 ? void 0 : output["version_info"]) !== null && _a !== void 0 ? _a : output;
325
340
  if (!output) {
341
+ /**
342
+ * fallback to the old 'gradle' key in package.json
343
+ *
344
+ * format:
345
+ *
346
+ * gradle: { version: '6.4', android: '3.6.4' }
347
+ *
348
+ */
326
349
  output = await this.$packageManager.view(`${constants_1.SCOPED_ANDROID_RUNTIME_NAME}@${runtimeVersion}`, { gradle: true });
327
350
  output = (_b = output === null || output === void 0 ? void 0 : output["gradle"]) !== null && _b !== void 0 ? _b : output;
328
351
  const { version, android } = output;
352
+ // covert output to the new format...
329
353
  output = {
330
354
  gradle: version,
331
355
  gradleAndroid: android,
@@ -397,6 +421,10 @@ class AndroidPluginBuildService {
397
421
  this.$errors.fail(`No built aar found at ${pathToBuiltAar}`);
398
422
  }
399
423
  }
424
+ /**
425
+ * @param {Object} options
426
+ * @param {string} options.platformsAndroidDirPath - The path to the 'plugin/src/platforms/android' directory.
427
+ */
400
428
  migrateIncludeGradle(options) {
401
429
  this.validatePlatformsAndroidDirPathOption(options);
402
430
  const includeGradleFilePath = path.join(options.platformsAndroidDirPath, constants_1.INCLUDE_GRADLE_NAME);
@@ -449,8 +477,8 @@ class AndroidPluginBuildService {
449
477
  };
450
478
  if (this.$options.hostProjectPath) {
451
479
  opts.env = {
452
- USER_PROJECT_PLATFORMS_ANDROID: path.resolve((0, process_1.cwd)(), this.$options.hostProjectPath),
453
- ...process.env,
480
+ USER_PROJECT_PLATFORMS_ANDROID: path.resolve((0, process_1.cwd)(), this.$options.hostProjectPath), // TODO: couldn't `hostProjectPath` have an absolute path already?
481
+ ...process.env, // TODO: any other way to pass automatically the current process.env?
454
482
  };
455
483
  }
456
484
  try {
@@ -497,3 +525,4 @@ __decorate([
497
525
  (0, helpers_1.hook)("buildAndroidPlugin")
498
526
  ], AndroidPluginBuildService.prototype, "buildPlugin", null);
499
527
  yok_1.injector.register("androidPluginBuildService", AndroidPluginBuildService);
528
+ //# sourceMappingURL=android-plugin-build-service.js.map