Move files from `packager/` to `local-cli`

Summary: public

This is not only to put the files on a place where it makes more sense but also to allow to use ES6 features on them as `/packager` is not whitelisted on `babel`.

Reviewed By: mkonicek

Differential Revision: D2577267

fb-gh-sync-id: b69a17c0aad349a3eda987e33d1778d97a8e1549
This commit is contained in:
Martín Bigio 2015-10-26 12:59:54 -07:00 committed by facebook-github-bot-3
parent f87d2e15bd
commit bcf762af60
19 changed files with 30 additions and 24 deletions

View File

@ -10,7 +10,7 @@
const buildBundle = require('./buildBundle');
const bundleCommandLineArgs = require('./bundleCommandLineArgs');
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
/**
* Builds the bundle starting to look for dependencies at the given entry path.

View File

@ -10,7 +10,7 @@
const fs = require('fs');
const log = require('../util/log').out('dependencies');
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const ReactPackager = require('../../packager/react-packager');

View File

@ -8,7 +8,7 @@
*/
'use strict';
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const yeoman = require('yeoman-environment');

View File

@ -11,7 +11,7 @@
const copyAndReplace = require('../util/copyAndReplace');
const fs = require('fs');
const isValidPackageName = require('../util/isValidPackageName');
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const walk = require('../util/walk');

View File

@ -12,7 +12,7 @@ const chalk = require('chalk');
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
const isPackagerRunning = require('../util/isPackagerRunning');
const Promise = require('promise');

View File

@ -27,11 +27,11 @@ function getChromeAppName() {
module.exports = function(options, isDebuggerConnected) {
return function(req, res, next) {
if (req.url === '/debugger-ui') {
var debuggerPath = path.join(__dirname, 'debugger.html');
var debuggerPath = path.join(__dirname, '..', 'util', 'debugger.html');
res.writeHead(200, {'Content-Type': 'text/html'});
fs.createReadStream(debuggerPath).pipe(res);
} else if (req.url === '/debuggerWorker.js') {
var workerPath = path.join(__dirname, 'debuggerWorker.js');
var workerPath = path.join(__dirname, '..', 'util', 'debuggerWorker.js');
res.writeHead(200, {'Content-Type': 'application/javascript'});
fs.createReadStream(workerPath).pipe(res);
} else if (req.url === '/launch-safari-devtools') {

View File

@ -11,7 +11,7 @@
var chalk = require('chalk');
var exec = require('child_process').exec;
var url = require('url');
var Activity = require('./react-packager').Activity;
var Activity = require('../../../packager/react-packager').Activity;
var hasWarned = {};

View File

@ -8,7 +8,7 @@
*/
'use strict';
const launchEditor = require('./launchEditor');
const launchEditor = require('../util/launchEditor');
module.exports = function(req, res, next) {
if (req.url === '/open-stack-frame') {

View File

@ -9,21 +9,23 @@
'use strict';
const connect = require('connect');
const cpuProfilerMiddleware = require('../../packager/cpuProfilerMiddleware');
const getDevToolsMiddleware = require('../../packager/getDevToolsMiddleware');
const cpuProfilerMiddleware = require('./middleware/cpuProfilerMiddleware');
const getDevToolsMiddleware = require('./middleware/getDevToolsMiddleware');
const http = require('http');
const isAbsolutePath = require('absolute-path');
const loadRawBodyMiddleware = require('../../packager/loadRawBodyMiddleware');
const openStackFrameInEditorMiddleware = require('../../packager/openStackFrameInEditorMiddleware');
const loadRawBodyMiddleware = require('./middleware/loadRawBodyMiddleware');
const openStackFrameInEditorMiddleware = require('./middleware/openStackFrameInEditorMiddleware');
const path = require('path');
const ReactPackager = require('../../packager/react-packager');
const statusPageMiddleware = require('../../packager/statusPageMiddleware.js');
const systraceProfileMiddleware = require('../../packager/systraceProfileMiddleware.js');
const statusPageMiddleware = require('./middleware/statusPageMiddleware.js');
const systraceProfileMiddleware = require('./middleware/systraceProfileMiddleware.js');
const webSocketProxy = require('./util/webSocketProxy.js');
function runServer(args, config, readyCallback) {
var wsProxy = null;
const app = connect()
.use(loadRawBodyMiddleware)
.use(getDevToolsMiddleware(args))
.use(getDevToolsMiddleware(args, () => wsProxy && wsProxy.isChromeConnected()))
.use(openStackFrameInEditorMiddleware)
.use(statusPageMiddleware)
.use(systraceProfileMiddleware)
@ -38,7 +40,15 @@ function runServer(args, config, readyCallback) {
.use(connect.compress())
.use(connect.errorHandler());
return http.createServer(app).listen(args.port, '::', readyCallback);
const serverInstance = http.createServer(app).listen(
args.port,
'::',
function() {
wsProxy = webSocketProxy.attachToServer(serverInstance, '/debugger-proxy');
webSocketProxy.attachToServer(serverInstance, '/devtools');
readyCallback();
}
);
}
function getAppMiddleware(args, config) {

View File

@ -11,11 +11,10 @@
const chalk = require('chalk');
const checkNodeVersion = require('./checkNodeVersion');
const formatBanner = require('./formatBanner');
const parseCommandLine = require('../../packager/parseCommandLine');
const parseCommandLine = require('../util/parseCommandLine');
const path = require('path');
const Promise = require('promise');
const runServer = require('./runServer');
const webSocketProxy = require('../../packager/webSocketProxy.js');
/**
* Starts the React Native Packager Server.
@ -138,12 +137,9 @@ function _server(argv, config, resolve, reject) {
}
function startServer(args, config) {
const serverInstance = runServer(args, config, () =>
runServer(args, config, () =>
console.log('\nReact packager ready.\n')
);
webSocketProxy.attachToServer(serverInstance, '/debugger-proxy');
webSocketProxy.attachToServer(serverInstance, '/devtools');
}
function argToArray(arg) {

View File

@ -63,7 +63,7 @@ function attachToServer(server, path) {
return clients
.map(function(ws) { return ws.upgradeReq.headers['user-agent']; })
.filter(Boolean)
.some(function(userAgent) { return userAgent.includes('Chrome'); })
.some(function(userAgent) { return userAgent.includes('Chrome'); });
}
};
}