@akylas/nativescript-cli 8.8.2 → 8.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android-tools-info.js +9 -20
- package/lib/base-package-manager.js +47 -64
- package/lib/bun-package-manager.js +65 -88
- package/lib/color.js +2 -2
- package/lib/commands/add-platform.js +14 -30
- package/lib/commands/apple-login.js +18 -29
- package/lib/commands/appstore-list.js +34 -45
- package/lib/commands/appstore-upload.js +55 -68
- package/lib/commands/build.js +57 -86
- package/lib/commands/clean.js +161 -176
- package/lib/commands/command-base.js +14 -27
- package/lib/commands/config.js +51 -70
- package/lib/commands/create-project.js +210 -229
- package/lib/commands/debug.js +66 -88
- package/lib/commands/deploy.js +28 -44
- package/lib/commands/embedding/embed.js +33 -52
- package/lib/commands/extensibility/install-extension.js +5 -16
- package/lib/commands/extensibility/list-extensions.js +13 -24
- package/lib/commands/extensibility/uninstall-extension.js +4 -15
- package/lib/commands/fonts.js +30 -41
- package/lib/commands/generate-assets.js +13 -28
- package/lib/commands/generate-help.js +2 -13
- package/lib/commands/generate.js +17 -26
- package/lib/commands/info.js +2 -13
- package/lib/commands/install.js +34 -49
- package/lib/commands/list-platforms.js +14 -25
- package/lib/commands/migrate.js +15 -26
- package/lib/commands/native-add.js +23 -46
- package/lib/commands/platform-clean.js +19 -32
- package/lib/commands/plugin/add-plugin.js +12 -25
- package/lib/commands/plugin/build-plugin.js +34 -39
- package/lib/commands/plugin/create-plugin.js +110 -133
- package/lib/commands/plugin/list-plugins.js +22 -33
- package/lib/commands/plugin/remove-plugin.js +20 -33
- package/lib/commands/plugin/update-plugin.js +20 -33
- package/lib/commands/post-install.js +20 -33
- package/lib/commands/prepare.js +19 -35
- package/lib/commands/preview.js +49 -62
- package/lib/commands/remove-platform.js +7 -18
- package/lib/commands/resources/resources-update.js +13 -26
- package/lib/commands/run.js +55 -76
- package/lib/commands/start.js +6 -19
- package/lib/commands/test-init.js +123 -134
- package/lib/commands/test.js +66 -89
- package/lib/commands/typings.js +126 -142
- package/lib/commands/update-platform.js +22 -35
- package/lib/commands/update.js +30 -43
- package/lib/common/child-process.js +53 -72
- package/lib/common/codeGeneration/code-entity.js +1 -1
- package/lib/common/codeGeneration/code-printer.js +1 -1
- package/lib/common/command-params.js +7 -18
- package/lib/common/commands/analytics.js +27 -40
- package/lib/common/commands/autocompletion.js +39 -56
- package/lib/common/commands/device/device-log-stream.js +12 -23
- package/lib/common/commands/device/get-file.js +22 -33
- package/lib/common/commands/device/list-applications.js +12 -23
- package/lib/common/commands/device/list-devices.js +72 -87
- package/lib/common/commands/device/list-files.js +23 -34
- package/lib/common/commands/device/put-file.js +22 -33
- package/lib/common/commands/device/run-application.js +12 -25
- package/lib/common/commands/device/stop-application.js +11 -22
- package/lib/common/commands/device/uninstall-application.js +6 -17
- package/lib/common/commands/generate-messages.js +17 -28
- package/lib/common/commands/help.js +20 -33
- package/lib/common/commands/package-manager-get.js +6 -17
- package/lib/common/commands/package-manager-set.js +9 -20
- package/lib/common/commands/post-install.js +2 -13
- package/lib/common/commands/preuninstall.js +23 -38
- package/lib/common/commands/proxy/proxy-base.js +8 -19
- package/lib/common/commands/proxy/proxy-clear.js +4 -15
- package/lib/common/commands/proxy/proxy-get.js +3 -14
- package/lib/common/commands/proxy/proxy-set.js +87 -100
- package/lib/common/constants.js +11 -11
- package/lib/common/decorators.js +10 -22
- package/lib/common/dispatchers.js +79 -96
- package/lib/common/errors.js +89 -104
- package/lib/common/file-system.js +106 -127
- package/lib/common/header.js +1 -2
- package/lib/common/helpers.js +149 -178
- package/lib/common/host-info.js +37 -50
- package/lib/common/http-client.js +93 -108
- package/lib/common/logger/appenders/cli-appender.js +1 -2
- package/lib/common/logger/appenders/emit-appender.js +1 -2
- package/lib/common/logger/layouts/cli-layout.js +1 -2
- package/lib/common/logger/logger.js +1 -1
- package/lib/common/mobile/android/android-application-manager.js +121 -142
- package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -1
- package/lib/common/mobile/android/android-debug-bridge.js +87 -112
- package/lib/common/mobile/android/android-device-file-system.js +98 -131
- package/lib/common/mobile/android/android-device-hash-service.js +50 -75
- package/lib/common/mobile/android/android-device.js +74 -91
- package/lib/common/mobile/android/android-emulator-services.js +105 -130
- package/lib/common/mobile/android/android-log-filter.js +1 -1
- package/lib/common/mobile/android/android-virtual-device-service.js +76 -97
- package/lib/common/mobile/android/device-android-debug-bridge.js +13 -29
- package/lib/common/mobile/android/genymotion/genymotion-service.js +91 -118
- package/lib/common/mobile/android/genymotion/virtualbox-service.js +64 -81
- package/lib/common/mobile/android/logcat-helper.js +108 -127
- package/lib/common/mobile/application-manager-base.js +84 -107
- package/lib/common/mobile/device-log-provider-base.js +7 -18
- package/lib/common/mobile/ios/device/ios-application-manager.js +79 -108
- package/lib/common/mobile/ios/device/ios-device-file-system.js +78 -105
- package/lib/common/mobile/ios/device/ios-device-operations.js +105 -142
- package/lib/common/mobile/ios/device/ios-device.js +20 -36
- package/lib/common/mobile/ios/ios-device-base.js +58 -81
- package/lib/common/mobile/ios/simulator/ios-emulator-services.js +63 -92
- package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -1
- package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +60 -89
- package/lib/common/mobile/ios/simulator/ios-simulator-device.js +27 -43
- package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +37 -62
- package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +24 -35
- package/lib/common/mobile/mobile-core/android-device-discovery.js +43 -62
- package/lib/common/mobile/mobile-core/android-emulator-discovery.js +21 -32
- package/lib/common/mobile/mobile-core/android-process-service.js +143 -182
- package/lib/common/mobile/mobile-core/device-discovery.js +2 -13
- package/lib/common/mobile/mobile-core/devices-service.js +385 -436
- package/lib/common/mobile/mobile-core/ios-device-discovery.js +24 -35
- package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +47 -62
- package/lib/common/mobile/mobile-helper.js +15 -26
- package/lib/common/mobile/wp8/wp8-emulator-services.js +25 -52
- package/lib/common/opener.js +2 -2
- package/lib/common/plist-parser.js +2 -2
- package/lib/common/prompter.js +90 -105
- package/lib/common/queue.js +9 -20
- package/lib/common/services/auto-completion-service.js +39 -52
- package/lib/common/services/cancellation.js +17 -28
- package/lib/common/services/commands-service.js +146 -169
- package/lib/common/services/help-service.js +132 -157
- package/lib/common/services/hooks-service.js +93 -108
- package/lib/common/services/ios-notification-service.js +21 -34
- package/lib/common/services/json-file-settings-service.js +52 -71
- package/lib/common/services/lock-service.js +35 -52
- package/lib/common/services/message-contract-generator.js +35 -46
- package/lib/common/services/micro-templating-service.js +4 -15
- package/lib/common/services/net-service.js +90 -107
- package/lib/common/services/project-files-manager.js +10 -23
- package/lib/common/services/proxy-service.js +13 -24
- package/lib/common/services/qr.js +13 -24
- package/lib/common/services/settings-service.js +1 -1
- package/lib/common/services/xcode-select-service.js +20 -35
- package/lib/common/utils.js +2 -2
- package/lib/common/validators/project-name-validator.js +1 -1
- package/lib/common/validators/validation-result.js +1 -1
- package/lib/common/verify-node-version.js +2 -3
- package/lib/common/yok.js +23 -36
- package/lib/config.js +7 -58
- package/lib/constants.js +24 -24
- package/lib/controllers/build-controller.js +82 -99
- package/lib/controllers/debug-controller.js +107 -128
- package/lib/controllers/deploy-controller.js +17 -22
- package/lib/controllers/migrate-controller.js +722 -795
- package/lib/controllers/platform-controller.js +72 -87
- package/lib/controllers/prepare-controller.js +266 -299
- package/lib/controllers/run-controller.js +392 -406
- package/lib/controllers/update-controller-base.js +16 -29
- package/lib/controllers/update-controller.js +94 -119
- package/lib/data/prepare-data.js +4 -1
- package/lib/definitions/ios-debugger-port-service.d.ts +1 -1
- package/lib/definitions/livesync.d.ts +1 -1
- package/lib/detached-processes/cleanup-js-subprocess.js +3 -12
- package/lib/detached-processes/cleanup-process.js +16 -25
- package/lib/device-path-provider.js +23 -34
- package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +149 -164
- package/lib/device-sockets/ios/notification.js +1 -1
- package/lib/device-sockets/ios/socket-request-executor.js +24 -39
- package/lib/helpers/android-bundle-validator-helper.js +1 -1
- package/lib/helpers/deploy-command-helper.js +45 -49
- package/lib/helpers/key-command-helper.js +4 -13
- package/lib/helpers/livesync-command-helper.js +137 -152
- package/lib/helpers/network-connectivity-validator.js +6 -17
- package/lib/helpers/options-track-helper.js +6 -17
- package/lib/helpers/platform-command-helper.js +99 -120
- package/lib/key-commands/index.js +161 -211
- package/lib/nativescript-cli.js +5 -14
- package/lib/node-package-manager.js +81 -104
- package/lib/options.js +3 -12
- package/lib/package-installation-manager.js +130 -165
- package/lib/package-manager.js +63 -86
- package/lib/platform-command-param.js +4 -15
- package/lib/pnpm-package-manager.js +59 -78
- package/lib/project-data.js +1 -1
- package/lib/providers/project-files-provider.js +1 -1
- package/lib/services/analytics/analytics-broker-process.js +13 -22
- package/lib/services/analytics/analytics-broker.js +17 -30
- package/lib/services/analytics/analytics-service.js +161 -198
- package/lib/services/analytics/google-analytics-provider.js +41 -56
- package/lib/services/analytics-settings-service.js +15 -32
- package/lib/services/android/android-bundle-tool-service.js +43 -60
- package/lib/services/android/gradle-build-args-service.js +9 -20
- package/lib/services/android/gradle-build-service.js +34 -47
- package/lib/services/android/gradle-command-service.js +22 -35
- package/lib/services/android-device-debug-service.js +90 -117
- package/lib/services/android-plugin-build-service.js +230 -256
- package/lib/services/android-project-service.js +163 -199
- package/lib/services/android-resources-migration-service.js +51 -64
- package/lib/services/apple-portal/apple-portal-application-service.js +46 -63
- package/lib/services/apple-portal/apple-portal-session-service.js +171 -188
- package/lib/services/assets-generation/assets-generation-service.js +98 -115
- package/lib/services/build-artifacts-service.js +9 -20
- package/lib/services/build-info-file-service.js +20 -35
- package/lib/services/cleanup-service.js +47 -76
- package/lib/services/cocoapods-service.js +115 -136
- package/lib/services/device/device-install-app-service.js +73 -90
- package/lib/services/doctor-service.js +99 -118
- package/lib/services/extensibility-service.js +81 -100
- package/lib/services/files-hash-service.js +26 -43
- package/lib/services/hmr-status-service.js +1 -1
- package/lib/services/initialize-service.js +37 -50
- package/lib/services/ios/export-options-plist-service.js +38 -51
- package/lib/services/ios/ios-signing-service.js +161 -180
- package/lib/services/ios/spm-service.js +40 -53
- package/lib/services/ios/xcodebuild-args-service.js +77 -94
- package/lib/services/ios/xcodebuild-command-service.js +14 -25
- package/lib/services/ios/xcodebuild-service.js +50 -69
- package/lib/services/ios-debugger-port-service.js +23 -36
- package/lib/services/ios-device-debug-service.js +75 -102
- package/lib/services/ios-entitlements-service.js +31 -42
- package/lib/services/ios-extensions-service.js +18 -29
- package/lib/services/ios-project-service.js +405 -460
- package/lib/services/ios-provision-service.js +108 -129
- package/lib/services/ios-watch-app-service.js +21 -32
- package/lib/services/ip-service.js +38 -53
- package/lib/services/itmstransporter-service.js +129 -152
- package/lib/services/livesync/android-device-livesync-service-base.js +31 -48
- package/lib/services/livesync/android-device-livesync-service.js +120 -149
- package/lib/services/livesync/android-device-livesync-sockets-service.js +121 -152
- package/lib/services/livesync/android-livesync-service.js +14 -35
- package/lib/services/livesync/android-livesync-tool.js +89 -112
- package/lib/services/livesync/device-livesync-service-base.js +15 -28
- package/lib/services/livesync/ios-device-livesync-service.js +114 -143
- package/lib/services/livesync/ios-livesync-service.js +42 -58
- package/lib/services/livesync/platform-livesync-service-base.js +94 -119
- package/lib/services/log-parser-service.js +1 -1
- package/lib/services/log-source-map-service.js +30 -41
- package/lib/services/marking-mode-service.js +15 -28
- package/lib/services/npm-config-service.js +1 -1
- package/lib/services/pacote-service.js +49 -64
- package/lib/services/performance-service.js +1 -1
- package/lib/services/platform/add-platform-service.js +50 -71
- package/lib/services/platform/platform-validation-service.js +22 -33
- package/lib/services/platform/prepare-native-platform-service.js +49 -62
- package/lib/services/platform-environment-requirements.js +26 -37
- package/lib/services/plugins-service.js +122 -147
- package/lib/services/project-backup-service.js +1 -1
- package/lib/services/project-changes-service.js +124 -141
- package/lib/services/project-cleanup-service.js +64 -77
- package/lib/services/project-config-service.js +71 -80
- package/lib/services/project-data-service.js +101 -118
- package/lib/services/project-name-service.js +28 -43
- package/lib/services/project-service.js +84 -103
- package/lib/services/project-templates-service.js +52 -67
- package/lib/services/start-service.js +41 -59
- package/lib/services/temp-service.js +8 -21
- package/lib/services/terminal-spinner-service.js +13 -24
- package/lib/services/test-execution-service.js +59 -72
- package/lib/services/test-initialization-service.js +2 -2
- package/lib/services/timeline-profiler-service.js +1 -1
- package/lib/services/versions-service.js +119 -138
- package/lib/services/webpack/webpack-compiler-service.js +211 -231
- package/lib/services/xcconfig-service.js +8 -19
- package/lib/sys-info.js +45 -62
- package/lib/tools/node-modules/node-modules-builder.js +16 -27
- package/lib/yarn-package-manager.js +59 -78
- package/lib/yarn2-package-manager.js +60 -79
- package/package.json +57 -55
- package/vendor/aab-tool/bundletool.jar +0 -0
- package/lib/common/resources/platform-tools/android/darwin/NOTICE.txt +0 -3407
- package/lib/common/resources/platform-tools/android/darwin/adb +0 -0
- package/lib/common/resources/platform-tools/android/linux/NOTICE.txt +0 -4451
- package/lib/common/resources/platform-tools/android/linux/adb +0 -0
- package/lib/common/resources/platform-tools/android/win32/AdbWinApi.dll +0 -0
- package/lib/common/resources/platform-tools/android/win32/AdbWinUsbApi.dll +0 -0
- package/lib/common/resources/platform-tools/android/win32/NOTICE.txt +0 -4451
- package/lib/common/resources/platform-tools/android/win32/adb.exe +0 -0
- package/lib/common/resources/platform-tools/android/win32/fastboot.exe +0 -0
|
@@ -5,15 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
9
|
exports.DevicesService = void 0;
|
|
19
10
|
const assert = require("assert");
|
|
@@ -63,107 +54,101 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
63
54
|
this.$iOSSimulatorDiscovery,
|
|
64
55
|
];
|
|
65
56
|
}
|
|
66
|
-
pickSingleDevice(options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
async pickSingleDevice(options) {
|
|
58
|
+
if (options.onlyDevices && options.onlyEmulators) {
|
|
59
|
+
this.$errors.fail(constants_1.DebugCommandErrors.UNABLE_TO_USE_FOR_DEVICE_AND_EMULATOR);
|
|
60
|
+
}
|
|
61
|
+
if (options.deviceId) {
|
|
62
|
+
const device = await this.getDevice(options.deviceId);
|
|
63
|
+
return device;
|
|
64
|
+
}
|
|
65
|
+
const availableDevicesAndEmulators = this.getDeviceInstances().filter((d) => d.deviceInfo.status === constants_2.CONNECTED_STATUS &&
|
|
66
|
+
(!this.platform ||
|
|
67
|
+
d.deviceInfo.platform.toLowerCase() === this.platform.toLowerCase()));
|
|
68
|
+
const selectedDevices = availableDevicesAndEmulators.filter((d) => options.onlyEmulators
|
|
69
|
+
? d.isEmulator
|
|
70
|
+
: options.onlyDevices
|
|
71
|
+
? !d.isEmulator
|
|
72
|
+
: true);
|
|
73
|
+
if (selectedDevices.length > 1) {
|
|
74
|
+
if ((0, helpers_1.isInteractive)()) {
|
|
75
|
+
const choices = selectedDevices.map((e) => `${e.deviceInfo.identifier} - ${e.deviceInfo.displayName}`);
|
|
76
|
+
const selectedDeviceString = await this.$prompter.promptForChoice("Select device for debugging", choices);
|
|
77
|
+
const selectedDevice = _.find(selectedDevices, (d) => `${d.deviceInfo.identifier} - ${d.deviceInfo.displayName}` ===
|
|
78
|
+
selectedDeviceString);
|
|
79
|
+
return selectedDevice;
|
|
74
80
|
}
|
|
75
|
-
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
: true);
|
|
83
|
-
if (selectedDevices.length > 1) {
|
|
84
|
-
if ((0, helpers_1.isInteractive)()) {
|
|
85
|
-
const choices = selectedDevices.map((e) => `${e.deviceInfo.identifier} - ${e.deviceInfo.displayName}`);
|
|
86
|
-
const selectedDeviceString = yield this.$prompter.promptForChoice("Select device for debugging", choices);
|
|
87
|
-
const selectedDevice = _.find(selectedDevices, (d) => `${d.deviceInfo.identifier} - ${d.deviceInfo.displayName}` ===
|
|
88
|
-
selectedDeviceString);
|
|
89
|
-
return selectedDevice;
|
|
81
|
+
else {
|
|
82
|
+
const sortedInstances = _.sortBy(selectedDevices, (e) => e.deviceInfo.version);
|
|
83
|
+
const emulators = sortedInstances.filter((e) => e.isEmulator);
|
|
84
|
+
const devices = sortedInstances.filter((d) => !d.isEmulator);
|
|
85
|
+
let selectedInstance;
|
|
86
|
+
if (options.onlyEmulators || options.onlyDevices) {
|
|
87
|
+
selectedInstance = _.last(sortedInstances);
|
|
90
88
|
}
|
|
91
89
|
else {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const devices = sortedInstances.filter((d) => !d.isEmulator);
|
|
95
|
-
let selectedInstance;
|
|
96
|
-
if (options.onlyEmulators || options.onlyDevices) {
|
|
97
|
-
selectedInstance = _.last(sortedInstances);
|
|
90
|
+
if (emulators.length) {
|
|
91
|
+
selectedInstance = _.last(emulators);
|
|
98
92
|
}
|
|
99
93
|
else {
|
|
100
|
-
|
|
101
|
-
selectedInstance = _.last(emulators);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
selectedInstance = _.last(devices);
|
|
105
|
-
}
|
|
94
|
+
selectedInstance = _.last(devices);
|
|
106
95
|
}
|
|
107
|
-
this.$logger.warn(`Multiple devices/emulators found. Starting debugger on ${selectedInstance.deviceInfo.identifier}. ` +
|
|
108
|
-
"If you want to debug on specific device/emulator, you can specify it with --device option.");
|
|
109
|
-
return selectedInstance;
|
|
110
96
|
}
|
|
97
|
+
this.$logger.warn(`Multiple devices/emulators found. Starting debugger on ${selectedInstance.deviceInfo.identifier}. ` +
|
|
98
|
+
"If you want to debug on specific device/emulator, you can specify it with --device option.");
|
|
99
|
+
return selectedInstance;
|
|
111
100
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
}
|
|
102
|
+
else if (selectedDevices.length === 1) {
|
|
103
|
+
return _.head(selectedDevices);
|
|
104
|
+
}
|
|
105
|
+
this.$errors.fail(constants_1.DebugCommandErrors.NO_DEVICES_EMULATORS_FOUND_FOR_OPTIONS);
|
|
117
106
|
}
|
|
118
|
-
getEmulatorImages(options) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(!options ||
|
|
123
|
-
!options.platform ||
|
|
124
|
-
this.$mobileHelper.isiOSPlatform(options.platform))) {
|
|
125
|
-
result.ios = yield this.$iOSEmulatorServices.getEmulatorImages();
|
|
126
|
-
}
|
|
127
|
-
if (!options ||
|
|
107
|
+
async getEmulatorImages(options) {
|
|
108
|
+
const result = Object.create(null);
|
|
109
|
+
if (this.$hostInfo.isDarwin &&
|
|
110
|
+
(!options ||
|
|
128
111
|
!options.platform ||
|
|
129
|
-
this.$mobileHelper.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
112
|
+
this.$mobileHelper.isiOSPlatform(options.platform))) {
|
|
113
|
+
result.ios = await this.$iOSEmulatorServices.getEmulatorImages();
|
|
114
|
+
}
|
|
115
|
+
if (!options ||
|
|
116
|
+
!options.platform ||
|
|
117
|
+
this.$mobileHelper.isAndroidPlatform(options.platform)) {
|
|
118
|
+
result.android = await this.$androidEmulatorServices.getEmulatorImages();
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
134
121
|
}
|
|
135
|
-
startEmulator(options) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
platform: options.platform,
|
|
142
|
-
});
|
|
143
|
-
const emulators = this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
|
|
144
|
-
const errors = this.$emulatorHelper.getErrorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
|
|
145
|
-
let emulator = null;
|
|
146
|
-
if (options.imageIdentifier) {
|
|
147
|
-
emulator = this.$emulatorHelper.getEmulatorByImageIdentifier(options.imageIdentifier, emulators);
|
|
148
|
-
}
|
|
149
|
-
else if (options.emulatorIdOrName) {
|
|
150
|
-
emulator = this.$emulatorHelper.getEmulatorByIdOrName(options.emulatorIdOrName, emulators);
|
|
151
|
-
}
|
|
152
|
-
if (!emulator) {
|
|
153
|
-
const additionalErrors = errors && errors.length ? errors : [];
|
|
154
|
-
return [
|
|
155
|
-
`Unable to find emulator with provided options: ${options}`,
|
|
156
|
-
...additionalErrors,
|
|
157
|
-
];
|
|
158
|
-
}
|
|
159
|
-
if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
options.emulator = emulator;
|
|
163
|
-
const emulatorService = this.resolveEmulatorServices(emulator.platform);
|
|
164
|
-
const result = yield emulatorService.startEmulator(options);
|
|
165
|
-
return result.errors && result.errors.length ? result.errors : null;
|
|
122
|
+
async startEmulator(options) {
|
|
123
|
+
if (!options || (!options.imageIdentifier && !options.emulatorIdOrName)) {
|
|
124
|
+
return ["Missing mandatory image identifier or name option."];
|
|
125
|
+
}
|
|
126
|
+
const availableEmulatorsOutput = await this.getEmulatorImages({
|
|
127
|
+
platform: options.platform,
|
|
166
128
|
});
|
|
129
|
+
const emulators = this.$emulatorHelper.getEmulatorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
|
|
130
|
+
const errors = this.$emulatorHelper.getErrorsFromAvailableEmulatorsOutput(availableEmulatorsOutput);
|
|
131
|
+
let emulator = null;
|
|
132
|
+
if (options.imageIdentifier) {
|
|
133
|
+
emulator = this.$emulatorHelper.getEmulatorByImageIdentifier(options.imageIdentifier, emulators);
|
|
134
|
+
}
|
|
135
|
+
else if (options.emulatorIdOrName) {
|
|
136
|
+
emulator = this.$emulatorHelper.getEmulatorByIdOrName(options.emulatorIdOrName, emulators);
|
|
137
|
+
}
|
|
138
|
+
if (!emulator) {
|
|
139
|
+
const additionalErrors = errors && errors.length ? errors : [];
|
|
140
|
+
return [
|
|
141
|
+
`Unable to find emulator with provided options: ${options}`,
|
|
142
|
+
...additionalErrors,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
if (emulator.status === constants.RUNNING_EMULATOR_STATUS) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
options.emulator = emulator;
|
|
149
|
+
const emulatorService = this.resolveEmulatorServices(emulator.platform);
|
|
150
|
+
const result = await emulatorService.startEmulator(options);
|
|
151
|
+
return result.errors && result.errors.length ? result.errors : null;
|
|
167
152
|
}
|
|
168
153
|
get platform() {
|
|
169
154
|
return this._platform;
|
|
@@ -207,11 +192,9 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
207
192
|
return device;
|
|
208
193
|
});
|
|
209
194
|
}
|
|
210
|
-
getInstalledApplications(deviceIdentifier) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return device.applicationManager.getInstalledApplications();
|
|
214
|
-
});
|
|
195
|
+
async getInstalledApplications(deviceIdentifier) {
|
|
196
|
+
const device = await this.getDevice(deviceIdentifier);
|
|
197
|
+
return device.applicationManager.getInstalledApplications();
|
|
215
198
|
}
|
|
216
199
|
addDeviceDiscovery(deviceDiscovery) {
|
|
217
200
|
this._otherDeviceDiscoveries.push(deviceDiscovery);
|
|
@@ -264,66 +247,62 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
264
247
|
delete this._availableEmulators[emulator.imageIdentifier];
|
|
265
248
|
this.emit(constants.EmulatorDiscoveryNames.EMULATOR_IMAGE_LOST, emulator);
|
|
266
249
|
}
|
|
267
|
-
detectCurrentlyAttachedDevices(deviceInitOpts) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
for (const deviceDiscovery of this._allDeviceDiscoveries) {
|
|
271
|
-
try {
|
|
272
|
-
yield deviceDiscovery.startLookingForDevices(options);
|
|
273
|
-
}
|
|
274
|
-
catch (err) {
|
|
275
|
-
this.$logger.trace("Error while checking for devices.", err);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
detectCurrentlyAvailableEmulators() {
|
|
281
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
-
try {
|
|
283
|
-
yield this.$androidEmulatorDiscovery.startLookingForDevices();
|
|
284
|
-
}
|
|
285
|
-
catch (err) {
|
|
286
|
-
this.$logger.trace(`Error while checking for Android emulators. ${err}`);
|
|
287
|
-
}
|
|
250
|
+
async detectCurrentlyAttachedDevices(deviceInitOpts) {
|
|
251
|
+
const options = this.getDeviceLookingOptions(deviceInitOpts);
|
|
252
|
+
for (const deviceDiscovery of this._allDeviceDiscoveries) {
|
|
288
253
|
try {
|
|
289
|
-
|
|
254
|
+
await deviceDiscovery.startLookingForDevices(options);
|
|
290
255
|
}
|
|
291
256
|
catch (err) {
|
|
292
|
-
this.$logger.trace(
|
|
257
|
+
this.$logger.trace("Error while checking for devices.", err);
|
|
293
258
|
}
|
|
294
|
-
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async detectCurrentlyAvailableEmulators() {
|
|
262
|
+
try {
|
|
263
|
+
await this.$androidEmulatorDiscovery.startLookingForDevices();
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
this.$logger.trace(`Error while checking for Android emulators. ${err}`);
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
await this.$iOSSimulatorDiscovery.checkForAvailableSimulators();
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
this.$logger.trace(`Error while checking for iOS simulators. ${err}`);
|
|
273
|
+
}
|
|
295
274
|
}
|
|
296
275
|
startDeviceDetectionInterval(deviceInitOpts = {}) {
|
|
297
276
|
if (!this.deviceDetectionInterval) {
|
|
298
277
|
let isDeviceDetectionIntervalInProgress = false;
|
|
299
|
-
this.deviceDetectionInterval = setInterval(() =>
|
|
278
|
+
this.deviceDetectionInterval = setInterval(async () => {
|
|
300
279
|
if (isDeviceDetectionIntervalInProgress) {
|
|
301
280
|
return;
|
|
302
281
|
}
|
|
303
282
|
isDeviceDetectionIntervalInProgress = true;
|
|
304
|
-
|
|
283
|
+
await this.detectCurrentlyAttachedDevices(deviceInitOpts);
|
|
305
284
|
try {
|
|
306
285
|
const trustedDevices = _.filter(this._devices, (device) => device.deviceInfo.status === constants.CONNECTED_STATUS);
|
|
307
|
-
|
|
286
|
+
await (0, helpers_1.settlePromises)(_.map(trustedDevices, (device) => device.applicationManager.checkForApplicationUpdates()));
|
|
308
287
|
}
|
|
309
288
|
catch (err) {
|
|
310
289
|
this.$logger.trace("Error checking for application updates on devices.", err);
|
|
311
290
|
}
|
|
312
291
|
isDeviceDetectionIntervalInProgress = false;
|
|
313
|
-
}
|
|
292
|
+
}, deviceInitOpts.detectionInterval || DevicesService.DEVICE_LOOKING_INTERVAL);
|
|
314
293
|
this.deviceDetectionInterval.unref();
|
|
315
294
|
}
|
|
316
295
|
}
|
|
317
296
|
startEmulatorDetectionInterval(opts = {}) {
|
|
318
297
|
let isEmulatorDetectionIntervalRunning = false;
|
|
319
|
-
this.emulatorDetectionInterval = setInterval(() =>
|
|
298
|
+
this.emulatorDetectionInterval = setInterval(async () => {
|
|
320
299
|
if (isEmulatorDetectionIntervalRunning) {
|
|
321
300
|
return;
|
|
322
301
|
}
|
|
323
302
|
isEmulatorDetectionIntervalRunning = true;
|
|
324
|
-
|
|
303
|
+
await this.detectCurrentlyAvailableEmulators();
|
|
325
304
|
isEmulatorDetectionIntervalRunning = false;
|
|
326
|
-
}
|
|
305
|
+
}, opts.detectionInterval || DevicesService.EMULATOR_IMAGES_DETECTION_INTERVAL);
|
|
327
306
|
this.emulatorDetectionInterval.unref();
|
|
328
307
|
}
|
|
329
308
|
stopDeviceDetectionInterval() {
|
|
@@ -351,89 +330,81 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
351
330
|
}
|
|
352
331
|
return searchedDevice;
|
|
353
332
|
}
|
|
354
|
-
startLookingForDevices(deviceInitOpts) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
yield this.startDeviceDetectionInterval(deviceInitOpts);
|
|
363
|
-
});
|
|
333
|
+
async startLookingForDevices(deviceInitOpts) {
|
|
334
|
+
this.$logger.trace("startLookingForDevices; platform is %s", this._platform);
|
|
335
|
+
if (this._platform) {
|
|
336
|
+
return this.detectCurrentlyAttachedDevices(deviceInitOpts);
|
|
337
|
+
}
|
|
338
|
+
await this.detectCurrentlyAttachedDevices(deviceInitOpts);
|
|
339
|
+
await this.detectCurrentlyAvailableEmulators();
|
|
340
|
+
await this.startDeviceDetectionInterval(deviceInitOpts);
|
|
364
341
|
}
|
|
365
342
|
getDeviceByIndex(index) {
|
|
366
343
|
this.validateIndex(index - 1);
|
|
367
344
|
return this.getDeviceInstances()[index - 1];
|
|
368
345
|
}
|
|
369
|
-
getDevice(deviceOption) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
this.$
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return device;
|
|
388
|
-
});
|
|
346
|
+
async getDevice(deviceOption) {
|
|
347
|
+
let device = null;
|
|
348
|
+
if (!device) {
|
|
349
|
+
device = _.find(this.getDeviceInstances(), (d) => (d.deviceInfo.identifier &&
|
|
350
|
+
d.deviceInfo.identifier === deviceOption) ||
|
|
351
|
+
(d.deviceInfo.displayName &&
|
|
352
|
+
d.deviceInfo.displayName === deviceOption) ||
|
|
353
|
+
(d.deviceInfo.imageIdentifier &&
|
|
354
|
+
d.deviceInfo.imageIdentifier === deviceOption));
|
|
355
|
+
}
|
|
356
|
+
if (!device && helpers.isNumberWithoutExponent(deviceOption)) {
|
|
357
|
+
device = this.getDeviceByIndex(parseInt(deviceOption, 10));
|
|
358
|
+
}
|
|
359
|
+
if (!device) {
|
|
360
|
+
this.$errors.fail(this.$messages.Devices
|
|
361
|
+
.NotFoundDeviceByIdentifierErrorMessageWithIdentifier, deviceOption, this.$staticConfig.CLIENT_NAME.toLowerCase());
|
|
362
|
+
}
|
|
363
|
+
return device;
|
|
389
364
|
}
|
|
390
|
-
executeOnDevice(action, canExecute) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
});
|
|
365
|
+
async executeOnDevice(action, canExecute) {
|
|
366
|
+
if (!canExecute || canExecute(this._device)) {
|
|
367
|
+
return {
|
|
368
|
+
deviceIdentifier: this._device.deviceInfo.identifier,
|
|
369
|
+
result: await action(this._device),
|
|
370
|
+
};
|
|
371
|
+
}
|
|
399
372
|
}
|
|
400
|
-
executeOnAllConnectedDevices(action, canExecute) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
catch (err) {
|
|
416
|
-
err.deviceIdentifier = device.deviceInfo.identifier;
|
|
417
|
-
this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is`, err);
|
|
418
|
-
errors.push(err);
|
|
373
|
+
async executeOnAllConnectedDevices(action, canExecute) {
|
|
374
|
+
const devices = this.filterDevicesByPlatform();
|
|
375
|
+
const sortedDevices = _.sortBy(devices, (device) => device.deviceInfo.platform);
|
|
376
|
+
const result = [];
|
|
377
|
+
const errors = [];
|
|
378
|
+
for (const device of sortedDevices) {
|
|
379
|
+
try {
|
|
380
|
+
if (!canExecute || canExecute(device)) {
|
|
381
|
+
result.push({
|
|
382
|
+
deviceIdentifier: device.deviceInfo.identifier,
|
|
383
|
+
result: await action(device),
|
|
384
|
+
});
|
|
419
385
|
}
|
|
420
386
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
const errorMessage = `${preErrorMsg}${errors
|
|
427
|
-
.map((e) => e.stack || e.message || e)
|
|
428
|
-
.join(os_1.EOL)}`;
|
|
429
|
-
this.$errors.fail(errorMessage);
|
|
387
|
+
catch (err) {
|
|
388
|
+
err.deviceIdentifier = device.deviceInfo.identifier;
|
|
389
|
+
this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is`, err);
|
|
390
|
+
errors.push(err);
|
|
430
391
|
}
|
|
431
|
-
|
|
432
|
-
|
|
392
|
+
}
|
|
393
|
+
if (errors.length) {
|
|
394
|
+
let preErrorMsg = "";
|
|
395
|
+
if (errors.length > 1) {
|
|
396
|
+
preErrorMsg = "Multiple errors were thrown:" + os_1.EOL;
|
|
397
|
+
}
|
|
398
|
+
const errorMessage = `${preErrorMsg}${errors
|
|
399
|
+
.map((e) => e.stack || e.message || e)
|
|
400
|
+
.join(os_1.EOL)}`;
|
|
401
|
+
this.$errors.fail(errorMessage);
|
|
402
|
+
}
|
|
403
|
+
return result;
|
|
433
404
|
}
|
|
434
405
|
deployOnDevices(deviceIdentifiers, packagePath, appId, projectName, projectDir) {
|
|
435
406
|
this.$logger.trace(`Called deployOnDevices for identifiers ${deviceIdentifiers} for packageFile: ${packagePath}. Application identifier is ${appId}. Project Name is: ${projectName}`);
|
|
436
|
-
return _.map(deviceIdentifiers, (deviceIdentifier) =>
|
|
407
|
+
return _.map(deviceIdentifiers, async (deviceIdentifier) => {
|
|
437
408
|
const device = this.getDeviceByIdentifier(deviceIdentifier);
|
|
438
409
|
let identifier;
|
|
439
410
|
if (typeof appId === "string") {
|
|
@@ -448,117 +419,109 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
448
419
|
projectName,
|
|
449
420
|
projectDir,
|
|
450
421
|
});
|
|
451
|
-
})
|
|
422
|
+
});
|
|
452
423
|
}
|
|
453
|
-
execute(action, canExecute, options) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (this.
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
424
|
+
async execute(action, canExecute, options) {
|
|
425
|
+
assert.ok(this._isInitialized, "Devices services not initialized!");
|
|
426
|
+
if (this.hasDevices) {
|
|
427
|
+
if (this.$hostInfo.isDarwin &&
|
|
428
|
+
this._platform &&
|
|
429
|
+
this.$mobileHelper.isiOSPlatform(this._platform) &&
|
|
430
|
+
this.$options.emulator &&
|
|
431
|
+
!this.isOnlyiOSSimultorRunning()) {
|
|
432
|
+
const originalCanExecute = canExecute;
|
|
433
|
+
canExecute = (dev) => this.isiOSSimulator(dev) &&
|
|
434
|
+
(!originalCanExecute || !!originalCanExecute(dev));
|
|
435
|
+
}
|
|
436
|
+
return this.executeCore(action, canExecute);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
const message = constants.ERROR_NO_DEVICES;
|
|
440
|
+
if (options && options.allowNoDevices) {
|
|
441
|
+
this.$logger.info(message);
|
|
467
442
|
}
|
|
468
443
|
else {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
this.$
|
|
444
|
+
if (!this.$hostInfo.isDarwin &&
|
|
445
|
+
this._platform &&
|
|
446
|
+
this.$mobileHelper.isiOSPlatform(this._platform)) {
|
|
447
|
+
this.$errors.fail(message);
|
|
472
448
|
}
|
|
473
449
|
else {
|
|
474
|
-
|
|
475
|
-
this._platform &&
|
|
476
|
-
this.$mobileHelper.isiOSPlatform(this._platform)) {
|
|
477
|
-
this.$errors.fail(message);
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
return this.executeCore(action, canExecute);
|
|
481
|
-
}
|
|
450
|
+
return this.executeCore(action, canExecute);
|
|
482
451
|
}
|
|
483
452
|
}
|
|
484
|
-
}
|
|
453
|
+
}
|
|
485
454
|
}
|
|
486
|
-
startEmulatorIfNecessary(deviceInitOpts) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
this.$errors.fail(`--device and --emulator are incompatible options.
|
|
455
|
+
async startEmulatorIfNecessary(deviceInitOpts) {
|
|
456
|
+
if (deviceInitOpts && deviceInitOpts.deviceId && deviceInitOpts.emulator) {
|
|
457
|
+
this.$errors.fail(`--device and --emulator are incompatible options.
|
|
490
458
|
If you are trying to run on specific emulator, use "${this.$staticConfig.CLIENT_NAME} run --device <DeviceID>`);
|
|
459
|
+
}
|
|
460
|
+
if (deviceInitOpts &&
|
|
461
|
+
deviceInitOpts.platform &&
|
|
462
|
+
!deviceInitOpts.skipEmulatorStart) {
|
|
463
|
+
this._platform = deviceInitOpts.platform;
|
|
464
|
+
try {
|
|
465
|
+
await this.startLookingForDevices(deviceInitOpts);
|
|
491
466
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
!deviceInitOpts.skipEmulatorStart) {
|
|
495
|
-
this._platform = deviceInitOpts.platform;
|
|
496
|
-
try {
|
|
497
|
-
yield this.startLookingForDevices(deviceInitOpts);
|
|
498
|
-
}
|
|
499
|
-
catch (err) {
|
|
500
|
-
this.$logger.trace("Error while checking for devices.", err);
|
|
501
|
-
}
|
|
502
|
-
const deviceInstances = this.getDeviceInstances();
|
|
503
|
-
if (!deviceInitOpts.deviceId && _.isEmpty(deviceInstances)) {
|
|
504
|
-
if (!this.$hostInfo.isDarwin &&
|
|
505
|
-
this.$mobileHelper.isApplePlatform(deviceInitOpts.platform)) {
|
|
506
|
-
this.$errors.fail(constants.ERROR_NO_DEVICES_CANT_USE_IOS_SIMULATOR);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
try {
|
|
510
|
-
yield this._startEmulatorIfNecessary(deviceInitOpts);
|
|
511
|
-
}
|
|
512
|
-
catch (err) {
|
|
513
|
-
const errorMessage = this.getEmulatorError(err, deviceInitOpts.platform);
|
|
514
|
-
this.$errors.fail(errorMessage);
|
|
515
|
-
}
|
|
467
|
+
catch (err) {
|
|
468
|
+
this.$logger.trace("Error while checking for devices.", err);
|
|
516
469
|
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
_startEmulatorIfNecessary(data) {
|
|
520
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
521
470
|
const deviceInstances = this.getDeviceInstances();
|
|
522
|
-
if (!
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (!helpers.isNumberWithoutExponent(data.deviceId)) {
|
|
527
|
-
const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
|
|
528
|
-
if (!activeDeviceInstance) {
|
|
529
|
-
return this.startEmulatorCore(data);
|
|
530
|
-
}
|
|
471
|
+
if (!deviceInitOpts.deviceId && _.isEmpty(deviceInstances)) {
|
|
472
|
+
if (!this.$hostInfo.isDarwin &&
|
|
473
|
+
this.$mobileHelper.isApplePlatform(deviceInitOpts.platform)) {
|
|
474
|
+
this.$errors.fail(constants.ERROR_NO_DEVICES_CANT_USE_IOS_SIMULATOR);
|
|
531
475
|
}
|
|
532
476
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform === this.$devicePlatformsConstants.visionOS);
|
|
536
|
-
if (!runningDeviceInstance) {
|
|
537
|
-
return this.startEmulatorCore(data);
|
|
538
|
-
}
|
|
477
|
+
try {
|
|
478
|
+
await this._startEmulatorIfNecessary(deviceInitOpts);
|
|
539
479
|
}
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
return this.startEmulatorCore(data);
|
|
544
|
-
}
|
|
480
|
+
catch (err) {
|
|
481
|
+
const errorMessage = this.getEmulatorError(err, deviceInitOpts.platform);
|
|
482
|
+
this.$errors.fail(errorMessage);
|
|
545
483
|
}
|
|
546
|
-
}
|
|
484
|
+
}
|
|
547
485
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
486
|
+
async _startEmulatorIfNecessary(data) {
|
|
487
|
+
const deviceInstances = this.getDeviceInstances();
|
|
488
|
+
if (!data.deviceId && _.isEmpty(deviceInstances)) {
|
|
489
|
+
return this.startEmulatorCore(data);
|
|
490
|
+
}
|
|
491
|
+
if (data.deviceId) {
|
|
492
|
+
if (!helpers.isNumberWithoutExponent(data.deviceId)) {
|
|
493
|
+
const activeDeviceInstance = _.find(deviceInstances, (device) => device.deviceInfo.identifier === data.deviceId);
|
|
494
|
+
if (!activeDeviceInstance) {
|
|
495
|
+
return this.startEmulatorCore(data);
|
|
496
|
+
}
|
|
552
497
|
}
|
|
553
|
-
|
|
554
|
-
|
|
498
|
+
}
|
|
499
|
+
if (data.platform === this.$devicePlatformsConstants.visionOS &&
|
|
500
|
+
deviceInstances.length) {
|
|
501
|
+
const runningDeviceInstance = deviceInstances.find((device) => device.deviceInfo.platform === this.$devicePlatformsConstants.visionOS);
|
|
502
|
+
if (!runningDeviceInstance) {
|
|
503
|
+
return this.startEmulatorCore(data);
|
|
555
504
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
505
|
+
}
|
|
506
|
+
if (data.emulator && deviceInstances.length) {
|
|
507
|
+
const runningDeviceInstance = _.some(deviceInstances, (value) => value.isEmulator);
|
|
508
|
+
if (!runningDeviceInstance) {
|
|
509
|
+
return this.startEmulatorCore(data);
|
|
560
510
|
}
|
|
561
|
-
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
async initialize(data) {
|
|
514
|
+
if (!this._deviceInitializePromise) {
|
|
515
|
+
this._deviceInitializePromise = this.initializeCore(data);
|
|
516
|
+
}
|
|
517
|
+
try {
|
|
518
|
+
await this._deviceInitializePromise;
|
|
519
|
+
}
|
|
520
|
+
catch (err) {
|
|
521
|
+
this.$logger.trace(`Error while initializing devicesService: ${err}`);
|
|
522
|
+
this._deviceInitializePromise = null;
|
|
523
|
+
throw err;
|
|
524
|
+
}
|
|
562
525
|
}
|
|
563
526
|
getPlatformsFromDeviceDescriptors(deviceDescriptors) {
|
|
564
527
|
const platforms = _(deviceDescriptors)
|
|
@@ -568,91 +531,89 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
568
531
|
.value();
|
|
569
532
|
return platforms;
|
|
570
533
|
}
|
|
571
|
-
initializeCore(deviceInitOpts) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
534
|
+
async initializeCore(deviceInitOpts) {
|
|
535
|
+
if (this._isInitialized) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (!this.$options.json) {
|
|
539
|
+
this.$logger.info("Searching for devices...");
|
|
540
|
+
}
|
|
541
|
+
deviceInitOpts = deviceInitOpts || {};
|
|
542
|
+
this._data = deviceInitOpts;
|
|
543
|
+
if (!deviceInitOpts.skipEmulatorStart) {
|
|
544
|
+
await this.startEmulatorIfNecessary(deviceInitOpts);
|
|
545
|
+
}
|
|
546
|
+
const platform = deviceInitOpts.platform;
|
|
547
|
+
const deviceOption = deviceInitOpts.deviceId;
|
|
548
|
+
const deviceLookingOptions = {
|
|
549
|
+
emulator: deviceInitOpts.emulator,
|
|
550
|
+
platform: deviceInitOpts.platform,
|
|
551
|
+
shouldReturnImmediateResult: deviceInitOpts.shouldReturnImmediateResult,
|
|
552
|
+
detectionInterval: deviceInitOpts.detectionInterval,
|
|
553
|
+
fullDiscovery: deviceInitOpts.fullDiscovery,
|
|
554
|
+
};
|
|
555
|
+
if (platform && deviceOption) {
|
|
556
|
+
this._platform = this.$mobileHelper.validatePlatformName(deviceInitOpts.platform);
|
|
557
|
+
await this.startLookingForDevices(deviceLookingOptions);
|
|
558
|
+
this._device = await this.getDevice(deviceOption);
|
|
559
|
+
if (this._device.deviceInfo.platform !== this._platform) {
|
|
560
|
+
this.$errors.fail(constants.ERROR_CANNOT_RESOLVE_DEVICE);
|
|
561
|
+
}
|
|
562
|
+
this.$logger.warn("Your application will be deployed only on the device specified by the provided index or identifier.");
|
|
563
|
+
}
|
|
564
|
+
else if (!platform && deviceOption) {
|
|
565
|
+
await this.startLookingForDevices(deviceLookingOptions);
|
|
566
|
+
this._device = await this.getDevice(deviceOption);
|
|
567
|
+
this._platform = this._device.deviceInfo.platform;
|
|
568
|
+
}
|
|
569
|
+
else if (platform && !deviceOption) {
|
|
570
|
+
this._platform = this.$mobileHelper.validatePlatformName(platform);
|
|
571
|
+
await this.startLookingForDevices(deviceLookingOptions);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
if (deviceInitOpts.skipInferPlatform) {
|
|
575
|
+
if (deviceInitOpts.skipDeviceDetectionInterval) {
|
|
576
|
+
await this.detectCurrentlyAttachedDevices(deviceLookingOptions);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
deviceInitOpts.shouldReturnImmediateResult = true;
|
|
580
|
+
await this.startLookingForDevices(deviceLookingOptions);
|
|
599
581
|
}
|
|
600
|
-
this.$logger.warn("Your application will be deployed only on the device specified by the provided index or identifier.");
|
|
601
|
-
}
|
|
602
|
-
else if (!platform && deviceOption) {
|
|
603
|
-
yield this.startLookingForDevices(deviceLookingOptions);
|
|
604
|
-
this._device = yield this.getDevice(deviceOption);
|
|
605
|
-
this._platform = this._device.deviceInfo.platform;
|
|
606
|
-
}
|
|
607
|
-
else if (platform && !deviceOption) {
|
|
608
|
-
this._platform = this.$mobileHelper.validatePlatformName(platform);
|
|
609
|
-
yield this.startLookingForDevices(deviceLookingOptions);
|
|
610
582
|
}
|
|
611
583
|
else {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
584
|
+
await this.startLookingForDevices(deviceLookingOptions);
|
|
585
|
+
const devices = this.getDeviceInstances();
|
|
586
|
+
const platforms = _(devices)
|
|
587
|
+
.map((device) => device.deviceInfo.platform)
|
|
588
|
+
.filter((pl) => {
|
|
589
|
+
try {
|
|
590
|
+
return !!this.$mobileHelper.validatePlatformName(pl);
|
|
615
591
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
592
|
+
catch (err) {
|
|
593
|
+
this.$logger.warn(err.message);
|
|
594
|
+
return null;
|
|
619
595
|
}
|
|
596
|
+
})
|
|
597
|
+
.uniq()
|
|
598
|
+
.value();
|
|
599
|
+
if (platforms.length === 1) {
|
|
600
|
+
this._platform = platforms[0];
|
|
601
|
+
}
|
|
602
|
+
else if (platforms.length === 0) {
|
|
603
|
+
this.$errors.fail(constants.ERROR_NO_DEVICES);
|
|
620
604
|
}
|
|
621
605
|
else {
|
|
622
|
-
|
|
623
|
-
const devices = this.getDeviceInstances();
|
|
624
|
-
const platforms = _(devices)
|
|
625
|
-
.map((device) => device.deviceInfo.platform)
|
|
626
|
-
.filter((pl) => {
|
|
627
|
-
try {
|
|
628
|
-
return !!this.$mobileHelper.validatePlatformName(pl);
|
|
629
|
-
}
|
|
630
|
-
catch (err) {
|
|
631
|
-
this.$logger.warn(err.message);
|
|
632
|
-
return null;
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
.uniq()
|
|
636
|
-
.value();
|
|
637
|
-
if (platforms.length === 1) {
|
|
638
|
-
this._platform = platforms[0];
|
|
639
|
-
}
|
|
640
|
-
else if (platforms.length === 0) {
|
|
641
|
-
this.$errors.fail(constants.ERROR_NO_DEVICES);
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
this.$errors.fail("Multiple device platforms detected (%s). Specify platform or device on command line.", helpers.formatListOfNames(platforms, "and"));
|
|
645
|
-
}
|
|
606
|
+
this.$errors.fail("Multiple device platforms detected (%s). Specify platform or device on command line.", helpers.formatListOfNames(platforms, "and"));
|
|
646
607
|
}
|
|
647
608
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
609
|
+
}
|
|
610
|
+
if (!this.$hostInfo.isDarwin &&
|
|
611
|
+
this._platform &&
|
|
612
|
+
this.$mobileHelper.isiOSPlatform(this._platform) &&
|
|
613
|
+
this.$options.emulator) {
|
|
614
|
+
this.$errors.fail(constants.ERROR_CANT_USE_SIMULATOR);
|
|
615
|
+
}
|
|
616
|
+
this._isInitialized = true;
|
|
656
617
|
}
|
|
657
618
|
get hasDevices() {
|
|
658
619
|
if (!this._platform) {
|
|
@@ -672,30 +633,24 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
672
633
|
getDeviceByDeviceOption() {
|
|
673
634
|
return this._device;
|
|
674
635
|
}
|
|
675
|
-
mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework) {
|
|
676
|
-
return
|
|
677
|
-
return this.$androidProcessService.mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework);
|
|
678
|
-
});
|
|
636
|
+
async mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework) {
|
|
637
|
+
return this.$androidProcessService.mapAbstractToTcpPort(deviceIdentifier, appIdentifier, framework);
|
|
679
638
|
}
|
|
680
639
|
getDebuggableApps(deviceIdentifiers) {
|
|
681
640
|
return _.map(deviceIdentifiers, (deviceIdentifier) => this.getDebuggableAppsCore(deviceIdentifier));
|
|
682
641
|
}
|
|
683
|
-
getDebuggableViews(deviceIdentifier, appIdentifier) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
return debuggableViewsPerApp && debuggableViewsPerApp[appIdentifier];
|
|
687
|
-
});
|
|
642
|
+
async getDebuggableViews(deviceIdentifier, appIdentifier) {
|
|
643
|
+
const device = this.getDeviceByIdentifier(deviceIdentifier), debuggableViewsPerApp = await device.applicationManager.getDebuggableAppViews([appIdentifier]);
|
|
644
|
+
return debuggableViewsPerApp && debuggableViewsPerApp[appIdentifier];
|
|
688
645
|
}
|
|
689
646
|
getDebuggableAppsCore(deviceIdentifier) {
|
|
690
647
|
const device = this.getDeviceByIdentifier(deviceIdentifier);
|
|
691
648
|
return device.applicationManager.getDebuggableApps();
|
|
692
649
|
}
|
|
693
|
-
deployOnDevice(device, appData) {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
yield device.applicationManager.tryStartApplication(appData);
|
|
698
|
-
});
|
|
650
|
+
async deployOnDevice(device, appData) {
|
|
651
|
+
await device.applicationManager.reinstallApplication(appData.appId, appData.packagePath);
|
|
652
|
+
this.$logger.info(`Successfully deployed on device with identifier '${device.deviceInfo.identifier}'.`);
|
|
653
|
+
await device.applicationManager.tryStartApplication(appData);
|
|
699
654
|
}
|
|
700
655
|
filterDevicesByPlatform() {
|
|
701
656
|
return _.filter(this.getDeviceInstances(), (device) => {
|
|
@@ -723,58 +678,52 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
723
678
|
}
|
|
724
679
|
return null;
|
|
725
680
|
}
|
|
726
|
-
startEmulatorCore(deviceInitOpts = {}) {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
sdk: this._data && this._data.sdk,
|
|
739
|
-
});
|
|
740
|
-
if (result && result.errors && result.errors.length) {
|
|
741
|
-
this.$errors.fail(result.errors.join("\n"));
|
|
742
|
-
}
|
|
743
|
-
const deviceLookingOptions = this.getDeviceLookingOptions(deviceInitOpts);
|
|
744
|
-
if (this.$mobileHelper.isAndroidPlatform(platform)) {
|
|
745
|
-
yield this.$androidDeviceDiscovery.startLookingForDevices(deviceLookingOptions);
|
|
746
|
-
}
|
|
747
|
-
else if (this.$mobileHelper.isiOSPlatform(platform) &&
|
|
748
|
-
this.$hostInfo.isDarwin) {
|
|
749
|
-
yield this.$iOSSimulatorDiscovery.startLookingForDevices(deviceLookingOptions);
|
|
750
|
-
}
|
|
681
|
+
async startEmulatorCore(deviceInitOpts = {}) {
|
|
682
|
+
const { deviceId } = deviceInitOpts;
|
|
683
|
+
const platform = deviceInitOpts.platform || this._platform;
|
|
684
|
+
const emulatorServices = this.resolveEmulatorServices(platform);
|
|
685
|
+
if (!emulatorServices) {
|
|
686
|
+
this.$errors.fail("Unable to detect platform for which to start emulator.");
|
|
687
|
+
}
|
|
688
|
+
const result = await emulatorServices.startEmulator({
|
|
689
|
+
emulatorIdOrName: deviceId,
|
|
690
|
+
imageIdentifier: deviceId,
|
|
691
|
+
platform: platform,
|
|
692
|
+
sdk: this._data && this._data.sdk,
|
|
751
693
|
});
|
|
694
|
+
if (result && result.errors && result.errors.length) {
|
|
695
|
+
this.$errors.fail(result.errors.join("\n"));
|
|
696
|
+
}
|
|
697
|
+
const deviceLookingOptions = this.getDeviceLookingOptions(deviceInitOpts);
|
|
698
|
+
if (this.$mobileHelper.isAndroidPlatform(platform)) {
|
|
699
|
+
await this.$androidDeviceDiscovery.startLookingForDevices(deviceLookingOptions);
|
|
700
|
+
}
|
|
701
|
+
else if (this.$mobileHelper.isiOSPlatform(platform) &&
|
|
702
|
+
this.$hostInfo.isDarwin) {
|
|
703
|
+
await this.$iOSSimulatorDiscovery.startLookingForDevices(deviceLookingOptions);
|
|
704
|
+
}
|
|
752
705
|
}
|
|
753
|
-
executeCore(action, canExecute) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
return this.executeOnAllConnectedDevices(action, canExecute);
|
|
759
|
-
});
|
|
706
|
+
async executeCore(action, canExecute) {
|
|
707
|
+
if (this._device) {
|
|
708
|
+
return [await this.executeOnDevice(action, canExecute)];
|
|
709
|
+
}
|
|
710
|
+
return this.executeOnAllConnectedDevices(action, canExecute);
|
|
760
711
|
}
|
|
761
|
-
isApplicationInstalledOnDevice(deviceIdentifier, appData) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
};
|
|
777
|
-
});
|
|
712
|
+
async isApplicationInstalledOnDevice(deviceIdentifier, appData) {
|
|
713
|
+
let isInstalled = false;
|
|
714
|
+
const device = this.getDeviceByIdentifier(deviceIdentifier);
|
|
715
|
+
try {
|
|
716
|
+
isInstalled = await device.applicationManager.isApplicationInstalled(appData.appId);
|
|
717
|
+
await device.applicationManager.tryStartApplication(appData);
|
|
718
|
+
}
|
|
719
|
+
catch (err) {
|
|
720
|
+
this.$logger.trace("Error while checking is application installed. Error is: ", err);
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
appIdentifier: appData.appId,
|
|
724
|
+
deviceIdentifier,
|
|
725
|
+
isInstalled,
|
|
726
|
+
};
|
|
778
727
|
}
|
|
779
728
|
getDeviceLookingOptions(deviceInitOpts = {}) {
|
|
780
729
|
const { shouldReturnImmediateResult, emulator } = deviceInitOpts;
|
|
@@ -797,6 +746,7 @@ class DevicesService extends events_1.EventEmitter {
|
|
|
797
746
|
`To list available ${emulatorName.toLowerCase()} images, run '${this.$staticConfig.CLIENT_NAME.toLowerCase()} device <Platform> --available-devices'.`);
|
|
798
747
|
}
|
|
799
748
|
}
|
|
749
|
+
exports.DevicesService = DevicesService;
|
|
800
750
|
DevicesService.DEVICE_LOOKING_INTERVAL = 200;
|
|
801
751
|
DevicesService.EMULATOR_IMAGES_DETECTION_INTERVAL = 60 * 1000;
|
|
802
752
|
__decorate([
|
|
@@ -850,5 +800,4 @@ __decorate([
|
|
|
850
800
|
__decorate([
|
|
851
801
|
(0, decorators_1.exported)("devicesService")
|
|
852
802
|
], DevicesService.prototype, "getDebuggableViews", null);
|
|
853
|
-
exports.DevicesService = DevicesService;
|
|
854
803
|
yok_1.injector.register("devicesService", DevicesService);
|