2015-10-12 23:46:52 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-10-12 23:46:52 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-05-17 11:56:02 +00:00
|
|
|
*
|
2018-05-11 19:43:49 +00:00
|
|
|
* @format
|
2018-08-17 00:25:06 +00:00
|
|
|
* @flow
|
2015-10-12 23:46:52 +00:00
|
|
|
*/
|
2017-05-17 11:56:02 +00:00
|
|
|
|
2015-10-12 23:46:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const runServer = require('./runServer');
|
|
|
|
|
2017-05-17 11:56:02 +00:00
|
|
|
import type {RNConfig} from '../core';
|
2018-07-25 12:44:40 +00:00
|
|
|
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
2017-05-17 11:56:02 +00:00
|
|
|
import type {Args as RunServerArgs} from './runServer';
|
|
|
|
|
2015-10-12 23:46:52 +00:00
|
|
|
/**
|
|
|
|
* Starts the React Native Packager Server.
|
|
|
|
*/
|
2018-07-02 16:33:08 +00:00
|
|
|
function server(argv: mixed, config: RNConfig, args: RunServerArgs) {
|
2018-03-29 13:24:04 +00:00
|
|
|
/* $FlowFixMe(site=react_native_fb) ConfigT shouldn't be extendable. */
|
2017-05-17 11:56:02 +00:00
|
|
|
const configT: ConfigT = config;
|
2018-07-02 16:33:08 +00:00
|
|
|
runServer(args, configT);
|
2015-10-12 23:46:52 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 15:59:16 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'start',
|
|
|
|
func: server,
|
|
|
|
description: 'starts the webserver',
|
2018-05-11 19:43:49 +00:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
command: '--port [number]',
|
|
|
|
parse: (val: string) => Number(val),
|
2018-09-18 15:08:48 +00:00
|
|
|
default: (config: ConfigT) => config.server.port,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--host [string]',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
2018-06-22 15:09:48 +00:00
|
|
|
command: '--projectRoot [string]',
|
|
|
|
description: 'Specify the main project root',
|
2018-09-18 15:08:48 +00:00
|
|
|
default: (config: ConfigT) => config.projectRoot,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
2018-06-19 20:45:17 +00:00
|
|
|
command: '--watchFolders [list]',
|
|
|
|
description:
|
2018-06-22 15:09:48 +00:00
|
|
|
'Specify any additional folders to be added to the watch list',
|
2018-05-11 19:43:49 +00:00
|
|
|
parse: (val: string) => val.split(','),
|
2018-09-18 15:08:48 +00:00
|
|
|
default: (config: ConfigT) => config.watchFolders,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--assetExts [list]',
|
|
|
|
description:
|
|
|
|
'Specify any additional asset extensions to be used by the packager',
|
|
|
|
parse: (val: string) => val.split(','),
|
2018-07-25 12:44:40 +00:00
|
|
|
default: (config: ConfigT) => config.resolver.assetExts,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--sourceExts [list]',
|
|
|
|
description:
|
|
|
|
'Specify any additional source extensions to be used by the packager',
|
|
|
|
parse: (val: string) => val.split(','),
|
2018-07-25 12:44:40 +00:00
|
|
|
default: (config: ConfigT) => config.resolver.sourceExts,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--platforms [list]',
|
|
|
|
description:
|
|
|
|
'Specify any additional platforms to be used by the packager',
|
|
|
|
parse: (val: string) => val.split(','),
|
2018-07-25 12:44:40 +00:00
|
|
|
default: (config: ConfigT) => config.resolver.platforms,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--providesModuleNodeModules [list]',
|
|
|
|
description:
|
|
|
|
'Specify any npm packages that import dependencies with providesModule',
|
|
|
|
parse: (val: string) => val.split(','),
|
2018-09-18 15:08:48 +00:00
|
|
|
default: (config: ConfigT) => config.resolver.providesModuleNodeModules,
|
2018-05-11 19:43:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--max-workers [number]',
|
|
|
|
description:
|
|
|
|
'Specifies the maximum number of workers the worker-pool ' +
|
|
|
|
'will spawn for transforming files. This defaults to the number of the ' +
|
|
|
|
'cores available on your machine.',
|
2018-09-18 15:08:48 +00:00
|
|
|
default: (config: ConfigT) => config.maxWorkers,
|
2018-05-11 19:43:49 +00:00
|
|
|
parse: (workers: string) => Number(workers),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--skipflow',
|
|
|
|
description: 'Disable flow checks',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--nonPersistent',
|
|
|
|
description: 'Disable file watcher',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--transformer [string]',
|
|
|
|
description: 'Specify a custom transformer to be used',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--reset-cache, --resetCache',
|
|
|
|
description: 'Removes cached files',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--custom-log-reporter-path, --customLogReporterPath [string]',
|
|
|
|
description:
|
|
|
|
'Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--verbose',
|
|
|
|
description: 'Enables logging',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--https',
|
|
|
|
description: 'Enables https connections to the server',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--key [path]',
|
|
|
|
description: 'Path to custom SSL key',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
command: '--cert [path]',
|
|
|
|
description: 'Path to custom SSL cert',
|
|
|
|
},
|
|
|
|
],
|
2016-07-30 15:59:16 +00:00
|
|
|
};
|