Remove remaining process.env

Summary: Per title

Reviewed By: passy

Differential Revision: D32721205

fbshipit-source-id: 8e8a7fcac7d73f32d7fb59f852a8099cfe20e542
This commit is contained in:
Michel Weststrate
2021-12-08 04:25:28 -08:00
committed by Facebook GitHub Bot
parent 2b4981c7cb
commit 058785a509
8 changed files with 37 additions and 14 deletions

View File

@@ -207,6 +207,7 @@ const environmentVariables = {
FLIPPER_NO_PLUGIN_MARKETPLACE: 1, FLIPPER_NO_PLUGIN_MARKETPLACE: 1,
HOME: 1, HOME: 1,
METRO_PORT_ENV_VAR: 1, METRO_PORT_ENV_VAR: 1,
FLIPPER_PLUGIN_AUTO_UPDATE_POLLING_INTERVAL: 1,
} as const; } as const;
export type ENVIRONMENT_VARIABLES = keyof typeof environmentVariables; export type ENVIRONMENT_VARIABLES = keyof typeof environmentVariables;

View File

@@ -77,7 +77,7 @@ export type EnvironmentInfo = {
appVersion: string; appVersion: string;
os: { os: {
arch: string; arch: string;
platform: string; platform: NodeJS.Platform;
unixname: string; unixname: string;
}; };
versions: { versions: {

View File

@@ -201,7 +201,10 @@ async function verifyLighthouseAndUserLoggedIn(
store: Store, store: Store,
title: string, title: string,
): Promise<boolean> { ): Promise<boolean> {
if (!getFlipperLib().isFB || process.env.NODE_ENV === 'test') { if (
!getFlipperLib().isFB ||
getRenderHostInstance().serverConfig.env.NODE_ENV === 'test'
) {
return true; // ok, continue return true; // ok, continue
} }

View File

@@ -107,7 +107,10 @@ export default async (store: Store, _logger: Logger) => {
const classicPlugins = initialPlugins.filter( const classicPlugins = initialPlugins.filter(
(p) => !isSandyPlugin(p.details), (p) => !isSandyPlugin(p.details),
); );
if (process.env.NODE_ENV !== 'test' && classicPlugins.length) { if (
getRenderHostInstance().serverConfig.env.NODE_ENV !== 'test' &&
classicPlugins.length
) {
console.warn( console.warn(
`${ `${
classicPlugins.length classicPlugins.length
@@ -154,7 +157,7 @@ export function getLatestCompatibleVersionOfEachPlugin<
} }
async function getBundledPlugins(): Promise<Array<BundledPluginDetails>> { async function getBundledPlugins(): Promise<Array<BundledPluginDetails>> {
if (process.env.NODE_ENV === 'test') { if (getRenderHostInstance().serverConfig.env.NODE_ENV === 'test') {
return []; return [];
} }
try { try {

View File

@@ -66,6 +66,7 @@ import {
} from '../utils/exportData'; } from '../utils/exportData';
import {openDeeplinkDialog} from '../deeplink'; import {openDeeplinkDialog} from '../deeplink';
import {css} from '@emotion/css'; import {css} from '@emotion/css';
import {getRenderHostInstance} from '../RenderHost';
const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({ const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({
width: kind === 'small' ? 32 : 36, width: kind === 'small' ? 32 : 36,
@@ -300,7 +301,12 @@ function ExtrasMenu() {
</Menu> </Menu>
</NUX> </NUX>
{showSettings && ( {showSettings && (
<SettingsSheet platform={process.platform} onHide={onSettingsClose} /> <SettingsSheet
platform={
getRenderHostInstance().serverConfig.environmentInfo.os.platform
}
onHide={onSettingsClose}
/>
)} )}
<WelcomeScreen <WelcomeScreen
visible={welcomeVisible} visible={welcomeVisible}

View File

@@ -104,7 +104,12 @@ export function SandyApp() {
if (hasPlatformWizardBeenDone(window.localStorage)) { if (hasPlatformWizardBeenDone(window.localStorage)) {
Dialog.showModal((onHide) => ( Dialog.showModal((onHide) => (
<PlatformSelectWizard onHide={onHide} platform={process.platform} /> <PlatformSelectWizard
onHide={onHide}
platform={
getRenderHostInstance().serverConfig.environmentInfo.os.platform
}
/>
)); ));
} }

View File

@@ -20,6 +20,7 @@ import {debounce} from 'lodash';
import ToggleButton from '../ToggleSwitch'; import ToggleButton from '../ToggleSwitch';
import React from 'react'; import React from 'react';
import {Layout, theme, Toolbar} from 'flipper-plugin'; import {Layout, theme, Toolbar} from 'flipper-plugin';
import {getRenderHostInstance} from '../../../RenderHost';
const SearchBar = styled(Toolbar)({ const SearchBar = styled(Toolbar)({
height: 42, height: 42,
@@ -298,9 +299,11 @@ export default function Searchable(
}; };
onKeyDown = (e: KeyboardEvent) => { onKeyDown = (e: KeyboardEvent) => {
const {platform} =
getRenderHostInstance().serverConfig.environmentInfo.os;
const ctrlOrCmd = (e: KeyboardEvent) => const ctrlOrCmd = (e: KeyboardEvent) =>
(e.metaKey && process.platform === 'darwin') || (e.metaKey && platform === 'darwin') ||
(e.ctrlKey && process.platform !== 'darwin'); (e.ctrlKey && platform !== 'darwin');
if (e.key === 'f' && ctrlOrCmd(e) && this._inputRef) { if (e.key === 'f' && ctrlOrCmd(e) && this._inputRef) {
e.preventDefault(); e.preventDefault();

View File

@@ -32,6 +32,7 @@ import {debounce} from 'lodash';
import {DEFAULT_ROW_HEIGHT} from './types'; import {DEFAULT_ROW_HEIGHT} from './types';
import {notNull} from '../../../utils/typeUtils'; import {notNull} from '../../../utils/typeUtils';
import {getFlipperLib, textContent} from 'flipper-plugin'; import {getFlipperLib, textContent} from 'flipper-plugin';
import {getRenderHostInstance} from '../../../RenderHost';
const EMPTY_OBJECT = {}; const EMPTY_OBJECT = {};
Object.freeze(EMPTY_OBJECT); Object.freeze(EMPTY_OBJECT);
@@ -328,12 +329,13 @@ export class ManagedTable extends React.Component<
onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => { onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
const {highlightedRows} = this.state; const {highlightedRows} = this.state;
const {platform} = getRenderHostInstance().serverConfig.environmentInfo.os;
if (highlightedRows.size === 0) { if (highlightedRows.size === 0) {
return; return;
} }
if ( if (
((e.metaKey && process.platform === 'darwin') || ((e.metaKey && platform === 'darwin') ||
(e.ctrlKey && process.platform !== 'darwin')) && (e.ctrlKey && platform !== 'darwin')) &&
e.keyCode === 67 e.keyCode === 67
) { ) {
e.stopPropagation(); e.stopPropagation();
@@ -421,6 +423,7 @@ export class ManagedTable extends React.Component<
if (!this.props.highlightableRows) { if (!this.props.highlightableRows) {
return; return;
} }
const {platform} = getRenderHostInstance().serverConfig.environmentInfo.os;
if (e.shiftKey) { if (e.shiftKey) {
// prevents text selection // prevents text selection
@@ -430,8 +433,7 @@ export class ManagedTable extends React.Component<
let {highlightedRows} = this.state; let {highlightedRows} = this.state;
const contextClick = const contextClick =
e.button !== 0 || e.button !== 0 || (platform === 'darwin' && e.button === 0 && e.ctrlKey);
(process.platform === 'darwin' && e.button === 0 && e.ctrlKey);
if (contextClick) { if (contextClick) {
if (!highlightedRows.has(row.key)) { if (!highlightedRows.has(row.key)) {
@@ -445,8 +447,8 @@ export class ManagedTable extends React.Component<
document.addEventListener('mouseup', this.onStopDragSelecting); document.addEventListener('mouseup', this.onStopDragSelecting);
if ( if (
((process.platform === 'darwin' && e.metaKey) || ((platform === 'darwin' && e.metaKey) ||
(process.platform !== 'darwin' && e.ctrlKey)) && (platform !== 'darwin' && e.ctrlKey)) &&
this.props.multiHighlight this.props.multiHighlight
) { ) {
highlightedRows.add(row.key); highlightedRows.add(row.key);