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,
HOME: 1,
METRO_PORT_ENV_VAR: 1,
FLIPPER_PLUGIN_AUTO_UPDATE_POLLING_INTERVAL: 1,
} as const;
export type ENVIRONMENT_VARIABLES = keyof typeof environmentVariables;

View File

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

View File

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

View File

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

View File

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

View File

@@ -104,7 +104,12 @@ export function SandyApp() {
if (hasPlatformWizardBeenDone(window.localStorage)) {
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 React from 'react';
import {Layout, theme, Toolbar} from 'flipper-plugin';
import {getRenderHostInstance} from '../../../RenderHost';
const SearchBar = styled(Toolbar)({
height: 42,
@@ -298,9 +299,11 @@ export default function Searchable(
};
onKeyDown = (e: KeyboardEvent) => {
const {platform} =
getRenderHostInstance().serverConfig.environmentInfo.os;
const ctrlOrCmd = (e: KeyboardEvent) =>
(e.metaKey && process.platform === 'darwin') ||
(e.ctrlKey && process.platform !== 'darwin');
(e.metaKey && platform === 'darwin') ||
(e.ctrlKey && platform !== 'darwin');
if (e.key === 'f' && ctrlOrCmd(e) && this._inputRef) {
e.preventDefault();

View File

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