Move FlipperServer initialisation out of flipper-core

Summary: This diff makes sure flipper-ui-core no longer depends on flipper-server-core. Currently server config is still transferred from UI to server, which doesn't really make sense in future scenarios where server might start before client, but will address that separately

Reviewed By: timur-valiev, aigoncharov

Differential Revision: D32462835

fbshipit-source-id: 498a944256ba1aabbf963b896953e64d11e27214
This commit is contained in:
Michel Weststrate
2021-12-08 04:25:28 -08:00
committed by Facebook GitHub Bot
parent d48f22b8dc
commit eed19b3a3d
16 changed files with 79 additions and 65 deletions

View File

@@ -26,9 +26,12 @@ import type {RenderHost} from 'flipper-ui-core';
import fs from 'fs';
import {setupMenuBar} from './setupMenuBar';
import os from 'os';
import {FlipperServerImpl} from 'flipper-server-core';
declare global {
interface Window {
// We store this as a global, to make sure the renderHost is available
// before flipper-ui-core is loaded and needs those during module initialisation
FlipperRenderHostInstance: RenderHost;
}
}
@@ -46,6 +49,8 @@ export function initializeElectron() {
const app = remote.app;
const execPath = process.execPath || remote.process.execPath;
const isProduction = !/node_modules[\\/]electron[\\/]/.test(execPath);
const staticPath = getStaticDir();
const tempPath = app.getPath('temp');
function restart(update: boolean = false) {
if (isProduction) {
@@ -192,11 +197,21 @@ export function initializeElectron() {
appPath: app.getAppPath(),
homePath: app.getPath('home'),
execPath,
staticPath: getStaticDir(),
tempPath: app.getPath('temp'),
staticPath,
tempPath,
desktopPath: app.getPath('desktop'),
},
loadDefaultPlugins: getDefaultPluginsIndex,
startFlipperServer({logger, ...config}) {
return new FlipperServerImpl(
{
...config,
staticPath,
tempPath,
},
logger,
);
},
};
setupMenuBar();