Move settings, launcherSettings, GKs to app / flipper-server-core
Summary: This diff moves a lot of stuff from the client to the server. This diff is fairly large, as a lot of concept closely relate, although some things have split off to the earlier diffs in the stack, or are still to follow (like making intern requests). This diff primarily moves reading and storing settings and GKs from client to server (both flipper and launcher settings). This means that settings are no longer persisted by Redux (which only exists on client). Most other changes are fallout from that. For now settings are just one big object, although we might need to separate settings that are only make sense in an Electron context. For example launcher settings. Reviewed By: passy, aigoncharov Differential Revision: D32498649 fbshipit-source-id: d842faf7a7f03774b621c7656e53a9127afc6192
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eed19b3a3d
commit
bca169df73
@@ -98,7 +98,7 @@ export function xcrunStartLogListener(udid: string, deviceType: DeviceType) {
|
||||
|
||||
function makeTempScreenshotFilePath() {
|
||||
const imageName = uuid() + '.png';
|
||||
return path.join(getFlipperServerConfig().tempPath, imageName);
|
||||
return path.join(getFlipperServerConfig().paths.tempPath, imageName);
|
||||
}
|
||||
|
||||
async function runScreenshotCommand(
|
||||
|
||||
@@ -7,13 +7,23 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {makeIOSBridge} from '../IOSBridge';
|
||||
import childProcess from 'child_process';
|
||||
import * as promisifyChildProcess from 'promisify-child-process';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('promisify-child-process');
|
||||
|
||||
import {makeIOSBridge} from '../IOSBridge';
|
||||
import * as promisifyChildProcess from 'promisify-child-process';
|
||||
import {setFlipperServerConfig} from '../../../FlipperServerConfig';
|
||||
import {getRenderHostInstance} from 'flipper-ui-core';
|
||||
|
||||
beforeEach(() => {
|
||||
setFlipperServerConfig(getRenderHostInstance().serverConfig);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
setFlipperServerConfig(undefined);
|
||||
});
|
||||
|
||||
test('uses xcrun with no idb when xcode is detected', async () => {
|
||||
const ib = await makeIOSBridge('', true);
|
||||
|
||||
@@ -95,10 +105,10 @@ test.unix(
|
||||
async () => {
|
||||
const ib = await makeIOSBridge('', true);
|
||||
|
||||
ib.screenshot('deadbeef');
|
||||
await expect(() => ib.screenshot('deadbeef')).rejects.toThrow();
|
||||
|
||||
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
|
||||
'xcrun simctl io deadbeef screenshot /temp/00000000-0000-0000-0000-000000000000.png',
|
||||
expect((promisifyChildProcess.exec as any).mock.calls[0][0]).toMatch(
|
||||
'xcrun simctl io deadbeef screenshot',
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -106,17 +116,17 @@ test.unix(
|
||||
test.unix('uses idb to take screenshots when available', async () => {
|
||||
const ib = await makeIOSBridge('/usr/local/bin/idb', true, async (_) => true);
|
||||
|
||||
ib.screenshot('deadbeef');
|
||||
await expect(() => ib.screenshot('deadbeef')).rejects.toThrow();
|
||||
|
||||
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
|
||||
'idb screenshot --udid deadbeef /temp/00000000-0000-0000-0000-000000000000.png',
|
||||
expect((promisifyChildProcess.exec as any).mock.calls[0][0]).toMatch(
|
||||
'idb screenshot --udid deadbeef ',
|
||||
);
|
||||
});
|
||||
|
||||
test('uses xcrun to navigate with no idb when xcode is detected', async () => {
|
||||
const ib = await makeIOSBridge('', true);
|
||||
|
||||
ib.navigate('deadbeef', 'fb://dummy');
|
||||
await ib.navigate('deadbeef', 'fb://dummy');
|
||||
|
||||
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
|
||||
'xcrun simctl io deadbeef launch url "fb://dummy"',
|
||||
@@ -126,7 +136,7 @@ test('uses xcrun to navigate with no idb when xcode is detected', async () => {
|
||||
test('uses idb to navigate when available', async () => {
|
||||
const ib = await makeIOSBridge('/usr/local/bin/idb', true, async (_) => true);
|
||||
|
||||
ib.navigate('deadbeef', 'fb://dummy');
|
||||
await ib.navigate('deadbeef', 'fb://dummy');
|
||||
|
||||
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
|
||||
'idb open --udid deadbeef "fb://dummy"',
|
||||
|
||||
@@ -11,9 +11,19 @@ import {parseXcodeFromCoreSimPath} from '../iOSDeviceManager';
|
||||
import {getLogger} from 'flipper-common';
|
||||
import {IOSBridge} from '../IOSBridge';
|
||||
import {FlipperServerImpl} from '../../../FlipperServerImpl';
|
||||
import {getFlipperServerConfig} from '../../../FlipperServerConfig';
|
||||
import {getRenderHostInstance} from 'flipper-ui-core';
|
||||
import {
|
||||
getFlipperServerConfig,
|
||||
setFlipperServerConfig,
|
||||
} from '../../../FlipperServerConfig';
|
||||
|
||||
const testConfig = getFlipperServerConfig();
|
||||
beforeEach(() => {
|
||||
setFlipperServerConfig(getRenderHostInstance().serverConfig);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
setFlipperServerConfig(undefined);
|
||||
});
|
||||
|
||||
const standardCoresimulatorLog =
|
||||
'username 1264 0.0 0.1 5989740 41648 ?? Ss 2:23PM 0:12.92 /Applications/Xcode_12.4.0_fb.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/libexec/mobileassetd';
|
||||
@@ -56,7 +66,10 @@ test('test parseXcodeFromCoreSimPath from standard locations', () => {
|
||||
});
|
||||
|
||||
test('test getAllPromisesForQueryingDevices when xcode detected', () => {
|
||||
const flipperServer = new FlipperServerImpl(testConfig, getLogger());
|
||||
const flipperServer = new FlipperServerImpl(
|
||||
getFlipperServerConfig(),
|
||||
getLogger(),
|
||||
);
|
||||
flipperServer.ios.iosBridge = {} as IOSBridge;
|
||||
const promises = flipperServer.ios.getAllPromisesForQueryingDevices(
|
||||
true,
|
||||
@@ -66,7 +79,10 @@ test('test getAllPromisesForQueryingDevices when xcode detected', () => {
|
||||
});
|
||||
|
||||
test('test getAllPromisesForQueryingDevices when xcode is not detected', () => {
|
||||
const flipperServer = new FlipperServerImpl(testConfig, getLogger());
|
||||
const flipperServer = new FlipperServerImpl(
|
||||
getFlipperServerConfig(),
|
||||
getLogger(),
|
||||
);
|
||||
flipperServer.ios.iosBridge = {} as IOSBridge;
|
||||
const promises = flipperServer.ios.getAllPromisesForQueryingDevices(
|
||||
false,
|
||||
@@ -76,7 +92,10 @@ test('test getAllPromisesForQueryingDevices when xcode is not detected', () => {
|
||||
});
|
||||
|
||||
test('test getAllPromisesForQueryingDevices when xcode and idb are both unavailable', () => {
|
||||
const flipperServer = new FlipperServerImpl(testConfig, getLogger());
|
||||
const flipperServer = new FlipperServerImpl(
|
||||
getFlipperServerConfig(),
|
||||
getLogger(),
|
||||
);
|
||||
flipperServer.ios.iosBridge = {} as IOSBridge;
|
||||
const promises = flipperServer.ios.getAllPromisesForQueryingDevices(
|
||||
false,
|
||||
@@ -86,7 +105,10 @@ test('test getAllPromisesForQueryingDevices when xcode and idb are both unavaila
|
||||
});
|
||||
|
||||
test('test getAllPromisesForQueryingDevices when both idb and xcode are available', () => {
|
||||
const flipperServer = new FlipperServerImpl(testConfig, getLogger());
|
||||
const flipperServer = new FlipperServerImpl(
|
||||
getFlipperServerConfig(),
|
||||
getLogger(),
|
||||
);
|
||||
flipperServer.ios.iosBridge = {} as IOSBridge;
|
||||
const promises = flipperServer.ios.getAllPromisesForQueryingDevices(
|
||||
true,
|
||||
|
||||
@@ -46,7 +46,7 @@ export class IOSDeviceManager {
|
||||
private portForwarders: Array<ChildProcess> = [];
|
||||
|
||||
private portforwardingClient = path.join(
|
||||
getFlipperServerConfig().staticPath,
|
||||
getFlipperServerConfig().paths.staticPath,
|
||||
'PortForwardingMacApp.app',
|
||||
'Contents',
|
||||
'MacOS',
|
||||
@@ -111,7 +111,7 @@ export class IOSDeviceManager {
|
||||
isXcodeDetected: boolean,
|
||||
isIdbAvailable: boolean,
|
||||
): Array<Promise<any>> {
|
||||
const config = getFlipperServerConfig();
|
||||
const config = getFlipperServerConfig().settings;
|
||||
return [
|
||||
isIdbAvailable
|
||||
? getActiveDevices(config.idbPath, config.enablePhysicalIOS).then(
|
||||
@@ -130,7 +130,7 @@ export class IOSDeviceManager {
|
||||
}
|
||||
|
||||
private async queryDevices(): Promise<any> {
|
||||
const config = getFlipperServerConfig();
|
||||
const config = getFlipperServerConfig().settings;
|
||||
const isXcodeInstalled = await iosUtil.isXcodeDetected();
|
||||
const isIdbAvailable = await iosUtil.isAvailable(config.idbPath);
|
||||
console.debug(
|
||||
@@ -182,21 +182,19 @@ export class IOSDeviceManager {
|
||||
|
||||
public async watchIOSDevices() {
|
||||
// TODO: pull this condition up
|
||||
if (!getFlipperServerConfig().enableIOS) {
|
||||
const settings = getFlipperServerConfig().settings;
|
||||
if (!settings.enableIOS) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const isDetected = await iosUtil.isXcodeDetected();
|
||||
this.xcodeCommandLineToolsDetected = isDetected;
|
||||
if (getFlipperServerConfig().enablePhysicalIOS) {
|
||||
if (settings.enablePhysicalIOS) {
|
||||
this.startDevicePortForwarders();
|
||||
}
|
||||
try {
|
||||
// Awaiting the promise here to trigger immediate error handling.
|
||||
this.iosBridge = await makeIOSBridge(
|
||||
getFlipperServerConfig().idbPath,
|
||||
isDetected,
|
||||
);
|
||||
this.iosBridge = await makeIOSBridge(settings.idbPath, isDetected);
|
||||
this.queryDevicesForever();
|
||||
} catch (err) {
|
||||
// This case is expected if both Xcode and idb are missing.
|
||||
|
||||
Reference in New Issue
Block a user