Extract environment config initialisation to server-core
Summary: This diff makes most stuff that is read from the `os` package, and version info etc available from the `serverConfig` object, so that flipper-ui-core no longer needs the `os` package. Reviewed By: passy Differential Revision: D32694848 fbshipit-source-id: 93af1e95d898da9aaf351a6970b5a7652ee835c8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
de59bbedd2
commit
2a4fe77404
@@ -9,13 +9,13 @@
|
||||
|
||||
import chalk from 'chalk';
|
||||
import path from 'path';
|
||||
import {startFlipperServer} from './startFlipperServer';
|
||||
import {startBaseServer} from './startBaseServer';
|
||||
import {startSocketServer} from './startSocketServer';
|
||||
// TODO: currently flipper-server is only suitable for development,
|
||||
// needs to be come independently runnable, prebundled, distributed, etc!
|
||||
// in future require conditionally
|
||||
import {startWebServerDev} from './startWebServerDev';
|
||||
import {startFlipperServer} from './startFlipperServer';
|
||||
import {startBaseServer} from './startBaseServer';
|
||||
import {startSocketServer} from './startSocketServer';
|
||||
|
||||
const PORT = 52342;
|
||||
const rootDir = path.resolve(__dirname, '..', '..');
|
||||
|
||||
@@ -14,9 +14,10 @@ import {
|
||||
loadLauncherSettings,
|
||||
loadProcessConfig,
|
||||
loadSettings,
|
||||
getEnvironmentInfo,
|
||||
} from 'flipper-server-core';
|
||||
import {
|
||||
ENVIRONMENT_VARIABLES,
|
||||
parseEnvironmentVariables,
|
||||
isTest,
|
||||
Logger,
|
||||
setLoggerInstance,
|
||||
@@ -26,7 +27,7 @@ import fs from 'fs';
|
||||
|
||||
export async function startFlipperServer(
|
||||
rootDir: string,
|
||||
staticDir: string,
|
||||
staticPath: string,
|
||||
): Promise<FlipperServerImpl> {
|
||||
if (os.platform() === 'darwin') {
|
||||
// By default Node.JS has its internal certificate storage and doesn't use
|
||||
@@ -57,7 +58,7 @@ export async function startFlipperServer(
|
||||
try {
|
||||
if (!isTest()) {
|
||||
keytar = require(path.join(
|
||||
staticDir,
|
||||
staticPath,
|
||||
'native-modules',
|
||||
`keytar-${process.platform}.node`,
|
||||
));
|
||||
@@ -66,20 +67,19 @@ export async function startFlipperServer(
|
||||
console.error('Failed to load keytar:', e);
|
||||
}
|
||||
|
||||
const envVars: Partial<Record<ENVIRONMENT_VARIABLES, string | undefined>> =
|
||||
Object.fromEntries(
|
||||
([] as ENVIRONMENT_VARIABLES[]).map((v) => [v, process.env[v]] as const),
|
||||
);
|
||||
const environmentInfo = await getEnvironmentInfo(staticPath, isProduction);
|
||||
|
||||
const flipperServer = new FlipperServerImpl(
|
||||
{
|
||||
env: envVars,
|
||||
gatekeepers: getGatekeepers(),
|
||||
isProduction,
|
||||
environmentInfo,
|
||||
env: parseEnvironmentVariables(process.env),
|
||||
// TODO: make userame parameterizable
|
||||
gatekeepers: getGatekeepers(environmentInfo.os.unixname),
|
||||
paths: {
|
||||
appPath,
|
||||
homePath: os.homedir(),
|
||||
execPath,
|
||||
staticPath: staticDir,
|
||||
staticPath: staticPath,
|
||||
tempPath: os.tmpdir(),
|
||||
desktopPath: desktopPath,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user