From d1aa3f34e634904eceee3876482b1b42a3b83c33 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 31 Mar 2016 12:22:34 -0500 Subject: [PATCH] chore(): cleanup dependencies --- lib/ports.js | 238 ++++++++++++++++++++++++++------------------------- lib/serve.js | 7 +- lib/start.js | 4 +- lib/utils.js | 2 +- package.json | 12 +-- 5 files changed, 127 insertions(+), 136 deletions(-) diff --git a/lib/ports.js b/lib/ports.js index de8cee1..707bf58 100644 --- a/lib/ports.js +++ b/lib/ports.js @@ -7,8 +7,10 @@ var fs = require('fs'), net = require('net'), - path = require('path'), - async = require('async'); + path = require('path'); + + // for getPorts, which isn't used + // async = require('async'); // for getSocket, which isn't used // mkdirp = require('mkdirp').mkdirp; @@ -64,28 +66,28 @@ exports.getPort = function (options, callback) { options.server.listen(options.port, options.host); }; -exports.getPorts = function (count, options, callback) { - if (!callback) { - callback = options; - options = {}; - } - - var lastPort = null; - async.timesSeries(count, function(index, asyncCallback) { - if (lastPort) { - options.port = exports.nextPort(lastPort); - } - - exports.getPort(options, function (err, port) { - if (err) { - asyncCallback(err); - } else { - lastPort = port; - asyncCallback(null, port); - } - }); - }, callback); -}; +// exports.getPorts = function (count, options, callback) { +// if (!callback) { +// callback = options; +// options = {}; +// } +// +// var lastPort = null; +// async.timesSeries(count, function(index, asyncCallback) { +// if (lastPort) { +// options.port = exports.nextPort(lastPort); +// } +// +// exports.getPort(options, function (err, port) { +// if (err) { +// asyncCallback(err); +// } else { +// lastPort = port; +// asyncCallback(null, port); +// } +// }); +// }, callback); +// }; // // ### function getSocket (options, callback) @@ -94,86 +96,86 @@ exports.getPorts = function (count, options, callback) { // Responds with a unbound socket using the specified directory and base // name on the current machine. // -exports.getSocket = function (options, callback) { - if (!callback) { - callback = options; - options = {}; - } - - options.mod = options.mod || 0755; - options.path = options.path || exports.basePath + '.sock'; - - // - // Tests the specified socket - // - function testSocket () { - fs.stat(options.path, function (err) { - // - // If file we're checking doesn't exist (thus, stating it emits ENOENT), - // we should be OK with listening on this socket. - // - if (err) { - if (err.code == 'ENOENT') { - callback(null, options.path); - } - else { - callback(err); - } - } - else { - // - // This file exists, so it isn't possible to listen on it. Lets try - // next socket. - // - options.path = exports.nextSocket(options.path); - exports.getSocket(options, callback); - } - }); - } - - // - // Create the target `dir` then test connection - // against the socket. - // - function createAndTestSocket (dir) { - mkdirp(dir, options.mod, function (err) { - if (err) { - return callback(err); - } - - options.exists = true; - testSocket(); - }); - } - - // - // Check if the parent directory of the target - // socket path exists. If it does, test connection - // against the socket. Otherwise, create the directory - // then test connection. - // - function checkAndTestSocket () { - var dir = path.dirname(options.path); - - fs.stat(dir, function (err, stats) { - if (err || !stats.isDirectory()) { - return createAndTestSocket(dir); - } - - options.exists = true; - testSocket(); - }); - } - - // - // If it has been explicitly stated that the - // target `options.path` already exists, then - // simply test the socket. - // - return options.exists - ? testSocket() - : checkAndTestSocket(); -}; +// exports.getSocket = function (options, callback) { +// if (!callback) { +// callback = options; +// options = {}; +// } +// +// options.mod = options.mod || 0755; +// options.path = options.path || exports.basePath + '.sock'; +// +// // +// // Tests the specified socket +// // +// function testSocket () { +// fs.stat(options.path, function (err) { +// // +// // If file we're checking doesn't exist (thus, stating it emits ENOENT), +// // we should be OK with listening on this socket. +// // +// if (err) { +// if (err.code == 'ENOENT') { +// callback(null, options.path); +// } +// else { +// callback(err); +// } +// } +// else { +// // +// // This file exists, so it isn't possible to listen on it. Lets try +// // next socket. +// // +// options.path = exports.nextSocket(options.path); +// exports.getSocket(options, callback); +// } +// }); +// } +// +// // +// // Create the target `dir` then test connection +// // against the socket. +// // +// function createAndTestSocket (dir) { +// mkdirp(dir, options.mod, function (err) { +// if (err) { +// return callback(err); +// } +// +// options.exists = true; +// testSocket(); +// }); +// } +// +// // +// // Check if the parent directory of the target +// // socket path exists. If it does, test connection +// // against the socket. Otherwise, create the directory +// // then test connection. +// // +// function checkAndTestSocket () { +// var dir = path.dirname(options.path); +// +// fs.stat(dir, function (err, stats) { +// if (err || !stats.isDirectory()) { +// return createAndTestSocket(dir); +// } +// +// options.exists = true; +// testSocket(); +// }); +// } +// +// // +// // If it has been explicitly stated that the +// // target `options.path` already exists, then +// // simply test the socket. +// // +// return options.exists +// ? testSocket() +// : checkAndTestSocket(); +// }; // // ### function nextPort (port) @@ -191,17 +193,17 @@ exports.nextPort = function (port) { // Gets the next socket path in sequence from the // specified `socketPath`. // -exports.nextSocket = function (socketPath) { - var dir = path.dirname(socketPath), - name = path.basename(socketPath, '.sock'), - match = name.match(/^([a-zA-z]+)(\d*)$/i), - index = parseInt(match[2]), - base = match[1]; - - if (isNaN(index)) { - index = 0; - } - - index += 1; - return path.join(dir, base + index + '.sock'); -}; +// exports.nextSocket = function (socketPath) { +// var dir = path.dirname(socketPath), +// name = path.basename(socketPath, '.sock'), +// match = name.match(/^([a-zA-z]+)(\d*)$/i), +// index = parseInt(match[2]), +// base = match[1]; +// +// if (isNaN(index)) { +// index = 0; +// } +// +// index += 1; +// return path.join(dir, base + index + '.sock'); +// }; diff --git a/lib/serve.js b/lib/serve.js index dcf9319..6a03eb5 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -8,7 +8,7 @@ var fs = require('fs'), serveStatic = require('serve-static'), tinylr = require('tiny-lr-fork'), lr = require('connect-livereload'), - vfs = require('vinyl-fs'), + globWatch = require('glob-watcher'), request = require('request'), proxyMiddleware = require('proxy-middleware'), url = require('url'), @@ -268,9 +268,10 @@ Serve.runLivereload = function runLivereload(options, app) { // log.debug('Absolute watch paths:', absoluteWatchPaths); - vfs.watch(options.watchPatterns, {}, function(f) { + var watcher = globWatch(options.watchPatterns); + watcher.on('change', function(evt){ //TODO: Move prototype to Serve._changed - Serve._changed(f.path, options); + Serve._changed(evt.path, options); }); var liveReloadPort = process.env.CONNECT_LIVE_RELOAD_PORT || options.liveReloadPort; diff --git a/lib/start.js b/lib/start.js index 2287f6e..43991b0 100644 --- a/lib/start.js +++ b/lib/start.js @@ -8,7 +8,7 @@ var fs = require('fs'), colors = require('colors'), Q = require('q'), open = require('open'), - unzip = require('unzip'), + unzip = require('unzip2'), xml2js = require('xml2js'), ProgressBar = require('progress'), IonicProject = require('./project'), @@ -273,8 +273,6 @@ Start.loadAppSetup = function loadAppSetup(options) { //Not Tested Start.fetchCreatorApp = function(options) { - var unzip = require('unzip2'); - var cookies = new IonicStore('cookies').get('https://apps.ionic.io'); var sessionId; diff --git a/lib/utils.js b/lib/utils.js index be56087..08ad58b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -86,7 +86,7 @@ Utils.fetchArchive = function fetchArchive(targetPath, archiveUrl, isGui) { var os = require('os'); var fs = require('fs'); var path = require('path'); - var unzip = require('unzip'); + var unzip = require('unzip2'); var q = Q.defer(); // The folder name the project will be downloaded and extracted to diff --git a/package.json b/package.json index 900024f..f1eb7d8 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,6 @@ "license": "MIT", "dependencies": { "archiver": "0.5.2", - "async": "0.9.0", - "autoprefixer": "6.2.3", "cheerio": "0.19.0", "colors": "0.6.2", "connect": "3.1.1", @@ -50,17 +48,11 @@ "cordova-lib": "6.1.0", "crc": "3.2.1", "cross-spawn-async": "2.1.9", - "event-stream": "3.0.20", "finalhandler": "0.2.0", "form-data": "0.1.4", - "gulp-autoprefixer": "3.1.0", - "gulp-cached": "1.1.0", - "gulp-sass": "2.1.1", - "gulp-watch": "4.3.5", - "lodash": "3.10.1", + "glob-watcher": "2.0.0", "open": "0.0.5", "optimist": "0.6.0", - "postcss": "5.0.14", "progress": "1.1.7", "prompt": "0.2.12", "proxy-middleware": "0.7.0", @@ -72,9 +64,7 @@ "shelljs": "0.2.6", "tiny-lr-fork": "0.0.5", "underscore": "1.7.0", - "unzip": "0.1.9", "unzip2": "0.2.5", - "vinyl-fs": "1.0.0", "winston": "1.1.2", "xml2js": "0.4.16" },