From 7fa0c9d4cb23336018081d31145ce6ddce0db9b5 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Tue, 7 Apr 2015 14:09:53 +1000 Subject: [PATCH 01/16] hotfix(modules): Correctly handle multiple peerDependencies as module dependencies Release v1.2.5 --- lib/util/dependencies.js | 10 ++++------ package.json | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/util/dependencies.js b/lib/util/dependencies.js index 3603906..735ba5c 100644 --- a/lib/util/dependencies.js +++ b/lib/util/dependencies.js @@ -1,4 +1,5 @@ var Promise = require('bluebird') + , lodash = require('lodash') , path = require('path') , async = require('async') , fs = require('fs') @@ -17,7 +18,7 @@ function installPeerModules(project, dependencies, projectDir) { return new Promise(function(resolve, reject) { projectDir = typeof projectDir !== 'undefined' ? projectDir : project; - dependencies = Array.isArray(dependencies) ? dependencies : [dependencies]; + dependencies = lodash.pairs(dependencies); // @todo refactor this if (dependencies.length < 1) { @@ -29,7 +30,7 @@ function installPeerModules(project, dependencies, projectDir) { async.filter( dependencies, function filterAlreadyInstalledModules(dependency, moduleIsInstalled) { - fs.exists(path.join(projectDir, Object.keys(dependency)[0]), function IsModuleInModulesFolder(exists) { + fs.exists(path.join(projectDir, dependency[0]), function IsModuleInModulesFolder(exists) { moduleIsInstalled(!exists); }); }, @@ -39,10 +40,7 @@ function installPeerModules(project, dependencies, projectDir) { } modulesToInstall = modulesToInstall.map(function(dependency) { - var dependencyName = Object.keys(dependency)[0] - , dependencyVersion = dependency[dependencyName]; - - return dependencyName + '@' + dependencyVersion; + return dependency.join('@'); }); lib diff --git a/package.json b/package.json index 2d09567..3a19970 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.4", + "version" : "1.2.5", "license" : "MIT", "author": { "name" : "CleverStack", From 5b8718ff94579331419870623e1d9c82b832309a Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Mon, 13 Apr 2015 03:59:44 +1000 Subject: [PATCH 02/16] feat(bower): Now uses spawn instead of exec --- lib/util/bower.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/util/bower.js b/lib/util/bower.js index 3fcbd95..e40f994 100644 --- a/lib/util/bower.js +++ b/lib/util/bower.js @@ -1,4 +1,6 @@ -var exec = require('child_process').exec; +var spawn = require('child_process').spawn + , os = require('os') + , isWin = /^win32/.test(os.platform()); /** * Runs bower install @@ -21,6 +23,8 @@ exports.install = function(modulePath, options, fn) { options = typeof options === 'object' && options !== null ? options : { }; + additionalOptions.push('install'); + if (program.allowRoot) { additionalOptions.push('--allow-root'); } @@ -38,7 +42,7 @@ exports.install = function(modulePath, options, fn) { additionalOptions.push('--config.' + option + '=' + options[ option ]); }); - // Any additional paramters in which we want to allow within exec() + // Any additional paramters in which we want to allow within spawn() [ 'env' ].filter(function(key) { return program.hasOwnProperty(key); }) @@ -46,11 +50,22 @@ exports.install = function(modulePath, options, fn) { params[ key ] = params[ key ]; }); - var proc = exec(('bower install ' + additionalOptions.join(' ')).trim(), params, fn); - - // Pipe the output of exec if verbose has been specified - if (program.verbose) { - proc.stdout.pipe(process.stdout); - proc.stderr.pipe(process.stdout); + if (!!program.verbose) { + additionalOptions.push('--verbose'); } + + var proc = spawn(!isWin ? 'bower' : 'bower.cmd', additionalOptions, params) + , error; + + proc.on('error', function(err) { + error += err; + }); + + proc.on('close', function(code) { + if (code !== 0 || !!error) { + fn(error); + } else { + fn(null); + } + }); }; From 528cda0e130d5111aacf52ee88b89f611cce5531 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Tue, 14 Apr 2015 19:43:29 +1000 Subject: [PATCH 03/16] chore(cleanup): Handle exists for all spawned processes + deadline implementation + cleanup --- bin/clever-init | 16 +++++++-- bin/clever-setup | 37 +++++++++++++------ lib/project.js | 49 +++++++++++++++++--------- lib/util/bower.js | 24 +++++++++---- lib/util/grunt.js | 90 ++++++++++++++++++++++++++++++++++------------- 5 files changed, 155 insertions(+), 61 deletions(-) diff --git a/bin/clever-init b/bin/clever-init index c22cd90..15a0539 100755 --- a/bin/clever-init +++ b/bin/clever-init @@ -10,6 +10,7 @@ var path = require('path') , async = require('async') , exec = require('child_process').exec , spawn = require('child_process').spawn + , readline = require('readline') , Promise = require('bluebird') , singleSeed = true , seedsToInstall = [] @@ -112,15 +113,24 @@ function installNPMPackages(projectDir) { var args = ['install'] , opts = { env: process.env, cwd: projectDir }; - if (!!program.verbose) { - opts.stdio = 'inherit'; - } else { + if (!program.verbose) { args.push('--silent'); } var proc = spawn('npm', args, opts) , error = ''; + if (!!program.verbose) { + readline + .createInterface({ + input : proc.stdout, + terminal : false + }) + .on('line', function(line) { + console.log(' ' + line); + }); + } + proc.on('error', function(err) { error += err; }); diff --git a/bin/clever-setup b/bin/clever-setup index 7011833..1aec604 100755 --- a/bin/clever-setup +++ b/bin/clever-setup @@ -5,6 +5,7 @@ var path = require('path') , program = GLOBAL.program = require('commander') , async = require('async') , spawn = require('child_process').spawn + , readline = require('readline') , fs = require('fs') , os = require('os') , isWin = /^win32/.test(os.platform()) @@ -99,23 +100,39 @@ async.waterfall( var args = ['install'] , opts = { cwd: _path, env: process.env }; - if (program.verbose) { - opts.stdio = 'inherit'; - lib.utils.info(' Installing NPM modules for ' + _path + '...'); - } else { + lib + .utils + .info(' Installing NPM modules for ' + seed.name + '...') + .running(' Installing NPM modules for ' + seed.name + '...'); + + if (!program.verbose) { args.push('--silent'); - lib.utils.info(' Installing NPM modules for ' + seed.name + '...'); } - lib.utils.running(' Installing NPM modules for ' + seed.name + '...'); - var proc = spawn(!isWin ? 'npm' : 'npm.cmd', args, opts) - , error = ''; + var posixProc = spawn(!isWin ? 'npm' : 'npm.cmd', args, opts) + , exitHdlr = process.kill.bind(process, posixProc) + , error = ''; + + if (!!program.verbose) { + readline + .createInterface({ + input : posixProc.stdout, + terminal : false + }) + .on('line', function(line) { + console.log(' ' + line); + }); + } - proc.on('error', function(err) { + process.on('SIGTERM', exitHdlr); + + posixProc.on('error', function(err) { error += err; }); - proc.on('close', function(code) { + posixProc.on('close', function(code) { + process.removeListener('SIGTERM', exitHdlr); + if (code !== 0) { return lib.utils.fail(error); } diff --git a/lib/project.js b/lib/project.js index bbaf871..9dcef53 100644 --- a/lib/project.js +++ b/lib/project.js @@ -1,13 +1,14 @@ -var Promise = require('bluebird') - , path = require('path') - , async = require('async') - , spawn = require('child_process').spawn - , fs = Promise.promisifyAll(require('fs')) - , install = GLOBAL.lib.install - , _bower = GLOBAL.lib.util.bower - , utils = GLOBAL.lib.utils - , os = require('os') - , isWin = /^win32/.test(os.platform()); +var Promise = require('bluebird') + , path = require('path') + , async = require('async') + , spawn = require('child_process').spawn + , readline = require('readline') + , fs = Promise.promisifyAll(require('fs')) + , install = GLOBAL.lib.install + , _bower = GLOBAL.lib.util.bower + , utils = GLOBAL.lib.utils + , os = require('os') + , isWin = /^win32/.test(os.platform()); Promise.longStackTraces(); @@ -156,20 +157,34 @@ exports.installModule = function(project, modulePath) { , args = ['install', '--prefix', projectFolder].concat(deps) , cmd = !isWin ? 'npm' : 'npm.cmd'; - if (!!program.verbose) { - opts.stdio = 'inherit'; - } else { + if (!program.verbose) { args.push('--silent'); } - var proc = spawn(cmd, args, opts) - , error = ''; + var posixProc = spawn(cmd, args, opts) + , exitHdlr = process.kill.bind(process, posixProc) + , error = ''; + + process.on('SIGTERM', exitHdlr); + + if (!!program.verbose) { + readline + .createInterface({ + input : posixProc.stdout, + terminal : false + }) + .on('line', function(line) { + console.log(' ' + line); + }); + } - proc.on('error', function(err) { + posixProc.on('error', function(err) { error += err; }); - proc.on('close', function(code) { + posixProc.on('close', function(code) { + process.removeListener('SIGTERM', exitHdlr); + if (code !== 0 || !!error) { callback(error); } else { diff --git a/lib/util/bower.js b/lib/util/bower.js index e40f994..2ab3c25 100644 --- a/lib/util/bower.js +++ b/lib/util/bower.js @@ -1,6 +1,7 @@ -var spawn = require('child_process').spawn - , os = require('os') - , isWin = /^win32/.test(os.platform()); +var spawn = require('child_process').spawn + , readline = require('readline') + , os = require('os') + , isWin = /^win32/.test(os.platform()); /** * Runs bower install @@ -54,14 +55,25 @@ exports.install = function(modulePath, options, fn) { additionalOptions.push('--verbose'); } - var proc = spawn(!isWin ? 'bower' : 'bower.cmd', additionalOptions, params) + var posixProc = spawn(!isWin ? 'bower' : 'bower.cmd', additionalOptions, params) , error; - proc.on('error', function(err) { + if (!!program.verbose || process.mainModule.filename.match('build')) { + readline + .createInterface({ + input : posixProc.stdout, + terminal : false + }) + .on('line', function(line) { + console.log(' ' + line); + }); + } + + posixProc.on('error', function(err) { error += err; }); - proc.on('close', function(code) { + posixProc.on('close', function(code) { if (code !== 0 || !!error) { fn(error); } else { diff --git a/lib/util/grunt.js b/lib/util/grunt.js index 957a054..2097d24 100644 --- a/lib/util/grunt.js +++ b/lib/util/grunt.js @@ -1,10 +1,11 @@ -var Promise = require('bluebird') - , path = require('path') - , async = require('async') - , fs = require('fs') - , spawn = require('child_process').spawn - , os = require('os') - , isWin = /^win32/.test(os.platform()); +var Promise = require('bluebird') + , path = require('path') + , async = require('async') + , fs = require('fs') + , spawn = require('child_process').spawn + , readline = require('readline') + , os = require('os') + , isWin = /^win32/.test(os.platform()); /** * Mimmicks a small grunt-cli utility @@ -107,31 +108,65 @@ var readTasks = exports.readTasks = function(pathSrc, silence) { * @return {Promise} Returns a promise from bluebird * @api private */ -function runTask(projectFolder, cmd) { +exports.runTask = function runTask(projectFolder, command) { + var args = [].slice.call(arguments, 1); + return new Promise(function(resolve, reject) { - var env = process.env - , paths = process.env.NODE_PATH ? [process.env.NODE_PATH] : []; + var cmd = !isWin ? 'grunt' : 'grunt.cmd' + , env = process.env + , opts = {env: env, cwd: projectFolder} + , paths = process.env.NODE_PATH ? [process.env.NODE_PATH] : []; + + // Pass the --verbose call down to grunt as well + if (!!program.verbose) { + args.push('--verbose'); + + var logMsg = 'Spawning posix child process to run '+lib.colors.lightGreen(cmd+' '+args.join(' ')) + '...'; + lib.utils.info(logMsg).running(logMsg); + } paths.push(path.resolve(path.join(projectFolder, 'lib')) + path.sep); paths.push(path.resolve(path.join(projectFolder, 'modules')) + path.sep); - env.NODE_PATH = paths.join(os.platform() === 'win32' ? ';' : ':'); + env.NODE_PATH = paths.join(!!isWin ? ';' : ':'); - spawn(!isWin ? 'grunt' : 'grunt.cmd', [ cmd ], { cwd: projectFolder, env: env, stdio: 'inherit' }) - .on('close', function(code) { - if (code !== 0) { - return reject(); - } + var posixProc = spawn(cmd, args, opts) + , exitHdlr = process.kill.bind(process, posixProc) + , error = ''; - if (cmd.indexOf('prompt')) { - lib.utils.progress(); - lib.utils.startBar(function() { - resolve(); - }); - } else { + process.on('SIGTERM', exitHdlr); + + if (!!program.verbose || process.mainModule.filename.match('build')) { + readline + .createInterface({ + input : posixProc.stdout, + terminal : false + }) + .on('line', function(line) { + console.log(' ' + line); + }); + } + + posixProc.on('error', function(err) { + error += err; + }); + + posixProc.on('close', function(code) { + process.removeListener('SIGTERM', exitHdlr); + + if (code !== 0 || !!error) { + return reject(error); + } + + if (command.indexOf('prompt')) { + lib.utils.progress(); + lib.utils.startBar(function() { resolve(); - } - }); + }); + } else { + resolve(); + } + }); }); } @@ -152,7 +187,7 @@ function runDBMigrations(projectFolder) { paths.push(path.resolve(path.join(projectFolder, 'lib')) + path.sep); paths.push(path.resolve(path.join(projectFolder, 'modules')) + path.sep); - env.NODE_PATH = paths.join(os.platform() === 'win32' ? ';' : ':'); + env.NODE_PATH = paths.join(!!isWin ? ';' : ':'); // check for NODE_ENV json config file if it doesn't exist then revert to local if (!fs.existsSync(path.join(projectFolder, 'config', env.NOD_ENV + '.json'))) { @@ -198,8 +233,13 @@ function runDBMigrations(projectFolder) { */ exports.runTasks = function(projectFolder, modulePath) { return new Promise(function(resolve, reject) { + var originalCwd = process.cwd(); + process.chdir(projectFolder); + readTasks(modulePath) .spread(function(tasks) { + + process.chdir(originalCwd); if (tasks.length) { lib.utils.warn(' Running grunt tasks for module ' + modulePath.split(path.sep).pop() + '...'); From 31bc883e0930487b9de08ee1806e7f06ce50ee48 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Tue, 14 Apr 2015 19:43:37 +1000 Subject: [PATCH 04/16] fix(build): Build working again for frontend using spawn --- bin/clever-build | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/bin/clever-build b/bin/clever-build index aa6544c..a3e9f33 100755 --- a/bin/clever-build +++ b/bin/clever-build @@ -1,11 +1,12 @@ #!/usr/bin/env node -var path = require('path') - , fs = require('fs') - , spawn = require('child_process').spawn - , async = require('async') - , lib = GLOBAL.lib = require(path.join(__dirname, '..', 'lib')) - , program = GLOBAL.program = require('commander'); +var path = require('path') + , fs = require('fs') + , spawn = require('child_process').spawn + , readline = require('readline') + , async = require('async') + , lib = GLOBAL.lib = require(path.join(__dirname, '..', 'lib')) + , program = GLOBAL.program = require('commander'); /** Define CLI Options @@ -47,7 +48,7 @@ files var readPkg = require(pkg) , hasPkgName = readPkg.hasOwnProperty('name'); - if (hasPkgName && readPkg.name.indexOf('package.json') === -1) { + if (hasPkgName && readPkg.name.indexOf('package.json') === -1 && readPkg.name.indexOf('node-seed') === -1) { folders.push({ path: path.resolve(path.join(pkg, '..')) }); @@ -64,17 +65,19 @@ if (folders.length < 1) { async.each( folders, function run(folder, next) { - var proc = spawn(['grunt', '--base', folder.path, '--gruntfile', path.resolve(path.join(folder.path, 'Gruntfile.js')), 'build'].join(' '), function(err) { - if (err !== null && err !== undefined) { - next(err); - } else { - lib.utils.success('Build for ' + folder.path + ' was successful'); - next(null); - } - }); - - proc.stdout.pipe(process.stdout); - proc.stderr.pipe(process.stderr); + lib + .util + .grunt + .runTask( + folder.path, 'build', + '--base', folder.path, + '--gruntfile', path.resolve(path.join(folder.path, 'Gruntfile.js')) + ) + .then(function() { + lib.utils.success('Build for ' + folder.path + ' was successful'); + next(null); + }) + .catch(next); }, function handleErr(err) { if (!!err) { From 3f5b49da0e542c5e7a0e68b93df5fb8edd90d536 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Mon, 20 Apr 2015 13:42:47 +1000 Subject: [PATCH 05/16] fix(windows): Fix windows error in init - fixes #66 --- bin/clever-init | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/clever-init b/bin/clever-init index 15a0539..55a2642 100755 --- a/bin/clever-init +++ b/bin/clever-init @@ -10,6 +10,8 @@ var path = require('path') , async = require('async') , exec = require('child_process').exec , spawn = require('child_process').spawn + , os = require('os') + , isWin = /^win32/.test(os.platform()) , readline = require('readline') , Promise = require('bluebird') , singleSeed = true @@ -117,7 +119,7 @@ function installNPMPackages(projectDir) { args.push('--silent'); } - var proc = spawn('npm', args, opts) + var proc = spawn(!isWin ? 'npm' : 'npm.cmd', args, opts) , error = ''; if (!!program.verbose) { diff --git a/package.json b/package.json index 3a19970..5a71cf1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.5", + "version" : "1.2.6", "license" : "MIT", "author": { "name" : "CleverStack", From ab9c5424af1f019ce55f288a1e9558f2cce448bb Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Tue, 5 May 2015 23:13:46 +1000 Subject: [PATCH 06/16] fix(grunt): Resolved issue with function hoisting runTask and issue with stdio --- lib/util/grunt.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/util/grunt.js b/lib/util/grunt.js index 2097d24..17eb77b 100644 --- a/lib/util/grunt.js +++ b/lib/util/grunt.js @@ -108,13 +108,14 @@ var readTasks = exports.readTasks = function(pathSrc, silence) { * @return {Promise} Returns a promise from bluebird * @api private */ -exports.runTask = function runTask(projectFolder, command) { +function runTask(projectFolder, command) { var args = [].slice.call(arguments, 1); return new Promise(function(resolve, reject) { var cmd = !isWin ? 'grunt' : 'grunt.cmd' , env = process.env - , opts = {env: env, cwd: projectFolder} + , opts = {env: env, cwd: projectFolder, stdio: 'inherit'} + , isPrompt = /prompt/i.test(args[0]) , paths = process.env.NODE_PATH ? [process.env.NODE_PATH] : []; // Pass the --verbose call down to grunt as well @@ -136,17 +137,6 @@ exports.runTask = function runTask(projectFolder, command) { process.on('SIGTERM', exitHdlr); - if (!!program.verbose || process.mainModule.filename.match('build')) { - readline - .createInterface({ - input : posixProc.stdout, - terminal : false - }) - .on('line', function(line) { - console.log(' ' + line); - }); - } - posixProc.on('error', function(err) { error += err; }); @@ -169,6 +159,7 @@ exports.runTask = function runTask(projectFolder, command) { }); }); } +exports.runTask = runTask; /** * Runs DB migrations from grunt From 8a7b10d9e5784d74806a44db191470199c54c147 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Wed, 6 May 2015 00:10:48 +1000 Subject: [PATCH 07/16] release(1.2.7): Hotfix - Fixed issues with grunt utility --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a71cf1..9bfd26e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.6", + "version" : "1.2.7", "license" : "MIT", "author": { "name" : "CleverStack", From 133259f4ce297d0b8b117d9f0c61004adcd7acf5 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Wed, 27 Jan 2016 22:56:25 +1000 Subject: [PATCH 08/16] fix(init): Fixed issue with buffer filling up and pausing child_process until its emptied MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we always create a readline interface and clear out the pipe regardless of —verbose mode --- bin/clever-init | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/bin/clever-init b/bin/clever-init index 55a2642..05e1a0d 100755 --- a/bin/clever-init +++ b/bin/clever-init @@ -115,23 +115,20 @@ function installNPMPackages(projectDir) { var args = ['install'] , opts = { env: process.env, cwd: projectDir }; - if (!program.verbose) { - args.push('--silent'); - } - var proc = spawn(!isWin ? 'npm' : 'npm.cmd', args, opts) , error = ''; - - if (!!program.verbose) { - readline - .createInterface({ - input : proc.stdout, - terminal : false - }) - .on('line', function(line) { + + // Create a readline interface because otherwise the buffer will + readline + .createInterface({ + input : proc.stdout, + terminal : false + }) + .on('line', function(line) { + if (!!program.verbose) { console.log(' ' + line); - }); - } + } + }); proc.on('error', function(err) { error += err; @@ -176,7 +173,7 @@ function setupBackend() { } utils - .info('Downloading and extracting ' + csPackage.name + '...') + .info(' Downloading and extracting ' + csPackage.name + '...') .running('Downloading and extracting ' + csPackage.name + '...'); lib.packages From b2bdc3f643fc09491c86e7cf26e3ed2c2e9cada0 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Wed, 27 Jan 2016 22:57:57 +1000 Subject: [PATCH 09/16] release(1.2.8): Fixed init command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bfd26e..1ffdc50 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.7", + "version" : "1.2.8", "license" : "MIT", "author": { "name" : "CleverStack", From 5b15523123280fbec97211581fa4d7051f706b39 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Wed, 17 Feb 2016 15:27:10 +1000 Subject: [PATCH 10/16] fix(proxy): Support proxies fixes #81 --- bin/clever | 2 +- lib/packages.js | 32 +++++++++++++++++++------------- package.json | 3 ++- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/bin/clever b/bin/clever index 4d68528..bba4922 100755 --- a/bin/clever +++ b/bin/clever @@ -35,7 +35,7 @@ async.waterfall( }); // Only check for updates on a set interval - if (Date.now() - updateConfig.get('lastUpdateCheck') > checkUpdatesEvery) { + if (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY && Date.now() - updateConfig.get('lastUpdateCheck') > checkUpdatesEvery) { notifier = updateNotifier({ pkg: packageJson, callback: checkDone }); } else { checkDone(null); diff --git a/lib/packages.js b/lib/packages.js index 99bd9ff..5aa0f2a 100644 --- a/lib/packages.js +++ b/lib/packages.js @@ -1,15 +1,16 @@ -var Promise = require('bluebird') - , zlib = require('zlib') - , async = require('async') - , path = require('path') - , fs = require('fs') - , ncp = require('ncp') - , rimraf = require('rimraf') - , tar = require('tar') - , _url = require('url') - , https = require('follow-redirects').https - , project = GLOBAL.lib.project - , utils = GLOBAL.lib.utils; +var Promise = require('bluebird') + , zlib = require('zlib') + , async = require('async') + , path = require('path') + , fs = require('fs') + , ncp = require('ncp') + , rimraf = require('rimraf') + , tar = require('tar') + , _url = require('url') + , https = require('follow-redirects').https + , proxyAgent = require('https-proxy-agent') + , project = GLOBAL.lib.project + , utils = GLOBAL.lib.utils; /** * Downloads the package, unzips and untars into dir @@ -85,7 +86,12 @@ var get = exports.get = function(pkg, url, dir) { secureProtocol: require('constants').SSL_OP_NO_TLSv1_2 }; - options.agent = new https.Agent(options); + var proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || null; + if (proxy !== null) { + options.agent = new proxyAgent(proxy); + } else { + options.agent = new https.Agent(options); + } return download(options, dir); }; diff --git a/package.json b/package.json index 1ffdc50..4f1732f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.8", + "version" : "1.2.9", "license" : "MIT", "author": { "name" : "CleverStack", @@ -39,6 +39,7 @@ "event-stream" : "~3.3.0", "findit" : "~2.0.0", "follow-redirects" : "~0.0.3", + "https-proxy-agent" : "^1.0.0", "i" : "^0.3.2", "lodash" : "~3.4.0", "mkdirp" : "~0.5.0", From 42f5ade9ace12181f4e385ef1dad421cd7cceb7e Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Thu, 18 Feb 2016 10:16:38 +1000 Subject: [PATCH 11/16] fix(proxy): Support HTTP_PROXY and HTTPS_PROXY environment variables for install and search commands - fixes #81 --- lib/install.js | 25 ++++++++++++++++--------- package.json | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/install.js b/lib/install.js index a5529a6..330c8bf 100644 --- a/lib/install.js +++ b/lib/install.js @@ -1,12 +1,13 @@ -var Promise = require('bluebird') - , path = require('path') - , _ = require('lodash') - , https = require('follow-redirects').https - , async = require('async') - , utils = GLOBAL.lib.utils - , search = GLOBAL.lib.search - , packages = GLOBAL.lib.packages - , util = GLOBAL.lib.util; +var Promise = require('bluebird') + , path = require('path') + , _ = require('lodash') + , https = require('follow-redirects').https + , proxyAgent = require('https-proxy-agent') + , async = require('async') + , utils = GLOBAL.lib.utils + , search = GLOBAL.lib.search + , packages = GLOBAL.lib.packages + , util = GLOBAL.lib.util; /** * Launches the installation process @@ -173,6 +174,12 @@ exports.run = function(args) { * @public */ exports.getJSON = function(options) { + // Handle HTTP_PROXY and HTTPS_PROXY environment variables + var proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY || null; + if (proxy !== null) { + options.agent = new proxyAgent(proxy); + } + return new Promise(function(resolve) { var req = https.request(options, function(res) { res.setEncoding('utf-8'); diff --git a/package.json b/package.json index 4f1732f..cc61896 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "cleverstack-cli", "description" : "Command line interface for CleverStack", - "version" : "1.2.9", + "version" : "1.2.10", "license" : "MIT", "author": { "name" : "CleverStack", From e431d6d7aa0cbe7437fba72287afda74b928ea94 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 4 May 2016 16:04:12 +1000 Subject: [PATCH 12/16] fix(repl): Templated Event Handlers now work in the REPL --- lib/boot.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/boot.js b/lib/boot.js index ef1f2fc..5c09ee3 100644 --- a/lib/boot.js +++ b/lib/boot.js @@ -25,6 +25,10 @@ var env = utils.bootstrapEnv(); // Load all the modules try { + // Fire the routesInitialized event so that our templated event handlers are parsed + env.moduleLoader.on('modulesLoaded', function() { + env.moduleLoader.emit('routesInitialized'); + }); env.moduleLoader.loadModules(); } catch (_error) { if (_error.code === 'MODULE_NOT_FOUND') { From c9ff7fa4c85f1eaf31206df36fc6c7ef39516f74 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Thu, 5 May 2016 11:45:31 +1000 Subject: [PATCH 13/16] fix(tests): List and Search tests updated to work --- tests/list.test.js | 4 ++-- tests/search.test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/list.test.js b/tests/list.test.js index c2bb0cc..158077e 100644 --- a/tests/list.test.js +++ b/tests/list.test.js @@ -12,11 +12,11 @@ describe('List', function() { exec(path.join(binPath, 'clever-list'), { cwd: assetPath }, function (err, stdout, stderr) { expect(stderr).to.equal(''); expect(stdout).to.match(/clever-auth/); - expect(stdout).to.match(/git:\/\/github.com\/CleverStack\/clever-auth.git/); + expect(stdout).to.match(/github.com\/CleverStack\/clever-auth.git/); expect(stdout).to.match(/CleverStack Authentication Module/); expect(stdout).to.match(/clever-datatables/); - expect(stdout).to.match(/git:\/\/github.com\/CleverStack\/clever-datatables.git/); + expect(stdout).to.match(/github.com\/CleverStack\/clever-datatables.git/); expect(stdout).to.match(/This module provides a directive to create jQuery dataTables./); done(err); diff --git a/tests/search.test.js b/tests/search.test.js index da623c7..6939bd1 100644 --- a/tests/search.test.js +++ b/tests/search.test.js @@ -34,7 +34,7 @@ describe('Search', function() { expect(stdout).to.match(/Found 1 module/); expect(stdout).to.match(/clever\-datatables/); - expect(stdout).to.match(/git:\/\/github.com\/CleverStack\/clever\-datatables.git/); + expect(stdout).to.match(/github.com\/CleverStack\/clever\-datatables.git/); expect(stdout).to.match(/This module provides a directive to create jQuery dataTables./); done(err); @@ -50,7 +50,7 @@ describe('Search', function() { expect(stdout).to.match(/Found 2 modules/); expect(stdout).to.match(/clever\-datatables/); - expect(stdout).to.match(/git:\/\/github.com\/CleverStack\/clever\-datatables.git/); + expect(stdout).to.match(/github.com\/CleverStack\/clever\-datatables.git/); expect(stdout).to.match(/This module provides a directive to create jQuery dataTables./); expect(stdout).to.match(/clever\-orm/); From cade112353d4a65ff086a89381c51cb7a13b475d Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Thu, 5 May 2016 11:47:26 +1000 Subject: [PATCH 14/16] fix(target): Specify Supported Node & NPM versions in package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cc61896..ad3a58b 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "clever" : "./bin/clever" }, "engines": { - "node" : ">=0.10 <=0.12", - "npm" : ">=1.4 <=2.5" + "node" : ">=0.10 <=6.0", + "npm" : ">=1.4 <=3.8" }, "dependencies": { "async" : "~0.9.0", From 43fae427fd597cccefb26b3feeb92e90287271fe Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Thu, 5 May 2016 11:47:37 +1000 Subject: [PATCH 15/16] fix(travis): Target supported node versions --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8af7475..e0a64a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,8 @@ node_js: - '0.10' - '0.11' - '0.12' - - 'iojs' + - '5.0' + - '6.0' before_install: - 'npm install -g grunt-cli' From 7ba952799d100d2baabb7f0428b532f29c29d623 Mon Sep 17 00:00:00 2001 From: Richard Gustin Date: Thu, 5 May 2016 14:26:56 +1000 Subject: [PATCH 16/16] fix(travis): use travis_wait to fix timeout issue in tests --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index e0a64a3..96b815b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,9 @@ before_install: - 'npm install -g grunt-cli' - 'npm install -g bower' +script: + - "travis_wait make tests" + cache: directories: - node_modules