Skip to content

Commit

Permalink
Adding UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Oct 22, 2012
1 parent 4249605 commit 13a7945
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 136 deletions.
88 changes: 66 additions & 22 deletions lib/cli/commands/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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");
Expand Down Expand Up @@ -62,7 +61,7 @@ exports.init = function(cli) {

scm.getScmChannel = getScmChannel;

scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription <id>", "use the subscription id").option("-m, --max <count>", "limit the maximum number of results").execute(function __1(name, options, _) { var context, repositoryUri; var __frame = { name: "__1", line: 71 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription <id>", "use the subscription id").option("-m, --max <count>", "limit the maximum number of results").execute(function __1(name, options, _) { var context, repositoryUri; var __frame = { name: "__1", line: 70 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {



Expand All @@ -85,7 +84,7 @@ exports.init = function(cli) {



scm.command("show <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Show your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { var context, repositoryUri, deployment, data, logs, i, details, j; var __frame = { name: "__2", line: 94 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
scm.command("show <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Show your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { var context, repositoryUri, deployment, data, logs, i, details, j; var __frame = { name: "__2", line: 93 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {



Expand Down Expand Up @@ -137,7 +136,7 @@ exports.init = function(cli) {



scm.command("redeploy <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for redeploy confirmation").execute(function __3(commitId, name, options, _) { var context, repositoryUri; var __frame = { name: "__3", line: 146 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
scm.command("redeploy <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for redeploy confirmation").execute(function __3(commitId, name, options, _) { var context, repositoryUri; var __frame = { name: "__3", line: 145 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {



Expand All @@ -158,7 +157,7 @@ exports.init = function(cli) {

return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __4) { repositoryUri = __4; return (function __$__3(__then) {
if (repositoryUri) { return (function __$__3(_) {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 31, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -145, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { return _(null); } else { __then(); } ; })(function __$__3() {
var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 31, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -144, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { return _(null); } else { __then(); } ; })(function __$__3() {


return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() {
Expand All @@ -168,7 +167,52 @@ exports.init = function(cli) {



scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__4", line: 171 }; return __func(_, this, arguments, scm_doDeploymentsGet__4, 1, __frame, function __$scm_doDeploymentsGet__4() {
scm.command("github [name]").whiteListPowershell().usage("[options] [name]").description("Links a website to a github account for deployment").option("-s, --subscription <id>", "use the subscription id").option("-u, --username <user>", "The username").option("-up, --pass <pass>", "The password").option("-r, --repository <repository>", "The github repository").execute(function __4(name, options, _) { var context;
























function promptForGithubCredentials(_) { var __frame = { name: "promptForGithubCredentials", line: 195 }; return __func(_, this, arguments, promptForGithubCredentials, 0, __frame, function __$promptForGithubCredentials() {
log.help("Enter your github credentials"); return (function __$promptForGithubCredentials(__then) {

if (options.username) {
context.username = options.username; __then(); } else {

return prompt("Username: ", __cb(_, __frame, 6, 29, function ___(__0, __1) { context.username = __1; __then(); }, true)); } ; })(function __$promptForGithubCredentials() { return (function __$promptForGithubCredentials(__then) {


if (options.pass) {
context.password = options.pass; __then(); } else {

return promptPassword("Password: ", __cb(_, __frame, 12, 29, function ___(__0, __2) { context.password = __2; __then(); }, true)); } ; })(function __$promptForGithubCredentials() {


context.lvcClient = LinkedRevisionControl.createClient(cli, "github");
return context.lvcClient.authenticate(context.username, context.password, __cb(_, __frame, 16, 8, _, true)); }); }); }); }; var __frame = { name: "__4", line: 178 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), site: { name: name }, remoteUri: options.repository }; return scm.ensureRepositoryUri(context, __cb(_, __frame, 10, 6, function __$__4() { return promptForGithubCredentials(__cb(_, __frame, 11, 6, function __$__4() { context.flags = { forceRepositorySelection: true }; return context.lvcClient.init(context, __cb(_, __frame, 14, 6, function __$__4() { return context.lvcClient.deploy(context, __cb(_, __frame, 15, 6, _, true)); }, true)); }, true)); }, true)); }); });



scm.doDeploymentsGet = function scm_doDeploymentsGet__5(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__5", line: 215 }; return __func(_, this, arguments, scm_doDeploymentsGet__5, 1, __frame, function __$scm_doDeploymentsGet__5() {
maxItems = parseInt(context.maxItems, 10);
if ((!maxItems || (maxItems <= 0))) {
maxItems = 20; } ;
Expand All @@ -179,55 +223,55 @@ exports.init = function(cli) {

channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems);

progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__4() {
progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__5() {

return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) { deployments = ensureShortCommitId(__1);
return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() {
return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__4() {
return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__5() {
return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__5() {

progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };



scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__5", line: 192 }; return __func(_, this, arguments, scm_doDeploymentGet__5, 1, __frame, function __$scm_doDeploymentGet__5() {
scm.doDeploymentGet = function scm_doDeploymentGet__6(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__6", line: 236 }; return __func(_, this, arguments, scm_doDeploymentGet__6, 1, __frame, function __$scm_doDeploymentGet__6() {


channel = getScmChannel(context).path("deployments").path(context.id);
progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__5() {
progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__6() {

return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { var __1 = formatDeployment(__2); return _(null, __1); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentGet__5() {
return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { var __1 = formatDeployment(__2); return _(null, __1); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentGet__6() {

progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };



scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__6", line: 204 }; return __func(_, this, arguments, scm_doDeploymentPut__6, 1, __frame, function __$scm_doDeploymentPut__6() {
scm.doDeploymentPut = function scm_doDeploymentPut__7(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__7", line: 248 }; return __func(_, this, arguments, scm_doDeploymentPut__7, 1, __frame, function __$scm_doDeploymentPut__7() {


channel = getScmChannel(context).path("deployments").path(context.id);
progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__6() {
progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__7() {

return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__6() {
return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__7() {

progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };



scm.doLogGet = function scm_doLogGet__7(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__7", line: 216 }; return __func(_, this, arguments, scm_doLogGet__7, 1, __frame, function __$scm_doLogGet__7() {
scm.doLogGet = function scm_doLogGet__8(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__8", line: 260 }; return __func(_, this, arguments, scm_doLogGet__8, 1, __frame, function __$scm_doLogGet__8() {



channel = getScmChannel(context).path("deployments").path(context.id).path("log");
progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__7() {
progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__8() {

return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) { logs = __1;
return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__7() {
return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__8() {

progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };



function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 230 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 274 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) { deployments = __1;
authorLength = 0; messageLength = 0;
if ((deployments && deployments.length)) {
Expand All @@ -245,13 +289,13 @@ exports.init = function(cli) {



function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 248 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {
function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 292 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {

return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) { logs = __2; return (function __$getLogDetails(__then) {
if ((logs && logs.length)) {
progress = cli.progress("Retrieving log details"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getLogDetails() {

return async.map(logs, function __1(log, _) { var details; var __frame = { name: "__1", line: 254 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
return async.map(logs, function __1(log, _) { var details; var __frame = { name: "__1", line: 298 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
if (log.hasDetails) {


Expand Down Expand Up @@ -332,7 +376,7 @@ exports.init = function(cli) {



function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 335 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 379 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 1, 19, function ___(__0, __1) { siteData = __1;
repositoryUri = (siteData && site.getRepositoryUri(siteData)); return (function __$ensureRepositoryUri(__then) {
if (!repositoryUri) {
Expand Down
4 changes: 3 additions & 1 deletion lib/cli/commands/deployment_.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ exports.init = function (cli) {
.option('-s, --subscription <id>', 'use the subscription id')
.option('-u, --username <user>', 'The username')
.option('-up, --pass <pass>', 'The password')
.option('-r, --repository <repository>', 'The github repository')
.execute(function (name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
site: {
name: name
}
},
remoteUri: options.repository
};

// Fetch site and repository data
Expand Down
Loading

0 comments on commit 13a7945

Please sign in to comment.