EnvironmentInfo as argument to start server
Summary: Clean initialisation by passing down the environment info to start server. (Also rename dir to path as that's the name used in other places) Reviewed By: passy Differential Revision: D45731751 fbshipit-source-id: a60fdd49c567fc312d1f8da72db3a46a0828c140
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0f9eeda2dd
commit
a96caacb2b
@@ -18,7 +18,11 @@ import fs from 'fs-extra';
|
||||
import yargs from 'yargs';
|
||||
import open from 'open';
|
||||
import {initCompanionEnv} from 'flipper-server-companion';
|
||||
import {startFlipperServer, startServer} from 'flipper-server-core';
|
||||
import {
|
||||
getEnvironmentInfo,
|
||||
startFlipperServer,
|
||||
startServer,
|
||||
} from 'flipper-server-core';
|
||||
import {isTest} from 'flipper-common';
|
||||
import exitHook from 'exit-hook';
|
||||
import {getAuthToken} from 'flipper-server-core';
|
||||
@@ -76,19 +80,19 @@ console.log(
|
||||
}`,
|
||||
);
|
||||
|
||||
const rootDir = argv.bundler
|
||||
const rootPath = argv.bundler
|
||||
? path.resolve(__dirname, '..', '..')
|
||||
: path.resolve(__dirname, '..'); // in pre packaged versions of the server, static is copied inside the package
|
||||
const staticDir = path.join(rootDir, 'static');
|
||||
const staticPath = path.join(rootPath, 'static');
|
||||
|
||||
async function start() {
|
||||
const enhanceLogger = await initializeLogger(staticDir);
|
||||
const enhanceLogger = await initializeLogger(staticPath);
|
||||
|
||||
let keytar: any = undefined;
|
||||
try {
|
||||
if (!isTest()) {
|
||||
const keytarPath = path.join(
|
||||
staticDir,
|
||||
staticPath,
|
||||
'native-modules',
|
||||
`keytar-${process.platform}-${process.arch}.node`,
|
||||
);
|
||||
@@ -104,20 +108,29 @@ async function start() {
|
||||
}
|
||||
|
||||
const {app, server, socket, readyForIncomingConnections} = await startServer({
|
||||
staticDir,
|
||||
staticPath,
|
||||
entry: `index.web${argv.bundler ? '.dev' : ''}.html`,
|
||||
port: argv.port,
|
||||
tcp: argv.tcp,
|
||||
});
|
||||
|
||||
const isProduction =
|
||||
process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test';
|
||||
|
||||
const environmentInfo = await getEnvironmentInfo(
|
||||
rootPath,
|
||||
isProduction,
|
||||
true,
|
||||
);
|
||||
|
||||
const flipperServer = await startFlipperServer(
|
||||
rootDir,
|
||||
staticDir,
|
||||
rootPath,
|
||||
staticPath,
|
||||
argv.settingsString,
|
||||
argv.launcherSettings,
|
||||
keytar,
|
||||
'external',
|
||||
true,
|
||||
environmentInfo,
|
||||
);
|
||||
|
||||
exitHook(async () => {
|
||||
@@ -142,7 +155,7 @@ async function start() {
|
||||
await flipperServer.connect();
|
||||
|
||||
if (argv.bundler) {
|
||||
await attachDevServer(app, server, socket, rootDir);
|
||||
await attachDevServer(app, server, socket, rootPath);
|
||||
}
|
||||
await readyForIncomingConnections(flipperServer, companionEnv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user