Revert RN-only
Summary: ^ Reviewed By: aigoncharov Differential Revision: D49953166 fbshipit-source-id: b08a09b89e3b857f633e62bbc5b63064c3657aa4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c05fe8cb53
commit
4b078a4472
@@ -291,10 +291,10 @@ async function waitForLogin(store: Store) {
|
|||||||
|
|
||||||
async function verifyFlipperIsUpToDate(title: string) {
|
async function verifyFlipperIsUpToDate(title: string) {
|
||||||
const serverConfig = getRenderHostInstance().serverConfig;
|
const serverConfig = getRenderHostInstance().serverConfig;
|
||||||
// If this is not a headless build, do not check for updates.
|
// // If this is not a headless build, do not check for updates.
|
||||||
if (!serverConfig.environmentInfo.isHeadlessBuild) {
|
// if (!serverConfig.environmentInfo.isHeadlessBuild) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const config = serverConfig.processConfig;
|
const config = serverConfig.processConfig;
|
||||||
if (
|
if (
|
||||||
!isProduction() ||
|
!isProduction() ||
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ export const Navbar = withTrackingScope(function Navbar() {
|
|||||||
<TroubleshootMenu />
|
<TroubleshootMenu />
|
||||||
<ExtrasMenu />
|
<ExtrasMenu />
|
||||||
<RightSidebarToggleButton />
|
<RightSidebarToggleButton />
|
||||||
{getRenderHostInstance().serverConfig.environmentInfo
|
<UpdateIndicator />
|
||||||
.isHeadlessBuild && <UpdateIndicator />}
|
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
</Layout.Horizontal>
|
</Layout.Horizontal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,32 +15,31 @@ import {
|
|||||||
Layout,
|
Layout,
|
||||||
Dialog,
|
Dialog,
|
||||||
_PortalsManager,
|
_PortalsManager,
|
||||||
getFlipperLib,
|
|
||||||
styled,
|
|
||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
|
import {Link, styled} from '../ui';
|
||||||
import {theme} from 'flipper-plugin';
|
import {theme} from 'flipper-plugin';
|
||||||
import {isProduction, Logger} from 'flipper-common';
|
import {Logger} from 'flipper-common';
|
||||||
|
|
||||||
import {Navbar} from './Navbar';
|
import {Navbar} from './Navbar';
|
||||||
import {useStore} from '../utils/useStore';
|
import {useStore} from '../utils/useStore';
|
||||||
import {AppInspect} from './appinspect/AppInspect';
|
import {AppInspect} from './appinspect/AppInspect';
|
||||||
import PluginContainer from '../PluginContainer';
|
import PluginContainer from '../PluginContainer';
|
||||||
import {ContentContainer} from './ContentContainer';
|
import {ContentContainer} from './ContentContainer';
|
||||||
|
import {showChangelog} from '../chrome/ChangelogSheet';
|
||||||
import PlatformSelectWizard, {
|
import PlatformSelectWizard, {
|
||||||
hasPlatformWizardBeenDone,
|
hasPlatformWizardBeenDone,
|
||||||
} from '../chrome/PlatformSelectWizard';
|
} from '../chrome/PlatformSelectWizard';
|
||||||
import {getVersionString} from '../utils/versionString';
|
|
||||||
import config from '../fb-stubs/config';
|
|
||||||
import {WelcomeScreenStaticView} from './WelcomeScreen';
|
|
||||||
import {isFBEmployee} from '../utils/fbEmployee';
|
|
||||||
import {Button, Modal, notification} from 'antd';
|
|
||||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
|
||||||
import {WarningOutlined} from '@ant-design/icons';
|
|
||||||
import PWAInstallationWizard, {
|
import PWAInstallationWizard, {
|
||||||
shouldShowPWAInstallationWizard,
|
shouldShowPWAInstallationWizard,
|
||||||
} from '../chrome/PWAppInstallationWizard';
|
} from '../chrome/PWAppInstallationWizard';
|
||||||
import {showChangelog} from '../chrome/ChangelogSheet';
|
import {getVersionString} from '../utils/versionString';
|
||||||
import {Link} from '../ui';
|
import config from '../fb-stubs/config';
|
||||||
|
import {WelcomeScreenStaticView} from './WelcomeScreen';
|
||||||
import fbConfig from '../fb-stubs/config';
|
import fbConfig from '../fb-stubs/config';
|
||||||
|
import {isFBEmployee} from '../utils/fbEmployee';
|
||||||
|
import {notification} from 'antd';
|
||||||
|
import isProduction from '../utils/isProduction';
|
||||||
|
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||||
|
|
||||||
export function SandyApp() {
|
export function SandyApp() {
|
||||||
const logger = useLogger();
|
const logger = useLogger();
|
||||||
@@ -49,17 +48,10 @@ export function SandyApp() {
|
|||||||
);
|
);
|
||||||
const staticView = useStore((state) => state.connections.staticView);
|
const staticView = useStore((state) => state.connections.staticView);
|
||||||
|
|
||||||
const serverConfig = getRenderHostInstance().serverConfig;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let title = `Flipper (${getVersionString()}${
|
document.title = `Flipper (${getVersionString()}${
|
||||||
config.isFBBuild ? '@FB' : ''
|
config.isFBBuild ? '@FB' : ''
|
||||||
})`;
|
})`;
|
||||||
if (!serverConfig.environmentInfo.isHeadlessBuild) {
|
|
||||||
title += ' (Unsupported)';
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = title;
|
|
||||||
|
|
||||||
registerStartupTime(logger);
|
registerStartupTime(logger);
|
||||||
|
|
||||||
@@ -79,55 +71,17 @@ export function SandyApp() {
|
|||||||
Dialog.showModal((onHide) => <PWAInstallationWizard onHide={onHide} />);
|
Dialog.showModal((onHide) => <PWAInstallationWizard onHide={onHide} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverConfig.environmentInfo.isHeadlessBuild) {
|
|
||||||
showChangelog(true);
|
showChangelog(true);
|
||||||
}
|
|
||||||
|
|
||||||
// don't warn about logger, even with a new logger we don't want to re-register
|
// don't warn about logger, even with a new logger we don't want to re-register
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (fbConfig.warnFBEmployees && isProduction()) {
|
||||||
isFBEmployee()
|
isFBEmployee()
|
||||||
.then((isEmployee) => {
|
.then((isEmployee) => {
|
||||||
if (isEmployee) {
|
if (isEmployee) {
|
||||||
if (!serverConfig.environmentInfo.isHeadlessBuild) {
|
|
||||||
Dialog.showModal((onHide) => (
|
|
||||||
<Modal
|
|
||||||
closable={false}
|
|
||||||
keyboard={false} // Don't allow escape to close modal
|
|
||||||
maskClosable={false} // Don't allow clicking away
|
|
||||||
open
|
|
||||||
centered
|
|
||||||
onCancel={() => onHide()}
|
|
||||||
width={570}
|
|
||||||
title={
|
|
||||||
<>
|
|
||||||
<WarningOutlined /> This Version of Flipper is Unsupported
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
footer={
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
onClick={() => {
|
|
||||||
getFlipperLib().openLink('munki://detail-Flipper');
|
|
||||||
onHide();
|
|
||||||
}}>
|
|
||||||
Open Flipper Stable instead
|
|
||||||
</Button>
|
|
||||||
<Button type="ghost" onClick={() => onHide()}>
|
|
||||||
I understand
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
}>
|
|
||||||
This version is only meant to be used for React Native
|
|
||||||
debugging. It is not maintained and it doesn't receive updates.
|
|
||||||
Instead, you should be using the main Flipper version from
|
|
||||||
Managed Software Center for all other purposes.
|
|
||||||
</Modal>
|
|
||||||
));
|
|
||||||
} else if (fbConfig.warnFBEmployees && isProduction()) {
|
|
||||||
notification.warning({
|
notification.warning({
|
||||||
placement: 'bottomLeft',
|
placement: 'bottomLeft',
|
||||||
message: 'Please use Flipper@FB',
|
message: 'Please use Flipper@FB',
|
||||||
@@ -144,11 +98,11 @@ export function SandyApp() {
|
|||||||
duration: null,
|
duration: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.warn('Failed to check if user is employee', e);
|
console.warn('Failed to check if user is employee', e);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ function WelcomeScreenContent() {
|
|||||||
}}
|
}}
|
||||||
width={125}
|
width={125}
|
||||||
height={125}
|
height={125}
|
||||||
src={isHeadlessBuild ? './icon.png' : './icon-rn-only.png'}
|
src={isHeadlessBuild ? './icon.png' : './icon.png'}
|
||||||
preview={false}
|
preview={false}
|
||||||
/>
|
/>
|
||||||
<Title level={1}>Welcome to Flipper</Title>
|
<Title level={1}>Welcome to Flipper</Title>
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ async function buildDist(buildFolder: string) {
|
|||||||
},
|
},
|
||||||
mac: {
|
mac: {
|
||||||
bundleVersion: FIX_RELEASE_VERSION,
|
bundleVersion: FIX_RELEASE_VERSION,
|
||||||
icon: path.resolve(buildFolder, 'icon-rn-only.icns'),
|
|
||||||
},
|
},
|
||||||
win: {
|
win: {
|
||||||
signAndEditExecutable: !isFB,
|
signAndEditExecutable: !isFB,
|
||||||
|
|||||||
100
desktop/static/launcher.tsx
Normal file
100
desktop/static/launcher.tsx
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and 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 os from 'os';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import {spawn} from 'child_process';
|
||||||
|
import xdg from 'xdg-basedir';
|
||||||
|
import mkdirp from 'mkdirp';
|
||||||
|
|
||||||
|
const isProduction = () =>
|
||||||
|
!/node_modules[\\/]electron[\\/]/.test(process.execPath);
|
||||||
|
|
||||||
|
const isLauncherInstalled = async () => {
|
||||||
|
if (os.type() == 'Darwin') {
|
||||||
|
const receipt = 'com.facebook.flipper.launcher';
|
||||||
|
const plistLocation = '/Applications/Flipper.app/Contents/Info.plist';
|
||||||
|
try {
|
||||||
|
return (
|
||||||
|
(await fs.promises.stat(plistLocation)) &&
|
||||||
|
(await fs.promises.readFile(plistLocation)).indexOf(receipt) > 0
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error while reading Info.plist', e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const startLauncher = (argv: {file?: string; url?: string}) => {
|
||||||
|
const args = [];
|
||||||
|
if (argv.file) {
|
||||||
|
args.push('--file', argv.file);
|
||||||
|
}
|
||||||
|
if (argv.url) {
|
||||||
|
args.push('--url', argv.url);
|
||||||
|
}
|
||||||
|
if (os.type() == 'Darwin') {
|
||||||
|
spawn('open', ['/Applications/Flipper.app', '--args'].concat(args));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkIsCycle = async () => {
|
||||||
|
const dir = path.join(xdg.cache!, 'flipper');
|
||||||
|
const filePath = path.join(dir, 'last-launcher-run');
|
||||||
|
// This isn't monotonically increasing, so there's a change we get time drift
|
||||||
|
// between the checks, but the worst case here is that we do two roundtrips
|
||||||
|
// before this check works.
|
||||||
|
const rightNow = Date.now();
|
||||||
|
|
||||||
|
let backThen;
|
||||||
|
try {
|
||||||
|
backThen = parseInt((await fs.promises.readFile(filePath)).toString(), 10);
|
||||||
|
} catch (e) {
|
||||||
|
backThen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delta = rightNow - backThen;
|
||||||
|
await mkdirp(dir);
|
||||||
|
await fs.promises.writeFile(filePath, '' + rightNow);
|
||||||
|
|
||||||
|
// If the last startup was less than 5s ago, something's not okay.
|
||||||
|
return Math.abs(delta) < 5000;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the launcher if required and returns a boolean based on whether
|
||||||
|
* it has. You should shut down this instance of the app in that case.
|
||||||
|
*/
|
||||||
|
export default async function delegateToLauncher(argv: {
|
||||||
|
launcher: boolean;
|
||||||
|
file?: string;
|
||||||
|
url?: string;
|
||||||
|
}) {
|
||||||
|
if (argv.launcher && isProduction() && (await isLauncherInstalled())) {
|
||||||
|
if (await checkIsCycle()) {
|
||||||
|
console.error(
|
||||||
|
'Launcher cycle detected. Not delegating even though I usually would.',
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.warn('Delegating to Flipper Launcher ...');
|
||||||
|
console.warn(
|
||||||
|
`You can disable this behavior by passing '--no-launcher' at startup.`,
|
||||||
|
);
|
||||||
|
startLauncher(argv);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import fixPath from 'fix-path';
|
|||||||
import {exec} from 'child_process';
|
import {exec} from 'child_process';
|
||||||
import setup, {Config, configPath} from './setup';
|
import setup, {Config, configPath} from './setup';
|
||||||
import isFB from './fb-stubs/isFB';
|
import isFB from './fb-stubs/isFB';
|
||||||
|
import delegateToLauncher from './launcher';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
@@ -173,8 +174,14 @@ app.on('ready', async () => {
|
|||||||
const config = await setup(argv);
|
const config = await setup(argv);
|
||||||
processConfig(config);
|
processConfig(config);
|
||||||
|
|
||||||
|
// If we delegate to the launcher, shut down this instance of the app.
|
||||||
|
delegateToLauncher(argv)
|
||||||
|
.then(async (hasLauncherInvoked: boolean) => {
|
||||||
|
if (hasLauncherInvoked) {
|
||||||
|
app.quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
appReady = true;
|
appReady = true;
|
||||||
|
|
||||||
app.commandLine.appendSwitch('scroll-bounce');
|
app.commandLine.appendSwitch('scroll-bounce');
|
||||||
configureSession();
|
configureSession();
|
||||||
createWindow(config);
|
createWindow(config);
|
||||||
@@ -217,6 +224,8 @@ app.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error('Error while delegating app launch', e));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('web-contents-created', (_event, contents) => {
|
app.on('web-contents-created', (_event, contents) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user