From 676af2f5a2ed6efb3e55b9750227bb9df04b38a4 Mon Sep 17 00:00:00 2001 From: suwatch Date: Tue, 22 May 2012 18:10:43 -0700 Subject: [PATCH 1/2] deployment support --- lib/cli/cacheUtils.js | 43 ++- lib/cli/channel.js | 49 ++- lib/cli/commands/deployment.js | 562 +++++++++++++++++++++++++++ lib/cli/commands/deployment_.js | 351 +++++++++++++++++ lib/cli/commands/log.js | 113 ++++++ lib/cli/commands/log_.js | 84 ++++ lib/cli/commands/site.js | 653 ++++++++++++++++---------------- lib/cli/commands/site_.js | 268 ++++++------- projects/VS/Azure.csproj | 12 + 9 files changed, 1675 insertions(+), 460 deletions(-) create mode 100644 lib/cli/commands/deployment.js create mode 100644 lib/cli/commands/deployment_.js create mode 100644 lib/cli/commands/log.js create mode 100644 lib/cli/commands/log_.js diff --git a/lib/cli/cacheUtils.js b/lib/cli/cacheUtils.js index 0c6c518b6..719836ebd 100644 --- a/lib/cli/cacheUtils.js +++ b/lib/cli/cacheUtils.js @@ -27,6 +27,10 @@ function getSitesFile(context) { return path.join(utils.azureDir(), "sites." + context.subscription + ".json"); } +function getCommitIdsFile(context) { + return path.join(utils.azureDir(), "commitids." + context.subscription + ".json"); +} + function readSpaces(context, cb) { var cacheFile = getSpacesFile(context); return path.exists(cacheFile, function (exists) { @@ -117,12 +121,47 @@ function saveSites(context, sites, cb) { }); } +function saveCommitIds(context, deployments, cb) { + var cacheFile = getCommitIdsFile(context); + var commitIds = deployments.map(function (deployment) { + return { + shortId: deployment.shortId, + id: deployment.id + }; + }); + return fs.writeFile(cacheFile, JSON.stringify(commitIds), function (err) { + cb && cb(err, deployments); + }); +} + +function readCommitId(context, cb) { + var cacheFile = getCommitIdsFile(context); + return path.exists(cacheFile, function (exists) { + if (exists) { + return fs.readFile(cacheFile, function (err, data) { + var commitIds = JSON.parse(data); + if (commitIds && commitIds.length) { + for (var i = 0; i < commitIds.length; i++) { + if (utils.ignoreCaseEquals(context.shortId, commitIds[i].shortId)) { + return cb && cb(null, commitIds[i].id); + } + } + } + return cb && cb(null, null); + }); + } + return cb && cb(null, null); + }); +} + function clear() { var isDeleted = false; if (path.existsSync(utils.azureDir())) { var cacheFiles = fs.readdirSync(utils.azureDir()); for (var i = 0; i < cacheFiles.length; ++i) { - if (/sites[.].+[.]json/.test(cacheFiles[i]) || /spaces[.].+[.]json/.test(cacheFiles[i])) { + if (/sites[.].+[.]json/.test(cacheFiles[i]) + || /spaces[.].+[.]json/.test(cacheFiles[i]) + || /deployments[.].+[.]json/.test(cacheFiles[i])) { fs.unlinkSync(path.join(utils.azureDir(), cacheFiles[i])); isDeleted = true; } @@ -137,6 +176,8 @@ CacheUtils.readSite = readSite; CacheUtils.saveSite = saveSite; CacheUtils.deleteSite = deleteSite; CacheUtils.saveSites = saveSites; +CacheUtils.saveCommitIds = saveCommitIds; +CacheUtils.readCommitId = readCommitId; CacheUtils.clear = clear; module.exports = CacheUtils; \ No newline at end of file diff --git a/lib/cli/channel.js b/lib/cli/channel.js index 4b8727d5e..e3c738e9c 100644 --- a/lib/cli/channel.js +++ b/lib/cli/channel.js @@ -88,26 +88,43 @@ Channel.prototype.send = function (method, data, cb) { log.silly('Request.Method', options.method); log.silly('Request.Path', options.path); var req = https.request(options, function (res) { - var done = 0; - var parser = new xml2js.Parser(); + var data = [], + dataLen = 0, + contentType; log.silly('Response.Headers', res.headers); - res.on('data', function (data) { - log.silly('Response.Data', data.toString()); - try { - parser.parseString(data); - } - catch (err) { - cb(err); - } + res.on('data', function (chunk) { + data.push(chunk); + dataLen += chunk.length; + contentType = contentType || res.headers['content-type']; }); res.on('end', function () { - if (++done == 1) cb(null, {}); - }); - parser.on('end', function (result) { - if (result.Message && result.Code) { - if (++done == 1) cb(result, null); + if (!dataLen) { + return cb && cb(null, null); + } + var buf = new Buffer(dataLen); + for (var i = 0, len = data.length, pos = 0; i < len; i++) { + data[i].copy(buf, pos); + pos += data[i].length; + } + if (contentType && contentType.indexOf('application/json') != -1) { + return cb && cb(null, JSON.parse(buf.toString())); + } else if (contentType && contentType.indexOf('application/zip') != -1) { + return cb && cb(null, buf); } else { - if (++done == 1) cb(null, result); + var parser = new xml2js.Parser(); + parser.on('end', function (result) { + if (result.Message && result.Code) { + return cb && cb(result, null); + } else { + return cb && cb(null, result); + } + }); + try { + parser.parseString(buf); + } + catch (err) { + return cb && cb(err); + } } }); }); diff --git a/lib/cli/commands/deployment.js b/lib/cli/commands/deployment.js new file mode 100644 index 000000000..33c933cd5 --- /dev/null +++ b/lib/cli/commands/deployment.js @@ -0,0 +1,562 @@ +/*** Generated by streamline 0.2.5 - DO NOT EDIT ***/ +var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g; +/* 1 */ var common = require("../common"); +/* 20 */ var fs = require("fs"); +/* 21 */ var path = require("path"); +/* 22 */ var url = require("url"); +/* 23 */ var crypto = require("crypto"); +/* 24 */ var pfx2pem = require("../../util/certificates/pkcs").pfx2pem; +/* 25 */ var Channel = require("../channel"); +/* 26 */ var async = require("async"); +/* 27 */ var child_process = require("child_process"); +/* 28 */ var utils = require("../utils"); +/* 29 */ var constants = require("../constants"); +/* 30 */ var cacheUtils = require("../cacheUtils"); +/* 32 */ exports.init = function(cli) { +/* 34 */ var log = cli.output; +/* 35 */ var site = cli.category("site"); +/* 36 */ var scm = site.category("deployment").description("Commands to manage your git deployments"); +/* 39 */ function getScmChannel(context) { +/* 40 */ var parts = url.parse(context.repositoryUri); +/* 41 */ var channel = new Channel({ +/* 42 */ host: parts.hostname, +/* 43 */ port: (((parts.port && parseInt(parts.port, 10))) || ((/https/i.test(parts.protocol) ? 443 : 80))), +/* 44 */ auth: context.repositoryAuth + }); +/* 47 */ var proxyString = (((process.env.HTTPS_PROXY || process.env.https_proxy) || process.env.ALL_PROXY) || process.env.all_proxy); +/* 53 */ if ((proxyString !== undefined)) { +/* 54 */ var proxyUrl = url.parse(proxyString); +/* 55 */ if (((proxyUrl.protocol !== "http:") && (proxyUrl.protocol !== "https:"))) { +/* 58 */ proxyUrl = url.parse(("http://" + proxyString)); + } + ; +/* 61 */ channel = channel.add({ +/* 61 */ proxy: proxyUrl + }); + } + ; +/* 64 */ return channel; + }; +/* 66 */ scm.getScmChannel = getScmChannel; +/* 68 */ scm.command("list [name]").whiteListPowershell().description("List your git deployments").option("-s, --subscription ", "use the subscription id").option("-m, --max ", "limit the maximum number of results").execute(function __1(name, options, _) { + var context, repositoryUri; + var __frame = { + name: "__1", + line: 73 + }; + return __func(_, this, arguments, __1, 2, __frame, function __$__1() { +/* 74 */ context = { +/* 75 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 76 */ maxItems: options.max, +/* 77 */ site: { +/* 78 */ name: name + } + }; +/* 82 */ return ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) { + repositoryUri = __1; + return (function __$__1(__then) { +/* 83 */ if (repositoryUri) { +/* 84 */ return listDeployments(context, __cb(_, __frame, 11, 8, __then, true)); + } + else { +/* 86 */ log.error("Repository is not setup"); + __then(); + } + ; + })(_); + }, true)); + }); + }); +/* 90 */ scm.command("show [name]").whiteListPowershell().description("Show your git deployment").option("-s, --subscription ", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { + var context, repositoryUri, deployment; + var __frame = { + name: "__2", + line: 95 + }; + return __func(_, this, arguments, __2, 3, __frame, function __$__2() { +/* 96 */ context = { +/* 97 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 98 */ shortId: commitId, +/* 99 */ site: { +/* 100 */ name: name + } + }; +/* 104 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { +/* 104 */ var __1 = !(context.id = __2); + return (function __$__2(__then) { + if (__1) { +/* 105 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); + } + else { + __then(); + } + ; + })(function __$__2() { +/* 108 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { + repositoryUri = __3; + return (function __$__2(__then) { +/* 109 */ if (repositoryUri) { +/* 110 */ return scm.doDeploymentGet(context, __cb(_, __frame, 15, 25, function ___(__0, __4) { + deployment = __4; +/* 111 */ site.logEachData("info", deployment); + return (function __$__2(__then) { +/* 112 */ if (options.details) { +/* 113 */ return showLogDetails(context, __cb(_, __frame, 18, 10, __then, true)); + } + else { +/* 115 */ log.info("To see more details, specify -d or --details option"); + __then(); + } + ; + })(__then); + }, true)); + } + else { +/* 118 */ log.error("Repository is not setup"); + __then(); + } + ; + })(_); + }, true)); + }); + }, true)); + }); + }); +/* 122 */ scm.command("redeploy [name]").whiteListPowershell().description("Show your git deployment").option("-s, --subscription ", "use the subscription id").execute(function __3(commitId, name, options, _) { + var context, repositoryUri; + var __frame = { + name: "__3", + line: 126 + }; + return __func(_, this, arguments, __3, 3, __frame, function __$__3() { +/* 127 */ context = { +/* 128 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 129 */ shortId: commitId, +/* 130 */ site: { +/* 131 */ name: name + } + }; +/* 135 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { +/* 135 */ var __1 = !(context.id = __2); + return (function __$__3(__then) { + if (__1) { +/* 136 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); + } + else { + __then(); + } + ; + })(function __$__3() { +/* 139 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { + repositoryUri = __3; + return (function __$__3(__then) { +/* 140 */ if (repositoryUri) { +/* 141 */ return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 13, function ___(__0, __5) { +/* 141 */ var __4 = !__5; + return (function __$__3(__then) { + if (__4) { + return _(null); + } + else { + __then(); + } + ; + })(function __$__3() { +/* 144 */ return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() { +/* 145 */ return listDeployments(context, __cb(_, __frame, 19, 8, __then, true)); + }, true)); + }); + }, true)); + } + else { +/* 147 */ log.error("Repository is not setup"); + __then(); + } + ; + })(_); + }, true)); + }); + }, true)); + }); + }); +/* 151 */ scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) { + var maxItems, channel, progress, deployments; + var __frame = { + name: "scm_doDeploymentsGet__4", + line: 151 + }; + return __func(_, this, arguments, scm_doDeploymentsGet__4, 1, __frame, function __$scm_doDeploymentsGet__4() { +/* 152 */ maxItems = parseInt(context.maxItems, 10); +/* 153 */ if ((!maxItems || (maxItems <= 0))) { +/* 154 */ maxItems = 20; + } + ; +/* 160 */ channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems); +/* 162 */ progress = cli.progress("Enumerating deployments"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$scm_doDeploymentsGet__4() { +/* 164 */ return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) { +/* 164 */ deployments = ensureShortCommitId(__1); +/* 165 */ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() { +/* 166 */ return _(null, deployments.map(formatDeployment)); + }, true)); + }, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$scm_doDeploymentsGet__4() { +/* 168 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, _); + }); + }); + }; +/* 172 */ scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) { + var channel, progress; + var __frame = { + name: "scm_doDeploymentGet__5", + line: 172 + }; + return __func(_, this, arguments, scm_doDeploymentGet__5, 1, __frame, function __$scm_doDeploymentGet__5() { +/* 175 */ channel = getScmChannel(context).path("deployments").path(context.id); +/* 176 */ progress = cli.progress("Retrieving deployment info"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$scm_doDeploymentGet__5() { +/* 178 */ return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { +/* 178 */ var __1 = formatDeployment(__2); + return _(null, __1); + }, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$scm_doDeploymentGet__5() { +/* 180 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, _); + }); + }); + }; +/* 184 */ scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) { + var channel, progress; + var __frame = { + name: "scm_doDeploymentPut__6", + line: 184 + }; + return __func(_, this, arguments, scm_doDeploymentPut__6, 1, __frame, function __$scm_doDeploymentPut__6() { +/* 187 */ channel = getScmChannel(context).path("deployments").path(context.id); +/* 188 */ progress = cli.progress("Redeploying deployment"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$scm_doDeploymentPut__6() { +/* 190 */ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$scm_doDeploymentPut__6() { +/* 192 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, _); + }); + }); + }; +/* 196 */ scm.doLogGet = function scm_doLogGet__7(context, _) { + var channel, progress, logs; + var __frame = { + name: "scm_doLogGet__7", + line: 196 + }; + return __func(_, this, arguments, scm_doLogGet__7, 1, __frame, function __$scm_doLogGet__7() { +/* 200 */ channel = getScmChannel(context).path("deployments").path(context.id).path("log"); +/* 201 */ progress = cli.progress("Retrieving deployment log info"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$scm_doLogGet__7() { +/* 203 */ return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) { + logs = __1; +/* 204 */ return _(null, logs.map(formatLog)); + }, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$scm_doLogGet__7() { +/* 206 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, _); + }); + }); + }; +/* 210 */ function listDeployments(context, _) { + var deployments, authorLength, messageLength; + var __frame = { + name: "listDeployments", + line: 210 + }; + return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() { +/* 211 */ return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) { + deployments = __1; +/* 212 */ authorLength = 0; +/* 212 */ messageLength = 0; +/* 213 */ log.table(deployments, function(row, deployment) { +/* 214 */ row.cell("Time", deployment.start_time); +/* 215 */ row.cell("Commit id", deployment.shortId); +/* 216 */ row.cell("Status", deployment.status); +/* 217 */ authorLength = Math.max(deployment.author.length, authorLength); +/* 218 */ row.cell("Author", deployment.author, null, Math.min(authorLength, 15)); +/* 219 */ messageLength = Math.max(deployment.message.length, messageLength); +/* 220 */ row.cell("Message", deployment.message, null, Math.min(messageLength, 40)); + }); + _(); + }, true)); + }); + }; +/* 224 */ function showLogDetails(context, _) { + var results, logs, progress, i, details, j; + var __frame = { + name: "showLogDetails", + line: 224 + }; + return __func(_, this, arguments, showLogDetails, 1, __frame, function __$showLogDetails() { +/* 226 */ return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) { + logs = __2; + return (function __$showLogDetails(__then) { +/* 227 */ if ((logs && logs.length)) { +/* 228 */ progress = cli.progress("Retrieving log details"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$showLogDetails() { +/* 230 */ return async.map(logs, function __1(log, _) { + var details; + var __frame = { + name: "__1", + line: 230 + }; + return __func(_, this, arguments, __1, 1, __frame, function __$__1() { + return (function __$__1(__then) { +/* 231 */ if (log.hasDetails) { +/* 237 */ return getScmChannel(context).path("deployments").path(context.id).path("log").path(log.id).GET(__cb(_, __frame, 7, 26, function ___(__0, __1) { + details = __1; +/* 238 */ return _(null, details.map(formatLog)); + }, true)); + } + else { + __then(); + } + ; + })(_); + }); + }, __cb(_, __frame, 6, 18, function ___(__0, __3) { +/* 230 */ results = __3; + _(null, null, true); + }, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$showLogDetails() { +/* 242 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, function __$showLogDetails() { +/* 244 */ for (i = 0; (i < logs.length); ++i) { +/* 245 */ displayLog(logs[i]); +/* 246 */ if (results[i]) { +/* 247 */ details = results[i]; +/* 248 */ for (j = 0; (j < details.length); ++j) { +/* 249 */ displayLog(details[j]); + }; + } + ; + }; + __then(); + }); + }); + } + else { +/* 254 */ log.info("deployment has no detail"); + __then(); + } + ; + })(_); + }, true)); + }); + }; +/* 258 */ function displayLog(item) { +/* 259 */ if ((item.type == "Warning")) { +/* 260 */ log.warn(((item.short_time + " ") + item.message)); + } +/* 261 */ else if ((item.type == "Error")) { +/* 262 */ log.error(((item.short_time + " ") + item.message)); + } +/* 263 */ else { +/* 264 */ log.info(((item.short_time + " ") + item.message)); + } + + ; + }; +/* 268 */ function fromJsonDate(str) { +/* 269 */ return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)")); + }; +/* 272 */ function formatDate(dt) { +/* 273 */ var date = dt.getDate(), month = dt.getMonth(); +/* 275 */ date = ((((date < 10) ? "0" : "")) + date); +/* 276 */ month = ((((month < 10) ? "0" : "")) + month); +/* 277 */ return ((((((dt.getFullYear() + "-") + month) + "-") + date) + " ") + dt.toLocaleTimeString()); + }; +/* 280 */ function dateTimeText(str) { +/* 281 */ return formatDate(fromJsonDate(str)); + }; +/* 284 */ function deploymentStatusText(status) { +/* 285 */ switch (status) { +/* 286 */ case 0: +/* 286 */ return "Pending"; +/* 286 */ case 1: + return "Building"; +/* 287 */ case 2: +/* 287 */ return "Deploying"; +/* 287 */ case 3: + return "Failed"; +/* 288 */ case 4: +/* 288 */ return "Success"; +/* 288 */ default: + return "Unknown"; +/* 289 */ }; +/* 289 */ }; +/* 289 */ function logTypeText(type) { + switch (type) { +/* 290 */ case 0: +/* 290 */ return "Message"; +/* 290 */ case 1: + return "Warning"; + case 2: +/* 291 */ return "Error"; +/* 291 */ default: + return "Unknown"; + }; + }; +/* 295 */ function ensureShortCommitId(deployments) { +/* 296 */ return deployments.map(function(deployment) { +/* 297 */ deployment.shortId = deployment.id.substr(0, 10); +/* 297 */ return deployment; +/* 297 */ }); + }; +/* 298 */ function ensureRepositoryUri(context, _) { +/* 298 */ var siteData, repositoryUri; +/* 298 */ var __frame = { + name: "ensureRepositoryUri", +/* 299 */ line: 311 +/* 299 */ }; +/* 299 */ return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() { + return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 1, 19, function ___(__0, __1) { + siteData = __1; +/* 300 */ repositoryUri = (siteData && site.getRepositoryUri(siteData)); +/* 300 */ return (function __$ensureRepositoryUri(__then) { + if (!repositoryUri) { + return site.doSiteGet(context, __cb(_, __frame, 4, 17, function ___(__0, __2) { + siteData = __2; +/* 304 */ repositoryUri = site.getRepositoryUri(siteData); +/* 305 */ __then(); +/* 306 */ }, true)); +/* 307 */ } + else { + __then(); +/* 311 */ } + ; + })(function __$ensureRepositoryUri() { + if (repositoryUri) { + context.repositoryAuth = site.getRepositoryAuth(siteData); + return _(null, context.repositoryUri = repositoryUri); + } +/* 312 */ ; + _(); +/* 313 */ }); + }, true)); +/* 314 */ }); +/* 315 */ }; +/* 315 */ scm.ensureRepositoryUri = ensureRepositoryUri; +/* 316 */ function formatDeployment(deployment) { + var timeProperties = ["end_time","last_success_end_time","received_time","start_time",]; + for (var i = 0; (i < timeProperties.length); ++i) { + if (deployment[timeProperties[i]]) { + deployment[timeProperties[i]] = dateTimeText(deployment[timeProperties[i]]); + } + ; + }; + deployment.complete = (!!deployment.complete).toString(); +/* 318 */ deployment.status = (deployment.active ? "Active" : deploymentStatusText(deployment.status)); +/* 319 */ deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1"); +/* 320 */ delete deployment.active; + delete deployment.status_text; + delete deployment.url; + delete deployment.log_url; + return deployment; + }; + function formatLog(log) { + log.hasDetails = !!log.details_url; +/* 323 */ log.log_time = (log.log_time && dateTimeText(log.log_time)); +/* 325 */ log.short_time = (log.log_time && log.log_time.replace(/.* +(.*)/g, "$1")); +/* 326 */ log.type = logTypeText(log.type); +/* 327 */ log.shortId = log.id.substr(0, 10); +/* 328 */ delete log.details_url; +/* 329 */ return log; + }; + }; diff --git a/lib/cli/commands/deployment_.js b/lib/cli/commands/deployment_.js new file mode 100644 index 000000000..ee867ad39 --- /dev/null +++ b/lib/cli/commands/deployment_.js @@ -0,0 +1,351 @@ +/** +* Copyright 2011 Microsoft Corporation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +//if (!require('streamline/module')(module)) return; + +var common = require('../common'); +var fs = require('fs'); +var path = require('path'); +var url = require('url'); +var crypto = require('crypto'); +var pfx2pem = require('../../util/certificates/pkcs').pfx2pem; +var Channel = require('../channel'); +var async = require('async'); +var child_process = require('child_process'); +var utils = require('../utils'); +var constants = require('../constants'); +var cacheUtils = require('../cacheUtils'); + +exports.init = function (cli) { + + var log = cli.output; + var site = cli.category('site'); + var scm = site.category('deployment') + .description('Commands to manage your git deployments'); + + function getScmChannel(context) { + var parts = url.parse(context.repositoryUri); + var channel = new Channel({ + host: parts.hostname, + port: (parts.port && parseInt(parts.port, 10)) || (/https/i.test(parts.protocol) ? 443 : 80), + auth: context.repositoryAuth + }); + + var proxyString = + process.env.HTTPS_PROXY || + process.env.https_proxy || + process.env.ALL_PROXY || + process.env.all_proxy; + + if (proxyString !== undefined) { + var proxyUrl = url.parse(proxyString); + if (proxyUrl.protocol !== 'http:' && + proxyUrl.protocol !== 'https:') { + // fall-back parsing support XXX_PROXY=host:port environment variable values + proxyUrl = url.parse('http://' + proxyString); + } + + channel = channel.add({ proxy: proxyUrl }); + } + + return channel; + } + scm.getScmChannel = getScmChannel; + + scm.command('list [name]') + .whiteListPowershell() + .description('List your git deployments') + .option('-s, --subscription ', 'use the subscription id') + .option('-m, --max ', 'limit the maximum number of results') + .execute(function (name, options, _) { + var context = { + subscription: cli.category('account').lookupSubscriptionId(options.subscription), + maxItems: options.max, + site: { + name: name + } + }; + + var repositoryUri = ensureRepositoryUri(context, _); + if (repositoryUri) { + listDeployments(context, _); + } else { + log.error('Repository is not setup'); + } + }); + + scm.command('show [name]') + .whiteListPowershell() + .description('Show your git deployment') + .option('-s, --subscription ', 'use the subscription id') + .option('-d, --details', 'display log details') + .execute(function (commitId, name, options, _) { + var context = { + subscription: cli.category('account').lookupSubscriptionId(options.subscription), + shortId: commitId, + site: { + name: name + } + }; + + if (!(context.id = cacheUtils.readCommitId(context, _))) { + return log.error('deployment with ' + commitId + ' does not exist'); + } + + var repositoryUri = ensureRepositoryUri(context, _); + if (repositoryUri) { + var deployment = scm.doDeploymentGet(context, _); + site.logEachData('info', deployment); + if (options.details) { + showLogDetails(context, _); + } else { + log.info('To see more details, specify -d or --details option'); + } + } else { + log.error('Repository is not setup'); + } + }); + + scm.command('redeploy [name]') + .whiteListPowershell() + .description('Show your git deployment') + .option('-s, --subscription ', 'use the subscription id') + .execute(function (commitId, name, options, _) { + var context = { + subscription: cli.category('account').lookupSubscriptionId(options.subscription), + shortId: commitId, + site: { + name: name + } + }; + + if (!(context.id = cacheUtils.readCommitId(context, _))) { + return log.error('deployment with ' + commitId + ' does not exist'); + } + + var repositoryUri = ensureRepositoryUri(context, _); + if (repositoryUri) { + if (!site.confirm('Reploy deployment with ' + context.shortId + ' id? (y/n) ', _)) { + return; + } + scm.doDeploymentPut(context, _); + listDeployments(context, _); + } else { + log.error('Repository is not setup'); + } + }); + + scm.doDeploymentsGet = function (context, _) { + var maxItems = parseInt(context.maxItems, 10); + if (!maxItems || maxItems <= 0) { + maxItems = 20; + } + + var channel = getScmChannel(context) + .path('deployments') + .query('$orderby', 'ReceivedTime desc') + .query('$top', maxItems); + + var progress = cli.progress('Enumerating deployments'); + try { + var deployments = ensureShortCommitId(channel.GET(_)); + cacheUtils.saveCommitIds(context, deployments, _); + return deployments.map(formatDeployment); + } finally { + progress.end(); + } + }; + + scm.doDeploymentGet = function (context, _) { + var channel = getScmChannel(context) + .path('deployments') + .path(context.id); + var progress = cli.progress('Retrieving deployment info'); + try { + return formatDeployment(channel.GET(_)); + } finally { + progress.end(); + } + }; + + scm.doDeploymentPut = function (context, _) { + var channel = getScmChannel(context) + .path('deployments') + .path(context.id); + var progress = cli.progress('Redeploying deployment'); + try { + return channel.PUT(null, _); + } finally { + progress.end(); + } + }; + + scm.doLogGet = function (context, _) { + var channel = getScmChannel(context) + .path('deployments') + .path(context.id) + .path('log'); + var progress = cli.progress('Retrieving deployment log info'); + try { + var logs = channel.GET(_); + return logs.map(formatLog); + } finally { + progress.end(); + } + }; + + function listDeployments(context, _) { + var deployments = scm.doDeploymentsGet(context, _); + var authorLength = 0, messageLength = 0; + log.table(deployments, function (row, deployment) { + row.cell('Time', deployment.start_time); + row.cell('Commit id', deployment.shortId); + row.cell('Status', deployment.status); + authorLength = Math.max(deployment.author.length, authorLength); + row.cell('Author', deployment.author, null, Math.min(authorLength, 15)); + messageLength = Math.max(deployment.message.length, messageLength); + row.cell('Message', deployment.message, null, Math.min(messageLength, 40)); + }); + } + + function showLogDetails(context, _) { + var results, + logs = scm.doLogGet(context, _); + if (logs && logs.length) { + var progress = cli.progress('Retrieving log details'); + try { + results = async.map(logs, function (log, _) { + if (log.hasDetails) { + var details = getScmChannel(context) + .path('deployments') + .path(context.id) + .path('log') + .path(log.id) + .GET(_); + return details.map(formatLog); + } + }, _); + } finally { + progress.end(); + } + for (var i = 0; i < logs.length; ++i) { + displayLog(logs[i]); + if (results[i]) { + var details = results[i]; + for (var j = 0; j < details.length; ++j) { + displayLog(details[j]); + } + } + } + } else { + log.info('deployment has no detail'); + } + } + + function displayLog(item) { + if (item.type == 'Warning') { + log.warn(item.short_time + ' ' + item.message); + } else if (item.type == 'Error') { + log.error(item.short_time + ' ' + item.message); + } else { + log.info(item.short_time + ' ' + item.message); + } + } + + function fromJsonDate(str) { + return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)")); + } + + function formatDate(dt) { + var date = dt.getDate(), + month = dt.getMonth(); + date = (date < 10 ? "0" : "") + date; + month = (month < 10 ? "0" : "") + month; + return dt.getFullYear() + "-" + month + "-" + date + " " + dt.toLocaleTimeString(); + } + + function dateTimeText(str) { + return formatDate(fromJsonDate(str)); + } + + function deploymentStatusText(status) { + switch (status) { + case 0: return 'Pending'; + case 1: return 'Building'; + case 2: return 'Deploying'; + case 3: return 'Failed'; + case 4: return 'Success'; + default: return 'Unknown'; + } + } + + function logTypeText(type) { + switch (type) { + case 0: return 'Message'; + case 1: return 'Warning'; + case 2: return 'Error'; + default: return 'Unknown'; + } + } + + function ensureShortCommitId(deployments) { + return deployments.map(function (deployment) { + deployment.shortId = deployment.id.substr(0, 10); + return deployment; + }); + } + + function ensureRepositoryUri(context, _) { + var siteData = site.lookupSiteNameAndWebSpace(context, _); + var repositoryUri = siteData && site.getRepositoryUri(siteData); + if (!repositoryUri) { + siteData = site.doSiteGet(context, _); + repositoryUri = site.getRepositoryUri(siteData); + } + if (repositoryUri) { + context.repositoryAuth = site.getRepositoryAuth(siteData); + return context.repositoryUri = repositoryUri; + } + } + scm.ensureRepositoryUri = ensureRepositoryUri; + + function formatDeployment(deployment) { + var timeProperties = ['end_time', 'last_success_end_time', 'received_time', 'start_time']; + for (var i = 0; i < timeProperties.length; ++i) { + if (deployment[timeProperties[i]]) { + deployment[timeProperties[i]] = dateTimeText(deployment[timeProperties[i]]); + } + } + deployment.complete = (!!deployment.complete).toString(); + deployment.status = deployment.active ? 'Active' : deploymentStatusText(deployment.status); + deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1"); + delete deployment.active; + delete deployment.status_text; + delete deployment.url; + delete deployment.log_url; + return deployment; + } + + function formatLog(log) { + log.hasDetails = !!log.details_url; + log.log_time = log.log_time && dateTimeText(log.log_time); + log.short_time = log.log_time && log.log_time.replace(/.* +(.*)/g, "$1"); + log.type = logTypeText(log.type); + log.shortId = log.id.substr(0, 10); + delete log.details_url; + return log; + } +}; diff --git a/lib/cli/commands/log.js b/lib/cli/commands/log.js new file mode 100644 index 000000000..ab670ec66 --- /dev/null +++ b/lib/cli/commands/log.js @@ -0,0 +1,113 @@ +/*** Generated by streamline 0.2.5 - DO NOT EDIT ***/ +var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g; +/* 1 */ var common = require("../common"); +/* 20 */ var fs = require("fs"); +/* 21 */ var path = require("path"); +/* 22 */ var url = require("url"); +/* 23 */ var crypto = require("crypto"); +/* 24 */ var pfx2pem = require("../../util/certificates/pkcs").pfx2pem; +/* 25 */ var Channel = require("../channel"); +/* 26 */ var async = require("async"); +/* 27 */ var child_process = require("child_process"); +/* 28 */ var utils = require("../utils"); +/* 29 */ var constants = require("../constants"); +/* 30 */ var cacheUtils = require("../cacheUtils"); +/* 32 */ exports.init = function(cli) { +/* 34 */ var log = cli.output; +/* 35 */ var site = cli.category("site"); +/* 36 */ var scm = site.category("deployment"); +/* 37 */ var diagnostic = site.category("log").description("Commands to download diagnostic log"); +/* 40 */ diagnostic.command("download [name]").whiteListPowershell().description("Download diagnostic log").option("-s, --subscription ", "use the subscription id").option("-o, --output ", "output path, default is local folder").execute(function __1(name, options, _) { + var context, repositoryUri, buf; + var __frame = { + name: "__1", + line: 45 + }; + return __func(_, this, arguments, __1, 2, __frame, function __$__1() { +/* 46 */ context = { +/* 47 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 48 */ path: (options.output || ""), +/* 49 */ site: { +/* 50 */ name: name + } + }; +/* 54 */ if (!(/[.]zip$/i.test(context.path))) { +/* 55 */ context.path = path.join(context.path, "diagnostics.zip"); + } + ; + return (function __$__1(__then) { +/* 58 */ if (path.existsSync(context.path)) { +/* 59 */ return site.confirm((("Replace existing " + context.path) + "? (y/n) "), __cb(_, __frame, 14, 13, function ___(__0, __2) { +/* 59 */ var __1 = !__2; + return (function __$__1(__then) { + if (__1) { + return _(null); + } + else { + __then(); + } + ; + })(__then); + }, true)); + } + else { + __then(); + } + ; + })(function __$__1() { +/* 64 */ return scm.ensureRepositoryUri(context, __cb(_, __frame, 19, 26, function ___(__0, __3) { + repositoryUri = __3; + return (function __$__1(__then) { +/* 65 */ if (repositoryUri) { +/* 66 */ return doDownloadDiagnostic(context, __cb(_, __frame, 21, 18, function ___(__0, __4) { + buf = __4; +/* 67 */ log.info(("Writing to " + context.path)); +/* 68 */ return fs.writeFile(context.path, buf, __cb(_, __frame, 23, 8, __then, true)); + }, true)); + } + else { +/* 70 */ log.error("Repository is not setup"); + __then(); + } + ; + })(_); + }, true)); + }); + }); + }); +/* 74 */ function doDownloadDiagnostic(context, _) { + var channel, progress; + var __frame = { + name: "doDownloadDiagnostic", + line: 74 + }; + return __func(_, this, arguments, doDownloadDiagnostic, 1, __frame, function __$doDownloadDiagnostic() { +/* 76 */ channel = scm.getScmChannel(context).path("dump"); +/* 77 */ progress = cli.progress("Downloading diagnostic log"); + return (function ___(__then) { + (function ___(_) { + __tryCatch(_, function __$doDownloadDiagnostic() { +/* 79 */ return channel.GET(__cb(_, __frame, 5, 13, _, true)); + }); + })(function ___(__e, __r, __cont) { + (function ___(__then) { + __tryCatch(_, function __$doDownloadDiagnostic() { +/* 81 */ progress.end(); + __then(); + }); + })(function ___() { + __tryCatch(_, function ___() { + if (__cont) { + __then(); + } else { + _(__e, __r); + }; + }); + }); + }); + })(function ___() { + __tryCatch(_, _); + }); + }); + }; + }; diff --git a/lib/cli/commands/log_.js b/lib/cli/commands/log_.js new file mode 100644 index 000000000..173a40440 --- /dev/null +++ b/lib/cli/commands/log_.js @@ -0,0 +1,84 @@ +/** +* Copyright 2011 Microsoft Corporation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +//if (!require('streamline/module')(module)) return; + +var common = require('../common'); +var fs = require('fs'); +var path = require('path'); +var url = require('url'); +var crypto = require('crypto'); +var pfx2pem = require('../../util/certificates/pkcs').pfx2pem; +var Channel = require('../channel'); +var async = require('async'); +var child_process = require('child_process'); +var utils = require('../utils'); +var constants = require('../constants'); +var cacheUtils = require('../cacheUtils'); + +exports.init = function (cli) { + + var log = cli.output; + var site = cli.category('site'); + var scm = site.category('deployment'); + var diagnostic = site.category('log') + .description('Commands to download diagnostic log'); + + diagnostic.command('download [name]') + .whiteListPowershell() + .description('Download diagnostic log') + .option('-s, --subscription ', 'use the subscription id') + .option('-o, --output ', 'output path, default is local folder') + .execute(function (name, options, _) { + var context = { + subscription: cli.category('account').lookupSubscriptionId(options.subscription), + path: options.output || '', + site: { + name: name + } + }; + + if (!(/[.]zip$/i.test(context.path))) { + context.path = path.join(context.path, 'diagnostics.zip'); + } + + if (path.existsSync(context.path)) { + if (!site.confirm('Replace existing ' + context.path + '? (y/n) ', _)) { + return; + } + } + + var repositoryUri = scm.ensureRepositoryUri(context, _); + if (repositoryUri) { + var buf = doDownloadDiagnostic(context, _); + log.info('Writing to ' + context.path); + fs.writeFile(context.path, buf, _); + } else { + log.error('Repository is not setup'); + } + }); + + function doDownloadDiagnostic(context, _) { + var channel = scm.getScmChannel(context) + .path('dump'); + var progress = cli.progress('Downloading diagnostic log'); + try { + return channel.GET(_); + } finally { + progress.end(); + } + } +}; diff --git a/lib/cli/commands/site.js b/lib/cli/commands/site.js index ef8aee64e..f2e5834e9 100644 --- a/lib/cli/commands/site.js +++ b/lib/cli/commands/site.js @@ -73,6 +73,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= /* 97 */ callback(undefined, x); }); }; +/* 99 */ site.confirm = confirm; /* 101 */ site.command("create [name]").whiteListPowershell().description("Create a new web site and local directory").option("-s, --subscription ", "use the subscription id").option("--location ", "the geographic region to create the website").option("--hostname ", "custom host name to use").option("--git", "configure git on web site and local folder").execute(function __2(nameArg, options, _) { var context; /* 130 */ function promptForSiteName(_) { @@ -521,7 +522,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); /* 340 */ site.command("show [name]").whiteListPowershell().description("Show details for a web site").option("-s, --subscription ", "use the subscription id").execute(function __5(name, options, _) { - var context, result, repositoryUri, i, pair; + var context, result, repositoryUri; var __frame = { name: "__5", line: 344 @@ -556,114 +557,133 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= result = __3; /* 363 */ logEachData("Site", result[0]); /* 364 */ logEachData("Config", result[1]); -/* 366 */ repositoryUri = null; -/* 367 */ for (i = 0; (i < result[0].SiteProperties.Properties.NameValuePair.length); ++i) { -/* 368 */ pair = result[0].SiteProperties.Properties.NameValuePair[i]; -/* 369 */ if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) { -/* 370 */ repositoryUri = (!pair.Value["@"] && pair.Value); -/* 371 */ break; - } - ; - }; -/* 374 */ log.data("Repository", (repositoryUri ? ((((clean(repositoryUri) + "/") + context.site.name) + ".git")) : "")); +/* 366 */ repositoryUri = getRepositoryUri(result[0]); +/* 367 */ log.data("Repository", (repositoryUri ? ((((repositoryUri + "/") + context.site.name) + ".git")) : "")); _(); }, true)); }, true)); }); }); -/* 377 */ function lookupSiteName(context, _) { +/* 370 */ function lookupSiteName(context, _) { var cfg; var __frame = { name: "lookupSiteName", - line: 377 + line: 370 }; return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() { -/* 378 */ if ((context.site.name !== undefined)) { +/* 371 */ if ((context.site.name !== undefined)) { return _(null); } ; -/* 383 */ return site.readConfig(__cb(_, __frame, 6, 14, function ___(__0, __1) { +/* 376 */ return site.readConfig(__cb(_, __frame, 6, 14, function ___(__0, __1) { cfg = __1; -/* 384 */ if ((cfg !== undefined)) { -/* 386 */ context.site.name = cfg.name; -/* 387 */ context.site.webspace = cfg.webspace; +/* 377 */ if ((cfg && cfg.name)) { +/* 379 */ context.site.name = cfg.name; +/* 380 */ context.site.webspace = cfg.webspace; return _(null); } ; -/* 391 */ return prompt("Web site name: ", __cb(_, __frame, 14, 24, function ___(__0, __2) { -/* 391 */ context.site.name = __2; +/* 384 */ return prompt("Web site name: ", __cb(_, __frame, 14, 24, function ___(__0, __2) { +/* 384 */ context.site.name = __2; _(); }, true)); }, true)); }); }; -/* 394 */ function lookupSiteWebSpace(context, _) { +/* 387 */ function lookupSiteWebSpace(context, _) { var sites, index; var __frame = { name: "lookupSiteWebSpace", - line: 394 + line: 387 }; return __func(_, this, arguments, lookupSiteWebSpace, 1, __frame, function __$lookupSiteWebSpace() { -/* 395 */ log.verbose("Attempting to locate site ", context.site.name); -/* 396 */ return site.doSitesGet(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { +/* 388 */ log.verbose("Attempting to locate site ", context.site.name); +/* 389 */ return site.doSitesGet(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { sites = __1; -/* 397 */ for (index in sites) { -/* 398 */ if (utils.ignoreCaseEquals(sites[index].Name, context.site.name)) { -/* 399 */ log.verbose("Site located at ", sites[index].WebSpace); -/* 400 */ context.site.webspace = sites[index].WebSpace; +/* 390 */ for (index in sites) { +/* 391 */ if (utils.ignoreCaseEquals(sites[index].Name, context.site.name)) { +/* 392 */ log.verbose("Site located at ", sites[index].WebSpace); +/* 393 */ context.site.webspace = sites[index].WebSpace; } ; }; -/* 403 */ if ((context.site.webspace === undefined)) { -/* 404 */ return _(new Error(("Unable to locate site named " + context.site.name))); +/* 396 */ if ((context.site.webspace === undefined)) { +/* 397 */ return _(new Error(("Unable to locate site named " + context.site.name))); } ; _(); }, true)); }); }; -/* 408 */ function lookupSiteNameAndWebSpace(context, _) { +/* 401 */ function lookupSiteNameAndWebSpace(context, _) { var cache; var __frame = { name: "lookupSiteNameAndWebSpace", - line: 408 + line: 401 }; return __func(_, this, arguments, lookupSiteNameAndWebSpace, 1, __frame, function __$lookupSiteNameAndWebSpace() { -/* 409 */ return lookupSiteName(context, __cb(_, __frame, 1, 4, function __$lookupSiteNameAndWebSpace() { -/* 410 */ return cacheUtils.readSite(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { +/* 402 */ return lookupSiteName(context, __cb(_, __frame, 1, 4, function __$lookupSiteNameAndWebSpace() { +/* 403 */ return cacheUtils.readSite(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { cache = __1; -/* 411 */ if ((cache || context.site.webspace)) { -/* 412 */ context.site.webspace = (((cache && cache.WebSpace)) || context.site.webspace); -/* 413 */ return _(null, cache); +/* 404 */ if ((cache || context.site.webspace)) { +/* 405 */ context.site.webspace = (((cache && cache.WebSpace)) || context.site.webspace); +/* 406 */ return _(null, cache); } ; -/* 415 */ return lookupSiteWebSpace(context, __cb(_, __frame, 7, 4, _, true)); +/* 408 */ return lookupSiteWebSpace(context, __cb(_, __frame, 7, 4, _, true)); }, true)); }, true)); }); }; -/* 418 */ site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription ", "use the subscription id").execute(function __6(name, options, _) { +/* 410 */ site.lookupSiteNameAndWebSpace = lookupSiteNameAndWebSpace; +/* 412 */ function getRepositoryUri(siteData) { +/* 413 */ for (var i = 0; (i < siteData.SiteProperties.Properties.NameValuePair.length); ++i) { +/* 414 */ var pair = siteData.SiteProperties.Properties.NameValuePair[i]; +/* 415 */ if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) { +/* 416 */ return (((typeof pair.Value === "string")) ? pair.Value : null); + } + ; + }; + }; +/* 420 */ site.getRepositoryUri = getRepositoryUri; +/* 422 */ function getRepositoryAuth(siteData) { +/* 423 */ var userName, password; +/* 424 */ for (var i = 0; (i < siteData.SiteProperties.Properties.NameValuePair.length); ++i) { +/* 425 */ var pair = siteData.SiteProperties.Properties.NameValuePair[i]; +/* 426 */ if (utils.ignoreCaseEquals(pair.Name, "PublishingUsername")) { +/* 427 */ userName = pair.Value; + } +/* 428 */ else if (utils.ignoreCaseEquals(pair.Name, "PublishingPassword")) { +/* 429 */ password = pair.Value; + } + + ; + }; +/* 432 */ return (userName && (((userName + ":") + password))); + }; +/* 434 */ site.getRepositoryAuth = getRepositoryAuth; +/* 436 */ site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription ", "use the subscription id").execute(function __6(name, options, _) { var context, progress, result; var __frame = { name: "__6", - line: 422 + line: 440 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() { -/* 423 */ context = { -/* 424 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 425 */ site: { -/* 426 */ name: name +/* 441 */ context = { +/* 442 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 443 */ site: { +/* 444 */ name: name } }; -/* 430 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__6() { -/* 432 */ log.info("Deleting site", context.site.name); -/* 434 */ progress = cli.progress("Deleting site"); +/* 448 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__6() { +/* 450 */ log.info("Deleting site", context.site.name); +/* 452 */ progress = cli.progress("Deleting site"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__6() { -/* 443 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).DELETE(__cb(_, __frame, 21, 25, function ___(__0, __1) { +/* 461 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).DELETE(__cb(_, __frame, 21, 25, function ___(__0, __1) { result = __1; -/* 444 */ return cacheUtils.deleteSite(context, __cb(_, __frame, 22, 12, function __$__6() { +/* 462 */ return cacheUtils.deleteSite(context, __cb(_, __frame, 22, 12, function __$__6() { _(null, null, true); }, true)); }, true)); @@ -671,7 +691,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__6() { -/* 447 */ progress.end(); +/* 465 */ progress.end(); __then(); }); })(function ___() { @@ -686,47 +706,47 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); })(function ___() { __tryCatch(_, function __$__6() { -/* 449 */ log.info((("Site " + context.site.name) + " has been deleted")); +/* 467 */ log.info((("Site " + context.site.name) + " has been deleted")); _(); }); }); }, true)); }); }); -/* 453 */ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription ", "use the subscription id").execute(function __7(name, options, _) { +/* 471 */ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription ", "use the subscription id").execute(function __7(name, options, _) { var context, progress, result; var __frame = { name: "__7", - line: 457 + line: 475 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() { -/* 458 */ context = { -/* 459 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 460 */ site: { -/* 461 */ name: name +/* 476 */ context = { +/* 477 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 478 */ site: { +/* 479 */ name: name } }; -/* 465 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__7() { -/* 467 */ log.info("Starting site", context.site.name); -/* 469 */ progress = cli.progress("Updating site state"); +/* 483 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__7() { +/* 485 */ log.info("Starting site", context.site.name); +/* 487 */ progress = cli.progress("Updating site state"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { -/* 479 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) { -/* 480 */ req.write(""); -/* 481 */ req.write(""); -/* 482 */ req.write(""); -/* 483 */ req.write((context.site.name + cli.category("account").hostNameSuffix())); -/* 484 */ req.write(""); -/* 485 */ req.write(""); -/* 486 */ req.write(""); -/* 487 */ req.write(context.site.name); -/* 488 */ req.write(""); -/* 489 */ req.write(""); -/* 490 */ req.write("Running"); -/* 491 */ req.write(""); -/* 492 */ req.write(""); -/* 494 */ req.end(); +/* 497 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) { +/* 498 */ req.write(""); +/* 499 */ req.write(""); +/* 500 */ req.write(""); +/* 501 */ req.write((context.site.name + cli.category("account").hostNameSuffix())); +/* 502 */ req.write(""); +/* 503 */ req.write(""); +/* 504 */ req.write(""); +/* 505 */ req.write(context.site.name); +/* 506 */ req.write(""); +/* 507 */ req.write(""); +/* 508 */ req.write("Running"); +/* 509 */ req.write(""); +/* 510 */ req.write(""); +/* 512 */ req.end(); }, __cb(_, __frame, 22, 25, function ___(__0, __1) { result = __1; _(null, null, true); @@ -735,7 +755,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__7() { -/* 498 */ progress.end(); +/* 516 */ progress.end(); __then(); }); })(function ___() { @@ -750,47 +770,47 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); })(function ___() { __tryCatch(_, function __$__7() { -/* 501 */ log.info((("Site " + context.site.name) + " has been started")); +/* 519 */ log.info((("Site " + context.site.name) + " has been started")); _(); }); }); }, true)); }); }); -/* 504 */ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription ", "use the subscription id").execute(function __8(name, options, _) { +/* 522 */ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription ", "use the subscription id").execute(function __8(name, options, _) { var context, progress, result; var __frame = { name: "__8", - line: 508 + line: 526 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() { -/* 509 */ context = { -/* 510 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 511 */ site: { -/* 512 */ name: name +/* 527 */ context = { +/* 528 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 529 */ site: { +/* 530 */ name: name } }; -/* 516 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__8() { -/* 518 */ log.info("Stopping site", context.site.name); -/* 520 */ progress = cli.progress("Updating site state"); +/* 534 */ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__8() { +/* 536 */ log.info("Stopping site", context.site.name); +/* 538 */ progress = cli.progress("Updating site state"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() { -/* 530 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) { -/* 531 */ req.write(""); -/* 532 */ req.write(""); -/* 533 */ req.write(""); -/* 534 */ req.write((context.site.name + cli.category("account").hostNameSuffix())); -/* 535 */ req.write(""); -/* 536 */ req.write(""); -/* 537 */ req.write(""); -/* 538 */ req.write(context.site.name); -/* 539 */ req.write(""); -/* 540 */ req.write(""); -/* 541 */ req.write("Stopped"); -/* 542 */ req.write(""); -/* 543 */ req.write(""); -/* 545 */ req.end(); +/* 548 */ return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) { +/* 549 */ req.write(""); +/* 550 */ req.write(""); +/* 551 */ req.write(""); +/* 552 */ req.write((context.site.name + cli.category("account").hostNameSuffix())); +/* 553 */ req.write(""); +/* 554 */ req.write(""); +/* 555 */ req.write(""); +/* 556 */ req.write(context.site.name); +/* 557 */ req.write(""); +/* 558 */ req.write(""); +/* 559 */ req.write("Stopped"); +/* 560 */ req.write(""); +/* 561 */ req.write(""); +/* 563 */ req.end(); }, __cb(_, __frame, 22, 25, function ___(__0, __1) { result = __1; _(null, null, true); @@ -799,7 +819,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() { -/* 549 */ progress.end(); +/* 567 */ progress.end(); __then(); }); })(function ___() { @@ -814,61 +834,61 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); })(function ___() { __tryCatch(_, function __$__8() { -/* 552 */ log.info((("Site " + context.site.name) + " has been stopped")); +/* 570 */ log.info((("Site " + context.site.name) + " has been stopped")); _(); }); }); }, true)); }); }); -/* 559 */ site.readConfig = function site_readConfig__9(_) { +/* 577 */ site.readConfig = function site_readConfig__9(_) { var __frame = { name: "site_readConfig__9", - line: 559 + line: 577 }; return __func(_, this, arguments, site_readConfig__9, 0, __frame, function __$site_readConfig__9() { -/* 561 */ return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) { -/* 562 */ return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) { -/* 560 */ var __1 = { -/* 561 */ name: __2, -/* 562 */ webspace: __3 +/* 579 */ return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) { +/* 580 */ return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) { +/* 578 */ var __1 = { +/* 579 */ name: __2, +/* 580 */ webspace: __3 }; return _(null, __1); }, true)); }, true)); }); }; -/* 566 */ site.writeConfig = function site_writeConfig__10(cfg, _) { +/* 584 */ site.writeConfig = function site_writeConfig__10(cfg, _) { var __frame = { name: "site_writeConfig__10", - line: 566 + line: 584 }; return __func(_, this, arguments, site_writeConfig__10, 1, __frame, function __$site_writeConfig__10() { -/* 567 */ return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__10() { -/* 568 */ return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true)); +/* 585 */ return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__10() { +/* 586 */ return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true)); }, true)); }); }; -/* 571 */ site.readConfigValue = function site_readConfigValue__11(name, _) { +/* 589 */ site.readConfigValue = function site_readConfigValue__11(name, _) { var result; var __frame = { name: "site_readConfigValue__11", - line: 571 + line: 589 }; return __func(_, this, arguments, site_readConfigValue__11, 1, __frame, function __$site_readConfigValue__11() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_readConfigValue__11() { -/* 573 */ return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) { +/* 591 */ return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) { result = __1; -/* 574 */ return _(null, ((result.stdout + result.stderr)).trim()); +/* 592 */ return _(null, ((result.stdout + result.stderr)).trim()); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$site_readConfigValue__11() { if (err) { -/* 577 */ log.silly("Unable to read config", err); -/* 578 */ return _(null, ""); +/* 595 */ log.silly("Unable to read config", err); +/* 596 */ return _(null, ""); } else { _(null, __result); @@ -881,86 +901,86 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 582 */ site.writeConfigValue = function site_writeConfigValue__12(name, value, _) { +/* 600 */ site.writeConfigValue = function site_writeConfigValue__12(name, value, _) { var __frame = { name: "site_writeConfigValue__12", - line: 582 + line: 600 }; return __func(_, this, arguments, site_writeConfigValue__12, 2, __frame, function __$site_writeConfigValue__12() { -/* 583 */ return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true)); +/* 601 */ return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true)); }); }; -/* 590 */ site.doSitesPost = function(options, callback) { -/* 591 */ log.info("Creating a new web site at ", (options.site.name + cli.category("account").hostNameSuffix())); -/* 592 */ log.verbose("Subscription", options.subscription); -/* 593 */ log.verbose("Webspace", options.site.webspace); -/* 594 */ log.verbose("Site", options.site.name); -/* 596 */ var progress = cli.progress("Sending site information"); -/* 597 */ try { -/* 598 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").header("Content-Type", "application/xml").POST(writers.Site.xml(options.site), function(err, result) { -/* 608 */ if (err) { -/* 609 */ logError("Failed to create site", err); - } -/* 610 */ else { -/* 611 */ return cacheUtils.saveSite(options, result, function(err) { -/* 612 */ log.info("Created website at ", clean(result).HostNames); -/* 613 */ log.verbose("Site", clean(result)); -/* 614 */ callback(err, result); - }); - } - ; -/* 617 */ callback(err, result); - }); -/* 620 */ } finally { -/* 621 */ progress.end(); +/* 608 */ site.doSitesPost = function(options, callback) { +/* 609 */ log.info("Creating a new web site at ", (options.site.name + cli.category("account").hostNameSuffix())); +/* 610 */ log.verbose("Subscription", options.subscription); +/* 611 */ log.verbose("Webspace", options.site.webspace); +/* 612 */ log.verbose("Site", options.site.name); +/* 614 */ var progress = cli.progress("Sending site information"); +/* 615 */ var cb = function(err, result) { +/* 616 */ progress.end(); +/* 617 */ return (callback && callback(err, result)); }; +/* 620 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").header("Content-Type", "application/xml").POST(writers.Site.xml(options.site), function(err, result) { +/* 630 */ if (err) { +/* 631 */ logError("Failed to create site", err); + } +/* 632 */ else { +/* 633 */ return cacheUtils.saveSite(options, result, function(err) { +/* 634 */ log.info("Created website at ", clean(result).HostNames); +/* 635 */ log.verbose("Site", clean(result)); +/* 636 */ return cb(err, result); + }); + } + ; +/* 639 */ return cb(err, result); + }); }; -/* 625 */ site.doRepositoryPost = function(options, callback) { -/* 626 */ log.info("Initializing repository"); -/* 627 */ log.verbose("Subscription", options.subscription); -/* 628 */ log.verbose("Webspace", options.site.webspace); -/* 629 */ log.verbose("Site", options.site.name); -/* 631 */ var progress = cli.progress("Updating site information"); -/* 632 */ try { -/* 633 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").POST("", function(err, result) { -/* 644 */ if (err) { -/* 645 */ logError("Failed to initialize repository", err); - } -/* 646 */ else { -/* 647 */ log.info("Repository initialized"); - } - ; -/* 649 */ callback(err, result); - }); -/* 652 */ } finally { -/* 653 */ progress.end(); +/* 643 */ site.doRepositoryPost = function(options, callback) { +/* 644 */ log.info("Initializing repository"); +/* 645 */ log.verbose("Subscription", options.subscription); +/* 646 */ log.verbose("Webspace", options.site.webspace); +/* 647 */ log.verbose("Site", options.site.name); +/* 649 */ var progress = cli.progress("Updating site information"); +/* 650 */ var cb = function(err, result) { +/* 651 */ progress.end(); +/* 652 */ return (callback && callback(err, result)); }; +/* 654 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").POST("", function(err, result) { +/* 665 */ if (err) { +/* 666 */ logError("Failed to initialize repository", err); + } +/* 667 */ else { +/* 668 */ log.info("Repository initialized"); + } + ; +/* 670 */ return cb(err, result); + }); }; -/* 657 */ site.doSpacesGet = function site_doSpacesGet__13(options, _) { +/* 674 */ site.doSpacesGet = function site_doSpacesGet__13(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__13", - line: 657 + line: 674 }; return __func(_, this, arguments, site_doSpacesGet__13, 1, __frame, function __$site_doSpacesGet__13() { -/* 658 */ log.verbose("Subscription", options.subscription); -/* 660 */ progress = cli.progress("Enumerating locations"); +/* 675 */ log.verbose("Subscription", options.subscription); +/* 677 */ progress = cli.progress("Enumerating locations"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSpacesGet__13() { -/* 667 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").GET(__cb(_, __frame, 10, 19, function ___(__0, __1) { +/* 684 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").GET(__cb(_, __frame, 10, 19, function ___(__0, __1) { result = __1; -/* 669 */ log.json("silly", result); -/* 670 */ spaces = toArray(result.WebSpace); -/* 671 */ return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__13() { -/* 672 */ return _(null, spaces); +/* 686 */ log.json("silly", result); +/* 687 */ spaces = toArray(result.WebSpace); +/* 688 */ return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__13() { +/* 689 */ return _(null, spaces); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSpacesGet__13() { -/* 675 */ progress.end(); +/* 692 */ progress.end(); __then(); }); })(function ___() { @@ -978,46 +998,46 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 679 */ site.doSitesGet = function site_doSitesGet__14(options, _) { +/* 696 */ site.doSitesGet = function site_doSitesGet__14(options, _) { var spaces, channel, progress, result, sites; var __frame = { name: "site_doSitesGet__14", - line: 679 + line: 696 }; return __func(_, this, arguments, site_doSitesGet__14, 1, __frame, function __$site_doSitesGet__14() { -/* 680 */ log.verbose("Subscription", options.subscription); -/* 682 */ return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) { +/* 697 */ log.verbose("Subscription", options.subscription); +/* 699 */ return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) { spaces = __2; -/* 687 */ channel = getChannel().path(options.subscription).path("services").path("webspaces"); -/* 689 */ progress = cli.progress("Enumerating sites"); +/* 704 */ channel = getChannel().path(options.subscription).path("services").path("webspaces"); +/* 706 */ progress = cli.progress("Enumerating sites"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSitesGet__14() { -/* 691 */ return async.map(spaces, function __1(webspace, _) { +/* 708 */ return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", - line: 693 + line: 710 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { -/* 699 */ return channel.path(webspace.Name).path("sites").path("").query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(__cb(_, __frame, 6, 25, _, true)); +/* 716 */ return channel.path(webspace.Name).path("sites").path("").query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(__cb(_, __frame, 6, 25, _, true)); }); }, __cb(_, __frame, 12, 19, function ___(__0, __3) { result = __3; -/* 703 */ sites = []; -/* 704 */ result.forEach(function(item) { -/* 705 */ sites = sites.concat(toArray(item.Site)); +/* 720 */ sites = []; +/* 721 */ result.forEach(function(item) { +/* 722 */ sites = sites.concat(toArray(item.Site)); }); -/* 707 */ result = sites; -/* 709 */ log.json("verbose", sites); -/* 710 */ return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__14() { -/* 711 */ return _(null, sites); +/* 724 */ result = sites; +/* 726 */ log.json("verbose", sites); +/* 727 */ return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__14() { +/* 728 */ return _(null, sites); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSitesGet__14() { -/* 714 */ progress.end(); +/* 731 */ progress.end(); __then(); }); })(function ___() { @@ -1036,84 +1056,84 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); }); }; -/* 718 */ site.doSiteGet = function(options, callback) { -/* 719 */ var progress = cli.progress("Retrieving site information"); -/* 720 */ try { -/* 721 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(function(err, result) { -/* 731 */ if (err) { -/* 732 */ logError("Failed to get site info", err); -/* 733 */ if ((err.Code === "NotFound")) { -/* 734 */ return cacheUtils.deleteSite(options, function() { -/* 735 */ callback(err, result); - }); - } - ; - } -/* 738 */ else { -/* 739 */ return cacheUtils.saveSite(options, result, function(err) { -/* 740 */ log.verbose("Site", clean(result)); -/* 741 */ callback(err, result); +/* 735 */ site.doSiteGet = function(options, callback) { +/* 736 */ var progress = cli.progress("Retrieving site information"); +/* 737 */ var cb = function(err, result) { +/* 738 */ progress.end(); +/* 739 */ return (callback && callback(err, result)); + }; +/* 741 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).query("propertiesToInclude", "repositoryuri,publishingpassword,publishingusername").GET(function(err, result) { +/* 751 */ if (err) { +/* 752 */ logError("Failed to get site info", err); +/* 753 */ if ((err.Code === "NotFound")) { +/* 754 */ return cacheUtils.deleteSite(options, function() { +/* 755 */ return cb(err, result); }); } ; -/* 744 */ callback(err, result); - }); -/* 747 */ } finally { -/* 748 */ progress.end(); - }; + } +/* 758 */ else { +/* 759 */ return cacheUtils.saveSite(options, result, function(err) { +/* 760 */ log.verbose("Site", clean(result)); +/* 761 */ return cb(err, result); + }); + } + ; +/* 764 */ return cb(err, result); + }); }; -/* 752 */ site.doSiteConfigGet = function(options, callback) { -/* 753 */ var progress = cli.progress("Retrieving site config information"); -/* 754 */ try { -/* 755 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("config").GET(function(err, result) { -/* 765 */ if (err) { -/* 766 */ logError("Failed to get site config info", err); - } -/* 767 */ else { -/* 768 */ log.verbose("SiteConfig", clean(result)); - } - ; -/* 770 */ callback(err, result); - }); -/* 773 */ } finally { -/* 774 */ progress.end(); +/* 768 */ site.doSiteConfigGet = function(options, callback) { +/* 769 */ var progress = cli.progress("Retrieving site config information"); +/* 770 */ var cb = function(err, result) { +/* 771 */ progress.end(); +/* 772 */ return (callback && callback(err, result)); }; +/* 774 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("config").GET(function(err, result) { +/* 784 */ if (err) { +/* 785 */ logError("Failed to get site config info", err); + } +/* 786 */ else { +/* 787 */ log.verbose("SiteConfig", clean(result)); + } + ; +/* 789 */ return cb(err, result); + }); }; -/* 778 */ site.doRepositoryGet = function(options, callback) { -/* 779 */ var progress = cli.progress("Retrieving site repository information"); -/* 780 */ try { -/* 781 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").GET(function(err, result) { -/* 791 */ if (result) { -/* 792 */ log.verbose("Repository", clean(result)); - } - ; -/* 794 */ callback(err, clean(result)); - }); -/* 797 */ } finally { -/* 798 */ progress.end(); +/* 793 */ site.doRepositoryGet = function(options, callback) { +/* 794 */ var progress = cli.progress("Retrieving site repository information"); +/* 795 */ var cb = function(err, result) { +/* 796 */ progress.end(); +/* 797 */ return (callback && callback(err, result)); }; +/* 799 */ getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("repository").GET(function(err, result) { +/* 809 */ if (result) { +/* 810 */ log.verbose("Repository", clean(result)); + } + ; +/* 812 */ return cb(err, clean(result)); + }); }; -/* 802 */ site.doPublishingUsersGet = function site_doPublishingUsersGet__15(options, _) { +/* 816 */ site.doPublishingUsersGet = function site_doPublishingUsersGet__15(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__15", - line: 802 + line: 816 }; return __func(_, this, arguments, site_doPublishingUsersGet__15, 1, __frame, function __$site_doPublishingUsersGet__15() { -/* 803 */ progress = cli.progress("Retrieving user information"); +/* 817 */ progress = cli.progress("Retrieving user information"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__15() { -/* 811 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 9, 34, function ___(__0, __1) { -/* 805 */ publishingUsers = clean(__1); -/* 813 */ log.verbose("PublishingUsers", publishingUsers); -/* 814 */ return _(null, publishingUsers); +/* 825 */ return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 9, 34, function ___(__0, __1) { +/* 819 */ publishingUsers = clean(__1); +/* 827 */ log.verbose("PublishingUsers", publishingUsers); +/* 828 */ return _(null, publishingUsers); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doPublishingUsersGet__15() { -/* 817 */ progress.end(); +/* 831 */ progress.end(); __then(); }); })(function ___() { @@ -1131,88 +1151,89 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 825 */ var writers = { -/* 826 */ Site: { -/* 827 */ xml: function(site) { -/* 828 */ return function(req) { -/* 829 */ req.write(""); -/* 830 */ req.write(""); -/* 831 */ req.write(""); -/* 832 */ req.write((site.name + cli.category("account").hostNameSuffix())); -/* 833 */ req.write(""); -/* 835 */ if (site.hostname) { -/* 836 */ req.write(""); -/* 837 */ req.write(site.hostname); -/* 838 */ req.write(""); +/* 839 */ var writers = { +/* 840 */ Site: { +/* 841 */ xml: function(site) { +/* 842 */ return function(req) { +/* 843 */ req.write(""); +/* 844 */ req.write(""); +/* 845 */ req.write(""); +/* 846 */ req.write((site.name + cli.category("account").hostNameSuffix())); +/* 847 */ req.write(""); +/* 849 */ if (site.hostname) { +/* 850 */ req.write(""); +/* 851 */ req.write(site.hostname); +/* 852 */ req.write(""); } ; -/* 840 */ req.write(""); -/* 841 */ req.write(""); -/* 842 */ req.write(site.name); -/* 843 */ req.write(""); -/* 844 */ req.write(""); -/* 846 */ req.end(); +/* 854 */ req.write(""); +/* 855 */ req.write(""); +/* 856 */ req.write(site.name); +/* 857 */ req.write(""); +/* 858 */ req.write(""); +/* 860 */ req.end(); }; } } }; -/* 852 */ function clean(source) { -/* 853 */ if ((typeof (source) === "string")) { -/* 854 */ return source; +/* 866 */ function clean(source) { +/* 867 */ if ((typeof (source) === "string")) { +/* 868 */ return source; } ; -/* 857 */ var target = { +/* 871 */ var target = { }; -/* 858 */ var hasString = false; -/* 859 */ var hasNonString = false; -/* 860 */ var stringValue = ""; -/* 862 */ for (var prop in source) { -/* 863 */ if ((prop == "@")) { -/* 864 */ continue; +/* 872 */ var hasString = false; +/* 873 */ var hasNonString = false; +/* 874 */ var stringValue = ""; +/* 876 */ for (var prop in source) { +/* 877 */ if ((prop == "@")) { +/* 878 */ continue; } -/* 865 */ else { -/* 866 */ if ((((prop === "#") || (prop === "string")) || (prop.substring((prop.length - 7)) === ":string"))) { -/* 867 */ hasString = true; -/* 868 */ stringValue = source[prop]; +/* 879 */ else { +/* 880 */ if ((((prop === "#") || (prop === "string")) || (prop.substring((prop.length - 7)) === ":string"))) { +/* 881 */ hasString = true; +/* 882 */ stringValue = source[prop]; } -/* 869 */ else { -/* 870 */ hasNonString = true; +/* 883 */ else { +/* 884 */ hasNonString = true; } ; -/* 872 */ target[prop] = clean(source[prop]); +/* 886 */ target[prop] = clean(source[prop]); } ; }; -/* 875 */ if ((hasString && !hasNonString)) { -/* 876 */ return stringValue; +/* 889 */ if ((hasString && !hasNonString)) { +/* 890 */ return stringValue; } ; -/* 878 */ return target; +/* 892 */ return target; }; -/* 881 */ function logEachData(title, data) { -/* 882 */ var cleaned = clean(data); -/* 883 */ for (var property in cleaned) { -/* 884 */ log.data(((title + " ") + property), cleaned[property]); +/* 895 */ function logEachData(title, data) { +/* 896 */ var cleaned = clean(data); +/* 897 */ for (var property in cleaned) { +/* 898 */ log.data(((title + " ") + property), cleaned[property]); }; }; -/* 888 */ function logError(message, err) { -/* 889 */ if ((arguments.length == 1)) { -/* 890 */ err = message; -/* 891 */ message = undefined; +/* 901 */ site.logEachData = logEachData; +/* 903 */ function logError(message, err) { +/* 904 */ if ((arguments.length == 1)) { +/* 905 */ err = message; +/* 906 */ message = undefined; } -/* 892 */ else { -/* 893 */ log.error(message); +/* 907 */ else { +/* 908 */ log.error(message); } ; -/* 896 */ if (err) { -/* 897 */ if (err.message) { -/* 899 */ log.verbose("stack", err.stack); -/* 900 */ log.json("silly", err); +/* 911 */ if (err) { +/* 912 */ if (err.message) { +/* 914 */ log.verbose("stack", err.stack); +/* 915 */ log.json("silly", err); } -/* 902 */ else if (err.Message) { -/* 904 */ log.json("verbose", clean(err)); +/* 917 */ else if (err.Message) { +/* 919 */ log.json("verbose", clean(err)); } -/* 906 */ else { +/* 921 */ else { } @@ -1220,20 +1241,20 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= } ; }; -/* 912 */ function isArray(testObject) { -/* 913 */ return (((testObject && !(testObject.propertyIsEnumerable("length"))) && (typeof testObject === "object")) && (typeof testObject.length === "number")); +/* 927 */ function isArray(testObject) { +/* 928 */ return (((testObject && !(testObject.propertyIsEnumerable("length"))) && (typeof testObject === "object")) && (typeof testObject.length === "number")); }; -/* 916 */ function toArray(testObject) { -/* 917 */ return (isArray(testObject) ? testObject : ((typeof testObject === "undefined") ? [] : [testObject,])); +/* 931 */ function toArray(testObject) { +/* 932 */ return (isArray(testObject) ? testObject : ((typeof testObject === "undefined") ? [] : [testObject,])); }; -/* 920 */ function endsWith(str, suffix) { -/* 921 */ return (str.indexOf(suffix, (str.length - suffix.length)) !== -1); +/* 935 */ function endsWith(str, suffix) { +/* 936 */ return (str.indexOf(suffix, (str.length - suffix.length)) !== -1); }; -/* 924 */ function exec(cmd, cb) { -/* 925 */ child_process.exec(cmd, function(err, stdout, stderr) { -/* 926 */ cb(err, { -/* 927 */ stdout: stdout, -/* 928 */ stderr: stderr +/* 939 */ function exec(cmd, cb) { +/* 940 */ child_process.exec(cmd, function(err, stdout, stderr) { +/* 941 */ cb(err, { +/* 942 */ stdout: stdout, +/* 943 */ stderr: stderr }); }); }; diff --git a/lib/cli/commands/site_.js b/lib/cli/commands/site_.js index 144984a44..457e62824 100644 --- a/lib/cli/commands/site_.js +++ b/lib/cli/commands/site_.js @@ -96,7 +96,7 @@ exports.init = function (cli) { function confirm(label, callback) { cli.confirm(label, function (x) { callback(undefined, x); }); } - + site.confirm = confirm; site.command('create [name]') .whiteListPowershell() @@ -363,15 +363,8 @@ exports.init = function (cli) { logEachData('Site', result[0]); logEachData('Config', result[1]); - var repositoryUri = null; - for (var i = 0; i < result[0].SiteProperties.Properties.NameValuePair.length; ++i) { - var pair = result[0].SiteProperties.Properties.NameValuePair[i]; - if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) { - repositoryUri = !pair.Value['@'] && pair.Value; - break; - } - } - log.data('Repository', repositoryUri ? (clean(repositoryUri) + '/' + context.site.name + '.git') : ''); + var repositoryUri = getRepositoryUri(result[0]); + log.data('Repository', repositoryUri ? (repositoryUri + '/' + context.site.name + '.git') : ''); }); function lookupSiteName(context, _) { @@ -381,7 +374,7 @@ exports.init = function (cli) { } var cfg = site.readConfig(_); - if (cfg !== undefined) { + if (cfg && cfg.name) { // using the name from current location context.site.name = cfg.name; context.site.webspace = cfg.webspace; @@ -414,6 +407,31 @@ exports.init = function (cli) { } lookupSiteWebSpace(context, _); } + site.lookupSiteNameAndWebSpace = lookupSiteNameAndWebSpace; + + function getRepositoryUri(siteData) { + for (var i = 0; i < siteData.SiteProperties.Properties.NameValuePair.length; ++i) { + var pair = siteData.SiteProperties.Properties.NameValuePair[i]; + if (utils.ignoreCaseEquals(pair.Name, "RepositoryUri")) { + return (typeof pair.Value === 'string') ? pair.Value : null; + } + } + } + site.getRepositoryUri = getRepositoryUri; + + function getRepositoryAuth(siteData) { + var userName, password; + for (var i = 0; i < siteData.SiteProperties.Properties.NameValuePair.length; ++i) { + var pair = siteData.SiteProperties.Properties.NameValuePair[i]; + if (utils.ignoreCaseEquals(pair.Name, "PublishingUsername")) { + userName = pair.Value; + } else if (utils.ignoreCaseEquals(pair.Name, "PublishingPassword")) { + password = pair.Value; + } + } + return userName && (userName + ":" + password); + } + site.getRepositoryAuth = getRepositoryAuth; site.command('delete [name]') .whiteListPowershell() @@ -594,32 +612,32 @@ exports.init = function (cli) { log.verbose('Site', options.site.name); var progress = cli.progress('Sending site information'); - try { - getChannel() - .path(options.subscription) - .path('services') - .path('webspaces') - .path(options.site.webspace) - .path('sites') - .header('Content-Type', 'application/xml') - .POST( - writers.Site.xml(options.site), - function (err, result) { - if (err) { - logError('Failed to create site', err); - } else { - return cacheUtils.saveSite(options, result, function (err) { - log.info('Created website at ', clean(result).HostNames); - log.verbose('Site', clean(result)); - callback(err, result); - }); - } - callback(err, result); - }); - } - finally { + var cb = function (err, result) { progress.end(); - } + return callback && callback(err, result); + }; + + getChannel() + .path(options.subscription) + .path('services') + .path('webspaces') + .path(options.site.webspace) + .path('sites') + .header('Content-Type', 'application/xml') + .POST( + writers.Site.xml(options.site), + function (err, result) { + if (err) { + logError('Failed to create site', err); + } else { + return cacheUtils.saveSite(options, result, function (err) { + log.info('Created website at ', clean(result).HostNames); + log.verbose('Site', clean(result)); + return cb(err, result); + }); + } + return cb(err, result); + }); }; site.doRepositoryPost = function (options, callback) { @@ -629,29 +647,28 @@ exports.init = function (cli) { log.verbose('Site', options.site.name); var progress = cli.progress('Updating site information'); - try { - getChannel() - .path(options.subscription) - .path('services') - .path('webspaces') - .path(options.site.webspace) - .path('sites') - .path(options.site.name) - .path('repository') - .POST( - "", - function (err, result) { - if (err) { - logError('Failed to initialize repository', err); - } else { - log.info('Repository initialized'); - } - callback(err, result); - }); - } - finally { + var cb = function (err, result) { progress.end(); - } + return callback && callback(err, result); + }; + getChannel() + .path(options.subscription) + .path('services') + .path('webspaces') + .path(options.site.webspace) + .path('sites') + .path(options.site.name) + .path('repository') + .POST( + "", + function (err, result) { + if (err) { + logError('Failed to initialize repository', err); + } else { + log.info('Repository initialized'); + } + return cb(err, result); + }); }; site.doSpacesGet = function (options, _) { @@ -717,86 +734,83 @@ exports.init = function (cli) { site.doSiteGet = function (options, callback) { var progress = cli.progress('Retrieving site information'); - try { - getChannel() - .path(options.subscription) - .path('services') - .path('webspaces') - .path(options.site.webspace) - .path('sites') - .path(options.site.name) - .query('propertiesToInclude', 'repositoryuri,publishingpassword,publishingusername') - .GET( - function (err, result) { - if (err) { - logError('Failed to get site info', err); - if (err.Code === 'NotFound') { - return cacheUtils.deleteSite(options, function () { - callback(err, result); - }); - } - } else { - return cacheUtils.saveSite(options, result, function (err) { - log.verbose('Site', clean(result)); - callback(err, result); + var cb = function (err, result) { + progress.end(); + return callback && callback(err, result); + }; + getChannel() + .path(options.subscription) + .path('services') + .path('webspaces') + .path(options.site.webspace) + .path('sites') + .path(options.site.name) + .query('propertiesToInclude', 'repositoryuri,publishingpassword,publishingusername') + .GET( + function (err, result) { + if (err) { + logError('Failed to get site info', err); + if (err.Code === 'NotFound') { + return cacheUtils.deleteSite(options, function () { + return cb(err, result); }); } - callback(err, result); - }); - } - finally { - progress.end(); - } + } else { + return cacheUtils.saveSite(options, result, function (err) { + log.verbose('Site', clean(result)); + return cb(err, result); + }); + } + return cb(err, result); + }); }; site.doSiteConfigGet = function (options, callback) { var progress = cli.progress('Retrieving site config information'); - try { - getChannel() - .path(options.subscription) - .path('services') - .path('webspaces') - .path(options.site.webspace) - .path('sites') - .path(options.site.name) - .path('config') - .GET( - function (err, result) { - if (err) { - logError('Failed to get site config info', err); - } else { - log.verbose('SiteConfig', clean(result)); - } - callback(err, result); - }); - } - finally { + var cb = function (err, result) { progress.end(); - } + return callback && callback(err, result); + }; + getChannel() + .path(options.subscription) + .path('services') + .path('webspaces') + .path(options.site.webspace) + .path('sites') + .path(options.site.name) + .path('config') + .GET( + function (err, result) { + if (err) { + logError('Failed to get site config info', err); + } else { + log.verbose('SiteConfig', clean(result)); + } + return cb(err, result); + }); }; site.doRepositoryGet = function (options, callback) { var progress = cli.progress('Retrieving site repository information'); - try { - getChannel() - .path(options.subscription) - .path('services') - .path('webspaces') - .path(options.site.webspace) - .path('sites') - .path(options.site.name) - .path('repository') - .GET( - function (err, result) { - if (result) { - log.verbose('Repository', clean(result)); - } - callback(err, clean(result)); - }); - } - finally { + var cb = function (err, result) { progress.end(); - } + return callback && callback(err, result); + }; + getChannel() + .path(options.subscription) + .path('services') + .path('webspaces') + .path(options.site.webspace) + .path('sites') + .path(options.site.name) + .path('repository') + .GET( + function (err, result) { + if (result) { + log.verbose('Repository', clean(result)); + } + return cb(err, clean(result)); + }); }; site.doPublishingUsersGet = function (options, _) { @@ -884,6 +898,7 @@ exports.init = function (cli) { log.data(title + ' ' + property, cleaned[property]); } } + site.logEachData = logEachData; function logError(message, err) { if (arguments.length == 1) { @@ -930,4 +945,3 @@ exports.init = function (cli) { }); } }; - diff --git a/projects/VS/Azure.csproj b/projects/VS/Azure.csproj index 1b8ee4682..eeb4e2d49 100644 --- a/projects/VS/Azure.csproj +++ b/projects/VS/Azure.csproj @@ -227,6 +227,18 @@ lib\cli\commands\site_.js + + lib\cli\commands\deployment.js + + + lib\cli\commands\deployment_.js + + + lib\cli\commands\log.js + + + lib\cli\commands\log_.js + lib\cli\commands\vm.js From c798afd8f3c7f9ff6f9e05722701a0aa71d9ee2a Mon Sep 17 00:00:00 2001 From: suwatch Date: Tue, 22 May 2012 20:25:30 -0700 Subject: [PATCH 2/2] fix after review --- lib/cli/commands/deployment.js | 356 ++++++++++++++++---------------- lib/cli/commands/deployment_.js | 13 +- 2 files changed, 186 insertions(+), 183 deletions(-) diff --git a/lib/cli/commands/deployment.js b/lib/cli/commands/deployment.js index 33c933cd5..2b5e23646 100644 --- a/lib/cli/commands/deployment.js +++ b/lib/cli/commands/deployment.js @@ -38,28 +38,28 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= /* 64 */ return channel; }; /* 66 */ scm.getScmChannel = getScmChannel; -/* 68 */ scm.command("list [name]").whiteListPowershell().description("List your git deployments").option("-s, --subscription ", "use the subscription id").option("-m, --max ", "limit the maximum number of results").execute(function __1(name, options, _) { +/* 68 */ scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription ", "use the subscription id").option("-m, --max ", "limit the maximum number of results").execute(function __1(name, options, _) { var context, repositoryUri; var __frame = { name: "__1", - line: 73 + line: 74 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() { -/* 74 */ context = { -/* 75 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 76 */ maxItems: options.max, -/* 77 */ site: { -/* 78 */ name: name +/* 75 */ context = { +/* 76 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 77 */ maxItems: options.max, +/* 78 */ site: { +/* 79 */ name: name } }; -/* 82 */ return ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) { +/* 83 */ return ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) { repositoryUri = __1; return (function __$__1(__then) { -/* 83 */ if (repositoryUri) { -/* 84 */ return listDeployments(context, __cb(_, __frame, 11, 8, __then, true)); +/* 84 */ if (repositoryUri) { +/* 85 */ return listDeployments(context, __cb(_, __frame, 11, 8, __then, true)); } else { -/* 86 */ log.error("Repository is not setup"); +/* 87 */ log.error("Repository is not setup"); __then(); } ; @@ -67,44 +67,44 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); }); }); -/* 90 */ scm.command("show [name]").whiteListPowershell().description("Show your git deployment").option("-s, --subscription ", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { +/* 91 */ scm.command("show [name]").whiteListPowershell().usage("[options] [name]").description("Show your git deployment").option("-s, --subscription ", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { var context, repositoryUri, deployment; var __frame = { name: "__2", - line: 95 + line: 97 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() { -/* 96 */ context = { -/* 97 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 98 */ shortId: commitId, -/* 99 */ site: { -/* 100 */ name: name +/* 98 */ context = { +/* 99 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 100 */ shortId: commitId, +/* 101 */ site: { +/* 102 */ name: name } }; -/* 104 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { -/* 104 */ var __1 = !(context.id = __2); +/* 106 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { +/* 106 */ var __1 = !(context.id = __2); return (function __$__2(__then) { if (__1) { -/* 105 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); +/* 107 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); } else { __then(); } ; })(function __$__2() { -/* 108 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { +/* 110 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { repositoryUri = __3; return (function __$__2(__then) { -/* 109 */ if (repositoryUri) { -/* 110 */ return scm.doDeploymentGet(context, __cb(_, __frame, 15, 25, function ___(__0, __4) { +/* 111 */ if (repositoryUri) { +/* 112 */ return scm.doDeploymentGet(context, __cb(_, __frame, 15, 25, function ___(__0, __4) { deployment = __4; -/* 111 */ site.logEachData("info", deployment); +/* 113 */ site.logEachData("info", deployment); return (function __$__2(__then) { -/* 112 */ if (options.details) { -/* 113 */ return showLogDetails(context, __cb(_, __frame, 18, 10, __then, true)); +/* 114 */ if (options.details) { +/* 115 */ return showLogDetails(context, __cb(_, __frame, 18, 10, __then, true)); } else { -/* 115 */ log.info("To see more details, specify -d or --details option"); +/* 117 */ log.help("To see more details, specify -d or --details option"); __then(); } ; @@ -112,7 +112,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); } else { -/* 118 */ log.error("Repository is not setup"); +/* 120 */ log.error("Repository is not setup"); __then(); } ; @@ -122,37 +122,37 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); }); }); -/* 122 */ scm.command("redeploy [name]").whiteListPowershell().description("Show your git deployment").option("-s, --subscription ", "use the subscription id").execute(function __3(commitId, name, options, _) { +/* 124 */ scm.command("redeploy [name]").whiteListPowershell().usage("[options] [name]").description("Redeploy your git deployment").option("-s, --subscription ", "use the subscription id").execute(function __3(commitId, name, options, _) { var context, repositoryUri; var __frame = { name: "__3", - line: 126 + line: 129 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() { -/* 127 */ context = { -/* 128 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), -/* 129 */ shortId: commitId, -/* 130 */ site: { -/* 131 */ name: name +/* 130 */ context = { +/* 131 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription), +/* 132 */ shortId: commitId, +/* 133 */ site: { +/* 134 */ name: name } }; -/* 135 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { -/* 135 */ var __1 = !(context.id = __2); +/* 138 */ return cacheUtils.readCommitId(context, __cb(_, __frame, 9, 25, function ___(__0, __2) { +/* 138 */ var __1 = !(context.id = __2); return (function __$__3(__then) { if (__1) { -/* 136 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); +/* 139 */ return _(null, log.error((("deployment with " + commitId) + " does not exist"))); } else { __then(); } ; })(function __$__3() { -/* 139 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { +/* 142 */ return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { repositoryUri = __3; return (function __$__3(__then) { -/* 140 */ if (repositoryUri) { -/* 141 */ return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 13, function ___(__0, __5) { -/* 141 */ var __4 = !__5; +/* 143 */ if (repositoryUri) { +/* 144 */ return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 13, function ___(__0, __5) { +/* 144 */ var __4 = !__5; return (function __$__3(__then) { if (__4) { return _(null); @@ -162,14 +162,14 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= } ; })(function __$__3() { -/* 144 */ return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() { -/* 145 */ return listDeployments(context, __cb(_, __frame, 19, 8, __then, true)); +/* 147 */ return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() { +/* 148 */ return listDeployments(context, __cb(_, __frame, 19, 8, __then, true)); }, true)); }); }, true)); } else { -/* 147 */ log.error("Repository is not setup"); +/* 150 */ log.error("Repository is not setup"); __then(); } ; @@ -179,34 +179,34 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); }); }); -/* 151 */ scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) { +/* 154 */ scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__4", - line: 151 + line: 154 }; return __func(_, this, arguments, scm_doDeploymentsGet__4, 1, __frame, function __$scm_doDeploymentsGet__4() { -/* 152 */ maxItems = parseInt(context.maxItems, 10); -/* 153 */ if ((!maxItems || (maxItems <= 0))) { -/* 154 */ maxItems = 20; +/* 155 */ maxItems = parseInt(context.maxItems, 10); +/* 156 */ if ((!maxItems || (maxItems <= 0))) { +/* 157 */ maxItems = 20; } ; -/* 160 */ channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems); -/* 162 */ progress = cli.progress("Enumerating deployments"); +/* 163 */ channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems); +/* 165 */ progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__4() { -/* 164 */ return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) { -/* 164 */ deployments = ensureShortCommitId(__1); -/* 165 */ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() { -/* 166 */ return _(null, deployments.map(formatDeployment)); +/* 167 */ return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) { +/* 167 */ deployments = ensureShortCommitId(__1); +/* 168 */ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() { +/* 169 */ return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__4() { -/* 168 */ progress.end(); +/* 171 */ progress.end(); __then(); }); })(function ___() { @@ -224,27 +224,27 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 172 */ scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) { +/* 175 */ scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__5", - line: 172 + line: 175 }; return __func(_, this, arguments, scm_doDeploymentGet__5, 1, __frame, function __$scm_doDeploymentGet__5() { -/* 175 */ channel = getScmChannel(context).path("deployments").path(context.id); -/* 176 */ progress = cli.progress("Retrieving deployment info"); +/* 178 */ channel = getScmChannel(context).path("deployments").path(context.id); +/* 179 */ progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__5() { -/* 178 */ return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { -/* 178 */ var __1 = formatDeployment(__2); +/* 181 */ return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { +/* 181 */ var __1 = formatDeployment(__2); return _(null, __1); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentGet__5() { -/* 180 */ progress.end(); +/* 183 */ progress.end(); __then(); }); })(function ___() { @@ -262,24 +262,24 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 184 */ scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) { +/* 187 */ scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__6", - line: 184 + line: 187 }; return __func(_, this, arguments, scm_doDeploymentPut__6, 1, __frame, function __$scm_doDeploymentPut__6() { -/* 187 */ channel = getScmChannel(context).path("deployments").path(context.id); -/* 188 */ progress = cli.progress("Redeploying deployment"); +/* 190 */ channel = getScmChannel(context).path("deployments").path(context.id); +/* 191 */ progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__6() { -/* 190 */ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); +/* 193 */ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__6() { -/* 192 */ progress.end(); +/* 195 */ progress.end(); __then(); }); })(function ___() { @@ -297,27 +297,27 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 196 */ scm.doLogGet = function scm_doLogGet__7(context, _) { +/* 199 */ scm.doLogGet = function scm_doLogGet__7(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__7", - line: 196 + line: 199 }; return __func(_, this, arguments, scm_doLogGet__7, 1, __frame, function __$scm_doLogGet__7() { -/* 200 */ channel = getScmChannel(context).path("deployments").path(context.id).path("log"); -/* 201 */ progress = cli.progress("Retrieving deployment log info"); +/* 203 */ channel = getScmChannel(context).path("deployments").path(context.id).path("log"); +/* 204 */ progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__7() { -/* 203 */ return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) { +/* 206 */ return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) { logs = __1; -/* 204 */ return _(null, logs.map(formatLog)); +/* 207 */ return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__7() { -/* 206 */ progress.end(); +/* 209 */ progress.end(); __then(); }); })(function ___() { @@ -335,57 +335,57 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); }); }; -/* 210 */ function listDeployments(context, _) { +/* 213 */ function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", - line: 210 + line: 213 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() { -/* 211 */ return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) { +/* 214 */ return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) { deployments = __1; -/* 212 */ authorLength = 0; -/* 212 */ messageLength = 0; -/* 213 */ log.table(deployments, function(row, deployment) { -/* 214 */ row.cell("Time", deployment.start_time); -/* 215 */ row.cell("Commit id", deployment.shortId); -/* 216 */ row.cell("Status", deployment.status); -/* 217 */ authorLength = Math.max(deployment.author.length, authorLength); -/* 218 */ row.cell("Author", deployment.author, null, Math.min(authorLength, 15)); -/* 219 */ messageLength = Math.max(deployment.message.length, messageLength); -/* 220 */ row.cell("Message", deployment.message, null, Math.min(messageLength, 40)); +/* 215 */ authorLength = 0; +/* 215 */ messageLength = 0; +/* 216 */ log.table(deployments, function(row, deployment) { +/* 217 */ row.cell("Time", deployment.start_time); +/* 218 */ row.cell("Commit id", deployment.shortId); +/* 219 */ row.cell("Status", deployment.status); +/* 220 */ authorLength = Math.max(deployment.author.length, authorLength); +/* 221 */ row.cell("Author", deployment.author, null, Math.min(authorLength, 15)); +/* 222 */ messageLength = Math.max(deployment.message.length, messageLength); +/* 223 */ row.cell("Message", deployment.message, null, Math.min(messageLength, 40)); }); _(); }, true)); }); }; -/* 224 */ function showLogDetails(context, _) { +/* 227 */ function showLogDetails(context, _) { var results, logs, progress, i, details, j; var __frame = { name: "showLogDetails", - line: 224 + line: 227 }; return __func(_, this, arguments, showLogDetails, 1, __frame, function __$showLogDetails() { -/* 226 */ return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) { +/* 229 */ return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) { logs = __2; return (function __$showLogDetails(__then) { -/* 227 */ if ((logs && logs.length)) { -/* 228 */ progress = cli.progress("Retrieving log details"); +/* 230 */ if ((logs && logs.length)) { +/* 231 */ progress = cli.progress("Retrieving log details"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showLogDetails() { -/* 230 */ return async.map(logs, function __1(log, _) { +/* 233 */ return async.map(logs, function __1(log, _) { var details; var __frame = { name: "__1", - line: 230 + line: 233 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) { -/* 231 */ if (log.hasDetails) { -/* 237 */ return getScmChannel(context).path("deployments").path(context.id).path("log").path(log.id).GET(__cb(_, __frame, 7, 26, function ___(__0, __1) { +/* 234 */ if (log.hasDetails) { +/* 240 */ return getScmChannel(context).path("deployments").path(context.id).path("log").path(log.id).GET(__cb(_, __frame, 7, 26, function ___(__0, __1) { details = __1; -/* 238 */ return _(null, details.map(formatLog)); +/* 241 */ return _(null, details.map(formatLog)); }, true)); } else { @@ -395,14 +395,14 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= })(_); }); }, __cb(_, __frame, 6, 18, function ___(__0, __3) { -/* 230 */ results = __3; +/* 233 */ results = __3; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showLogDetails() { -/* 242 */ progress.end(); +/* 245 */ progress.end(); __then(); }); })(function ___() { @@ -417,12 +417,12 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); })(function ___() { __tryCatch(_, function __$showLogDetails() { -/* 244 */ for (i = 0; (i < logs.length); ++i) { -/* 245 */ displayLog(logs[i]); -/* 246 */ if (results[i]) { -/* 247 */ details = results[i]; -/* 248 */ for (j = 0; (j < details.length); ++j) { -/* 249 */ displayLog(details[j]); +/* 247 */ for (i = 0; (i < logs.length); ++i) { +/* 248 */ displayLog(logs[i]); +/* 249 */ if (results[i]) { +/* 250 */ details = results[i]; +/* 251 */ for (j = 0; (j < details.length); ++j) { +/* 252 */ displayLog(details[j]); }; } ; @@ -432,7 +432,7 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }); } else { -/* 254 */ log.info("deployment has no detail"); +/* 257 */ log.info("deployment has no detail"); __then(); } ; @@ -440,100 +440,100 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }, true)); }); }; -/* 258 */ function displayLog(item) { -/* 259 */ if ((item.type == "Warning")) { -/* 260 */ log.warn(((item.short_time + " ") + item.message)); +/* 261 */ function displayLog(item) { +/* 262 */ if ((item.type === "Warning")) { +/* 263 */ log.warn(((item.short_time + " ") + item.message)); } -/* 261 */ else if ((item.type == "Error")) { -/* 262 */ log.error(((item.short_time + " ") + item.message)); +/* 264 */ else if ((item.type === "Error")) { +/* 265 */ log.error(((item.short_time + " ") + item.message)); } -/* 263 */ else { -/* 264 */ log.info(((item.short_time + " ") + item.message)); +/* 266 */ else { +/* 267 */ log.data(((item.short_time + " ") + item.message)); } ; }; -/* 268 */ function fromJsonDate(str) { -/* 269 */ return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)")); +/* 271 */ function fromJsonDate(str) { +/* 272 */ return eval(str.replace(/\/Date\((.*)[+].*\)\//gi, "new Date($1)")); }; -/* 272 */ function formatDate(dt) { -/* 273 */ var date = dt.getDate(), month = dt.getMonth(); -/* 275 */ date = ((((date < 10) ? "0" : "")) + date); -/* 276 */ month = ((((month < 10) ? "0" : "")) + month); -/* 277 */ return ((((((dt.getFullYear() + "-") + month) + "-") + date) + " ") + dt.toLocaleTimeString()); +/* 275 */ function formatDate(dt) { +/* 276 */ var date = dt.getDate(), month = dt.getMonth(); +/* 278 */ date = ((((date < 10) ? "0" : "")) + date); +/* 279 */ month = ((((month < 10) ? "0" : "")) + month); +/* 280 */ return ((((((dt.getFullYear() + "-") + month) + "-") + date) + " ") + dt.toLocaleTimeString()); }; -/* 280 */ function dateTimeText(str) { -/* 281 */ return formatDate(fromJsonDate(str)); +/* 283 */ function dateTimeText(str) { +/* 284 */ return formatDate(fromJsonDate(str)); }; -/* 284 */ function deploymentStatusText(status) { -/* 285 */ switch (status) { -/* 286 */ case 0: -/* 286 */ return "Pending"; -/* 286 */ case 1: +/* 287 */ function deploymentStatusText(status) { +/* 288 */ switch (status) { +/* 289 */ case 0: +/* 289 */ return "Pending"; +/* 289 */ case 1: return "Building"; -/* 287 */ case 2: -/* 287 */ return "Deploying"; -/* 287 */ case 3: +/* 290 */ case 2: +/* 290 */ return "Deploying"; +/* 290 */ case 3: return "Failed"; -/* 288 */ case 4: -/* 288 */ return "Success"; -/* 288 */ default: +/* 291 */ case 4: +/* 291 */ return "Success"; +/* 291 */ default: return "Unknown"; -/* 289 */ }; -/* 289 */ }; -/* 289 */ function logTypeText(type) { +/* 292 */ }; +/* 292 */ }; +/* 292 */ function logTypeText(type) { switch (type) { -/* 290 */ case 0: -/* 290 */ return "Message"; -/* 290 */ case 1: +/* 293 */ case 0: +/* 293 */ return "Message"; +/* 293 */ case 1: return "Warning"; case 2: -/* 291 */ return "Error"; -/* 291 */ default: +/* 294 */ return "Error"; +/* 294 */ default: return "Unknown"; }; }; -/* 295 */ function ensureShortCommitId(deployments) { -/* 296 */ return deployments.map(function(deployment) { -/* 297 */ deployment.shortId = deployment.id.substr(0, 10); -/* 297 */ return deployment; -/* 297 */ }); +/* 298 */ function ensureShortCommitId(deployments) { +/* 299 */ return deployments.map(function(deployment) { +/* 300 */ deployment.shortId = deployment.id.substr(0, 10); +/* 300 */ return deployment; +/* 300 */ }); }; -/* 298 */ function ensureRepositoryUri(context, _) { -/* 298 */ var siteData, repositoryUri; -/* 298 */ var __frame = { +/* 301 */ function ensureRepositoryUri(context, _) { +/* 301 */ var siteData, repositoryUri; +/* 301 */ var __frame = { name: "ensureRepositoryUri", -/* 299 */ line: 311 -/* 299 */ }; -/* 299 */ return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() { +/* 302 */ line: 314 +/* 302 */ }; +/* 302 */ return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() { return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 1, 19, function ___(__0, __1) { siteData = __1; -/* 300 */ repositoryUri = (siteData && site.getRepositoryUri(siteData)); -/* 300 */ return (function __$ensureRepositoryUri(__then) { +/* 303 */ repositoryUri = (siteData && site.getRepositoryUri(siteData)); +/* 303 */ return (function __$ensureRepositoryUri(__then) { if (!repositoryUri) { return site.doSiteGet(context, __cb(_, __frame, 4, 17, function ___(__0, __2) { siteData = __2; -/* 304 */ repositoryUri = site.getRepositoryUri(siteData); -/* 305 */ __then(); -/* 306 */ }, true)); -/* 307 */ } +/* 307 */ repositoryUri = site.getRepositoryUri(siteData); +/* 308 */ __then(); +/* 309 */ }, true)); +/* 310 */ } else { __then(); -/* 311 */ } +/* 314 */ } ; })(function __$ensureRepositoryUri() { if (repositoryUri) { context.repositoryAuth = site.getRepositoryAuth(siteData); return _(null, context.repositoryUri = repositoryUri); } -/* 312 */ ; +/* 315 */ ; _(); -/* 313 */ }); +/* 316 */ }); }, true)); -/* 314 */ }); -/* 315 */ }; -/* 315 */ scm.ensureRepositoryUri = ensureRepositoryUri; -/* 316 */ function formatDeployment(deployment) { +/* 317 */ }); +/* 318 */ }; +/* 318 */ scm.ensureRepositoryUri = ensureRepositoryUri; +/* 319 */ function formatDeployment(deployment) { var timeProperties = ["end_time","last_success_end_time","received_time","start_time",]; for (var i = 0; (i < timeProperties.length); ++i) { if (deployment[timeProperties[i]]) { @@ -542,9 +542,9 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= ; }; deployment.complete = (!!deployment.complete).toString(); -/* 318 */ deployment.status = (deployment.active ? "Active" : deploymentStatusText(deployment.status)); -/* 319 */ deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1"); -/* 320 */ delete deployment.active; +/* 321 */ deployment.status = (deployment.active ? "Active" : deploymentStatusText(deployment.status)); +/* 322 */ deployment.message = deployment.message.replace(/\s*(.*)\s*?/g, "$1"); +/* 323 */ delete deployment.active; delete deployment.status_text; delete deployment.url; delete deployment.log_url; @@ -552,11 +552,11 @@ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func= }; function formatLog(log) { log.hasDetails = !!log.details_url; -/* 323 */ log.log_time = (log.log_time && dateTimeText(log.log_time)); -/* 325 */ log.short_time = (log.log_time && log.log_time.replace(/.* +(.*)/g, "$1")); -/* 326 */ log.type = logTypeText(log.type); -/* 327 */ log.shortId = log.id.substr(0, 10); -/* 328 */ delete log.details_url; -/* 329 */ return log; +/* 326 */ log.log_time = (log.log_time && dateTimeText(log.log_time)); +/* 328 */ log.short_time = (log.log_time && log.log_time.replace(/.* +(.*)/g, "$1")); +/* 329 */ log.type = logTypeText(log.type); +/* 330 */ log.shortId = log.id.substr(0, 10); +/* 331 */ delete log.details_url; +/* 332 */ return log; }; }; diff --git a/lib/cli/commands/deployment_.js b/lib/cli/commands/deployment_.js index ee867ad39..7adb1d27e 100644 --- a/lib/cli/commands/deployment_.js +++ b/lib/cli/commands/deployment_.js @@ -67,6 +67,7 @@ exports.init = function (cli) { scm.command('list [name]') .whiteListPowershell() + .usage('[options] [name]') .description('List your git deployments') .option('-s, --subscription ', 'use the subscription id') .option('-m, --max ', 'limit the maximum number of results') @@ -89,6 +90,7 @@ exports.init = function (cli) { scm.command('show [name]') .whiteListPowershell() + .usage('[options] [name]') .description('Show your git deployment') .option('-s, --subscription ', 'use the subscription id') .option('-d, --details', 'display log details') @@ -112,7 +114,7 @@ exports.init = function (cli) { if (options.details) { showLogDetails(context, _); } else { - log.info('To see more details, specify -d or --details option'); + log.help('To see more details, specify -d or --details option'); } } else { log.error('Repository is not setup'); @@ -121,7 +123,8 @@ exports.init = function (cli) { scm.command('redeploy [name]') .whiteListPowershell() - .description('Show your git deployment') + .usage('[options] [name]') + .description('Redeploy your git deployment') .option('-s, --subscription ', 'use the subscription id') .execute(function (commitId, name, options, _) { var context = { @@ -256,12 +259,12 @@ exports.init = function (cli) { } function displayLog(item) { - if (item.type == 'Warning') { + if (item.type === 'Warning') { log.warn(item.short_time + ' ' + item.message); - } else if (item.type == 'Error') { + } else if (item.type === 'Error') { log.error(item.short_time + ' ' + item.message); } else { - log.info(item.short_time + ' ' + item.message); + log.data(item.short_time + ' ' + item.message); } }