Comparing version 0.0.1 to 0.0.2
89
index.js
@@ -6,5 +6,6 @@ #!/usr/bin/env node | ||
, Uri = require('jsuri') | ||
, urlcodeJson = require('urlcode-json') | ||
, colors = require("colors") | ||
, moment = require("moment"); | ||
, moment = require("moment") | ||
, path = require('path') | ||
, commander = require('commander'); | ||
@@ -24,2 +25,29 @@ colors.setTheme({ | ||
commander.helpInformation = function() { | ||
return [ | ||
'', | ||
' remoty', | ||
'', | ||
' Usage: ' + this._name + ' ' + this.usage(), | ||
'' + this.commandHelp(), | ||
' Options:', | ||
'', | ||
'' + this.optionHelp().replace(/^/gm, ' '), | ||
'', | ||
'' | ||
].join('\n'); | ||
}; | ||
commander | ||
.version('0.0.1') | ||
.option('-p, --port <value>', 'set the service port') | ||
.option('-h, --help', 'help'); | ||
commander.on('--port',function(){ | ||
console.log(arguments); | ||
}); | ||
commander.parse(process.argv); | ||
var app = connect() | ||
@@ -30,30 +58,41 @@ //.use(connect.favicon('public/favicon.ico')) | ||
if(uri.path() === '/k.gif'){ | ||
var data = uri.getQueryParamValue('data'); | ||
data = decodeURIComponent(data); | ||
try{ | ||
data = JSON.parse(data); | ||
}catch(e){ | ||
data = {}; | ||
var data = uri.getQueryParamValue('data'), | ||
type = uri.getQueryParamValue('type'); | ||
if(type === 'error'){ | ||
data = decodeURIComponent(data); | ||
try{ | ||
data = JSON.parse(data); | ||
}catch(e){ | ||
data = {}; | ||
} | ||
if(data.type === 'error'){ | ||
console.log('[error] '.error + moment(req['_startTime']).format('YYYY-MM-DD HH:mm:ss') + ' - ' + data.message.warn); | ||
console.log(('行:' + data.lineno + ', 列:' + data.colno).verbose); | ||
console.log(req.headers['user-agent'].input); | ||
console.log(data.filename.input); | ||
} | ||
} | ||
if(data.type === 'error'){ | ||
console.log('[error] '.error + moment(req['_startTime']).format('YYYY-MM-DD HH:mm:ss') + ' - ' + data.message.warn); | ||
console.log(('行:' + data.lineno + ', 列:' + data.colno).verbose); | ||
console.log(req.headers['user-agent'].input); | ||
console.log(data.filename.input); | ||
if(type === 'log'){ | ||
data = decodeURIComponent(data); | ||
data = data.split(','); | ||
var args = []; | ||
data.forEach(function(d,i){ | ||
try{ | ||
args.push(d.toString().warn); | ||
}catch(e){ | ||
//args.push(d.toString()); | ||
} | ||
}); | ||
console.log('[log] '.warn + moment(req['_startTime']).format('YYYY-MM-DD HH:mm:ss')); | ||
console.log(args.toString().verbose); | ||
//console.log(data); | ||
//console.log(req.headers['user-agent']); | ||
//console.log(req['_startTime']); | ||
} | ||
//console.log(req); | ||
} | ||
//return 'some format string'; | ||
})) | ||
.use(connect.static('htdocs')) | ||
.use(connect.directory('htdocs')) | ||
.use(connect.static(path.resolve(path.dirname(module.filename),'./htdocs/'))) | ||
.use(connect.directory(path.resolve(path.dirname(module.filename),'./htdocs/'))) | ||
//.use(connect.cookieParser()) | ||
@@ -65,2 +104,6 @@ //.use(connect.session({ secret: 'my secret here' })) | ||
http.createServer(app).listen(3000); | ||
//console.log(commander.port); | ||
http.createServer(app).listen(commander.port || 3000,function(){ | ||
console.log('remoty server is listening on port:' + (commander.port || 3000), 'good luck!'.silly); | ||
}); |
{ | ||
"name": "remoty", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "remote console", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git@gitlab.alibaba-inc.com:alipay-ct-wd/remoty.git" | ||
"url": "git@github.com:alexyan/remoty.git" | ||
}, | ||
@@ -21,5 +21,5 @@ "dependencies": { | ||
"connect":"~2.17.1", | ||
"urlcode-json":"~0.0.5", | ||
"colors":"~0.6.2", | ||
"moment":"~2.6.0" | ||
"moment":"~2.6.0", | ||
"commander":"~2.2.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "author": "alexyan", |
Sorry, the diff of this file is too big to display
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
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
176420
8
5013
+ Addedcommander@~2.2.0
+ Addedcommander@2.2.0(transitive)
- Removedurlcode-json@~0.0.5
- Removedurlcode-json@0.0.5(transitive)