2015-10-12 23:46:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const runServer = require('./runServer');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the React Native Packager Server.
|
|
|
|
*/
|
2016-07-30 15:59:16 +00:00
|
|
|
function server(argv, config, args) {
|
2017-03-06 08:18:21 +00:00
|
|
|
args.projectRoots = args.projectRoots.concat(args.root);
|
2015-10-12 23:46:52 +00:00
|
|
|
|
2017-03-31 09:10:00 +00:00
|
|
|
const startedCallback = logReporter => {
|
|
|
|
logReporter.update({
|
|
|
|
type: 'initialize_packager_started',
|
|
|
|
port: args.port,
|
|
|
|
projectRoots: args.projectRoots,
|
|
|
|
});
|
2015-10-12 23:46:52 +00:00
|
|
|
|
2017-03-31 09:10:00 +00:00
|
|
|
process.on('uncaughtException', error => {
|
|
|
|
logReporter.update({
|
|
|
|
type: 'initialize_packager_failed',
|
|
|
|
port: args.port,
|
|
|
|
error,
|
|
|
|
});
|
2015-10-12 23:46:52 +00:00
|
|
|
|
2017-03-31 09:10:00 +00:00
|
|
|
process.exit(11);
|
|
|
|
});
|
|
|
|
};
|
2015-10-12 23:46:52 +00:00
|
|
|
|
2017-03-31 09:10:00 +00:00
|
|
|
const readyCallback = logReporter => {
|
|
|
|
logReporter.update({
|
|
|
|
type: 'initialize_packager_done',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
runServer(args, config, startedCallback, readyCallback);
|
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',
|
|
|
|
options: [{
|
|
|
|
command: '--port [number]',
|
|
|
|
default: 8081,
|
|
|
|
parse: (val) => Number(val),
|
|
|
|
}, {
|
|
|
|
command: '--host [string]',
|
|
|
|
default: '',
|
|
|
|
}, {
|
|
|
|
command: '--root [list]',
|
|
|
|
description: 'add another root(s) to be used by the packager in this project',
|
|
|
|
parse: (val) => val.split(',').map(root => path.resolve(root)),
|
|
|
|
default: [],
|
|
|
|
}, {
|
|
|
|
command: '--projectRoots [list]',
|
|
|
|
description: 'override the root(s) to be used by the packager',
|
|
|
|
parse: (val) => val.split(','),
|
|
|
|
default: (config) => config.getProjectRoots(),
|
2016-08-02 17:13:13 +00:00
|
|
|
}, {
|
|
|
|
command: '--assetExts [list]',
|
2017-05-04 12:06:27 +00:00
|
|
|
description: 'Specify any additional asset extensions to be used by the packager',
|
2016-08-02 17:13:13 +00:00
|
|
|
parse: (val) => val.split(','),
|
|
|
|
default: (config) => config.getAssetExts(),
|
2017-05-04 12:06:27 +00:00
|
|
|
}, {
|
|
|
|
command: '--sourceExts [list]',
|
|
|
|
description: 'Specify any additional source extensions to be used by the packager',
|
|
|
|
parse: (val) => val.split(','),
|
|
|
|
default: (config) => config.getSourceExts(),
|
2016-12-02 17:41:28 +00:00
|
|
|
}, {
|
|
|
|
command: '--platforms [list]',
|
|
|
|
description: 'Specify any additional platforms to be used by the packager',
|
|
|
|
parse: (val) => val.split(','),
|
|
|
|
default: (config) => config.getPlatforms(),
|
2017-01-13 05:03:57 +00:00
|
|
|
}, {
|
|
|
|
command: '--providesModuleNodeModules [list]',
|
|
|
|
description: 'Specify any npm packages that import dependencies with providesModule',
|
|
|
|
parse: (val) => val.split(','),
|
|
|
|
default: (config) => {
|
|
|
|
if (typeof config.getProvidesModuleNodeModules === 'function') {
|
|
|
|
return config.getProvidesModuleNodeModules();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2016-07-30 15:59:16 +00:00
|
|
|
}, {
|
|
|
|
command: '--skipflow',
|
|
|
|
description: 'Disable flow checks'
|
|
|
|
}, {
|
|
|
|
command: '--nonPersistent',
|
|
|
|
description: 'Disable file watcher'
|
|
|
|
}, {
|
|
|
|
command: '--transformer [string]',
|
2016-09-12 22:11:22 +00:00
|
|
|
description: 'Specify a custom transformer to be used'
|
2016-07-30 15:59:16 +00:00
|
|
|
}, {
|
|
|
|
command: '--reset-cache, --resetCache',
|
|
|
|
description: 'Removes cached files',
|
2017-03-31 01:14:28 +00:00
|
|
|
}, {
|
|
|
|
command: '--custom-log-reporter-path, --customLogReporterPath [string]',
|
|
|
|
description: 'Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter',
|
2016-07-30 15:59:16 +00:00
|
|
|
}, {
|
|
|
|
command: '--verbose',
|
|
|
|
description: 'Enables logging',
|
|
|
|
}],
|
|
|
|
};
|