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 ServerController from './comms/ServerController';
|
||||||
import {CertificateExchangeMedium} from './utils/CertificateProvider';
|
import {CertificateExchangeMedium} from './utils/CertificateProvider';
|
||||||
import {AndroidDeviceManager} from './devices/android/androidDeviceManager';
|
import {AndroidDeviceManager} from './devices/android/androidDeviceManager';
|
||||||
import {
|
import {IOSDeviceManager} from './devices/ios/iOSDeviceManager';
|
||||||
IOSDeviceManager,
|
|
||||||
launchSimulator,
|
|
||||||
} from './devices/ios/iOSDeviceManager';
|
|
||||||
import metroDevice from './devices/metro/metroDeviceManager';
|
import metroDevice from './devices/metro/metroDeviceManager';
|
||||||
import desktopDevice from './devices/desktop/desktopDeviceManager';
|
import desktopDevice from './devices/desktop/desktopDeviceManager';
|
||||||
import {
|
import {
|
||||||
@@ -356,7 +353,8 @@ export class FlipperServerImpl implements FlipperServer {
|
|||||||
launchEmulator(this.config.settings.androidHome, name, coldBoot),
|
launchEmulator(this.config.settings.androidHome, name, coldBoot),
|
||||||
'ios-get-simulators': async (bootedOnly) =>
|
'ios-get-simulators': async (bootedOnly) =>
|
||||||
this.ios.getSimulators(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-settings': async (settings) => saveSettings(settings),
|
||||||
'persist-launcher-settings': async (settings) =>
|
'persist-launcher-settings': async (settings) =>
|
||||||
saveLauncherSettings(settings),
|
saveLauncherSettings(settings),
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import child_process from 'child_process';
|
|||||||
import {DeviceType} from 'flipper-common';
|
import {DeviceType} from 'flipper-common';
|
||||||
import {v1 as uuid} from 'uuid';
|
import {v1 as uuid} from 'uuid';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {exec} from 'promisify-child-process';
|
import {exec, execFile} from 'promisify-child-process';
|
||||||
import {getFlipperServerConfig} from '../../FlipperServerConfig';
|
import {getFlipperServerConfig} from '../../FlipperServerConfig';
|
||||||
|
|
||||||
export const ERR_NO_IDB_OR_XCODE_AVAILABLE =
|
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(
|
startLogListener(
|
||||||
udid: string,
|
udid: string,
|
||||||
deviceType: DeviceType,
|
deviceType: DeviceType,
|
||||||
@@ -114,6 +114,11 @@ class SimctlBridge implements IOSBridge {
|
|||||||
`xcrun simctl io ${serial} recordVideo --codec=h264 --force ${outputFile}`,
|
`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> {
|
async function isAvailable(idbPath: string): Promise<boolean> {
|
||||||
@@ -155,6 +160,12 @@ async function readScreenshotIntoBuffer(imagePath: string): Promise<Buffer> {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDeviceSetPath() {
|
||||||
|
return process.env.DEVICE_SET_PATH
|
||||||
|
? ['--set', process.env.DEVICE_SET_PATH]
|
||||||
|
: [];
|
||||||
|
}
|
||||||
|
|
||||||
export async function makeIOSBridge(
|
export async function makeIOSBridge(
|
||||||
idbPath: string,
|
idbPath: string,
|
||||||
isXcodeDetected: boolean,
|
isXcodeDetected: boolean,
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import {
|
|||||||
ERR_NO_IDB_OR_XCODE_AVAILABLE,
|
ERR_NO_IDB_OR_XCODE_AVAILABLE,
|
||||||
IOSBridge,
|
IOSBridge,
|
||||||
makeIOSBridge,
|
makeIOSBridge,
|
||||||
|
getDeviceSetPath,
|
||||||
|
SimctlBridge,
|
||||||
} from './IOSBridge';
|
} from './IOSBridge';
|
||||||
import {FlipperServerImpl} from '../../FlipperServerImpl';
|
import {FlipperServerImpl} from '../../FlipperServerImpl';
|
||||||
import {notNull} from '../../utils/typeUtils';
|
import {notNull} from '../../utils/typeUtils';
|
||||||
@@ -57,6 +59,7 @@ export class IOSDeviceManager {
|
|||||||
'PortForwardingMacApp',
|
'PortForwardingMacApp',
|
||||||
);
|
);
|
||||||
iosBridge: IOSBridge | undefined;
|
iosBridge: IOSBridge | undefined;
|
||||||
|
simctlBridge: SimctlBridge = new SimctlBridge();
|
||||||
private xcodeVersionMismatchFound = false;
|
private xcodeVersionMismatchFound = false;
|
||||||
public xcodeCommandLineToolsDetected = 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(
|
function getActiveDevices(
|
||||||
idbPath: string,
|
idbPath: string,
|
||||||
isPhysicalDeviceEnabled: boolean,
|
isPhysicalDeviceEnabled: boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user