@akylas/nativescript-cli 8.7.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 (531) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +385 -0
  3. package/bin/nativescript +3 -0
  4. package/bin/nativescript.js +3 -0
  5. package/bin/ns +3 -0
  6. package/bin/nsc +3 -0
  7. package/bin/nsc.js +3 -0
  8. package/bin/tns +12 -0
  9. package/bin/tns.cmd +1 -0
  10. package/config/config.json +8 -0
  11. package/config/test-dependencies.json +58 -0
  12. package/config/test-deps-versions-generated.json +1 -0
  13. package/docs/build-jekyll-md.sh +7 -0
  14. package/docs/helpers/favicon.ico +0 -0
  15. package/docs/helpers/logo.png +0 -0
  16. package/docs/man_pages/cloud/cloud-setup.md +29 -0
  17. package/docs/man_pages/device/device-android.md +32 -0
  18. package/docs/man_pages/device/device-ios.md +40 -0
  19. package/docs/man_pages/device/device-list-applications.md +37 -0
  20. package/docs/man_pages/device/device-log.md +37 -0
  21. package/docs/man_pages/device/device-run.md +55 -0
  22. package/docs/man_pages/device/device.md +46 -0
  23. package/docs/man_pages/env-configuration/setup.md +22 -0
  24. package/docs/man_pages/general/autocomplete-disable.md +37 -0
  25. package/docs/man_pages/general/autocomplete-enable.md +37 -0
  26. package/docs/man_pages/general/autocomplete-status.md +35 -0
  27. package/docs/man_pages/general/autocomplete.md +46 -0
  28. package/docs/man_pages/general/clean.md +22 -0
  29. package/docs/man_pages/general/doctor.md +33 -0
  30. package/docs/man_pages/general/error-reporting.md +41 -0
  31. package/docs/man_pages/general/extension-install.md +45 -0
  32. package/docs/man_pages/general/extension-uninstall.md +41 -0
  33. package/docs/man_pages/general/extension.md +35 -0
  34. package/docs/man_pages/general/help.md +39 -0
  35. package/docs/man_pages/general/info.md +33 -0
  36. package/docs/man_pages/general/migrate.md +79 -0
  37. package/docs/man_pages/general/package-manager-get.md +26 -0
  38. package/docs/man_pages/general/package-manager-set.md +29 -0
  39. package/docs/man_pages/general/package-manager.md +25 -0
  40. package/docs/man_pages/general/proxy-clear.md +26 -0
  41. package/docs/man_pages/general/proxy-set.md +45 -0
  42. package/docs/man_pages/general/proxy.md +31 -0
  43. package/docs/man_pages/general/update.md +40 -0
  44. package/docs/man_pages/general/usage-reporting.md +41 -0
  45. package/docs/man_pages/index.html +3 -0
  46. package/docs/man_pages/lib-management/plugin-add.md +42 -0
  47. package/docs/man_pages/lib-management/plugin-build.md +32 -0
  48. package/docs/man_pages/lib-management/plugin-create.md +48 -0
  49. package/docs/man_pages/lib-management/plugin-install.md +42 -0
  50. package/docs/man_pages/lib-management/plugin-remove.md +31 -0
  51. package/docs/man_pages/lib-management/plugin-update.md +41 -0
  52. package/docs/man_pages/lib-management/plugin.md +39 -0
  53. package/docs/man_pages/project/configuration/generate.md +36 -0
  54. package/docs/man_pages/project/configuration/install.md +43 -0
  55. package/docs/man_pages/project/configuration/open-android.md +27 -0
  56. package/docs/man_pages/project/configuration/open-ios.md +31 -0
  57. package/docs/man_pages/project/configuration/open.md +36 -0
  58. package/docs/man_pages/project/configuration/platform-add.md +46 -0
  59. package/docs/man_pages/project/configuration/platform-clean.md +41 -0
  60. package/docs/man_pages/project/configuration/platform-remove.md +41 -0
  61. package/docs/man_pages/project/configuration/platform-update.md +45 -0
  62. package/docs/man_pages/project/configuration/platform.md +29 -0
  63. package/docs/man_pages/project/configuration/prepare.md +49 -0
  64. package/docs/man_pages/project/configuration/resources/resources-generate-icons.md +39 -0
  65. package/docs/man_pages/project/configuration/resources/resources-generate-splashes.md +39 -0
  66. package/docs/man_pages/project/configuration/resources/resources-update.md +35 -0
  67. package/docs/man_pages/project/configuration/resources/resources.md +14 -0
  68. package/docs/man_pages/project/creation/create.md +64 -0
  69. package/docs/man_pages/project/testing/build-android.md +62 -0
  70. package/docs/man_pages/project/testing/build-ios.md +65 -0
  71. package/docs/man_pages/project/testing/build.md +66 -0
  72. package/docs/man_pages/project/testing/debug-android.md +64 -0
  73. package/docs/man_pages/project/testing/debug-ios.md +65 -0
  74. package/docs/man_pages/project/testing/debug.md +67 -0
  75. package/docs/man_pages/project/testing/deploy.md +72 -0
  76. package/docs/man_pages/project/testing/dev-test-android.md +31 -0
  77. package/docs/man_pages/project/testing/dev-test-ios.md +36 -0
  78. package/docs/man_pages/project/testing/preview.md +35 -0
  79. package/docs/man_pages/project/testing/run-android.md +79 -0
  80. package/docs/man_pages/project/testing/run-ios.md +83 -0
  81. package/docs/man_pages/project/testing/run.md +92 -0
  82. package/docs/man_pages/project/testing/test-android.md +46 -0
  83. package/docs/man_pages/project/testing/test-init.md +34 -0
  84. package/docs/man_pages/project/testing/test-ios.md +48 -0
  85. package/docs/man_pages/project/testing/test.md +48 -0
  86. package/docs/man_pages/project/testing/typings.md +52 -0
  87. package/docs/man_pages/publishing/apple-login.md +35 -0
  88. package/docs/man_pages/publishing/appstore-upload.md +52 -0
  89. package/docs/man_pages/publishing/appstore.md +42 -0
  90. package/docs/man_pages/publishing/publish-ios.md +55 -0
  91. package/docs/man_pages/publishing/publish.md +38 -0
  92. package/docs/man_pages/start.md +81 -0
  93. package/lib/.d.ts +494 -0
  94. package/lib/android-tools-info.js +135 -0
  95. package/lib/base-package-manager.js +129 -0
  96. package/lib/bash-scripts/terminateProcess.sh +12 -0
  97. package/lib/bootstrap.js +203 -0
  98. package/lib/bun-package-manager.js +135 -0
  99. package/lib/color.js +10 -0
  100. package/lib/commands/add-platform.js +49 -0
  101. package/lib/commands/apple-login.js +52 -0
  102. package/lib/commands/appstore-list.js +75 -0
  103. package/lib/commands/appstore-upload.js +106 -0
  104. package/lib/commands/build.js +161 -0
  105. package/lib/commands/clean.js +253 -0
  106. package/lib/commands/command-base.js +46 -0
  107. package/lib/commands/config.js +135 -0
  108. package/lib/commands/create-project.js +431 -0
  109. package/lib/commands/debug.js +191 -0
  110. package/lib/commands/deploy.js +78 -0
  111. package/lib/commands/extensibility/install-extension.js +33 -0
  112. package/lib/commands/extensibility/list-extensions.js +40 -0
  113. package/lib/commands/extensibility/uninstall-extension.js +32 -0
  114. package/lib/commands/fonts.js +64 -0
  115. package/lib/commands/generate-assets.js +71 -0
  116. package/lib/commands/generate-help.js +26 -0
  117. package/lib/commands/generate.js +78 -0
  118. package/lib/commands/info.js +26 -0
  119. package/lib/commands/install.js +80 -0
  120. package/lib/commands/list-platforms.js +45 -0
  121. package/lib/commands/migrate.js +44 -0
  122. package/lib/commands/platform-clean.js +54 -0
  123. package/lib/commands/plugin/add-plugin.js +43 -0
  124. package/lib/commands/plugin/build-plugin.js +70 -0
  125. package/lib/commands/plugin/create-plugin.js +175 -0
  126. package/lib/commands/plugin/list-plugins.js +54 -0
  127. package/lib/commands/plugin/remove-plugin.js +52 -0
  128. package/lib/commands/plugin/update-plugin.js +52 -0
  129. package/lib/commands/post-install.js +57 -0
  130. package/lib/commands/prepare.js +63 -0
  131. package/lib/commands/preview.js +93 -0
  132. package/lib/commands/remove-platform.js +40 -0
  133. package/lib/commands/resources/resources-update.js +45 -0
  134. package/lib/commands/run.js +177 -0
  135. package/lib/commands/setup.js +15 -0
  136. package/lib/commands/start.js +33 -0
  137. package/lib/commands/test-init.js +167 -0
  138. package/lib/commands/test.js +146 -0
  139. package/lib/commands/typings.js +180 -0
  140. package/lib/commands/update-platform.js +57 -0
  141. package/lib/commands/update.js +70 -0
  142. package/lib/common/LICENSE +201 -0
  143. package/lib/common/README.md +1084 -0
  144. package/lib/common/bin/common-lib.js +5 -0
  145. package/lib/common/bootstrap.js +97 -0
  146. package/lib/common/child-process.js +217 -0
  147. package/lib/common/codeGeneration/code-entity.js +47 -0
  148. package/lib/common/codeGeneration/code-generation.d.ts +47 -0
  149. package/lib/common/codeGeneration/code-printer.js +48 -0
  150. package/lib/common/command-params.js +45 -0
  151. package/lib/common/commands/analytics.js +81 -0
  152. package/lib/common/commands/autocompletion.js +110 -0
  153. package/lib/common/commands/device/device-log-stream.js +44 -0
  154. package/lib/common/commands/device/get-file.js +54 -0
  155. package/lib/common/commands/device/list-applications.js +42 -0
  156. package/lib/common/commands/device/list-devices.js +150 -0
  157. package/lib/common/commands/device/list-files.js +55 -0
  158. package/lib/common/commands/device/put-file.js +55 -0
  159. package/lib/common/commands/device/run-application.js +46 -0
  160. package/lib/common/commands/device/stop-application.js +42 -0
  161. package/lib/common/commands/device/uninstall-application.js +33 -0
  162. package/lib/common/commands/doctor.js +54 -0
  163. package/lib/common/commands/generate-messages.js +45 -0
  164. package/lib/common/commands/help.js +51 -0
  165. package/lib/common/commands/package-manager-get.js +32 -0
  166. package/lib/common/commands/package-manager-set.js +37 -0
  167. package/lib/common/commands/post-install.js +27 -0
  168. package/lib/common/commands/preuninstall.js +61 -0
  169. package/lib/common/commands/proxy/proxy-base.js +34 -0
  170. package/lib/common/commands/proxy/proxy-clear.js +32 -0
  171. package/lib/common/commands/proxy/proxy-get.js +31 -0
  172. package/lib/common/commands/proxy/proxy-set.js +150 -0
  173. package/lib/common/common-lib.js +5 -0
  174. package/lib/common/constants.js +122 -0
  175. package/lib/common/declarations.d.ts +1713 -0
  176. package/lib/common/decorators.js +201 -0
  177. package/lib/common/definitions/cli-global.d.ts +22 -0
  178. package/lib/common/definitions/commands-service.d.ts +27 -0
  179. package/lib/common/definitions/commands.d.ts +51 -0
  180. package/lib/common/definitions/config.d.ts +33 -0
  181. package/lib/common/definitions/extensibility.d.ts +147 -0
  182. package/lib/common/definitions/google-analytics.d.ts +109 -0
  183. package/lib/common/definitions/json-file-settings-service.d.ts +24 -0
  184. package/lib/common/definitions/key-commands.d.ts +62 -0
  185. package/lib/common/definitions/logger.d.ts +41 -0
  186. package/lib/common/definitions/mobile.d.ts +1499 -0
  187. package/lib/common/definitions/validator.d.ts +8 -0
  188. package/lib/common/definitions/yok.d.ts +56 -0
  189. package/lib/common/dispatchers.js +151 -0
  190. package/lib/common/docs/helpers/basic-extensions-page.html +15 -0
  191. package/lib/common/docs/helpers/basic-page.html +14 -0
  192. package/lib/common/docs/helpers/styles.css +365 -0
  193. package/lib/common/doctor.d.ts +6 -0
  194. package/lib/common/errors.js +206 -0
  195. package/lib/common/file-system.js +441 -0
  196. package/lib/common/header.js +30 -0
  197. package/lib/common/helpers.js +658 -0
  198. package/lib/common/host-info.js +133 -0
  199. package/lib/common/http-client.js +173 -0
  200. package/lib/common/logger/appenders/cli-appender.js +24 -0
  201. package/lib/common/logger/appenders/emit-appender.js +30 -0
  202. package/lib/common/logger/layouts/cli-layout.js +33 -0
  203. package/lib/common/logger/logger.js +199 -0
  204. package/lib/common/messages/messages.interface.d.ts +10 -0
  205. package/lib/common/messages/messages.js +15 -0
  206. package/lib/common/mobile/android/android-application-manager.js +228 -0
  207. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +332 -0
  208. package/lib/common/mobile/android/android-debug-bridge.js +167 -0
  209. package/lib/common/mobile/android/android-device-file-system.js +176 -0
  210. package/lib/common/mobile/android/android-device-hash-service.js +133 -0
  211. package/lib/common/mobile/android/android-device.js +164 -0
  212. package/lib/common/mobile/android/android-emulator-services.js +205 -0
  213. package/lib/common/mobile/android/android-ini-file-parser.js +77 -0
  214. package/lib/common/mobile/android/android-log-filter.js +42 -0
  215. package/lib/common/mobile/android/android-virtual-device-service.js +360 -0
  216. package/lib/common/mobile/android/device-android-debug-bridge.js +48 -0
  217. package/lib/common/mobile/android/genymotion/genymotion-service.js +211 -0
  218. package/lib/common/mobile/android/genymotion/virtualbox-service.js +121 -0
  219. package/lib/common/mobile/android/logcat-helper.js +165 -0
  220. package/lib/common/mobile/application-manager-base.js +136 -0
  221. package/lib/common/mobile/device-emitter.js +61 -0
  222. package/lib/common/mobile/device-log-emitter.js +40 -0
  223. package/lib/common/mobile/device-log-provider-base.js +76 -0
  224. package/lib/common/mobile/device-log-provider.js +126 -0
  225. package/lib/common/mobile/device-platforms-constants.js +22 -0
  226. package/lib/common/mobile/emulator-helper.js +84 -0
  227. package/lib/common/mobile/ios/device/ios-application-manager.js +159 -0
  228. package/lib/common/mobile/ios/device/ios-device-file-system.js +133 -0
  229. package/lib/common/mobile/ios/device/ios-device-operations.js +234 -0
  230. package/lib/common/mobile/ios/device/ios-device.js +153 -0
  231. package/lib/common/mobile/ios/ios-device-base.js +108 -0
  232. package/lib/common/mobile/ios/ios-device-product-name-mapper.js +65 -0
  233. package/lib/common/mobile/ios/ios-log-filter.js +24 -0
  234. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +139 -0
  235. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +23 -0
  236. package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +147 -0
  237. package/lib/common/mobile/ios/simulator/ios-simulator-device.js +106 -0
  238. package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +81 -0
  239. package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +69 -0
  240. package/lib/common/mobile/local-to-device-path-data-factory.js +37 -0
  241. package/lib/common/mobile/log-filter.js +51 -0
  242. package/lib/common/mobile/logging-levels.js +12 -0
  243. package/lib/common/mobile/mobile-core/android-device-discovery.js +91 -0
  244. package/lib/common/mobile/mobile-core/android-emulator-discovery.js +65 -0
  245. package/lib/common/mobile/mobile-core/android-process-service.js +259 -0
  246. package/lib/common/mobile/mobile-core/device-discovery.js +64 -0
  247. package/lib/common/mobile/mobile-core/devices-service.js +854 -0
  248. package/lib/common/mobile/mobile-core/ios-device-discovery.js +63 -0
  249. package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +109 -0
  250. package/lib/common/mobile/mobile-helper.js +102 -0
  251. package/lib/common/mobile/wp8/wp8-emulator-services.js +82 -0
  252. package/lib/common/old.npmignore +12 -0
  253. package/lib/common/opener.js +16 -0
  254. package/lib/common/os-info.js +21 -0
  255. package/lib/common/plist-parser.js +24 -0
  256. package/lib/common/project-helper.js +70 -0
  257. package/lib/common/prompter.js +191 -0
  258. package/lib/common/queue.js +37 -0
  259. package/lib/common/resource-loader.js +25 -0
  260. package/lib/common/resources/messages/errorMessages.json +7 -0
  261. package/lib/common/resources/platform-tools/android/darwin/NOTICE.txt +3407 -0
  262. package/lib/common/resources/platform-tools/android/darwin/adb +0 -0
  263. package/lib/common/resources/platform-tools/android/linux/NOTICE.txt +4451 -0
  264. package/lib/common/resources/platform-tools/android/linux/adb +0 -0
  265. package/lib/common/resources/platform-tools/android/win32/AdbWinApi.dll +0 -0
  266. package/lib/common/resources/platform-tools/android/win32/AdbWinUsbApi.dll +0 -0
  267. package/lib/common/resources/platform-tools/android/win32/NOTICE.txt +4451 -0
  268. package/lib/common/resources/platform-tools/android/win32/adb.exe +0 -0
  269. package/lib/common/resources/platform-tools/android/win32/fastboot.exe +0 -0
  270. package/lib/common/resources/platform-tools/unzip/win32/unzip.exe +0 -0
  271. package/lib/common/services/analytics/google-analytics-custom-dimensions.d.ts +16 -0
  272. package/lib/common/services/auto-completion-service.js +265 -0
  273. package/lib/common/services/cancellation.js +67 -0
  274. package/lib/common/services/commands-service.js +268 -0
  275. package/lib/common/services/help-service.js +252 -0
  276. package/lib/common/services/hooks-service.js +318 -0
  277. package/lib/common/services/ios-notification-service.js +49 -0
  278. package/lib/common/services/json-file-settings-service.js +133 -0
  279. package/lib/common/services/lock-service.js +129 -0
  280. package/lib/common/services/message-contract-generator.js +83 -0
  281. package/lib/common/services/messages-service.js +77 -0
  282. package/lib/common/services/micro-templating-service.js +49 -0
  283. package/lib/common/services/net-service.js +137 -0
  284. package/lib/common/services/project-files-manager.js +100 -0
  285. package/lib/common/services/project-files-provider-base.js +54 -0
  286. package/lib/common/services/proxy-service.js +64 -0
  287. package/lib/common/services/qr.js +39 -0
  288. package/lib/common/services/settings-service.js +42 -0
  289. package/lib/common/services/xcode-select-service.js +62 -0
  290. package/lib/common/utils.js +31 -0
  291. package/lib/common/validators/project-name-validator.js +88 -0
  292. package/lib/common/validators/validation-result.js +16 -0
  293. package/lib/common/vendor/License.txt +4 -0
  294. package/lib/common/vendor/jaro-winkler_distance.js +111 -0
  295. package/lib/common/verify-node-version.js +78 -0
  296. package/lib/common/yok.js +426 -0
  297. package/lib/config.js +137 -0
  298. package/lib/constants-provider.js +12 -0
  299. package/lib/constants.js +350 -0
  300. package/lib/controllers/build-controller.js +133 -0
  301. package/lib/controllers/debug-controller.js +235 -0
  302. package/lib/controllers/deploy-controller.js +38 -0
  303. package/lib/controllers/migrate-controller.js +1114 -0
  304. package/lib/controllers/platform-controller.js +127 -0
  305. package/lib/controllers/prepare-controller.js +353 -0
  306. package/lib/controllers/run-controller.js +525 -0
  307. package/lib/controllers/update-controller-base.js +84 -0
  308. package/lib/controllers/update-controller.js +188 -0
  309. package/lib/data/build-data.js +44 -0
  310. package/lib/data/controller-data-base.js +11 -0
  311. package/lib/data/debug-data.js +6 -0
  312. package/lib/data/platform-data.js +13 -0
  313. package/lib/data/prepare-data.js +46 -0
  314. package/lib/data/run-data.js +11 -0
  315. package/lib/declarations.d.ts +1256 -0
  316. package/lib/definitions/android-bundle-tool-service.d.ts +17 -0
  317. package/lib/definitions/android-plugin-migrator.d.ts +52 -0
  318. package/lib/definitions/build.d.ts +92 -0
  319. package/lib/definitions/cleanup-service.d.ts +79 -0
  320. package/lib/definitions/data.d.ts +7 -0
  321. package/lib/definitions/debug.d.ts +166 -0
  322. package/lib/definitions/deploy.d.ts +3 -0
  323. package/lib/definitions/file-log-service.d.ts +19 -0
  324. package/lib/definitions/files-hash-service.d.ts +35 -0
  325. package/lib/definitions/gradle.d.ts +33 -0
  326. package/lib/definitions/hmr-status-service.d.ts +5 -0
  327. package/lib/definitions/initialize-service.d.ts +11 -0
  328. package/lib/definitions/ios-debugger-port-service.d.ts +29 -0
  329. package/lib/definitions/ios.d.ts +97 -0
  330. package/lib/definitions/ip-service.d.ts +10 -0
  331. package/lib/definitions/livesync-global.d.ts +7 -0
  332. package/lib/definitions/livesync.d.ts +601 -0
  333. package/lib/definitions/lock-service.d.ts +43 -0
  334. package/lib/definitions/log-parser-service.d.ts +14 -0
  335. package/lib/definitions/marking-mode-service.d.ts +11 -0
  336. package/lib/definitions/metadata-filtering-service.d.ts +48 -0
  337. package/lib/definitions/migrate.d.ts +46 -0
  338. package/lib/definitions/nativescript-dev-xcode.d.ts +87 -0
  339. package/lib/definitions/pacote-service.d.ts +50 -0
  340. package/lib/definitions/platform.d.ts +146 -0
  341. package/lib/definitions/plugins.d.ts +75 -0
  342. package/lib/definitions/prepare.d.ts +51 -0
  343. package/lib/definitions/project-changes.d.ts +34 -0
  344. package/lib/definitions/project.d.ts +858 -0
  345. package/lib/definitions/prompter.d.ts +27 -0
  346. package/lib/definitions/qr-code.d.ts +3 -0
  347. package/lib/definitions/require.d.ts +11 -0
  348. package/lib/definitions/run.d.ts +45 -0
  349. package/lib/definitions/start-service.d.ts +15 -0
  350. package/lib/definitions/subscription-service.d.ts +11 -0
  351. package/lib/definitions/system-warnings.d.ts +4 -0
  352. package/lib/definitions/temp-service.d.ts +9 -0
  353. package/lib/definitions/terminal-spinner-service.d.ts +12 -0
  354. package/lib/definitions/update.d.ts +16 -0
  355. package/lib/definitions/xcode.d.ts +12 -0
  356. package/lib/detached-processes/cleanup-js-subprocess.js +62 -0
  357. package/lib/detached-processes/cleanup-process-definitions.d.ts +70 -0
  358. package/lib/detached-processes/cleanup-process.js +281 -0
  359. package/lib/detached-processes/detached-process-enums.d.ts +70 -0
  360. package/lib/detached-processes/file-log-service.js +20 -0
  361. package/lib/device-path-provider.js +60 -0
  362. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +217 -0
  363. package/lib/device-sockets/ios/notification.js +30 -0
  364. package/lib/device-sockets/ios/socket-request-executor.js +56 -0
  365. package/lib/helpers/android-bundle-validator-helper.js +52 -0
  366. package/lib/helpers/deploy-command-helper.js +70 -0
  367. package/lib/helpers/key-command-helper.js +124 -0
  368. package/lib/helpers/livesync-command-helper.js +220 -0
  369. package/lib/helpers/network-connectivity-validator.js +47 -0
  370. package/lib/helpers/options-track-helper.js +88 -0
  371. package/lib/helpers/package-path-helper.js +6 -0
  372. package/lib/helpers/platform-command-helper.js +192 -0
  373. package/lib/helpers/version-validator-helper.js +25 -0
  374. package/lib/key-commands/bootstrap.js +21 -0
  375. package/lib/key-commands/index.js +456 -0
  376. package/lib/nativescript-cli-lib-bootstrap.js +8 -0
  377. package/lib/nativescript-cli-lib.js +5 -0
  378. package/lib/nativescript-cli.js +55 -0
  379. package/lib/node/pbxproj-dom-xcode.js +5 -0
  380. package/lib/node/xcode.js +7 -0
  381. package/lib/node-package-manager.js +156 -0
  382. package/lib/options.js +393 -0
  383. package/lib/package-installation-manager.js +221 -0
  384. package/lib/package-manager.js +184 -0
  385. package/lib/platform-command-param.js +29 -0
  386. package/lib/pnpm-package-manager.js +136 -0
  387. package/lib/project-data.js +237 -0
  388. package/lib/providers/project-files-provider.js +46 -0
  389. package/lib/resolvers/livesync-service-resolver.js +22 -0
  390. package/lib/services/analytics/analytics-broker-process.js +77 -0
  391. package/lib/services/analytics/analytics-broker.js +53 -0
  392. package/lib/services/analytics/analytics-service.js +366 -0
  393. package/lib/services/analytics/analytics.d.ts +55 -0
  394. package/lib/services/analytics/google-analytics-cross-client-custom-dimensions.d.ts +6 -0
  395. package/lib/services/analytics/google-analytics-provider.js +152 -0
  396. package/lib/services/analytics-settings-service.js +104 -0
  397. package/lib/services/android/android-bundle-tool-service.js +81 -0
  398. package/lib/services/android/gradle-build-args-service.js +87 -0
  399. package/lib/services/android/gradle-build-service.js +68 -0
  400. package/lib/services/android/gradle-command-service.js +49 -0
  401. package/lib/services/android-device-debug-service.js +173 -0
  402. package/lib/services/android-plugin-build-service.js +527 -0
  403. package/lib/services/android-project-service.js +600 -0
  404. package/lib/services/android-resources-migration-service.js +104 -0
  405. package/lib/services/apple-portal/apple-portal-application-service.js +82 -0
  406. package/lib/services/apple-portal/apple-portal-cookie-service.js +53 -0
  407. package/lib/services/apple-portal/apple-portal-session-service.js +277 -0
  408. package/lib/services/apple-portal/definitions.d.ts +87 -0
  409. package/lib/services/assets-generation/assets-generation-service.js +178 -0
  410. package/lib/services/build-artifacts-service.js +113 -0
  411. package/lib/services/build-data-service.js +20 -0
  412. package/lib/services/build-info-file-service.js +79 -0
  413. package/lib/services/cleanup-service.js +194 -0
  414. package/lib/services/cocoapods-platform-manager.js +137 -0
  415. package/lib/services/cocoapods-service.js +354 -0
  416. package/lib/services/debug-data-service.js +21 -0
  417. package/lib/services/debug-service-base.js +44 -0
  418. package/lib/services/device/device-install-app-service.js +118 -0
  419. package/lib/services/doctor-service.js +294 -0
  420. package/lib/services/extensibility-service.js +220 -0
  421. package/lib/services/files-hash-service.js +79 -0
  422. package/lib/services/hmr-status-service.js +128 -0
  423. package/lib/services/info-service.js +14 -0
  424. package/lib/services/initialize-service.js +70 -0
  425. package/lib/services/ios/export-options-plist-service.js +131 -0
  426. package/lib/services/ios/ios-signing-service.js +265 -0
  427. package/lib/services/ios/spm-service.js +78 -0
  428. package/lib/services/ios/xcodebuild-args-service.js +163 -0
  429. package/lib/services/ios/xcodebuild-command-service.js +40 -0
  430. package/lib/services/ios/xcodebuild-service.js +93 -0
  431. package/lib/services/ios-debugger-port-service.js +140 -0
  432. package/lib/services/ios-device-debug-service.js +167 -0
  433. package/lib/services/ios-entitlements-service.js +78 -0
  434. package/lib/services/ios-extensions-service.js +63 -0
  435. package/lib/services/ios-log-filter.js +70 -0
  436. package/lib/services/ios-native-target-service.js +108 -0
  437. package/lib/services/ios-project-service.js +851 -0
  438. package/lib/services/ios-provision-service.js +173 -0
  439. package/lib/services/ios-watch-app-service.js +76 -0
  440. package/lib/services/ip-service.js +78 -0
  441. package/lib/services/itmstransporter-service.js +216 -0
  442. package/lib/services/karma-execution.js +16 -0
  443. package/lib/services/livesync/android-device-livesync-service-base.js +68 -0
  444. package/lib/services/livesync/android-device-livesync-service.js +203 -0
  445. package/lib/services/livesync/android-device-livesync-sockets-service.js +198 -0
  446. package/lib/services/livesync/android-livesync-service.js +76 -0
  447. package/lib/services/livesync/android-livesync-tool.js +427 -0
  448. package/lib/services/livesync/android-livesync-tool.md +211 -0
  449. package/lib/services/livesync/device-livesync-service-base.js +69 -0
  450. package/lib/services/livesync/ios-device-livesync-service.js +218 -0
  451. package/lib/services/livesync/ios-livesync-service.js +95 -0
  452. package/lib/services/livesync/livesync-socket.js +14 -0
  453. package/lib/services/livesync/platform-livesync-service-base.js +180 -0
  454. package/lib/services/livesync-process-data-service.js +43 -0
  455. package/lib/services/log-parser-service.js +52 -0
  456. package/lib/services/log-source-map-service.js +235 -0
  457. package/lib/services/marking-mode-service.js +56 -0
  458. package/lib/services/metadata-filtering-service.js +105 -0
  459. package/lib/services/npm-config-service.js +39 -0
  460. package/lib/services/pacote-service.js +109 -0
  461. package/lib/services/performance-service.js +92 -0
  462. package/lib/services/platform/add-platform-service.js +119 -0
  463. package/lib/services/platform/platform-validation-service.js +85 -0
  464. package/lib/services/platform/prepare-native-platform-service.js +87 -0
  465. package/lib/services/platform-environment-requirements.js +87 -0
  466. package/lib/services/platform-project-service-base.js +32 -0
  467. package/lib/services/platforms-data-service.js +31 -0
  468. package/lib/services/plugins-service.js +477 -0
  469. package/lib/services/prepare-data-service.js +21 -0
  470. package/lib/services/project-backup-service.js +114 -0
  471. package/lib/services/project-changes-service.js +274 -0
  472. package/lib/services/project-cleanup-service.js +102 -0
  473. package/lib/services/project-config-service.js +335 -0
  474. package/lib/services/project-data-service.js +478 -0
  475. package/lib/services/project-name-service.js +67 -0
  476. package/lib/services/project-service.js +204 -0
  477. package/lib/services/project-templates-service.js +114 -0
  478. package/lib/services/qr-code-terminal-service.js +20 -0
  479. package/lib/services/require-service.js +11 -0
  480. package/lib/services/start-service.js +116 -0
  481. package/lib/services/temp-service.js +36 -0
  482. package/lib/services/terminal-spinner-service.js +38 -0
  483. package/lib/services/test-execution-service.js +154 -0
  484. package/lib/services/test-initialization-service.js +54 -0
  485. package/lib/services/timeline-profiler-service.js +108 -0
  486. package/lib/services/user-settings-service.js +34 -0
  487. package/lib/services/versions-service.js +196 -0
  488. package/lib/services/watch-ignore-list-service.js +20 -0
  489. package/lib/services/webpack/webpack-compiler-service.js +405 -0
  490. package/lib/services/webpack/webpack.d.ts +227 -0
  491. package/lib/services/xcconfig-service.js +76 -0
  492. package/lib/services/xcproj-service.js +11 -0
  493. package/lib/shared-event-bus.js +7 -0
  494. package/lib/sys-info.js +120 -0
  495. package/lib/tools/config-manipulation/config-transformer.js +201 -0
  496. package/lib/tools/node-modules/node-modules-builder.js +42 -0
  497. package/lib/tools/node-modules/node-modules-dependencies-builder.js +100 -0
  498. package/lib/yarn-package-manager.js +134 -0
  499. package/lib/yarn2-package-manager.js +143 -0
  500. package/package.json +192 -0
  501. package/postinstall.js +10 -0
  502. package/preuninstall.js +14 -0
  503. package/resources/assets/image-definitions.json +655 -0
  504. package/resources/test/example.jasmine.js +6 -0
  505. package/resources/test/example.jasmine.ts +6 -0
  506. package/resources/test/example.mocha.js +9 -0
  507. package/resources/test/example.mocha.ts +9 -0
  508. package/resources/test/example.qunit.js +7 -0
  509. package/resources/test/example.qunit.ts +7 -0
  510. package/resources/test/karma.conf.js +93 -0
  511. package/resources/test/test-main.js +9 -0
  512. package/resources/test/test-main.ts +11 -0
  513. package/resources/test/tsconfig.spec.json +9 -0
  514. package/setup/mac-startup-shell-script.sh +2 -0
  515. package/vendor/aab-tool/LICENSE +202 -0
  516. package/vendor/aab-tool/README.txt +1 -0
  517. package/vendor/aab-tool/bundletool.jar +0 -0
  518. package/vendor/gradle-app/app/build.gradle +1054 -0
  519. package/vendor/gradle-app/app/gradle-helpers/AnalyticsCollector.gradle +48 -0
  520. package/vendor/gradle-app/app/gradle-helpers/BuildToolTask.gradle +50 -0
  521. package/vendor/gradle-app/app/gradle-helpers/CustomExecutionLogger.gradle +52 -0
  522. package/vendor/gradle-app/build.gradle +170 -0
  523. package/vendor/gradle-app/settings.gradle +78 -0
  524. package/vendor/gradle-plugin/LICENSE +995 -0
  525. package/vendor/gradle-plugin/build.gradle +363 -0
  526. package/vendor/gradle-plugin/gradle/wrapper/gradle-wrapper.jar +0 -0
  527. package/vendor/gradle-plugin/gradle/wrapper/gradle-wrapper.properties +6 -0
  528. package/vendor/gradle-plugin/gradle.properties +6 -0
  529. package/vendor/gradle-plugin/gradlew +172 -0
  530. package/vendor/gradle-plugin/gradlew.bat +84 -0
  531. package/vendor/gradle-plugin/settings.gradle +45 -0
@@ -0,0 +1,427 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AndroidLivesyncTool = void 0;
13
+ const path = require("path");
14
+ const _ = require("lodash");
15
+ const crypto = require("crypto");
16
+ const yok_1 = require("../../common/yok");
17
+ const color_1 = require("../../color");
18
+ const PROTOCOL_VERSION_LENGTH_SIZE = 1;
19
+ const PROTOCOL_OPERATION_LENGTH_SIZE = 1;
20
+ const SIZE_BYTE_LENGTH = 1;
21
+ const REPORT_LENGTH = 1;
22
+ const DO_REFRESH_LENGTH = 1;
23
+ const SYNC_OPERATION_TIMEOUT = 60000;
24
+ const TRY_CONNECT_TIMEOUT = 60000;
25
+ const DEFAULT_LOCAL_HOST_ADDRESS = "127.0.0.1";
26
+ class AndroidLivesyncTool {
27
+ constructor($androidProcessService, $errors, $fs, $logger, $mobileHelper, $injector) {
28
+ this.$androidProcessService = $androidProcessService;
29
+ this.$errors = $errors;
30
+ this.$fs = $fs;
31
+ this.$logger = $logger;
32
+ this.$mobileHelper = $mobileHelper;
33
+ this.$injector = $injector;
34
+ this.pendingConnectionData = null;
35
+ this.operationPromises = Object.create(null);
36
+ this.socketError = null;
37
+ this.socketConnection = null;
38
+ }
39
+ connect(configuration) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ if (!configuration.appIdentifier) {
42
+ this.$errors.fail(AndroidLivesyncTool.APP_IDENTIFIER_MISSING_ERROR);
43
+ }
44
+ if (!configuration.appPlatformsPath) {
45
+ this.$errors.fail(AndroidLivesyncTool.APP_PLATFORMS_PATH_MISSING_ERROR);
46
+ }
47
+ if (this.socketConnection) {
48
+ this.$errors.fail(AndroidLivesyncTool.SOCKET_CONNECTION_ALREADY_EXISTS_ERROR);
49
+ }
50
+ if (!configuration.localHostAddress) {
51
+ configuration.localHostAddress =
52
+ process.env.NATIVESCRIPT_LIVESYNC_ADDRESS || DEFAULT_LOCAL_HOST_ADDRESS;
53
+ }
54
+ const connectTimeout = configuration.connectTimeout || TRY_CONNECT_TIMEOUT;
55
+ this.configuration = configuration;
56
+ this.socketError = null;
57
+ const port = yield this.$androidProcessService.forwardFreeTcpToAbstractPort({
58
+ deviceIdentifier: configuration.deviceIdentifier,
59
+ appIdentifier: configuration.appIdentifier,
60
+ abstractPort: `localabstract:${configuration.appIdentifier}-livesync`,
61
+ });
62
+ const connectionResult = yield this.connectEventuallyUntilTimeout(this.createSocket.bind(this, port), connectTimeout, configuration);
63
+ this.handleConnection(connectionResult);
64
+ });
65
+ }
66
+ sendFile(filePath) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ yield this.sendFileHeader(filePath);
69
+ yield this.sendFileContent(filePath);
70
+ });
71
+ }
72
+ sendFiles(filePaths) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ for (const filePath of filePaths) {
75
+ if (this.$fs.getLsStats(filePath).isFile()) {
76
+ if (!this.$fs.exists(filePath)) {
77
+ this.$errors.fail(`${filePath} doesn't exist.`);
78
+ }
79
+ yield this.sendFile(filePath);
80
+ }
81
+ }
82
+ });
83
+ }
84
+ sendDirectory(directoryPath) {
85
+ const list = this.$fs.enumerateFilesInDirectorySync(directoryPath);
86
+ return this.sendFiles(list);
87
+ }
88
+ removeFile(filePath) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ this.verifyActiveConnection();
91
+ const filePathData = this.getFilePathData(filePath);
92
+ const headerBuffer = Buffer.alloc(PROTOCOL_OPERATION_LENGTH_SIZE +
93
+ SIZE_BYTE_LENGTH +
94
+ filePathData.filePathLengthSize +
95
+ filePathData.filePathLengthBytes);
96
+ let offset = 0;
97
+ offset += headerBuffer.write(AndroidLivesyncTool.DELETE_FILE_OPERATION.toString(), offset, PROTOCOL_OPERATION_LENGTH_SIZE);
98
+ offset = headerBuffer.writeInt8(filePathData.filePathLengthSize, offset);
99
+ offset += headerBuffer.write(filePathData.filePathLengthString, offset, filePathData.filePathLengthSize);
100
+ headerBuffer.write(filePathData.relativeFilePath, offset, filePathData.filePathLengthBytes);
101
+ const hash = crypto.createHash("md5").update(headerBuffer).digest();
102
+ yield this.writeToSocket(headerBuffer);
103
+ yield this.writeToSocket(hash);
104
+ });
105
+ }
106
+ removeFiles(files) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ for (const file of files) {
109
+ yield this.removeFile(file);
110
+ }
111
+ });
112
+ }
113
+ generateOperationIdentifier() {
114
+ return crypto.randomBytes(16).toString("hex");
115
+ }
116
+ isOperationInProgress(operationId) {
117
+ return !!this.operationPromises[operationId];
118
+ }
119
+ sendDoSyncOperation(options) {
120
+ options = _.assign({ doRefresh: true, timeout: SYNC_OPERATION_TIMEOUT }, options);
121
+ const { doRefresh, timeout, operationId } = options;
122
+ const id = operationId || this.generateOperationIdentifier();
123
+ const operationPromise = new Promise((resolve, reject) => {
124
+ if (!this.verifyActiveConnection(reject)) {
125
+ return;
126
+ }
127
+ const message = `${AndroidLivesyncTool.DO_SYNC_OPERATION}${id}`;
128
+ const headerBuffer = Buffer.alloc(Buffer.byteLength(message) + DO_REFRESH_LENGTH);
129
+ const socketId = this.socketConnection.uid;
130
+ const doRefreshCode = doRefresh
131
+ ? AndroidLivesyncTool.DO_REFRESH
132
+ : AndroidLivesyncTool.SKIP_REFRESH;
133
+ const offset = headerBuffer.write(message);
134
+ headerBuffer.writeUInt8(doRefreshCode, offset);
135
+ const hash = crypto.createHash("md5").update(headerBuffer).digest();
136
+ this.writeToSocket(headerBuffer)
137
+ .then(() => {
138
+ this.writeToSocket(hash).catch(reject);
139
+ })
140
+ .catch(reject);
141
+ const timeoutId = setTimeout(() => {
142
+ if (this.isOperationInProgress(id)) {
143
+ this.handleSocketError(socketId, "Sync operation is taking too long");
144
+ }
145
+ }, timeout);
146
+ this.operationPromises[id] = {
147
+ resolve,
148
+ reject,
149
+ socketId,
150
+ timeoutId,
151
+ };
152
+ });
153
+ return operationPromise;
154
+ }
155
+ end(error) {
156
+ if (this.socketConnection) {
157
+ const socketUid = this.socketConnection.uid;
158
+ const socket = this.socketConnection;
159
+ error =
160
+ error ||
161
+ this.getErrorWithMessage("Socket connection ended before sync operation is complete.");
162
+ this.cleanState(socketUid);
163
+ socket.end();
164
+ socket.destroy();
165
+ this.rejectPendingSyncOperations(socketUid, error);
166
+ }
167
+ }
168
+ hasConnection() {
169
+ return !!this.socketConnection;
170
+ }
171
+ sendFileHeader(filePath) {
172
+ return __awaiter(this, void 0, void 0, function* () {
173
+ this.verifyActiveConnection();
174
+ const filePathData = this.getFilePathData(filePath);
175
+ const stats = this.$fs.getFsStats(filePathData.filePath);
176
+ const fileContentLengthBytes = stats.size;
177
+ const fileContentLengthString = fileContentLengthBytes.toString();
178
+ const fileContentLengthSize = Buffer.byteLength(fileContentLengthString);
179
+ const headerBuffer = Buffer.alloc(PROTOCOL_OPERATION_LENGTH_SIZE +
180
+ SIZE_BYTE_LENGTH +
181
+ filePathData.filePathLengthSize +
182
+ filePathData.filePathLengthBytes +
183
+ SIZE_BYTE_LENGTH +
184
+ fileContentLengthSize);
185
+ if (filePathData.filePathLengthSize > 255) {
186
+ this.$errors.fail("File name size is longer that 255 digits.");
187
+ }
188
+ else if (fileContentLengthSize > 255) {
189
+ this.$errors.fail("File name size is longer that 255 digits.");
190
+ }
191
+ let offset = 0;
192
+ offset += headerBuffer.write(AndroidLivesyncTool.CREATE_FILE_OPERATION.toString(), offset, PROTOCOL_OPERATION_LENGTH_SIZE);
193
+ offset = headerBuffer.writeUInt8(filePathData.filePathLengthSize, offset);
194
+ offset += headerBuffer.write(filePathData.filePathLengthString, offset, filePathData.filePathLengthSize);
195
+ offset += headerBuffer.write(filePathData.relativeFilePath, offset, filePathData.filePathLengthBytes);
196
+ offset = headerBuffer.writeUInt8(fileContentLengthSize, offset);
197
+ headerBuffer.write(fileContentLengthString, offset, fileContentLengthSize);
198
+ const hash = crypto.createHash("md5").update(headerBuffer).digest();
199
+ yield this.writeToSocket(headerBuffer);
200
+ yield this.writeToSocket(hash);
201
+ });
202
+ }
203
+ sendFileContent(filePath) {
204
+ return new Promise((resolve, reject) => {
205
+ if (!this.verifyActiveConnection(reject)) {
206
+ return;
207
+ }
208
+ const fileStream = this.$fs.createReadStream(filePath);
209
+ const fileHash = crypto.createHash("md5");
210
+ fileStream
211
+ .on("data", (chunk) => {
212
+ fileHash.update(chunk);
213
+ this.writeToSocket(chunk).catch(reject);
214
+ })
215
+ .on("end", () => {
216
+ this.writeToSocket(fileHash.digest())
217
+ .then(() => resolve())
218
+ .catch(reject);
219
+ })
220
+ .on("error", (error) => {
221
+ reject(error);
222
+ });
223
+ });
224
+ }
225
+ createSocket(port) {
226
+ const socket = this.$injector.resolve("LiveSyncSocket");
227
+ socket.connect(port, this.configuration.localHostAddress);
228
+ return socket;
229
+ }
230
+ checkConnectionStatus() {
231
+ if (this.socketConnection === null) {
232
+ const defaultError = this.getErrorWithMessage(AndroidLivesyncTool.NO_SOCKET_CONNECTION_AVAILABLE_ERROR);
233
+ const error = this.socketError || defaultError;
234
+ return error;
235
+ }
236
+ }
237
+ verifyActiveConnection(rejectHandler) {
238
+ const error = this.checkConnectionStatus();
239
+ if (error && rejectHandler) {
240
+ rejectHandler(error);
241
+ return false;
242
+ }
243
+ if (error && !rejectHandler) {
244
+ this.$errors.fail(error.toString());
245
+ }
246
+ return true;
247
+ }
248
+ handleConnection({ socket, data, }) {
249
+ this.socketConnection = socket;
250
+ this.socketConnection.uid = this.generateOperationIdentifier();
251
+ const versionLength = data.readUInt8(0);
252
+ const versionBuffer = data.slice(PROTOCOL_VERSION_LENGTH_SIZE, versionLength + PROTOCOL_VERSION_LENGTH_SIZE);
253
+ const appIdentifierBuffer = data.slice(versionLength + PROTOCOL_VERSION_LENGTH_SIZE, data.length);
254
+ const protocolVersion = versionBuffer.toString();
255
+ const appIdentifier = appIdentifierBuffer.toString();
256
+ this.$logger.trace(`Handle socket connection for app identifier: ${appIdentifier} with protocol version: ${protocolVersion}.`);
257
+ this.protocolVersion = protocolVersion;
258
+ this.socketConnection.on("data", (connectionData) => this.handleData(socket.uid, connectionData));
259
+ this.socketConnection.on("close", (hasError) => this.handleSocketClose(socket.uid, hasError));
260
+ this.socketConnection.on("error", (err) => {
261
+ const error = new Error(`Socket Error:\n${err}`);
262
+ if (this.configuration.errorHandler) {
263
+ this.configuration.errorHandler(error);
264
+ }
265
+ else {
266
+ this.handleSocketError(socket.uid, error.message);
267
+ }
268
+ });
269
+ }
270
+ connectEventuallyUntilTimeout(factory, timeout, configuration) {
271
+ return new Promise((resolve, reject) => {
272
+ let lastKnownError, isConnected = false;
273
+ const connectionTimer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
274
+ if (!isConnected) {
275
+ isConnected = true;
276
+ if (this.pendingConnectionData &&
277
+ this.pendingConnectionData.socketTimer) {
278
+ clearTimeout(this.pendingConnectionData.socketTimer);
279
+ }
280
+ const applicationPid = yield this.$androidProcessService.getAppProcessId(configuration.deviceIdentifier, configuration.appIdentifier);
281
+ if (!applicationPid) {
282
+ this.$logger.trace("In Android LiveSync tool, lastKnownError is: ", lastKnownError);
283
+ this.$logger.info(color_1.color.yellow(`Application ${configuration.appIdentifier} is not running on device ${configuration.deviceIdentifier}.`));
284
+ this.$logger.info(color_1.color.cyan(`This issue may be caused by:
285
+ * crash at startup (try \`ns debug android --debug-brk\` to check why it crashes)
286
+ * different application identifier in your package.json and in your gradle files (check your identifier in \`package.json\` and in all *.gradle files in your App_Resources directory)
287
+ * device is locked
288
+ * manual closing of the application`));
289
+ reject(new Error(`Application ${configuration.appIdentifier} is not running`));
290
+ }
291
+ else {
292
+ reject(lastKnownError ||
293
+ new Error(AndroidLivesyncTool.SOCKET_CONNECTION_TIMED_OUT_ERROR));
294
+ }
295
+ this.pendingConnectionData = null;
296
+ }
297
+ }), timeout);
298
+ this.pendingConnectionData = {
299
+ connectionTimer,
300
+ rejectHandler: reject,
301
+ };
302
+ const tryConnect = () => {
303
+ const socket = factory();
304
+ const tryConnectAfterTimeout = (error) => {
305
+ if (isConnected) {
306
+ this.pendingConnectionData = null;
307
+ return;
308
+ }
309
+ if (typeof error === "boolean" && error) {
310
+ error = new Error("Socket closed due to error");
311
+ }
312
+ lastKnownError = error;
313
+ socket.removeAllListeners();
314
+ this.pendingConnectionData.socketTimer = setTimeout(tryConnect, 1000);
315
+ };
316
+ this.pendingConnectionData.socket = socket;
317
+ socket.once("data", (data) => {
318
+ socket.removeListener("close", tryConnectAfterTimeout);
319
+ socket.removeListener("error", tryConnectAfterTimeout);
320
+ isConnected = true;
321
+ clearTimeout(connectionTimer);
322
+ resolve({ socket, data });
323
+ });
324
+ socket.on("close", tryConnectAfterTimeout);
325
+ socket.on("error", tryConnectAfterTimeout);
326
+ };
327
+ tryConnect();
328
+ });
329
+ }
330
+ handleData(socketId, data) {
331
+ const reportType = data.readUInt8();
332
+ const infoBuffer = data.slice(REPORT_LENGTH, data.length);
333
+ if (reportType === AndroidLivesyncTool.ERROR_REPORT) {
334
+ const errorMessage = infoBuffer.toString();
335
+ this.handleSocketError(socketId, errorMessage);
336
+ }
337
+ else if (reportType === AndroidLivesyncTool.OPERATION_END_REPORT) {
338
+ this.handleSyncEnd({ data: infoBuffer, didRefresh: true });
339
+ }
340
+ else if (reportType === AndroidLivesyncTool.OPERATION_END_NO_REFRESH_REPORT_CODE) {
341
+ this.handleSyncEnd({ data: infoBuffer, didRefresh: false });
342
+ }
343
+ }
344
+ handleSyncEnd({ data, didRefresh, }) {
345
+ const operationId = data.toString();
346
+ const promiseHandler = this.operationPromises[operationId];
347
+ if (promiseHandler) {
348
+ clearTimeout(promiseHandler.timeoutId);
349
+ promiseHandler.resolve({ operationId, didRefresh });
350
+ delete this.operationPromises[operationId];
351
+ }
352
+ }
353
+ handleSocketClose(socketId, hasError) {
354
+ const errorMessage = "Socket closed from server before operation end.";
355
+ this.handleSocketError(socketId, errorMessage);
356
+ }
357
+ handleSocketError(socketId, errorMessage) {
358
+ const error = this.getErrorWithMessage(errorMessage);
359
+ if (this.socketConnection && this.socketConnection.uid === socketId) {
360
+ this.socketError = error;
361
+ this.end(error);
362
+ }
363
+ else {
364
+ this.rejectPendingSyncOperations(socketId, error);
365
+ }
366
+ }
367
+ cleanState(socketId) {
368
+ if (this.socketConnection && this.socketConnection.uid === socketId) {
369
+ this.socketConnection.removeAllListeners();
370
+ this.socketConnection = null;
371
+ }
372
+ }
373
+ rejectPendingSyncOperations(socketId, error) {
374
+ _.keys(this.operationPromises).forEach((operationId) => {
375
+ const operationPromise = this.operationPromises[operationId];
376
+ if (operationPromise.socketId === socketId) {
377
+ clearTimeout(operationPromise.timeoutId);
378
+ operationPromise.reject(error);
379
+ delete this.operationPromises[operationId];
380
+ }
381
+ });
382
+ }
383
+ getErrorWithMessage(errorMessage) {
384
+ const error = new Error(errorMessage);
385
+ error.message = errorMessage;
386
+ return error;
387
+ }
388
+ getFilePathData(filePath) {
389
+ const relativeFilePath = this.resolveRelativePath(filePath);
390
+ const filePathLengthBytes = Buffer.byteLength(relativeFilePath);
391
+ const filePathLengthString = filePathLengthBytes.toString();
392
+ const filePathLengthSize = Buffer.byteLength(filePathLengthString);
393
+ return {
394
+ relativeFilePath,
395
+ filePathLengthBytes,
396
+ filePathLengthString,
397
+ filePathLengthSize,
398
+ filePath,
399
+ };
400
+ }
401
+ resolveRelativePath(filePath) {
402
+ const relativeFilePath = path.relative(this.configuration.appPlatformsPath, filePath);
403
+ return this.$mobileHelper.buildDevicePath(relativeFilePath);
404
+ }
405
+ writeToSocket(data) {
406
+ return __awaiter(this, void 0, void 0, function* () {
407
+ this.verifyActiveConnection();
408
+ const result = yield this.socketConnection.writeAsync(data);
409
+ return result;
410
+ });
411
+ }
412
+ }
413
+ AndroidLivesyncTool.DELETE_FILE_OPERATION = 7;
414
+ AndroidLivesyncTool.CREATE_FILE_OPERATION = 8;
415
+ AndroidLivesyncTool.DO_SYNC_OPERATION = 9;
416
+ AndroidLivesyncTool.ERROR_REPORT = 1;
417
+ AndroidLivesyncTool.OPERATION_END_REPORT = 2;
418
+ AndroidLivesyncTool.OPERATION_END_NO_REFRESH_REPORT_CODE = 3;
419
+ AndroidLivesyncTool.DO_REFRESH = 1;
420
+ AndroidLivesyncTool.SKIP_REFRESH = 0;
421
+ AndroidLivesyncTool.APP_IDENTIFIER_MISSING_ERROR = 'You need to provide "appIdentifier" as a configuration property!';
422
+ AndroidLivesyncTool.APP_PLATFORMS_PATH_MISSING_ERROR = 'You need to provide "appPlatformsPath" as a configuration property!';
423
+ AndroidLivesyncTool.SOCKET_CONNECTION_ALREADY_EXISTS_ERROR = "Socket connection already exists.";
424
+ AndroidLivesyncTool.SOCKET_CONNECTION_TIMED_OUT_ERROR = "Socket connection timed out.";
425
+ AndroidLivesyncTool.NO_SOCKET_CONNECTION_AVAILABLE_ERROR = "No socket connection available.";
426
+ exports.AndroidLivesyncTool = AndroidLivesyncTool;
427
+ yok_1.injector.register("androidLivesyncTool", AndroidLivesyncTool);
@@ -0,0 +1,211 @@
1
+ # android-livesync-tool
2
+ Tool for livesyncing changes to a NativeScript application on Android.
3
+
4
+ ## Usage
5
+ The tool has a few public methods that allow file manipulation to the files of a NativeScript application and provide control for refreshing the application. Restarting the application if necessary should be done by the user of this tool.
6
+
7
+ ### Getting an instance
8
+
9
+ * Example:
10
+ ```JavaScript
11
+ const globalModulesPath = require("global-modules-path");
12
+ const cliPath = globalModulesPath.getPath("nativescript", "tns");
13
+ cli = require(cliPath);
14
+
15
+ const liveSyncTool = cli.androidLivesyncTool;
16
+ ```
17
+
18
+
19
+ ### Calling connect
20
+ Connect method will establish a fresh socket connection with the application. The method takes a configuration as a parameter.
21
+
22
+ * Definition
23
+ ```TypeScript
24
+ interface ILivesyncToolConfiguration {
25
+ appIdentifier: string;
26
+ deviceIdentifier: string;
27
+ appPlatformsPath: string; // path to /c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/
28
+ localHostAddress?: string;
29
+ errorHandler?: any;
30
+ }
31
+
32
+ /**
33
+ * Creates new socket connection.
34
+ * @param configuration - The configuration to the socket connection.
35
+ * @returns {Promise<void>}
36
+ */
37
+ connect(configuration: ILivesyncToolConfiguration): Promise<void>;
38
+ ```
39
+
40
+ * Example:
41
+ ```JavaScript
42
+
43
+ var configuration = {
44
+ appPlatformsPath: "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/",
45
+ fullApplicationName: "com.tns.myapp",
46
+ deviceIdentifier: "aaaaaaaa"
47
+ }
48
+
49
+ liveSyncTool.connect(configuration)
50
+ ```
51
+
52
+ The method returns a promise which is resolved once the connection is established. There is a 30 seconds timeout for establishing the connection. In order the connection to be established successfully, the app must be started.
53
+
54
+ ### Calling sendFile
55
+ Send file will create/update the file with the file content it reads from the filePath that is provided. It will compute the relative path based on the fullApplicationName provided in configuration that was passed to the connect method. This method resolves its promise once the file is written to the output stream of the socket. To be sure the all files have been read and saved by the runtime see sendDoSyncOperation.
56
+
57
+ * Definition
58
+ ```TypeScript
59
+ /**
60
+ * Sends a file through the socket.
61
+ * @param filePath - The full path to the file.
62
+ * @returns {Promise<void>}
63
+ */
64
+ sendFile(filePath: string): Promise<void>;
65
+ ```
66
+
67
+ * Example:
68
+ ```JavaScript
69
+ liveSyncTool.sendFile("/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/index.js");
70
+ ```
71
+
72
+ ### Calling sendFiles
73
+ This method takes an array of file paths as an argument and sends their content to the application.
74
+
75
+ * Definition
76
+ ```TypeScript
77
+ /**
78
+ * Sends files through the socket.
79
+ * @param filePaths - Array of files that will be send by the socket.
80
+ * @returns {Promise<void>}
81
+ */
82
+ sendFiles(filePaths: string[]): Promise<void>;
83
+ ```
84
+
85
+ * Example:
86
+ ```JavaScript
87
+ liveSyncTool.sendFile([
88
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/index.js"
89
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/test.js"
90
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/page.js"
91
+ ]);
92
+ ```
93
+
94
+ ### Calling sendDirectory
95
+ This method takes a path to a directory, enumerates the files recursively and sends the to the device.
96
+
97
+ * Definition
98
+ ```TypeScript
99
+ /**
100
+ * Sends all files from directory by the socket.
101
+ * @param directoryPath - The path to the directory which files will be send by the socket.
102
+ * @returns {Promise<void>}
103
+ */
104
+ sendDirectory(directoryPath: string): Promise<void>;
105
+ ```
106
+
107
+ * Example:
108
+ ```JavaScript
109
+ liveSyncTool.sendDirectory("/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app");
110
+ ```
111
+
112
+ ### Calling removeFile
113
+ When called, removeFile will compute the relative path based on the fullApplicationName provided in configuration that was passed to the connect method and delete the corresponding file/directory on the device.
114
+
115
+ * Definition
116
+ ```TypeScript
117
+ /**
118
+ * Removes file
119
+ * @param filePath - The full path to the file.
120
+ * @returns {Promise<boolean>}
121
+ */
122
+ removeFile(filePath: string): Promise<boolean>;
123
+ ```
124
+
125
+ * Example:
126
+ ```JavaScript
127
+ liveSyncTool.removeFile("/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/index.js");
128
+ ```
129
+
130
+ ### Calling removeFiles
131
+ When called, removeFiles will compute the relative paths based on the fullApplicationName provided in configuration that was passed to the connect method and delete the corresponding files/directories on the device.
132
+
133
+ * Definition
134
+ ```TypeScript
135
+ /**
136
+ * Removes files
137
+ * @param filePaths - Array of files that will be removed.
138
+ * @returns {Promise<boolean[]>}
139
+ */
140
+ removeFiles(filePaths: string[]): Promise<boolean[]>;
141
+ ```
142
+
143
+ * Example:
144
+ ```JavaScript
145
+ liveSyncTool.removeFiles([
146
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/index.js"
147
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/test.js"
148
+ "/c/myprojects/myapp/app/platforms/android/app/src/main/assets/app/page.js"
149
+ ]);
150
+ ```
151
+
152
+ ### Calling sendDoSyncOperation
153
+ When called, sendDoSyncOperation will tell the runtime to execute a script that will refresh the application(this will render changes to the .html and .css files). This method accepts an optional parameter - operationId. It can be used for status check of the operation. The promise returned from this method will be resolved when the application has read the operation and started executing it. This can be used as a sync point - once this promise is resolved, the user can be sure that all other operations have been read and executed by the application. The operation accepts an operation id
154
+
155
+ * Definition
156
+ ```TypeScript
157
+ /**
158
+ * Sends doSyncOperation that will be handled by the runtime.
159
+ * @param doRefresh - Indicates if the application should be restarted. Defaults to true.
160
+ * @param operationId - The identifier of the operation
161
+ * @param timeout - The timeout in milliseconds
162
+ * @returns {Promise<void>}
163
+ */
164
+ sendDoSyncOperation(doRefresh: boolean, timeout?: number, operationId?: string): Promise<IAndroidLivesyncSyncOperationResult>;
165
+ ```
166
+
167
+ * Example:
168
+ ```JavaScript
169
+ const operationId = liveSyncTool.generateOperationIdentifier();
170
+ await liveSyncTool.sendDoSyncOperation(true, 10000, operationId);
171
+ ```
172
+
173
+ ### Calling end
174
+ End will close the current liveSync socket. Any sync operations that are still in progress will be rejected.
175
+
176
+ * Definition
177
+ ```TypeScript
178
+ /**
179
+ * Closes the current socket connection.
180
+ * @param error - Optional error for rejecting pending sync operations
181
+ */
182
+ end(error? Error): void;
183
+ ```
184
+
185
+ * Example:
186
+ ```JavaScript
187
+ liveSyncTool.end();
188
+ ```
189
+
190
+ ## Protocol:
191
+
192
+ Application input
193
+
194
+ |Operation Name(not send) | Operation | Operation id | File Name Length Size | File Name Length | File Name | File Content Length Size | File Content Length | Header Hash | File Content | File hash |
195
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
196
+ | runSync: | 9 | 32bit | | | | | | md5 hash | | |
197
+ | create: | 8 | | 1 | 7 | ./a.txt | 2 | 11 | md5 hash | fileContent | md5 hash |
198
+ | delete: | 7 | | 1 | 3 | ./a | | | md5 hash | | |
199
+
200
+ Application output on connect
201
+
202
+ | Protocol Version length | Protocol Version String | Application Identifier |
203
+ | --- | --- | --- |
204
+ | 1 byte | "0.1.0" | "org.nativescript.myapp" |
205
+
206
+ Application output after connect
207
+
208
+ | Report Name(not send) | Report Code | Payload |
209
+ | --- | --- | --- |
210
+ | Error | 1 | Error message string |
211
+ | Sync end | 2 | Sync operation uid |