Comparing version 2.0.0-0 to 2.0.0-1
@@ -1,4 +0,58 @@ | ||
2015-11-19, Version 2.0.0-0 | ||
2016-04-30, Version 2.0.0-1 | ||
=========================== | ||
* output environment varialbes in predicatable order (Ryan Graham) | ||
* Allow loading multiple ENV files. (Joe Esposito) | ||
* add --raw option to suppress log decorations (Andrew Herrington) | ||
* Changed handler name to error instead of proxyError (Nazar Hussain) | ||
* improve error messages when loading a procfile (toastynerd) | ||
* fix exported systemd unit dependencies (Guten Ye) | ||
* test: refactor tests to use ephemeral ports (Ryan Graham) | ||
* clean up CLI argument handling (Ryan Graham) | ||
* deps: upgrade commander (Ryan Graham) | ||
* fix padding of keys (Jeff Dickey) | ||
* fix 'nf' command name (Jeff Dickey) | ||
* disable trimming by default (Jeff Dickey) | ||
* reorderd colors (Jeff Dickey) | ||
* disable black/white colors (Jeff Dickey) | ||
* display exit code (Jeff Dickey) | ||
* test: use OS-specific env expansion (Ryan Graham) | ||
* test: improve assertion message (Ryan Graham) | ||
* disable node 6.x in Travis and Appveyor (Ryan Graham) | ||
* update Travis config and add Appveyor (Ryan Graham) | ||
* Remove note about dropping privileges (#108) (Ari Pollak) | ||
* fix jshint issues (Jeff Dickey) | ||
* jshint all local js files (Jeff Dickey) | ||
* added jshintignore (Jeff Dickey) | ||
* Add '' argument to sed -i to fix mac os tests (Ransom Briggs) | ||
* Small typo fix in README (Simon Taranto) | ||
2015-11-18, Version 2.0.0-0 | ||
=========================== | ||
* Dont' drop sudo (Vasiliy Yorkin) | ||
@@ -5,0 +59,0 @@ |
var reset = '\x1B[0m'; | ||
var colors = { | ||
black: '\x1B[30m', | ||
red: '\x1B[31m', | ||
magenta: '\x1B[35m', | ||
blue: '\x1B[34m', | ||
cyan: '\x1B[36m', | ||
green: '\x1B[32m', | ||
yellow: '\x1B[33m', | ||
blue: '\x1B[34m', | ||
magenta: '\x1B[35m', | ||
cyan: '\x1B[36m', | ||
white: '\x1B[37m', | ||
bright_black: '\x1B[30m', | ||
bright_red: '\x1B[31m', | ||
red: '\x1B[31m', | ||
bright_magenta: '\x1B[35m', | ||
bright_cyan: '\x1B[36m', | ||
bright_blue: '\x1B[34m', | ||
bright_green: '\x1B[32m', | ||
bright_yellow: '\x1B[33m', | ||
bright_blue: '\x1B[34m', | ||
bright_magenta: '\x1B[35m', | ||
bright_cyan: '\x1B[36m', | ||
bright_white: '\x1B[37m', | ||
bright_red: '\x1B[31m', | ||
}; | ||
@@ -20,0 +16,0 @@ |
@@ -63,5 +63,5 @@ var util = require('util'); | ||
this.Info = function info(key, proc, string) { | ||
this.error = function error(key, proc, string) { | ||
var stamp = (new Date().toLocaleTimeString()) + " " + key; | ||
logger.log(proc.color(this.pad(stamp,this.padding)), colors.bright_cyan(string)); | ||
logger.error(proc.color(this.pad(stamp,this.padding)), colors.red(string)); | ||
}; | ||
@@ -71,2 +71,8 @@ | ||
var self = this; | ||
if(self.raw) { | ||
logger.log(string); | ||
return; | ||
} | ||
string.split(/\n/).forEach(function(line) { | ||
@@ -73,0 +79,0 @@ |
var fs = require('fs'); | ||
var util = require('util'); | ||
var cons = require('./console').Console; | ||
@@ -115,3 +116,3 @@ | ||
} | ||
return output.join('\n') + '\n'; | ||
return output.sort().join('\n') + '\n'; | ||
} | ||
@@ -121,3 +122,3 @@ | ||
// simplified dictionary | ||
function loadEnvs(path) { | ||
function loadEnvsFile(path) { | ||
var env, data; | ||
@@ -143,2 +144,11 @@ | ||
function loadEnvs(path) { | ||
var envs = path.split(',').map(loadEnvsFile).reduce(util._extend, {}); | ||
var sorted = Object.create(null); | ||
Object.keys(envs).sort().forEach(function(k) { | ||
sorted[k] = envs[k]; | ||
}); | ||
return sorted; | ||
} | ||
module.exports.loadEnvs = loadEnvs; | ||
@@ -145,0 +155,0 @@ module.exports.flattenJSON = flattenJSON; |
@@ -38,5 +38,5 @@ var prog = require('child_process'); | ||
if(code === 0) { | ||
cons.info(key,proc,"Exited Successfully"); | ||
cons.info(key, proc, "Exited Successfully"); | ||
} else { | ||
cons.Info(key,proc,"Exited Abnormally"); | ||
cons.error(key, proc, "Exited with exit code " + code); | ||
} | ||
@@ -43,0 +43,0 @@ }); |
var fs = require('fs'); | ||
var cons = require('./console').Console; | ||
var path = require('path'); | ||
@@ -18,7 +19,7 @@ // Parse Procfile | ||
if(!prockey) { | ||
return cons.Warn('Syntax Error in Procfile, Line %d: No Prockey Found'); | ||
throw new Error('Syntax Error in Procfile, Line %d: No Prockey Found'); | ||
} | ||
if(!command) { | ||
return cons.Warn('Syntax Error in Procfile, Line %d: No Command Found'); | ||
throw new Error('Syntax Error in Procfile, Line %d: No Command Found'); | ||
} | ||
@@ -33,9 +34,9 @@ | ||
// Look for a Procfile at the Specified Location | ||
function loadProc(path) { | ||
function loadProc(filename) { | ||
try { | ||
var data = fs.readFileSync(path); | ||
var data = fs.readFileSync(filename); | ||
return procs(data); | ||
} catch(e) { | ||
cons.Warn('No Procfile Found'); | ||
cons.Warn(e.message); | ||
if(fs.existsSync('package.json')) { | ||
@@ -45,3 +46,3 @@ cons.Alert("package.json file found - trying 'npm start'"); | ||
} else { | ||
cons.Error("No Procfile found in Current Directory - See nf --help"); | ||
cons.Error("No Procfile and no package.json file found in Current Directory - See " + path.basename(process.argv[1]) + " --help"); | ||
return; | ||
@@ -48,0 +49,0 @@ } |
@@ -12,7 +12,7 @@ var fs = require('fs'); | ||
if(port < 1024 && process.getuid() !== 0) { | ||
if(port > 0 && port < 1024 && process.getuid() !== 0) { | ||
return cons.Error('Cannot Bind to Privileged Port %s Without Permission - Try \'sudo\'',port); | ||
} | ||
if(!port) { | ||
if(isNaN(port)) { | ||
return cons.Warn('No Downstream Port Defined for \'%s\' Proxy', key); | ||
@@ -28,3 +28,3 @@ } | ||
var proxy = prog.fork(__dirname + '/../proxy.js', [], { | ||
var proxy = prog.fork(require.resolve('../proxy'), [], { | ||
env: { | ||
@@ -38,3 +38,3 @@ HOST: localhost, | ||
SSL_KEY: ssl.key, | ||
SSL_PORT: ssl_port | ||
SSL_PORT: port ? ssl_port : 0 | ||
} | ||
@@ -56,2 +56,11 @@ }); | ||
proxy.on('message', function(msg) { | ||
if ('http' in msg) { | ||
emitter.emit('http', msg.http); | ||
} | ||
if ('https' in msg) { | ||
emitter.emit('https', msg.https); | ||
} | ||
}); | ||
emitter.once('killall', function(signal) { | ||
@@ -70,3 +79,3 @@ cons.Done('Killing Proxy Server on Port %s', port); | ||
if(command.proxy){ | ||
if ('proxy' in command) { | ||
@@ -73,0 +82,0 @@ var localhost = 'localhost'; |
@@ -42,3 +42,3 @@ function parseRequirements(req) { | ||
} | ||
return padding + 10; | ||
return padding + 12; | ||
} | ||
@@ -45,0 +45,0 @@ |
36
nf.js
@@ -16,6 +16,5 @@ #!/usr/bin/env node | ||
program.option('-j, --procfile <FILE>' ,'load procfile FILE','Procfile'); | ||
program.option('-e, --env <FILE>' ,'use FILE to load environment','.env'); | ||
program.option('-e, --env <FILE>' ,'load environment from FILE, a comma-separated list','.env'); | ||
program.option('-p, --port <PORT>' ,'start indexing ports at number PORT',0); | ||
var command; | ||
@@ -54,3 +53,3 @@ // Foreman Event Bus/Emitter // | ||
program | ||
.command('start') | ||
.command('start [procs]') | ||
.usage('[Options] [Processes] e.g. web=1,log=2,api') | ||
@@ -63,8 +62,9 @@ .option('-s, --showenvs' ,'show ENV variables on start',false) | ||
.option('-i, --intercept <HOSTNAME>' ,'set forward proxy to intercept HOSTNAME',null) | ||
.option('-r, --raw' ,'raw log output with no app name, timestamp, wrap or trim', false) | ||
.option('-t, --trim <N>' ,'trim logs to N characters',0) | ||
.option('-w, --wrap' ,'wrap logs (negates trim)') | ||
.description('Start the jobs in the Procfile') | ||
.action(function(command_left, command_right) { | ||
.action(function(args) { | ||
command = command_right || command_left; | ||
var command = this; | ||
@@ -83,6 +83,8 @@ var envs = loadEnvs(program.env); | ||
var reqs = getreqs(program.args[0],proc); | ||
var reqs = getreqs(args, proc); | ||
display.padding = calculatePadding(reqs); | ||
display.raw = command.raw; | ||
if(command.wrap) { | ||
@@ -93,3 +95,3 @@ display.wrapline = process.stdout.columns - display.padding - 7; | ||
} else { | ||
display.trimline = command.trim || process.stdout.columns - display.padding - 5; | ||
display.trimline = command.trim; | ||
if(display.trimline > 0){ | ||
@@ -110,13 +112,11 @@ display.Alert('Trimming display Output to %d Columns', display.trimline); | ||
program | ||
.command('run') | ||
.command('run <COMMAND...>') | ||
.usage('[Options]') | ||
.option('-s, --showenvs', 'show ENV variables on start', false) | ||
.description('Run a one off process using the ENV variables') | ||
.action(function(command_left, command_right) { | ||
.action(function(args) { | ||
command = command_right || command_left; | ||
var command = this; | ||
var envs = loadEnvs(program.env); | ||
var args = Array.prototype.slice.apply(this.args); | ||
args.pop(); | ||
@@ -127,3 +127,3 @@ var callback = function(code) { | ||
if(!command) { return; } | ||
if(!args || !args.length) { return; } | ||
@@ -146,3 +146,3 @@ var input = quote(args); | ||
program | ||
.command('export') | ||
.command('export [PROCS]') | ||
.option('-a, --app <NAME>' ,'export upstart application as NAME','foreman') | ||
@@ -157,5 +157,5 @@ .option('-u, --user <NAME>' ,'export upstart user as NAME','root') | ||
.description('Export to an upstart job independent of foreman') | ||
.action(function(command_left, command_right) { | ||
.action(function(procArgs) { | ||
command = command_right || command_left; | ||
var command = this; | ||
@@ -168,3 +168,3 @@ var envs = loadEnvs(program.env); | ||
var req = getreqs(program.args[0],procs); | ||
var req = getreqs(procArgs, procs); | ||
@@ -290,3 +290,3 @@ // Variables for Upstart Template | ||
if(program.args.length === 0) { | ||
if (!process.argv.slice(2).length) { | ||
console.log(colors.cyan(' _____ ')); | ||
@@ -293,0 +293,0 @@ console.log(colors.cyan(' | __|___ ___ ___ _____ ___ ___ ')); |
{ | ||
"name": "foreman", | ||
"version": "2.0.0-0", | ||
"version": "2.0.0-1", | ||
"homepage": "http://strongloop.github.io/node-foreman/", | ||
@@ -25,7 +25,7 @@ "description": "Node Implementation of Foreman", | ||
"scripts": { | ||
"pretest": "jshint *.js lib/*.js", | ||
"pretest": "jshint .", | ||
"test": "tap test/*.test.*" | ||
}, | ||
"dependencies": { | ||
"commander": "~2.1.0", | ||
"commander": "~2.9.0", | ||
"http-proxy": "~1.11.1", | ||
@@ -32,0 +32,0 @@ "mu2": "~0.5.20", |
10
proxy.js
@@ -33,3 +33,3 @@ var fs = require('fs'); | ||
// Hanle Error | ||
proxy.on('proxyError',function(err,req,res){ | ||
proxy.on('error',function(err,req,res){ | ||
console.error("Proxy Error: ",err); | ||
@@ -50,3 +50,5 @@ res.writeHead(500); | ||
}).listen(port); | ||
}).listen(port, function() { | ||
process.send({http: this.address().port}); | ||
}); | ||
@@ -66,3 +68,5 @@ if (sslCert && sslKey) { | ||
}).listen(sslPort); | ||
}).listen(sslPort, function() { | ||
process.send({https: this.address().port}); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1013
48363
26
1
0
+ Addedcommander@2.9.0(transitive)
+ Addedgraceful-readlink@1.0.1(transitive)
- Removedcommander@2.1.0(transitive)
Updatedcommander@~2.9.0