Skip to content

Commit

Permalink
Adding username and password parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Oct 18, 2012
1 parent 3883ae8 commit 9fe4b55
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 28 deletions.
61 changes: 38 additions & 23 deletions lib/cli/commands/deployment.js
Expand Up @@ -172,7 +172,7 @@ exports.init = function(cli) {



scm.command("associate [name]").whiteListPowershell().usage("[options]").description("Redeploy your git deployment").execute(function __4(nameArg, options, _) { var context;
scm.command("associate [name]").whiteListPowershell().usage("[options] [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-u, --username <username>", "The username").option("-p, --password <password>", "The password").execute(function __4(name, options, _) { var context;



Expand All @@ -191,20 +191,35 @@ exports.init = function(cli) {



function promptForCredentials(_) { var __frame = { name: "promptForCredentials", line: 194 }; return __func(_, this, arguments, promptForCredentials, 0, __frame, function __$promptForCredentials() {



function promptForCredentials(_) { var __frame = { name: "promptForCredentials", line: 197 }; return __func(_, this, arguments, promptForCredentials, 0, __frame, function __$promptForCredentials() {
log.help("Enter your github credentials");
return prompt("username: ", __cb(_, __frame, 2, 27, function ___(__0, __1) { context.username = __1;
return prompt("password: ", __cb(_, __frame, 3, 27, function ___(__0, __2) { context.password = __2;

console.log(options); return (function __$promptForCredentials(__then) {

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

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


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

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


context.github = new GitHubApi({ version: "3.0.0" });
context.github.authenticate({
type: "basic",
username: context.username,
password: context.password }); _(); }, true)); }, true)); }); };
password: context.password }); _(); }); }); }); };



function promptForRepository(_) { var repositories, parsedRepositoryUri, pathParts, owner, name, localRepositories; var __frame = { name: "promptForRepository", line: 207 }; return __func(_, this, arguments, promptForRepository, 0, __frame, function __$promptForRepository() {
function promptForRepository(_) { var repositories, parsedRepositoryUri, pathParts, owner, name, localRepositories; var __frame = { name: "promptForRepository", line: 222 }; return __func(_, this, arguments, promptForRepository, 0, __frame, function __$promptForRepository() {
return scm.doGetRepositories(context, __cb(_, __frame, 1, 27, function ___(__0, __1) { repositories = __1;

return scm.doGetRemoteUri(context, __cb(_, __frame, 3, 28, function ___(__0, __2) { context.remoteUri = __2;
Expand Down Expand Up @@ -232,7 +247,7 @@ exports.init = function(cli) {



function linkRemoteGitRepo(_) { var parsedRepositoryUri, hookUrl, hooks, existingHook; var __frame = { name: "linkRemoteGitRepo", line: 235 }; return __func(_, this, arguments, linkRemoteGitRepo, 0, __frame, function __$linkRemoteGitRepo() {
function linkRemoteGitRepo(_) { var parsedRepositoryUri, hookUrl, hooks, existingHook; var __frame = { name: "linkRemoteGitRepo", line: 250 }; return __func(_, this, arguments, linkRemoteGitRepo, 0, __frame, function __$linkRemoteGitRepo() {
parsedRepositoryUri = url.parse(context.repositoryUri);
parsedRepositoryUri.auth = context.repositoryAuth;
parsedRepositoryUri.pathname = "/deploy";
Expand Down Expand Up @@ -274,7 +289,7 @@ exports.init = function(cli) {



function addRemoteToLocalGitRepo(_) { var gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 277 }; return __func(_, this, arguments, addRemoteToLocalGitRepo, 0, __frame, function __$addRemoteToLocalGitRepo() {
function addRemoteToLocalGitRepo(_) { var gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 292 }; return __func(_, this, arguments, addRemoteToLocalGitRepo, 0, __frame, function __$addRemoteToLocalGitRepo() {
if (context.remoteUri) { return _(null); } ;


Expand All @@ -283,11 +298,11 @@ exports.init = function(cli) {


log.info((("Executing `git remote add azure " + gitUri) + "`"));
return exec(("git remote add azure " + gitUri), __cb(_, __frame, 9, 8, _, true)); }); }; var __frame = { name: "__4", line: 179 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), site: { name: nameArg } }; return ensureRepositoryUri(context, __cb(_, __frame, 9, 6, function __$__4() { return promptForCredentials(__cb(_, __frame, 10, 6, function __$__4() { return promptForRepository(__cb(_, __frame, 11, 6, function __$__4() { return linkRemoteGitRepo(__cb(_, __frame, 12, 6, function __$__4() { return addRemoteToLocalGitRepo(__cb(_, __frame, 13, 6, _, true)); }, true)); }, true)); }, true)); }, true)); }); });
return exec(("git remote add azure " + gitUri), __cb(_, __frame, 9, 8, _, true)); }); }; var __frame = { name: "__4", line: 182 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), site: { name: name } }; return ensureRepositoryUri(context, __cb(_, __frame, 9, 6, function __$__4() { return promptForCredentials(__cb(_, __frame, 10, 6, function __$__4() { return promptForRepository(__cb(_, __frame, 11, 6, function __$__4() { return linkRemoteGitRepo(__cb(_, __frame, 12, 6, function __$__4() { return addRemoteToLocalGitRepo(__cb(_, __frame, 13, 6, _, true)); }, true)); }, true)); }, true)); }, true)); }); });



scm.doCreateHook = function scm_doCreateHook__5(context, _) { var progress; var __frame = { name: "scm_doCreateHook__5", line: 290 }; return __func(_, this, arguments, scm_doCreateHook__5, 1, __frame, function __$scm_doCreateHook__5() {
scm.doCreateHook = function scm_doCreateHook__5(context, _) { var progress; var __frame = { name: "scm_doCreateHook__5", line: 305 }; return __func(_, this, arguments, scm_doCreateHook__5, 1, __frame, function __$scm_doCreateHook__5() {
progress = cli.progress("Creating new hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doCreateHook__5() {


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



scm.doUpdateHook = function scm_doUpdateHook__6(context, _) { var progress; var __frame = { name: "scm_doUpdateHook__6", line: 300 }; return __func(_, this, arguments, scm_doUpdateHook__6, 1, __frame, function __$scm_doUpdateHook__6() {
scm.doUpdateHook = function scm_doUpdateHook__6(context, _) { var progress; var __frame = { name: "scm_doUpdateHook__6", line: 315 }; return __func(_, this, arguments, scm_doUpdateHook__6, 1, __frame, function __$scm_doUpdateHook__6() {
progress = cli.progress("Updating hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doUpdateHook__6() {


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



scm.doGetHooks = function scm_doGetHooks__7(context, _) { var progress; var __frame = { name: "scm_doGetHooks__7", line: 310 }; return __func(_, this, arguments, scm_doGetHooks__7, 1, __frame, function __$scm_doGetHooks__7() {
scm.doGetHooks = function scm_doGetHooks__7(context, _) { var progress; var __frame = { name: "scm_doGetHooks__7", line: 325 }; return __func(_, this, arguments, scm_doGetHooks__7, 1, __frame, function __$scm_doGetHooks__7() {
progress = cli.progress("Retrieving website hooks"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doGetHooks__7() {


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



function getRemote(name, _) { var remotes, origin; var __frame = { name: "getRemote", line: 328 }; return __func(_, this, arguments, getRemote, 1, __frame, function __$getRemote() {
function getRemote(name, _) { var remotes, origin; var __frame = { name: "getRemote", line: 343 }; return __func(_, this, arguments, getRemote, 1, __frame, function __$getRemote() {
return exec("git remote -v", __cb(_, __frame, 1, 22, function ___(__0, __1) { remotes = __1;
origin = ((remotes.stdout + remotes.stderr)).split("\n").filter(function(item) {
return item.split(" ").some(function(it) {
Expand All @@ -337,7 +352,7 @@ exports.init = function(cli) {
return _(null, origin[0].split(" ")[1].split(" ")[0]); } ;


return _(null, null); }, true)); }); }; var __frame = { name: "scm_doGetRemoteUri__8", line: 323 }; return __func(_, this, arguments, scm_doGetRemoteUri__8, 1, __frame, function __$scm_doGetRemoteUri__8() { progress = cli.progress("Retrieving local git repositories"); originUri = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doGetRemoteUri__8() {
return _(null, null); }, true)); }); }; var __frame = { name: "scm_doGetRemoteUri__8", line: 338 }; return __func(_, this, arguments, scm_doGetRemoteUri__8, 1, __frame, function __$scm_doGetRemoteUri__8() { progress = cli.progress("Retrieving local git repositories"); originUri = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doGetRemoteUri__8() {


return getRemote("azure", __cb(_, __frame, 20, 18, function ___(__0, __1) { originUri = __1; return (function __$scm_doGetRemoteUri__8(__then) {
Expand All @@ -351,7 +366,7 @@ exports.init = function(cli) {
return _(null, originUri); }); }); }); };


scm.doGetRepositories = function scm_doGetRepositories__9(context, _) { var progress, userRepos, orgs, i, org; var __frame = { name: "scm_doGetRepositories__9", line: 354 }; return __func(_, this, arguments, scm_doGetRepositories__9, 1, __frame, function __$scm_doGetRepositories__9() {
scm.doGetRepositories = function scm_doGetRepositories__9(context, _) { var progress, userRepos, orgs, i, org; var __frame = { name: "scm_doGetRepositories__9", line: 369 }; return __func(_, this, arguments, scm_doGetRepositories__9, 1, __frame, function __$scm_doGetRepositories__9() {
progress = cli.progress("Retrieving repositories");
userRepos = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doGetRepositories__9() {

Expand All @@ -375,7 +390,7 @@ exports.init = function(cli) {
return _(null, userRepos); }); }); }); };


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



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


channel = getScmChannel(context).path("deployments").path(context.id);
Expand All @@ -408,7 +423,7 @@ exports.init = function(cli) {



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


channel = getScmChannel(context).path("deployments").path(context.id);
Expand All @@ -420,7 +435,7 @@ exports.init = function(cli) {



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



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



function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 437 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 452 }; 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 @@ -452,13 +467,13 @@ exports.init = function(cli) {



function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 455 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {
function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 470 }; 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: 461 }; 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: 476 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
if (log.hasDetails) {


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



function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 554 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 569 }; 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
23 changes: 18 additions & 5 deletions lib/cli/commands/deployment_.js
Expand Up @@ -174,13 +174,16 @@ exports.init = function (cli) {

scm.command('associate [name]')
.whiteListPowershell()
.usage('[options]')
.usage('[options] [name]')
.description('Redeploy your git deployment')
.execute(function (nameArg, options, _) {
.option('-s, --subscription <id>', 'use the subscription id')
.option('-u, --username <username>', 'The username')
.option('-p, --password <password>', 'The password')
.execute(function (name, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
site: {
name: nameArg
name: name
}
};

Expand All @@ -193,8 +196,18 @@ exports.init = function (cli) {

function promptForCredentials(_) {
log.help('Enter your github credentials');
context.username = prompt('username: ', _);
context.password = prompt('password: ', _);

if (options.username) {
context.username = options.username;
} else {
context.username = prompt('Username: ', _);
}

if (options.password) {
context.password = options.password;
} else {
context.password = prompt('Password: ', _);
}

context.github = new GitHubApi({ version: "3.0.0" });
context.github.authenticate({
Expand Down

0 comments on commit 9fe4b55

Please sign in to comment.