Extract launchSimulator to IOSBridge
Summary: This is related to `simctl` functionality, so can be extracted there. This will aid in future changes whereby we can hide `getDeviceSetPath` in the IOSBridge module Reviewed By: passy Differential Revision: D33842987 fbshipit-source-id: de292ce5afba3e7d79d8ba27c2b8852909d7e6f3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8316a00ef7
commit
959a2a77d7
@@ -11,10 +11,7 @@ import EventEmitter from 'events';
|
||||
import ServerController from './comms/ServerController';
|
||||
import {CertificateExchangeMedium} from './utils/CertificateProvider';
|
||||
import {AndroidDeviceManager} from './devices/android/androidDeviceManager';
|
||||
import {
|
||||
IOSDeviceManager,
|
||||
launchSimulator,
|
||||
} from './devices/ios/iOSDeviceManager';
|
||||
import {IOSDeviceManager} from './devices/ios/iOSDeviceManager';
|
||||
import metroDevice from './devices/metro/metroDeviceManager';
|
||||
import desktopDevice from './devices/desktop/desktopDeviceManager';
|
||||
import {
|
||||
@@ -356,7 +353,8 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
launchEmulator(this.config.settings.androidHome, name, coldBoot),
|
||||
'ios-get-simulators': async (bootedOnly) =>
|
||||
this.ios.getSimulators(bootedOnly),
|
||||
'ios-launch-simulator': async (udid) => launchSimulator(udid),
|
||||
'ios-launch-simulator': async (udid) =>
|
||||
this.ios.simctlBridge.launchSimulator(udid),
|
||||
'persist-settings': async (settings) => saveSettings(settings),
|
||||
'persist-launcher-settings': async (settings) =>
|
||||
saveLauncherSettings(settings),
|
||||
|
||||
@@ -12,7 +12,7 @@ import child_process from 'child_process';
|
||||
import {DeviceType} from 'flipper-common';
|
||||
import {v1 as uuid} from 'uuid';
|
||||
import path from 'path';
|
||||
import {exec} from 'promisify-child-process';
|
||||
import {exec, execFile} from 'promisify-child-process';
|
||||
import {getFlipperServerConfig} from '../../FlipperServerConfig';
|
||||
|
||||
export const ERR_NO_IDB_OR_XCODE_AVAILABLE =
|
||||
@@ -72,7 +72,7 @@ class IDBBridge implements IOSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
class SimctlBridge implements IOSBridge {
|
||||
export class SimctlBridge implements IOSBridge {
|
||||
startLogListener(
|
||||
udid: string,
|
||||
deviceType: DeviceType,
|
||||
@@ -114,6 +114,11 @@ class SimctlBridge implements IOSBridge {
|
||||
`xcrun simctl io ${serial} recordVideo --codec=h264 --force ${outputFile}`,
|
||||
);
|
||||
}
|
||||
|
||||
async launchSimulator(udid: string): Promise<any> {
|
||||
await execFile('xcrun', ['simctl', ...getDeviceSetPath(), 'boot', udid]);
|
||||
await execFile('open', ['-a', 'simulator']);
|
||||
}
|
||||
}
|
||||
|
||||
async function isAvailable(idbPath: string): Promise<boolean> {
|
||||
@@ -155,6 +160,12 @@ async function readScreenshotIntoBuffer(imagePath: string): Promise<Buffer> {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
export function getDeviceSetPath() {
|
||||
return process.env.DEVICE_SET_PATH
|
||||
? ['--set', process.env.DEVICE_SET_PATH]
|
||||
: [];
|
||||
}
|
||||
|
||||
export async function makeIOSBridge(
|
||||
idbPath: string,
|
||||
isXcodeDetected: boolean,
|
||||
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
ERR_NO_IDB_OR_XCODE_AVAILABLE,
|
||||
IOSBridge,
|
||||
makeIOSBridge,
|
||||
getDeviceSetPath,
|
||||
SimctlBridge,
|
||||
} from './IOSBridge';
|
||||
import {FlipperServerImpl} from '../../FlipperServerImpl';
|
||||
import {notNull} from '../../utils/typeUtils';
|
||||
@@ -57,6 +59,7 @@ export class IOSDeviceManager {
|
||||
'PortForwardingMacApp',
|
||||
);
|
||||
iosBridge: IOSBridge | undefined;
|
||||
simctlBridge: SimctlBridge = new SimctlBridge();
|
||||
private xcodeVersionMismatchFound = false;
|
||||
public xcodeCommandLineToolsDetected = false;
|
||||
|
||||
@@ -289,17 +292,6 @@ export class IOSDeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
function getDeviceSetPath() {
|
||||
return process.env.DEVICE_SET_PATH
|
||||
? ['--set', process.env.DEVICE_SET_PATH]
|
||||
: [];
|
||||
}
|
||||
|
||||
export async function launchSimulator(udid: string): Promise<any> {
|
||||
await execFile('xcrun', ['simctl', ...getDeviceSetPath(), 'boot', udid]);
|
||||
await execFile('open', ['-a', 'simulator']);
|
||||
}
|
||||
|
||||
function getActiveDevices(
|
||||
idbPath: string,
|
||||
isPhysicalDeviceEnabled: boolean,
|
||||
|
||||
Reference in New Issue
Block a user