split setup
Summary: `static/index.js` is called by Electron's main process, it does the setup required to run Flipper. However, some of this setup is electron specific, other is not. This moves all non-Electron specific code into `setup.js` which later can be called from node, too. All Electron specific stuff is still in `static/index.js`. On a side note, this remove the renaming from `.sonar` to `.flipper` config folder, as I think most users should have been migrated by now, users that are not yet migrated will lose their settings, which isn't too much of an issue as our settings are very minimal anyways. Reviewed By: passy Differential Revision: D13638253 fbshipit-source-id: 22ab2a65ffec87b40bd86899630d582d9dc5d05c
This commit is contained in:
committed by
Facebook Github Bot
parent
978b14c3d3
commit
e02d823e5f
@@ -15,20 +15,11 @@ const fs = require('fs');
|
||||
const {exec} = require('child_process');
|
||||
const compilePlugins = require('./compilePlugins.js');
|
||||
const os = require('os');
|
||||
const setup = require('./setup');
|
||||
|
||||
// disable electron security warnings: https://github.com/electron/electron/blob/master/docs/tutorial/security.md#security-native-capabilities-and-your-responsibility
|
||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;
|
||||
|
||||
if (!process.env.ANDROID_HOME) {
|
||||
process.env.ANDROID_HOME = '/opt/android_sdk';
|
||||
}
|
||||
|
||||
// emulator/emulator is more reliable than tools/emulator, so prefer it if
|
||||
// it exists
|
||||
process.env.PATH = `${process.env.ANDROID_HOME}/emulator:${
|
||||
process.env.ANDROID_HOME
|
||||
}/tools:${process.env.PATH}`;
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
// If we are running on macOS and the app is called Flipper, we add a comment
|
||||
// with the old name, to make it findable via Spotlight using its old name.
|
||||
@@ -44,29 +35,7 @@ if (process.platform === 'darwin') {
|
||||
}
|
||||
}
|
||||
|
||||
// ensure .flipper folder and config exist
|
||||
const sonarDir = path.join(os.homedir(), '.sonar');
|
||||
const flipperDir = path.join(os.homedir(), '.flipper');
|
||||
if (fs.existsSync(flipperDir)) {
|
||||
// nothing to do
|
||||
} else if (fs.existsSync(sonarDir)) {
|
||||
// move .sonar to .flipper
|
||||
fs.renameSync(sonarDir, flipperDir);
|
||||
} else {
|
||||
fs.mkdirSync(flipperDir);
|
||||
}
|
||||
|
||||
const configPath = path.join(flipperDir, 'config.json');
|
||||
let config = {pluginPaths: [], disabledPlugins: [], lastWindowPosition: {}};
|
||||
|
||||
try {
|
||||
config = {
|
||||
...config,
|
||||
...JSON.parse(fs.readFileSync(configPath)),
|
||||
};
|
||||
} catch (e) {
|
||||
fs.writeFileSync(configPath, JSON.stringify(config));
|
||||
}
|
||||
let {config, configPath, flipperDir} = setup();
|
||||
|
||||
const pluginPaths = config.pluginPaths
|
||||
.concat(
|
||||
|
||||
Reference in New Issue
Block a user