Comparing version 0.7.26-187 to 0.7.27-189
@@ -183,3 +183,3 @@ // Misc common functions.. | ||
var not = notifications[p].fields; | ||
table.push([ notifications[p].guid, moment(not.sysCreated, 'YYYY-MM-DD h:mm:ss:SSS').fromNow(), not.updatedBy, not.eventType, not.message]); | ||
table.push([ notifications[p].guid, moment(not.sysCreated, 'YYYY-MM-DD h:mm:ss:SSS').fromNow(), not.updatedBy, not.eventType, not.message.replace(/[\r?\n]/g, " ")]); | ||
} | ||
@@ -186,0 +186,0 @@ return table; |
module.exports = notifications; | ||
notifications.usage = "fhc notifications [list] <app-guid>" | ||
+ "\nfhc notifications auditlog <app-guid>" | ||
+ "\nfhc notifications dismiss <app-guid> <notification-guid> [<notification-guid>]"; | ||
notifications.usage = "fhc notifications [list] <app-guid> [--live] " | ||
+ "\nfhc notifications auditlog <app-guid> [--live] " | ||
+ "\nfhc notifications dismiss <app-guid> <notification-guid> [<notification-guid>] [--live]"; | ||
@@ -14,2 +14,3 @@ var fhc = require("./fhc"); | ||
if (args.length === 0) return cb(notifications.usage); | ||
if (args.length === 1){ | ||
@@ -24,3 +25,3 @@ return doList(fhc.appId(args[0]), cb); | ||
} else if(act === "dismiss"){ | ||
return doDismiss(fhc.appId(args[1]), args.slice(1), cb); | ||
return doDismiss(fhc.appId(args[1]), args.slice(2), cb); | ||
} else { | ||
@@ -44,4 +45,5 @@ return cb(notifications.usage); | ||
} | ||
var env = ini.get('live') ? 'live' : 'dev'; | ||
var uri = "box/srv/1.1/app/eventlog/listEvents"; | ||
var payload = {appGuid: appId, eventGroup:"NOTIFICATION"}; | ||
var payload = {appGuid: appId, eventGroup:"NOTIFICATION", env: env}; | ||
if(audit){ | ||
@@ -48,0 +50,0 @@ payload.audit = true; |
@@ -5,5 +5,7 @@ | ||
stage.usage = "\nfhc stage <appId> " | ||
+ "\nfhc stage <appId> --live " | ||
+"\nfhc stage <appId> [number_of_instances] --live" | ||
+ "\nStage is made to Live environment if the '--live' flag is used"; | ||
+ "\nfhc stage <appId> [approver] [comment] --live " | ||
+"\nfhc stage <appId> [number_of_instances] [approver] [comment] --live" | ||
+ "\nStage is made to Live environment if the '--live' flag is used" | ||
+ "\nApprover is required if stage to Live environment. If it's not provided from the command line, user will be prompted for it." | ||
+ "\nComment is optional and should only be provided if Approver is set." | ||
@@ -18,6 +20,7 @@ var log = require("./utils/log"); | ||
var update = require('./update.js'); | ||
var prompt = require('./utils/prompt'); | ||
// main stage entry point | ||
function stage (args, cb) { | ||
if(args.length > 4 || args.length == 0) return unknown("stage", cb); | ||
if(args.length > 6 || args.length == 0) return unknown("stage", cb); | ||
@@ -27,2 +30,4 @@ var clean = ini.get('clean'); | ||
var numappinstances; | ||
var approver; | ||
var comment; | ||
@@ -33,5 +38,14 @@ // horrible hack for passing flags as args if used from api, e.g. 'live' instead of '--live' | ||
numappinstances = Number(arg); | ||
}else { | ||
if(arg === 'live' || arg === 'development') target = arg; | ||
if(arg === 'clean') clean = true; | ||
} else if(arg === 'live' || arg === 'development'){ | ||
target = arg; | ||
} else if(arg === 'clean'){ | ||
clean = true; | ||
} else { | ||
//then arg should be either approver or comment, | ||
//but does rely on comment is after approver in command line | ||
if(approver){ | ||
comment = arg; | ||
} else { | ||
approver = arg; | ||
} | ||
} | ||
@@ -42,4 +56,6 @@ } | ||
if(args[3]) processArg(args[3]); | ||
if(args[4]) processArg(args[4]); | ||
if(args[5]) processArg(args[5]); | ||
doStage(fhc.appId(args[0]), target, clean, numappinstances, cb); | ||
doStage(fhc.appId(args[0]), target, clean, numappinstances, approver, comment, cb); | ||
}; | ||
@@ -52,3 +68,3 @@ | ||
// do our staging.. | ||
function doStage(app, target, clean, numappinstances, cb) { | ||
function doStage(app, target, clean, numappinstances, approver, comment, cb) { | ||
var type = 'stage'; | ||
@@ -61,2 +77,32 @@ | ||
startStage(app, type, clean, numappinstances, approver, comment, function(err, results){ | ||
if(err){ | ||
if(err.indexOf("approver") > -1){ | ||
//the approver field is required, ask for it | ||
prompt("Please enter approver:", "", false, function(err, val){ | ||
if(err) return cb(err); | ||
if(val && val.length > 0){ | ||
approver = val; | ||
prompt("Please enter comment:", "", false, function(err, cval){ | ||
if(err) return cb(err); | ||
cval = cval.replace(/[\r?\n]/g, ""); | ||
if(cval.length > 0){ | ||
comment = cval; | ||
} | ||
startStage(app, type, clean, numappinstances, approver, comment, cb); | ||
}); | ||
} else { | ||
return cb("Approver name/email is required to stage to live environment."); | ||
} | ||
}); | ||
} else { | ||
return cb(err); | ||
} | ||
} else { | ||
cb(); | ||
} | ||
}); | ||
}; | ||
function startStage(app, type, clean, numappinstances, approver, comment, cb){ | ||
// constuct uri and payload | ||
@@ -68,2 +114,10 @@ var uri = "box/srv/1.1/ide/" + fhc.target + "/app/" + type; | ||
} | ||
if(type === "releasestage"){ | ||
if(approver){ | ||
payload.payload.approver = approver; | ||
} | ||
if(comment){ | ||
payload.payload.comment = comment; | ||
} | ||
} | ||
log.silly(payload, "Stage payload"); | ||
@@ -93,7 +147,7 @@ | ||
}); | ||
}; | ||
} | ||
// bash completion | ||
// bash completion | ||
stage.completion = function (opts, cb) { | ||
common.getAppIds(cb); | ||
common.getAppIds(cb); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"keywords" : [ "cli", "feedhenry" ], | ||
"version": "0.7.26-187", | ||
"version": "0.7.27-189", | ||
"preferGlobal" : true, | ||
@@ -8,0 +8,0 @@ "homepage" : "http://git.io/fh-fhc", |
@@ -1,1 +0,1 @@ | ||
0.7.26-187 | ||
0.7.27-189 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
378172
9718