add command line options
Summary: Adding options for the CLI Reviewed By: passy Differential Revision: D13864405 fbshipit-source-id: 1900c32833c7d18a4806f2a839215b5b536cb44f
This commit is contained in:
committed by
Facebook Github Bot
parent
db9bc985eb
commit
45d1a7b35c
@@ -12,43 +12,88 @@ import Logger, {init} from '../src/fb-stubs/Logger.js';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
// $FlowFixMe this file exist, trust me, flow!
|
// $FlowFixMe this file exist, trust me, flow!
|
||||||
import setup from '../static/setup.js';
|
import setup from '../static/setup.js';
|
||||||
|
import yargs from 'yargs';
|
||||||
|
|
||||||
console.error(`
|
yargs
|
||||||
_____ _ _
|
.usage('$0 [args]')
|
||||||
| __| |_|___ ___ ___ ___
|
.command(
|
||||||
| __| | | . | . | -_| _|
|
'*',
|
||||||
|__| |_|_| _| _|___|_| v${global.__VERSION__}
|
'Start a headless Flipper instance',
|
||||||
|_| |_|
|
yargs => {
|
||||||
`);
|
yargs.option('secure-port', {
|
||||||
// redirect all logging to stderr
|
default: '8088',
|
||||||
const verboseMode = false;
|
describe: 'Secure port the Flipper server should run on.',
|
||||||
const originalConsole = global.console;
|
type: 'string',
|
||||||
global.console = new Proxy(console, {
|
});
|
||||||
get: function(obj, prop) {
|
yargs.option('insecure-port', {
|
||||||
return (...args) => {
|
default: '8089',
|
||||||
if (prop === 'error' || verboseMode) {
|
describe: 'Insecure port the Flipper server should run on.',
|
||||||
originalConsole.error(`[${prop}] `, ...args);
|
type: 'string',
|
||||||
}
|
});
|
||||||
};
|
yargs.option('dev', {
|
||||||
},
|
default: false,
|
||||||
});
|
describe:
|
||||||
|
'Enable redux-devtools. Tries to connect to devtools running on port 8181',
|
||||||
|
type: 'boolean',
|
||||||
|
});
|
||||||
|
yargs.option('v', {
|
||||||
|
alias: 'verbose',
|
||||||
|
default: false,
|
||||||
|
describe: 'Enable verbose logging',
|
||||||
|
type: 'boolean',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
startFlipper,
|
||||||
|
)
|
||||||
|
.version(global.__VERSION__)
|
||||||
|
.help().argv;
|
||||||
|
|
||||||
// Polyfills
|
function startFlipper({
|
||||||
global.WebSocket = require('ws'); // used for redux devtools
|
dev,
|
||||||
global.fetch = require('node-fetch/lib/index');
|
verbose,
|
||||||
|
'insecure-port': insecurePort,
|
||||||
|
'secure-port': securePort,
|
||||||
|
}) {
|
||||||
|
console.error(`
|
||||||
|
_____ _ _
|
||||||
|
| __| |_|___ ___ ___ ___
|
||||||
|
| __| | | . | . | -_| _|
|
||||||
|
|__| |_|_| _| _|___|_| v${global.__VERSION__}
|
||||||
|
|_| |_|
|
||||||
|
`);
|
||||||
|
// redirect all logging to stderr
|
||||||
|
const originalConsole = global.console;
|
||||||
|
global.console = new Proxy(console, {
|
||||||
|
get: function(obj, prop) {
|
||||||
|
return (...args) => {
|
||||||
|
if (prop === 'error' || verbose) {
|
||||||
|
originalConsole.error(`[${prop}] `, ...args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
process.env.BUNDLED_PLUGIN_PATH =
|
// Polyfills
|
||||||
process.env.BUNDLED_PLUGIN_PATH ||
|
global.WebSocket = require('ws'); // used for redux devtools
|
||||||
path.join(path.dirname(process.execPath), 'plugins');
|
global.fetch = require('node-fetch/lib/index');
|
||||||
|
|
||||||
// needs to be required after WebSocket polyfill is loaded
|
process.env.BUNDLED_PLUGIN_PATH =
|
||||||
const devToolsEnhancer = require('remote-redux-devtools').default;
|
process.env.BUNDLED_PLUGIN_PATH ||
|
||||||
|
path.join(path.dirname(process.execPath), 'plugins');
|
||||||
|
|
||||||
setup();
|
process.env.FLIPPER_PORTS = `${insecurePort},${securePort}`;
|
||||||
const store = createStore(
|
|
||||||
reducers,
|
// needs to be required after WebSocket polyfill is loaded
|
||||||
devToolsEnhancer({realtime: true, hostname: 'localhost', port: 8181}),
|
const devToolsEnhancer = require('remote-redux-devtools').default;
|
||||||
);
|
|
||||||
const logger = new Logger(store);
|
setup();
|
||||||
init(store);
|
const store = dev
|
||||||
dispatcher(store, logger);
|
? createStore(
|
||||||
|
reducers,
|
||||||
|
devToolsEnhancer({realtime: true, hostname: 'localhost', port: 8181}),
|
||||||
|
)
|
||||||
|
: createStore(reducers);
|
||||||
|
const logger = new Logger(store);
|
||||||
|
init(store);
|
||||||
|
dispatcher(store, logger);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user