nativescript 8.5.3 → 8.5.4-dev.1

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 (227) hide show
  1. package/config/config.json +0 -5
  2. package/lib/.d.ts +2 -37
  3. package/lib/bootstrap.js +1 -12
  4. package/lib/color.js +5 -0
  5. package/lib/commands/build.js +2 -6
  6. package/lib/commands/clean.js +11 -10
  7. package/lib/commands/config.js +6 -5
  8. package/lib/commands/create-project.js +12 -11
  9. package/lib/commands/debug.js +10 -11
  10. package/lib/commands/plugin/list-plugins.js +3 -2
  11. package/lib/commands/post-install.js +3 -5
  12. package/lib/commands/preview.js +4 -3
  13. package/lib/commands/run.js +17 -19
  14. package/lib/commands/test-init.js +14 -15
  15. package/lib/commands/test.js +0 -3
  16. package/lib/commands/update.js +1 -1
  17. package/lib/common/bootstrap.js +0 -1
  18. package/lib/common/child-process.js +3 -3
  19. package/lib/common/codeGeneration/code-printer.js +1 -1
  20. package/lib/common/commands/device/device-log-stream.js +1 -1
  21. package/lib/common/commands/device/list-devices.js +7 -8
  22. package/lib/common/commands/generate-messages.js +1 -1
  23. package/lib/common/constants.js +11 -11
  24. package/lib/common/declarations.d.ts +1 -53
  25. package/lib/common/definitions/commands-service.d.ts +0 -1
  26. package/lib/common/definitions/commands.d.ts +0 -1
  27. package/lib/common/definitions/google-analytics.d.ts +0 -5
  28. package/lib/common/dispatchers.js +4 -7
  29. package/lib/common/file-system.js +18 -22
  30. package/lib/common/host-info.js +4 -4
  31. package/lib/common/http-client.js +2 -2
  32. package/lib/common/logger/layouts/cli-layout.js +6 -2
  33. package/lib/common/logger/logger.js +7 -7
  34. package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -1
  35. package/lib/common/mobile/android/android-log-filter.js +5 -5
  36. package/lib/common/mobile/android/android-virtual-device-service.js +2 -2
  37. package/lib/common/mobile/android/genymotion/genymotion-service.js +2 -2
  38. package/lib/common/mobile/android/logcat-helper.js +1 -1
  39. package/lib/common/mobile/device-log-provider.js +8 -8
  40. package/lib/common/mobile/ios/device/ios-device-file-system.js +1 -1
  41. package/lib/common/mobile/ios/simulator/ios-emulator-services.js +1 -1
  42. package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -1
  43. package/lib/common/mobile/mobile-helper.js +1 -1
  44. package/lib/common/mobile/wp8/wp8-emulator-services.js +4 -4
  45. package/lib/common/opener.js +5 -1
  46. package/lib/common/plist-parser.js +3 -3
  47. package/lib/common/project-helper.js +2 -2
  48. package/lib/common/services/analytics/google-analytics-custom-dimensions.d.ts +7 -7
  49. package/lib/common/services/auto-completion-service.js +2 -2
  50. package/lib/common/services/commands-service.js +5 -114
  51. package/lib/common/services/help-service.js +16 -16
  52. package/lib/common/services/hooks-service.js +2 -1
  53. package/lib/common/services/json-file-settings-service.js +3 -3
  54. package/lib/common/services/lock-service.js +5 -5
  55. package/lib/common/services/messages-service.js +6 -6
  56. package/lib/common/services/net-service.js +1 -1
  57. package/lib/common/services/project-files-manager.js +2 -2
  58. package/lib/common/services/settings-service.js +2 -2
  59. package/lib/common/validators/project-name-validator.js +1 -1
  60. package/lib/common/validators/validation-result.js +1 -1
  61. package/lib/common/verify-node-version.js +2 -2
  62. package/lib/config.js +3 -8
  63. package/lib/constants.js +18 -32
  64. package/lib/controllers/build-controller.js +5 -5
  65. package/lib/controllers/debug-controller.js +2 -2
  66. package/lib/controllers/migrate-controller.js +21 -20
  67. package/lib/controllers/update-controller.js +5 -4
  68. package/lib/declarations.d.ts +0 -24
  69. package/lib/definitions/build.d.ts +1 -1
  70. package/lib/definitions/livesync.d.ts +0 -10
  71. package/lib/definitions/project.d.ts +0 -6
  72. package/lib/definitions/xcode.d.ts +1 -1
  73. package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +15 -4
  74. package/lib/device-sockets/ios/notification.js +1 -1
  75. package/lib/helpers/android-bundle-validator-helper.js +1 -1
  76. package/lib/helpers/network-connectivity-validator.js +1 -1
  77. package/lib/helpers/options-track-helper.js +1 -1
  78. package/lib/nativescript-cli.js +8 -10
  79. package/lib/options.js +61 -21
  80. package/lib/package-installation-manager.js +5 -4
  81. package/lib/project-data.js +9 -10
  82. package/lib/providers/project-files-provider.js +3 -3
  83. package/lib/services/analytics/analytics-broker-process.js +0 -3
  84. package/lib/services/analytics/analytics-broker.js +5 -5
  85. package/lib/services/analytics/analytics-service.js +0 -4
  86. package/lib/services/analytics/analytics.d.ts +1 -8
  87. package/lib/services/analytics/google-analytics-provider.js +1 -21
  88. package/lib/services/analytics-settings-service.js +3 -11
  89. package/lib/services/android-device-debug-service.js +3 -3
  90. package/lib/services/android-plugin-build-service.js +3 -3
  91. package/lib/services/android-resources-migration-service.js +1 -1
  92. package/lib/services/assets-generation/assets-generation-service.js +5 -5
  93. package/lib/services/{build-artefacts-service.js → build-artifacts-service.js} +4 -4
  94. package/lib/services/cocoapods-service.js +1 -1
  95. package/lib/services/device/device-install-app-service.js +3 -3
  96. package/lib/services/doctor-service.js +10 -9
  97. package/lib/services/extensibility-service.js +8 -8
  98. package/lib/services/ios-entitlements-service.js +1 -1
  99. package/lib/services/ios-project-service.js +5 -5
  100. package/lib/services/ios-provision-service.js +7 -7
  101. package/lib/services/ios-watch-app-service.js +1 -1
  102. package/lib/services/ip-service.js +2 -4
  103. package/lib/services/itmstransporter-service.js +2 -2
  104. package/lib/services/livesync/android-device-livesync-sockets-service.js +1 -1
  105. package/lib/services/livesync/android-livesync-tool.js +5 -5
  106. package/lib/services/livesync/ios-device-livesync-service.js +2 -2
  107. package/lib/services/livesync/platform-livesync-service-base.js +2 -1
  108. package/lib/services/log-parser-service.js +1 -5
  109. package/lib/services/log-source-map-service.js +10 -7
  110. package/lib/services/npm-config-service.js +23 -9
  111. package/lib/services/performance-service.js +3 -3
  112. package/lib/services/platform-environment-requirements.js +1 -1
  113. package/lib/services/plugins-service.js +19 -19
  114. package/lib/services/project-backup-service.js +4 -3
  115. package/lib/services/project-cleanup-service.js +4 -3
  116. package/lib/services/test-execution-service.js +2 -2
  117. package/lib/services/timeline-profiler-service.js +4 -1
  118. package/lib/services/user-settings-service.js +4 -4
  119. package/lib/tools/config-manipulation/config-transformer.js +3 -3
  120. package/lib/tools/node-modules/node-modules-builder.js +1 -1
  121. package/node_modules/@npmcli/move-file/LICENSE.md +22 -0
  122. package/node_modules/@npmcli/move-file/README.md +69 -0
  123. package/node_modules/@npmcli/move-file/lib/index.js +185 -0
  124. package/node_modules/@npmcli/move-file/node_modules/mkdirp/CHANGELOG.md +15 -0
  125. package/node_modules/@npmcli/move-file/node_modules/mkdirp/LICENSE +21 -0
  126. package/node_modules/@npmcli/move-file/node_modules/mkdirp/bin/cmd.js +68 -0
  127. package/node_modules/@npmcli/move-file/node_modules/mkdirp/index.js +31 -0
  128. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/find-made.js +29 -0
  129. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-manual.js +64 -0
  130. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-native.js +39 -0
  131. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/opts-arg.js +23 -0
  132. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/path-arg.js +29 -0
  133. package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/use-native.js +10 -0
  134. package/node_modules/@npmcli/move-file/node_modules/mkdirp/package.json +44 -0
  135. package/node_modules/@npmcli/move-file/node_modules/mkdirp/readme.markdown +266 -0
  136. package/node_modules/@npmcli/move-file/package.json +47 -0
  137. package/node_modules/balanced-match/.npmignore +5 -0
  138. package/node_modules/balanced-match/LICENSE.md +21 -0
  139. package/node_modules/balanced-match/README.md +91 -0
  140. package/node_modules/balanced-match/index.js +59 -0
  141. package/node_modules/balanced-match/package.json +49 -0
  142. package/node_modules/brace-expansion/LICENSE +21 -0
  143. package/node_modules/brace-expansion/README.md +129 -0
  144. package/node_modules/brace-expansion/index.js +201 -0
  145. package/node_modules/brace-expansion/package.json +47 -0
  146. package/node_modules/concat-map/.travis.yml +4 -0
  147. package/node_modules/concat-map/LICENSE +18 -0
  148. package/node_modules/concat-map/README.markdown +62 -0
  149. package/node_modules/concat-map/example/map.js +6 -0
  150. package/node_modules/concat-map/index.js +13 -0
  151. package/node_modules/concat-map/package.json +43 -0
  152. package/node_modules/concat-map/test/map.js +39 -0
  153. package/node_modules/fs.realpath/LICENSE +43 -0
  154. package/node_modules/fs.realpath/README.md +33 -0
  155. package/node_modules/fs.realpath/index.js +66 -0
  156. package/node_modules/fs.realpath/old.js +303 -0
  157. package/node_modules/fs.realpath/package.json +26 -0
  158. package/node_modules/inflight/LICENSE +15 -0
  159. package/node_modules/inflight/README.md +37 -0
  160. package/node_modules/inflight/inflight.js +54 -0
  161. package/node_modules/inflight/package.json +29 -0
  162. package/node_modules/inherits/LICENSE +16 -0
  163. package/node_modules/inherits/README.md +42 -0
  164. package/node_modules/inherits/inherits.js +9 -0
  165. package/node_modules/inherits/inherits_browser.js +27 -0
  166. package/node_modules/inherits/package.json +29 -0
  167. package/node_modules/once/LICENSE +15 -0
  168. package/node_modules/once/README.md +79 -0
  169. package/node_modules/once/once.js +42 -0
  170. package/node_modules/once/package.json +33 -0
  171. package/node_modules/path-is-absolute/index.js +20 -0
  172. package/node_modules/path-is-absolute/license +21 -0
  173. package/node_modules/path-is-absolute/package.json +43 -0
  174. package/node_modules/path-is-absolute/readme.md +59 -0
  175. package/node_modules/rimraf/CHANGELOG.md +65 -0
  176. package/node_modules/rimraf/LICENSE +15 -0
  177. package/node_modules/rimraf/README.md +101 -0
  178. package/node_modules/rimraf/bin.js +68 -0
  179. package/node_modules/rimraf/node_modules/glob/LICENSE +21 -0
  180. package/node_modules/rimraf/node_modules/glob/README.md +378 -0
  181. package/node_modules/rimraf/node_modules/glob/common.js +238 -0
  182. package/node_modules/rimraf/node_modules/glob/glob.js +790 -0
  183. package/node_modules/rimraf/node_modules/glob/package.json +55 -0
  184. package/node_modules/rimraf/node_modules/glob/sync.js +486 -0
  185. package/node_modules/rimraf/node_modules/minimatch/LICENSE +15 -0
  186. package/node_modules/rimraf/node_modules/minimatch/README.md +230 -0
  187. package/node_modules/rimraf/node_modules/minimatch/minimatch.js +947 -0
  188. package/node_modules/rimraf/node_modules/minimatch/package.json +33 -0
  189. package/node_modules/rimraf/package.json +32 -0
  190. package/node_modules/rimraf/rimraf.js +360 -0
  191. package/node_modules/stringify-package/CHANGELOG.md +16 -0
  192. package/node_modules/stringify-package/LICENSE +13 -0
  193. package/node_modules/stringify-package/README.md +55 -0
  194. package/node_modules/stringify-package/index.js +18 -0
  195. package/node_modules/stringify-package/package.json +38 -0
  196. package/node_modules/wrappy/LICENSE +15 -0
  197. package/node_modules/wrappy/README.md +36 -0
  198. package/node_modules/wrappy/package.json +29 -0
  199. package/node_modules/wrappy/wrappy.js +33 -0
  200. package/package.json +88 -89
  201. package/lib/common/definitions/byline.d.ts +0 -4
  202. package/lib/common/definitions/colors.d.ts +0 -24
  203. package/lib/common/definitions/marked.d.ts +0 -125
  204. package/lib/common/definitions/open.d.ts +0 -5
  205. package/lib/common/definitions/osenv.d.ts +0 -4
  206. package/lib/common/definitions/plist.d.ts +0 -7
  207. package/lib/common/definitions/rimraf.d.ts +0 -9
  208. package/lib/common/definitions/shelljs.d.ts +0 -583
  209. package/lib/common/definitions/simple-plist.d.ts +0 -7
  210. package/lib/common/definitions/xmlhttprequest.d.ts +0 -29
  211. package/lib/controllers/company-insights-controller.js +0 -78
  212. package/lib/controllers/preview-app-controller.js +0 -251
  213. package/lib/definitions/company-insights-controller.d.ts +0 -59
  214. package/lib/definitions/email-validator.d.ts +0 -8
  215. package/lib/definitions/libnpmconfig.d.ts +0 -3
  216. package/lib/definitions/npm.d.ts +0 -12
  217. package/lib/definitions/preview-app-livesync.d.ts +0 -116
  218. package/lib/services/livesync/playground/devices/preview-devices-service.js +0 -67
  219. package/lib/services/livesync/playground/preview-app-constants.js +0 -23
  220. package/lib/services/livesync/playground/preview-app-files-service.js +0 -83
  221. package/lib/services/livesync/playground/preview-app-log-provider.js +0 -14
  222. package/lib/services/livesync/playground/preview-app-plugins-service.js +0 -134
  223. package/lib/services/livesync/playground/preview-qr-code-service.js +0 -109
  224. package/lib/services/livesync/playground/preview-schema-service.js +0 -57
  225. package/lib/services/livesync/playground/preview-sdk-service.js +0 -112
  226. package/lib/services/playground-service.js +0 -65
  227. package/lib/xml-validator.js +0 -47
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PreviewAppFilesService = void 0;
4
- const path = require("path");
5
- const _ = require("lodash");
6
- const constants_1 = require("../../../constants");
7
- const preview_app_constants_1 = require("./preview-app-constants");
8
- const yok_1 = require("../../../common/yok");
9
- const istextorbinary_1 = require("istextorbinary");
10
- class PreviewAppFilesService {
11
- constructor($fs, $logger, $platformsDataService, $projectDataService, $projectFilesManager, $projectFilesProvider) {
12
- this.$fs = $fs;
13
- this.$logger = $logger;
14
- this.$platformsDataService = $platformsDataService;
15
- this.$projectDataService = $projectDataService;
16
- this.$projectFilesManager = $projectFilesManager;
17
- this.$projectFilesProvider = $projectFilesProvider;
18
- this.excludedFileExtensions = [".ts", ".sass", ".scss", ".less"];
19
- this.excludedFiles = [".DS_Store"];
20
- }
21
- getInitialFilesPayload(data, platform, deviceId) {
22
- const rootFilesDir = this.getRootFilesDir(data, platform);
23
- const filesToSync = this.$projectFilesManager.getProjectFiles(rootFilesDir);
24
- const payloads = this.getFilesPayload(data, { filesToSync }, platform, deviceId);
25
- return payloads;
26
- }
27
- getFilesPayload(data, filesData, platform, deviceId) {
28
- const { filesToSync, filesToRemove } = filesData;
29
- const filesToTransfer = filesToSync
30
- .filter((file) => file.indexOf(constants_1.TNS_MODULES_FOLDER_NAME) === -1)
31
- .filter((file) => file.indexOf(constants_1.APP_RESOURCES_FOLDER_NAME) === -1)
32
- .filter((file) => !_.includes(this.excludedFiles, path.basename(file)))
33
- .filter((file) => !_.includes(this.excludedFileExtensions, path.extname(file)));
34
- this.$logger.trace(`Sending ${filesToTransfer.join("\n")}.`);
35
- const files = this.createFilePayloads(data, platform, filesToTransfer, filesToRemove);
36
- return {
37
- files,
38
- platform,
39
- hmrMode: data.useHotModuleReload ? 1 : 0,
40
- deviceId,
41
- };
42
- }
43
- createFilePayloads(data, platform, filesToTransfer, filesToRemove) {
44
- const rootFilesDir = this.getRootFilesDir(data, platform);
45
- const payloadsToSync = _.filter(filesToTransfer, (file) => {
46
- const fileInfo = this.$projectFilesProvider.getProjectFileInfo(file, platform, {});
47
- return fileInfo && fileInfo.shouldIncludeFile;
48
- }).map((file) => this.createFilePayload(file, platform, rootFilesDir, preview_app_constants_1.PreviewSdkEventNames.CHANGE_EVENT_NAME));
49
- const payloadsToRemove = _.map(filesToRemove, (file) => this.createFilePayload(file, platform, rootFilesDir, preview_app_constants_1.PreviewSdkEventNames.UNLINK_EVENT_NAME));
50
- const payloads = payloadsToSync.concat(payloadsToRemove);
51
- return payloads;
52
- }
53
- createFilePayload(file, platform, rootFilesDir, event) {
54
- let fileContents = "";
55
- let binary = false;
56
- if (event === preview_app_constants_1.PreviewSdkEventNames.CHANGE_EVENT_NAME) {
57
- binary = (0, istextorbinary_1.isBinary)(file);
58
- if (binary) {
59
- const bitmap = this.$fs.readFile(file);
60
- const base64 = Buffer.from(bitmap).toString("base64");
61
- fileContents = base64;
62
- }
63
- else {
64
- fileContents = this.$fs.readText(file);
65
- }
66
- }
67
- const filePayload = {
68
- event,
69
- file: path.relative(rootFilesDir, file),
70
- binary,
71
- fileContents,
72
- };
73
- return filePayload;
74
- }
75
- getRootFilesDir(data, platform) {
76
- const projectData = this.$projectDataService.getProjectData(data.projectDir);
77
- const platformData = this.$platformsDataService.getPlatformData(platform, projectData);
78
- const rootFilesDir = path.join(platformData.appDestinationDirectoryPath, constants_1.APP_FOLDER_NAME);
79
- return rootFilesDir;
80
- }
81
- }
82
- exports.PreviewAppFilesService = PreviewAppFilesService;
83
- yok_1.injector.register("previewAppFilesService", PreviewAppFilesService);
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PreviewAppLogProvider = void 0;
4
- const events_1 = require("events");
5
- const constants_1 = require("../../../common/constants");
6
- const yok_1 = require("../../../common/yok");
7
- class PreviewAppLogProvider extends events_1.EventEmitter {
8
- logData(log, deviceName, deviceId) {
9
- const message = `LOG from device ${deviceName}: ${log}`;
10
- this.emit(constants_1.DEVICE_LOG_EVENT_NAME, deviceId, message);
11
- }
12
- }
13
- exports.PreviewAppLogProvider = PreviewAppLogProvider;
14
- yok_1.injector.register("previewAppLogProvider", PreviewAppLogProvider);
@@ -1,134 +0,0 @@
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.PreviewAppPluginsService = void 0;
13
- const path = require("path");
14
- const semver = require("semver");
15
- const util = require("util");
16
- const _ = require("lodash");
17
- const preview_app_constants_1 = require("./preview-app-constants");
18
- const constants_1 = require("../../../common/constants");
19
- const constants_2 = require("../../../constants");
20
- const yok_1 = require("../../../common/yok");
21
- class PreviewAppPluginsService {
22
- constructor($errors, $fs, $logger, $packageInstallationManager, $pluginsService) {
23
- this.$errors = $errors;
24
- this.$fs = $fs;
25
- this.$logger = $logger;
26
- this.$packageInstallationManager = $packageInstallationManager;
27
- this.$pluginsService = $pluginsService;
28
- }
29
- getPluginsUsageWarnings(data, device) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- if (!device) {
32
- this.$errors.fail("No device provided.");
33
- }
34
- if (!device.previewAppVersion) {
35
- this.$errors.fail("No version of preview app provided.");
36
- }
37
- const devicePlugins = this.getDevicePlugins(device);
38
- const localPlugins = this.getLocalPlugins(data.projectDir);
39
- const warnings = [];
40
- for (const pluginName in localPlugins) {
41
- const localPluginVersion = localPlugins[pluginName];
42
- const devicePluginVersion = devicePlugins[pluginName];
43
- const pluginWarnings = yield this.getWarningForPlugin(data, pluginName, localPluginVersion, devicePluginVersion, device);
44
- if (pluginWarnings) {
45
- warnings.push(pluginWarnings);
46
- }
47
- }
48
- return warnings;
49
- });
50
- }
51
- comparePluginsOnDevice(data, device) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const warnings = yield this.getPluginsUsageWarnings(data, device);
54
- _.map(warnings, (warning) => this.$logger.warn(warning));
55
- if (warnings && warnings.length) {
56
- this.$logger.warn(`In the app are used one or more NativeScript plugins with native dependencies.
57
- Those plugins will not work while building the project via \`$ tns preview\`. Please, use \`$ tns run <platform>\` command instead.`, { [constants_2.LoggerConfigData.wrapMessageWithBorders]: true });
58
- }
59
- });
60
- }
61
- getExternalPlugins(device) {
62
- const devicePlugins = this.getDevicePlugins(device);
63
- const themeNamesArray = [constants_2.TNS_CORE_THEME_NAME, constants_2.SCOPED_TNS_CORE_THEME_NAME];
64
- const result = _.keys(devicePlugins)
65
- .filter((plugin) => themeNamesArray.indexOf(plugin) === -1);
66
- return result;
67
- }
68
- getDevicePlugins(device) {
69
- try {
70
- return JSON.parse(device.plugins);
71
- }
72
- catch (err) {
73
- this.$logger.trace(`Error while parsing plugins from device ${device.id}. Error is ${err.message}`);
74
- return {};
75
- }
76
- }
77
- getLocalPlugins(projectDir) {
78
- const projectFilePath = path.join(projectDir, constants_2.PACKAGE_JSON_FILE_NAME);
79
- try {
80
- return this.$fs.readJson(projectFilePath).dependencies;
81
- }
82
- catch (err) {
83
- this.$logger.trace(`Error while parsing ${projectFilePath}. Error is ${err.message}`);
84
- return {};
85
- }
86
- }
87
- getWarningForPlugin(data, localPlugin, localPluginVersion, devicePluginVersion, device) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- const pluginPackageJsonPath = path.join(data.projectDir, constants_1.NODE_MODULES_DIR_NAME, localPlugin, constants_2.PACKAGE_JSON_FILE_NAME);
90
- const isNativeScriptPlugin = this.$pluginsService.isNativeScriptPlugin(pluginPackageJsonPath);
91
- const shouldCompare = isNativeScriptPlugin &&
92
- this.hasNativeCode(localPlugin, device.platform, data.projectDir);
93
- let warning = null;
94
- if (shouldCompare) {
95
- warning = yield this.getWarningForPluginCore(localPlugin, localPluginVersion, devicePluginVersion, device.id);
96
- }
97
- return warning;
98
- });
99
- }
100
- getWarningForPluginCore(pluginName, localPluginVersion, devicePluginVersion, deviceId) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- this.$logger.trace(`Comparing plugin ${pluginName} with localPluginVersion ${localPluginVersion} and devicePluginVersion ${devicePluginVersion}`);
103
- if (!devicePluginVersion) {
104
- return util.format(preview_app_constants_1.PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, pluginName, deviceId);
105
- }
106
- const shouldSkipCheck = !semver.valid(localPluginVersion) &&
107
- !semver.validRange(localPluginVersion);
108
- if (shouldSkipCheck) {
109
- return null;
110
- }
111
- const localPluginVersionData = yield this.$packageInstallationManager.getMaxSatisfyingVersionSafe(pluginName, localPluginVersion);
112
- const devicePluginVersionData = yield this.$packageInstallationManager.getMaxSatisfyingVersionSafe(pluginName, devicePluginVersion);
113
- if (semver.valid(localPluginVersionData) &&
114
- semver.valid(devicePluginVersionData)) {
115
- if (semver.major(localPluginVersionData) !==
116
- semver.major(devicePluginVersionData)) {
117
- return util.format(preview_app_constants_1.PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, pluginName, localPluginVersion, devicePluginVersion);
118
- }
119
- else if (semver.minor(localPluginVersionData) >
120
- semver.minor(devicePluginVersionData)) {
121
- return util.format(preview_app_constants_1.PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, pluginName, localPluginVersion, devicePluginVersion);
122
- }
123
- }
124
- return null;
125
- });
126
- }
127
- hasNativeCode(localPlugin, platform, projectDir) {
128
- const nativeFolderPath = path.join(projectDir, constants_1.NODE_MODULES_DIR_NAME, localPlugin, constants_2.PLATFORMS_DIR_NAME, platform.toLowerCase());
129
- return (this.$fs.exists(nativeFolderPath) &&
130
- !this.$fs.isEmptyDir(nativeFolderPath));
131
- }
132
- }
133
- exports.PreviewAppPluginsService = PreviewAppPluginsService;
134
- yok_1.injector.register("previewAppPluginsService", PreviewAppPluginsService);
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.PreviewQrCodeService = void 0;
19
- const util = require("util");
20
- const os_1 = require("os");
21
- const decorators_1 = require("../../../common/decorators");
22
- const yok_1 = require("../../../common/yok");
23
- class PreviewQrCodeService {
24
- constructor($config, $httpClient, $logger, $mobileHelper, $previewSdkService, $previewSchemaService, $qrCodeTerminalService, $qr) {
25
- this.$config = $config;
26
- this.$httpClient = $httpClient;
27
- this.$logger = $logger;
28
- this.$mobileHelper = $mobileHelper;
29
- this.$previewSdkService = $previewSdkService;
30
- this.$previewSchemaService = $previewSchemaService;
31
- this.$qrCodeTerminalService = $qrCodeTerminalService;
32
- this.$qr = $qr;
33
- }
34
- getPlaygroundAppQrCode(options) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const { projectDir } = options || {};
37
- const result = Object.create(null);
38
- if (!options ||
39
- !options.platform ||
40
- this.$mobileHelper.isAndroidPlatform(options.platform)) {
41
- result.android = yield this.getLiveSyncQrCode(this.getGooglePlayUrl(projectDir));
42
- }
43
- if (!options ||
44
- !options.platform ||
45
- this.$mobileHelper.isiOSPlatform(options.platform)) {
46
- result.ios = yield this.getLiveSyncQrCode(this.getAppStoreUrl(projectDir));
47
- }
48
- return result;
49
- });
50
- }
51
- getLiveSyncQrCode(url) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const shortenUrl = yield this.getShortenUrl(url);
54
- const imageData = yield this.$qr.generateDataUri(shortenUrl);
55
- return {
56
- originalUrl: url,
57
- shortenUrl,
58
- imageData,
59
- };
60
- });
61
- }
62
- printLiveSyncQrCode(options) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const qrCodeUrl = this.$previewSdkService.getQrCodeUrl(options);
65
- const url = yield this.getShortenUrl(qrCodeUrl);
66
- this.$logger.info();
67
- const message = `${os_1.EOL} Generating qrcode for url ${url}.`;
68
- this.$logger.trace(message);
69
- if (options.link) {
70
- this.$logger.printMarkdown(message);
71
- }
72
- else {
73
- this.$qrCodeTerminalService.generate(url);
74
- this.$logger.info();
75
- this.$logger.printMarkdown(`# Use \`NativeScript Playground app\` and scan the \`QR code\` above to preview the application on your device.`);
76
- this.$logger.printMarkdown(`
77
- To scan the QR code and deploy your app on a device, you need to have the \`NativeScript Playground app\`:
78
- App Store (iOS): ${this.getAppStoreUrl(options.projectDir)}
79
- Google Play (Android): ${this.getGooglePlayUrl(options.projectDir)}`);
80
- }
81
- });
82
- }
83
- getShortenUrl(url) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const shortenUrlEndpoint = util.format(this.$config.SHORTEN_URL_ENDPOINT, encodeURIComponent(url));
86
- try {
87
- const response = yield this.$httpClient.httpRequest(shortenUrlEndpoint);
88
- const responseBody = JSON.parse(response.body);
89
- url = responseBody.shortURL || url;
90
- }
91
- catch (e) {
92
- }
93
- return url;
94
- });
95
- }
96
- getGooglePlayUrl(projectDir) {
97
- const schema = this.$previewSchemaService.getSchemaData(projectDir);
98
- return `https://play.google.com/store/apps/details?id=${schema.scannerAppId}`;
99
- }
100
- getAppStoreUrl(projectDir) {
101
- const schema = this.$previewSchemaService.getSchemaData(projectDir);
102
- return `https://itunes.apple.com/us/app/nativescript-playground/id${schema.scannerAppStoreId}?mt=8&ls=1`;
103
- }
104
- }
105
- __decorate([
106
- (0, decorators_1.exported)("previewQrCodeService")
107
- ], PreviewQrCodeService.prototype, "getPlaygroundAppQrCode", null);
108
- exports.PreviewQrCodeService = PreviewQrCodeService;
109
- yok_1.injector.register("previewQrCodeService", PreviewQrCodeService);
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PreviewSchemaService = void 0;
4
- const preview_app_constants_1 = require("./preview-app-constants");
5
- const yok_1 = require("../../../common/yok");
6
- const _ = require("lodash");
7
- class PreviewSchemaService {
8
- constructor($errors, $projectDataService) {
9
- this.$errors = $errors;
10
- this.$projectDataService = $projectDataService;
11
- this.previewSchemas = {
12
- nsplay: {
13
- name: "nsplay",
14
- scannerAppId: "org.nativescript.play",
15
- scannerAppStoreId: "1263543946",
16
- previewAppId: "org.nativescript.preview",
17
- previewAppStoreId: "1264484702",
18
- msvKey: "cli",
19
- publishKey: preview_app_constants_1.PubnubKeys.PUBLISH_KEY,
20
- subscribeKey: preview_app_constants_1.PubnubKeys.SUBSCRIBE_KEY,
21
- default: true,
22
- },
23
- kspreview: {
24
- name: "kspreview",
25
- scannerAppId: "com.kinvey.scanner",
26
- scannerAppStoreId: "1458317125",
27
- previewAppId: "com.kinvey.preview",
28
- previewAppStoreId: "1458502055",
29
- msvKey: "kinveyStudio",
30
- publishKey: preview_app_constants_1.PubnubKeys.PUBLISH_KEY,
31
- subscribeKey: preview_app_constants_1.PubnubKeys.SUBSCRIBE_KEY,
32
- },
33
- };
34
- }
35
- getSchemaData(projectDir) {
36
- let schemaName = this.getSchemaNameFromProject(projectDir);
37
- if (!schemaName) {
38
- schemaName = _.findKey(this.previewSchemas, (previewSchema) => previewSchema.default);
39
- }
40
- const result = this.previewSchemas[schemaName];
41
- if (!result) {
42
- this.$errors.fail(`Invalid schema. The valid schemas are ${_.keys(this.previewSchemas)}.`);
43
- }
44
- return result;
45
- }
46
- getSchemaNameFromProject(projectDir) {
47
- try {
48
- const projectData = this.$projectDataService.getProjectData(projectDir);
49
- return projectData.previewAppSchema;
50
- }
51
- catch (err) {
52
- }
53
- return null;
54
- }
55
- }
56
- exports.PreviewSchemaService = PreviewSchemaService;
57
- yok_1.injector.register("previewSchemaService", PreviewSchemaService);
@@ -1,112 +0,0 @@
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.PreviewSdkService = void 0;
13
- const nativescript_preview_sdk_1 = require("nativescript-preview-sdk");
14
- const yok_1 = require("../../../common/yok");
15
- const pako = require("pako");
16
- class PreviewSdkService {
17
- constructor($config, $httpClient, $logger, $previewDevicesService, $previewAppLogProvider, $previewSchemaService) {
18
- this.$config = $config;
19
- this.$httpClient = $httpClient;
20
- this.$logger = $logger;
21
- this.$previewDevicesService = $previewDevicesService;
22
- this.$previewAppLogProvider = $previewAppLogProvider;
23
- this.$previewSchemaService = $previewSchemaService;
24
- this.messagingService = null;
25
- this.instanceId = null;
26
- }
27
- getQrCodeUrl(options) {
28
- const { projectDir, useHotModuleReload } = options;
29
- const schema = this.$previewSchemaService.getSchemaData(projectDir);
30
- const hmrValue = useHotModuleReload ? "1" : "0";
31
- const result = `${schema.name}://boot?instanceId=${this.instanceId}&pKey=${schema.publishKey}&sKey=${schema.subscribeKey}&template=play-ng&hmr=${hmrValue}`;
32
- return result;
33
- }
34
- initialize(projectDir, getInitialFiles) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const initConfig = this.getInitConfig(projectDir, getInitialFiles);
37
- this.messagingService = new nativescript_preview_sdk_1.MessagingService();
38
- this.instanceId = yield this.messagingService.initialize(initConfig);
39
- });
40
- }
41
- applyChanges(filesPayload) {
42
- return new Promise((resolve, reject) => {
43
- this.messagingService.applyChanges(this.instanceId, filesPayload, (err) => {
44
- if (err) {
45
- reject(err);
46
- }
47
- else {
48
- resolve();
49
- }
50
- });
51
- });
52
- }
53
- stop() {
54
- this.messagingService.stop();
55
- }
56
- getInitConfig(projectDir, getInitialFiles) {
57
- const schema = this.$previewSchemaService.getSchemaData(projectDir);
58
- return {
59
- pubnubPublishKey: schema.publishKey,
60
- pubnubSubscribeKey: schema.subscribeKey,
61
- msvKey: schema.msvKey,
62
- msvEnv: this.$config.PREVIEW_APP_ENVIRONMENT,
63
- callbacks: this.getCallbacks(),
64
- getInitialFiles,
65
- previewAppStoreId: schema.previewAppStoreId,
66
- previewAppGooglePlayId: schema.previewAppId,
67
- };
68
- }
69
- getCallbacks() {
70
- return {
71
- onLogSdkMessage: (log) => {
72
- this.$logger.trace("Received onLogSdkMessage message: ", log);
73
- },
74
- onLogMessage: (log, deviceName, deviceId) => {
75
- this.$previewAppLogProvider.logData(log, deviceName, deviceId);
76
- },
77
- onRestartMessage: () => {
78
- this.$logger.trace("Received onRestartMessage event.");
79
- },
80
- onUncaughtErrorMessage: () => {
81
- this.$logger.warn("The Preview app has terminated unexpectedly. Please run it again to get a detailed crash report.");
82
- },
83
- onConnectedDevicesChange: (connectedDevices) => ({}),
84
- onDeviceConnectedMessage: (deviceConnectedMessage) => ({}),
85
- onDeviceConnected: (device) => ({}),
86
- onDevicesPresence: (devices) => this.$previewDevicesService.updateConnectedDevices(devices),
87
- onSendingChange: (sending) => ({}),
88
- onBiggerFilesUpload: (filesContent, callback) => __awaiter(this, void 0, void 0, function* () {
89
- const gzippedContent = Buffer.from(pako.gzip(filesContent));
90
- const byteLength = filesContent.length;
91
- if (byteLength > PreviewSdkService.MAX_FILES_UPLOAD_BYTE_LENGTH) {
92
- this.$logger.warn("The files to upload exceed the maximum allowed size of 15MB. Your app might not work as expected.");
93
- }
94
- const playgroundUploadResponse = yield this.$httpClient.httpRequest({
95
- url: this.$config.UPLOAD_PLAYGROUND_FILES_ENDPOINT,
96
- method: "POST",
97
- body: gzippedContent,
98
- headers: {
99
- "Content-Encoding": "gzip",
100
- "Content-Type": "text/plain",
101
- },
102
- });
103
- const responseBody = JSON.parse(playgroundUploadResponse.body);
104
- const location = responseBody && responseBody.location;
105
- callback(location, playgroundUploadResponse.error);
106
- }),
107
- };
108
- }
109
- }
110
- exports.PreviewSdkService = PreviewSdkService;
111
- PreviewSdkService.MAX_FILES_UPLOAD_BYTE_LENGTH = 15 * 1024 * 1024;
112
- yok_1.injector.register("previewSdkService", PreviewSdkService);
@@ -1,65 +0,0 @@
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.PlaygroundService = void 0;
13
- const yok_1 = require("../common/yok");
14
- class PlaygroundService {
15
- constructor($fs, $projectDataService, $userSettingsService) {
16
- this.$fs = $fs;
17
- this.$projectDataService = $projectDataService;
18
- this.$userSettingsService = $userSettingsService;
19
- }
20
- getPlaygroundInfo(projectDir) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const projectData = this.getProjectData(projectDir);
23
- if (projectData) {
24
- const projectFileContent = this.$fs.readJson(projectData.projectFilePath);
25
- if (this.hasPlaygroundKey(projectFileContent)) {
26
- const id = projectFileContent.nativescript.playground.id;
27
- let usedTutorial = projectFileContent.nativescript.playground.usedTutorial || false;
28
- const playgroundInfo = yield this.getPlaygroundInfoFromUserSettingsFile();
29
- if (playgroundInfo && playgroundInfo.usedTutorial) {
30
- usedTutorial = true;
31
- }
32
- delete projectFileContent.nativescript.playground;
33
- this.$fs.writeJson(projectData.projectFilePath, projectFileContent);
34
- const result = { id, usedTutorial };
35
- yield this.$userSettingsService.saveSettings({
36
- playground: result,
37
- });
38
- return result;
39
- }
40
- }
41
- return this.getPlaygroundInfoFromUserSettingsFile();
42
- });
43
- }
44
- getProjectData(projectDir) {
45
- try {
46
- return this.$projectDataService.getProjectData(projectDir);
47
- }
48
- catch (e) {
49
- return null;
50
- }
51
- }
52
- hasPlaygroundKey(projectFileContent) {
53
- return (projectFileContent &&
54
- projectFileContent.nativescript &&
55
- projectFileContent.nativescript.playground &&
56
- projectFileContent.nativescript.playground.id);
57
- }
58
- getPlaygroundInfoFromUserSettingsFile() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return this.$userSettingsService.getSettingValue("playground");
61
- });
62
- }
63
- }
64
- exports.PlaygroundService = PlaygroundService;
65
- yok_1.injector.register("playgroundService", PlaygroundService);
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XmlValidator = void 0;
4
- const os_1 = require("os");
5
- const _ = require("lodash");
6
- const constants = require("./constants");
7
- const yok_1 = require("./common/yok");
8
- class XmlValidator {
9
- constructor($fs, $logger) {
10
- this.$fs = $fs;
11
- this.$logger = $logger;
12
- }
13
- validateXmlFiles(sourceFiles) {
14
- let xmlHasErrors = false;
15
- sourceFiles
16
- .filter((file) => _.endsWith(file, constants.XML_FILE_EXTENSION))
17
- .forEach((file) => {
18
- const errorOutput = this.getXmlFileErrors(file);
19
- const hasErrors = !!errorOutput;
20
- xmlHasErrors = xmlHasErrors || hasErrors;
21
- if (hasErrors) {
22
- this.$logger.info(`${file} has syntax errors.`.red.bold);
23
- this.$logger.info(errorOutput.yellow);
24
- }
25
- });
26
- return !xmlHasErrors;
27
- }
28
- getXmlFileErrors(sourceFile) {
29
- let errorOutput = "";
30
- const fileContents = this.$fs.readText(sourceFile);
31
- const domErrorHandler = (level, msg) => {
32
- errorOutput += level + os_1.EOL + msg + os_1.EOL;
33
- };
34
- this.getDomParser(domErrorHandler).parseFromString(fileContents, "text/xml");
35
- return errorOutput || null;
36
- }
37
- getDomParser(errorHandler) {
38
- const DomParser = require("xmldom").DOMParser;
39
- const parser = new DomParser({
40
- locator: {},
41
- errorHandler: errorHandler,
42
- });
43
- return parser;
44
- }
45
- }
46
- exports.XmlValidator = XmlValidator;
47
- yok_1.injector.register("xmlValidator", XmlValidator);