From 6233116fedb63dbeb42ab0d791db9c9c6bb79f3d Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 31 Jul 2020 04:55:43 -0700 Subject: [PATCH] Add devserver check Reviewed By: jknoxville Differential Revision: D22864430 fbshipit-source-id: ce37e6abeb3b152aedb2013bc9cd548807cad7b3 --- desktop/scripts/start-dev-server.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/desktop/scripts/start-dev-server.ts b/desktop/scripts/start-dev-server.ts index 629404f1c..3efd5eb38 100644 --- a/desktop/scripts/start-dev-server.ts +++ b/desktop/scripts/start-dev-server.ts @@ -18,6 +18,7 @@ import chalk from 'chalk'; import http from 'http'; import path from 'path'; import fs from 'fs-extra'; +import {hostname} from 'os'; import {compileMain, generatePluginEntryPoints} from './build-utils'; import Watchman from '../static/watchman'; import Metro from 'metro'; @@ -51,6 +52,17 @@ if (!process.argv.includes('--plugin-auto-update')) { process.env.FLIPPER_DISABLE_PLUGIN_AUTO_UPDATE = 'true'; } +function looksLikeDevServer(): boolean { + const hn = hostname(); + if (/^devvm.*\.facebook\.com$/.test(hn)) { + return true; + } + if (hn.endsWith('.od.fbinfra.net')) { + return true; + } + return false; +} + function launchElectron(port: number) { const entry = process.env.FLIPPER_FAST_REFRESH ? 'init-fast-refresh' : 'init'; const devServerURL = `http://localhost:${port}`; @@ -273,7 +285,18 @@ function outputScreen(socket?: socketIo.Server) { } } +function checkDevServer() { + if (looksLikeDevServer()) { + console.log( + chalk.red( + `✖ It looks like you're trying to start Flipper on your OnDemand or DevServer, which is not supported. Please run this in a local checkout on your laptop or desktop instead.`, + ), + ); + } +} + (async () => { + checkDevServer(); await generatePluginEntryPoints(); await ensurePluginFoldersWatchable(); const port = await detect(DEFAULT_PORT);