flipper-server refactor
Summary: This changes moves most of the functionality found in flipper-server to flipper-server-core. flipper-server will mostly be a package that wraps around flipper-server-core. Staying in flipper-server: - Command line args - Orchestration to start the necessary servers Reviewed By: aigoncharov Differential Revision: D36807087 fbshipit-source-id: f29002c7cc5d08b8c5184fdaaa02ba22562a9f45
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c88e769013
commit
9cc8e4076f
@@ -10,15 +10,18 @@
|
||||
import process from 'process';
|
||||
import chalk from 'chalk';
|
||||
import path from 'path';
|
||||
import {startFlipperServer} from './startFlipperServer';
|
||||
import {startServer} from './startServer';
|
||||
import {attachSocketServer} from './attachSocketServer';
|
||||
import {attachDevServer} from './attachDevServer';
|
||||
import {initializeLogger} from './logger';
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import yargs from 'yargs';
|
||||
import open from 'open';
|
||||
import {initCompanionEnv} from 'flipper-server-companion';
|
||||
import {
|
||||
attachSocketServer,
|
||||
startFlipperServer,
|
||||
startServer,
|
||||
} from 'flipper-server-core';
|
||||
import {isTest} from 'flipper-common';
|
||||
|
||||
const argv = yargs
|
||||
.usage('yarn flipper-server [args]')
|
||||
@@ -75,6 +78,25 @@ const staticDir = path.join(rootDir, 'static');
|
||||
async function start() {
|
||||
initializeLogger(staticDir);
|
||||
|
||||
let keytar: any = undefined;
|
||||
try {
|
||||
if (!isTest()) {
|
||||
const keytarPath = path.join(
|
||||
staticDir,
|
||||
'native-modules',
|
||||
`keytar-${process.platform}-${process.arch}.node`,
|
||||
);
|
||||
if (!(await fs.pathExists(keytarPath))) {
|
||||
throw new Error(
|
||||
`Keytar binary does not exist for platform ${process.platform}-${process.arch}`,
|
||||
);
|
||||
}
|
||||
keytar = electronRequire(keytarPath);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load keytar:', e);
|
||||
}
|
||||
|
||||
const {app, server, socket} = await startServer({
|
||||
port: argv.port,
|
||||
staticDir,
|
||||
@@ -86,6 +108,7 @@ async function start() {
|
||||
staticDir,
|
||||
argv.settingsString,
|
||||
argv.launcherSettings,
|
||||
keytar,
|
||||
);
|
||||
const companionEnv = await initCompanionEnv(flipperServer);
|
||||
if (argv.failFast) {
|
||||
|
||||
Reference in New Issue
Block a user