Move app/server to flipper-server-core

Summary: moved `app/src/server` to `flipper-server-core/src` and fixed any fallout from that (aka integration points I missed on the preparing diffs).

Reviewed By: passy

Differential Revision: D31541378

fbshipit-source-id: 8a7e0169ebefa515781f6e5e0f7b926415d4b7e9
This commit is contained in:
Michel Weststrate
2021-10-12 15:59:44 -07:00
committed by Facebook GitHub Bot
parent 3e7a6b1b4b
commit d88b28330a
73 changed files with 563 additions and 534 deletions

View File

@@ -0,0 +1,93 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {isTest} from 'flipper-common';
import {parseFlipperPorts} from './utils/environmentVariables';
export interface FlipperServerConfig {
enableAndroid: boolean;
androidHome: string;
enableIOS: boolean;
idbPath: string;
enablePhysicalIOS: boolean;
validWebSocketOrigins: string[];
staticPath: string;
tmpPath: string;
}
// defaultConfig should be used for testing only, and disables by default all features
const testConfig: FlipperServerConfig = {
androidHome: '',
enableAndroid: false,
enableIOS: false,
enablePhysicalIOS: false,
idbPath: '',
validWebSocketOrigins: [],
staticPath: '/static/',
tmpPath: '/temp/',
};
let currentConfig: FlipperServerConfig | undefined = undefined;
export function getFlipperServerConfig(): FlipperServerConfig {
if (!currentConfig) {
if (isTest()) return testConfig;
throw new Error('FlipperServerConfig has not been set');
}
return currentConfig;
}
export function setFlipperServerConfig(config: FlipperServerConfig) {
currentConfig = config;
}
type ServerPorts = {
insecure: number;
secure: number;
};
export function getServerPortsConfig(): {
serverPorts: ServerPorts;
altServerPorts: ServerPorts;
} {
let portOverrides: ServerPorts | undefined;
if (process.env.FLIPPER_PORTS) {
portOverrides = parseFlipperPorts(process.env.FLIPPER_PORTS);
if (!portOverrides) {
console.error(
`Ignoring malformed FLIPPER_PORTS env variable:
"${process.env.FLIPPER_PORTS || ''}".
Example expected format: "1111,2222".`,
);
}
}
let portAltOverrides: ServerPorts | undefined;
if (process.env.FLIPPER_ALT_PORTS) {
portAltOverrides = parseFlipperPorts(process.env.FLIPPER_ALT_PORTS);
if (!portAltOverrides) {
console.error(
`Ignoring malformed FLIPPER_ALT_PORTS env variable:
"${process.env.FLIPPER_ALT_PORTS || ''}".
Example expected format: "1111,2222".`,
);
}
}
return {
serverPorts: portOverrides ?? {
insecure: 8089,
secure: 8088,
},
altServerPorts: portAltOverrides ?? {
insecure: 9089,
secure: 9088,
},
};
}