Comparing version 0.6.1-14 to 0.6.1-19
@@ -107,11 +107,11 @@ module.exports = df; | ||
// calculate widths | ||
var maxApp=4, maxDynoMan=8, maxPort=5, maxState=5, maxUrl = 3; | ||
var maxApp=4, maxUser = 5, maxInstance=8, maxPort=5, maxState=5, maxUrl = 3; | ||
for (var a in apps) { | ||
if(common.strlen(a) > maxApp) maxApp = common.strlen(a); | ||
var url = getAppUrl(a); | ||
if(common.strlen(url) > maxUrl) maxUrl = common.strlen(url); | ||
var app = apps[a]; | ||
var app = apps[a]; | ||
if(common.strlen(app.dynoman) > maxDynoMan) maxDynoMan = common.strlen(app.dynoman); | ||
if(common.strlen(app.title) > maxApp) maxApp = common.strlen(app.title); | ||
if(common.strlen(app.url) > maxUrl) maxUrl = common.strlen(app.url); | ||
if(common.strlen(app.email) > maxUser) maxUser = common.strlen(app.email); | ||
if(common.strlen(app.instance) > maxInstance) maxInstance = common.strlen(app.instance); | ||
if(common.strlen(app.port) > maxPort) maxPort = common.strlen(app.port); | ||
@@ -123,4 +123,4 @@ if(common.strlen(app.state) > maxState) maxState = common.strlen(app.state); | ||
df.table = new Table({ | ||
head: ['App', 'Url', 'DynoMan', 'Port', 'State'], | ||
colWidths: [maxApp+2 , maxUrl+2, maxDynoMan+2, maxPort+2, maxState+2], | ||
head: ['App', 'Url', 'Email', 'Instance', 'Port', 'State'], | ||
colWidths: [maxApp+2 , maxUrl+2, maxUser+2, maxInstance+2, maxPort+2, maxState+2], | ||
style: common.style() | ||
@@ -131,5 +131,4 @@ }); | ||
for (var a in apps) { | ||
var url = getAppUrl(a); | ||
var app = apps[a]; | ||
df.table.push([a, url, app.dynoman, app.port || '-', app.state]); | ||
df.table.push([app.title, app.url, app.email, app.instance, app.port || '-', app.state]); | ||
} | ||
@@ -180,3 +179,3 @@ } | ||
} catch (x) { | ||
return cb("Error parsing app: " + util.inspect(body) + " error: " + util.inspect(x)); | ||
return cb(x); | ||
} | ||
@@ -183,0 +182,0 @@ |
@@ -15,2 +15,3 @@ // target millicore | ||
var util = require('util'); | ||
var version = require('./version.js'); | ||
@@ -26,38 +27,51 @@ // Main target entry point | ||
// TODO - suboptimal this now that we have 'targets', ini file being saved twice.. REFACTOR | ||
var where = ini.get("global") ? "global" : "user"; | ||
ini.set('feedhenry', args[0], where); | ||
ini.save(function(err) { | ||
if (err) return cb(err); | ||
var tar = args[0]; | ||
if (args.length == 3) { | ||
return login([args[1], args[2]], cb); | ||
}else { | ||
// attempt to set existing target cookie.. | ||
var t = { | ||
target: args[0] | ||
}; | ||
if(args[1]) t['user'] = args[1]; | ||
// Check if target begins with http/https | ||
if (tar.indexOf('http://') != 0 && tar.indexOf('https://') != 0) { | ||
log.info("No http/https given, assuming https://"); | ||
tar = "https://" + tar; | ||
} | ||
// Valiate FeedHenry target can be pinged.. | ||
version([tar], function(err, data){ | ||
if(err) return cb(err); | ||
if(data.statusCode !== 200) return cb("Invalid target: " +tar); | ||
log.silly(t, "Getting Target"); | ||
var targ = targets.getTarget(t); | ||
log.silly(targ, "Got Target"); | ||
if (targ == undefined) { | ||
ini.del("cookie"); | ||
ini.save(function(err){ | ||
target.message = "Successfully targeted " + args[0]; | ||
return cb(err, args[0]); | ||
}); | ||
}else { | ||
// set username and cookie | ||
ini.set("username", targ.user, "user"); | ||
ini.set("cookie", targ.cookie, "user"); | ||
ini.save(function(err){ | ||
target.message = "Successfully targeted: " + targ.target + " User: " + targ.user; | ||
return cb(err, targ); | ||
}); | ||
// TODO - suboptimal this now that we have 'targets', ini file being saved twice.. REFACTOR | ||
var where = ini.get("global") ? "global" : "user"; | ||
ini.set('feedhenry', tar, where); | ||
ini.save(function(err) { | ||
if (err) return cb(err); | ||
if (args.length == 3) { | ||
return login([args[1], args[2]], cb); | ||
}else { | ||
// attempt to set existing target cookie.. | ||
var t = { | ||
target: tar | ||
}; | ||
if(args[1]) t['user'] = args[1]; | ||
log.silly(t, "Getting Target"); | ||
var targ = targets.getTarget(t); | ||
log.silly(targ, "Got Target"); | ||
if (targ == undefined) { | ||
ini.del("cookie"); | ||
ini.save(function(err){ | ||
target.message = "Successfully targeted " + tar; | ||
return cb(err, tar); | ||
}); | ||
}else { | ||
// set username and cookie | ||
ini.set("username", targ.user, "user"); | ||
ini.set("cookie", targ.cookie, "user"); | ||
ini.save(function(err){ | ||
target.message = "Successfully targeted: " + targ.target + " User: " + targ.user; | ||
return cb(err, targ); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -64,0 +78,0 @@ |
module.exports = version; | ||
version.usage = "fhc version"; | ||
var fhc = require("./fhc"), | ||
fhreq = require("./utils/request"); | ||
var util = require('util'); | ||
var fhc = require("./fhc"); | ||
var fhreq = require("./utils/request"); | ||
// Get FeedHenry platform version | ||
function version (args, cb) { | ||
fhreq.GET(fhreq.getFeedHenryUrl(), "box/srv/1.1/tst/version", function (err, remoteData, raw, response) { | ||
return cb(err, remoteData); | ||
function version (args, cb) { | ||
var url = fhreq.getFeedHenryUrl(); | ||
if (args.length === 1) url = args[0]; | ||
fhreq.GET(url, "box/srv/1.1/tst/version", function (err, remoteData, raw, response) { | ||
if (err) return cb(err); | ||
if (response.statusCode === 200) { | ||
remoteData.status = "ok"; | ||
remoteData.statusCode = 200; | ||
return cb(err, remoteData); | ||
} | ||
return cb(undefined, {status: 'error', error: remoteData, statusCode: response.statusCode}); | ||
}); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"keywords" : [ "cli", "feedhenry" ], | ||
"version": "0.6.1-14", | ||
"version": "0.6.1-19", | ||
"preferGlobal" : true, | ||
@@ -8,0 +8,0 @@ "homepage" : "http://git.io/fh-fhc", |
@@ -1,1 +0,1 @@ | ||
0.6.1-14 | ||
0.6.1-19 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
222543
5143